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

make_uDST.h

Go to the documentation of this file.
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 // Options are kMC, kData, kMockData, kBlind
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:     // Fallthrough
00064     case kMockData: // Fallthrough
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   string runPeriodStr;
00086   switch(runPeriod){
00087   case NC::RunUtil::kRunI:
00088     runPeriodStr="r1"; break;
00089   case NC::RunUtil::kRunII:
00090     runPeriodStr="r2"; break;
00091   case NC::RunUtil::kRunIII:
00092     runPeriodStr="r3"; break;
00093   case NC::RunUtil::kRunAll:
00094     // This will happen for data
00095     runPeriodStr=""; break;
00096   default:
00097     assert(0 && "Unknown runPeriod");
00098   }
00099   string glob=path+"/"+
00100     get_designator(det, datatype)+"*"+runPeriodStr+"*.antp*.root";
00101   reg.Set("FilePath", glob.c_str());
00102 }
00103 
00104 //===========================================================
00105 
00106 void set_mc_version(ReleaseType::Release_t r)
00107 {
00108   reg.Set("MCVersion", r);
00109 }
00110 
00111 //===========================================================
00112 
00113 void set_beamtype(BeamType::BeamType_t b)
00114 {
00115   beamtype=b;
00116   reg.Set("BeamType", BeamType::AsString(beamtype));
00117 }
00118 
00119 //===========================================================
00120 
00121 void set_output(string path, string tag="")
00122 {
00123   assert(det!=Detector::kUnknown);
00124   assert(datatype!=kUnknown);
00125   assert(beamtype!=BeamType::kUnknown);
00126   // Make sure the run period is set for MC
00127   assert(runPeriod!=NC::RunUtil::kRunAll || datatype==kData);
00128 
00129   string fileName(path+"/");
00130   if (det == Detector::kFar) fileName += "far";
00131   else if (det==Detector::kNear) fileName += "near";
00132   else assert(0 && "Unknown detector. Have you called set_detector?");
00133 
00134   fileName += "_";
00135   fileName += BeamType::AsString(beamtype);
00136   fileName += "_";
00137   // Only add "run<n>" to the filename if we've been given a specific runperiod
00138   // This means that data doesn't get one
00139   if(runPeriod!=NC::RunUtil::kRunAll){
00140     // This relies on NC::RunUtil::kRunI == 1 etc, which is indeed the case
00141     fileName += Form("run%d_", (int)runPeriod);
00142   }
00143 
00144   switch(datatype){
00145   case kMC:
00146     fileName += "mc";
00147     break;
00148   case kElectron:
00149     fileName += "electron";
00150     break;
00151   case kTau:
00152     fileName += "tau";
00153     break;
00154   case kData:
00155     fileName += "data_"+month;
00156     break;
00157   case kMockData: 
00158     fileName += "mock";
00159     break;
00160   case kBlind:
00161     fileName += "blind";
00162     break;
00163   case kUnknown:
00164     assert(0 && "datatype not set");
00165   }
00166 
00167   fileName += tag+".uDST.root";
00168 
00169   reg.Set("FileName", fileName.c_str());
00170 }
00171 
00172 //===========================================================
00173 
00174 void set_cuts(NCType::ECuts c)
00175 {
00176   reg.Set("CutSuite", int(c));
00177 }
00178 
00179 //===========================================================
00180 
00181 void do_extractions(string codenames)
00182 {
00183   reg.Set("ExtractionsList", codenames.c_str());
00184 }
00185 
00186 //===========================================================
00187 
00188 void set_file_limit(int limit)
00189 {
00190   if(limit>0) reg.Set("FileCountLimit", limit);
00191 }
00192 
00193 // Extraction-specific things
00194 
00195 //===========================================================
00196 
00197 void set_pdf_training_file(TString s)
00198 {
00199   reg.Set("ExtractionPDFTrainingFilePath", s.Data());
00200 }
00201 
00202 //===========================================================
00203 
00204 void set_mda_mc_path(TString s)
00205 {
00206   reg.Set("MDAMCPath", s.Data());
00207 }
00208 
00209 //===========================================================
00210 void set_ann_use_lowE(bool useLowE)
00211 {
00212   reg.Set("RPAnnUseLowETrain", useLowE);
00213 }
00214 
00215 //===========================================================
00216 
00217 void run()
00218 {
00219 
00220   // Check we have a meaningful combination of options
00221   if (det==Detector::kNear && (datatype==kTau || datatype==kElectron)){
00222     assert(0 && "Tau/Electron files don't exist for ND");
00223   }
00224 
00225   reg.Set("UseAll185i", false); //use all -185kA data
00226   reg.Set("ReadPDFs", true);
00227   reg.Set("RunPeriod", (int)runPeriod);
00228 
00229   // According to some error message, this is done somewhere else...
00230   //MCReweight &mcReweight = MCReweight::Instance();
00231   //NeugenWeightCalculator *neugenWeightCal = new NeugenWeightCalculator;
00232   //mcReweight.AddWeightCalculator(neugenWeightCal);
00233 
00234   JobC jc;
00235 
00236   // set message service verbosity levels before creating path
00237   // so that messages from the constructor don't get lost
00238   jc.Msg.SetLevel("MicroDSTMaker","Info");
00239   jc.Msg.SetLevel("NCAnalysisUtils","Info");
00240   jc.Msg.SetLevel("NCAnalysisCuts","Info");
00241   jc.Msg.SetLevel("NCUtils","Info");
00242 
00243   //Create path
00244   jc.Path.Create("Analysis", "MicroDSTMaker::Ana");
00245 
00246   JobCModule& jm=jc.Path("Analysis").Mod("MicroDSTMaker");
00247 
00248   jm.GetConfig().UnLockValues();
00249   jm.GetConfig() = reg;
00250   jm.Config(jm.GetConfig());
00251   jm.GetConfig().LockKeys();
00252 
00253   jc.Path("Analysis").Run();
00254   //Job Report
00255   jc.Path("Analysis").Report();
00256   //Get Message Statistics
00257   jc.Msg.Stats();
00258 }

Generated on Mon Feb 15 11:06:56 2010 for loon by  doxygen 1.3.9.1