10 #include "CAFAna/Cuts/NumuCuts2018.h" 15 #include "CAFAna/Vars/NumuVars.h" 23 #include "TGraphErrors.h" 24 #include "TGraphAsymmErrors.h" 31 #include "TSpectrum.h" 44 gStyle->SetStatFormat(
"6.3g");
45 gStyle->SetPaintTextFormat(
"6.3g");
46 gStyle->SetFitFormat(
"6.3g");
49 const std::string outDir =
"/nova/ana/users/novadq/BeamMonitoring/Plots/stability/";
51 const std::string fFiles =
"dataset_def_name_newest_snapshot " + samdef + Form(
" and online.subrunendtime >= '%u' and online.subrunendtime <= '%u'", timestamp - 86400*nDays, timestamp);
67 hPOT[
j] =
new TH1D(Form(
"pot_%i",
j+1),
";Central Time;POT (10^{15})", nBins, timestamp - 86400*nDays, timestamp);
75 {
";Central Time;Reconstructed neutrino energy (GeV)",
"ccE",
Binning::Simple(10,0,5),
kCCE, kNumuNDCut, 1.5, 2.0},
76 {
";Central Time;Reconstructed hadronic energy (GeV)",
"hadE",
Binning::Simple(12,0,3),
kHadE, kNumuNDCut, 0.15, 0.50},
77 {
";Central Time;Reconstructed muon energy (GeV)",
"muonE",
Binning::Simple(15,0,4.5),
kMuE, kNumuNDCut, 1.0, 2.0},
101 TCanvas*
c =
new TCanvas(
"c",(fullName).c_str());
102 c->SetBottomMargin(0.15);
103 c->SetLeftMargin(0.15);
104 c->SetRightMargin(0.15);
106 TLegend*
leg =
new TLegend(0.17,0.17,0.83,0.4);
107 leg->SetFillColor(0);
115 TH2* Histogram = hData[
i][
j]->
ToTH2(hData[
i][
j]->
POT());
117 TProfile*
Profile = Histogram->ProfileX((monthName+
"Profile").c_str());
118 Profile->SetMarkerStyle(
datasets[
j].style);
120 Profile->SetLineColor(
datasets[
j].color);
121 Profile->SetMarkerSize(1.4);
123 Profile->GetXaxis()->CenterTitle();
124 Profile->GetYaxis()->CenterTitle();
125 Profile->GetYaxis()->SetTitle(Histogram->GetYaxis()->GetTitle());
126 Profile->GetXaxis()->SetTimeDisplay(1);
127 Profile->GetXaxis()->SetTimeFormat(
"%y-%m-%d%F1970-01-01 00:00:00");
129 unsigned int minBin = Profile->GetXaxis()->FindBin(timestamp - 86400*nDays);
130 unsigned int maxBin = Profile->GetXaxis()->FindBin(timestamp);
132 double minZoom = Profile->GetXaxis()->GetBinLowEdge(minBin-1);
133 double maxZoom = Profile->GetXaxis()->GetBinLowEdge(maxBin+2);
135 Profile->GetXaxis()->SetRangeUser(minZoom, maxZoom);
139 Profile->GetYaxis()->SetRangeUser(plots[
i].yRangeLow, plots[
i].yRangeHigh);
143 else Profile->Draw(
"same");
155 c->SaveAs((outDir+fullName+
".png").c_str());
156 c->SaveAs((outDir+fullName+
".pdf").c_str());
157 c->SaveAs((outDir+fullName+
".root").c_str());
160 double ww = c->GetWw();
161 double wh = c->GetWh();
163 TCanvas*
c2 =
new TCanvas(
"c2",(fullName).c_str(), 2*ww, wh);
164 c2->SetBottomMargin(0.15);
165 c2->SetLeftMargin(0.15);
166 c2->SetRightMargin(0.15);
168 c2->SetWindowSize(2*ww, wh);
171 if(
i>4) leg2 =
new TLegend(0.35,0.20,0.62,0.48);
172 else leg2 =
new TLegend(0.55,0.60,0.82,0.88);
173 leg2->SetFillColor(0);
174 leg2->SetNColumns(3);
178 TH1* hMean1D =
new TH1();
183 TH2* Histogram = hData[
i][
j]->
ToTH2(hData[
i][
j]->
POT());
185 TH1* Hist1D = Histogram->ProjectionY((dim1NameMonth).c_str());
187 if(
j == 0) hMean1D = (TH1*) Hist1D->Clone(
"Mean_1D");
188 else hMean1D->Add(Hist1D);
192 TGraphErrors* Graph =
new TGraphErrors(Hist1D);
193 Graph->SetName((dim1NameMonth+
"_gr").c_str());
194 Graph->SetMarkerStyle(
datasets[
j].style);
197 Graph->GetXaxis()->SetTitle(Hist1D->GetXaxis()->GetTitle());
198 Graph->GetYaxis()->SetTitle(
"Slices / 10^{15} POT");
199 Graph->GetXaxis()->CenterTitle();
200 Graph->GetYaxis()->CenterTitle();
202 for(
int fPoint = 0; fPoint<Graph->GetN(); ++fPoint)
205 double shift = (Hist1D->GetBinWidth(1) /
kNumPeriods) * ((
j+1)*1. - kNumPeriods*0.5);
206 Graph->GetPoint(fPoint, x, y);
207 dy = Graph->GetErrorY(fPoint);
208 Graph->SetPoint(fPoint, x + shift, y);
209 Graph->SetPointError(fPoint,0,dy);
214 Hist1D->SetLineWidth(0);
215 Hist1D->SetLineColor(10);
216 Hist1D->SetMarkerStyle(0);
217 Hist1D->SetMarkerColor(0);
218 Hist1D->Draw(
"hist");
227 hMean1D->Scale(1.0e15/hData[
i][0]->
POT());
228 hMean1D->SetLineWidth(1);
229 hMean1D->SetLineColor(kBlack);
230 hMean1D->Draw(
"hist same");
232 leg2->AddEntry(hMean1D,
"Average",
"l");
239 c2->SaveAs((outDir+dim1Name+
".png").c_str());
240 c2->SaveAs((outDir+dim1Name+
".pdf").c_str());
241 c2->SaveAs((outDir+dim1Name+
".root").c_str());
251 TH2* Histogram = hData[
i][
j]->
ToTH2(hData[
i][
j]->
POT());
253 TH1* Hist1D = Histogram->ProjectionY((ratioNameMonth).c_str());
257 TGraphErrors* Graph =
new TGraphErrors(Hist1D);
259 Graph->SetName((ratioNameMonth+
"_gr").c_str());
260 Graph->SetMarkerStyle(
datasets[
j].style);
263 Graph->GetXaxis()->SetTitle(Hist1D->GetXaxis()->GetTitle());
264 Graph->GetYaxis()->SetTitle(
"Slices per 10^{15} POT / Average");
265 Graph->GetXaxis()->CenterTitle();
266 Graph->GetYaxis()->CenterTitle();
268 for(
int fPoint = 0; fPoint<Graph->GetN(); ++fPoint)
271 double shift = (Hist1D->GetBinWidth(1) /
kNumPeriods) * ((
j+1)*1. - kNumPeriods*0.5);
272 my = hMean1D->GetBinContent(fPoint+1);
273 Graph->GetPoint(fPoint, x, y);
277 dy = Graph->GetErrorY(fPoint)/my;
278 Graph->SetPoint(fPoint, x + shift, y);
279 Graph->SetPointError(fPoint,0,dy);
285 Hist1D->GetYaxis()->SetRangeUser(0.8,1.2);
286 Hist1D->SetLineWidth(0);
287 Hist1D->SetLineColor(10);
288 Hist1D->SetMarkerStyle(0);
289 Hist1D->SetMarkerColor(0);
290 Hist1D->Draw(
"hist");
296 TGraph*
gr1 =
new TGraph;
297 gr1->SetPoint(0,-1.e99,1.);
298 gr1->SetPoint(1, 1.e99,1.);
299 gr1->SetLineColor(kBlack);
300 gr1->SetLineWidth(1);
301 gr1->SetFillColor(10);
309 c2->SaveAs((outDir+ratioName+
".png").c_str());
310 c2->SaveAs((outDir+ratioName+
".pdf").c_str());
311 c2->SaveAs((outDir+ratioName+
".root").c_str());
TH2 * ToTH2(double exposure, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Spectrum must be 2D to obtain TH2.
Represent the binning of a Spectrum's x-axis.
Cuts and Vars for the 2020 FD DiF Study.
const SpillVar kSpillTime([](const caf::SRSpillProxy *spill){return spill->spilltimesec;})
double Integral(const Spectrum &s, const double pot, int cvnregion)
std::vector< Dataset > datasets
const Var kTrkStartY([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return-10.0f;return sr->trk.kalman.tracks[0].start.Y()/100;})
TGraph * Profile(const IExperiment *expt, osc::IOscCalcAdjustable *calc, const IFitVar *v, int nbinsx, double minx, double maxx, double input_minchi, const std::vector< const IFitVar * > &profVars, const std::vector< const ISyst * > &profSysts, const SeedList &seedPts, const std::vector< SystShifts > &systSeedPts, std::map< const IFitVar *, TGraph * > &profVarsMap, std::map< const ISyst *, TGraph * > &profSystsMap, MinuitFitter::FitOpts opts)
scan in one variable, profiling over all others
void SetSpillCut(const SpillCut &cut)
Representation of a spectrum in any variable, with associated POT.
void lastUpdated(unsigned int timestamp)
====================================================================== ///
virtual void AddSpillHistogram(TH1 *h, const SpillVar &var, const SpillCut &cut, const SpillVar &wei=kSpillUnweighted)
Uses include counting the total POT or spills in a run.
const std::vector< Plot > plots
const Var kTrkStartZ([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return-10.0f;return sr->trk.kalman.tracks[0].start.Z()/100;})
SpillCut getYearAndMonth(unsigned int iYear, unsigned int iMonth)
virtual void Go() override
Load all the registered spectra.
std::vector< float > Spectrum
const Var kTrkStartX([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return-10.0f;return sr->trk.kalman.tracks[0].start.X()/100;})
std::vector< double > POT
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
const SpillVar kPOTe15([](const caf::SRSpillProxy *spill){return spill->spillpot/1e15;})
const SpillCut kStandardSpillCuts
Apply this unless you're doing something special.
void drawLongTerm(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={})
static constexpr Double_t year