NuAnalysis Class Reference

#include <NuAnalysis.h>

Inheritance diagram for NuAnalysis:
NuBase

List of all members.

Public Member Functions

 NuAnalysis ()
 ~NuAnalysis ()
void BasicPlots ()
void ChargeSignCut ()
void ChargeSeparation ()
void ChargeSeparationOneSnarl (const NtpStRecord *pntp, const NtpBDLiteRecord *pntpBD, const NtpFitSARecord *pntpSA)
virtual const std::vector< Int_t > ContributingTrueEvents (const NuEvent &event) const
void CrossSections ()
void Efficiencies ()
void EfficienciesOld ()
void EnergySpect ()
void EnergySpectMC ()
void LIRejectionTest ()
void MakeFullDST (const NtpStRecord *pntp, const NtpBDLiteRecord *pntpBD, const NtpFitSARecord *pntpSA)
void NuMuBarAppearance ()
void NMBSummaryTreeAna ()
void N_1 ()
void EndJob ()
void DoExtractions (const NtpStRecord &ntp, const NtpSREvent &evt, const NtpFitSARecord *pntpSA, NuPIDInterface &pid, NuEvent &nu) const
void changeRunPeriod (NuEvent &nu) const
void changeRunPeriodTruth (NuMCEvent &nu) const
void ExtractPIDsAndWeights (const NtpStRecord &ntp, const NtpSREvent &evt, NuPIDInterface &pid, NuEvent &nu) const

Static Public Member Functions

static void altRun (Int_t AltRun)

Private Member Functions

void CopyConfig (const NuConfig &config, NuEvent &nu)
void CopySnarlInfo (const NuEvent &nuSnarl, NuEvent &nu)
TSpline3 * CreateTSpline3 (std::string splName, std::string varNames, std::string fileName)
void DemoInfidSRInterface (const NtpStRecord &ntp, const NtpSREvent &evt, const NuEvent &nu)
void ExtractConfig (NuConfig &config)
Bool_t ExtractConfig (const NtpStRecord *pntp, const NtpBDLiteRecord *pntpBD, NuConfig &config) const
void DetermineBeamType (NuConfig &config) const
void OldDetermineBeamType (NuConfig &config)
void CopyAcrossHistos (TDirectory *dirInput, TDirectory *dirOutput) const
void LoopOverTruthInfo (const NtpStRecord &ntp, NuOutputWriter &output, const NuEvent &nuSnarl, const std::vector< Int_t > vTthInd) const
void SetAnaFlags (NuConfig &config)
void StoreOrFinishTree (NuOutputWriter *pOutput, NuTime *pTime, Bool_t finish) const

Static Private Attributes

static Int_t iAltRun = 0

Detailed Description

Definition at line 26 of file NuAnalysis.h.


Constructor & Destructor Documentation

NuAnalysis::NuAnalysis (  ) 

Definition at line 86 of file NuAnalysis.cxx.

References Msg::kDebug, and MSG.

00087 {
00088   MSG("NuAnalysis",Msg::kDebug)
00089     <<"Running NuAnalysis Constructor..."<<endl;
00090 
00091 
00092   MSG("NuAnalysis",Msg::kDebug)
00093     <<"Finished NuAnalysis Constructor"<<endl;
00094 }

NuAnalysis::~NuAnalysis (  ) 

Definition at line 98 of file NuAnalysis.cxx.

References Msg::kDebug, and MSG.

00099 {
00100   MSG("NuAnalysis",Msg::kDebug)
00101     <<"Running NuAnalysis Destructor..."<<endl;
00102   
00103 
00104   MSG("NuAnalysis",Msg::kDebug)
00105     <<"Finished NuAnalysis Destructor"<<endl;
00106 }


Member Function Documentation

void NuAnalysis::altRun ( Int_t  AltRun  )  [static]

Definition at line 7338 of file NuAnalysis.cxx.

References iAltRun.

07339 {
07340   iAltRun=AltRun;
07341 }

void NuAnalysis::BasicPlots (  ) 

Definition at line 206 of file NuAnalysis.cxx.

References NuBase::fOutFile, NuBase::GetEntries(), NuBase::GetNtpStRecord(), NtpMCTruth::iaction, NuBase::InitialiseLoopVariables(), NtpMCTruth::inu, NtpMCTruth::iresonance, Msg::kInfo, Msg::kWarning, MAXMSG, NtpStRecord::mc, MSG, NuBase::OpenFile(), NtpMCTruth::p4neu, and NuBase::SetLoopVariables().

00207 {
00208   MSG("NuAnalysis",Msg::kInfo) 
00209     <<" ** Running BasicPlots method... **"<<endl;
00210   
00211   //open the output file for the histograms
00212   fOutFile=this->OpenFile(100,"NuBasicPlots");
00213 
00214   TH1F* hNuInt=new TH1F("hNuInt","hNuInt",10000,-100,1000);
00215   hNuInt->SetTitle("Number of neutrino interactions per spill");
00216   hNuInt->GetXaxis()->SetTitle("# interactions");
00217   hNuInt->GetXaxis()->CenterTitle();
00218   hNuInt->GetYaxis()->SetTitle("");
00219   hNuInt->GetYaxis()->CenterTitle();
00220   hNuInt->SetFillColor(0);
00221   hNuInt->SetLineColor(1);
00222   //hNuInt->SetBit(TH1::kCanRebin);
00223 
00224   TH1F* hNuMuBarEn=new TH1F("hNuMuBarEn","hNuMuBarEn",4*352,-32,320);
00225   hNuMuBarEn->GetXaxis()->SetTitle("Energy (GeV)");
00226   hNuMuBarEn->GetXaxis()->CenterTitle();
00227   hNuMuBarEn->GetYaxis()->SetTitle("");
00228   hNuMuBarEn->GetYaxis()->CenterTitle();
00229   hNuMuBarEn->SetFillColor(0);
00230   hNuMuBarEn->SetLineColor(2);
00231   //hNuMuBarEn->SetBit(TH1::kCanRebin);
00232 
00233   TH1F* hNuMuEn=new TH1F("hNuMuEn","hNuMuEn",4*352,-32,320);
00234   hNuMuEn->GetXaxis()->SetTitle("Energy (GeV)");
00235   hNuMuEn->GetXaxis()->CenterTitle();
00236   hNuMuEn->GetYaxis()->SetTitle("");
00237   hNuMuEn->GetYaxis()->CenterTitle();
00238   hNuMuEn->SetFillColor(0);
00239   hNuMuEn->SetLineColor(1);
00240   hNuMuEn->SetLineWidth(2);
00241   //hNuMuEn->SetBit(TH1::kCanRebin);
00242 
00243   TH1F* hNueBarEn=new TH1F("hNueBarEn","hNueBarEn",4*352,-32,320);
00244   hNueBarEn->GetXaxis()->SetTitle("Energy (GeV)");
00245   hNueBarEn->GetXaxis()->CenterTitle();
00246   hNueBarEn->GetYaxis()->SetTitle("");
00247   hNueBarEn->GetYaxis()->CenterTitle();
00248   hNueBarEn->SetFillColor(0);
00249   hNueBarEn->SetLineColor(2);
00250   hNueBarEn->SetLineWidth(2);
00251   hNueBarEn->SetLineStyle(2);
00252   //hNueBarEn->SetBit(TH1::kCanRebin);
00253 
00254   TH1F* hNueEn=new TH1F("hNueEn","hNueEn",4*352,-32,320);
00255   hNueEn->GetXaxis()->SetTitle("Energy (GeV)");
00256   hNueEn->GetXaxis()->CenterTitle();
00257   hNueEn->GetYaxis()->SetTitle("");
00258   hNueEn->GetYaxis()->CenterTitle();
00259   hNueEn->SetFillColor(0);
00260   hNueEn->SetLineColor(1);
00261   hNueEn->SetLineWidth(1);
00262   hNueEn->SetLineStyle(2);
00263   //hNueEn->SetBit(TH1::kCanRebin);
00264 
00268   
00269   this->InitialiseLoopVariables();  
00270   
00271   //for(Int_t entry=0;entry<10000;entry++){
00272   for(Int_t entry=0;entry<this->GetEntries();entry++){
00273       
00274     this->SetLoopVariables(entry);
00275       
00276     //get reference to NtpStRecord from base class
00277     const NtpStRecord& ntp=(*this->GetNtpStRecord());
00278     
00279     TClonesArray& mcTca=*ntp.mc;
00280     Int_t numInt=mcTca.GetEntries();
00281     MAXMSG("NuAnalysis",Msg::kInfo,20)
00282       <<"Number of entries in NtpMCTruth="
00283       <<mcTca.GetEntries()<<endl;
00284     //if (mcTca.GetEntries()==0){ 
00285 
00286     hNuInt->Fill(mcTca.GetEntries());
00287 
00288     for (Int_t i=0;i<numInt;i++){
00289       const NtpMCTruth& mc=*(dynamic_cast<NtpMCTruth*>(mcTca[i]));
00290 
00291       string iaction="NC";
00292       if (mc.iaction==1) iaction="CC";
00293       string iresonance="QE ";
00294       if (mc.iresonance==1002) iresonance="RES";
00295       else if (mc.iresonance==1003) iresonance="DIS";
00296       else if (mc.iresonance==1004) iresonance=
00297                                       "Coherent pion production";
00298       string inu="??";
00299       if (mc.inu==14) inu="NuMu   ";
00300       else if (mc.inu==-14) inu="NuMuBar";
00301       else if (mc.inu==12) inu="NuE    ";
00302       else if (mc.inu==-12) inu="NuEBar ";
00303       
00304       MAXMSG("NuAnalysis",Msg::kInfo,100)
00305         <<"Interaction #"<<i<<" is "<<inu
00306         <<" "<<iaction
00307         <<" "<<iresonance<<endl;
00308 
00309       if (mc.inu==-14) hNuMuBarEn->Fill(mc.p4neu[3]);
00310       else if (mc.inu==14) hNuMuEn->Fill(mc.p4neu[3]);
00311       else if (mc.inu==-12) hNueBarEn->Fill(mc.p4neu[3]);
00312       else if (mc.inu==12) hNueEn->Fill(mc.p4neu[3]);
00313       else {
00314         MAXMSG("NuAnalysis",Msg::kWarning,100)
00315           <<"particle not defined for filling histo="<<mc.inu<<endl;
00316       }
00317     }
00318 
00319     //TClonesArray& tcaTk=(*ntpst.trk);
00320     //Int_t numTrks=tcaTk.GetEntries();
00321     
00322     //MAXMSG("NuAnalysis",Msg::kInfo,10)
00323     //<<"numTrks="<<numTrks
00324     //<<", ndigit="<<fRec->evthdr.ndigit
00325     //<<", nTrack="<<fRec->evthdr.ntrack<<endl;
00326 
00327     //Loop over tracks
00328     //for (Int_t itrk=0;itrk<numTrks;itrk++){
00329     //const NtpSRTrack* ptrk=
00330     //dynamic_cast<NtpSRTrack*>(tcaTk[itrk]);
00331     //const NtpSRTrack& trk=(*ptrk);
00332     //}
00333 
00334 
00335   }//end of for                                       
00336   
00340 
00341   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
00342 
00343   MSG("NuAnalysis",Msg::kInfo) 
00344     <<" ** Finished BasicPlots method **"<<endl;
00345 }

void NuAnalysis::changeRunPeriod ( NuEvent nu  )  const

Definition at line 6636 of file NuAnalysis.cxx.

Referenced by MakeFullDST().

06637 {
06638   nu.runPeriod=iAltRun;
06639   return;
06640 }

void NuAnalysis::changeRunPeriodTruth ( NuMCEvent nu  )  const

Definition at line 6642 of file NuAnalysis.cxx.

Referenced by LoopOverTruthInfo().

06643 {
06644   numc.runPeriod=iAltRun;
06645   return;
06646 }

void NuAnalysis::ChargeSeparation (  ) 

Definition at line 6437 of file NuAnalysis.cxx.

References ChargeSeparationOneSnarl(), NuBase::GetEntries(), NuBase::GetNtpBDLiteRecord(), NuBase::GetNtpStRecord(), NuBase::InitialiseLoopVariables(), Msg::kInfo, MSG, NuBase::SetLoopVariables(), and StoreOrFinishTree().

06438 {
06439   MSG("NuAnalysis",Msg::kInfo) 
06440     <<" ** Running ChargeSeparation method... **"<<endl;
06441   
06445   
06446   cout<<endl
06447       <<"************************************************"<<endl
06448       <<"***      Starting main loop over snarls      ***"<<endl
06449       <<"************************************************"<<endl;
06450   
06451   this->InitialiseLoopVariables();  
06452   
06453   for(Int_t entry=0;entry<this->GetEntries();entry++){
06454     
06455     this->SetLoopVariables(entry);
06456       
06457 
06458     this->ChargeSeparationOneSnarl(this->GetNtpStRecord(),
06459                                    this->GetNtpBDLiteRecord(),0);
06460   }
06461 
06462   //finish the job
06463   this->StoreOrFinishTree(NULL,NULL,1);
06464 
06465   MSG("NuAnalysis",Msg::kInfo) 
06466     <<" ** Finished ChargeSeparation method **"<<endl;
06467 }

void NuAnalysis::ChargeSeparationOneSnarl ( const NtpStRecord pntp,
const NtpBDLiteRecord pntpBD,
const NtpFitSARecord pntpSA 
)

code to produce the NuDST ntuple this should be called once per snarl

Definition at line 6694 of file NuAnalysis.cxx.

References NuEvent::abID, NuConfig::anaVersion, NuCounter::badSpillCounter, NuEvent::charge, NuLibrary::cnt, NuEvent::coilIsOk, CopyConfig(), CopySnarlInfo(), NuCounter::CountTrkStdhepId(), NuLibrary::cuts, DoExtractions(), NuEvent::dpID, NuCounter::entry, NuEvent::entry, NtpStRecord::evt, NuCounter::evtCounter, NtpStRecord::evthdr, NuCounter::evtInFidVolCounter, NuCounter::evtNotIsLI, NuCounter::evtNotlitime, NuCounter::evtWithTrkCounter, NuLibrary::ext, NuExtraction::ExtractBasicInfo(), NuExtraction::ExtractCoilInfo(), ExtractConfig(), NuExtraction::ExtractGeneralInfo(), NuPlots::FillCoilCurrentHistos(), NuPlots::FillContainmentHistos(), NuPlots::FillDPIdSigmaQPFailDpIDCutPlots(), NuPlots::FillDPIdSigmaQPFailProbCutPlots(), NuPlots::FillDPIdSigmaQPFailSigQPCutPlots(), NuPlots::FillDPIdSigmaQPPassDpIDCutPlots(), NuPlots::FillDPIdSigmaQPPassPreSelCutPlots(), NuPlots::FillDPIdSigmaQPPassSigQPCutPlots(), NuPlots::FillDPIdSigmaQPPassUVVtxCutPlots(), NuPlots::FillDPIdSigmaQPPlotsN(), NuPlots::FillEnergyBinHistos(), NuPlots::FillEvtAndSpillTimingPlots(), NuPlots::FillGeneralHistos(), NuPlots::FillKinematicsHistos(), NuPlots::FillLowProbPlots(), NuHistos::FillMatrixMethodHistos(), NuPlots::FillNtupleEarliestLatestTime(), NuOutputWriter::FillNuEventTree(), NuPlots::FillRangeCurvCompHistos(), NuPlots::FillRecoEnYHistosN(), NuPlots::FillShwHistos(), NuPlots::FillSigmaQPPlots(), NuPlots::FillStpfitqpPlots(), NuTime::FillTime(), NuPlots::FillTrackResponseHistos(), NuPlots::FillTrueAbIDHistos(), NuPlots::FillTrueAbIDHistosPQNQ(), NuPlots::FillTrueDpIDHistos(), NuPlots::FillTrueDpIDHistosPQNQ(), NuPlots::FillTruePIDHistos(), NuPlots::FillTrueRoIDHistos(), NuPlots::FillTrueRoIDHistosPQNQ(), NuPlots::FillXYZHistos(), NuReco::GetBestTrack(), VldContext::GetDetector(), NuReco::GetEvtEnergy(), RecRecordImp< T >::GetHeader(), NuOutputWriter::GetNuEventToFill(), RecDataHeader::GetRun(), VldContext::GetSimFlag(), RecPhysicsHeader::GetSnarl(), RecDataHeader::GetSubRun(), NuReco::GetTrackWithIndexX(), RecHeader::GetVldContext(), NuCounter::goodBeamInfoDBCounter, NuEvent::goodBeamSntp, NuCounter::goodCoilCurrentSpillCounter, NuCounter::goodDataQualityCounter, NuCounter::goodDirectionCosineCounter, NuCounter::goodFitProbCounter, NuCounter::goodFitSigQPCounter, NuCounter::goodPIDCounter, NuCounter::goodSpillCounter, NuCounter::goodTimeToNearestSpillCounter, NuCounter::goodTrkPassCounter, NuLibrary::hist, NuLibrary::Instance(), NuCuts::IsGoodBeam(), NuCuts::IsGoodDataQuality(), NuCuts::IsGoodDirCos(), NuCuts::IsGoodFitProb(), NuCuts::IsGoodNumberOfTracks(), NuCuts::IsGoodPID(), NuCuts::IsGoodSigmaQP_QP(), NuBeam::IsGoodSpillAndFillPot(), NuCuts::IsGoodTimeToNearestSpill(), NuCuts::IsGoodTrackFitPass(), NuCuts::IsInFidVolLoose(), NuCuts::IsInFidVolTrk(), NuCuts::IsLI(), NuCuts::kCC0250Std, Msg::kDebug, Msg::kError, Msg::kInfo, NtpSREventSummary::litime, LoopOverTruthInfo(), MAXMSG, NuEvent::nevt, NtpSREvent::ntrack, NuCounter::nuNQCounter, NuCounter::nuPQCounter, NuBase::OpenTxtFile(), plots(), NuEvent::poID, NuEvent::pot, NuEvent::potSinceLastEvt, NuEvent::potSinceLastEvtBad, NuEvent::potSinceLastEvtGood, NuPlots::PrintEventInfo(), NuEvent::prob, NuLibrary::reco, NuEvent::roID, NuEvent::roIDNuMuBar, NuConfig::sBeamType, SetAnaFlags(), NuOutputWriter::SetupFile(), StoreOrFinishTree(), NuEvent::timeSec, NuCounter::totalPot, NuCounter::totalPotBad, NuCounter::trkInFidVolCounter, NuTime::vTimeNuMuBarEvt, and NuTime::vTimeNuMuEvt.

Referenced by NuModule::Ana(), and ChargeSeparation().

06697 {
06698   MAXMSG("NuAnalysis",Msg::kError,100) 
06699     <<"ChargeSeparationOneSnarl is deprecated. Use MakeFullDst instead"
06700     <<endl;
06701 
06704 
06705   //get an instance of the code library
06706   NuLibrary& lib=NuLibrary::Instance();
06707   
06708   //increment ntuple entry (snarl) counter 
06709   lib.cnt.entry++;//initialised to -1 so first entry=0
06710 
06714   
06715   //extract the config from the beam information
06716   //occasionally the first snarl fails the beam cuts
06717   //so therefore you can't determine the proper beam config
06718   //this messes up the counting of bad pot but it should be a tiny 
06719   //effect
06720   static NuConfig config;
06721   static Bool_t configNotExtracted=true;
06722   if (configNotExtracted) {
06723     configNotExtracted=!this->ExtractConfig(pntp,pntpBD,config);
06724     if (configNotExtracted) return;//skip to next snarl
06725   }
06726 
06727   static Bool_t firstTime=true;
06728   static NuOutputWriter output;
06729 
06730   static ofstream* pnmbTxt=0;
06731   static ofstream* pnmTxt=0;
06732   static ofstream* pnmbTxtProb=0;
06733   static ofstream* pnmbTxtProb001=0;
06734   static ofstream* pnmbTxtProb003=0;
06735 
06736   //classes to organise the code in to related functions
06737   static const NuPlots plots;
06738   static const NuBeam beam;
06739   static NuTime time;//class to record times of spills, etc
06740 
06741   //interface for the pids
06742   static NuPIDInterface pid;
06743 
06744   if (firstTime) {
06745     firstTime=false;//set the control variable so code not run again
06746         
06747     //open the output file for the histograms
06748     string sFilePrefix="NuDST"+config.sBeamType;
06749     //fOutFile=this->OpenFile(config,sFilePrefix.c_str());
06750     output.SetupFile(config,sFilePrefix);
06751     
06752     string sTxt="nmb"+config.sBeamType;
06753     pnmbTxt=this->OpenTxtFile(config,sTxt.c_str());
06754     string sTxtNM="nm"+config.sBeamType;
06755     pnmTxt=this->OpenTxtFile(config,sTxtNM.c_str());
06756     string sTxtProb="nmbProb"+config.sBeamType;
06757     pnmbTxtProb=this->OpenTxtFile(config,sTxtProb.c_str());
06758     string sTxtProb001="nmbProb001"+config.sBeamType;
06759     pnmbTxtProb001=this->OpenTxtFile(config,sTxtProb001.c_str());
06760     string sTxtProb003="nmbProb003"+config.sBeamType;
06761     pnmbTxtProb003=this->OpenTxtFile(config,sTxtProb003.c_str());
06762 
06763     //define the analysis flags
06764     this->SetAnaFlags(config);
06765     config.anaVersion=NuCuts::kCC0250Std;
06766 
06767     //this stores the objects' pointers for access at job end
06768     //NOTE: run this after the output file has been opened
06769     this->StoreOrFinishTree(&output,&time,false);
06770     
06771     cout<<endl
06772         <<"************************************************"<<endl
06773         <<"***      Starting main loop over snarls      ***"<<endl
06774         <<"************************************************"<<endl;
06775   }
06776   
06777   //get references (coding preference)
06778   static ofstream& nmbTxt=*pnmbTxt;
06779   static ofstream& nmTxt=*pnmTxt;
06780   static ofstream& nmbTxtProb=*pnmbTxtProb;
06781   static ofstream& nmbTxtProb001=*pnmbTxtProb001;
06782   static ofstream& nmbTxtProb003=*pnmbTxtProb003;
06783   
06784   //don't get a reference to NtpBDLiteRecord because it doesn't exist
06785   //for MC
06786   const NtpStRecord& ntp=*pntp;
06787 
06791   
06792   const RecCandHeader& rec=ntp.GetHeader();
06793   MAXMSG("NuAnalysis",Msg::kInfo,5)
06794     <<"Found: run="<<rec.GetRun()
06795     <<", subrun="<<rec.GetSubRun()
06796     <<", detector="<<rec.GetVldContext().GetDetector()
06797     <<", simFlag="<<rec.GetVldContext().GetSimFlag()
06798     <<", snarl="<<rec.GetSnarl()
06799     <<endl;
06800   
06801   //write out the detector, simflag, etc
06802   plots.FillGeneralHistos(ntp);
06803   
06804   //simple event object to hold important quantities for snarl
06805   NuEvent nuSnarl;
06806   this->CopyConfig(config,nuSnarl);
06807 
06808   //get the run, snarl, etc info
06809   lib.ext.ExtractGeneralInfo(ntp,nuSnarl);
06810 
06811   //get the true energy spectra of events in the fid vol
06812   std::vector<Int_t> vEmpty;
06813   this->LoopOverTruthInfo(ntp,output,nuSnarl,vEmpty);
06814 
06815   //extract coil info early in order to get POT counting right
06816   //doesn't matter for the FD because POTs are externally defined
06817   lib.ext.ExtractCoilInfo(nuSnarl);
06818   plots.FillCoilCurrentHistos(nuSnarl);
06819   if (!nuSnarl.coilIsOk) return;
06820   lib.cnt.goodCoilCurrentSpillCounter++;
06821   
06822   //get POT and event time info
06823   beam.IsGoodSpillAndFillPot(pntpBD,config,nuSnarl);
06824   time.FillTime(nuSnarl.timeSec,nuSnarl.pot,nuSnarl.goodBeamSntp);
06825   if (!nuSnarl.goodBeamSntp) {
06826     lib.cnt.badSpillCounter++;
06827     lib.cnt.totalPotBad+=nuSnarl.pot;
06828     return;
06829   }
06830   lib.cnt.goodSpillCounter++;
06831   lib.cnt.totalPot+=nuSnarl.pot;   
06832   
06833   //count the pots since the last evt was written to file
06834   static Float_t potSinceLastEvt=0;
06835   static Float_t potSinceLastEvtGood=0;
06836   static Float_t potSinceLastEvtBad=0;//this is always zero here
06837   potSinceLastEvt+=nuSnarl.pot;
06838   if (nuSnarl.goodBeamSntp && 
06839       nuSnarl.coilIsOk) potSinceLastEvtGood+=nuSnarl.pot;
06840   else potSinceLastEvtBad+=nuSnarl.pot;
06841 
06842   //get the tca of evts
06843   TClonesArray& evtTca=(*ntp.evt);
06844   const Int_t numEvts=evtTca.GetEntriesFast();
06845 
06847   //loop over the reconstructed events
06849   for (Int_t ievt=0;ievt<numEvts;ievt++){
06850     const NtpSREvent& evt=
06851       *dynamic_cast<NtpSREvent*>(evtTca[ievt]);
06852     lib.cnt.evtCounter++;
06853       
06854     MAXMSG("NuAnalysis",Msg::kInfo,5)
06855       <<"Found event, "<<ievt+1<<"/"<<numEvts<<endl;
06856 
06857     //loose pre-selection cut: just require 1 or more trks
06858     if (evt.ntrack<1) continue;
06859     lib.cnt.evtWithTrkCounter++;
06860 
06861     //get rid of LI events
06862     const NtpSREventSummary& evthdr=ntp.evthdr;
06863     if (evthdr.litime!=-1) continue;
06864     lib.cnt.evtNotlitime++;
06865     
06866     //simple event object to hold important quantities
06867     NuEvent& nu=output.GetNuEventToFill();
06868     nu.entry=lib.cnt.entry;//store the entry in the tree number
06869     nu.nevt=numEvts;//store the numEvts in snarl
06870     //copy info, copy the analysis (cuts and reco) version to use
06871     this->CopySnarlInfo(nuSnarl,nu);
06872     this->CopyConfig(config,nu);
06873     
06874     //extract the general info and evt, trk and shw info
06875     lib.ext.ExtractBasicInfo(ntp,evt,nu);
06876 
06877     //check if trk or evt vertex is in the loose fid vol
06878     if (!lib.cuts.IsInFidVolLoose(nu)) continue;
06879     lib.cnt.evtInFidVolCounter++;
06880     
06881     //RECONSTRUCT the neutrino energy
06882     lib.reco.GetEvtEnergy(nu, false);
06883 
06884     MAXMSG("NuAnalysis",Msg::kDebug,10)
06885       <<endl<<"After reco:"<<endl
06886       <<plots.PrintEventInfo(cout,nu)<<endl;
06887 
06888     
06889     //do multiple extractions
06890 
06891     this->DoExtractions(ntp,evt,pntpSA,pid,nu);//beam weights set here
06892 
06893     MAXMSG("NuAnalysis",Msg::kInfo,10)
06894       <<"PID: dp="<<nu.dpID<<", ab="<<nu.abID<<", ro="<<nu.roID
06895       <<", po="<<nu.poID<<", roNMB="<<nu.roIDNuMuBar<<endl;
06896     
06897     //figure out the first and last time in the whole ntuple
06898     //this is very useful for making plots of quantities vs time
06899     plots.FillNtupleEarliestLatestTime(nu);
06900 
06901     //write out the pots since the last evt
06902     //this variable takes account of spills with zero entries
06903     //and spills with >=2 evts
06904     nu.potSinceLastEvt=potSinceLastEvt;
06905     nu.potSinceLastEvtGood=potSinceLastEvtGood;
06906     nu.potSinceLastEvtBad=potSinceLastEvtBad;
06907     potSinceLastEvt=0;//reset this for the next loop
06908     potSinceLastEvtGood=0;
06909     potSinceLastEvtBad=0;
06910 
06912     //fill the tree
06913     output.FillNuEventTree();
06914       
06915     //get the best track in the event
06916     Int_t bestTrack=lib.reco.GetBestTrack(nu);
06917     const NtpSRTrack* ptrk=lib.reco.GetTrackWithIndexX
06918       (ntp,evt,bestTrack-1);
06919     const NtpSRTrack& trk=*ptrk;
06920 
06921     //ensure good number of tracks in event (note preselection above)
06922     if (!lib.cuts.IsGoodNumberOfTracks(nu)) continue;
06923     lib.cnt.evtWithTrkCounter++;
06924 
06925     //check trk is in fiducial volume (note preselection above)
06926     if (!lib.cuts.IsInFidVolTrk(nu)) continue;
06927     lib.cnt.trkInFidVolCounter++;
06928 
06929     //cut on LI
06930     if (lib.cuts.IsLI(nu)) continue;
06931     lib.cnt.evtNotIsLI++;
06932       
06933     //cut on the data quality
06934     if (!lib.cuts.IsGoodDataQuality(nu)) continue;
06935     lib.cnt.goodDataQualityCounter++;
06936       
06937     //cut on the spill time
06938     plots.FillEvtAndSpillTimingPlots(nu);
06939     if (!lib.cuts.IsGoodTimeToNearestSpill(nu)) continue;
06940     lib.cnt.goodTimeToNearestSpillCounter++;
06941 
06942     //cut on the beam
06943     if (!lib.cuts.IsGoodBeam(nu)) continue;
06944     lib.cnt.goodBeamInfoDBCounter++;
06945       
06946     //require a good trk fit
06947     if (!lib.cuts.IsGoodTrackFitPass(nu)) continue;
06948     lib.cnt.goodTrkPassCounter++;
06949 
06950     //require a forward going neutrino about beam direction
06951     if (!lib.cuts.IsGoodDirCos(nu)) continue;
06952     lib.cnt.goodDirectionCosineCounter++;
06953 
06954     //fill pid plots AFTER pre-selection
06955     plots.FillTrueDpIDHistos(nu);
06956     plots.FillTrueDpIDHistosPQNQ(nu);
06957     plots.FillDPIdSigmaQPPassPreSelCutPlots(nu);
06958     plots.FillSigmaQPPlots(nu);//sig, chi, prob plots
06959     // PoID Officially depracated
06960     //plots.FillTruePoIDHistos(nu);
06961     //plots.FillTruePoIDHistosPQNQ(nu);
06962     plots.FillTrueAbIDHistos(nu);
06963     plots.FillTrueAbIDHistosPQNQ(nu);      
06964     plots.FillTrueRoIDHistos(nu);
06965     plots.FillTrueRoIDHistosPQNQ(nu);
06966     plots.FillDPIdSigmaQPPassUVVtxCutPlots(nu);//fill these anyway
06967     
06968     //cut on the PID
06969     if (!lib.cuts.IsGoodPID(nu)) {
06970       plots.FillDPIdSigmaQPFailDpIDCutPlots(nu);
06971       continue;
06972     }
06973     lib.cnt.goodPIDCounter++;   
06974     plots.FillDPIdSigmaQPPassDpIDCutPlots(nu);
06975 
06976     //cut on the fractional track momentum and sign error      
06977     if (!lib.cuts.IsGoodSigmaQP_QP(nu)) {
06978       plots.FillDPIdSigmaQPFailSigQPCutPlots(nu);
06979       continue;
06980     }
06981     lib.cnt.goodFitSigQPCounter++;
06982     plots.FillDPIdSigmaQPPassSigQPCutPlots(nu);
06983       
06984     //fill plots
06985     plots.FillStpfitqpPlots(ntp,trk,nu);
06986     plots.FillLowProbPlots(trk,nu);
06987 
06988     //cut on the track fit probability      
06989     if (!lib.cuts.IsGoodFitProb(nu)) {
06990       plots.FillDPIdSigmaQPFailProbCutPlots(nu);
06991       if (nu.charge==+1) {
06992         plots.PrintEventInfo(nmbTxtProb,nu);
06993         if (nu.prob<=0.001) plots.PrintEventInfo(nmbTxtProb001,nu);
06994         else if (nu.prob>0.001 && nu.prob<0.003) plots.PrintEventInfo
06995                                                    (nmbTxtProb003,nu);
06996       }
06997       continue;
06998     }
06999     lib.cnt.goodFitProbCounter++;
07000       
07001     //plots.FillStpfitqpPlots(ntp,trk,nu);
07002      
07004     //END OF STD CUTS
07006       
07007     if (nu.charge==-1) {
07008       plots.PrintEventInfo(nmTxt,nu);
07009       time.vTimeNuMuEvt.push_back(nu.timeSec);
07010       lib.cnt.nuNQCounter++;
07011     }
07012     else if (nu.charge==+1) {
07013       plots.PrintEventInfo(nmbTxt,nu);
07014       lib.cnt.CountTrkStdhepId(ntp,evt,trk,nu);
07015       time.vTimeNuMuBarEvt.push_back(nu.timeSec);
07016       lib.cnt.nuPQCounter++;
07017     }
07018     //    else cout<<"ahhh, bad charge"<<endl;
07019 
07020     MAXMSG("NuAnalysis",Msg::kDebug,100)
07021       <<plots.PrintEventInfo(cout,nu)<<endl;
07022       
07023     //fill all the plots
07024     plots.FillRecoEnYHistosN(nu);
07025     plots.FillDPIdSigmaQPPlotsN(nu);
07026     plots.FillEnergyBinHistos(nu);
07027     plots.FillShwHistos(ntp,evt,nu);
07028     plots.FillXYZHistos(nu);
07029     plots.FillContainmentHistos(nu);
07030     plots.FillTruePIDHistos(nu);
07031     plots.FillTrackResponseHistos(ntp,trk,nu);
07032     plots.FillRangeCurvCompHistos(nu);
07033     plots.FillKinematicsHistos(nu);
07034 
07035     //fill matrix method histos
07036     lib.hist.FillMatrixMethodHistos(nu);
07037   }//end of loop over events
07038 }

void NuAnalysis::ChargeSignCut (  ) 

Definition at line 4654 of file NuAnalysis.cxx.

References NuEvent::anaVersion, NuConfig::beamType, MadDpID::CalcPID(), NuCuts::CalcTotalPot(), NuEvent::charge, MadDpID::ChoosePDFs(), NuEvent::detector, NuEvent::dpID, NuEvent::energy, NuGeneral::EpochTo1995(), NtpStRecord::evt, NuEvent::evt, NtpStRecord::evthdr, ExtractConfig(), NuExtraction::ExtractGeneralInfo(), NuPlots::FillContainmentHistos(), NuPlots::FillGeneralHistos(), NuPlots::FillRangeCurvCompHistos(), NuPlots::FillRelativeAngleHistos(), NuPlots::FillTrackResponseHistos(), NuPlots::FillTruePIDHistos(), NuPlots::FillXYZHistos(), NtpSRTrack::fit, NuBase::fOutFile, VldContext::GetDetector(), NuBase::GetEntries(), RecRecordImp< T >::GetHeader(), NuBase::GetNtpStRecord(), NuBase::GetNumFilesAddedToChain(), RecDataHeader::GetRun(), VldContext::GetSimFlag(), RecDataHeader::GetSubRun(), NuReco::GetTruthInfo(), RecHeader::GetVldContext(), NuEvent::iaction, NuBase::InitialiseLoopVariables(), NuLibrary::Instance(), NuEvent::inu, NuBeam::IsGoodSpillAndFillPot(), NuCuts::IsInFidVol(), LISieve::IsLI(), Msg::kDebug, Msg::kInfo, NtpSREventSummary::litime, MAXMSG, NtpSRTrack::momentum, MSG, NtpSREvent::ntrack, NuBase::OpenFile(), NuBase::OpenTxtFile(), NtpSRFitTrack::pass, plots(), NuEvent::pot, NtpSRMomentum::qp, NuEvent::releaseType, NuConfig::run, NuEvent::run, NuConfig::sBeamType, NuMadAnalysis::SetEntry(), NuGeneral::SetGraphAxis(), NuBase::SetLoopVariables(), NuEvent::shwEn, NuEvent::simFlag, NuEvent::snarl, NuGeneral::TH1FFill(), NuEvent::trkEn, NtpSRVertex::u, NtpSRVertex::v, NtpSREvent::vtx, NtpSRVertex::x, NuEvent::y, NtpSRVertex::y, and NtpSRVertex::z.

04655 {
04656   MSG("NuAnalysis",Msg::kInfo) 
04657     <<" ** Running ChargeSignCut method... **"<<endl;
04658   
04659   NuConfig config;
04660   this->ExtractConfig(config);
04661 
04662   //open the output file for the histograms
04663   string sFilePrefix="NMBCutQ"+config.sBeamType;
04664   fOutFile=this->OpenFile(config,sFilePrefix.c_str());
04665 
04666   TH1F* hNuMuBarRecoEn=new TH1F("hNuMuBarRecoEn","hNuMuBarRecoEn",
04667                                 4*352,-32,320);
04668   hNuMuBarRecoEn->GetXaxis()->SetTitle("Energy (GeV)");
04669   hNuMuBarRecoEn->GetXaxis()->CenterTitle();
04670   hNuMuBarRecoEn->GetYaxis()->SetTitle("");
04671   hNuMuBarRecoEn->GetYaxis()->CenterTitle();
04672   hNuMuBarRecoEn->SetFillColor(0);
04673   hNuMuBarRecoEn->SetLineColor(2);
04674   //hNuMuBarRecoEn->SetBit(TH1::kCanRebin);
04675   
04676   TH1F* hNuMuRecoEn=new TH1F("hNuMuRecoEn","hNuMuRecoEn",4*352,-32,320);
04677   hNuMuRecoEn->GetXaxis()->SetTitle("Energy (GeV)");
04678   hNuMuRecoEn->GetXaxis()->CenterTitle();
04679   hNuMuRecoEn->GetYaxis()->SetTitle("");
04680   hNuMuRecoEn->GetYaxis()->CenterTitle();
04681   hNuMuRecoEn->SetFillColor(0);
04682   hNuMuRecoEn->SetLineColor(1);
04683   hNuMuRecoEn->SetLineWidth(2);
04684   //hNuMuRecoEn->SetBit(TH1::kCanRebin);
04685 
04686   TH1F* hNuMuBarRecoY=new TH1F("hNuMuBarRecoY","hNuMuBarRecoY",
04687                                 4*144,-0.16,1.28);
04688   hNuMuBarRecoY->GetXaxis()->SetTitle("y");
04689   hNuMuBarRecoY->GetXaxis()->CenterTitle();
04690   hNuMuBarRecoY->GetYaxis()->SetTitle("");
04691   hNuMuBarRecoY->GetYaxis()->CenterTitle();
04692   hNuMuBarRecoY->SetFillColor(0);
04693   hNuMuBarRecoY->SetLineColor(2);
04694   //hNuMuBarRecoY->SetBit(TH1::kCanRebin);
04695   
04696   TH1F* hNuMuRecoY=new TH1F("hNuMuRecoY","hNuMuRecoY",4*144,-0.16,1.28);
04697   hNuMuRecoY->GetXaxis()->SetTitle("y");
04698   hNuMuRecoY->GetXaxis()->CenterTitle();
04699   hNuMuRecoY->GetYaxis()->SetTitle("");
04700   hNuMuRecoY->GetYaxis()->CenterTitle();
04701   hNuMuRecoY->SetFillColor(0);
04702   hNuMuRecoY->SetLineColor(1);
04703   hNuMuRecoY->SetLineWidth(2);
04704   //hNuMuRecoY->SetBit(TH1::kCanRebin);
04705 
04706   TH1F* hDpIDAll=new TH1F("hDpIDAll","hDpIDAll",4*160,-1.6,1.6);
04707   hDpIDAll->GetXaxis()->SetTitle("PID (from MadDpID)");
04708   hDpIDAll->GetXaxis()->CenterTitle();
04709   hDpIDAll->GetYaxis()->SetTitle("");
04710   hDpIDAll->GetYaxis()->CenterTitle();
04711   hDpIDAll->SetFillColor(0);
04712   hDpIDAll->SetLineColor(1);
04713   hDpIDAll->SetLineWidth(2);
04714   //hDpIDAll->SetBit(TH1::kCanRebin);
04715 
04716   TH1F* hDpIDPQ=new TH1F("hDpIDPQ","hDpIDPQ",4*160,-1.6,1.6);
04717   hDpIDPQ->GetXaxis()->SetTitle("PID (from MadDpID)");
04718   hDpIDPQ->GetXaxis()->CenterTitle();
04719   hDpIDPQ->GetYaxis()->SetTitle("");
04720   hDpIDPQ->GetYaxis()->CenterTitle();
04721   hDpIDPQ->SetFillColor(0);
04722   hDpIDPQ->SetLineColor(1);
04723   hDpIDPQ->SetLineWidth(2);
04724   //hDpIDPQ->SetBit(TH1::kCanRebin);
04725 
04726   TH1F* hDpIDNQ=new TH1F("hDpIDNQ","hDpIDNQ",4*160,-1.6,1.6);
04727   hDpIDNQ->GetXaxis()->SetTitle("PID (from MadDpID)");
04728   hDpIDNQ->GetXaxis()->CenterTitle();
04729   hDpIDNQ->GetYaxis()->SetTitle("");
04730   hDpIDNQ->GetYaxis()->CenterTitle();
04731   hDpIDNQ->SetFillColor(0);
04732   hDpIDNQ->SetLineColor(1);
04733   hDpIDNQ->SetLineWidth(2);
04734   //hDpIDNQ->SetBit(TH1::kCanRebin);
04735 
04736   TH1F* hDpIDPQN_1=new TH1F("hDpIDPQN_1","hDpIDPQN_1",4*160,-1.6,1.6);
04737   hDpIDPQN_1->GetXaxis()->SetTitle("PID (from MadDpID)");
04738   hDpIDPQN_1->GetXaxis()->CenterTitle();
04739   hDpIDPQN_1->GetYaxis()->SetTitle("");
04740   hDpIDPQN_1->GetYaxis()->CenterTitle();
04741   hDpIDPQN_1->SetFillColor(0);
04742   hDpIDPQN_1->SetLineColor(1);
04743   hDpIDPQN_1->SetLineWidth(2);
04744   //hDpIDPQN_1->SetBit(TH1::kCanRebin);
04745 
04746   TH1F* hDpIDNQN_1=new TH1F("hDpIDNQN_1","hDpIDNQN_1",4*160,-1.6,1.6);
04747   hDpIDNQN_1->GetXaxis()->SetTitle("PID (from MadDpID)");
04748   hDpIDNQN_1->GetXaxis()->CenterTitle();
04749   hDpIDNQN_1->GetYaxis()->SetTitle("");
04750   hDpIDNQN_1->GetYaxis()->CenterTitle();
04751   hDpIDNQN_1->SetFillColor(0);
04752   hDpIDNQN_1->SetLineColor(1);
04753   hDpIDNQN_1->SetLineWidth(2);
04754   //hDpIDNQN_1->SetBit(TH1::kCanRebin);
04755 
04756   //vectors
04757   Int_t entries=static_cast<Int_t>(this->GetEntries());
04758   Int_t startTimeSecs=2000000000;//2 billion
04759   Int_t endTimeSecs=1;
04760   vector<Double_t> vPot;
04761   vPot.reserve(entries);
04762   vector<Double_t> vTime;
04763   vTime.reserve(entries);
04764   vector<Double_t> vPotBad;
04765   vPotBad.reserve(entries/10);
04766   vector<Double_t> vTimeBad;
04767   vTimeBad.reserve(entries/10);
04768   
04769   vector<Double_t> vTimeNuMuEvt;
04770   vTimeNuMuEvt.reserve(entries/5);
04771   vector<Double_t> vTimeNuMuBarEvt;
04772   vTimeNuMuBarEvt.reserve(entries/5);
04773  
04774   //maps to store evt info
04775   map<Int_t,Double_t> deltaTs;
04776   map<Int_t,Int_t> evtsPerSlc;
04777 
04778   //counters
04779   Int_t goodSpillCounter=0;
04780   Int_t badSpillCounter=0;
04781   Float_t totalPot=0;
04782   Float_t totalPotBad=0;
04783   Int_t evtCounter=0;
04784   Int_t evtNotlitime=0;
04785   Int_t evtNotIsLI=0;
04786   Int_t evtInFidVolCounter=0;
04787   Int_t evtWithTrkCounter=0;
04788   Int_t goodBestTrkCounter=0;
04789   Int_t goodTrkPassCounter=0;
04790   Int_t goodRecoEnCounter=0;
04791   Int_t goodUVDiffCounter=0;
04792   Int_t trkInFidVolCounter=0;
04793   Int_t goodFitSigQPCounter=0;
04794   Int_t goodFitProbCounter=0;
04795   Int_t goodFitChi2Counter=0;
04796   Int_t goodDeltaTCounter=0;
04797   Int_t goodEvtsPerSlcCounter=0; 
04798   Int_t goodPIDCounter=0;
04799   Int_t goodBeyondTrkEndCounter=0;
04800   Int_t goodShwFractCounter=0;
04801   Int_t nuNQCounter=0;
04802   Int_t nuPQCounter=0;
04803   
04804   string sTxtFilePrefix="nmbQCut"+config.sBeamType;
04805   ofstream& nmbTxt=*(this->OpenTxtFile(config,
04806                                        sTxtFilePrefix.c_str()));
04807   nmbTxt<<"# All NuMuBar like events (with standard CC cuts)"<<endl;
04808   nmbTxt<<"#"<<endl;
04809 
04810   sTxtFilePrefix="nmbQCut05"+config.sBeamType;
04811   ofstream& nmb05Txt=*(this->OpenTxtFile(config,
04812                                        sTxtFilePrefix.c_str()));
04813   nmb05Txt<<"# NuMuBar like events below 5 GeV (with standard CC cuts)"
04814           <<endl;
04815   nmb05Txt<<"#"<<endl;
04816 
04817   sTxtFilePrefix="nmbQCut02"+config.sBeamType;
04818   ofstream& nmb02Txt=*(this->OpenTxtFile(config,
04819                                        sTxtFilePrefix.c_str()));
04820   nmb02Txt<<"# NuMuBar like events below 2 GeV (with standard CC cuts)"
04821           <<endl;
04822   nmb02Txt<<"#"<<endl;
04823 
04824   //classes to organise the code in to related functions
04825   const NuCuts cuts;
04826   const NuGeneral general;
04827   const NuPlots plots;
04828   const NuReco reco;
04829   const NuExtraction ext;
04830   const NuBeam beam;
04831 
04832   //create these on the heap so that they don't destruct
04833   // - on purpose to avoid a segv on destruction... nice coding!
04834   NuMadAnalysis& mad=*new NuMadAnalysis();
04835   MadDpID& dp=*new MadDpID();
04836   //BeamType::BeamType_t beamType=BeamType::kLE;
04837   BeamType::BeamType_t beamType=static_cast
04838     <BeamType::BeamType_t>(config.beamType);
04839 
04840   //get an instance of the code library
04841   const NuLibrary& lib=NuLibrary::Instance();
04842  
04846   
04847   this->InitialiseLoopVariables();  
04848   
04849   //for(Int_t entry=0;entry<10000;entry++){
04850   for(Int_t entry=0;entry<this->GetEntries();entry++){
04851       
04852     this->SetLoopVariables(entry);
04853       
04854     //get reference to NtpStRecord from base class
04855     const NtpStRecord& ntp=(*this->GetNtpStRecord());
04856 
04857     const RecCandHeader& rec=ntp.GetHeader();
04858     MAXMSG("NuAnalysis",Msg::kInfo,5)
04859       <<"Found: run="<<rec.GetRun()
04860       <<", subrun="<<rec.GetSubRun()
04861       <<", detector="<<rec.GetVldContext().GetDetector()
04862       <<", simFlag="<<rec.GetVldContext().GetSimFlag()
04863       <<endl;
04864 
04865     //write out the detector, simflag, etc
04866     plots.FillGeneralHistos(ntp);
04867 
04868     //simple event object to hold important quantities for snarl
04869     NuEvent nuSnarl;
04870     
04871     //get the run, snarl, etc info
04872     ext.ExtractGeneralInfo(ntp,nuSnarl);
04873 
04874     if (!beam.IsGoodSpillAndFillPot
04875         (this->GetNtpBDLiteRecord(),config,nuSnarl)) {
04876       badSpillCounter++;
04877       totalPotBad+=nuSnarl.pot;
04878       continue;
04879     }
04880     goodSpillCounter++;
04881     totalPot+=nuSnarl.pot;    
04882 
04883     dp.ChoosePDFs(rec.GetVldContext().GetDetector(),beamType);
04884     mad.SetEntry(&ntp);
04885 
04886     TClonesArray& evtTca=(*ntp.evt);
04887     const Int_t numEvts=evtTca.GetEntriesFast();
04888 
04890     //loop over the reconstructed events
04892     for (Int_t ievt=0;ievt<numEvts;ievt++){
04893       const NtpSREvent& evt=
04894         *dynamic_cast<NtpSREvent*>(evtTca[ievt]);
04895       evtCounter++;
04896 
04897       const NtpSREventSummary& evthdr=ntp.evthdr;
04898       
04899       if (evthdr.litime!=-1) {
04900         MAXMSG("NuAnalysis",Msg::kInfo,500)
04901           <<"skipping event: litime="<<evthdr.litime<<endl;
04902         continue;
04903       }
04904       evtNotlitime++;
04905 
04906       Bool_t isLI=LISieve::IsLI(ntp);
04907       if (isLI){
04908         MAXMSG("NuAnalysis",Msg::kInfo,5)
04909           <<endl<<endl<<endl
04910           <<"Found LI"
04911           <<", run="<<config.run
04912           <<", entry="<<entry
04913           <<", event="<<ievt
04914           <<", litime="<<evthdr.litime
04915           <<endl<<endl<<endl;
04916       }
04917       else {
04918         MAXMSG("NuAnalysis",Msg::kDebug,50)
04919           <<"Not LI"
04920           <<", run="<<config.run
04921           <<", entry="<<entry
04922           <<", event="<<ievt
04923           <<", litime="<<evthdr.litime
04924           <<endl;
04925       }
04926       if (isLI) continue;
04927       evtNotIsLI++;
04928 
04929       //simple event object to hold important quantities
04930       NuEvent nu;
04931       
04932       //get the run, snarl, etc info
04933       ext.ExtractGeneralInfo(ntp,nu);
04934       
04935       Bool_t isInFidVol=cuts.IsInFidVol(evt.vtx.x,evt.vtx.y,
04936                                         evt.vtx.z,
04937                                         evt.vtx.u,evt.vtx.v,0,0,
04938                                         nu.detector,nu.anaVersion,
04939                                         nu.releaseType,nu.simFlag);
04940 
04941       if (!isInFidVol) continue;
04942       evtInFidVolCounter++;
04943 
04944       nu.dpID=dp.CalcPID(&mad,ievt,0);
04945       MAXMSG("NuAnalysis",Msg::kDebug,50)
04946         <<"dpID="<<nu.dpID<<endl;
04947       hDpIDAll->Fill(nu.dpID);
04948             
04949       //ensure there is a track in the event
04950       if (evt.ntrack<1) continue;
04951       //if (evt.ntrack!=1) continue;//require exactly 1 track
04952       evtWithTrkCounter++;
04953 
04954       //get the best track in the event
04955       Int_t bestTrack=lib.reco.GetBestTrack(nu);
04956       const NtpSRTrack* ptrk=lib.reco.GetTrackWithIndexX
04957         (ntp,evt,bestTrack-1);
04958       if (ptrk==0) continue;
04959       const NtpSRTrack& trk=*ptrk;
04960       goodBestTrkCounter++;
04961 
04962       //require a trk fit
04963       if (!trk.fit.pass) continue;
04964       goodTrkPassCounter++;
04965 
04966       
04968       //RECONSTRUCT the neutrino energy
04969       lib.reco.GetEvtEnergy(nu, false);
04970       goodRecoEnCounter++;
04971   
04972       //get the truth info (reco quantities are done above)
04973       reco.GetTruthInfo(ntp,evt,nu);
04974 
04975       //set the charge
04976       nu.charge=trk.momentum.qp<0 ? -1 : +1;
04977       if (trk.momentum.qp==0) nu.charge=0;
04978 
04979       //cut on the fractional track momentum and sign error      
04980       //if (!cuts.IsGoodSigmaQP_QP(nu)) continue;
04981       //goodFitSigQPCounter++;
04982       
04983       //cut on the track fit probability      
04984       //if (!cuts.IsGoodFitProb(nu)) continue;
04985       //goodFitProbCounter++;
04986 
04987       //Float_t chi2PerNdof=999999;
04988       //if (!cuts.IsGoodFitChi2PerNdof(nu)){
04989       //MAXMSG("NuAnalysis",Msg::kVerbose,100)
04990       //<<"Cutting out bad chi2PerNdof="<<chi2PerNdof<<endl;
04991       //continue;
04992       //}
04993       //goodFitChi2Counter++;
04994 
04995       //cut on the PID
04996       //if (!cuts.IsGoodDpID(nu)) continue;
04997       if (nu.dpID<=-0.1) continue;
04998       goodPIDCounter++;
04999       
05000       if (trk.momentum.qp<0) {
05001         hNuMuRecoEn->Fill(nu.energy);
05002         hNuMuRecoY->Fill(nu.y);
05003         hDpIDNQ->Fill(nu.dpID);
05004         nuNQCounter++;
05005       }
05006       else if (trk.momentum.qp>0) {
05007         string siaction="CC";
05008         if (nu.iaction==0) siaction="NC";
05009         //file format: run snarl event
05010         nmbTxt<<"#"<<endl;
05011         nmbTxt<<"# recoEn="<<nu.energy
05012               <<", trkEn="<<nu.trkEn
05013               <<", shwEn="<<nu.shwEn
05014               <<", recoy="<<nu.y
05015               <<", true inu="<<nu.inu
05016               <<" "<<siaction
05017               <<endl;
05018         nmbTxt<<nu.run<<" "<<nu.snarl<<" "<<nu.evt<<endl;
05019         if (nu.energy<5){
05020           nmb05Txt<<"#"<<endl;
05021           nmb05Txt<<"# recoEn="<<nu.energy
05022                   <<", trkEn="<<nu.trkEn
05023                   <<", shwEn="<<nu.shwEn
05024                   <<", recoy="<<nu.y
05025                   <<", true inu="<<nu.inu
05026                   <<" "<<siaction
05027                   <<endl;
05028           nmb05Txt<<nu.run<<" "<<nu.snarl<<" "<<nu.evt<<endl;
05029         }
05030 
05031         if (nu.energy<2){
05032           nmb02Txt<<"#"<<endl;
05033           nmb02Txt<<"# recoEn="<<nu.energy
05034                   <<", trkEn="<<nu.trkEn
05035                   <<", shwEn="<<nu.shwEn
05036                   <<", recoy="<<nu.y
05037                   <<", true inu="<<nu.inu
05038                   <<" "<<siaction
05039                   <<endl;
05040           nmb02Txt<<nu.run<<" "<<nu.snarl<<" "<<nu.evt<<endl;
05041         }
05042         
05043         hNuMuBarRecoEn->Fill(nu.energy);
05044         hNuMuBarRecoY->Fill(nu.y);
05045         hDpIDPQ->Fill(nu.dpID);
05046         nuPQCounter++;
05047       }
05048       else cout<<"ahhh, zero qp"<<endl;
05049 
05050       plots.FillXYZHistos(nu);
05051       plots.FillContainmentHistos(nu);
05052       plots.FillRelativeAngleHistos(nu);
05053       plots.FillTruePIDHistos(nu);
05054       plots.FillTrackResponseHistos(ntp,trk,nu);
05055       plots.FillRangeCurvCompHistos(nu);
05056     }
05057   }//end of for                                       
05058   
05062 
05063   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
05064 
05065   //store the number of files added to the chain
05066   Int_t nf=this->GetNumFilesAddedToChain();
05067   TH1F* hRun=dynamic_cast<TH1F*>(gROOT->FindObject("hRun"));
05068   Float_t nr=-1;
05069   if (hRun) nr=hRun->GetEntries();
05070   TH1F* hNumFiles=new TH1F("hNumFiles","hNumFiles",15,-5,10);
05071   hNumFiles->Fill(1,nf);//store as weight, access with GetMaximum
05072   MSG("NuAnalysis",Msg::kInfo)
05073     <<"Files added to chain="<<hNumFiles->GetMaximum()
05074     <<", runs found="<<nr<<endl;
05075 
05076   MSG("NuAnalysis",Msg::kInfo)
05077     <<"Found start time and end time: "
05078     <<startTimeSecs<<" -> "<<endTimeSecs<<endl;
05079   general.EpochTo1995(endTimeSecs);
05080   general.EpochTo1995(startTimeSecs);
05081   
05082   MSG("NuAnalysis",Msg::kInfo)<<"Filling vs. Time plots..."<<endl;
05083   TH1F* hSpillsVsTime=new TH1F("hSpillsVsTime","hSpillsVsTime",
05084                                100,startTimeSecs,endTimeSecs);
05085   general.TH1FFill(hSpillsVsTime,vTime);
05086   general.SetGraphAxis(hSpillsVsTime->GetXaxis(),
05087                      startTimeSecs,endTimeSecs);
05088   hSpillsVsTime->GetXaxis()->CenterTitle();
05089   hSpillsVsTime->GetYaxis()->SetTitle("Spills");
05090   hSpillsVsTime->GetYaxis()->CenterTitle();
05091 
05092   TH1F* hSpillsBadVsTime=new TH1F("hSpillsBadVsTime","hSpillsBadVsTime",
05093                                   100,startTimeSecs,endTimeSecs);
05094   general.TH1FFill(hSpillsBadVsTime,vTimeBad);
05095   general.SetGraphAxis(hSpillsBadVsTime->GetXaxis(),
05096                      startTimeSecs,endTimeSecs);
05097   hSpillsBadVsTime->GetXaxis()->CenterTitle();
05098   hSpillsBadVsTime->GetYaxis()->SetTitle("Spills");
05099   hSpillsBadVsTime->GetYaxis()->CenterTitle();
05100   
05101   TH1F* hNuMuVsTime=new TH1F("hNuMuVsTime","hNuMuVsTime",
05102                              100,startTimeSecs,endTimeSecs);
05103   general.TH1FFill(hNuMuVsTime,vTimeNuMuEvt);
05104   general.SetGraphAxis(hNuMuVsTime->GetXaxis(),
05105                      startTimeSecs,endTimeSecs);
05106   hNuMuVsTime->GetXaxis()->CenterTitle();
05107   hNuMuVsTime->GetYaxis()->SetTitle("#nu_#mu events");
05108   hNuMuVsTime->GetYaxis()->CenterTitle();
05109 
05110   TH1F* hNuMuBarVsTime=new TH1F("hNuMuBarVsTime","hNuMuBarVsTime",
05111                                100,startTimeSecs,endTimeSecs);
05112   general.TH1FFill(hNuMuBarVsTime,vTimeNuMuBarEvt);
05113   general.SetGraphAxis(hNuMuBarVsTime->GetXaxis(),
05114                      startTimeSecs,endTimeSecs);
05115   hNuMuBarVsTime->GetXaxis()->CenterTitle();
05116   hNuMuBarVsTime->GetYaxis()->SetTitle("#bar{#nu_#mu} events");
05117   hNuMuBarVsTime->GetYaxis()->CenterTitle();
05118 
05119   TH1F* hPotVsTime=new TH1F("hPotVsTime","hPotVsTime",
05120                              100,startTimeSecs,endTimeSecs);
05121   general.TH1FFill(hPotVsTime,vTime,vPot);
05122   general.SetGraphAxis(hPotVsTime->GetXaxis(),
05123                      startTimeSecs,endTimeSecs);
05124   hPotVsTime->GetXaxis()->CenterTitle();
05125   hPotVsTime->GetYaxis()->SetTitle("POT");
05126   hPotVsTime->GetYaxis()->CenterTitle();
05127 
05128   TH1F* hPotBadVsTime=new TH1F("hPotBadVsTime","hPotBadVsTime",
05129                              100,startTimeSecs,endTimeSecs);
05130   general.TH1FFill(hPotBadVsTime,vTimeBad,vPotBad);
05131   general.SetGraphAxis(hPotBadVsTime->GetXaxis(),
05132                      startTimeSecs,endTimeSecs);
05133   hPotBadVsTime->GetXaxis()->CenterTitle();
05134   hPotBadVsTime->GetYaxis()->SetTitle("POT");
05135   hPotBadVsTime->GetYaxis()->CenterTitle();
05136   
05137   Float_t totalPotHist=0;
05138   Float_t totalPotBadHist=0;
05139   cuts.CalcTotalPot(totalPotHist,totalPotBadHist);
05140   Float_t pcPotRejected=0;
05141   if (totalPotHist) pcPotRejected=100.*totalPotBadHist/totalPotHist;
05142 
05143   //msg was giving pots=412886000000000000.000000... still is for MC!
05144   cout<<"Number of spills     ="<<this->GetEntries()<<endl
05145       <<"Number of good spills="<<goodSpillCounter<<endl
05146       <<"Number of bad spills ="<<badSpillCounter<<endl
05147       <<"Sum of good+bad spill="<<badSpillCounter+goodSpillCounter<<endl
05148       <<endl
05149       <<"Total POT good       ="<<totalPot*1e12<<endl
05150       <<"Total POT bad        ="<<totalPotBad*1e12<<endl
05151       <<"Total POT good (hist)="<<totalPotHist*1e12<<endl
05152       <<"Total POT bad  (hist)="<<totalPotBadHist*1e12
05153       <<"  ("<<pcPotRejected<<"%)"<<endl;
05154 
05155   MSG("NuAnalysis",Msg::kInfo)
05156     <<endl<<"*************************************"<<endl
05157     <<"Total Events    ="<<evtCounter<<endl
05158     <<"Evt not litime  ="<<evtNotlitime<<endl
05159     <<"Evt not IsLI    ="<<evtNotIsLI<<endl
05160     <<"Evts in Fid     ="<<evtInFidVolCounter<<endl
05161     <<"Evts w/ Trk     ="<<evtWithTrkCounter<<endl
05162     <<"Good Best Trk   ="<<goodBestTrkCounter<<endl
05163     <<"Track Pass      ="<<goodTrkPassCounter<<endl
05164     <<"Good reco energy="<<goodRecoEnCounter<<endl
05165     <<"Good UVDiff     ="<<goodUVDiffCounter<<endl
05166     <<"Trk Vtx in Fid  ="<<trkInFidVolCounter<<endl
05167     <<"Good Fit SigQP  ="<<goodFitSigQPCounter<<endl
05168     <<"Good Fit Prob   ="<<goodFitProbCounter<<endl
05169     <<"Good Fit Chi2   ="<<goodFitChi2Counter<<endl
05170     <<"Good Delta T    ="<<goodDeltaTCounter<<endl
05171     <<"Good EvtPerSlc  ="<<goodEvtsPerSlcCounter<<endl
05172     <<"Good DP ID      ="<<goodPIDCounter<<endl
05173     <<"Good beyond tEnd="<<goodBeyondTrkEndCounter<<endl
05174     <<"Good shw fract  ="<<goodShwFractCounter<<endl
05175     <<"*************************************"<<endl;
05176 
05177   Float_t pcPQ=0;
05178   if (nuPQCounter+nuNQCounter>0) pcPQ=100.*nuPQCounter/
05179                                    (nuPQCounter+nuNQCounter);
05180   MSG("NuAnalysis",Msg::kInfo)
05181     <<endl
05182     <<"Neutrinos with NQ="<<nuNQCounter<<endl
05183     <<"Neutrinos with PQ="<<nuPQCounter
05184     <<"   ("<<pcPQ<<"%)"<<endl
05185     <<"Sum NQ+PQ        ="<<nuNQCounter+nuPQCounter<<endl
05186     <<endl;
05187   
05188   MSG("NuAnalysis",Msg::kInfo) 
05189     <<" ** Finished ChargeSignCut method **"<<endl;
05190 }

const std::vector< Int_t > NuAnalysis::ContributingTrueEvents ( const NuEvent event  )  const [virtual]

Definition at line 7042 of file NuAnalysis.cxx.

References NuEvent::mc, NuEvent::mcEvt, NuEvent::mcShw, NuEvent::mcShw1, NuEvent::mcShw2, NuEvent::mcShw3, NuEvent::mcShw4, NuEvent::mcShw5, NuEvent::mcTrk, NuEvent::mcTrk1, NuEvent::mcTrk2, NuEvent::mcTrk3, NuEvent::shwExists1, NuEvent::shwExists2, NuEvent::shwExists3, NuEvent::shwExists4, NuEvent::shwExists5, NuEvent::trkExists1, NuEvent::trkExists2, and NuEvent::trkExists3.

Referenced by MakeFullDST().

07043 {
07044   std::vector<Int_t> vTthInd;
07045   vTthInd.push_back(event.mc);
07046   if (event.mcEvt != event.mc && event.mcEvt > -1)
07047     {vTthInd.push_back(event.mcEvt);}
07048   if (event.mcTrk != event.mc && event.mcTrk > -1)
07049     {vTthInd.push_back(event.mcTrk);}
07050   if (event.mcShw != event.mc && event.mcShw > -1)
07051     {vTthInd.push_back(event.mcShw);}
07052   if (event.mcTrk1 != event.mcTrk && event.trkExists1 && event.mcTrk1 > -1)
07053     {vTthInd.push_back(event.mcTrk1);}
07054   if (event.mcTrk2 != event.mcTrk && event.trkExists2 && event.mcTrk2 > -1)
07055     {vTthInd.push_back(event.mcTrk2);}
07056   if (event.mcTrk3 != event.mcTrk && event.trkExists3 && event.mcTrk3 > -1)
07057     {vTthInd.push_back(event.mcTrk3);}
07058   if (event.mcShw1 != event.mcShw && event.shwExists1 && event.mcShw1 > -1)
07059     {vTthInd.push_back(event.mcShw1);}
07060   if (event.mcShw2 != event.mcShw && event.shwExists2 && event.mcShw2 > -1)
07061     {vTthInd.push_back(event.mcShw2);}
07062   if (event.mcShw3 != event.mcShw && event.shwExists3 && event.mcShw3 > -1)
07063     {vTthInd.push_back(event.mcShw3);}
07064   if (event.mcShw4 != event.mcShw && event.shwExists4 && event.mcShw4 > -1)
07065     {vTthInd.push_back(event.mcShw4);}
07066   if (event.mcShw5 != event.mcShw && event.shwExists5 && event.mcShw5 > -1)
07067     {vTthInd.push_back(event.mcShw5);}
07068   return vTthInd;
07069 }

void NuAnalysis::CopyAcrossHistos ( TDirectory *  dirInput,
TDirectory *  dirOutput 
) const [private]

Definition at line 5777 of file NuAnalysis.cxx.

References NuGeneral::CopyAcrossObjects().

Referenced by NMBSummaryTreeAna().

05779 {
05780   //vector to store the names of the histograms to copy across
05781   vector<string> vObjectNames;
05782   vObjectNames.push_back("hDetector");
05783   vObjectNames.push_back("hSimFlag");
05784   vObjectNames.push_back("hTrigSrc");
05785   vObjectNames.push_back("hRun");
05786   vObjectNames.push_back("hPottortgt");
05787   vObjectNames.push_back("hPotBadtortgt");
05788   vObjectNames.push_back("hPottrtgtd");
05789   vObjectNames.push_back("hPotBadtrtgtd");
05790   vObjectNames.push_back("hPottor101");
05791   vObjectNames.push_back("hPotBadtor101");
05792   vObjectNames.push_back("hPottr101d");
05793   vObjectNames.push_back("hPotBadtr101d");
05794   vObjectNames.push_back("hSpillsPerFile");
05795 
05796   NuGeneral general;
05797   general.CopyAcrossObjects(dirInput,dirOutput,vObjectNames);
05798 }

void NuAnalysis::CopyConfig ( const NuConfig config,
NuEvent nu 
) [private]

Definition at line 6284 of file NuAnalysis.cxx.

References NuEvent::anaVersion, NuConfig::anaVersion, NuEvent::beamType, NuConfig::beamType, NuConfig::calcJmID, NuEvent::calcJmID, NuConfig::calcMajCurv, NuEvent::calcMajCurv, NuConfig::calcRoID, NuEvent::calcRoID, NuEvent::cutOnBeamInfo, NuConfig::cutOnBeamInfo, NuConfig::cutOnDataQuality, NuEvent::cutOnDataQuality, NuConfig::cutOnSpillTiming, NuEvent::cutOnSpillTiming, NuConfig::generatorConfigNo, NuEvent::generatorConfigNo, NuEvent::hornCur, NuConfig::hornCurrent, NuEvent::hornIsReverse, NuConfig::hornIsReverse, NuEvent::intensity, NuConfig::intensity, NuConfig::mcVersion, NuEvent::mcVersion, NuConfig::recoVersion, NuEvent::recoVersion, NuConfig::releaseType, NuEvent::releaseType, NuEvent::reweightVersion, NuConfig::reweightVersion, NuConfig::runPeriod, NuEvent::runPeriod, NuConfig::sGeneratorConfigName, NuEvent::sGeneratorConfigName, NuEvent::useDBForBeamInfo, NuConfig::useDBForBeamInfo, NuEvent::useDBForDataQuality, NuConfig::useDBForDataQuality, NuConfig::useDBForSpillTiming, NuEvent::useDBForSpillTiming, NuEvent::useGeneratorReweight, and NuConfig::useGeneratorReweight.

Referenced by ChargeSeparationOneSnarl(), LIRejectionTest(), and MakeFullDST().

06285 {
06286   nu.anaVersion=config.anaVersion;
06287 
06288   nu.useGeneratorReweight=config.useGeneratorReweight;
06289   nu.sGeneratorConfigName=config.sGeneratorConfigName;
06290   nu.generatorConfigNo=config.generatorConfigNo;
06291   nu.reweightVersion=config.reweightVersion;
06292 
06293   nu.mcVersion=config.mcVersion;
06294   nu.recoVersion=config.recoVersion;
06295   nu.releaseType=config.releaseType;
06296 
06297   nu.runPeriod=config.runPeriod;
06298   nu.hornIsReverse=config.hornIsReverse;
06299   nu.beamType=config.beamType;
06300   nu.intensity=config.intensity;
06301   nu.hornCur=config.hornCurrent;
06302 
06303   nu.useDBForDataQuality=config.useDBForDataQuality;
06304   nu.useDBForSpillTiming=config.useDBForSpillTiming;
06305   nu.useDBForBeamInfo=config.useDBForBeamInfo;
06306 
06307   nu.cutOnDataQuality=config.cutOnDataQuality;
06308   nu.cutOnSpillTiming=config.cutOnSpillTiming;
06309   nu.cutOnBeamInfo=config.cutOnBeamInfo;
06310 
06311   nu.calcMajCurv=config.calcMajCurv;
06312   nu.calcRoID=config.calcRoID;
06313   nu.calcJmID=config.calcJmID;
06314 
06315 }

void NuAnalysis::CopySnarlInfo ( const NuEvent nuSnarl,
NuEvent nu 
) [private]

Definition at line 6319 of file NuAnalysis.cxx.

References NuEvent::coilCurrent, NuEvent::coilIsOk, NuEvent::coilIsReverse, NuEvent::goodBeamSntp, and NuEvent::pot.

Referenced by ChargeSeparationOneSnarl(), and MakeFullDST().

06320 {
06321   //copy across
06322   nu.goodBeamSntp=nuSnarl.goodBeamSntp;
06323   nu.pot=nuSnarl.pot;
06324   nu.coilIsOk=nuSnarl.coilIsOk;
06325   nu.coilIsReverse=nuSnarl.coilIsReverse;
06326   nu.coilCurrent=nuSnarl.coilCurrent;
06327 }

TSpline3 * NuAnalysis::CreateTSpline3 ( std::string  splName,
std::string  varNames,
std::string  fileName 
) [private]

Definition at line 610 of file NuAnalysis.cxx.

References n, and TMath::Sort().

Referenced by CrossSections().

00613 {
00614   TNtuple nt(splName.c_str(),splName.c_str(),varNames.c_str());
00615   nt.ReadFile(fileName.c_str(),varNames.c_str());
00616   //nt.ReadFile("xsec.data", "E:xsec");
00617   //nt.Draw("E:xsec","","GOFF");
00618   nt.Print();
00619   //nt.Show(0);
00620   //nt.Show(1);
00621   //nt.Show(2);
00622 
00623   //Note: this line has to be here because it defines V1 and V2
00624   nt.Draw("energy:xsec","","GOFF");//graphics off
00625 
00626   unsigned int n = (int) nt.GetSelectedRows();
00627 #if ROOT_VERSION_CODE < ROOT_VERSION(5,21,5)
00628   int *    idx = new int[n];
00629 #else
00630   unsigned int * idx = new unsigned int[n];
00631 #endif
00632   double * xx  = new double[n];
00633   double * yy  = new double[n];
00634   
00635   TMath::Sort(n,nt.GetV1(),idx,false); // sort in energy
00636 
00637   for(unsigned int i=0; i<n; i++) {
00638     int ii = idx[i];
00639     xx[i]  = (nt.GetV1())[ii];
00640     yy[i]  = (nt.GetV2())[ii];
00641     //MSG("NuAnalysis",Msg::kInfo) 
00642     //<<"E="<<xx[i]<<" GeV, xsec="<<yy[i]<<endl;
00643   }
00644   
00645   TSpline3 * spl=new TSpline3(("spl"+splName).c_str(),xx,yy,n,"0");
00646   
00647   delete [] idx;
00648   delete [] xx;
00649   delete [] yy;
00650 
00651   return spl;
00652 }

void NuAnalysis::CrossSections (  ) 

Definition at line 656 of file NuAnalysis.cxx.

References CreateTSpline3(), NuBase::fOutFile, Msg::kInfo, MAXMSG, MSG, and NuBase::OpenFile().

00657 {
00658   MSG("NuAnalysis",Msg::kInfo) 
00659     <<" ** Running CrossSections method... **"<<endl;
00660   
00661   //open the output file for the histograms
00662   fOutFile=this->OpenFile(100,"NuCrossSections");
00663 
00664   cout<<"here"<<endl;
00665   TSpline3* splnumupCC=CreateTSpline3
00666     ("numupCC","energy:xsec",
00667      "/home/hartnell/mytest/NuMuBar/numu-p-CC.txt");
00668   cout<<"here"<<endl;
00669   TSpline3* splnumunCC=CreateTSpline3
00670     ("numunCC","energy:xsec",
00671      "/home/hartnell/mytest/NuMuBar/numu-n-CC.txt");
00672   cout<<"here"<<endl;
00673   TSpline3* splnumubarpCC=CreateTSpline3
00674     ("numubarpCC","energy:xsec",
00675      "/home/hartnell/mytest/NuMuBar/numubar-p-CC.txt");
00676   cout<<"here"<<endl;
00677   TSpline3* splnumubarnCC=CreateTSpline3
00678     ("numubarnCC","energy:xsec",
00679      "/home/hartnell/mytest/NuMuBar/numubar-n-CC.txt");
00680   cout<<"hereend"<<endl;
00681  
00682   TH1F* hXsecNuMuPCC=new TH1F("hXsecNuMuPCC","hXsecNuMuPCC",
00683                               1000,0,100);
00684   hXsecNuMuPCC->SetTitle("NuMu Cross Section on Protons");
00685   hXsecNuMuPCC->GetXaxis()->SetTitle("Energy (GeV)");
00686   hXsecNuMuPCC->GetXaxis()->CenterTitle();
00687   hXsecNuMuPCC->GetYaxis()->SetTitle("#sigma (cm^{2})");
00688   hXsecNuMuPCC->GetYaxis()->CenterTitle();
00689 
00690   TH1F* hXsecNuMuNCC=new TH1F("hXsecNuMuNCC","hXsecNuMuNCC",
00691                               1000,0,100);
00692   hXsecNuMuNCC->SetTitle("NuMu Cross Section on Neutrons");
00693   hXsecNuMuNCC->GetXaxis()->SetTitle("Energy (GeV)");
00694   hXsecNuMuNCC->GetXaxis()->CenterTitle();
00695   hXsecNuMuNCC->GetYaxis()->SetTitle("#sigma (cm^{2})");
00696   hXsecNuMuNCC->GetYaxis()->CenterTitle();
00697 
00698   TH1F* hXsecNuMuBarPCC=new TH1F("hXsecNuMuBarPCC","hXsecNuMuBarPCC",
00699                                  1000,0,100);
00700   hXsecNuMuBarPCC->SetTitle("NuMuBar Cross Section on Protons");
00701   hXsecNuMuBarPCC->GetXaxis()->SetTitle("Energy (GeV)");
00702   hXsecNuMuBarPCC->GetXaxis()->CenterTitle();
00703   hXsecNuMuBarPCC->GetYaxis()->SetTitle("#sigma (cm{^2})");
00704   hXsecNuMuBarPCC->GetYaxis()->CenterTitle();
00705   
00706   TH1F* hXsecNuMuBarNCC=new TH1F("hXsecNuMuBarNCC","hXsecNuMuBarNCC",
00707                                  1000,0,100);
00708   hXsecNuMuBarNCC->SetTitle("NuMuBar Cross Section on Neutrons");
00709   hXsecNuMuBarNCC->GetXaxis()->SetTitle("Energy (GeV)");
00710   hXsecNuMuBarNCC->GetXaxis()->CenterTitle();
00711   hXsecNuMuBarNCC->GetYaxis()->SetTitle("#sigma (cm^{2})");
00712   hXsecNuMuBarNCC->GetYaxis()->CenterTitle();
00713 
00714 
00715   TH1F* hXsecNuMuFeCC=new TH1F("hXsecNuMuFeCC","hXsecNuMuFeCC",
00716                               1000,0,100);
00717   hXsecNuMuFeCC->SetTitle("NuMu Cross Section on Fe");
00718   hXsecNuMuFeCC->GetXaxis()->SetTitle("Energy (GeV)");
00719   hXsecNuMuFeCC->GetXaxis()->CenterTitle();
00720   hXsecNuMuFeCC->GetYaxis()->SetTitle("#sigma (cm^{2})");
00721   hXsecNuMuFeCC->GetYaxis()->CenterTitle();
00722 
00723   TH1F* hXsecNuMuBarFeCC=new TH1F("hXsecNuMuBarFeCC","hXsecNuMuBarFeCC",
00724                                  1000,0,100);
00725   hXsecNuMuBarFeCC->SetTitle("NuMuBar Cross Section on Fe");
00726   hXsecNuMuBarFeCC->GetXaxis()->SetTitle("Energy (GeV)");
00727   hXsecNuMuBarFeCC->GetXaxis()->CenterTitle();
00728   hXsecNuMuBarFeCC->GetYaxis()->SetTitle("#sigma (cm^{2})");
00729   hXsecNuMuBarFeCC->GetYaxis()->CenterTitle();
00730   
00731 
00732   for (Float_t i=0.05;i<100;i+=0.1){
00733     MAXMSG("NuAnalysis",Msg::kInfo,20) 
00734       <<"E="<<i<<" GeV"<<endl
00735       <<"  numu    p CC xsec="<<splnumupCC->Eval(i)<<"e-38 cm^2"
00736       <<", numu    n CC xsec="<<splnumunCC->Eval(i)<<"e-38 cm^2"<<endl
00737       <<"  numubar p CC xsec="<<splnumubarpCC->Eval(i)<<"e-38 cm^2"
00738       <<", numubar n CC xsec="<<splnumubarnCC->Eval(i)<<"e-38 cm^2"
00739       <<endl;
00740 
00741     Float_t xsecNuMuPCC=splnumupCC->Eval(i)<0 ? 0:splnumupCC->Eval(i);
00742     Float_t xsecNuMuNCC=splnumunCC->Eval(i)<0 ? 0:splnumunCC->Eval(i);
00743     Float_t xsecNuMuBarPCC=
00744       splnumubarpCC->Eval(i)<0 ? 0:splnumubarpCC->Eval(i);
00745     Float_t xsecNuMuBarNCC=
00746       splnumubarnCC->Eval(i)<0 ? 0:splnumubarnCC->Eval(i);
00747 
00748     hXsecNuMuPCC->Fill(i,xsecNuMuPCC);
00749     hXsecNuMuNCC->Fill(i,xsecNuMuNCC);
00750     hXsecNuMuBarPCC->Fill(i,xsecNuMuBarPCC);
00751     hXsecNuMuBarNCC->Fill(i,xsecNuMuBarNCC);
00752     
00753     Float_t FeA=55.845;
00754     Float_t FeZ=26;
00755     Float_t FeP=FeZ;
00756     Float_t FeN=FeA-FeZ;
00757 
00758     Float_t xsecNuMuBarFeCC=xsecNuMuBarPCC*FeP+xsecNuMuBarNCC*FeN;
00759     Float_t xsecNuMuFeCC=xsecNuMuPCC*FeP+xsecNuMuNCC*FeN;
00760     hXsecNuMuFeCC->Fill(i,xsecNuMuFeCC);
00761     hXsecNuMuBarFeCC->Fill(i,xsecNuMuBarFeCC);
00762     
00763     
00764   }
00765 
00766   MSG("NuAnalysis",Msg::kInfo) 
00767     <<" ** Finished CrossSections method **"<<endl;
00768 }

void NuAnalysis::DemoInfidSRInterface ( const NtpStRecord ntp,
const NtpSREvent evt,
const NuEvent nu 
) [private]

Definition at line 110 of file NuAnalysis.cxx.

References choose_infid_set(), NuReco::GetBestShower(), NuReco::GetBestTrack(), VldContext::GetDetector(), RecRecordImp< T >::GetHeader(), NuReco::GetShowerWithIndexX(), VldContext::GetSimFlag(), NuReco::GetTrackWithIndexX(), RecHeader::GetVldContext(), infid(), NuLibrary::Instance(), Msg::kInfo, Munits::m, MAXMSG, MSG, NtpSRVertex::plane, NuLibrary::reco, NtpSRShower::vtx, NtpSREvent::vtx, NtpSRTrack::vtx, NtpSRVertex::x, NtpSRVertex::y, and NtpSRVertex::z.

00113 {
00114   MAXMSG("NuAnalysis",Msg::kInfo,3)
00115     <<"Running DemoInfidSRInterface..."<<endl;
00116   
00117   //get the track and the shower
00118   //this first part is specific to the NuMuBar/NtupleUtils package
00119   //and is not part of the code demonstration
00120   
00121   //get an instance of the code library
00122   const NuLibrary& lib=NuLibrary::Instance();
00123 
00124   //get the best track in the event
00125   Int_t bestTrack=lib.reco.GetBestTrack(nu);
00126   if (bestTrack<1) return;
00127   const NtpSRTrack* ptrk=lib.reco.GetTrackWithIndexX
00128     (ntp,evt,bestTrack-1);
00129   const NtpSRTrack& trk=*ptrk;
00130 
00131   //get the best shower in the event
00132   Int_t bestShower=lib.reco.GetBestShower(nu);
00133   if (bestShower<1) return;
00134   const NtpSRShower* pshw=lib.reco.GetShowerWithIndexX
00135     (ntp,evt,bestShower-1);
00136   const NtpSRShower& shw=*pshw;
00137 
00141 
00142   //first up initialise the cuts to be the cc2008 version
00143   //just need to do this once
00144   static Bool_t infid_initialised=false;
00145   if (!infid_initialised) {
00146     infid_initialised=true;
00147     choose_infid_set("cc2008");
00148 
00149     //map out the z positions of the cuts
00150     for (Float_t z=0;z<30;z+=0.005) {
00151 
00152       //use values that will be in both detectors fiducial volumes
00153       Float_t x=1.5*Munits::m;
00154       Float_t y=0.6*Munits::m;
00155       
00156       //determine if in the fid. vol.
00157       const RecCandHeader& rec=ntp.GetHeader();
00158       Bool_t inFid=infid(rec.GetVldContext().GetDetector(),
00159                          rec.GetVldContext().GetSimFlag(),
00160                          x,y,z);
00161       MSG("NuAnalysis",Msg::kInfo)
00162         <<"z="<<z<<", inFid = "<<inFid<<endl;
00163     }
00164   }
00165   
00166   //determine if evt, trk and shw are in the fiducial volume
00167   //the offset to the trk vtx is subtracted in the function below
00168   Bool_t evtIsInFid=infid(ntp,evt);
00169   Bool_t trkIsInFid=infid(ntp,trk);
00170   Bool_t shwIsInFid=infid(ntp,shw);
00171   
00172   MAXMSG("NuAnalysis",Msg::kInfo,100)
00173     <<"Evt/Trk/Shw IsInFid = "
00174     <<evtIsInFid<<"/"<<trkIsInFid<<"/"<<shwIsInFid<<endl
00175     <<"evt(x,y,z) = ("<<evt.vtx.x<<","<<evt.vtx.y<<","<<evt.vtx.z<<")"
00176     <<endl
00177     <<"trk(x,y,z) = ("<<trk.vtx.x<<","<<trk.vtx.y<<","<<trk.vtx.z<<")"
00178     <<endl
00179     <<"shw(x,y,z) = ("<<shw.vtx.x<<","<<shw.vtx.y<<","<<shw.vtx.z<<")"
00180     <<endl;
00181   
00182   //check for differences due to trk vtx being in scintillator
00183   //and evt vtx being in the steel (usually)
00184   if (evtIsInFid!=trkIsInFid && evt.vtx.plane==trk.vtx.plane-1) {
00185     MAXMSG("NuAnalysis",Msg::kInfo,200)
00186       <<"*******************************************************"<<endl
00187       <<"*******************************************************"<<endl
00188       <<"*******************************************************"<<endl
00189       <<"Evt/Trk/Shw IsInFid = "
00190       <<evtIsInFid<<"/"<<trkIsInFid<<"/"<<shwIsInFid<<endl
00191       <<"evt(x,y,z) = ("<<evt.vtx.x<<","<<evt.vtx.y<<","<<evt.vtx.z<<")"
00192       <<endl
00193       <<"trk(x,y,z) = ("<<trk.vtx.x<<","<<trk.vtx.y<<","<<trk.vtx.z<<")"
00194       <<endl
00195       <<"shw(x,y,z) = ("<<shw.vtx.x<<","<<shw.vtx.y<<","<<shw.vtx.z<<")"
00196       <<endl
00197       <<"*******************************************************"<<endl
00198       <<"*******************************************************"<<endl
00199       <<"*******************************************************"<<endl
00200       <<endl;
00201   }
00202 }

void NuAnalysis::DetermineBeamType ( NuConfig config  )  const [private]

Only determine the new Conventions BeamType Don't bother trying to determine the BeamMonSpill (beamTypeSntp) for MC - you have it for data but it is converted straight into the Conventions beam type

Definition at line 2900 of file NuAnalysis.cxx.

References NuConfig::beamType, NuConfig::hornIsReverse, Msg::kError, Msg::kInfo, BeamType::kL000z200i, BeamType::kL010z000i, BeamType::kL010z170i, BeamType::kL010z185i, BeamType::kL010z185i_rev, BeamType::kL010z200i, BeamType::kL050z200i, BeamType::kL100z200i, BeamType::kL150z200i, BeamType::kL200z200i, BeamType::kL250z200i, BeamType::kM000z000i_nova, BeamType::kM000z200i_nova, BeamType::kM000z200i_nova_rev, BeamType::kUnknown, Msg::kWarning, MAXMSG, NuConfig::sBeamType, NuConfig::sHornCurrent, and NuConfig::sTargetPos.

Referenced by ExtractConfig(), and OldDetermineBeamType().

02901 {
02906 
02907   /*
02908 
02909     //from Conventions/BeamType.h
02910 
02911     kL000z200i, // true LE (data has a few POTs before target broke)
02912     kL010z185i, // normal "LE"-like running condition (pLE)
02913     kL050z200i,
02914     kL100z200i, // pseudo-medium (pME)
02915     kL200z200i,
02916     kL250z200i, // pseudo-high (pHE)
02917     kUser,
02918     kL010z000i, // "horns off"
02919     kL010z170i, // pLE low current test run
02920     kL010z200i, // pLE high current test run
02921     kL010z185i_lowintensity,
02922     kL150z200i, // pseudo-mediumhigh (pMHE)
02923     
02924     // retain old forms (new value go before this)
02925     kLE  = kL000z200i,
02926     k010 = kL010z185i,
02927     k050 = kL050z200i,
02928     k100 = kL100z200i,
02929     k200 = kL200z200i,
02930     k250 = kL250z200i,
02931     kME  = k100,  // obsolete (ambiguiously used for pME vs. true-ME)
02932     kHE  = k250,  // obsolete (ambiguiously used for pHE vs. true-HE)
02933     kEndOfList
02934   */
02935 
02936   //25/Feb/07 NEW: now using Conventions definitions which has
02937   //horn current built in to the beam type
02938   //don't have a case for "kL010z185i_lowintensity" yet
02939   
02940   //these are the BeamMonSpill definitions, which are different
02941   //to the MCReweight definitions
02942   //0=unknown,1=LE,2=ME,3=HE,4=psME,5=psHE mask=0x1c. LE-10 is LE
02943 
02944   
02945   //Work out if this is NOvA beam.
02946   Bool_t novaFlag = false;
02947   TString beamType = config.sBeamType;
02948   if (beamType.Contains("NOVA",TString::kIgnoreCase)){
02949     novaFlag = true;
02950   }
02951 
02952   if (novaFlag && "000"!=config.sTargetPos){
02953     MAXMSG("NuAnalysis",Msg::kWarning,5)
02954       << "Found NOvA beam with unrecognized horn current. Asserting now."
02955       << endl;
02956     assert(0);
02957   }
02958 
02959   if (config.sTargetPos=="000") {
02960     if (novaFlag){
02961       if (config.sHornCurrent=="200"){
02962         if (config.hornIsReverse){
02963           config.beamType=BeamType::kM000z200i_nova_rev;
02964         }
02965         else{
02966           config.beamType=BeamType::kM000z200i_nova;
02967         }
02968       }
02969       else if (config.sHornCurrent=="000") {
02970         config.beamType=BeamType::kM000z000i_nova;  //Nova era "Horn-Off"
02971       }
02972       else{
02973         MAXMSG("NuAnalysis",Msg::kWarning,5)
02974           << "Found NOvA beam with target position 0 but unrecognized horn current"
02975           << endl;
02976         assert(0);
02977       }
02978     }
02979     else{
02980       MAXMSG("NuAnalysis",Msg::kInfo,5)
02981         <<"Identified case for sTargetPos="<<config.sTargetPos
02982         <<", now searching for horn current case..."<<endl;
02983       if (config.sHornCurrent=="200") {
02984         config.beamType=BeamType::kL000z200i;
02985       }
02986       else {
02987         MAXMSG("NuAnalysis",Msg::kError,5)
02988           <<"Ahhh, no horn current case for hornCurrent="
02989           <<config.sHornCurrent<<" for sTargetPos="<<config.sTargetPos
02990           <<endl;
02991         config.beamType=BeamType::kUnknown;
02992         assert(false);
02993       }
02994     }
02995   }
02996   else if (config.sTargetPos=="010") {
02997     MAXMSG("NuAnalysis",Msg::kInfo,5)
02998       <<"Identified case for sTargetPos="<<config.sTargetPos
02999       <<", now searching for horn current..."<<endl;
03000     if (config.sHornCurrent=="185") {
03001       if(config.hornIsReverse)
03002         config.beamType=BeamType::kL010z185i_rev;
03003       else
03004         config.beamType=BeamType::kL010z185i;
03005     }
03006     else if (config.sHornCurrent=="200") {
03007       config.beamType=BeamType::kL010z200i;
03008     }
03009     else if (config.sHornCurrent=="170") {
03010       config.beamType=BeamType::kL010z170i;
03011     }
03012     else if (config.sHornCurrent=="000") {
03013       config.beamType=BeamType::kL010z000i;
03014     }
03015     else {
03016       MAXMSG("NuAnalysis",Msg::kError,5)
03017         <<"Ahhh, no horn current case for hornCurrent="
03018         <<config.sHornCurrent<<" for sTargetPos="<<config.sTargetPos
03019         <<endl;
03020       config.beamType=BeamType::kUnknown;
03021       assert(false);
03022     }
03023   }
03024   else if (config.sTargetPos=="50") {
03025     MAXMSG("NuAnalysis",Msg::kInfo,5)
03026       <<"Identified case for sTargetPos="<<config.sTargetPos
03027       <<", now searching for horn current..."<<endl;
03028     if (config.sHornCurrent=="200") {
03029       config.beamType=BeamType::kL050z200i;
03030     }
03031     else {
03032       MAXMSG("NuAnalysis",Msg::kError,5)
03033         <<"Ahhh, no horn current case for hornCurrent="
03034         <<config.sHornCurrent<<" for sTargetPos="<<config.sTargetPos
03035         <<endl;
03036       config.beamType=BeamType::kUnknown;
03037       assert(false);
03038     }
03039   }
03040   else if (config.sTargetPos=="100") {
03041     MAXMSG("NuAnalysis",Msg::kInfo,5)
03042       <<"Identified case for sTargetPos="<<config.sTargetPos
03043       <<", now searching for horn current..."<<endl;
03044     if (config.sHornCurrent=="200") {
03045       config.beamType=BeamType::kL100z200i;
03046     }
03047     else {
03048       MAXMSG("NuAnalysis",Msg::kError,5)
03049         <<"Ahhh, no horn current case for hornCurrent="
03050         <<config.sHornCurrent<<" for sTargetPos="<<config.sTargetPos
03051         <<endl;
03052       config.beamType=BeamType::kUnknown;
03053       assert(false);
03054     }
03055   }
03056   else if (config.sTargetPos=="150") {
03057     MAXMSG("NuAnalysis",Msg::kInfo,5)
03058       <<"Identified case for sTargetPos="<<config.sTargetPos
03059       <<", now searching for horn current..."<<endl;
03060     if (config.sHornCurrent=="200") {
03061       config.beamType=BeamType::kL150z200i;
03062     }
03063     else {
03064       MAXMSG("NuAnalysis",Msg::kError,5)
03065         <<"Ahhh, no horn current case for hornCurrent="
03066         <<config.sHornCurrent<<" for sTargetPos="<<config.sTargetPos
03067         <<endl;
03068       config.beamType=BeamType::kUnknown;
03069       assert(false);
03070     }
03071   }
03072   else if (config.sTargetPos=="200") {
03073     MAXMSG("NuAnalysis",Msg::kInfo,5)
03074       <<"Identified case for sTargetPos="<<config.sTargetPos
03075       <<", now searching for horn current..."<<endl;
03076     if (config.sHornCurrent=="200") {
03077       config.beamType=BeamType::kL200z200i;
03078     }
03079     else {
03080       MAXMSG("NuAnalysis",Msg::kError,5)
03081         <<"Ahhh, no horn current case for hornCurrent="
03082         <<config.sHornCurrent<<" for sTargetPos="<<config.sTargetPos
03083         <<endl;
03084       config.beamType=BeamType::kUnknown;
03085       assert(false);
03086     }
03087   }
03088   else if (config.sTargetPos=="250") {
03089     MAXMSG("NuAnalysis",Msg::kInfo,5)
03090       <<"Identified case for sTargetPos="<<config.sTargetPos
03091       <<", now searching for horn current..."<<endl;
03092     if (config.sHornCurrent=="200") {
03093       config.beamType=BeamType::kL250z200i;
03094     }
03095     else {
03096       MAXMSG("NuAnalysis",Msg::kError,5)
03097         <<"Ahhh, no horn current case for hornCurrent="
03098         <<config.sHornCurrent<<" for sTargetPos="<<config.sTargetPos
03099         <<endl;
03100       config.beamType=BeamType::kUnknown;
03101       assert(false);
03102     }
03103   }
03104   else {
03105     config.beamType=BeamType::kUnknown; 
03106     MAXMSG("NuAnalysis",Msg::kError,10)
03107       <<"Ahhhhh, target position="<<config.sTargetPos
03108       <<" case not known..."<<endl;
03109     //assert(false);
03110   }
03111 } 

void NuAnalysis::DoExtractions ( const NtpStRecord ntp,
const NtpSREvent evt,
const NtpFitSARecord pntpSA,
NuPIDInterface pid,
NuEvent nu 
) const

Definition at line 6617 of file NuAnalysis.cxx.

References NuLibrary::ext, NuExtraction::ExtractAuxiliaryInfo(), ExtractPIDsAndWeights(), NuReco::GetTruthInfo(), NuLibrary::Instance(), and NuLibrary::reco.

Referenced by ChargeSeparationOneSnarl(), and MakeFullDST().

06621 {
06622   //get an instance of the code library
06623   const NuLibrary& lib=NuLibrary::Instance();
06624   
06625   //extract other necessary information
06626   lib.ext.ExtractAuxiliaryInfo(ntp,evt,pntpSA,nu);
06627   //get the truth info (reco quantities are done above)
06628   lib.reco.GetTruthInfo(ntp,evt,nu);
06629 
06630   //get the pids and the event weights
06631   this->ExtractPIDsAndWeights(ntp,evt,pid,nu);
06632 
06633 
06634 }

void NuAnalysis::Efficiencies (  ) 

Definition at line 3957 of file NuAnalysis.cxx.

References NuEvent::anaVersion, NuConfig::beamType, MadDpID::CalcPID(), NuCuts::CalcTotalPot(), NuEvent::charge, MadDpID::ChoosePDFs(), NuEvent::detector, NuEvent::dpID, NuGeneral::EpochTo1995(), NtpStRecord::evt, ExtractConfig(), NuExtraction::ExtractGeneralInfo(), NuPlots::FillGeneralHistos(), NtpSRTrack::fit, NuBase::fOutFile, VldContext::GetDetector(), NuBase::GetEntries(), RecRecordImp< T >::GetHeader(), NuBase::GetNtpStRecord(), NuBase::GetNumFilesAddedToChain(), RecDataHeader::GetRun(), VldContext::GetSimFlag(), RecDataHeader::GetSubRun(), NuReco::GetTruthInfo(), RecHeader::GetVldContext(), NtpMCTruth::iaction, NtpSREvent::index, NtpMCTruth::index, NuBase::InitialiseLoopVariables(), NuLibrary::Instance(), NtpMCTruth::inu, NuCuts::IsGoodFitProb(), NuCuts::IsGoodSigmaQP_QP(), NuBeam::IsGoodSpillAndFillPot(), NuCuts::IsInFidVol(), Msg::kInfo, Msg::kWarning, MAXMSG, NtpStRecord::mc, NtpSRTrack::momentum, MSG, NtpTHEvent::neumc, NtpSREvent::ntrack, NuBase::OpenFile(), NtpMCTruth::p4neu, NtpSRFitTrack::pass, plots(), NuEvent::pot, NtpSRMomentum::qp, NuEvent::releaseType, NuConfig::sBeamType, NuMadAnalysis::SetEntry(), NuGeneral::SetGraphAxis(), NuBase::SetLoopVariables(), NuEvent::simFlag, NuGeneral::TH1FFill(), NtpStRecord::thevt, NtpSRVertex::u, NtpSRVertex::v, NtpSREvent::vtx, NtpSRTrack::vtx, NtpMCTruth::vtxx, NtpMCTruth::vtxy, NtpMCTruth::vtxz, NtpSRVertex::x, NtpSRVertex::y, and NtpSRVertex::z.

03958 {
03959   MSG("NuAnalysis",Msg::kInfo) 
03960     <<" ** Running Efficiencies method... **"<<endl;
03961   
03962   NuConfig config;
03963   this->ExtractConfig(config);
03964 
03965   //open the output file for the histograms
03966   string sFilePrefix="NMBEff"+config.sBeamType;
03967   fOutFile=this->OpenFile(config,sFilePrefix.c_str());
03968 
03969   TH1F* hRecoEnNMBFull=new TH1F("hRecoEnNMBFull","hRecoEnNMBFull",
03970                                 4*352,-32,320);
03971   hRecoEnNMBFull->GetXaxis()->SetTitle("True Energy (GeV)");
03972   hRecoEnNMBFull->GetXaxis()->CenterTitle();
03973   hRecoEnNMBFull->GetYaxis()->SetTitle("");
03974   hRecoEnNMBFull->GetYaxis()->CenterTitle();
03975   //hRecoEnNMBFull->SetBit(TH1::kCanRebin);
03976 
03977   TH1F* hRecoEnNMBReco=new TH1F("hRecoEnNMBReco","hRecoEnNMBReco",
03978                                4*352,-32,320);
03979   hRecoEnNMBReco->GetXaxis()->SetTitle("True Energy (GeV)");
03980   hRecoEnNMBReco->GetXaxis()->CenterTitle();
03981   hRecoEnNMBReco->GetYaxis()->SetTitle("");
03982   hRecoEnNMBReco->GetYaxis()->CenterTitle();
03983   //hRecoEnNMBReco->SetBit(TH1::kCanRebin);
03984 
03985   TH1F* hRecoEnNMBFid=new TH1F("hRecoEnNMBFid","hRecoEnNMBFid",
03986                                 4*352,-32,320);
03987   hRecoEnNMBFid->GetXaxis()->SetTitle("True Energy (GeV)");
03988   hRecoEnNMBFid->GetXaxis()->CenterTitle();
03989   hRecoEnNMBFid->GetYaxis()->SetTitle("");
03990   hRecoEnNMBFid->GetYaxis()->CenterTitle();
03991   //hRecoEnNMBFid->SetBit(TH1::kCanRebin);
03992 
03993   TH1F* hRecoEnNMBTrack=new TH1F("hRecoEnNMBTrack","hRecoEnNMBTrack",
03994                                 4*352,-32,320);
03995   hRecoEnNMBTrack->GetXaxis()->SetTitle("True Energy (GeV)");
03996   hRecoEnNMBTrack->GetXaxis()->CenterTitle();
03997   hRecoEnNMBTrack->GetYaxis()->SetTitle("");
03998   hRecoEnNMBTrack->GetYaxis()->CenterTitle();
03999   //hRecoEnNMBTrack->SetBit(TH1::kCanRebin);
04000 
04001   TH1F* hRecoEnNMBPass=new TH1F("hRecoEnNMBPass","hRecoEnNMBPass",
04002                                 4*352,-32,320);
04003   hRecoEnNMBPass->GetXaxis()->SetTitle("True Energy (GeV)");
04004   hRecoEnNMBPass->GetXaxis()->CenterTitle();
04005   hRecoEnNMBPass->GetYaxis()->SetTitle("");
04006   hRecoEnNMBPass->GetYaxis()->CenterTitle();
04007   //hRecoEnNMBPass->SetBit(TH1::kCanRebin);
04008   
04009   TH1F* hRecoEnNMBQCut=new TH1F("hRecoEnNMBQCut","hRecoEnNMBQCut",
04010                                 4*352,-32,320);
04011   hRecoEnNMBQCut->GetXaxis()->SetTitle("True Energy (GeV)");
04012   hRecoEnNMBQCut->GetXaxis()->CenterTitle();
04013   hRecoEnNMBQCut->GetYaxis()->SetTitle("");
04014   hRecoEnNMBQCut->GetYaxis()->CenterTitle();
04015   //hRecoEnNMBQCut->SetBit(TH1::kCanRebin);
04016 
04017   TH1F* hRecoEnNMBSigQP=new TH1F("hRecoEnNMBSigQP","hRecoEnNMBSigQP",
04018                                 4*352,-32,320);
04019   hRecoEnNMBSigQP->GetXaxis()->SetTitle("True Energy (GeV)");
04020   hRecoEnNMBSigQP->GetXaxis()->CenterTitle();
04021   hRecoEnNMBSigQP->GetYaxis()->SetTitle("");
04022   hRecoEnNMBSigQP->GetYaxis()->CenterTitle();
04023   //hRecoEnNMBSigQP->SetBit(TH1::kCanRebin);
04024 
04025   TH1F* hRecoEnNMBProb=new TH1F("hRecoEnNMBProb","hRecoEnNMBProb",
04026                                 4*352,-32,320);
04027   hRecoEnNMBProb->GetXaxis()->SetTitle("True Energy (GeV)");
04028   hRecoEnNMBProb->GetXaxis()->CenterTitle();
04029   hRecoEnNMBProb->GetYaxis()->SetTitle("");
04030   hRecoEnNMBProb->GetYaxis()->CenterTitle();
04031   //hRecoEnNMBProb->SetBit(TH1::kCanRebin);
04032 
04033   TH1F* hRecoEnNMBProb05=new TH1F("hRecoEnNMBProb05","hRecoEnNMBProb05",
04034                                 4*352,-32,320);
04035   hRecoEnNMBProb05->GetXaxis()->SetTitle("True Energy (GeV)");
04036   hRecoEnNMBProb05->GetXaxis()->CenterTitle();
04037   hRecoEnNMBProb05->GetYaxis()->SetTitle("");
04038   hRecoEnNMBProb05->GetYaxis()->CenterTitle();
04039   //hRecoEnNMBProb05->SetBit(TH1::kCanRebin);
04040 
04041   TH1F* hRecoEnNMBDpID01=new TH1F("hRecoEnNMBDpID01","hRecoEnNMBDpID01",
04042                                 4*352,-32,320);
04043   hRecoEnNMBDpID01->GetXaxis()->SetTitle("True Energy (GeV)");
04044   hRecoEnNMBDpID01->GetXaxis()->CenterTitle();
04045   hRecoEnNMBDpID01->GetYaxis()->SetTitle("");
04046   hRecoEnNMBDpID01->GetYaxis()->CenterTitle();
04047   //hRecoEnNMBDpID01->SetBit(TH1::kCanRebin);
04048 
04049   TH1F* hRecoEnNMBDpID04=new TH1F("hRecoEnNMBDpID04","hRecoEnNMBDpID04",
04050                                 4*352,-32,320);
04051   hRecoEnNMBDpID04->GetXaxis()->SetTitle("True Energy (GeV)");
04052   hRecoEnNMBDpID04->GetXaxis()->CenterTitle();
04053   hRecoEnNMBDpID04->GetYaxis()->SetTitle("");
04054   hRecoEnNMBDpID04->GetYaxis()->CenterTitle();
04055   //hRecoEnNMBDpID04->SetBit(TH1::kCanRebin);
04056 
04057 
04058   //leak in/out histos
04059   TH1F* hRecoEnNMBLeakIn=new TH1F("hRecoEnNMBLeakIn","hRecoEnNMBLeakIn",
04060                                 4*352,-32,320);
04061   hRecoEnNMBLeakIn->GetXaxis()->SetTitle("True Energy (GeV)");
04062   hRecoEnNMBLeakIn->GetXaxis()->CenterTitle();
04063   hRecoEnNMBLeakIn->GetYaxis()->SetTitle("");
04064   hRecoEnNMBLeakIn->GetYaxis()->CenterTitle();
04065   //hRecoEnNMBLeakIn->SetBit(TH1::kCanRebin);
04066 
04067   TH1F* hRecoEnNMBLeakOut=new TH1F("hRecoEnNMBLeakOut",
04068                                    "hRecoEnNMBLeakOut",
04069                                    4*352,-32,320);
04070   hRecoEnNMBLeakOut->GetXaxis()->SetTitle("True Energy (GeV)");
04071   hRecoEnNMBLeakOut->GetXaxis()->CenterTitle();
04072   hRecoEnNMBLeakOut->GetYaxis()->SetTitle("");
04073   hRecoEnNMBLeakOut->GetYaxis()->CenterTitle();
04074   //hRecoEnNMBLeakOut->SetBit(TH1::kCanRebin);
04075 
04076 
04077 
04078   TH2F* hYvsXTrueLeakIn=new TH2F("hYvsXTrueLeakIn","hYvsXTrueLeakIn",
04079                              100,-5,5,100,-5,5);
04080   hYvsXTrueLeakIn->SetTitle("Y vs X");
04081   hYvsXTrueLeakIn->GetXaxis()->SetTitle("X");
04082   hYvsXTrueLeakIn->GetXaxis()->CenterTitle();
04083   hYvsXTrueLeakIn->GetYaxis()->SetTitle("Y");
04084   hYvsXTrueLeakIn->GetYaxis()->CenterTitle();
04085   //hYvsXTrueLeakIn->SetBit(TH1::kCanRebin);
04086 
04087   TH2F* hYvsXRecoLeakIn=new TH2F("hYvsXRecoLeakIn","hYvsXRecoLeakIn",
04088                              100,-5,5,100,-5,5);
04089   hYvsXRecoLeakIn->SetTitle("Y vs X");
04090   hYvsXRecoLeakIn->GetXaxis()->SetTitle("X");
04091   hYvsXRecoLeakIn->GetXaxis()->CenterTitle();
04092   hYvsXRecoLeakIn->GetYaxis()->SetTitle("Y");
04093   hYvsXRecoLeakIn->GetYaxis()->CenterTitle();
04094   //hYvsXRecoLeakIn->SetBit(TH1::kCanRebin);
04095 
04096   TH2F* hYvsXTrueLeakOut=new TH2F("hYvsXTrueLeakOut","hYvsXTrueLeakOut",
04097                              100,-5,5,100,-5,5);
04098   hYvsXTrueLeakOut->SetTitle("Y vs X");
04099   hYvsXTrueLeakOut->GetXaxis()->SetTitle("X");
04100   hYvsXTrueLeakOut->GetXaxis()->CenterTitle();
04101   hYvsXTrueLeakOut->GetYaxis()->SetTitle("Y");
04102   hYvsXTrueLeakOut->GetYaxis()->CenterTitle();
04103   //hYvsXTrueLeakOut->SetBit(TH1::kCanRebin);
04104 
04105   TH2F* hYvsXRecoLeakOut=new TH2F("hYvsXRecoLeakOut","hYvsXRecoLeakOut",
04106                              100,-5,5,100,-5,5);
04107   hYvsXRecoLeakOut->SetTitle("Y vs X");
04108   hYvsXRecoLeakOut->GetXaxis()->SetTitle("X");
04109   hYvsXRecoLeakOut->GetXaxis()->CenterTitle();
04110   hYvsXRecoLeakOut->GetYaxis()->SetTitle("Y");
04111   hYvsXRecoLeakOut->GetYaxis()->CenterTitle();
04112   //hYvsXRecoLeakOut->SetBit(TH1::kCanRebin);
04113 
04114 
04115   TH1F* hRecoEnNMBTrkLeakIn=new TH1F("hRecoEnNMBTrkLeakIn",
04116                                      "hRecoEnNMBTrkLeakIn",
04117                                      4*352,-32,320);
04118   hRecoEnNMBTrkLeakIn->GetXaxis()->SetTitle("True Energy (GeV)");
04119   hRecoEnNMBTrkLeakIn->GetXaxis()->CenterTitle();
04120   hRecoEnNMBTrkLeakIn->GetYaxis()->SetTitle("");
04121   hRecoEnNMBTrkLeakIn->GetYaxis()->CenterTitle();
04122   //hRecoEnNMBTrkLeakIn->SetBit(TH1::kCanRebin);
04123 
04124   TH1F* hRecoEnNMBTrkLeakOut=new TH1F("hRecoEnNMBTrkLeakOut",
04125                                       "hRecoEnNMBTrkLeakOut",
04126                                       4*352,-32,320);
04127   hRecoEnNMBTrkLeakOut->GetXaxis()->SetTitle("True Energy (GeV)");
04128   hRecoEnNMBTrkLeakOut->GetXaxis()->CenterTitle();
04129   hRecoEnNMBTrkLeakOut->GetYaxis()->SetTitle("");
04130   hRecoEnNMBTrkLeakOut->GetYaxis()->CenterTitle();
04131   //hRecoEnNMBTrkLeakOut->SetBit(TH1::kCanRebin);
04132 
04133 
04134 
04135   TH2F* hYvsXTrueTrkLeakIn=new TH2F("hYvsXTrueTrkLeakIn",
04136                                     "hYvsXTrueTrkLeakIn",
04137                                     100,-5,5,100,-5,5);
04138   hYvsXTrueTrkLeakIn->SetTitle("Y vs X");
04139   hYvsXTrueTrkLeakIn->GetXaxis()->SetTitle("X");
04140   hYvsXTrueTrkLeakIn->GetXaxis()->CenterTitle();
04141   hYvsXTrueTrkLeakIn->GetYaxis()->SetTitle("Y");
04142   hYvsXTrueTrkLeakIn->GetYaxis()->CenterTitle();
04143   //hYvsXTrueTrkLeakIn->SetBit(TH1::kCanRebin);
04144 
04145   TH2F* hYvsXRecoTrkLeakIn=new TH2F("hYvsXRecoTrkLeakIn",
04146                                     "hYvsXRecoTrkLeakIn",
04147                                     100,-5,5,100,-5,5);
04148   hYvsXRecoTrkLeakIn->SetTitle("Y vs X");
04149   hYvsXRecoTrkLeakIn->GetXaxis()->SetTitle("X");
04150   hYvsXRecoTrkLeakIn->GetXaxis()->CenterTitle();
04151   hYvsXRecoTrkLeakIn->GetYaxis()->SetTitle("Y");
04152   hYvsXRecoTrkLeakIn->GetYaxis()->CenterTitle();
04153   //hYvsXRecoTrkLeakIn->SetBit(TH1::kCanRebin);
04154   
04155   TH2F* hYvsXTrueTrkLeakOut=new TH2F("hYvsXTrueTrkLeakOut",
04156                                      "hYvsXTrueTrkLeakOut",
04157                                      100,-5,5,100,-5,5);
04158   hYvsXTrueTrkLeakOut->SetTitle("Y vs X");
04159   hYvsXTrueTrkLeakOut->GetXaxis()->SetTitle("X");
04160   hYvsXTrueTrkLeakOut->GetXaxis()->CenterTitle();
04161   hYvsXTrueTrkLeakOut->GetYaxis()->SetTitle("Y");
04162   hYvsXTrueTrkLeakOut->GetYaxis()->CenterTitle();
04163   //hYvsXTrueTrkLeakOut->SetBit(TH1::kCanRebin);
04164 
04165   TH2F* hYvsXRecoTrkLeakOut=new TH2F("hYvsXRecoTrkLeakOut",
04166                                      "hYvsXRecoTrkLeakOut",
04167                                      100,-5,5,100,-5,5);
04168   hYvsXRecoTrkLeakOut->SetTitle("Y vs X");
04169   hYvsXRecoTrkLeakOut->GetXaxis()->SetTitle("X");
04170   hYvsXRecoTrkLeakOut->GetXaxis()->CenterTitle();
04171   hYvsXRecoTrkLeakOut->GetYaxis()->SetTitle("Y");
04172   hYvsXRecoTrkLeakOut->GetYaxis()->CenterTitle();
04173   //hYvsXRecoTrkLeakOut->SetBit(TH1::kCanRebin);
04174 
04175   //vectors
04176   Int_t entries=static_cast<Int_t>(this->GetEntries());
04177   Int_t startTimeSecs=2000000000;//2 billion
04178   Int_t endTimeSecs=1;
04179   vector<Double_t> vPot;
04180   vPot.reserve(entries);
04181   vector<Double_t> vTime;
04182   vTime.reserve(entries);
04183   vector<Double_t> vPotBad;
04184   vPotBad.reserve(entries/10);
04185   vector<Double_t> vTimeBad;
04186   vTimeBad.reserve(entries/10);
04187   
04188   vector<Double_t> vTimeNuMuEvt;
04189   vTimeNuMuEvt.reserve(entries/5);
04190   vector<Double_t> vTimeNuMuBarEvt;
04191   vTimeNuMuBarEvt.reserve(entries/5);
04192  
04193   //maps to store evt info
04194   map<Int_t,Double_t> deltaTs;
04195   map<Int_t,Int_t> evtsPerSlc;
04196 
04197   //counters
04198   Int_t goodSpillCounter=0;
04199   Int_t badSpillCounter=0;
04200   Float_t totalPot=0;
04201   Float_t totalPotBad=0;
04202   Int_t evtCounter=0;
04203   Int_t evtNotlitime=0;
04204   Int_t evtNotIsLI=0;
04205   Int_t evtInFidVolCounter=0;
04206   Int_t evtWithTrkCounter=0;
04207   Int_t goodBestTrkCounter=0;
04208   Int_t goodTrkPassCounter=0;
04209   Int_t goodRecoEnCounter=0;
04210   Int_t goodUVDiffCounter=0;
04211   Int_t trkInFidVolCounter=0;
04212   Int_t goodFitSigQPCounter=0;
04213   Int_t goodFitProbCounter=0;
04214   Int_t goodFitChi2Counter=0;
04215   Int_t goodDeltaTCounter=0;
04216   Int_t goodEvtsPerSlcCounter=0; 
04217   Int_t goodPIDCounter=0;
04218   Int_t goodBeyondTrkEndCounter=0;
04219   Int_t goodShwFractCounter=0;
04220   Int_t nuNQCounter=0;
04221   Int_t nuPQCounter=0;
04222   
04223   //string sTxtFilePrefix="nmb"+config.sBeamType;
04224   //ofstream& nmbTxt=*(this->OpenTxtFile(config,
04225   //                           sTxtFilePrefix.c_str()));
04226 
04227   //classes to organise the code in to related functions
04228   const NuCuts cuts;
04229   const NuGeneral general;
04230   const NuPlots plots;
04231   const NuReco reco;
04232   const NuExtraction ext;
04233   const NuBeam beam;
04234 
04235   //create these on the heap so that they don't destruct
04236   // - on purpose to avoid a segv on destruction... nice coding!
04237   NuMadAnalysis& mad=*new NuMadAnalysis();
04238   MadDpID& dp=*new MadDpID();
04239   //BeamType::BeamType_t beamType=BeamType::kLE;
04240   BeamType::BeamType_t beamType=static_cast
04241     <BeamType::BeamType_t>(config.beamType);
04242  
04243   //get an instance of the code library
04244   const NuLibrary& lib=NuLibrary::Instance();
04245  
04249   
04250   this->InitialiseLoopVariables();  
04251   
04252   //for(Int_t entry=0;entry<10000;entry++){
04253   for(Int_t entry=0;entry<this->GetEntries();entry++){
04254       
04255     this->SetLoopVariables(entry);
04256       
04257     //get reference to NtpStRecord from base class
04258     const NtpStRecord& ntp=(*this->GetNtpStRecord());
04259 
04260     const RecCandHeader& rec=ntp.GetHeader();
04261     MAXMSG("NuAnalysis",Msg::kInfo,5)
04262       <<"Found: run="<<rec.GetRun()
04263       <<", subrun="<<rec.GetSubRun()
04264       <<", detector="<<rec.GetVldContext().GetDetector()
04265       <<", simFlag="<<rec.GetVldContext().GetSimFlag()
04266       <<endl;
04267 
04268     //write out the detector, simflag, etc
04269     plots.FillGeneralHistos(ntp);
04270 
04271     //simple event object to hold important quantities for snarl
04272     NuEvent nuSnarl;
04273     
04274     //get the run, snarl, etc info
04275     ext.ExtractGeneralInfo(ntp,nuSnarl);
04276 
04277     if (!beam.IsGoodSpillAndFillPot
04278         (this->GetNtpBDLiteRecord(),config,nuSnarl)) {
04279       badSpillCounter++;
04280       totalPotBad+=nuSnarl.pot;
04281       continue;
04282     }
04283     goodSpillCounter++;
04284     totalPot+=nuSnarl.pot;    
04285 
04286     dp.ChoosePDFs(rec.GetVldContext().GetDetector(),beamType);
04287     mad.SetEntry(&ntp);
04288 
04289     set<Int_t> setNuMuBarInTrueFidCC;
04290   
04291     VldTimeStamp vldts;
04292     //VldTimeStamp vldts(ev.UnixTime,0);
04293     VldContext vc(rec.GetVldContext().GetDetector(),
04294                   rec.GetVldContext().GetSimFlag(),vldts);
04295     //get the ugh
04296     UgliGeomHandle ugh(vc);
04297     
04298     TClonesArray& mcTca=(*ntp.mc);
04299     Int_t numInt=mcTca.GetEntries();
04300     MAXMSG("NuAnalysis",Msg::kInfo,10)
04301       <<"Number of entries in NtpMCTruth="
04302       <<mcTca.GetEntries()<<endl;
04303     
04304     //simple event object to hold important quantities
04305     NuEvent nu;
04306     
04307     //get the run, snarl, etc info
04308     ext.ExtractGeneralInfo(ntp,nu);
04309       
04310 
04312     //loop over true events
04314     for (Int_t i=0;i<numInt;i++){
04315       const NtpMCTruth& mc=*(dynamic_cast<NtpMCTruth*>(mcTca[i]));
04316       
04317       TVector3 xyz(mc.vtxx,mc.vtxy,mc.vtxz);
04318       // calculate the positions in UVZ space
04319       TVector3 uvz=ugh.xyz2uvz(xyz);
04320       
04321       if (!(mc.iaction==1 && mc.inu==-14)) continue;
04322       
04323       Bool_t isInFidVol=cuts.IsInFidVol(mc.vtxx,mc.vtxy,mc.vtxz,
04324                                         uvz.X(),uvz.Y(),0,0,
04325                                         nu.detector,nu.anaVersion,
04326                                         nu.releaseType,nu.simFlag);
04327       
04328       if (!isInFidVol) continue;
04329       setNuMuBarInTrueFidCC.insert(mc.index);
04330 
04331       hRecoEnNMBFull->Fill(fabs(mc.p4neu[3]));
04332     }
04333 
04334     MAXMSG("NuAnalysis",Msg::kInfo,20)
04335       <<"Number of NuMuBar fiducial volume interactions in spill="
04336       <<setNuMuBarInTrueFidCC.size()<<endl;
04337 
04338 
04339     TClonesArray& thevtTca=(*ntp.thevt);//TruthHelper Event TCA
04340     const Int_t numthevts=thevtTca.GetEntriesFast();
04341     if (numthevts<=0) {
04342       MSG("NuAnalysis",Msg::kWarning)
04343         <<"No THEvents..."<<endl;
04344       continue;
04345     }
04346 
04347     set<Int_t> setNuMuBarInRecoFidCC;
04348 
04349     TClonesArray& evtTca=(*ntp.evt);
04350     const Int_t numEvts=evtTca.GetEntriesFast();
04351 
04353     //loop over the reconstructed events
04355     for (Int_t ievt=0;ievt<numEvts;ievt++){
04356       const NtpSREvent& evt=
04357         *dynamic_cast<NtpSREvent*>(evtTca[ievt]);
04358       evtCounter++;
04359 
04360       const NtpTHEvent& thevt=
04361         *dynamic_cast<NtpTHEvent*>(thevtTca[evt.index]);
04362       
04363       //now get the mc object (neutrino interaction) that 
04364       //corresponds to the evt using the thevt.neumc index
04365       const NtpMCTruth& mc=
04366         *(dynamic_cast<NtpMCTruth*>(mcTca[thevt.neumc]));
04367       
04368       //cut out all but numubar cc
04369       if (!(mc.iaction==1 && mc.inu==-14)) continue;
04370 
04371       //simple event object to hold important quantities
04372       NuEvent nu;
04373 
04374       //get the run, snarl, etc info
04375       ext.ExtractGeneralInfo(ntp,nu);
04376       //get info from the evt
04377       lib.ext.ExtractEvtInfo(evt,nu);
04378       //extract trk info (needed to get best track info)
04379       lib.ext.ExtractTrkInfo(ntp,evt,nu);
04380       //extract shw info
04381       lib.ext.ExtractShwInfo(ntp,evt,nu);
04382 
04383       Bool_t isInFidVol=cuts.IsInFidVol(evt.vtx.x,evt.vtx.y,
04384                                         evt.vtx.z,
04385                                         evt.vtx.u,evt.vtx.v,0,0,
04386                                         nu.detector,nu.anaVersion,
04387                                         nu.releaseType,nu.simFlag);
04388       
04389       //make sure that no event is used twice
04390       set<Int_t>::iterator itT=setNuMuBarInRecoFidCC.find(thevt.neumc);
04391       if (itT==setNuMuBarInRecoFidCC.end()) {
04392         MAXMSG("NuAnalysis",Msg::kInfo,20)
04393           <<"Found reco event for mc="<<thevt.neumc<<endl;
04394         setNuMuBarInRecoFidCC.insert(thevt.neumc);
04395       }
04396       else {
04397         MAXMSG("NuAnalysis",Msg::kInfo,20)
04398           <<"Already found reco event for mc="<<thevt.neumc<<endl;
04399         continue;
04400       }
04401       
04402       //get the best track in the event
04403       Int_t bestTrack=lib.reco.GetBestTrack(nu);
04404       const NtpSRTrack* ptrk=lib.reco.GetTrackWithIndexX
04405         (ntp,evt,bestTrack-1);
04406       Bool_t trkIsInFidVol=false;
04407       if (ptrk!=0) {
04408         const NtpSRTrack& trk=*ptrk;
04409         trkIsInFidVol=cuts.IsInFidVol(trk.vtx.x,trk.vtx.y,
04410                                       trk.vtx.z,
04411                                       trk.vtx.u,trk.vtx.v,0,0,
04412                                       nu.detector,nu.anaVersion,
04413                                       nu.releaseType,nu.simFlag);
04414         trkIsInFidVol=true;
04415       }
04416 
04417       //these ones are leaking into the fiducial volume
04418       set<Int_t>::iterator itR=setNuMuBarInTrueFidCC.find(thevt.neumc);
04419       if (itR==setNuMuBarInTrueFidCC.end()) {
04420         MAXMSG("NuAnalysis",Msg::kInfo,20)
04421           <<"ievt="<<ievt<<" has no true event in fid"<<endl; 
04422         if (isInFidVol){
04423           hRecoEnNMBLeakIn->Fill(fabs(mc.p4neu[3]));
04424           hYvsXRecoLeakIn->Fill(evt.vtx.x,evt.vtx.y);
04425           hYvsXTrueLeakIn->Fill(mc.vtxx,mc.vtxy);
04426           if (trkIsInFidVol){
04427             const NtpSRTrack& trk=*ptrk;
04428             hRecoEnNMBTrkLeakIn->Fill(fabs(mc.p4neu[3]));
04429             hYvsXRecoTrkLeakIn->Fill(trk.vtx.x,trk.vtx.y);
04430             hYvsXTrueTrkLeakIn->Fill(mc.vtxx,mc.vtxy);
04431           }
04432         }
04433         continue;
04434       }
04435       
04436       //record events that are reconstructed regardless of fid or not
04437       hRecoEnNMBReco->Fill(fabs(mc.p4neu[3]));
04438 
04439       //any event that makes it to here is in the true fid vol
04440 
04441       //now check if the events in the true fid vol are in reco fid vol
04442       if (!trkIsInFidVol) {
04443         //these events leaked out of fid vol
04444         if (ptrk){
04445           const NtpSRTrack& trk=*ptrk;
04446           hRecoEnNMBTrkLeakOut->Fill(fabs(mc.p4neu[3]));
04447           hYvsXRecoTrkLeakOut->Fill(trk.vtx.x,trk.vtx.y);
04448           hYvsXTrueTrkLeakOut->Fill(mc.vtxx,mc.vtxy);
04449         }
04450         else{
04451           MAXMSG("NuAnalysis",Msg::kInfo,20)
04452             <<"No track, using evt vtx"<<endl;
04453           hRecoEnNMBTrkLeakOut->Fill(fabs(mc.p4neu[3]));
04454           hYvsXRecoTrkLeakOut->Fill(evt.vtx.x,evt.vtx.y);
04455           hYvsXTrueTrkLeakOut->Fill(mc.vtxx,mc.vtxy);
04456         }
04457       }
04458       if (!isInFidVol) {
04459         //these events leaked out of fid vol
04460         hRecoEnNMBLeakOut->Fill(fabs(mc.p4neu[3]));
04461         hYvsXRecoLeakOut->Fill(evt.vtx.x,evt.vtx.y);
04462         hYvsXTrueLeakOut->Fill(mc.vtxx,mc.vtxy);
04463         continue;
04464       }
04465       evtInFidVolCounter++;
04466       hRecoEnNMBFid->Fill(fabs(mc.p4neu[3]));
04467 
04468       //ensure there is a track in the event
04469       if (evt.ntrack<1) continue;
04470       //if (evt.ntrack!=1) continue;//require exactly 1 track
04471       evtWithTrkCounter++;
04472       hRecoEnNMBTrack->Fill(fabs(mc.p4neu[3]));
04473 
04474       //get the best track in the event
04475       if (ptrk==0) continue;
04476       const NtpSRTrack& trk=*ptrk;
04477       goodBestTrkCounter++;
04478 
04479       //require a trk fit
04480       if (!trk.fit.pass) continue;
04481       goodTrkPassCounter++;
04482       hRecoEnNMBPass->Fill(fabs(mc.p4neu[3]));
04483 
04484       //check for wrong sign
04485       if (trk.momentum.qp<=0) continue;
04486       hRecoEnNMBQCut->Fill(fabs(mc.p4neu[3]));
04487       
04489       //RECONSTRUCT the neutrino energy
04490       lib.reco.GetEvtEnergy(nu, false);
04491       goodRecoEnCounter++;
04492       //get the truth info (reco quantities are done above)
04493       reco.GetTruthInfo(ntp,evt,nu);
04494       //set the charge
04495       nu.charge=trk.momentum.qp<0 ? -1 : 1;
04496       if (trk.momentum.qp==0) nu.charge=0;
04497 
04498       //cut on the fractional track momentum and sign error      
04499       if (!cuts.IsGoodSigmaQP_QP(nu)) continue;
04500       goodFitSigQPCounter++;
04501       hRecoEnNMBSigQP->Fill(fabs(mc.p4neu[3]));
04502 
04503       //cut on the track fit probability      
04504       if (!cuts.IsGoodFitProb(nu)) continue;
04505       goodFitProbCounter++;
04506       hRecoEnNMBProb->Fill(fabs(mc.p4neu[3]));
04507 
04508       nu.dpID=dp.CalcPID(&mad,ievt,0);
04509       if (nu.dpID>=-0.1) {
04510         hRecoEnNMBDpID01->Fill(fabs(mc.p4neu[3]));
04511       }
04512 
04513       if (nu.dpID>=0.4) {
04514         hRecoEnNMBDpID04->Fill(fabs(mc.p4neu[3]));
04515       }
04516     }
04517   }//end of for                                       
04518   
04522 
04523   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
04524 
04525   //store the number of files added to the chain
04526   Int_t nf=this->GetNumFilesAddedToChain();
04527   TH1F* hRun=dynamic_cast<TH1F*>(gROOT->FindObject("hRun"));
04528   Float_t nr=-1;
04529   if (hRun) nr=hRun->GetEntries();
04530   TH1F* hNumFiles=new TH1F("hNumFiles","hNumFiles",15,-5,10);
04531   hNumFiles->Fill(1,nf);//store as weight, access with GetMaximum
04532   MSG("NuAnalysis",Msg::kInfo)
04533     <<"Files added to chain="<<hNumFiles->GetMaximum()
04534     <<", runs found="<<nr<<endl;
04535 
04536   MSG("NuAnalysis",Msg::kInfo)
04537     <<"Found start time and end time: "
04538     <<startTimeSecs<<" -> "<<endTimeSecs<<endl;
04539   general.EpochTo1995(endTimeSecs);
04540   general.EpochTo1995(startTimeSecs);
04541   
04542   MSG("NuAnalysis",Msg::kInfo)<<"Filling vs. Time plots..."<<endl;
04543   TH1F* hSpillsVsTime=new TH1F("hSpillsVsTime","hSpillsVsTime",
04544                                100,startTimeSecs,endTimeSecs);
04545   general.TH1FFill(hSpillsVsTime,vTime);
04546   general.SetGraphAxis(hSpillsVsTime->GetXaxis(),
04547                      startTimeSecs,endTimeSecs);
04548   hSpillsVsTime->GetXaxis()->CenterTitle();
04549   hSpillsVsTime->GetYaxis()->SetTitle("Spills");
04550   hSpillsVsTime->GetYaxis()->CenterTitle();
04551 
04552   TH1F* hSpillsBadVsTime=new TH1F("hSpillsBadVsTime","hSpillsBadVsTime",
04553                                   100,startTimeSecs,endTimeSecs);
04554   general.TH1FFill(hSpillsBadVsTime,vTimeBad);
04555   general.SetGraphAxis(hSpillsBadVsTime->GetXaxis(),
04556                      startTimeSecs,endTimeSecs);
04557   hSpillsBadVsTime->GetXaxis()->CenterTitle();
04558   hSpillsBadVsTime->GetYaxis()->SetTitle("Spills");
04559   hSpillsBadVsTime->GetYaxis()->CenterTitle();
04560   
04561   TH1F* hNuMuVsTime=new TH1F("hNuMuVsTime","hNuMuVsTime",
04562                              100,startTimeSecs,endTimeSecs);
04563   general.TH1FFill(hNuMuVsTime,vTimeNuMuEvt);
04564   general.SetGraphAxis(hNuMuVsTime->GetXaxis(),
04565                      startTimeSecs,endTimeSecs);
04566   hNuMuVsTime->GetXaxis()->CenterTitle();
04567   hNuMuVsTime->GetYaxis()->SetTitle("#nu_#mu events");
04568   hNuMuVsTime->GetYaxis()->CenterTitle();
04569 
04570   TH1F* hNuMuBarVsTime=new TH1F("hNuMuBarVsTime","hNuMuBarVsTime",
04571                                100,startTimeSecs,endTimeSecs);
04572   general.TH1FFill(hNuMuBarVsTime,vTimeNuMuBarEvt);
04573   general.SetGraphAxis(hNuMuBarVsTime->GetXaxis(),
04574                      startTimeSecs,endTimeSecs);
04575   hNuMuBarVsTime->GetXaxis()->CenterTitle();
04576   hNuMuBarVsTime->GetYaxis()->SetTitle("#bar{#nu_#mu} events");
04577   hNuMuBarVsTime->GetYaxis()->CenterTitle();
04578 
04579   TH1F* hPotVsTime=new TH1F("hPotVsTime","hPotVsTime",
04580                              100,startTimeSecs,endTimeSecs);
04581   general.TH1FFill(hPotVsTime,vTime,vPot);
04582   general.SetGraphAxis(hPotVsTime->GetXaxis(),
04583                      startTimeSecs,endTimeSecs);
04584   hPotVsTime->GetXaxis()->CenterTitle();
04585   hPotVsTime->GetYaxis()->SetTitle("POT");
04586   hPotVsTime->GetYaxis()->CenterTitle();
04587 
04588   TH1F* hPotBadVsTime=new TH1F("hPotBadVsTime","hPotBadVsTime",
04589                              100,startTimeSecs,endTimeSecs);
04590   general.TH1FFill(hPotBadVsTime,vTimeBad,vPotBad);
04591   general.SetGraphAxis(hPotBadVsTime->GetXaxis(),
04592                      startTimeSecs,endTimeSecs);
04593   hPotBadVsTime->GetXaxis()->CenterTitle();
04594   hPotBadVsTime->GetYaxis()->SetTitle("POT");
04595   hPotBadVsTime->GetYaxis()->CenterTitle();
04596   
04597   Float_t totalPotHist=0;
04598   Float_t totalPotBadHist=0;
04599   cuts.CalcTotalPot(totalPotHist,totalPotBadHist);
04600   Float_t pcPotRejected=0;
04601   if (totalPotHist) pcPotRejected=100.*totalPotBadHist/totalPotHist;
04602 
04603   //msg was giving pots=412886000000000000.000000... still is for MC!
04604   cout<<"Number of spills     ="<<this->GetEntries()<<endl
04605       <<"Number of good spills="<<goodSpillCounter<<endl
04606       <<"Number of bad spills ="<<badSpillCounter<<endl
04607       <<"Sum of good+bad spill="<<badSpillCounter+goodSpillCounter<<endl
04608       <<endl
04609       <<"Total POT good       ="<<totalPot*1e12<<endl
04610       <<"Total POT bad        ="<<totalPotBad*1e12<<endl
04611       <<"Total POT good (hist)="<<totalPotHist*1e12<<endl
04612       <<"Total POT bad  (hist)="<<totalPotBadHist*1e12
04613       <<"  ("<<pcPotRejected<<"%)"<<endl;
04614 
04615   MSG("NuAnalysis",Msg::kInfo)
04616     <<endl<<"*************************************"<<endl
04617     <<"Total Events    ="<<evtCounter<<endl
04618     <<"Evt not litime  ="<<evtNotlitime<<endl
04619     <<"Evt not IsLI    ="<<evtNotIsLI<<endl
04620     <<"Evts in Fid     ="<<evtInFidVolCounter<<endl
04621     <<"Evts w/ Trk     ="<<evtWithTrkCounter<<endl
04622     <<"Good Best Trk   ="<<goodBestTrkCounter<<endl
04623     <<"Track Pass      ="<<goodTrkPassCounter<<endl
04624     <<"Good reco energy="<<goodRecoEnCounter<<endl
04625     <<"Good UVDiff     ="<<goodUVDiffCounter<<endl
04626     <<"Trk Vtx in Fid  ="<<trkInFidVolCounter<<endl
04627     <<"Good Fit SigQP  ="<<goodFitSigQPCounter<<endl
04628     <<"Good Fit Prob   ="<<goodFitProbCounter<<endl
04629     <<"Good Fit Chi2   ="<<goodFitChi2Counter<<endl
04630     <<"Good Delta T    ="<<goodDeltaTCounter<<endl
04631     <<"Good EvtPerSlc  ="<<goodEvtsPerSlcCounter<<endl
04632     <<"Good DP ID      ="<<goodPIDCounter<<endl
04633     <<"Good beyond tEnd="<<goodBeyondTrkEndCounter<<endl
04634     <<"Good shw fract  ="<<goodShwFractCounter<<endl
04635     <<"*************************************"<<endl;
04636 
04637   Float_t pcPQ=0;
04638   if (nuPQCounter+nuNQCounter>0) pcPQ=100.*nuPQCounter/
04639                                    (nuPQCounter+nuNQCounter);
04640   MSG("NuAnalysis",Msg::kInfo)
04641     <<endl
04642     <<"Neutrinos with NQ="<<nuNQCounter<<endl
04643     <<"Neutrinos with PQ="<<nuPQCounter
04644     <<"   ("<<pcPQ<<"%)"<<endl
04645     <<"Sum NQ+PQ        ="<<nuNQCounter+nuPQCounter<<endl
04646     <<endl;
04647   
04648   MSG("NuAnalysis",Msg::kInfo) 
04649     <<" ** Finished Efficiencies method **"<<endl;
04650 }

void NuAnalysis::EfficienciesOld (  ) 

Definition at line 349 of file NuAnalysis.cxx.

References NtpMCStdHep::child, NtpStRecord::evt, NtpSRTrack::fit, NuBase::fOutFile, NuBase::GetEntries(), NuBase::GetNtpStRecord(), NtpSRStripPulseHeight::gev, NtpMCTruth::iaction, NtpMCStdHep::IdHEP, NtpSRTrack::index, NuBase::InitialiseLoopVariables(), NtpMCTruth::inu, NtpMCTruth::iresonance, NtpMCStdHep::IstHEP, Msg::kInfo, NtpMCStdHep::mass, MAXMSG, NtpStRecord::mc, NtpMCStdHep::mc, NtpSRTrack::momentum, MSG, NtpTHTrack::neumc, NtpSREvent::nshower, NtpSREvent::ntrack, NuBase::OpenFile(), NtpMCStdHep::p4, NtpMCTruth::p4mu1, NtpMCTruth::p4neu, NtpMCStdHep::parent, NtpSRFitTrack::pass, NtpSRShower::ph, NtpSRMomentum::qp, NtpSRMomentum::range, NuBase::SetLoopVariables(), NtpSREvent::shw, NtpStRecord::shw, NtpStRecord::stdhep, NtpStRecord::thshw, NtpStRecord::thtrk, NtpStRecord::trk, and NtpSREvent::trk.

00350 {
00351   MSG("NuAnalysis",Msg::kInfo) 
00352     <<" ** Running Efficiencies method... **"<<endl;
00353   
00354   //open the output file for the histograms
00355   fOutFile=this->OpenFile(100,"NuEfficiencies");
00356 
00357   TProfile* pNuMuBarQEffVsEn=new TProfile("pNuMuBarQEffVsEn","pNuMuBarQEffVsEn",50,0,50);
00358   pNuMuBarQEffVsEn->SetTitle("Charge Sign Efficiency vs. True Neutrino Energy");
00359   pNuMuBarQEffVsEn->GetXaxis()->SetTitle("Energy (GeV)");
00360   pNuMuBarQEffVsEn->GetXaxis()->CenterTitle();
00361   pNuMuBarQEffVsEn->GetYaxis()->SetTitle("Efficiency");
00362   pNuMuBarQEffVsEn->GetYaxis()->CenterTitle();
00363   pNuMuBarQEffVsEn->SetLineColor(1);
00364   pNuMuBarQEffVsEn->SetFillColor(0);
00365   //pNuMuBarQEffVsEn->SetBit(TH1::kCanRebin);
00366 
00367   TProfile* pNuMuQEffVsEn=new TProfile("pNuMuQEffVsEn","pNuMuQEffVsEn",50,0,50);
00368   pNuMuQEffVsEn->SetTitle("Charge Sign Efficiency vs. True Neutrino Energy");
00369   pNuMuQEffVsEn->GetXaxis()->SetTitle("Energy (GeV)");
00370   pNuMuQEffVsEn->GetXaxis()->CenterTitle();
00371   pNuMuQEffVsEn->GetYaxis()->SetTitle("Efficiency");
00372   pNuMuQEffVsEn->GetYaxis()->CenterTitle();
00373   pNuMuQEffVsEn->SetLineColor(1);
00374   pNuMuQEffVsEn->SetFillColor(0);
00375   //pNuMuQEffVsEn->SetBit(TH1::kCanRebin);
00376 
00377   TProfile* pNuMuBarFitPassVsEn=new TProfile("pNuMuBarFitPassVsEn","pNuMuBarFitPassVsEn",50,0,50);
00378   pNuMuBarFitPassVsEn->SetTitle("Fit Pass Fraction vs. True Neutrino Energy");
00379   pNuMuBarFitPassVsEn->GetXaxis()->SetTitle("Energy (GeV)");
00380   pNuMuBarFitPassVsEn->GetXaxis()->CenterTitle();
00381   pNuMuBarFitPassVsEn->GetYaxis()->SetTitle("Pass Fraction");
00382   pNuMuBarFitPassVsEn->GetYaxis()->CenterTitle();
00383   pNuMuBarFitPassVsEn->SetLineColor(1);
00384   pNuMuBarFitPassVsEn->SetFillColor(0);
00385   //pNuMuBarFitPassVsEn->SetBit(TH1::kCanRebin);
00386 
00387   TProfile* pNuMuFitPassVsEn=new TProfile("pNuMuFitPassVsEn","pNuMuFitPassVsEn",50,0,50);
00388   pNuMuFitPassVsEn->SetTitle("Fit Pass Fraction vs. True Neutrino Energy");
00389   pNuMuFitPassVsEn->GetXaxis()->SetTitle("Energy (GeV)");
00390   pNuMuFitPassVsEn->GetXaxis()->CenterTitle();
00391   pNuMuFitPassVsEn->GetYaxis()->SetTitle("Pass Fraction");
00392   pNuMuFitPassVsEn->GetYaxis()->CenterTitle();
00393   pNuMuFitPassVsEn->SetLineColor(1);
00394   pNuMuFitPassVsEn->SetFillColor(0);
00395   //pNuMuFitPassVsEn->SetBit(TH1::kCanRebin);
00396 
00400   
00401   this->InitialiseLoopVariables();  
00402   
00403   //for(Int_t entry=0;entry<10000;entry++){
00404   for(Int_t entry=0;entry<this->GetEntries();entry++){
00405       
00406     this->SetLoopVariables(entry);
00407       
00408     //get reference to NtpStRecord from base class
00409     const NtpStRecord& ntp=(*this->GetNtpStRecord());
00410     
00411     TClonesArray& mcTca=*ntp.mc;
00412     Int_t numInt=mcTca.GetEntries();
00413     MAXMSG("NuAnalysis",Msg::kInfo,20)
00414       <<"Number of entries in NtpMCTruth="
00415       <<mcTca.GetEntries()<<endl;
00416     //if (mcTca.GetEntries()==0){ 
00417 
00418     TClonesArray& evtTca=(*ntp.evt);
00419     const Int_t numEvts=evtTca.GetEntriesFast();
00420     
00421     TClonesArray& trkTca=(*ntp.trk);
00422     const Int_t numTrks=trkTca.GetEntriesFast();
00423 
00424     TClonesArray& thtrkTca=(*ntp.thtrk);//TruthHelper Track TCA
00425     const Int_t numthtrks=thtrkTca.GetEntriesFast();
00426 
00427     TClonesArray& thshwTca=(*ntp.thshw);//TruthHelper Shw TCA
00428     const Int_t numthshws=thshwTca.GetEntriesFast();
00429     
00430     TClonesArray& shwTca=(*ntp.shw);
00431     const Int_t numShws=shwTca.GetEntriesFast();
00432 
00433     //TClonesArray& stpTca=(*ntp.stp);
00434     //const Int_t numStps=stpTca.GetEntries();
00435 
00436     //TClonesArray& slcTca=(*ntp.slc);
00437     //const Int_t numSlcs=slcTca.GetEntries();
00438     
00439     TClonesArray& hepTca=(*ntp.stdhep);
00440     const Int_t numHeps=hepTca.GetEntriesFast();
00441     MAXMSG("NuAnalysis",Msg::kInfo,1000)
00442       <<"Num stdhep entries="<<numHeps<<endl;
00443 
00444     Int_t charmEvent=-1;
00445 
00446     //loop over stdhep
00447     for (Int_t ihep=0;ihep<numHeps;++ihep) {
00448       const NtpMCStdHep& stdhep=
00449         *dynamic_cast<NtpMCStdHep*>(hepTca[ihep]);
00450       
00451       MAXMSG("NuAnalysis",Msg::kInfo,3000)
00452         <<"ihep="<<ihep
00453         <<", mc="<<stdhep.mc
00454         <<", id="<<stdhep.IdHEP
00455         <<", Ist="<<stdhep.IstHEP
00456         <<", parent=["<<stdhep.parent[0]<<","<<stdhep.parent[1]<<"]"
00457         <<", child=["<<stdhep.child[0]<<","<<stdhep.child[1]<<"]"
00458         <<", m="<<stdhep.mass
00459         <<", E="<<stdhep.p4[3]
00460         <<endl;
00461       
00462       if (abs(stdhep.IdHEP)==411 || abs(stdhep.IdHEP)==421 ||
00463           abs(stdhep.IdHEP)==431 || abs(stdhep.IdHEP)==4122){
00464         charmEvent=stdhep.mc;
00465         MAXMSG("NuAnalysis",Msg::kInfo,3000)
00466           <<"Found Charm event, mc="<<charmEvent
00467           <<", id="<<stdhep.IdHEP<<endl;
00468       }
00469     }
00470 
00471     if (charmEvent!=-1){
00472       MAXMSG("NuAnalysis",Msg::kInfo,3000)
00473         <<"CHARM EVENT, mc="<<charmEvent
00474         <<", entry="<<entry<<endl;
00475       //loop over stdhep
00476       for (Int_t ihep=0;ihep<numHeps;++ihep) {
00477         const NtpMCStdHep& stdhep=
00478           *dynamic_cast<NtpMCStdHep*>(hepTca[ihep]);
00479         
00480         if (stdhep.mc!=charmEvent) continue;
00481         
00482         MAXMSG("NuAnalysis",Msg::kInfo,3000)
00483           <<"CH: i="<<ihep
00484           <<", mc="<<stdhep.mc
00485           <<", id="<<stdhep.IdHEP
00486           <<", Ist="<<stdhep.IstHEP
00487           <<", par=["<<stdhep.parent[0]<<","<<stdhep.parent[1]<<"]"
00488           <<", chi=["<<stdhep.child[0]<<","<<stdhep.child[1]<<"]"
00489           <<", m="<<stdhep.mass
00490           <<", E="<<stdhep.p4[3]
00491           <<endl;
00492       }
00493     }
00494     
00495     //loop over the events
00496     for (Int_t ntpevt=0;ntpevt<numEvts;++ntpevt) {
00497       const NtpSREvent& evt=
00498         *dynamic_cast<NtpSREvent*>(evtTca[ntpevt]);
00499       
00500       //ensure there is only 1 track in the event
00501       if (evt.ntrack!=1) continue;
00502       
00503       const NtpSRTrack& trk=
00504         *dynamic_cast<NtpSRTrack*>(trkTca[evt.trk[0]]);
00505 
00506       //sum up the energy of the showers
00507       Float_t totalShwEn=0;
00508       for (Int_t ishw=0;ishw<evt.nshower;++ishw) {
00509         const NtpSRShower& shw=
00510           *dynamic_cast<NtpSRShower*>(shwTca[evt.shw[ishw]]);
00511         totalShwEn+=shw.ph.gev;
00512       }
00513 
00514       MAXMSG("NuAnalysis",Msg::kInfo,100)
00515         <<"Entry "<<entry<<", event "<<ntpevt
00516         <<" has tracks="<<evt.ntrack
00517         <<", evts="<<numEvts
00518         <<", trks="<<numTrks<<", thtrks="<<numthtrks
00519         <<", shws="<<numShws<<", thshws="<<numthshws
00520         <<endl;
00521         //<<", shws="<<numShws<<", slcs="<<numSlcs<<endl;
00522       
00523       //there is a 1 to 1 correspondance between tracks and thtrks
00524       //so just use trk.index to index into the thtrkTca
00525       const NtpTHTrack& thtrk=
00526         *dynamic_cast<NtpTHTrack*>(thtrkTca[trk.index]);
00527       MAXMSG("NuAnalysis",Msg::kInfo,100)
00528         <<"numInt="<<numInt<<", thtrk.neumc="<<thtrk.neumc<<endl;
00529 
00530       //now get the mc object (neutrino interaction) that 
00531       //corresponds to the trk using the thtrk.neumc index
00532       const NtpMCTruth& mc=
00533         *(dynamic_cast<NtpMCTruth*>(mcTca[thtrk.neumc]));
00534      
00535       string iaction="NC";
00536       if (mc.iaction==1) iaction="CC";
00537       string iresonance="QE ";
00538       if (mc.iresonance==1002) iresonance="RES";
00539       else if (mc.iresonance==1003) iresonance="DIS";
00540       else if (mc.iresonance==1004) iresonance=
00541                                       "Coherent pion production";
00542       string inu="??";
00543       if (mc.inu==14) inu="NuMu   ";
00544       else if (mc.inu==-14) inu="NuMuBar";
00545       else if (mc.inu==12) inu="NuE    ";
00546       else if (mc.inu==-12) inu="NuEBar ";
00547       
00548       Float_t trkCurveP=0;
00549       if (trk.momentum.qp!=0) trkCurveP=1./trk.momentum.qp;
00550 
00551       MAXMSG("NuAnalysis",Msg::kInfo,100)
00552         <<""<<inu
00553         <<" "<<iaction
00554         <<" "<<iresonance
00555         <<", E="<<mc.p4neu[3]<<", mu="<<mc.p4mu1[3]<<" GeV"
00556         <<", Reco: trk="<<trk.momentum.range
00557         <<" (curv="<<trkCurveP<<")"
00558         <<", shw="<<totalShwEn//<<", evt="<<evt.ph.gev
00559         <<endl;
00560       
00561       //cut out the NCs
00562       if (mc.iaction==0) continue; 
00563 
00564       Int_t chargeMC=0;
00565       if (mc.p4mu1[3]<0) chargeMC=-1;
00566       else if (mc.p4mu1[3]>0) chargeMC=+1;
00567       
00568       Int_t charge=0;
00569       if (trk.momentum.qp<0) charge=-1;
00570       else if (trk.momentum.qp>0) charge=+1;
00571 
00572       //fill profiles
00573       if (mc.inu==14) {
00574         pNuMuFitPassVsEn->Fill(mc.p4neu[3],trk.fit.pass);      
00575       }
00576       else if (mc.inu==-14) {
00577         pNuMuBarFitPassVsEn->Fill(mc.p4neu[3],trk.fit.pass);      
00578       }
00579       
00580       if (trk.fit.pass){
00581         if (mc.inu==14) {
00582           pNuMuQEffVsEn->Fill(mc.p4neu[3],charge==chargeMC);
00583         }
00584         else if (mc.inu==-14) {
00585           pNuMuBarQEffVsEn->Fill(mc.p4neu[3],charge==chargeMC);
00586         }
00587       }
00588 
00589       //TruthHelperNtuple
00590       //NtpTHModule NtpTHEvent NtpTHRecord NtpTHShower NtpTHSlice
00591       //NtpTHStrip NtpTHTrack
00592       //trk.momentum.qp
00593       //trk.momentum.eqp
00594       //trk.momentum.range
00595     }
00596   }//end of for                                       
00597   
00601 
00602   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
00603 
00604   MSG("NuAnalysis",Msg::kInfo) 
00605     <<" ** Finished Efficiencies method **"<<endl;
00606 }

void NuAnalysis::EndJob (  ) 

Definition at line 6682 of file NuAnalysis.cxx.

References NuBase::fOutFile, StoreOrFinishTree(), and NuBase::WriteOutHistos().

Referenced by NuModule::EndJob().

06683 {
06684   this->StoreOrFinishTree(NULL,NULL,1);
06685   
06686   //write out any histos if a file was opened 
06687   //StoreOrFinishTree deals with the output usually
06688   cout<<"fOutFile="<<fOutFile<<endl;
06689   this->WriteOutHistos();
06690 }

void NuAnalysis::EnergySpect (  ) 

Definition at line 5194 of file NuAnalysis.cxx.

References NuEvent::anaVersion, bfld::AsString(), NuConfig::beamType, NtpSRPlane::beg, MadDpID::CalcPID(), NuCuts::CalcTotalPot(), NuEvent::charge, MadDpID::ChoosePDFs(), NuEvent::containmentFlag, NuEvent::detector, NuConfig::detector, NuEvent::dpID, NuEvent::energy, NuGeneral::EpochTo1995(), NtpStRecord::evt, NuEvent::evt, NtpStRecord::evthdr, NuLibrary::ext, ExtractConfig(), NuExtraction::ExtractEvtInfo(), NuExtraction::ExtractGeneralInfo(), NuExtraction::ExtractShwInfo(), NuExtraction::ExtractTrkInfo(), NuPlots::FillContainmentHistos(), NuPlots::FillDPIdSigmaQPPlotsN(), NuPlots::FillGeneralHistos(), NuPlots::FillRecoEnYHistosN(), NuPlots::FillShwHistos(), NuPlots::FillSigmaQPPlots(), NuPlots::FillTrackResponseHistos(), NuPlots::FillTrueDpIDHistos(), NuPlots::FillTrueDpIDHistosPQNQ(), NuPlots::FillTrueFidEnergySpect(), NuPlots::FillTruePIDHistos(), NuPlots::FillXYZHistos(), NtpSRTrack::fit, NuBase::fOutFile, NuReco::GetBestTrack(), VldContext::GetDetector(), NuBase::GetEntries(), NuReco::GetEvtDeltaTs(), NuReco::GetEvtEnergy(), NuReco::GetEvtsPerSlc(), RecRecordImp< T >::GetHeader(), NuBase::GetNtpStRecord(), RecDataHeader::GetRun(), VldTimeStamp::GetSec(), VldContext::GetSimFlag(), RecDataHeader::GetSubRun(), VldContext::GetTimeStamp(), NuReco::GetTrackWithIndexX(), NuReco::GetTruthInfo(), RecHeader::GetVldContext(), NuBase::InitialiseLoopVariables(), NuLibrary::Instance(), NuCuts::IsGoodDpID(), NuCuts::IsGoodFitChi2PerNdof(), NuCuts::IsGoodFitProb(), NuCuts::IsGoodSigmaQP_QP(), NuBeam::IsGoodSpillAndFillPot(), NuCuts::IsGoodUVVtx(), NuCuts::IsInFidVol(), LISieve::IsLI(), Msg::kDebug, Msg::kInfo, NuCuts::kJJH1, Detector::kNear, Msg::kVerbose, NtpSREventSummary::litime, MAXMSG, NtpSRTrack::momentum, MSG, Munits::ns, NtpSREvent::ntrack, NuBase::OpenFile(), NuBase::OpenTxtFile(), NtpSRFitTrack::pass, NtpSRTrack::plane, NtpSREvent::plane, plots(), NuEvent::pot, NtpSRMomentum::qp, NuLibrary::reco, NuEvent::releaseType, NuConfig::run, NuEvent::run, NuConfig::sBeamType, NuMadAnalysis::SetEntry(), NuGeneral::SetGraphAxis(), NuBase::SetLoopVariables(), NuEvent::simFlag, NtpSREvent::slc, NuEvent::snarl, NuGeneral::TH1FFill(), NuEvent::trkEnMC, NuEvent::trkEnRange, NtpSRVertex::u, NtpSRVertex::v, NtpSREvent::vtx, NtpSRTrack::vtx, NtpSRVertex::x, NuEvent::y, NtpSRVertex::y, and NtpSRVertex::z.

05195 {
05196   MSG("NuAnalysis",Msg::kInfo) 
05197     <<" ** Running EnergySpect method... **"<<endl;
05198   
05199   NuConfig config;
05200   this->ExtractConfig(config);
05201 
05202   //open the output file for the histograms
05203   string sFilePrefix="NMBEnSp"+config.sBeamType;
05204   fOutFile=this->OpenFile(config,sFilePrefix.c_str());
05205 
05206   TH1F* hNuMuBarRecoEn=new TH1F("hNuMuBarRecoEn","hNuMuBarRecoEn",
05207                                 4*352,-32,320);
05208   hNuMuBarRecoEn->GetXaxis()->SetTitle("Energy (GeV)");
05209   hNuMuBarRecoEn->GetXaxis()->CenterTitle();
05210   hNuMuBarRecoEn->GetYaxis()->SetTitle("");
05211   hNuMuBarRecoEn->GetYaxis()->CenterTitle();
05212   hNuMuBarRecoEn->SetFillColor(0);
05213   hNuMuBarRecoEn->SetLineColor(2);
05214   //hNuMuBarRecoEn->SetBit(TH1::kCanRebin);
05215   
05216   TH1F* hNuMuRecoEn=new TH1F("hNuMuRecoEn","hNuMuRecoEn",4*352,-32,320);
05217   hNuMuRecoEn->GetXaxis()->SetTitle("Energy (GeV)");
05218   hNuMuRecoEn->GetXaxis()->CenterTitle();
05219   hNuMuRecoEn->GetYaxis()->SetTitle("");
05220   hNuMuRecoEn->GetYaxis()->CenterTitle();
05221   hNuMuRecoEn->SetFillColor(0);
05222   hNuMuRecoEn->SetLineColor(1);
05223   hNuMuRecoEn->SetLineWidth(2);
05224   //hNuMuRecoEn->SetBit(TH1::kCanRebin);
05225 
05226   TH1F* hNuMuBarRecoY=new TH1F("hNuMuBarRecoY","hNuMuBarRecoY",
05227                                 4*144,-0.16,1.28);
05228   hNuMuBarRecoY->GetXaxis()->SetTitle("y");
05229   hNuMuBarRecoY->GetXaxis()->CenterTitle();
05230   hNuMuBarRecoY->GetYaxis()->SetTitle("");
05231   hNuMuBarRecoY->GetYaxis()->CenterTitle();
05232   hNuMuBarRecoY->SetFillColor(0);
05233   hNuMuBarRecoY->SetLineColor(2);
05234   //hNuMuBarRecoY->SetBit(TH1::kCanRebin);
05235   
05236   TH1F* hNuMuRecoY=new TH1F("hNuMuRecoY","hNuMuRecoY",4*144,-0.16,1.28);
05237   hNuMuRecoY->GetXaxis()->SetTitle("y");
05238   hNuMuRecoY->GetXaxis()->CenterTitle();
05239   hNuMuRecoY->GetYaxis()->SetTitle("");
05240   hNuMuRecoY->GetYaxis()->CenterTitle();
05241   hNuMuRecoY->SetFillColor(0);
05242   hNuMuRecoY->SetLineColor(1);
05243   hNuMuRecoY->SetLineWidth(2);
05244   //hNuMuRecoY->SetBit(TH1::kCanRebin);
05245 
05246   TH1F* hDpIDAll=new TH1F("hDpIDAll","hDpIDAll",4*160,-1.6,1.6);
05247   hDpIDAll->GetXaxis()->SetTitle("PID (from MadDpID)");
05248   hDpIDAll->GetXaxis()->CenterTitle();
05249   hDpIDAll->GetYaxis()->SetTitle("");
05250   hDpIDAll->GetYaxis()->CenterTitle();
05251   hDpIDAll->SetFillColor(0);
05252   hDpIDAll->SetLineColor(1);
05253   hDpIDAll->SetLineWidth(2);
05254   //hDpIDAll->SetBit(TH1::kCanRebin);
05255 
05256   TH1F* hDpIDPQ=new TH1F("hDpIDPQ","hDpIDPQ",4*160,-1.6,1.6);
05257   hDpIDPQ->GetXaxis()->SetTitle("PID (from MadDpID)");
05258   hDpIDPQ->GetXaxis()->CenterTitle();
05259   hDpIDPQ->GetYaxis()->SetTitle("");
05260   hDpIDPQ->GetYaxis()->CenterTitle();
05261   hDpIDPQ->SetFillColor(0);
05262   hDpIDPQ->SetLineColor(1);
05263   hDpIDPQ->SetLineWidth(2);
05264   //hDpIDPQ->SetBit(TH1::kCanRebin);
05265 
05266   TH1F* hDpIDNQ=new TH1F("hDpIDNQ","hDpIDNQ",4*160,-1.6,1.6);
05267   hDpIDNQ->GetXaxis()->SetTitle("PID (from MadDpID)");
05268   hDpIDNQ->GetXaxis()->CenterTitle();
05269   hDpIDNQ->GetYaxis()->SetTitle("");
05270   hDpIDNQ->GetYaxis()->CenterTitle();
05271   hDpIDNQ->SetFillColor(0);
05272   hDpIDNQ->SetLineColor(1);
05273   hDpIDNQ->SetLineWidth(2);
05274   //hDpIDNQ->SetBit(TH1::kCanRebin);
05275 
05276   TH1F* hDpIDPQN_1=new TH1F("hDpIDPQN_1","hDpIDPQN_1",4*160,-1.6,1.6);
05277   hDpIDPQN_1->GetXaxis()->SetTitle("PID (from MadDpID)");
05278   hDpIDPQN_1->GetXaxis()->CenterTitle();
05279   hDpIDPQN_1->GetYaxis()->SetTitle("");
05280   hDpIDPQN_1->GetYaxis()->CenterTitle();
05281   hDpIDPQN_1->SetFillColor(0);
05282   hDpIDPQN_1->SetLineColor(1);
05283   hDpIDPQN_1->SetLineWidth(2);
05284   //hDpIDPQN_1->SetBit(TH1::kCanRebin);
05285 
05286   TH1F* hDpIDNQN_1=new TH1F("hDpIDNQN_1","hDpIDNQN_1",4*160,-1.6,1.6);
05287   hDpIDNQN_1->GetXaxis()->SetTitle("PID (from MadDpID)");
05288   hDpIDNQN_1->GetXaxis()->CenterTitle();
05289   hDpIDNQN_1->GetYaxis()->SetTitle("");
05290   hDpIDNQN_1->GetYaxis()->CenterTitle();
05291   hDpIDNQN_1->SetFillColor(0);
05292   hDpIDNQN_1->SetLineColor(1);
05293   hDpIDNQN_1->SetLineWidth(2);
05294   //hDpIDNQN_1->SetBit(TH1::kCanRebin);
05295 
05296   //vectors
05297   Int_t entries=static_cast<Int_t>(this->GetEntries());
05298   Int_t startTimeSecs=2000000000;//2 billion
05299   Int_t endTimeSecs=1;
05300   vector<Double_t> vPot;
05301   vPot.reserve(entries);
05302   vector<Double_t> vTime;
05303   vTime.reserve(entries);
05304   vector<Double_t> vPotBad;
05305   vPotBad.reserve(entries/10);
05306   vector<Double_t> vTimeBad;
05307   vTimeBad.reserve(entries/10);
05308   
05309   vector<Double_t> vTimeNuMuEvt;
05310   vTimeNuMuEvt.reserve(entries/5);
05311   vector<Double_t> vTimeNuMuBarEvt;
05312   vTimeNuMuBarEvt.reserve(entries/5);
05313  
05314   //maps to store evt info
05315   map<Int_t,Double_t> deltaTs;
05316   map<Int_t,Int_t> evtsPerSlc;
05317 
05318   //counters
05319   Int_t goodSpillCounter=0;
05320   Int_t badSpillCounter=0;
05321   Float_t totalPot=0;
05322   Float_t totalPotBad=0;
05323   Int_t evtCounter=0;
05324   Int_t evtNotlitime=0;
05325   Int_t evtNotIsLI=0;
05326   Int_t evtInFidVolCounter=0;
05327   Int_t evtWithTrkCounter=0;
05328   Int_t goodBestTrkCounter=0;
05329   Int_t goodTrkPassCounter=0;
05330   Int_t goodRecoEnCounter=0;
05331   Int_t goodUVDiffCounter=0;
05332   Int_t trkInFidVolCounter=0;
05333   Int_t goodFitSigQPCounter=0;
05334   Int_t goodFitProbCounter=0;
05335   Int_t goodFitChi2Counter=0;
05336   Int_t goodDeltaTCounter=0;
05337   Int_t goodEvtsPerSlcCounter=0; 
05338   Int_t goodPIDCounter=0;
05339   Int_t goodBeyondTrkEndCounter=0;
05340   Int_t goodShwFractCounter=0;
05341   Int_t nuNQCounter=0;
05342   Int_t nuPQCounter=0;
05343   
05344   string sTxtFilePrefix="nmb"+config.sBeamType;
05345   ofstream& nmbTxt=*(this->OpenTxtFile(config,
05346                                        sTxtFilePrefix.c_str()));
05347 
05348   //classes to organise the code in to related functions
05349   const NuCuts cuts;
05350   const NuGeneral general;
05351   const NuPlots plots;
05352   const NuReco reco;
05353   const NuExtraction ext;
05354   const NuBeam beam;
05355 
05356   //create these on the heap so that they don't destruct
05357   // - on purpose to avoid a segv on destruction... nice coding!
05358   NuMadAnalysis& mad=*new NuMadAnalysis();
05359   MadDpID& dp=*new MadDpID();
05360   //BeamType::BeamType_t beamType=BeamType::kLE;
05361   BeamType::BeamType_t beamType=static_cast
05362     <BeamType::BeamType_t>(config.beamType);
05363  
05364   //define the analysis (cuts and reco) to use
05365   NuCuts::NuAnaVersion_t anaVersion=NuCuts::kJJH1;
05366   
05367   //get an instance of the code library
05368   const NuLibrary& lib=NuLibrary::Instance();
05369   
05373   
05374   cout<<endl
05375       <<"************************************************"<<endl
05376       <<"***      Starting main loop over snarls      ***"<<endl
05377       <<"************************************************"<<endl;
05378 
05379   this->InitialiseLoopVariables();  
05380   
05381   //for(Int_t entry=12100;entry<this->GetEntries();entry++){
05382   for(Int_t entry=0;entry<this->GetEntries();entry++){
05383       
05384     this->SetLoopVariables(entry);
05385       
05386     //get reference to NtpStRecord from base class
05387     const NtpStRecord& ntp=(*this->GetNtpStRecord());
05388 
05389     const RecCandHeader& rec=ntp.GetHeader();
05390     MAXMSG("NuAnalysis",Msg::kInfo,5)
05391       <<"Found: run="<<rec.GetRun()
05392       <<", subrun="<<rec.GetSubRun()
05393       <<", detector="<<rec.GetVldContext().GetDetector()
05394       <<", simFlag="<<rec.GetVldContext().GetSimFlag()
05395       <<endl;
05396 
05397     //write out the detector, simflag, etc
05398     plots.FillGeneralHistos(ntp);
05399 
05400     //simple event object to hold important quantities for snarl
05401     NuEvent nuSnarl;
05402     //set the analysis (cuts and reco) version to use
05403     nuSnarl.anaVersion=anaVersion;
05404     //get the run, snarl, etc info
05405     ext.ExtractGeneralInfo(ntp,nuSnarl);
05406 
05407     //get the true energy spectra of events in the fid vol
05408     plots.FillTrueFidEnergySpect(nuSnarl);
05409 
05410     Int_t evTime=rec.GetVldContext().GetTimeStamp().GetSec();
05411     //get the min and max times
05412     if (evTime>endTimeSecs) endTimeSecs=evTime;
05413     if (evTime<startTimeSecs && evTime>0) startTimeSecs=evTime;
05414     if (evTime<=0) cout<<"Bad time="<<evTime<<endl;
05415     //convert to 1995 time
05416     general.EpochTo1995(evTime);
05417     
05418     if (!beam.IsGoodSpillAndFillPot
05419         (this->GetNtpBDLiteRecord(),config,nuSnarl)) {
05420       badSpillCounter++;
05421       totalPotBad+=nuSnarl.pot;
05422       vPotBad.push_back(nuSnarl.pot*1e12);
05423       vTimeBad.push_back(evTime);
05424       continue;
05425     }
05426     goodSpillCounter++;
05427     totalPot+=nuSnarl.pot;    
05428     vPot.push_back(nuSnarl.pot*1e12);
05429     vTime.push_back(evTime);
05430 
05431     dp.ChoosePDFs(rec.GetVldContext().GetDetector(),beamType,
05432                   ReleaseType::AsString(nuSnarl.releaseType),
05433                   ReleaseType::AsString(nuSnarl.releaseType));
05434     mad.SetEntry(&ntp);
05435 
05436     TClonesArray& evtTca=(*ntp.evt);
05437     const Int_t numEvts=evtTca.GetEntriesFast();
05438 
05440     //loop over the reconstructed events
05442     for (Int_t ievt=0;ievt<numEvts;ievt++){
05443       const NtpSREvent& evt=
05444         *dynamic_cast<NtpSREvent*>(evtTca[ievt]);
05445       evtCounter++;
05446 
05447       const NtpSREventSummary& evthdr=ntp.evthdr;
05448       
05449       if (evthdr.litime!=-1) {
05450         MAXMSG("NuAnalysis",Msg::kInfo,500)
05451           <<"skipping event: litime="<<evthdr.litime<<endl;
05452         continue;
05453       }
05454       evtNotlitime++;
05455 
05456       Bool_t isLI=LISieve::IsLI(ntp);
05457       if (isLI){
05458         MAXMSG("NuAnalysis",Msg::kInfo,50)
05459           <<"Found LI"
05460           <<", run="<<config.run
05461           <<", entry="<<entry
05462           <<", event="<<ievt
05463           <<", litime="<<evthdr.litime
05464           <<endl;
05465       }
05466       else {
05467         MAXMSG("NuAnalysis",Msg::kInfo,50)
05468           <<"Not LI"
05469           <<", run="<<config.run
05470           <<", entry="<<entry
05471           <<", event="<<ievt
05472           <<", litime="<<evthdr.litime
05473           <<endl;
05474       }
05475       if (isLI) continue;
05476       evtNotIsLI++;
05477 
05478       //simple event object to hold important quantities
05479       NuEvent nu;
05480       
05481       //get the run, snarl, etc info
05482       ext.ExtractGeneralInfo(ntp,nu);
05483       //get info from the evt
05484       lib.ext.ExtractEvtInfo(evt,nu);
05485       //extract trk info (needed to get best track info)
05486       lib.ext.ExtractTrkInfo(ntp,evt,nu);
05487       //extract shw info
05488       lib.ext.ExtractShwInfo(ntp,evt,nu);
05489       
05490       Bool_t isInFidVol=cuts.IsInFidVol(evt.vtx.x,evt.vtx.y,
05491                                         evt.vtx.z,
05492                                         evt.vtx.u,evt.vtx.v,0,0,
05493                                         nu.detector,nu.anaVersion,
05494                                         nu.releaseType,nu.simFlag);
05495 
05496       if (!isInFidVol) continue;
05497       evtInFidVolCounter++;
05498 
05499       nu.dpID=dp.CalcPID(&mad,ievt,0);
05500       MAXMSG("NuAnalysis",Msg::kDebug,50)
05501         <<"dpID="<<nu.dpID<<endl;
05502       hDpIDAll->Fill(nu.dpID);
05503             
05504       //ensure there is a track in the event
05505       //if (evt.ntrack<1) continue;
05506       if (evt.ntrack!=1) continue;//require exactly 1 track
05507       evtWithTrkCounter++;
05508 
05509       //get the best track in the event
05510       Int_t bestTrack=lib.reco.GetBestTrack(nu);
05511       const NtpSRTrack* ptrk=lib.reco.GetTrackWithIndexX
05512         (ntp,evt,bestTrack-1);
05513       if (ptrk==0) continue;
05514       const NtpSRTrack& trk=*ptrk;
05515       goodBestTrkCounter++;
05516 
05517       //require a trk fit
05518       if (!trk.fit.pass) continue;
05519       goodTrkPassCounter++;
05520       
05522       //RECONSTRUCT the neutrino energy
05523       lib.reco.GetEvtEnergy(nu, false);
05524       goodRecoEnCounter++;
05525   
05526       //get the truth info (reco quantities are done above)
05527       reco.GetTruthInfo(ntp,evt,nu);
05528 
05529       if (!cuts.IsGoodUVVtx(nu)){
05530         continue;
05531       }
05532       goodUVDiffCounter++;
05533 
05534       //check if the trk is in the fiducial volume
05535       Bool_t isTrkInFidVol=cuts.IsInFidVol(trk.vtx.x,trk.vtx.y,
05536                                            trk.vtx.z,
05537                                            trk.vtx.u,trk.vtx.v,0,0,
05538                                            nu.detector,nu.anaVersion,
05539                                            nu.releaseType,nu.simFlag);
05540       if (!isTrkInFidVol) continue;
05541       trkInFidVolCounter++;
05542       
05543       plots.FillSigmaQPPlots(nu);
05544       plots.FillTrueDpIDHistos(nu);
05545 
05546       //set the charge
05547       nu.charge=trk.momentum.qp<0 ? -1 : 1;
05548       if (trk.momentum.qp==0) nu.charge=0;
05549 
05550       //cut on the fractional track momentum and sign error      
05551       if (!cuts.IsGoodSigmaQP_QP(nu)) continue;
05552       goodFitSigQPCounter++;
05553       
05554       //cut on the track fit probability      
05555       if (!cuts.IsGoodFitProb(nu)) continue;
05556       goodFitProbCounter++;
05557 
05558       Float_t chi2PerNdof=999999;
05559       if (!cuts.IsGoodFitChi2PerNdof(nu)){
05560         MAXMSG("NuAnalysis",Msg::kVerbose,100)
05561           <<"Cutting out bad chi2PerNdof="<<chi2PerNdof<<endl;
05562         continue;
05563       }
05564       goodFitChi2Counter++;
05565 
05566       //get the maps of evts' info
05567       deltaTs.clear();
05568       reco.GetEvtDeltaTs(ntp,deltaTs);
05569       evtsPerSlc.clear();
05570       reco.GetEvtsPerSlc(ntp,evtsPerSlc);      
05571       MsgFormat ffmt("%9.9f");
05572       MAXMSG("NuReco",Msg::kDebug,100)
05573         <<"smallestDelta="<<ffmt(deltaTs[ievt])
05574         <<", evtsPerSlc="<<evtsPerSlc[evt.slc]<<endl;
05575 
05576       //only do the cut for the ND
05577       if (config.detector==Detector::kNear && 
05578           deltaTs[ievt]<50*Munits::ns) continue;
05579       goodDeltaTCounter++;
05580 
05581       //only do the cut for the ND
05582       if (config.detector==Detector::kNear && 
05583           evtsPerSlc[evt.slc]!=1) continue;
05584       goodEvtsPerSlcCounter++;
05585 
05586       plots.FillTrueDpIDHistosPQNQ(nu);
05587       if (trk.momentum.qp<0) {
05588         hDpIDNQN_1->Fill(nu.dpID);
05589       }
05590       else if (trk.momentum.qp>0) {
05591         hDpIDPQN_1->Fill(nu.dpID);
05592       }
05593 
05594       //cut on the PID
05595       if (!cuts.IsGoodDpID(nu)) continue;
05596       goodPIDCounter++;
05597       
05598       Float_t sigCorBeyond=0;
05599       goodBeyondTrkEndCounter++;
05600 
05601       Float_t fractFull=0;
05602       //if (!cuts.IsGoodShwFract(ntp,evt,nu,&fractFull)) continue;
05603       goodShwFractCounter++;
05604 
05605       Float_t evtTrkVtxDiff=evt.plane.beg-trk.plane.beg;
05606       
05607       //reco.PrintTrueEnergy(ntp,evt,nu.energy);
05608       
05609       if (trk.momentum.qp<0) {
05610         hNuMuRecoEn->Fill(nu.energy);
05611         hNuMuRecoY->Fill(nu.y);
05612         hDpIDNQ->Fill(nu.dpID);
05613         vTimeNuMuEvt.push_back(evTime);
05614         nuNQCounter++;
05615       }
05616       else if (trk.momentum.qp>0) {
05617         //file format: run snarl event
05618         nmbTxt<<nu.run<<" "<<nu.snarl<<" "<<nu.evt<<endl;
05619         string sStop="PC";
05620         if (nu.containmentFlag==1 || 
05621             nu.containmentFlag==3) sStop="FC";
05622         
05623         Float_t dRng=999999;
05624         if (nu.trkEnMC) dRng=(nu.trkEnRange-nu.trkEnMC)/nu.trkEnMC;
05625         nmbTxt<<"# "
05626               <<sStop<<nu.containmentFlag
05627               <<", dRng="<<dRng
05628               <<", beyond="<<sigCorBeyond
05629               <<", frFull="<<fractFull
05630               <<", e-tVtx="<<evtTrkVtxDiff
05631               <<endl;
05632         nmbTxt<<"# "<<endl;//leave a line
05633 
05634         hNuMuBarRecoEn->Fill(nu.energy);
05635         hNuMuBarRecoY->Fill(nu.y);
05636         hDpIDPQ->Fill(nu.dpID);
05637         vTimeNuMuBarEvt.push_back(evTime);
05638         nuPQCounter++;
05639       }
05640       else cout<<"ahhh, zero qp"<<endl;
05641       
05642       plots.FillRecoEnYHistosN(nu);
05643       plots.FillDPIdSigmaQPPlotsN(nu);
05644 
05645       plots.FillShwHistos(ntp,evt,nu);
05646       plots.FillXYZHistos(nu);
05647       plots.FillContainmentHistos(nu);
05648       plots.FillTruePIDHistos(nu);
05649       plots.FillTrackResponseHistos(ntp,trk,nu);
05650     }
05651   }//end of for                                       
05652   
05656 
05657   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
05658 
05659   MSG("NuAnalysis",Msg::kInfo)
05660     <<"Found start time and end time: "
05661     <<startTimeSecs<<" -> "<<endTimeSecs<<endl;
05662   general.EpochTo1995(endTimeSecs);
05663   general.EpochTo1995(startTimeSecs);
05664   
05665   MSG("NuAnalysis",Msg::kInfo)<<"Filling vs. Time plots..."<<endl;
05666   TH1F* hSpillsVsTime=new TH1F("hSpillsVsTime","hSpillsVsTime",
05667                                100,startTimeSecs,endTimeSecs);
05668   general.TH1FFill(hSpillsVsTime,vTime);
05669   general.SetGraphAxis(hSpillsVsTime->GetXaxis(),
05670                      startTimeSecs,endTimeSecs);
05671   hSpillsVsTime->GetXaxis()->CenterTitle();
05672   hSpillsVsTime->GetYaxis()->SetTitle("Spills");
05673   hSpillsVsTime->GetYaxis()->CenterTitle();
05674 
05675   TH1F* hSpillsBadVsTime=new TH1F("hSpillsBadVsTime","hSpillsBadVsTime",
05676                                   100,startTimeSecs,endTimeSecs);
05677   general.TH1FFill(hSpillsBadVsTime,vTimeBad);
05678   general.SetGraphAxis(hSpillsBadVsTime->GetXaxis(),
05679                      startTimeSecs,endTimeSecs);
05680   hSpillsBadVsTime->GetXaxis()->CenterTitle();
05681   hSpillsBadVsTime->GetYaxis()->SetTitle("Spills");
05682   hSpillsBadVsTime->GetYaxis()->CenterTitle();
05683   
05684   TH1F* hNuMuVsTime=new TH1F("hNuMuVsTime","hNuMuVsTime",
05685                              100,startTimeSecs,endTimeSecs);
05686   general.TH1FFill(hNuMuVsTime,vTimeNuMuEvt);
05687   general.SetGraphAxis(hNuMuVsTime->GetXaxis(),
05688                      startTimeSecs,endTimeSecs);
05689   hNuMuVsTime->GetXaxis()->CenterTitle();
05690   hNuMuVsTime->GetYaxis()->SetTitle("#nu_#mu events");
05691   hNuMuVsTime->GetYaxis()->CenterTitle();
05692 
05693   TH1F* hNuMuBarVsTime=new TH1F("hNuMuBarVsTime","hNuMuBarVsTime",
05694                                100,startTimeSecs,endTimeSecs);
05695   general.TH1FFill(hNuMuBarVsTime,vTimeNuMuBarEvt);
05696   general.SetGraphAxis(hNuMuBarVsTime->GetXaxis(),
05697                      startTimeSecs,endTimeSecs);
05698   hNuMuBarVsTime->GetXaxis()->CenterTitle();
05699   hNuMuBarVsTime->GetYaxis()->SetTitle("#bar{#nu_#mu} events");
05700   hNuMuBarVsTime->GetYaxis()->CenterTitle();
05701 
05702   TH1F* hPotVsTime=new TH1F("hPotVsTime","hPotVsTime",
05703                              100,startTimeSecs,endTimeSecs);
05704   general.TH1FFill(hPotVsTime,vTime,vPot);
05705   general.SetGraphAxis(hPotVsTime->GetXaxis(),
05706                      startTimeSecs,endTimeSecs);
05707   hPotVsTime->GetXaxis()->CenterTitle();
05708   hPotVsTime->GetYaxis()->SetTitle("POT");
05709   hPotVsTime->GetYaxis()->CenterTitle();
05710 
05711   TH1F* hPotBadVsTime=new TH1F("hPotBadVsTime","hPotBadVsTime",
05712                              100,startTimeSecs,endTimeSecs);
05713   general.TH1FFill(hPotBadVsTime,vTimeBad,vPotBad);
05714   general.SetGraphAxis(hPotBadVsTime->GetXaxis(),
05715                      startTimeSecs,endTimeSecs);
05716   hPotBadVsTime->GetXaxis()->CenterTitle();
05717   hPotBadVsTime->GetYaxis()->SetTitle("POT");
05718   hPotBadVsTime->GetYaxis()->CenterTitle();
05719   
05720   Float_t totalPotHist=0;
05721   Float_t totalPotBadHist=0;
05722   cuts.CalcTotalPot(totalPotHist,totalPotBadHist);
05723   Float_t pcPotRejected=0;
05724   if (totalPotHist) pcPotRejected=100.*totalPotBadHist/totalPotHist;
05725 
05726   //msg was giving pots=412886000000000000.000000... still is for MC!
05727   cout<<"Number of spills     ="<<this->GetEntries()<<endl
05728       <<"Number of good spills="<<goodSpillCounter<<endl
05729       <<"Number of bad spills ="<<badSpillCounter<<endl
05730       <<"Sum of good+bad spill="<<badSpillCounter+goodSpillCounter<<endl
05731       <<endl
05732       <<"Total POT good       ="<<totalPot*1e12<<endl
05733       <<"Total POT bad        ="<<totalPotBad*1e12<<endl
05734       <<"Total POT good (hist)="<<totalPotHist*1e12<<endl
05735       <<"Total POT bad  (hist)="<<totalPotBadHist*1e12
05736       <<"  ("<<pcPotRejected<<"%)"<<endl;
05737 
05738   MSG("NuAnalysis",Msg::kInfo)
05739     <<endl<<"*************************************"<<endl
05740     <<"Total Events    ="<<evtCounter<<endl
05741     <<"Evt not litime  ="<<evtNotlitime<<endl
05742     <<"Evt not IsLI    ="<<evtNotIsLI<<endl
05743     <<"Evts in Fid     ="<<evtInFidVolCounter<<endl
05744     <<"Evts w/ Trk     ="<<evtWithTrkCounter<<endl
05745     <<"Good Best Trk   ="<<goodBestTrkCounter<<endl
05746     <<"Track Pass      ="<<goodTrkPassCounter<<endl
05747     <<"Good reco energy="<<goodRecoEnCounter<<endl
05748     <<"Good UVDiff     ="<<goodUVDiffCounter<<endl
05749     <<"Trk Vtx in Fid  ="<<trkInFidVolCounter<<endl
05750     <<"Good Fit SigQP  ="<<goodFitSigQPCounter<<endl
05751     <<"Good Fit Prob   ="<<goodFitProbCounter<<endl
05752     <<"Good Fit Chi2   ="<<goodFitChi2Counter<<endl
05753     <<"Good Delta T    ="<<goodDeltaTCounter<<endl
05754     <<"Good EvtPerSlc  ="<<goodEvtsPerSlcCounter<<endl
05755     <<"Good DP ID      ="<<goodPIDCounter<<endl
05756     <<"Good beyond tEnd="<<goodBeyondTrkEndCounter<<endl
05757     <<"Good shw fract  ="<<goodShwFractCounter<<endl
05758     <<"*************************************"<<endl;
05759 
05760   Float_t pcPQ=0;
05761   if (nuPQCounter+nuNQCounter>0) pcPQ=100.*nuPQCounter/
05762                                    (nuPQCounter+nuNQCounter);
05763   MSG("NuAnalysis",Msg::kInfo)
05764     <<endl
05765     <<"Neutrinos with NQ="<<nuNQCounter<<endl
05766     <<"Neutrinos with PQ="<<nuPQCounter
05767     <<"   ("<<pcPQ<<"%)"<<endl
05768     <<"Sum NQ+PQ        ="<<nuNQCounter+nuPQCounter<<endl
05769     <<endl;
05770   
05771   MSG("NuAnalysis",Msg::kInfo) 
05772     <<" ** Finished EnergySpect method **"<<endl;
05773 }

void NuAnalysis::EnergySpectMC (  ) 

Definition at line 772 of file NuAnalysis.cxx.

References NuEvent::anaVersion, NtpSRFitTrack::chi2, NuEvent::detector, NuEvent::energy, NtpSRMomentum::eqp, NtpStRecord::evt, NuLibrary::ext, ExtractConfig(), NuExtraction::ExtractEvtInfo(), NuExtraction::ExtractGeneralInfo(), NuExtraction::ExtractShwInfo(), NuExtraction::ExtractTrkInfo(), NtpSRTrack::fit, Form(), NuBase::fOutFile, VldContext::GetDetector(), NuBase::GetEntries(), NuReco::GetEvtDeltaTs(), NuReco::GetEvtEnergy(), NuReco::GetEvtMedianTime(), NuReco::GetEvtsPerSlc(), RecRecordImp< T >::GetHeader(), NuBase::GetNtpStRecord(), RecDataHeader::GetRun(), VldContext::GetSimFlag(), RecDataHeader::GetSubRun(), RecHeader::GetVldContext(), NtpMCTruth::iaction, NtpSREvent::index, NtpMCTruth::index, NuBase::InitialiseLoopVariables(), NuLibrary::Instance(), NtpMCTruth::inu, NuCuts::IsInFidVol(), it, Msg::kDebug, Msg::kInfo, Msg::kWarning, MAXMSG, NtpStRecord::mc, NtpSRTrack::momentum, MSG, NtpSRFitTrack::ndof, NtpTHEvent::neumc, Munits::ns, NtpSREvent::nshower, NtpSREvent::ntrack, NtpSRTrackPlane::ntrklike, NuBase::OpenFile(), NtpMCTruth::p4mu1, NtpMCTruth::p4neu, NtpSRFitTrack::pass, NtpSRTrack::plane, NtpSRMomentum::qp, NuLibrary::reco, NuEvent::releaseType, NuBase::SetLoopVariables(), NuEvent::simFlag, NtpSREvent::slc, NtpStRecord::thevt, NtpStRecord::trk, NtpSREvent::trk, NtpMCTruth::vtxx, NtpMCTruth::vtxy, NtpMCTruth::vtxz, and NtpMCTruth::y.

00773 {
00774   MSG("NuAnalysis",Msg::kInfo) 
00775     <<" ** Running EnergySpectMC method... **"<<endl;
00776   
00777   //open the output file for the histograms
00778   fOutFile=this->OpenFile(100,"NuEnergySpectMC");
00779 
00780   TH1F* hNuInt=new TH1F("hNuInt","hNuInt",10000,-100,1000);
00781   hNuInt->SetTitle("Number of neutrino interactions per spill");
00782   hNuInt->GetXaxis()->SetTitle("# interactions");
00783   hNuInt->GetXaxis()->CenterTitle();
00784   hNuInt->GetYaxis()->SetTitle("");
00785   hNuInt->GetYaxis()->CenterTitle();
00786   hNuInt->SetFillColor(0);
00787   hNuInt->SetLineColor(1);
00788   //hNuInt->SetBit(TH1::kCanRebin);
00789   
00790   TH1F* hinuCC=new TH1F("hinuCC","hinuCC",80,-20,20);
00791   hinuCC->SetTitle("MC Number of Neutrino");
00792   hinuCC->GetXaxis()->SetTitle("MC Number");
00793   hinuCC->GetXaxis()->CenterTitle();
00794   hinuCC->GetYaxis()->SetTitle("");
00795   hinuCC->GetYaxis()->CenterTitle();
00796   hinuCC->SetFillColor(0);
00797   hinuCC->SetLineColor(1);
00798   //hinuCC->SetBit(TH1::kCanRebin);
00799 
00800   TH1F* hinuNC=new TH1F("hinuNC","hinuNC",80,-20,20);
00801   hinuNC->SetTitle("MC Number of Neutrino");
00802   hinuNC->GetXaxis()->SetTitle("MC Number");
00803   hinuNC->GetXaxis()->CenterTitle();
00804   hinuNC->GetYaxis()->SetTitle("");
00805   hinuNC->GetYaxis()->CenterTitle();
00806   hinuNC->SetFillColor(0);
00807   hinuNC->SetLineColor(3);
00808   hinuNC->SetLineWidth(2);
00809   //hinuNC->SetBit(TH1::kCanRebin);
00810 
00811 
00812   TH1F* hNuMuBarEnCC=new TH1F("hNuMuBarEnCC","hNuMuBarEnCC",
00813                               4*352,-32,320);
00814   hNuMuBarEnCC->GetXaxis()->SetTitle("Energy (GeV)");
00815   hNuMuBarEnCC->GetXaxis()->CenterTitle();
00816   hNuMuBarEnCC->GetYaxis()->SetTitle("");
00817   hNuMuBarEnCC->GetYaxis()->CenterTitle();
00818   hNuMuBarEnCC->SetFillColor(0);
00819   hNuMuBarEnCC->SetLineColor(2);
00820   //hNuMuBarEnCC->SetBit(TH1::kCanRebin);
00821 
00822   TH1F* hNuMuBarFidEnCC=new TH1F("hNuMuBarFidEnCC","hNuMuBarFidEnCC",
00823                               4*352,-32,320);
00824   hNuMuBarFidEnCC->GetXaxis()->SetTitle("Energy (GeV)");
00825   hNuMuBarFidEnCC->GetXaxis()->CenterTitle();
00826   hNuMuBarFidEnCC->GetYaxis()->SetTitle("");
00827   hNuMuBarFidEnCC->GetYaxis()->CenterTitle();
00828   hNuMuBarFidEnCC->SetFillColor(0);
00829   hNuMuBarFidEnCC->SetLineColor(2);
00830   //hNuMuBarFidEnCC->SetBit(TH1::kCanRebin);
00831 
00832   TH1F* hNuMuBarLike=new TH1F("hNuMuBarLike","hNuMuBarLike",
00833                               4*352,-32,320);
00834   hNuMuBarLike->GetXaxis()->SetTitle("Energy (GeV)");
00835   hNuMuBarLike->GetXaxis()->CenterTitle();
00836   hNuMuBarLike->GetYaxis()->SetTitle("");
00837   hNuMuBarLike->GetYaxis()->CenterTitle();
00838   hNuMuBarLike->SetFillColor(0);
00839   hNuMuBarLike->SetLineColor(2);
00840   //hNuMuBarLike->SetBit(TH1::kCanRebin);
00841 
00842   TH1F* hNuMuEnCC=new TH1F("hNuMuEnCC","hNuMuEnCC",4*352,-32,320);
00843   hNuMuEnCC->GetXaxis()->SetTitle("Energy (GeV)");
00844   hNuMuEnCC->GetXaxis()->CenterTitle();
00845   hNuMuEnCC->GetYaxis()->SetTitle("");
00846   hNuMuEnCC->GetYaxis()->CenterTitle();
00847   hNuMuEnCC->SetFillColor(0);
00848   hNuMuEnCC->SetLineColor(1);
00849   hNuMuEnCC->SetLineWidth(2);
00850   //hNuMuEnCC->SetBit(TH1::kCanRebin);
00851 
00852   TH1F* hNuMuFidEnCC=new TH1F("hNuMuFidEnCC","hNuMuFidEnCC",
00853                               4*352,-32,320);
00854   hNuMuFidEnCC->GetXaxis()->SetTitle("Energy (GeV)");
00855   hNuMuFidEnCC->GetXaxis()->CenterTitle();
00856   hNuMuFidEnCC->GetYaxis()->SetTitle("");
00857   hNuMuFidEnCC->GetYaxis()->CenterTitle();
00858   hNuMuFidEnCC->SetFillColor(0);
00859   hNuMuFidEnCC->SetLineColor(1);
00860   hNuMuFidEnCC->SetLineWidth(2);
00861   //hNuMuFidEnCC->SetBit(TH1::kCanRebin);
00862 
00863   TH1F* hNuMuLike=new TH1F("hNuMuLike","hNuMuLike",4*352,-32,320);
00864   hNuMuLike->GetXaxis()->SetTitle("Energy (GeV)");
00865   hNuMuLike->GetXaxis()->CenterTitle();
00866   hNuMuLike->GetYaxis()->SetTitle("");
00867   hNuMuLike->GetYaxis()->CenterTitle();
00868   hNuMuLike->SetFillColor(0);
00869   hNuMuLike->SetLineColor(1);
00870   hNuMuLike->SetLineWidth(2);
00871   //hNuMuLike->SetBit(TH1::kCanRebin);
00872 
00873   TH1F* hNuMuBarEn4000CC=new TH1F("hNuMuBarEn4000CC","hNuMuBarEn4000CC",
00874                                   4000,-10,200);
00875   hNuMuBarEn4000CC->GetXaxis()->SetTitle("Energy (GeV)");
00876   hNuMuBarEn4000CC->GetXaxis()->CenterTitle();
00877   hNuMuBarEn4000CC->GetYaxis()->SetTitle("");
00878   hNuMuBarEn4000CC->GetYaxis()->CenterTitle();
00879   hNuMuBarEn4000CC->SetFillColor(0);
00880   hNuMuBarEn4000CC->SetLineColor(2);
00881   //hNuMuBarEn4000CC->SetBit(TH1::kCanRebin);
00882 
00883   TH1F* hNuMuEn4000CC=new TH1F("hNuMuEn4000CC","hNuMuEn4000CC",
00884                                4000,-10,200);
00885   hNuMuEn4000CC->GetXaxis()->SetTitle("Energy (GeV)");
00886   hNuMuEn4000CC->GetXaxis()->CenterTitle();
00887   hNuMuEn4000CC->GetYaxis()->SetTitle("");
00888   hNuMuEn4000CC->GetYaxis()->CenterTitle();
00889   hNuMuEn4000CC->SetFillColor(0);
00890   hNuMuEn4000CC->SetLineColor(1);
00891   hNuMuEn4000CC->SetLineWidth(2);
00892   //hNuMuEn4000CC->SetBit(TH1::kCanRebin);
00893 
00894   TH1F* hNueBarEnCC=new TH1F("hNueBarEnCC","hNueBarEnCC",4*352,-32,320);
00895   hNueBarEnCC->GetXaxis()->SetTitle("Energy (GeV)");
00896   hNueBarEnCC->GetXaxis()->CenterTitle();
00897   hNueBarEnCC->GetYaxis()->SetTitle("");
00898   hNueBarEnCC->GetYaxis()->CenterTitle();
00899   hNueBarEnCC->SetFillColor(0);
00900   hNueBarEnCC->SetLineColor(2);
00901   hNueBarEnCC->SetLineWidth(2);
00902   hNueBarEnCC->SetLineStyle(2);
00903   //hNueBarEnCC->SetBit(TH1::kCanRebin);
00904 
00905   TH1F* hNueEnCC=new TH1F("hNueEnCC","hNueEnCC",4*352,-32,320);
00906   hNueEnCC->GetXaxis()->SetTitle("Energy (GeV)");
00907   hNueEnCC->GetXaxis()->CenterTitle();
00908   hNueEnCC->GetYaxis()->SetTitle("");
00909   hNueEnCC->GetYaxis()->CenterTitle();
00910   hNueEnCC->SetFillColor(0);
00911   hNueEnCC->SetLineColor(1);
00912   hNueEnCC->SetLineWidth(1);
00913   hNueEnCC->SetLineStyle(2);
00914   //hNueEnCC->SetBit(TH1::kCanRebin);
00915 
00916 
00917   TH1F* hNuMuBarEnNC=new TH1F("hNuMuBarEnNC","hNuMuBarEnNC",4*352,-32,320);
00918   hNuMuBarEnNC->GetXaxis()->SetTitle("Energy (GeV)");
00919   hNuMuBarEnNC->GetXaxis()->CenterTitle();
00920   hNuMuBarEnNC->GetYaxis()->SetTitle("");
00921   hNuMuBarEnNC->GetYaxis()->CenterTitle();
00922   hNuMuBarEnNC->SetFillColor(0);
00923   hNuMuBarEnNC->SetLineColor(4);
00924   //hNuMuBarEnNC->SetBit(TH1::kCanRebin);
00925 
00926   TH1F* hNuMuEnNC=new TH1F("hNuMuEnNC","hNuMuEnNC",4*352,-32,320);
00927   hNuMuEnNC->GetXaxis()->SetTitle("Energy (GeV)");
00928   hNuMuEnNC->GetXaxis()->CenterTitle();
00929   hNuMuEnNC->GetYaxis()->SetTitle("");
00930   hNuMuEnNC->GetYaxis()->CenterTitle();
00931   hNuMuEnNC->SetFillColor(0);
00932   hNuMuEnNC->SetLineColor(1);
00933   hNuMuEnNC->SetLineWidth(3);
00934   //hNuMuEnNC->SetBit(TH1::kCanRebin);
00935 
00936   TH1F* hNueBarEnNC=new TH1F("hNueBarEnNC","hNueBarEnNC",4*352,-32,320);
00937   hNueBarEnNC->GetXaxis()->SetTitle("Energy (GeV)");
00938   hNueBarEnNC->GetXaxis()->CenterTitle();
00939   hNueBarEnNC->GetYaxis()->SetTitle("");
00940   hNueBarEnNC->GetYaxis()->CenterTitle();
00941   hNueBarEnNC->SetFillColor(0);
00942   hNueBarEnNC->SetLineColor(4);
00943   hNueBarEnNC->SetLineWidth(2);
00944   hNueBarEnNC->SetLineStyle(2);
00945   //hNueBarEnNC->SetBit(TH1::kCanRebin);
00946 
00947   TH1F* hNueEnNC=new TH1F("hNueEnNC","hNueEnNC",4*352,-32,320);
00948   hNueEnNC->GetXaxis()->SetTitle("Energy (GeV)");
00949   hNueEnNC->GetXaxis()->CenterTitle();
00950   hNueEnNC->GetYaxis()->SetTitle("");
00951   hNueEnNC->GetYaxis()->CenterTitle();
00952   hNueEnNC->SetFillColor(0);
00953   hNueEnNC->SetLineColor(3);
00954   hNueEnNC->SetLineWidth(1);
00955   hNueEnNC->SetLineStyle(2);
00956   //hNueEnNC->SetBit(TH1::kCanRebin);
00957 
00958 
00959   TH1F* hNuMuBarEnDepNC=new TH1F("hNuMuBarEnDepNC","hNuMuBarEnDepNC",4*352,-32,320);
00960   hNuMuBarEnDepNC->GetXaxis()->SetTitle("Energy (GeV)");
00961   hNuMuBarEnDepNC->GetXaxis()->CenterTitle();
00962   hNuMuBarEnDepNC->GetYaxis()->SetTitle("");
00963   hNuMuBarEnDepNC->GetYaxis()->CenterTitle();
00964   hNuMuBarEnDepNC->SetFillColor(0);
00965   hNuMuBarEnDepNC->SetLineColor(4);
00966   //hNuMuBarEnDepNC->SetBit(TH1::kCanRebin);
00967 
00968   TH1F* hNuMuEnDepNC=new TH1F("hNuMuEnDepNC","hNuMuEnDepNC",4*352,-32,320);
00969   hNuMuEnDepNC->GetXaxis()->SetTitle("Energy (GeV)");
00970   hNuMuEnDepNC->GetXaxis()->CenterTitle();
00971   hNuMuEnDepNC->GetYaxis()->SetTitle("");
00972   hNuMuEnDepNC->GetYaxis()->CenterTitle();
00973   hNuMuEnDepNC->SetFillColor(0);
00974   hNuMuEnDepNC->SetLineColor(1);
00975   hNuMuEnDepNC->SetLineWidth(3);
00976   //hNuMuEnDepNC->SetBit(TH1::kCanRebin);
00977 
00978   TH1F* hNueBarEnDepNC=new TH1F("hNueBarEnDepNC","hNueBarEnDepNC",4*352,-32,320);
00979   hNueBarEnDepNC->GetXaxis()->SetTitle("Energy (GeV)");
00980   hNueBarEnDepNC->GetXaxis()->CenterTitle();
00981   hNueBarEnDepNC->GetYaxis()->SetTitle("");
00982   hNueBarEnDepNC->GetYaxis()->CenterTitle();
00983   hNueBarEnDepNC->SetFillColor(0);
00984   hNueBarEnDepNC->SetLineColor(4);
00985   hNueBarEnDepNC->SetLineWidth(2);
00986   hNueBarEnDepNC->SetLineStyle(2);
00987   //hNueBarEnDepNC->SetBit(TH1::kCanRebin);
00988 
00989   TH1F* hNueEnDepNC=new TH1F("hNueEnDepNC","hNueEnDepNC",4*352,-32,320);
00990   hNueEnDepNC->GetXaxis()->SetTitle("Energy (GeV)");
00991   hNueEnDepNC->GetXaxis()->CenterTitle();
00992   hNueEnDepNC->GetYaxis()->SetTitle("");
00993   hNueEnDepNC->GetYaxis()->CenterTitle();
00994   hNueEnDepNC->SetFillColor(0);
00995   hNueEnDepNC->SetLineColor(3);
00996   hNueEnDepNC->SetLineWidth(1);
00997   hNueEnDepNC->SetLineStyle(2);
00998   //hNueEnDepNC->SetBit(TH1::kCanRebin);
00999 
01000 
01001   TH1F* hNuYCC=new TH1F("hNuYCC","hNuYCC",100,-0.1,1.1);
01002   hNuYCC->GetXaxis()->SetTitle("Neutrino y");
01003   hNuYCC->GetXaxis()->CenterTitle();
01004   hNuYCC->GetYaxis()->SetTitle("");
01005   hNuYCC->GetYaxis()->CenterTitle();
01006   hNuYCC->SetFillColor(0);
01007   hNuYCC->SetLineColor(1);
01008   hNuYCC->SetLineWidth(1);
01009   hNuYCC->SetLineStyle(1);
01010   //hNuYCC->SetBit(TH1::kCanRebin);
01011 
01012   TH1F* hNuYNC=new TH1F("hNuYNC","hNuYNC",100,-0.1,1.1);
01013   hNuYNC->GetXaxis()->SetTitle("Neutrino y");
01014   hNuYNC->GetXaxis()->CenterTitle();
01015   hNuYNC->GetYaxis()->SetTitle("");
01016   hNuYNC->GetYaxis()->CenterTitle();
01017   hNuYNC->SetFillColor(0);
01018   hNuYNC->SetLineColor(3);
01019   hNuYNC->SetLineWidth(2);
01020   hNuYNC->SetLineStyle(1);
01021   //hNuYNC->SetBit(TH1::kCanRebin);
01022 
01023   TH1F* hNuYFidNuMuBarCC=new TH1F("hNuYFidNuMuBarCC","hNuYFidNuMuBarCC",
01024                                   100,-0.1,1.1);
01025   hNuYFidNuMuBarCC->GetXaxis()->SetTitle("Neutrino y");
01026   hNuYFidNuMuBarCC->GetXaxis()->CenterTitle();
01027   hNuYFidNuMuBarCC->GetYaxis()->SetTitle("");
01028   hNuYFidNuMuBarCC->GetYaxis()->CenterTitle();
01029   hNuYFidNuMuBarCC->SetFillColor(0);
01030   hNuYFidNuMuBarCC->SetLineColor(1);
01031   hNuYFidNuMuBarCC->SetLineWidth(1);
01032   hNuYFidNuMuBarCC->SetLineStyle(1);
01033   //hNuYFidNuMuBarCC->SetBit(TH1::kCanRebin);
01034 
01035   TH1F* hNuYFidNuMuBarNC=new TH1F("hNuYFidNuMuBarNC","hNuYFidNuMuBarNC",
01036                                   100,-0.1,1.1);
01037   hNuYFidNuMuBarNC->GetXaxis()->SetTitle("Neutrino y");
01038   hNuYFidNuMuBarNC->GetXaxis()->CenterTitle();
01039   hNuYFidNuMuBarNC->GetYaxis()->SetTitle("");
01040   hNuYFidNuMuBarNC->GetYaxis()->CenterTitle();
01041   hNuYFidNuMuBarNC->SetFillColor(0);
01042   hNuYFidNuMuBarNC->SetLineColor(3);
01043   hNuYFidNuMuBarNC->SetLineWidth(2);
01044   hNuYFidNuMuBarNC->SetLineStyle(1);
01045   //hNuYFidNuMuBarNC->SetBit(TH1::kCanRebin);
01046 
01047   TH1F* hNuYFidNuMuCC=new TH1F("hNuYFidNuMuCC","hNuYFidNuMuCC",
01048                                100,-0.1,1.1);
01049   hNuYFidNuMuCC->GetXaxis()->SetTitle("Neutrino y");
01050   hNuYFidNuMuCC->GetXaxis()->CenterTitle();
01051   hNuYFidNuMuCC->GetYaxis()->SetTitle("");
01052   hNuYFidNuMuCC->GetYaxis()->CenterTitle();
01053   hNuYFidNuMuCC->SetFillColor(0);
01054   hNuYFidNuMuCC->SetLineColor(1);
01055   hNuYFidNuMuCC->SetLineWidth(1);
01056   hNuYFidNuMuCC->SetLineStyle(1);
01057   //hNuYFidNuMuCC->SetBit(TH1::kCanRebin);
01058 
01059   TH1F* hNuYFidNuMuNC=new TH1F("hNuYFidNuMuNC","hNuYFidNuMuNC",
01060                                100,-0.1,1.1);
01061   hNuYFidNuMuNC->GetXaxis()->SetTitle("Neutrino y");
01062   hNuYFidNuMuNC->GetXaxis()->CenterTitle();
01063   hNuYFidNuMuNC->GetYaxis()->SetTitle("");
01064   hNuYFidNuMuNC->GetYaxis()->CenterTitle();
01065   hNuYFidNuMuNC->SetFillColor(0);
01066   hNuYFidNuMuNC->SetLineColor(3);
01067   hNuYFidNuMuNC->SetLineWidth(2);
01068   hNuYFidNuMuNC->SetLineStyle(1);
01069   //hNuYFidNuMuNC->SetBit(TH1::kCanRebin);
01070 
01071 
01072   Int_t nbinsForY=60;
01073   vector<TH1F*> vNuYNuMuBarCC(nbinsForY);
01074   vector<TH1F*> vNuYNuMuCC(nbinsForY);
01075   vector<TH1F*> vNuYNuMuBarNC(nbinsForY);
01076   vector<TH1F*> vNuYNuMuNC(nbinsForY);
01077   for (Int_t i=0;i<nbinsForY;i++){
01078     Int_t en=(i+1)*5;
01079     string sEn=Form("%d",en);
01080     string s="hNuYNuMuBarCC"+sEn;
01081     //cout<<"Creating "<<s<<endl;
01082     vNuYNuMuBarCC[i]=new TH1F(s.c_str(),s.c_str(),100,-0.1,1.1);
01083     vNuYNuMuBarCC[i]->GetXaxis()->SetTitle("Neutrino y");
01084     vNuYNuMuBarCC[i]->GetXaxis()->CenterTitle();
01085     vNuYNuMuBarCC[i]->GetYaxis()->SetTitle("");
01086     vNuYNuMuBarCC[i]->GetYaxis()->CenterTitle();
01087     vNuYNuMuBarCC[i]->SetFillColor(0);
01088     vNuYNuMuBarCC[i]->SetLineColor(2);
01089     vNuYNuMuBarCC[i]->SetLineWidth(2);
01090     vNuYNuMuBarCC[i]->SetLineStyle(2);
01091     //vNuYNuMuBarCC[i]->SetBit(TH1::kCanRebin);
01092     
01093     s="hNuYNuMuCC"+sEn;
01094     //cout<<"Creating "<<s<<endl;
01095     vNuYNuMuCC[i]=new TH1F(s.c_str(),s.c_str(),100,-0.1,1.1);
01096     vNuYNuMuCC[i]->GetXaxis()->SetTitle("Neutrino y");
01097     vNuYNuMuCC[i]->GetXaxis()->CenterTitle();
01098     vNuYNuMuCC[i]->GetYaxis()->SetTitle("");
01099     vNuYNuMuCC[i]->GetYaxis()->CenterTitle();
01100     vNuYNuMuCC[i]->SetFillColor(0);
01101     vNuYNuMuCC[i]->SetLineColor(1);
01102     vNuYNuMuCC[i]->SetLineWidth(2);
01103     vNuYNuMuCC[i]->SetLineStyle(1);
01104     //vNuYNuMuCC[i]->SetBit(TH1::kCanRebin);
01105 
01106     s="hNuYNuMuBarNC"+sEn;
01107     //cout<<"Creating "<<s<<endl;
01108     vNuYNuMuBarNC[i]=new TH1F(s.c_str(),s.c_str(),100,-0.1,1.1);
01109     vNuYNuMuBarNC[i]->GetXaxis()->SetTitle("Neutrino y");
01110     vNuYNuMuBarNC[i]->GetXaxis()->CenterTitle();
01111     vNuYNuMuBarNC[i]->GetYaxis()->SetTitle("");
01112     vNuYNuMuBarNC[i]->GetYaxis()->CenterTitle();
01113     vNuYNuMuBarNC[i]->SetFillColor(0);
01114     vNuYNuMuBarNC[i]->SetLineColor(2);
01115     vNuYNuMuBarNC[i]->SetLineWidth(2);
01116     vNuYNuMuBarNC[i]->SetLineStyle(2);
01117     //vNuYNuMuBarNC[i]->SetBit(TH1::kCanRebin);
01118     
01119     s="hNuYNuMuNC"+sEn;
01120     //cout<<"Creating "<<s<<endl;
01121     vNuYNuMuNC[i]=new TH1F(s.c_str(),s.c_str(),100,-0.1,1.1);
01122     vNuYNuMuNC[i]->GetXaxis()->SetTitle("Neutrino y");
01123     vNuYNuMuNC[i]->GetXaxis()->CenterTitle();
01124     vNuYNuMuNC[i]->GetYaxis()->SetTitle("");
01125     vNuYNuMuNC[i]->GetYaxis()->CenterTitle();
01126     vNuYNuMuNC[i]->SetFillColor(0);
01127     vNuYNuMuNC[i]->SetLineColor(1);
01128     vNuYNuMuNC[i]->SetLineWidth(2);
01129     vNuYNuMuNC[i]->SetLineStyle(1);
01130     //vNuYNuMuNC[i]->SetBit(TH1::kCanRebin);
01131   }
01132 
01133   TH1F* hZCC=new TH1F("hZCC","hZCC",1000,-10,100);
01134   hZCC->GetXaxis()->SetTitle("Z (m)");
01135   hZCC->GetXaxis()->CenterTitle();
01136   hZCC->GetYaxis()->SetTitle("");
01137   hZCC->GetYaxis()->CenterTitle();
01138   hZCC->SetFillColor(0);
01139   hZCC->SetLineColor(1);
01140   hZCC->SetLineWidth(1);
01141   hZCC->SetLineStyle(1);
01142   //hZCC->SetBit(TH1::kCanRebin);
01143 
01144   TH1F* hZNC=new TH1F("hZNC","hZNC",1000,-10,100);
01145   hZNC->GetXaxis()->SetTitle("Z (m)");
01146   hZNC->GetXaxis()->CenterTitle();
01147   hZNC->GetYaxis()->SetTitle("");
01148   hZNC->GetYaxis()->CenterTitle();
01149   hZNC->SetFillColor(0);
01150   hZNC->SetLineColor(3);
01151   hZNC->SetLineWidth(2);
01152   hZNC->SetLineStyle(2);
01153   //hZNC->SetBit(TH1::kCanRebin);
01154 
01155   TH2F* hYvsXCC=new TH2F("hYvsXCC","hYvsXCC",
01156                        100,-5,5,100,-5,5);
01157   hYvsXCC->SetTitle("Y vs X");
01158   hYvsXCC->GetXaxis()->SetTitle("X");
01159   hYvsXCC->GetXaxis()->CenterTitle();
01160   hYvsXCC->GetYaxis()->SetTitle("Y");
01161   hYvsXCC->GetYaxis()->CenterTitle();
01162   hYvsXCC->SetFillColor(0);
01163   //hYvsXCC->SetBit(TH1::kCanRebin);
01164 
01165   TH2F* hYvsXNC=new TH2F("hYvsXNC","hYvsXNC",
01166                        100,-5,5,100,-5,5);
01167   hYvsXNC->SetTitle("Y vs X");
01168   hYvsXNC->GetXaxis()->SetTitle("X");
01169   hYvsXNC->GetXaxis()->CenterTitle();
01170   hYvsXNC->GetYaxis()->SetTitle("Y");
01171   hYvsXNC->GetYaxis()->CenterTitle();
01172   hYvsXNC->SetFillColor(0);
01173   //hYvsXNC->SetBit(TH1::kCanRebin);
01174 
01175   TH2F* hYvsXFidCC=new TH2F("hYvsXFidCC","hYvsXFidCC",
01176                        100,-5,5,100,-5,5);
01177   hYvsXFidCC->SetTitle("Y vs X");
01178   hYvsXFidCC->GetXaxis()->SetTitle("X");
01179   hYvsXFidCC->GetXaxis()->CenterTitle();
01180   hYvsXFidCC->GetYaxis()->SetTitle("Y");
01181   hYvsXFidCC->GetYaxis()->CenterTitle();
01182   hYvsXFidCC->SetFillColor(0);
01183   //hYvsXFidCC->SetBit(TH1::kCanRebin);
01184 
01185   TH2F* hYvsXFidNC=new TH2F("hYvsXFidNC","hYvsXFidNC",
01186                        100,-5,5,100,-5,5);
01187   hYvsXFidNC->SetTitle("Y vs X");
01188   hYvsXFidNC->GetXaxis()->SetTitle("X");
01189   hYvsXFidNC->GetXaxis()->CenterTitle();
01190   hYvsXFidNC->GetYaxis()->SetTitle("Y");
01191   hYvsXFidNC->GetYaxis()->CenterTitle();
01192   hYvsXFidNC->SetFillColor(0);
01193   //hYvsXFidNC->SetBit(TH1::kCanRebin);
01194 
01195   TH2F* hYvsX400CC=new TH2F("hYvsX400CC","hYvsX400CC",
01196                          400,-20,20,400,-20,20);
01197   hYvsX400CC->SetTitle("Y vs X");
01198   hYvsX400CC->GetXaxis()->SetTitle("X");
01199   hYvsX400CC->GetXaxis()->CenterTitle();
01200   hYvsX400CC->GetYaxis()->SetTitle("Y");
01201   hYvsX400CC->GetYaxis()->CenterTitle();
01202   hYvsX400CC->SetFillColor(0);
01203   //hYvsX400CC->SetBit(TH1::kCanRebin);
01204 
01205   TH2F* hYvsX400NC=new TH2F("hYvsX400NC","hYvsX400NC",
01206                          400,-20,20,400,-20,20);
01207   hYvsX400NC->SetTitle("Y vs X");
01208   hYvsX400NC->GetXaxis()->SetTitle("X");
01209   hYvsX400NC->GetXaxis()->CenterTitle();
01210   hYvsX400NC->GetYaxis()->SetTitle("Y");
01211   hYvsX400NC->GetYaxis()->CenterTitle();
01212   hYvsX400NC->SetFillColor(0);
01213   //hYvsX400NC->SetBit(TH1::kCanRebin);
01214 
01215 
01216   TH2F* hYvsZCC=new TH2F("hYvsZCC","hYvsZCC",
01217                             1000,-200,50,400,-20,20);
01218   hYvsZCC->SetTitle("Y vs Z");
01219   hYvsZCC->GetXaxis()->SetTitle("Z");
01220   hYvsZCC->GetXaxis()->CenterTitle();
01221   hYvsZCC->GetYaxis()->SetTitle("Y");
01222   hYvsZCC->GetYaxis()->CenterTitle();
01223   hYvsZCC->SetFillColor(0);
01224   //hYvsZCC->SetBit(TH1::kCanRebin);
01225 
01226   TH2F* hYvsZNC=new TH2F("hYvsZNC","hYvsZNC",
01227                             1000,-200,50,400,-20,20);
01228   hYvsZNC->SetTitle("Y vs Z");
01229   hYvsZNC->GetXaxis()->SetTitle("Z");
01230   hYvsZNC->GetXaxis()->CenterTitle();
01231   hYvsZNC->GetYaxis()->SetTitle("Y");
01232   hYvsZNC->GetYaxis()->CenterTitle();
01233   hYvsZNC->SetFillColor(0);
01234   //hYvsZNC->SetBit(TH1::kCanRebin);
01235 
01236 
01237   TH2F* hXvsZCC=new TH2F("hXvsZCC","hXvsZCC",
01238                             1000,-200,50,400,-20,20);
01239   hXvsZCC->SetTitle("X vs Z");
01240   hXvsZCC->GetXaxis()->SetTitle("Z");
01241   hXvsZCC->GetXaxis()->CenterTitle();
01242   hXvsZCC->GetYaxis()->SetTitle("X");
01243   hXvsZCC->GetYaxis()->CenterTitle();
01244   hXvsZCC->SetFillColor(0);
01245   //hXvsZCC->SetBit(TH1::kCanRebin);
01246 
01247   TH2F* hXvsZNC=new TH2F("hXvsZNC","hXvsZNC",
01248                             1000,-200,50,400,-20,20);
01249   hXvsZNC->SetTitle("X vs Z");
01250   hXvsZNC->GetXaxis()->SetTitle("Z");
01251   hXvsZNC->GetXaxis()->CenterTitle();
01252   hXvsZNC->GetYaxis()->SetTitle("X");
01253   hXvsZNC->GetYaxis()->CenterTitle();
01254   hXvsZNC->SetFillColor(0);
01255   //hXvsZNC->SetBit(TH1::kCanRebin);
01256 
01257   TH2F* hXvsZZoomCC=new TH2F("hXvsZZoomCC","hXvsZZoomCC",
01258                              20000,-2,25,200,-3,4);
01259   hXvsZZoomCC->SetTitle("X vs Z");
01260   hXvsZZoomCC->GetXaxis()->SetTitle("Z");
01261   hXvsZZoomCC->GetXaxis()->CenterTitle();
01262   hXvsZZoomCC->GetYaxis()->SetTitle("X");
01263   hXvsZZoomCC->GetYaxis()->CenterTitle();
01264   hXvsZZoomCC->SetFillColor(0);
01265   //hXvsZZoomCC->SetBit(TH1::kCanRebin);
01266   
01267   TH2F* hXvsZZoomNC=new TH2F("hXvsZZoomNC","hXvsZZoomNC",
01268                              20000,-2,25,200,-3,4);
01269   hXvsZZoomNC->SetTitle("X vs Z");
01270   hXvsZZoomNC->GetXaxis()->SetTitle("Z");
01271   hXvsZZoomNC->GetXaxis()->CenterTitle();
01272   hXvsZZoomNC->GetYaxis()->SetTitle("X");
01273   hXvsZZoomNC->GetYaxis()->CenterTitle();
01274   hXvsZZoomNC->SetFillColor(0);
01275   //hXvsZZoomNC->SetBit(TH1::kCanRebin);
01276 
01277   
01278   TH3F* hXYZCC=new TH3F("hXYZCC","hXYZCC",
01279                         100,-8,8,  400,-150,25,  200,-8,15);
01280   hXYZCC->SetTitle("XYZ");
01281   hXYZCC->GetXaxis()->SetTitle("X");
01282   hXYZCC->GetXaxis()->CenterTitle();
01283   hXYZCC->GetYaxis()->SetTitle("Y");
01284   hXYZCC->GetYaxis()->CenterTitle();
01285   hXYZCC->SetFillColor(0);
01286   //hXYZCC->SetBit(TH1::kCanRebin);
01287 
01288   TH3F* hXYZNC=new TH3F("hXYZNC","hXYZNC",
01289                         100,-8,8,  400,-150,25,  200,-8,15);
01290   hXYZNC->SetTitle("XYZ");
01291   hXYZNC->GetXaxis()->SetTitle("X");
01292   hXYZNC->GetXaxis()->CenterTitle();
01293   hXYZNC->GetYaxis()->SetTitle("Y");
01294   hXYZNC->GetYaxis()->CenterTitle();
01295   hXYZNC->SetFillColor(0);
01296   //hXYZNC->SetBit(TH1::kCanRebin);
01297 
01298   TH1F* hTrksPerEvt=new TH1F("hTrksPerEvt","hTrksPerEvt",10,-1,9);
01299   hTrksPerEvt->SetTitle("Tracks per Reco'd Event");
01300   hTrksPerEvt->GetXaxis()->SetTitle("# tracks");
01301   hTrksPerEvt->GetXaxis()->CenterTitle();
01302   hTrksPerEvt->GetYaxis()->SetTitle("");
01303   hTrksPerEvt->GetYaxis()->CenterTitle();
01304   hTrksPerEvt->SetFillColor(0);
01305   hTrksPerEvt->SetLineColor(1);
01306   hTrksPerEvt->SetLineWidth(1);
01307   hTrksPerEvt->SetLineStyle(1);
01308   //hTrksPerEvt->SetBit(TH1::kCanRebin);
01309 
01310   TH1F* hEvtsPerNu=new TH1F("hEvtsPerNu","hEvtsPerNu",10,-1,9);
01311   hEvtsPerNu->SetTitle("Events reco'd per neutrino interaction");
01312   hEvtsPerNu->GetXaxis()->SetTitle("Events reco'd");
01313   hEvtsPerNu->GetXaxis()->CenterTitle();
01314   hEvtsPerNu->GetYaxis()->SetTitle("");
01315   hEvtsPerNu->GetYaxis()->CenterTitle();
01316   hEvtsPerNu->SetFillColor(0);
01317   hEvtsPerNu->SetLineColor(1);
01318   hEvtsPerNu->SetLineWidth(1);
01319   hEvtsPerNu->SetLineStyle(1);
01320   //hEvtsPerNu->SetBit(TH1::kCanRebin);
01321 
01322   TH1F* hEvtsPerNuCC=new TH1F("hEvtsPerNuCC","hEvtsPerNuCC",10,-1,9);
01323   hEvtsPerNuCC->SetTitle("Events reco'd per neutrino interaction");
01324   hEvtsPerNuCC->GetXaxis()->SetTitle("Events reco'd");
01325   hEvtsPerNuCC->GetXaxis()->CenterTitle();
01326   hEvtsPerNuCC->GetYaxis()->SetTitle("");
01327   hEvtsPerNuCC->GetYaxis()->CenterTitle();
01328   hEvtsPerNuCC->SetFillColor(0);
01329   hEvtsPerNuCC->SetLineColor(1);
01330   hEvtsPerNuCC->SetLineWidth(1);
01331   hEvtsPerNuCC->SetLineStyle(1);
01332   //hEvtsPerNuCC->SetBit(TH1::kCanRebin);
01333 
01334   TH1F* hEvtsPerNuNC=new TH1F("hEvtsPerNuNC","hEvtsPerNuNC",10,-1,9);
01335   hEvtsPerNuNC->SetTitle("Events reco'd per neutrino interaction");
01336   hEvtsPerNuNC->GetXaxis()->SetTitle("Events reco'd");
01337   hEvtsPerNuNC->GetXaxis()->CenterTitle();
01338   hEvtsPerNuNC->GetYaxis()->SetTitle("");
01339   hEvtsPerNuNC->GetYaxis()->CenterTitle();
01340   hEvtsPerNuNC->SetFillColor(0);
01341   hEvtsPerNuNC->SetLineColor(3);
01342   hEvtsPerNuNC->SetLineWidth(2);
01343   hEvtsPerNuNC->SetLineStyle(1);
01344   //hEvtsPerNuNC->SetBit(TH1::kCanRebin);
01345   
01346   TH1F* hEvtsPerSlc=new TH1F("hEvtsPerSlc","hEvtsPerSlc",10,-1,9);
01347   hEvtsPerSlc->SetTitle("Events reco'd per Slice");
01348   hEvtsPerSlc->GetXaxis()->SetTitle("Events reco'd");
01349   hEvtsPerSlc->GetXaxis()->CenterTitle();
01350   hEvtsPerSlc->GetYaxis()->SetTitle("");
01351   hEvtsPerSlc->GetYaxis()->CenterTitle();
01352   hEvtsPerSlc->SetFillColor(0);
01353   hEvtsPerSlc->SetLineColor(1);
01354   hEvtsPerSlc->SetLineWidth(2);
01355   hEvtsPerSlc->SetLineStyle(1);
01356   //hEvtsPerSlc->SetBit(TH1::kCanRebin);
01357   
01358   TH1F* hEvtsPerSlcg1=new TH1F("hEvtsPerSlcg1","hEvtsPerSlcg1",10,-1,9);
01359   hEvtsPerSlcg1->SetTitle("Events reco'd per Slice");
01360   hEvtsPerSlcg1->GetXaxis()->SetTitle("Events reco'd");
01361   hEvtsPerSlcg1->GetXaxis()->CenterTitle();
01362   hEvtsPerSlcg1->GetYaxis()->SetTitle("");
01363   hEvtsPerSlcg1->GetYaxis()->CenterTitle();
01364   hEvtsPerSlcg1->SetFillColor(0);
01365   hEvtsPerSlcg1->SetLineColor(2);
01366   hEvtsPerSlcg1->SetLineWidth(2);
01367   hEvtsPerSlcg1->SetLineStyle(1);
01368   //hEvtsPerSlcg1->SetBit(TH1::kCanRebin);
01369 
01370   TH1F* hEvtsPerSlcg1T=new TH1F("hEvtsPerSlcg1T","hEvtsPerSlcg1T",10,-1,9);
01371   hEvtsPerSlcg1T->SetTitle("Events reco'd per Slice");
01372   hEvtsPerSlcg1T->GetXaxis()->SetTitle("Events reco'd");
01373   hEvtsPerSlcg1T->GetXaxis()->CenterTitle();
01374   hEvtsPerSlcg1T->GetYaxis()->SetTitle("");
01375   hEvtsPerSlcg1T->GetYaxis()->CenterTitle();
01376   hEvtsPerSlcg1T->SetFillColor(0);
01377   hEvtsPerSlcg1T->SetLineColor(4);
01378   hEvtsPerSlcg1T->SetLineWidth(2);
01379   hEvtsPerSlcg1T->SetLineStyle(1);
01380   //hEvtsPerSlcg1T->SetBit(TH1::kCanRebin);
01381 
01382   TH2F* hEvtsVsNuEnCC=new TH2F("hEvtsVsNuEnCC","hEvtsVsNuEnCC",
01383                                110,-2,20,8,-1,7);
01384   hEvtsVsNuEnCC->SetTitle("Events Reco'd per Neutrino vs True Neutrino Energy");
01385   hEvtsVsNuEnCC->GetXaxis()->SetTitle("True Neutrino Energy (GeV)");
01386   hEvtsVsNuEnCC->GetXaxis()->CenterTitle();
01387   hEvtsVsNuEnCC->GetYaxis()->SetTitle("Events Reco'd");
01388   hEvtsVsNuEnCC->GetYaxis()->CenterTitle();
01389   hEvtsVsNuEnCC->SetFillColor(0);
01390   //hEvtsVsNuEnCC->SetBit(TH1::kCanRebin);
01391 
01392   TH2F* hEvtsVsNuEnNC=new TH2F("hEvtsVsNuEnNC","hEvtsVsNuEnNC",
01393                                110,-2,20,8,-1,7);
01394   hEvtsVsNuEnNC->SetTitle("Events Reco'd per Neutrino vs True Neutrino Energy");
01395   hEvtsVsNuEnNC->GetXaxis()->SetTitle("True Neutrino Energy (GeV)");
01396   hEvtsVsNuEnNC->GetXaxis()->CenterTitle();
01397   hEvtsVsNuEnNC->GetYaxis()->SetTitle("Events Reco'd");
01398   hEvtsVsNuEnNC->GetYaxis()->CenterTitle();
01399   hEvtsVsNuEnNC->SetFillColor(0);
01400   //hEvtsVsNuEnNC->SetBit(TH1::kCanRebin);
01401 
01402 
01403 
01404   TProfile* pNuMuBarQEffVsEn=new TProfile("pNuMuBarQEffVsEn","pNuMuBarQEffVsEn",50,0,50);
01405   pNuMuBarQEffVsEn->SetTitle("Charge Sign Efficiency vs. True Neutrino Energy");
01406   pNuMuBarQEffVsEn->GetXaxis()->SetTitle("Energy (GeV)");
01407   pNuMuBarQEffVsEn->GetXaxis()->CenterTitle();
01408   pNuMuBarQEffVsEn->GetYaxis()->SetTitle("Efficiency");
01409   pNuMuBarQEffVsEn->GetYaxis()->CenterTitle();
01410   pNuMuBarQEffVsEn->SetLineColor(2);
01411   pNuMuBarQEffVsEn->SetFillColor(0);
01412   //pNuMuBarQEffVsEn->SetBit(TH1::kCanRebin);
01413 
01414   TProfile* pNuMuQEffVsEn=new TProfile("pNuMuQEffVsEn","pNuMuQEffVsEn",50,0,50);
01415   pNuMuQEffVsEn->SetTitle("Charge Sign Efficiency vs. True Neutrino Energy");
01416   pNuMuQEffVsEn->GetXaxis()->SetTitle("Energy (GeV)");
01417   pNuMuQEffVsEn->GetXaxis()->CenterTitle();
01418   pNuMuQEffVsEn->GetYaxis()->SetTitle("Efficiency");
01419   pNuMuQEffVsEn->GetYaxis()->CenterTitle();
01420   pNuMuQEffVsEn->SetLineColor(1);
01421   pNuMuQEffVsEn->SetFillColor(0);
01422   //pNuMuQEffVsEn->SetBit(TH1::kCanRebin);
01423 
01424   TProfile* pNuMuBarFitPassVsEn=new TProfile("pNuMuBarFitPassVsEn","pNuMuBarFitPassVsEn",50,0,50);
01425   pNuMuBarFitPassVsEn->SetTitle("Fit Pass Fraction vs. True Neutrino Energy");
01426   pNuMuBarFitPassVsEn->GetXaxis()->SetTitle("Energy (GeV)");
01427   pNuMuBarFitPassVsEn->GetXaxis()->CenterTitle();
01428   pNuMuBarFitPassVsEn->GetYaxis()->SetTitle("Pass Fraction");
01429   pNuMuBarFitPassVsEn->GetYaxis()->CenterTitle();
01430   pNuMuBarFitPassVsEn->SetLineColor(2);
01431   pNuMuBarFitPassVsEn->SetFillColor(0);
01432   //pNuMuBarFitPassVsEn->SetBit(TH1::kCanRebin);
01433 
01434   TProfile* pNuMuFitPassVsEn=new TProfile("pNuMuFitPassVsEn","pNuMuFitPassVsEn",50,0,50);
01435   pNuMuFitPassVsEn->SetTitle("Fit Pass Fraction vs. True Neutrino Energy");
01436   pNuMuFitPassVsEn->GetXaxis()->SetTitle("Energy (GeV)");
01437   pNuMuFitPassVsEn->GetXaxis()->CenterTitle();
01438   pNuMuFitPassVsEn->GetYaxis()->SetTitle("Pass Fraction");
01439   pNuMuFitPassVsEn->GetYaxis()->CenterTitle();
01440   pNuMuFitPassVsEn->SetLineColor(1);
01441   pNuMuFitPassVsEn->SetFillColor(0);
01442   //pNuMuFitPassVsEn->SetBit(TH1::kCanRebin);
01443 
01444 
01445   
01446   TH1F* hNuMuBarEnGoodQ=new TH1F("hNuMuBarEnGoodQ","hNuMuBarEnGoodQ",
01447                               4*352,-32,320);
01448   hNuMuBarEnGoodQ->GetXaxis()->SetTitle("Energy (GeV)");
01449   hNuMuBarEnGoodQ->GetXaxis()->CenterTitle();
01450   hNuMuBarEnGoodQ->GetYaxis()->SetTitle("");
01451   hNuMuBarEnGoodQ->GetYaxis()->CenterTitle();
01452   hNuMuBarEnGoodQ->SetFillColor(0);
01453   hNuMuBarEnGoodQ->SetLineColor(2);
01454   //hNuMuBarEnGoodQ->SetBit(TH1::kCanRebin);
01455 
01456   TH1F* hNuMuEnGoodQ=new TH1F("hNuMuEnGoodQ","hNuMuEnGoodQ",4*352,-32,320);
01457   hNuMuEnGoodQ->GetXaxis()->SetTitle("Energy (GeV)");
01458   hNuMuEnGoodQ->GetXaxis()->CenterTitle();
01459   hNuMuEnGoodQ->GetYaxis()->SetTitle("");
01460   hNuMuEnGoodQ->GetYaxis()->CenterTitle();
01461   hNuMuEnGoodQ->SetFillColor(0);
01462   hNuMuEnGoodQ->SetLineColor(1);
01463   hNuMuEnGoodQ->SetLineWidth(2);
01464   //hNuMuEnGoodQ->SetBit(TH1::kCanRebin);
01465 
01466   TH1F* hNuMuBarEnBadQ=new TH1F("hNuMuBarEnBadQ","hNuMuBarEnBadQ",
01467                               4*352,-32,320);
01468   hNuMuBarEnBadQ->GetXaxis()->SetTitle("Energy (GeV)");
01469   hNuMuBarEnBadQ->GetXaxis()->CenterTitle();
01470   hNuMuBarEnBadQ->GetYaxis()->SetTitle("");
01471   hNuMuBarEnBadQ->GetYaxis()->CenterTitle();
01472   hNuMuBarEnBadQ->SetFillColor(0);
01473   hNuMuBarEnBadQ->SetLineColor(2);
01474   //hNuMuBarEnBadQ->SetBit(TH1::kCanRebin);
01475 
01476   TH1F* hNuMuEnBadQ=new TH1F("hNuMuEnBadQ","hNuMuEnBadQ",4*352,-32,320);
01477   hNuMuEnBadQ->GetXaxis()->SetTitle("Energy (GeV)");
01478   hNuMuEnBadQ->GetXaxis()->CenterTitle();
01479   hNuMuEnBadQ->GetYaxis()->SetTitle("");
01480   hNuMuEnBadQ->GetYaxis()->CenterTitle();
01481   hNuMuEnBadQ->SetFillColor(0);
01482   hNuMuEnBadQ->SetLineColor(1);
01483   hNuMuEnBadQ->SetLineWidth(2);
01484   //hNuMuEnBadQ->SetBit(TH1::kCanRebin);
01485 
01486 
01487 
01488   TH1F* hNuMuBarRecoEnGoodQ=new TH1F("hNuMuBarRecoEnGoodQ","hNuMuBarRecoEnGoodQ",
01489                               4*352,-32,320);
01490   hNuMuBarRecoEnGoodQ->GetXaxis()->SetTitle("Energy (GeV)");
01491   hNuMuBarRecoEnGoodQ->GetXaxis()->CenterTitle();
01492   hNuMuBarRecoEnGoodQ->GetYaxis()->SetTitle("");
01493   hNuMuBarRecoEnGoodQ->GetYaxis()->CenterTitle();
01494   hNuMuBarRecoEnGoodQ->SetFillColor(0);
01495   hNuMuBarRecoEnGoodQ->SetLineColor(2);
01496   //hNuMuBarRecoEnGoodQ->SetBit(TH1::kCanRebin);
01497 
01498   TH1F* hNuMuRecoEnGoodQ=new TH1F("hNuMuRecoEnGoodQ","hNuMuRecoEnGoodQ",4*352,-32,320);
01499   hNuMuRecoEnGoodQ->GetXaxis()->SetTitle("Energy (GeV)");
01500   hNuMuRecoEnGoodQ->GetXaxis()->CenterTitle();
01501   hNuMuRecoEnGoodQ->GetYaxis()->SetTitle("");
01502   hNuMuRecoEnGoodQ->GetYaxis()->CenterTitle();
01503   hNuMuRecoEnGoodQ->SetFillColor(0);
01504   hNuMuRecoEnGoodQ->SetLineColor(1);
01505   hNuMuRecoEnGoodQ->SetLineWidth(2);
01506   //hNuMuRecoEnGoodQ->SetBit(TH1::kCanRebin);
01507 
01508   TH1F* hNuMuBarRecoEnBadQ=new TH1F("hNuMuBarRecoEnBadQ","hNuMuBarRecoEnBadQ",
01509                               4*352,-32,320);
01510   hNuMuBarRecoEnBadQ->GetXaxis()->SetTitle("Energy (GeV)");
01511   hNuMuBarRecoEnBadQ->GetXaxis()->CenterTitle();
01512   hNuMuBarRecoEnBadQ->GetYaxis()->SetTitle("");
01513   hNuMuBarRecoEnBadQ->GetYaxis()->CenterTitle();
01514   hNuMuBarRecoEnBadQ->SetFillColor(0);
01515   hNuMuBarRecoEnBadQ->SetLineColor(2);
01516   //hNuMuBarRecoEnBadQ->SetBit(TH1::kCanRebin);
01517 
01518   TH1F* hNuMuRecoEnBadQ=new TH1F("hNuMuRecoEnBadQ","hNuMuRecoEnBadQ",4*352,-32,320);
01519   hNuMuRecoEnBadQ->GetXaxis()->SetTitle("Energy (GeV)");
01520   hNuMuRecoEnBadQ->GetXaxis()->CenterTitle();
01521   hNuMuRecoEnBadQ->GetYaxis()->SetTitle("");
01522   hNuMuRecoEnBadQ->GetYaxis()->CenterTitle();
01523   hNuMuRecoEnBadQ->SetFillColor(0);
01524   hNuMuRecoEnBadQ->SetLineColor(1);
01525   hNuMuRecoEnBadQ->SetLineWidth(2);
01526   //hNuMuRecoEnBadQ->SetBit(TH1::kCanRebin);
01527 
01528 
01529 
01530   TH1F* hNuMuBarEnTrk0=new TH1F("hNuMuBarEnTrk0","hNuMuBarEnTrk0",
01531                               4*352,-32,320);
01532   hNuMuBarEnTrk0->GetXaxis()->SetTitle("Energy (GeV)");
01533   hNuMuBarEnTrk0->GetXaxis()->CenterTitle();
01534   hNuMuBarEnTrk0->GetYaxis()->SetTitle("");
01535   hNuMuBarEnTrk0->GetYaxis()->CenterTitle();
01536   hNuMuBarEnTrk0->SetFillColor(0);
01537   hNuMuBarEnTrk0->SetLineColor(2);
01538   //hNuMuBarEnTrk0->SetBit(TH1::kCanRebin);
01539 
01540   TH1F* hNuMuEnTrk0=new TH1F("hNuMuEnTrk0","hNuMuEnTrk0",4*352,-32,320);
01541   hNuMuEnTrk0->GetXaxis()->SetTitle("Energy (GeV)");
01542   hNuMuEnTrk0->GetXaxis()->CenterTitle();
01543   hNuMuEnTrk0->GetYaxis()->SetTitle("");
01544   hNuMuEnTrk0->GetYaxis()->CenterTitle();
01545   hNuMuEnTrk0->SetFillColor(0);
01546   hNuMuEnTrk0->SetLineColor(1);
01547   hNuMuEnTrk0->SetLineWidth(2);
01548   //hNuMuEnTrk0->SetBit(TH1::kCanRebin);
01549 
01550 
01551 
01552   TH1F* hNuMuBarChi2GoodQ=new TH1F("hNuMuBarChi2GoodQ",
01553                                    "hNuMuBarChi2GoodQ",
01554                                    10*176,-16,160);
01555   hNuMuBarChi2GoodQ->GetXaxis()->SetTitle("Chi2/ndof");
01556   hNuMuBarChi2GoodQ->GetXaxis()->CenterTitle();
01557   hNuMuBarChi2GoodQ->GetYaxis()->SetTitle("");
01558   hNuMuBarChi2GoodQ->GetYaxis()->CenterTitle();
01559   hNuMuBarChi2GoodQ->SetFillColor(0);
01560   hNuMuBarChi2GoodQ->SetLineColor(2);
01561   //hNuMuBarChi2GoodQ->SetBit(TH1::kCanRebin);
01562 
01563   TH1F* hNuMuChi2GoodQ=new TH1F("hNuMuChi2GoodQ","hNuMuChi2GoodQ",
01564                                 10*176,-16,160);
01565   hNuMuChi2GoodQ->GetXaxis()->SetTitle("Chi2/ndof");
01566   hNuMuChi2GoodQ->GetXaxis()->CenterTitle();
01567   hNuMuChi2GoodQ->GetYaxis()->SetTitle("");
01568   hNuMuChi2GoodQ->GetYaxis()->CenterTitle();
01569   hNuMuChi2GoodQ->SetFillColor(0);
01570   hNuMuChi2GoodQ->SetLineColor(1);
01571   hNuMuChi2GoodQ->SetLineWidth(2);
01572   //hNuMuChi2GoodQ->SetBit(TH1::kCanRebin);
01573 
01574   TH1F* hNuMuBarChi2BadQ=new TH1F("hNuMuBarChi2BadQ",
01575                                   "hNuMuBarChi2BadQ",
01576                                   10*176,-16,160);
01577   hNuMuBarChi2BadQ->GetXaxis()->SetTitle("Chi2/ndof");
01578   hNuMuBarChi2BadQ->GetXaxis()->CenterTitle();
01579   hNuMuBarChi2BadQ->GetYaxis()->SetTitle("");
01580   hNuMuBarChi2BadQ->GetYaxis()->CenterTitle();
01581   hNuMuBarChi2BadQ->SetFillColor(0);
01582   hNuMuBarChi2BadQ->SetLineColor(2);
01583   hNuMuBarChi2BadQ->SetLineStyle(2);
01584   //hNuMuBarChi2BadQ->SetBit(TH1::kCanRebin);
01585 
01586   TH1F* hNuMuChi2BadQ=new TH1F("hNuMuChi2BadQ","hNuMuChi2BadQ",
01587                                10*176,-16,160);
01588   hNuMuChi2BadQ->GetXaxis()->SetTitle("Chi2/ndof");
01589   hNuMuChi2BadQ->GetXaxis()->CenterTitle();
01590   hNuMuChi2BadQ->GetYaxis()->SetTitle("");
01591   hNuMuChi2BadQ->GetYaxis()->CenterTitle();
01592   hNuMuChi2BadQ->SetFillColor(0);
01593   hNuMuChi2BadQ->SetLineColor(1);
01594   hNuMuChi2BadQ->SetLineWidth(2);
01595   hNuMuChi2BadQ->SetLineStyle(2);
01596   //hNuMuChi2BadQ->SetBit(TH1::kCanRebin);
01597 
01598 
01599   
01600   TH1F* hNuMuBarSigqp_qpGoodQ=new TH1F("hNuMuBarSigqp_qpGoodQ",
01601                                        "hNuMuBarSigqp_qpGoodQ",
01602                                        5000,-100,100);
01603   hNuMuBarSigqp_qpGoodQ->GetXaxis()->SetTitle("#sigma(Q/P)/(Q/P)");
01604   hNuMuBarSigqp_qpGoodQ->GetXaxis()->CenterTitle();
01605   hNuMuBarSigqp_qpGoodQ->GetYaxis()->SetTitle("");
01606   hNuMuBarSigqp_qpGoodQ->GetYaxis()->CenterTitle();
01607   hNuMuBarSigqp_qpGoodQ->SetFillColor(0);
01608   hNuMuBarSigqp_qpGoodQ->SetLineColor(2);
01609   //hNuMuBarSigqp_qpGoodQ->SetBit(TH1::kCanRebin);
01610 
01611   TH1F* hNuMuSigqp_qpGoodQ=new TH1F("hNuMuSigqp_qpGoodQ",
01612                                     "hNuMuSigqp_qpGoodQ",
01613                                     5000,-100,100);
01614   hNuMuSigqp_qpGoodQ->GetXaxis()->SetTitle("#sigma(Q/P)/(Q/P)");
01615   hNuMuSigqp_qpGoodQ->GetXaxis()->CenterTitle();
01616   hNuMuSigqp_qpGoodQ->GetYaxis()->SetTitle("");
01617   hNuMuSigqp_qpGoodQ->GetYaxis()->CenterTitle();
01618   hNuMuSigqp_qpGoodQ->SetFillColor(0);
01619   hNuMuSigqp_qpGoodQ->SetLineColor(1);
01620   hNuMuSigqp_qpGoodQ->SetLineWidth(2);
01621   //hNuMuSigqp_qpGoodQ->SetBit(TH1::kCanRebin);
01622 
01623   TH1F* hNuMuBarSigqp_qpBadQ=new TH1F("hNuMuBarSigqp_qpBadQ",
01624                                       "hNuMuBarSigqp_qpBadQ",
01625                                       5000,-100,100);
01626   hNuMuBarSigqp_qpBadQ->GetXaxis()->SetTitle("#sigma(Q/P)/(Q/P)");
01627   hNuMuBarSigqp_qpBadQ->GetXaxis()->CenterTitle();
01628   hNuMuBarSigqp_qpBadQ->GetYaxis()->SetTitle("");
01629   hNuMuBarSigqp_qpBadQ->GetYaxis()->CenterTitle();
01630   hNuMuBarSigqp_qpBadQ->SetFillColor(0);
01631   hNuMuBarSigqp_qpBadQ->SetLineColor(2);
01632   hNuMuBarSigqp_qpBadQ->SetLineStyle(2);
01633   //hNuMuBarSigqp_qpBadQ->SetBit(TH1::kCanRebin);
01634 
01635   TH1F* hNuMuSigqp_qpBadQ=new TH1F("hNuMuSigqp_qpBadQ",
01636                                    "hNuMuSigqp_qpBadQ",
01637                                    5000,-100,100);
01638   hNuMuSigqp_qpBadQ->GetXaxis()->SetTitle("#sigma(Q/P)/(Q/P)");
01639   hNuMuSigqp_qpBadQ->GetXaxis()->CenterTitle();
01640   hNuMuSigqp_qpBadQ->GetYaxis()->SetTitle("");
01641   hNuMuSigqp_qpBadQ->GetYaxis()->CenterTitle();
01642   hNuMuSigqp_qpBadQ->SetFillColor(0);
01643   hNuMuSigqp_qpBadQ->SetLineColor(1);
01644   hNuMuSigqp_qpBadQ->SetLineWidth(2);
01645   hNuMuSigqp_qpBadQ->SetLineStyle(2);
01646   //hNuMuSigqp_qpBadQ->SetBit(TH1::kCanRebin);
01647 
01648   TH1F* hDeltaTime=new TH1F("hDeltaTime","hDeltaTime",10100,-100,10000);
01649   hDeltaTime->GetXaxis()->SetTitle("{#Delta}T (ns)");
01650   hDeltaTime->GetXaxis()->CenterTitle();
01651   hDeltaTime->GetYaxis()->SetTitle("");
01652   hDeltaTime->GetYaxis()->CenterTitle();
01653   hDeltaTime->SetFillColor(0);
01654   hDeltaTime->SetLineColor(1);
01655   hDeltaTime->SetLineWidth(2);
01656   hDeltaTime->SetLineStyle(2);
01657   //hDeltaTime->SetBit(TH1::kCanRebin);
01658 
01659   TH1F* hDeltaT=new TH1F("hDeltaT","hDeltaT",10100,-100,10000);
01660   hDeltaT->GetXaxis()->SetTitle("#DeltaT (ns)");
01661   hDeltaT->GetXaxis()->CenterTitle();
01662   hDeltaT->GetYaxis()->SetTitle("");
01663   hDeltaT->GetYaxis()->CenterTitle();
01664   hDeltaT->SetFillColor(0);
01665   hDeltaT->SetLineColor(1);
01666   hDeltaT->SetLineWidth(2);
01667   hDeltaT->SetLineStyle(1);
01668   //hDeltaT->SetBit(TH1::kCanRebin);
01669 
01670   TH1F* hDeltaTg1=new TH1F("hDeltaTg1","hDeltaTg1",10100,-100,10000);
01671   hDeltaTg1->GetXaxis()->SetTitle("#DeltaT (ns)");
01672   hDeltaTg1->GetXaxis()->CenterTitle();
01673   hDeltaTg1->GetYaxis()->SetTitle("");
01674   hDeltaTg1->GetYaxis()->CenterTitle();
01675   hDeltaTg1->SetFillColor(0);
01676   hDeltaTg1->SetLineColor(2);
01677   hDeltaTg1->SetLineWidth(2);
01678   hDeltaTg1->SetLineStyle(1);
01679   //hDeltaTg1->SetBit(TH1::kCanRebin);
01680 
01681   Int_t totalSnarlsCounter=0;
01682   Int_t ccInFidCounter=0;
01683   Int_t recoEvtCounter=0;
01684   Int_t nuIntCounter=0;
01685   Int_t oneRecoEvtCounter=0;
01686   Int_t zeroTrackCounter=0;
01687   Int_t zeroTrackNuMuCounter=0;
01688   Int_t zeroTrackNuMuBarCounter=0;
01689   Int_t twoTrackCounter=0;
01690   Int_t twoTrackNuMuCounter=0;
01691   Int_t twoTrackNuMuBarCounter=0;
01692   Int_t threeTrackCounter=0;
01693   Int_t gr3TrackCounter=0;
01694   Int_t oneTrackCounter=0;
01695   Int_t passFitCounter=0;
01696   Int_t badNuMuCounter=0;
01697   Int_t goodNuMuCounter=0;
01698   Int_t badNuMuBarCounter=0;
01699   Int_t goodNuMuBarCounter=0;
01700 
01701   const NuCuts cuts;
01702   const NuReco reco;
01703   const NuExtraction ext;
01704 
01705   NuConfig config;
01706   this->ExtractConfig(config);
01707   //get an instance of the code library
01708   const NuLibrary& lib=NuLibrary::Instance();
01709  
01713   
01714   this->InitialiseLoopVariables();  
01715   
01716   //for(Int_t entry=0;entry<10000;entry++){
01717   for(Int_t entry=0;entry<this->GetEntries();entry++){
01718       
01719     this->SetLoopVariables(entry);
01720       
01721     set<Int_t> setNuInFid;
01722     set<Int_t> setNuInFidCC;
01723     map<Int_t,Double_t> deltaTs;
01724     map<Int_t,Int_t> evtsPerSlc;
01725   
01726     //get reference to NtpStRecord from base class
01727     const NtpStRecord& ntp=(*this->GetNtpStRecord());
01728 
01729 
01730     const RecCandHeader& rec=ntp.GetHeader();
01731     MAXMSG("NuAnalysis",Msg::kInfo,5)
01732       <<"Found: run="<<rec.GetRun()
01733       <<", subrun="<<rec.GetSubRun()
01734       <<", detector="<<rec.GetVldContext().GetDetector()
01735       <<", simFlag="<<rec.GetVldContext().GetSimFlag()
01736       <<endl;
01737 
01738     VldTimeStamp vldts;
01739     //VldTimeStamp vldts(ev.UnixTime,0);
01740     VldContext vc(rec.GetVldContext().GetDetector(),
01741                   rec.GetVldContext().GetSimFlag(),vldts);
01742     //get the ugh
01743     UgliGeomHandle ugh(vc);
01744     
01745     TClonesArray& mcTca=*ntp.mc;
01746     Int_t numInt=mcTca.GetEntries();
01747     MAXMSG("NuAnalysis",Msg::kInfo,20)
01748       <<"Number of entries in NtpMCTruth="
01749       <<mcTca.GetEntries()<<endl;
01750     //if (mcTca.GetEntries()==0){ 
01751 
01752     hNuInt->Fill(mcTca.GetEntries());
01753 
01754     for (Int_t i=0;i<numInt;i++){
01755       const NtpMCTruth& mc=*(dynamic_cast<NtpMCTruth*>(mcTca[i]));
01756       
01757       TVector3 xyz(mc.vtxx,mc.vtxy,mc.vtxz);
01758       // calculate the positions in UVZ space
01759       TVector3 uvz=ugh.xyz2uvz(xyz);
01760       
01761       //simple event object to hold important quantities
01762       NuEvent nu;
01763       
01764       //get the run, snarl, etc info
01765       ext.ExtractGeneralInfo(ntp,nu);
01766       
01767       Bool_t isInFidVol=cuts.IsInFidVol(mc.vtxx,mc.vtxy,mc.vtxz,
01768                                         uvz.X(),uvz.Y(),
01769                                         0,0,
01770                                         nu.detector,nu.anaVersion,
01771                                         nu.releaseType,nu.simFlag);
01772 
01773       if (isInFidVol) {
01774         deltaTs.clear();
01775         reco.GetEvtDeltaTs(ntp,deltaTs);
01776         evtsPerSlc.clear();
01777         reco.GetEvtsPerSlc(ntp,evtsPerSlc);
01778         MAXMSG("NuAnalysis",Msg::kInfo,100)
01779           <<"Contained mc="<<mc.index<<endl;
01780         setNuInFid.insert(mc.index);
01781         if (mc.iaction==1 && (mc.inu==-14 || mc.inu==14)) {
01782           setNuInFidCC.insert(mc.index);
01783         }
01784       }
01785 
01786       MAXMSG("NuAnalysis",Msg::kDebug,20)
01787         <<"isInFidVol="<<isInFidVol
01788         <<", x="<<mc.vtxx<<", y="<<mc.vtxy<<", z="<<mc.vtxz
01789         <<", u="<<uvz.X()<<", v="<<uvz.Y()<<endl;
01790       
01791       if (isInFidVol){
01792         MAXMSG("NuAnalysis",Msg::kInfo,20)
01793           <<"isInFidVol="<<isInFidVol
01794           <<", x="<<mc.vtxx<<", y="<<mc.vtxy<<", z="<<mc.vtxz
01795           <<", u="<<uvz.X()<<", v="<<uvz.Y()<<endl;
01796       }
01797       
01798       //calc index for vector of histos
01799       Int_t enIndex=static_cast<Int_t>(mc.p4neu[3]*2.0+1);
01800 
01801       if (mc.iaction==1){
01802         hNuYCC->Fill(mc.y);
01803         if (isInFidVol) {
01804           hYvsXFidCC->Fill(mc.vtxx,mc.vtxy);
01805         }
01806         hYvsXCC->Fill(mc.vtxx,mc.vtxy);
01807         hYvsX400CC->Fill(mc.vtxx,mc.vtxy);
01808         hYvsZCC->Fill(mc.vtxz,mc.vtxy);
01809         hXvsZCC->Fill(mc.vtxz,mc.vtxx);
01810         if (mc.vtxy>-2.5 && mc.vtxy<3) hXvsZZoomCC->
01811                                          Fill(mc.vtxz,mc.vtxx);
01812         hXYZCC->Fill(mc.vtxx,mc.vtxz,mc.vtxy);
01813         hZCC->Fill(mc.vtxz);
01814         hinuCC->Fill(mc.inu);
01815         if (mc.inu==-14){
01816           if (enIndex<nbinsForY) vNuYNuMuBarCC[enIndex]->Fill(mc.y);
01817           hNuMuBarEnCC->Fill(mc.p4neu[3]);
01818           hNuMuBarEn4000CC->Fill(mc.p4neu[3]);
01819           if (isInFidVol) {
01820             hNuYFidNuMuBarCC->Fill(mc.y);
01821             MAXMSG("NuAnalysis",Msg::kInfo,200)
01822               <<"enIndex="<<enIndex<<", E="<<mc.p4neu[3]<<endl;
01823             hNuMuBarFidEnCC->Fill(mc.p4neu[3]);
01824             hNuMuBarLike->Fill(mc.p4neu[3]);
01825           }
01826         }
01827         else if (mc.inu==14) {
01828           if (enIndex<nbinsForY) vNuYNuMuCC[enIndex]->Fill(mc.y);
01829           hNuMuEnCC->Fill(mc.p4neu[3]);
01830           hNuMuEn4000CC->Fill(mc.p4neu[3]);
01831           if (isInFidVol) {
01832             hNuYFidNuMuCC->Fill(mc.y);
01833             hNuMuFidEnCC->Fill(mc.p4neu[3]);
01834             hNuMuLike->Fill(mc.p4neu[3]);
01835           }
01836         }
01837         else if (mc.inu==-12) hNueBarEnCC->Fill(mc.p4neu[3]);
01838         else if (mc.inu==12) hNueEnCC->Fill(mc.p4neu[3]);
01839         else {
01840           MAXMSG("NuAnalysis",Msg::kWarning,100)
01841             <<"particle not defined for filling histo="<<mc.inu<<endl;
01842         }
01843       }
01844       else if (mc.iaction==0){
01845         hNuYNC->Fill(mc.y);
01846         if (isInFidVol) {
01847           hYvsXFidNC->Fill(mc.vtxx,mc.vtxy);
01848         }
01849         hYvsXNC->Fill(mc.vtxx,mc.vtxy);
01850         hYvsX400NC->Fill(mc.vtxx,mc.vtxy);
01851         hYvsZNC->Fill(mc.vtxz,mc.vtxy);
01852         hXvsZNC->Fill(mc.vtxz,mc.vtxx);
01853         //cut out rock events above and below
01854         if (mc.vtxy>-2.5 && mc.vtxy<3) hXvsZZoomNC->
01855                                          Fill(mc.vtxz,mc.vtxx);
01856         hXYZNC->Fill(mc.vtxx,mc.vtxz,mc.vtxy);
01857         hZNC->Fill(mc.vtxz);
01858         hinuNC->Fill(mc.inu);
01859         if (mc.inu==-14) {
01860           if (enIndex<nbinsForY) vNuYNuMuBarNC[enIndex]->Fill(mc.y);
01861           hNuMuBarEnNC->Fill(mc.p4neu[3]);
01862           hNuMuBarEnDepNC->Fill(mc.y*mc.p4neu[3]);
01863           if (isInFidVol) {
01864             hNuYFidNuMuBarNC->Fill(mc.y);
01865           }
01866         }
01867         else if (mc.inu==14) { 
01868           if (enIndex<nbinsForY) vNuYNuMuNC[enIndex]->Fill(mc.y);
01869           hNuMuEnNC->Fill(mc.p4neu[3]);
01870           hNuMuEnDepNC->Fill(mc.y*mc.p4neu[3]);
01871           if (isInFidVol) {
01872             hNuYFidNuMuNC->Fill(mc.y);
01873           }
01874         }
01875         else if (mc.inu==-12) {
01876           hNueBarEnNC->Fill(mc.p4neu[3]);
01877           hNueBarEnDepNC->Fill(mc.y*mc.p4neu[3]);
01878         }
01879         else if (mc.inu==12) {
01880           hNueEnNC->Fill(mc.p4neu[3]);
01881           hNueEnDepNC->Fill(mc.y*mc.p4neu[3]);
01882         }
01883         else {
01884           MAXMSG("NuAnalysis",Msg::kWarning,100)
01885             <<"particle not defined for filling histo="<<mc.inu<<endl;
01886         }
01887       }
01888       else cout<<"Ahhh, bad iaction"<<endl;
01889     }
01890 
01891     MAXMSG("NuAnalysis",Msg::kInfo,100)
01892       <<"Number of fiducial volume interactions in spill="
01893       <<setNuInFid.size()<<endl;
01894 
01895     TClonesArray& thevtTca=(*ntp.thevt);//TruthHelper Track TCA
01896     const Int_t numthevts=thevtTca.GetEntriesFast();
01897     TClonesArray& evtTca=(*ntp.evt);
01898     //const Int_t numEvts=evtTca.GetEntriesFast();
01899     
01900     //set of events with true neutrino interactions in the fid vol
01901     set<Int_t> evtsInFid;
01902     set<Int_t> evtsInFidCC;
01903 
01904     set<Int_t>::iterator setNuInFidEnd=setNuInFid.end();
01905     map<Int_t,Int_t> nuEvtCounter;
01906     map<Int_t,Int_t> nuEvtCounterCC;
01907     map<Int_t,multiset<Double_t> > nuIntEvtTimesCC;
01908     for (Int_t ithevt=0;ithevt<numthevts;ithevt++){
01909       const NtpTHEvent& thevt=
01910         *dynamic_cast<NtpTHEvent*>(thevtTca[ithevt]);
01911       const NtpSREvent& evt=
01912         *dynamic_cast<NtpSREvent*>(evtTca[ithevt]);
01913       
01914       if (setNuInFid.find(thevt.neumc)!=setNuInFidEnd){
01915         MAXMSG("NuAnalysis",Msg::kInfo,100)
01916           <<"Found mc="<<thevt.neumc<<endl;
01917         //count the number of reco events a particular nu interaction
01918         //is believed to cause
01919         nuEvtCounter[thevt.neumc]++;
01920         //keep a list of the events corresponding to neutrinos in
01921         //the fiducial volume
01922         evtsInFid.insert(ithevt);
01923 
01924         const NtpMCTruth& mc=
01925           *(dynamic_cast<NtpMCTruth*>(mcTca[thevt.neumc]));
01926         if (mc.iaction==1 && (mc.inu==-14 || mc.inu==14)) {
01927           nuEvtCounterCC[thevt.neumc]++;
01928           evtsInFidCC.insert(ithevt);
01929 
01930           //store the median times of the events 
01931           //from each neutrino interaction
01932           Double_t time=reco.GetEvtMedianTime(ntp,evt);
01933           nuIntEvtTimesCC[thevt.neumc].insert(time);
01934         }
01935       }
01936     }
01937 
01938     //need to work out the number of times no event is found
01939     typedef set<Int_t>::iterator setNuInFidIt;
01940     for (setNuInFidIt it=setNuInFid.begin();
01941          it!=setNuInFid.end();++it){
01942       //check if event is not in the map (i.e. no evt reco'd)
01943       MAXMSG("NuAnalysis",Msg::kInfo,100)
01944         <<"Looking in evt counter for mc.index="<<*it
01945         <<", evtCo size="<<nuEvtCounter.size()
01946         <<", setNu size="<<setNuInFid.size()
01947         <<endl;
01948       if (nuEvtCounter.find(*it)!=nuEvtCounter.end()){
01949         MAXMSG("NuAnalysis",Msg::kInfo,100)
01950           <<"   Found mc.index="<<*it<<endl;
01951       }
01952       else {
01953         MAXMSG("NuAnalysis",Msg::kInfo,30)
01954           <<"   NOT found mc.index="<<*it
01955           <<", evtCo size="<<nuEvtCounter.size()
01956           <<", setNu size="<<setNuInFid.size()
01957           <<endl;
01958         //put an entry in the map with a zero
01959         nuEvtCounter[*it]=0;
01960       }
01961     }
01962 
01963     //fill histo with number of reco evts per nu interaction
01964     typedef map<Int_t,Int_t>::iterator evCounterIt;
01965     for (evCounterIt it=nuEvtCounter.begin();
01966          it!=nuEvtCounter.end();++it){
01967       //get the mc object
01968       const NtpMCTruth& mc=
01969         *(dynamic_cast<NtpMCTruth*>(mcTca[it->first]));
01970 
01971       //cut out the nues
01972       if (!(mc.inu==-14 || mc.inu==14)) continue;
01973       
01974       hEvtsPerNu->Fill(it->second);
01975       if (mc.iaction==1){//CC
01976         hEvtsPerNuCC->Fill(it->second);
01977         hEvtsVsNuEnCC->Fill(mc.p4neu[3],it->second);
01978       }
01979       else if (mc.iaction==0){//NC
01980         hEvtsPerNuNC->Fill(it->second);
01981         hEvtsVsNuEnNC->Fill(mc.p4neu[3],it->second);
01982       }
01983     }
01984 
01988 
01989     //nuEvtCounterCC
01990     totalSnarlsCounter++;
01991     //check that a CC neutrino interaction occured in fid vol
01992     if (setNuInFidCC.size()<1) continue;
01993     ccInFidCounter++;
01994     //require that there is a reco'd fid vol event
01995     if (evtsInFidCC.size()<1) continue;
01996     recoEvtCounter++;
01997 
01998     //get the TCAs
01999     TClonesArray& trkTca=(*ntp.trk);
02000     //const Int_t numTrks=trkTca.GetEntriesFast();
02001     //TClonesArray& stpTca=(*ntp.stp);
02002     //const Int_t numStps=stpTca.GetEntriesFast();
02003 
02004     typedef set<Int_t>::iterator setEvtsInFidIt;
02005     for (setEvtsInFidIt it=evtsInFidCC.begin();
02006          it!=evtsInFidCC.end();++it) {
02007       const NtpTHEvent& thevt=
02008         *dynamic_cast<NtpTHEvent*>(thevtTca[*it]);
02009       const NtpSREvent& evt=
02010         *dynamic_cast<NtpSREvent*>(evtTca[*it]);
02011       const NtpMCTruth& mc=
02012         *(dynamic_cast<NtpMCTruth*>(mcTca[thevt.neumc]));
02013 
02014       //count the total number of neutrino interactions
02015       nuIntCounter++;
02016 
02017       //cut out the NCs
02018       if (mc.iaction==0) cout<<"Ahhh NC"<<endl;
02019       //cut out the nues
02020       if (!(mc.inu==-14 || mc.inu==14)) cout<<"Ahhh nue"<<endl;
02021       
02022       //find number of reco'd events for neutrino int 
02023       //associated with this event
02024       Int_t numEvtsPerNuInt=-1;
02025       map<Int_t,Int_t>::iterator countIt=
02026         nuEvtCounterCC.find(thevt.neumc);
02027       if (countIt!=nuEvtCounterCC.end()){
02028         numEvtsPerNuInt=countIt->second;
02029 
02030         //      nuIntEvtTimesCC[thevt.neumc].insert(time);
02031         Int_t times=nuIntEvtTimesCC.find(thevt.neumc)->second.size();
02032         if (times>1 || numEvtsPerNuInt>1){
02033           MAXMSG("NuAnalysis",Msg::kInfo,200)
02034             <<"numEvtsPerNuInt="<<numEvtsPerNuInt
02035             <<", times="<<times<<endl;
02036           
02037           typedef map<Int_t,multiset<Double_t> >::iterator nuIntIt;
02038           nuIntIt nuInt=nuIntEvtTimesCC.find(thevt.neumc);
02039           typedef multiset<Double_t>::iterator timeIt;
02040           timeIt beg=nuInt->second.begin();
02041           timeIt end=nuInt->second.end();
02042           timeIt lastTimeIt=nuInt->second.end();
02043           for (timeIt it=beg;it!=end;++it){
02044             MsgFormat ffmt("%9.9f");
02045             
02046             MAXMSG("NuAnalysis",Msg::kDebug,200)
02047               <<"  in multiset time="<<ffmt(*it)
02048               <<", evt.slc="<<evt.slc<<endl;
02049             if (lastTimeIt!=end){
02050               Double_t deltaTime=(*it)-(*lastTimeIt);
02051               MAXMSG("NuAnalysis",Msg::kDebug,200)
02052               <<"  deltaTime="<<ffmt(deltaTime)<<endl;
02053               hDeltaTime->Fill(deltaTime/(Munits::ns));         
02054             }
02055 
02056             //record the current it
02057             lastTimeIt=it;
02058           }
02059           //nuIntEvtTimesCC.find(thevt.neumc)->second.begin();
02060         }
02061         //if (countIt->second!=1) {
02062           //MAXMSG("NuAnalysis",Msg::kInfo,100)
02063           //<<"NOT using mc="<<thevt.neumc
02064           //<<" with reco'd events="<<countIt->second
02065           //<<endl;
02066           //continue;
02067         //}
02068       }
02069       else cout<<"Can't find mc="<<thevt.neumc<<endl;
02070       
02071       if (numEvtsPerNuInt>1) {
02072         const NtpSREvent& evt=
02073           *dynamic_cast<NtpSREvent*>(evtTca[*it]);
02074         const NtpMCTruth& mc=
02075           *(dynamic_cast<NtpMCTruth*>(mcTca[thevt.neumc]));
02076         MAXMSG("NuAnalysis",Msg::kDebug,200)
02077           <<"entry="<<entry<<", NuInt: mc="<<thevt.neumc
02078           <<", slc="<<evt.slc
02079           <<", evt="<<*it<<" ("<<numEvtsPerNuInt<<")"
02080           <<", ntrk="<<evt.ntrack
02081           <<", nshw="<<evt.nshower
02082           <<", Nu: E="<<mc.p4neu[3]
02083           <<", y="<<mc.y
02084           <<endl;
02085         
02086         //check that a delta T was found for this event
02087         if (deltaTs.find(evt.index)!=deltaTs.end()){
02088           hDeltaTg1->Fill(deltaTs[evt.index]/(Munits::ns));
02089           //only look at evts per slice for > 50 ns dT
02090           if (deltaTs[evt.index]/(Munits::ns)>50){
02091             hEvtsPerSlcg1T->Fill(evtsPerSlc[evt.slc]);
02092           }
02093         }
02094         else cout<<"No delta T for evt="<<evt.index<<endl;
02095         hEvtsPerSlcg1->Fill(evtsPerSlc[evt.slc]);
02096       }
02097       else {
02098         if (deltaTs.find(evt.index)!=deltaTs.end()){
02099           hDeltaT->Fill(deltaTs[evt.index]/(Munits::ns));
02100         }
02101         else cout<<"No delta T for evt="<<evt.index<<endl;
02102         hEvtsPerSlc->Fill(evtsPerSlc[evt.slc]);
02103       }
02104 
02105       //only analyse further events with 1 reco'd evt
02106       if (numEvtsPerNuInt!=1) continue;
02107       
02108       //get this far with only one reco'd evt per nu
02109       oneRecoEvtCounter++;
02110 
02111       //get the current reco'd event
02112       //const NtpSREvent& evt=
02113       //*dynamic_cast<NtpSREvent*>(evtTca[*it]);
02114 
02115       //fill number of tracks in the event
02116       hTrksPerEvt->Fill(evt.ntrack);
02117 
02119       //deal with the events that don't have a track
02121       if (evt.ntrack==0) {
02122         zeroTrackCounter++;
02123         if (mc.inu==14) {
02124           zeroTrackNuMuCounter++;
02125           hNuMuEnTrk0->Fill(mc.p4neu[3]);
02126           //don't fill this since you would not assume it NuMuBar
02127           //hNuMuBarLike->Fill(mc.p4neu[3]);
02128         }
02129         else if (mc.inu==-14) {
02130           zeroTrackNuMuBarCounter++;
02131           hNuMuBarEnTrk0->Fill(mc.p4neu[3]);
02132           //add NuMuBars with no track to NuMu-like sample
02133           //also assuming here that it is not ID'd as NC
02134           hNuMuLike->Fill(mc.p4neu[3]);
02135         }
02136       }
02137       if (evt.ntrack==1) {
02138         oneTrackCounter++;
02139       }
02140       if (evt.ntrack==2) {
02141         twoTrackCounter++;
02142         if (mc.inu==14) {
02143           twoTrackNuMuCounter++;
02144         }
02145         else if (mc.inu==-14) {
02146           twoTrackNuMuBarCounter++;
02147         }
02148       }
02149       if (evt.ntrack==3) {
02150         threeTrackCounter++;
02151       }
02152       if (evt.ntrack>3) {
02153         gr3TrackCounter++;
02154       }
02155 
02156       //work out the best track to use in the case that there is 
02157       //more than one
02158       Int_t trkToUse=0;
02159       Float_t trkLength=0;
02160       if (evt.ntrack>1){
02161         for(Int_t itrk=0;itrk<evt.ntrack;itrk++){
02162           const NtpSRTrack& trk=
02163             *dynamic_cast<NtpSRTrack*>(trkTca[evt.trk[itrk]]);
02164           
02165           MAXMSG("NuAnalysis",Msg::kDebug,200)
02166             <<"trk="<<itrk<<"/"<<evt.ntrack
02167             <<", pass="<<trk.fit.pass
02168             <<", ntrklike="<<trk.plane.ntrklike
02169             <<endl;
02170           
02171           if (!trk.fit.pass) continue;//trkToUse=0 here
02172           
02173           //select the longest trk (in track-like planes)
02174           if (trk.plane.ntrklike>trkLength) {
02175             trkLength=trk.plane.ntrklike;
02176             trkToUse=itrk;
02177           }
02178         }
02179         MAXMSG("NuAnalysis",Msg::kDebug,200)
02180           <<"selected trkToUse="<<trkToUse<<endl;
02181       }
02182 
02183       //simple event object to hold important quantities
02184       NuEvent nu;
02185       
02186       //get the run, snarl, etc info
02187       lib.ext.ExtractGeneralInfo(ntp,nu);
02188       //get info from the evt
02189       lib.ext.ExtractEvtInfo(evt,nu);
02190       //extract trk info (needed to get best track info)
02191       lib.ext.ExtractTrkInfo(ntp,evt,nu);
02192       //extract shw info
02193       lib.ext.ExtractShwInfo(ntp,evt,nu);
02194       
02196       //RECONSTRUCT the neutrino energy
02197       lib.reco.GetEvtEnergy(nu, false);
02198       
02199       Float_t recoEn=nu.energy;
02200       MAXMSG("NuAnalysis",Msg::kInfo,500)
02201         <<"Reco'd event energy="<<recoEn<<endl;
02202 
02203       //ensure there is a track in the event
02204       if (evt.ntrack<1) continue;
02205       
02206       //get the track in the event
02207       const NtpSRTrack& trk=
02208         *dynamic_cast<NtpSRTrack*>(trkTca[evt.trk[trkToUse]]);
02209 
02210       Int_t chargeMC=0;
02211       if (mc.p4mu1[3]<0) chargeMC=-1;
02212       else if (mc.p4mu1[3]>0) chargeMC=+1;
02213       
02214       Int_t charge=0;
02215       if (trk.momentum.qp<0) charge=-1;
02216       else if (trk.momentum.qp>0) charge=+1;
02217 
02218       //fill profiles
02219       if (mc.inu==14) {
02220         pNuMuFitPassVsEn->Fill(mc.p4neu[3],trk.fit.pass);      
02221       }
02222       else if (mc.inu==-14) {
02223         pNuMuBarFitPassVsEn->Fill(mc.p4neu[3],trk.fit.pass);      
02224       }
02225       
02226       if (trk.fit.pass){
02227         Float_t chi2PerNdof=-1;
02228         if (trk.fit.ndof) chi2PerNdof=trk.fit.chi2/trk.fit.ndof;
02229         Float_t sigqp_qp=0;
02230         if (trk.momentum.qp) sigqp_qp=trk.momentum.eqp/trk.momentum.qp;
02231 
02232         passFitCounter++;
02233         if (mc.inu==14) {
02234           pNuMuQEffVsEn->Fill(mc.p4neu[3],charge==chargeMC);
02235           if (charge!=chargeMC){
02236             badNuMuCounter++;
02237             hNuMuEnBadQ->Fill(mc.p4neu[3]);
02238             hNuMuRecoEnBadQ->Fill(recoEn);
02239             //if Q is wrong then think NuMu is NuMuBar-like
02240             hNuMuBarLike->Fill(mc.p4neu[3]);
02241             hNuMuChi2BadQ->Fill(chi2PerNdof);
02242             hNuMuSigqp_qpBadQ->Fill(sigqp_qp);
02243           }
02244           else{
02245             goodNuMuCounter++;
02246             hNuMuEnGoodQ->Fill(mc.p4neu[3]);
02247             hNuMuRecoEnGoodQ->Fill(recoEn);
02248             hNuMuChi2GoodQ->Fill(chi2PerNdof);
02249             hNuMuSigqp_qpGoodQ->Fill(sigqp_qp);
02250           }
02251         }
02252         else if (mc.inu==-14) {
02253           pNuMuBarQEffVsEn->Fill(mc.p4neu[3],charge==chargeMC);
02254           if (charge!=chargeMC){
02255             badNuMuBarCounter++;
02256             hNuMuBarEnBadQ->Fill(mc.p4neu[3]);
02257             hNuMuBarRecoEnBadQ->Fill(recoEn);
02258             //if Q is wrong then think NuMuBar is NuMu-like
02259             hNuMuLike->Fill(mc.p4neu[3]);
02260             hNuMuBarChi2BadQ->Fill(chi2PerNdof);
02261             hNuMuBarSigqp_qpBadQ->Fill(sigqp_qp);
02262           }
02263           else{
02264             goodNuMuBarCounter++;
02265             hNuMuBarEnGoodQ->Fill(mc.p4neu[3]);
02266             hNuMuBarRecoEnGoodQ->Fill(recoEn);
02267             hNuMuBarChi2GoodQ->Fill(chi2PerNdof);
02268             hNuMuBarSigqp_qpGoodQ->Fill(sigqp_qp);
02269           }
02270         }
02271       }
02272     }
02273   }//end of for                                       
02274   
02278 
02279   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
02280 
02281   MSG("NuAnalysis",Msg::kInfo)
02282     <<endl<<"  *** Summary ***"<<endl
02283     <<"Total snarls             ="<<totalSnarlsCounter<<endl
02284     <<"Snarls w/ CC NuInt in Fid="<<ccInFidCounter<<endl
02285     <<"Snarls w/ reco'd fid evt ="<<recoEvtCounter<<endl
02286     <<endl
02287     <<"Total neutrino interactions="<<nuIntCounter<<endl
02288     <<"Only 1 reco'd evt per nu   ="<<oneRecoEvtCounter<<endl
02289     <<"Only 1 track               ="<<oneTrackCounter<<endl
02290     <<"Pass track fit             ="<<passFitCounter<<endl
02291     <<"  bad Q NuMu               ="<<badNuMuCounter<<endl
02292     <<"  good Q NuMu              ="<<goodNuMuCounter<<endl
02293     <<"  bad Q NuMuBar            ="<<badNuMuBarCounter<<endl
02294     <<"  good Q NuMuBar           ="<<goodNuMuBarCounter<<endl;
02295 
02296   MSG("NuAnalysis",Msg::kInfo)
02297     <<endl<<"  *** CC NuMu Event Track Breakdown ***"<<endl
02298     <<"zeroTrackCounter ="<<zeroTrackCounter<<endl
02299     <<"  NuMu   ="<<zeroTrackNuMuCounter<<endl
02300     <<"  NuMuBar="<<zeroTrackNuMuBarCounter<<endl
02301     <<"oneTrackCounter  ="<<oneTrackCounter<<endl
02302     <<"twoTrackCounter  ="<<twoTrackCounter<<endl
02303     <<"  NuMu   ="<<twoTrackNuMuCounter<<endl
02304     <<"  NuMuBar="<<twoTrackNuMuBarCounter<<endl
02305     <<"threeTrackCounter="<<threeTrackCounter<<endl
02306     <<"g3TrackCounter   ="<<gr3TrackCounter<<endl;
02307     
02308   MSG("NuAnalysis",Msg::kInfo) 
02309     <<" ** Finished EnergySpectMC method **"<<endl;
02310 }

Bool_t NuAnalysis::ExtractConfig ( const NtpStRecord pntp,
const NtpBDLiteRecord pntpBD,
NuConfig config 
) const [private]

Definition at line 3125 of file NuAnalysis.cxx.

References bfld::AsString(), VldTimeStamp::AsString(), BeamMonSpill::BeamType(), NuConfig::beamType, NuConfig::beamTypeSntp, BeamMonSpill::BpmAtTarget(), NtpBDLiteRecord::bwidx, NtpBDLiteRecord::bwidy, NuConfig::detector, DetermineBeamType(), VldContext::GetDetector(), NuBase::GetFirstFileName(), RecRecordImp< T >::GetHeader(), NuBase::GetInputFileName(), ReleaseType::GetMCInfo(), VldTimeStamp::GetNanoSec(), NuBase::GetNtpStRecord(), ReleaseType::GetRecoInfo(), NtpStRecord::GetRelease(), RecDataHeader::GetRun(), VldTimeStamp::GetSec(), VldTimeStamp::GetSeconds(), VldContext::GetSimFlag(), RecPhysicsHeader::GetSnarl(), BeamMonSpill::GetStatusBits(), Anp::GetString(), RecDataHeader::GetSubRun(), BeamDataLiteHeader::GetTimeDiffStreamSpill(), VldContext::GetTimeStamp(), RecPhysicsHeader::GetTrigSrc(), RecRecordImp< T >::GetVldContext(), NtpBDLiteRecord::horncur, NuConfig::hornCurrent, NuConfig::hornIsReverse, info, NuConfig::intensity, ReleaseType::IsBirch(), BeamMonSpill::IsRHCRunning(), ReleaseType::kBirch, SimFlag::kData, Msg::kDebug, ReleaseType::kDogwood, Msg::kInfo, BeamType::kL010z185i, BeamType::kL010z185i_rev, SimFlag::kMC, Msg::kWarning, MAXMSG, NuConfig::mcVersion, MSG, NuConfig::overrideBeamDataConfigExtraction, BMSpillAna::Print(), NuUtilities::PrintRelease(), NuConfig::recoVersion, NuConfig::releaseType, NuConfig::run, NuConfig::runPeriod, NuConfig::sBeamType, BMSpillAna::SelectSpill(), BMSpillAna::SetSpill(), NuConfig::sHornCurrent, NuConfig::simFlag, NuConfig::snarl, NuConfig::sTargetPos, NuConfig::subRun, NuConfig::targetPos, NuConfig::timeNanoSec, NuConfig::timeSec, NuConfig::trigSrc, NtpBDLiteRecord::trtgtd, BMSpillAna::UseDatabaseCuts(), NuUtilities::vtsRunIEnd, NuUtilities::vtsRunIIEnd, NuUtilities::vtsRunIIIEnd, NuUtilities::vtsRunIVEnd, NuUtilities::vtsRunIXEnd, NuUtilities::vtsRunVEnd, NuUtilities::vtsRunVIEnd, NuUtilities::vtsRunVIIEnd, NuUtilities::vtsRunVIIIEnd, and NuUtilities::vtsRunXEnd.

03128 {
03129   //get reference to NtpStRecord
03130   const NtpStRecord& ntp=*pntp;
03131   
03132   const RecCandHeader& rec=ntp.GetHeader();
03133   MAXMSG("NuAnalysis",Msg::kInfo,5)
03134     <<"ExtractConfig: run="<<rec.GetRun()
03135     <<", subrun="<<rec.GetSubRun()
03136     <<", detector="<<ntp.GetVldContext()->GetDetector()
03137     <<", simFlag="<<ntp.GetVldContext()->GetSimFlag()
03138     <<endl;
03139     
03140   //set the variables
03141   config.run=rec.GetRun();
03142   config.subRun=rec.GetSubRun();
03143   config.snarl=rec.GetSnarl();
03144   config.timeSec=ntp.GetVldContext()->GetTimeStamp().GetSec();
03145   config.timeNanoSec=ntp.GetVldContext()->GetTimeStamp().GetNanoSec();
03146   config.detector=ntp.GetVldContext()->GetDetector();
03147   config.simFlag=ntp.GetVldContext()->GetSimFlag();
03148   config.trigSrc=rec.GetTrigSrc();
03149   
03150   //get the reco and MC version
03151   /*
03152   MAXMSG("NuAnalysis",Msg::kInfo,50)
03153     <<"Using ntp.GetTitle()="<<ntp.GetTitle()<<endl
03154     <<"Using ntp.mchdr.geninfo.codename="
03155     <<ntp.mchdr.geninfo.codename<<endl;
03156     
03157   //get the release type
03158   config.releaseType=ReleaseType::MakeReleaseType
03159     (ntp.GetTitle(),ntp.mchdr.geninfo.codename);
03160   */
03161   config.releaseType=ntp.GetRelease();
03162    
03163   // Check for obviously wrong releaseType
03164   if ( ReleaseType::IsBirch(config.releaseType)) {
03165     int oldrel = config.releaseType;
03166     config.releaseType -= ReleaseType::kBirch;
03167     config.releaseType += ReleaseType::kDogwood;
03168 
03169     MAXMSG("NuAnalysis",Msg::kInfo, 5) << "Changing the release type from " 
03170     << NuUtilities::PrintRelease(oldrel) << " to "
03171     << NuUtilities::PrintRelease(config.releaseType) << endl;
03172   }
03173   
03174   
03175   //extract the mcVersion from the releaseType
03176   config.mcVersion=ReleaseType::GetMCInfo(config.releaseType);
03177   //extract the recoVersion from the releaseType
03178   config.recoVersion=ReleaseType::GetRecoInfo(config.releaseType);
03179 
03180 
03181     
03182   MAXMSG("NuAnalysis",Msg::kInfo,50)
03183     <<"Extracted:"<<endl
03184     <<"  ReleaseType = " <<NuUtilities::PrintRelease(config.releaseType) << endl
03185     <<"  mcVersion   = " <<NuUtilities::PrintRelease(config.mcVersion) << endl
03186     <<"  recoVersion = " <<NuUtilities::PrintRelease(config.recoVersion) << endl;
03187   
03188     
03190   //check if NtpBDLiteRecord exists in the data case
03192   if (ntp.GetVldContext()->GetSimFlag()==SimFlag::kData && 
03193       (!pntpBD || config.overrideBeamDataConfigExtraction)) {
03194     if (!pntpBD) {
03195       MSG("NuAnalysis",Msg::kInfo)
03196         <<"ExtractConfig: no NtpBDLiteRecord available"
03197         <<", making up settings..."<<endl;
03198     }
03199     else if (config.overrideBeamDataConfigExtraction) {
03200       MSG("NuAnalysis",Msg::kInfo)
03201         <<"ExtractConfig: overriding use of Beam Data"
03202         <<" to extract config, making up settings..."<<endl;
03203     }
03204     config.beamType=BeamType::kL010z185i;
03205     config.hornCurrent=-185;
03206     string btAsString=BeamType::AsString
03207       (static_cast<BeamType::BeamType_t>(config.beamType));
03208     config.sTargetPos=btAsString.substr(1,3);
03209     config.targetPos=-1.*atoi(config.sTargetPos.c_str());
03210     config.sHornCurrent=btAsString.substr(5,7);      
03211     //create the std MC naming scheme name
03212 
03213     const VldTimeStamp startNOvA(2013,6,1,0/*hr*/,0/*min*/,0/*sec*/,0/*ns*/);
03214     
03215     if(config.timeSec < (double)startNOvA){
03216     config.sBeamType="L"+config.sTargetPos+config.sHornCurrent;
03217     }
03218     if(config.timeSec >= (double)startNOvA){
03219     config.sBeamType="M"+config.sTargetPos+config.sHornCurrent;
03220     }       
03221     //the beammonspill beamType is not same as Conventions one
03222     config.beamTypeSntp=1;
03223   }
03225   //check if DATA
03227   else if (ntp.GetVldContext()->GetSimFlag()==SimFlag::kData){
03228     MAXMSG("NuAnalysis",Msg::kDebug,1)
03229       <<"ExtractConfig: running on DATA..."<<endl;
03230     const NtpBDLiteRecord& ntpBD=*pntpBD;
03231     
03232     //static BeamMonSpill spill;
03233     //static BMSpillAna bmsa;
03234     BeamMonSpill spill;
03235     BMSpillAna bmsa;
03236     //bmsa.Print();
03237 
03238     //tell it to use the database defined values of the cuts
03239     //doesn't actually load the database until you ask SelectSpill
03240     bmsa.UseDatabaseCuts();
03241       
03242     //give it the spill
03243     bmsa.SetSpill(ntpBD,spill);
03244 
03245     // evaluate the cuts, this triggers reading the DB
03246     // and updating the cut values
03247     bool isgoodspill = bmsa.SelectSpill();
03248 
03249     static int mxmsg = 10;
03250     if ( mxmsg > 0 ) {
03251       --mxmsg;
03252       MAXMSG("NuAnalysis",Msg::kInfo,10)
03253         <<"ExtractConfig: after SetSpill & UseDatabaseCuts:"<<endl;
03254       // only after doing SelectSpill() can we print the state
03255       bmsa.Print();
03256       cout<<endl;
03257     }
03258 
03259     //check if a good spill
03260     if ( ! isgoodspill ) {
03261       Double_t xmean=0;
03262       Double_t ymean=0;
03263       Double_t xrms=0;
03264       Double_t yrms=0;
03265       spill.BpmAtTarget(xmean,ymean,xrms,yrms);
03266       Int_t targetIn=spill.GetStatusBits().target_in;
03267       
03268       MAXMSG("NuExtraction",Msg::kWarning, 20)
03269       << "ExtractConfig: BAD SPILL:" << endl
03270       << " > Time diffrence (s):             " << ntpBD.GetHeader().GetTimeDiffStreamSpill() << endl
03271       << " > Spill intensity (1e12 pot):     " << ntpBD.trtgtd << endl
03272       << " > Horn Current (kA):              " << ntpBD.horncur << endl
03273       << " > Target in/out:                  " << targetIn << endl
03274       << " > fBeamType:                      " << BeamType::AsString(spill.BeamType()) <<" ("<<spill.BeamType()<<")"<<endl
03275       << " > Horizontal beam position (mm):  " << xmean << endl
03276       << " > Vertical beam position (mm):    " << ymean << endl
03277       << " > Horizontal beam width a (mm):   " << ntpBD.bwidx << endl
03278       << " > Vertical beam width a (mm):     " << ntpBD.bwidy << endl;
03279       MAXMSG("NuBeam",Msg::kWarning, 20)
03280         <<endl<<endl
03281         <<"Occasionally the first spill is bad so have to skip to next"
03282         <<" snarl in order to ExtractConfig... return..."
03283         <<endl<<endl<<endl;
03284       return false;
03285     }
03286 
03287     //get the beam type directly from the BeamMomSpill
03288     //the time of various data taking is hard coded
03289     //so you can differentiate le000 from le010 and le150 from le100
03290     config.beamType=spill.BeamType();
03291       
03292     //get the horn current
03293     config.hornCurrent=ntpBD.horncur;
03294       
03295     string btAsString=BeamType::AsString
03296       (static_cast<BeamType::BeamType_t>(config.beamType));
03297     //L000z200i
03298     config.sTargetPos=btAsString.substr(1,3);
03299     config.targetPos=-1.*atoi(config.sTargetPos.c_str());
03300     config.sHornCurrent=btAsString.substr(5,3);
03301     if (BeamType::kL010z185i_rev == static_cast<BeamType::BeamType_t>(config.beamType)){
03302       config.sHornCurrent += "R";
03303     }
03304       
03305     //create the std MC naming scheme name
03306     const VldTimeStamp startNOvA(2013,6,1,0/*hr*/,0/*min*/,0/*sec*/,0/*ns*/);
03307     if(config.timeSec < (double)startNOvA){
03308     config.sBeamType="L"+config.sTargetPos+config.sHornCurrent;
03309     }
03310     if(config.timeSec >= (double)startNOvA){
03311     config.sBeamType="M"+config.sTargetPos+config.sHornCurrent;
03312     }    
03313 
03314     //the beammonspill beamType is not the same as the Conventions one
03315     //these are the beammonspill ones:
03316     //0=unknown,1=LE,2=ME,3=HE,4=psME,5=psHE mask=0x1c. LE-10 is LE.
03317     config.beamTypeSntp=spill.GetStatusBits().beam_type;      
03318   }
03320   //check if MC
03322   else if (ntp.GetVldContext()->GetSimFlag()==SimFlag::kMC){  
03323     MSG("NuAnalysis",Msg::kInfo)
03324       <<"ExtractConfig: running on MC..."<<endl;
03325     //get the filename
03326     TString sFileName="n13021160_0000_L010185.sntp.R1_18_2.root";
03327     //check if the ntp was from mom or directly accessed
03328     if (this->GetNtpStRecord()) {//direct
03329       sFileName=this->GetFirstFileName().c_str();
03330     }
03331     else {//mom
03332       sFileName=this->GetInputFileName().c_str();
03333     }
03334     
03335     Int_t lastSlash=sFileName.Last('/');
03336     sFileName.Remove(0,lastSlash+1);
03337     MAXMSG("NuAnalysis",Msg::kInfo,5)
03338       <<"Extracting MC beam info from run filename="<<sFileName<<endl;
03339 
03340     // Known filename types
03341     // Cedar-n13010100_0000_L010185_PDtest03.root
03342     // n13021160_0000_L010185.sntp.R1_18_2.root
03343     // n11011020_0000_L010185N_D00.sntp.cedar_phy.root
03344     // n13037038_0027_L250200N_D04_i194.sntp.dogwood1.root
03345     // n13035001_0003_L150200N_D07_r2.sntp.dogwood1.root
03346     // n13047001_0000_L010185R_D04.sntp.dogwood1.0.root
03347     // n13037001_0000_L010185N_D04.reroot.root
03348     // n13037009_0029_L010185N_D04_charm.reroot.root
03349     // n13035001_0000_L010170N_D07_r1.reroot.root
03350     // n13035001_0000_L010185N_D07_r1i999.reroot.root
03351     
03352     TRegexp rbeam      = "^[LMH][0-9][0-9][0-9][0-9][0-9][0-9][RN]?$";
03353     TRegexp rmc        = "^D[0-9]+$";
03354     TRegexp rboth      = "^r[1-9]i[0-9]+$";
03355     TRegexp r11altint      = "^r[0-9][0-9]i[0-9]+$";
03356     TRegexp r11syst      = "^r[0-9][0-9]syst$";
03357     TRegexp rintensity = "^i[0-9]+$";
03358     TRegexp rrun       = "^r[0-9]+$";
03359     TRegexp rrunfluka08  = "^r[0-9]fluka08+$";
03360     TRegexp rrunfluka11  = "^r[0-9]fluka11+$";
03361     
03362     //check for preDiakon name
03363     sFileName.ReplaceAll("Cedar-","");
03364     
03365     TObjArray* part1 = sFileName.Tokenize(".");
03366     TString info = ((TObjString*)part1->At(0))->GetString();
03367     TObjArray* part2 = info.Tokenize("_");
03368     
03369     config.sTargetPos = "010";
03370     config.sHornCurrent = "185";
03371     config.runPeriod = 0; // Unspecified Period
03372     config.intensity = 0; // Average intensity
03373     config.hornIsReverse = false;
03374     int dver = 0; // Daikon version
03375     
03376     Bool_t novaFlag = false;
03377     for (int j = 0; j < part2->GetEntries(); j++) {
03378       TString temp = ((TObjString*)part2->At(j))->GetString();
03379 
03380       // Look for Beam type ex. L010185N
03381       if (temp.Contains(rbeam)) {
03382         config.sBeamType = temp;
03383         config.sTargetPos   = (temp(1,3)+"").Data();
03384         config.sHornCurrent = (temp(4,3)+"").Data();
03385         if (temp.EndsWith("R")) {
03386           config.hornIsReverse = true;
03387         }
03388         MAXMSG("NuAnalysis",Msg::kInfo,1) << "Found beam " << temp << " in name" << endl;
03389         
03390       }
03391       // Run Period + Intensity rNiXYZ
03392       else if (temp.Contains(rboth)) {
03393         TString tempR = temp(1,1);
03394         config.runPeriod = tempR.Atoi();
03395         TString tempI = temp(3,3);
03396         config.intensity = tempI.Atoi();
03397         MAXMSG("NuAnalysis",Msg::kInfo,1) << "Found run and intensity " << temp << " in name" << endl;
03398       }
03399        else if (temp.Contains(r11altint)) {
03400          TString tempR = temp(1,2);
03401          config.runPeriod = tempR.Atoi();
03402          TString tempI = temp(4,3);
03403          config.intensity = tempI.Atoi();
03404         // Found run and intensity r11i090 in name
03405         MAXMSG("NuAnalysis",Msg::kInfo,1) << "Found run and intensity " << temp << " in name" << endl;
03406        }
03407        else if (temp.Contains(r11syst)) {
03408          TString tempR = temp(1,2);
03409          config.runPeriod = tempR.Atoi();
03410         //TString tempI = temp(4,3);
03411          //config.intensity = tempI.Atoi();
03412         // Found run and intensity r11i090 in name
03413         MAXMSG("NuAnalysis",Msg::kInfo,1) << "Found run and intensity " << temp << " in name" << endl;
03414        }
03415       // Look for Run Period ex. rN
03416       else if (temp.Contains(rrun)|| temp.Contains(rrunfluka08) || temp.Contains(rrunfluka11)) {
03417         temp.Remove(0,1);
03418         config.runPeriod = temp.Atoi();
03419         MAXMSG("NuAnalysis",Msg::kInfo,1) << "Found run " << temp << " in name" << endl;
03420       }              
03421       // Look for intensity ex. iXYZ
03422       else if (temp.Contains(rintensity)) {
03423         temp.Remove(0,1);
03424         config.intensity = temp.Atoi();
03425         MAXMSG("NuAnalysis",Msg::kInfo,1) << "Found intensity " << temp << " in name" << endl;
03426       }              
03427       // Look for Daikon version - not needed
03428       else if (temp.Contains(rmc)) {
03429         temp.Remove(0,1);
03430         dver = temp.Atoi();
03431         MAXMSG("NuAnalysis",Msg::kInfo,1) << "Found Daikon v. " << temp << " in name" << endl;
03432       }
03433       // Is this Nova running?
03434       else if (temp.Contains("NOVA",TString::kIgnoreCase)){
03435         novaFlag = true;
03436       }
03437       else if (temp.Contains("r11",TString::kIgnoreCase)){
03438         novaFlag = true;
03439       }
03440       // Look for intensity - not needed
03441     }
03442     delete part2;
03443     delete part1;
03444     if (novaFlag){
03445       TString newBeamType = config.sBeamType;
03446       newBeamType.Append("_NOVA");
03447       config.sBeamType = newBeamType;
03448       config.runPeriod = 11;
03449     }
03450        
03451     if (config.runPeriod>10){
03452       TString newBeamType = config.sBeamType;
03453       newBeamType.Append("_NOVA");
03454       config.sBeamType = newBeamType;
03455     }
03456 
03457     config.targetPos=-1.*atoi(config.sTargetPos.c_str());
03458     config.hornCurrent=-1.*atoi(config.sHornCurrent.c_str());
03459     
03460     if (config.hornIsReverse) config.hornCurrent *= -1;
03461 
03462     if (10 == config.runPeriod){
03463       if (0 != config.intensity){
03464         cout << "Found run 10 MC with a non-zero intensity in the filename. This shouldn't be possible."
03465              << endl;
03466         assert(false);
03467       }
03468       config.intensity = 361;
03469     }
03470     
03471     if (dver >= 7) {
03472       if (config.runPeriod <= 0) {
03473         if (!novaFlag){
03474           MAXMSG("NuAnalysis",Msg::kWarning,5)
03475             << "Found Daikon07 (or more recent) MC which has no run period"
03476             << "and isn't NOvA beam! "
03477             <<config.runPeriod 
03478             << endl;
03479           assert(0);
03480         }
03481         else{
03482           if (10 != dver){
03483             MAXMSG("NuAnalysis",Msg::kWarning,5)
03484               << "Found NOvA beam which isn't Daikon10. Asserting now."
03485               << endl;
03486             assert(0);
03487           }
03488         }
03489       }
03490       if (config.runPeriod == 4 && (!config.hornIsReverse)) {
03491         MAXMSG("NuAnalysis",Msg::kWarning,5) << "Daikon07 Run4 found with forward field" << endl;
03492       }
03493       if (config.runPeriod == 7 && (!config.hornIsReverse)) {
03494         MAXMSG("NuAnalysis",Msg::kWarning,5) << "Daikon07 Run7 found with forward field" << endl;
03495       }
03496       if (config.runPeriod == 9 && (!config.hornIsReverse)) {
03497         MAXMSG("NuAnalysis",Msg::kWarning,5) << "Daikon07 Run9 found with forward field" << endl;
03498       }
03499     }
03500     
03501     MAXMSG("NuAnalysis",Msg::kInfo,5)
03502         <<"Extracted from the filename: sTargetPos="<<config.sTargetPos
03503         <<", targetPos="<< config.targetPos
03504         <<", sHornCurrent="<<config.sHornCurrent
03505         <<", hornCurrent="<<config.hornCurrent
03506         <<", runPeriod="<<config.runPeriod
03507         <<", mcVersion="<<config.mcVersion
03508         <<", intensity="<<config.intensity
03509         <<", hornIsReverse="<<config.hornIsReverse
03510         << endl;
03511 
03512     //get the beam type based on the info config already holds
03513     this->DetermineBeamType(config);
03514   }
03515   
03516   // Extract run period for data from VldContext
03517   if (ntp.GetVldContext()->GetSimFlag()==SimFlag::kData){
03518     VldTimeStamp ts = ntp.GetVldContext()->GetTimeStamp();
03519     
03520     if     (ts.GetSeconds() < NuUtilities::vtsRunIEnd.GetSeconds()) config.runPeriod = 1;
03521     else if(ts.GetSeconds() < NuUtilities::vtsRunIIEnd.GetSeconds()) config.runPeriod = 2;
03522     else if(ts.GetSeconds() < NuUtilities::vtsRunIIIEnd.GetSeconds()) config.runPeriod = 3;
03523     else if(ts.GetSeconds() < NuUtilities::vtsRunIVEnd.GetSeconds()) config.runPeriod = 4;
03524     else if(ts.GetSeconds() < NuUtilities::vtsRunVEnd.GetSeconds()) config.runPeriod = 5;
03525     else if(ts.GetSeconds() < NuUtilities::vtsRunVIEnd.GetSeconds()) config.runPeriod = 6;
03526     else if(ts.GetSeconds() < NuUtilities::vtsRunVIIEnd.GetSeconds()) config.runPeriod = 7;
03527     else if(ts.GetSeconds() < NuUtilities::vtsRunVIIIEnd.GetSeconds()) config.runPeriod = 8;
03528     else if(ts.GetSeconds() < NuUtilities::vtsRunIXEnd.GetSeconds()) config.runPeriod = 9;
03529     else if(ts.GetSeconds() < NuUtilities::vtsRunXEnd.GetSeconds()) config.runPeriod = 10;
03530     else config.runPeriod = 11;
03531     
03532     // Check for RHC
03533     if (BeamMonSpill::IsRHCRunning(ts)){
03534       MAXMSG("NuAnalysis",Msg::kInfo, 10) 
03535       << "Found RHC date: " << ts.AsString() << endl;
03536       config.hornIsReverse = true;
03537       config.hornCurrent *= -1;
03538     }
03539     else {
03540       MAXMSG("NuAnalysis",Msg::kInfo, 10) 
03541       << "Found FHC date: " << ts.AsString() << endl;
03542       config.hornIsReverse = false;
03543     }    
03544   }
03545   
03546   if (config.runPeriod == 4 && (!config.hornIsReverse)) {
03547     MAXMSG("NuAnalysis",Msg::kWarning,20) << "Run4 found with forward field.  This may be ok." << endl;
03548   }
03549   if (config.runPeriod == 7 && (!config.hornIsReverse)) {
03550     MAXMSG("NuAnalysis",Msg::kWarning,20) << "Run7 found with forward field.  This may be ok." << endl;
03551   }
03552   if (config.runPeriod == 9 && (!config.hornIsReverse)) {
03553     MAXMSG("NuAnalysis",Msg::kWarning,20) << "Run9 found with forward field.  This may be ok." << endl;
03554   }
03555   
03556 
03557   MSG("NuAnalysis",Msg::kInfo)
03558     <<"ExtractConfig: final config is beamType="
03559     <<BeamType::AsString(static_cast<BeamType::BeamType_t>
03560                          (config.beamType))
03561     <<" ("<<config.beamType<<")"
03562     <<", btSntp="<<config.beamTypeSntp
03563     <<endl
03564     <<"               sHornCurrent="<<config.sHornCurrent
03565     <<" ("<<config.hornCurrent<<")"
03566     <<", sTargetPos="<<config.sTargetPos
03567     <<" ("<<config.targetPos<<")"
03568     <<", sBeamType="<<config.sBeamType
03569     <<", runPeriod="<<config.runPeriod
03570     <<endl;
03571 
03572   //the beamTypeSntp is only present for data when it is
03573   //obtained from the ntuples
03574   //so only print for data
03575   //if (ntp.GetVldContext().GetSimFlag()==SimFlag::kData){
03576   //MAXMSG("NuAnalysis",Msg::kInfo,5)
03577   //<<"Converting beamTypeSntp to New Conventions gives "
03578   //<<BeamType::AsString(static_cast<BeamType::BeamType_t>
03579   //                 (BeamType::
03580   //                  FromBeamMon(config.beamTypeSntp)))
03581   //<<" ("<<BeamType::FromBeamMon(config.beamTypeSntp)<<")"
03582   //<<endl
03583   //<<"  FromZarko="<<BeamType::FromZarko(config.beamType)
03584   //<<endl
03586   //<<endl;
03587   //}
03588   return true;
03589 }

void NuAnalysis::ExtractConfig ( NuConfig config  )  [private]

this is here for backwards compatibility

Definition at line 3115 of file NuAnalysis.cxx.

References NuBase::GetNtpBDLiteRecord(), and NuBase::GetNtpStRecord().

Referenced by ChargeSeparationOneSnarl(), ChargeSignCut(), Efficiencies(), EnergySpect(), EnergySpectMC(), LIRejectionTest(), MakeFullDST(), N_1(), and NuMuBarAppearance().

03116 {
03118 
03119   this->ExtractConfig(this->GetNtpStRecord(),
03120                       this->GetNtpBDLiteRecord(),config);
03121 }

void NuAnalysis::ExtractPIDsAndWeights ( const NtpStRecord ntp,
const NtpSREvent evt,
NuPIDInterface pid,
NuEvent nu 
) const

Definition at line 6650 of file NuAnalysis.cxx.

References NuReco::ApplyReweights(), NuEvent::beamType, NuZBeamReweight::CalcGeneratorReweight(), NuEvent::calcJmID, NuEvent::calcRoID, NuLibrary::ext, NuExtraction::ExtractMajorityCurvature(), NuZBeamReweight::ExtractZBeamReweight(), NuPIDInterface::GetAbID(), NuPIDInterface::GetDpID(), NuPIDInterface::GetJmID(), NuPIDInterface::GetRoID(), NuPIDInterface::GetRoIDNuMuBar(), NuPIDInterface::GetRoIDPlus(), NuLibrary::Instance(), BeamType::kM000z200i_nova, NuLibrary::reco, and NuLibrary::zBeamReweight.

Referenced by DoExtractions().

06654 {
06655   //get an instance of the code library
06656   const NuLibrary& lib=NuLibrary::Instance();
06657   
06658   //do the reweighting
06659   lib.zBeamReweight.ExtractZBeamReweight(nu);
06660   lib.zBeamReweight.CalcGeneratorReweight(ntp,evt,nu);
06661   lib.reco.ApplyReweights(nu);
06662 
06663   //calculate PIDs
06664   pid.GetDpID(ntp,evt,nu);
06665   pid.GetAbID(ntp,evt,nu);
06666   if (nu.calcRoID) pid.GetRoID(ntp,evt,nu);//gets muon and nubar pid
06667   else pid.GetRoIDNuMuBar(ntp,evt,nu);//just gets nubar pid
06668 
06669   if(nu.calcJmID) pid.GetJmID(ntp,evt,nu);
06670 
06671   // junting@physics.utexas.edu
06672   if(nu.beamType == BeamType::kM000z200i_nova)
06673     pid.GetRoIDPlus(nu);
06674 
06675   // PoID Officially depracated
06676   //pid.GetPoID(nu);
06677   lib.ext.ExtractMajorityCurvature(ntp,evt,nu);
06678 }

void NuAnalysis::LIRejectionTest (  ) 

Definition at line 5955 of file NuAnalysis.cxx.

References NuEvent::abID, NuEvent::anaVersion, NuConfig::anaVersion, NuReco::ApplyReweights(), NuCuts::AsString(), NuCounter::badSpillCounter, NuEvent::charge, CopyConfig(), NuEvent::dirCosNu, NuEvent::dpID, NuEvent::entry, NtpStRecord::evt, NuCounter::evtCounter, NtpStRecord::evthdr, NuCounter::evtNotIsLI, NuCounter::evtNotlitime, NuCounter::evtWithTrkCounter, NuLibrary::ext, ExtractConfig(), NuExtraction::ExtractDataQuality(), NuExtraction::ExtractEvtInfo(), NuExtraction::ExtractGeneralInfo(), NuExtraction::ExtractMinMaxEvtTimes(), NuExtraction::ExtractShwInfo(), NuExtraction::ExtractTimeToNearestSpill(), NuExtraction::ExtractTrkInfo(), NuZBeamReweight::ExtractZBeamReweight(), NuReco::FDRCBoundary(), NuPlots::FillContainmentHistos(), NuPlots::FillDPIdSigmaQPFailDpIDCutPlots(), NuPlots::FillDPIdSigmaQPFailProbCutPlots(), NuPlots::FillDPIdSigmaQPFailSigQPCutPlots(), NuPlots::FillDPIdSigmaQPPassDpIDCutPlots(), NuPlots::FillDPIdSigmaQPPassSigQPCutPlots(), NuPlots::FillDPIdSigmaQPPlotsN(), NuPlots::FillEnergyBinHistos(), NuPlots::FillGeneralHistos(), NuPlots::FillKinematicsHistos(), NuPlots::FillRangeCurvCompHistos(), NuPlots::FillRecoEnYHistosN(), NuPlots::FillShwHistos(), NuTime::FillTime(), NuPlots::FillTrueFidEnergySpect(), NuPlots::FillTruePIDHistos(), NuPlots::FillXYZHistos(), NuBase::fOutFile, NuPIDInterface::GetAbID(), VldContext::GetDetector(), NuPIDInterface::GetDpID(), NuBase::GetEntries(), NuReco::GetEvtEnergy(), RecRecordImp< T >::GetHeader(), NuBase::GetNtpBDLiteRecord(), NuBase::GetNtpStRecord(), RecDataHeader::GetRun(), VldTimeStamp::GetSec(), VldContext::GetSimFlag(), RecPhysicsHeader::GetSnarl(), RecDataHeader::GetSubRun(), VldContext::GetTimeStamp(), NuReco::GetTruthInfo(), RecHeader::GetVldContext(), NuCounter::goodDataQualityCounter, NuCounter::goodDirectionCosineCounter, NuCounter::goodFitProbCounter, NuCounter::goodFitSigQPCounter, NuCounter::goodPIDCounter, NuCounter::goodRecoEnCounter, NuCounter::goodSpillCounter, NuCounter::goodTimeToNearestSpillCounter, NuCounter::goodTrkPassCounter, NuBase::InitialiseLoopVariables(), NuLibrary::Instance(), NuCuts::IsGoodDataQuality(), NuCuts::IsGoodDirCos(), NuCuts::IsGoodFitProb(), NuCuts::IsGoodNumberOfTracks(), NuCuts::IsGoodPID(), NuCuts::IsGoodSigmaQP_QP(), NuBeam::IsGoodSpillAndFillPot(), NuCuts::IsGoodTimeToNearestSpill(), NuCuts::IsGoodTrackFitPass(), NuCuts::IsInFidVolTrk(), LISieve::IsLI(), NuCuts::kCC0250Std, ReleaseType::kDaikon, ReleaseType::kData, Msg::kInfo, SKZPWeightCalculator::kPiMinus, NtpSREventSummary::litime, MAXMSG, NuConfig::mcVersion, NuEvent::mcVersion, Munits::microsecond, MSG, NuEvent::nshw, NuCounter::nuNQCounter, NuCounter::nuPQCounter, NuBase::OpenFile(), NuBase::OpenTxtFile(), NuEvent::planeEvtBeg, NuEvent::planeEvtEnd, plots(), NuEvent::poID, NuEvent::pot, NuPlots::PrintEventInfo(), NuCounter::PrintNMB(), NuUtilities::PrintRelease(), NuEvent::rawPhEvt, NuConfig::recoVersion, NuEvent::recoVersion, NuConfig::reweightVersion, NuEvent::roID, NuEvent::roIDNuMuBar, NuConfig::run, NuConfig::sBeamType, NuBase::SetLoopVariables(), NuEvent::timeEvtMin, NuEvent::timeToNearestSpill, NuCounter::totalPot, NuCounter::totalPotBad, NuCounter::trkInFidVolCounter, NuEvent::trkvtxdcosz, and NuConfig::useGeneratorReweight.

05956 {
05957   MSG("NuAnalysis",Msg::kInfo) 
05958     <<" ** Running LIRejectionTest method... **"<<endl;
05959   
05960   NuConfig config;
05961   this->ExtractConfig(config);
05962 
05963   //open the output file for the histograms
05964   string sFilePrefix="LIRejectionTest"+config.sBeamType;
05965   fOutFile=this->OpenFile(config,sFilePrefix.c_str());
05966   
05967   string sTxt="litag"+config.sBeamType;
05968   ofstream& litagTxt=*(this->OpenTxtFile(config,sTxt.c_str()));
05969   sTxt="liSieve"+config.sBeamType;
05970   ofstream& liSieveTxt=*(this->OpenTxtFile(config,sTxt.c_str()));
05971   
05972   //classes to organise the code in to related functions
05973   const NuCuts cuts;
05974   const NuGeneral general;
05975   const NuPlots plots;
05976   const NuReco reco;
05977   const NuExtraction ext;
05978   const NuBeam beam;
05979 
05980   //classes to count numbers of events, etc and times of spills, etc
05981   NuCounter cnt;
05982   NuTime time;
05983 
05984   //interface for the pids
05985   NuPIDInterface pid;
05986   
05987   //create an object to do the beam reweighting
05988   const NuZBeamReweight zBeamReweight;
05989 
05990   config.anaVersion=NuCuts::kCC0250Std;
05991   config.useGeneratorReweight=false;
05992   config.reweightVersion=SKZPWeightCalculator::kPiMinus;
05993   Int_t mcVersionOveride=ReleaseType::kDaikon;//selects pdfs for data
05994 
05995   MSG("NuAnalysis",Msg::kInfo)
05996     <<"Setting:"<<endl
05997     <<"  anaVersion="
05998     <<cuts.AsString(static_cast<NuCuts::NuAnaVersion_t>
05999                     (config.anaVersion))
06000     <<" ("<<config.anaVersion<<")"<<endl
06001     <<"  useGeneratorReweight="<<config.useGeneratorReweight<<endl
06002     <<"  reweightVersion="<<config.reweightVersion<<endl;
06003   
06004   //if MC then the mcVersion will be determined from the file
06005   //override the version to use here (only gets set in the data case)
06006   if (config.mcVersion==ReleaseType::kData) {
06007     MSG("NuAnalysis",Msg::kInfo)
06008       <<"Overiding mcVersion:"<<endl
06009       <<"  new mcVersion="<< NuUtilities::PrintRelease(mcVersionOveride)
06010       <<", old mcVersion="<< NuUtilities::PrintRelease(config.mcVersion)
06011       <<endl;
06012     config.mcVersion=mcVersionOveride;
06013   }
06014  
06015   //get an instance of the code library
06016   const NuLibrary& lib=NuLibrary::Instance();
06017  
06021   
06022   this->InitialiseLoopVariables();  
06023   
06024   //for(Int_t entry=0;entry<10000;entry++){
06025   for(Int_t entry=0;entry<this->GetEntries();entry++){
06026       
06027     this->SetLoopVariables(entry);
06028       
06029     //get reference to NtpStRecord from base class
06030     const NtpStRecord& ntp=(*this->GetNtpStRecord());
06031 
06032     const RecCandHeader& rec=ntp.GetHeader();
06033     MAXMSG("NuAnalysis",Msg::kInfo,5)
06034       <<"Found: run="<<rec.GetRun()
06035       <<", subrun="<<rec.GetSubRun()
06036       <<", detector="<<rec.GetVldContext().GetDetector()
06037       <<", simFlag="<<rec.GetVldContext().GetSimFlag()
06038       <<", snarl="<<rec.GetSnarl()
06039       <<endl;
06040     
06041     //write out the detector, simflag, etc
06042     plots.FillGeneralHistos(ntp);
06043 
06044     //simple event object to hold important quantities for snarl
06045     NuEvent nuSnarl;
06046     nuSnarl.anaVersion=config.anaVersion;
06047     nuSnarl.mcVersion=config.mcVersion;
06048     nuSnarl.recoVersion=config.recoVersion;
06049     ext.ExtractGeneralInfo(ntp,nuSnarl);
06050 
06051     //get the true energy spectra of events in the fid vol
06052     plots.FillTrueFidEnergySpect(nuSnarl);
06053     
06054     Int_t evTime=rec.GetVldContext().GetTimeStamp().GetSec();
06055     Bool_t goodSpill=beam.IsGoodSpillAndFillPot
06056       (this->GetNtpBDLiteRecord(),config,nuSnarl);
06057     time.FillTime(evTime,nuSnarl.pot,goodSpill);
06058     if (!goodSpill) {
06059       cnt.badSpillCounter++;
06060       cnt.totalPotBad+=nuSnarl.pot;
06061       continue;
06062     }
06063     cnt.goodSpillCounter++;
06064     cnt.totalPot+=nuSnarl.pot;    
06065     
06066     TClonesArray& evtTca=(*ntp.evt);
06067     const Int_t numEvts=evtTca.GetEntriesFast();
06068 
06070     //loop over the reconstructed events
06072     for (Int_t ievt=0;ievt<numEvts;ievt++){
06073       const NtpSREvent& evt=
06074         *dynamic_cast<NtpSREvent*>(evtTca[ievt]);
06075       cnt.evtCounter++;
06076       
06077       MAXMSG("NuAnalysis",Msg::kInfo,5)
06078         <<"Found event, "<<ievt+1<<"/"<<numEvts<<endl;
06079 
06080       const NtpSREventSummary& evthdr=ntp.evthdr;
06081       
06082       if (evthdr.litime!=-1) {
06083         MAXMSG("NuAnalysis",Msg::kInfo,500)
06084           <<"skipping event: litime="<<evthdr.litime<<endl;
06085         continue;
06086       }
06087       cnt.evtNotlitime++;
06088 
06089       Bool_t isLI=LISieve::IsLI(ntp);
06090       if (isLI){
06091         MAXMSG("NuAnalysis",Msg::kInfo,5)
06092           <<endl<<endl<<endl
06093           <<"Found LI"
06094           <<", run="<<config.run
06095           <<", entry="<<entry
06096           <<", event="<<ievt
06097           <<", litime="<<evthdr.litime
06098           <<endl<<endl<<endl;
06099       }
06100       else {
06101         MAXMSG("NuAnalysis",Msg::kInfo,50)
06102           <<"Not LI"
06103           <<", run="<<config.run
06104           <<", entry="<<entry
06105           <<", event="<<ievt
06106           <<", litime="<<evthdr.litime
06107           <<endl;
06108       }
06109       //if (isLI) continue;
06110       if (!isLI) cnt.evtNotIsLI++;
06111       
06112       //simple event object to hold important quantities
06113       NuEvent nu;
06114       nu.entry=entry;//store the entry in the tree number
06115       this->CopyConfig(config,nu);
06116       
06117       //get the run, snarl, etc info
06118       ext.ExtractGeneralInfo(ntp,nu);
06119       //get info from the evt
06120       lib.ext.ExtractEvtInfo(evt,nu);
06121       //extract trk info (needed to get best track info)
06122       lib.ext.ExtractTrkInfo(ntp,evt,nu);
06123       //extract shw info
06124       lib.ext.ExtractShwInfo(ntp,evt,nu);
06125 
06126       //CC LI cut
06127       Int_t litag=reco.FDRCBoundary(nu);
06128       if (litag) {
06129         MAXMSG("NuAnalysis",Msg::kInfo,50)
06130           <<endl<<endl
06131           <<"litag="<<litag
06132           <<", run="<<config.run
06133           <<", entry="<<entry
06134           <<", event="<<ievt
06135           <<", litime="<<evthdr.litime
06136           <<endl
06137           <<", nu.nshw="<<nu.nshw
06138           <<", nu.rawPhEvt="<<nu.rawPhEvt
06139           <<", nu.planeEvtBeg="<<nu.planeEvtBeg
06140           <<", nu.planeEvtEnd="<<nu.planeEvtEnd
06141           <<endl<<endl<<endl;
06142       }
06143       if (litag>10) {
06144         MAXMSG("NuAnalysis",Msg::kInfo,50)
06145           <<endl<<endl
06146           <<"litag="<<litag
06147           <<", run="<<config.run
06148           <<", entry="<<entry
06149           <<", event="<<ievt
06150           <<", litime="<<evthdr.litime
06151           <<endl
06152           <<", nu.nshw="<<nu.nshw
06153           <<", nu.rawPhEvt="<<nu.rawPhEvt
06154           <<", nu.planeEvtBeg="<<nu.planeEvtBeg
06155           <<", nu.planeEvtEnd="<<nu.planeEvtEnd
06156           <<endl<<endl<<endl;
06157       }
06158 
06159       //only continue if event is not either litag or isLI
06160       if (!(litag || isLI)) continue;
06161       
06162       //extract trk/shw info (put this after ExtractEvtInfo to save cpu)
06163       reco.GetEvtEnergy(nu, false);
06164       cnt.goodRecoEnCounter++;
06165       
06166       //calculate PIDs
06167       pid.GetDpID(ntp,evt,nu);
06168       pid.GetAbID(ntp,evt,nu);
06169 
06170       MAXMSG("NuAnalysis",Msg::kInfo,10)
06171         <<"After reco:"<<endl;
06172       MAXMSG("NuAnalysis",Msg::kInfo,10)
06173         <<endl<<plots.PrintEventInfo(cout,nu)<<endl;
06174       
06175       //get the truth info (reco quantities are done above)
06176       reco.GetTruthInfo(ntp,evt,nu);
06177 
06178       if (litag) plots.PrintEventInfo(litagTxt,nu);
06179       if (isLI) plots.PrintEventInfo(liSieveTxt,nu);
06180 
06181       //hardly any of these
06182       if (isLI) continue;
06183 
06184       //ensure good number of tracks in the event
06185       if (!cuts.IsGoodNumberOfTracks(nu)) continue;
06186       cnt.evtWithTrkCounter++;
06187 
06188       //do the beam reweighting
06189       zBeamReweight.ExtractZBeamReweight(ntp,evt,nu);
06190       reco.ApplyReweights(nu);
06191 
06192       MAXMSG("NuAnalysis",Msg::kInfo,10)
06193         <<"PID: dp="<<nu.dpID<<", ab="<<nu.abID
06194         <<", ro="<<nu.roID<<", po="<<nu.poID
06195         <<", roNMB="<<nu.roIDNuMuBar<<endl;
06196       
06197       //check if the trk is in the fiducial volume
06198       if (!cuts.IsInFidVolTrk(nu)) continue;
06199       cnt.trkInFidVolCounter++;
06200       
06201       //require a good trk fit
06202       if (!cuts.IsGoodTrackFitPass(nu)) continue;
06203       cnt.goodTrkPassCounter++;
06204       
06205       if (!cuts.IsGoodDirCos(nu)) {
06206         MAXMSG("NuAnalysis",Msg::kInfo,50)
06207           <<"Bad DirCos, trkvtxdcosz="<<nu.trkvtxdcosz
06208           <<", dirCosNu="<<nu.dirCosNu<<endl;
06209         continue;
06210       }
06211       cnt.goodDirectionCosineCounter++;
06212 
06213       //check data quality
06214       ext.ExtractDataQuality(nu);//lots of db access
06215       if (!cuts.IsGoodDataQuality(nu)) continue;
06216       cnt.goodDataQualityCounter++;
06217 
06218       //check timing
06219       ext.ExtractMinMaxEvtTimes(ntp,evt,nu);
06220       ext.ExtractTimeToNearestSpill(nu);//lots of db access
06221       MAXMSG("NuAnalysis",Msg::kInfo,1000)
06222         <<"Time to spill="
06223         <<(nu.timeEvtMin-nu.timeToNearestSpill)/(Munits::microsecond)
06224         <<" us"<<endl;
06225       if (!cuts.IsGoodTimeToNearestSpill(nu)) continue;
06226       cnt.goodTimeToNearestSpillCounter++;
06227       
06228       //cut on the PID
06229       if (!cuts.IsGoodPID(nu)) {
06230         plots.FillDPIdSigmaQPFailDpIDCutPlots(nu);
06231         continue;
06232       }
06233       cnt.goodPIDCounter++;      
06234       plots.FillDPIdSigmaQPPassDpIDCutPlots(nu);
06235 
06236       //cut on the fractional track q/p error      
06237       if (!cuts.IsGoodSigmaQP_QP(nu)) {
06238         plots.FillDPIdSigmaQPFailSigQPCutPlots(nu);
06239         continue;
06240       }
06241       cnt.goodFitSigQPCounter++;
06242       plots.FillDPIdSigmaQPPassSigQPCutPlots(nu);
06243       
06244       //cut on the track fit probability      
06245       if (!cuts.IsGoodFitProb(nu)) {
06246         plots.FillDPIdSigmaQPFailProbCutPlots(nu);
06247         continue;
06248       }
06249       cnt.goodFitProbCounter++;
06250       
06251       if (nu.charge==-1) cnt.nuNQCounter++;
06252       else if (nu.charge==+1) cnt.nuPQCounter++;
06253       else cout<<"ahhh, bad charge (lirej)"<<endl;
06254       
06255       plots.FillRecoEnYHistosN(nu);
06256       plots.FillDPIdSigmaQPPlotsN(nu);
06257       plots.FillEnergyBinHistos(nu);
06258       
06259       plots.FillShwHistos(ntp,evt,nu);
06260       plots.FillXYZHistos(nu);
06261       plots.FillContainmentHistos(nu);
06262       plots.FillTruePIDHistos(nu);
06263       //plots.FillTrackResponseHistos(ntp,trk,nu);
06264       plots.FillRangeCurvCompHistos(nu);
06265       plots.FillKinematicsHistos(nu);
06266 
06267     }//end of loop over events
06268   }//end of for                                       
06269   
06273 
06274   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
06275 
06276   cnt.PrintNMB();
06277 
06278   MSG("NuAnalysis",Msg::kInfo) 
06279     <<" ** Finished LIRejectionTest method **"<<endl;
06280 }

void NuAnalysis::LoopOverTruthInfo ( const NtpStRecord ntp,
NuOutputWriter output,
const NuEvent nuSnarl,
const std::vector< Int_t >  vTthInd 
) const [private]

Definition at line 6331 of file NuAnalysis.cxx.

References NuEvent::anaVersion, NuReco::ApplyReweights(), changeRunPeriodTruth(), NuLibrary::cuts, NuEvent::detector, NuLibrary::ext, NuZBeamReweight::ExtractZBeamReweight(), NuOutputWriter::FillNuMCEventTree(), NuPlots::FillTrueFidEnergySpect(), NuOutputWriter::GetNuMCEventToFill(), NuReco::GetTruthInfo(), iAltRun, NuLibrary::Instance(), NuCuts::IsInFidVol(), NuCuts::IsInFidVolLoose(), it, Msg::kDebug, Msg::kInfo, Detector::kNear, Munits::m, MAXMSG, NtpStRecord::mc, NuEvent::mc, NuExtraction::NuMCEventFromNuEvent(), NuEvent::planeTrkVtxMC, plots(), NuLibrary::reco, NuEvent::releaseType, NuEvent::rTrkVtxMC, NuEvent::shwEn, NuEvent::shwEnMC, NuEvent::simFlag, NuEvent::trkEn, NuEvent::trkEnMC, NuEvent::vtxuMC, NuEvent::vtxvMC, NuEvent::vtxxMC, NuEvent::vtxyMC, NtpMCTruth::vtxz, NuEvent::vtxzMC, and NuLibrary::zBeamReweight.

Referenced by ChargeSeparationOneSnarl(), and MakeFullDST().

06335 {
06336   //vTthInd is the list of true events we must write out
06337   //e.g. it contributes to a reconstructed event
06338 
06339   TClonesArray& mcTca=(*ntp.mc);
06340   const Int_t nummcs=mcTca.GetEntriesFast();
06341   static NuPlots plots;
06342   if (nummcs<=0) {
06343     MAXMSG("NuAnalysis",Msg::kDebug,1)
06344       <<"LoopOverTruthInfo: no MCTruth so return..."<<endl;
06345     //call this routine so that the plots are created
06346     plots.FillTrueFidEnergySpect(nuSnarl);
06347     return;
06348   }
06349   
06350   //get an instance of the code library
06351   const NuLibrary& lib=NuLibrary::Instance();
06352   
06353   //loop over all the true neutrino interactions
06354   for (Int_t imc=0;imc<nummcs;++imc){
06355     const NtpMCTruth& mc=
06356       *(dynamic_cast<NtpMCTruth*>(mcTca[imc]));
06357     
06358     //Does this true event contribute to a reco event?
06359     Bool_t mustWriteOut = false;
06360     for (std::vector<Int_t>::const_iterator it = vTthInd.begin();
06361          it != vTthInd.end();
06362          ++it){
06363       if (*it == imc){
06364         mustWriteOut = true;
06365       }
06366     }
06367     
06368     if (!mustWriteOut){
06369       //remove events that happen outside the ND calorimeter
06370       //this should speed things up
06371       if (nuSnarl.detector==Detector::kNear &&
06372           (mc.vtxz<-0.1*(Munits::m) || mc.vtxz>7.3*(Munits::m))) {
06373         MAXMSG("NuAnalysis",Msg::kInfo,1)
06374           <<"Not looping over true events occuring in front or behind"
06375           <<" the ND calorimeter (-0.1<Z<7.3m)"
06376           <<" (this mc.vtxz="<<mc.vtxz<<")"<<endl;
06377         continue;
06378       }
06379     }
06380     
06381     //extract the info from this mc object
06382     //bit inefficient to do this for every true event... but safer
06383     NuEvent nu=nuSnarl;//copy to hold truth info and weights
06384     
06385     //need to set this for both GetTruthInfo and reweight
06386     nu.mc=imc;
06387     
06388     //now get the truth info (need nu.mc to be set)
06389     lib.reco.GetTruthInfo(ntp,mc,nu);
06390     
06391     //set the reconstructed variables to the true ones
06392     //so that the MCReweight is ok about it (might not be necessary)
06393     nu.shwEn=nu.shwEnMC;
06394     nu.trkEn=fabs(nu.trkEnMC);//fabs: charge is stored with the energy
06395     
06396     //get the beam weight
06397     lib.zBeamReweight.ExtractZBeamReweight(nu);
06398     lib.reco.ApplyReweights(nu);
06399     
06400     if (!mustWriteOut){
06401       //write out events in loose fid vol
06402       if (!lib.cuts.IsInFidVolLoose
06403           (nu.vtxxMC,nu.vtxyMC,nu.vtxzMC,nu.detector)) {
06404         continue;
06405       }
06406     }
06407     
06408     //get NuMCEvent to fill
06409     NuMCEvent& numc=output.GetNuMCEventToFill();
06410     lib.ext.NuMCEventFromNuEvent(nu,numc);
06411     //don't set the value of numc.mc here, since it is done above
06412     //in NuMCEventFromNuEvent(nu,numc): changed by JJH 2009/09/17
06413     //numc.mc=imc;//the index in the TClonesArray
06414     if(iAltRun!=0){
06415       this->changeRunPeriodTruth(numc); 
06416     }
06417     //fill the tree
06418     output.FillNuMCEventTree();
06419     
06420     //check if true event vtx is in fid vol
06421     //NOTE: event has to have already passed the loose fid vol cut
06422     //this works for analyses up to 2008/02 but newer cuts maybe diff.
06423     Bool_t isInFidVol=lib.cuts.IsInFidVol
06424       (nu.vtxxMC,nu.vtxyMC,nu.vtxzMC,
06425        nu.vtxuMC,nu.vtxvMC,
06426        nu.planeTrkVtxMC,nu.rTrkVtxMC,
06427        nu.detector,nu.anaVersion,nu.releaseType,nu.simFlag);
06428     if (!isInFidVol) continue;
06429     
06430     //fill the plots
06431     plots.FillTrueFidEnergySpect(nu);
06432   }
06433 }

void NuAnalysis::MakeFullDST ( const NtpStRecord pntp,
const NtpBDLiteRecord pntpBD,
const NtpFitSARecord pntpSA 
)

code to produce the NuDST ntuple this should be called once per snarl

Definition at line 7073 of file NuAnalysis.cxx.

References NuEvent::abID, NuCounter::badSpillCounter, NuConfig::beamType, changeRunPeriod(), NuEvent::charge, NuLibrary::cnt, NuEvent::coilIsOk, ContributingTrueEvents(), CopyConfig(), CopySnarlInfo(), NuLibrary::cuts, DoExtractions(), NuEvent::dpID, NuCounter::entry, NuEvent::entry, NtpStRecord::evt, NuCounter::evtCounter, NtpStRecord::evthdr, NuCounter::evtInFidVolCounter, NuCounter::evtNotlitime, NuLibrary::ext, NuExtraction::ExtractBasicInfo(), NuExtraction::ExtractBeamInfoDB(), NuExtraction::ExtractCoilInfo(), ExtractConfig(), NuExtraction::ExtractDataQuality(), NuExtraction::ExtractGeneralInfo(), NuExtraction::ExtractNCInfo(), NuPlots::FillCoilCurrentHistos(), NuPlots::FillGeneralHistos(), NuPlots::FillNtupleEarliestLatestTime(), NuOutputWriter::FillNuEventTree(), NuTime::FillTime(), VldContext::GetDetector(), NuReco::GetEvtEnergy(), RecRecordImp< T >::GetHeader(), NuOutputWriter::GetNuEventToFill(), VldContext::GetSimFlag(), RecPhysicsHeader::GetSnarl(), RecHeader::GetVldContext(), NuEvent::goodBeam, NuEvent::goodBeamSntp, NuCounter::goodCoilCurrentSpillCounter, NuCounter::goodSpillCounter, iAltRun, NuLibrary::Instance(), NuEvent::isGoodDataQuality, NuBeam::IsGoodSpillAndFillPot(), NuCuts::IsInFidVolLoose(), Msg::kDebug, Msg::kInfo, BeamType::kM000z000i_nova, BeamType::kM000z200i_nova, BeamType::kM000z200i_nova_rev, Msg::kWarning, NtpSREventSummary::litime, LoopOverTruthInfo(), MAXMSG, MSG, NuEvent::nevt, NtpSREvent::ntrack, NuEvent::ntrk, NuCounter::nuNoQCounter, NuCounter::nuNoTrkCounter, NuCounter::nuNQCounter, NuCounter::nuPQCounter, NuConfig::overrideBeamDataConfigExtraction, plots(), NuEvent::poID, NuEvent::pot, NuEvent::potDB, NuEvent::potListSinceLastEvtGood, NuEvent::potSinceLastEvt, NuEvent::potSinceLastEvtBad, NuEvent::potSinceLastEvtBadDB, NuEvent::potSinceLastEvtDB, NuEvent::potSinceLastEvtGood, NuEvent::potSinceLastEvtGoodDB, NuPlots::PrintEventInfo(), NuLibrary::reco, NuEvent::roID, NuEvent::roIDNuMuBar, NuConfig::sBeamType, SetAnaFlags(), NuOutputWriter::SetupFile(), StoreOrFinishTree(), NuEvent::timeSec, NuCounter::totalPot, NuCounter::totalPotBad, and NuEvent::useDBForDataQuality.

Referenced by NuModule::Ana().

07076 {
07079 
07080   //get an instance of the code library
07081   NuLibrary& lib=NuLibrary::Instance();
07082   
07083   //increment ntuple entry (snarl) counter 
07084   lib.cnt.entry++;//initialised to -1 so first entry=0
07085 
07086 
07090   
07091   //extract the config from the beam information
07092   //occasionally the first snarl fails the beam cuts
07093   //so therefore you can't determine the proper beam config
07094   //this messes up the counting of bad pot but it should be a tiny 
07095   //effect (and bad pot isn't very important)
07096   static NuConfig config;
07097   static Bool_t configNotExtracted=true;
07098   if (configNotExtracted) {
07099     //set the flag to override the use of beam data in configuration
07100     //config.overrideBeamDataConfigExtraction=true;//default is false
07101     if (config.overrideBeamDataConfigExtraction) {
07102       MSG("NuAnalysis",Msg::kWarning)
07103         <<"Overriding use of Beam Data to extract configuration"<<endl
07104         <<"config.overrideBeamDataConfigExtraction="
07105         <<config.overrideBeamDataConfigExtraction<<endl;
07106     }
07107     configNotExtracted=!this->ExtractConfig(pntp,pntpBD,config);
07108     if (configNotExtracted) return;//skip to next snarl
07109   }
07110 
07111   static Bool_t firstTime=true;
07112   static NuOutputWriter output;
07113 
07114   //classes to organise the code in to related functions
07115   static const NuPlots plots;
07116   static const NuBeam beam;
07117   static NuTime time;//class to record times of spills, etc
07118 
07119   //interface for the pids
07120   static NuPIDInterface pid;
07121 
07122   if (firstTime) {
07123     firstTime=false;//set the control variable so code not run again
07124     
07125     //open the output file for the histograms
07126     string sFilePrefix="NuDSTFull"+config.sBeamType;
07127     //fOutFile=this->OpenFile(config,sFilePrefix.c_str());
07128     output.SetupFile(config,sFilePrefix);
07129     
07130     //define the analysis flags to use
07131     this->SetAnaFlags(config);
07132 
07133     //this stores the objects' pointers for access at job end
07134     //NOTE: run this after the output file has been opened
07135     this->StoreOrFinishTree(&output,&time,false);
07136 
07137     cout<<endl
07138         <<"************************************************"<<endl
07139         <<"***      Starting main loop over snarls      ***"<<endl
07140         <<"************************************************"<<endl;
07141   }
07142 
07143   //don't get a reference to NtpBDLiteRecord because it doesn't exist
07144   //for MC
07145   const NtpStRecord& ntp=*pntp;
07146 
07150   
07151   const RecCandHeader& rec=ntp.GetHeader();
07152   MAXMSG("NuAnalysis",Msg::kInfo,1)
07153     <<"Found: detector="<<rec.GetVldContext().GetDetector()
07154     <<", simFlag="<<rec.GetVldContext().GetSimFlag()
07155     <<", snarl="<<rec.GetSnarl()<<endl;
07156   
07157   Bool_t novaBeam = false;
07158   if (BeamType::kM000z200i_nova == static_cast<BeamType::BeamType_t>(config.beamType) ||
07159       BeamType::kM000z200i_nova_rev == static_cast<BeamType::BeamType_t>(config.beamType) ||
07160       BeamType::kM000z000i_nova == static_cast<BeamType::BeamType_t>(config.beamType)){
07161     novaBeam = true;
07162   }
07163 
07164   //write out the detector, simflag, 
07165   //count runs or subruns, and snarls, etc
07166   plots.FillGeneralHistos(ntp, novaBeam);
07167 
07168   //simple event object to hold important quantities for snarl
07169   NuEvent nuSnarl;
07170   this->CopyConfig(config,nuSnarl);
07171 
07172   //get the run, snarl, etc info
07173   lib.ext.ExtractGeneralInfo(ntp,nuSnarl);
07174   lib.ext.ExtractBeamInfoDB(nuSnarl);//done again later per event
07175 
07176   //extract coil current early in order to get POT counting right
07177   //doesn't matter for the FD because POTs are externally defined
07178   lib.ext.ExtractCoilInfo(nuSnarl);
07179   plots.FillCoilCurrentHistos(nuSnarl);
07180   if (nuSnarl.coilIsOk) lib.cnt.goodCoilCurrentSpillCounter++;
07181 
07182   //extract the data quality early as well (to get pot counting right)
07183   //the data quality variable can be cut on at analysis time 
07184   //as long as the definition of data quality is exactly 
07185   //the same (otherwise pot counting is wrong)
07186   lib.ext.ExtractDataQuality(nuSnarl);//done again later per event
07187 
07188   //get POT and event time info
07189   beam.IsGoodSpillAndFillPot(pntpBD,config,nuSnarl);
07190   time.FillTime(nuSnarl.timeSec,nuSnarl.pot,nuSnarl.goodBeamSntp);
07191   if (!(nuSnarl.goodBeamSntp && nuSnarl.coilIsOk && 
07192         (nuSnarl.isGoodDataQuality || !nuSnarl.useDBForDataQuality))) {
07193     lib.cnt.badSpillCounter++;
07194     lib.cnt.totalPotBad+=nuSnarl.pot;
07195   }
07196   else {
07197     lib.cnt.goodSpillCounter++;
07198     lib.cnt.totalPot+=nuSnarl.pot;   
07199   }
07200 
07201   //count the pots since the last evt was written to file
07202   static Float_t potSinceLastEvt=0;
07203   static Float_t potSinceLastEvtGood=0;
07204   static Float_t potSinceLastEvtBad=0;
07205   static Float_t potSinceLastEvtDB=0;
07206   static Float_t potSinceLastEvtGoodDB=0;
07207   static Float_t potSinceLastEvtBadDB=0;
07208   static vector<Double_t> potListSinceLastEvtGood;
07209   
07210   //count the sntp version of pots
07211   potSinceLastEvt+=nuSnarl.pot;
07212   if (nuSnarl.goodBeamSntp && 
07213       nuSnarl.coilIsOk && 
07214       nuSnarl.isGoodDataQuality){
07215     potSinceLastEvtGood+=nuSnarl.pot;
07216     potListSinceLastEvtGood.push_back(nuSnarl.pot);
07217   }
07218   else potSinceLastEvtBad+=nuSnarl.pot;
07219   
07220   //count the database version of pots
07221   potSinceLastEvtDB+=nuSnarl.potDB;
07222   if (nuSnarl.goodBeam && 
07223       nuSnarl.coilIsOk && 
07224       nuSnarl.isGoodDataQuality) potSinceLastEvtGoodDB+=nuSnarl.potDB;
07225   else potSinceLastEvtBadDB+=nuSnarl.potDB;
07226 
07227   //get the tca of evts
07228   TClonesArray& evtTca=(*ntp.evt);
07229   const Int_t numEvts=evtTca.GetEntriesFast();
07230 
07232   //loop over the reconstructed events
07234   std::vector<Int_t> vTrueEventsToStore;
07235   for (Int_t ievt=0;ievt<numEvts;ievt++){
07236     const NtpSREvent& evt= *dynamic_cast<NtpSREvent*>(evtTca[ievt]);
07237     lib.cnt.evtCounter++;
07238       
07239     MAXMSG("NuAnalysis",Msg::kDebug,5)
07240       <<"Found event "<<ievt+1<<"/"<<numEvts
07241       <<", ntrk="<<evt.ntrack<<endl;
07242     
07243     //simple event object to hold important quantities
07244     NuEvent& nu=output.GetNuEventToFill();
07245 
07247     //prepare NuMuBar variables to write
07248     //loose pre-selection cut: just require 1 or more trks
07249     //removed to include NC events
07250     //if (evt.ntrack<1) continue;
07251     //lib.cnt.evtWithTrkCounter++;
07252 
07253     //get rid of LI events
07254     const NtpSREventSummary& evthdr=ntp.evthdr;
07255     if (evthdr.litime!=-1) continue;
07256     lib.cnt.evtNotlitime++;
07257  
07258     nu.entry=lib.cnt.entry;//store the entry in the tree number
07259     nu.nevt=numEvts;//store the numEvts in snarl
07260     //copy info, copy the analysis (cuts and reco) version to use
07261     this->CopySnarlInfo(nuSnarl,nu);
07262     this->CopyConfig(config,nu);
07263  
07264     //extract the general info and evt, trk and shw info
07265     lib.ext.ExtractBasicInfo(ntp,evt,nu);
07266  
07267     //extract NC info
07268     lib.ext.ExtractNCInfo(pntp, ievt, nu);
07269 
07270     //RECONSTRUCT the neutrino energy, including kNN
07271     lib.reco.GetEvtEnergy(nu, true);
07272 
07273     MAXMSG("NuAnalysis",Msg::kDebug,10)
07274       <<endl<<"After reco:"<<endl
07275       <<plots.PrintEventInfo(cout,nu)<<endl;
07276 
07277     //change runPeriod
07278     if(iAltRun!=0){
07279       this->changeRunPeriod(nu); 
07280     }
07281     //do multiple extractions
07282     this->DoExtractions(ntp,evt,pntpSA,pid,nu); //MARK
07283 
07284     //check if trk or evt vertex is in the loose fid vol
07285         //4/4/2012 A.Gavrilenko: move loose fiducial cut to be done after track vertices are extracted
07286         if (!lib.cuts.IsInFidVolLoose(nu)) continue;
07287     lib.cnt.evtInFidVolCounter++;
07288 
07289     //Get a list of all the truth events which contribute to reco events
07290     const std::vector<Int_t> vTthInd = this->ContributingTrueEvents(nu);
07291     vTrueEventsToStore.insert(vTrueEventsToStore.end(),
07292                               vTthInd.begin(),
07293                               vTthInd.end());
07294 
07295     MAXMSG("NuAnalysis",Msg::kInfo,10)
07296       <<"PID: dp="<<nu.dpID<<", ab="<<nu.abID<<", ro="<<nu.roID
07297       <<", po="<<nu.poID<<", roNMB="<<nu.roIDNuMuBar<<endl;
07298     
07299     //count the positive and negative events
07300     if (nu.charge==-1) lib.cnt.nuNQCounter++;
07301     else if (nu.charge==+1) lib.cnt.nuPQCounter++;
07302     else if (nu.ntrk>0) lib.cnt.nuNoQCounter++;
07303     else if (nu.ntrk==-1) lib.cnt.nuNoTrkCounter++;
07304 
07305 
07306     //figure out the first and last time in the whole ntuple
07307     //this is very useful for making plots of quantities vs time
07308     plots.FillNtupleEarliestLatestTime(nu);
07309 
07310 
07311     //write out the pots since the last evt
07312     //this variable takes account of spills with zero entries
07313     //and spills with >=2 evts
07314     nu.potSinceLastEvt=potSinceLastEvt;
07315     nu.potSinceLastEvtGood=potSinceLastEvtGood;
07316     nu.potListSinceLastEvtGood = potListSinceLastEvtGood;
07317     nu.potSinceLastEvtBad=potSinceLastEvtBad;
07318     nu.potSinceLastEvtDB=potSinceLastEvtDB;
07319     nu.potSinceLastEvtGoodDB=potSinceLastEvtGoodDB;
07320     nu.potSinceLastEvtBadDB=potSinceLastEvtBadDB;
07321     potSinceLastEvt=0;//reset this for the next loop
07322     potSinceLastEvtGood=0;
07323     potListSinceLastEvtGood.clear();
07324     potSinceLastEvtBad=0;
07325     potSinceLastEvtDB=0;
07326     potSinceLastEvtGoodDB=0;
07327     potSinceLastEvtBadDB=0;
07328 
07330     //fill the tree
07331     output.FillNuEventTree();      
07332   }//end of loop over reconstructed events
07333 
07334   //now loop over all the true events
07335   this->LoopOverTruthInfo(ntp,output,nuSnarl,vTrueEventsToStore);
07336 }

void NuAnalysis::N_1 (  ) 

Definition at line 2314 of file NuAnalysis.cxx.

References NuEvent::anaVersion, NuConfig::beamType, MadDpID::CalcPID(), NuEvent::chi2PerNdof, MadDpID::ChoosePDFs(), NuEvent::detector, NuEvent::dpID, NtpStRecord::evt, NuLibrary::ext, ExtractConfig(), NuExtraction::ExtractEvtInfo(), NuExtraction::ExtractGeneralInfo(), NuExtraction::ExtractShwInfo(), NuExtraction::ExtractTrkInfo(), NuPlots::FillGeneralHistos(), NtpSRTrack::fit, NuBase::fOutFile, NuReco::GetBestTrack(), VldContext::GetDetector(), NuBase::GetEntries(), NuReco::GetEvtDeltaTs(), NuReco::GetEvtEnergy(), NuReco::GetEvtsPerSlc(), RecRecordImp< T >::GetHeader(), NuBase::GetNtpStRecord(), RecDataHeader::GetRun(), VldContext::GetSimFlag(), RecDataHeader::GetSubRun(), NuReco::GetTrackWithIndexX(), RecHeader::GetVldContext(), NuBase::InitialiseLoopVariables(), NuLibrary::Instance(), NuCuts::IsGoodDpID(), NuCuts::IsGoodFitChi2PerNdof(), NuCuts::IsGoodFitProb(), NuCuts::IsGoodSigmaQP_QP(), NuBeam::IsGoodSpillAndFillPot(), NuCuts::IsGoodUVVtx(), NuCuts::IsInFidVol(), Msg::kDebug, Msg::kInfo, MAXMSG, MSG, Munits::ns, NtpSREvent::ntrack, NuBase::OpenFile(), NtpSRFitTrack::pass, plots(), NuEvent::pot, NuEvent::prob, NuLibrary::reco, NuEvent::releaseType, NuMadAnalysis::SetEntry(), NuBase::SetLoopVariables(), NuEvent::sigqp_qp, NuEvent::simFlag, NtpSREvent::slc, NtpSRVertex::u, NtpSRVertex::v, NtpSREvent::vtx, NtpSRVertex::x, NtpSRVertex::y, and NtpSRVertex::z.

02315 {
02316   MSG("NuAnalysis",Msg::kInfo) 
02317     <<" ** Running N_1 method... **"<<endl;
02318 
02319   //open the output file for the histograms
02320   fOutFile=this->OpenFile(100,"NuMuBarN_1");
02321   
02322   TH1F* hDpID=new TH1F("hDpID","hDpID",4*160,-1.6,1.6);
02323   hDpID->GetXaxis()->SetTitle("PID (from MadDpID)");
02324   hDpID->GetXaxis()->CenterTitle();
02325   hDpID->GetYaxis()->SetTitle("");
02326   hDpID->GetYaxis()->CenterTitle();
02327   hDpID->SetFillColor(0);
02328   hDpID->SetLineColor(1);
02329   hDpID->SetLineWidth(3);
02330   //hDpID->SetBit(TH1::kCanRebin);
02331 
02332   TH1F* hDpIDN_1=new TH1F("hDpIDN_1","hDpIDN_1",4*160,-1.6,1.6);
02333   hDpIDN_1->GetXaxis()->SetTitle("PID (from MadDpID)");
02334   hDpIDN_1->GetXaxis()->CenterTitle();
02335   hDpIDN_1->GetYaxis()->SetTitle("");
02336   hDpIDN_1->GetYaxis()->CenterTitle();
02337   hDpIDN_1->SetFillColor(0);
02338   hDpIDN_1->SetLineColor(2);//red for N-1 cuts
02339   hDpIDN_1->SetLineWidth(3);
02340   //hDpIDN_1->SetBit(TH1::kCanRebin);
02341 
02342   TH1F* hDpIDN=new TH1F("hDpIDN","hDpIDN",4*160,-1.6,1.6);
02343   hDpIDN->GetXaxis()->SetTitle("PID (from MadDpID)");
02344   hDpIDN->GetXaxis()->CenterTitle();
02345   hDpIDN->GetYaxis()->SetTitle("");
02346   hDpIDN->GetYaxis()->CenterTitle();
02347   hDpIDN->SetFillColor(0);
02348   hDpIDN->SetLineColor(4);//blue for N cuts
02349   hDpIDN->SetLineWidth(3);
02350   //hDpIDN->SetBit(TH1::kCanRebin);
02351 
02352 
02353 
02354   TH1F* hSigmaqp_qp=new TH1F("hSigmaqp_qp","hSigmaqp_qp",200*160,-160,160);
02355   hSigmaqp_qp->GetXaxis()->SetTitle("Sigmaqp_qp");
02356   hSigmaqp_qp->GetXaxis()->CenterTitle();
02357   hSigmaqp_qp->GetYaxis()->SetTitle("");
02358   hSigmaqp_qp->GetYaxis()->CenterTitle();
02359   hSigmaqp_qp->SetFillColor(0);
02360   hSigmaqp_qp->SetLineColor(1);
02361   hSigmaqp_qp->SetLineWidth(3);
02362   //hSigmaqp_qp->SetBit(TH1::kCanRebin);
02363 
02364   TH1F* hSigmaqp_qpN_1=new TH1F("hSigmaqp_qpN_1","hSigmaqp_qpN_1",200*160,-160,160);
02365   hSigmaqp_qpN_1->GetXaxis()->SetTitle("Sigmaqp_qp");
02366   hSigmaqp_qpN_1->GetXaxis()->CenterTitle();
02367   hSigmaqp_qpN_1->GetYaxis()->SetTitle("");
02368   hSigmaqp_qpN_1->GetYaxis()->CenterTitle();
02369   hSigmaqp_qpN_1->SetFillColor(0);
02370   hSigmaqp_qpN_1->SetLineColor(2);//red for N-1 cuts
02371   hSigmaqp_qpN_1->SetLineWidth(3);
02372   //hSigmaqp_qpN_1->SetBit(TH1::kCanRebin);
02373 
02374   TH1F* hSigmaqp_qpN=new TH1F("hSigmaqp_qpN","hSigmaqp_qpN",200*160,-160,160);
02375   hSigmaqp_qpN->GetXaxis()->SetTitle("Sigmaqp_qp");
02376   hSigmaqp_qpN->GetXaxis()->CenterTitle();
02377   hSigmaqp_qpN->GetYaxis()->SetTitle("");
02378   hSigmaqp_qpN->GetYaxis()->CenterTitle();
02379   hSigmaqp_qpN->SetFillColor(0);
02380   hSigmaqp_qpN->SetLineColor(4);//blue for N cuts
02381   hSigmaqp_qpN->SetLineWidth(3);
02382   //hSigmaqp_qpN->SetBit(TH1::kCanRebin);
02383 
02384 
02385 
02386   TH1F* hChi2=new TH1F("hChi2","hChi2",10*176,-16,160);
02387   hChi2->GetXaxis()->SetTitle("Chi2");
02388   hChi2->GetXaxis()->CenterTitle();
02389   hChi2->GetYaxis()->SetTitle("");
02390   hChi2->GetYaxis()->CenterTitle();
02391   hChi2->SetFillColor(0);
02392   hChi2->SetLineColor(1);
02393   hChi2->SetLineWidth(3);
02394   //hChi2->SetBit(TH1::kCanRebin);
02395 
02396   TH1F* hChi2N_1=new TH1F("hChi2N_1","hChi2N_1",10*176,-16,160);
02397   hChi2N_1->GetXaxis()->SetTitle("Chi2");
02398   hChi2N_1->GetXaxis()->CenterTitle();
02399   hChi2N_1->GetYaxis()->SetTitle("");
02400   hChi2N_1->GetYaxis()->CenterTitle();
02401   hChi2N_1->SetFillColor(0);
02402   hChi2N_1->SetLineColor(2);//red for N-1 cuts
02403   hChi2N_1->SetLineWidth(3);
02404   //hChi2N_1->SetBit(TH1::kCanRebin);
02405 
02406   TH1F* hChi2N=new TH1F("hChi2N","hChi2N",10*176,-16,160);
02407   hChi2N->GetXaxis()->SetTitle("Chi2");
02408   hChi2N->GetXaxis()->CenterTitle();
02409   hChi2N->GetYaxis()->SetTitle("");
02410   hChi2N->GetYaxis()->CenterTitle();
02411   hChi2N->SetFillColor(0);
02412   hChi2N->SetLineColor(4);//blue for N cuts
02413   hChi2N->SetLineWidth(3);
02414   //hChi2N->SetBit(TH1::kCanRebin);
02415 
02416 
02417 
02418   TH1F* hFitProb=new TH1F("hFitProb","hFitProb",10*160,-1.6,1.6);
02419   hFitProb->GetXaxis()->SetTitle("FitProb");
02420   hFitProb->GetXaxis()->CenterTitle();
02421   hFitProb->GetYaxis()->SetTitle("");
02422   hFitProb->GetYaxis()->CenterTitle();
02423   hFitProb->SetFillColor(0);
02424   hFitProb->SetLineColor(1);
02425   hFitProb->SetLineWidth(3);
02426   //hFitProb->SetBit(TH1::kCanRebin);
02427 
02428   TH1F* hFitProbN_1=new TH1F("hFitProbN_1","hFitProbN_1",10*160,-1.6,1.6);
02429   hFitProbN_1->GetXaxis()->SetTitle("FitProb");
02430   hFitProbN_1->GetXaxis()->CenterTitle();
02431   hFitProbN_1->GetYaxis()->SetTitle("");
02432   hFitProbN_1->GetYaxis()->CenterTitle();
02433   hFitProbN_1->SetFillColor(0);
02434   hFitProbN_1->SetLineColor(2);//red for N-1 cuts
02435   hFitProbN_1->SetLineWidth(3);
02436   //hFitProbN_1->SetBit(TH1::kCanRebin);
02437 
02438   TH1F* hFitProbN=new TH1F("hFitProbN","hFitProbN",10*160,-1.6,1.6);
02439   hFitProbN->GetXaxis()->SetTitle("FitProb");
02440   hFitProbN->GetXaxis()->CenterTitle();
02441   hFitProbN->GetYaxis()->SetTitle("");
02442   hFitProbN->GetYaxis()->CenterTitle();
02443   hFitProbN->SetFillColor(0);
02444   hFitProbN->SetLineColor(4);//blue for N cuts
02445   hFitProbN->SetLineWidth(3);
02446   //hFitProbN->SetBit(TH1::kCanRebin);
02447 
02448 
02449 
02450   TH1F* hDeltaT=new TH1F("hDeltaT","hDeltaT",2010,-10,2000);
02451   hDeltaT->GetXaxis()->SetTitle("Delta T (ns)");
02452   hDeltaT->GetXaxis()->CenterTitle();
02453   hDeltaT->GetYaxis()->SetTitle("");
02454   hDeltaT->GetYaxis()->CenterTitle();
02455   hDeltaT->SetFillColor(0);
02456   hDeltaT->SetLineColor(1);
02457   hDeltaT->SetLineWidth(3);
02458   //hDeltaT->SetBit(TH1::kCanRebin);
02459 
02460   TH1F* hDeltaTN_1=new TH1F("hDeltaTN_1","hDeltaTN_1",2010,-10,2000);
02461   hDeltaTN_1->GetXaxis()->SetTitle("Delta T (ns)");
02462   hDeltaTN_1->GetXaxis()->CenterTitle();
02463   hDeltaTN_1->GetYaxis()->SetTitle("");
02464   hDeltaTN_1->GetYaxis()->CenterTitle();
02465   hDeltaTN_1->SetFillColor(0);
02466   hDeltaTN_1->SetLineColor(2);//red for N-1 cuts
02467   hDeltaTN_1->SetLineWidth(3);
02468   //hDeltaTN_1->SetBit(TH1::kCanRebin);
02469 
02470   TH1F* hDeltaTN=new TH1F("hDeltaTN","hDeltaTN",2010,-10,2000);
02471   hDeltaTN->GetXaxis()->SetTitle("Delta T (ns)");
02472   hDeltaTN->GetXaxis()->CenterTitle();
02473   hDeltaTN->GetYaxis()->SetTitle("");
02474   hDeltaTN->GetYaxis()->CenterTitle();
02475   hDeltaTN->SetFillColor(0);
02476   hDeltaTN->SetLineColor(4);//blue for N cuts
02477   hDeltaTN->SetLineWidth(3);
02478   //hDeltaTN->SetBit(TH1::kCanRebin);
02479 
02480 
02481 
02482   TH1F* hEvtsPerSlc=new TH1F("hEvtsPerSlc","hEvtsPerSlc",60,-10,50);
02483   hEvtsPerSlc->GetXaxis()->SetTitle("Evts Per Slc");
02484   hEvtsPerSlc->GetXaxis()->CenterTitle();
02485   hEvtsPerSlc->GetYaxis()->SetTitle("");
02486   hEvtsPerSlc->GetYaxis()->CenterTitle();
02487   hEvtsPerSlc->SetFillColor(0);
02488   hEvtsPerSlc->SetLineColor(1);
02489   hEvtsPerSlc->SetLineWidth(3);
02490   //hEvtsPerSlc->SetBit(TH1::kCanRebin);
02491 
02492   TH1F* hEvtsPerSlcN_1=new TH1F("hEvtsPerSlcN_1","hEvtsPerSlcN_1",
02493                                 60,-10,50);
02494   hEvtsPerSlcN_1->GetXaxis()->SetTitle("Evts Per Slc");
02495   hEvtsPerSlcN_1->GetXaxis()->CenterTitle();
02496   hEvtsPerSlcN_1->GetYaxis()->SetTitle("");
02497   hEvtsPerSlcN_1->GetYaxis()->CenterTitle();
02498   hEvtsPerSlcN_1->SetFillColor(0);
02499   hEvtsPerSlcN_1->SetLineColor(2);//red for N-1 cuts
02500   hEvtsPerSlcN_1->SetLineWidth(3);
02501   //hEvtsPerSlcN_1->SetBit(TH1::kCanRebin);
02502 
02503   TH1F* hEvtsPerSlcN=new TH1F("hEvtsPerSlcN","hEvtsPerSlcN",60,-10,50);
02504   hEvtsPerSlcN->GetXaxis()->SetTitle("Evts Per Slc");
02505   hEvtsPerSlcN->GetXaxis()->CenterTitle();
02506   hEvtsPerSlcN->GetYaxis()->SetTitle("");
02507   hEvtsPerSlcN->GetYaxis()->CenterTitle();
02508   hEvtsPerSlcN->SetFillColor(0);
02509   hEvtsPerSlcN->SetLineColor(4);//blue for N cuts
02510   hEvtsPerSlcN->SetLineWidth(3);
02511   //hEvtsPerSlcN->SetBit(TH1::kCanRebin);
02512 
02513   //classes to organise the code in to related functions
02514   const NuCuts cuts;
02515   //const NuGeneral general;
02516   const NuPlots plots;
02517   const NuReco reco;
02518   const NuExtraction ext;
02519   const NuBeam beam;
02520 
02521   NuConfig config;
02522   this->ExtractConfig(config);
02523 
02524   //create these on the heap so that they don't destruct
02525   // - on purpose to avoid a segv on destruction... nice coding!
02526   NuMadAnalysis& mad=*new NuMadAnalysis();
02527   MadDpID& dp=*new MadDpID();
02528   //BeamType::BeamType_t beamType=BeamType::kLE;
02529   BeamType::BeamType_t beamType=static_cast
02530     <BeamType::BeamType_t>(config.beamType);
02531 
02532   //maps to store evt info
02533   map<Int_t,Double_t> deltaTs;
02534   map<Int_t,Int_t> evtsPerSlc;
02535 
02536   Int_t goodSpillCounter=0;
02537   Int_t badSpillCounter=0;
02538   Float_t totalPot=0;
02539   Float_t totalPotBad=0;
02540   Int_t evtCounter=0;
02541   Int_t evtInFidVolCounter=0;
02542   Int_t evtWithTrkCounter=0;
02543   Int_t goodBestTrkCounter=0;
02544   Int_t goodTrkPassCounter=0;
02545   Int_t goodRecoEnCounter=0;
02546   Int_t goodUVDiffCounter=0;
02547   //Int_t goodFitSigQPCounter=0;
02548   //Int_t goodFitProbCounter=0;
02549   //Int_t goodFitChi2Counter=0;
02550   //Int_t goodPIDCounter=0;
02551   
02552   //get an instance of the code library
02553   const NuLibrary& lib=NuLibrary::Instance();
02554  
02558   
02559   this->InitialiseLoopVariables();  
02560   
02561   //for(Int_t entry=0;entry<10000;entry++){
02562   for(Int_t entry=0;entry<this->GetEntries();entry++){
02563       
02564     this->SetLoopVariables(entry);
02565       
02566     //get reference to NtpStRecord from base class
02567     const NtpStRecord& ntp=(*this->GetNtpStRecord());
02568 
02569     const RecCandHeader& rec=ntp.GetHeader();
02570     MAXMSG("NuAnalysis",Msg::kInfo,5)
02571       <<"Found: run="<<rec.GetRun()
02572       <<", subrun="<<rec.GetSubRun()
02573       <<", detector="<<rec.GetVldContext().GetDetector()
02574       <<", simFlag="<<rec.GetVldContext().GetSimFlag()
02575       <<endl;
02576 
02577     //write out the detector, simflag, etc
02578     plots.FillGeneralHistos(ntp);
02579 
02580     //simple event object to hold important quantities for snarl
02581     NuEvent nuSnarl;
02582     
02583     //get the run, snarl, etc info
02584     ext.ExtractGeneralInfo(ntp,nuSnarl);
02585 
02586     if (!beam.IsGoodSpillAndFillPot
02587         (this->GetNtpBDLiteRecord(),config,nuSnarl)) {
02588       badSpillCounter++;
02589       totalPotBad+=nuSnarl.pot;
02590       continue;
02591     }
02592     goodSpillCounter++;
02593     totalPot+=nuSnarl.pot;    
02594 
02595     dp.ChoosePDFs(rec.GetVldContext().GetDetector(),beamType);
02596     mad.SetEntry(&ntp);
02597 
02598     TClonesArray& evtTca=(*ntp.evt);
02599     const Int_t numEvts=evtTca.GetEntriesFast();
02600     
02601     //loop over the reconstructed events
02602     for (Int_t ievt=0;ievt<numEvts;ievt++){
02603       const NtpSREvent& evt=
02604         *dynamic_cast<NtpSREvent*>(evtTca[ievt]);
02605       evtCounter++;
02606 
02607       //simple event object to hold important quantities
02608       NuEvent nu;
02609       
02610       //get the run, snarl, etc info
02611       ext.ExtractGeneralInfo(ntp,nu);
02612       //get info from the evt
02613       lib.ext.ExtractEvtInfo(evt,nu);
02614       //extract trk info (needed to get best track info)
02615       lib.ext.ExtractTrkInfo(ntp,evt,nu);
02616       //extract shw info
02617       lib.ext.ExtractShwInfo(ntp,evt,nu);
02618             
02619       Bool_t isInFidVol=cuts.IsInFidVol(evt.vtx.x,evt.vtx.y,
02620                                         evt.vtx.z,
02621                                         evt.vtx.u,evt.vtx.v,
02622                                         0,0,
02623                                         nu.detector,nu.anaVersion,
02624                                         nu.releaseType,nu.simFlag);
02625 
02626       if (!isInFidVol) continue;
02627       evtInFidVolCounter++;
02628 
02629       nu.dpID=dp.CalcPID(&mad,ievt,0);
02630       MAXMSG("NuAnalysis",Msg::kDebug,50)
02631         <<"dpID="<<nu.dpID<<endl;
02632       
02633       //ensure there is a track in the event
02634       //if (evt.ntrack<1) continue;
02635       if (evt.ntrack!=1) continue;//require exactly 1 track
02636       evtWithTrkCounter++;
02637 
02638       //get the best track in the event
02639       Int_t bestTrack=lib.reco.GetBestTrack(nu);
02640       const NtpSRTrack* ptrk=lib.reco.GetTrackWithIndexX
02641         (ntp,evt,bestTrack-1);
02642       const NtpSRTrack& trk=*ptrk;
02643       goodBestTrkCounter++;
02644 
02645       //require a trk fit
02646       if (!trk.fit.pass) continue;
02647       goodTrkPassCounter++;
02648 
02649 
02651       //RECONSTRUCT the neutrino energy
02652       lib.reco.GetEvtEnergy(nu, false);
02653       goodRecoEnCounter++;
02654   
02655       if (!cuts.IsGoodUVVtx(nu)){
02656         continue;
02657       }
02658       goodUVDiffCounter++;
02659 
02660 
02662 
02663       Bool_t goodSigmaQP=cuts.IsGoodSigmaQP_QP(nu);
02664       Bool_t goodFitProb=cuts.IsGoodFitProb(nu);
02665       Bool_t goodChi2=cuts.IsGoodFitChi2PerNdof(nu);
02666       Bool_t goodDpID=cuts.IsGoodDpID(nu);
02667       
02668       //get the maps of evts' info
02669       deltaTs.clear();
02670       reco.GetEvtDeltaTs(ntp,deltaTs);
02671       evtsPerSlc.clear();
02672       reco.GetEvtsPerSlc(ntp,evtsPerSlc);      
02673       Bool_t goodDeltaT=deltaTs[ievt]>=50*Munits::ns;
02674       Bool_t goodEvtsPerSlc=evtsPerSlc[evt.slc]==1;
02675 
02676       //only fill histos for anti-neutrinos
02677       if (nu.sigqp_qp<0) continue;
02678 
02679       //fill the ALL histos
02680       hSigmaqp_qp->Fill(nu.sigqp_qp);
02681       hFitProb->Fill(nu.prob);
02682       hChi2->Fill(nu.chi2PerNdof);
02683       hDpID->Fill(nu.dpID);
02684       hDeltaT->Fill(deltaTs[ievt]/Munits::ns);
02685       hEvtsPerSlc->Fill(evtsPerSlc[evt.slc]);
02686       
02688       //fill the N-1 cuts plots
02690       if (true && 
02691           goodFitProb &&
02692           goodChi2 &&
02693           goodDpID &&
02694           goodDeltaT &&
02695           goodEvtsPerSlc) {
02696         hSigmaqp_qpN_1->Fill(nu.sigqp_qp);
02697       }
02698 
02699       if (goodSigmaQP && 
02700           true &&
02701           goodChi2 &&
02702           goodDpID &&
02703           goodDeltaT &&
02704           goodEvtsPerSlc){
02705         hFitProbN_1->Fill(nu.prob);
02706       }
02707       
02708       if (goodSigmaQP && 
02709           goodFitProb &&
02710           true &&
02711           goodDpID &&
02712           goodDeltaT &&
02713           goodEvtsPerSlc){
02714         hChi2N_1->Fill(nu.chi2PerNdof);
02715       }
02716       
02717       if (goodSigmaQP && 
02718           goodFitProb &&
02719           goodChi2 &&
02720           true &&
02721           goodDeltaT &&
02722           goodEvtsPerSlc){
02723         hDpIDN_1->Fill(nu.dpID);
02724       }
02725 
02726       if (goodSigmaQP && 
02727           goodFitProb &&
02728           goodChi2 &&
02729           goodDpID &&
02730           true &&
02731           goodEvtsPerSlc){
02732         hDeltaTN_1->Fill(deltaTs[ievt]/Munits::ns);
02733       }
02734 
02735       if (goodSigmaQP && 
02736           goodFitProb &&
02737           goodChi2 &&
02738           goodDpID &&
02739           goodDeltaT &&
02740           true){
02741         hEvtsPerSlcN_1->Fill(evtsPerSlc[evt.slc]);
02742       }
02743 
02745       //fill the N cuts plots
02747       if (goodSigmaQP && 
02748           goodFitProb &&
02749           goodChi2 &&
02750           goodDpID &&
02751           goodDeltaT &&
02752           goodEvtsPerSlc){
02753         hSigmaqp_qpN->Fill(nu.sigqp_qp);
02754         hFitProbN->Fill(nu.prob);
02755         hChi2N->Fill(nu.chi2PerNdof);
02756         hDpIDN->Fill(nu.dpID);
02757         hDeltaTN->Fill(deltaTs[ievt]/Munits::ns);
02758         hEvtsPerSlcN->Fill(evtsPerSlc[evt.slc]);
02759       }
02760     }
02761   }//end of for                                       
02762   
02766   
02767   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
02768 
02769 
02770   MSG("NuAnalysis",Msg::kInfo) 
02771     <<" ** Finished N_1 method **"<<endl;
02772 }

void NuAnalysis::NMBSummaryTreeAna (  ) 

Definition at line 5802 of file NuAnalysis.cxx.

References CopyAcrossHistos(), NuPlots::FillContainmentHistos(), NuPlots::FillDPIdSigmaQPFailDpIDCutPlots(), NuPlots::FillDPIdSigmaQPFailProbCutPlots(), NuPlots::FillDPIdSigmaQPFailSigQPCutPlots(), NuPlots::FillDPIdSigmaQPPassDpIDCutPlots(), NuPlots::FillDPIdSigmaQPPassPreSelCutPlots(), NuPlots::FillDPIdSigmaQPPassSigQPCutPlots(), NuPlots::FillDPIdSigmaQPPlotsN(), NuPlots::FillEnergyBinHistos(), NuPlots::FillKinematicsHistos(), NuPlots::FillRangeCurvCompHistos(), NuPlots::FillRecoEnYHistosN(), NuPlots::FillSigmaQPPlots(), NuPlots::FillTrueAbIDHistos(), NuPlots::FillTrueAbIDHistosPQNQ(), NuPlots::FillTrueDpIDHistos(), NuPlots::FillTrueDpIDHistosPQNQ(), NuPlots::FillTruePIDHistos(), NuPlots::FillXYZHistos(), NuBase::fOutFile, NuInputEvents::GetEntriesNuEvent(), NuInputEvents::GetNextNuEvent(), NuInputEvents::InitialiseChains(), NuInputEvents::InitialiseNuEventBranch(), NuInputEvents::InputFileName(), NuCuts::IsGoodAbID(), NuCuts::IsGoodFitChi2PerNdof(), NuCuts::IsGoodFitProb(), NuCuts::IsGoodSigmaQP_QP(), Msg::kDebug, Msg::kInfo, NuCuts::kJJH1, MAXMSG, NuBase::OpenFile(), NuInputEvents::OpenInputFile(), NuGeneral::OscWeight(), plots(), NuBase::PrintLoopProgress(), and NuInputEvents::ResetNuEventLoopPositionToStart().

05803 {
05804   string sFilePrefix="NMBSumAna";
05805   fOutFile=this->OpenFile(100,sFilePrefix.c_str());
05806 
05807   TDirectory* dirOutput=gDirectory;
05808   cout<<"After opening output file:"<<endl;
05809   dirOutput->Print();
05810   
05811   string sBase="/home/hartnell/mytest/NuMuBar/";
05812   string inputFileName=
05813     "NMBChgSepL010185iN00009059_2.root";//hs, csf, qp
05814   
05815   inputFileName=sBase+inputFileName;
05816   
05817   NuInputEvents* fpInput=new NuInputEvents();
05818   NuInputEvents& input=*fpInput;
05819   input.InputFileName(inputFileName);
05820   input.InitialiseChains();
05821   input.InitialiseNuEventBranch();
05822   TDirectory* dirInput=input.OpenInputFile();
05823   
05824   //copy across histos such hDetector, hSimFlag, and POT ones
05825   this->CopyAcrossHistos(dirInput,dirOutput);
05826 
05827   //create a cache of selected events to speed up the fitting
05828   //input.InitialiseNuEventCache();
05829   //this->CreateInputCache();
05830   
05831   //tell the input object to use cached events
05832   //input.UseNuEventCache();
05833   
05834   input.ResetNuEventLoopPositionToStart();
05835   
05836   static NuGeneral general;
05837   static NuPlots plots;
05838   static NuCuts cuts;
05839   
05840   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
05841 
05842     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
05843 
05844     NuEvent& nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
05845     
05846     //these ones go before the pid and other cuts
05847     plots.FillTrueDpIDHistos(nu);
05848     plots.FillTrueDpIDHistosPQNQ(nu);
05849     plots.FillDPIdSigmaQPPassPreSelCutPlots(nu);
05850     plots.FillSigmaQPPlots(nu);//sig, chi, prob plots
05851     // PoID Officially depracated
05852     //plots.FillTruePoIDHistos(nu);
05853     //plots.FillTruePoIDHistosPQNQ(nu);
05854     plots.FillTrueAbIDHistos(nu);
05855     plots.FillTrueAbIDHistosPQNQ(nu);
05856     
05857     //override the anaVersion
05858     nu.anaVersion=NuCuts::kJJH1;
05859     
05860     //cut on the PID
05861     //if (!cuts.IsGoodDpID(nu)) {
05862     if (!cuts.IsGoodAbID(nu)) {
05863       plots.FillDPIdSigmaQPFailDpIDCutPlots(nu);
05864       continue;
05865     }
05866     plots.FillDPIdSigmaQPPassDpIDCutPlots(nu);
05867     
05868     plots.FillEnergyBinHistos(nu);//just PID cut
05869     
05870     //cut on the fractional track momentum and sign error      
05871     if (!cuts.IsGoodSigmaQP_QP(nu)) {
05872       plots.FillDPIdSigmaQPFailSigQPCutPlots(nu);
05873       continue;
05874     }
05875     plots.FillDPIdSigmaQPPassSigQPCutPlots(nu);
05876     
05877     //cut on the chi2
05878     if (!cuts.IsGoodFitChi2PerNdof(nu)) continue;
05879     
05880     //was here
05881     //plots.FillEnergyBinHistos(nu);
05882 
05883     //cut on the track fit probability      
05884     if (!cuts.IsGoodFitProb(nu)) {
05885       plots.FillDPIdSigmaQPFailProbCutPlots(nu);
05886       continue;
05887     }
05888       
05889 
05890 
05891 
05892     //extra cuts to test
05893     //if (nu.dpID<+0.1) continue;
05894     //if (nu.dpID<+0.4) continue;
05895     //if (nu.dpID<+0.4 && nu.charge>0) continue;
05896     //if (nu.prob<0.1) continue;
05897     //if (nu.sigqp_qp>0.3) continue;
05898   
05899     //Bool_t weightForOsc=true;
05900     Bool_t weightForOsc=false;
05901     if (weightForOsc){
05902       //get the weight for the event
05903       Double_t weight=nu.rw;
05904       //apply the oscillation weight to CC events
05905       if (nu.iaction==1) {
05906         Float_t dm2=2.7e-3;
05907         Double_t oscWeight=general.OscWeight(dm2,1,
05908                                              nu.energyMC);
05909         weight*=oscWeight;
05910       }
05911       nu.rw=weight;
05912     }
05913 
05914     //if (nu.containedTrk && nu.rTrkEnd<0.3) {
05915     //MAXMSG("NuMinuit",Msg::kInfo,200)
05916     //<<"nu.rTrkEnd="<<nu.rTrkEnd<<endl;
05917     //}
05918 
05920     //if (nu.rTrkEnd>0.3) continue;
05921     
05922     //if (nu.xTrkEnd<-0.2 && nu.planeTrkEnd<=120 && nu.containmentFlag==1) {
05923     //MAXMSG("NuMinuit",Msg::kInfo,200)
05924     //<<"xTrkEnd="<<nu.xTrkEnd
05925     //<<", y="<<nu.yTrkEnd
05926     //<<", r="<<nu.rTrkEnd
05927     //<<", plTrkEnd"<<nu.planeTrkEnd
05928     //<<", con="<<nu.containedTrk
05929     //<<", flag="<<nu.containmentFlag
05930     //<<endl;
05931     //}
05932 
05933 
05934     //same list as below, but with trk/evt ones commented out
05935     plots.FillRecoEnYHistosN(nu);
05936     plots.FillDPIdSigmaQPPlotsN(nu);
05937     
05938     //plots.FillShwHistos(ntp,evt,nu);
05939     plots.FillXYZHistos(nu);
05940     plots.FillContainmentHistos(nu);
05941     plots.FillTruePIDHistos(nu);
05942     //plots.FillTrackResponseHistos(ntp,trk,nu);
05943     plots.FillRangeCurvCompHistos(nu);
05944     plots.FillKinematicsHistos(nu);
05945 
05946     MAXMSG("NuMinuit",Msg::kInfo,5)
05947       <<"NMBSummaryTreeAna: NuEvent: index="<<nu.index
05948       <<", energy="<<nu.energy<<", energyMC="<<nu.energyMC<<endl;    
05949   }//end of loop over summary tree
05950 
05951 }

void NuAnalysis::NuMuBarAppearance (  ) 

Definition at line 3593 of file NuAnalysis.cxx.

References NuEvent::anaVersion, NuConfig::beamType, NuCuts::CalcTotalPot(), MadDpID::ChoosePDFs(), NuEvent::detector, MuELoss::e, NuGeneral::EpochTo1995(), ExtractConfig(), NuExtraction::ExtractGeneralInfo(), NuPlots::FillGeneralHistos(), NuBase::fOutFile, VldContext::GetDetector(), NuBase::GetEntries(), RecRecordImp< T >::GetHeader(), NuBase::GetNtpStRecord(), NuBase::GetNumFilesAddedToChain(), RecDataHeader::GetRun(), VldContext::GetSimFlag(), RecDataHeader::GetSubRun(), RecHeader::GetVldContext(), NtpMCTruth::iaction, NtpMCTruth::index, NuBase::InitialiseLoopVariables(), NtpMCTruth::inu, NuBeam::IsGoodSpillAndFillPot(), NuCuts::IsInFidVol(), Msg::kInfo, MAXMSG, NtpStRecord::mc, MSG, NuBase::OpenFile(), NuGeneral::OscWeight(), NtpMCTruth::p4neu, plots(), NuEvent::pot, NuEvent::releaseType, NuConfig::sBeamType, NuMadAnalysis::SetEntry(), NuGeneral::SetGraphAxis(), NuBase::SetLoopVariables(), NuEvent::simFlag, NuGeneral::TH1FFill(), NtpMCTruth::vtxx, NtpMCTruth::vtxy, and NtpMCTruth::vtxz.

03594 {
03595   MSG("NuAnalysis",Msg::kInfo) 
03596     <<" ** Running NuMuBarAppearance method... **"<<endl;
03597   
03598   NuConfig config;
03599   this->ExtractConfig(config);
03600 
03601   //open the output file for the histograms
03602   string sFilePrefix="NMBApp"+config.sBeamType;
03603   fOutFile=this->OpenFile(config,sFilePrefix.c_str());
03604 
03605   TH1F* hRecoEnNMBFull=new TH1F("hRecoEnNMBFull","hRecoEnNMBFull",
03606                                 4*352,-32,320);
03607   hRecoEnNMBFull->GetXaxis()->SetTitle("True Energy (GeV)");
03608   hRecoEnNMBFull->GetXaxis()->CenterTitle();
03609   hRecoEnNMBFull->GetYaxis()->SetTitle("");
03610   hRecoEnNMBFull->GetYaxis()->CenterTitle();
03611   //hRecoEnNMBFull->SetBit(TH1::kCanRebin);
03612   hRecoEnNMBFull->Sumw2();
03613 
03614   TH1F* hRecoEnNMFull=new TH1F("hRecoEnNMFull","hRecoEnNMFull",
03615                                 4*352,-32,320);
03616   hRecoEnNMFull->GetXaxis()->SetTitle("True Energy (GeV)");
03617   hRecoEnNMFull->GetXaxis()->CenterTitle();
03618   hRecoEnNMFull->GetYaxis()->SetTitle("");
03619   hRecoEnNMFull->GetYaxis()->CenterTitle();
03620   //hRecoEnNMFull->SetBit(TH1::kCanRebin);
03621   hRecoEnNMFull->Sumw2();
03622 
03623   TH1F* hRecoEnNMBOsc=new TH1F("hRecoEnNMBOsc","hRecoEnNMBOsc",
03624                                 4*352,-32,320);
03625   hRecoEnNMBOsc->GetXaxis()->SetTitle("True Energy (GeV)");
03626   hRecoEnNMBOsc->GetXaxis()->CenterTitle();
03627   hRecoEnNMBOsc->GetYaxis()->SetTitle("");
03628   hRecoEnNMBOsc->GetYaxis()->CenterTitle();
03629   //hRecoEnNMBOsc->SetBit(TH1::kCanRebin);
03630   hRecoEnNMBOsc->Sumw2();
03631 
03632   TH1F* hRecoEnNMOsc=new TH1F("hRecoEnNMOsc","hRecoEnNMOsc",
03633                                 4*352,-32,320);
03634   hRecoEnNMOsc->GetXaxis()->SetTitle("True Energy (GeV)");
03635   hRecoEnNMOsc->GetXaxis()->CenterTitle();
03636   hRecoEnNMOsc->GetYaxis()->SetTitle("");
03637   hRecoEnNMOsc->GetYaxis()->CenterTitle();
03638   //hRecoEnNMOsc->SetBit(TH1::kCanRebin);
03639   hRecoEnNMOsc->Sumw2();
03640 
03641   //vectors
03642   Int_t entries=static_cast<Int_t>(this->GetEntries());
03643   Int_t startTimeSecs=2000000000;//2 billion
03644   Int_t endTimeSecs=1;
03645   vector<Double_t> vPot;
03646   vPot.reserve(entries);
03647   vector<Double_t> vTime;
03648   vTime.reserve(entries);
03649   vector<Double_t> vPotBad;
03650   vPotBad.reserve(entries/10);
03651   vector<Double_t> vTimeBad;
03652   vTimeBad.reserve(entries/10);
03653   
03654   vector<Double_t> vTimeNuMuEvt;
03655   vTimeNuMuEvt.reserve(entries/5);
03656   vector<Double_t> vTimeNuMuBarEvt;
03657   vTimeNuMuBarEvt.reserve(entries/5);
03658  
03659   //maps to store evt info
03660   map<Int_t,Double_t> deltaTs;
03661   map<Int_t,Int_t> evtsPerSlc;
03662 
03663   //counters
03664   Int_t goodSpillCounter=0;
03665   Int_t badSpillCounter=0;
03666   Float_t totalPot=0;
03667   Float_t totalPotBad=0;
03668   Int_t evtCounter=0;
03669   Int_t evtNotlitime=0;
03670   Int_t evtNotIsLI=0;
03671   Int_t evtInFidVolCounter=0;
03672   Int_t evtWithTrkCounter=0;
03673   Int_t goodBestTrkCounter=0;
03674   Int_t goodTrkPassCounter=0;
03675   Int_t goodRecoEnCounter=0;
03676   Int_t goodUVDiffCounter=0;
03677   Int_t trkInFidVolCounter=0;
03678   Int_t goodFitSigQPCounter=0;
03679   Int_t goodFitProbCounter=0;
03680   Int_t goodFitChi2Counter=0;
03681   Int_t goodDeltaTCounter=0;
03682   Int_t goodEvtsPerSlcCounter=0; 
03683   Int_t goodPIDCounter=0;
03684   Int_t goodBeyondTrkEndCounter=0;
03685   Int_t goodShwFractCounter=0;
03686   Int_t nuNQCounter=0;
03687   Int_t nuPQCounter=0;
03688   
03689   //string sTxtFilePrefix="nmb"+config.sBeamType;
03690   //ofstream& nmbTxt=*(this->OpenTxtFile(config,
03691   //                           sTxtFilePrefix.c_str()));
03692 
03693   //classes to organise the code in to related functions
03694   const NuCuts cuts;
03695   const NuGeneral general;
03696   const NuPlots plots;
03697   const NuReco reco;
03698   const NuExtraction ext;
03699   const NuBeam beam;
03700 
03701   //create these on the heap so that they don't destruct
03702   // - on purpose to avoid a segv on destruction... nice coding!
03703   NuMadAnalysis& mad=*new NuMadAnalysis();
03704   MadDpID& dp=*new MadDpID();
03705   //BeamType::BeamType_t beamType=BeamType::kLE;
03706   BeamType::BeamType_t beamType=static_cast
03707     <BeamType::BeamType_t>(config.beamType);
03708 
03712   
03713   this->InitialiseLoopVariables();  
03714   
03715   //for(Int_t entry=0;entry<10000;entry++){
03716   for(Int_t entry=0;entry<this->GetEntries();entry++){
03717       
03718     this->SetLoopVariables(entry);
03719       
03720     //get reference to NtpStRecord from base class
03721     const NtpStRecord& ntp=(*this->GetNtpStRecord());
03722 
03723     const RecCandHeader& rec=ntp.GetHeader();
03724     MAXMSG("NuAnalysis",Msg::kInfo,5)
03725       <<"Found: run="<<rec.GetRun()
03726       <<", subrun="<<rec.GetSubRun()
03727       <<", detector="<<rec.GetVldContext().GetDetector()
03728       <<", simFlag="<<rec.GetVldContext().GetSimFlag()
03729       <<endl;
03730 
03731     //write out the detector, simflag, etc
03732     plots.FillGeneralHistos(ntp);
03733 
03734     //simple event object to hold important quantities for snarl
03735     NuEvent nuSnarl;
03736     
03737     //get the run, snarl, etc info
03738     ext.ExtractGeneralInfo(ntp,nuSnarl);
03739 
03740     if (!beam.IsGoodSpillAndFillPot
03741         (this->GetNtpBDLiteRecord(),config,nuSnarl)) {
03742       badSpillCounter++;
03743       totalPotBad+=nuSnarl.pot;
03744       continue;
03745     }
03746     goodSpillCounter++;
03747     totalPot+=nuSnarl.pot;    
03748 
03749     dp.ChoosePDFs(rec.GetVldContext().GetDetector(),beamType);
03750     mad.SetEntry(&ntp);
03751 
03752     set<Int_t> setNuMuBarInTrueFidCC;
03753   
03754     VldTimeStamp vldts;
03755     //VldTimeStamp vldts(ev.UnixTime,0);
03756     VldContext vc(rec.GetVldContext().GetDetector(),
03757                   rec.GetVldContext().GetSimFlag(),vldts);
03758     //get the ugh
03759     UgliGeomHandle ugh(vc);
03760     
03761     TClonesArray& mcTca=(*ntp.mc);
03762     Int_t numInt=mcTca.GetEntries();
03763     MAXMSG("NuAnalysis",Msg::kInfo,10)
03764       <<"Number of entries in NtpMCTruth="
03765       <<mcTca.GetEntries()<<endl;
03766     
03767     //simple event object to hold important quantities
03768     NuEvent nu;
03769     
03770     //get the run, snarl, etc info
03771     ext.ExtractGeneralInfo(ntp,nu);
03772       
03773 
03775     //loop over true events
03777     for (Int_t i=0;i<numInt;i++){
03778       const NtpMCTruth& mc=*(dynamic_cast<NtpMCTruth*>(mcTca[i]));
03779       
03780       TVector3 xyz(mc.vtxx,mc.vtxy,mc.vtxz);
03781       // calculate the positions in UVZ space
03782       TVector3 uvz=ugh.xyz2uvz(xyz);
03783       
03784       //if (!(mc.iaction==1 && mc.inu==-14)) continue;
03785       //remove all NC and non NuMu(Bar) events
03786       if (mc.iaction!=1) continue;
03787       if (abs(mc.inu)!=14) continue;
03788       
03789       Bool_t isInFidVol=cuts.IsInFidVol(mc.vtxx,mc.vtxy,mc.vtxz,
03790                                         uvz.X(),uvz.Y(),0,0,
03791                                         nu.detector,nu.anaVersion,
03792                                         nu.releaseType,nu.simFlag);
03793       
03794       if (!isInFidVol) continue;
03795       setNuMuBarInTrueFidCC.insert(mc.index);
03796 
03797       Double_t oscWeight=general.OscWeight(3e-3,1,fabs(mc.p4neu[3]));
03798       
03799       MAXMSG("NuAnalysis",Msg::kInfo,200)
03800         <<"inu="<<mc.inu<<", iaction="<<mc.iaction
03801         <<", E="<<mc.p4neu[3]<<", oscWeight="<<oscWeight<<endl;
03802 
03803       if (mc.inu==-14) {
03804         hRecoEnNMBFull->Fill(fabs(mc.p4neu[3]));
03805         hRecoEnNMBOsc->Fill(fabs(mc.p4neu[3]),oscWeight);
03806       }
03807       else if (mc.inu==14) {
03808         hRecoEnNMFull->Fill(fabs(mc.p4neu[3]));
03809         hRecoEnNMOsc->Fill(fabs(mc.p4neu[3]),oscWeight);
03810       }
03811       else {
03812         cout<<"Ahhh, bad inu"<<endl;
03813       }
03814 
03815     }
03816 
03817     MAXMSG("NuAnalysis",Msg::kInfo,20)
03818       <<"Number of NuMuBar fiducial volume interactions in spill="
03819       <<setNuMuBarInTrueFidCC.size()<<endl;
03820   }//end of for                                       
03821   
03825 
03826   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
03827 
03828   //store the number of files added to the chain
03829   Int_t nf=this->GetNumFilesAddedToChain();
03830   TH1F* hRun=dynamic_cast<TH1F*>(gROOT->FindObject("hRun"));
03831   Float_t nr=-1;
03832   if (hRun) nr=hRun->GetEntries();
03833   TH1F* hNumFiles=new TH1F("hNumFiles","hNumFiles",15,-5,10);
03834   hNumFiles->Fill(1,nf);//store as weight, access with GetMaximum
03835   MSG("NuAnalysis",Msg::kInfo)
03836     <<"Files added to chain="<<hNumFiles->GetMaximum()
03837     <<", runs found="<<nr<<endl;
03838 
03839   MSG("NuAnalysis",Msg::kInfo)
03840     <<"Found start time and end time: "
03841     <<startTimeSecs<<" -> "<<endTimeSecs<<endl;
03842   general.EpochTo1995(endTimeSecs);
03843   general.EpochTo1995(startTimeSecs);
03844   
03845   MSG("NuAnalysis",Msg::kInfo)<<"Filling vs. Time plots..."<<endl;
03846   TH1F* hSpillsVsTime=new TH1F("hSpillsVsTime","hSpillsVsTime",
03847                                100,startTimeSecs,endTimeSecs);
03848   general.TH1FFill(hSpillsVsTime,vTime);
03849   general.SetGraphAxis(hSpillsVsTime->GetXaxis(),
03850                      startTimeSecs,endTimeSecs);
03851   hSpillsVsTime->GetXaxis()->CenterTitle();
03852   hSpillsVsTime->GetYaxis()->SetTitle("Spills");
03853   hSpillsVsTime->GetYaxis()->CenterTitle();
03854 
03855   TH1F* hSpillsBadVsTime=new TH1F("hSpillsBadVsTime","hSpillsBadVsTime",
03856                                   100,startTimeSecs,endTimeSecs);
03857   general.TH1FFill(hSpillsBadVsTime,vTimeBad);
03858   general.SetGraphAxis(hSpillsBadVsTime->GetXaxis(),
03859                      startTimeSecs,endTimeSecs);
03860   hSpillsBadVsTime->GetXaxis()->CenterTitle();
03861   hSpillsBadVsTime->GetYaxis()->SetTitle("Spills");
03862   hSpillsBadVsTime->GetYaxis()->CenterTitle();
03863   
03864   TH1F* hNuMuVsTime=new TH1F("hNuMuVsTime","hNuMuVsTime",
03865                              100,startTimeSecs,endTimeSecs);
03866   general.TH1FFill(hNuMuVsTime,vTimeNuMuEvt);
03867   general.SetGraphAxis(hNuMuVsTime->GetXaxis(),
03868                      startTimeSecs,endTimeSecs);
03869   hNuMuVsTime->GetXaxis()->CenterTitle();
03870   hNuMuVsTime->GetYaxis()->SetTitle("#nu_#mu events");
03871   hNuMuVsTime->GetYaxis()->CenterTitle();
03872 
03873   TH1F* hNuMuBarVsTime=new TH1F("hNuMuBarVsTime","hNuMuBarVsTime",
03874                                100,startTimeSecs,endTimeSecs);
03875   general.TH1FFill(hNuMuBarVsTime,vTimeNuMuBarEvt);
03876   general.SetGraphAxis(hNuMuBarVsTime->GetXaxis(),
03877                      startTimeSecs,endTimeSecs);
03878   hNuMuBarVsTime->GetXaxis()->CenterTitle();
03879   hNuMuBarVsTime->GetYaxis()->SetTitle("#bar{#nu_#mu} events");
03880   hNuMuBarVsTime->GetYaxis()->CenterTitle();
03881 
03882   TH1F* hPotVsTime=new TH1F("hPotVsTime","hPotVsTime",
03883                              100,startTimeSecs,endTimeSecs);
03884   general.TH1FFill(hPotVsTime,vTime,vPot);
03885   general.SetGraphAxis(hPotVsTime->GetXaxis(),
03886                      startTimeSecs,endTimeSecs);
03887   hPotVsTime->GetXaxis()->CenterTitle();
03888   hPotVsTime->GetYaxis()->SetTitle("POT");
03889   hPotVsTime->GetYaxis()->CenterTitle();
03890 
03891   TH1F* hPotBadVsTime=new TH1F("hPotBadVsTime","hPotBadVsTime",
03892                              100,startTimeSecs,endTimeSecs);
03893   general.TH1FFill(hPotBadVsTime,vTimeBad,vPotBad);
03894   general.SetGraphAxis(hPotBadVsTime->GetXaxis(),
03895                      startTimeSecs,endTimeSecs);
03896   hPotBadVsTime->GetXaxis()->CenterTitle();
03897   hPotBadVsTime->GetYaxis()->SetTitle("POT");
03898   hPotBadVsTime->GetYaxis()->CenterTitle();
03899   
03900   Float_t totalPotHist=0;
03901   Float_t totalPotBadHist=0;
03902   cuts.CalcTotalPot(totalPotHist,totalPotBadHist);
03903   Float_t pcPotRejected=0;
03904   if (totalPotHist) pcPotRejected=100.*totalPotBadHist/totalPotHist;
03905 
03906   //msg was giving pots=412886000000000000.000000... still is for MC!
03907   cout<<"Number of spills     ="<<this->GetEntries()<<endl
03908       <<"Number of good spills="<<goodSpillCounter<<endl
03909       <<"Number of bad spills ="<<badSpillCounter<<endl
03910       <<"Sum of good+bad spill="<<badSpillCounter+goodSpillCounter<<endl
03911       <<endl
03912       <<"Total POT good       ="<<totalPot*1e12<<endl
03913       <<"Total POT bad        ="<<totalPotBad*1e12<<endl
03914       <<"Total POT good (hist)="<<totalPotHist*1e12<<endl
03915       <<"Total POT bad  (hist)="<<totalPotBadHist*1e12
03916       <<"  ("<<pcPotRejected<<"%)"<<endl;
03917 
03918   MSG("NuAnalysis",Msg::kInfo)
03919     <<endl<<"*************************************"<<endl
03920     <<"Total Events    ="<<evtCounter<<endl
03921     <<"Evt not litime  ="<<evtNotlitime<<endl
03922     <<"Evt not IsLI    ="<<evtNotIsLI<<endl
03923     <<"Evts in Fid     ="<<evtInFidVolCounter<<endl
03924     <<"Evts w/ Trk     ="<<evtWithTrkCounter<<endl
03925     <<"Good Best Trk   ="<<goodBestTrkCounter<<endl
03926     <<"Track Pass      ="<<goodTrkPassCounter<<endl
03927     <<"Good reco energy="<<goodRecoEnCounter<<endl
03928     <<"Good UVDiff     ="<<goodUVDiffCounter<<endl
03929     <<"Trk Vtx in Fid  ="<<trkInFidVolCounter<<endl
03930     <<"Good Fit SigQP  ="<<goodFitSigQPCounter<<endl
03931     <<"Good Fit Prob   ="<<goodFitProbCounter<<endl
03932     <<"Good Fit Chi2   ="<<goodFitChi2Counter<<endl
03933     <<"Good Delta T    ="<<goodDeltaTCounter<<endl
03934     <<"Good EvtPerSlc  ="<<goodEvtsPerSlcCounter<<endl
03935     <<"Good DP ID      ="<<goodPIDCounter<<endl
03936     <<"Good beyond tEnd="<<goodBeyondTrkEndCounter<<endl
03937     <<"Good shw fract  ="<<goodShwFractCounter<<endl
03938     <<"*************************************"<<endl;
03939 
03940   Float_t pcPQ=0;
03941   if (nuPQCounter+nuNQCounter>0) pcPQ=100.*nuPQCounter/
03942                                    (nuPQCounter+nuNQCounter);
03943   MSG("NuAnalysis",Msg::kInfo)
03944     <<endl
03945     <<"Neutrinos with NQ="<<nuNQCounter<<endl
03946     <<"Neutrinos with PQ="<<nuPQCounter
03947     <<"   ("<<pcPQ<<"%)"<<endl
03948     <<"Sum NQ+PQ        ="<<nuNQCounter+nuPQCounter<<endl
03949     <<endl;
03950   
03951   MSG("NuAnalysis",Msg::kInfo) 
03952     <<" ** Finished NuMuBarAppearance method **"<<endl;
03953 }

void NuAnalysis::OldDetermineBeamType ( NuConfig config  )  [private]

Definition at line 2776 of file NuAnalysis.cxx.

References NuConfig::beamTypeSntp, DetermineBeamType(), NuConfig::hornCurrent, Msg::kError, MAXMSG, NuConfig::sBeamType, NuConfig::sHornCurrent, NuConfig::sTargetPos, and NuConfig::targetPos.

02777 {
02778   //my old version
02779   //if (config.beamTypeSntp==0) config.beamType=BeamType::kUnknown;
02780   //else if (config.beamTypeSntp==1) config.beamType=BeamType::kLE;
02781   //else if (config.beamTypeSntp==2) config.beamType=BeamType::kME;
02782   //else if (config.beamTypeSntp==3) config.beamType=BeamType::kHE;
02783   //else if (config.beamTypeSntp==4) config.beamType=BeamType::kME;
02784   //else if (config.beamTypeSntp==5) config.beamType=BeamType::kHE;
02785 
02786   //this doesn't work because the new beam type is target+hornCur
02787   //my new version
02788   //note that the conventions package does not have true ME/HE
02789   //kME and kHE are ambiguiously used for pME and pHE
02790   //if (config.beamTypeSntp==0) config.beamType=BeamType::kUnknown;
02791   //else if (config.beamTypeSntp==1) config.beamType=
02792   //                             BeamType::kL010z185i;
02793   //else if (config.beamTypeSntp==2) config.beamType=BeamType::kME;
02794   //else if (config.beamTypeSntp==3) config.beamType=BeamType::kHE;
02795   //else if (config.beamTypeSntp==4) config.beamType=
02796   //BeamType::kL100z200i;
02797   //else if (config.beamTypeSntp==5) config.beamType=
02798   //                             BeamType::kL250z200i;
02799       
02800   //my new version
02801   //note: the beamTypeSntp ONLY refers to the target position
02802   //note: the conventions package does not have true ME/HE
02803   //kME and kHE are ambiguiously used for kpME and kpHE
02804   if (config.beamTypeSntp==0) {
02805     config.targetPos=-1;
02806     config.sTargetPos="UknownTargetPos";
02807   }
02808   else if (config.beamTypeSntp==1) {
02809     config.targetPos=10;
02810     config.sTargetPos="010";
02811   }
02812   else if (config.beamTypeSntp==2) {
02813     config.targetPos=100;
02814     config.sTargetPos="100";
02815   }
02816   else if (config.beamTypeSntp==3) {
02817     config.targetPos=250;
02818     config.sTargetPos="250";
02819   }
02820   else if (config.beamTypeSntp==4) {
02821     config.targetPos=100;
02822     config.sTargetPos="100";
02823   }
02824   else if (config.beamTypeSntp==5) {
02825     config.targetPos=250;
02826     config.sTargetPos="250";
02827   }
02828   else {
02829     MAXMSG("NuAnalysis",Msg::kError,10)
02830       <<"Ahhh, don't recognise beamTypeSntp="
02831       <<config.beamTypeSntp<<endl;
02832     assert(false);
02833   }
02834 
02835   //get the horn current
02836   //config.hornCurrent=ntpBD.horncur;
02837     
02838   //for LE hornCurrent=-    (-176?) 
02839   //for run 9235 (LE I believe) the horn current is -182.352
02840   //for ME hornCurrent=-191.13
02841   //for HE hornCurrent=-190.651
02842   //the actual horncurrents are out by ~10 kA compared to MC
02843   //the -2 is for safety
02844   //it's 1/3 of the way between the 15 kA separated runs we took
02845   //this may need to be changed if the horn current in data changes
02846   if (fabs(config.hornCurrent)>200-10-2){
02847     config.sHornCurrent="200";
02848   }
02849   else if (fabs(config.hornCurrent)>185-10-2) {
02850     config.sHornCurrent="185";
02851   }
02852   else if (fabs(config.hornCurrent)>170-10-2) {
02853     config.sHornCurrent="170";
02854   }
02855   else if (fabs(config.hornCurrent)>=0) {
02856     config.sHornCurrent="000";
02857   }
02858   else {
02859     MAXMSG("NuAnalysis",Msg::kError,10)
02860       <<"Ahh, no case for hornCurrent="<<config.hornCurrent<<endl;
02861   }
02862 
02863   //create the std MC naming scheme name
02864   config.sBeamType="L"+config.sTargetPos+config.sHornCurrent;
02865 
02866   //now make the config string
02867   //the -2 is for safety
02868   //if (config.beamType==BeamType::kHE){
02869   //config.sBeamType="L250200";
02870   //}
02871   //else if (config.beamType==BeamType::kME) {
02872   //config.sBeamType="L100200";
02873   //}
02874   //else if (config.beamType==BeamType::kLE) {
02875   //if (fabs(config.hornCurrent)>200-10-2){
02876   //  config.sBeamType="L010200";
02877   //}
02878   //else if (fabs(config.hornCurrent)>185-10-2) {
02879   //  config.sBeamType="L010185";
02880   //}
02881   //else if (fabs(config.hornCurrent)>170-10-2) {
02882   //  config.sBeamType="L010170";
02883   //}
02884   //else {
02885   //  MAXMSG("NuAnalysis",Msg::kError,10)
02886   //    <<"Ahh, don't know hornCurrent="<<config.hornCurrent<<endl;
02887   //}
02888   //}
02889       
02890   //temporary selection for the FD...
02891   //if (rec.GetVldContext().GetDetector()==Detector::kFar &&
02892   //config.beamType!=BeamType::kLE) continue;
02893 
02894   //get the beam type based on the info config already holds
02895   this->DetermineBeamType(config);
02896 }

void NuAnalysis::SetAnaFlags ( NuConfig config  )  [private]

define the analysis (cuts and reco) to use

Definition at line 6529 of file NuAnalysis.cxx.

References NuConfig::anaVersion, NuCuts::AsString(), NuLibrary::cuts, ReleaseType::GetMCSubVersion(), NuLibrary::Instance(), ReleaseType::IsDaikon(), ReleaseType::kDaikon, ReleaseType::kData, SKZPWeightCalculator::kDetXs, SKZPWeightCalculator::kDogwood5_Daikon07_2012, NuCuts::kFullDST, Msg::kInfo, SKZPWeightCalculator::kMINOSplus_2014_v2, SKZPWeightCalculator::kUnknown, Msg::kWarning, MAXMSG, NuConfig::mcVersion, MSG, NuUtilities::PrintRelease(), NuConfig::releaseType, NuConfig::reweightVersion, NuConfig::runPeriod, and NuConfig::useGeneratorReweight.

Referenced by ChargeSeparationOneSnarl(), and MakeFullDST().

06530 {
06532   
06533   //get an instance of the code library
06534   const NuLibrary& lib=NuLibrary::Instance();
06535   
06536   //set the cuts version
06537   config.anaVersion=NuCuts::kFullDST;
06538 
06539   //set the reweighting variables
06540   //config.reweightVersion=SKZPWeightCalculator::kBoston;
06541   //config.reweightVersion=SKZPWeightCalculator::kPiMinus;//Cedar/Daikon
06542   if (config.mcVersion==ReleaseType::kData) {
06543     MAXMSG("NuAnalysis",Msg::kInfo,1) << "Found Data, setting reweightVersion to SKZPWeightCalculator::kUnknown" << endl;    
06544     config.reweightVersion=SKZPWeightCalculator::kUnknown;
06545   }
06546   else if (!ReleaseType::IsDaikon(config.releaseType)) {
06547     MAXMSG("NuAnalysis",Msg::kWarning,1) << "Don't know what weights to use for non-daikon MC version " 
06548     << NuUtilities::PrintRelease(config.releaseType) << " so I will assume DetXs" << endl;
06549     config.reweightVersion=SKZPWeightCalculator::kDetXs;
06550   }
06551   else {
06552     if (ReleaseType::GetMCSubVersion(config.releaseType) <= 4) {
06553       MAXMSG("NuAnalysis",Msg::kInfo,1) << "Found MC version " 
06554       <<  NuUtilities::PrintRelease(config.releaseType) 
06555       << " so I will use SKZPWeightCalculator::kDetXs" << endl;
06556       config.reweightVersion=SKZPWeightCalculator::kDetXs;
06557     }
06558     else if(config.runPeriod<11) {
06559       MAXMSG("NuAnalysis",Msg::kInfo,1) << "Found MC version " 
06560       <<  NuUtilities::PrintRelease(config.releaseType) 
06561       << " so I will use SKZPWeightCalculator::kDogwood5_Daikon07_2012" << endl;
06562       config.reweightVersion=SKZPWeightCalculator::kDogwood5_Daikon07_2012;
06563     }
06564     else{
06565       MAXMSG("NuAnalysis",Msg::kInfo,1) << "Found MC version "
06566                                         <<  NuUtilities::PrintRelease(config.releaseType)
06567                                         << " so I will use SKZPWeightCalculator::kMINOSplus_2014_v2" << endl;
06568       config.reweightVersion=SKZPWeightCalculator::kMINOSplus_2014_v2;
06569     }
06570   }
06571   
06572   
06573   config.useGeneratorReweight=false;
06574   //config.sGeneratorConfigName="MODBYRS3";
06575   //config.generatorConfigNo=-1;
06576 
06577   //flags to switch parts of the code on and off
06578   //can be used to avoid needing various database tables
06579   //config.useDBForDataQuality=false;//default is true
06580   //config.useDBForSpillTiming=false;//default is true
06581   //config.useDBForBeamInfo=false;//default is true
06582   //config.cutOnDataQuality=false;//default is true
06583   //config.cutOnSpillTiming=false;//default is true
06584   //config.cutOnBeamInfo=false;//default is true
06585   //config.calcMajCurv=false;//default is true
06586   //config.calcRoID=false;//default is true
06587 
06588   //set the MC version to determine which pdfs to use for data
06589   Int_t mcVersionOveride=ReleaseType::kDaikon;//selects data pdfs
06590   //Int_t mcVersionOveride=ReleaseType::kCarrot;//selects data pdfs
06591 
06592   MSG("NuAnalysis",Msg::kInfo)
06593     <<"Setting:"<<endl
06594     <<"  anaVersion="
06595     <<lib.cuts.AsString(static_cast<NuCuts::NuAnaVersion_t>
06596                         (config.anaVersion))
06597     <<" ("<<config.anaVersion<<")"<<endl
06598     <<"  useGeneratorReweight="<<config.useGeneratorReweight<<endl
06599     <<"  reweightVersion="<<config.reweightVersion<<endl;
06600   
06601   //if MC then the mcVersion will be determined from the file
06602   //override the version to use here (only gets set in the data case)
06603   if (config.mcVersion==ReleaseType::kData) {
06604     MSG("NuAnalysis",Msg::kInfo)
06605       <<"Overiding mcVersion for PDF selection:"<<endl
06606       <<"  new mcVersion="<<NuUtilities::PrintRelease(mcVersionOveride)
06607       <<", old mcVersion="<<NuUtilities::PrintRelease(config.mcVersion)
06608       <<endl;
06609     config.mcVersion=mcVersionOveride;
06610   }  
06611   
06612 
06613 }

void NuAnalysis::StoreOrFinishTree ( NuOutputWriter pOutput,
NuTime pTime,
Bool_t  finish 
) const [private]

Definition at line 6471 of file NuAnalysis.cxx.

References NuHistos::CalcPOTsFromHistos(), NuLibrary::cnt, NuTime::FillTimeHistos(), NuOutputWriter::Finish(), NuOutputWriter::GetDirectory(), NuLibrary::hist, NuLibrary::Instance(), Msg::kInfo, Msg::kWarning, MSG, NuCounter::PrintFullDST(), and NuCounter::PrintStdhepCounter().

Referenced by ChargeSeparation(), ChargeSeparationOneSnarl(), EndJob(), and MakeFullDST().

06474 {
06475   //this stores the pointers the first time the function is called
06476   static NuTime& time=*pTime;
06477   static NuOutputWriter& output=*pOutput;
06478   static Bool_t firstTime=true;
06479 
06480   if (firstTime) {
06481     MSG("NuPIDInterface",Msg::kInfo)
06482       <<"StoreOrFinishTree: TDirectory for NuOutputWriter is:"<<endl;
06483     if (pOutput) output.GetDirectory()->pwd();
06484     else cout<<"Ahhh, no NuOutputWriter"<<endl;
06485     
06486     MSG("NuPIDInterface",Msg::kInfo)
06487       <<"StoreOrFinishTree: gDirectory is:"<<endl;
06488     gDirectory->pwd();
06489   }
06490   
06491   //this section runs methods on objects at the end of job
06492   if (finish){
06493     if (!firstTime) {
06494       //get an instance of the code library
06495       const NuLibrary& lib=NuLibrary::Instance();
06496       
06497       MSG("NuPIDInterface",Msg::kInfo)
06498         <<"StoreOrFinishTree: gDirectory is:"<<endl;
06499       gDirectory->pwd();
06500       MSG("NuPIDInterface",Msg::kInfo)
06501         <<"After reseting gDirectory to NuOutputWriter location:"<<endl;
06502       gDirectory=output.GetDirectory();
06503       gDirectory->pwd();
06504       
06505       //fill time histos
06506       time.FillTimeHistos();
06507       
06508       //print out job info
06509       lib.cnt.PrintFullDST();
06510       lib.cnt.PrintStdhepCounter();
06511       
06512       lib.hist.CalcPOTsFromHistos();
06513       
06514       //close the file and write everything out
06515       output.Finish();
06516     }
06517     else {
06518       MSG("NuAnalysis",Msg::kWarning) 
06519         <<"StoreOrFinishTree was not run in store mode"<<endl;
06520     }
06521   }
06522 
06523   //no longer first time
06524   firstTime=false;
06525 }


Member Data Documentation

Int_t NuAnalysis::iAltRun = 0 [static, private]

Definition at line 70 of file NuAnalysis.h.

Referenced by altRun(), LoopOverTruthInfo(), and MakeFullDST().


The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1