SysFileGen2D Class Reference

#include <SysFileGen2D.h>

List of all members.

Public Member Functions

 SysFileGen2D ()
virtual ~SysFileGen2D ()
void Initialize ()
void AddSystematic (std::string sys)
void SetOutputFile (std::string name="DefaultOut.root")
void SetNearPOT (double pot=1e19)
void SetFarPOT (double pot=3.14e20)
void AddPID (std::string pid)
void SetCutLevel (Selection::Selection_t s=Selection::kPre)
double GetNueRecoEnergy (NueRecord *nr)
double GetCCRecoEnergy (NueRecord *nr)
std::string GetCurrentSysName ()
void ResetHistograms ()
void WriteToFile ()
virtual void FillHistograms ()
void RunSystematics ()

Public Attributes

std::map
< Background::Background_t,
SysHists2D * > 
fSysHistsMap

Private Member Functions

void InitializeHistograms ()
void FinalizeHistograms ()
void SetDefaultOsc ()

Private Attributes

vector< std::string > fSysNames
std::string fCurrentSysName
Selection::Selection_t CutLevel
std::string outFileName
double fNearPOT
double fFarPOT
vector< std::string > PIDlist
TFile * fout
TTree * paramtree
double Theta12
double Theta13
double Theta23
double DeltaMSq23
double DeltaMSq12
double DeltaCP

Detailed Description

Definition at line 23 of file SysFileGen2D.h.


Constructor & Destructor Documentation

SysFileGen2D::SysFileGen2D (  ) 

Definition at line 3 of file SysFileGen2D.cxx.

References Initialize().

00004 {
00005   Initialize();
00006   return;
00007 }

virtual SysFileGen2D::~SysFileGen2D (  )  [inline, virtual]

Definition at line 27 of file SysFileGen2D.h.

00027 {};


Member Function Documentation

void SysFileGen2D::AddPID ( std::string  pid  ) 

Definition at line 21 of file SysFileGen2D.cxx.

References PIDlist.

00022 {
00023   PIDlist.push_back(pid);
00024   return;
00025 }

void SysFileGen2D::AddSystematic ( std::string  sys  )  [inline]

Definition at line 30 of file SysFileGen2D.h.

References fSysNames.

00030 { fSysNames.push_back(sys);};//one should be 'Nominal', another could be e.g. 'Xtalk'

void SysFileGen2D::FillHistograms (  )  [virtual]

Definition at line 45 of file SysFileGen2D.cxx.

Referenced by RunSystematics().

00046 {
00047 }

void SysFileGen2D::FinalizeHistograms (  )  [private]

Definition at line 56 of file SysFileGen2D.cxx.

References SysHists2D::FD_RecoVsPID, SysHists2D::FD_RecoVsPID_ErrorHist, SysHists2D::fDirectory, fSysHistsMap, SysHists2D::GetPIDBins(), SysHists2D::GetRecoBins(), SysHists2D::ND_RecoVsPID, and SysHists2D::ND_RecoVsPID_ErrorHist.

Referenced by WriteToFile().

00057 {
00058   std::map<Background::Background_t, SysHists2D*>::iterator bgiter = fSysHistsMap.begin();
00059   std::map<Background::Background_t, SysHists2D*>::iterator last  = fSysHistsMap.end();
00060   
00061   int ir;
00062   int npid,nreco;
00063   double r,p;
00064   double c1,c2;
00065   
00066   while(bgiter != last)
00067   {
00068     SysHists2D* sysh = bgiter->second;
00069     
00070     sysh->fDirectory->cd();
00071     
00072     npid = sysh->GetPIDBins();
00073     nreco = sysh->GetRecoBins();
00074 
00075     std::map<std::string, TH2D*>::iterator piditer = sysh->ND_RecoVsPID.begin();
00076     std::map<std::string, TH2D*>::iterator lastpid = sysh->ND_RecoVsPID.end();
00077     
00078     while(piditer != lastpid)
00079     {
00080       TH2D *h = piditer->second;
00081       p = h->GetXaxis()->GetBinCenter(npid);
00082       for(ir=0;ir<nreco;ir++)
00083       {
00084         r = h->GetYaxis()->GetBinCenter(ir+1);
00085         h->Fill(p,r,h->GetBinContent(npid+1,ir+1));//fill last pid bin with overflow content
00086         h->SetBinContent(npid+1,ir+1,0);//set overflow content to 0
00087       }
00088       piditer++;
00089     }
00090     
00091     piditer = sysh->FD_RecoVsPID.begin();
00092     lastpid = sysh->FD_RecoVsPID.end();
00093     
00094     while(piditer != lastpid)
00095     {
00096       TH2D *h = piditer->second;
00097       p = h->GetXaxis()->GetBinCenter(npid);
00098       for(ir=0;ir<nreco;ir++)
00099       {
00100         r = h->GetYaxis()->GetBinCenter(ir+1);
00101         h->Fill(p,r,h->GetBinContent(npid+1,ir+1));//fill last pid bin with overflow content
00102         h->SetBinContent(npid+1,ir+1,0);//set overflow content to 0
00103       }
00104       piditer++;
00105     }
00106     
00107     piditer = sysh->ND_RecoVsPID_ErrorHist.begin();
00108     lastpid = sysh->ND_RecoVsPID_ErrorHist.end();
00109     
00110     while(piditer != lastpid)
00111     {
00112       TH2D *h = piditer->second;
00113       for(ir=0;ir<nreco;ir++)
00114       {
00115         c1 = h->GetBinContent(npid,ir+1);//content of last pid bin
00116         c2 = h->GetBinContent(npid+1,ir+1);//content of overflow bin
00117         h->SetBinContent(npid,ir+1,sqrt(c1*c1 + c2*c2));//add content of overflow bin to last pid bin (sum in quadrature because this is an error histogram)
00118         h->SetBinContent(npid+1,ir+1,0);//set overflow content to 0
00119       }
00120       piditer++;
00121     }
00122     
00123     piditer = sysh->FD_RecoVsPID_ErrorHist.begin();
00124     lastpid = sysh->FD_RecoVsPID_ErrorHist.end();
00125     
00126     while(piditer != lastpid)
00127     {
00128       TH2D *h = piditer->second;
00129       
00130       for(ir=0;ir<nreco;ir++)
00131       {
00132         c1 = h->GetBinContent(npid,ir+1);//content of last pid bin
00133         c2 = h->GetBinContent(npid+1,ir+1);//content of overflow bin
00134         h->SetBinContent(npid,ir+1,sqrt(c1*c1 + c2*c2));//add content of overflow bin to last pid bin (sum in quadrature because this is an error histogram)
00135         h->SetBinContent(npid+1,ir+1,0);//set overflow content to 0
00136       }
00137       piditer++;
00138     }
00139     
00140     bgiter++;
00141   }
00142   
00143   return;
00144 }

double SysFileGen2D::GetCCRecoEnergy ( NueRecord nr  ) 

Definition at line 290 of file SysFileGen2D.cxx.

References ANtpTrackInfoNue::phCCGeV, ANtpShowerInfoNue::phCCGeV, NueRecord::srshower, and NueRecord::srtrack.

00291 {
00292   double CCEn = 0.0;
00293   if(nr->srtrack.phCCGeV > 0) CCEn += nr->srtrack.phCCGeV;
00294   if(nr->srshower.phCCGeV > 0) CCEn += nr->srshower.phCCGeV;
00295   
00296   return CCEn;
00297 }

std::string SysFileGen2D::GetCurrentSysName (  )  [inline]

Definition at line 39 of file SysFileGen2D.h.

References fCurrentSysName.

00039 { return fCurrentSysName; };

double SysFileGen2D::GetNueRecoEnergy ( NueRecord nr  ) 

Definition at line 286 of file SysFileGen2D.cxx.

References ANtpEventInfoNue::phNueGeV, and NueRecord::srevent.

00287 {
00288   return nr->srevent.phNueGeV;
00289 }

void SysFileGen2D::Initialize (  ) 

Definition at line 8 of file SysFileGen2D.cxx.

References fout, paramtree, SetCutLevel(), SetDefaultOsc(), SetFarPOT(), SetNearPOT(), and SetOutputFile().

Referenced by SysFileGen2D().

00009 {
00010   SetOutputFile();
00011   SetNearPOT();
00012   SetFarPOT();
00013   SetDefaultOsc();
00014   SetCutLevel();
00015   
00016   fout = 0;
00017   paramtree = 0;
00018   
00019   return;
00020 }

void SysFileGen2D::InitializeHistograms (  )  [private]

Definition at line 207 of file SysFileGen2D.cxx.

References SysHists2D::AddPID(), Background::AsString(), SysHists2D::fDirectory, fSysHistsMap, SysHists2D::InitializeHists(), Background::kBNueCC, Background::kNC, Background::kNueCC, Background::kNuMuCC, Background::kNuTauCC, and PIDlist.

Referenced by ResetHistograms().

00208 {
00209 
00210   vector<Background::Background_t> bgs;
00211   bgs.push_back(Background::kNC);
00212   bgs.push_back(Background::kNuMuCC);
00213   bgs.push_back(Background::kNuTauCC);
00214   bgs.push_back(Background::kNueCC);
00215   bgs.push_back(Background::kBNueCC);
00216 
00217   for(unsigned int i = 0; i < bgs.size(); i++){
00218     gDirectory->cd("/");
00219     std::string sysh_name = std::string(Background::AsString(bgs[i]));
00220     SysHists2D *sysh = new SysHists2D(sysh_name.c_str());
00221     sysh->fDirectory->cd();
00222     for(unsigned int j=0;j<PIDlist.size();j++)
00223     {
00224       sysh->AddPID(PIDlist.at(j));
00225     }
00226     sysh->InitializeHists();
00227  
00228     (fSysHistsMap)[bgs[i]] = sysh;
00229   }
00230 }

void SysFileGen2D::ResetHistograms (  ) 

Definition at line 231 of file SysFileGen2D.cxx.

References SysHists2D::FD_RecoVsPID, SysHists2D::FD_RecoVsPID_ErrorHist, SysHists2D::FD_TrueVsReco, SysHists2D::FD_TrueVsReco_ErrorHist, SysHists2D::fDirectory, fSysHistsMap, InitializeHistograms(), SysHists2D::ND_RecoVsPID, SysHists2D::ND_RecoVsPID_ErrorHist, SysHists2D::ND_TrueVsReco, and SysHists2D::ND_TrueVsReco_ErrorHist.

Referenced by RunSystematics().

00232 {
00233 
00234   if(fSysHistsMap.size() == 0) InitializeHistograms();
00235   
00236   std::map<Background::Background_t, SysHists2D*>::iterator bgiter = fSysHistsMap.begin();
00237   std::map<Background::Background_t, SysHists2D*>::iterator last  = fSysHistsMap.end();
00238   
00239   while(bgiter != last)
00240   {
00241     SysHists2D* sysh = bgiter->second;
00242     
00243     sysh->fDirectory->cd();
00244     
00245     sysh->ND_TrueVsReco->Reset("ICE");
00246     sysh->FD_TrueVsReco->Reset("ICE");
00247     sysh->ND_TrueVsReco_ErrorHist->Reset("ICE");
00248     sysh->FD_TrueVsReco_ErrorHist->Reset("ICE");
00249     
00250     std::map<std::string, TH2D*>::iterator piditer = sysh->ND_RecoVsPID.begin();
00251     std::map<std::string, TH2D*>::iterator lastpid = sysh->ND_RecoVsPID.end();
00252     while(piditer != lastpid)
00253     {
00254       TH2D *h = piditer->second;
00255       h->Reset("ICE");
00256       piditer++;
00257     }
00258     piditer = sysh->FD_RecoVsPID.begin();
00259     lastpid = sysh->FD_RecoVsPID.end();
00260     while(piditer != lastpid)
00261     {
00262       TH2D *h = piditer->second;
00263       h->Reset("ICE");
00264       piditer++;
00265     }
00266     piditer = sysh->ND_RecoVsPID_ErrorHist.begin();
00267     lastpid = sysh->ND_RecoVsPID_ErrorHist.end();
00268     while(piditer != lastpid)
00269     {
00270       TH2D *h = piditer->second;
00271       h->Reset("ICE");
00272       piditer++;
00273     }
00274     piditer = sysh->FD_RecoVsPID_ErrorHist.begin();
00275     lastpid = sysh->FD_RecoVsPID_ErrorHist.end();
00276     while(piditer != lastpid)
00277     {
00278       TH2D *h = piditer->second;
00279       h->Reset("ICE");
00280       piditer++;
00281     }
00282     
00283     bgiter++;
00284   }
00285 }

void SysFileGen2D::RunSystematics (  ) 

Definition at line 33 of file SysFileGen2D.cxx.

References fCurrentSysName, FillHistograms(), fSysNames, ResetHistograms(), and WriteToFile().

00034 {
00035   for(unsigned int j = 0; j < fSysNames.size(); j++)
00036   {
00037     std::cout<<fSysNames[j]<<endl;
00038     fCurrentSysName = fSysNames[j];
00039     ResetHistograms();  //Clear out whatever happened last time
00040     FillHistograms();
00041     WriteToFile();
00042   }
00043 }

void SysFileGen2D::SetCutLevel ( Selection::Selection_t  s = Selection::kPre  )  [inline]

Definition at line 35 of file SysFileGen2D.h.

References CutLevel.

Referenced by Initialize().

00035 { CutLevel = s; };

void SysFileGen2D::SetDefaultOsc (  )  [private]

Definition at line 27 of file SysFileGen2D.cxx.

References NueStandard::SetDefaultOscParam().

Referenced by Initialize().

00028 {
00029   NueStandard::SetDefaultOscParam();
00030   return; 
00031 }

void SysFileGen2D::SetFarPOT ( double  pot = 3.14e20  )  [inline]

Definition at line 33 of file SysFileGen2D.h.

References fFarPOT.

Referenced by Initialize().

00033 { fFarPOT = pot;};

void SysFileGen2D::SetNearPOT ( double  pot = 1e19  )  [inline]

Definition at line 32 of file SysFileGen2D.h.

References fNearPOT.

Referenced by Initialize().

00032 { fNearPOT = pot;};

void SysFileGen2D::SetOutputFile ( std::string  name = "DefaultOut.root"  ) 

Definition at line 49 of file SysFileGen2D.cxx.

References outFileName.

Referenced by Initialize().

00050 {
00051    outFileName = name;
00052    
00053    return;
00054 }

void SysFileGen2D::WriteToFile (  ) 

Definition at line 145 of file SysFileGen2D.cxx.

References Selection::AsString(), CutLevel, DeltaCP, DeltaMSq12, DeltaMSq23, fCurrentSysName, fFarPOT, FinalizeHistograms(), fNearPOT, fout, fSysHistsMap, fSysNames, NueStandard::GetOscParam(), OscPar::kDelta, OscPar::kDeltaM12, OscPar::kDeltaM23, OscPar::kTh12, OscPar::kTh13, OscPar::kTh23, outFileName, paramtree, Theta12, Theta13, and Theta23.

Referenced by RunSystematics().

00146 {
00147   FinalizeHistograms();
00148   
00149   char selection[256];
00150   
00151   double par[100]={0};
00152   NueStandard::GetOscParam(par);
00153   Theta12 = par[OscPar::kTh12];
00154   Theta13 = par[OscPar::kTh13];
00155   Theta23 = par[OscPar::kTh23];
00156   DeltaMSq23 = par[OscPar::kDeltaM23];
00157   DeltaMSq12 = par[OscPar::kDeltaM12];
00158   DeltaCP = par[OscPar::kDelta];
00159   
00160   if(fout == 0)
00161   {
00162     fout = new TFile(outFileName.c_str(),"RECREATE");
00163     paramtree = new TTree("paramtree","paramtree");
00164     paramtree->Branch("Selection",selection,"Selection/C");
00165     paramtree->Branch("nearPOT",&fNearPOT,"nearPOT/D");
00166     paramtree->Branch("farPOT",&fFarPOT,"farPOT/D");
00167     paramtree->Branch("Theta12",&Theta12,"Theta12/D");
00168     paramtree->Branch("Theta13",&Theta13,"Theta13/D");
00169     paramtree->Branch("Theta23",&Theta23,"Theta23/D");
00170     paramtree->Branch("DeltaMSq23",&DeltaMSq23,"DeltaMSq23/D");
00171     paramtree->Branch("DeltaMSq12",&DeltaMSq12,"DeltaMSq12/D");
00172     paramtree->Branch("DeltaCP",&DeltaCP,"DeltaCP/D");
00173   }
00174   
00175   fout->cd();
00176   
00177   sprintf(selection,"%s",Selection::AsString(CutLevel));
00178 
00179   std::map<Background::Background_t,SysHists2D*>::iterator bgiter = fSysHistsMap.begin();
00180   std::map<Background::Background_t,SysHists2D*>::iterator last = fSysHistsMap.end();
00181 
00182   while(bgiter!=last) {
00183     std::string sysh_name = bgiter->second->fDirectory->GetName();
00184     sysh_name += "_" + fCurrentSysName + "_" + std::string(Selection::AsString(CutLevel));
00185 
00186     TDirectory *filedir = fout->mkdir(sysh_name.c_str());
00187     filedir->cd();
00188     TList *list = bgiter->second->fDirectory->GetList();
00189     TIter iter(list->MakeIterator());
00190     TObject *ob = 0;
00191     while((ob = iter())) ob->Write();
00192     fout->cd();
00193     bgiter++;
00194   }
00195 
00196   fout->cd();
00197 
00198   paramtree->Fill();
00199 
00200   if(fCurrentSysName == fSysNames[fSysNames.size()-1])
00201   {
00202     paramtree->Write();
00203     fout->Close();
00204   }
00205 }


Member Data Documentation

Definition at line 55 of file SysFileGen2D.h.

Referenced by SetCutLevel(), and WriteToFile().

double SysFileGen2D::DeltaCP [private]

Definition at line 69 of file SysFileGen2D.h.

Referenced by WriteToFile().

double SysFileGen2D::DeltaMSq12 [private]

Definition at line 68 of file SysFileGen2D.h.

Referenced by WriteToFile().

double SysFileGen2D::DeltaMSq23 [private]

Definition at line 67 of file SysFileGen2D.h.

Referenced by WriteToFile().

std::string SysFileGen2D::fCurrentSysName [private]

Definition at line 54 of file SysFileGen2D.h.

Referenced by GetCurrentSysName(), RunSystematics(), and WriteToFile().

double SysFileGen2D::fFarPOT [private]

Definition at line 58 of file SysFileGen2D.h.

Referenced by SetFarPOT(), and WriteToFile().

double SysFileGen2D::fNearPOT [private]

Definition at line 57 of file SysFileGen2D.h.

Referenced by SetNearPOT(), and WriteToFile().

TFile* SysFileGen2D::fout [private]

Definition at line 61 of file SysFileGen2D.h.

Referenced by Initialize(), and WriteToFile().

vector<std::string> SysFileGen2D::fSysNames [private]

Definition at line 53 of file SysFileGen2D.h.

Referenced by AddSystematic(), RunSystematics(), and WriteToFile().

std::string SysFileGen2D::outFileName [private]

Definition at line 56 of file SysFileGen2D.h.

Referenced by SetOutputFile(), and WriteToFile().

TTree* SysFileGen2D::paramtree [private]

Definition at line 62 of file SysFileGen2D.h.

Referenced by Initialize(), and WriteToFile().

vector<std::string> SysFileGen2D::PIDlist [private]

Definition at line 59 of file SysFileGen2D.h.

Referenced by AddPID(), and InitializeHistograms().

double SysFileGen2D::Theta12 [private]

Definition at line 64 of file SysFileGen2D.h.

Referenced by WriteToFile().

double SysFileGen2D::Theta13 [private]

Definition at line 65 of file SysFileGen2D.h.

Referenced by WriteToFile().

double SysFileGen2D::Theta23 [private]

Definition at line 66 of file SysFileGen2D.h.

Referenced by WriteToFile().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1