psana/src/ExpNameFromDs.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id: ExpNameFromDs.cpp 8960 2014-09-24 18:15:41Z cpo@SLAC.STANFORD.EDU $
00004 //
00005 // Description:
00006 //      Class ExpNameFromDs...
00007 //
00008 // Author List:
00009 //      Andy Salnikov
00010 //
00011 //------------------------------------------------------------------------
00012 
00013 //-----------------------
00014 // This Class's Header --
00015 //-----------------------
00016 #include "psana/ExpNameFromDs.h"
00017 
00018 //-----------------
00019 // C/C++ Headers --
00020 //-----------------
00021 #include <stdlib.h>
00022 #include <fstream>
00023 
00024 //-------------------------------
00025 // Collaborating Class Headers --
00026 //-------------------------------
00027 #include "ExpNameDb/ExpNameDatabase.h"
00028 #include "IData/Dataset.h"
00029 #include "MsgLogger/MsgLogger.h"
00030 
00031 //-----------------------------------------------------------------------
00032 // Local Macros, Typedefs, Structures, Unions and Forward Declarations --
00033 //-----------------------------------------------------------------------
00034 
00035 using namespace std;
00036 
00037 namespace {
00038 
00039   const char* logger = "ExpNameFromDs";
00040 
00041 }
00042 
00043 //              ----------------------------------------
00044 //              -- Public Function Member Definitions --
00045 //              ----------------------------------------
00046 
00047 namespace psana {
00048 
00049 //----------------
00050 // Constructors --
00051 //----------------
00052 ExpNameFromDs::ExpNameFromDs (const std::vector<std::string>& files)
00053   : IExpNameProvider()
00054   , m_instr()
00055   , m_exp()
00056   , m_expNum(0)
00057 {
00058   // extract exp number for every file name, they all must be the same
00059   for (vector<string>::const_iterator it = files.begin(); it != files.end(); ++ it) {
00060     
00061     IData::Dataset ds(*it);
00062     
00063     if (m_expNum == 0) {
00064       if (ds.expID() == 0) {
00065         // no warning msg, since shared memory has no valid exp. number (cpo)
00066         break;
00067       } else {
00068         m_expNum = ds.expID();
00069         m_instr = ds.instrument();
00070         m_exp = ds.experiment();
00071       }
00072     } else {
00073       if (ds.expID() != m_expNum) {
00074         WithMsgLog(logger, warning, out ) {
00075           out << "ExpNameFromDs: datasets belong to different experiments:";
00076           for (vector<string>::const_iterator it = files.begin(); it != files.end(); ++ it) {
00077             out << "\n    " << *it;
00078           }
00079         }
00080         break;
00081       }
00082     }
00083     
00084   }
00085 }
00086 
00087 //--------------
00088 // Destructor --
00089 //--------------
00090 ExpNameFromDs::~ExpNameFromDs ()
00091 {
00092 }
00093 
00094 } // namespace psana

Generated on 19 Dec 2016 for PSANAclasses by  doxygen 1.4.7