JBComparator Class Reference

#include <JBComparator.h>

List of all members.

Public Member Functions

 JBComparator (std::string)
 ~JBComparator ()
void AddBackground (Background::Background_t bg)
void AddSysFile (Systematic::Systematic_t, string)
Bool_t ExtractDataHists (TFile *)
void ComputeAll ()
void DrawAll (Int_t)
void DrawAll (Int_t, Int_t)
void DrawPrediction (Int_t whichSys)
void DrawPrediction (Int_t whichSys, Int_t whichBG)
void DrawRatio (Int_t whichSys)
void DrawRatio (Int_t whichSys, Int_t whichBG)
void DrawIntegral (Int_t whichSys)
void DrawIntegral (Int_t whichSys, Int_t whichBG)
void DrawSummary ()
TGraph * GetSummary (Int_t bg=-1)
void DoPrint (Bool_t doPrint)
void SetOscSysString (string oss)
void GetError (Int_t whichSys, double *error, double *minerr, TH1D *Base)
void DetermineError ()

Protected Member Functions

std::map< NueSystematic *, TH1D * > GetPredictions (Systematic::Systematic_t, Background::Background_t)
Double_t GetFDSpectrumIntegral (Background::Background_t, Systematic::Systematic_t, Double_t)
Bool_t InBGVector (Background::Background_t)
void DeletePredictionsForDrawing ()
void DeleteRatiosForDrawing ()
void DeleteIntegralsForDrawing ()
void DeleteSummaryForDrawing ()

Protected Attributes

Double_t fNDDataPOT
Double_t fFDDataPOT
std::string fHistType
char fSelection [256]
Int_t fColourArray [20]
Bool_t fDoPrint
std::string fOscSysString
std::map
< Systematic::Systematic_t,
string > 
fFileMap
std::vector
< Background::Background_t
fBgVec
std::map< Detector::Detector_t,
std::map
< Background::Background_t,
NueBackground * > > 
fDataHists
std::map
< Background::Background_t,
std::map
< Systematic::Systematic_t,
std::map< NueSystematic
*, TH1D * > > > 
fPredictionMap
TCanvas * fCanvasForPredictions
TCanvas * fCanvasForRatios
TCanvas * fCanvasForIntegrals
TCanvas * fCanvasForSummary
THStack * fPredictionsForDrawing
THStack * fRatiosForDrawing
TMultiGraph * fIntegralsForDrawing
TMultiGraph * fSummaryForDrawing
TFile * fRatioFile

Detailed Description

Definition at line 24 of file JBComparator.h.


Constructor & Destructor Documentation

JBComparator::JBComparator ( std::string   ) 
JBComparator::~JBComparator (  ) 

Definition at line 36 of file JBComparator.cxx.

References DeleteIntegralsForDrawing(), DeletePredictionsForDrawing(), DeleteRatiosForDrawing(), DeleteSummaryForDrawing(), fCanvasForIntegrals, fCanvasForPredictions, fCanvasForRatios, fCanvasForSummary, fDataHists, fFileMap, fIntegralsForDrawing, fPredictionMap, fPredictionsForDrawing, fRatiosForDrawing, fSummaryForDrawing, Detector::kFar, and Detector::kNear.

00037 {
00038   //delete predictions:
00039   std::map<Background::Background_t,NueBackground*>::iterator dataBeg = 
00040     fDataHists[Detector::kNear].begin();
00041   std::map<Background::Background_t,NueBackground*>::iterator dataEnd = 
00042     fDataHists[Detector::kNear].end();
00043   while(dataBeg!=dataEnd){
00044     std::map<Systematic::Systematic_t,std::string>::iterator fileBeg = fFileMap.begin();
00045     std::map<Systematic::Systematic_t,std::string>::iterator fileEnd = fFileMap.end();
00046     while(fileBeg!=fileEnd){
00047       std::map<NueSystematic*,TH1D*>::iterator histBeg = 
00048         fPredictionMap[dataBeg->first][fileBeg->first].begin();
00049       std::map<NueSystematic*,TH1D*>::iterator histEnd = 
00050         fPredictionMap[dataBeg->first][fileBeg->first].end();
00051       while(histBeg!=histEnd){
00052         delete histBeg->first;
00053         delete histBeg->second;
00054         histBeg++;
00055       }
00056       fileBeg++;
00057     }
00058     dataBeg++;
00059   }
00060 
00061   //delete data hists:
00062   dataBeg = fDataHists[Detector::kNear].begin();
00063   while(dataBeg!=dataEnd) {
00064     delete dataBeg->second;
00065     dataBeg++;
00066   }
00067   dataBeg = fDataHists[Detector::kFar].begin();
00068   dataEnd = fDataHists[Detector::kFar].end(); 
00069   while(dataBeg!=dataEnd) {
00070     delete dataBeg->second;
00071     dataBeg++;
00072   }
00073 
00074   //delete histos/graphs held for plotting:
00075   this->DeletePredictionsForDrawing();
00076   this->DeleteRatiosForDrawing();
00077   this->DeleteIntegralsForDrawing();
00078   this->DeleteSummaryForDrawing();
00079   delete fPredictionsForDrawing;
00080   delete fRatiosForDrawing;
00081   delete fIntegralsForDrawing;
00082   delete fSummaryForDrawing;
00083   delete fCanvasForPredictions;
00084   delete fCanvasForRatios;
00085   delete fCanvasForIntegrals;
00086   delete fCanvasForSummary;
00087 }


Member Function Documentation

void JBComparator::AddBackground ( Background::Background_t  bg  )  [inline]

Definition at line 32 of file JBComparator.h.

References fBgVec.

00032 {fBgVec.push_back(bg);}  

void JBComparator::AddSysFile ( Systematic::Systematic_t  sys,
string  fname 
)

Definition at line 89 of file JBComparator.cxx.

References ExtractDataHists(), fDataHists, and fFileMap.

00090 {  
00091   fFileMap[sys] = fname;
00092   if(fDataHists.begin()==fDataHists.end()) {
00093     TFile *f = new TFile(fname.c_str(),"READ");
00094     if(!this->ExtractDataHists(f)) 
00095       std::cout << "Error: Could not extract data histograms from file: " 
00096                 << fname << endl;
00097     delete f;
00098   }
00099 }

void JBComparator::ComputeAll (  ) 

Definition at line 152 of file JBComparator.cxx.

References fDataHists, fFileMap, fPredictionMap, GetPredictions(), and Detector::kNear.

00153 {
00154   std::map<Background::Background_t,NueBackground*>::iterator dataBeg = 
00155     fDataHists[Detector::kNear].begin();
00156   std::map<Background::Background_t,NueBackground*>::iterator dataEnd = 
00157     fDataHists[Detector::kNear].end();
00158   while(dataBeg!=dataEnd){
00159     std::map<Systematic::Systematic_t,std::string>::iterator fileBeg = fFileMap.begin();
00160     std::map<Systematic::Systematic_t,std::string>::iterator fileEnd = fFileMap.end();
00161     while(fileBeg!=fileEnd){
00162       fPredictionMap[dataBeg->first][fileBeg->first] = GetPredictions(fileBeg->first,
00163                                                                       dataBeg->first);
00164       fileBeg++;
00165     }
00166     dataBeg++;
00167   }
00168 }

void JBComparator::DeleteIntegralsForDrawing (  )  [protected]

Definition at line 947 of file JBComparator.cxx.

References fIntegralsForDrawing, and it.

Referenced by DrawIntegral(), and ~JBComparator().

00948 {
00949   if(fIntegralsForDrawing->GetListOfGraphs()){
00950     TIter it(fIntegralsForDrawing->GetListOfGraphs()->MakeIterator());
00951     TObject *ob = 0;
00952     while((ob = it())) delete ob;
00953   }
00954 }

void JBComparator::DeletePredictionsForDrawing (  )  [protected]

Definition at line 929 of file JBComparator.cxx.

References fPredictionsForDrawing, and it.

Referenced by DrawPrediction(), and ~JBComparator().

00930 {
00931   if(fPredictionsForDrawing->GetHists()) {
00932     TIter it(fPredictionsForDrawing->GetHists()->MakeIterator());
00933     TObject *ob = 0;
00934     while((ob = it())) delete ob;
00935   }
00936 }

void JBComparator::DeleteRatiosForDrawing (  )  [protected]

Definition at line 938 of file JBComparator.cxx.

References fRatiosForDrawing, and it.

Referenced by DrawRatio(), and ~JBComparator().

00939 {
00940   if(fRatiosForDrawing->GetHists()) {
00941     TIter it(fRatiosForDrawing->GetHists()->MakeIterator());
00942     TObject *ob = 0;
00943     while((ob = it())) delete ob;
00944   }
00945 }

void JBComparator::DeleteSummaryForDrawing (  )  [protected]

Definition at line 956 of file JBComparator.cxx.

References fSummaryForDrawing, and it.

Referenced by DrawSummary(), and ~JBComparator().

00957 {
00958   if(fSummaryForDrawing->GetListOfGraphs()){
00959     TIter it(fSummaryForDrawing->GetListOfGraphs()->MakeIterator());
00960     TObject *ob = 0;
00961     while((ob = it())) delete ob;
00962   }
00963 }

void JBComparator::DetermineError (  ) 

Definition at line 1038 of file JBComparator.cxx.

References DrawPrediction(), fFileMap, fOscSysString, fPredictionsForDrawing, fRatioFile, fSelection, GetError(), it, and Systematic::kOscProb.

01039 {
01040   if(!fRatioFile)  fRatioFile = new TFile("RatioFile.root", "RECREATE");
01041   fRatioFile->cd();
01042 
01043   TH1D* Base = 0;
01044   this->DrawPrediction(0); 
01045   //it already has all the ratios in
01046   if(fPredictionsForDrawing->GetHists()) {
01047     TIter it(fPredictionsForDrawing->GetHists()->MakeIterator());
01048     TObject* ob = 0;
01049     while((ob = it())){
01050       if(strstr(ob->GetName(), "DataHist")!=0){
01051          Base = (TH1D*) ob->Clone("Base");
01052          break;
01053       }
01054     }
01055   }
01056 
01057 
01058   std::map<Systematic::Systematic_t,std::string>::iterator fileBeg =
01059     fFileMap.begin();
01060   std::map<Systematic::Systematic_t,std::string>::iterator fileEnd =
01061     fFileMap.end();
01062 
01063   Double_t totMaxError[10] = {0};
01064   Double_t MaxError[10]    = {0};
01065   Double_t totMinError[10] = {0};
01066   Double_t MinError[10]    = {0};
01067 
01068   bool first = true;
01069   fOscSysString = "Theta23";
01070 
01071   while(fileBeg!=fileEnd){
01072     if(fileBeg->first==Systematic::kOscProb) {
01073        if(first) first = false;
01074        else fOscSysString = "Delta23";
01075      }
01076 
01077      this->DrawPrediction(Int_t(fileBeg->first));
01078      this->GetError(Int_t(fileBeg->first),MaxError, MinError, Base);
01079 
01080      for(int i = 0; i < 10; i++){
01081         totMaxError[i] = TMath::Sqrt(totMaxError[i]*totMaxError[i] + MaxError[i]*MaxError[i]);
01082         totMinError[i] = TMath::Sqrt(totMinError[i]*totMinError[i] + MinError[i]*MinError[i]);
01083 
01084         MaxError[i] = MinError[i] = 0;
01085      }
01086     if(!(fileBeg->first==Systematic::kOscProb && fOscSysString == "Theta23")) fileBeg++;
01087   }
01088 
01089   string name = "NCandCC_" +  string(fSelection);
01090 
01091   TString baseName = "Prediction_" + name;
01092   Base->SetName(baseName);
01093   TString errName = "MaxErrorBand_" + name + "_AllSystematic";
01094   TH1D* errBand = (TH1D*) Base->Clone(errName);
01095   errBand->Reset("ICE");
01096 
01097   errName = "MinErrorBand_" + name + "_AllSystematic";
01098   TH1D* errBandm = (TH1D*) Base->Clone(errName);
01099   errBandm->Reset("ICE");
01100 
01101 
01102   for(int i = 0; i < 11; i++){
01103     errBand->SetBinContent(i, totMaxError[i]);
01104     errBandm->SetBinContent(i, totMinError[i]);
01105   }
01106   Base->Write();
01107   errBand->Write();
01108   errBandm->Write();
01109 
01110   cout<<errBand->GetSum()/Base->GetSum()<<endl;
01111   cout<<errBandm->GetSum()/Base->GetSum()<<endl;
01112 
01113   cout<<"Finished"<<endl;
01114 }

void JBComparator::DoPrint ( Bool_t  doPrint  )  [inline]

Definition at line 54 of file JBComparator.h.

References fDoPrint.

00054 {fDoPrint = doPrint;}

void JBComparator::DrawAll ( Int_t  whichSys,
Int_t  whichBG 
)

Definition at line 241 of file JBComparator.cxx.

References DrawIntegral(), DrawPrediction(), and DrawRatio().

00242 {
00243   this->DrawPrediction(whichSys,whichBG);
00244   this->DrawRatio(whichSys,whichBG);
00245   this->DrawIntegral(whichSys,whichBG);
00246 }

void JBComparator::DrawAll ( Int_t  whichSys  ) 

Definition at line 234 of file JBComparator.cxx.

References DrawIntegral(), DrawPrediction(), and DrawRatio().

00235 {
00236   this->DrawPrediction(whichSys);
00237   this->DrawRatio(whichSys);
00238   this->DrawIntegral(whichSys);
00239 }

void JBComparator::DrawIntegral ( Int_t  whichSys,
Int_t  whichBG 
)

Definition at line 681 of file JBComparator.cxx.

References Background::AsString(), Systematic::AsString(), DeleteIntegralsForDrawing(), fCanvasForIntegrals, fDataHists, fDoPrint, fFileMap, fIntegralsForDrawing, fOscSysString, fPredictionMap, fSelection, GetFDSpectrumIntegral(), InBGVector(), Detector::kFar, Systematic::kOscProb, and n.

00682 {
00683   //delete previous TGraphs
00684   this->DeleteIntegralsForDrawing();
00685   //get/make TLegend
00686   fCanvasForIntegrals->cd();  
00687   TLegend *leg = (TLegend*) fCanvasForIntegrals->FindObject("CFILeg");
00688   if(leg) leg->Clear();
00689   else {
00690     leg = new TLegend(0.2,0.2,0.4,0.4);
00691     leg->SetName("CFILeg");
00692     leg->SetBorderSize(0);
00693   }
00694   fCanvasForIntegrals->Clear();
00695 
00696   Int_t n = 0;
00697   Double_t sysValues[100] = {0}; //unfeasibly large...
00698   Double_t mcIntegValues[100] = {0};
00699   Double_t extrapIntegValues[100] = {0};
00700   Systematic::Systematic_t sys = Systematic::ESystematic(whichSys);
00701   Background::Background_t bg = Background::EBackground(whichBG);
00702   if(!this->InBGVector(bg)) return;
00703   if(fFileMap.find(sys)==fFileMap.end()) return;
00704   std::map<NueSystematic*,TH1D*>::iterator predBeg = fPredictionMap[bg][sys].begin();
00705   std::map<NueSystematic*,TH1D*>::iterator predEnd = fPredictionMap[bg][sys].end();
00706   while(predBeg!=predEnd) {
00707     if(sys==Systematic::kOscProb) {
00708       TString ts(predBeg->first->GetName());
00709       if(!ts.Contains(fOscSysString)) { predBeg++; continue;}
00710       Double_t tmpDub, theta23, delta23;
00711       Int_t tmpInt;
00712       predBeg->first->GetOscParams(tmpDub,theta23,tmpDub,tmpDub,delta23,tmpDub,tmpInt); 
00713       if(ts.Contains("Theta23")) sysValues[n] = theta23;
00714       else if(ts.Contains("Delta23")) sysValues[n] = delta23;
00715     }
00716     else sysValues[n] = predBeg->first->GetSysValue(sys);
00717 
00718     //if(sysValues[n]<-9998) sysValues[n] = 0;
00719     Double_t dataTot = fDataHists[Detector::kFar][bg]->GetHist()->Integral();
00720     extrapIntegValues[n] = predBeg->second->Integral();
00721     mcIntegValues[n] = this->GetFDSpectrumIntegral(bg,sys,sysValues[n]);
00722     if(dataTot>0){
00723       extrapIntegValues[n]/=dataTot;
00724       mcIntegValues[n]/=dataTot;
00725     }
00726     predBeg++;
00727     n++;
00728   }
00729   TGraph *extrapGr = new TGraph(n,sysValues,extrapIntegValues);
00730   TGraph *mcGr = new TGraph(n,sysValues,mcIntegValues);
00731   extrapGr->SetMarkerColor(4);
00732   mcGr->SetMarkerColor(2);
00733   fIntegralsForDrawing->Add(extrapGr,"P");
00734   fIntegralsForDrawing->Add(mcGr,"P");
00735   leg->AddEntry(extrapGr,"Data_{ND}#times(F/N)_{sys}/Data_{FD}","p");
00736   leg->AddEntry(mcGr,"MC^{sys}_{FD}/Data_{FD}","p");
00737 
00738   fIntegralsForDrawing->Draw("A");
00739   string title = "FD Spectrum Integral Ratios for " + string(Background::AsString(bg)) + 
00740     " with " + string(fSelection) + " and Tweaks in " + string(Systematic::AsString(sys));
00741   fIntegralsForDrawing->SetTitle(title.c_str());  
00742   leg->Draw();
00743   gROOT->ProcessLine("SortOutStats(gPad,0.3,0.075,1,0.7,0.09);STS(0.04);");
00744   if(fDoPrint) {
00745     string printName = "FD_Integral_" + string(Background::AsString(bg)) + "_" + 
00746       string(fSelection) + "_" + string(Systematic::AsString(sys)) + ".gif";
00747     fCanvasForIntegrals->Print(printName.c_str());
00748   }
00749 }

void JBComparator::DrawIntegral ( Int_t  whichSys  ) 

Definition at line 575 of file JBComparator.cxx.

References Systematic::AsString(), DeleteIntegralsForDrawing(), MuELoss::e, fCanvasForIntegrals, fDataHists, fDoPrint, fFileMap, fIntegralsForDrawing, fOscSysString, fPredictionMap, fSelection, GetFDSpectrumIntegral(), Background::kBNueCC, Detector::kFar, Detector::kNear, Background::kNuTauCC, Systematic::kOscProb, Background::kSelCC, and n.

Referenced by DrawAll(), and GetSummary().

00576 {
00577   //delete previous TGraphs
00578   this->DeleteIntegralsForDrawing();
00579   //get/make TLegend
00580   fCanvasForIntegrals->cd();
00581   TLegend *leg = (TLegend*) fCanvasForIntegrals->FindObject("CFILeg");
00582   if(leg) leg->Clear();
00583   else {
00584     leg = new TLegend(0.2,0.2,0.4,0.4);
00585     leg->SetName("CFILeg");
00586     leg->SetBorderSize(0);
00587   }
00588   fCanvasForIntegrals->Clear();
00589 
00590   Int_t n = 0;
00591   Double_t sysValues[100] = {0}; //unfeasibly large...
00592   Double_t mcIntegValues[100] = {0};
00593   Double_t extrapIntegValues[100] = {0};
00594   Double_t dataTot = 0;
00595   Bool_t firstPass = true;
00596   Systematic::Systematic_t sys = Systematic::ESystematic(whichSys);
00597   if(fFileMap.find(sys)==fFileMap.end()) return;
00598 
00599   std::map<Background::Background_t,NueBackground*>::iterator dataBeg = 
00600     fDataHists[Detector::kNear].begin();
00601   std::map<Background::Background_t,NueBackground*>::iterator dataEnd = 
00602     fDataHists[Detector::kNear].end();
00603   while(dataBeg!=dataEnd){
00604     Background::Background_t bg = dataBeg->first;
00605     if(bg == Background::kBNueCC || bg == Background::kSelCC || bg == Background::kNuTauCC) {
00606        dataBeg++; continue;
00607     }
00608 
00609     std::map<NueSystematic*,TH1D*>::iterator predBeg = fPredictionMap[bg][sys].begin();
00610     std::map<NueSystematic*,TH1D*>::iterator predEnd = fPredictionMap[bg][sys].end();    
00611     while(predBeg!=predEnd){
00612       Double_t theVal = 0;
00613       if(sys==Systematic::kOscProb) {
00614         TString ts(predBeg->first->GetName());
00615         if(!ts.Contains(fOscSysString)) { predBeg++; continue;}
00616         Double_t tmpDub, theta23, delta23;
00617         Int_t tmpInt;
00618         predBeg->first->GetOscParams(tmpDub,theta23,tmpDub,tmpDub,delta23,tmpDub,tmpInt);       
00619         if(ts.Contains("Theta23")) theVal = theta23;
00620         else if(ts.Contains("Delta23")) theVal = delta23;
00621       }
00622       else theVal = predBeg->first->GetSysValue(sys);
00623       if(firstPass) {
00624         sysValues[n] = theVal;
00625         extrapIntegValues[n] += predBeg->second->Integral();
00626         mcIntegValues[n] += this->GetFDSpectrumIntegral(bg,sys,sysValues[n]);
00627         n++;
00628       }
00629       else {
00630         for(int i=0;i<n;i++) {
00631 //          cout<<extrapIntegValues[i]<<"  "<<dataTot<<endl;
00632 
00633           if(TMath::Abs(sysValues[i]-theVal)<1e-6) {
00634             extrapIntegValues[i] += predBeg->second->Integral();
00635             mcIntegValues[i] += this->GetFDSpectrumIntegral(bg,sys,sysValues[i]);
00636             break;
00637           }
00638         }
00639       }
00640 //      cout<<extrapIntegValues[n]<<"  "<<dataTot<<endl;
00641 
00642       predBeg++;
00643     }
00644  
00645     dataTot += fDataHists[Detector::kFar][bg]->GetHist()->Integral();
00646 //    cout<<Background::AsString(bg)<<"  "<<dataTot<<endl;
00647     firstPass = false;
00648     dataBeg++;
00649   }
00650   if(dataTot>0){
00651     for(int i=0;i<n;i++){
00652       mcIntegValues[i]/=dataTot;
00653       extrapIntegValues[i]/=dataTot;
00654 
00655 //      cout<<extrapIntegValues[i]<<"  "<<dataTot<<endl;
00656     }
00657   }
00658 
00659   TGraph *extrapGr = new TGraph(n,sysValues,extrapIntegValues);
00660   TGraph *mcGr = new TGraph(n,sysValues,mcIntegValues);
00661   extrapGr->SetMarkerColor(4);
00662   mcGr->SetMarkerColor(2);
00663   fIntegralsForDrawing->Add(extrapGr,"P");
00664   fIntegralsForDrawing->Add(mcGr,"P");
00665   leg->AddEntry(extrapGr,"Data_{ND}#times(F/N)_{sys}/Data_{FD}","p");
00666   leg->AddEntry(mcGr,"MC^{sys}_{FD}/Data_{FD}","p");
00667 
00668   fIntegralsForDrawing->Draw("A");
00669   string title = "FD Total Spectrum Integral Ratios with " + string(fSelection) + 
00670     " and Tweaks in " + string(Systematic::AsString(sys));
00671   fIntegralsForDrawing->SetTitle(title.c_str());  
00672   leg->Draw();
00673   gROOT->ProcessLine("SortOutStats(gPad,0.3,0.075,1,0.7,0.09);STS(0.04);");
00674   if(fDoPrint) {
00675     string printName = "FD_Integral_" + string(fSelection) + "_" + 
00676       string(Systematic::AsString(sys)) + ".gif";
00677     fCanvasForIntegrals->Print(printName.c_str());
00678   }
00679 }

void JBComparator::DrawPrediction ( Int_t  whichSys,
Int_t  whichBG 
)

Definition at line 347 of file JBComparator.cxx.

References Background::AsString(), Systematic::AsString(), DeletePredictionsForDrawing(), fCanvasForPredictions, fColourArray, fDataHists, fDoPrint, fFileMap, fOscSysString, fPredictionMap, fPredictionsForDrawing, fSelection, NueSystematic::GetName(), NueSystematic::GetOscParams(), NueSystematic::GetSysValue(), InBGVector(), Detector::kFar, and Systematic::kOscProb.

00348 {
00349   //delete previously made/drawn histograms  
00350   this->DeletePredictionsForDrawing();
00351  
00352   //get/make TLegend
00353   fCanvasForPredictions->cd();  
00354   TLegend *leg = 0;
00355   if((leg = (TLegend*) fCanvasForPredictions->FindObject("CFPLeg"))) leg->Clear();
00356   else {
00357     leg = new TLegend(0.2,0.2,0.4,0.4);
00358     leg->SetName("CFPLeg");
00359     leg->SetBorderSize(1);
00360   }
00361 
00362   Int_t colCounter = 0;
00363   Systematic::Systematic_t sys = Systematic::ESystematic(whichSys);
00364   Background::Background_t bg = Background::EBackground(whichBG);
00365   if(!this->InBGVector(bg)) return;
00366   if(fFileMap.find(sys)==fFileMap.end()) return;
00367   std::map<NueSystematic*,TH1D*>::iterator predBeg = fPredictionMap[bg][sys].begin();
00368   std::map<NueSystematic*,TH1D*>::iterator predEnd = fPredictionMap[bg][sys].end();
00369   char label[256];
00370   while(predBeg!=predEnd) {
00371     NueSystematic *tmpSys = predBeg->first;
00372     if(sys==Systematic::kOscProb) {
00373       TString ts(tmpSys->GetName());
00374       if(!ts.Contains(fOscSysString)) { predBeg++; continue;}
00375       Double_t tmpDub, theta23, delta23;
00376       Int_t tmpInt;
00377       tmpSys->GetOscParams(tmpDub,theta23,tmpDub,tmpDub,delta23,tmpDub,tmpInt);
00378       if(ts.Contains("Theta23")) sprintf(label,"%s = %.4f",tmpSys->GetName(),theta23);
00379       else if(ts.Contains("Delta23")) sprintf(label,"%s = %.4f",tmpSys->GetName(),delta23);
00380     }
00381     else sprintf(label,"%s = %.2f",Systematic::AsString(sys),tmpSys->GetSysValue(sys));
00382     TH1D *tmpPred = (TH1D*) predBeg->second->
00383       Clone(string(string(predBeg->second->GetName())+string("_copy")).c_str());
00384     tmpPred->SetLineColor(fColourArray[colCounter]);
00385     tmpPred->SetMarkerColor(fColourArray[colCounter]);
00386     tmpPred->SetAxisRange(0,10);
00387     fPredictionsForDrawing->Add(tmpPred,"hist");
00388     leg->AddEntry(tmpPred,label,"lp");
00389     colCounter++;
00390     predBeg++;
00391   }
00392 
00393   //Draw:
00394   fPredictionsForDrawing->Draw("nostack");
00395   fPredictionsForDrawing->GetXaxis()->SetRangeUser(0,10);
00396   TH1D *dataHist = 
00397         (TH1D*) fDataHists[Detector::kFar][bg]->GetHist()->Clone("DataHist");
00398   dataHist->SetAxisRange(0,10);
00399   dataHist->Draw("same");
00400   leg->AddEntry(dataHist,"Pseudo-Data","lp");
00401   string title = "FD Prediction for " + string(Background::AsString(bg)) + " with " + 
00402     string(fSelection) + " and Tweaks in " + string(Systematic::AsString(sys));
00403   fPredictionsForDrawing->SetTitle(title.c_str());
00404   leg->Draw();
00405   gROOT->ProcessLine("SortOutStats(gPad,0.25,0.6,1,0.98,0.81);STS(0.04);");
00406   if(fDoPrint) {
00407     string printName = "FD_Prediction_" + string(Background::AsString(bg)) + "_" +
00408       string(fSelection) + "_" + string(Systematic::AsString(sys)) + ".gif";
00409     fCanvasForPredictions->Print(printName.c_str());
00410   }
00411 }

void JBComparator::DrawPrediction ( Int_t  whichSys  ) 

Definition at line 248 of file JBComparator.cxx.

References Systematic::AsString(), DeletePredictionsForDrawing(), fCanvasForPredictions, fColourArray, fDataHists, fDoPrint, fFileMap, fOscSysString, fPredictionMap, fPredictionsForDrawing, fSelection, Background::kBNueCC, Detector::kFar, Detector::kNear, Background::kNuTauCC, Systematic::kOscProb, and Background::kSelCC.

Referenced by DetermineError(), and DrawAll().

00249 {
00250   //delete previously made/drawn histograms
00251   this->DeletePredictionsForDrawing();
00252 
00253   //get/make TLegend
00254   fCanvasForPredictions->cd();
00255   TLegend *leg = 0;
00256   if((leg = (TLegend*) fCanvasForPredictions->FindObject("CFPLeg"))) leg->Clear();
00257   else {
00258     leg = new TLegend(0.2,0.2,0.4,0.4);
00259     leg->SetName("CFPLeg");
00260     leg->SetBorderSize(1);
00261   }
00262 
00263   Systematic::Systematic_t sys = Systematic::ESystematic(whichSys);
00264   if(fFileMap.find(sys)==fFileMap.end()) return;
00265   std::map<string,TH1D*> summedMap;
00266   TH1D *dataHist = NULL;
00267 
00268   std::map<Background::Background_t,NueBackground*>::iterator dataBeg = 
00269     fDataHists[Detector::kNear].begin();
00270   std::map<Background::Background_t,NueBackground*>::iterator dataEnd = 
00271     fDataHists[Detector::kNear].end();
00272   while(dataBeg!=dataEnd){
00273     Background::Background_t bg = dataBeg->first;
00274 
00275     if(bg == Background::kBNueCC || bg == Background::kSelCC
00276               || bg == Background::kNuTauCC) {
00277        dataBeg++; continue;
00278     }
00279 
00280     std::map<NueSystematic*,TH1D*>::iterator predBeg = fPredictionMap[bg][sys].begin();
00281     std::map<NueSystematic*,TH1D*>::iterator predEnd = fPredictionMap[bg][sys].end();
00282     Int_t colCounter = 0;
00283     char label[256];
00284     while(predBeg!=predEnd){
00285       string sysNom = predBeg->first->GetName();
00286       Double_t sysVal = predBeg->first->GetSysValue(sys);
00287       if(sys==Systematic::kOscProb) {
00288         TString ts(sysNom);
00289         if(!ts.Contains(fOscSysString)) { predBeg++; continue;}
00290         Double_t tmpDub, theta23, delta23;
00291         Int_t tmpInt;
00292         predBeg->first->GetOscParams(tmpDub,theta23,tmpDub,tmpDub,delta23,tmpDub,tmpInt);       
00293         if(ts.Contains("Theta23")) sysVal = theta23;
00294         else if(ts.Contains("Delta23")) sysVal = delta23;
00295       }
00296       if(summedMap.find(sysNom)!=summedMap.end()) {
00297         summedMap[sysNom]->Add(predBeg->second);
00298       }
00299       else {
00300         string name = "FD_Total_Prediction_" + string(fSelection) + "_" + 
00301           string(Systematic::AsString(sys));
00302         summedMap[sysNom] = (TH1D*) predBeg->second->Clone(name.c_str());
00303         summedMap[sysNom]->SetLineColor(fColourArray[colCounter]);
00304         summedMap[sysNom]->SetMarkerColor(fColourArray[colCounter]);
00305         if(sys!=Systematic::kOscProb) sprintf(label,"%s = %.2f",
00306                                               Systematic::AsString(sys),sysVal);
00307         else sprintf(label,"%s = %.4f",fOscSysString.c_str(),sysVal);
00308         leg->AddEntry(summedMap[sysNom],label,"l");
00309         colCounter++;
00310       }
00311       predBeg++;
00312    }
00313     if(dataHist==0) {
00314       dataHist = (TH1D*) fDataHists[Detector::kFar][dataBeg->first]->
00315         GetHist()->Clone("DataHist");
00316       leg->AddEntry(dataHist,"Pseudo-Data","lp");
00317     }
00318     else dataHist->Add(fDataHists[Detector::kFar][dataBeg->first]->GetHist());
00319     dataBeg++;
00320   }
00321 
00322   std::map<string,TH1D*>::iterator sumBeg = summedMap.begin();
00323   std::map<string,TH1D*>::iterator sumEnd = summedMap.end();
00324   while(sumBeg!=sumEnd){
00325     sumBeg->second->SetAxisRange(0,10);
00326     fPredictionsForDrawing->Add(sumBeg->second,"hist");
00327     sumBeg++;
00328   }
00329   fPredictionsForDrawing->Add(dataHist);
00330 
00331   cout<<"Entries in dataHist "<<dataHist->GetSum()<<endl;
00332   //draw:
00333   fPredictionsForDrawing->Draw("nostack");
00334   fPredictionsForDrawing->GetXaxis()->SetRangeUser(0,10);
00335   string title = "FD Total Prediction with " + 
00336     string(fSelection) + " and Tweaks in " + string(Systematic::AsString(sys));
00337   fPredictionsForDrawing->SetTitle(title.c_str());
00338   leg->Draw();
00339   gROOT->ProcessLine("SortOutStats(gPad,0.25,0.6,1,0.98,0.81);STS(0.04);");
00340   if(fDoPrint) {
00341     string printName = "FD_Total_Prediction_" + 
00342       string(fSelection) + "_" + string(Systematic::AsString(sys)) + ".gif";
00343     fCanvasForPredictions->Print(printName.c_str());
00344   }
00345 }

void JBComparator::DrawRatio ( Int_t  whichSys,
Int_t  whichBG 
)

Definition at line 512 of file JBComparator.cxx.

References Background::AsString(), Systematic::AsString(), DeleteRatiosForDrawing(), fCanvasForRatios, fColourArray, fDataHists, fDoPrint, fFileMap, fOscSysString, fPredictionMap, fRatiosForDrawing, fSelection, NueSystematic::GetName(), NueSystematic::GetOscParams(), NueSystematic::GetSysValue(), InBGVector(), Detector::kNear, and Systematic::kOscProb.

00513 {
00514   //delete previously made/drawn histograms  
00515   this->DeleteRatiosForDrawing();
00516   
00517   //get/make TLegend
00518   fCanvasForRatios->cd();  
00519   TLegend *leg = 0;
00520   if((leg = (TLegend*) fCanvasForRatios->FindObject("CFRLeg"))) leg->Clear();
00521   else {
00522     leg = new TLegend(0.2,0.2,0.4,0.4);
00523     leg->SetName("CFRLeg");
00524     leg->SetBorderSize(1);
00525   }
00526  
00527   Systematic::Systematic_t sys = Systematic::ESystematic(whichSys);
00528   Background::Background_t bg = Background::EBackground(whichBG);
00529   if(!this->InBGVector(bg)) return;
00530   if(fFileMap.find(sys)==fFileMap.end()) return;
00531   std::map<NueSystematic*,TH1D*>::iterator predBeg = fPredictionMap[bg][sys].begin();
00532   std::map<NueSystematic*,TH1D*>::iterator predEnd = fPredictionMap[bg][sys].end();
00533   Int_t colCounter = 0;
00534   char label[256];
00535   while(predBeg!=predEnd) {
00536     NueSystematic *tmpSys = predBeg->first;
00537     if(sys==Systematic::kOscProb) {
00538       TString ts(tmpSys->GetName());
00539       if(!ts.Contains(fOscSysString)) { predBeg++; continue;}
00540       Double_t tmpDub, theta23, delta23;
00541       Int_t tmpInt;
00542       tmpSys->GetOscParams(tmpDub,theta23,tmpDub,tmpDub,delta23,tmpDub,tmpInt);
00543       if(ts.Contains("Theta23")) sprintf(label,"%s = %.4f",fOscSysString.c_str(),theta23);
00544       else if(ts.Contains("Delta23")) sprintf(label,"%s = %.4f",fOscSysString.c_str(),delta23);
00545     }
00546     else sprintf(label,"%s = %.2f",Systematic::AsString(sys),tmpSys->GetSysValue(sys));
00547     TH1D *tmpPred = (TH1D*) predBeg->second->Clone(string(predBeg->second->GetName() + 
00548                                                           string("_Copy")).c_str());    
00549     tmpPred->Divide(fDataHists[Detector::kNear][bg]->GetHist());
00550     tmpPred->Scale(1e19/(3.5e20));
00551     tmpPred->SetLineColor(fColourArray[colCounter]);
00552     tmpPred->SetMarkerColor(fColourArray[colCounter]);
00553     tmpPred->SetAxisRange(0,10);
00554     fRatiosForDrawing->Add(tmpPred,"hist");
00555     leg->AddEntry(tmpPred,label,"lp");
00556     colCounter++;
00557     predBeg++;
00558   }
00559 
00560   //draw:
00561   fRatiosForDrawing->Draw("nostack");
00562   fRatiosForDrawing->GetXaxis()->SetRangeUser(0,10);
00563   string title = "F/N Ratio for " + string(Background::AsString(bg)) + " with " + 
00564     string(fSelection) + " and Tweaks in " + string(Systematic::AsString(sys));
00565   fRatiosForDrawing->SetTitle(title.c_str());
00566   leg->Draw();
00567   gROOT->ProcessLine("SortOutStats(gPad,0.25,0.6,1,0.98,0.81);STS(0.04);");
00568   if(fDoPrint) {
00569     string printName = "FN_Ratio_" + string(Background::AsString(bg)) + "_" + 
00570       string(fSelection) + "_" + string(Systematic::AsString(sys)) + ".gif";
00571     fCanvasForRatios->Print(printName.c_str());
00572   }
00573 }

void JBComparator::DrawRatio ( Int_t  whichSys  ) 

Definition at line 413 of file JBComparator.cxx.

References Systematic::AsString(), DeleteRatiosForDrawing(), fCanvasForRatios, fColourArray, fDataHists, fDoPrint, fFileMap, fOscSysString, fPredictionMap, fRatiosForDrawing, fSelection, Background::kBNueCC, Detector::kNear, Background::kNuTauCC, Systematic::kOscProb, and Background::kSelCC.

Referenced by DrawAll().

00414 {
00415   //delete previously made/drawn histograms
00416   this->DeleteRatiosForDrawing();
00417   
00418   //get/make TLegend
00419   fCanvasForRatios->cd();  
00420   TLegend *leg = 0;
00421   if((leg = (TLegend*) fCanvasForRatios->FindObject("CFRLeg"))) leg->Clear();
00422   else {
00423     leg = new TLegend(0.2,0.2,0.4,0.4);
00424     leg->SetName("CFRLeg");
00425     leg->SetBorderSize(1);
00426   }
00427 
00428   Systematic::Systematic_t sys = Systematic::ESystematic(whichSys);
00429   if(fFileMap.find(sys)==fFileMap.end()) return;
00430   std::map<string,TH1D*> summedMap;
00431   TH1D *dataHist = NULL;
00432 
00433   std::map<Background::Background_t,NueBackground*>::iterator dataBeg = 
00434     fDataHists[Detector::kNear].begin();
00435   std::map<Background::Background_t,NueBackground*>::iterator dataEnd = 
00436     fDataHists[Detector::kNear].end();
00437   while(dataBeg!=dataEnd){
00438     Background::Background_t bg = dataBeg->first;
00439 
00440     if(bg == Background::kBNueCC || bg == Background::kSelCC
00441               || bg == Background::kNuTauCC) {
00442        dataBeg++; continue;
00443     }
00444 
00445     std::map<NueSystematic*,TH1D*>::iterator predBeg = fPredictionMap[bg][sys].begin();
00446     std::map<NueSystematic*,TH1D*>::iterator predEnd = fPredictionMap[bg][sys].end();
00447     Int_t colCounter = 0;
00448     char label[256];
00449     while(predBeg!=predEnd){
00450       Double_t sysVal = predBeg->first->GetSysValue(sys);
00451       string sysNom = predBeg->first->GetName();
00452       if(sys==Systematic::kOscProb) {
00453         TString ts(sysNom);
00454         if(!ts.Contains(fOscSysString)) { predBeg++; continue;}
00455         Double_t tmpDub, theta23, delta23;
00456         Int_t tmpInt;
00457         predBeg->first->GetOscParams(tmpDub,theta23,tmpDub,tmpDub,delta23,tmpDub,tmpInt);
00458         if(ts.Contains("Theta23")) sysVal = theta23;
00459         else if(ts.Contains("Delta23")) sysVal = delta23;
00460       }
00461       if(summedMap.find(sysNom)!=summedMap.end()) 
00462         summedMap[sysNom]->Add(predBeg->second);
00463       else {
00464         string name = "FN_Total_Ratio_" + string(fSelection) + "_" + 
00465           string(Systematic::AsString(sys));
00466         summedMap[sysNom] = (TH1D*) predBeg->second->Clone(name.c_str());
00467         summedMap[sysNom]->SetLineColor(fColourArray[colCounter]);
00468         summedMap[sysNom]->SetMarkerColor(fColourArray[colCounter]);
00469         if(sys!=Systematic::kOscProb) sprintf(label,"%s = %.2f",
00470                                               Systematic::AsString(sys),sysVal);
00471         else sprintf(label,"%s = %.4f",fOscSysString.c_str(),sysVal);
00472         leg->AddEntry(summedMap[sysNom],label,"lp");
00473         colCounter++;
00474       }
00475       predBeg++;
00476     }
00477     if(dataHist==0) {
00478       dataHist = (TH1D*) fDataHists[Detector::kNear][dataBeg->first]
00479         ->GetHist()->Clone("tmpHist");
00480       //leg->AddEntry(dataHist,"Pseudo-Data","lp");
00481     }
00482     else dataHist->Add(fDataHists[Detector::kNear][dataBeg->first]->GetHist());
00483     dataBeg++;
00484   }
00485 
00486   std::map<string,TH1D*>::iterator sumBeg = summedMap.begin();
00487   std::map<string,TH1D*>::iterator sumEnd = summedMap.end();
00488   while(sumBeg!=sumEnd){
00489     sumBeg->second->Divide(dataHist);
00490     sumBeg->second->Scale(1e19/(3.5e20));
00491     sumBeg->second->SetAxisRange(0,10);
00492     fRatiosForDrawing->Add(sumBeg->second,"hist");
00493     sumBeg++;
00494   }
00495   delete dataHist;
00496 
00497   //draw:
00498   fRatiosForDrawing->Draw("nostack");
00499   fRatiosForDrawing->GetXaxis()->SetRangeUser(0,10);
00500   string title = "F/N Total Ratio with " + string(fSelection) + 
00501     " and Tweaks in " + string(Systematic::AsString(sys));
00502   fRatiosForDrawing->SetTitle(title.c_str());
00503   leg->Draw();
00504   gROOT->ProcessLine("SortOutStats(gPad,0.25,0.6,1,0.98,0.81);STS(0.04);");
00505   if(fDoPrint) {
00506     string printName = "FN_Total_Ratio_" + string(fSelection) + "_" + 
00507       string(Systematic::AsString(sys)) + ".gif";
00508     fCanvasForRatios->Print(printName.c_str());
00509   }
00510 }

void JBComparator::DrawSummary (  ) 

Definition at line 789 of file JBComparator.cxx.

References Systematic::AsString(), DeleteSummaryForDrawing(), fCanvasForSummary, fDoPrint, fSelection, fSummaryForDrawing, GetSummary(), and it.

00790 {
00791   this->DeleteSummaryForDrawing();
00792   fCanvasForSummary->cd();  
00793   TLegend *leg = (TLegend*) fCanvasForSummary->FindObject("CFSLeg");
00794   if(leg) leg->Clear();
00795   else {
00796     leg = new TLegend(0.2,0.2,0.4,0.4);
00797     leg->SetName("CFSLeg");
00798     leg->SetBorderSize(1);
00799   }
00800   fCanvasForSummary->Clear();
00801     
00802   TGraph *tot_min_sum = this->GetSummary();
00803   leg->AddEntry(tot_min_sum,"Total","p");
00804   TIter it(fSummaryForDrawing->GetListOfGraphs()->MakeIterator());
00805   TGraph *tot_max_sum = 0;
00806   while((tot_max_sum = (TGraph*) it())) {
00807     if(tot_min_sum != tot_max_sum) break;
00808   }
00809   
00810   Double_t min_sys = 0;
00811   Double_t max_sys = 0;
00812   for(int i=0;i<tot_min_sum->GetN();i++) {
00813     min_sys += TMath::Power(1-tot_min_sum->GetY()[i],2);
00814     max_sys += TMath::Power(tot_max_sum->GetY()[i]-1,2);
00815   }
00816   min_sys = 100*TMath::Sqrt(min_sys);
00817   max_sys = 100*TMath::Sqrt(max_sys);
00818  /* 
00819   std::map<Background::Background_t,NueBackground*>::iterator dataBeg = 
00820     fDataHists[Detector::kNear].begin();
00821   std::map<Background::Background_t,NueBackground*>::iterator dataEnd = 
00822     fDataHists[Detector::kNear].end();
00823   while(dataBeg!=dataEnd){
00824     leg->AddEntry(this->GetSummary(Int_t(dataBeg->first)),
00825                   Background::AsString(dataBeg->first),"p");
00826     dataBeg++;
00827   }
00828 */
00829   fCanvasForSummary->Clear();  
00830   fSummaryForDrawing->Draw("A");
00831   for(int i=0;i<tot_min_sum->GetN();i++){
00832     Systematic::Systematic_t sys = Systematic::ESystematic((int)tot_min_sum->GetX()[i]);
00833     fSummaryForDrawing->GetXaxis()->SetBinLabel(fSummaryForDrawing->GetXaxis()->
00834                                                 FindBin(tot_min_sum->GetX()[i]),
00835                                                 Systematic::AsString(sys));
00836   }
00837   leg->Draw();
00838 
00839   char tex_string[100]; sprintf(tex_string,"Total Systematic = +%.1f%% -%.1f%%",max_sys,min_sys);
00840   TLatex *tex = new TLatex(0.015,0.9,tex_string);
00841   tex->SetNDC();
00842   tex->SetTextSize(0.045);
00843   tex->Draw();
00844 
00845   gROOT->ProcessLine("SortOutStats(gPad,0.2,0.2,1,0.98,0.98);STS(0.04);");
00846   if(fDoPrint) {
00847     string printName = "SystematicSummary_" + string(fSelection) + ".gif";
00848     fCanvasForSummary->Print(printName.c_str());
00849   }
00850 }

Bool_t JBComparator::ExtractDataHists ( TFile *  file  ) 

Definition at line 101 of file JBComparator.cxx.

References Background::AsString(), fBgVec, fDataHists, fFDDataPOT, fHistType, fNDDataPOT, fSelection, Detector::kFar, Detector::kNear, Background::kNueCC, Background::kNuMuCC, Background::kNuTauCC, and Selection::StringToEnum().

Referenced by AddSysFile().

00102 {
00103   std::cout << "Extracting Data Hists" << std::endl;
00104   if(!file) return false;
00105  
00106   TTree *tree = (TTree*) file->Get("energytree");
00107   if(!tree) return false;
00108   
00109   tree->SetBranchAddress("nearPOT",&fNDDataPOT);
00110   tree->SetBranchAddress("farPOT",&fFDDataPOT);
00111   tree->SetBranchAddress("Selection",fSelection);
00112   tree->GetEvent(0);
00113   tree->ResetBranchAddresses();
00114 
00115   std::vector<Background::Background_t>::iterator bgBeg = fBgVec.begin();
00116   std::vector<Background::Background_t>::iterator bgEnd = fBgVec.end();
00117   while(bgBeg!=bgEnd){
00118     string directory = "Predictions_Standard_" + string(fSelection);
00119 
00120     string histname = directory + "/ND_Data_RecoEnergy_" + string(Background::AsString(*bgBeg));
00121 
00122     if((*bgBeg)==Background::kNuTauCC || (*bgBeg)==Background::kNueCC) {
00123       histname = directory + "/ND_Data_RecoEnergy_" + 
00124                       string(Background::AsString(Background::kNuMuCC));
00125     }
00126     cout<<"Reaching for "<<histname<<endl;
00127     TH1D *hist = (TH1D*) file->Get(histname.c_str());
00128     if(!hist) return false;
00129     string nuename = "ND_" + fHistType + "_" + string(fSelection) + "_" + 
00130       string(Background::AsString(*bgBeg)) + "_DATA";
00131     NueBackground *nbg = new NueBackground(nuename,hist,Detector::kNear,
00132                                            (*bgBeg),Selection::StringToEnum(fSelection),
00133                                            fNDDataPOT);
00134     fDataHists[Detector::kNear][*bgBeg] = nbg;
00135 
00136 
00137     histname = directory + "/FarPrediction_" + string(Background::AsString(*bgBeg));
00138     hist = (TH1D*) file->Get(histname.c_str());
00139     cout<<"Reaching for "<<histname<<endl;
00140     if(!hist) return false;
00141     nuename = "FD_" + fHistType + "_" + string(fSelection) + "_" + 
00142       string(Background::AsString(*bgBeg)) + "_DATA";
00143     NueBackground *fbg = new NueBackground(nuename,hist,Detector::kFar,
00144                                            (*bgBeg),Selection::StringToEnum(fSelection),
00145                                            fFDDataPOT);
00146     fDataHists[Detector::kFar][*bgBeg] = fbg;
00147     bgBeg++;
00148   }
00149   return true;
00150 }

void JBComparator::GetError ( Int_t  whichSys,
double *  error,
double *  minerr,
TH1D *  Base 
)

Definition at line 976 of file JBComparator.cxx.

References Systematic::AsString(), fPredictionsForDrawing, fSelection, and it.

Referenced by DetermineError().

00977 {
00978   static double totMin = 0;
00979   static double totMax = 0;
00980 
00981   double maxDiff = 0;
00982   double minDiff = 0;
00983 
00984   //it already has all the ratios in
00985   if(fPredictionsForDrawing->GetHists()) {
00986     TIter it(fPredictionsForDrawing->GetHists()->MakeIterator());
00987     TObject* ob = 0;
00988 
00989     while((ob = it())){
00990       if(strstr(ob->GetName(), "DataHist")!=0) continue;
00991       TH1D* temp = (TH1D*) ob;
00992 
00993       double diffa = Base->GetSum() - temp->GetSum();
00994       if(diffa > 0 && diffa > maxDiff) maxDiff = diffa;
00995       if(diffa < 0 && diffa < minDiff) minDiff = diffa;
00996  
00997       for(int i = 0; i < 10; i++){
00998          double diff = Base->GetBinContent(i) - temp->GetBinContent(i);
00999          if(diff > 0 && diff > error[i]) error[i] = diff;
01000          if(diff < 0 && diff < minerr[i]) minerr[i] = diff;          
01001       }
01002     }
01003   }
01004 
01005   string name = "NCandCC_" +
01006       string(fSelection) + "_" + string(Systematic::AsString(Systematic::ESystematic(whichSys)));
01007 
01008   TString errName = "MaxErrorBand_" + name;
01009   TH1D* errBand = (TH1D*) Base->Clone(errName);
01010   errBand->Reset("ICE");
01011 
01012   errName = "MinErrorBand_" + name;
01013   TH1D* errBandm = (TH1D*) Base->Clone(errName);
01014   errBandm->Reset("ICE");
01015 
01016   for(int i = 0; i < 11; i++){
01017       errBand->SetBinContent(i, error[i]);
01018       errBandm->SetBinContent(i, minerr[i]);
01019   }
01020 
01021   cout<<errBand->GetSum()/Base->GetSum()<<endl;
01022   cout<<errBandm->GetSum()/Base->GetSum()<<endl;
01023 
01024   errBand->Write();
01025   errBandm->Write();
01026   cout<<minDiff<<"  "<<maxDiff<<endl;
01027   cout<<minDiff/Base->GetSum()<<"  "<<maxDiff/Base->GetSum()<<endl;
01028 
01029   totMax = TMath::Sqrt(totMax*totMax + maxDiff*maxDiff);
01030   totMin = TMath::Sqrt(totMin*totMin + minDiff*minDiff);
01031 
01032   cout<<totMax<<"  "<<totMin<<"  "<<totMax/Base->GetSum()<<"  "<<totMin/Base->GetSum()<<endl;
01033 
01034   cout<<"DOne with "<<name<<endl;
01035 }

Double_t JBComparator::GetFDSpectrumIntegral ( Background::Background_t  bg,
Systematic::Systematic_t  sys,
Double_t  inputVal 
) [protected]

Definition at line 751 of file JBComparator.cxx.

References Background::AsString(), Systematic::AsString(), MuELoss::e, fFileMap, fHistType, fOscSysString, fSelection, and Systematic::kOscProb.

Referenced by DrawIntegral().

00753 {
00754   TFile *f = new TFile(fFileMap[sys].c_str(),"READ");
00755   TTree *tree = (TTree*) f->Get("energytree");  
00756   Double_t sysVal = 0;
00757   tree->SetBranchAddress(Systematic::AsString(sys),&sysVal);
00758   char sysname[256];
00759   tree->SetBranchAddress("SysName",sysname);
00760   Double_t farPOT = 0;
00761   tree->SetBranchAddress("farPOT",&farPOT);
00762   Double_t theta23,delta23;
00763   tree->SetBranchAddress("Theta23",&theta23); 
00764   tree->SetBranchAddress("DeltaMSq23",&delta23);
00765   for(int i=0;i<tree->GetEntries();i++){
00766     tree->GetEntry(i);
00767     if(sys==Systematic::kOscProb) {
00768       TString ts(sysname);
00769       if(!ts.Contains(fOscSysString)) continue;
00770       if(ts.Contains("Theta23")) {
00771         if(TMath::Abs(theta23-inputVal)<1e-6) break;
00772       }
00773       else if(ts.Contains("Delta23")) {
00774         if(TMath::Abs(delta23-inputVal)<1e-6) break;
00775       }
00776     }
00777    else if(TMath::Abs(sysVal-inputVal)<1e-6) break;
00778   }
00779   string hname = string(Background::AsString(bg)) + "_" + string(sysname) 
00780                  + "_" + string(fSelection) + "/FD_" + fHistType;
00781   TH1D *hist = (TH1D*) f->Get(hname.c_str());
00782   if(hist == 0) cout<<"Failed to get hist: "<<hname<<endl;
00783   Double_t integ = hist->Integral()*(3.5e20/farPOT);
00784   f->Close();
00785   delete f;
00786   return integ;
00787 }

std::map< NueSystematic *, TH1D * > JBComparator::GetPredictions ( Systematic::Systematic_t  sysType,
Background::Background_t  bgType 
) [protected]

Definition at line 170 of file JBComparator.cxx.

References NueSystematic::AddSystematic(), bfld::AsString(), Background::AsString(), Systematic::AsString(), fFileMap, fSelection, and NueSystematic::SetOscParams().

Referenced by ComputeAll().

00172 {
00173   cout << "Getting Predictions for " << Systematic::AsString(sysType) << " and "
00174        << Background::AsString(bgType) << endl;
00175   std::map<NueSystematic*,TH1D*> histVec;
00176   TFile *file = new TFile(fFileMap[sysType].c_str(),"READ");
00177 
00178   char SysName[200];
00179 
00180   TTree *tree = (TTree*) file->Get("energytree");
00181   tree->SetBranchAddress("Selection",fSelection);
00182   Double_t theta12=0,theta23=0,theta13=0;
00183   Double_t deltaMSq23=0,deltaMSq12=0;
00184   Double_t deltaCP=0;Int_t massHierarchy=0;
00185 
00186   Int_t max_sys = tree->GetEntries();
00187   for(int i=0;i<max_sys;i++){
00188     tree->SetBranchAddress("SysName",SysName);
00189     tree->SetBranchAddress("Theta12",&theta12);
00190     tree->SetBranchAddress("Theta23",&theta23);
00191     tree->SetBranchAddress("Theta13",&theta13);
00192     tree->SetBranchAddress("DeltaMSq23",&deltaMSq23);
00193     tree->SetBranchAddress("DeltaMSq12",&deltaMSq12);
00194     tree->SetBranchAddress("DeltaCP",&deltaCP);
00195     tree->SetBranchAddress("MassHierarchy",&massHierarchy);
00196 
00197     tree->GetEntry(i);
00198     
00199     string dir = "Predictions_" + string(SysName) + "_" + string(fSelection) + "/";
00200     string hist = "FarPrediction_" + string(Background::AsString(bgType));
00201     string histname = dir + hist;
00202 
00203     TH1D *histo = (TH1D*) file->Get(histname.c_str());
00204 
00205     string nomus = hist + "_" + string(SysName);
00206     histo->SetName(nomus.c_str());
00207     histo->SetDirectory(0);
00208 
00209     NueSystematic *nueSys = new NueSystematic(string(SysName));
00210     nueSys->SetOscParams(theta12,theta23,theta13,deltaMSq12,
00211                        deltaMSq23,deltaCP,massHierarchy);
00212                                                                                                    
00213     Int_t max_sys_index = 0;
00214     while(strcmp(Systematic::AsString(Systematic::ESystematic(max_sys_index)),
00215                "?Unknown?")!=0) {
00216       tree->ResetBranchAddresses();
00217       Double_t tempDouble = 0;
00218       tree->SetBranchAddress(Systematic::AsString(Systematic::ESystematic(max_sys_index)),
00219                                   &tempDouble);
00220       tree->GetEntry(i);
00221       if(tempDouble>-9998) {
00222         nueSys->AddSystematic(Systematic::ESystematic(max_sys_index),tempDouble);
00223       }
00224       max_sys_index++;
00225     }
00226 
00227     histVec[nueSys] = histo;
00228   }
00229 
00230   delete file;
00231   return histVec;
00232 }

TGraph * JBComparator::GetSummary ( Int_t  bg = -1  ) 

Definition at line 852 of file JBComparator.cxx.

References bfld::AsString(), DrawIntegral(), fColourArray, fFileMap, fIntegralsForDrawing, fOscSysString, fSummaryForDrawing, it, Systematic::kOscProb, n, one(), and zero().

Referenced by DrawSummary().

00853 {
00854 
00855   Int_t n = 0;
00856   Double_t one[100] = {0};
00857   Double_t zero[100] = {0};
00858   Double_t sysNum[100] = {0};
00859   Double_t sysMin[100] = {0};
00860   Double_t sysMax[100] = {0};
00861 
00862   //hold current value of OscSysString. Will do Theta23 first then Delta23.
00863   string oscSt = fOscSysString;
00864   fOscSysString = "Theta23";
00865 
00866   std::map<Systematic::Systematic_t,std::string>::iterator fileBeg = 
00867     fFileMap.begin();
00868   std::map<Systematic::Systematic_t,std::string>::iterator fileEnd = 
00869     fFileMap.end();
00870   while(fileBeg!=fileEnd){
00871     if(whichBG<0) this->DrawIntegral(Int_t(fileBeg->first));
00872     else this->DrawIntegral(Int_t(fileBeg->first),whichBG);
00873     TGraph *gr = 0;
00874     if(fIntegralsForDrawing->GetListOfGraphs()){
00875       TIter it(fIntegralsForDrawing->GetListOfGraphs()->MakeIterator());
00876       while((gr = (TGraph*) it())) {
00877         if(gr->GetMarkerColor()==4) break;
00878       }
00879     }
00880     if(gr) {      
00881       sysNum[n] = Int_t(fileBeg->first);
00882       Double_t x=0,y=0;
00883       for(int i=0;i<gr->GetN();i++){
00884         gr->GetPoint(i,x,y);
00885         if(i==0 || y>sysMax[n]) sysMax[n] = y;
00886         if(i==0 || y<sysMin[n]) sysMin[n] = y;
00887       }
00888     }
00889     one[n] = 1;
00890     zero[n] = 0;
00891     n++;
00892 
00893     //if we are doing OscProb, and fOscSysString is Theta23, 
00894     //then do Delta23, otherwise move onto the next systematic
00895     if(fileBeg->first==Systematic::kOscProb && 
00896        fOscSysString!="Delta23") fOscSysString = "Delta23";
00897     else fileBeg++;
00898   }
00899 
00900   //revert back to original value of fOscSysString
00901   fOscSysString = oscSt;
00902 
00903   TGraph *minGr = new TGraph(n,sysNum,sysMin);
00904   TGraph *maxGr = new TGraph(n,sysNum,sysMax);
00905   if(whichBG<0) cout << "Summary info for Total background" << endl;
00906   else {
00907     Background::Background_t bg = Background::EBackground(whichBG);
00908     cout << "Summary info for " << Background::AsString(bg) << endl;;
00909   }
00910   for(int i=0;i<n;i++){
00911     Systematic::Systematic_t sys = Systematic::ESystematic((int)sysNum[i]);
00912     cout << Systematic::AsString(sys) << " " 
00913          << sysMin[i] << " " << sysMax[i] << endl;
00914   }
00915   if(whichBG>0){
00916     minGr->SetMarkerColor(fColourArray[whichBG+1]);
00917     maxGr->SetMarkerColor(fColourArray[whichBG+1]);
00918     minGr->SetMarkerStyle(24); //open circles
00919     maxGr->SetMarkerStyle(24);
00920     minGr->SetMarkerSize(1); //open circles
00921     maxGr->SetMarkerSize(1);
00922   }
00923   fSummaryForDrawing->Add(minGr,"P");
00924   fSummaryForDrawing->Add(maxGr,"P");
00925   return minGr;
00926 }

Bool_t JBComparator::InBGVector ( Background::Background_t  bg  )  [protected]

Definition at line 965 of file JBComparator.cxx.

References fBgVec.

Referenced by DrawIntegral(), DrawPrediction(), and DrawRatio().

00966 {
00967   std::vector<Background::Background_t>::iterator beg = fBgVec.begin();
00968   std::vector<Background::Background_t>::iterator end = fBgVec.end();
00969   while(beg!=end) {
00970     if((*beg)==bg) return true;
00971     beg++;
00972   }
00973   return false;
00974 }

void JBComparator::SetOscSysString ( string  oss  )  [inline]

Definition at line 55 of file JBComparator.h.

References fOscSysString.

00055 {fOscSysString = oss;}


Member Data Documentation

Definition at line 75 of file JBComparator.h.

Referenced by AddBackground(), ExtractDataHists(), and InBGVector().

TCanvas* JBComparator::fCanvasForIntegrals [protected]

Definition at line 94 of file JBComparator.h.

Referenced by DrawIntegral(), and ~JBComparator().

Definition at line 92 of file JBComparator.h.

Referenced by DrawPrediction(), and ~JBComparator().

TCanvas* JBComparator::fCanvasForRatios [protected]

Definition at line 93 of file JBComparator.h.

Referenced by DrawRatio(), and ~JBComparator().

TCanvas* JBComparator::fCanvasForSummary [protected]

Definition at line 95 of file JBComparator.h.

Referenced by DrawSummary(), and ~JBComparator().

Int_t JBComparator::fColourArray[20] [protected]

Definition at line 67 of file JBComparator.h.

Referenced by DrawPrediction(), DrawRatio(), and GetSummary().

Bool_t JBComparator::fDoPrint [protected]

Definition at line 68 of file JBComparator.h.

Referenced by DoPrint(), DrawIntegral(), DrawPrediction(), DrawRatio(), and DrawSummary().

Double_t JBComparator::fFDDataPOT [protected]

Definition at line 64 of file JBComparator.h.

Referenced by ExtractDataHists().

std::map<Systematic::Systematic_t,string> JBComparator::fFileMap [protected]
std::string JBComparator::fHistType [protected]

Definition at line 65 of file JBComparator.h.

Referenced by ExtractDataHists(), and GetFDSpectrumIntegral().

TMultiGraph* JBComparator::fIntegralsForDrawing [protected]

Definition at line 104 of file JBComparator.h.

Referenced by DeleteIntegralsForDrawing(), DrawIntegral(), GetSummary(), and ~JBComparator().

Double_t JBComparator::fNDDataPOT [protected]

Definition at line 63 of file JBComparator.h.

Referenced by ExtractDataHists().

std::string JBComparator::fOscSysString [protected]

Definition at line 83 of file JBComparator.h.

Referenced by ComputeAll(), DrawIntegral(), DrawPrediction(), DrawRatio(), and ~JBComparator().

TFile* JBComparator::fRatioFile [protected]

Definition at line 107 of file JBComparator.h.

Referenced by DetermineError().

THStack* JBComparator::fRatiosForDrawing [protected]

Definition at line 103 of file JBComparator.h.

Referenced by DeleteRatiosForDrawing(), DrawRatio(), and ~JBComparator().

char JBComparator::fSelection[256] [protected]
TMultiGraph* JBComparator::fSummaryForDrawing [protected]

Definition at line 105 of file JBComparator.h.

Referenced by DeleteSummaryForDrawing(), DrawSummary(), GetSummary(), and ~JBComparator().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1