40 "BIS",
"BIL",
"BMS",
"BML",
"BOS",
"BOL",
"BEE",
41 "EIS",
"EIL",
"EMS",
"EML",
"EOS",
"EOL",
"EES",
53 double invsq2pi = 0.3989422804014;
72 for (
i = 1.0;
i <=
np / 2;
i++) {
73 xx = xlow + (
i - .5) *
step;
74 fland = TMath::BreitWigner(xx,
par[1],
par[0]);
75 sum += fland * TMath::Gaus(
x[0], xx,
par[3]);
77 xx = xupp - (
i - .5) *
step;
78 fland = TMath::BreitWigner(xx,
par[1],
par[0]);
79 sum += fland * TMath::Gaus(
x[0], xx,
par[3]);
84 void TwoDto2D_Eff(TH2* Numerator, TH2* Denominator, TH2* Efficiency,
bool rebin2d =
false) {
86 if (Numerator == NULL || Denominator == NULL || Efficiency == NULL) {
91 Efficiency->Rebin2D();
94 int n_xbins = Numerator->GetNbinsX();
95 if (Denominator->GetNbinsX() != n_xbins || Efficiency->GetNbinsX() != n_xbins) {
98 int n_ybins = Numerator->GetNbinsY();
99 if (Denominator->GetNbinsY() != n_ybins || Efficiency->GetNbinsY() != n_ybins) {
104 for (
int bin_itrX = 1; bin_itrX < Efficiency->GetNbinsX() + 1; bin_itrX++) {
105 for (
int bin_itrY = 1; bin_itrY < Efficiency->GetNbinsY() + 1; bin_itrY++) {
106 if (Denominator->GetBinContent(bin_itrX, bin_itrY) == 0)
continue;
107 Efficiency->SetBinContent(bin_itrX, bin_itrY,
108 Numerator->GetBinContent(bin_itrX,
109 bin_itrY) / Denominator->GetBinContent(bin_itrX, bin_itrY));
112 Efficiency->Write(
"", TObject::kOverwrite);
118 if (h_parent == NULL || h_child == NULL) {
121 if (h_parent->GetNbinsX() != h_child->GetNbinsX()) {
125 for (
int bin_itrX = 1; bin_itrX < h_parent->GetNbinsX() + 1; bin_itrX++) {
126 double parent_event = 0;
127 double parent_sum = 0;
128 for (
int bin_itrY = 1; bin_itrY < h_parent->GetNbinsY() + 1; bin_itrY++) {
129 parent_event += h_parent->GetBinContent(bin_itrX, bin_itrY);
130 parent_sum += h_parent->GetBinContent(bin_itrX, bin_itrY) * h_parent->GetYaxis()->GetBinCenter(bin_itrY);
132 if (parent_event == 0) {
135 h_child->SetBinContent(bin_itrX, parent_sum / parent_event);
137 TString sHistTitle = h_child->GetTitle();
138 h_child->Rebin(rebinning);
139 h_child->SetTitle(sHistTitle +
" per event");
140 h_child->Write(
"", TObject::kOverwrite);
146 if (h_parent == NULL || h_child == NULL) {
149 if (h_parent->GetNbinsX() != h_child->GetNbinsX()) {
153 for (
int bin_itrX = 1; bin_itrX < h_parent->GetNbinsX() + 1; bin_itrX++) {
154 double parent_sum = 0;
155 for (
int bin_itrY = 1; bin_itrY < h_parent->GetNbinsY() + 1; bin_itrY++) {
156 parent_sum += h_parent->GetBinContent(bin_itrX, bin_itrY) * h_parent->GetYaxis()->GetBinCenter(bin_itrY);
158 if (parent_sum == 0) {
161 h_child->SetBinContent(bin_itrX, parent_sum);
163 h_child->Rebin(rebinning);
164 h_child->Write(
"", TObject::kOverwrite);
169 if (
InputHist == NULL || OutMean == NULL || OutSigma == NULL) {
173 if (recalg_path ==
"Z") {
175 fit1->SetLineColor(kRed);
176 fit1->SetParameter(0, 3.0);
177 fit1->SetParameter(1, 91.2);
178 fit1->SetParameter(2,
InputHist->GetEntries());
179 fit1->SetParameter(3, 1.0);
180 InputHist->Fit(
"fit1",
"q",
"", 77, 105);
182 OutMean->SetBinContent(iBin, fit1->GetParameter(1));
183 OutMean->SetBinError(iBin, fit1->GetParError(1));
184 OutSigma->SetBinContent(iBin, fit1->GetParameter(0));
185 OutSigma->SetBinError(iBin, fit1->GetParError(0));
187 if (recalg_path ==
"Jpsi") {
188 InputHist->Fit(
"gaus",
"q",
"", 2.95, 3.25);
189 TF1* fit1 = (TF1*)
InputHist->GetFunction(
"gaus");
191 OutMean->SetBinContent(iBin, fit1->GetParameter(1));
192 OutMean->SetBinError(iBin, fit1->GetParError(1));
193 OutSigma->SetBinContent(iBin, fit1->GetParameter(2));
194 OutSigma->SetBinError(iBin, fit1->GetParError(2));
197 OutMean->SetBinContent(iBin,
InputHist->GetMean(1));
198 OutMean->SetBinError(iBin,
InputHist->GetMeanError(1));
199 OutSigma->SetBinContent(iBin,
InputHist->GetRMS(1));
200 OutSigma->SetBinError(iBin,
InputHist->GetRMSError(1));
220 plotdirname.ReplaceAll(
"/",
"_");
222 TFile*
f = TFile::Open(inFilename.c_str(),
"UPDATE");
225 std::cerr <<
"MuonTrackMonitoring(): " <<
"Input file not opened \n";
228 if (
f->GetSize() < 1000.) {
229 std::cerr <<
"MuonTrackMonitoring(): " <<
"Input file empty \n";
235 TKey* key0 = (TKey*) nextcd0();
236 if (key0 == 0)
return;
238 TDirectory* dir0 =
dynamic_cast<TDirectory*
> (key0->ReadObj());
239 if (dir0 == 0)
return;
247 TString mDir = motherDir +
"Segments/";
248 if (!
f->cd(mDir))
return;
251 while (TKey*
key1 =
dynamic_cast<TKey*
>(nextcd1())) {
253 TString recalg_path =
key1->GetName();
254 TString recalg_fullStr = mDir +
key1->GetName();
255 TDirectory* dir1 =
f->GetDirectory(recalg_fullStr);
260 TH2F* h_EffNumerator =
261 (
TH2F*) dir1->Get(Form(
"%sSegments_%s_eff_chamberIndex_perSector_numerator", plotdirname.Data(),
262 recalg_path.Data()));
263 TH2F* h_EffDenominator =
264 (
TH2F*) dir1->Get(Form(
"%sSegments_%s_eff_chamberIndex_perSector_denominator", plotdirname.Data(),
265 recalg_path.Data()));
267 (
TH2F*) dir1->Get(Form(
"%sSegments_%s_eff_chamberIndex_perSector", plotdirname.Data(), recalg_path.Data()));
269 TwoDto2D_Eff(h_EffNumerator, h_EffDenominator, h_Efficiency);
272 for (
int i = 0;
i < 17;
i++) {
273 TH2F* seg_prec_EffNumerator =
274 (
TH2F*) dir1->Get(Form(
"%sSegments_%s_%s_etastation_nPrechit", plotdirname.Data(), recalg_path.Data(),
276 TH2F* seg_prec_EffDenominator =
277 (
TH2F*) dir1->Get(Form(
"%sSegments_%s_eff_%s_etastation_nPrechit", plotdirname.Data(), recalg_path.Data(),
279 TH2F* seg_prec_Efficiency =
280 (
TH2F*) dir1->Get(Form(
"%sSegments_%s_eff_%s_etastation_nPrechit", plotdirname.Data(), recalg_path.Data(),
283 TwoDto2D_Eff(seg_prec_EffNumerator, seg_prec_EffDenominator, seg_prec_Efficiency);
285 TH2F* seg_trig_EffNumerator =
286 (
TH2F*) dir1->Get(Form(
"%sSegments_%s_%s_etastation_nTrighit", plotdirname.Data(), recalg_path.Data(),
288 TH2F* seg_trig_EffDenominator =
289 (
TH2F*) dir1->Get(Form(
"%sSegments_%s_eff_%s_etastation_nTrighit", plotdirname.Data(), recalg_path.Data(),
291 TH2F* seg_trig_Efficiency =
292 (
TH2F*) dir1->Get(Form(
"%sSegments_%s_eff_%s_etastation_nTrighit", plotdirname.Data(), recalg_path.Data(),
295 TwoDto2D_Eff(seg_trig_EffNumerator, seg_trig_EffDenominator, seg_trig_Efficiency);
300 TString mDir_muons = motherDir +
"Muons/";
301 if (!
f->cd(mDir_muons))
return;
303 TIter nextcd_muons(
gDirectory->GetListOfKeys());
304 while (TKey*
key1 =
dynamic_cast<TKey*
>(nextcd_muons())) {
306 TString recalg_path =
key1->GetName();
307 TString recalg_fullStr = mDir_muons +
key1->GetName();
308 TDirectory* dir1 =
f->GetDirectory(recalg_fullStr);
312 TString muonqualstr[4] = {
313 "Tight",
"Medium",
"Loose",
"Veryloose"
316 TH2F* h_EffDenominator =
317 (
TH2F*) dir1->Get(Form(
"%sMuons_%s_Origin_eta_phi", plotdirname.Data(), recalg_path.Data()));
319 for (
int i = 0;
i < 4;
i++) {
320 TH2F* h_EffNumerator =
321 (
TH2F*) dir1->Get(Form(
"%sMuons_%s_%s_eta_phi", plotdirname.Data(), recalg_path.Data(),
322 muonqualstr[
i].Data()));
324 (
TH2F*) dir1->Get(Form(
"%sMuons_%s_%s_eff", plotdirname.Data(), recalg_path.Data(), muonqualstr[
i].Data()));
325 TwoDto2D_Eff(h_EffNumerator, h_EffDenominator, h_Efficiency);
328 TH2F* eff_nPrec = (
TH2F*) dir1->Get(Form(
"%sMuons_%s_eff_nPrec", plotdirname.Data(), recalg_path.Data()));
329 TH2F* eff_nPhi = (
TH2F*) dir1->Get(Form(
"%sMuons_%s_eff_nPhi", plotdirname.Data(), recalg_path.Data()));
330 TH2F* eff_nTrigEta = (
TH2F*) dir1->Get(Form(
"%sMuons_%s_eff_nTrigEta", plotdirname.Data(), recalg_path.Data()));
331 TH2F* eff_ndof = (
TH2F*) dir1->Get(Form(
"%sMuons_%s_eff_ndof", plotdirname.Data(), recalg_path.Data()));
332 TH2F* eff_chi2 = (
TH2F*) dir1->Get(Form(
"%sMuons_%s_eff_chi2", plotdirname.Data(), recalg_path.Data()));
333 TH2F* ID_eff_ndof = (
TH2F*) dir1->Get(Form(
"%sMuons_%s_ID_eff_ndof", plotdirname.Data(), recalg_path.Data()));
334 TH2F* ID_eff_chi2 = (
TH2F*) dir1->Get(Form(
"%sMuons_%s_ID_eff_chi2", plotdirname.Data(), recalg_path.Data()));
335 TH2F* MS_eff_ndof = (
TH2F*) dir1->Get(Form(
"%sMuons_%s_MS_eff_ndof", plotdirname.Data(), recalg_path.Data()));
336 TH2F* MS_eff_chi2 = (
TH2F*) dir1->Get(Form(
"%sMuons_%s_MS_eff_chi2", plotdirname.Data(), recalg_path.Data()));
338 TH2F* avg_hits_precision_inner =
339 (
TH2F*) dir1->Get(Form(
"%sMuons_%s_avg_hits_precision_inner", plotdirname.Data(), recalg_path.Data()));
340 TH2F* avg_hits_precision_middle =
341 (
TH2F*) dir1->Get(Form(
"%sMuons_%s_avg_hits_precision_middle", plotdirname.Data(), recalg_path.Data()));
342 TH2F* avg_hits_precision_outer =
343 (
TH2F*) dir1->Get(Form(
"%sMuons_%s_avg_hits_precision_outer", plotdirname.Data(), recalg_path.Data()));
344 TH2F* avg_hits_precision_extended =
345 (
TH2F*) dir1->Get(Form(
"%sMuons_%s_avg_hits_precision_extended", plotdirname.Data(), recalg_path.Data()));
347 TH2F* avg_hits_trigger_layer1 =
348 (
TH2F*) dir1->Get(Form(
"%sMuons_%s_avg_hits_trigger_layer1", plotdirname.Data(), recalg_path.Data()));
349 TH2F* avg_hits_trigger_layer2 =
350 (
TH2F*) dir1->Get(Form(
"%sMuons_%s_avg_hits_trigger_layer2", plotdirname.Data(), recalg_path.Data()));
351 TH2F* avg_hits_trigger_layer3 =
352 (
TH2F*) dir1->Get(Form(
"%sMuons_%s_avg_hits_trigger_layer3", plotdirname.Data(), recalg_path.Data()));
353 TH2F* avg_hits_trigger_layer4 =
354 (
TH2F*) dir1->Get(Form(
"%sMuons_%s_avg_hits_trigger_layer4", plotdirname.Data(), recalg_path.Data()));
356 TH2F* avg_hits_ibl = (
TH2F*) dir1->Get(Form(
"%sMuons_%s_avg_hits_ibl", plotdirname.Data(), recalg_path.Data()));
357 TH2F* avg_hits_pix = (
TH2F*) dir1->Get(Form(
"%sMuons_%s_avg_hits_pix", plotdirname.Data(), recalg_path.Data()));
358 TH2F* avg_hits_sct = (
TH2F*) dir1->Get(Form(
"%sMuons_%s_avg_hits_sct", plotdirname.Data(), recalg_path.Data()));
359 TH2F* avg_hits_trt = (
TH2F*) dir1->Get(Form(
"%sMuons_%s_avg_hits_trt", plotdirname.Data(), recalg_path.Data()));
361 TH2F* avg_ddpt_idme = (
TH2F*) dir1->Get(Form(
"%sMuons_%s_avg_ddpt_idme", plotdirname.Data(), recalg_path.Data()));
362 TH2F* avg_dptsignif = (
TH2F*) dir1->Get(Form(
"%sMuons_%s_avg_dptsignif", plotdirname.Data(), recalg_path.Data()));
366 TwoDto2D_Eff(eff_nTrigEta, h_EffDenominator, eff_nTrigEta);
369 TwoDto2D_Eff(ID_eff_ndof, h_EffDenominator, ID_eff_ndof);
370 TwoDto2D_Eff(ID_eff_chi2, h_EffDenominator, ID_eff_chi2);
371 TwoDto2D_Eff(MS_eff_ndof, h_EffDenominator, MS_eff_ndof);
372 TwoDto2D_Eff(MS_eff_chi2, h_EffDenominator, MS_eff_chi2);
374 TwoDto2D_Eff(avg_hits_precision_inner, h_EffDenominator, avg_hits_precision_inner);
375 TwoDto2D_Eff(avg_hits_precision_middle, h_EffDenominator, avg_hits_precision_middle);
376 TwoDto2D_Eff(avg_hits_precision_outer, h_EffDenominator, avg_hits_precision_outer);
377 TwoDto2D_Eff(avg_hits_precision_extended, h_EffDenominator, avg_hits_precision_extended);
379 TwoDto2D_Eff(avg_hits_trigger_layer1, h_EffDenominator, avg_hits_trigger_layer1);
380 TwoDto2D_Eff(avg_hits_trigger_layer2, h_EffDenominator, avg_hits_trigger_layer2);
381 TwoDto2D_Eff(avg_hits_trigger_layer3, h_EffDenominator, avg_hits_trigger_layer3);
382 TwoDto2D_Eff(avg_hits_trigger_layer4, h_EffDenominator, avg_hits_trigger_layer4);
384 TwoDto2D_Eff(avg_hits_ibl, h_EffDenominator, avg_hits_ibl);
385 TwoDto2D_Eff(avg_hits_pix, h_EffDenominator, avg_hits_pix);
386 TwoDto2D_Eff(avg_hits_sct, h_EffDenominator, avg_hits_sct);
387 TwoDto2D_Eff(avg_hits_trt, h_EffDenominator, avg_hits_trt);
389 TwoDto2D_Eff(avg_ddpt_idme, h_EffDenominator, avg_ddpt_idme);
390 TwoDto2D_Eff(avg_dptsignif, h_EffDenominator, avg_dptsignif);
395 TString mDir_lb = motherDir +
"Overview/";
396 if (!
f->cd(mDir_lb))
return;
399 while (TKey*
key1 =
dynamic_cast<TKey*
>(nextcd_lb())) {
401 TString recalg_path =
key1->GetName();
402 TString recalg_fullStr = mDir_lb +
key1->GetName();
403 TDirectory* dir1 =
f->GetDirectory(recalg_fullStr);
407 TString montype[3] = {
408 "Segment",
"MuonTrack",
"Muon"
411 for (
int i = 0;
i < 3;
i++) {
413 (
TH2F*) dir1->Get(Form(
"%sOverview_%s_n%s_LB_2D", plotdirname.Data(), recalg_path.Data(), montype[
i].Data()));
415 (
TH1F*) dir1->Get(Form(
"%sOverview_%s_n%s_LB", plotdirname.Data(), recalg_path.Data(), montype[
i].Data()));
428 TString resonance[2] = {
432 for (
int i = 0;
i < 2;
i++) {
434 (
TH2F*) dir1->Get(Form(
"%sOverview_%s_n%s_LB_2D", plotdirname.Data(), recalg_path.Data(),
435 resonance[
i].Data()));
437 (
TH1F*) dir1->Get(Form(
"%sOverview_%s_n%s_LB", plotdirname.Data(), recalg_path.Data(), resonance[
i].Data()));
454 if (!
dirname.Contains(
"NoTrig")) {
456 TString mDir_phys = motherDir +
"MuonTrkPhys/";
457 if (!
f->cd(mDir_phys))
return;
459 TIter nextcd_phys(
gDirectory->GetListOfKeys());
460 while (TKey*
key1 =
dynamic_cast<TKey*
>(nextcd_phys())) {
462 TString recalg_path =
key1->GetName();
463 TString recalg_fullStr = mDir_phys +
key1->GetName();
464 TDirectory* dir1 =
f->GetDirectory(recalg_fullStr);
468 TH1* h_Mass_Mean = (
TH1F*) dir1->Get(Form(
"m_%s_M_Mean", recalg_path.Data()));
469 TH1* h_Mass_Sigma = (
TH1F*) dir1->Get(Form(
"m_%s_M_Sigma", recalg_path.Data()));
471 TString det_region[4] = {
472 "EC",
"BC",
"BA",
"EA"
474 for (
int i = 0;
i < 4;
i++) {
475 for (
int j = 0; j < 4; j++) {
476 TH1* h_Mass_region = (
TH1F*) dir1->Get(Form(
"m_%s_M_%s_%s", recalg_path.Data(),
477 det_region[
i].Data(), det_region[j].Data()));
480 SetMassInfo(
i * 4 + (j + 1), h_Mass_region, h_Mass_Mean, h_Mass_Sigma, recalg_path);
481 if (h_Mass_region != NULL) h_Mass_region->Write(
"", TObject::kOverwrite);
484 if (h_Mass_Mean != NULL) h_Mass_Mean->Write(
"", TObject::kOverwrite);
485 if (h_Mass_Sigma != NULL) h_Mass_Sigma->Write(
"", TObject::kOverwrite);