00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "psana/ExpNameFromDs.h"
00017
00018
00019
00020
00021 #include <stdlib.h>
00022 #include <fstream>
00023
00024
00025
00026
00027 #include "ExpNameDb/ExpNameDatabase.h"
00028 #include "IData/Dataset.h"
00029 #include "MsgLogger/MsgLogger.h"
00030
00031
00032
00033
00034
00035 using namespace std;
00036
00037 namespace {
00038
00039 const char* logger = "ExpNameFromDs";
00040
00041 }
00042
00043
00044
00045
00046
00047 namespace psana {
00048
00049
00050
00051
00052 ExpNameFromDs::ExpNameFromDs (const std::vector<std::string>& files)
00053 : IExpNameProvider()
00054 , m_instr()
00055 , m_exp()
00056 , m_expNum(0)
00057 {
00058
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
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
00089
00090 ExpNameFromDs::~ExpNameFromDs ()
00091 {
00092 }
00093
00094 }