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;
81 for (
unsigned int i = 0;
i <
runs.size(); ++
i) {
83 sprintf(runlabel,
"%d",
runs[
i]);
85 sprintf(runpath,
"run_%d",
runs[
i]);
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);
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());
167 ratio->SetTitle(
"Fraction of events vs run");
170 ratio->SetDirectory(
nullptr);
177 TFile&
f1,
const char* mod1, TFile&
f2,
const char* mod2,
const char* ) {
181 TGraphAsymmErrors*
ratio =
new TGraphAsymmErrors;
198 for (
unsigned int i = 0;
i <
runs.size(); ++
i) {
200 sprintf(runlabel,
"%d",
runs[
i]);
202 sprintf(runpath,
"run_%d",
runs[
i]);
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);
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());