00001
00002
00003
00004
00005
00006
00007
00008
00010
00011 #include "NCUtils/Extraction/NCAnalysisModule.h"
00012 #include "NCUtils/NCOscProb.h"
00013
00014 #include "NCUtils/Extraction/NCExtractionADM.h"
00015 #include "NCUtils/Extraction/NCExtractionDP.h"
00016 #include "NCUtils/Extraction/NCExtractionAS.h"
00017 #include "NCUtils/Extraction/NCExtractionTR.h"
00018 #include "NCUtils/Extraction/NCExtractionTRann.h"
00019 #include "NCUtils/Extraction/NCExtractionTO.h"
00020 #include "NCUtils/Extraction/NCExtractionTOm.h"
00021 #include "NCUtils/Extraction/NCExtractionNS.h"
00022 #include "NCUtils/Extraction/NCExtractionKA.h"
00023 #include "NCUtils/Extraction/NCExtractionKAD.h"
00024 #include "NCUtils/Extraction/NCExtractionRO.h"
00025 #include "NCUtils/Extraction/NCExtractionPL.h"
00026 #include "NCUtils/Extraction/NCExtractionRPann.h"
00027 #include "NCUtils/NCType.h"
00028
00029 #include "Validity/VldTimeStamp.h"
00030 #include "MessageService/MsgService.h"
00031 #include "MinosObjectMap/MomNavigator.h"
00032 #include "DataUtil/EnergyCorrections.h"
00033 #include "JobControl/JobCModuleRegistry.h"
00034 #include "JobControl/JobCommand.h"
00035 #include "Conventions/Detector.h"
00036 #include "Conventions/ReleaseType.h"
00037 #include "Conventions/SimFlag.h"
00038 #include "Conventions/Munits.h"
00039 #include "DataUtil/MCInfo.h"
00040
00041 #include "TSystemFile.h"
00042 #include "TCanvas.h"
00043 #include "TPad.h"
00044 #include "TLegend.h"
00045
00046 #include <cmath>
00047 #include <cassert>
00048 #include <algorithm>
00049
00050 using namespace EnergyCorrections;
00051
00052
00053
00054 static const int kLT05GeV = 0;
00055 static const int kLT1GeV = 1;
00056 static const int kGT1GeV = 2;
00057 static const int kAllGeV = 3;
00058 static const int kNumEventsVsPOT = 4;
00059
00060 CVSID("$Id: NCAnalysisModule.cxx,v 1.45 2008/04/02 20:32:51 brebel Exp $");
00061
00062
00063
00064
00065
00066 JOBMODULE(NCAnalysisModule,
00067 "NCAnalysisModule",
00068 "A module used for analyzing beam data");
00069
00070
00071 NCAnalysisModule::NCAnalysisModule() :
00072 fFileName("ncccSeparation.root"),
00073 fTreeName("PAN"),
00074 fMCPath("mcFiles/*.root"),
00075 fDataPath("dataFiles/*.root"),
00076 fNtpFile(0),
00077 fNtuple(0),
00078 fStrippedNtpFile(0)
00079 {
00080 MSG("JobC", Msg::kDebug) << "NCAnalysisModule::Constructor" << endl;
00081
00082 fHeaderInfo = new ANtpHeaderInfo();
00083 fBeamInfo = new ANtpBeamInfo();
00084 fRecoInfo = new ANtpRecoInfo();
00085 fEventInfo = new ANtpEventInfoNC();
00086 fShowerInfo = new ANtpShowerInfoNC();
00087 fTrackInfo = new ANtpTrackInfoNC();
00088 fTruthInfo = new ANtpTruthInfoBeam();
00089
00090 fUtils = new NCAnalysisUtils();
00091
00092 NCType::ConstructBadRuns();
00093
00094 VldTimeStamp start(2005,5,1,0,0,0);
00095 VldTimeStamp end(2007,5,1,0,0,0);
00096 fPOTVsTime = new TH1F("potVsTime", "", 365*2, start.GetSec(), end.GetSec());
00097 fPOTVsTime->GetXaxis()->SetTimeDisplay(1);
00098 fPOTVsTime->GetXaxis()->SetTimeFormat("%m/%d");
00099 fPOTVsTime->SetXTitle("Date");
00100 fPOTVsTime->SetYTitle("POT#times10^{12}");
00101
00102 NCType::MakeDataQualityPlots(fDataQualityTotal, "DataTotal");
00103 NCType::MakeDataQualityPlots(fDataQualityNC, "DataNC");
00104 NCType::MakeDataQualityPlots(fDataQualityCC, "DataCC");
00105
00106 NCType::MakeDataQualityPlots(fDataQualityTotalLowIntensity, "DataTotalLowIntensity");
00107 NCType::MakeDataQualityPlots(fDataQualityNCLowIntensity, "DataNCLowIntensity");
00108 NCType::MakeDataQualityPlots(fDataQualityCCLowIntensity, "DataCCLowIntensity");
00109
00110 NCType::Make2DDataQualityPlots(fDataQuality2DTotal, "DataTotal");
00111 NCType::Make2DDataQualityPlots(fDataQuality2DNC, "DataNC");
00112 NCType::Make2DDataQualityPlots(fDataQuality2DCC, "DataCC");
00113
00114 NCType::MakeDataQualityPlots(fDataQualityMCTotal, "MCTotal");
00115 NCType::MakeDataQualityPlots(fDataQualityMCNC, "MCNC");
00116 NCType::MakeDataQualityPlots(fDataQualityMCCC, "MCCC");
00117
00118 NCType::MakeDataQualityPlots(fDataQualityMCTotalOsc, "MCTotalOsc");
00119 NCType::MakeDataQualityPlots(fDataQualityMCNCOsc, "MCNCOsc");
00120 NCType::MakeDataQualityPlots(fDataQualityMCCCOsc, "MCCCOsc");
00121
00122 }
00123
00124
00125 NCAnalysisModule::~NCAnalysisModule()
00126 {
00127
00128 MSG("JobC", Msg::kDebug) << "NCAnalysisModule::Destructor" << endl;
00129
00130
00131 if (fHeaderInfo) delete fHeaderInfo;
00132 if (fBeamInfo) delete fBeamInfo;
00133 if (fRecoInfo) delete fRecoInfo;
00134 if (fEventInfo) delete fEventInfo;
00135 if (fShowerInfo) delete fShowerInfo;
00136 if (fTruthInfo) delete fTruthInfo;
00137 if (fTrackInfo) delete fTrackInfo;
00138
00139 if (fCuts) delete fCuts;
00140
00141 if (fUtils) delete fUtils;
00142
00143 }
00144
00145
00146 void NCAnalysisModule::BeginJob()
00147 {
00148 MSG("NCAnalysisModule", Msg::kDebug) << "start BeginJob" << endl;
00149
00150 return;
00151 }
00152
00153
00154
00155
00156 JobCResult NCAnalysisModule::Ana(const MomNavigator *mom)
00157 {
00158 MSG("NCAnalysisModule", Msg::kDebug) << "start ana" << endl;
00159
00160 JobCResult result(JobCResult::kPassed);
00161
00162
00163 assert(mom);
00164
00165 return result;
00166 }
00167
00168
00169 void NCAnalysisModule::Help()
00170 {
00171 MSG("JobC", Msg::kInfo)
00172 << "NCAnalysisModule::Help\n"
00173 <<"NCAnalysisModule is a module which analyzes beam data."
00174 << endl;
00175 }
00176
00177
00178 void NCAnalysisModule::EndJob()
00179 {
00180
00181 MakeuDST(NCType::kMC);
00182 MakeuDST(NCType::kData);
00183
00184 return;
00185 }
00186
00187
00188 void NCAnalysisModule::MakeuDST(int dataMC)
00189 {
00190 TString name = "data_" + fDataSet;
00191 bool fakeData = false;
00192 if(dataMC == NCType::kMC) name = "mc";
00193 else if(dataMC == NCType::kData && fUseMCAsData) fakeData = true;
00194
00195
00196 TChain *chain = new TChain(fTreeName);
00197
00198 TString path = "";
00199
00200
00201 if(dataMC == NCType::kMC)
00202 path = fMCPath;
00203 else{
00204 path = fDataPath;
00205 }
00206
00207 chain->Add(path);
00208
00209 MSG("NCAnalysisModule", Msg::kInfo) << "adding path " << path
00210 << " to chain" << endl;
00211
00212 MSG("NCAnalysisModule", Msg::kInfo) << "Tree Name = "
00213 << fTreeName << endl;
00214
00215 chain->SetBranchAddress("header.", &fHeaderInfo);
00216 chain->SetBranchAddress("beam.", &fBeamInfo);
00217 chain->SetBranchAddress("event.", &fEventInfo);
00218 chain->SetBranchAddress("shower.", &fShowerInfo);
00219 chain->SetBranchAddress("track.", &fTrackInfo);
00220 if(fUseMCAsData || dataMC == NCType::kMC)
00221 chain->SetBranchAddress("truth.", &fTruthInfo);
00222
00223 chain->GetEntry(0);
00224
00225
00226 MSG("NCAnalysisModule", Msg::kInfo) << "fCutSuite = " << fCutSuite << endl;
00227 if(fCutSuite == NCType::kCCCuts)
00228 fCuts = new NCAnalysisCutsCC();
00229 else if(fCutSuite == NCType::kNCCuts)
00230 fCuts = new NCAnalysisCutsNC();
00231 else if(fCutSuite == NCType::kNCCCFidCuts)
00232 fCuts = new NCAnalysisCutsNCCCFid();
00233 else if(fCutSuite == NCType::kTOCuts)
00234 fCuts = new NCAnalysisCutsTO();
00235 else if(fCutSuite == NCType::kOxCuts)
00236 fCuts = new NCAnalysisCutsOx();
00237
00238 fCuts->SetInfoObjects(fHeaderInfo, fBeamInfo, fEventInfo,
00239 fTrackInfo, fShowerInfo, fTruthInfo);
00240 fUtils->SetInfoObjects(fHeaderInfo, fBeamInfo, fEventInfo,
00241 fTrackInfo, fShowerInfo, 0, 0, fTruthInfo);
00242 fUtils->SetCutsObject(fCuts);
00243
00244
00245
00246 fUtils->SetMEGAWeightConfig(fMEGAWeightConfig);
00247
00248
00249 fCuts->SetBeamType(fBeamType);
00250
00251
00252 fCuts->SetUseAllBeams(fUseAllBeams);
00253 fCuts->SetUseAllL010z(fUseAllL010z);
00254 fCuts->SetUseAll185i(fUseAll185i);
00255
00256
00257 FillExtractionAndAnalysisVectors(dataMC);
00258
00259
00260
00261 TDirectory* saveDir = gDirectory;
00262
00263
00264 TString fileName = fFileName;
00265
00266 int pos = fileName.Index(".uDST");
00267 fileName.Insert(pos, "_"+name);
00268
00269
00270 TString stripFileName = fileName;
00271 pos = stripFileName.Index(".root");
00272 stripFileName.Insert(pos, "_strip");
00273 TFile *strippedNtpFile = new TFile(stripFileName,"RECREATE");
00274 TTree *strippedNtuple = new TTree("uDST", "Stripped AnalysisTree");
00275 strippedNtuple->Branch("header.", "ANtpHeaderInfo", &fHeaderInfo,
00276 64000, 2);
00277 if(fUseMCAsData || dataMC == NCType::kMC)
00278 strippedNtuple->Branch("truth.", "ANtpTruthInfoBeam", &fTruthInfo,
00279 64000, 2);
00280 strippedNtuple->Branch("beam.", "ANtpBeamInfo", &fBeamInfo, 64000, 2);
00281 strippedNtuple->Branch("reco.", "ANtpRecoInfo", &fRecoInfo, 64000, 2);
00282 strippedNtuple->SetDirectory(strippedNtpFile);
00283
00284
00285 for(UInt_t i = 0; i < fExtractions.size(); ++i) {
00286 string branchName = fExtractions[i]->ClassName();
00287 branchName = branchName.erase(0,12);
00288
00289 branchName = "analysis" + branchName + ".";
00290
00291
00292 MSG("NCAnalysisModule", Msg::kInfo)
00293 << "Setting " << branchName << " branch..." << endl;
00294 strippedNtuple->Branch(branchName.c_str(), "ANtpAnalysisInfo",
00295 &fAnalysisInfos[i], 64000, 2);
00296 }
00297 TTree *beamntps = new TTree("beam", "AnalysisTree");
00298 beamntps->Branch("header.", "ANtpHeaderInfo", &fHeaderInfo, 64000, 2);
00299 beamntps->Branch("beam.", "ANtpBeamInfo", &fBeamInfo, 64000, 2);
00300 beamntps->SetDirectory(strippedNtpFile);
00301
00302
00303 saveDir->cd();
00304
00305 TFile *ntpFile = new TFile(fileName,"RECREATE");
00306 TTree *ntuple = new TTree("uDST", "AnalysisTree");
00307 ntuple->Branch("header.", "ANtpHeaderInfo", &fHeaderInfo, 64000, 2);
00308 if(fUseMCAsData || dataMC == NCType::kMC)
00309 ntuple->Branch("truth.", "ANtpTruthInfoBeam", &fTruthInfo, 64000, 2);
00310 ntuple->Branch("beam.", "ANtpBeamInfo", &fBeamInfo, 64000, 2);
00311 ntuple->Branch("reco.", "ANtpRecoInfo", &fRecoInfo, 64000, 2);
00312 for(UInt_t i = 0; i < fExtractions.size(); ++i) {
00313 string branchName = fExtractions[i]->ClassName();
00314 branchName = branchName.erase(0,12);
00315
00316 branchName = "analysis" + branchName + ".";
00317
00318
00319 MSG("NCAnalysisModule", Msg::kInfo)
00320 << "Setting " << branchName << " branch..." << endl;
00321 ntuple->Branch(branchName.c_str(), "ANtpAnalysisInfo",
00322 &fAnalysisInfos[i], 64000, 2);
00323 }
00324 ntuple->SetDirectory(ntpFile);
00325 TTree *beamntp = new TTree("beam", "AnalysisTree");
00326 beamntp->Branch("header.", "ANtpHeaderInfo", &fHeaderInfo, 64000, 2);
00327 beamntp->Branch("beam.", "ANtpBeamInfo", &fBeamInfo, 64000, 2);
00328 beamntp->SetDirectory(ntpFile);
00329
00330
00331 saveDir->cd();
00332
00333 fStrippedNtpFile = strippedNtpFile;
00334 fNtpFile = ntpFile;
00335
00336 MSG("NCAnalysisModule", Msg::kInfo) << "filenames " << fileName
00337 << " " << stripFileName << endl;
00338
00339 fNtuple = ntuple;
00340 fStrippedNtuple = strippedNtuple;
00341 fBeamNtuple = beamntp;
00342 fBeamNtupleStp = beamntps;
00343
00344
00345 fDataPOTs.clear();
00346
00347
00348
00349
00350
00351 if(dataMC == NCType::kMC) PrepareForExtraction(chain);
00352 ExtractNCCC(chain, fakeData);
00353
00354 int ntupleEntries = fNtuple->GetEntries();
00355
00356
00357
00358 double mcPOT = GetTotalPOTCount(NCType::kMC);
00359 double dataPOT = GetTotalPOTCount(NCType::kData);
00360 for(int k = 0; k < static_cast<int>(fExtractions.size()); ++k){
00361 if(dataPOT > 0. && mcPOT > 0.)
00362 fExtractions[k]->SetNormalization(dataPOT/mcPOT);
00363 }
00364
00365 WriteFile(fNtpFile, fNtuple, fBeamNtuple, dataMC);
00366 WriteFile(fStrippedNtpFile, fStrippedNtuple, fBeamNtupleStp, dataMC);
00367
00368 fNtuple = 0;
00369 fStrippedNtuple = 0;
00370 fNtpFile = 0;
00371 fStrippedNtpFile = 0;
00372
00373
00374
00375 if(ntupleEntries < 1){
00376 TSystemFile ntp(fileName, "./");
00377 TSystemFile strip(stripFileName, "./");
00378
00379 ntp.Delete();
00380 strip.Delete();
00381 }
00382
00383
00384
00385
00386 delete chain;
00387
00388 return;
00389 }
00390
00391
00392 void NCAnalysisModule::FillExtractionAndAnalysisVectors(int dataMC)
00393 {
00394 MSG("NCAnalysisModule", Msg::kInfo) << "SimFlag = "
00395 << fHeaderInfo->dataType << endl;
00396 Detector::Detector_t det = Detector::kNear;
00397 if(fHeaderInfo->detector == (int)Detector::kFar) det = Detector::kFar;
00398
00399 if(dataMC == NCType::kMC){
00400 fExtractions.clear();
00401 fTOExtraction = -1;
00402 fTOmExtraction = -1;
00403
00404 if(fDoDPExtraction)
00405 fExtractions.push_back(new NCExtractionDP(fCuts, fUtils, this->GetConfig() ));
00406 if(fDoADMExtraction){
00407 fExtractions.push_back(new NCExtractionADM(fCuts, fUtils, this->GetConfig() ));
00408 fResultsADM = new NCExtractionResultsADM(det);
00409 }
00410 if(fDoTRExtraction)
00411 fExtractions.push_back(new NCExtractionTR(fCuts, fUtils, this->GetConfig() ));
00412 if(fDoTOExtraction){
00413 fTOExtraction = fExtractions.size();
00414 fExtractions.push_back(new NCExtractionTO(fCuts, fUtils, this->GetConfig() ));
00415 }
00416 if(fDoTOmExtraction){
00417 fTOmExtraction = fExtractions.size();
00418 fExtractions.push_back(new NCExtractionTOm(fCuts, fUtils, this->GetConfig() ));
00419 }
00420 if(fDoTRannExtraction)
00421 fExtractions.push_back(new NCExtractionTRann(fCuts, fUtils, this->GetConfig() ));
00422 if(fDoRPannExtraction)
00423 fExtractions.push_back(new NCExtractionRPann(fCuts, fUtils, this->GetConfig() ));
00424 if(fDoASExtraction)
00425 fExtractions.push_back(new NCExtractionAS(fCuts, fUtils, this->GetConfig() ));
00426 if(fDoNSExtraction)
00427 fExtractions.push_back(new NCExtractionNS(fCuts, fUtils, this->GetConfig() ));
00428 if(fDoKAExtraction)
00429 fExtractions.push_back(new NCExtractionKA(fCuts, fUtils, this->GetConfig() ));
00430 if(fDoKADExtraction)
00431 fExtractions.push_back(new NCExtractionKAD(fCuts, fUtils, this->GetConfig() ));
00432 if(fDoROExtraction){
00433 fExtractions.push_back(new NCExtractionRO(fCuts, fUtils, this->GetConfig() ));
00434 }
00435 if(fDoPLExtraction)
00436 fExtractions.push_back(new NCExtractionPL(fCuts, fUtils, this->GetConfig() ));
00437
00438
00439 MSG("NCAnalysisModule", Msg::kInfo)
00440 << "Using " << fExtractions.size() << " extraction methods."
00441 << " Now adding the corresponding ANtpAnalysisInfo objects..."
00442 << endl;
00443
00444 fAnalysisInfos.clear();
00445 for (uint i = 0; i < fExtractions.size(); ++i)
00446 fAnalysisInfos.push_back(new ANtpAnalysisInfo());
00447
00448
00450 int numEx = (int)fAnalysisInfos.size();
00451 TString dataType[2] = {"MC", "Data"};
00452 TString label = "";
00453 for(int i = 0; i < 2; ++i){
00454 fNCLikeNumerator.push_back(new TH2D("ncLikeNumerator"+dataType[i], "",
00455 numEx, 0., 1.*numEx, numEx, 0., 1.*numEx));
00456 fNCLikeDenominator.push_back(new TH2D("ncLikeDenominator"+dataType[i], "",
00457 numEx, 0., 1.*numEx, numEx, 0., 1.*numEx));
00458 fNCLikeCorrelation.push_back(new TH2D("ncLikeCorrelation"+dataType[i], "",
00459 numEx, 0., 1.*numEx, numEx, 0., 1.*numEx));
00460 fNCLikeHist.push_back(new TH1D("ncLike"+dataType[i], "", numEx+1, 0., 1.*(numEx+1)));
00461 fNCLikeHist[i]->SetXTitle("# Methods");
00462 fNCLikeHist[i]->SetYTitle("# Events");
00463
00464 fCCLikeNumerator.push_back(new TH2D("ccLikeNumerator"+dataType[i], "",
00465 numEx, 0., 1.*numEx, numEx, 0., 1.*numEx));
00466 fCCLikeDenominator.push_back(new TH2D("ccLikeDenominator"+dataType[i], "",
00467 numEx, 0., 1.*numEx, numEx, 0., 1.*numEx));
00468 fCCLikeCorrelation.push_back(new TH2D("ccLikeCorrelation"+dataType[i], "",
00469 numEx, 0., 1.*numEx, numEx, 0., 1.*numEx));
00470 fCCLikeHist.push_back(new TH1D("ccLike"+dataType[i], "", numEx+1, 0., 1.*(numEx+1)));
00471 fCCLikeHist[i]->SetXTitle("# Methods");
00472 fCCLikeHist[i]->SetYTitle("# Events");
00473
00474 if(i == 0){
00475 fNCLikeNumeratorTrue = new TH2D("ncLikeNumeratorTrue", "",
00476 numEx, 0., 1.*numEx, numEx, 0., 1.*numEx);
00477 fNCLikeDenominatorTrue = new TH2D("ncLikeDenominatorTrue", "",
00478 numEx, 0., 1.*numEx, numEx, 0., 1.*numEx);
00479 fNCLikeCorrelationTrue = new TH2D("ncLikeCorrelationTrue"+dataType[i], "",
00480 numEx, 0., 1.*numEx, numEx, 0., 1.*numEx);
00481
00482 fCCLikeNumeratorTrue = new TH2D("ccLikeNumeratorTrue", "",
00483 numEx, 0., 1.*numEx, numEx, 0., 1.*numEx);
00484 fCCLikeDenominatorTrue = new TH2D("ccLikeDenominatorTrue", "",
00485 numEx, 0., 1.*numEx, numEx, 0., 1.*numEx);
00486 fCCLikeCorrelationTrue = new TH2D("ccLikeCorrelationTrue"+dataType[i], "",
00487 numEx, 0., 1.*numEx, numEx, 0., 1.*numEx);
00488 }
00489
00490 for(int x = 0; x < numEx; ++x){
00491
00492 label = fExtractions[x]->ClassName();
00493 label.Remove(0,12);
00494 fNCLikeDenominator[i]->GetXaxis()->SetBinLabel(x+1, label);
00495 fNCLikeNumerator[i]->GetXaxis()->SetBinLabel(x+1, label);
00496 fNCLikeCorrelation[i]->GetXaxis()->SetBinLabel(x+1, label);
00497 fNCLikeDenominator[i]->GetYaxis()->SetBinLabel(x+1, label);
00498 fNCLikeNumerator[i]->GetYaxis()->SetBinLabel(x+1, label);
00499 fNCLikeCorrelation[i]->GetYaxis()->SetBinLabel(x+1, label);
00500
00501 fCCLikeDenominator[i]->GetXaxis()->SetBinLabel(x+1, label);
00502 fCCLikeNumerator[i]->GetXaxis()->SetBinLabel(x+1, label);
00503 fCCLikeCorrelation[i]->GetXaxis()->SetBinLabel(x+1, label);
00504 fCCLikeDenominator[i]->GetYaxis()->SetBinLabel(x+1, label);
00505 fCCLikeNumerator[i]->GetYaxis()->SetBinLabel(x+1, label);
00506 fCCLikeCorrelation[i]->GetYaxis()->SetBinLabel(x+1, label);
00507 if(i == 0){
00508 fNCLikeDenominatorTrue->GetXaxis()->SetBinLabel(x+1, label);
00509 fNCLikeNumeratorTrue->GetXaxis()->SetBinLabel(x+1, label);
00510 fNCLikeCorrelationTrue->GetXaxis()->SetBinLabel(x+1, label);
00511 fNCLikeDenominatorTrue->GetYaxis()->SetBinLabel(x+1, label);
00512 fNCLikeNumeratorTrue->GetYaxis()->SetBinLabel(x+1, label);
00513 fNCLikeCorrelationTrue->GetYaxis()->SetBinLabel(x+1, label);
00514
00515 fCCLikeDenominatorTrue->GetXaxis()->SetBinLabel(x+1, label);
00516 fCCLikeNumeratorTrue->GetXaxis()->SetBinLabel(x+1, label);
00517 fCCLikeCorrelationTrue->GetXaxis()->SetBinLabel(x+1, label);
00518 fCCLikeDenominatorTrue->GetYaxis()->SetBinLabel(x+1, label);
00519 fCCLikeNumeratorTrue->GetYaxis()->SetBinLabel(x+1, label);
00520 fCCLikeCorrelationTrue->GetYaxis()->SetBinLabel(x+1, label);
00521 }
00522 }
00523
00524
00525 }
00526
00527 }
00528 else{
00529
00530 if(fExtractions.size() < 1)
00531 MSG("NCAnalysisModule", Msg::kWarning)
00532 << "trying to reset extraction objects"
00533 << " in vector with no entries."
00534 << " must fill mc first" << endl;
00535
00536
00537
00538 for(uint i = 0; i < fExtractions.size(); ++i)
00539 fExtractions[i]->ResetHistograms(NCType::kData);
00540
00541
00542 fNCLikeHist[NCType::kData]->Reset();
00543 fNCLikeNumerator[NCType::kData]->Reset();
00544 fNCLikeDenominator[NCType::kData]->Reset();
00545 fNCLikeCorrelation[NCType::kData]->Reset();
00546 fCCLikeHist[NCType::kData]->Reset();
00547 fCCLikeNumerator[NCType::kData]->Reset();
00548 fCCLikeDenominator[NCType::kData]->Reset();
00549 fCCLikeCorrelation[NCType::kData]->Reset();
00550 }
00551
00552 return;
00553 }
00554
00555
00556 const Registry& NCAnalysisModule::DefaultConfig() const
00557 {
00558
00559 int itrue = 1;
00560 int ifalse = 0;
00561
00562 static Registry r;
00563
00564 r.UnLockValues();
00565
00566 r.Set("FileName", "ncccSeparation.root");
00567 r.Set("TreeName", "antp");
00568 r.Set("MCPath", "mcFiles/*.root");
00569 r.Set("DataPath", "dataFiles/*.root");
00570 r.Set("PDFPath", "DP_histos_far.root");
00571 r.Set("FillNtuples", ifalse);
00572 r.Set("ReadPDFs", ifalse);
00573 r.Set("UseMCAsData", itrue);
00574 r.Set("BeamType", "L010z185i");
00575 r.Set("UseAllBeams", ifalse);
00576 r.Set("UseAllL010z", ifalse);
00577 r.Set("UseAll185i", ifalse);
00578 r.Set("DoDPExtraction", itrue);
00579 r.Set("DoADMExtraction", ifalse);
00580 r.Set("DoTOExtraction", ifalse);
00581 r.Set("DoTOmExtraction", ifalse);
00582 r.Set("DoTRExtraction", ifalse);
00583 r.Set("DoTRannExtraction", ifalse);
00584 r.Set("DoASExtraction", ifalse);
00585 r.Set("DoNSExtraction", ifalse);
00586 r.Set("DoKAExtraction", ifalse);
00587 r.Set("DoKADExtraction", ifalse);
00588 r.Set("DoROExtraction", ifalse);
00589 r.Set("DoRPannExtraction", ifalse);
00590 r.Set("DoPLExtraction", ifalse);
00591 r.Set("RPAnnUseLowETrain", ifalse);
00592 r.Set("NDSubRunToUse", 6);
00593 r.Set("FileCountLimit", 1000000000);
00594 r.Set("DataSet", "/");
00595 r.Set("CutSuite", NCType::kCCCuts);
00596 r.Set("MEGAWeightConfig", "Boston");
00597 r.Set("AnnNSPrior", 1);
00598 r.Set("AnnNSFiducial", 1);
00599 r.Set("CountChainEntries", itrue);
00600 r.LockValues();
00601 return r;
00602 }
00603
00604
00605 void NCAnalysisModule::Config(const Registry& r)
00606 {
00607 int tmpb;
00608 int tmpi;
00609 double tmpd;
00610 const char* tmps;
00611
00612 if (r.Get("FileName", tmps)) fFileName = tmps;
00613 if (r.Get("TreeName", tmps)) fTreeName = tmps;
00614 if (r.Get("MCPath", tmps)) fMCPath = tmps;
00615 if (r.Get("DataPath", tmps)) fDataPath = tmps;
00616 if (r.Get("FillNtuples", tmpb)) fFillNtuples = tmpb;
00617 if (r.Get("UseMCAsData", tmpb)) fUseMCAsData = tmpb;
00618 if (r.Get("BeamType", tmps)) fBeamType = BeamType::TagToEnum(tmps);
00619 if (r.Get("UseAllBeams", tmpb)) fUseAllBeams = tmpb;
00620 if (r.Get("UseAllL010z", tmpb)) fUseAllL010z = tmpb;
00621 if (r.Get("UseAll185i", tmpb)) fUseAll185i = tmpb;
00622 if (r.Get("DoDPExtraction", tmpb)) fDoDPExtraction = tmpb;
00623 if (r.Get("DoADMExtraction", tmpb)) fDoADMExtraction = tmpb;
00624 if (r.Get("DoTOExtraction" ,tmpb)) fDoTOExtraction = tmpb;
00625 if (r.Get("DoTOmExtraction" ,tmpb)) fDoTOmExtraction = tmpb;
00626 if (r.Get("DoTRExtraction" ,tmpb)) fDoTRExtraction = tmpb;
00627 if (r.Get("DoTRannExtraction",tmpb)) fDoTRannExtraction = tmpb;
00628 if (r.Get("DoASExtraction", tmpb)) fDoASExtraction = tmpb;
00629 if (r.Get("DoNSExtraction", tmpb)) fDoNSExtraction = tmpb;
00630 if (r.Get("DoKAExtraction", tmpb)) fDoKAExtraction = tmpb;
00631 if (r.Get("DoKADExtraction", tmpb)) fDoKADExtraction = tmpb;
00632 if (r.Get("DoROExtraction", tmpb)) fDoROExtraction = tmpb;
00633 if (r.Get("DoPLExtraction", tmpb)) fDoPLExtraction = tmpb;
00634 if (r.Get("DoRPannExtraction",tmpb)) fDoRPannExtraction = tmpb;
00635 if (r.Get("CutSuite", tmpi)) fCutSuite = tmpi;
00636 if (r.Get("MEGAWeightConfig", tmps)) fMEGAWeightConfig = tmps;
00637 if (r.Get("NDSubRunToUse", tmpi)) fNDSubRunToUse = tmpi;
00638 if (r.Get("FileCountLimit", tmpi)) fFileCountLimit = tmpi;
00639 if (r.Get("CountChainEntries",tmpb)) fCountChainEntries = tmpb;
00640 if (r.Get("DataSet", tmps)){
00641 fDataSet = tmps;
00642 fDataSet.Remove(TString::kLeading, '/');
00643 }
00644
00645 tmpd = 0.;
00646
00647 return;
00648 }
00649
00650
00651
00652
00653
00654 void NCAnalysisModule::PrepareForExtraction(TChain *chain)
00655 {
00656 MSG("NCAnalysisModule", Msg::kInfo) << "PrepareForExtraction "
00657 << chain->GetName() << endl;
00658
00659
00660 for(uint i = 0; i < fExtractions.size(); ++i)
00661 fExtractions[i]->Prepare();
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721 return;
00722 }
00723
00724
00725
00726
00727 void NCAnalysisModule::ExtractNCCC(TChain *chain, bool fakeData)
00728 {
00729
00730 MSG("NCAnalysisModule", Msg::kInfo) << "ExtractNCCC" << endl;
00731
00732 int ctr = 0;
00733 int passSnarl = 0;
00734 int passEvt = 0;
00735 int passFid = 0;
00736 bool passCut1 = false;
00737 bool passCut2 = false;
00738 bool passCut3 = false;
00739 bool newSnarl = false;
00740
00741 int fileCtr = 0;
00742 int prevRun = -1;
00743 int prevSubRun = -1;
00744 int tot = fFileCountLimit;
00745 if(fCountChainEntries) tot = chain->GetEntries();
00746
00747 chain->GetEntry(0);
00748
00749 Detector::Detector_t detType = Detector::kUnknown;
00750 if(fHeaderInfo->detector == static_cast<int>(Detector::kFar))
00751 detType = Detector::kFar;
00752 if(fHeaderInfo->detector == static_cast<int>(Detector::kNear))
00753 detType = Detector::kNear;
00754
00755 int dataMC = NCType::kMC;
00756 if(fHeaderInfo->dataType == (int)SimFlag::kMC){
00757 const char* mcString = (fHeaderInfo->softVersion).Data();
00758 ReleaseType::Release_t mcType=ReleaseType::StringToType(mcString);
00759 if (mcType==ReleaseType::kUnknown) {
00760 MSG("NCAnalysisModule",Msg::kWarning)
00761 << "Can't figure out MC version, defaulting to carrot.\n";
00762 mcType = ReleaseType::kCarrot;
00763 }
00764
00765 fMCPOTPerSnarl = MCInfo::GetMCPoT(detType,fBeamType,mcType);
00766 if(fHeaderInfo->dataType == (int)SimFlag::kMC)
00767 MSG("NCAnalysisModule",Msg::kInfo) << "MC POT per snarl: "
00768 << fMCPOTPerSnarl << endl;
00769 }
00770 if(fakeData || fHeaderInfo->dataType == (int)SimFlag::kData){
00771 dataMC = NCType::kData;
00772 tot = 100000;
00773 }
00774
00775 double multiplicityNC[kNumEventsVsPOT] = {0.};
00776 double multiplicityCC[kNumEventsVsPOT] = {0.};
00777 double prevPOT = 0.;
00778
00779 while( chain->GetEntry(ctr) && fileCtr < tot){
00780 if(ctr % 20000 == 0)
00781 MSG("NCAnalysisModule", Msg::kInfo)
00782 << "On " << ctr << " / " << tot << " file " << fileCtr << endl;
00783
00784 ++ctr;
00785
00786 if(fHeaderInfo->run != prevRun || fHeaderInfo->subRun != prevSubRun){
00787 prevRun = fHeaderInfo->run;
00788 prevSubRun = fHeaderInfo->subRun;
00789 ++fileCtr;
00790 }
00791
00792 if(fHeaderInfo->newSnarl > 0
00793 && fHeaderInfo->dataType == (int)SimFlag::kData
00794 && detType == Detector::kNear){
00795 for(uint i = 0; i < fDataQuality2DTotal.size(); ++i){
00796 fDataQuality2DTotal[i]->Fill(prevPOT, multiplicityCC[i]+multiplicityNC[i]);
00797 fDataQuality2DNC[i]->Fill(prevPOT, multiplicityNC[i]);
00798 multiplicityNC[i] = 0.;
00799 fDataQuality2DCC[i]->Fill(prevPOT, multiplicityCC[i]);
00800 multiplicityCC[i] = 0.;
00801 }
00802 prevPOT = 0.;
00803 }
00804
00805 if(fHeaderInfo->dataType == (int)SimFlag::kData){
00806 fTruthInfo = 0;
00807
00808
00809
00810
00811 fBeamInfo->protonIntensity = fBeamInfo->tortgt;
00812 if(fBeamInfo->tortgt <= 0.0) fBeamInfo->protonIntensity = fBeamInfo->trtgtd;
00813 else if(fBeamInfo->trtgtd <= 0.0) fBeamInfo->protonIntensity = fBeamInfo->tor101;
00814
00815 if(!NCType::IsNDRunGood(fHeaderInfo->run, fHeaderInfo->subRun)) continue;
00816 }
00817
00818 else if(fHeaderInfo->dataType == (int)SimFlag::kMC){
00819 fBeamInfo->beamType = BeamType::ToZarko(fBeamType);
00820 fBeamInfo->protonIntensity = fMCPOTPerSnarl;
00821 }
00822 prevPOT = fBeamInfo->protonIntensity;
00823
00824
00825 fCuts->SetInfoObjects(fHeaderInfo, fBeamInfo, fEventInfo,
00826 fTrackInfo, fShowerInfo, fTruthInfo);
00827 fUtils->SetInfoObjects(fHeaderInfo, fBeamInfo, fEventInfo,
00828 fTrackInfo, fShowerInfo, 0, 0, fTruthInfo);
00829
00830 newSnarl = fCuts->IsNewSnarl();
00831
00832 if (passCut1 = (fCuts->IsGoodBeamSnarl()) ) passSnarl++;
00833 if (passCut2 = (fCuts->IsGoodBeamEvent() && passCut1) ) passEvt++;
00834 if (passCut3 = (fCuts->InBeamFiducialVolume() && passCut2)) passFid++;
00835
00836 if( newSnarl && passCut1 ){
00837 CountPOTs(fakeData);
00838 AddToNtuple(newSnarl);
00839 }
00840
00841 if (!passCut2) continue;
00842
00843 FillRecoInfo(fRecoInfo, fHeaderInfo,
00844 fEventInfo, fShowerInfo,
00845 fTrackInfo, fBeamInfo, fCuts,
00846 fUtils, fBeamInfo->beamType);
00847
00848 for(uint i = 0; i < fExtractions.size(); ++i)
00849 fExtractions[i]->DoExtraction(fAnalysisInfos[i], fRecoInfo,
00850 fHeaderInfo, fEventInfo,
00851 fShowerInfo, fTrackInfo,
00852 fTruthInfo, fBeamInfo->beamType);
00853
00854 AddToNtuple();
00855
00856 if(fHeaderInfo->dataType == (int)SimFlag::kData
00857 && detType == Detector::kNear
00858 && fRecoInfo->inFiducialVolume > 0
00859 && fTOmExtraction >= 0){
00860 if(fAnalysisInfos[fTOmExtraction]->isNC > 0
00861 && fRecoInfo->isCleanHighMultSnarl > 0){
00862 if(fRecoInfo->nuEnergy < 0.5) multiplicityNC[kLT05GeV] += 1.;
00863 else if(fRecoInfo->nuEnergy < 1.0) multiplicityNC[kLT1GeV] += 1.;
00864 else if(fRecoInfo->nuEnergy > 1.0) multiplicityNC[kGT1GeV] += 1.;
00865 multiplicityNC[kAllGeV] += 1.;
00866 }
00867 if(fAnalysisInfos[fTOmExtraction]->isCC > 0){
00868 if(fRecoInfo->nuEnergy < 0.5) multiplicityCC[kLT05GeV] += 1.;
00869 else if(fRecoInfo->nuEnergy < 1.0) multiplicityCC[kLT1GeV] += 1.;
00870 else if(fRecoInfo->nuEnergy > 1.0) multiplicityCC[kGT1GeV] += 1.;
00871 multiplicityCC[kAllGeV] += 1.;
00872 }
00873 }
00874
00875
00876 if( fCuts->PassesFinalSelection(fRecoInfo) ) FindCorrelations(dataMC);
00877
00878 }
00879
00880
00881
00882
00883
00884 MSG("NCAnalysisModule", Msg::kInfo)
00885 << passSnarl << "/" << ctr << " passed IsGoodBeamSnarl()\n"
00886 << passEvt << "/" << passSnarl << " passed IsGoodBeamEvent()\n"
00887 << passFid << "/" << passEvt << " passed fiducial cuts"
00888 << endl;
00889
00890 return;
00891 }
00892
00893
00894 void NCAnalysisModule::AddToNtuple(bool beam)
00895 {
00896
00897
00898
00899 if(beam){
00900 if(fNtpFile->GetSize() < 1850400000)
00901 fBeamNtuple->Fill();
00902 if(fStrippedNtpFile->GetSize() < 1850400000)
00903 fBeamNtupleStp->Fill();
00904 }
00905
00906 else{
00907
00908 if(fNtpFile->GetSize() < 1850400000)
00909 fNtuple->Fill();
00910 else{
00911 MAXMSG("NCAnalysisModule", Msg::kWarning,1)
00912 << "Size limit exceeded no longer filling full ntuple" << endl;
00913 }
00914
00915 if( fCuts->PassesFinalSelection(fRecoInfo) ){
00916 if(fStrippedNtpFile->GetSize() < 1850400000)
00917 fStrippedNtuple->Fill();
00918 else{
00919 MAXMSG("NCAnalysisModule", Msg::kWarning,1)
00920 << "Size limit exceeded no longer filling stripped ntuple"
00921 << endl;
00922 }
00923
00924 ANtpAnalysisInfo *ana = 0;
00925 if(fTOmExtraction >= 0){
00926 ana = fAnalysisInfos[fTOmExtraction];
00927 if( fUtils->FinalEventCheck(ana, fRecoInfo) ){
00928 if(fHeaderInfo->dataType == (int)SimFlag::kData){
00929 FillDataQualityPlots(fDataQualityTotal, NCType::kUnknown, false);
00930 if(ana->isNC > 0)
00931 FillDataQualityPlots(fDataQualityNC, NCType::kNC, false);
00932 else if(ana->isCC > 0)
00933 FillDataQualityPlots(fDataQualityCC, NCType::kCC, false);
00934 if(fBeamInfo->protonIntensity < 4.){
00935 FillDataQualityPlots(fDataQualityTotalLowIntensity, NCType::kUnknown, false);
00936 if(ana->isNC > 0)
00937 FillDataQualityPlots(fDataQualityNCLowIntensity, NCType::kNC, false);
00938 else if(ana->isCC > 0)
00939 FillDataQualityPlots(fDataQualityCCLowIntensity, NCType::kCC, false);
00940 }
00941 }
00942 else if(fHeaderInfo->dataType == (int)SimFlag::kMC){
00943 FillDataQualityPlots(fDataQualityMCTotal, NCType::kUnknown, false);
00944 FillDataQualityPlots(fDataQualityMCTotalOsc, NCType::kUnknown, true);
00945 if(fHeaderInfo->detector == (int)Detector::kFar){
00946 if(ana->isNC > 0){
00947 FillDataQualityPlots(fDataQualityMCNC, NCType::kNC, false);
00948 FillDataQualityPlots(fDataQualityMCNCOsc, NCType::kNC, true);
00949 }
00950 else if(ana->isCC > 0){
00951 FillDataQualityPlots(fDataQualityMCCC, NCType::kCC, false);
00952 FillDataQualityPlots(fDataQualityMCCCOsc, NCType::kCC, true);
00953 }
00954 }
00955 else{
00956 FillDataQualityPlots(fDataQualityMCNC, NCType::kNC, false);
00957 FillDataQualityPlots(fDataQualityMCNCOsc, NCType::kNC, true);
00958 FillDataQualityPlots(fDataQualityMCCC, NCType::kCC, false);
00959 FillDataQualityPlots(fDataQualityMCCCOsc, NCType::kCC, true);
00960 }
00961 }
00962 }
00963 }
00964 }
00965 }
00966 return;
00967 }
00968
00969
00970 void NCAnalysisModule::FillDataQualityPlots(std::vector<TH1D *> &dq,
00971 int nccc,
00972 bool osc)
00973 {
00974
00975 if(fRecoInfo->inFiducialVolume < 1) return;
00976
00977 double weight = fRecoInfo->weight;
00978 if(NCType::FindRunType(fHeaderInfo) == NCType::kRunII){
00979 weight = fRecoInfo->weightRunII;
00980 }
00981
00982 double trackExtension = -1.*fRecoInfo->trackExtension;
00983 double month = (1.*fHeaderInfo->month-4.5)+12.*(fHeaderInfo->year-2005);
00984 double showerEnergy = fRecoInfo->showerEnergyNC;
00985 double energy = fRecoInfo->nuEnergyNC;
00986 if(nccc == NCType::kNC){
00987
00988
00989
00990 if(fHeaderInfo->detector == (int)Detector::kNear
00991 && fHeaderInfo->dataType == (int)SimFlag::kMC
00992 && fTruthInfo->interactionType == NCType::kCC) return;
00993 }
00994 else if(nccc == NCType::kCC){
00995 showerEnergy = fRecoInfo->showerEnergyCC;
00996 energy = fRecoInfo->nuEnergyCC;
00997
00998
00999
01000 if(fHeaderInfo->detector == (int)Detector::kNear
01001 && fHeaderInfo->dataType == (int)SimFlag::kMC
01002 && fTruthInfo->interactionType == NCType::kNC) return;
01003 }
01004
01005 VldTimeStamp ts(fHeaderInfo->year, fHeaderInfo->month, fHeaderInfo->day,
01006 fHeaderInfo->hour, fHeaderInfo->minute, (int)fHeaderInfo->second);
01007
01008 double deltaT = 0.;
01009 if(fHeaderInfo->detector == (int)Detector::kFar){
01010 if(fHeaderInfo->dataType == (int)SimFlag::kMC && osc){
01011 vector<double> oscPars;
01012 oscPars.push_back(0.25*TMath::Pi());
01013 oscPars.push_back(2.38e-3);
01014 oscPars.push_back(0.);
01015 oscPars.push_back(0.61);
01016 oscPars.push_back(7.59e-5);
01017 oscPars.push_back(2.7);
01018 oscPars.push_back(0.);
01019 oscPars.push_back(1.);
01020
01021 weight *= fUtils->Find3FlavorProbability(NCType::kNuMuToNuMu,
01022 fTruthInfo->interactionType,
01023 NCType::kBaseLineFar,
01024 fTruthInfo->nuEnergy,
01025 oscPars);
01026 }
01027 else if(fHeaderInfo->dataType == (int)SimFlag::kData){
01028 deltaT = 1.e6*(fEventInfo->stripTime1st-1.e-9*fBeamInfo->nearestNSToSpill);
01029 fVtxX.push_back(fRecoInfo->vtxX);
01030 fVtxY.push_back(fRecoInfo->vtxY);
01031 }
01032 }
01033
01034 if(fHeaderInfo->detector == (int)Detector::kNear
01035 && fRecoInfo->isCleanHighMultSnarl < 1 ) return;
01036
01037 dq[NCType::kDQVtxX]->Fill(fRecoInfo->vtxX, weight);
01038 dq[NCType::kDQVtxY]->Fill(fRecoInfo->vtxY, weight);
01039 dq[NCType::kDQVtxZ]->Fill(fRecoInfo->vtxZ, weight);
01040 dq[NCType::kDQEventLength]->Fill(fRecoInfo->eventLength, weight);
01041 dq[NCType::kDQNumTracks]->Fill(fRecoInfo->numberTracks, weight);
01042 dq[NCType::kDQShowerE]->Fill(showerEnergy, weight);
01043 dq[NCType::kDQTrackMomentum]->Fill(fRecoInfo->trackMomentum, weight);
01044 dq[NCType::kDQEventsVsTime]->Fill(month);
01045 dq[NCType::kDQRadialVtx]->Fill(TMath::Sqrt(TMath::Power(fRecoInfo->vtxX, 2.)
01046 + TMath::Power(fRecoInfo->vtxY, 2.)), weight);
01047 dq[NCType::kDQRadialSqrVtx]->Fill(TMath::Power(fRecoInfo->vtxX, 2.)
01048 + TMath::Power(fRecoInfo->vtxY, 2.), weight);
01049 if(fHeaderInfo->newSnarl > 0)
01050 dq[NCType::kDQEventsPerSnarl]->Fill(fHeaderInfo->events);
01051 dq[NCType::kDQPHFraction]->Fill(fEventInfo->pulseHeight/fHeaderInfo->snarlPulseHeight, weight);
01052 dq[NCType::kDQDeltaTSpill]->Fill(deltaT, weight);
01053 dq[NCType::kDQAvStripsPerPlane]->Fill(fEventInfo->totalStrips/TMath::Power(fEventInfo->planes,2.), weight);
01054 if(fEventInfo->showers > 0.)
01055 dq[NCType::kDQTransverseRMS]->Fill(TMath::Sqrt(TMath::Power(fShowerInfo->transverseRMSU,2.)
01056 +TMath::Power(fShowerInfo->transverseRMSV,2.)),
01057 weight);
01058
01059 if(fEventInfo->tracks > 0.){
01060 dq[NCType::kDQTrackDCosZVtx]->Fill(fTrackInfo->dcosZVtx, weight);
01061 dq[NCType::kDQTrackDCosYVtx]->Fill(fTrackInfo->dcosYVtx, weight);
01062 dq[NCType::kDQTrackEndZ]->Fill(fTrackInfo->endZ, weight);
01063 dq[NCType::kDQTrackEndY]->Fill(fTrackInfo->endY, weight);
01064 dq[NCType::kDQEndMetersToEdge]->Fill(fTrackInfo->endMetersToCloseEdge, weight);
01065 }
01066 if(fRecoInfo->numberTracks > 0 && fEventInfo->showers > 0.)
01067 dq[NCType::kDQTrackExtension]->Fill(trackExtension, weight);
01068
01069 dq[NCType::kDQTotalStrips]->Fill(fEventInfo->totalStrips, weight);
01070 dq[NCType::kDQPulseHeight]->Fill(1.e-3*fEventInfo->pulseHeight, weight);
01071
01072
01073 dq[NCType::kDQEnergy]->Fill(energy, weight);
01074
01075
01076 if(fRecoInfo->vtxX > 1.5 && fRecoInfo->vtxY > 0.)
01077 dq[NCType::kDQEnergyQ1]->Fill(energy, weight);
01078 else if(fRecoInfo->vtxX < 1.5 && fRecoInfo->vtxY > 0.)
01079 dq[NCType::kDQEnergyQ2]->Fill(energy, weight);
01080 else if(fRecoInfo->vtxX < 1.5 && fRecoInfo->vtxY < 0.)
01081 dq[NCType::kDQEnergyQ3]->Fill(energy, weight);
01082 else if(fRecoInfo->vtxX > 1.5 && fRecoInfo->vtxY < 0.)
01083 dq[NCType::kDQEnergyQ4]->Fill(energy, weight);
01084
01085
01086 if(fRecoInfo->vtxZ > 1.73 && fRecoInfo->vtxZ < 2.73)
01087 dq[NCType::kDQEnergyZ1]->Fill(energy, weight);
01088 else if(fRecoInfo->vtxZ > 2.73 && fRecoInfo->vtxZ < 3.73)
01089 dq[NCType::kDQEnergyZ2]->Fill(energy, weight);
01090 else if(fRecoInfo->vtxZ > 3.73 && fRecoInfo->vtxZ < 4.73)
01091 dq[NCType::kDQEnergyZ3]->Fill(energy, weight);
01092
01093
01094 if(TMath::Sqrt(TMath::Power(fRecoInfo->vtxX-1.4885, 2.)
01095 + TMath::Power(fRecoInfo->vtxY-0.1397, 2.)) < 0.5)
01096 dq[NCType::kDQEnergyA1]->Fill(energy, weight);
01097 else if(TMath::Sqrt(TMath::Power(fRecoInfo->vtxX-1.4885, 2.)
01098 + TMath::Power(fRecoInfo->vtxY-0.1397, 2.)) > 0.5)
01099 dq[NCType::kDQEnergyA2]->Fill(energy, weight);
01100
01101 return;
01102 }
01103
01104
01105 void NCAnalysisModule::FindCorrelations(int dataMC)
01106 {
01107
01108
01109
01110 int ncLike = 0;
01111 int ccLike = 0;
01112 vector<bool> isNCLike;
01113 vector<bool> isCCLike;
01114 for(uint i = 0; i < fAnalysisInfos.size(); ++i){
01115 isNCLike.push_back((bool)fAnalysisInfos[i]->isNC);
01116 isCCLike.push_back((bool)fAnalysisInfos[i]->isCC);
01117 ncLike += fAnalysisInfos[i]->isNC;
01118 ccLike += fAnalysisInfos[i]->isCC;
01119 }
01120
01121 fNCLikeHist[dataMC]->Fill(ncLike*1. + 0.5);
01122 fCCLikeHist[dataMC]->Fill(ccLike*1. + 0.5);
01123
01124
01125
01126
01127 int numX = fNCLikeDenominator[dataMC]->GetXaxis()->GetNbins();
01128 int numY = fNCLikeDenominator[dataMC]->GetYaxis()->GetNbins();
01129
01130
01131 if(numX != numY || numX != (int)isNCLike.size()){
01132 MSG("NCAnalysisModule", Msg::kWarning) << "cant do correlations"
01133 << " " << numX << " "
01134 << numY << " " << isNCLike.size()
01135 << " - bail" << endl;
01136 return;
01137 }
01138
01139 for(int x = 0; x < numX; ++x){
01140 for(int y = 0; y < numY; ++y){
01141
01142 if(isNCLike[x]){
01143 fNCLikeDenominator[dataMC]->Fill(x*1.+0.5, y*1.+0.5);
01144 if(isNCLike[y]) fNCLikeNumerator[dataMC]->Fill(x*1.+0.5, y*1.+0.5);
01145
01146 if(dataMC == NCType::kMC
01147 && fTruthInfo->interactionType == NCType::kNC){
01148 fNCLikeDenominatorTrue->Fill(x*1.+0.5, y*1.+0.5);
01149 if(isNCLike[y]) fNCLikeNumeratorTrue->Fill(x*1.+0.5, y*1.+0.5);
01150 }
01151 if(dataMC == NCType::kMC
01152 && fTruthInfo->interactionType == NCType::kCC){
01153 fCCLikeDenominatorTrue->Fill(x*1.+0.5, y*1.+0.5);
01154 if(isNCLike[y]) fCCLikeNumeratorTrue->Fill(x*1.+0.5, y*1.+0.5);
01155 }
01156 }
01157
01158 if(isCCLike[x]){
01159 fCCLikeDenominator[dataMC]->Fill(x*1.+0.5, y*1.+0.5);
01160 if(isCCLike[y]) fCCLikeNumerator[dataMC]->Fill(x*1.+0.5, y*1.+0.5);
01161
01162 }
01163
01164 }
01165 }
01166
01167 return;
01168 }
01169
01170
01171 void NCAnalysisModule::CountPOTs(bool fakeData)
01172 {
01173 map<int, double>::iterator dataItr = fDataPOTs.begin();
01174 map<int, double>::iterator mcItr = fMCPOTs.begin();
01175 int run = 100*fHeaderInfo->run + fHeaderInfo->subRun;
01176 if(fHeaderInfo->dataType == (int)SimFlag::kData){
01177 dataItr = fDataPOTs.find(run);
01178 if( dataItr != fDataPOTs.end() )
01179 fDataPOTs[run] += fBeamInfo->protonIntensity;
01180 else
01181 fDataPOTs[run] = fBeamInfo->protonIntensity;
01182
01183 double month = (1.*fHeaderInfo->month-4.5)+12.*(fHeaderInfo->year-2005);
01184 fDataQualityTotal[NCType::kDQPOTVsTime]->Fill(month, fBeamInfo->protonIntensity);
01185 fDataQualityCC[NCType::kDQPOTVsTime]->Fill(month, fBeamInfo->protonIntensity);
01186 fDataQualityNC[NCType::kDQPOTVsTime]->Fill(month, fBeamInfo->protonIntensity);
01187 }
01188 else if(fakeData){
01189
01190 dataItr = fDataPOTs.find(run);
01191
01192
01193 if( dataItr != fDataPOTs.end()
01194 && fHeaderInfo->detector == (int)Detector::kNear){
01195 MAXMSG("NCAnalysisModule", Msg::kDebug, 100)
01196 << "data " << fMCPOTPerSnarl << " "
01197 << fHeaderInfo->run << " " << fHeaderInfo->subRun
01198 << " " << run << " " << fDataPOTs[run] << endl;
01199 fDataPOTs[run] += fMCPOTPerSnarl;
01200 MAXMSG("NCAnalysisModule", Msg::kDebug, 100)
01201 << fDataPOTs[run] << endl;
01202 }
01203 else
01204 fDataPOTs[run] = fMCPOTPerSnarl;
01205 }
01206 else if(fHeaderInfo->dataType == (int)SimFlag::kMC){
01207
01208 mcItr = fMCPOTs.find(run);
01209 if( mcItr != fMCPOTs.end()
01210 && fHeaderInfo->detector == (int)Detector::kNear){
01211 MAXMSG("NCAnalysisModule", Msg::kDebug,100)
01212 << "mc " << fMCPOTPerSnarl << " "
01213 << fHeaderInfo->run << " "
01214 << fMCPOTs[run] << endl;
01215 fMCPOTs[run] += fMCPOTPerSnarl;
01216 MAXMSG("NCAnalysisModule", Msg::kDebug,100)
01217 << fMCPOTs[run] << endl;
01218 }
01219 else
01220 fMCPOTs[run] = fMCPOTPerSnarl;
01221 MAXMSG("NCAnalysisModule", Msg::kDebug,100)
01222 << fMCPOTs[run] << endl;
01223 }
01224
01225 return;
01226 }
01227
01228
01229 void NCAnalysisModule::WritePOTInfo(int dataMC)
01230 {
01231 if(fDataPOTs.size() != 0 && dataMC == NCType::kData){
01232 int firstDataRun = fDataPOTs.begin()->first;
01233
01234 int lastDataRun = fDataPOTs.rbegin()->first;
01235 TH1F *dataPOT = new TH1F("dataPOT", "", lastDataRun-firstDataRun+1,
01236 1.*firstDataRun, 1.*(lastDataRun+1));
01237 map<int, double>::iterator dataItr = fDataPOTs.begin();
01238 while( dataItr != fDataPOTs.end() ){
01239 dataPOT->Fill(1.*dataItr->first + 0.5, dataItr->second);
01240 ++dataItr;
01241 }
01242 dataPOT->Write();
01243 MSG("NCAnalysisModule", Msg::kInfo) << "total data POT = "
01244 << dataPOT->Integral()
01245 << " x 10^{12}" << endl;
01246
01247 fPOTVsTime->Write();
01248 delete dataPOT;
01249 }
01250
01251 if(fMCPOTs.size() != 0 && dataMC == NCType::kMC){
01252 int firstMCRun = fMCPOTs.begin()->first;
01253
01254 int lastMCRun = fMCPOTs.rbegin()->first;
01255 TH1F *mcPOT = new TH1F("mcPOT", "", lastMCRun-firstMCRun+1,
01256 1.*firstMCRun, 1.*(lastMCRun+1));
01257 map<int, double>::iterator mcItr = fMCPOTs.begin();
01258 while( mcItr != fMCPOTs.end() ){
01259 mcPOT->Fill(1.*mcItr->first + 0.5, mcItr->second);
01260 ++mcItr;
01261 }
01262 mcPOT->Write();
01263 MSG("NCAnalysisModule", Msg::kInfo) << "total MC POT = "
01264 << mcPOT->Integral()
01265 << " x 10^{12}" << endl;
01266 delete mcPOT;
01267 }
01268
01269 return;
01270 }
01271
01272
01273 double NCAnalysisModule::GetTotalPOTCount(int dataMC)
01274 {
01275 double total = 0.;
01276
01277 if(fDataPOTs.size() != 0 && dataMC == NCType::kData){
01278 map<int, double>::iterator dataItr = fDataPOTs.begin();
01279 while( dataItr != fDataPOTs.end() ){
01280 total += dataItr->second;
01281 ++dataItr;
01282 }
01283 }
01284
01285 if(fMCPOTs.size() != 0 && dataMC == NCType::kMC){
01286 map<int, double>::iterator mcItr = fMCPOTs.begin();
01287 while( mcItr != fMCPOTs.end() ){
01288 total += mcItr->second;
01289 ++mcItr;
01290 }
01291 }
01292
01293 return total;
01294 }
01295
01296
01297 void NCAnalysisModule::WriteFile(TFile *file, TTree *events, TTree *beam, int dataMC)
01298 {
01299
01300
01301
01302 TDirectory* saveDir = gDirectory;
01303
01304 file->cd();
01305
01306
01307 for(int k = 0; k < static_cast<int>(fExtractions.size()); ++k){
01308 fExtractions[k]->WriteResources();
01309 }
01310
01311 events->Write();
01312 beam->Write();
01313 WritePOTInfo(dataMC);
01314 for(int i = 0; i < NCType::kNumEfficiencyAndPurityBaseNames; ++i){
01315 for(int j = 0; j < 2; ++j){
01316 WriteComparisonCanvas(i, j);
01317 }
01318 }
01319
01320
01321 fNCLikeCorrelation[dataMC]->Divide(fNCLikeNumerator[dataMC],
01322 fNCLikeDenominator[dataMC]);
01323
01324 fNCLikeHist[dataMC]->Write();
01325 fNCLikeNumerator[dataMC]->Write();
01326 fNCLikeDenominator[dataMC]->Write();
01327 fNCLikeCorrelation[dataMC]->Write();
01328
01329 fCCLikeCorrelation[dataMC]->Divide(fCCLikeNumerator[dataMC],
01330 fCCLikeDenominator[dataMC]);
01331
01332 fCCLikeHist[dataMC]->Write();
01333 fCCLikeNumerator[dataMC]->Write();
01334 fCCLikeDenominator[dataMC]->Write();
01335 fCCLikeCorrelation[dataMC]->Write();
01336
01337 if(dataMC == NCType::kMC){
01338 fNCLikeCorrelationTrue->Divide(fNCLikeNumeratorTrue,
01339 fNCLikeDenominatorTrue);
01340 fNCLikeNumeratorTrue->Write();
01341 fNCLikeDenominatorTrue->Write();
01342 fNCLikeCorrelationTrue->Write();
01343
01344 fCCLikeCorrelationTrue->Divide(fCCLikeNumeratorTrue,
01345 fCCLikeDenominatorTrue);
01346 fCCLikeNumeratorTrue->Write();
01347 fCCLikeDenominatorTrue->Write();
01348 fCCLikeCorrelationTrue->Write();
01349 }
01350
01351 TDirectory *dir = file->mkdir("DataQuality", "DataQuality");
01352 dir->cd();
01353
01354 if(dataMC == NCType::kData){
01355 for(int i = 0; i < NCType::kDQNumDists; ++i){
01356 fDataQualityTotal[i]->Write();
01357 fDataQualityNC[i]->Write();
01358 fDataQualityCC[i]->Write();
01359 }
01360
01361 for(int i = 0; i < NCType::kDQ2DNumDists; ++i){
01362 fDataQuality2DTotal[i]->Write();
01363 fDataQuality2DNC[i]->Write();
01364 fDataQuality2DCC[i]->Write();
01365 }
01366
01367 TGraph *vtxXY = new TGraph(fVtxX.size(), &fVtxX[0], &fVtxY[0]);
01368 vtxXY->SetTitle("");
01369 vtxXY->SetName("vertexXY");
01370 vtxXY->GetHistogram()->SetXTitle("x_{vtx} (m)");
01371 vtxXY->GetHistogram()->SetYTitle("y_{vtx} (m)");
01372 vtxXY->GetHistogram()->GetXaxis()->CenterTitle();
01373 vtxXY->GetHistogram()->GetYaxis()->CenterTitle();
01374 vtxXY->Write();
01375
01376 TDirectory *dirli = file->mkdir("LowIntensity", "LowIntensity");
01377 dirli->cd();
01378
01379 for(int i = 0; i < NCType::kDQNumDists; ++i){
01380 fDataQualityTotalLowIntensity[i]->Write();
01381 fDataQualityNCLowIntensity[i]->Write();
01382 fDataQualityCCLowIntensity[i]->Write();
01383 }
01384
01385 }
01386 else if(dataMC == NCType::kMC){
01387
01388 double mcPOT = 1.e12*GetTotalPOTCount(NCType::kMC);
01389 MSG("NCAnalysisModule", Msg::kInfo) << "mcPOT = " << mcPOT << endl;
01390
01391 for(int i = 0; i < NCType::kDQNumDists; ++i){
01392 fDataQualityMCTotal[i]->Scale(2.5e20/mcPOT);
01393 fDataQualityMCTotal[i]->Write();
01394 fDataQualityMCTotal[i]->Scale(mcPOT/2.5e20);
01395
01396 fDataQualityMCNC[i]->Scale(2.5e20/mcPOT);
01397 fDataQualityMCNC[i]->Write();
01398 fDataQualityMCNC[i]->Scale(mcPOT/2.5e20);
01399
01400 fDataQualityMCCC[i]->Scale(2.5e20/mcPOT);
01401 fDataQualityMCCC[i]->Write();
01402 fDataQualityMCCC[i]->Scale(mcPOT/2.5e20);
01403
01404 fDataQualityMCTotalOsc[i]->Scale(2.5e20/mcPOT);
01405 fDataQualityMCTotalOsc[i]->Write();
01406 fDataQualityMCTotalOsc[i]->Scale(mcPOT/2.5e20);
01407
01408 fDataQualityMCNCOsc[i]->Scale(2.5e20/mcPOT);
01409 fDataQualityMCNCOsc[i]->Write();
01410 fDataQualityMCNCOsc[i]->Scale(mcPOT/2.5e20);
01411
01412 fDataQualityMCCCOsc[i]->Scale(2.5e20/mcPOT);
01413 fDataQualityMCCCOsc[i]->Write();
01414 fDataQualityMCCCOsc[i]->Scale(mcPOT/2.5e20);
01415 }
01416 }
01417
01418 file->cd();
01419
01420 file->Write("",TObject::kOverwrite);
01421
01422 MSG("NCAnalysisModule", Msg::kInfo) << "file " << file->GetName()
01423 << " written" << endl;
01424
01425
01426 saveDir->cd();
01427
01428 return;
01429 }
01430
01431
01432 void NCAnalysisModule::WriteComparisonCanvas(int hist, int nccc)
01433 {
01434 if(hist > NCType::kNumEfficiencyAndPurityBaseNames){
01435 MSG("NCAnalysisModule", Msg::kWarning) << "trying to compare non-existant"
01436 << " histogram in WriteComparisonCanvas"
01437 << endl;
01438 return;
01439 }
01440 if(fExtractions.size() == 0){
01441 MSG("NCAnalysisModule", Msg::kWarning) << "no extractions to compare"
01442 << " in WriteComparisonCanvas"
01443 << endl;
01444 return;
01445 }
01446
01447 TString name = fExtractions[0]->GetIDHistogram(hist, nccc)->GetName();
01448 int pos = name.Index(fExtractions[0]->GetDataType());
01449 name.Remove(pos);
01450 if(nccc == NCType::kNC) name += "NC";
01451 else if(nccc == NCType::kCC) name += "CC";
01452 name += "Comparisons";
01453
01454 TCanvas *canv = new TCanvas(name, name, 150, 10, 600, 600);
01455
01456 TLegend *leg = new TLegend(0.75, 0.75, 0.9, 0.9);
01457 leg->SetBorderSize(0);
01458
01459
01460 int numX = 2;
01461 int numY = 2;
01462 double xSize = 0.5;
01463 double ySize = 0.5;
01464
01465 TString xNames[2] = {"1", "2"};
01466 TString yNames[2] = {"1", "2"};
01467 TString padNames[4] = {"Efficiency", "Purity", "FoM1", "FoM2"};
01468 TString drawOption = "ace1";
01469
01470
01471 vector<TPad *> pads;
01472 int ctr = 0;
01473
01474
01475 for(int y = 0; y < numY; ++y){
01476 for(int x = 0; x < numX; ++x){
01477
01478 pads.push_back(new TPad(padNames[ctr]+xNames[x]+yNames[y], "",
01479 0.0+x*xSize, 1.0-(y+1)*ySize,
01480 (x+1)*xSize, 1.0-y*ySize));
01481
01482 canv->cd();
01483 pads[ctr]->Draw();
01484 pads[ctr]->SetGridx();
01485 pads[ctr]->SetGridy();
01486 pads[ctr]->cd();
01487
01488 for(uint i = 0; i < fExtractions.size(); ++i){
01489 if(i == 0) drawOption = "ace1";
01490 else drawOption = "ce1";
01491
01492 if(ctr == 0){
01493 fExtractions[i]->GetEfficiency(hist, nccc)->Draw(drawOption);
01494 leg->AddEntry(fExtractions[i]->GetEfficiency(hist, nccc),
01495 fExtractions[i]->GetDataType(), "l");
01496 }
01497 else if(ctr == 1)
01498 fExtractions[i]->GetPurity(hist, nccc)->Draw(drawOption);
01499 else if(ctr == 2)
01500 fExtractions[i]->GetFoM1(hist, nccc)->Draw(drawOption);
01501 else if(ctr == 3)
01502 fExtractions[i]->GetFoM2(hist, nccc)->Draw(drawOption);
01503 }
01504
01505 ++ctr;
01506 }
01507 }
01508
01509 leg->Draw();
01510 canv->Update();
01511 canv->Write();
01512
01513 delete leg;
01514 delete canv;
01515
01516 return;
01517 }
01518
01519
01520 void NCAnalysisModule::DoADMFit()
01521 {
01522 NCExtractionADM* extADM
01523 = dynamic_cast<NCExtractionADM *>(fExtractions[1]);
01524
01525 if (extADM!=0x0) extADM->FitForNCCC();
01526
01527 double nc = 0.;
01528 double cc = 0.;
01529 double ncError = 0.;
01530 double ccError = 0.;
01531 double ncTrue = 0.;
01532 double ccTrue = 0.;
01533 double binCenter = 0.;
01534 vector<double> nctrueVec;
01535 vector<double> cctrueVec;
01536
01537 for(int i = 0; i < NCType::kNumRangeLowerLimitsADM; ++i){
01538
01539
01540 MSG("NCAnalysisModule", Msg::kInfo) << binCenter << " nc - " << nc
01541 << " +/- " << ncError
01542 << "/" << ncTrue
01543 << " cc - " << cc
01544 << " +/- " << ccError
01545 << "/" << ccTrue << endl;
01546
01547 cctrueVec.push_back(ccTrue);
01548 nctrueVec.push_back(ncTrue);
01549 }
01550
01551 vector<double> ncVec;
01552 vector<double> ncErrorVec;
01553 vector<double> ccVec;
01554 vector<double> ccErrorVec;
01555
01556 if (extADM!=0x0) extADM->GetEnergyBinFitParameters(ccVec, ccErrorVec,
01557 ncVec, ncErrorVec);
01558
01559
01560
01561
01562
01563 fResultsADM->SetResults(ccVec, ccErrorVec, ncVec,
01564 ncErrorVec, 0.,
01565 static_cast<int>(ncVec.size()));
01566
01567
01568 return;
01569 }
01570
01571
01572
01573 void NCAnalysisModule::FillRecoInfo(ANtpRecoInfo *recoInfo,
01574 ANtpHeaderInfo *headerInfo,
01575 ANtpEventInfoNC *eventInfo,
01576 ANtpShowerInfoNC *showerInfo,
01577 ANtpTrackInfoNC *trackInfo,
01578 ANtpBeamInfo *beamInfo,
01579 NCAnalysisCuts *cuts,
01580 NCAnalysisUtils *utils,
01581 int beamType)
01582 {
01583 void *junk = showerInfo;
01584 junk = 0;
01585
01586
01587 recoInfo->Reset();
01588
01589 recoInfo->inFiducialVolume = (int)cuts->InBeamFiducialVolume();
01590 recoInfo->isFullyContained = (int)(cuts->InBeamFiducialVolume()
01591 && cuts->IsStoppingBeamMuon());
01592
01593 recoInfo->passesCuts = 1;
01594 recoInfo->pass = 1;
01595
01596
01597
01598
01599 recoInfo->nuEnergyCC = utils->GetEventEnergy(CandShowerHandle::kCC);
01600 recoInfo->nuEnergyNC = utils->GetShowerEnergy(CandShowerHandle::kNC);
01601 recoInfo->nuEnergy = utils->GetEventEnergy();
01602
01603 if(eventInfo->tracks > 0)
01604 recoInfo->muEnergy = utils->GetTrackEnergy(cuts->IsStoppingBeamMuon());
01605 else
01606 recoInfo->muEnergy = 0.;
01607
01608 if(eventInfo->showers > 0){
01609 recoInfo->showerEnergy = utils->GetShowerEnergy(CandShowerHandle::kCC);
01610 recoInfo->showerEnergyCC = utils->GetShowerEnergy(CandShowerHandle::kCC);
01611 recoInfo->showerEnergyNC = utils->GetShowerEnergy(CandShowerHandle::kNC);
01612 }
01613 else{
01614 recoInfo->showerEnergy = 0.;
01615 recoInfo->showerEnergyCC = 0.;
01616 recoInfo->showerEnergyNC = 0.;
01617 }
01618
01619
01620 recoInfo->isGoodShower = (int)cuts->IsGoodShower();
01621
01622
01623
01624
01625
01626
01627 if(recoInfo->nuEnergy > 0.){
01628 recoInfo->hadronicY = recoInfo->showerEnergy;
01629 recoInfo->hadronicY /= recoInfo->nuEnergy;
01630 }
01631
01632 recoInfo->muDCosZVtx = trackInfo->dcosZVtx;
01633 double vtxX = 0., vtxY = 0., vtxZ = 0.;
01634 recoInfo->vtxR = utils->GetEventVertex(vtxX, vtxY, vtxZ);
01635 recoInfo->vtxX = vtxX;
01636 recoInfo->vtxY = vtxY;
01637 recoInfo->vtxZ = vtxZ;
01638 recoInfo->eventLength = eventInfo->lengthInPlanes;
01639 recoInfo->trackExtension = eventInfo->trackExtension;
01640 recoInfo->numberTracks = eventInfo->tracks;
01641 recoInfo->trackLength = trackInfo->length;
01642
01643 bool isdata = true;
01644 if(headerInfo->dataType == (int)SimFlag::kMC)
01645 isdata = false;
01646
01647 Detector::Detector_t detType = Detector::kNear;
01648 if(headerInfo->detector == (int)Detector::kFar)
01649 detType = Detector::kFar;
01650
01651 recoInfo->trackMomentum = CorrectSignedMomentumFromCurvature(trackInfo->fitMomentum,
01652 isdata, detType );
01653
01654
01655 if( 0 < trackInfo->rangeMomentum ){
01656 recoInfo->trackRange = CorrectMomentumFromRange(trackInfo->rangeMomentum,
01657 isdata, detType);
01658 }
01659 else{
01660 recoInfo->trackRange = trackInfo->rangeMomentum;
01661 }
01662
01663 recoInfo->sigmaQoverP = trackInfo->sigmaQoverP;
01664 recoInfo->eventInSnarl = eventInfo->index;
01665
01666 recoInfo->weight = 1.0;
01667 recoInfo->weightRunII = 1.0;
01668
01669 if(headerInfo->dataType == (int)SimFlag::kMC){
01670
01671
01672
01673 recoInfo->weight = utils->FindMEGAFitWeight(beamType, NCType::kRunI);
01674 recoInfo->weightRunII = utils->FindMEGAFitWeight(beamType, NCType::kRunII);
01675
01676
01677
01678 }
01679
01680
01681 recoInfo->minTimeSeparation = eventInfo->minTimeSeparation;
01682 recoInfo->closeTimeEvent = eventInfo->closeTimeEvent;
01683
01684 recoInfo->totalStrips = eventInfo->totalStrips;
01685 recoInfo->planes = eventInfo->planes;
01686 recoInfo->trackPlanes = trackInfo->planes;
01687 recoInfo->showerPlanes = showerInfo->planes;
01688 recoInfo->showerTotalStrips = showerInfo->totalStrips;
01689 recoInfo->evtEnergyGeV = eventInfo->energyGeV;
01690
01691 if(detType == Detector::kNear){
01692 recoInfo->closeTimeDeltaZ = eventInfo->closeTimeDeltaZ;
01693 recoInfo->edgeActivityPH = eventInfo->edgeActivityPH;
01694 recoInfo->edgeActivityStrips = eventInfo->edgeActivityStrips;
01695 recoInfo->oppEdgePH = eventInfo->oppEdgePH;
01696 recoInfo->oppEdgeStrips = eventInfo->oppEdgeStrips;
01697 recoInfo->isCleanLowMultSnarl = (int)cuts->IsCleanLowMultSnarl();
01698 recoInfo->isCleanHighMultSnarl = (int)cuts->IsCleanHighMultSnarl();
01699 }
01700
01701 recoInfo->deltaTimeSpill = (eventInfo->stripTime1st - 1.e-9*beamInfo->nearestNSToSpill)*1.e6;
01702
01703 return;
01704 }
01705
01706
01707 void NCAnalysisModule::SetWeight(ANtpRecoInfo *recoInfo,
01708 ANtpHeaderInfo *headerInfo,
01709 int beamType,
01710 NCAnalysisUtils *utils)
01711 {
01712 double xfptWeight = recoInfo->weight;
01713
01714
01715
01716
01717 double showerEnergyShift = 0.1098;
01718 double trackEnergyShift = -0.0176;
01719 double normalizationFar = 0.0014;
01720 double skzpShift = 1.3822;
01721 double deltaMSqr = 0.002867;
01722 double sinSqr2Theta = 0.8472;
01723 double fSterile = 0.1452;
01724
01725
01726
01727
01728 xfptWeight *= utils->FindMEGAFitWeightUncertainty(beamType,
01729 NCType::kRunI,
01730 skzpShift);
01731
01732
01733 double survivalProb = 1.;
01734 std::vector<double> oscPars;
01735 oscPars.push_back(sinSqr2Theta);
01736 oscPars.push_back(deltaMSqr);
01737 oscPars.push_back(fSterile);
01738
01739 survivalProb = utils->FindSurvivalProbability(oscPars);
01740
01741
01742 recoInfo->weight = xfptWeight;
01743
01744
01745 if(headerInfo->detector == (int)Detector::kFar)
01746 recoInfo->weight *= normalizationFar*survivalProb;
01747
01748
01749
01750 recoInfo->muEnergy *= 1. + trackEnergyShift;
01751
01752 recoInfo->showerEnergy *= 1. + showerEnergyShift;
01753 recoInfo->showerEnergyCC *= 1. + showerEnergyShift;
01754 recoInfo->showerEnergyNC *= 1. + showerEnergyShift;
01755
01756 recoInfo->nuEnergyCC = recoInfo->muEnergy + recoInfo->showerEnergyCC;
01757 recoInfo->nuEnergyNC = recoInfo->showerEnergyNC;
01758 recoInfo->nuEnergy = recoInfo->muEnergy + recoInfo->showerEnergy;
01759
01760 if(headerInfo->detector == (int)Detector::kFar)
01761 headerInfo->run += 899000;
01762 else if(headerInfo->detector == (int)Detector::kNear)
01763 headerInfo->run += 500000;
01764
01765 return;
01766 }
01767