14 const char* ootmodule,
18 if (ootsumm ==
nullptr) {
26 for (
unsigned int i = 0;
i <
runs.size(); ++
i) {
28 sprintf(runlabel,
"%d",
runs[
i]);
32 if (
res->ngoodbx !=
res->hratio->GetEntries())
33 std::cout <<
"Inconsistency in number of good bx" << std::endl;
42 std::cout <<
"File is not ok" << std::endl;
49 const char* ootmodule,
53 if (ootsumm ==
nullptr) {
61 for (
unsigned int i = 0;
i <
runs.size(); ++
i) {
63 sprintf(runlabel,
"%d",
runs[
i]);
67 if (
res->ngoodbx !=
res->hratio->GetEntries())
68 std::cout <<
"Inconsistency in number of good bx" << std::endl;
77 std::cout <<
"File is not ok" << std::endl;
85 const char* ootmodule,
89 const bool& perFill) {
100 sprintf(itpath,
"%s/fill_%d", itmodule,
run);
101 sprintf(ootpath,
"%s/fill_%d", ootmodule,
run);
102 sprintf(etpath,
"%s/fill_%d", etmodule,
run);
104 sprintf(itpath,
"%s/run_%d", itmodule,
run);
105 sprintf(ootpath,
"%s/run_%d", ootmodule,
run);
106 sprintf(etpath,
"%s/run_%d", etmodule,
run);
112 res->nfilledbx = filledbx.size();
116 if (filledbx.size() != filledbxtest.size())
117 std::cout <<
"Inconsistency in number of filled BX " <<
run <<
" " << filledbx.size() <<
" " 118 << filledbxtest.size() << std::endl;
121 TProfile* itmult =
nullptr;
122 TProfile* ootmult =
nullptr;
123 res->hratio =
new TH1F(
"ratio",
"ratio", 200, 0., 2.);
128 float errclrandom = 0;
133 if (
ff->cd(itpath)) {
134 itmult = (TProfile*)gDirectory->Get(hname);
136 std::cout <<
"In time path is not ok" << std::endl;
138 if (
ff->cd(ootpath)) {
139 ootmult = (TProfile*)gDirectory->Get(hname);
141 std::cout <<
"out of time path is not ok" << std::endl;
143 if (itmult && ootmult) {
144 ootmult->SetLineColor(kRed);
145 ootmult->SetMarkerColor(kRed);
148 for (std::vector<int>::const_iterator fbx = filledbx.begin(); fbx != filledbx.end(); ++fbx) {
149 nzb += itmult->GetBinEntries(*fbx);
150 nrandom += ootmult->GetBinEntries(*fbx + 1);
152 for (std::vector<int>::const_iterator fbx = filledbx.begin(); fbx != filledbx.end(); ++fbx) {
153 if (nzb > 0 && nrandom > 0) {
154 rclzb += (itmult->GetBinContent(*fbx) * itmult->GetBinEntries(*fbx)) / nzb;
155 errclzb += (itmult->GetBinError(*fbx) * itmult->GetBinEntries(*fbx)) *
156 (itmult->GetBinError(*fbx) * itmult->GetBinEntries(*fbx)) / (nzb * nzb);
157 rclrandom += (ootmult->GetBinContent(*fbx + 1) * ootmult->GetBinEntries(*fbx + 1)) / nrandom;
158 errclrandom += (ootmult->GetBinError(*fbx + 1) * ootmult->GetBinEntries(*fbx + 1)) *
159 (ootmult->GetBinError(*fbx + 1) * ootmult->GetBinEntries(*fbx + 1)) / (nrandom * nrandom);
161 if (itmult->GetBinContent(*fbx) == 0) {
162 std::cout <<
"No cluster in filled BX! " << *fbx << std::endl;
163 }
else if (ootmult->GetBinEntries(*fbx + 1) ==
166 float rat = ootmult->GetBinContent(*fbx + 1) / itmult->GetBinContent(*fbx);
167 res->hratio->Fill(rat);
171 std::cout <<
"histograms not found" << std::endl;
174 std::cout <<
"Input file pointer is not ok" << std::endl;
177 res->ngoodbx =
res->hratio->GetEntries();
179 if (nzb > 0 && nrandom > 0 && rclzb > 0 && rclrandom > 0) {
180 res->ootfracsum = rclrandom / rclzb;
181 res->ootfracsumerr = rclrandom / rclzb *
sqrt(errclzb / (rclzb * rclzb) + errclrandom / (rclrandom * rclrandom));
184 res->hratio->Fit(
"gaus",
"Q0",
"", .01, 1.99);
185 if (
res->hratio->GetFunction(
"gaus")) {
186 res->ootfrac =
res->hratio->GetFunction(
"gaus")->GetParameter(1);
187 res->ootfracerr =
res->hratio->GetFunction(
"gaus")->GetParError(1);
189 std::cout <<
"Missing fitting function" << std::endl;
192 std::cout <<
"No filled BX or strange filling scheme" << std::endl;
200 std::vector<int> filledbx;
203 bx = (TH1F*)gDirectory->Get(
"bx");
206 std::cout <<
"Number of entries " <<
bx->GetEntries() <<
" threshold " << thr / 3564. *
bx->GetEntries()
208 for (
int i = 1;
i <
bx->GetNbinsX() + 1; ++
i) {
209 if (
bx->GetBinContent(
i) > thr / 3564. *
bx->GetEntries()) {
210 if (!filledbx.empty() &&
i == filledbx[filledbx.size() - 1] + 1) {
211 std::cout <<
"This is not a 50ns run ! " << std::endl;
215 filledbx.push_back(
i);
219 std::cout <<
"Histogram not found" << std::endl;
222 std::cout <<
"module path is not ok" << std::endl;
225 std::cout <<
"Input file pointer is not ok" << std::endl;
233 TProfile*
bx =
nullptr;
234 std::vector<int> filledbx;
237 bx = (TProfile*)gDirectory->Get(hname);
240 std::cout <<
"Number of entries " <<
bx->GetEntries() <<
" threshold " << thr / 3564. *
bx->GetEntries()
242 for (
int i = 1;
i <
bx->GetNbinsX() + 1; ++
i) {
243 if (
bx->GetBinEntries(
i) > thr / 3564. *
bx->GetEntries()) {
244 if (!filledbx.empty() &&
i == filledbx[filledbx.size() - 1] + 1) {
245 std::cout <<
"This is not a 50ns run ! " << std::endl;
249 filledbx.push_back(
i);
253 std::cout <<
"Histogram not found" << std::endl;
256 std::cout <<
"module path is not ok" << std::endl;
259 std::cout <<
"Input file pointer is not ok" << std::endl;
OOTSummary * ComputeOOTFractionvsFill(TFile *ff, const char *itmodule, const char *ootmodule, const char *etmodule, const char *hname, OOTSummary *ootsumm)
OOTResult * ComputeOOTFraction(TFile *ff, const char *itmodule, const char *ootmodule, const char *etmodule, const int run, const char *hname, const bool &perFill)
std::vector< int > FillingSchemeFromProfile(TFile *ff, const char *path, const char *hname, const float thr)
const std::vector< unsigned int > getRunList() const
std::vector< int > FillingScheme(TFile *ff, const char *path, const float thr)
const std::vector< unsigned int > getFillList() const
OOTSummary * ComputeOOTFractionvsRun(TFile *ff, const char *itmodule, const char *ootmodule, const char *etmodule, const char *hname, OOTSummary *ootsumm)