ATLAS Offline Software
MonitoringFile_IDPerfPostProcess.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3  */
4 
5 // **********************************************************************
6 // $Id: MonitoringFile_IDPerfPostProcess.cxx,v 1.2 2009-04-16 17:49:23 weina Exp $
7 // **********************************************************************
8 
10 
11 #include <cmath>
12 #include <vector>
13 
14 #include <TCanvas.h>
15 #include <TF1.h>
16 #include <TFile.h>
17 #include <TH1.h>
18 #include <TH2.h>
19 #include <TKey.h>
20 #include <TMath.h>
21 #include <TProfile.h>
22 #include <TTree.h>
23 #include <TROOT.h>
24 
25 #include "RooRealVar.h"
26 #include "RooDataHist.h"
27 #include "RooArgList.h"
28 #include "RooPlot.h"
29 #include "RooBreitWigner.h"
30 #include "RooCBShape.h"
31 #include "RooFFTConvPdf.h"
32 #include "RooGlobalFunc.h"
33 #include "RooFitResult.h"
34 
35 namespace dqutils {
36  void
38  fitMergedFile_IDPerfMonManager(const std::string& inFilename, bool /* isIncremental */) {
39  //std::cout << "\n";
40  //std::cout << "Running Inner-Detector performance-monitoring analysis\n";
41  //std::cout << "\nWarning messages from fitting and histogram updating follow:\n\n";
42 
43  TFile* f = TFile::Open(inFilename.c_str(), "UPDATE");
44 
45  if (f == 0 || !f->IsOpen()) {
46  //std::cerr << "MonitoringFile::fitMergedFile_IDPerfMonManager(): "
47  //<< "Input file not opened\n";
48  delete f;
49  return;
50  }
51  if (f->GetSize() < 1000.) {
52  //std::cerr << "MonitoringFile::fitMergedFile_IDPerfMonManager(): "
53  //<< "MonitoringFile empty\n";
54  delete f;
55  return;
56  }
57  std::string run_dir;
58  TIter next_run(f->GetListOfKeys());
59  TKey* key_run(0);
60  while ((key_run = dynamic_cast<TKey*>(next_run())) != 0) {
61  TObject* obj_run = key_run->ReadObj();
62  TDirectory* tdir_run = dynamic_cast<TDirectory*>(obj_run);
63  if (tdir_run != 0) {
64  std::string tdir_run_name(tdir_run->GetName());
65  if (tdir_run_name.find("run") != std::string::npos) {
66  run_dir = tdir_run_name;
67  // std::cout<<"Run_directory: "<<run_dir<<std::endl;
68  TIter next_perf(tdir_run->GetListOfKeys());
69  TKey* key_perf(0);
70  while ((key_perf = dynamic_cast<TKey*>(next_perf())) != 0) {
71  std::string perf_name(key_perf->GetName());
72  // for hist file with run_directory
73  if (perf_name.find("IDPerfMon") != std::string::npos) {
74  TObject* obj_perf = key_perf->ReadObj();
75  TDirectory* tdir_perf = dynamic_cast<TDirectory*>(obj_perf);
76  if (tdir_perf != 0) {
77  run_dir = run_dir + '/';
78  TIter next_module(tdir_perf->GetListOfKeys());
79  TKey* key_module(0);
80  while ((key_module = dynamic_cast<TKey*>(next_module())) != 0) {
81  std::string module_name(key_module->GetName());
82  if (module_name.find("Kshort") != std::string::npos) {
83  TObject* obj_Kshort = key_module->ReadObj();
84  TDirectory* tdir_Kshort = dynamic_cast<TDirectory*>(obj_Kshort);
85  if (tdir_Kshort != 0) {
86  TIter next_trigger(tdir_Kshort->GetListOfKeys());
87  TKey* key_trigger(0);
88  while ((key_trigger = dynamic_cast<TKey*>(next_trigger())) != 0) {
89  std::string TriggerName = key_trigger->GetName();
90  // std::cout<<"Find Module: "<<module_name<<" Trigger: "<<TriggerName<<std::endl;
91  fitMergedFile_IDPerfMonKshort(f, run_dir, TriggerName);
92  }
93  } else {
94  delete obj_Kshort;
95  }
96  }
97 
98  if (module_name.find("Jpsi") != std::string::npos) {
99  TObject* obj_Jpsi = key_module->ReadObj();
100  TDirectory* tdir_Jpsi = dynamic_cast<TDirectory*>(obj_Jpsi);
101  if (tdir_Jpsi != 0) {
102  TIter next_trigger(tdir_Jpsi->GetListOfKeys());
103  TKey* key_trigger(0);
104  while ((key_trigger = dynamic_cast<TKey*>(next_trigger())) != 0) {
105  std::string TriggerName = key_trigger->GetName();
106  // std::cout<<"Find Module: "<<module_name<<" Trigger: "<<TriggerName<<std::endl;
107  fitMergedFile_IDPerfMonJpsi(f, run_dir, TriggerName);
108  }
109  } else {
110  delete obj_Jpsi;
111  }
112  }
113  if (module_name.find("Upsilon") != std::string::npos) {
114  TObject* obj_Upsilon = key_module->ReadObj();
115  TDirectory* tdir_Upsilon = dynamic_cast<TDirectory*>(obj_Upsilon);
116  if (tdir_Upsilon != 0) {
117  TIter next_trigger(tdir_Upsilon->GetListOfKeys());
118  TKey* key_trigger(0);
119  while ((key_trigger = dynamic_cast<TKey*>(next_trigger())) != 0) {
120  std::string TriggerName = key_trigger->GetName();
121  // std::cout<<"Find Module: "<<module_name<<" Trigger: "<<TriggerName<<std::endl;
122  fitMergedFile_IDPerfMonUpsilon(f, run_dir, TriggerName);
123  }
124  } else {
125  delete obj_Upsilon;
126  }
127  }
128  if (module_name.find("Zee") != std::string::npos) {
129  TObject* obj_Zee = key_module->ReadObj();
130  TDirectory* tdir_Zee = dynamic_cast<TDirectory*>(obj_Zee);
131  if (tdir_Zee != 0) {
132  TIter next_trigger(tdir_Zee->GetListOfKeys());
133  TKey* key_trigger(0);
134  while ((key_trigger = dynamic_cast<TKey*>(next_trigger())) != 0) {
135  std::string TriggerName = key_trigger->GetName();
136  // std::cout<<"Find Module: "<<module_name<<" Trigger: "<<TriggerName<<std::endl;
137  fitMergedFile_IDPerfMonZee(f, run_dir, TriggerName);
138  }
139  } else {
140  delete obj_Zee;
141  }
142  }
143  if (module_name.find("Wenu") != std::string::npos) {
144  TObject* obj_Wenu = key_module->ReadObj();
145  TDirectory* tdir_Wenu = dynamic_cast<TDirectory*>(obj_Wenu);
146  if (tdir_Wenu != 0) {
147  TIter next_trigger(tdir_Wenu->GetListOfKeys());
148  TKey* key_trigger(0);
149  while ((key_trigger = dynamic_cast<TKey*>(next_trigger())) != 0) {
150  std::string TriggerName = key_trigger->GetName();
151  // std::cout<<"Find Module: "<<module_name<<" Trigger: "<<TriggerName<<std::endl;
152  fitMergedFile_IDPerfMonWenu(f, run_dir, TriggerName);
153  }
154  } else {
155  delete obj_Wenu;
156  }
157  }
158  if (module_name.find("ZMM") != std::string::npos) {
159  TObject* obj_ZMM = key_module->ReadObj();
160  TDirectory* tdir_ZMM = dynamic_cast<TDirectory*>(obj_ZMM);
161  if (tdir_ZMM != 0) {
162  TIter next_trigger(tdir_ZMM->GetListOfKeys());
163  TKey* key_trigger(0);
164  while ((key_trigger = dynamic_cast<TKey*>(next_trigger())) != 0) {
165  std::string TriggerName = key_trigger->GetName();
166  // std::cout<<"Find Module: "<<module_name<<" Trigger: "<<TriggerName<<std::endl;
167  fitMergedFile_IDPerfMonZMM(f, run_dir, TriggerName);
168  }
169  } else {
170  delete obj_ZMM;
171  }
172  }
173  }
174  } else {
175  delete obj_perf;
176  }
177  }
178  }
179  }
180  // if without top run_directory
181  else if (tdir_run_name.find("IDPerfMon") != std::string::npos) {
182  //std::cout<<"without run_directory"<<std::endl;
183  TObject* obj_perf = key_run->ReadObj();
184  TDirectory* tdir_perf = dynamic_cast<TDirectory*>(obj_perf);
185  if (tdir_perf != 0) {
186  run_dir = '/';
187  TIter next_module(tdir_perf->GetListOfKeys());
188  TKey* key_module(0);
189  while ((key_module = dynamic_cast<TKey*>(next_module())) != 0) {
190  std::string module_name(key_module->GetName());
191  if (module_name.find("Kshort") != std::string::npos) {
192  TObject* obj_Kshort = key_module->ReadObj();
193  TDirectory* tdir_Kshort = dynamic_cast<TDirectory*>(obj_Kshort);
194  if (tdir_Kshort != 0) {
195  TIter next_trigger(tdir_Kshort->GetListOfKeys());
196  TKey* key_trigger(0);
197  while ((key_trigger = dynamic_cast<TKey*>(next_trigger())) != 0) {
198  std::string TriggerName = key_trigger->GetName();
199  // std::cout<<"Find Module: "<<module_name<<" Trigger: "<<TriggerName<<std::endl;
200  fitMergedFile_IDPerfMonKshort(f, run_dir, TriggerName);
201  }
202  } else {
203  delete obj_Kshort;
204  }
205  }
206  if (module_name.find("Jpsi") != std::string::npos) {
207  TObject* obj_Jpsi = key_module->ReadObj();
208  TDirectory* tdir_Jpsi = dynamic_cast<TDirectory*>(obj_Jpsi);
209  if (tdir_Jpsi != 0) {
210  TIter next_trigger(tdir_Jpsi->GetListOfKeys());
211  TKey* key_trigger(0);
212  while ((key_trigger = dynamic_cast<TKey*>(next_trigger())) != 0) {
213  std::string TriggerName = key_trigger->GetName();
214  // std::cout<<"Find Module: "<<module_name<<" Trigger: "<<TriggerName<<std::endl;
215  fitMergedFile_IDPerfMonJpsi(f, run_dir, TriggerName);
216  }
217  } else {
218  delete obj_Jpsi;
219  }
220  }
221  if (module_name.find("Upsilon") != std::string::npos) {
222  TObject* obj_Upsilon = key_module->ReadObj();
223  TDirectory* tdir_Upsilon = dynamic_cast<TDirectory*>(obj_Upsilon);
224  if (tdir_Upsilon != 0) {
225  TIter next_trigger(tdir_Upsilon->GetListOfKeys());
226  TKey* key_trigger(0);
227  while ((key_trigger = dynamic_cast<TKey*>(next_trigger())) != 0) {
228  std::string TriggerName = key_trigger->GetName();
229  // std::cout<<"Find Module: "<<module_name<<" Trigger: "<<TriggerName<<std::endl;
230  fitMergedFile_IDPerfMonUpsilon(f, run_dir, TriggerName);
231  }
232  } else {
233  delete obj_Upsilon;
234  }
235  }
236  if (module_name.find("Zee") != std::string::npos) {
237  TObject* obj_Zee = key_module->ReadObj();
238  TDirectory* tdir_Zee = dynamic_cast<TDirectory*>(obj_Zee);
239  if (tdir_Zee != 0) {
240  TIter next_trigger(tdir_Zee->GetListOfKeys());
241  TKey* key_trigger(0);
242  while ((key_trigger = dynamic_cast<TKey*>(next_trigger())) != 0) {
243  std::string TriggerName = key_trigger->GetName();
244  // std::cout<<"Find Module: "<<module_name<<" Trigger: "<<TriggerName<<std::endl;
245  fitMergedFile_IDPerfMonZee(f, run_dir, TriggerName);
246  }
247  } else {
248  delete obj_Zee;
249  }
250  }
251  if (module_name.find("Wenu") != std::string::npos) {
252  TObject* obj_Wenu = key_module->ReadObj();
253  TDirectory* tdir_Wenu = dynamic_cast<TDirectory*>(obj_Wenu);
254  if (tdir_Wenu != 0) {
255  TIter next_trigger(tdir_Wenu->GetListOfKeys());
256  TKey* key_trigger(0);
257  while ((key_trigger = dynamic_cast<TKey*>(next_trigger())) != 0) {
258  std::string TriggerName = key_trigger->GetName();
259  // std::cout<<"Find Module: "<<module_name<<" Trigger: "<<TriggerName<<std::endl;
260  fitMergedFile_IDPerfMonWenu(f, run_dir, TriggerName);
261  }
262  } else {
263  delete obj_Wenu;
264  }
265  }
266  if (module_name.find("ZMM") != std::string::npos) {
267  TObject* obj_ZMM = key_module->ReadObj();
268  TDirectory* tdir_ZMM = dynamic_cast<TDirectory*>(obj_ZMM);
269  if (tdir_ZMM != 0) {
270  TIter next_trigger(tdir_ZMM->GetListOfKeys());
271  TKey* key_trigger(0);
272  while ((key_trigger = dynamic_cast<TKey*>(next_trigger())) != 0) {
273  std::string TriggerName = key_trigger->GetName();
274  // std::cout<<"Find Module: "<<module_name<<" Trigger: "<<TriggerName<<std::endl;
275  fitMergedFile_IDPerfMonZMM(f, run_dir, TriggerName);
276  }
277  } else {
278  delete obj_ZMM;
279  }
280  }
281  }
282  } else {
283  delete obj_perf;
284  }
285  }
286  // else
287  //std::cerr<<"directory IDPerfMon doesn't exist !"<<std::endl;
288  } else {
289  delete obj_run;
290  }
291  }
292 
293  f->Close();
294  delete f;
295  // std::cout << "\n";
296  //std::cout << "Finish Inner-Detector performance-monitoring analysis"<<std::endl;
297  }
298 
299  void
301  fitMergedFile_IDPerfMonKshort(TFile* f, const std::string& run_dir, const std::string& TriggerName) {
302  std::string path;
303  path = run_dir + "IDPerfMon/Kshort/" + TriggerName;
304  if (f->cd(path.c_str()) == 0) {
305  //std::cerr << "MonitoringFile::fitMergedFile_IDPerfMonKshort(): "
306  //<< "No such directory \"" << path << "\"\n";
307  return;
308  }
309 
310  Double_t myPi = TMath::Pi();
311 
312  TH1F* h_massVPtBinFittedHistos[5];
313  TH1F* h_massVRadiusBinFittedHistos[7];
314  TH1F* h_massVEtaBinHistos[10];
315  TH1F* h_massVPhiBinHistos[10];
316  TH1F* h_massVCurvatureDiffBinHistos[6];
317 
318  if (!CheckHistogram(f, (path + "/ks_mass").c_str())) return;
319 
320  if (!CheckHistogram(f, (path + "/MassVptBinFitted0").c_str())) return;
321 
322  if (!CheckHistogram(f, (path + "/MassVptBinFitted1").c_str())) return;
323 
324  if (!CheckHistogram(f, (path + "/MassVptBinFitted2").c_str())) return;
325 
326  if (!CheckHistogram(f, (path + "/MassVptBinFitted3").c_str())) return;
327 
328  if (!CheckHistogram(f, (path + "/MassVptBinFitted4").c_str())) return;
329 
330  if (!CheckHistogram(f, (path + "/MassVradiusBinFitted0").c_str())) return;
331 
332  if (!CheckHistogram(f, (path + "/MassVradiusBinFitted1").c_str())) return;
333 
334  if (!CheckHistogram(f, (path + "/MassVradiusBinFitted2").c_str())) return;
335 
336  if (!CheckHistogram(f, (path + "/MassVradiusBinFitted3").c_str())) return;
337 
338  if (!CheckHistogram(f, (path + "/MassVradiusBinFitted4").c_str())) return;
339 
340  if (!CheckHistogram(f, (path + "/MassVradiusBinFitted5").c_str())) return;
341 
342  if (!CheckHistogram(f, (path + "/MassVradiusBinFitted6").c_str())) return;
343 
344  if (!CheckHistogram(f, (path + "/MassVEtaBin0").c_str())) return;
345 
346  if (!CheckHistogram(f, (path + "/MassVEtaBin1").c_str())) return;
347 
348  if (!CheckHistogram(f, (path + "/MassVEtaBin2").c_str())) return;
349 
350  if (!CheckHistogram(f, (path + "/MassVEtaBin3").c_str())) return;
351 
352  if (!CheckHistogram(f, (path + "/MassVEtaBin4").c_str())) return;
353 
354  if (!CheckHistogram(f, (path + "/MassVEtaBin5").c_str())) return;
355 
356  if (!CheckHistogram(f, (path + "/MassVEtaBin6").c_str())) return;
357 
358  if (!CheckHistogram(f, (path + "/MassVEtaBin7").c_str())) return;
359 
360  if (!CheckHistogram(f, (path + "/MassVEtaBin8").c_str())) return;
361 
362  if (!CheckHistogram(f, (path + "/MassVEtaBin9").c_str())) return;
363 
364  if (!CheckHistogram(f, (path + "/MassVPhiBin0").c_str())) return;
365 
366  if (!CheckHistogram(f, (path + "/MassVPhiBin1").c_str())) return;
367 
368  if (!CheckHistogram(f, (path + "/MassVPhiBin2").c_str())) return;
369 
370  if (!CheckHistogram(f, (path + "/MassVPhiBin3").c_str())) return;
371 
372  if (!CheckHistogram(f, (path + "/MassVPhiBin4").c_str())) return;
373 
374  if (!CheckHistogram(f, (path + "/MassVPhiBin5").c_str())) return;
375 
376  if (!CheckHistogram(f, (path + "/MassVPhiBin6").c_str())) return;
377 
378  if (!CheckHistogram(f, (path + "/MassVPhiBin7").c_str())) return;
379 
380  if (!CheckHistogram(f, (path + "/MassVPhiBin8").c_str())) return;
381 
382  if (!CheckHistogram(f, (path + "/MassVPhiBin9").c_str())) return;
383 
384  if (!CheckHistogram(f, (path + "/MassVCurvatureDiffBin0").c_str())) return;
385 
386  if (!CheckHistogram(f, (path + "/MassVCurvatureDiffBin1").c_str())) return;
387 
388  if (!CheckHistogram(f, (path + "/MassVCurvatureDiffBin2").c_str())) return;
389 
390  if (!CheckHistogram(f, (path + "/MassVCurvatureDiffBin3").c_str())) return;
391 
392  if (!CheckHistogram(f, (path + "/MassVCurvatureDiffBin4").c_str())) return;
393 
394  if (!CheckHistogram(f, (path + "/MassVCurvatureDiffBin5").c_str())) return;
395 
396  TH1F* h_mass = (TH1F*) (f->Get((path + "/ks_mass").c_str())->Clone());
397  if (CheckHistogram(f, (path + "/Nevents").c_str())) {
398  TH1F* h_Nevents = (TH1F*) f->Get((path + "/Nevents").c_str());
399  TH1F* h_rate = new TH1F("rate", "production rate", 1, 0, 1);
400  double Ntot = h_Nevents->GetEntries();
401  double yield = h_mass->Integral(h_mass->FindBin(0.487), h_mass->FindBin(0.507));
402  double rate = yield / Ntot;
403  double rate_error = sqrt(1 / yield + 1 / Ntot) * yield / Ntot;
404  h_rate->SetBinContent(1, rate);
405  h_rate->SetBinError(1, rate_error);
406  h_rate->Write("", TObject::kOverwrite);
407  }
408 // TH1F* h_mass_scaled = (TH1F*)(f->Get((path+"/ks_mass").c_str())->Clone("ks_mass_scaled_copy"));
409 // TString title(h_mass_scaled->GetTitle());
410 // if (CheckHistogram(f,(path+"/ks_mass_scaled").c_str())) {
411 // if (CheckHistogram(f,(path+"/Nevents").c_str())) {
412 // TH1F* h_Nevents=(TH1F*)f->Get((path+"/Nevents").c_str());
413 // double Ntot =h_Nevents->GetEntries();
414 // if (Ntot!=0.) h_mass_scaled->Scale(1./Ntot);
415 // h_mass_scaled->SetTitle(title+" (per event)");
416 // h_mass_scaled->Write("ks_mass_scaled",TObject::kOverwrite);
417 // }
418 // }
419 // delete h_mass_scaled;
420 
421  h_massVPtBinFittedHistos[0] = (TH1F*) (f->Get((path + "/MassVptBinFitted0").c_str())->Clone());
422  h_massVPtBinFittedHistos[1] = (TH1F*) (f->Get((path + "/MassVptBinFitted1").c_str())->Clone());
423  h_massVPtBinFittedHistos[2] = (TH1F*) (f->Get((path + "/MassVptBinFitted2").c_str())->Clone());
424  h_massVPtBinFittedHistos[3] = (TH1F*) (f->Get((path + "/MassVptBinFitted3").c_str())->Clone());
425  h_massVPtBinFittedHistos[4] = (TH1F*) (f->Get((path + "/MassVptBinFitted4").c_str())->Clone());
426  h_massVRadiusBinFittedHistos[0] = (TH1F*) (f->Get((path + "/MassVradiusBinFitted0").c_str())->Clone());
427  h_massVRadiusBinFittedHistos[1] = (TH1F*) (f->Get((path + "/MassVradiusBinFitted1").c_str())->Clone());
428  h_massVRadiusBinFittedHistos[2] = (TH1F*) (f->Get((path + "/MassVradiusBinFitted2").c_str())->Clone());
429  h_massVRadiusBinFittedHistos[3] = (TH1F*) (f->Get((path + "/MassVradiusBinFitted3").c_str())->Clone());
430  h_massVRadiusBinFittedHistos[4] = (TH1F*) (f->Get((path + "/MassVradiusBinFitted4").c_str())->Clone());
431  h_massVRadiusBinFittedHistos[5] = (TH1F*) (f->Get((path + "/MassVradiusBinFitted5").c_str())->Clone());
432  h_massVRadiusBinFittedHistos[6] = (TH1F*) (f->Get((path + "/MassVradiusBinFitted6").c_str())->Clone());
433  h_massVEtaBinHistos[0] = (TH1F*) (f->Get((path + "/MassVEtaBin0").c_str())->Clone());
434  h_massVEtaBinHistos[1] = (TH1F*) (f->Get((path + "/MassVEtaBin1").c_str())->Clone());
435  h_massVEtaBinHistos[2] = (TH1F*) (f->Get((path + "/MassVEtaBin2").c_str())->Clone());
436  h_massVEtaBinHistos[3] = (TH1F*) (f->Get((path + "/MassVEtaBin3").c_str())->Clone());
437  h_massVEtaBinHistos[4] = (TH1F*) (f->Get((path + "/MassVEtaBin4").c_str())->Clone());
438  h_massVEtaBinHistos[5] = (TH1F*) (f->Get((path + "/MassVEtaBin5").c_str())->Clone());
439  h_massVEtaBinHistos[6] = (TH1F*) (f->Get((path + "/MassVEtaBin6").c_str())->Clone());
440  h_massVEtaBinHistos[7] = (TH1F*) (f->Get((path + "/MassVEtaBin7").c_str())->Clone());
441  h_massVEtaBinHistos[8] = (TH1F*) (f->Get((path + "/MassVEtaBin8").c_str())->Clone());
442  h_massVEtaBinHistos[9] = (TH1F*) (f->Get((path + "/MassVEtaBin9").c_str())->Clone());
443  h_massVPhiBinHistos[0] = (TH1F*) (f->Get((path + "/MassVPhiBin0").c_str())->Clone());
444  h_massVPhiBinHistos[1] = (TH1F*) (f->Get((path + "/MassVPhiBin1").c_str())->Clone());
445  h_massVPhiBinHistos[2] = (TH1F*) (f->Get((path + "/MassVPhiBin2").c_str())->Clone());
446  h_massVPhiBinHistos[3] = (TH1F*) (f->Get((path + "/MassVPhiBin3").c_str())->Clone());
447  h_massVPhiBinHistos[4] = (TH1F*) (f->Get((path + "/MassVPhiBin4").c_str())->Clone());
448  h_massVPhiBinHistos[5] = (TH1F*) (f->Get((path + "/MassVPhiBin5").c_str())->Clone());
449  h_massVPhiBinHistos[6] = (TH1F*) (f->Get((path + "/MassVPhiBin6").c_str())->Clone());
450  h_massVPhiBinHistos[7] = (TH1F*) (f->Get((path + "/MassVPhiBin7").c_str())->Clone());
451  h_massVPhiBinHistos[8] = (TH1F*) (f->Get((path + "/MassVPhiBin8").c_str())->Clone());
452  h_massVPhiBinHistos[9] = (TH1F*) (f->Get((path + "/MassVPhiBin9").c_str())->Clone());
453  h_massVCurvatureDiffBinHistos[0] = (TH1F*) (f->Get((path + "/MassVCurvatureDiffBin0").c_str())->Clone());
454  h_massVCurvatureDiffBinHistos[1] = (TH1F*) (f->Get((path + "/MassVCurvatureDiffBin1").c_str())->Clone());
455  h_massVCurvatureDiffBinHistos[2] = (TH1F*) (f->Get((path + "/MassVCurvatureDiffBin2").c_str())->Clone());
456  h_massVCurvatureDiffBinHistos[3] = (TH1F*) (f->Get((path + "/MassVCurvatureDiffBin3").c_str())->Clone());
457  h_massVCurvatureDiffBinHistos[4] = (TH1F*) (f->Get((path + "/MassVCurvatureDiffBin4").c_str())->Clone());
458  h_massVCurvatureDiffBinHistos[5] = (TH1F*) (f->Get((path + "/MassVCurvatureDiffBin5").c_str())->Clone());
459 
460  TF1* func1 = new TF1("func1", "gaus", 0.460, 0.540);
461  TF1* func2 = new TF1("func2", "expo", 0.460, 0.540);
462  TF1* func = new TF1("func", "func1+func2", 0.460, 0.540);
463 
464  func->SetLineColor(4);
465  func->SetParameters(10., 0.500, 0.010, 2., -.001);
466  // func->SetParLimits(0,0.,10000.);
467  func->SetParLimits(1, 0.460, 0.540);
468  func->SetParLimits(2, 0., 0.100);
469  func->SetParLimits(3, 0., 10000.);
470  func->SetParLimits(4, -1000., 0.);
471  func->SetParNames("Constant", "Mean", "Sigma", "Constant", "Slope");
472 
473  TCanvas* myCanvas = new TCanvas("MyCanvas");
474  myCanvas->cd();
475 
476  h_mass->Fit(func, "lmhqnr");
477 
478  Double_t massBins[5], massErrorBins[5], widthBins[5], widthErrorBins[5];
479  const Int_t nPtBinsHisto = 5 + 1;
480  Double_t ptBins[nPtBinsHisto] = {
481  0.5, 1.6, 2.1, 2.8, 3.9, 5.1
482  };
483  for (int binFill = 0; binFill < 5; binFill++) {
484  double max = h_massVPtBinFittedHistos[binFill]->GetBinContent(h_massVPtBinFittedHistos[binFill]->GetMaximumBin());
485  func->SetParLimits(0, 0, 2 * max);
486  h_massVPtBinFittedHistos[binFill]->Fit(func, "lmhqr");
487  massBins[binFill] = func->GetParameter(1);
488  massErrorBins[binFill] = func->GetParError(1);
489  widthBins[binFill] = func->GetParameter(2);
490  widthErrorBins[binFill] = func->GetParError(2);
491  }
492 
493  const Double_t* ptBinsFinal = ptBins;
494  const Double_t* massBinsFinal = massBins;
495  const Double_t* massErrorBinsFinal = massErrorBins;
496  const Double_t* widthBinsFinal = widthBins;
497  const Double_t* widthErrorBinsFinal = widthErrorBins;
498 
499  TH1F* h_massVersusPt = new TH1F("KsMassVersusPt_Merged", "", 5, ptBinsFinal);
500  h_massVersusPt->SetXTitle("p_{T} (Gev / c)");
501  h_massVersusPt->SetYTitle("Mass (Gev / c^{2})");
502  h_massVersusPt->SetMarkerStyle(20);
503  for (int binFill = 0; binFill < 5; binFill++) {
504  Double_t binContent = massBinsFinal[binFill];
505  Double_t binError = massErrorBinsFinal[binFill];
506  h_massVersusPt->SetBinContent(binFill + 1, binContent);
507  h_massVersusPt->SetBinError(binFill + 1, binError);
508  }
509 
510  TH1F* h_widthVersusPt = new TH1F("KsWidthVersusPt_Merged", "", 5, ptBinsFinal);
511  h_widthVersusPt->SetXTitle("p_{T} (Gev / c)");
512  h_widthVersusPt->SetYTitle("Width (Gev / c^{2})");
513  h_widthVersusPt->SetMarkerStyle(20);
514  for (int binFill = 0; binFill < 5; binFill++) {
515  Double_t binContent = widthBinsFinal[binFill];
516  Double_t binError = widthErrorBinsFinal[binFill];
517  h_widthVersusPt->SetBinContent(binFill + 1, binContent);
518  h_widthVersusPt->SetBinError(binFill + 1, binError);
519  }
520 
521  Double_t massVradiusBins[7], massVradiusErrorBins[7], widthVradiusBins[7], widthVradiusErrorBins[7];
522  const Int_t nRadiusBinsHisto = 7 + 1;
523  Double_t radiusBins[nRadiusBinsHisto] = {
524  0., 30., 40., 60., 80., 100., 140., 230
525  };
526  for (int binFill = 0; binFill < 7; binFill++) {
527  double max = h_massVRadiusBinFittedHistos[binFill]->GetBinContent(
528  h_massVRadiusBinFittedHistos[binFill]->GetMaximumBin());
529  func->SetParLimits(0, 0, 2 * max);
530  h_massVRadiusBinFittedHistos[binFill]->Fit(func, "lmhqr");
531  massVradiusBins[binFill] = func->GetParameter(1);
532  massVradiusErrorBins[binFill] = func->GetParError(1);
533  widthVradiusBins[binFill] = func->GetParameter(2);
534  widthVradiusErrorBins[binFill] = func->GetParError(2);
535  }
536 
537  const Double_t* radiusBinsFinal = radiusBins;
538  const Double_t* massVradiusBinsFinal = massVradiusBins;
539  const Double_t* massVradiusErrorBinsFinal = massVradiusErrorBins;
540  const Double_t* widthVradiusBinsFinal = widthVradiusBins;
541  const Double_t* widthVradiusErrorBinsFinal = widthVradiusErrorBins;
542 
543  TH1F* h_massVersusRadius = new TH1F("KsMassVersusRadius_Merged", "", 7, radiusBinsFinal);
544  h_massVersusRadius->SetXTitle("Decay Radius (mm)");
545  h_massVersusRadius->SetYTitle("Mass (Gev / c^{2})");
546  h_massVersusRadius->SetMarkerStyle(20);
547  for (int binFill = 0; binFill < 7; binFill++) {
548  Double_t binContent = massVradiusBinsFinal[binFill];
549  Double_t binError = massVradiusErrorBinsFinal[binFill];
550  h_massVersusRadius->SetBinContent(binFill + 1, binContent);
551  h_massVersusRadius->SetBinError(binFill + 1, binError);
552  }
553  TH1F* h_widthVersusRadius = new TH1F("KsWidthVersusRadius_Merged", "", 7, radiusBinsFinal);
554  h_widthVersusRadius->SetXTitle("Decay Radius (mm)");
555  h_widthVersusRadius->SetYTitle("Width (Gev / c^{2})");
556  h_widthVersusRadius->SetMarkerStyle(20);
557  for (int binFill = 0; binFill < 7; binFill++) {
558  Double_t binContent = widthVradiusBinsFinal[binFill];
559  Double_t binError = widthVradiusErrorBinsFinal[binFill];
560  h_widthVersusRadius->SetBinContent(binFill + 1, binContent);
561  h_widthVersusRadius->SetBinError(binFill + 1, binError);
562  }
563 
564  Double_t etaBins[11] = {
565  -2.5, -2.0, -1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, 2.5
566  };
567  Double_t massVetaBins[10], massVetaErrorBins[10], widthVetaBins[10], widthVetaErrorBins[10];
568  for (int binFill = 0; binFill < 10; binFill++) {
569  double max = h_massVEtaBinHistos[binFill]->GetBinContent(h_massVEtaBinHistos[binFill]->GetMaximumBin());
570  func->SetParLimits(0, 0, 2 * max);
571  h_massVEtaBinHistos[binFill]->Fit(func, "lmhqr");
572  massVetaBins[binFill] = func->GetParameter(1);
573  massVetaErrorBins[binFill] = func->GetParError(1);
574  widthVetaBins[binFill] = func->GetParameter(2);
575  widthVetaErrorBins[binFill] = func->GetParError(2);
576  }
577  TH1F* h_massVersusEta = new TH1F("KsMassVersusEta_Merged", "", 10, etaBins);
578  h_massVersusEta->SetXTitle("#eta");
579  h_massVersusEta->SetYTitle("Mass (Gev / c^{2})");
580  h_massVersusEta->SetMarkerStyle(20);
581  for (int binFill = 0; binFill < 10; binFill++) {
582  Double_t binContent = massVetaBins[binFill];
583  Double_t binError = massVetaErrorBins[binFill];
584  h_massVersusEta->SetBinContent(binFill + 1, binContent);
585  h_massVersusEta->SetBinError(binFill + 1, binError);
586  }
587  TH1F* h_widthVersusEta = new TH1F("KsWidthVersusEta_Merged", "", 10, etaBins);
588  h_widthVersusEta->SetXTitle("#eta");
589  h_widthVersusEta->SetYTitle("Width (Gev / c^{2})");
590  h_widthVersusEta->SetMarkerStyle(20);
591  for (int binFill = 0; binFill < 10; binFill++) {
592  Double_t binContent = widthVetaBins[binFill];
593  Double_t binError = widthVetaErrorBins[binFill];
594  h_widthVersusEta->SetBinContent(binFill + 1, binContent);
595  h_widthVersusEta->SetBinError(binFill + 1, binError);
596  }
597 
598  Double_t phiBins[11] = {
599  (-5.0 * myPi / 5),
600  (-4.0 * myPi / 5),
601  (-3.0 * myPi / 5),
602  (-2.0 * myPi / 5),
603  (-1.0 * myPi / 5),
604  (0.0 * myPi / 5),
605  (1.0 * myPi / 5),
606  (2.0 * myPi / 5),
607  (3.0 * myPi / 5),
608  (4.0 * myPi / 5),
609  (5.0 * myPi / 5)
610  };
611  Double_t massVphiBins[10], massVphiErrorBins[10], widthVphiBins[10], widthVphiErrorBins[10];
612  for (int binFill = 0; binFill < 10; binFill++) {
613  double max = h_massVPhiBinHistos[binFill]->GetBinContent(h_massVPhiBinHistos[binFill]->GetMaximumBin());
614  func->SetParLimits(0, 0, 2 * max);
615  h_massVPhiBinHistos[binFill]->Fit(func, "lmhqr");
616  massVphiBins[binFill] = func->GetParameter(1);
617  massVphiErrorBins[binFill] = func->GetParError(1);
618  widthVphiBins[binFill] = func->GetParameter(2);
619  widthVphiErrorBins[binFill] = func->GetParError(2);
620  }
621  TH1F* h_massVersusPhi = new TH1F("KsMassVersusPhi_Merged", "", 10, phiBins);
622  h_massVersusPhi->SetXTitle("#phi");
623  h_massVersusPhi->SetYTitle("Mass (Gev / c^{2})");
624  h_massVersusPhi->SetMarkerStyle(20);
625  for (int binFill = 0; binFill < 10; binFill++) {
626  Double_t binContent = massVphiBins[binFill];
627  Double_t binError = massVphiErrorBins[binFill];
628  h_massVersusPhi->SetBinContent(binFill + 1, binContent);
629  h_massVersusPhi->SetBinError(binFill + 1, binError);
630  }
631  TH1F* h_widthVersusPhi = new TH1F("KsWidthVersusPhi_Merged", "", 10, phiBins);
632  h_widthVersusPhi->SetXTitle("#phi");
633  h_widthVersusPhi->SetYTitle("Width (Gev / c^{2})");
634  h_widthVersusPhi->SetMarkerStyle(20);
635  for (int binFill = 0; binFill < 10; binFill++) {
636  Double_t binContent = widthVphiBins[binFill];
637  Double_t binError = widthVphiErrorBins[binFill];
638  h_widthVersusPhi->SetBinContent(binFill + 1, binContent);
639  h_widthVersusPhi->SetBinError(binFill + 1, binError);
640  }
641 
642  Double_t curvatureDiffBins[7] = {
643  -0.0012, -0.0008, -0.0004, 0.0000, 0.0004, 0.0008, 0.0012
644  };
645  Double_t massVcurvatureDiffBins[6], massVcurvatureDiffErrorBins[6], widthVcurvatureDiffBins[6],
646  widthVcurvatureDiffErrorBins[6];
647  for (int binFill = 0; binFill < 6; binFill++) {
648  double max = h_massVCurvatureDiffBinHistos[binFill]->GetBinContent(
649  h_massVCurvatureDiffBinHistos[binFill]->GetMaximumBin());
650  func->SetParLimits(0, 0, 2 * max);
651  h_massVCurvatureDiffBinHistos[binFill]->Fit(func, "lmhqr");
652  massVcurvatureDiffBins[binFill] = func->GetParameter(1);
653  massVcurvatureDiffErrorBins[binFill] = func->GetParError(1);
654  widthVcurvatureDiffBins[binFill] = func->GetParameter(2);
655  widthVcurvatureDiffErrorBins[binFill] = func->GetParError(2);
656  }
657  TH1F* h_massVersusCurvatureDiff = new TH1F("KsMassVersusCurvatureDiff_Merged", "", 6, curvatureDiffBins);
658  h_massVersusCurvatureDiff->SetXTitle("1/p_{T}(#pi^{+}) - 1/p_{T}(#pi^{-}) [GeV^{-1}]");
659  h_massVersusCurvatureDiff->SetYTitle("Mass (Gev / c^{2})");
660  h_massVersusCurvatureDiff->SetMarkerStyle(20);
661  for (int binFill = 0; binFill < 6; binFill++) {
662  Double_t binContent = massVcurvatureDiffBins[binFill];
663  Double_t binError = massVcurvatureDiffErrorBins[binFill];
664  h_massVersusCurvatureDiff->SetBinContent(binFill + 1, binContent);
665  h_massVersusCurvatureDiff->SetBinError(binFill + 1, binError);
666  }
667  TH1F* h_widthVersusCurvatureDiff = new TH1F("KsWidthVersusCurvatureDiff_Merged", "", 6, curvatureDiffBins);
668  h_widthVersusCurvatureDiff->SetXTitle("1/p_{T}(#pi^{+}) - 1/p_{T}(#pi^{-}) [GeV^{-1}]");
669  h_widthVersusCurvatureDiff->SetYTitle("Width (Gev / c^{2})");
670  h_widthVersusCurvatureDiff->SetMarkerStyle(20);
671  for (int binFill = 0; binFill < 6; binFill++) {
672  Double_t binContent = widthVcurvatureDiffBins[binFill];
673  Double_t binError = widthVcurvatureDiffErrorBins[binFill];
674  h_widthVersusCurvatureDiff->SetBinContent(binFill + 1, binContent);
675  h_widthVersusCurvatureDiff->SetBinError(binFill + 1, binError);
676  }
677 
678  if (f->cd(path.c_str()) == 0) {
679  //std::cerr << "MonitoringFile::fitMergedFile_IDPerfMonKshort(): "
680  //<< "No such directory \"" << path << "\"\n";
681  return;
682  }
683 
684  // f->cd(path.c_str());
685 
686  h_mass->Write("", TObject::kOverwrite);
687 
688  h_massVPtBinFittedHistos[0]->Write("", TObject::kOverwrite);
689  h_massVPtBinFittedHistos[1]->Write("", TObject::kOverwrite);
690  h_massVPtBinFittedHistos[2]->Write("", TObject::kOverwrite);
691  h_massVPtBinFittedHistos[3]->Write("", TObject::kOverwrite);
692  h_massVPtBinFittedHistos[4]->Write("", TObject::kOverwrite);
693  h_massVRadiusBinFittedHistos[0]->Write("", TObject::kOverwrite);
694  h_massVRadiusBinFittedHistos[1]->Write("", TObject::kOverwrite);
695  h_massVRadiusBinFittedHistos[2]->Write("", TObject::kOverwrite);
696  h_massVRadiusBinFittedHistos[3]->Write("", TObject::kOverwrite);
697  h_massVRadiusBinFittedHistos[4]->Write("", TObject::kOverwrite);
698  h_massVRadiusBinFittedHistos[5]->Write("", TObject::kOverwrite);
699  h_massVRadiusBinFittedHistos[6]->Write("", TObject::kOverwrite);
700  h_massVEtaBinHistos[0]->Write("", TObject::kOverwrite);
701  h_massVEtaBinHistos[1]->Write("", TObject::kOverwrite);
702  h_massVEtaBinHistos[2]->Write("", TObject::kOverwrite);
703  h_massVEtaBinHistos[3]->Write("", TObject::kOverwrite);
704  h_massVEtaBinHistos[4]->Write("", TObject::kOverwrite);
705  h_massVEtaBinHistos[5]->Write("", TObject::kOverwrite);
706  h_massVEtaBinHistos[6]->Write("", TObject::kOverwrite);
707  h_massVEtaBinHistos[7]->Write("", TObject::kOverwrite);
708  h_massVEtaBinHistos[8]->Write("", TObject::kOverwrite);
709  h_massVEtaBinHistos[9]->Write("", TObject::kOverwrite);
710  h_massVPhiBinHistos[0]->Write("", TObject::kOverwrite);
711  h_massVPhiBinHistos[1]->Write("", TObject::kOverwrite);
712  h_massVPhiBinHistos[2]->Write("", TObject::kOverwrite);
713  h_massVPhiBinHistos[3]->Write("", TObject::kOverwrite);
714  h_massVPhiBinHistos[4]->Write("", TObject::kOverwrite);
715  h_massVPhiBinHistos[5]->Write("", TObject::kOverwrite);
716  h_massVPhiBinHistos[6]->Write("", TObject::kOverwrite);
717  h_massVPhiBinHistos[7]->Write("", TObject::kOverwrite);
718  h_massVPhiBinHistos[8]->Write("", TObject::kOverwrite);
719  h_massVPhiBinHistos[9]->Write("", TObject::kOverwrite);
720  h_massVCurvatureDiffBinHistos[0]->Write("", TObject::kOverwrite);
721  h_massVCurvatureDiffBinHistos[1]->Write("", TObject::kOverwrite);
722  h_massVCurvatureDiffBinHistos[2]->Write("", TObject::kOverwrite);
723  h_massVCurvatureDiffBinHistos[3]->Write("", TObject::kOverwrite);
724  h_massVCurvatureDiffBinHistos[4]->Write("", TObject::kOverwrite);
725  h_massVCurvatureDiffBinHistos[5]->Write("", TObject::kOverwrite);
726 
727  h_massVersusPt->Write("", TObject::kOverwrite);
728  h_widthVersusPt->Write("", TObject::kOverwrite);
729  h_massVersusRadius->Write("", TObject::kOverwrite);
730  h_widthVersusRadius->Write("", TObject::kOverwrite);
731  h_massVersusEta->Write("", TObject::kOverwrite);
732  h_widthVersusEta->Write("", TObject::kOverwrite);
733  h_massVersusPhi->Write("", TObject::kOverwrite);
734  h_widthVersusPhi->Write("", TObject::kOverwrite);
735  h_massVersusCurvatureDiff->Write("", TObject::kOverwrite);
736  h_widthVersusCurvatureDiff->Write("", TObject::kOverwrite);
737 
738  myCanvas->Close();
739  delete myCanvas;
740 
741  f->Write();
742 
743  delete func;
744  delete func1;
745  delete func2;
746  }
747 
748 //Jpsi plots merging
749  void
751  fitMergedFile_IDPerfMonJpsi(TFile* f, const std::string& run_dir, const std::string& TriggerName) {
752  std::string path;
753  path = run_dir + "IDPerfMon/Jpsi/" + TriggerName;
754 
755  if (f->cd(path.c_str()) == 0) {
756  //std::cerr//<< "MonitoringFile::fitMergedFile_IDPerfMonJpsi(): "
757  //<<"No such directory \""<< path << "\"\n";
758  return;
759  }
760 
761  TH1F* h_jpsi_invmass_vs_pt = new TH1F("Jpsi_invmass_vs_pt",
762  "Jpsi invmass-PDGmass vs. Jpsi Pt; p_{T}(J/#psi) [GeV/c]; Mass Shift [GeV/c^{2}]", 6, 10.,
763  20.);
764  TH1F* h_jpsi_invmass_vs_z0 = new TH1F("Jpsi_invmass_vs_z0",
765  "Jpsi invmass-PDGmass vs. muon z0; z0(#mu) [mm]; Mass Shift [GeV/c^{2}]", 6,
766  -100., 100.);
767  TH1F* h_jpsi_invmass_vs_phi = new TH1F("Jpsi_invmass_vs_phi",
768  "Jpsi invmass-PDGmass vs. Jpsi phi; #phi(J/#psi) [rad]; Mass Shift [GeV/c^{2}]", 6, -3.15,
769  3.15);
770  TH1F* h_jpsi_invmass_vs_phiplus = new TH1F("Jpsi_invmass_vs_phiplus",
771  "Jpsi invmass-PDGmass vs. Muon+ phi; #phi(#mu^{+}) [rad]; Mass Shift [GeV/c^{2}]", 6, -3.15,
772  3.15);
773  TH1F* h_jpsi_invmass_vs_phiminus = new TH1F("Jpsi_invmass_vs_phiminus",
774  "Jpsi invmass-PDGmass vs. Muon- phi; #phi(#mu^{-}) [rad]; Mass Shift [GeV/c^{2}]", 6, -3.15,
775  3.15);
776  TH1F* h_jpsi_invmass_vs_phidiff = new TH1F("Jpsi_invmass_vs_phidiff",
777  "Jpsi invmass-PDGmass vs. |phi(+)-phi(-)|; |#phi(#mu^{+})-#phi(#mu^{-})| [rad]; Mass Shift [GeV/c^{2}]", 6, 0.,
778  0.4);
779  TH1F* h_jpsi_invmass_vs_phisum = new TH1F("Jpsi_invmass_vs_phisum",
780  "Jpsi invmass-PDGmass vs. phi(+)+phi(-);#phi(#mu^{+})+#phi(#mu^{-}) [rad];Mass Shift [GeV/c^{2}]", 6, -3.15,
781  3.15);
782  TH1F* h_jpsi_invmass_vs_eta = new TH1F("Jpsi_invmass_vs_eta",
783  "Jpsi invmass-PDGmass vs. Jpsi eta; #eta(J/#psi); Mass Shift [GeV/c^{2}]", 6,
784  -2.4, 2.4);
785  TH1F* h_jpsi_invmass_vs_eta_barrel = new TH1F("Jpsi_invmass_vs_eta_barrel",
786  "Jpsi invmass-PDGmass vs. Jpsi eta (barrel); #eta(J/#psi); Mass Shift [GeV/c^{2}]", 2, -0.8,
787  0.8);
788  TH1F* h_jpsi_invmass_vs_eta_ecc = new TH1F("Jpsi_invmass_vs_eta_ecc",
789  "Jpsi invmass-PDGmass vs. Jpsi eta (endcap C); #eta(J/#psi); Mass Shift [GeV/c^{2}]", 2, -2.4,
790  -0.8);
791  TH1F* h_jpsi_invmass_vs_eta_eca = new TH1F("Jpsi_invmass_vs_eta_eca",
792  "Jpsi invmass-PDGmass vs. Jpsi eta (endcap A); #eta(J/#psi); Mass Shift [GeV/c^{2}]", 2, 0.8,
793  2.4);
794  TH1F* h_jpsi_invmass_vs_etaplus = new TH1F("Jpsi_invmass_vs_etaplus",
795  "Jpsi invmass-PDGmass vs. Muon+ eta; #eta(#mu^{+}); Mass Shift [GeV/c^{2}]", 6, -2.4,
796  2.4);
797  TH1F* h_jpsi_invmass_vs_etaminus = new TH1F("Jpsi_invmass_vs_etaminus",
798  "Jpsi invmass-PDGmass vs. Muon- eta; #eta(#mu^{-}); Mass Shift [GeV/c^{2}]", 6, -2.4,
799  2.4);
800  TH1F* h_jpsi_invmass_vs_maxeta = new TH1F("Jpsi_invmass_vs_maxeta",
801  "Jpsi invmass-PDGmass vs. max Muon |eta|; max|#eta(#mu)|; Mass Shift [GeV/c^{2}]", 6, -2.4,
802  2.4);
803  TH1F* h_jpsi_invmass_vs_etadiff = new TH1F("Jpsi_invmass_vs_etadiff",
804  "Jpsi invmass-PDGmass vs. eta(+)-eta(-); #eta(#mu^{+})-#eta(#mu^{-}); Mass Shift [GeV/c^{2}]", 6, -0.5,
805  0.5);
806  TH1F* h_jpsi_invmass_vs_sumeta = new TH1F("Jpsi_invmass_vs_sumeta",
807  "Jpsi invmass-PDGmass vs. eta(+)+eta(-); #eta(#mu^{+})+#eta(#mu^{-});Mass Shift [GeV/c^{2}]", 6, -4.8,
808  4.8);
809  TH1F* h_jpsi_invmass_vs_sumabseta = new TH1F("Jpsi_invmass_vs_sumabseta",
810  "Jpsi invmass-PDGmass vs. |eta(+)|+|eta(-)|;|#eta(#mu^{+})|+|#eta(#mu^{-})|;Mass Shift [GeV/c^{2}]", 6, 0.,
811  4.8);
812  TH1F* h_jpsi_invmass_vs_crt = new TH1F("Jpsi_invmass_vs_curvature",
813  "Jpsi invmass-PDGmass vs. crt(+)-|crt(-)|; 1/p_{T}(#mu^{+})-1/p_{T}(#mu^{-}) [GeV^{-1}]; Mass Shift [GeV/c^{2}]", 6, -0.15,
814  0.15);
815  TH1F* h_jpsi_invmass_vs_invpt = new TH1F("Jpsi_invmass_vs_invpt",
816  "Jpsi invmass-PDGmass vs. muon 1/Pt; 1/p_{T}(#mu) [(GeV/c)^{-1}]; Mass Shift [GeV/c^{2}]", 6, 0.05,
817  0.25);
818  TH1F* h_jpsi_invmass_vs_angle_eta = new TH1F("Jpsi_invmass_vs_angle_eta",
819  "Jpsi invmass-PDGmass vs. arccos(#Delta#eta/#DeltaR);arccos(#Delta#eta/#DeltaR); Mass Shift [GeV/c^{2}]", 6, 0.,
820  90.);
821 
822  TH1F* h_jpsi_width_vs_pt = new TH1F("Jpsi_width_vs_pt",
823  "Jpsi width vs. Jpsi Pt; p_{T}(J/#psi) [GeV/c]; Width [GeV/c^{2}]", 6, 10.,
824  20.);
825  TH1F* h_jpsi_width_vs_z0 = new TH1F("Jpsi_width_vs_z0", "Jpsi width vs. muon z0; z0(#mu) [mm]; Width [GeV/c^{2}]",
826  6, -100., 100.);
827  TH1F* h_jpsi_width_vs_phi = new TH1F("Jpsi_width_vs_phi",
828  "Jpsi width vs. Jpsi phi; #phi(J/#psi) [rad]; Width [GeV/c^{2}]", 6, -3.15,
829  3.15);
830  TH1F* h_jpsi_width_vs_phiplus = new TH1F("Jpsi_width_vs_phiplus",
831  "Jpsi width vs. Muon+ phi; #phi(#mu^{+}) [rad]; Width [GeV/c^{2}]", 6,
832  -3.15, 3.15);
833  TH1F* h_jpsi_width_vs_phiminus = new TH1F("Jpsi_width_vs_phiminus",
834  "Jpsi width vs. Muon- phi; #phi(#mu^{-}) [rad]; Width [GeV/c^{2}]", 6,
835  -3.15, 3.15);
836  TH1F* h_jpsi_width_vs_phidiff = new TH1F("Jpsi_width_vs_phidiff",
837  "Jpsi width vs. |phi(+)-phi(-)|; |#phi(#mu^{+})-#phi(#mu^{-})| [rad]; Width [GeV/c^{2}]", 6, 0.,
838  0.4);
839  TH1F* h_jpsi_width_vs_phisum = new TH1F("Jpsi_width_vs_phisum",
840  "Jpsi width vs. phi(+)+phi(-);#phi(#mu^{+})+#phi(#mu^{-}) [rad];Width [GeV/c^{2}]", 6, -3.15,
841  3.15);
842  TH1F* h_jpsi_width_vs_eta = new TH1F("Jpsi_width_vs_eta", "Jpsi width vs. Jpsi eta; #eta(J/#psi); Width[GeV/c^{2}]",
843  6, -2.4, 2.4);
844  TH1F* h_jpsi_width_vs_eta_barrel = new TH1F("Jpsi_width_vs_eta_barrel",
845  "Jpsi width vs. Jpsi eta (barrel); #eta(J/#psi); Width [GeV/c^{2}]", 2,
846  -0.8, 0.8);
847  TH1F* h_jpsi_width_vs_eta_ecc = new TH1F("Jpsi_width_vs_eta_ecc",
848  "Jpsi width vs. Jpsi eta (endcap C); #eta(J/#psi); Width [GeV/c^{2}]", 2,
849  -2.4, -0.8);
850  TH1F* h_jpsi_width_vs_eta_eca = new TH1F("Jpsi_width_vs_eta_eca",
851  "Jpsi width vs. Jpsi eta (endcap A); #eta(J/#psi); Width [GeV/c^{2}]", 2,
852  0.8, 2.4);
853  TH1F* h_jpsi_width_vs_etaplus = new TH1F("Jpsi_width_vs_etaplus",
854  "Jpsi width vs. Muon+ eta; #eta(#mu^{+}); Width [GeV/c^{2}]", 6, -2.4,
855  2.4);
856  TH1F* h_jpsi_width_vs_etaminus = new TH1F("Jpsi_width_vs_etaminus",
857  "Jpsi width vs. Muon- eta; #eta(#mu^{-}); Width [GeV/c^{2}]", 6, -2.4,
858  2.4);
859  TH1F* h_jpsi_width_vs_maxeta = new TH1F("Jpsi_width_vs_maxeta",
860  "Jpsi width vs. max Muon |eta|; max|#eta(#mu)|; Width[GeV/c^{2}]", 6, -2.4,
861  2.4);
862  TH1F* h_jpsi_width_vs_etadiff = new TH1F("Jpsi_width_vs_etadiff",
863  "Jpsi width vs. eta(+)-eta(-); #eta(#mu^{+})-#eta(#mu^{-}); Width [GeV/c^{2}]", 6, -0.5,
864  0.5);
865  TH1F* h_jpsi_width_vs_sumeta = new TH1F("Jpsi_width_vs_sumeta",
866  "Jpsi width vs. eta(+)+eta(-); #eta(#mu^{+})+#eta(#mu^{-});Width [GeV/c^{2}]", 6, -4.8,
867  4.8);
868  TH1F* h_jpsi_width_vs_sumabseta = new TH1F("Jpsi_width_vs_sumabseta",
869  "Jpsi width vs. |eta(+)|+|eta(-)|;|#eta(#mu^{+})|+|#eta(#mu^{-})|;Width [GeV/c^{2}]", 6, 0.,
870  4.8);
871  TH1F* h_jpsi_width_vs_crt = new TH1F("Jpsi_width_vs_curvature",
872  "Jpsi width vs. crt(+)-|crt(-)|; 1/p_{T}(#mu^{+})-1/p_{T}(#mu^{-}) [GeV^{-1}]; Width [GeV/c^{2}]", 6, -0.15,
873  0.15);
874  TH1F* h_jpsi_width_vs_invpt = new TH1F("Jpsi_width_vs_invpt",
875  "Jpsi width vs. muon 1/Pt; 1/p_{T}(#mu) [(GeV/c)^{-1}]; Width [GeV/c^{2}]",
876  6, 0.05, 0.25);
877  TH1F* h_jpsi_width_vs_angle_eta = new TH1F("Jpsi_width_vs_angle_eta",
878  "Jpsi width vs. arccos(#Delta#eta/#DeltaR);arccos(#Delta#eta/#DeltaR); Width [GeV/c^{2}]", 6, 0.,
879  90.);
880 
881  TH1F* h_eff_pt = new TH1F("eff_pt", "ID tracking efficiency vs p_{T} (tag-and-probe);p_{T} [GeV]", 9, 2., 20.);
882  TH1F* h_eff_eta = new TH1F("eff_eta", "ID tracking efficiency vs #eta (tag-and-probe);#eta", 10, -2.5, 2.5);
883  TH1F* h_eff_phi = new TH1F("eff_phi", "ID tracking efficiency vs #phi (tag-and-probe);#phi [rad]", 8, -3.15, 3.15);
884 
885  TH1F* h_chargeasym_vs_pt = new TH1F("chargeAsym_vs_pt",
886  "Charge asymmetry vs. p_{T};p_{T}(#mu) [GeV];#frac{N^{-}-N^{+}}{N^{-}+N^{+}}",
887  10, 0., 20.);
888 
889  const int nbins = 6;
890  TH1F* hpt[nbins];
891  TH1F* hz0[nbins];
892  TH1F* hphi[nbins];
893  TH1F* hphiplus[nbins];
894  TH1F* hphiminus[nbins];
895  TH1F* hphidiff[nbins];
896  TH1F* heta[nbins];
897  TH1F* heta_b[2];
898  TH1F* heta_ecc[2];
899  TH1F* heta_eca[2];
900  TH1F* hetadiff[nbins];
901  TH1F* hmaxeta[nbins];
902  TH1F* hinvpt[nbins];
903  TH1F* hcrt[nbins];
904  TH1F* hetaplus[nbins];
905  TH1F* hetaminus[nbins];
906  TH1F* hangle_eta[nbins];
907  TH1F* hsumphi[nbins];
908  TH1F* hsumeta[nbins];
909  TH1F* hsumabseta[nbins];
910 
911  if (!CheckHistogram(f, (path + "/Jpsi_invmass").c_str())) return;
912 
913  TH1F* h_mass = (TH1F*) (f->Get((path + "/Jpsi_invmass").c_str())->Clone());
914  if (CheckHistogram(f, (path + "/Nevents").c_str())) {
915  TH1F* h_Nevents = (TH1F*) f->Get((path + "/Nevents").c_str());
916  TH1F* h_rate = new TH1F("rate", "production rate", 1, 0, 1);
917  double Ntot = h_Nevents->GetEntries();
918  double yield = h_mass->Integral(h_mass->FindBin(2.95), h_mass->FindBin(3.25));
919  double rate = yield / Ntot;
920  double rate_error = sqrt(1 / yield + 1 / Ntot) * yield / Ntot;
921  h_rate->SetBinContent(1, rate);
922  h_rate->SetBinError(1, rate_error);
923  h_rate->Write("", TObject::kOverwrite);
924  }
925 // TH1F* h_mass_scaled = (TH1F*)(f->Get((path+"/Jpsi_invmass").c_str())->Clone("Jpsi_invmass_scaled_copy"));
926 // h_mass_scaled->SetMarkerStyle(21);
927 // TString title(h_mass_scaled->GetTitle());
928 // if (CheckHistogram(f,(path+"/Jpsi_invmass_scaled").c_str())) {
929 // if (CheckHistogram(f,(path+"/Nevents").c_str())) {
930 // TH1F* h_Nevents=(TH1F*)f->Get((path+"/Nevents").c_str());
931 // double Ntot =h_Nevents->GetEntries();
932 // if (Ntot!=0.) h_mass_scaled->Scale(1./Ntot);
933 // h_mass_scaled->SetTitle(title+" (per event)");
934 // h_mass_scaled->Write("Jpsi_invmass_scaled",TObject::kOverwrite);
935 // }
936 // }
937 // delete h_mass_scaled;
938  if (CheckHistogram(f, (path + "/Jpsi_invmass").c_str())) {
939  TH1F* h_mass_rebin = (TH1F*) (f->Get((path + "/Jpsi_invmass").c_str())->Clone("Jpsi_invmass_rebin"));
940  TString title = h_mass_rebin->GetTitle();
941  h_mass_rebin->SetMarkerStyle(21);
942  h_mass_rebin->Rebin(2);
943  h_mass_rebin->SetTitle(title + " (larger binning for low Stats.)");
944  h_mass_rebin->Write("Jpsi_invmass_rebin", TObject::kOverwrite);
945  }
946 
947  if (!CheckHistogram(f, (path + "/probe_all_pt").c_str())) return;
948 
949  TH1F* h_probe_all_pt = (TH1F*) (f->Get((path + "/probe_all_pt").c_str())->Clone());
950  if (!CheckHistogram(f, (path + "/probe_match_pt").c_str())) return;
951 
952  TH1F* h_probe_match_pt = (TH1F*) (f->Get((path + "/probe_match_pt").c_str())->Clone());
953  if (!CheckHistogram(f, (path + "/probe_all_eta").c_str())) return;
954 
955  TH1F* h_probe_all_eta = (TH1F*) (f->Get((path + "/probe_all_eta").c_str())->Clone());
956  if (!CheckHistogram(f, (path + "/probe_match_eta").c_str())) return;
957 
958  TH1F* h_probe_match_eta = (TH1F*) (f->Get((path + "/probe_match_eta").c_str())->Clone());
959  if (!CheckHistogram(f, (path + "/probe_all_phi").c_str())) return;
960 
961  TH1F* h_probe_all_phi = (TH1F*) (f->Get((path + "/probe_all_phi").c_str())->Clone());
962  if (!CheckHistogram(f, (path + "/probe_match_phi").c_str())) return;
963 
964  TH1F* h_probe_match_phi = (TH1F*) (f->Get((path + "/probe_match_phi").c_str())->Clone());
965  if (!CheckHistogram(f, (path + "/Muonplus_pt").c_str())) return;
966 
967  TH1F* h_ptplus = (TH1F*) (f->Get((path + "/Muonplus_pt").c_str())->Clone());
968  if (!CheckHistogram(f, (path + "/Muonminus_pt").c_str())) return;
969 
970  TH1F* h_ptminus = (TH1F*) (f->Get((path + "/Muonminus_pt").c_str())->Clone());
971 
972  char cpt[100], cz0[100], cphi[100], cphidiff[100], ceta[100], cetadiff[100], cmaxeta[100], ccrt[100], cinvpt[100],
973  cphiplus[100], cphiminus[100], cetaplus[100], cetaminus[100], ceta_b[100], ceta_ecc[100], ceta_eca[100],
974  cangle_eta[100], csumeta[100], csumabseta[100], csumphi[100];
975  for (int i = 0; i < nbins; i++) {
976  sprintf(cpt, (path + "/pt_bin%d").c_str(), i);
977  sprintf(cz0, (path + "/z0_bin%d").c_str(), i);
978  sprintf(cphi, (path + "/phi_bin%d").c_str(), i);
979  sprintf(cphiplus, (path + "/phiplus_bin%d").c_str(), i);
980  sprintf(cphiminus, (path + "/phiminus_bin%d").c_str(), i);
981  sprintf(cphidiff, (path + "/phidiff_bin%d").c_str(), i);
982  sprintf(ceta, (path + "/eta_bin%d").c_str(), i);
983  sprintf(cetaplus, (path + "/etaplus_bin%d").c_str(), i);
984  sprintf(cetaminus, (path + "/etaminus_bin%d").c_str(), i);
985  sprintf(cmaxeta, (path + "/maxeta_bin%d").c_str(), i);
986  sprintf(cetadiff, (path + "/etadiff_bin%d").c_str(), i);
987  sprintf(ccrt, (path + "/crt_bin%d").c_str(), i);
988  sprintf(cinvpt, (path + "/invpt_bin%d").c_str(), i);
989  sprintf(cangle_eta, (path + "/angle_eta_bin%d").c_str(), i);
990  sprintf(csumphi, (path + "/phi_sum%d").c_str(), i);
991  sprintf(csumeta, (path + "/eta_sum%d").c_str(), i);
992  sprintf(csumabseta, (path + "/eta_AbsSum%d").c_str(), i);
993 
994  if (!CheckHistogram(f, cpt)) return;
995 
996  if (!CheckHistogram(f, cz0)) return;
997 
998  if (!CheckHistogram(f, cphi)) return;
999 
1000  if (!CheckHistogram(f, cphiplus)) return;
1001 
1002  if (!CheckHistogram(f, cphiminus)) return;
1003 
1004  if (!CheckHistogram(f, cphidiff)) return;
1005 
1006  if (!CheckHistogram(f, ceta)) return;
1007 
1008  if (!CheckHistogram(f, cetaplus)) return;
1009 
1010  if (!CheckHistogram(f, cetaminus)) return;
1011 
1012  if (!CheckHistogram(f, cmaxeta)) return;
1013 
1014  if (!CheckHistogram(f, cetadiff)) return;
1015 
1016  if (!CheckHistogram(f, ccrt)) return;
1017 
1018  if (!CheckHistogram(f, cinvpt)) return;
1019 
1020  if (!CheckHistogram(f, cangle_eta)) return;
1021 
1022  if (!CheckHistogram(f, csumphi)) return;
1023 
1024  if (!CheckHistogram(f, csumeta)) return;
1025 
1026  if (!CheckHistogram(f, csumabseta)) return;
1027 
1028  hpt[i] = (TH1F*) (f->Get(cpt)->Clone());
1029  hz0[i] = (TH1F*) (f->Get(cz0)->Clone());
1030  hphi[i] = (TH1F*) (f->Get(cphi)->Clone());
1031  hphiplus[i] = (TH1F*) (f->Get(cphiplus)->Clone());
1032  hphiminus[i] = (TH1F*) (f->Get(cphiminus)->Clone());
1033  hphidiff[i] = (TH1F*) (f->Get(cphidiff)->Clone());
1034  heta[i] = (TH1F*) (f->Get(ceta)->Clone());
1035  hetaplus[i] = (TH1F*) (f->Get(cetaplus)->Clone());
1036  hetaminus[i] = (TH1F*) (f->Get(cetaminus)->Clone());
1037  hetadiff[i] = (TH1F*) (f->Get(cetadiff)->Clone());
1038  hmaxeta[i] = (TH1F*) (f->Get(cmaxeta)->Clone());
1039  hcrt[i] = (TH1F*) (f->Get(ccrt)->Clone());
1040  hinvpt[i] = (TH1F*) (f->Get(cinvpt)->Clone());
1041  hangle_eta[i] = (TH1F*) (f->Get(cangle_eta)->Clone());
1042  hsumphi[i] = (TH1F*) (f->Get(csumphi)->Clone());
1043  hsumeta[i] = (TH1F*) (f->Get(csumeta)->Clone());
1044  hsumabseta[i] = (TH1F*) (f->Get(csumabseta)->Clone());
1045 
1046  if (i < 2) {
1047  sprintf(ceta_b, (path + "/eta_b_bin%d").c_str(), i);
1048  sprintf(ceta_eca, (path + "/eta_eca_bin%d").c_str(), i);
1049  sprintf(ceta_ecc, (path + "/eta_ecc_bin%d").c_str(), i);
1050  if (!CheckHistogram(f, ceta_b)) return;
1051 
1052  if (!CheckHistogram(f, ceta_eca)) return;
1053 
1054  if (!CheckHistogram(f, ceta_ecc)) return;
1055 
1056  heta_b[i] = (TH1F*) (f->Get(ceta_b)->Clone());
1057  heta_ecc[i] = (TH1F*) (f->Get(ceta_ecc)->Clone());
1058  heta_eca[i] = (TH1F*) (f->Get(ceta_eca)->Clone());
1059  }
1060  }
1061  h_mass->SetMarkerStyle(21);
1062 
1063  TCanvas* myCanvas = new TCanvas("MyCanvas");
1064  myCanvas->cd();
1065 
1066 // h_mass->Fit(f1,"RQMN");
1067 
1068  fitJpsiHistograms(h_jpsi_invmass_vs_pt, h_jpsi_width_vs_pt, hpt, nbins);
1069  fitJpsiHistograms(h_jpsi_invmass_vs_z0, h_jpsi_width_vs_z0, hz0, nbins);
1070  fitJpsiHistograms(h_jpsi_invmass_vs_phi, h_jpsi_width_vs_phi, hphi, nbins);
1071  fitJpsiHistograms(h_jpsi_invmass_vs_phiplus, h_jpsi_width_vs_phiplus, hphiplus, nbins);
1072  fitJpsiHistograms(h_jpsi_invmass_vs_phiminus, h_jpsi_width_vs_phiminus, hphiminus, nbins);
1073  fitJpsiHistograms(h_jpsi_invmass_vs_phidiff, h_jpsi_width_vs_phidiff, hphidiff, nbins);
1074  fitJpsiHistograms(h_jpsi_invmass_vs_eta, h_jpsi_width_vs_eta, heta, nbins);
1075  fitJpsiHistograms(h_jpsi_invmass_vs_etaplus, h_jpsi_width_vs_etaplus, hetaplus, nbins);
1076  fitJpsiHistograms(h_jpsi_invmass_vs_etaminus, h_jpsi_width_vs_etaminus, hetaminus, nbins);
1077  fitJpsiHistograms(h_jpsi_invmass_vs_maxeta, h_jpsi_width_vs_maxeta, hmaxeta, nbins);
1078  fitJpsiHistograms(h_jpsi_invmass_vs_etadiff, h_jpsi_width_vs_etadiff, hetadiff, nbins);
1079  fitJpsiHistograms(h_jpsi_invmass_vs_crt, h_jpsi_width_vs_crt, hcrt, nbins);
1080  fitJpsiHistograms(h_jpsi_invmass_vs_invpt, h_jpsi_width_vs_invpt, hinvpt, nbins);
1081  fitJpsiHistograms(h_jpsi_invmass_vs_eta_barrel, h_jpsi_width_vs_eta_barrel, heta_b, 2);
1082  fitJpsiHistograms(h_jpsi_invmass_vs_eta_eca, h_jpsi_width_vs_eta_eca, heta_eca, 2);
1083  fitJpsiHistograms(h_jpsi_invmass_vs_eta_ecc, h_jpsi_width_vs_eta_ecc, heta_ecc, 2);
1084  fitJpsiHistograms(h_jpsi_invmass_vs_angle_eta, h_jpsi_width_vs_angle_eta, hangle_eta, nbins);
1085  fitJpsiHistograms(h_jpsi_invmass_vs_phisum, h_jpsi_width_vs_phisum, hsumphi, nbins);
1086  fitJpsiHistograms(h_jpsi_invmass_vs_sumeta, h_jpsi_width_vs_sumeta, hsumeta, nbins);
1087  fitJpsiHistograms(h_jpsi_invmass_vs_sumabseta, h_jpsi_width_vs_sumabseta, hsumabseta, nbins);
1088  if (h_eff_pt->GetNbinsX() == h_probe_match_pt->GetNbinsX()) {
1089  h_eff_pt->SetMarkerStyle(21);
1090  h_eff_eta->SetMarkerStyle(21);
1091  h_eff_phi->SetMarkerStyle(21);
1092  h_eff_pt->Divide(h_probe_match_pt, h_probe_all_pt, 1, 1, "B");
1093  h_eff_eta->Divide(h_probe_match_eta, h_probe_all_eta, 1, 1, "B");
1094  h_eff_phi->Divide(h_probe_match_phi, h_probe_all_phi, 1, 1, "B");
1095  }
1096  ProcessAsymHistograms(h_ptminus, h_ptplus, h_chargeasym_vs_pt);
1097  h_chargeasym_vs_pt->Write("", TObject::kOverwrite);
1098 
1099  // f->cd(path.c_str());
1100  if (f->cd(path.c_str()) == 0) {
1101  //std::cerr<< "MonitoringFile::fitMergedFile_IDPerfMonJpsi(): "
1102  //<<"No such directory \""<< path << "\"\n";
1103  return;
1104  }
1105 
1106  h_mass->Write("", TObject::kOverwrite);
1107  for (int i = 0; i < nbins; i++) {
1108  hpt[i]->Write("", TObject::kOverwrite);
1109  hz0[i]->Write("", TObject::kOverwrite);
1110  hphi[i]->Write("", TObject::kOverwrite);
1111  hphiplus[i]->Write("", TObject::kOverwrite);
1112  hphiminus[i]->Write("", TObject::kOverwrite);
1113  hphidiff[i]->Write("", TObject::kOverwrite);
1114  heta[i]->Write("", TObject::kOverwrite);
1115  hetadiff[i]->Write("", TObject::kOverwrite);
1116  hmaxeta[i]->Write("", TObject::kOverwrite);
1117  hinvpt[i]->Write("", TObject::kOverwrite);
1118  hcrt[i]->Write("", TObject::kOverwrite);
1119  hetaplus[i]->Write("", TObject::kOverwrite);
1120  hetaminus[i]->Write("", TObject::kOverwrite);
1121  hangle_eta[i]->Write("", TObject::kOverwrite);
1122  hsumphi[i]->Write("", TObject::kOverwrite);
1123  hsumeta[i]->Write("", TObject::kOverwrite);
1124  hsumabseta[i]->Write("", TObject::kOverwrite);
1125  if (i < 2) {
1126  heta_b[i]->Write("", TObject::kOverwrite);
1127  heta_ecc[i]->Write("", TObject::kOverwrite);
1128  heta_eca[i]->Write("", TObject::kOverwrite);
1129  }
1130  }
1131 
1132  h_jpsi_invmass_vs_pt->Write("", TObject::kOverwrite);
1133  h_jpsi_invmass_vs_z0->Write("", TObject::kOverwrite);
1134  h_jpsi_invmass_vs_phi->Write("", TObject::kOverwrite);
1135  h_jpsi_invmass_vs_phiplus->Write("", TObject::kOverwrite);
1136  h_jpsi_invmass_vs_phiminus->Write("", TObject::kOverwrite);
1137  h_jpsi_invmass_vs_phidiff->Write("", TObject::kOverwrite);
1138  h_jpsi_invmass_vs_eta->Write("", TObject::kOverwrite);
1139  h_jpsi_invmass_vs_eta_barrel->Write("", TObject::kOverwrite);
1140  h_jpsi_invmass_vs_eta_ecc->Write("", TObject::kOverwrite);
1141  h_jpsi_invmass_vs_eta_eca->Write("", TObject::kOverwrite);
1142  h_jpsi_invmass_vs_etadiff->Write("", TObject::kOverwrite);
1143  h_jpsi_invmass_vs_etaplus->Write("", TObject::kOverwrite);
1144  h_jpsi_invmass_vs_etaminus->Write("", TObject::kOverwrite);
1145  h_jpsi_invmass_vs_maxeta->Write("", TObject::kOverwrite);
1146  h_jpsi_invmass_vs_crt->Write("", TObject::kOverwrite);
1147  h_jpsi_invmass_vs_invpt->Write("", TObject::kOverwrite);
1148  h_jpsi_invmass_vs_angle_eta->Write("", TObject::kOverwrite);
1149  h_jpsi_invmass_vs_phisum->Write("", TObject::kOverwrite);
1150  h_jpsi_invmass_vs_sumeta->Write("", TObject::kOverwrite);
1151  h_jpsi_invmass_vs_sumabseta->Write("", TObject::kOverwrite);
1152 
1153  h_jpsi_width_vs_pt->Write("", TObject::kOverwrite);
1154  h_jpsi_width_vs_z0->Write("", TObject::kOverwrite);
1155  h_jpsi_width_vs_phi->Write("", TObject::kOverwrite);
1156  h_jpsi_width_vs_phiplus->Write("", TObject::kOverwrite);
1157  h_jpsi_width_vs_phiminus->Write("", TObject::kOverwrite);
1158  h_jpsi_width_vs_phidiff->Write("", TObject::kOverwrite);
1159  h_jpsi_width_vs_eta->Write("", TObject::kOverwrite);
1160  h_jpsi_width_vs_eta_barrel->Write("", TObject::kOverwrite);
1161  h_jpsi_width_vs_eta_ecc->Write("", TObject::kOverwrite);
1162  h_jpsi_width_vs_eta_eca->Write("", TObject::kOverwrite);
1163  h_jpsi_width_vs_etadiff->Write("", TObject::kOverwrite);
1164  h_jpsi_width_vs_etaplus->Write("", TObject::kOverwrite);
1165  h_jpsi_width_vs_etaminus->Write("", TObject::kOverwrite);
1166  h_jpsi_width_vs_maxeta->Write("", TObject::kOverwrite);
1167  h_jpsi_width_vs_crt->Write("", TObject::kOverwrite);
1168  h_jpsi_width_vs_invpt->Write("", TObject::kOverwrite);
1169  h_jpsi_width_vs_angle_eta->Write("", TObject::kOverwrite);
1170  h_jpsi_width_vs_phisum->Write("", TObject::kOverwrite);
1171  h_jpsi_width_vs_sumeta->Write("", TObject::kOverwrite);
1172  h_jpsi_width_vs_sumabseta->Write("", TObject::kOverwrite);
1173 
1174  h_eff_pt->Write("", TObject::kOverwrite);
1175  h_eff_eta->Write("", TObject::kOverwrite);
1176  h_eff_phi->Write("", TObject::kOverwrite);
1177 
1178 
1179 
1180  myCanvas->Close();
1181  delete myCanvas;
1182 
1183  f->Write();
1184 
1185 // delete f1;
1186  }
1187 
1188 //Upsilon
1189  void
1191  fitMergedFile_IDPerfMonUpsilon(TFile* f, const std::string& run_dir, const std::string& TriggerName) {
1192  std::string path;
1193  path = run_dir + "IDPerfMon/Upsilon/" + TriggerName;
1194 
1195  if (f->cd(path.c_str()) == 0) {
1196  //std::cerr<< "MonitoringFile::fitMergedFile_IDPerfMonUpsilon(): "
1197  //<<"No such directory \""<< path << "\"\n";
1198  return;
1199  }
1200 
1201  TH1F* h_upsilon_invmass_vs_pt = new TH1F("Upsilon_invmass_vs_pt",
1202  "Upsilon invmass-PDGmass vs. Upsilon Pt; p_{T}(#Upsilon) [GeV/c]; Mass Shift [GeV/c^{2}]", 6, 4.,
1203  20.);
1204  TH1F* h_upsilon_invmass_vs_z0 = new TH1F("Upsilon_invmass_vs_z0",
1205  "Upsilon invmass-PDGmass vs. muon z0; z0(#mu) [mm]; Mass Shift [GeV/c^{2}]", 6, -100.,
1206  100.);
1207  TH1F* h_upsilon_invmass_vs_phi = new TH1F("Upsilon_invmass_vs_phi",
1208  "Upsilon invmass-PDGmass vs. Upsilon phi; #phi(#Upsilon) [rad]; Mass Shift [GeV/c^{2}]", 6, -3.15,
1209  3.15);
1210  TH1F* h_upsilon_invmass_vs_phiplus = new TH1F("Upsilon_invmass_vs_phiplus",
1211  "Upsilon invmass-PDGmass vs. Muon+ phi; #phi(#mu^{+}) [rad]; Mass Shift [GeV/c^{2}]", 6, -3.15,
1212  3.15);
1213  TH1F* h_upsilon_invmass_vs_phiminus = new TH1F("Upsilon_invmass_vs_phiminus",
1214  "Upsilon invmass-PDGmass vs. Muon- phi; #phi(#mu^{-}) [rad]; Mass Shift [GeV/c^{2}]", 6, -3.15,
1215  3.15);
1216  TH1F* h_upsilon_invmass_vs_phidiff = new TH1F("Upsilon_invmass_vs_phidiff",
1217  "Upsilon invmass-PDGmass vs. |phi(+)-phi(-)|; |#phi(#mu^{+})-#phi(#mu^{-})| [rad]; Mass Shift [GeV/c^{2}]", 6, 0.,
1218  2.5);
1219  TH1F* h_upsilon_invmass_vs_eta = new TH1F("Upsilon_invmass_vs_eta",
1220  "Upsilon invmass-PDGmass vs. Upsilon eta; #eta(#Upsilon); Mass Shift [GeV/c^{2}]", 8, -3.2,
1221  3.2);
1222  TH1F* h_upsilon_invmass_vs_eta_barrel = new TH1F("Upsilon_invmass_vs_eta_barrel",
1223  "Upsilon invmass-PDGmass vs. Upsilon eta (barrel); #eta(#Upsilon); Mass Shift [GeV/c^{2}]", 2, -0.8,
1224  0.8);
1225  TH1F* h_upsilon_invmass_vs_eta_eca = new TH1F("Upsilon_invmass_vs_eta_eca",
1226  "Upsilon invmass-PDGmass vs. Upsilon eta (endcap A); #eta(#Upsilon); Mass Shift [GeV/c^{2}]", 3, 0.8,
1227  3.2);
1228  TH1F* h_upsilon_invmass_vs_eta_ecc = new TH1F("Upsilon_invmass_vs_eta_ecc",
1229  "Upsilon invmass-PDGmass vs. Upsilon eta (endcap C); #eta(#Upsilon); Mass Shift [GeV/c^{2}]", 3, -3.2,
1230  -0.8);
1231  TH1F* h_upsilon_invmass_vs_etaplus = new TH1F("Upsilon_invmass_vs_etaplus",
1232  "Upsilon invmass-PDGmass vs. Muon+ eta; #eta(#mu^{+}); Mass Shift [GeV/c^{2}]", 6, -2.4,
1233  2.4);
1234  TH1F* h_upsilon_invmass_vs_etaminus = new TH1F("Upsilon_invmass_vs_etaminus",
1235  "Upsilon invmass-PDGmass vs. Muon- eta; #eta(#mu^{-}); Mass Shift [GeV/c^{2}]", 6, -2.4,
1236  2.4);
1237  TH1F* h_upsilon_invmass_vs_maxeta = new TH1F("Upsilon_invmass_vs_maxeta",
1238  "Upsilon invmass-PDGmass vs. max Muon |eta|; max|#eta(#mu)|; Mass Shift [GeV/c^{2}]", 6, -2.4,
1239  2.4);
1240  TH1F* h_upsilon_invmass_vs_etadiff = new TH1F("Upsilon_invmass_vs_etadiff",
1241  "Upsilon invmass-PDGmass vs. eta(+)-eta(-); #eta(#mu^{+})-#eta(#mu^{-}); Mass Shift [GeV/c^{2}]", 6, -1.5,
1242  1.5);
1243  TH1F* h_upsilon_invmass_vs_crt = new TH1F("Upsilon_invmass_vs_curvature",
1244  "Upsilon invmass-PDGmass vs. crt(+)-|crt(-)|; 1/p_{T}(#mu^{+})-1/p_{T}(#mu^{-}) [GeV^{-1}]; Mass Shift [GeV/c^{2}]", 6, -0.15,
1245  0.15);
1246  TH1F* h_upsilon_invmass_vs_invpt = new TH1F("Upsilon_invmass_vs_invpt",
1247  "Upsilon invmass-PDGmass vs. muon 1/Pt; 1/p_{T}(#mu) [(GeV/c)^{-1}]; Mass Shift [GeV/c^{2}]", 6, 0.05,
1248  0.25);
1249  TH1F* h_upsilon_invmass_vs_angle_eta = new TH1F("Upsilon_invmass_vs_angle_eta",
1250  "Upsilon invmass-PDGmass vs. arccos(#Delta#eta/#DeltaR);arccos(#Delta#eta/#DeltaR); Mass Shift [GeV/c^{2}]", 6, 0.,
1251  90.);
1252 
1253  TH1F* h_upsilon_width_vs_pt = new TH1F("Upsilon_width_vs_pt",
1254  "Upsilon width vs. Upsilon Pt; p_{T}(#Upsilon) [GeV/c]; Width [GeV/c^{2}]",
1255  6, 4., 20.);
1256  TH1F* h_upsilon_width_vs_z0 = new TH1F("Upsilon_width_vs_z0",
1257  "Upsilon width vs. muon z0; z0(#mu) [mm]; Width [GeV/c^{2}]", 6, -100.,
1258  100.);
1259  TH1F* h_upsilon_width_vs_phi = new TH1F("Upsilon_width_vs_phi",
1260  "Upsilon width vs. Upsilon phi; #phi(#Upsilon) [rad]; Width [GeV/c^{2}]", 6,
1261  -3.15, 3.15);
1262  TH1F* h_upsilon_width_vs_phiplus = new TH1F("Upsilon_width_vs_phiplus",
1263  "Upsilon width vs. Muon+ phi; #phi(#mu^{+}) [rad]; Width [GeV/c^{2}]",
1264  6, -3.15, 3.15);
1265  TH1F* h_upsilon_width_vs_phiminus = new TH1F("Upsilon_width_vs_phiminus",
1266  "Upsilon width vs. Muon- phi; #phi(#mu^{-}) [rad]; Width [GeV/c^{2}]",
1267  6, -3.15, 3.15);
1268  TH1F* h_upsilon_width_vs_phidiff = new TH1F("Upsilon_width_vs_phidiff",
1269  "Upsilon width vs. |phi(+)-phi(-)|; |#phi(#mu^{+})-#phi(#mu^{-})| [rad]; Width [GeV/c^{2}]", 6, 0.,
1270  2.5);
1271  TH1F* h_upsilon_width_vs_eta = new TH1F("Upsilon_width_vs_eta",
1272  "Upsilon width vs. Upsilon eta; #eta(#Upsilon); Width [GeV/c^{2}]", 8, -3.2,
1273  3.2);
1274  TH1F* h_upsilon_width_vs_eta_barrel = new TH1F("Upsilon_width_vs_eta_barrel",
1275  "Upsilon width vs. Upsilon eta (barrel); #eta(#Upsilon); Width [GeV/c^{2}]", 2, -0.8,
1276  0.8);
1277  TH1F* h_upsilon_width_vs_eta_eca = new TH1F("Upsilon_width_vs_eta_eca",
1278  "Upsilon width vs. Upsilon eta (endcap A); #eta(#Upsilon); Width [GeV/c^{2}]", 3, 0.8,
1279  3.2);
1280  TH1F* h_upsilon_width_vs_eta_ecc = new TH1F("Upsilon_width_vs_eta_ecc",
1281  "Upsilon width vs. Upsilon eta (endcap C); #eta(#Upsilon); Width [GeV/c^{2}]", 3, -3.2,
1282  -0.8);
1283  TH1F* h_upsilon_width_vs_etaplus = new TH1F("Upsilon_width_vs_etaplus",
1284  "Upsilon width vs. Muon+ eta; #eta(#mu^{+}); Width [GeV/c^{2}]", 6,
1285  -2.4, 2.4);
1286  TH1F* h_upsilon_width_vs_etaminus = new TH1F("Upsilon_width_vs_etaminus",
1287  "Upsilon width vs. Muon- eta; #eta(#mu^{-}); Width [GeV/c^{2}]", 6,
1288  -2.4, 2.4);
1289  TH1F* h_upsilon_width_vs_maxeta = new TH1F("Upsilon_width_vs_maxeta",
1290  "Upsilon width vs. max Muon |eta|; max|#eta(#mu)|; Width [GeV/c^{2}]", 6,
1291  -2.4, 2.4);
1292  TH1F* h_upsilon_width_vs_etadiff = new TH1F("Upsilon_width_vs_etadiff",
1293  "Upsilon width vs. eta(+)-eta(-); #eta(#mu^{+})-#eta(#mu^{-}); Width [GeV/c^{2}]", 6, -1.5,
1294  1.5);
1295  TH1F* h_upsilon_width_vs_crt = new TH1F("Upsilon_width_vs_curvature",
1296  "Upsilon width vs. crt(+)-|crt(-)|; 1/p_{T}(#mu^{+})-1/p_{T}(#mu^{-}) [GeV^{-1}]; Width [GeV/c^{2}]", 6, -0.15,
1297  0.15);
1298  TH1F* h_upsilon_width_vs_invpt = new TH1F("Upsilon_width_vs_invpt",
1299  "Upsilon width vs. muon 1/Pt; 1/p_{T}(#mu) [(GeV/c)^{-1}]; Width [GeV/c^{2}]", 6, 0.05,
1300  0.25);
1301  TH1F* h_upsilon_width_vs_angle_eta = new TH1F("Upsilon_width_vs_angle_eta",
1302  "Upsilon width vs. arccos(#Delta#eta/#DeltaR);arccos(#Delta#eta/#DeltaR); width [GeV/c^{2}]", 6, 0.,
1303  90.);
1304 
1305  const int nbins = 6;
1306  TH1F* hpt[nbins];
1307  TH1F* hz0[nbins];
1308  TH1F* hphi[nbins];
1309  TH1F* hphiplus[nbins];
1310  TH1F* hphiminus[nbins];
1311  TH1F* hphidiff[nbins];
1312  TH1F* heta[8];
1313  TH1F* heta_b[2];
1314  TH1F* heta_ecc[3];
1315  TH1F* heta_eca[3];
1316  TH1F* hetadiff[nbins];
1317  TH1F* hmaxeta[nbins];
1318  TH1F* hinvpt[nbins];
1319  TH1F* hcrt[nbins];
1320  TH1F* hetaplus[nbins];
1321  TH1F* hetaminus[nbins];
1322  TH1F* hangle_eta[nbins];
1323 
1324  if (!CheckHistogram(f, (path + "/Upsilon_invmass").c_str())) return;
1325 
1326  TH1F* h_mass = (TH1F*) (f->Get((path + "/Upsilon_invmass").c_str())->Clone());
1327  if (CheckHistogram(f, (path + "/Nevents").c_str())) {
1328  TH1F* h_Nevents = (TH1F*) f->Get((path + "/Nevents").c_str());
1329  TH1F* h_rate = new TH1F("rate", "production rate", 1, 0, 1);
1330  double Ntot = h_Nevents->GetEntries();
1331  double yield = h_mass->Integral(h_mass->FindBin(9.1), h_mass->FindBin(9.8));
1332  double rate = yield / Ntot;
1333  double rate_error = sqrt(1 / yield + 1 / Ntot) * yield / Ntot;
1334  h_rate->SetBinContent(1, rate);
1335  h_rate->SetBinError(1, rate_error);
1336  h_rate->Write("", TObject::kOverwrite);
1337  }
1338 // TH1F* h_mass_scaled = (TH1F*)(f->Get((path+"/Upsilon_invmass").c_str())->Clone("Upsilon_invmass_scaled_copy"));
1339 // h_mass_scaled->SetMarkerStyle(21);
1340 // TString title(h_mass_scaled->GetTitle());
1341 // if (CheckHistogram(f,(path+"/Upsilon_invmass_scaled").c_str())) {
1342 // if (CheckHistogram(f,(path+"/Nevents").c_str())) {
1343 // TH1F* h_Nevents=(TH1F*)f->Get((path+"/Nevents").c_str());
1344 // double Ntot =h_Nevents->GetEntries();
1345 // if (Ntot!=0.) h_mass_scaled->Scale(1./Ntot);
1346 // h_mass_scaled->SetTitle(title+" (per event)");
1347 // h_mass_scaled->Write("Upsilon_invmass_scaled",TObject::kOverwrite);
1348 // }
1349 // }
1350 // delete h_mass_scaled;
1351  if (CheckHistogram(f, (path + "/Upsilon_invmass").c_str())) {
1352  TH1F* h_mass_rebin = (TH1F*) (f->Get((path + "/Upsilon_invmass").c_str())->Clone("Upsilon_invmass_rebin"));
1353  TString title = h_mass_rebin->GetTitle();
1354  h_mass_rebin->SetMarkerStyle(21);
1355  h_mass_rebin->Rebin(8);
1356  h_mass_rebin->SetTitle(title + " (larger binning for low Stats.)");
1357  h_mass_rebin->Write("Upsilon_invmass_rebin", TObject::kOverwrite);
1358  }
1359 
1360  char cpt[100], cz0[100], cphi[100], cphidiff[100], ceta[100], cetadiff[100], cmaxeta[100], ccrt[100], cinvpt[100],
1361  cphiplus[100], cphiminus[100], cetaplus[100], cetaminus[100], ceta_b[100], ceta_ecc[100], ceta_eca[100],
1362  cangle_eta[100];
1363 
1364  for (int i = 0; i < nbins; i++) {
1365  sprintf(cpt, (path + "/pt_bin%d").c_str(), i);
1366  sprintf(cz0, (path + "/z0_bin%d").c_str(), i);
1367  sprintf(cphi, (path + "/phi_bin%d").c_str(), i);
1368  sprintf(cphiplus, (path + "/phiplus_bin%d").c_str(), i);
1369  sprintf(cphiminus, (path + "/phiminus_bin%d").c_str(), i);
1370  sprintf(cphidiff, (path + "/phidiff_bin%d").c_str(), i);
1371  sprintf(cetaplus, (path + "/etaplus_bin%d").c_str(), i);
1372  sprintf(cetaminus, (path + "/etaminus_bin%d").c_str(), i);
1373  sprintf(cmaxeta, (path + "/maxeta_bin%d").c_str(), i);
1374  sprintf(cetadiff, (path + "/etadiff_bin%d").c_str(), i);
1375  sprintf(ccrt, (path + "/crt_bin%d").c_str(), i);
1376  sprintf(cinvpt, (path + "/invpt_bin%d").c_str(), i);
1377  sprintf(cangle_eta, (path + "/angle_eta_bin%d").c_str(), i);
1378 
1379  if (!CheckHistogram(f, cpt)) return;
1380 
1381  if (!CheckHistogram(f, cz0)) return;
1382 
1383  if (!CheckHistogram(f, cphi)) return;
1384 
1385  if (!CheckHistogram(f, cphiplus)) return;
1386 
1387  if (!CheckHistogram(f, cphiminus)) return;
1388 
1389  if (!CheckHistogram(f, cphidiff)) return;
1390 
1391  if (!CheckHistogram(f, cetaplus)) return;
1392 
1393  if (!CheckHistogram(f, cetaminus)) return;
1394 
1395  if (!CheckHistogram(f, cmaxeta)) return;
1396 
1397  if (!CheckHistogram(f, cetadiff)) return;
1398 
1399  if (!CheckHistogram(f, ccrt)) return;
1400 
1401  if (!CheckHistogram(f, cinvpt)) return;
1402 
1403  if (!CheckHistogram(f, cangle_eta)) return;
1404 
1405  hpt[i] = (TH1F*) (f->Get(cpt)->Clone());
1406  hz0[i] = (TH1F*) (f->Get(cz0)->Clone());
1407  hphi[i] = (TH1F*) (f->Get(cphi)->Clone());
1408  hphiplus[i] = (TH1F*) (f->Get(cphiplus)->Clone());
1409  hphiminus[i] = (TH1F*) (f->Get(cphiminus)->Clone());
1410  hphidiff[i] = (TH1F*) (f->Get(cphidiff)->Clone());
1411  hetaplus[i] = (TH1F*) (f->Get(cetaplus)->Clone());
1412  hetaminus[i] = (TH1F*) (f->Get(cetaminus)->Clone());
1413  hetadiff[i] = (TH1F*) (f->Get(cetadiff)->Clone());
1414  hmaxeta[i] = (TH1F*) (f->Get(cmaxeta)->Clone());
1415  hcrt[i] = (TH1F*) (f->Get(ccrt)->Clone());
1416  hinvpt[i] = (TH1F*) (f->Get(cinvpt)->Clone());
1417  hangle_eta[i] = (TH1F*) (f->Get(cangle_eta)->Clone());
1418 
1419  if (i < 2) {
1420  sprintf(ceta_b, (path + "/eta_b_bin%d").c_str(), i);
1421  if (!CheckHistogram(f, ceta_b)) return;
1422 
1423  heta_b[i] = (TH1F*) (f->Get(ceta_b)->Clone());
1424  }
1425  if (i < 3) {
1426  sprintf(ceta_ecc, (path + "/eta_ecc_bin%d").c_str(), i);
1427  sprintf(ceta_eca, (path + "/eta_eca_bin%d").c_str(), i);
1428  if (!CheckHistogram(f, ceta_ecc)) return;
1429 
1430  if (!CheckHistogram(f, ceta_eca)) return;
1431 
1432  heta_ecc[i] = (TH1F*) (f->Get(ceta_ecc)->Clone());
1433  heta_eca[i] = (TH1F*) (f->Get(ceta_eca)->Clone());
1434  }
1435  }
1436  for (int i = 0; i < 8; i++) {
1437  sprintf(ceta, (path + "/eta_bin%d").c_str(), i);
1438  if (!CheckHistogram(f, ceta)) return;
1439 
1440  heta[i] = (TH1F*) (f->Get(ceta)->Clone());
1441  }
1442 
1443 // TF1 *f1 = new TF1("f1","gaus",9.,10.);
1444 // f1->SetParameter(1,9.046);
1445 // f1->SetParameter(2,0.15);
1446 // f1->SetLineColor(2);
1447 // f1->SetParNames("Constant","Mean","Width");
1448  h_mass->SetMarkerStyle(21);
1449 
1450  TCanvas* myCanvas = new TCanvas("MyCanvas");
1451  myCanvas->cd();
1452 
1453 // h_mass->Fit(f1,"RQMN");
1454 
1455 
1456  fitUpsilonHistograms(h_upsilon_invmass_vs_pt, h_upsilon_width_vs_pt, hpt, nbins);
1457  fitUpsilonHistograms(h_upsilon_invmass_vs_z0, h_upsilon_width_vs_z0, hz0, nbins);
1458  fitUpsilonHistograms(h_upsilon_invmass_vs_phi, h_upsilon_width_vs_phi, hphi, nbins);
1459  fitUpsilonHistograms(h_upsilon_invmass_vs_phiplus, h_upsilon_width_vs_phiplus, hphiplus, nbins);
1460  fitUpsilonHistograms(h_upsilon_invmass_vs_phiminus, h_upsilon_width_vs_phiminus, hphiminus, nbins);
1461  fitUpsilonHistograms(h_upsilon_invmass_vs_phidiff, h_upsilon_width_vs_phidiff, hphidiff, nbins);
1462  fitUpsilonHistograms(h_upsilon_invmass_vs_eta, h_upsilon_width_vs_eta, heta, 8);
1463  fitUpsilonHistograms(h_upsilon_invmass_vs_eta_barrel, h_upsilon_width_vs_eta_barrel, heta_b, 2);
1464  fitUpsilonHistograms(h_upsilon_invmass_vs_eta_eca, h_upsilon_width_vs_eta_eca, heta_eca, 3);
1465  fitUpsilonHistograms(h_upsilon_invmass_vs_eta_ecc, h_upsilon_width_vs_eta_ecc, heta_ecc, 3);
1466  fitUpsilonHistograms(h_upsilon_invmass_vs_etaplus, h_upsilon_width_vs_etaplus, hetaplus, nbins);
1467  fitUpsilonHistograms(h_upsilon_invmass_vs_etaminus, h_upsilon_width_vs_etaminus, hetaminus, nbins);
1468  fitUpsilonHistograms(h_upsilon_invmass_vs_maxeta, h_upsilon_width_vs_maxeta, hmaxeta, nbins);
1469  fitUpsilonHistograms(h_upsilon_invmass_vs_etadiff, h_upsilon_width_vs_etadiff, hetadiff, nbins);
1470  fitUpsilonHistograms(h_upsilon_invmass_vs_crt, h_upsilon_width_vs_crt, hcrt, nbins);
1471  fitUpsilonHistograms(h_upsilon_invmass_vs_invpt, h_upsilon_width_vs_invpt, hinvpt, nbins);
1472  fitUpsilonHistograms(h_upsilon_invmass_vs_angle_eta, h_upsilon_width_vs_angle_eta, hangle_eta, nbins);
1473 
1474 
1475  // f->cd(path.c_str());
1476  if (f->cd(path.c_str()) == 0) {
1477  //std::cerr<< "MonitoringFile::fitMergedFile_IDPerfMonUpsilon(): "
1478  //<<"No such directory \""<< path << "\"\n";
1479  return;
1480  }
1481 
1482  h_mass->Write("", TObject::kOverwrite);
1483  for (int i = 0; i < nbins; i++) {
1484  hpt[i]->Write("", TObject::kOverwrite);
1485  hz0[i]->Write("", TObject::kOverwrite);
1486  hphi[i]->Write("", TObject::kOverwrite);
1487  hphiplus[i]->Write("", TObject::kOverwrite);
1488  hphiminus[i]->Write("", TObject::kOverwrite);
1489  hphidiff[i]->Write("", TObject::kOverwrite);
1490  hetadiff[i]->Write("", TObject::kOverwrite);
1491  hmaxeta[i]->Write("", TObject::kOverwrite);
1492  hinvpt[i]->Write("", TObject::kOverwrite);
1493  hcrt[i]->Write("", TObject::kOverwrite);
1494  hetaplus[i]->Write("", TObject::kOverwrite);
1495  hetaminus[i]->Write("", TObject::kOverwrite);
1496  hangle_eta[i]->Write("", TObject::kOverwrite);
1497  if (i < 2) {
1498  heta_b[i]->Write("", TObject::kOverwrite);
1499  }
1500  if (i < 3) {
1501  heta_ecc[i]->Write("", TObject::kOverwrite);
1502  heta_eca[i]->Write("", TObject::kOverwrite);
1503  }
1504  }
1505  for (int i = 0; i < 8; i++) {
1506  heta[i]->Write("", TObject::kOverwrite);
1507  }
1508  h_upsilon_invmass_vs_pt->Write("", TObject::kOverwrite);
1509  h_upsilon_invmass_vs_z0->Write("", TObject::kOverwrite);
1510  h_upsilon_invmass_vs_phi->Write("", TObject::kOverwrite);
1511  h_upsilon_invmass_vs_phiplus->Write("", TObject::kOverwrite);
1512  h_upsilon_invmass_vs_phiminus->Write("", TObject::kOverwrite);
1513  h_upsilon_invmass_vs_phidiff->Write("", TObject::kOverwrite);
1514  h_upsilon_invmass_vs_eta->Write("", TObject::kOverwrite);
1515  h_upsilon_invmass_vs_eta_barrel->Write("", TObject::kOverwrite);
1516  h_upsilon_invmass_vs_eta_ecc->Write("", TObject::kOverwrite);
1517  h_upsilon_invmass_vs_eta_eca->Write("", TObject::kOverwrite);
1518  h_upsilon_invmass_vs_etadiff->Write("", TObject::kOverwrite);
1519  h_upsilon_invmass_vs_etaplus->Write("", TObject::kOverwrite);
1520  h_upsilon_invmass_vs_etaminus->Write("", TObject::kOverwrite);
1521  h_upsilon_invmass_vs_maxeta->Write("", TObject::kOverwrite);
1522  h_upsilon_invmass_vs_crt->Write("", TObject::kOverwrite);
1523  h_upsilon_invmass_vs_invpt->Write("", TObject::kOverwrite);
1524  h_upsilon_invmass_vs_angle_eta->Write("", TObject::kOverwrite);
1525 
1526  h_upsilon_width_vs_pt->Write("", TObject::kOverwrite);
1527  h_upsilon_width_vs_z0->Write("", TObject::kOverwrite);
1528  h_upsilon_width_vs_phi->Write("", TObject::kOverwrite);
1529  h_upsilon_width_vs_phiplus->Write("", TObject::kOverwrite);
1530  h_upsilon_width_vs_phiminus->Write("", TObject::kOverwrite);
1531  h_upsilon_width_vs_phidiff->Write("", TObject::kOverwrite);
1532  h_upsilon_width_vs_eta->Write("", TObject::kOverwrite);
1533  h_upsilon_width_vs_eta_barrel->Write("", TObject::kOverwrite);
1534  h_upsilon_width_vs_eta_ecc->Write("", TObject::kOverwrite);
1535  h_upsilon_width_vs_eta_eca->Write("", TObject::kOverwrite);
1536  h_upsilon_width_vs_etadiff->Write("", TObject::kOverwrite);
1537  h_upsilon_width_vs_etaplus->Write("", TObject::kOverwrite);
1538  h_upsilon_width_vs_etaminus->Write("", TObject::kOverwrite);
1539  h_upsilon_width_vs_maxeta->Write("", TObject::kOverwrite);
1540  h_upsilon_width_vs_crt->Write("", TObject::kOverwrite);
1541  h_upsilon_width_vs_invpt->Write("", TObject::kOverwrite);
1542  h_upsilon_width_vs_angle_eta->Write("", TObject::kOverwrite);
1543 
1544  myCanvas->Close();
1545  delete myCanvas;
1546 
1547  f->Write();
1548 
1549 // delete f1;
1550  }
1551 
1552  void
1554  fitMergedFile_IDPerfMonZee(TFile* f, const std::string& run_dir, const std::string& TriggerName) {
1555  std::string path;
1556  path = run_dir + "IDPerfMon/Zee/" + TriggerName;
1557  if (f->cd(path.c_str()) == 0) {
1558  //std::cerr << "MonitoringFile::fitMergedFile_IDPerfMonZee(): "
1559  //<< "No such directory \"" << path << "\"\n";
1560  return;
1561  }
1562 
1563  f->cd(path.c_str());
1564 
1565  if (!CheckHistogram(f, (path + "/Zee_invmass").c_str())) return;
1566 
1567  TH1F* h_mass = (TH1F*) (f->Get((path + "/Zee_invmass").c_str())->Clone());
1568  if (CheckHistogram(f, (path + "/Nevents").c_str())) {
1569  TH1F* h_Nevents = (TH1F*) f->Get((path + "/Nevents").c_str());
1570  TH1F* h_rate = new TH1F("rate", "production rate", 1, 0, 1);
1571  double Ntot = h_Nevents->GetEntries();
1572  double yield = h_mass->Integral(h_mass->FindBin(80), h_mass->FindBin(105));
1573  double rate = yield / Ntot;
1574  double rate_error = sqrt(1 / yield + 1 / Ntot) * yield / Ntot;
1575  h_rate->SetBinContent(1, rate);
1576  h_rate->SetBinError(1, rate_error);
1577  h_rate->Write("", TObject::kOverwrite);
1578  }
1579 // TH1F* h_mass_scaled = (TH1F*)(f->Get((path+"/Zee_trk_invmass").c_str())->Clone("Zee_trk_invmass_scaled_copy"));
1580 // TString title(h_mass_scaled->GetTitle());
1581 // if (CheckHistogram(f,(path+"/Zee_trk_invmass_scaled").c_str())) {
1582 // if (CheckHistogram(f,(path+"/Nevents").c_str())) {
1583 // TH1F* h_Nevents=(TH1F*)f->Get((path+"/Nevents").c_str());
1584 // double Ntot =h_Nevents->GetEntries();
1585 // if (Ntot!=0.) h_mass_scaled->Scale(1./Ntot);
1586 // h_mass_scaled->SetTitle(title+" (per event)");
1587 // h_mass_scaled->Write("Zee_trk_invmass_scaled",TObject::kOverwrite);
1588 // }
1589 // }
1590 // delete h_mass_scaled;
1591 
1592  enum eta_region {
1593  incl, barrel, eca, ecc, Nregions
1594  };
1595  std::vector<std::string> region_strings;
1596  region_strings.push_back("incl");
1597  region_strings.push_back("barrel");
1598  region_strings.push_back("eca");
1599  region_strings.push_back("ecc");
1600 
1601  std::vector<TH1F*> h_Zee_Eopdiff;
1602  std::vector<TH1F*> h_Zee_Eop_plus;
1603  std::vector<TH1F*> h_Zee_Eop_minus;
1604 
1605  std::vector<TProfile*> h_Zee_Eopdiff_vs_p;
1606  std::vector<TProfile*> h_Zee_meanEop_vs_p_plus;
1607  std::vector<TProfile*> h_Zee_meanEop_vs_p_minus;
1608 
1609  std::vector<TProfile*> h_Zee_Eopdiff_vs_invp;
1610  std::vector<TProfile*> h_Zee_meanEop_vs_invp_plus;
1611  std::vector<TProfile*> h_Zee_meanEop_vs_invp_minus;
1612 
1613  std::vector<TProfile*> h_Zee_Eopdiff_vs_E;
1614  std::vector<TProfile*> h_Zee_meanEop_vs_E_plus;
1615  std::vector<TProfile*> h_Zee_meanEop_vs_E_minus;
1616 
1617  std::vector<TProfile*> h_Zee_Eopdiff_vs_phi;
1618  std::vector<TProfile*> h_Zee_meanEop_vs_phi_plus;
1619  std::vector<TProfile*> h_Zee_meanEop_vs_phi_minus;
1620 
1621  std::vector<TProfile*> h_Zee_Eopdiff_vs_eta;
1622  std::vector<TProfile*> h_Zee_meanEop_vs_eta_plus;
1623  std::vector<TProfile*> h_Zee_meanEop_vs_eta_minus;
1624 
1625  std::string str;
1626 
1627  for (int region = 0; region != Nregions; ++region) {
1628  str = path + "/Zee_Eop_plus_" + region_strings[region];
1629  if (!CheckHistogram(f, str.c_str())) return;
1630 
1631  h_Zee_Eop_plus.push_back((TH1F*) (f->Get(str.c_str())));
1632  h_Zee_Eop_plus[region]->SetTitle(h_Zee_Eop_plus[region]->GetTitle());
1633  str = path + "/Zee_Eop_minus_" + region_strings[region];
1634  if (!CheckHistogram(f, str.c_str())) return;
1635 
1636  h_Zee_Eop_minus.push_back((TH1F*) (f->Get(str.c_str())));
1637  h_Zee_Eop_minus[region]->SetTitle(h_Zee_Eop_minus[region]->GetTitle());
1638  str = path + "/Zee_Eopdiff_" + region_strings[region];
1639  if (!CheckHistogram(f, str.c_str())) return;
1640 
1641  h_Zee_Eopdiff.push_back((TH1F*) (f->Get(str.c_str())));
1642  h_Zee_Eopdiff[region]->SetTitle(h_Zee_Eopdiff[region]->GetTitle());
1643 
1644  h_Zee_Eopdiff[region]->Add(h_Zee_Eop_plus[region], h_Zee_Eop_minus[region], 1., -1);
1645 
1646  if (region == incl) {
1647  str = path + "/Zee_meanEop_vs_p_plus";
1648  if (!CheckHistogram(f, str.c_str())) return;
1649 
1650  h_Zee_meanEop_vs_p_plus.push_back((TProfile*) (f->Get(str.c_str())));
1651  h_Zee_meanEop_vs_p_plus[region]->SetTitle(h_Zee_meanEop_vs_p_plus[region]->GetTitle());
1652  str = path + "/Zee_meanEop_vs_p_minus";
1653  if (!CheckHistogram(f, str.c_str())) return;
1654 
1655  h_Zee_meanEop_vs_p_minus.push_back((TProfile*) (f->Get(str.c_str())));
1656  h_Zee_meanEop_vs_p_minus[region]->SetTitle(h_Zee_meanEop_vs_p_minus[region]->GetTitle());
1657  str = path + "/Zee_Eopdiff_vs_p";
1658  if (!CheckHistogram(f, str.c_str())) return;
1659 
1660  h_Zee_Eopdiff_vs_p.push_back((TProfile*) (f->Get(str.c_str())));
1661  h_Zee_Eopdiff_vs_p[region]->SetTitle(h_Zee_Eopdiff_vs_p[region]->GetTitle());
1662 
1663  str = path + "/Zee_meanEop_vs_invp_plus";
1664  if (!CheckHistogram(f, str.c_str())) return;
1665 
1666  h_Zee_meanEop_vs_invp_plus.push_back((TProfile*) (f->Get(str.c_str())));
1667  h_Zee_meanEop_vs_invp_plus[region]->SetTitle(h_Zee_meanEop_vs_invp_plus[region]->GetTitle());
1668  str = path + "/Zee_meanEop_vs_invp_minus";
1669  if (!CheckHistogram(f, str.c_str())) return;
1670 
1671  h_Zee_meanEop_vs_invp_minus.push_back((TProfile*) (f->Get(str.c_str())));
1672  h_Zee_meanEop_vs_invp_minus[region]->SetTitle(h_Zee_meanEop_vs_invp_minus[region]->GetTitle());
1673  str = path + "/Zee_Eopdiff_vs_invp";
1674  if (!CheckHistogram(f, str.c_str())) return;
1675 
1676  h_Zee_Eopdiff_vs_invp.push_back((TProfile*) (f->Get(str.c_str())));
1677  h_Zee_Eopdiff_vs_invp[region]->SetTitle(h_Zee_Eopdiff_vs_invp[region]->GetTitle());
1678 
1679  str = path + "/Zee_meanEop_vs_E_plus";
1680  if (!CheckHistogram(f, str.c_str())) return;
1681 
1682  h_Zee_meanEop_vs_E_plus.push_back((TProfile*) (f->Get(str.c_str())));
1683  h_Zee_meanEop_vs_E_plus[region]->SetTitle(h_Zee_meanEop_vs_E_plus[region]->GetTitle());
1684  str = path + "/Zee_meanEop_vs_E_minus";
1685  if (!CheckHistogram(f, str.c_str())) return;
1686 
1687  h_Zee_meanEop_vs_E_minus.push_back((TProfile*) (f->Get(str.c_str())));
1688  h_Zee_meanEop_vs_E_minus[region]->SetTitle(h_Zee_meanEop_vs_E_minus[region]->GetTitle());
1689  str = path + "/Zee_Eopdiff_vs_E";
1690  if (!CheckHistogram(f, str.c_str())) return;
1691 
1692  h_Zee_Eopdiff_vs_E.push_back((TProfile*) (f->Get(str.c_str())));
1693  h_Zee_Eopdiff_vs_E[region]->SetTitle(h_Zee_Eopdiff_vs_E[region]->GetTitle());
1694 
1695  str = path + "/Zee_meanEop_vs_phi_plus";
1696  if (!CheckHistogram(f, str.c_str())) return;
1697 
1698  h_Zee_meanEop_vs_phi_plus.push_back((TProfile*) (f->Get(str.c_str())));
1699  h_Zee_meanEop_vs_phi_plus[region]->SetTitle(h_Zee_meanEop_vs_phi_plus[region]->GetTitle());
1700  str = path + "/Zee_meanEop_vs_phi_minus";
1701  if (!CheckHistogram(f, str.c_str())) return;
1702 
1703  h_Zee_meanEop_vs_phi_minus.push_back((TProfile*) (f->Get(str.c_str())));
1704  h_Zee_meanEop_vs_phi_minus[region]->SetTitle(h_Zee_meanEop_vs_phi_minus[region]->GetTitle());
1705  str = path + "/Zee_Eopdiff_vs_phi";
1706  if (!CheckHistogram(f, str.c_str())) return;
1707 
1708  h_Zee_Eopdiff_vs_phi.push_back((TProfile*) (f->Get(str.c_str())));
1709  h_Zee_Eopdiff_vs_phi[region]->SetTitle(h_Zee_Eopdiff_vs_phi[region]->GetTitle());
1710 
1711  str = path + "/Zee_meanEop_vs_eta_plus";
1712  if (!CheckHistogram(f, str.c_str())) return;
1713 
1714  h_Zee_meanEop_vs_eta_plus.push_back((TProfile*) (f->Get(str.c_str())));
1715  h_Zee_meanEop_vs_eta_plus[region]->SetTitle(h_Zee_meanEop_vs_eta_plus[region]->GetTitle());
1716  str = path + "/Zee_meanEop_vs_eta_minus";
1717  if (!CheckHistogram(f, str.c_str())) return;
1718 
1719  h_Zee_meanEop_vs_eta_minus.push_back((TProfile*) (f->Get(str.c_str())));
1720  h_Zee_meanEop_vs_eta_minus[region]->SetTitle(h_Zee_meanEop_vs_eta_minus[region]->GetTitle());
1721  str = path + "/Zee_Eopdiff_vs_eta";
1722  if (!CheckHistogram(f, str.c_str())) return;
1723 
1724  h_Zee_Eopdiff_vs_eta.push_back((TProfile*) (f->Get(str.c_str())));
1725  h_Zee_Eopdiff_vs_eta[region]->SetTitle(h_Zee_Eopdiff_vs_eta[region]->GetTitle());
1726 
1727  h_Zee_Eopdiff_vs_p[region]->Add(h_Zee_meanEop_vs_p_plus[region], h_Zee_meanEop_vs_p_minus[region], 1., -1);
1728  h_Zee_Eopdiff_vs_invp[region]->Add(h_Zee_meanEop_vs_invp_plus[region], h_Zee_meanEop_vs_invp_minus[region], 1.,
1729  -1);
1730  h_Zee_Eopdiff_vs_E[region]->Add(h_Zee_meanEop_vs_E_plus[region], h_Zee_meanEop_vs_E_minus[region], 1., -1);
1731  h_Zee_Eopdiff_vs_phi[region]->Add(h_Zee_meanEop_vs_phi_plus[region], h_Zee_meanEop_vs_phi_minus[region], 1.,
1732  -1);
1733  h_Zee_Eopdiff_vs_eta[region]->Add(h_Zee_meanEop_vs_eta_plus[region], h_Zee_meanEop_vs_eta_minus[region], 1.,
1734  -1);
1735  }
1736  }
1737 
1738  for (int region = 0; region != Nregions; ++region) {
1739  h_Zee_Eopdiff[region]->Write("", TObject::kOverwrite);
1740  if (region == incl) {
1741  h_Zee_Eopdiff_vs_p[region]->Write("", TObject::kOverwrite);
1742  h_Zee_Eopdiff_vs_invp[region]->Write("", TObject::kOverwrite);
1743  h_Zee_Eopdiff_vs_E[region]->Write("", TObject::kOverwrite);
1744  h_Zee_Eopdiff_vs_phi[region]->Write("", TObject::kOverwrite);
1745  h_Zee_Eopdiff_vs_eta[region]->Write("", TObject::kOverwrite);
1746  }
1747  }
1748 
1749  f->Write();
1750  }
1751 
1752  void
1754  fitMergedFile_IDPerfMonWenu(TFile* f, const std::string& run_dir, const std::string& TriggerName) {
1755  std::string path;
1756  path = run_dir + "IDPerfMon/Wenu/" + TriggerName;
1757  if (f->cd(path.c_str()) == 0) {
1758  //std::cerr << "MonitoringFile::fitMergedFile_IDPerfMonWenu(): "
1759  //<< "No such directory \"" << path << "\"\n";
1760  return;
1761  }
1762 
1763  f->cd(path.c_str());
1764 
1765  if (!CheckHistogram(f, (path + "/Wenu_trk_transmass_sel").c_str())) return;
1766 
1767  TH1F* h_mass = (TH1F*) (f->Get((path + "/Wenu_trk_transmass_sel").c_str())->Clone());
1768  if (CheckHistogram(f, (path + "/Nevents").c_str())) {
1769  TH1F* h_Nevents = (TH1F*) f->Get((path + "/Nevents").c_str());
1770  TH1F* h_rate = new TH1F("rate", "production rate", 1, 0, 1);
1771  double Ntot = h_Nevents->GetEntries();
1772  double yield = h_mass->Integral(h_mass->FindBin(50), h_mass->FindBin(80));
1773  double rate = yield / Ntot;
1774  double rate_error = sqrt(1 / yield + 1 / Ntot) * yield / Ntot;
1775  h_rate->SetBinContent(1, rate);
1776  h_rate->SetBinError(1, rate_error);
1777  h_rate->Write("", TObject::kOverwrite);
1778  }
1779 // TH1F* h_mass_scaled =
1780 // (TH1F*)(f->Get((path+"/Wenu_trk_transmass_sel").c_str())->Clone("Wenu_trk_transmass_sel_scaled_copy"));
1781 // TString title(h_mass_scaled->GetTitle());
1782 // if (CheckHistogram(f,(path+"/Wenu_trk_transmass_sel_scaled").c_str())) {
1783 // if (CheckHistogram(f,(path+"/Nevents").c_str())) {
1784 // TH1F* h_Nevents=(TH1F*)f->Get((path+"/Nevents").c_str());
1785 // double Ntot =h_Nevents->GetEntries();
1786 // if (Ntot!=0.) h_mass_scaled->Scale(1./Ntot);
1787 // h_mass_scaled->SetTitle(title+" (per event)");
1788 // h_mass_scaled->Write("Wenu_trk_transmass_sel_scaled",TObject::kOverwrite);
1789 // }
1790 // }
1791 // delete h_mass_scaled;
1792 
1793  enum eta_region {
1794  incl, barrel, eca, ecc, Nregions
1795  };
1796  std::vector<std::string> region_strings;
1797  region_strings.push_back("incl");
1798  region_strings.push_back("barrel");
1799  region_strings.push_back("eca");
1800  region_strings.push_back("ecc");
1801 
1802  std::vector<TH1F*> h_Wenu_Eopdiff;
1803  std::vector<TH1F*> h_Wenu_Eop_plus;
1804  std::vector<TH1F*> h_Wenu_Eop_minus;
1805 
1806  std::vector<TProfile*> h_Wenu_Eopdiff_vs_p;
1807  std::vector<TProfile*> h_Wenu_meanEop_vs_p_plus;
1808  std::vector<TProfile*> h_Wenu_meanEop_vs_p_minus;
1809 
1810  std::vector<TProfile*> h_Wenu_Eopdiff_vs_invp;
1811  std::vector<TProfile*> h_Wenu_meanEop_vs_invp_plus;
1812  std::vector<TProfile*> h_Wenu_meanEop_vs_invp_minus;
1813 
1814  std::vector<TProfile*> h_Wenu_Eopdiff_vs_E;
1815  std::vector<TProfile*> h_Wenu_meanEop_vs_E_plus;
1816  std::vector<TProfile*> h_Wenu_meanEop_vs_E_minus;
1817 
1818  std::vector<TProfile*> h_Wenu_Eopdiff_vs_phi;
1819  std::vector<TProfile*> h_Wenu_meanEop_vs_phi_plus;
1820  std::vector<TProfile*> h_Wenu_meanEop_vs_phi_minus;
1821 
1822  std::vector<TProfile*> h_Wenu_Eopdiff_vs_eta;
1823  std::vector<TProfile*> h_Wenu_meanEop_vs_eta_plus;
1824  std::vector<TProfile*> h_Wenu_meanEop_vs_eta_minus;
1825 
1826  std::string str;
1827 
1828  for (int region = 0; region != Nregions; ++region) {
1829  str = path + "/Wenu_Eop_plus_" + region_strings[region];
1830  if (!CheckHistogram(f, str.c_str())) return;
1831 
1832  h_Wenu_Eop_plus.push_back((TH1F*) (f->Get(str.c_str())));
1833  h_Wenu_Eop_plus[region]->SetTitle(h_Wenu_Eop_plus[region]->GetTitle());
1834  str = path + "/Wenu_Eop_minus_" + region_strings[region];
1835  if (!CheckHistogram(f, str.c_str())) return;
1836 
1837  h_Wenu_Eop_minus.push_back((TH1F*) (f->Get(str.c_str())));
1838  h_Wenu_Eop_minus[region]->SetTitle(h_Wenu_Eop_minus[region]->GetTitle());
1839  str = path + "/Wenu_Eopdiff_" + region_strings[region];
1840  if (!CheckHistogram(f, str.c_str())) return;
1841 
1842  h_Wenu_Eopdiff.push_back((TH1F*) (f->Get(str.c_str())));
1843  h_Wenu_Eopdiff[region]->SetTitle(h_Wenu_Eopdiff[region]->GetTitle());
1844 
1845  h_Wenu_Eopdiff[region]->Add(h_Wenu_Eop_plus[region], h_Wenu_Eop_minus[region], 1., -1);
1846 
1847  if (region == incl) {
1848  str = path + "/Wenu_meanEop_vs_p_plus";
1849  if (!CheckHistogram(f, str.c_str())) return;
1850 
1851  h_Wenu_meanEop_vs_p_plus.push_back((TProfile*) (f->Get(str.c_str())));
1852  h_Wenu_meanEop_vs_p_plus[region]->SetTitle(h_Wenu_meanEop_vs_p_plus[region]->GetTitle());
1853  str = path + "/Wenu_meanEop_vs_p_minus";
1854  if (!CheckHistogram(f, str.c_str())) return;
1855 
1856  h_Wenu_meanEop_vs_p_minus.push_back((TProfile*) (f->Get(str.c_str())));
1857  h_Wenu_meanEop_vs_p_minus[region]->SetTitle(h_Wenu_meanEop_vs_p_minus[region]->GetTitle());
1858  str = path + "/Wenu_Eopdiff_vs_p";
1859  if (!CheckHistogram(f, str.c_str())) return;
1860 
1861  h_Wenu_Eopdiff_vs_p.push_back((TProfile*) (f->Get(str.c_str())));
1862  h_Wenu_Eopdiff_vs_p[region]->SetTitle(h_Wenu_Eopdiff_vs_p[region]->GetTitle());
1863 
1864  str = path + "/Wenu_meanEop_vs_invp_plus";
1865  if (!CheckHistogram(f, str.c_str())) return;
1866 
1867  h_Wenu_meanEop_vs_invp_plus.push_back((TProfile*) (f->Get(str.c_str())));
1868  h_Wenu_meanEop_vs_invp_plus[region]->SetTitle(h_Wenu_meanEop_vs_invp_plus[region]->GetTitle());
1869  str = path + "/Wenu_meanEop_vs_invp_minus";
1870  if (!CheckHistogram(f, str.c_str())) return;
1871 
1872  h_Wenu_meanEop_vs_invp_minus.push_back((TProfile*) (f->Get(str.c_str())));
1873  h_Wenu_meanEop_vs_invp_minus[region]->SetTitle(h_Wenu_meanEop_vs_invp_minus[region]->GetTitle());
1874  str = path + "/Wenu_Eopdiff_vs_invp";
1875  if (!CheckHistogram(f, str.c_str())) return;
1876 
1877  h_Wenu_Eopdiff_vs_invp.push_back((TProfile*) (f->Get(str.c_str())));
1878  h_Wenu_Eopdiff_vs_invp[region]->SetTitle(h_Wenu_Eopdiff_vs_invp[region]->GetTitle());
1879 
1880  str = path + "/Wenu_meanEop_vs_E_plus";
1881  if (!CheckHistogram(f, str.c_str())) return;
1882 
1883  h_Wenu_meanEop_vs_E_plus.push_back((TProfile*) (f->Get(str.c_str())));
1884  h_Wenu_meanEop_vs_E_plus[region]->SetTitle(h_Wenu_meanEop_vs_E_plus[region]->GetTitle());
1885  str = path + "/Wenu_meanEop_vs_E_minus";
1886  if (!CheckHistogram(f, str.c_str())) return;
1887 
1888  h_Wenu_meanEop_vs_E_minus.push_back((TProfile*) (f->Get(str.c_str())));
1889  h_Wenu_meanEop_vs_E_minus[region]->SetTitle(h_Wenu_meanEop_vs_E_minus[region]->GetTitle());
1890  str = path + "/Wenu_Eopdiff_vs_E";
1891  if (!CheckHistogram(f, str.c_str())) return;
1892 
1893  h_Wenu_Eopdiff_vs_E.push_back((TProfile*) (f->Get(str.c_str())));
1894  h_Wenu_Eopdiff_vs_E[region]->SetTitle(h_Wenu_Eopdiff_vs_E[region]->GetTitle());
1895 
1896  str = path + "/Wenu_meanEop_vs_phi_plus";
1897  if (!CheckHistogram(f, str.c_str())) return;
1898 
1899  h_Wenu_meanEop_vs_phi_plus.push_back((TProfile*) (f->Get(str.c_str())));
1900  h_Wenu_meanEop_vs_phi_plus[region]->SetTitle(h_Wenu_meanEop_vs_phi_plus[region]->GetTitle());
1901  str = path + "/Wenu_meanEop_vs_phi_minus";
1902  if (!CheckHistogram(f, str.c_str())) return;
1903 
1904  h_Wenu_meanEop_vs_phi_minus.push_back((TProfile*) (f->Get(str.c_str())));
1905  h_Wenu_meanEop_vs_phi_minus[region]->SetTitle(h_Wenu_meanEop_vs_phi_minus[region]->GetTitle());
1906  str = path + "/Wenu_Eopdiff_vs_phi";
1907  if (!CheckHistogram(f, str.c_str())) return;
1908 
1909  h_Wenu_Eopdiff_vs_phi.push_back((TProfile*) (f->Get(str.c_str())));
1910  h_Wenu_Eopdiff_vs_phi[region]->SetTitle(h_Wenu_Eopdiff_vs_phi[region]->GetTitle());
1911 
1912  str = path + "/Wenu_meanEop_vs_eta_plus";
1913  if (!CheckHistogram(f, str.c_str())) return;
1914 
1915  h_Wenu_meanEop_vs_eta_plus.push_back((TProfile*) (f->Get(str.c_str())));
1916  h_Wenu_meanEop_vs_eta_plus[region]->SetTitle(h_Wenu_meanEop_vs_eta_plus[region]->GetTitle());
1917  str = path + "/Wenu_meanEop_vs_eta_minus";
1918  if (!CheckHistogram(f, str.c_str())) return;
1919 
1920  h_Wenu_meanEop_vs_eta_minus.push_back((TProfile*) (f->Get(str.c_str())));
1921  h_Wenu_meanEop_vs_eta_minus[region]->SetTitle(h_Wenu_meanEop_vs_eta_minus[region]->GetTitle());
1922  str = path + "/Wenu_Eopdiff_vs_eta";
1923  if (!CheckHistogram(f, str.c_str())) return;
1924 
1925  h_Wenu_Eopdiff_vs_eta.push_back((TProfile*) (f->Get(str.c_str())));
1926  h_Wenu_Eopdiff_vs_eta[region]->SetTitle(h_Wenu_Eopdiff_vs_eta[region]->GetTitle());
1927 
1928  h_Wenu_Eopdiff_vs_p[region]->Add(h_Wenu_meanEop_vs_p_plus[region], h_Wenu_meanEop_vs_p_minus[region], 1., -1);
1929  h_Wenu_Eopdiff_vs_invp[region]->Add(h_Wenu_meanEop_vs_invp_plus[region], h_Wenu_meanEop_vs_invp_minus[region],
1930  1., -1);
1931  h_Wenu_Eopdiff_vs_E[region]->Add(h_Wenu_meanEop_vs_E_plus[region], h_Wenu_meanEop_vs_E_minus[region], 1., -1);
1932  h_Wenu_Eopdiff_vs_phi[region]->Add(h_Wenu_meanEop_vs_phi_plus[region], h_Wenu_meanEop_vs_phi_minus[region], 1.,
1933  -1);
1934  h_Wenu_Eopdiff_vs_eta[region]->Add(h_Wenu_meanEop_vs_eta_plus[region], h_Wenu_meanEop_vs_eta_minus[region], 1.,
1935  -1);
1936  }
1937  }
1938 
1939  for (int region = 0; region != Nregions; ++region) {
1940  h_Wenu_Eopdiff[region]->Write("", TObject::kOverwrite);
1941  if (region == incl) {
1942  h_Wenu_Eopdiff_vs_p[region]->Write("", TObject::kOverwrite);
1943  h_Wenu_Eopdiff_vs_invp[region]->Write("", TObject::kOverwrite);
1944  h_Wenu_Eopdiff_vs_E[region]->Write("", TObject::kOverwrite);
1945  h_Wenu_Eopdiff_vs_phi[region]->Write("", TObject::kOverwrite);
1946  h_Wenu_Eopdiff_vs_eta[region]->Write("", TObject::kOverwrite);
1947  }
1948  }
1949 
1950  f->Write();
1951  }
1952 
1953  void
1955  fitMergedFile_IDPerfMonZMM(TFile* f, const std::string& run_dir, const std::string& TriggerName) {
1956  std::string path;
1957  std::vector<TH1F*> hvec;
1958  gROOT->SetStyle("Plain");
1959 
1960  path = run_dir + "IDPerfMon/ZMM/" + TriggerName;
1961  //std::cout <<" ZMM path: "<< path << std::endl;
1962  if (f->cd(path.c_str()) == 0) {
1963  //std::cerr << "MonitoringFile::fitMergedFile_IDPerfMonZMM(): "
1964  //<< "No such directory \"" << path << "\"\n";
1965  return;
1966  }
1967  f->cd(path.c_str());
1968 
1969 
1970 
1971  // CB ---------
1972  TH1F* h_ZMass_CB_Shift_vs_Regions = new TH1F("Z_Mass_CB_Shift_vs_Regions", "Z_Mass_CB Shift vs. Regions", 4, 0.5,
1973  4.5);
1974  TH1F* h_ZMass_CB_Width_vs_Regions = new TH1F("Z_Mass_CB_Width_vs_Regions", "Z_Mass_CB Width vs. Regions", 4, 0.5,
1975  4.5);
1976 
1977  if (!CheckHistogram(f, (path + "/Z_Mass_CB_All").c_str()) ||
1978  !CheckHistogram(f, (path + "/Z_Mass_CB_BB").c_str()) ||
1979  !CheckHistogram(f, (path + "/Z_Mass_CB_BE").c_str()) ||
1980  !CheckHistogram(f, (path + "/Z_Mass_CB_EE").c_str())) return;
1981 
1982  hvec.push_back((TH1F*) (f->Get((path + "/Z_Mass_CB_All").c_str())->Clone()));
1983  hvec.push_back((TH1F*) (f->Get((path + "/Z_Mass_CB_BB").c_str())->Clone()));
1984  hvec.push_back((TH1F*) (f->Get((path + "/Z_Mass_CB_BE").c_str())->Clone()));
1985  hvec.push_back((TH1F*) (f->Get((path + "/Z_Mass_CB_EE").c_str())->Clone()));
1986  fitZmumuHistograms(h_ZMass_CB_Shift_vs_Regions, h_ZMass_CB_Width_vs_Regions, hvec);
1987  hvec.clear();
1988  h_ZMass_CB_Shift_vs_Regions->SetStats(0);
1989  h_ZMass_CB_Width_vs_Regions->SetStats(0);
1990  h_ZMass_CB_Shift_vs_Regions->Write("", TObject::kOverwrite);
1991  h_ZMass_CB_Width_vs_Regions->Write("", TObject::kOverwrite);
1992 
1993  // ID ----------
1994  TH1F* h_ZMass_ID_Shift_vs_Regions = new TH1F("Z_Mass_ID_Shift_vs_Regions", "Z_Mass_ID Shift vs. Regions", 4, 0.5,
1995  4.5);
1996  TH1F* h_ZMass_ID_Width_vs_Regions = new TH1F("Z_Mass_ID_Width_vs_Regions", "Z_Mass_ID Width vs. Regions", 4, 0.5,
1997  4.5);
1998 
1999  if (!CheckHistogram(f, (path + "/Z_Mass_ID_All").c_str()) ||
2000  !CheckHistogram(f, (path + "/Z_Mass_ID_BB").c_str()) ||
2001  !CheckHistogram(f, (path + "/Z_Mass_ID_BE").c_str()) ||
2002  !CheckHistogram(f, (path + "/Z_Mass_ID_EE").c_str())) return;
2003 
2004  hvec.push_back((TH1F*) (f->Get((path + "/Z_Mass_ID_All").c_str())->Clone()));
2005  hvec.push_back((TH1F*) (f->Get((path + "/Z_Mass_ID_BB").c_str())->Clone()));
2006  hvec.push_back((TH1F*) (f->Get((path + "/Z_Mass_ID_BE").c_str())->Clone()));
2007  hvec.push_back((TH1F*) (f->Get((path + "/Z_Mass_ID_EE").c_str())->Clone()));
2008  fitZmumuHistograms(h_ZMass_ID_Shift_vs_Regions, h_ZMass_ID_Width_vs_Regions, hvec);
2009  hvec.clear();
2010  h_ZMass_ID_Shift_vs_Regions->SetStats(0);
2011  h_ZMass_ID_Width_vs_Regions->SetStats(0);
2012  h_ZMass_ID_Shift_vs_Regions->Write("", TObject::kOverwrite);
2013  h_ZMass_ID_Width_vs_Regions->Write("", TObject::kOverwrite);
2014 
2015  // ME -----------
2016  TH1F* h_ZMass_ME_Shift_vs_Regions = new TH1F("Z_Mass_ME_Shift_vs_Regions", "Z_Mass_ME Shift vs. Regions", 4, 0.5,
2017  4.5);
2018  TH1F* h_ZMass_ME_Width_vs_Regions = new TH1F("Z_Mass_ME_Width_vs_Regions", "Z_Mass_ME Width vs. Regions", 4, 0.5,
2019  4.5);
2020 
2021  if (!CheckHistogram(f, (path + "/Z_Mass_ME_All").c_str()) ||
2022  !CheckHistogram(f, (path + "/Z_Mass_ME_BB").c_str()) ||
2023  !CheckHistogram(f, (path + "/Z_Mass_ME_BE").c_str()) ||
2024  !CheckHistogram(f, (path + "/Z_Mass_ME_EE").c_str())) return;
2025 
2026  hvec.push_back((TH1F*) (f->Get((path + "/Z_Mass_ME_All").c_str())->Clone()));
2027  hvec.push_back((TH1F*) (f->Get((path + "/Z_Mass_ME_BB").c_str())->Clone()));
2028  hvec.push_back((TH1F*) (f->Get((path + "/Z_Mass_ME_BE").c_str())->Clone()));
2029  hvec.push_back((TH1F*) (f->Get((path + "/Z_Mass_ME_EE").c_str())->Clone()));
2030  fitZmumuHistograms(h_ZMass_ME_Shift_vs_Regions, h_ZMass_ME_Width_vs_Regions, hvec);
2031  hvec.clear();
2032  h_ZMass_ME_Shift_vs_Regions->SetStats(0);
2033  h_ZMass_ME_Width_vs_Regions->SetStats(0);
2034  h_ZMass_ME_Shift_vs_Regions->Write("", TObject::kOverwrite);
2035  h_ZMass_ME_Width_vs_Regions->Write("", TObject::kOverwrite);
2036 
2037  // MS -----------
2038  TH1F* h_ZMass_MS_Shift_vs_Regions = new TH1F("Z_Mass_MS_Shift_vs_Regions", "Z_Mass_MS Shift vs. Regions", 4, 0.5,
2039  4.5);
2040  TH1F* h_ZMass_MS_Width_vs_Regions = new TH1F("Z_Mass_MS_Width_vs_Regions", "Z_Mass_MS Width vs. Regions", 4, 0.5,
2041  4.5);
2042 
2043 
2044  if (!CheckHistogram(f, (path + "/Z_Mass_MS_All").c_str()) ||
2045  !CheckHistogram(f, (path + "/Z_Mass_MS_BB").c_str()) ||
2046  !CheckHistogram(f, (path + "/Z_Mass_MS_BE").c_str()) ||
2047  !CheckHistogram(f, (path + "/Z_Mass_MS_EE").c_str())) return;
2048 
2049  hvec.push_back((TH1F*) (f->Get((path + "/Z_Mass_MS_All").c_str())->Clone()));
2050  hvec.push_back((TH1F*) (f->Get((path + "/Z_Mass_MS_BB").c_str())->Clone()));
2051  hvec.push_back((TH1F*) (f->Get((path + "/Z_Mass_MS_BE").c_str())->Clone()));
2052  hvec.push_back((TH1F*) (f->Get((path + "/Z_Mass_MS_EE").c_str())->Clone()));
2053  fitZmumuHistograms(h_ZMass_MS_Shift_vs_Regions, h_ZMass_MS_Width_vs_Regions, hvec);
2054  hvec.clear();
2055  h_ZMass_MS_Shift_vs_Regions->SetStats(0);
2056  h_ZMass_MS_Width_vs_Regions->SetStats(0);
2057  h_ZMass_MS_Shift_vs_Regions->Write("", TObject::kOverwrite);
2058  h_ZMass_MS_Width_vs_Regions->Write("", TObject::kOverwrite);
2059 
2060 
2061 
2062  // OLD naming style plots
2063  if (!CheckHistogram(f, (path + "/z-mass_trks").c_str())) return;
2064 
2065  TH1F* h_ZMass_ID = (TH1F*) (f->Get((path + "/z-mass_trks").c_str())->Clone());
2066  h_ZMass_ID->SetTitle("Z Mass ID Tracks");
2067  //fitZmumuMassPlot(h_ZMass_ID);
2068  //h_ZMass_ID->Write("",TObject::kOverwrite);
2069 
2070  if (!CheckHistogram(f, (path + "/z-mass_comb").c_str())) return;
2071 
2072  TH1F* h_ZMass_CB = (TH1F*) (f->Get((path + "/z-mass_comb").c_str())->Clone());
2073  h_ZMass_CB->SetTitle("Z Mass CB Tracks");
2074  //fitZmumuMassPlot(h_ZMass_CB);
2075  //h_ZMass_CB->Write("",TObject::kOverwrite);
2076 
2077 
2078  if (CheckHistogram(f, (path + "/Nevents").c_str())) {
2079  TH1F* h_Nevents = (TH1F*) f->Get((path + "/Nevents").c_str());
2080  TH1F* h_rate = new TH1F("rate", "production rate", 1, 0, 1);
2081  double Ntot = h_Nevents->GetEntries();
2082  double yield = h_ZMass_ID->Integral(h_ZMass_ID->FindBin(80), h_ZMass_ID->FindBin(105));
2083  double rate = yield / Ntot;
2084  double rate_error = sqrt(1 / yield + 1 / Ntot) * yield / Ntot;
2085  //std::cout <<" rate: "<< rate <<" rate_error: "<< rate_error <<std::endl;
2086  h_rate->SetBinContent(1, rate);
2087  h_rate->SetBinError(1, rate_error);
2088  h_rate->Write("rate", TObject::kOverwrite);
2089  }
2090 
2091  f->Write();
2092  }
2093 
2094  void
2096  fitJpsiHistograms(TH1F* hmass, TH1F* hwidth, TH1F* h1[], int n) {
2097  double jpsiPDGmass = 3.097;
2098  double mass = 0.;
2099  double mass_error = 0;
2100  double width = 0;
2101  double width_error = 0;
2102  double maxmass = 0.;
2103  double maxwidth = 0.;
2104  double minwidth = 999;
2105 
2106  hmass->SetMarkerStyle(21);
2107  hwidth->SetMarkerStyle(21);
2108 // TF1 *fitjpsi = new TF1("fitjpsi","gaus",2.9,3.3);
2109 // fitjpsi->SetParNames("Constant","Mean","Width");
2110  TF1* fitjpsi = new TF1("fitjpsi", "gaus", 2.6, 3.6);
2111  // fitjpsi->SetParNames("Constant","Mean","Sigma","Constant","Slope");
2112  fitjpsi->SetLineColor(2);
2113  for (int i = 0; i < n; i++) {
2114  int h1entries = h1[i]->GetEntries();
2115  if (h1entries > 50) {
2116  double mean = h1[i]->GetMean();
2117  double spread = 2 * (h1[i]->GetRMS());
2118  double constantGuess = double(h1entries) / 10.;
2119  fitjpsi->SetParameters(constantGuess, jpsiPDGmass, 0.05);
2120  fitjpsi->SetRange(mean - spread, mean + spread);
2121  h1[i]->Fit("fitjpsi", "RQM");
2122  mean = fitjpsi->GetParameter(1);
2123  spread = 1.2 * (fitjpsi->GetParameter(2));
2124  fitjpsi->SetRange(mean - spread, mean + spread);
2125  h1[i]->Fit("fitjpsi", "RQM");
2126  h1[i]->SetMarkerStyle(21);
2127  mass = fitjpsi->GetParameter(1) - jpsiPDGmass;
2128  mass_error = fitjpsi->GetParError(1);
2129  width = fitjpsi->GetParameter(2);
2130  width_error = fitjpsi->GetParError(2);
2131  hmass->SetBinContent(i + 1, mass);
2132  hmass->SetBinError(i + 1, mass_error);
2133  hwidth->SetBinContent(i + 1, width);
2134  hwidth->SetBinError(i + 1, width_error);
2135  if ((fabs(mass) + mass_error) > maxmass) maxmass = fabs(mass) + mass_error;
2136  if ((fabs(width) + width_error) > maxwidth) maxwidth = fabs(width) + width_error;
2137  if ((fabs(width) - width_error) < minwidth) minwidth = fabs(width) - width_error;
2138  }
2139  }
2140  if (maxmass > 0.1) maxmass = 0.1;
2141  if (maxwidth > 0.2) maxwidth = 0.2;
2142  if (minwidth < 0.) minwidth = 0.;
2143  hmass->SetAxisRange(-maxmass * 1.05, maxmass * 1.05, "Y");
2144 // hwidth->SetAxisRange(0.,maxwidth*1.05,"Y");
2145  if (minwidth < maxwidth) hwidth->SetAxisRange(minwidth * 0.9, maxwidth * 1.05, "Y");
2146 
2147  delete fitjpsi;
2148  }
2149 
2150  void
2152  fitUpsilonHistograms(TH1F* hmass, TH1F* hwidth, TH1F* h1[], int n) {
2153  double upsilonPDGmass = 9.46;
2154  double mass = 0;
2155  double mass_error = 0;
2156  double width = 0;
2157  double width_error = 0;
2158  double maxmass = 0.;
2159  double maxwidth = 0.;
2160  double minwidth = 999;
2161 
2162  hmass->SetMarkerStyle(21);
2163  hwidth->SetMarkerStyle(21);
2164 // TF1 *fitupsi = new TF1("fitupsi","gaus",9.,10.);
2165 // fitupsi->SetParNames("Constant","Mean","Width");
2166  TF1* fitupsi = new TF1("fitupsi", "gaus(0)+pol1(3)", 8.5, 10.5);
2167  fitupsi->SetParNames("Constant", "Mean", "Sigma", "Constant", "Slope");
2168  fitupsi->SetLineColor(2);
2169  for (int i = 0; i < n; i++) {
2170  if (h1[i]->GetEntries() > 20) {
2171  double max = h1[i]->GetBinContent(h1[i]->GetMaximumBin());
2172  fitupsi->SetParameter(1, 9.46);
2173  fitupsi->SetParameter(2, 0.15);
2174  fitupsi->SetParLimits(1, 8., 11.);
2175  fitupsi->SetParLimits(2, 0., 0.5);
2176  fitupsi->SetParameter(0, max);
2177  h1[i]->SetMarkerStyle(21);
2178  h1[i]->Fit("fitupsi", "RQM");
2179  mass = fitupsi->GetParameter(1) - upsilonPDGmass;
2180  mass_error = fitupsi->GetParError(1);
2181  width = fitupsi->GetParameter(2);
2182  width_error = fitupsi->GetParError(2);
2183  hmass->SetBinContent(i + 1, mass);
2184  hmass->SetBinError(i + 1, mass_error);
2185  hwidth->SetBinContent(i + 1, width);
2186  hwidth->SetBinError(i + 1, width_error);
2187  if ((fabs(mass) + mass_error) > maxmass) maxmass = fabs(mass) + mass_error;
2188  if ((fabs(width) + width_error) > maxwidth) maxwidth = fabs(width) + width_error;
2189  if ((fabs(width) - width_error) < minwidth) minwidth = fabs(width) - width_error;
2190  }
2191  }
2192  if (maxmass > 0.1) maxmass = 0.1;
2193  if (maxwidth > 0.4) maxwidth = 0.4;
2194  if (minwidth < 0.) minwidth = 0.;
2195  hmass->SetAxisRange(-maxmass * 1.05, maxmass * 1.05, "Y");
2196  if (minwidth < maxwidth) hwidth->SetAxisRange(minwidth * 0.9, maxwidth * 1.05, "Y");
2197 
2198  delete fitupsi;
2199  }
2200 
2201  void MonitoringFile::fitZmumuHistograms(TH1F* hmass, TH1F* hwidth, std::vector<TH1F*> hvec) {
2202  const double ZPDGmass = 91.1876;
2203  const int size = (int) hvec.size();
2204 
2205  for (int i = 0; i < size; i++) {
2206  double mass = fitZmumuMass(hvec[i]).first.getVal() - ZPDGmass;
2207  double mass_err = fitZmumuMass(hvec[i]).first.getError();
2208  double width = fitZmumuMass(hvec[i]).second.getVal();
2209  double width_err = fitZmumuMass(hvec[i]).second.getError();
2210 
2211  hmass->SetBinContent(i + 1, mass);
2212  hmass->SetBinError(i + 1, mass_err);
2213  hmass->GetXaxis()->SetBinLabel(i + 1, hvec[i]->GetName());
2214  hmass->GetXaxis()->SetTitle("Different Detector Regions");
2215  hmass->SetAxisRange(-3.0, 3.0, "Y");
2216 
2217  hwidth->SetBinContent(i + 1, width);
2218  hwidth->SetBinError(i + 1, width_err);
2219  hwidth->GetXaxis()->SetBinLabel(i + 1, hvec[i]->GetName());
2220  hwidth->GetXaxis()->SetTitle("Different Detector Regions");
2221  hwidth->SetAxisRange(0, 8, "Y");
2222  }
2223  }
2224 
2225  std::pair<RooRealVar, RooRealVar> MonitoringFile::fitZmumuMass(TH1F* hmass) {
2226  // gROOT->ProcessLine("gErrorIgnoreLevel=1001;");
2227  RooAbsPdf::verboseEval(-100); //sami in order to make roofit quiet
2228  RooRealVar m("mass", "dimuon invariable mass", 91.2, 60., 120., "GeV");
2229  RooDataHist* data = 0;
2230  data = new RooDataHist("data", "data", m, hmass);
2231  RooRealVar bwm0("bw_#mu", "bw_#mu", 91.2, 85., 95.);
2232  RooRealVar bwsg("bw_#sigma", "bw_#sigma", 2.4952);
2233  RooBreitWigner bw("bw", "bw", m, bwm0, bwsg);
2234 
2235  RooRealVar cbm0("cb_#mu", "cb_#mu", 0);
2236  RooRealVar cbsg("cb_#sigma", "cb_#sigma", 5., 0.1, 10.);
2237  RooRealVar cbal("cb_#alpha", "cb_#alpha", 1.5, 0.1, 10.);
2238  RooRealVar cbn("cb_n", "cb_n", 1.5, 0.01, 10.);
2239  RooCBShape cb("cb", "cb", m, cbm0, cbsg, cbal, cbn);
2240 
2241  m.setBins(5000);
2242  RooFFTConvPdf bxc("bxc", "BW (X) CB", m, bw, cb);
2243  auto resourceToDelete = bxc.fitTo(*data, RooFit::PrintLevel(-1), RooFit::PrintEvalErrors(-1), RooFit::Warnings(kFALSE));
2244 
2245  RooArgSet* params = bxc.getVariables();
2246  //params->Print("v");
2247  RooRealVar* fit_bwm0 = (RooRealVar*) params->find("bw_#mu");
2248  RooRealVar* fit_cbsg = (RooRealVar*) params->find("cb_#sigma");
2249  //double vfit_bwm0 = fit_bwm0->getVal();
2250  //double vfit_cbsg = fit_cbsg->getVal();
2251  //std::cout <<" vfit_bwm0: "<< vfit_bwm0 << " vfit_cbsg: " << vfit_cbsg << std::endl;
2252  delete data;
2253  delete resourceToDelete;
2254  return std::make_pair(*fit_bwm0, *fit_cbsg);
2255  }
2256 
2257 //void MonitoringFile::fitZmumuMass(TH1F* hmass , RooPlot* frame ){
2259  // gROOT->ProcessLine("gErrorIgnoreLevel=1001;");
2260  RooAbsPdf::verboseEval(-100); //sami in order to make roofit quiet
2261  RooRealVar m("mass", "dimuon invariable mass", 91.2, 60., 120., "GeV");
2262  RooDataHist* data = 0;
2263  data = new RooDataHist("data", "data", m, hmass);
2264  RooRealVar bwm0("bw_#mu", "bw_#mu", 91.2, 85., 95.);
2265  RooRealVar bwsg("bw_#sigma", "bw_#sigma", 2.4952);
2266  RooBreitWigner bw("bw", "bw", m, bwm0, bwsg);
2267 
2268  RooRealVar cbm0("cb_#mu", "cb_#mu", 0);
2269  RooRealVar cbsg("cb_#sigma", "cb_#sigma", 5., 0.1, 10.);
2270  RooRealVar cbal("cb_#alpha", "cb_#alpha", 1.5, 0.1, 10.);
2271  RooRealVar cbn("cb_n", "cb_n", 1.5, 0.01, 10.);
2272  RooCBShape cb("cb", "cb", m, cbm0, cbsg, cbal, cbn);
2273 
2274  m.setBins(5000);
2275  RooFFTConvPdf bxc("bxc", "BW (X) CB", m, bw, cb);
2276  auto resourceToDelete = bxc.fitTo(*data, RooFit::PrintLevel(-1), RooFit::PrintEvalErrors(-1), RooFit::Warnings(kFALSE));
2277  RooPlot* frame = m.frame();
2278  data->plotOn(frame, RooFit::MarkerSize(0.9));
2279  bxc.paramOn(frame, RooFit::Format("NELU", RooFit::AutoPrecision(2)), RooFit::Layout(0.1, 0.4, 0.9));
2280  bxc.plotOn(frame, RooFit::LineColor(kYellow));
2281  cb.plotOn(frame, RooFit::LineColor(kRed));
2282  bw.plotOn(frame, RooFit::LineStyle(kDashed));
2283  delete data;
2284  delete resourceToDelete;
2285  }
2286 }
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
dqutils::MonitoringFile::fitMergedFile_IDPerfMonManager
static void fitMergedFile_IDPerfMonManager(const std::string &inFileName, bool isIncremental=false)
Methods for creating ID Alignment summary plots on merged files.
Definition: MonitoringFile_IDPerfPostProcess.cxx:38
mean
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
Definition: dependence.cxx:254
dqutils::MonitoringFile::fitZmumuMassPlot
static void fitZmumuMassPlot(TH1F *hmass)
Definition: MonitoringFile_IDPerfPostProcess.cxx:2258
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:128
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
Base_Fragment.mass
mass
Definition: Sherpa_i/share/common/Base_Fragment.py:59
dqutils::MonitoringFile::CheckHistogram
static bool CheckHistogram(TFile *f, const char *HistoName)
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
StateLessPT_NewConfig.Format
Format
Definition: StateLessPT_NewConfig.py:146
ConvertOldUJHistosToNewHistos.etaBins
list etaBins
Definition: ConvertOldUJHistosToNewHistos.py:145
dqutils::MonitoringFile::fitMergedFile_IDPerfMonJpsi
static void fitMergedFile_IDPerfMonJpsi(TFile *f, const std::string &run_dir, const std::string &TriggerName)
Definition: MonitoringFile_IDPerfPostProcess.cxx:751
GetEntries
TGraphErrors * GetEntries(TH2F *histo)
Definition: TRTCalib_makeplots.cxx:4019
read_hist_ntuple.h1
h1
Definition: read_hist_ntuple.py:21
dqutils::MonitoringFile::fitMergedFile_IDPerfMonZee
static void fitMergedFile_IDPerfMonZee(TFile *f, const std::string &run_dir, const std::string &TriggerName)
Definition: MonitoringFile_IDPerfPostProcess.cxx:1554
dqutils::MonitoringFile::fitMergedFile_IDPerfMonZMM
static void fitMergedFile_IDPerfMonZMM(TFile *f, const std::string &run_dir, const std::string &TriggerName)
Definition: MonitoringFile_IDPerfPostProcess.cxx:1955
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
dqutils::MonitoringFile::fitZmumuMass
static std::pair< RooRealVar, RooRealVar > fitZmumuMass(TH1F *hmass)
Definition: MonitoringFile_IDPerfPostProcess.cxx:2225
dqutils::MonitoringFile::fitZmumuHistograms
static void fitZmumuHistograms(TH1F *hmass, TH1F *hwidth, std::vector< TH1F * > hvec)
Definition: MonitoringFile_IDPerfPostProcess.cxx:2201
lumiFormat.i
int i
Definition: lumiFormat.py:85
python.TrigEgammaMonitorHelper.TProfile
def TProfile(*args, **kwargs)
Definition: TrigEgammaMonitorHelper.py:81
beamspotman.n
n
Definition: beamspotman.py:731
covarianceTool.title
title
Definition: covarianceTool.py:542
hist_file_dump.f
f
Definition: hist_file_dump.py:135
dqutils::MonitoringFile::fitMergedFile_IDPerfMonUpsilon
static void fitMergedFile_IDPerfMonUpsilon(TFile *f, const std::string &run_dir, const std::string &TriggerName)
Definition: MonitoringFile_IDPerfPostProcess.cxx:1191
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
dqutils
Definition: CoolMdt.h:76
dqutils::MonitoringFile::ProcessAsymHistograms
static void ProcessAsymHistograms(TH1F *m_neg, TH1F *m_pos, TH1F *m_asym)
Definition: MonitoringFile_IDAlignPostProcess.cxx:3107
SCT_CalibAlgs::nbins
@ nbins
Definition: SCT_CalibNumbers.h:10
MonitoringFile.h
StateLessPT_NewConfig.Layout
Layout
Definition: StateLessPT_NewConfig.py:159
Base_Fragment.width
width
Definition: Sherpa_i/share/common/Base_Fragment.py:59
python.CaloScaleNoiseConfig.str
str
Definition: CaloScaleNoiseConfig.py:78
dqutils::MonitoringFile::fitUpsilonHistograms
static void fitUpsilonHistograms(TH1F *hmass, TH1F *hwidth, TH1F *h1[], int n)
Definition: MonitoringFile_IDPerfPostProcess.cxx:2152
dqutils::MonitoringFile::fitJpsiHistograms
static void fitJpsiHistograms(TH1F *hmass, TH1F *hwidth, TH1F *h1[], int n)
Definition: MonitoringFile_IDPerfPostProcess.cxx:2096
str
Definition: BTagTrackIpAccessor.cxx:11
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
dqutils::MonitoringFile::fitMergedFile_IDPerfMonKshort
static void fitMergedFile_IDPerfMonKshort(TFile *f, const std::string &run_dir, const std::string &TriggerName)
Definition: MonitoringFile_IDPerfPostProcess.cxx:301
dqutils::MonitoringFile::fitMergedFile_IDPerfMonWenu
static void fitMergedFile_IDPerfMonWenu(TFile *f, const std::string &run_dir, const std::string &TriggerName)
Definition: MonitoringFile_IDPerfPostProcess.cxx:1754
PowhegControl_ttFCNC_NLO.params
params
Definition: PowhegControl_ttFCNC_NLO.py:226