00001
00002
00003
00004
00005
00006
00007
00008
00010
00011 #include "NCUtils/Extraction/MicroDSTMaker.h"
00012
00013 #include "NCUtils/Cuts/NCAnalysisCutsCC.h"
00014 #include "NCUtils/Cuts/NCAnalysisCutsNCCCFid.h"
00015 #include "NCUtils/NCEventInfo.h"
00016 #include "NCUtils/NCType.h"
00017 #include "NCUtils/NCUtility.h"
00018
00019 #include "MessageService/MsgService.h"
00020 #include "MinosObjectMap/MomNavigator.h"
00021 #include "DataUtil/EnergyCorrections.h"
00022 #include "JobControl/JobCModuleRegistry.h"
00023 #include "Conventions/Detector.h"
00024 #include "Conventions/ReleaseType.h"
00025 #include "Conventions/SimFlag.h"
00026 #include "DataUtil/MCInfo.h"
00027
00028 #include "TSystemFile.h"
00029 #include "TH1.h"
00030
00031 #include <cmath>
00032 #include <cassert>
00033 #include <algorithm>
00034
00035 using namespace EnergyCorrections;
00036
00037 CVSID("$Id: MicroDSTMaker.cxx,v 1.10 2010/01/19 18:13:19 tinti Exp $");
00038
00039
00040
00041
00042
00043 JOBMODULE(MicroDSTMaker,
00044 "MicroDSTMaker",
00045 "A module to make NC uDSTs from antps");
00046
00047
00048 MicroDSTMaker::MicroDSTMaker() :
00049 fNtpFile(0),
00050 fNtuple(0),
00051 fStrippedNtpFile(0),
00052 fRunPeriod(NC::RunUtil::kRunAll)
00053 {
00054 MSG("JobC", Msg::kDebug) << "MicroDSTMaker::Constructor" << endl;
00055
00056 fHeaderInfo = new ANtpHeaderInfo;
00057 fBeamInfo = new ANtpBeamInfo;
00058 fRecoInfo = new ANtpRecoInfo;
00059 fEventInfo = new ANtpEventInfoNC;
00060 fShowerInfo = new ANtpShowerInfoNC;
00061 fTrackInfo = new ANtpTrackInfoNC;
00062 fTruthInfo = new ANtpTruthInfoBeam;
00063 fMRCCInfo = new ANtpEventInfoMRCC;
00064
00065 fInfo = new NCEventInfo;
00066
00067 }
00068
00069
00070 MicroDSTMaker::~MicroDSTMaker()
00071 {
00072
00073 MSG("JobC", Msg::kDebug) << "MicroDSTMaker::Destructor" << endl;
00074
00075
00076 if (fHeaderInfo) delete fHeaderInfo;
00077 if (fBeamInfo) delete fBeamInfo;
00078 if (fRecoInfo) delete fRecoInfo;
00079 if (fEventInfo) delete fEventInfo;
00080 if (fShowerInfo) delete fShowerInfo;
00081 if (fTruthInfo) delete fTruthInfo;
00082 if (fTrackInfo) delete fTrackInfo;
00083 if (fMRCCInfo) delete fMRCCInfo;
00084 if (fCuts) delete fCuts;
00085
00086 if (fInfo) delete fInfo;
00087
00088 }
00089
00090
00091 void MicroDSTMaker::EndJob()
00092 {
00093 MSG("MicroDSTMaker", Msg::kInfo) << "Running with registry:" << endl;
00094 GetConfig().Print();
00095 MakeuDST();
00096 }
00097
00098
00099 void MicroDSTMaker::CreateNtupleTree(TFile*& file, TTree*& tree,
00100 TTree*& beamTree,
00101 TString filename, TString treename,
00102 bool truthBranch,
00103 bool mrccBranch)
00104 {
00105
00106 TDirectory* saveDir = gDirectory;
00107
00108 file = new TFile(filename, "RECREATE");
00109 tree = new TTree("uDST", treename);
00110 tree->Branch("header.", "ANtpHeaderInfo", &fHeaderInfo, 64000, 2);
00111
00112 if(truthBranch)
00113 tree->Branch("truth.", "ANtpTruthInfoBeam", &fTruthInfo, 64000, 2);
00114
00115 tree->Branch("beam.", "ANtpBeamInfo", &fBeamInfo, 64000, 2);
00116 tree->Branch("reco.", "ANtpRecoInfo", &fRecoInfo, 64000, 2);
00117
00118
00119
00120
00121 if(mrccBranch)
00122 tree->Branch("mrcc.", "ANtpEventInfoMRCC", &fMRCCInfo, 64000, 2);
00123
00124 for(unsigned int i = 0; i < fExtractions.size(); ++i) {
00125 string branchName = fExtractions[i]->ClassName();
00126 branchName = branchName.erase(0, 12);
00127
00128 branchName = "analysis" + branchName + ".";
00129
00130
00131 MSG("MicroDSTMaker", Msg::kInfo)
00132 << "Setting " << branchName << " branch..." << endl;
00133 tree->Branch(branchName.c_str(), "ANtpAnalysisInfo",
00134 &fAnalysisInfos[i], 64000, 2);
00135 }
00136
00137 tree->SetDirectory(file);
00138
00139 beamTree = new TTree("beam", "AnalysisTree");
00140 beamTree->Branch("header.", "ANtpHeaderInfo", &fHeaderInfo, 64000, 2);
00141 beamTree->Branch("beam.", "ANtpBeamInfo", &fBeamInfo, 64000, 2);
00142 beamTree->SetDirectory(file);
00143
00144
00145 saveDir->cd();
00146 }
00147
00148
00149 void MicroDSTMaker::MakeuDST()
00150 {
00151
00152 TChain chain(fTreeName);
00153
00154 chain.Add(fFilePath);
00155
00156 fDataType=chain.FindBranch("truth.") ? NCType::kMC : NCType::kData;
00157
00158 bool haveMRCCBranch=chain.FindBranch("mrcc.");
00159
00160 MSG("MicroDSTMaker", Msg::kInfo) << "adding path " << fFilePath
00161 << " to chain." << endl;
00162
00163
00164 if(fDataType==NCType::kMC &&
00165 (fRunPeriod<NC::RunUtil::kRunI || fRunPeriod>NC::RunUtil::kMaxRun)){
00166 MSG("MicroDSTMaker", Msg::kFatal)
00167 << "Run Period not set, or set wrongly, when running on MC. Bailing" << endl;
00168
00169 MSG("MicroDSTMaker", Msg::kInfo) << endl;
00170 }
00171
00172 chain.SetBranchAddress("header.", &fHeaderInfo);
00173 chain.SetBranchAddress("beam.", &fBeamInfo);
00174 chain.SetBranchAddress("event.", &fEventInfo);
00175 chain.SetBranchAddress("shower.", &fShowerInfo);
00176 chain.SetBranchAddress("track.", &fTrackInfo);
00177
00178 if(fDataType==NCType::kMC) chain.SetBranchAddress("truth.", &fTruthInfo);
00179 if(haveMRCCBranch) chain.SetBranchAddress("mrcc.", &fMRCCInfo);
00180
00181 chain.GetEntry(0);
00182
00183
00184 MSG("MicroDSTMaker", Msg::kInfo) << "fCutSuite = " << fCutSuite << endl;
00185 switch(fCutSuite){
00186 case NCType::kCCCuts: fCuts = new NCAnalysisCutsCC; break;
00187 case NCType::kNCCuts: fCuts = new NCAnalysisCutsNC; break;
00188 case NCType::kNCCCFidCuts: fCuts = new NCAnalysisCutsNCCCFid; break;
00189 default: assert(0 && "Unknown cut suite");
00190 }
00191
00192 fCuts->SetInfoObjects(fHeaderInfo, fBeamInfo, fEventInfo,
00193 fTrackInfo, fShowerInfo, fTruthInfo);
00194 fInfo->SetInfoObjects(fHeaderInfo, fBeamInfo, fEventInfo,
00195 fTrackInfo, fShowerInfo, 0, 0, fTruthInfo);
00196
00197
00198 fCuts->SetBeamType(fBeamType);
00199
00200
00201 fCuts->SetUseAllBeams(fUseAllBeams);
00202 fCuts->SetUseAllL010z(fUseAllL010z);
00203 fCuts->SetUseAll185i(fUseAll185i);
00204
00205
00206 FillExtractionAndAnalysisVectors();
00207
00208
00209 TString fileName = fFileName;
00210
00211
00212 TString stripFileName = fileName;
00213 int pos = stripFileName.Index(".root");
00214 stripFileName.Insert(pos, "_strip");
00215
00216 CreateNtupleTree(fStrippedNtpFile, fStrippedNtuple, fBeamNtupleStp,
00217 stripFileName, "Stripped AnalysisTree", fDataType==NCType::kMC,
00218 haveMRCCBranch);
00219
00220 CreateNtupleTree(fNtpFile, fNtuple, fBeamNtuple,
00221 fileName, "AnalysisTree", fDataType==NCType::kMC,
00222 haveMRCCBranch);
00223
00224 MSG("MicroDSTMaker", Msg::kInfo) << "filenames " << fileName
00225 << " " << stripFileName << endl;
00226
00227
00228 fPOTs.clear();
00229
00230
00231 ExtractNCCC(&chain);
00232
00233 WriteFile(fNtpFile, fNtuple, fBeamNtuple);
00234 WriteFile(fStrippedNtpFile, fStrippedNtuple, fBeamNtupleStp);
00235
00236 const int ntupleEntries = fNtuple->GetEntries();
00237
00238
00239
00240 if(ntupleEntries < 1){
00241 TSystemFile ntp(fileName, "./");
00242 TSystemFile strip(stripFileName, "./");
00243
00244 ntp.Delete();
00245 strip.Delete();
00246 }
00247 }
00248
00249
00250 void MicroDSTMaker::FillExtractionAndAnalysisVectors()
00251 {
00252 MSG("MicroDSTMaker", Msg::kInfo) << "SimFlag = "
00253 << fHeaderInfo->dataType << endl;
00254
00255 fExtractions.clear();
00256 ParseExtractionsList(fExtractionsList);
00257
00258
00259 MSG("MicroDSTMaker", Msg::kInfo)
00260 << "Using " << fExtractions.size() << " extraction methods."
00261 << " Now adding the corresponding ANtpAnalysisInfo objects..."
00262 << endl;
00263
00264 fAnalysisInfos.clear();
00265 for (unsigned int i = 0; i < fExtractions.size(); ++i)
00266 fAnalysisInfos.push_back(new ANtpAnalysisInfo);
00267 }
00268
00269
00270 const Registry& MicroDSTMaker::DefaultConfig() const
00271 {
00272 static Registry r;
00273
00274 r.UnLockValues();
00275
00276 r.Set("FileName", "ncccSeparation.root");
00277 r.Set("TreeName", "antp");
00278 r.Set("FilePath", "");
00279 r.Set("PDFPath", "DP_histos_far.root");
00280 r.Set("ReadPDFs", false);
00281 r.Set("BeamType", "L010z185i");
00282 r.Set("UseAllBeams", false);
00283 r.Set("UseAllL010z", false);
00284 r.Set("UseAll185i", false);
00285 r.Set("ExtractionsList", "TOm");
00286 r.Set("RPAnnUseLowETrain", false);
00287 r.Set("FileCountLimit", 1000000000);
00288 r.Set("DataSet", "/");
00289 r.Set("CutSuite", int(NCType::kCCCuts));
00290
00291 r.Set("MCVersion",
00292 ReleaseType::kDogwood | ReleaseType::kDaikon | ReleaseType::k04);
00293
00294 r.Set("RunPeriod", int(NC::RunUtil::kRunAll));
00295
00296 r.LockValues();
00297 return r;
00298 }
00299
00300
00301 void MicroDSTMaker::Config(const Registry& r)
00302 {
00303 int tmpb;
00304 int tmpi;
00305 const char* tmps;
00306
00307 if (r.Get("FileName", tmps)) fFileName = tmps;
00308 if (r.Get("TreeName", tmps)) fTreeName = tmps;
00309 if (r.Get("FilePath", tmps)) fFilePath = tmps;
00310 if (r.Get("UseMCAsData", tmpb)) fUseMCAsData = tmpb;
00311 if (r.Get("BeamType", tmps)) fBeamType = BeamType::TagToEnum(tmps);
00312 if (r.Get("UseAllBeams", tmpb)) fUseAllBeams = tmpb;
00313 if (r.Get("UseAllL010z", tmpb)) fUseAllL010z = tmpb;
00314 if (r.Get("UseAll185i", tmpb)) fUseAll185i = tmpb;
00315 if (r.Get("ExtractionsList", tmps)) fExtractionsList = tmps;
00316 if (r.Get("CutSuite", tmpi)) fCutSuite = NCType::ECuts(tmpi);
00317 if (r.Get("FileCountLimit", tmpi)) fFileCountLimit = tmpi;
00318 if (r.Get("DataSet", tmps)){
00319 fDataSet = tmps;
00320 fDataSet.Remove(TString::kLeading, '/');
00321 }
00322 if (r.Get("RunPeriod", tmpi)) fRunPeriod = NC::RunUtil::ERunType(tmpi);
00323 }
00324
00325
00326 void MicroDSTMaker::ExtractNCCC(TChain *chain)
00327 {
00328
00329 MSG("MicroDSTMaker", Msg::kInfo) << "ExtractNCCC" << endl;
00330
00331 int ctr = 0;
00332 int passSnarl = 0;
00333 int passEvt = 0;
00334 int passFid = 0;
00335 bool passCut1 = false;
00336 bool passCut2 = false;
00337 bool passCut3 = false;
00338 bool newSnarl = false;
00339
00340 int fileCtr = 0;
00341 int prevRun = -1;
00342 int prevSubRun = -1;
00343
00344 chain->GetEntry(0);
00345
00346 Detector::Detector_t detType = (Detector::Detector_t)fHeaderInfo->detector;
00347
00348 if(fDataType==NCType::kMC){
00349 const char* mcString = (fHeaderInfo->softVersion).Data();
00350 ReleaseType::Release_t mcType=ReleaseType::StringToType(mcString);
00351 if (mcType==ReleaseType::kUnknown) {
00352 MSG("MicroDSTMaker",Msg::kFatal)
00353 << "Can't figure out MC version, bailing." << endl;
00354
00355 MSG("MicroDSTMaker",Msg::kFatal)
00356 << "Goodbye" << endl;
00357 }
00358
00359 fMCPOTPerSnarlOrSubrun = MCInfo::GetMCPoT(detType,fBeamType,mcType);
00360 MSG("MicroDSTMaker",Msg::kInfo) << "MC POT per snarl: "
00361 << fMCPOTPerSnarlOrSubrun << endl;
00362 }
00363
00364
00365 while( chain->GetEntry(ctr) && fileCtr<fFileCountLimit){
00366 if(ctr % 20000 == 0)
00367 MSG("MicroDSTMaker", Msg::kInfo)
00368 << "entry " << ctr << " file " << fileCtr << endl;
00369
00370 ++ctr;
00371
00372 if(fHeaderInfo->run != prevRun || fHeaderInfo->subRun != prevSubRun){
00373 prevRun = fHeaderInfo->run;
00374 prevSubRun = fHeaderInfo->subRun;
00375 ++fileCtr;
00376 }
00377
00378 if(fDataType==NCType::kData){
00379 fTruthInfo = 0;
00380 fBeamInfo->protonIntensity = fBeamInfo->trtgtd;
00381 if(fBeamInfo->protonIntensity <= 0.0)
00382 fBeamInfo->protonIntensity = fBeamInfo->tr101d;
00383 if(fBeamInfo->protonIntensity <= 0.0)
00384 fBeamInfo->protonIntensity = 0.;
00385 }
00386 else if(fDataType==NCType::kMC){
00387
00388 fBeamInfo->beamType = (Int_t)(fBeamType);
00389 fBeamInfo->protonIntensity = fMCPOTPerSnarlOrSubrun;
00390 }
00391 else{
00392 assert(0 && "Data Type neither MC or data. Bailing.");
00393 }
00394
00395
00396 fCuts->SetInfoObjects(fHeaderInfo, fBeamInfo, fEventInfo,
00397 fTrackInfo, fShowerInfo, fTruthInfo);
00398 fInfo->SetInfoObjects(fHeaderInfo, fBeamInfo, fEventInfo,
00399 fTrackInfo, fShowerInfo, 0, 0, fTruthInfo);
00400
00401 newSnarl = fCuts->IsNewSnarl();
00402
00403 if (passCut1 = (fCuts->IsGoodBeamSnarl()) ) passSnarl++;
00404 if (passCut2 = (fCuts->IsGoodBeamEvent() && passCut1) ) passEvt++;
00405 if (passCut3 = (fCuts->InBeamFiducialVolume() && passCut2)) passFid++;
00406
00407 if( newSnarl && passCut1 ){
00408 CountPOTs();
00409 AddToBeamNtuple();
00410 }
00411
00412 if (!passCut2) continue;
00413
00414 FillRecoInfo(fRecoInfo, fHeaderInfo,
00415 fEventInfo, fShowerInfo,
00416 fTrackInfo, fBeamInfo, fCuts,
00417 fBeamInfo->beamType);
00418
00419 NCEventInfo evtInfo;
00420 evtInfo.beam=fBeamInfo;
00421 evtInfo.event=fEventInfo;
00422 evtInfo.header=fHeaderInfo;
00423 evtInfo.reco=fRecoInfo;
00424 evtInfo.shower=fShowerInfo;
00425 evtInfo.track=fTrackInfo;
00426 evtInfo.truth=fTruthInfo;
00427
00428
00429 for (unsigned int i = 0; i < fExtractions.size(); ++i){
00430 evtInfo.analysis=fAnalysisInfos[i];
00431 NCExtraction* ext=fExtractions[i];
00432 ext->FillAnalysisInfo(evtInfo, fBeamInfo->beamType);
00433 }
00434 AddToNtuple();
00435
00436 }
00437
00438
00439 MSG("MicroDSTMaker", Msg::kInfo)
00440 << passSnarl << "/" << ctr << " passed IsGoodBeamSnarl()\n"
00441 << passEvt << "/" << passSnarl << " passed IsGoodBeamEvent()\n"
00442 << passFid << "/" << passEvt << " passed fiducial cuts"
00443 << endl;
00444 }
00445
00446
00447 void MicroDSTMaker::AddToBeamNtuple()
00448 {
00449 const bool canWriteFull = !OutputFileTooBig();
00450 const bool canWriteStripped = !StrippedOutputFileTooBig();
00451
00452 if(canWriteFull)
00453 fBeamNtuple->Fill();
00454 if(canWriteStripped)
00455 fBeamNtupleStp->Fill();
00456 }
00457
00458
00459 void MicroDSTMaker::AddToNtuple()
00460 {
00461
00462
00463 const bool canWriteFull = !OutputFileTooBig();
00464 const bool canWriteStripped = !StrippedOutputFileTooBig();
00465
00466 if(canWriteFull) fNtuple->Fill();
00467
00468 if(fCuts->PassesFinalSelection(fRecoInfo) && canWriteStripped)
00469 fStrippedNtuple->Fill();
00470 }
00471
00472
00473
00474 void MicroDSTMaker::CountPOTs()
00475 {
00476 int runCode = 100*fHeaderInfo->run + fHeaderInfo->subRun;
00477 map<int, double>::iterator itr=fPOTs.find(runCode);
00478
00479 if(fDataType==NCType::kData){
00480
00481 if( itr != fPOTs.end() )
00482 fPOTs[runCode] += fBeamInfo->protonIntensity;
00483 else
00484 fPOTs[runCode] = fBeamInfo->protonIntensity;
00485 }
00486 else{
00487
00488
00489
00490 if(fHeaderInfo->detector == Detector::kNear){
00491 if( itr != fPOTs.end())
00492 fPOTs[runCode] += fMCPOTPerSnarlOrSubrun;
00493 else
00494 fPOTs[runCode] = fMCPOTPerSnarlOrSubrun;
00495 }
00496 else{
00497
00498
00499 fPOTs[runCode] = fMCPOTPerSnarlOrSubrun;
00500 }
00501 }
00502 }
00503
00504
00505 void MicroDSTMaker::WritePOTInfo()
00506 {
00507 if(fPOTs.size() != 0){
00508 int firstRun = fPOTs.begin()->first;
00509
00510 int lastRun = fPOTs.rbegin()->first;
00511 TH1F *potHist = new TH1F(fDataType==NCType::kData ? "dataPOT" : "mcPOT",
00512 "",
00513 lastRun-firstRun+1,
00514 firstRun,
00515 lastRun+1);
00516 map<int, double>::iterator itr = fPOTs.begin();
00517 while( itr != fPOTs.end() ){
00518 potHist->Fill(itr->first + 0.5, itr->second);
00519 ++itr;
00520 }
00521 potHist->Write();
00522 MSG("MicroDSTMaker", Msg::kInfo) << "total POT = "
00523 << potHist->Integral()
00524 << " x 10^{12}" << endl;
00525 }
00526 }
00527
00528
00529 double MicroDSTMaker::GetTotalPOTCount()
00530 {
00531 double ret = 0;
00532 for(map<int, double>::iterator it = fPOTs.begin();
00533 it != fPOTs.end(); ++it) ret += it->second;
00534 return ret;
00535 }
00536
00537
00538 void MicroDSTMaker::WriteFile(TFile *file, TTree *events, TTree *beam)
00539 {
00540
00541
00542
00543 TDirectory* saveDir = gDirectory;
00544
00545 file->cd();
00546
00547 events->Write();
00548 beam->Write();
00549 WritePOTInfo();
00550
00551 file->cd();
00552
00553 file->Write("",TObject::kOverwrite);
00554
00555 MSG("MicroDSTMaker", Msg::kInfo) << "file " << file->GetName()
00556 << " written" << endl;
00557
00558
00559 saveDir->cd();
00560 }
00561
00562
00563 void MicroDSTMaker::FillRecoInfo(ANtpRecoInfo *recoInfo,
00564 ANtpHeaderInfo *headerInfo,
00565 ANtpEventInfoNC *eventInfo,
00566 ANtpShowerInfoNC* showerInfo,
00567 ANtpTrackInfoNC *trackInfo,
00568 ANtpBeamInfo *beamInfo,
00569 NCAnalysisCuts *cuts,
00570 int beamType)
00571 {
00572
00573 recoInfo->Reset();
00574
00575
00576 if(fDataType==NCType::kMC) recoInfo->runPeriod = (int)fRunPeriod;
00577
00578 recoInfo->inFiducialVolume = (int)cuts->InBeamFiducialVolume();
00579 recoInfo->isFullyContained = (int)(cuts->InBeamFiducialVolume() &&
00580 cuts->IsStoppingBeamMuon());
00581
00582 recoInfo->passesCuts = 1;
00583 recoInfo->pass = 1;
00584
00585
00586
00587
00588 const bool stop = cuts->IsStoppingBeamMuon();
00589 recoInfo->nuEnergyCC = fInfo->GetEventEnergy(CandShowerHandle::kCC, stop);
00590 recoInfo->nuEnergyNC = fInfo->GetShowerEnergy(CandShowerHandle::kNC);
00591 recoInfo->nuEnergy = fInfo->GetEventEnergy(CandShowerHandle::kCC, stop);
00592
00593 if(eventInfo->tracks > 0)
00594 recoInfo->muEnergy = fInfo->GetTrackEnergy(stop);
00595 else
00596 recoInfo->muEnergy = 0.;
00597
00598 if(eventInfo->showers > 0){
00599 recoInfo->showerEnergy = fInfo->GetShowerEnergy(CandShowerHandle::kCC);
00600 recoInfo->showerEnergyCC = fInfo->GetShowerEnergy(CandShowerHandle::kCC);
00601 recoInfo->showerEnergyNC = fInfo->GetShowerEnergy(CandShowerHandle::kNC);
00602 }
00603 else{
00604 recoInfo->showerEnergy = 0.;
00605 recoInfo->showerEnergyCC = 0.;
00606 recoInfo->showerEnergyNC = 0.;
00607 }
00608
00609
00610 recoInfo->isGoodShower = (int)cuts->IsGoodShower();
00611
00612
00613 if(recoInfo->nuEnergy > 0.){
00614 recoInfo->hadronicY = recoInfo->showerEnergy;
00615 recoInfo->hadronicY /= recoInfo->nuEnergy;
00616 }
00617
00618 recoInfo->muDCosZVtx = trackInfo->dcosZVtx;
00619 double vtxX = 0., vtxY = 0., vtxZ = 0.;
00620 recoInfo->vtxR = fInfo->GetEventVertex(vtxX, vtxY, vtxZ);
00621 recoInfo->vtxX = vtxX;
00622 recoInfo->vtxY = vtxY;
00623 recoInfo->vtxZ = vtxZ;
00624 recoInfo->eventLength = eventInfo->lengthInPlanes;
00625 recoInfo->trackExtension = eventInfo->trackExtension;
00626 recoInfo->numberTracks = eventInfo->tracks;
00627 recoInfo->trackLength = trackInfo->length;
00628
00629 bool isdata = fDataType==NCType::kData;
00630 Detector::Detector_t detType = (Detector::Detector_t)headerInfo->detector;
00631
00632 recoInfo->trackMomentum = CorrectSignedMomentumFromCurvature(trackInfo->fitMomentum,
00633 isdata, detType );
00634
00635
00636 if( 0 < trackInfo->rangeMomentum ){
00637 recoInfo->trackRange = CorrectMomentumFromRange(trackInfo->rangeMomentum,
00638 isdata, detType);
00639 }
00640 else{
00641 recoInfo->trackRange = trackInfo->rangeMomentum;
00642 }
00643
00644 recoInfo->sigmaQoverP = trackInfo->sigmaQoverP;
00645 recoInfo->eventInSnarl = eventInfo->index;
00646
00647 recoInfo->weight = 1.0;
00648 recoInfo->weightRunII = 1.0;
00649 recoInfo->weightRunIII = 1.0;
00650
00651 if(fDataType==NCType::kMC){
00652
00653
00654 recoInfo->weight = fInfo->FindMEGAFitWeight(beamType, NC::RunUtil::kRunI);
00655 recoInfo->weightRunII = fInfo->FindMEGAFitWeight(beamType, NC::RunUtil::kRunII);
00656 recoInfo->weightRunIII = fInfo->FindMEGAFitWeight(beamType, NC::RunUtil::kRunIII);
00657 }
00658
00659
00660 recoInfo->minTimeSeparation = eventInfo->minTimeSeparation;
00661 recoInfo->closeTimeEvent = eventInfo->closeTimeEvent;
00662
00663 recoInfo->totalStrips = eventInfo->totalStrips;
00664 recoInfo->planes = eventInfo->planes;
00665 recoInfo->trackPlanes = trackInfo->planes;
00666 recoInfo->showerPlanes = showerInfo->planes;
00667 recoInfo->showerTotalStrips = showerInfo->totalStrips;
00668 recoInfo->evtEnergyGeV = eventInfo->energyGeV;
00669
00670 if(detType == Detector::kNear){
00671 recoInfo->closeTimeDeltaZ = eventInfo->closeTimeDeltaZ;
00672 recoInfo->edgeActivityPH = eventInfo->edgeActivityPH;
00673 recoInfo->edgeActivityStrips = eventInfo->edgeActivityStrips;
00674 recoInfo->oppEdgePH = eventInfo->oppEdgePH;
00675 recoInfo->oppEdgeStrips = eventInfo->oppEdgeStrips;
00676 recoInfo->slicePHFraction = eventInfo->slicePHFraction;
00677 recoInfo->evtTimeDiff = eventInfo->evtTimeDiff;
00678 recoInfo->sharedStripFraction = eventInfo->sharedStripFraction;
00679 recoInfo->isCleanLowMultSnarl = int(cuts->IsCleanLowMultSnarl());
00680 recoInfo->isMultiCutsClean = int(cuts->IsMultiCutsClean());
00681 recoInfo->isSimpleCutsClean = int(cuts->IsSimpleCutsClean());
00682 }
00683
00684
00685
00686 if(detType == Detector::kFar){
00687 recoInfo->isSimpleCutsClean = 1;
00688 recoInfo->isMultiCutsClean = 1;
00689 }
00690
00691 recoInfo->deltaTimeSpill = (eventInfo->stripTime1st -
00692 1e-9*beamInfo->nearestNSToSpill)*1e6;
00693 }
00694
00695
00696 void MicroDSTMaker::ParseExtractionsList(TString extrs)
00697 {
00698 MSG("MicroDSTMaker", Msg::kInfo) << "Registered extractions:\n";
00699
00700 const vector<TString> extrsArgNames = NC::Utility::ParseStringList(extrs);
00701
00702 for(unsigned int n = 0; n < GetExtractionFactories().size(); ++n){
00703 NCExtractionFactory* ex = GetExtractionFactories()[n];
00704 const TString codeName = ex->GetCodeName();
00705
00706 MSG("MicroDSTMaker", Msg::kInfo) << " " << codeName << " - ";
00707
00708 bool inExtrs = false;
00709 for(unsigned int i = 0; i < extrsArgNames.size(); ++i)
00710 if(extrsArgNames[i] == codeName) inExtrs = true;
00711
00712 if(inExtrs){
00713 MSG("MicroDSTMaker", Msg::kInfo) << "Creating\n";
00714 fExtractions.push_back(ex->Create(fCuts, GetConfig()));
00715 }
00716 else{
00717 MSG("MicroDSTMaker", Msg::kInfo) << "Not in ExtractionsList\n";
00718 }
00719 }
00720 }
00721
00722
00723 bool MicroDSTMaker::OutputFileTooBig()
00724 {
00725
00726 if(fNtpFile->GetSize() < 1850400000)
00727 return false;
00728 else{
00729 MAXMSG("MicroDSTMaker", Msg::kWarning,1)
00730 << "Size limit exceeded no longer filling full ntuple" << endl;
00731 return true;
00732 }
00733 }
00734
00735
00736 bool MicroDSTMaker::StrippedOutputFileTooBig()
00737 {
00738
00739 if(fStrippedNtpFile->GetSize() < 1850400000)
00740 return false;
00741 else{
00742 MAXMSG("MicroDSTMaker", Msg::kWarning,1)
00743 << "Size limit exceeded no longer filling stripped ntuple" << endl;
00744 return true;
00745 }
00746 }