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

NuFluctuator.cxx

Go to the documentation of this file.
00001 
00002 // $Id: NuFluctuator.cxx,v 1.10 2009/10/01 18:56:09 bckhouse Exp $
00003 //
00004 // Provides statistically fluctuated mock data sets for CPT and
00005 // transition analyses.
00006 //
00007 // Justin Evans
00008 // j.evans2@physics.ox.ac.uk
00009 //
00010 // $Log: NuFluctuator.cxx,v $
00011 // Revision 1.10  2009/10/01 18:56:09  bckhouse
00012 // Centralize calculation of oscillation functions into NuUtilities: function OscillationWeight, DecayWeight, DecoherenceWeight.
00013 //
00014 // Revision 1.9  2008/02/26 18:53:47  ahimmel
00015 //
00016 //
00017 // Alternat flucutator implemented.  Seems to give the same results.
00018 //
00019 // Revision 1.8  2008/02/04 15:45:54  evans
00020 // A function to make fake transition data.
00021 //
00022 // Revision 1.7  2008/01/23 21:20:55  evans
00023 // The Oscillate() function was using the neutrino sn2 to oscillate the
00024 // antineutrinos. It isn't now.
00025 //
00026 // Revision 1.6  2008/01/15 23:57:31  evans
00027 // Adding the ability to make systematically shifted fake data. Also
00028 // adding IsGoodMajorityCurvature to the list of standard cuts.
00029 //
00030 // Revision 1.5  2008/01/10 19:57:49  ahimmel
00031 //
00032 //
00033 // Broke Fluctuate and Oscillate out into their own methods so they could be used externally.
00034 //
00035 // Revision 1.4  2008/01/04 04:30:08  evans
00036 // Removing unnecessary commented out code.
00037 //
00038 // Revision 1.3  2007/12/25 21:12:56  evans
00039 // In the transition analysis, using the true neutrino energy for the
00040 // efficiency corrections instead of the reconstructed energy.
00041 //
00042 // Revision 1.2  2007/12/24 17:35:02  evans
00043 // The Fluctuator can now produce fake data for a transition analysis. It
00044 // needs to be provided with root files containing the cross sections and
00045 // selection efficiencies.
00046 //
00047 // Revision 1.1  2007/12/18 12:36:02  evans
00048 // Class to produce Poisson fluctuated sets of fake ND and FD data, from
00049 // a high-statistics MC sample. Only produces FD CPT data so far:
00050 // transition functionality will be added presently. Can produce ND
00051 // nominal fake data at present. I'll add in functionality to produce
00052 // systematic shifts.
00053 //
00054 //
00056 
00057 #include "TString.h"
00058 #include <vector>
00059 
00060 #include "TGraph.h"
00061 #include "TFile.h"
00062 #include "TH1D.h"
00063 #include "TMath.h"
00064 #include "TRandom3.h"
00065 
00066 #include "MessageService/MsgService.h"
00067 
00068 #include "NtupleUtils/NuEvent.h"
00069 #include "NtupleUtils/NuFluctuator.h"
00070 #include "NtupleUtils/NuTreeWrapper.h"
00071 #include "NtupleUtils/NuXMLConfig.h"
00072 #include "NtupleUtils/NuSystematic.h"
00073 #include "NtupleUtils/NuUtilities.h"
00074 
00075 ClassImp(NuFluctuator)
00076 
00077 CVSID("$Id: NuFluctuator.cxx,v 1.10 2009/10/01 18:56:09 bckhouse Exp $");
00078 
00079 using std::vector;
00080 
00081 //____________________________________________________________________72
00082 NuFluctuator::NuFluctuator()
00083   : fPDFsFilled(false),
00084     fFakeDataPoT(0.0),
00085     fMCPoT(0.0),
00086     fNuMuDm2(0.0),
00087     fNuMuSn2(0.0),
00088     fNuBarDm2(0.0),
00089     fNuBarSn2(0.0),
00090     fTransitionProb(0.0),
00091     fSelection(NuCuts::kUnknown)
00092 {
00093   fhNuMuCCRecoE = 0;
00094   fhNuBarCCRecoE = 0;
00095   fMonteCarlo = 0;
00096   fRandom = new TRandom3(0);
00097   fxsecfilename = "$SRT_PRIVATE_CONTEXT/NtupleUtils/data/xsec_minos_modbyrs4_v3_5_0_mk.root";
00098   fSelEffFileName = "/minos/scratch/ahimmel/SystematicsStudies/Transitions/CombinedHelpers.root";
00099   fNuBarCCCrossSectionGraph = 0;
00100   fNuMuCCCrossSectionGraph = 0;
00101   fhNuBarCCSelectionEfficiency = 0;
00102   fhNuMuCCSelectionEfficiency = 0;
00103   fhNuBarCCCrossSections = 0;
00104   fhNuMuCCCrossSections = 0;
00105 }
00106 
00107 //____________________________________________________________________72
00108 NuFluctuator::~NuFluctuator()
00109 {
00110   if (fhNuMuCCRecoE) {
00111     delete fhNuMuCCRecoE; fhNuMuCCRecoE = 0;
00112   }
00113   if (fhNuBarCCRecoE) {
00114     delete fhNuBarCCRecoE; fhNuBarCCRecoE = 0;
00115   }
00116   if (fMonteCarlo) {
00117     delete fMonteCarlo; fMonteCarlo = 0;
00118   }
00119 }
00120 
00121 //____________________________________________________________________72
00122 TH1D NuFluctuator::Fluctuate(TH1D *hin) const
00123 {
00124         TH1D hData(*hin);
00125   hData.Reset();
00126   //Set all bins, including overflow (not underflow)
00127   for (Int_t binCounter = 1;
00128        binCounter < hin->GetNbinsX() + 2;
00129        ++binCounter){
00130     hData.SetBinContent
00131                  (binCounter,
00132                  fRandom->Poisson(hin->GetBinContent(binCounter)));
00133   }
00134   return hData;
00135 }
00136 
00137 //____________________________________________________________________72
00138 TH1D NuFluctuator::FluctuateSampling(TH1D *hin) const
00139 {
00140     TH1D hData(*hin);
00141     hData.Reset();
00142     int entries = fRandom->Poisson(hin->Integral());
00143     //Set all bins, including overflow (not underflow)
00144     for (int i = 0; i < entries; i++) {
00145         hData.Fill(hin->GetRandom());
00146     }
00147     return hData;
00148 }
00149 
00150 //____________________________________________________________________72
00151 const Bool_t NuFluctuator::CheckConfigForPDFMaking() const
00152 {
00153   if (!fhNuMuCCRecoE){
00154     MSG("NuFluctuator",Msg::kError)
00155       << "NuMuCC binning not supplied"
00156       << endl;
00157     return false;
00158   }
00159   if (!fhNuBarCCRecoE){
00160     MSG("NuFluctuator",Msg::kError)
00161       << "NuBarCC binning not supplied"
00162       << endl;
00163     return false;
00164   }
00165   if (!fMonteCarlo){
00166     MSG("NuFluctuator",Msg::kError)
00167       << "MC not supplied"
00168       << endl;
00169     return false;
00170   }
00171   if (fMCPoT<0.001){
00172     MSG("NuFluctuator",Msg::kError)
00173       << "MC PoT are worryingly small"
00174       << endl;
00175     return false;
00176   }
00177   if (fFakeDataPoT<0.001){
00178     MSG("NuFluctuator",Msg::kWarning)
00179       << "Your requested fake data PoT are worryingly small"
00180       << endl;
00181     return true;
00182   }
00183 
00184   return true;
00185 }
00186 
00187 //____________________________________________________________________72
00188 void NuFluctuator::ConfigHistosForTransitionAnalysis()
00189 {
00190   //Get cross-sections
00191   TFile *xsecfile = new TFile(fxsecfilename.c_str(),"READ");
00192 
00193   if (fNuMuCCCrossSectionGraph){
00194     delete fNuMuCCCrossSectionGraph;
00195     fNuMuCCCrossSectionGraph = 0;
00196   }
00197   if (fhNuMuCCCrossSections){
00198     delete fhNuMuCCCrossSections;
00199     fhNuMuCCCrossSections = 0;
00200   }
00201   TH1F* XSec_CC = (TH1F*) xsecfile->Get("h_numu_cc_tot");
00202   fhNuMuCCCrossSections = new TH1F(*XSec_CC);
00203   fhNuMuCCCrossSections->SetDirectory(0);
00204   Float_t *x = new Float_t[XSec_CC->GetNbinsX()];
00205   Float_t *y = new Float_t[XSec_CC->GetNbinsX()];
00206   for(int i=0;i<XSec_CC->GetNbinsX();i++) {
00207     x[i] = XSec_CC->GetBinCenter(i+1);
00208     y[i] = XSec_CC->GetBinContent(i+1);
00209   }
00210   fNuMuCCCrossSectionGraph = new TGraph(XSec_CC->GetNbinsX(),x,y);
00211   if (x) {delete[] x; x = 0;}
00212   if (y) {delete[] y; y = 0;}
00213 
00214   if (fNuBarCCCrossSectionGraph){
00215     delete fNuBarCCCrossSectionGraph;
00216     fNuBarCCCrossSectionGraph = 0;
00217   }
00218   if (fhNuBarCCCrossSections){
00219     delete fhNuBarCCCrossSections;
00220     fhNuBarCCCrossSections = 0;
00221   }
00222   XSec_CC = (TH1F*) xsecfile->Get("h_numubar_cc_tot");
00223   fhNuBarCCCrossSections = new TH1F(*XSec_CC);
00224   fhNuBarCCCrossSections->SetDirectory(0);
00225   x = new Float_t[XSec_CC->GetNbinsX()];
00226   y = new Float_t[XSec_CC->GetNbinsX()];
00227   for(int i=0;i<XSec_CC->GetNbinsX();i++) {
00228     x[i] = XSec_CC->GetBinCenter(i+1);
00229     y[i] = XSec_CC->GetBinContent(i+1);
00230   }
00231   fNuBarCCCrossSectionGraph = new TGraph(XSec_CC->GetNbinsX(),x,y);
00232   if (x) {delete[] x; x = 0;}
00233   if (y) {delete[] y; y = 0;}
00234   
00235   xsecfile->Close();
00236   if (xsecfile){delete xsecfile; xsecfile = 0;}
00237   
00238   //Get selection efficiencies
00239   TFile* selEffFile = new TFile(fSelEffFileName.c_str(),"READ");
00240 
00241   if (fhNuBarCCSelectionEfficiency){
00242     delete fhNuBarCCSelectionEfficiency;
00243     fhNuBarCCSelectionEfficiency = 0;
00244   }
00245   fhNuBarCCSelectionEfficiency = (TH1D*) selEffFile->Get("EfficiencyPQ_FD");
00246   fhNuBarCCSelectionEfficiency->SetDirectory(0);
00247 
00248   if (fhNuMuCCSelectionEfficiency){
00249     delete fhNuMuCCSelectionEfficiency;
00250     fhNuMuCCSelectionEfficiency = 0;
00251   }
00252   fhNuMuCCSelectionEfficiency = (TH1D*) selEffFile->Get("Efficiency_FD");
00253   fhNuMuCCSelectionEfficiency->SetDirectory(0);
00254 
00255   selEffFile->Close();
00256   if (selEffFile){delete selEffFile; selEffFile = 0;}
00257 }
00258 
00259 //____________________________________________________________________72
00260 void NuFluctuator::MakeCPTPDFs() const
00261 {
00262   if (!this->CheckConfigForPDFMaking()){return;}
00263         
00264   fhNuMuCCRecoE->Reset();
00265   fhNuBarCCRecoE->Reset();
00266         
00267   Int_t numMCEntries = fMonteCarlo->GetEntries();
00268   for (Int_t eventCounter = 0;
00269        eventCounter < numMCEntries;
00270        ++eventCounter){
00271     if (!(eventCounter%10000)){
00272       MSG("NuFluctuator",Msg::kInfo)
00273                         << eventCounter << " of " << numMCEntries
00274                         << endl
00275                         << "NuMu PDF has " << fhNuMuCCRecoE->GetEntries()
00276                         << " entries; NuBar PDF has "
00277                         << fhNuBarCCRecoE->GetEntries() << " entries."
00278                         << endl;
00279     }
00280     NuEvent event = fMonteCarlo->GetInfoObject(eventCounter);
00281     NuFluctuator::NuSelectionResult_t recoType = this->SelectedAs(event);
00282                 
00283 //     Double_t eventWeight = event.rw; 
00284     Double_t eventWeight = event.beamWeightRunI;
00285                 
00286     //Oscillate
00287                 eventWeight *= Oscillate(event);
00288     
00289     if (recoType==NuFluctuator::kCCNuMu){
00290       fhNuMuCCRecoE->Fill(event.energy,eventWeight);
00291     }
00292     if (recoType==NuFluctuator::kCCNuMuBar){
00293       fhNuBarCCRecoE->Fill(event.energy,eventWeight);
00294     }
00295   }
00296   fhNuMuCCRecoE->Scale(fFakeDataPoT/fMCPoT);
00297   fhNuBarCCRecoE->Scale(fFakeDataPoT/fMCPoT);
00298 }
00299 
00300 //____________________________________________________________________72
00301 void NuFluctuator::MakeShiftedCPTPDFs(const TString& xmlConfigFile) const
00302 {
00303   NuXMLConfig xmlConfig(xmlConfigFile);
00304 
00305   if (!this->CheckConfigForPDFMaking()){return;}
00306         
00307   fhNuMuCCRecoE->Reset();
00308   fhNuBarCCRecoE->Reset();
00309 
00310   NuSystematic nuSyst(xmlConfig);
00311         
00312   Int_t numMCEntries = fMonteCarlo->GetEntries();
00313   for (Int_t eventCounter = 0;
00314        eventCounter < numMCEntries;
00315        ++eventCounter){
00316     if (!(eventCounter%10000)){
00317       MSG("NuFluctuator",Msg::kInfo)
00318                         << eventCounter << " of " << numMCEntries
00319                         << endl
00320                         << "NuMu PDF has " << fhNuMuCCRecoE->GetEntries()
00321                         << " entries; NuBar PDF has "
00322                         << fhNuBarCCRecoE->GetEntries() << " entries."
00323                         << endl;
00324     }
00325     NuEvent event = fMonteCarlo->GetInfoObject(eventCounter);
00326     nuSyst.Shift(event);
00327     NuFluctuator::NuSelectionResult_t recoType = this->SelectedAs(event);
00328                 
00329     Double_t eventWeight = event.rw;
00330                 
00331     //Oscillate
00332                 eventWeight *= Oscillate(event);
00333     
00334     if (recoType==NuFluctuator::kCCNuMu){
00335       fhNuMuCCRecoE->Fill(event.energy,eventWeight);
00336     }
00337     if (recoType==NuFluctuator::kCCNuMuBar){
00338       fhNuBarCCRecoE->Fill(event.energy,eventWeight);
00339     }
00340   }
00341   fhNuMuCCRecoE->Scale(fFakeDataPoT/fMCPoT);
00342   fhNuBarCCRecoE->Scale(fFakeDataPoT/fMCPoT);
00343 }
00344 
00345 //____________________________________________________________________72
00346 Double_t NuFluctuator::Oscillate(NuEvent& event) const
00347 {
00348   if (1==event.iaction){
00349     if (14==event.inu){
00350       return NuUtilities::OscillationWeight(event.neuEnMC,
00351                                             fNuMuDm2, fNuMuSn2);
00352     }
00353     if (-14==event.inu){
00354       return NuUtilities::OscillationWeight(event.neuEnMC,
00355                                             fNuBarDm2, fNuBarSn2);
00356     }
00357   }
00358   return 1; // Doesn't oscillate
00359 }
00360 
00361 //____________________________________________________________________72
00362 void NuFluctuator::MakeTransitionPDFs()
00363 {
00364   if (!this->CheckConfigForPDFMaking()){return;}
00365   this->ConfigHistosForTransitionAnalysis();
00366 
00367   fhNuMuCCRecoE->Reset();
00368   fhNuBarCCRecoE->Reset();
00369 
00370   Int_t numMCEntries = fMonteCarlo->GetEntries();
00371   for (Int_t eventCounter = 0;
00372        eventCounter < numMCEntries;
00373        ++eventCounter){
00374     if (!(eventCounter%10000)){
00375       MSG("NuFluctuator",Msg::kInfo)
00376         << eventCounter << " of " << numMCEntries
00377         << endl;
00378     }
00379     NuEvent event = fMonteCarlo->GetInfoObject(eventCounter);
00380     NuFluctuator::NuSelectionResult_t recoType = this->SelectedAs(event);
00381 
00382     Double_t eventWeight = event.rw;
00383     Double_t transitionWeight = event.rw;
00384 
00385     //Oscillate
00386                 eventWeight *= Oscillate(event);
00387     
00388     Double_t nuBarSelEff = this->NuBarCCSelectionEfficiency(event.neuEnMC);
00389     Double_t nuBarXSec = this->NuBarCCCrossSection(event.neuEnMC);
00390     Double_t nuMuSelEff = this->NuMuCCSelectionEfficiency(event.neuEnMC);
00391     Double_t nuMuXSec = this->NuMuCCCrossSection(event.neuEnMC);
00392     
00393     if (recoType==NuFluctuator::kCCNuMu){
00394       fhNuMuCCRecoE->Fill(event.energy,eventWeight);
00395       if (1==event.iaction && 14==event.inu){
00396         transitionWeight *= fTransitionProb*(1-NuUtilities::OscillationWeight(event.neuEnMC, fNuMuDm2, fNuMuSn2));
00397         if (!nuMuXSec || !nuMuSelEff){
00398           MSG("NuFluctuator.cxx",Msg::kWarning)
00399             << "Trying to apply transitions to a NuMu event "
00400             << "that shouldn't exist."
00401             << endl;
00402         }
00403         else{
00404           transitionWeight /= nuMuXSec;
00405           transitionWeight /= nuMuSelEff;
00406           transitionWeight *= nuBarSelEff;
00407           transitionWeight *= nuBarXSec;
00408           fhNuBarCCRecoE->Fill(event.energy,transitionWeight);
00409         }
00410       }
00411     }
00412     if (recoType==NuFluctuator::kCCNuMuBar){
00413       fhNuBarCCRecoE->Fill(event.energy,eventWeight);
00414       if (1==event.iaction && -14==event.inu){
00415         transitionWeight *= fTransitionProb*(1-NuUtilities::OscillationWeight(event.neuEnMC, fNuMuDm2, fNuMuSn2));
00416         if (!nuMuXSec || !nuMuSelEff){
00417           MSG("NuFluctuator.cxx",Msg::kWarning)
00418             << "Trying to apply transitions to a NuMu event "
00419             << "that shouldn't exist."
00420             << endl;
00421         }
00422         else{
00423           transitionWeight *= nuMuXSec;
00424           transitionWeight *= nuMuSelEff;
00425           transitionWeight /= nuBarSelEff;
00426           transitionWeight /= nuBarXSec;
00427           fhNuMuCCRecoE->Fill(event.energy,transitionWeight);
00428         }
00429       }
00430     }
00431   }
00432   fhNuMuCCRecoE->Scale(fFakeDataPoT/fMCPoT);
00433   fhNuBarCCRecoE->Scale(fFakeDataPoT/fMCPoT);
00434 }
00435 
00436 //____________________________________________________________________72
00437 void NuFluctuator::MakeShiftedTransitionPDFs(const TString& xmlConfigFile)
00438 {
00439   NuXMLConfig xmlConfig(xmlConfigFile);
00440 
00441   if (!this->CheckConfigForPDFMaking()){return;}
00442   this->ConfigHistosForTransitionAnalysis();
00443 
00444   fhNuMuCCRecoE->Reset();
00445   fhNuBarCCRecoE->Reset();
00446 
00447   NuSystematic nuSyst(xmlConfig);
00448 
00449   Int_t numMCEntries = fMonteCarlo->GetEntries();
00450   for (Int_t eventCounter = 0;
00451        eventCounter < numMCEntries;
00452        ++eventCounter){
00453     if (!(eventCounter%10000)){
00454       MSG("NuFluctuator",Msg::kInfo)
00455         << eventCounter << " of " << numMCEntries
00456         << endl;
00457     }
00458     NuEvent event = fMonteCarlo->GetInfoObject(eventCounter);
00459     nuSyst.Shift(event);
00460     NuFluctuator::NuSelectionResult_t recoType = this->SelectedAs(event);
00461 
00462     Double_t eventWeight = event.rw;
00463     Double_t transitionWeight = event.rw;
00464 
00465     //Oscillate
00466                 eventWeight *= Oscillate(event);
00467     
00468     Double_t nuBarSelEff = this->NuBarCCSelectionEfficiency(event.neuEnMC);
00469     Double_t nuBarXSec = this->NuBarCCCrossSection(event.neuEnMC);
00470     Double_t nuMuSelEff = this->NuMuCCSelectionEfficiency(event.neuEnMC);
00471     Double_t nuMuXSec = this->NuMuCCCrossSection(event.neuEnMC);
00472     
00473     if (recoType==NuFluctuator::kCCNuMu){
00474       fhNuMuCCRecoE->Fill(event.energy,eventWeight);
00475       if (1==event.iaction && 14==event.inu){
00476         transitionWeight *= fTransitionProb*(1-NuUtilities::OscillationWeight(event.neuEnMC, fNuMuDm2, fNuMuSn2));
00477         if (!nuMuXSec || !nuMuSelEff){
00478           MSG("NuFluctuator.cxx",Msg::kWarning)
00479             << "Trying to apply transitions to a NuMu event "
00480             << "that shouldn't exist."
00481             << endl;
00482         }
00483         else{
00484           transitionWeight /= nuMuXSec;
00485           transitionWeight /= nuMuSelEff;
00486           transitionWeight *= nuBarSelEff;
00487           transitionWeight *= nuBarXSec;
00488           fhNuBarCCRecoE->Fill(event.energy,transitionWeight);
00489         }
00490       }
00491     }
00492     if (recoType==NuFluctuator::kCCNuMuBar){
00493       fhNuBarCCRecoE->Fill(event.energy,eventWeight);
00494       if (1==event.iaction && -14==event.inu){
00495         transitionWeight *= fTransitionProb*(1-NuUtilities::OscillationWeight(event.neuEnMC, fNuMuDm2, fNuMuSn2));
00496         if (!nuMuXSec || !nuMuSelEff){
00497           MSG("NuFluctuator.cxx",Msg::kWarning)
00498             << "Trying to apply transitions to a NuMu event "
00499             << "that shouldn't exist."
00500             << endl;
00501         }
00502         else{
00503           transitionWeight *= nuMuXSec;
00504           transitionWeight *= nuMuSelEff;
00505           transitionWeight /= nuBarSelEff;
00506           transitionWeight /= nuBarXSec;
00507           fhNuMuCCRecoE->Fill(event.energy,transitionWeight);
00508         }
00509       }
00510     }
00511   }
00512   fhNuMuCCRecoE->Scale(fFakeDataPoT/fMCPoT);
00513   fhNuBarCCRecoE->Scale(fFakeDataPoT/fMCPoT);
00514 }
00515 
00516 //____________________________________________________________________72
00517 const Double_t NuFluctuator
00518 ::NuBarCCCrossSection(const Double_t trueNuE) const
00519 {
00520   //  return fNuBarCCCrossSectionGraph->Eval(trueNuE,0,"");
00521   return fhNuBarCCCrossSections->
00522     GetBinContent(fhNuBarCCCrossSections->FindBin(trueNuE));
00523 }
00524 
00525 //____________________________________________________________________72
00526 const Double_t NuFluctuator
00527 ::NuBarCCSelectionEfficiency(const Double_t trueNuE) const
00528 {
00529   return fhNuBarCCSelectionEfficiency->
00530     GetBinContent(fhNuBarCCSelectionEfficiency->FindBin(trueNuE));
00531 }
00532 
00533 //____________________________________________________________________72
00534 const Double_t NuFluctuator
00535 ::NuMuCCCrossSection(const Double_t trueNuE) const
00536 {
00537   //  return fNuMuCCCrossSectionGraph->Eval(trueNuE,0,"");
00538   return fhNuMuCCCrossSections->
00539     GetBinContent(fhNuMuCCCrossSections->FindBin(trueNuE));
00540 }
00541 
00542 //____________________________________________________________________72
00543 const Double_t NuFluctuator
00544 ::NuMuCCSelectionEfficiency(const Double_t trueNuE) const
00545 {
00546   return fhNuMuCCSelectionEfficiency->
00547     GetBinContent(fhNuMuCCSelectionEfficiency->FindBin(trueNuE));
00548 }
00549 
00550 //____________________________________________________________________72
00551 const NuFluctuator::NuSelectionResult_t
00552 NuFluctuator::SelectedAs(NuEvent& nuEvent) const
00553 {
00554   NuCuts nuCuts;
00555   if (NuCuts::kUnknown != this->SelectionScheme()){
00556     nuEvent.anaVersion = this->SelectionScheme();
00557   }
00558   
00559   //cut on LI
00560   if (nuCuts.IsLI(nuEvent)) return NuFluctuator::kUnknown;
00561   //cut on the data quality
00562   if (!nuCuts.IsGoodDataQuality(nuEvent)) return NuFluctuator::kUnknown;
00563   //cut on the spill time
00564   if (!nuCuts.IsGoodTimeToNearestSpill(nuEvent)) return NuFluctuator::kUnknown;
00565   //cut on the beam
00566   if (!nuCuts.IsGoodBeam(nuEvent)) return NuFluctuator::kUnknown;
00567 
00568   //cut on whether event vtx is in fid vol (does nothing for CC ana)
00569   //    if (!nuCuts.IsInFidVol(evt,nu)) continue;
00570   //ensure good number of tracks in event (note preselection above)
00571   if (!nuCuts.IsGoodNumberOfTracks(nuEvent)) return NuFluctuator::kUnknown;
00572   //check trk is in fiducial volume (note preselection above)
00573   if (!nuCuts.IsInFidVolTrk(nuEvent)) return NuFluctuator::kUnknown;
00574 
00575   //require a good trk fit
00576   if (!nuCuts.IsGoodTrackFitPass(nuEvent)) return NuFluctuator::kUnknown;
00577   //require a forward going neutrino about beam direction
00578   if (!nuCuts.IsGoodDirCos(nuEvent)) return NuFluctuator::kUnknown;
00579 
00580   //cut on the PID
00581   if (!nuCuts.IsGoodPID(nuEvent)) {
00582     return NuFluctuator::kUnknown;
00583   }
00584   //cut on the fractional track momentum and sign error      
00585   if (!nuCuts.IsGoodSigmaQP_QP(nuEvent)) {
00586     return NuFluctuator::kUnknown;
00587   }
00588   //cut on the track fit probability      
00589   if (!nuCuts.IsGoodFitProb(nuEvent)) {
00590     return NuFluctuator::kUnknown;
00591   }
00592   if (!nuCuts.IsGoodMajorityCurvature(nuEvent)){
00593     return NuFluctuator::kUnknown;
00594   }
00595   
00596   if (-1==nuEvent.charge){return NuFluctuator::kCCNuMu;}
00597   if (1==nuEvent.charge){return NuFluctuator::kCCNuMuBar;}
00598   return NuFluctuator::kUnknown;
00599 }
00600 
00601 //____________________________________________________________________72
00602 void NuFluctuator::NuMuCCRecoEBinning(const vector<Double_t>& numuBins)
00603 {
00604   this->PDFsFilled(false);
00605 
00606   if (fhNuMuCCRecoE) {
00607     delete fhNuMuCCRecoE; fhNuMuCCRecoE = 0;
00608   }
00609 
00610   Int_t size = numuBins.size();
00611   if (!size){
00612     MSG("NuCrossSectionFitter",Msg::kError)
00613       << "NuMu reconstructed energy binning not supplied."
00614       << endl;
00615     return;
00616   }
00617 
00618   Double_t* recoEBinEdges = new Double_t[size];
00619 
00620   Int_t i=0;
00621   for (vector<Double_t>::const_iterator it =
00622          numuBins.begin();
00623        it != numuBins.end();
00624        ++it, ++i){
00625     recoEBinEdges[i] = *it;
00626   }
00627 
00628   fhNuMuCCRecoE = new TH1D("fhNuMuCCRecoE",
00629                            "",
00630                            size-1,
00631                            recoEBinEdges);
00632   return;
00633 }
00634 
00635 //____________________________________________________________________72
00636 void NuFluctuator::NuBarCCRecoEBinning(const vector<Double_t>& nubarBins)
00637 {
00638   this->PDFsFilled(false);
00639 
00640   if (fhNuBarCCRecoE) {
00641     delete fhNuBarCCRecoE; fhNuBarCCRecoE = 0;
00642   }
00643 
00644   Int_t size = nubarBins.size();
00645   if (!size){
00646     MSG("NuCrossSectionFitter",Msg::kError)
00647       << "NuMu reconstructed energy binning not supplied."
00648       << endl;
00649     return;
00650   }
00651 
00652   Double_t* recoEBinEdges = new Double_t[size];
00653 
00654   Int_t i=0;
00655   for (vector<Double_t>::const_iterator it =
00656          nubarBins.begin();
00657        it != nubarBins.end();
00658        ++it, ++i){
00659     recoEBinEdges[i] = *it;
00660   }
00661 
00662   fhNuBarCCRecoE = new TH1D("fhNuBarCCRecoE",
00663                                "",
00664                                size-1,
00665                                recoEBinEdges);
00666   return;
00667 }
00668 
00669 //____________________________________________________________________72
00670 void NuFluctuator::MonteCarlo(const string& mcFileName)
00671 {
00672   this->PDFsFilled(false);
00673 
00674   if (fMonteCarlo){
00675     delete fMonteCarlo; fMonteCarlo = 0;
00676   }
00677   fMonteCarlo = new NuTreeWrapper(mcFileName);
00678   fMCPoT = fMonteCarlo->GetPoT();
00679 }

Generated on Mon Feb 15 11:07:13 2010 for loon by  doxygen 1.3.9.1