15 #include "TGraphAsymmErrors.h"
21 float nspecialodd = 0;
22 float nspecialeven = 0;
23 unsigned int nbintotodd = 0;
24 unsigned int nbintoteven = 0;
25 unsigned int nbinspecialodd = 0;
26 unsigned int nbinspecialeven = 0;
28 for(
int i = 1;
i < hist->GetNbinsX()+1; ++
i) {
30 bool isSpecial =
false;
31 for(
unsigned int special = 0; special < bins.size() ; ++special) {
32 if(
i==bins[special]) {
41 nspecialeven += hist->GetBinContent(
i);
45 ntoteven += hist->GetBinContent(
i);
51 nspecialodd += hist->GetBinContent(
i);
55 ntotodd += hist->GetBinContent(
i);
60 std::cout <<
"Odd events " << ntotodd <<
" special " << nspecialodd << std::endl;
61 std::cout <<
"Odd bins " << nbintotodd <<
" special " << nbinspecialodd << std::endl;
62 std::cout <<
"Odd bins populations" << float(ntotodd)/nbintotodd <<
" special " << float(nspecialodd)/nbinspecialodd << std::endl;
63 std::cout <<
"Even events " << ntoteven <<
" special " << nspecialeven << std::endl;
64 std::cout <<
"Even bins " << nbintoteven <<
" special " << nbinspecialeven << std::endl;
65 std::cout <<
"Even bins populations" << float(ntoteven)/nbintoteven <<
" special " << float(nspecialeven)/nbinspecialeven << std::endl;
67 float oddloss = nspecialodd -nbinspecialodd*ntotodd/nbintotodd;
68 float evenloss = nspecialeven -nbinspecialeven*ntoteven/nbintoteven;
70 float fracloss = (oddloss+evenloss)/(ntotodd + ntoteven + nspecialodd + nspecialeven);
72 std::cout <<
"Loss " << oddloss <<
" " << evenloss <<
" " << fracloss << std::endl;
83 std::sort(runs.begin(),runs.end());
86 for(
unsigned int i=0;
i<runs.size();++
i) {
89 sprintf(runlabel,
"%d",runs[
i]);
91 sprintf(runpath,
"run_%d",runs[i]);
98 result =
new TH1F(*hist);
102 std::cout << hist->GetTitle() <<
" added: " << hist->GetEntries() <<
" " << result->GetEntries() << std::endl;
112 TH1F*
TimeRatio(TFile&
ff,
const char* modulen,
const char* moduled,
const int irun,
const int rebin) {
119 sprintf(runlabel,
"%d",irun);
121 sprintf(runpath,
"run_%d",irun);
128 if(orbitn==0) orbitn = (TH1F*)castatn.
getObject(
"orbit");
130 if(orbitd==0) orbitd = (TH1F*)castatd.
getObject(
"orbit");
131 if(orbitn != 0 && orbitd != 0) {
132 orbitn->Rebin(rebin);
133 orbitd->Rebin(rebin);
134 ratio =
new TH1F(*orbitd);
136 ratio->Divide(orbitn,orbitd);
146 TH1D*
nevents =
new TH1D(
"nevents",
"Number of events vs run",10,0.,10.);
147 nevents->SetCanExtend(TH1::kXaxis);
150 std::sort(runs.begin(),runs.end());
153 for(
unsigned int i=0;
i<runs.size();++
i) {
156 sprintf(runlabel,
"%d",runs[
i]);
158 sprintf(runpath,
"run_%d",runs[i]);
163 if(orbit==0) orbit = (TH1F*)castat.
getObject(
"orbit");
166 nevents->Fill(runlabel,orbit->GetEntries());
179 TH1D* ratio = (TH1D*)denom->Clone(hname);
180 ratio->SetTitle(
"Fraction of events vs run");
183 ratio->SetDirectory(0);
184 ratio->Divide(numer,denom,1,1,
"b");
195 TGraphAsymmErrors* ratio =
new TGraphAsymmErrors;;
197 ratio->BayesDivide(numer,denom);
210 std::sort(runs.begin(),runs.end());
213 for(
unsigned int i=0;
i<runs.size();++
i) {
216 sprintf(runlabel,
"%d",runs[
i]);
218 sprintf(runpath,
"run_%d",runs[i]);
225 result =
new TH2F(*hist);
229 std::cout << hist->GetTitle() <<
" added: " << hist->GetEntries() <<
" " << result->GetEntries() << std::endl;
242 const char* outtrunk) {
245 sprintf(modfull,
"%s%s",module,postfix);
247 sprintf(labfull,
"%s%s",label,postfix);
250 sprintf(dirname,
"%s",shortname);
279 TH1D*
nevents =
new TH1D(
"nevents",
"Number of events vs run",10,0.,10.);
280 nevents->SetCanExtend(TH1::kXaxis);
284 std::sort(runs.begin(),runs.end());
288 std::cout <<
"Collision Events" << std::endl;
290 for(
unsigned int i=0;
i<runs.size();++
i) {
293 sprintf(runlabel,
"%d",runs[
i]);
295 sprintf(runpath,
"run_%d",runs[i]);
299 TH2F* orbitvsbx = (TH2F*)castat.
getObject(
"orbitvsbxincycle");
300 if(orbitvsbx==0) orbitvsbx = (TH2F*)castat.
getObject(
"orbitvsbx");
302 std::cout << runpath <<
" " << orbitvsbx->GetEntries() << std::endl;
305 if(orbitvsbx->GetEntries()>0) {
306 orbit = orbitvsbx->ProjectionY();
310 if(orbit==0) orbit = (TH1F*)castat.
getObject(
"orbit");
312 orbit->GetXaxis()->SetTitle(
"orbit");
313 orbit->SetTitle(runpath);
315 orbit->Scale(11223,
"width");
316 orbit->GetYaxis()->SetTitle(
"Rate (Hz)");
318 nevents->Fill(runlabel,orbit->GetEntries());
323 plotfilename += outtrunk;
325 plotfilename +=
"/orbit_";
326 plotfilename += labfull;
330 plotfilename += runpath;
331 plotfilename +=
".gif";
332 gPad->Print(plotfilename.c_str());
336 TH1F* dbx = (TH1F*)castat.
getObject(
"dbx");
339 if(dbx->GetEntries()>0) {
343 plotfilename += outtrunk;
345 plotfilename +=
"/dbx_";
346 plotfilename += labfull;
350 plotfilename += runpath;
351 plotfilename +=
".gif";
352 gPad->Print(plotfilename.c_str());
357 TH1F* bx = (TH1F*)castat.
getObject(
"bx");
360 if(bx->GetEntries()>0) {
361 bx->SetLineColor(kRed);
365 plotfilename += outtrunk;
367 plotfilename +=
"/bx_";
368 plotfilename += labfull;
372 plotfilename += runpath;
373 plotfilename +=
".gif";
374 gPad->Print(plotfilename.c_str());
384 plotfilename = outtrunk;
386 plotfilename +=
"/nevents_";
387 plotfilename += labfull;
390 plotfilename +=
".gif";
392 TCanvas * cwide =
new TCanvas(plotfilename.c_str(),plotfilename.c_str(),1500,500);
396 sprintf(nentries,
"%.0f",nevents->GetSumOfWeights());
398 ttlabel.DrawTextNDC(.8,.7,nentries);
402 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 *)
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)