19 #include "TGraphAsymmErrors.h" 37 gStyle->SetStatFormat(
"6.3g");
38 gStyle->SetPaintTextFormat(
"6.3g");
39 gStyle->SetFitFormat(
"6.3g");
42 TFile *f_Out =
new TFile((TString)(outDir+
"BeamMonitoring_"+s_PeriodLength+
"_ShortTerm.root"),
"RECREATE");
45 unsigned int startTime = endTime - 86400*nDays;
46 const std::string fFiles =
"dataset_def_name_newest_snapshot " + samDef + Form(
" and online.subrunendtime >= '%u' and online.subrunendtime <= '%u'", startTime, endTime);
50 const Binning kTimeBinning =
Binning::Simple(nDays < 3 ? 24*nDays : nDays+1, startTime, startTime + 86400*(nDays+1));
55 {
"Central Time",
"Spill POT (#times10^{12})",
"spillPOT",
Binning::Simple(100,0,100),
kSpillPOT,
kNoCut, 1.0, 1. },
56 {
"Central Time",
"Reconstructed Neutrino Energy, (GeV)",
"ccE",
Binning::Simple(20,0,5),
kCCE, kNumuNDCut, 1.5, 2.2 },
57 {
"Central Time",
"Reconstructed Hadronic Energy, (GeV)",
"hadE",
Binning::Simple(30,0,3),
kHadE, kNumuNDCut, 0.15, 0.50},
58 {
"Central Time",
"Reconstructed Muon Energy, (GeV)",
"muonE",
Binning::Simple(45,0,4.5),
kMuE, kNumuNDCut, 1.0, 2.0 },
59 {
"Central Time",
"Hadronic Energy Fraction",
"hadEfrac",
Binning::Simple(20,0,1.0),
kHadEFrac, kNumuNDCut, 0.05, 0.3 },
60 {
"Central Time",
"No. of Hits",
"nhit",
Binning::Simple(25,0,250),
kNHit, kNumuNDCut, 90, 110 },
61 {
"Central Time",
"Vertex X, (m)",
"startX",
Binning::Simple(40,-2,2),
kTrkStartX, kNumuNDCut, -0.40, 0.0 },
62 {
"Central Time",
"Vertex Y, (m)",
"startY",
Binning::Simple(40,-2,2),
kTrkStartY, kNumuNDCut, -0.25, 0.15},
63 {
"Central Time",
"Vertex Z, (m)",
"startZ",
Binning::Simple(24,0,12),
kTrkStartZ, kNumuNDCut, 4.8, 6.25}
66 std::vector<Spectrum*> vec_Spectrum;
67 std::vector<TCanvas*> vec_Canvas;
69 for(
unsigned int i = 0;
i < vec_Plots.size();
i++)
71 Spectrum *h_Spectrum =
new Spectrum(vec_Plots.at(
i).fLabelX, vec_Plots.at(
i).fLabelY,
loader, kTimeBinning,
kTime, vec_Plots.at(
i).fBins, vec_Plots.at(
i).fVar, vec_Plots.at(
i).fCut);
72 vec_Spectrum.push_back(h_Spectrum);
73 TCanvas *c_Spectrum =
new TCanvas((TString)(
"c_"+vec_Plots.at(
i).fName+
"_"+s_PeriodLength),(TString)(
"c_"+vec_Plots.at(
i).fName+
"_"+s_PeriodLength));
74 c_Spectrum->SetBottomMargin(0.15);
75 c_Spectrum->SetLeftMargin (0.15);
76 c_Spectrum->SetRightMargin (0.15);
77 vec_Canvas.push_back(c_Spectrum);
82 for(
unsigned int i = 0;
i < vec_Plots.size();
i++)
84 vec_Canvas.at(
i)->cd();
85 TH2 *h_2D = vec_Spectrum.at(
i)->ToTH2(vec_Spectrum.at(
i)->POT());
86 h_2D->SetName((TString)(
"h_2D_"+vec_Plots.at(
i).fName+s_PeriodLength));
88 h_2D->GetXaxis()->CenterTitle();
89 h_2D->GetYaxis()->CenterTitle();
90 h_2D->GetXaxis()->SetTimeDisplay(1);
91 if (nDays >= 15) {h_2D->GetXaxis()->SetTimeFormat(
"%y-%m-%d%F1970-01-01 00:00:00"); }
92 else if(nDays > 3 && nDays < 15){h_2D->GetXaxis()->SetTimeFormat(
"%y-%m-%d-%H:%M%F1970-01-01 00:00:00");}
93 else {h_2D->GetXaxis()->SetTimeFormat(
"%H:%M%F1970-01-01 00:00:00"); }
95 unsigned int minBin = h_2D->GetXaxis()->FindBin(startTime);
96 unsigned int maxBin = h_2D->GetXaxis()->FindBin(endTime);
98 double minZoom = h_2D->GetXaxis()->GetBinLowEdge(minBin-1);
99 double maxZoom = h_2D->GetXaxis()->GetBinLowEdge(maxBin+2);
101 h_2D->GetXaxis()->SetRangeUser(minZoom, maxZoom);
103 TProfile *h_Prof1 = h_2D->ProfileX((TString)(
"h_Prof1_"+vec_Plots.at(
i).fName+
"_"+s_PeriodLength));
104 TProfile *h_Prof2 = h_2D->ProfileX((TString)(
"h_Prof2_"+vec_Plots.at(
i).fName+
"_"+s_PeriodLength));
105 h_Prof1->SetMarkerStyle(24);
106 h_Prof1->SetMarkerColor(kBlack);
107 h_Prof1->SetLineColor (kBlack);
108 h_Prof1->SetMarkerSize(1.4);
109 h_Prof2->SetMarkerStyle(20);
110 h_Prof2->SetMarkerColor(kYellow);
111 h_Prof2->SetLineColor (kYellow);
112 h_Prof2->SetMarkerSize(1.4);
115 h_Prof2->Draw(
"SAME");
116 h_Prof1->Draw(
"SAME");
118 TLatex *txt_Exposure =
new TLatex(0.2, 0.8, Form(
"%6.3g POT", vec_Spectrum.at(
i)->POT()));
119 txt_Exposure->SetNDC();
120 txt_Exposure->SetTextSize(0.04);
121 txt_Exposure->Draw();
124 vec_Canvas.at(
i)->SaveAs((TString)(outDir+vec_Plots.at(
i).fName+
"_"+s_PeriodLength+
"_ShortTerm.png"));
126 vec_Canvas.at(
i)->Write();
127 vec_Canvas.at(
i)->Clear();
128 vec_Canvas.at(
i)->SetName((TString)(
"c_1D_"+vec_Plots.at(
i).fName+
"_"+s_PeriodLength));
130 TH1D *h_1D = h_2D->ProjectionY((TString)(
"h_1D_"+vec_Plots.at(
i).fName+s_PeriodLength));
132 vec_Canvas.at(
i)->Write();
Represent the binning of a Spectrum's x-axis.
Cuts and Vars for the 2020 FD DiF Study.
std::vector< Plot > vec_Plots
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;})
void SetSpillCut(const SpillCut &cut)
Representation of a spectrum in any variable, with associated POT.
void drawShortTerm_2019(std::string samDef, unsigned int endTime, unsigned int nDays, std::string s_PeriodLength, std::string outDir)
void lastUpdated(unsigned int timestamp)
const Var kSpillPOT
Return the POT for the spill.
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;})
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;})
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
const SpillCut kStandardSpillCuts
Apply this unless you're doing something special.
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
const Cut kNoCut
The simplest possible cut: pass everything, used as a default.