ATLAS Offline Software
Loading...
Searching...
No Matches
MonitoringFile_MuonTrackPostProcess.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4
5
6
8//
9//Post processing algorithm for Muon Track Physics Monitoring
10//
12
14
15#include <iostream>
16#include <algorithm>
17#include <fstream>
18#include <cmath>
19#include <cstdlib>
20#include <sstream>
21#include <stdio.h>
22#include <map>
23#include <iomanip>
24#include <set>
25
26#include "TH1F.h"
27#include "TH2F.h"
28#include "TFile.h"
29#include "TClass.h"
30#include "TKey.h"
31#include "TMath.h"
32#include "TF1.h"
33#include "TTree.h"
34#include "TBranch.h"
35#include "TList.h"
36#include "TProfile.h"
37#include "TMinuit.h"
38
39const char* const SegStationName[17] = {
40 "BIS", "BIL", "BMS", "BML", "BOS", "BOL", "BEE",
41 "EIS", "EIL", "EMS", "EML", "EOS", "EOL", "EES",
42 "EEL", "CSS", "CSL"
43};//For filling in monitoring plots
44
45double breitgausfun(double* x, double* par) {
46 //Fit parameters:
47 //par[0]=Width (scale) Breit-Wigner
48 //par[1]=Most Probable (MP, location) Breit mean
49 //par[2]=Total area (integral -inf to inf, normalization constant)
50 //par[3]=Width (sigma) of convoluted Gaussian function
51
52 // Numeric constants
53 double invsq2pi = 0.3989422804014; // (2 pi)^(-1/2)
54 // Control constants
55 double np = 100.0; // number of convolution steps
56 double sc = 4; // convolution extends to +-sc Gaussian sigmas
57
58 // Variables
59 double xx;
60 double fland;
61 double sum = 0.0;
62 double xlow, xupp;
63 double step;
64 double i;
65
66 // Range of convolution integral
67 xlow = x[0] - sc * par[3];
68 xupp = x[0] + sc * par[3];
69 step = (xupp - xlow) / np;
70
71 // Convolution integral of Breit and Gaussian by sum
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]);
76
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]);
80 }
81 return(par[2] * step * sum * invsq2pi / par[3]);
82}
83
84void TwoDto2D_Eff(TH2* Numerator, TH2* Denominator, TH2* Efficiency, bool rebin2d = false) {
85 //the input histograms must have the same dimension!
86 if (Numerator == NULL || Denominator == NULL || Efficiency == NULL) {
87 return;
88 }
89 if (rebin2d) {
90 Numerator->Rebin2D();//here change the default binnning of eta-phi
91 Efficiency->Rebin2D();//here change the default binnning of eta-phi
92 }
93 //then check the dimensions
94 int n_xbins = Numerator->GetNbinsX();
95 if (Denominator->GetNbinsX() != n_xbins || Efficiency->GetNbinsX() != n_xbins) {
96 return;
97 }
98 int n_ybins = Numerator->GetNbinsY();
99 if (Denominator->GetNbinsY() != n_ybins || Efficiency->GetNbinsY() != n_ybins) {
100 return;
101 }
102
103 //after protection
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));
110 }
111 }
112 Efficiency->Write("", TObject::kOverwrite);
113 return;
114}
115
116void TwoDto1D_Mean(TH2* h_parent, TH1* h_child, int rebinning = 1) {
117 //the input histograms must have the same dimension!
118 if (h_parent == NULL || h_child == NULL) {
119 return;
120 }
121 if (h_parent->GetNbinsX() != h_child->GetNbinsX()) {
122 return;
123 }
124 //after protection
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);
131 }
132 if (parent_event == 0) {
133 continue;
134 }
135 h_child->SetBinContent(bin_itrX, parent_sum / parent_event);
136 }
137 TString sHistTitle = h_child->GetTitle();
138 h_child->Rebin(rebinning);
139 h_child->SetTitle(sHistTitle + " per event");
140 h_child->Write("", TObject::kOverwrite);
141 return;
142}
143
144void TwoDto1D_Sum(TH2* h_parent, TH1* h_child, int rebinning = 2) {
145 //the input histograms must have the same dimension!
146 if (h_parent == NULL || h_child == NULL) {
147 return;
148 }
149 if (h_parent->GetNbinsX() != h_child->GetNbinsX()) {
150 return;
151 }
152 //after protection
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);
157 }
158 if (parent_sum == 0) {
159 continue;
160 }
161 h_child->SetBinContent(bin_itrX, parent_sum);
162 }
163 h_child->Rebin(rebinning);
164 h_child->Write("", TObject::kOverwrite);
165 return;
166}
167
168void SetMassInfo(int iBin, TH1* InputHist, TH1* OutMean, TH1* OutSigma, TString recalg_path) {
169 if (InputHist == NULL || OutMean == NULL || OutSigma == NULL) {
170 return;
171 }
172 if (InputHist->GetMaximum() > 10.0) {
173 if (recalg_path == "Z") {//only for Z
174 TF1* fit1 = new TF1("fit1", breitgausfun, 76, 106, 4);
175 fit1->SetLineColor(kRed);
176 fit1->SetParameter(0, 3.0);//par[0]=Width (scale) Breit-Wigner
177 fit1->SetParameter(1, 91.2);//par[1]=Most Probable (MP, location) Breit mean
178 fit1->SetParameter(2, InputHist->GetEntries());//par[2]=Total area (integral -inf to inf, normalization constant)
179 fit1->SetParameter(3, 1.0);//par[3]=Width (sigma) of convoluted Gaussian function
180 InputHist->Fit("fit1", "q", "", 77, 105);
181 fit1->Draw();
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));
186 }
187 if (recalg_path == "Jpsi") {
188 InputHist->Fit("gaus", "q", "", 2.95, 3.25);
189 TF1* fit1 = (TF1*) InputHist->GetFunction("gaus");
190 fit1->Draw();
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));
195 }
196 } else {
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));
201 }
202 return;
203}
204
205namespace dqutils {
206 //main function
207 void MonitoringFile::MuonTrackPostProcess(const std::string& inFilename, bool isIncremental) {
208 if (isIncremental) {
209 return;
210 }
211 MonitoringFile::MuonTrack_Main(inFilename, "");
212 MonitoringFile::MuonTrack_Main(inFilename, "NoTrig/");
213 return;
214 }
215
216 //subfunctions
217 void MonitoringFile::MuonTrack_Main(const std::string& inFilename, TString dirname) {
218 TString plotdirname = dirname;//set the plottting dir anme
219
220 plotdirname.ReplaceAll("/", "_");//name clean
221 dirname = "MuonPhysics/" + dirname;//give it the full path
222 TFile* f = TFile::Open(inFilename.c_str(), "UPDATE");
223
224 if (f == 0) {
225 std::cerr << "MuonTrackMonitoring(): " << "Input file not opened \n";
226 return;
227 }
228 if (f->GetSize() < 1000.) {
229 std::cerr << "MuonTrackMonitoring(): " << "Input file empty \n";
230 return;
231 }
232 // get run directory name
233 //Seemingly unnecessary lines are necessary
234 TIter nextcd0(gDirectory->GetListOfKeys());
235 TKey* key0 = (TKey*) nextcd0();
236 if (key0 == 0) return;
237
238 TDirectory* dir0 = dynamic_cast<TDirectory*> (key0->ReadObj());
239 if (dir0 == 0) return;
240
241 dir0->cd();
242 TString runNumber = dir0->GetName();
243 TString motherDir = runNumber + "/" + dirname;
245
246 //Do the segment part
247 TString mDir = motherDir + "Segments/";
248 if (!f->cd(mDir)) return;
249
250 TIter nextcd1(gDirectory->GetListOfKeys());
251 while (TKey* key1 = dynamic_cast<TKey*>(nextcd1())) {
252 //While in the segments
253 TString recalg_path = key1->GetName();
254 TString recalg_fullStr = mDir + key1->GetName();
255 TDirectory* dir1 = f->GetDirectory(recalg_fullStr);
256 if (!dir1) continue;
257 dir1->cd();
258
259 // Divide the efficiency histograms
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()));
266 TH2F* h_Efficiency =
267 (TH2F*) dir1->Get(Form("%sSegments_%s_eff_chamberIndex_perSector", plotdirname.Data(), recalg_path.Data()));
268
269 TwoDto2D_Eff(h_EffNumerator, h_EffDenominator, h_Efficiency);
270
271 //add the efficiency for precision
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(),
275 SegStationName[i]));
276 TH2F* seg_prec_EffDenominator =
277 (TH2F*) dir1->Get(Form("%sSegments_%s_eff_%s_etastation_nPrechit", plotdirname.Data(), recalg_path.Data(),
278 SegStationName[i]));
279 TH2F* seg_prec_Efficiency =
280 (TH2F*) dir1->Get(Form("%sSegments_%s_eff_%s_etastation_nPrechit", plotdirname.Data(), recalg_path.Data(),
281 SegStationName[i]));
282
283 TwoDto2D_Eff(seg_prec_EffNumerator, seg_prec_EffDenominator, seg_prec_Efficiency);
284
285 TH2F* seg_trig_EffNumerator =
286 (TH2F*) dir1->Get(Form("%sSegments_%s_%s_etastation_nTrighit", plotdirname.Data(), recalg_path.Data(),
287 SegStationName[i]));
288 TH2F* seg_trig_EffDenominator =
289 (TH2F*) dir1->Get(Form("%sSegments_%s_eff_%s_etastation_nTrighit", plotdirname.Data(), recalg_path.Data(),
290 SegStationName[i]));
291 TH2F* seg_trig_Efficiency =
292 (TH2F*) dir1->Get(Form("%sSegments_%s_eff_%s_etastation_nTrighit", plotdirname.Data(), recalg_path.Data(),
293 SegStationName[i]));
294
295 TwoDto2D_Eff(seg_trig_EffNumerator, seg_trig_EffDenominator, seg_trig_Efficiency);
296 }
297 }//ends different subfolder for segment efficiency
298
299 //Do the muon part
300 TString mDir_muons = motherDir + "Muons/";
301 if (!f->cd(mDir_muons)) return;
302
303 TIter nextcd_muons(gDirectory->GetListOfKeys());
304 while (TKey* key1 = dynamic_cast<TKey*>(nextcd_muons())) {
305 //While in the segments
306 TString recalg_path = key1->GetName();
307 TString recalg_fullStr = mDir_muons + key1->GetName();
308 TDirectory* dir1 = f->GetDirectory(recalg_fullStr);
309 if (!dir1) continue;
310 dir1->cd();
311
312 TString muonqualstr[4] = {
313 "Tight", "Medium", "Loose", "Veryloose"
314 };
315 // Divide the efficiency histograms
316 TH2F* h_EffDenominator =
317 (TH2F*) dir1->Get(Form("%sMuons_%s_Origin_eta_phi", plotdirname.Data(), recalg_path.Data()));
318 //m_EffDenominator->Rebin2D();//here change the default binnning of eta-phi! disabled once we are in 64 bins
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()));
323 TH2F* h_Efficiency =
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);//here change the default binnning of eta-phi
326 }
327
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()));
337
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()));
346
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()));
355
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()));
360
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()));
363
364 TwoDto2D_Eff(eff_nPrec, h_EffDenominator, eff_nPrec);
365 TwoDto2D_Eff(eff_nPhi, h_EffDenominator, eff_nPhi);
366 TwoDto2D_Eff(eff_nTrigEta, h_EffDenominator, eff_nTrigEta);
367 TwoDto2D_Eff(eff_ndof, h_EffDenominator, eff_ndof);
368 TwoDto2D_Eff(eff_chi2, h_EffDenominator, eff_chi2);
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);
373
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);
378
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);
383
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);
388
389 TwoDto2D_Eff(avg_ddpt_idme, h_EffDenominator, avg_ddpt_idme);
390 TwoDto2D_Eff(avg_dptsignif, h_EffDenominator, avg_dptsignif);
391 }//ends different subfolder for muon efficiency
392
393
394 //Do the luminoisty part
395 TString mDir_lb = motherDir + "Overview/";
396 if (!f->cd(mDir_lb)) return;
397
398 TIter nextcd_lb(gDirectory->GetListOfKeys());
399 while (TKey* key1 = dynamic_cast<TKey*>(nextcd_lb())) {
400 //While in the segments
401 TString recalg_path = key1->GetName();
402 TString recalg_fullStr = mDir_lb + key1->GetName();
403 TDirectory* dir1 = f->GetDirectory(recalg_fullStr);
404 if (!dir1) continue;
405 dir1->cd();
406
407 TString montype[3] = {
408 "Segment", "MuonTrack", "Muon"
409 };
410 // Divide the efficiency histograms
411 for (int i = 0; i < 3; i++) {
412 TH2F* h_parent_lb =
413 (TH2F*) dir1->Get(Form("%sOverview_%s_n%s_LB_2D", plotdirname.Data(), recalg_path.Data(), montype[i].Data()));
414 TH1F* h_child_lb =
415 (TH1F*) dir1->Get(Form("%sOverview_%s_n%s_LB", plotdirname.Data(), recalg_path.Data(), montype[i].Data()));
416 //TH2F* h_parent_inst = (TH2F*)dir1->Get(Form("%sOverview_%s_n%s_Inst_2D", plotdirname.Data(),
417 // recalg_path.Data(), montype[i].Data()));
418 //TH1F* h_child_inst = (TH1F*)dir1->Get(Form("%sOverview_%s_n%s_Inst", plotdirname.Data(), recalg_path.Data(),
419 // montype[i].Data()));
420 //TH2F* h_parent_intlumi = (TH2F*)dir1->Get(Form("%sOverview_%s_n%s_IntLumi_2D", plotdirname.Data(),
421 // recalg_path.Data(), montype[i].Data()));
422 //TH1F* h_child_intlumi = (TH1F*)dir1->Get(Form("%sOverview_%s_n%s_IntLumi", plotdirname.Data(),
423 // recalg_path.Data(), montype[i].Data()));
424 TwoDto1D_Mean(h_parent_lb, h_child_lb);
425 //TwoDto1D_Mean(h_parent_inst, h_child_inst);
426 //TwoDto1D_Mean(h_parent_intlumi, h_child_intlumi);
427 }
428 TString resonance[2] = {
429 "Z", "Jpsi"
430 };
431 // Divide the efficiency histograms
432 for (int i = 0; i < 2; i++) {
433 TH2F* h_parent_lb =
434 (TH2F*) dir1->Get(Form("%sOverview_%s_n%s_LB_2D", plotdirname.Data(), recalg_path.Data(),
435 resonance[i].Data()));
436 TH1F* h_child_lb =
437 (TH1F*) dir1->Get(Form("%sOverview_%s_n%s_LB", plotdirname.Data(), recalg_path.Data(), resonance[i].Data()));
438 //TH2F* h_parent_inst = (TH2F*)dir1->Get(Form("%sOverview_%s_n%s_Inst_2D", plotdirname.Data(),
439 // recalg_path.Data(), resonance[i].Data()));
440 //TH1F* h_child_inst = (TH1F*)dir1->Get(Form("%sOverview_%s_n%s_Inst", plotdirname.Data(), recalg_path.Data(),
441 // resonance[i].Data()));
442 //TH2F* h_parent_intlumi = (TH2F*)dir1->Get(Form("%sOverview_%s_n%s_IntLumi_2D", plotdirname.Data(),
443 // recalg_path.Data(), resonance[i].Data()));
444 //TH1F* h_child_intlumi = (TH1F*)dir1->Get(Form("%sOverview_%s_n%s_IntLumi", plotdirname.Data(),
445 // recalg_path.Data(), resonance[i].Data()));
446 TwoDto1D_Sum(h_parent_lb, h_child_lb);
447 //TwoDto1D_Sum(h_parent_inst, h_child_inst);
448 //TwoDto1D_Sum(h_parent_intlumi, h_child_intlumi);
449 }
450 }//ends different subfolder for luminosity
451
452
453 //Do the muon part; only for the main directory!
454 if (!dirname.Contains("NoTrig")) {
455 //std::cout << "get to trackphys " << std::endl;
456 TString mDir_phys = motherDir + "MuonTrkPhys/";
457 if (!f->cd(mDir_phys)) return;
458
459 TIter nextcd_phys(gDirectory->GetListOfKeys());
460 while (TKey* key1 = dynamic_cast<TKey*>(nextcd_phys())) {
461 //While in the segments
462 TString recalg_path = key1->GetName();
463 TString recalg_fullStr = mDir_phys + key1->GetName();
464 TDirectory* dir1 = f->GetDirectory(recalg_fullStr);
465 if (!dir1) continue;
466 dir1->cd();
467
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()));
470 // Get each of the mass histograms
471 TString det_region[4] = {
472 "EC", "BC", "BA", "EA"
473 };
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()));
478 //std::cout << " bin " << i * 4 + (j + 1) << " content " << det_region[i] << " " << det_region[j] <<
479 // std::endl;
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);
482 }
483 }
484 if (h_Mass_Mean != NULL) h_Mass_Mean->Write("", TObject::kOverwrite);
485 if (h_Mass_Sigma != NULL) h_Mass_Sigma->Write("", TObject::kOverwrite);
486 }
487 }//ends different subfolder for muon efficiency
488
489 f->Close();
490 delete f;
491 return;
492 } //ends function
493} //namespace
static Double_t sc
void TwoDto1D_Mean(TH2 *h_parent, TH1 *h_child, int rebinning=1)
void TwoDto2D_Eff(TH2 *Numerator, TH2 *Denominator, TH2 *Efficiency, bool rebin2d=false)
double breitgausfun(double *x, double *par)
void TwoDto1D_Sum(TH2 *h_parent, TH1 *h_child, int rebinning=2)
void SetMassInfo(int iBin, TH1 *InputHist, TH1 *OutMean, TH1 *OutSigma, TString recalg_path)
const char *const SegStationName[17]
#define x
static void MuonTrack_Main(const std::string &inFileName, TString dirname)
static void MuonTrackPostProcess(const std::string &inFileName, bool isIncremental=false)
a structure to hold an efficiency together with a variable number of uncertainties
std::string dirname(std::string name)
Definition utils.cxx:200