Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

NCRunUtil.cxx

Go to the documentation of this file.
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       // According to Robert P., the last run in the run period is
00029       // 38449, while the last LE run is 38420. Be more inclusive here
00030       // in case we ever run on non-LE data
00031       else if(header->run > 35723 && header->run <= 38449) return kRunII;
00032       // TODO: Just used the end of run II as the start of run III,
00033       // but this includes shutdown. Probably not a problem
00034       //
00035       // The final run number comes from Justin
00036       else if(header->run > 38449 && header->run <= 43639) return kRunIII;
00037       assert(0 && "Unknown run");
00038     }
00039     else{
00040       // Near detector
00041       if     (header->run <= 10159) return kRunI;
00042       // According to Robert P., the last run in the run period is
00043       // 12623, while the last LE run is 12578. Be more inclusive here
00044       // in case we ever run on non-LE data
00045       else if(header->run > 10159 && header->run <= 12623) return kRunII;
00046       // TODO: Just used the end of run II as the start of run III,
00047       // but this includes shutdown. Probably not a problem
00048       //
00049       // The final run number comes from Andy's docdb 6572
00050       else if(header->run > 12623 && header->run <= 16502) return kRunIII;
00051       assert(0 && "Unknown run");
00052     } // end if near det
00053   } // end if data
00054   else{
00055     // MC
00056     assert(reco);
00057     return ERunType(reco->runPeriod);
00058   }
00059 }
00060 
00061 //-----------------------------------------------------------------------
00062 //any data before march 2006 is run I, anything between may 2006 and august 2007
00063 //is run II
00064 ERunType NC::RunUtil::FindRunType(TString fileName)
00065 {
00066 
00067   // Yay for string processing in C and its evil spawn. In perl these
00068   // five lines would be:
00069   // /(20\d\d)-(\d\d)/ and $epochMonth=100*$1+$2;
00070   // or something like that
00071 
00072   // Match something that looks like a month in yyyy-mm format between 2000 and 2100
00073   TRegexp re("20[0-9][0-9]-[0-9][0-9]");
00074   // TString::operator()(TRegexp) returns the TSubString that matches the regexp
00075   TString date=TString(fileName(re));
00076   if(date.Length()==7){
00077     // The filename had a month number in it - must be a data file
00078     int year=TString(date(0, 4)).Atoi();
00079     // Brief worry that this would try octal if the month has a
00080     // leading zero, but man 3 atoi assures me that it always uses base 10
00081     int month=TString(date(5, 2)).Atoi();
00082     
00083     int epochMonth=100*year+month;
00084     
00085     // May 2005 - Feb 2006: Run I
00086     // May 2006 - Aug 2007: Run II
00087     // Nov 2007 - Jun 2009: Run III
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     // Must be an MC file. No harm in checking
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 }

Generated on Mon Feb 15 11:07:04 2010 for loon by  doxygen 1.3.9.1