15 #include "TGraphAsymmErrors.h"
20 float nspecialodd = 0;
21 float nspecialeven = 0;
22 unsigned int nbintotodd = 0;
23 unsigned int nbintoteven = 0;
24 unsigned int nbinspecialodd = 0;
25 unsigned int nbinspecialeven = 0;
27 for (
int i = 1;
i < hist->GetNbinsX() + 1; ++
i) {
29 for (
unsigned int special = 0; special < bins.size(); ++special) {
30 if (
i == bins[special]) {
39 nspecialeven += hist->GetBinContent(
i);
42 ntoteven += hist->GetBinContent(
i);
47 nspecialodd += hist->GetBinContent(
i);
50 ntotodd += hist->GetBinContent(
i);
55 std::cout <<
"Odd events " << ntotodd <<
" special " << nspecialodd << std::endl;
56 std::cout <<
"Odd bins " << nbintotodd <<
" special " << nbinspecialodd << std::endl;
57 std::cout <<
"Odd bins populations" << float(ntotodd) / nbintotodd <<
" special "
58 << float(nspecialodd) / nbinspecialodd << std::endl;
59 std::cout <<
"Even events " << ntoteven <<
" special " << nspecialeven << std::endl;
60 std::cout <<
"Even bins " << nbintoteven <<
" special " << nbinspecialeven << std::endl;
61 std::cout <<
"Even bins populations" << float(ntoteven) / nbintoteven <<
" special "
62 << float(nspecialeven) / nbinspecialeven << std::endl;
64 float oddloss = nspecialodd - nbinspecialodd * ntotodd / nbintotodd;
65 float evenloss = nspecialeven - nbinspecialeven * ntoteven / nbintoteven;
67 float fracloss = (oddloss + evenloss) / (ntotodd + ntoteven + nspecialodd + nspecialeven);
69 std::cout <<
"Loss " << oddloss <<
" " << evenloss <<
" " << fracloss << std::endl;
78 std::sort(runs.begin(), runs.end());
81 for (
unsigned int i = 0;
i < runs.size(); ++
i) {
83 sprintf(runlabel,
"%d", runs[
i]);
85 sprintf(runpath,
"run_%d", runs[i]);
91 if (result ==
nullptr) {
92 result =
new TH1F(*hist);
96 std::cout << hist->GetTitle() <<
" added: " << hist->GetEntries() <<
" " << result->GetEntries() << std::endl;
104 TH1F*
TimeRatio(TFile&
ff,
const char* modulen,
const char* moduled,
const int irun,
const int rebin) {
109 sprintf(runlabel,
"%d", irun);
111 sprintf(runpath,
"run_%d", irun);
115 TH1F* ratio =
nullptr;
117 TH1F* orbitn =
nullptr;
118 if (orbitn ==
nullptr)
119 orbitn = (TH1F*)castatn.
getObject(
"orbit");
120 TH1F* orbitd =
nullptr;
121 if (orbitd ==
nullptr)
122 orbitd = (TH1F*)castatd.
getObject(
"orbit");
123 if (orbitn !=
nullptr && orbitd !=
nullptr) {
124 orbitn->Rebin(rebin);
125 orbitd->Rebin(rebin);
126 ratio =
new TH1F(*orbitd);
128 ratio->Divide(orbitn, orbitd);
136 TH1D*
nevents =
new TH1D(
"nevents",
"Number of events vs run", 10, 0., 10.);
137 nevents->SetCanExtend(TH1::kXaxis);
140 std::sort(runs.begin(), runs.end());
143 for (
unsigned int i = 0;
i < runs.size(); ++
i) {
145 sprintf(runlabel,
"%d", runs[
i]);
147 sprintf(runpath,
"run_%d", runs[i]);
150 TH1F* orbit =
nullptr;
151 if (orbit ==
nullptr)
152 orbit = (TH1F*)castat.
getObject(
"orbit");
155 nevents->Fill(runlabel, orbit->GetEntries());
166 TH1D* ratio = (TH1D*)denom->Clone(hname);
167 ratio->SetTitle(
"Fraction of events vs run");
170 ratio->SetDirectory(
nullptr);
171 ratio->Divide(numer, denom, 1, 1,
"b");
177 TFile&
f1,
const char* mod1, TFile&
f2,
const char* mod2,
const char* ) {
181 TGraphAsymmErrors* ratio =
new TGraphAsymmErrors;
184 ratio->BayesDivide(numer, denom);
195 std::sort(runs.begin(), runs.end());
198 for (
unsigned int i = 0;
i < runs.size(); ++
i) {
200 sprintf(runlabel,
"%d", runs[
i]);
202 sprintf(runpath,
"run_%d", runs[i]);
208 if (result ==
nullptr) {
209 result =
new TH2F(*hist);
213 std::cout << hist->GetTitle() <<
" added: " << hist->GetEntries() <<
" " << result->GetEntries() << std::endl;
225 const char* shortname,
226 const char* outtrunk) {
228 sprintf(modfull,
"%s%s", module, postfix);
230 sprintf(labfull,
"%s%s", label, postfix);
233 sprintf(dirname,
"%s", shortname);
262 TH1D*
nevents =
new TH1D(
"nevents",
"Number of events vs run", 10, 0., 10.);
263 nevents->SetCanExtend(TH1::kXaxis);
266 std::sort(runs.begin(), runs.end());
269 std::cout <<
"Collision Events" << std::endl;
271 for (
unsigned int i = 0;
i < runs.size(); ++
i) {
273 sprintf(runlabel,
"%d", runs[
i]);
275 sprintf(runpath,
"run_%d", runs[i]);
278 TH1* orbit =
nullptr;
279 TH2F* orbitvsbx = (TH2F*)castat.
getObject(
"orbitvsbxincycle");
280 if (orbitvsbx ==
nullptr)
281 orbitvsbx = (TH2F*)castat.
getObject(
"orbitvsbx");
283 std::cout << runpath <<
" " << orbitvsbx->GetEntries() << std::endl;
286 if (orbitvsbx->GetEntries() > 0) {
287 orbit = orbitvsbx->ProjectionY();
291 if (orbit ==
nullptr)
292 orbit = (TH1F*)castat.
getObject(
"orbit");
294 orbit->GetXaxis()->SetTitle(
"orbit");
295 orbit->SetTitle(runpath);
297 orbit->Scale(11223,
"width");
298 orbit->GetYaxis()->SetTitle(
"Rate (Hz)");
300 nevents->Fill(runlabel, orbit->GetEntries());
305 plotfilename += outtrunk;
307 plotfilename +=
"/orbit_";
308 plotfilename += labfull;
312 plotfilename += runpath;
313 plotfilename +=
".gif";
314 gPad->Print(plotfilename.c_str());
318 TH1F* dbx = (TH1F*)castat.
getObject(
"dbx");
321 if (dbx->GetEntries() > 0) {
325 plotfilename += outtrunk;
327 plotfilename +=
"/dbx_";
328 plotfilename += labfull;
332 plotfilename += runpath;
333 plotfilename +=
".gif";
334 gPad->Print(plotfilename.c_str());
342 if (bx->GetEntries() > 0) {
343 bx->SetLineColor(kRed);
347 plotfilename += outtrunk;
349 plotfilename +=
"/bx_";
350 plotfilename += labfull;
354 plotfilename += runpath;
355 plotfilename +=
".gif";
356 gPad->Print(plotfilename.c_str());
366 plotfilename = outtrunk;
368 plotfilename +=
"/nevents_";
369 plotfilename += labfull;
372 plotfilename +=
".gif";
374 TCanvas* cwide =
new TCanvas(plotfilename.c_str(), plotfilename.c_str(), 1500, 500);
378 sprintf(nentries,
"%.0f", nevents->GetSumOfWeights());
380 ttlabel.DrawTextNDC(.8, .7, nentries);
384 gPad->Print(plotfilename.c_str());
TH1D * SummaryHisto(TFile &ff, const char *module)
TH1F * CombinedHisto(TFile &ff, const char *module, const char *histname)
TObject * getObject(const char *name) const
void StatisticsPlots(const char *fullname, const char *module, const char *label, const char *postfix, const char *shortname, const char *outtrunk)
TH1D * SummaryHistoRatio(TFile &f1, const char *mod1, TFile &f2, const char *mod2, const char *hname)
TGraphAsymmErrors * SummaryHistoRatioGraph(TFile &f1, const char *mod1, TFile &f2, const char *mod2, const char *)
constexpr bool isSpecial(const float t)
TH1F * TimeRatio(TFile &ff, const char *modulen, const char *moduled, const int irun, const int rebin)
void setPath(const char *path)
void DeadTimeAPVCycle(TH1F *hist, const std::vector< int > &bins)
const std::vector< unsigned int > getRunList() const
TH2F * Combined2DHisto(TFile &ff, const char *module, const char *histname)