25 getData(timestamp, nDays, naming, samdef);
29 std::string mcFile =
"predictions_" + naming +
".root";
30 std::string dtFile =
"dataspectra_" + naming +
".root";
34 TFile* mcPred =
new TFile(mcFile.c_str());
35 TFile* dtSpec =
new TFile(dtFile.c_str());
66 {
"Time",
"time",
Binning::Simple(nDays<3 ? 24*nDays : nDays,timestamp - 86400*nDays,timestamp),
SIMPLEVAR(hdr.unixtime)},
90 std::cout <<
"Data name :" << dataName <<
" and the Bkg Name :" << bkgName <<
std::endl;
92 hBkg[
i] = LoadFrom<Spectrum>(dtSpec, bkgName).
release();
93 hPred[
i] = LoadFrom<PredictionNoExtrap>(mcPred, (p.
fname).c_str() ).
release();
99 Spectrum* massDenom = LoadFrom<Spectrum>(dtSpec,
"massDenom").
release();
101 Spectrum* nonSwapDenom = LoadFrom<Spectrum>(mcPred,
"nonSwapDenom").
release();
102 Spectrum* swapDenom = LoadFrom<Spectrum>(mcPred,
"swapDenom").
release();
104 const double massFactor = massNum->
ToTH1(1)->Integral(0, -1) / massDenom->
ToTH1(1)->Integral(0, -1);
105 double signal = 0, mcsig = 0, mcsig_min = 0, mcsig_max = 0,
bkg = 0;
106 double mc_numu = 0, mc_nue = 0, mc_nc = 0;
113 hSig->SetName((
"sig_"+plots[
i].
fname).c_str());
121 hSig->SetLineColor(0);
122 hSig->SetLineWidth(1);
123 hSig->SetMarkerColor(0);
124 hSig->GetXaxis()->SetTitle((plots[
i].
label).c_str());
125 hSig->GetYaxis()->SetRangeUser(0,hSig->GetMaximum()*1.12+4.);
127 grSig->SetMarkerStyle(20);
128 grSig->SetMarkerColor(kBlack);
129 grSig->SetLineColor(kBlack);
130 grSig->SetLineWidth(2);
131 grSig->SetName((
"grSig_"+plots[
i].fname).c_str());
132 grSig->GetXaxis()->SetTitle((plots[
i].label).c_str());
138 hMC_min->SetName((
"MC_min_"+plots[
i].fname).c_str());
139 hMC_min->SetLineColor(
kRed-9);
140 hMC_min->SetLineWidth(1);
142 hMC_max->SetName((
"MC_max_"+plots[
i].fname).c_str());
143 hMC_max->SetLineColor(
kRed-9);
144 hMC_max->SetLineWidth(1);
147 hMC_numu->SetLineColor(
kBlue);
149 hMC_nue->SetLineColor(
kGreen+2);
151 hMC_NC->SetLineColor(kGray);
154 hBKG->SetName((
"BKG_"+plots[
i].fname).c_str());
155 hBKG->SetLineColor(
kBlue);
163 signal = hSig->GetBinContent(19);
164 mcsig = hPred[
i]->
Predict(&calcDef).
ToTH1(hData[
i]->
POT()*massFactor)->Integral(0, -1);
165 mc_numu = hMC_numu->Integral(0, -1);
166 mc_nue = hMC_nue->Integral(0, -1);
167 mc_nc = hMC_NC->Integral(0, -1);
168 mcsig_min = hPred[
i]->
Predict(&calcMin).
ToTH1(hData[
i]->
POT()*massFactor)->Integral(0, -1);
169 mcsig_max = hPred[
i]->
Predict(&calcMax).
ToTH1(hData[
i]->
POT()*massFactor)->Integral(0, -1);
170 bkg = (hSig->Integral(1, hSig->GetNbinsX())-signal)/(hSig->GetNbinsX()-1);
181 hExp->SetBinContent(19,mcsig+
bkg);
182 hExp_min->SetBinContent(19,mcsig_min+
bkg);
183 hExp_max->SetBinContent(19,mcsig_max+
bkg);
185 TGraph*
g =
new TGraph;
186 g->SetPoint(0, -1000e3,
bkg);
187 g->SetPoint(1, +1000e3,
bkg);
188 g->SetLineColor(
kBlue);
196 TH1* hHelp = (TH1*)hBKG->Clone();
197 TH1* hHelpMin = (TH1*)hBKG->Clone();
198 TH1* hHelpMax = (TH1*)hBKG->Clone();
200 for(
int binId=0; binId<hExp->GetNbinsX(); binId++){
201 hHelp->SetBinContent(binId+1, hExp->GetBinContent(binId+1));
202 hHelpMin->SetBinContent(binId+1, hExp_min->GetBinContent(binId+1));
203 hHelpMax->SetBinContent(binId+1, hExp_max->GetBinContent(binId+1));
207 hExp = (TH1*)hHelp->Clone();
211 hExp_min = (TH1*)hHelp->Clone();
215 hExp_max = (TH1*)hHelp->Clone();
225 hExp_max->SetName((
"Exp_max_"+plots[
i].fname).c_str());
226 hExp_max->SetLineColor(
kRed-9);
227 hExp_min->SetName((
"Exp_min_"+plots[
i].fname).c_str());
228 hExp_max->SetLineColor(
kRed-9);
231 grShade->SetName((
"shade_"+plots[
i].fname).c_str());
232 grShade->SetFillColor(
kRed-9);
233 grShade->SetLineColor(
kRed-9);
236 double ymax = 1.3*
std::max( hSig->GetMaximum(), hExp->GetMaximum());
237 hExp->GetYaxis()->SetRangeUser(0,ymax);
239 hExp->GetXaxis()->SetTitle((plots[
i].
label).c_str());
240 hExp->SetName((
"Exp_"+plots[
i].fname).c_str());
241 hExp->SetLineColor(
kRed);
242 hExp->SetLineStyle(1);
243 hExp->Draw(
"hist same");
244 hMC_numu->Draw(
"hist same");
245 hMC_nue->Draw(
"hist same");
246 hMC_NC->Draw(
"hist same");
247 hExp->Draw(
"hist same");
249 hSig->Draw(
"hist same");
250 grSig->Draw(
"P same");
253 TLegend* ll =
new TLegend(0.15,0.60,0.45,0.89);
254 ll->AddEntry(grSig,
"Data",
"l");
255 ll->AddEntry(grShade,
"Osc. Uncty.",
"lf");
256 ll->AddEntry(hExp,
"Expectation",
"l");
257 ll->AddEntry(hMC_numu,
"#nu_{#mu}",
"l");
258 ll->AddEntry(hMC_nue,
"#nu_{e}",
"l");
259 ll->AddEntry(hMC_NC,
"NC",
"l");
264 hSig->SaveAs((
"/nova/ana/users/novadq/TimePeak/Plots/" + naming +
"/Tools/sig_"+plots[
i].fname+
".root").c_str());
265 hMC->SaveAs((
"/nova/ana/users/novadq/TimePeak/Plots/" + naming +
"/Tools/MC_"+plots[
i].fname+
".root").c_str());
266 hBKG->SaveAs((
"/nova/ana/users/novadq/TimePeak/Plots/" + naming +
"/Tools/BKG_"+plots[
i].fname+
".root").c_str());
269 gPad->SaveAs((
"/nova/ana/users/novadq/TimePeak/Plots/" + naming +
"/Plots/"+plots[
i].fname+
".png").c_str());
274 for(
int j = 1;
j <= h->GetNbinsX(); ++
j){
275 if(h->GetBinContent(
j) > 5)
282 TH2* hPOT = potTime->
ToTH2(mcsig);
283 hPOT->SetName(
"hPOT");
284 hPOT->SaveAs((
"/nova/ana/users/novadq/TimePeak/Plots/"+naming+
"/Tools/hPOT.root").c_str());
T max(const caf::Proxy< T > &a, T b)
TH2 * ToTH2(double exposure, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Spectrum must be 2D to obtain TH2.
Cuts and Vars for the 2020 FD DiF Study.
void SetTh13(const T &th13) override
void ResetOscCalcToDefault(osc::IOscCalcAdjustable *calc)
Reset calculator to default assumptions for all parameters.
void getData(int sampleCut=9, std::string period="full", std::string anaCut="3A", bool energy3a=true, bool optBin=true)
TH1D * ToTH1(double exposure, Color_t col=kBlack, Style_t style=kSolid, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Histogram made from this Spectrum, scaled to some exposure.
double Integral(const Spectrum &s, const double pot, int cvnregion)
const Var kSliceTime([](const caf::SRProxy *sr){return sr->slc.meantime/1000;})
void getSigmaPlots(double MCSignal, unsigned int timestamp, unsigned int nDays, std::string naming)
TGraphAsymmErrors * GraphWithPoissonErrors(const TH1 *h, bool noErrorsXaxis, bool drawEmptyBins)
Calculate statistical errors appropriate for small Poisson numbers.
const Var kDirZ([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return-5.f;return sr->trk.kalman.tracks[0].dir.Z();})
#define SIMPLEVAR(CAFNAME)
For Vars where literally all you need is a single CAF variable.
Representation of a spectrum in any variable, with associated POT.
void lastUpdated(unsigned int timestamp)
Track finder for cosmic rays.
const Var kPtP
Transverse momentum fraction in slice.
Charged-current interactions.
const double timeWindowFactor
void makePred(bool usesysts=true, bool useFakeNDData=false)
====================================================================== ///
const Var kBoxMaxY([](const caf::SRProxy *sr){return sr->slc.boxmax.Y()/100;})
const std::vector< Plot > plots
TGraph * ShadeBetweenHistograms(TH1 *hmin, TH1 *hmax)
Optimized version of OscCalcPMNS.
void SetTh23(const T &th23) override
void SetDmsq21(const T &dmsq21) override
std::vector< double > POT
void SetDmsq32(const T &dmsq32) override
void SetTh12(const T &th12) override
void getSigmaPlotsAll(double MCSignal, unsigned int timestamp, unsigned int nDays, std::string naming)
Neutral-current interactions.
Both neutrinos and antineutrinos.
All neutrinos, any flavor.
void getTimePeakPlots(std::string samdef, unsigned int timestamp, unsigned int nDays, std::string naming)
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})