00001 #include "NCUtils/NCType.h"
00002 #include "NCUtils/NCRunUtil.h"
00003 #include "JobControl/JobC.h"
00004 #include "JobControl/JobCModule.h"
00005 #include "Registry/Registry.h"
00006 #include "Conventions/Detector.h"
00007 #include "Conventions/BeamType.h"
00008 #include "Conventions/ReleaseType.h"
00009 #include "MCReweight/MCReweight.h"
00010 #include "MCReweight/NeugenWeightCalculator.h"
00011
00012 #include <iostream>
00013 #include <string>
00014
00015 enum EDataType {
00016 kUnknown=-1, kMC, kData, kMockData, kBlind, kElectron, kTau
00017 };
00018
00019 Registry reg;
00020
00021 EDataType datatype=kUnknown;
00022 Detector::Detector_t det=Detector::kUnknown;
00023 BeamType::BeamType_t beamtype=BeamType::kUnknown;
00024 NC::RunUtil::ERunType runPeriod=NC::RunUtil::kRunAll;
00025 string month="";
00026
00027
00028
00029 void set_month(string m)
00030 {
00031 month=m;
00032 }
00033
00034
00035
00036 void set_detector(Detector::Detector_t _det)
00037 {
00038 det=_det;
00039 }
00040
00041
00042
00043
00044 void set_datatype(EDataType t)
00045 {
00046 datatype=t;
00047 }
00048
00049
00050
00051 void set_runperiod(NC::RunUtil::ERunType r)
00052 {
00053 runPeriod=r;
00054 }
00055
00056
00057
00058 string get_designator(Detector::Detector_t d, EDataType t)
00059 {
00060 if(d==Detector::kFar){
00061 switch(datatype){
00062 case kMC: return "f210";
00063 case kData:
00064 case kMockData:
00065 case kBlind:
00066 return "F";
00067 case kElectron: return "f214";
00068 case kTau: return "f213";
00069 default: assert(0 && "Something went horribly wrong");
00070 }
00071 } else if(d==Detector::kNear){
00072 if(t==kMC) return "n";
00073 else return "N";
00074 }
00075
00076 assert(0 && "Something Wrong: unknown detector");
00077 }
00078
00079
00080
00081 void set_dir(string path)
00082 {
00083 assert(det!=Detector::kUnknown);
00084 assert(datatype!=kUnknown);
00085
00086
00087
00088
00089 string glob=path+"/"+
00090 get_designator(det, datatype)+"*antp*.root";
00091 reg.Set("FilePath", glob.c_str());
00092 }
00093
00094
00095
00096 void set_mc_version(ReleaseType::Release_t r)
00097 {
00098 reg.Set("MCVersion", r);
00099 }
00100
00101
00102
00103 void set_beamtype(BeamType::BeamType_t b)
00104 {
00105 beamtype=b;
00106 reg.Set("BeamType", BeamType::AsString(beamtype));
00107 }
00108
00109
00110
00111 void set_output(string path, string tag="")
00112 {
00113 assert(det!=Detector::kUnknown);
00114 assert(datatype!=kUnknown);
00115 assert(beamtype!=BeamType::kUnknown);
00116
00117 assert(runPeriod!=NC::RunUtil::kRunAll || datatype==kData);
00118
00119 string fileName(path+"/");
00120 if (det == Detector::kFar) fileName += "far";
00121 else if (det==Detector::kNear) fileName += "near";
00122 else assert(0 && "Unknown detector. Have you called set_detector?");
00123
00124 fileName += "_";
00125 fileName += BeamType::AsString(beamtype);
00126
00127 fileName += Form("_run%d_", (int)runPeriod);
00128
00129 switch(datatype){
00130 case kMC:
00131 fileName += "mc";
00132 break;
00133 case kElectron:
00134 fileName += "electron";
00135 break;
00136 case kTau:
00137 fileName += "tau";
00138 break;
00139 case kData:
00140 fileName += "data_"+month;
00141 break;
00142 case kMockData:
00143 fileName += "mock";
00144 break;
00145 case kBlind:
00146 fileName += "blind";
00147 break;
00148 case kUnknown:
00149 assert(0 && "datatype not set");
00150 }
00151
00152 fileName += tag+".uDST.root";
00153
00154 reg.Set("FileName", fileName.c_str());
00155 }
00156
00157
00158
00159 void set_cuts(NCType::ECuts c)
00160 {
00161 reg.Set("CutSuite", int(c));
00162 }
00163
00164
00165
00166 void do_extractions(string codenames)
00167 {
00168 reg.Set("ExtractionsList", codenames.c_str());
00169 }
00170
00171
00172
00173 void set_file_limit(int limit)
00174 {
00175 if(limit>0) reg.Set("FileCountLimit", limit);
00176 }
00177
00178
00179
00180
00181
00182 void set_pdf_training_file(TString s)
00183 {
00184 reg.Set("ExtractionPDFTrainingFilePath", s.Data());
00185 }
00186
00187
00188
00189 void set_mda_mc_path(TString s)
00190 {
00191 reg.Set("MDAMCPath", s.Data());
00192 }
00193
00194
00195 void set_ann_use_lowE(bool useLowE)
00196 {
00197 reg.Set("RPAnnUseLowETrain", useLowE);
00198 }
00199
00200
00201
00202 void run()
00203 {
00204
00205
00206 if (det==Detector::kNear && (datatype==kTau || datatype==kElectron)){
00207 assert(0 && "Tau/Electron files don't exist for ND");
00208 }
00209
00210 reg.Set("UseAll185i", false);
00211 reg.Set("ReadPDFs", true);
00212 reg.Set("RunPeriod", (int)runPeriod);
00213
00214
00215
00216
00217
00218
00219 JobC jc;
00220
00221
00222
00223 jc.Msg.SetLevel("MicroDSTMaker","Info");
00224 jc.Msg.SetLevel("NCAnalysisUtils","Info");
00225 jc.Msg.SetLevel("NCAnalysisCuts","Info");
00226 jc.Msg.SetLevel("NCUtils","Info");
00227
00228
00229 jc.Path.Create("Analysis", "MicroDSTMaker::Ana");
00230
00231 JobCModule& jm=jc.Path("Analysis").Mod("MicroDSTMaker");
00232
00233 jm.GetConfig().UnLockValues();
00234 jm.GetConfig() = reg;
00235 jm.Config(jm.GetConfig());
00236 jm.GetConfig().LockKeys();
00237
00238 jc.Path("Analysis").Run();
00239
00240 jc.Path("Analysis").Report();
00241
00242 jc.Msg.Stats();
00243 }