00001 #include "NCRunUtil.h"
00002 using namespace NC::RunUtil;
00003
00004 #include "AnalysisNtuples/ANtpHeaderInfo.h"
00005 #include "AnalysisNtuples/ANtpRecoInfo.h"
00006 #include "Conventions/Detector.h"
00007 #include "Conventions/SimFlag.h"
00008 #include "MessageService/MsgService.h"
00009
00010 #include "TRegexp.h"
00011
00012 #include <cassert>
00013 #include <map>
00014 #include <vector>
00015 using namespace std;
00016
00017 CVSID("$Id: NCRunUtil.cxx,v 1.7 2010/01/19 17:02:22 rodriges Exp $");
00018
00019
00020
00021 ERunType NC::RunUtil::FindRunType(ANtpHeaderInfo* header, ANtpRecoInfo* reco)
00022 {
00023 assert(header);
00024
00025 if(header->dataType == SimFlag::kData){
00026 if(header->detector == Detector::kFar){
00027 if (header->run <= 35723) return kRunI;
00028
00029
00030
00031 else if(header->run > 35723 && header->run <= 38449) return kRunII;
00032
00033
00034
00035
00036 else if(header->run > 38449 && header->run <= 43639) return kRunIII;
00037 assert(0 && "Unknown run");
00038 }
00039 else{
00040
00041 if (header->run <= 10159) return kRunI;
00042
00043
00044
00045 else if(header->run > 10159 && header->run <= 12623) return kRunII;
00046
00047
00048
00049
00050 else if(header->run > 12623 && header->run <= 16502) return kRunIII;
00051 assert(0 && "Unknown run");
00052 }
00053 }
00054 else{
00055
00056 assert(reco);
00057 return ERunType(reco->runPeriod);
00058 }
00059 }
00060
00061
00062
00063
00064 ERunType NC::RunUtil::FindRunType(TString fileName)
00065 {
00066
00067
00068
00069
00070
00071
00072
00073 TRegexp re("20[0-9][0-9]-[0-9][0-9]");
00074
00075 TString date=TString(fileName(re));
00076 if(date.Length()==7){
00077
00078 int year=TString(date(0, 4)).Atoi();
00079
00080
00081 int month=TString(date(5, 2)).Atoi();
00082
00083 int epochMonth=100*year+month;
00084
00085
00086
00087
00088 if (epochMonth >= 2005*100 + 5 && epochMonth <= 2006*100 + 2) return kRunI;
00089 if (epochMonth >= 2006*100 + 5 && epochMonth <= 2007*100 + 8) return kRunII;
00090 if (epochMonth >= 2007*100 + 11 && epochMonth <= 2006*100 + 6) return kRunIII;
00091
00092 assert(0 && "fileName with date outside known range");
00093 }
00094 else{
00095
00096 assert(fileName.Contains("mc") ||
00097 fileName.Contains("tau") ||
00098 fileName.Contains("electron") ||
00099 fileName.Contains("mock"));
00100
00101 TRegexp runRE("run[0-9]");
00102 TString runPeriodStr=TString(fileName(runRE));
00103 assert(runPeriodStr.Length()==4);
00104 int runPeriod=TString(runPeriodStr(3,1)).Atoi();
00105 return ERunType(runPeriod);
00106 }
00107 }