NueMatrixHelper Class Reference

#include <NueMatrixHelper.h>

Inheritance diagram for NueMatrixHelper:
NueExtrapHelper

List of all members.

Public Member Functions

 NueMatrixHelper (Int_t, Double_t, Double_t)
 NueMatrixHelper (Int_t, Double_t *)
virtual ~NueMatrixHelper ()
void MakeANANUEPlots (Selection::Selection_t)
void WriteFile (std::string)
virtual void AddNueSystematic (NueSystematic *)

Private Attributes

std::map< NueSystematic
*, std::map
< Background::Background_t,
MatrixHists * > > 
fMatrixHists

Detailed Description

Definition at line 14 of file NueMatrixHelper.h.


Constructor & Destructor Documentation

NueMatrixHelper::NueMatrixHelper ( Int_t  nbins,
Double_t  lowx,
Double_t  uppx 
)

Definition at line 23 of file NueMatrixHelper.cxx.

00023                                                                         :
00024   NueExtrapHelper(nbins,lowx,uppx)
00025 {
00026 }

NueMatrixHelper::NueMatrixHelper ( Int_t  nbins,
Double_t *  bins 
)

Definition at line 28 of file NueMatrixHelper.cxx.

00028                                                            :
00029   NueExtrapHelper(nbins,bins)
00030 {
00031 }

NueMatrixHelper::~NueMatrixHelper (  )  [virtual]

Definition at line 221 of file NueMatrixHelper.cxx.

00222 {
00223 }


Member Function Documentation

void NueMatrixHelper::AddNueSystematic ( NueSystematic nueSys  )  [virtual]

Reimplemented from NueExtrapHelper.

Definition at line 33 of file NueMatrixHelper.cxx.

References bfld::AsString(), fMatrixHists, NueExtrapHelper::fNXBins, NueExtrapHelper::fXBins, and NueSystematic::GetName().

00034 {
00035   fMatrixHists[nueSys];
00036   Int_t max_bg_index = 0;
00037   while(strcmp(Background::
00038                AsString(Background::EBackground(max_bg_index)),
00039                "?Unknown?")!=0) {
00040     gDirectory->cd("/");
00041     string mh_name = string(Background::
00042                             AsString(Background::EBackground(max_bg_index)));
00043     mh_name += "_" + string(nueSys->GetName());
00044     MatrixHists *mh = new MatrixHists(mh_name.c_str());
00045     mh->fDirectory->cd();
00046     
00047     //helper histos:
00048     mh->fRecoVsTrueEnergy_ND = 
00049       new TH2D("RecoVsTrueEnergy_ND",
00050                "Reco Vs True Energy (NearDet)",
00051                fNXBins,fXBins,fNXBins,fXBins);
00052     mh->fRecoVsTrueEnergy_ND->Sumw2();
00053 
00054     mh->fRecoVsTrueEnergy_FD = 
00055       new TH2D("RecoVsTrueEnergy_FD",
00056                "Reco Vs True Energy (FarDet)",
00057                fNXBins,fXBins,fNXBins,fXBins);
00058     mh->fRecoVsTrueEnergy_FD->Sumw2();
00059 
00060     mh->fEfficiency_ND = 
00061       new TH1D("Efficiency_ND",
00062                "NuMu CC Selection Efficiency with True Energy (NearDet)",
00063                fNXBins,fXBins);
00064     mh->fEfficiency_ND->Sumw2();
00065 
00066     mh->fEfficiency_FD = 
00067       new TH1D("Efficiency_FD",
00068                "NuMu CC Selection Efficiency with True Energy (FarDet)",
00069                fNXBins,fXBins);
00070     mh->fEfficiency_FD->Sumw2();
00071 
00072     mh->fPurity_ND = 
00073       new TH1D("Purity_ND",
00074                "NuMu CC Selection Purity with True Energy (NearDet)",
00075                fNXBins,fXBins);
00076     mh->fPurity_ND->Sumw2();
00077 
00078     mh->fPurity_FD = 
00079       new TH1D("Purity_FD",
00080                "NuMu CC Selection Purity with True Energy (FarDet)",
00081                fNXBins,fXBins);
00082     mh->fPurity_FD->Sumw2();
00083   
00084     mh->fFDVsNDMatrix = 
00085       new TH2D("FDVsNDMatrix",
00086                "Number of FD Vs ND Events with True Energy",
00087                fNXBins,fXBins,fNXBins,fXBins);
00088     mh->fFDVsNDMatrix->Sumw2();
00089 
00090     mh->fFDVsNDMatrixRW = 
00091       new TH2D("FDVsNDMatrixRW",
00092                "Number of FD Vs ND Events with True Energy (with Near Reweight)",
00093                fNXBins,fXBins,fNXBins,fXBins);
00094     mh->fFDVsNDMatrixRW->Sumw2();
00095 
00096     mh->fFDVsNDMatrixXSec = 
00097       new TH2D("FDVsNDMatrixXSec",
00098                "Number of FD Vs ND Events with True Energy (with XSec)",
00099                fNXBins,fXBins,fNXBins,fXBins);
00100     mh->fFDVsNDMatrixXSec->Sumw2();
00101     
00102     mh->fFDVsNDMatrixXSecRW = 
00103       new TH2D("FDVsNDMatrixXSecRW",
00104                "Number of FD Vs ND Events with True Energy (with XSec + Near Reweight)",
00105                fNXBins,fXBins,fNXBins,fXBins);
00106     mh->fFDVsNDMatrixXSecRW->Sumw2();
00107     
00108     mh->fXSec_CC = 
00109       new TH1D("XSec_CC","NuMu CC XSection with True Energy",
00110                fNXBins,fXBins);
00111     mh->fXSec_CC->Sumw2();
00112     
00113     mh->fFracErrOnPred = 
00114       new TH1D("FracErrOnPred",
00115                "Fractional Error on Energy Spectrum with Reco Energy",
00116                fNXBins,fXBins);
00117     mh->fFracErrOnPred->Sumw2();
00118     
00119     //Check list histos:
00120     mh->fRecoEnergyAllEvents_ND = 
00121       new TH1D("RecoEnergyAllEvents_ND",
00122                "Selected Events with Reco Energy (NearDet)",
00123                fNXBins,fXBins);
00124     mh->fRecoEnergyAllEvents_ND->Sumw2();
00125     
00126     mh->fRecoEnergyCCOnlyEvents_ND = 
00127       new TH1D("RecoEnergyCCOnlyEvents_ND",
00128                "NuMu CC Selected Events with Reco Energy (NearDet)",
00129                fNXBins,fXBins);
00130     mh->fRecoEnergyCCOnlyEvents_ND->Sumw2();
00131     
00132     mh->fTrueEnergyCCOnlyEvents_ND = 
00133       new TH1D("TrueEnergyCCOnlyEvents_ND",
00134                "NuMu CC Selected Events with True Energy (NearDet)",
00135                fNXBins,fXBins);
00136     mh->fTrueEnergyCCOnlyEvents_ND->Sumw2();
00137     
00138     mh->fTrueEnergyTrueCCFidEvents_ND = 
00139       new TH1D("TrueEnergyTrueCCFidEvents_ND",
00140                "True Fid NuMu CC Events with True Energy (NearDet)",
00141                fNXBins,fXBins);
00142     mh->fTrueEnergyTrueCCFidEvents_ND->Sumw2();
00143     
00144     mh->fTrueEnergyNuFlux_ND = 
00145       new TH1D("TrueEnergyNuFlux_ND",
00146                "Neutrino Flux with True Energy (NearDet)",
00147                fNXBins,fXBins);
00148     mh->fTrueEnergyNuFlux_ND->Sumw2();
00149     
00150     mh->fTrueEnergyNuFluxRW_ND = 
00151       new TH1D("TrueEnergyNuFluxRW_ND",
00152                "Neutrino Flux with True Energy (NearDet with Reweighting)",
00153                fNXBins,fXBins);
00154     mh->fTrueEnergyNuFluxRW_ND->Sumw2();
00155     
00156     mh->fTrueEnergyNuFlux_FD = 
00157       new TH1D("TrueEnergyNuFlux_FD",
00158                "Neutrino Flux with True Energy (FarDet)",
00159                fNXBins,fXBins);
00160     mh->fTrueEnergyNuFlux_FD->Sumw2();
00161     
00162     mh->fTrueEnergyNuFluxRW_FD = 
00163       new TH1D("TrueEnergyNuFluxRW_FD",
00164                "Neutrino Flux with True Energy (FarDet with Reweighting)",
00165                fNXBins,fXBins);
00166     mh->fTrueEnergyNuFluxRW_FD->Sumw2();
00167     
00168     mh->fTrueEnergyCCFlux_ND = 
00169       new TH1D("TrueEnergyCCFlux_ND",
00170                "NuMu CC Flux with True Energy (NearDet)",
00171                fNXBins,fXBins);
00172     mh->fTrueEnergyCCFlux_ND->Sumw2();
00173     
00174     mh->fTrueEnergyCCFluxRW_ND = 
00175       new TH1D("TrueEnergyCCFluxRW_ND",
00176                "NuMu CC Flux with True Energy with (NearDet with Reweighting)",
00177                fNXBins,fXBins);
00178     mh->fTrueEnergyCCFluxRW_ND->Sumw2();
00179     
00180     mh->fTrueEnergyCCFlux_FD = 
00181       new TH1D("TrueEnergyCCFlux_FD",
00182                "NuMu CC Flux with True Energy (FarDet)",
00183                fNXBins,fXBins);
00184     mh->fTrueEnergyCCFlux_FD->Sumw2();
00185     
00186     mh->fTrueEnergyCCFluxRW_FD = 
00187       new TH1D("TrueEnergyCCFluxRW_FD",
00188                "NuMu CC Flux with True Energy (FarDet with Reweighing)",
00189                fNXBins,fXBins);
00190     mh->fTrueEnergyCCFluxRW_FD->Sumw2();
00191     
00192     mh->fTrueEnergyTrueCCFidEvents_FD = 
00193       new TH1D("TrueEnergyTrueCCFidEvents_FD",
00194                "True Fid NuMu CC Events with True Energy (FarDet)",
00195                fNXBins,fXBins);
00196     mh->fTrueEnergyTrueCCFidEvents_FD->Sumw2();
00197     
00198     mh->fTrueEnergyCCOnlyEvents_FD = 
00199       new TH1D("TrueEnergyCCOnlyEvents_FD",
00200                "NuMu CC Selected Events with True Energy (FarDet)",
00201                fNXBins,fXBins);
00202     mh->fTrueEnergyCCOnlyEvents_FD->Sumw2();
00203     
00204     mh->fRecoEnergyCCOnlyEvents_FD = 
00205       new TH1D("RecoEnergyCCOnlyEvents_FD",
00206                "NuMu CC Selected Events with Reco Energy (FarDet)",
00207                fNXBins,fXBins);
00208     mh->fRecoEnergyCCOnlyEvents_FD->Sumw2();
00209   
00210     mh->fRecoEnergyAllEvents_FD = 
00211       new TH1D("RecoEnergyAllEvents_FD",
00212              "Selected Events with Reco Energy (FarDet)",
00213                fNXBins,fXBins);
00214     mh->fRecoEnergyAllEvents_FD->Sumw2();
00215     (fMatrixHists[nueSys])[Background::EBackground(max_bg_index)] = mh;
00216     max_bg_index++;
00217   }
00218   gDirectory->cd("/");
00219 }

void NueMatrixHelper::MakeANANUEPlots ( Selection::Selection_t  sel  ) 

Definition at line 225 of file NueMatrixHelper.cxx.

References NueExtrapHelper::fCurSel, NueExtrapHelper::fFarChain, NueRecord::fluxinfo, fMatrixHists, NueExtrapHelper::fNearChain, NueExtrapHelper::fNXBins, NueExtrapHelper::fRecord, NueExtrapHelper::GetNueEnergy(), ANtpTruthInfo::interactionType, NueRecord::mctrue, ANtpTruthInfoBeam::nonOscNuFlavor, ANtpTruthInfo::nuEnergy, ANtpTruthInfo::nuFlavor, NueExtrapHelper::PassCuts(), NtpMCFluxInfo::tptype, and Background::TranslateFromMC().

00226 {
00227   if(!fFarChain || !fNearChain) return;  
00228   fCurSel = sel;
00229 
00230   std::map<NueSystematic*,
00231     std::map<Background::Background_t,MatrixHists*> >::iterator mapBeg = 
00232     fMatrixHists.begin();
00233   std::map<NueSystematic*,
00234     std::map<Background::Background_t,MatrixHists*> >::iterator mapEnd = 
00235     fMatrixHists.end();
00236   if(mapBeg==mapEnd) return;
00237 
00238   //ND:
00239   Int_t ndEntries = fNearChain->GetEntries();
00240   for(int i=0;i<ndEntries;i++){
00241     if(i%100000==0) cout << "Processing event " << i << " / " << ndEntries << endl;
00242     mapBeg = fMatrixHists.begin();
00243     while(mapBeg!=mapEnd) {
00244       fNearChain->GetEvent(i);
00245       Double_t totWeight = 1;
00246       if((mapBeg->first)) totWeight = (mapBeg->first)->UpdateRecord(fRecord,sel);
00247       if(this->PassCuts(sel)) {
00248         Double_t recoEnergy = this->GetNueEnergy(sel);
00249         //fill histos:
00250         std::map<Background::Background_t,MatrixHists*>::iterator mhBeg = mapBeg->second.begin();
00251         std::map<Background::Background_t,MatrixHists*>::iterator mhEnd = mapBeg->second.end();
00252         while(mhBeg!=mhEnd){
00253           mhBeg->second->fRecoEnergyAllEvents_ND->Fill(recoEnergy,totWeight);
00254           mhBeg++;
00255         }
00256         Background::Background_t bg = 
00257           Background::TranslateFromMC(fRecord->mctrue.interactionType,
00258                                       fRecord->mctrue.nuFlavor,
00259                                       fRecord->mctrue.nonOscNuFlavor,
00260                                       fRecord->fluxinfo.tptype);                
00261         (mapBeg->second)[bg]->fRecoEnergyCCOnlyEvents_ND->Fill(recoEnergy,totWeight);
00262         (mapBeg->second)[bg]->fTrueEnergyCCOnlyEvents_ND->Fill(fRecord->mctrue.nuEnergy,totWeight);
00263         (mapBeg->second)[bg]->fPurity_ND->Fill(recoEnergy,totWeight);
00264         (mapBeg->second)[bg]->fEfficiency_ND->Fill(fRecord->mctrue.nuEnergy,totWeight);
00265         (mapBeg->second)[bg]->fRecoVsTrueEnergy_ND->Fill(fRecord->mctrue.nuEnergy,
00266                                                          recoEnergy,totWeight); 
00267         Background::Background_t bg2 = 
00268           Background::TranslateFromMC(fRecord->mctrue.interactionType,
00269                                       fRecord->mctrue.nuFlavor,
00270                                       fRecord->mctrue.nonOscNuFlavor);
00271         if(bg2!=bg) {
00272           (mapBeg->second)[bg2]->fRecoEnergyCCOnlyEvents_ND->Fill(recoEnergy,totWeight);
00273           (mapBeg->second)[bg2]->fTrueEnergyCCOnlyEvents_ND->Fill(fRecord->mctrue.nuEnergy,totWeight);
00274           (mapBeg->second)[bg2]->fPurity_ND->Fill(recoEnergy,totWeight);
00275           (mapBeg->second)[bg2]->fEfficiency_ND->Fill(fRecord->mctrue.nuEnergy,totWeight);
00276           (mapBeg->second)[bg2]->fRecoVsTrueEnergy_ND->Fill(fRecord->mctrue.nuEnergy,
00277                                                             recoEnergy,totWeight);
00278         }
00279       }
00280     }
00281   }
00282   
00283   //FD:
00284   Int_t fdEntries = fFarChain->GetEntries();
00285   for(int i=0;i<fdEntries;i++){
00286     if(i%100000==0) cout << "Processing event " << i << " / " << ndEntries << endl;
00287     mapBeg = fMatrixHists.begin();
00288     while(mapBeg!=mapEnd) {
00289       fFarChain->GetEvent(i);
00290       Double_t totWeight = 1;
00291       if((mapBeg->first)) totWeight = (mapBeg->first)->UpdateRecord(fRecord,sel);
00292       if(this->PassCuts(sel)) {
00293         Double_t recoEnergy = this->GetNueEnergy(sel);
00294         //fill histos:
00295         std::map<Background::Background_t,MatrixHists*>::iterator mhBeg = mapBeg->second.begin();
00296         std::map<Background::Background_t,MatrixHists*>::iterator mhEnd = mapBeg->second.end();
00297         while(mhBeg!=mhEnd){
00298           mhBeg->second->fRecoEnergyAllEvents_FD->Fill(recoEnergy,totWeight);
00299           mhBeg++;
00300         }
00301         Background::Background_t bg = 
00302           Background::TranslateFromMC(fRecord->mctrue.interactionType,
00303                                       fRecord->mctrue.nuFlavor,
00304                                       fRecord->mctrue.nonOscNuFlavor,
00305                                       fRecord->fluxinfo.tptype);                
00306         (mapBeg->second)[bg]->fRecoEnergyCCOnlyEvents_FD->Fill(recoEnergy,totWeight);
00307         (mapBeg->second)[bg]->fTrueEnergyCCOnlyEvents_FD->Fill(fRecord->mctrue.nuEnergy,totWeight);
00308         (mapBeg->second)[bg]->fPurity_FD->Fill(recoEnergy,totWeight);
00309         (mapBeg->second)[bg]->fEfficiency_FD->Fill(fRecord->mctrue.nuEnergy,totWeight);
00310         (mapBeg->second)[bg]->fRecoVsTrueEnergy_FD->Fill(fRecord->mctrue.nuEnergy,
00311                                                          recoEnergy,totWeight); 
00312         Background::Background_t bg2 = 
00313           Background::TranslateFromMC(fRecord->mctrue.interactionType,
00314                                       fRecord->mctrue.nuFlavor,
00315                                       fRecord->mctrue.nonOscNuFlavor);
00316         if(bg2!=bg) {
00317           (mapBeg->second)[bg2]->fRecoEnergyCCOnlyEvents_FD->Fill(recoEnergy,totWeight);
00318           (mapBeg->second)[bg2]->fTrueEnergyCCOnlyEvents_FD->Fill(fRecord->mctrue.nuEnergy,totWeight);
00319           (mapBeg->second)[bg2]->fPurity_FD->Fill(recoEnergy,totWeight);
00320           (mapBeg->second)[bg2]->fEfficiency_FD->Fill(fRecord->mctrue.nuEnergy,totWeight);
00321           (mapBeg->second)[bg2]->fRecoVsTrueEnergy_FD->Fill(fRecord->mctrue.nuEnergy,
00322                                                             recoEnergy,totWeight);
00323         }
00324       }
00325     }
00326   }
00327   
00328   mapBeg = fMatrixHists.begin();
00329   while(mapBeg!=mapEnd) {
00330     std::map<Background::Background_t,MatrixHists*>::iterator mhBeg = mapBeg->second.begin();
00331     std::map<Background::Background_t,MatrixHists*>::iterator mhEnd = mapBeg->second.end();
00332     while(mhBeg!=mhEnd) {
00333       for(int i=1;i<=fNXBins;i++){ //loop over true bins
00334         for(int j=1;j<=fNXBins+1;j++){ //loop over reco bins
00335           if(mhBeg->second->fRecoEnergyCCOnlyEvents_ND->GetBinContent(j)>0 && 
00336              mhBeg->second->fRecoVsTrueEnergy_ND->GetBinContent(i,j)>0) {
00337             Float_t error = ( mhBeg->second->fRecoVsTrueEnergy_ND->GetBinError(i,j) / 
00338                               mhBeg->second->fRecoVsTrueEnergy_ND->GetBinContent(i,j) );
00339             mhBeg->second->fRecoVsTrueEnergy_ND->
00340               SetBinContent(i,j,mhBeg->second->fRecoVsTrueEnergy_ND->GetBinContent(i,j)/
00341                             mhBeg->second->fRecoEnergyCCOnlyEvents_ND->GetBinContent(j));
00342             mhBeg->second->fRecoVsTrueEnergy_ND->
00343               SetBinError(i,j,error*mhBeg->second->fRecoVsTrueEnergy_ND->GetBinContent(i,j));
00344           }
00345           else {
00346             mhBeg->second->fRecoVsTrueEnergy_ND->SetBinContent(i,j,0);
00347             mhBeg->second->fRecoVsTrueEnergy_ND->SetBinError(i,j,0);
00348           }
00349           if(mhBeg->second->fRecoEnergyCCOnlyEvents_FD->GetBinContent(j)>0 && 
00350              mhBeg->second->fRecoVsTrueEnergy_FD->GetBinContent(i,j)>0) {
00351             Float_t error = ( mhBeg->second->fRecoVsTrueEnergy_FD->GetBinError(i,j) / 
00352                               mhBeg->second->fRecoVsTrueEnergy_FD->GetBinContent(i,j) );
00353             mhBeg->second->fRecoVsTrueEnergy_FD->
00354               SetBinContent(i,j,mhBeg->second->fRecoVsTrueEnergy_FD->GetBinContent(i,j)/
00355                             mhBeg->second->fRecoEnergyCCOnlyEvents_FD->GetBinContent(j));
00356             mhBeg->second->fRecoVsTrueEnergy_FD->
00357               SetBinError(i,j,error*mhBeg->second->fRecoVsTrueEnergy_FD->GetBinContent(i,j));
00358           }
00359           else {
00360             mhBeg->second->fRecoVsTrueEnergy_FD->SetBinContent(i,j,0);
00361             mhBeg->second->fRecoVsTrueEnergy_FD->SetBinError(i,j,0);
00362           }
00363         }
00364       }
00365     }
00366   }  
00367 }

void NueMatrixHelper::WriteFile ( std::string  tag  )  [virtual]

Reimplemented from NueExtrapHelper.

Definition at line 923 of file NueMatrixHelper.cxx.

References Selection::AsString(), NueExtrapHelper::fCurSel, NueExtrapHelper::fFarPOT, fMatrixHists, and NueExtrapHelper::fNearPOT.

00924 {
00925   std::map<NueSystematic*,
00926     std::map<Background::Background_t,MatrixHists*> >::iterator mapBeg = 
00927     fMatrixHists.begin();
00928   std::map<NueSystematic*,
00929     std::map<Background::Background_t,MatrixHists*> >::iterator mapEnd = 
00930     fMatrixHists.end();
00931   if(mapBeg==mapEnd) return;
00932 
00933   std::string filename = "MatrixHelper_" + tag + ".root";
00934   TFile *file = new TFile(filename.c_str(),"RECREATE");
00935   file->cd();
00936 
00937   char selection[256]; 
00938   sprintf(selection,"%s",Selection::AsString(fCurSel));  
00939   TTree *tree = new TTree("matrixtree","matrixtree");
00940   tree->Branch("Selection",selection,"Selection/C");
00941   tree->Branch("nearPOT",&fNearPOT,"nearPOT/D");
00942   tree->Branch("farPOT",&fFarPOT,"farPOT/D");
00943 
00944   while(mapBeg!=mapEnd){
00945     std::map<Background::Background_t,MatrixHists*>::iterator Matbeg = (mapBeg->second).begin();
00946     std::map<Background::Background_t,MatrixHists*>::iterator Matend = (mapBeg->second).end();
00947     while(Matbeg!=Matend) {
00948       Matbeg->second->fDirectory->Write();
00949       Matbeg++;
00950     }
00951     if((mapBeg->first)) (mapBeg->first)->MakeBranches(tree);
00952     tree->Fill();
00953     mapBeg++;
00954   }
00955   tree->Write();
00956   delete file;
00957 }


Member Data Documentation

Definition at line 32 of file NueMatrixHelper.h.

Referenced by AddNueSystematic(), MakeANANUEPlots(), and WriteFile().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1