ATLAS Offline Software
MonitoringFile_RPCPostProcess.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 // Class for the RPC merge histogram and fill the COOL DB
7 // author Michele Bianco michele.bianco@le.infn.it, Gabriele Chiodini gabriele.chiodini@le.infn.it
8 // and Angelo Guida angelo.guida@le.infn.it
9 // 08/April/2009
10 //************************************************
11 
14 
15 #include <iostream>
16 #include <iomanip>
17 #include <fstream>
18 #include <cmath>
19 #include <cstdlib>
20 
21 #include "TClass.h"
22 #include "TKey.h"
23 #include "CxxUtils/StringUtils.h"
24 
25 namespace {
26  void
27  writeIfValid(TH1F* pH) {
28  if (pH) pH->Write("", TObject::kOverwrite);
29  }
30 
31  void
32  fillIfValid(TH1F* pH, float val) {
33  if (pH) pH->Fill(val);
34  return;
35  }
36 
37  float
38  getBinContentIfValid(TH1F* pH, int binIdx) {
39  float result = -9999;
40  if (pH) result = pH->GetBinContent(binIdx);
41  return result;
42  }
43 
44  float
45  getBinErrorIfValid(TH1F* pH, int binIdx) {
46  float result = -1;
47  if (pH) result = pH->GetBinError(binIdx);
48  return result;
49  }
50  bool
51  panelOk(const TH1F* pPanel, int ib){
52  bool result = true;
53  if (pPanel and (pPanel->GetBinContent(ib + 1) == 0) ){
54  result = false;
55  }
56  return result;
57  }
58  void
59  writeToFile(TDirectory* pDir, TH1F* pH1, TH1F* pH2 = nullptr, TH1F* pH3 = nullptr){
60  if (not pDir) return; //do nothing
61  pDir->cd();
62  writeIfValid(pH1);
63  writeIfValid(pH2);
64  writeIfValid(pH3);
65  }
66  auto
67  safelyTakeLog(auto f){
68  if (f > 0) {
69  return log10(f);
70  }
71  return -10.;
72  }
73  bool
74  isASide( TH1F* pH, int idx){
75  return (idx>pH->GetNbinsX() / 2);
76  }
77  void
78  fillAorC(bool isA, TH1F* pA, TH1F* pC, double val){
79  if (isA){
80  fillIfValid(pA,val);
81  } else {
82  fillIfValid(pC,val);
83  }
84  }
85 }
86 
87 namespace dqutils {
88  void
89  MonitoringFile::RPCPostProcess(const std::string& inFilename, bool /* isIncremental */) {
90  bool applyEffThreshold = true;
91  bool EffThreshold = false;
92  bool printout = true;
93  float Minimum_efficiency = 0.5;
94  TFile* f = TFile::Open(inFilename.c_str(), "UPDATE");
95  if (f == 0) {
96  std::cerr << "MonitoringFile::RPCPostProcess(): "
97  << "Input file not opened \n";
98  return;
99  }
100  if (f->GetSize() < 1000.) {
101  std::cerr << "MonitoringFile::RPCPostProcess(): "
102  << "Input file empty \n";
103  return;
104  }
105  CoolRpc coolrpc;
106 
107  // get run directory name
108  std::string run_dir;
109  TIter next_run(f->GetListOfKeys());
110  TKey* key_run(0);
111  while ((key_run = dynamic_cast<TKey*>(next_run())) != 0) {
112  TObject* obj_run = key_run->ReadObj();
113  TDirectory* tdir_run = dynamic_cast<TDirectory*>(obj_run);
114  if (tdir_run != 0) {
115  std::string tdir_run_name(tdir_run->GetName());
116  if (tdir_run_name.find("run") != std::string::npos) {
117  run_dir = std::move(tdir_run_name);
118 
119  int run_number = CxxUtils::atoi(run_dir.substr(4, run_dir.size() - 4));
120  std::cout << "run_number rpc monitoring " << run_number << std::endl;
121 
122  std::string pathRawMon = run_dir + "/Muon/MuonRawDataMonitoring/RPC/";
123  std::string pathTrackMon = run_dir + "/Muon/MuonRawDataMonitoring/RPCStandAloneTrackMon/";
124 
125  std::string dir_ov_raw = pathRawMon + "Overview/";
126  std::string dir_sum_raw = pathRawMon + "Summary/";
127  std::string dir_dqmf_raw = pathRawMon + "Dqmf/";
128 
129  std::string dir_sideA_track = pathTrackMon + "RPCBA/";
130  std::string dir_sideC_track = pathTrackMon + "RPCBC/";
131  std::string dir_glob_track = pathTrackMon + "GLOBAL/";
132  std::string dir_sum_track = pathTrackMon + "Summary/";
133  std::string dir_dqmf_track = pathTrackMon + "Dqmf/";
134  std::string dir_trigger_track = pathTrackMon + "TriggerEfficiency/";
135 
136  double n_hit_f, n_tr_p, panel_eff, panel_err_eff;
137  double nEta, nPhi, nEtaPhi, gapEff = 0.0, gapErrEff = 0.0;
138  double res_mean, res2_mean, res_RMS;
139  double panel_occ;
140  double panelCS, panelCS2, panelCS_entries, panelCS_mean, panelCS2_mean, panelCS_RMS;
141  double Time_mean, Time2_mean, Time_RMS;
142  double noiseCorr, noiseCorrErr;
143  double noiseTot, noiseTotErr;
144  double noiseErrNorm;
145 
146  // trigger efficiency
147  std::string METracks_name = dir_trigger_track + "hMEtracks";
148  std::string MuctpiThr0_name = dir_trigger_track + "hRPCMuctpiThr0";
149  std::string MuctpiThr1_name = dir_trigger_track + "hRPCMuctpiThr1";
150  std::string MuctpiThr2_name = dir_trigger_track + "hRPCMuctpiThr2";
151  std::string MuctpiThr3_name = dir_trigger_track + "hRPCMuctpiThr3";
152  std::string MuctpiThr4_name = dir_trigger_track + "hRPCMuctpiThr4";
153  std::string MuctpiThr5_name = dir_trigger_track + "hRPCMuctpiThr5";
154  std::string PadThr0_name = dir_trigger_track + "hRPCPadThr0";
155  std::string PadThr1_name = dir_trigger_track + "hRPCPadThr1";
156  std::string PadThr2_name = dir_trigger_track + "hRPCPadThr2";
157  std::string PadThr3_name = dir_trigger_track + "hRPCPadThr3";
158  std::string PadThr4_name = dir_trigger_track + "hRPCPadThr4";
159  std::string PadThr5_name = dir_trigger_track + "hRPCPadThr5";
160  std::string PhiEtaCoinThr0_name = dir_trigger_track + "hRPCPhiEtaCoinThr0";
161  std::string PhiEtaCoinThr1_name = dir_trigger_track + "hRPCPhiEtaCoinThr1";
162  std::string PhiEtaCoinThr2_name = dir_trigger_track + "hRPCPhiEtaCoinThr2";
163  std::string PhiEtaCoinThr3_name = dir_trigger_track + "hRPCPhiEtaCoinThr3";
164  std::string PhiEtaCoinThr4_name = dir_trigger_track + "hRPCPhiEtaCoinThr4";
165  std::string PhiEtaCoinThr5_name = dir_trigger_track + "hRPCPhiEtaCoinThr5";
166 
167  std::string MuctpiThr_eff0_name = dir_trigger_track + "hRPCMuctpiThr_eff0";
168  std::string MuctpiThr_eff1_name = dir_trigger_track + "hRPCMuctpiThr_eff1";
169  std::string MuctpiThr_eff2_name = dir_trigger_track + "hRPCMuctpiThr_eff2";
170  std::string MuctpiThr_eff3_name = dir_trigger_track + "hRPCMuctpiThr_eff3";
171  std::string MuctpiThr_eff4_name = dir_trigger_track + "hRPCMuctpiThr_eff4";
172  std::string MuctpiThr_eff5_name = dir_trigger_track + "hRPCMuctpiThr_eff5";
173  std::string PadThr_eff0_name = dir_trigger_track + "hRPCPadThr_eff0";
174  std::string PadThr_eff1_name = dir_trigger_track + "hRPCPadThr_eff1";
175  std::string PadThr_eff2_name = dir_trigger_track + "hRPCPadThr_eff2";
176  std::string PadThr_eff3_name = dir_trigger_track + "hRPCPadThr_eff3";
177  std::string PadThr_eff4_name = dir_trigger_track + "hRPCPadThr_eff4";
178  std::string PadThr_eff5_name = dir_trigger_track + "hRPCPadThr_eff5";
179  std::string PhiEtaCoinThr_eff0_name = dir_trigger_track + "hRPCPhiEtaCoinThr_eff0";
180  std::string PhiEtaCoinThr_eff1_name = dir_trigger_track + "hRPCPhiEtaCoinThr_eff1";
181  std::string PhiEtaCoinThr_eff2_name = dir_trigger_track + "hRPCPhiEtaCoinThr_eff2";
182  std::string PhiEtaCoinThr_eff3_name = dir_trigger_track + "hRPCPhiEtaCoinThr_eff3";
183  std::string PhiEtaCoinThr_eff4_name = dir_trigger_track + "hRPCPhiEtaCoinThr_eff4";
184  std::string PhiEtaCoinThr_eff5_name = dir_trigger_track + "hRPCPhiEtaCoinThr_eff5";
185 
186 
187  if (RPCCheckHistogram(f,
188  METracks_name.c_str()) &&
189  RPCCheckHistogram(f, MuctpiThr0_name.c_str()) && RPCCheckHistogram(f, MuctpiThr_eff0_name.c_str())) {
190  TH1I* hist_METracks = (TH1I*) (f->Get(METracks_name.c_str()));
191  TH1I* hist_MuctpiThr0 = (TH1I*) (f->Get(MuctpiThr0_name.c_str()));
192  TH1I* hist_MuctpiThr1 = (TH1I*) (f->Get(MuctpiThr1_name.c_str()));
193  TH1I* hist_MuctpiThr2 = (TH1I*) (f->Get(MuctpiThr2_name.c_str()));
194  TH1I* hist_MuctpiThr3 = (TH1I*) (f->Get(MuctpiThr3_name.c_str()));
195  TH1I* hist_MuctpiThr4 = (TH1I*) (f->Get(MuctpiThr4_name.c_str()));
196  TH1I* hist_MuctpiThr5 = (TH1I*) (f->Get(MuctpiThr5_name.c_str()));
197  TH1I* hist_PadThr0 = (TH1I*) (f->Get(PadThr0_name.c_str()));
198  TH1I* hist_PadThr1 = (TH1I*) (f->Get(PadThr1_name.c_str()));
199  TH1I* hist_PadThr2 = (TH1I*) (f->Get(PadThr2_name.c_str()));
200  TH1I* hist_PadThr3 = (TH1I*) (f->Get(PadThr3_name.c_str()));
201  TH1I* hist_PadThr4 = (TH1I*) (f->Get(PadThr4_name.c_str()));
202  TH1I* hist_PadThr5 = (TH1I*) (f->Get(PadThr5_name.c_str()));
203  TH1I* hist_PhiEtaCoinThr0 = (TH1I*) (f->Get(PhiEtaCoinThr0_name.c_str()));
204  TH1I* hist_PhiEtaCoinThr1 = (TH1I*) (f->Get(PhiEtaCoinThr1_name.c_str()));
205  TH1I* hist_PhiEtaCoinThr2 = (TH1I*) (f->Get(PhiEtaCoinThr2_name.c_str()));
206  TH1I* hist_PhiEtaCoinThr3 = (TH1I*) (f->Get(PhiEtaCoinThr3_name.c_str()));
207  TH1I* hist_PhiEtaCoinThr4 = (TH1I*) (f->Get(PhiEtaCoinThr4_name.c_str()));
208  TH1I* hist_PhiEtaCoinThr5 = (TH1I*) (f->Get(PhiEtaCoinThr5_name.c_str()));
209  TH1I* hist_MuctpiThr_eff0 = (TH1I*) (f->Get(MuctpiThr_eff0_name.c_str()));
210  TH1I* hist_MuctpiThr_eff1 = (TH1I*) (f->Get(MuctpiThr_eff1_name.c_str()));
211  TH1I* hist_MuctpiThr_eff2 = (TH1I*) (f->Get(MuctpiThr_eff2_name.c_str()));
212  TH1I* hist_MuctpiThr_eff3 = (TH1I*) (f->Get(MuctpiThr_eff3_name.c_str()));
213  TH1I* hist_MuctpiThr_eff4 = (TH1I*) (f->Get(MuctpiThr_eff4_name.c_str()));
214  TH1I* hist_MuctpiThr_eff5 = (TH1I*) (f->Get(MuctpiThr_eff5_name.c_str()));
215  TH1I* hist_PadThr_eff0 = (TH1I*) (f->Get(PadThr_eff0_name.c_str()));
216  TH1I* hist_PadThr_eff1 = (TH1I*) (f->Get(PadThr_eff1_name.c_str()));
217  TH1I* hist_PadThr_eff2 = (TH1I*) (f->Get(PadThr_eff2_name.c_str()));
218  TH1I* hist_PadThr_eff3 = (TH1I*) (f->Get(PadThr_eff3_name.c_str()));
219  TH1I* hist_PadThr_eff4 = (TH1I*) (f->Get(PadThr_eff4_name.c_str()));
220  TH1I* hist_PadThr_eff5 = (TH1I*) (f->Get(PadThr_eff5_name.c_str()));
221  TH1I* hist_PhiEtaCoinThr_eff0 = (TH1I*) (f->Get(PhiEtaCoinThr_eff0_name.c_str()));
222  TH1I* hist_PhiEtaCoinThr_eff1 = (TH1I*) (f->Get(PhiEtaCoinThr_eff1_name.c_str()));
223  TH1I* hist_PhiEtaCoinThr_eff2 = (TH1I*) (f->Get(PhiEtaCoinThr_eff2_name.c_str()));
224  TH1I* hist_PhiEtaCoinThr_eff3 = (TH1I*) (f->Get(PhiEtaCoinThr_eff3_name.c_str()));
225  TH1I* hist_PhiEtaCoinThr_eff4 = (TH1I*) (f->Get(PhiEtaCoinThr_eff4_name.c_str()));
226  TH1I* hist_PhiEtaCoinThr_eff5 = (TH1I*) (f->Get(PhiEtaCoinThr_eff5_name.c_str()));
227 
228  int nb = hist_METracks->GetNbinsX();
229  double Ly_eff, Ly_effErr;
230  auto calculateErr = [](float hitOn, float trPrj) -> double {
231  return std::sqrt(std::abs(hitOn) / trPrj) *
232  std::sqrt(1. - std::abs(hitOn) / trPrj) / std::sqrt(trPrj);
233  };
234  for (int ib = 0; ib != nb; ib++) {
235  float n_Ly_hitOn = hist_MuctpiThr0->GetBinContent(ib + 1);
236  float n_Ly_TrPrj = hist_METracks->GetBinContent(ib + 1);
237  if (n_Ly_TrPrj<= 0) continue;
238  //MuctpiThr0
239  Ly_eff = float(n_Ly_hitOn) / float(n_Ly_TrPrj);
240 
241  Ly_effErr = calculateErr(n_Ly_hitOn, n_Ly_TrPrj);
242  hist_MuctpiThr_eff0->SetBinContent(ib + 1, Ly_eff);
243  hist_MuctpiThr_eff0->SetBinError(ib + 1, Ly_effErr);
244 
245  //MuctpiThr1
246  n_Ly_hitOn = hist_MuctpiThr1->GetBinContent(ib + 1);
247  Ly_eff = float(n_Ly_hitOn) / float(n_Ly_TrPrj);
248  Ly_effErr = calculateErr(n_Ly_hitOn, n_Ly_TrPrj);
249  hist_MuctpiThr_eff1->SetBinContent(ib + 1, Ly_eff);
250  hist_MuctpiThr_eff1->SetBinError(ib + 1, Ly_effErr);
251  //MuctpiThr2
252  n_Ly_hitOn = hist_MuctpiThr2->GetBinContent(ib + 1);
253  Ly_eff = float(n_Ly_hitOn) / float(n_Ly_TrPrj);
254 
255  Ly_effErr = calculateErr(n_Ly_hitOn, n_Ly_TrPrj);
256  hist_MuctpiThr_eff2->SetBinContent(ib + 1, Ly_eff);
257  hist_MuctpiThr_eff2->SetBinError(ib + 1, Ly_effErr);
258  //MuctpiThr3
259  n_Ly_hitOn = hist_MuctpiThr3->GetBinContent(ib + 1);
260  Ly_eff = float(n_Ly_hitOn) / float(n_Ly_TrPrj);
261 
262  Ly_effErr = calculateErr(n_Ly_hitOn, n_Ly_TrPrj);
263  hist_MuctpiThr_eff3->SetBinContent(ib + 1, Ly_eff);
264  hist_MuctpiThr_eff3->SetBinError(ib + 1, Ly_effErr);
265  //MuctpiThr4
266  n_Ly_hitOn = hist_MuctpiThr4->GetBinContent(ib + 1);
267  Ly_eff = float(n_Ly_hitOn) / float(n_Ly_TrPrj);
268 
269  Ly_effErr = calculateErr(n_Ly_hitOn, n_Ly_TrPrj);
270  hist_MuctpiThr_eff4->SetBinContent(ib + 1, Ly_eff);
271  hist_MuctpiThr_eff4->SetBinError(ib + 1, Ly_effErr);
272  //MuctpiThr5
273  n_Ly_hitOn = hist_MuctpiThr5->GetBinContent(ib + 1);
274  Ly_eff = float(n_Ly_hitOn) / float(n_Ly_TrPrj);
275 
276  Ly_effErr = calculateErr(n_Ly_hitOn, n_Ly_TrPrj);
277  hist_MuctpiThr_eff5->SetBinContent(ib + 1, Ly_eff);
278  hist_MuctpiThr_eff5->SetBinError(ib + 1, Ly_effErr);
279  //PadThr0
280  n_Ly_hitOn = hist_PadThr0->GetBinContent(ib + 1);
281  Ly_eff = float(n_Ly_hitOn) / float(n_Ly_TrPrj);
282 
283  Ly_effErr = calculateErr(n_Ly_hitOn, n_Ly_TrPrj);
284  hist_PadThr_eff0->SetBinContent(ib + 1, Ly_eff);
285  hist_PadThr_eff0->SetBinError(ib + 1, Ly_effErr);
286  //PadThr1
287  n_Ly_hitOn = hist_PadThr1->GetBinContent(ib + 1);
288  Ly_eff = float(n_Ly_hitOn) / float(n_Ly_TrPrj);
289 
290  Ly_effErr = calculateErr(n_Ly_hitOn, n_Ly_TrPrj);
291  hist_PadThr_eff1->SetBinContent(ib + 1, Ly_eff);
292  hist_PadThr_eff1->SetBinError(ib + 1, Ly_effErr);
293  //PadThr2
294  n_Ly_hitOn = hist_PadThr2->GetBinContent(ib + 1);
295  Ly_eff = float(n_Ly_hitOn) / float(n_Ly_TrPrj);
296 
297  Ly_effErr = calculateErr(n_Ly_hitOn, n_Ly_TrPrj);
298  hist_PadThr_eff2->SetBinContent(ib + 1, Ly_eff);
299  hist_PadThr_eff2->SetBinError(ib + 1, Ly_effErr);
300  //PadThr3
301  n_Ly_hitOn = hist_PadThr3->GetBinContent(ib + 1);
302  Ly_eff = float(n_Ly_hitOn) / float(n_Ly_TrPrj);
303 
304  Ly_effErr = calculateErr(n_Ly_hitOn, n_Ly_TrPrj);
305  hist_PadThr_eff3->SetBinContent(ib + 1, Ly_eff);
306  hist_PadThr_eff3->SetBinError(ib + 1, Ly_effErr);
307  //PadThr4
308  n_Ly_hitOn = hist_PadThr4->GetBinContent(ib + 1);
309  Ly_eff = float(n_Ly_hitOn) / float(n_Ly_TrPrj);
310 
311  Ly_effErr = calculateErr(n_Ly_hitOn, n_Ly_TrPrj);
312  hist_PadThr_eff4->SetBinContent(ib + 1, Ly_eff);
313  hist_PadThr_eff4->SetBinError(ib + 1, Ly_effErr);
314  //PadThr5
315  n_Ly_hitOn = hist_PadThr5->GetBinContent(ib + 1);
316  Ly_eff = float(n_Ly_hitOn) / float(n_Ly_TrPrj);
317 
318  Ly_effErr = calculateErr(n_Ly_hitOn, n_Ly_TrPrj);
319  hist_PadThr_eff5->SetBinContent(ib + 1, Ly_eff);
320  hist_PadThr_eff5->SetBinError(ib + 1, Ly_effErr);
321  //PhiEtaCoinThr0
322  n_Ly_hitOn = hist_PhiEtaCoinThr0->GetBinContent(ib + 1);
323  Ly_eff = float(n_Ly_hitOn) / float(n_Ly_TrPrj);
324 
325  Ly_effErr = calculateErr(n_Ly_hitOn, n_Ly_TrPrj);
326  hist_PhiEtaCoinThr_eff0->SetBinContent(ib + 1, Ly_eff);
327  hist_PhiEtaCoinThr_eff0->SetBinError(ib + 1, Ly_effErr);
328  //PhiEtaCoinThr1
329  n_Ly_hitOn = hist_PhiEtaCoinThr1->GetBinContent(ib + 1);
330  Ly_eff = float(n_Ly_hitOn) / float(n_Ly_TrPrj);
331 
332  Ly_effErr = calculateErr(n_Ly_hitOn, n_Ly_TrPrj);
333  hist_PhiEtaCoinThr_eff1->SetBinContent(ib + 1, Ly_eff);
334  hist_PhiEtaCoinThr_eff1->SetBinError(ib + 1, Ly_effErr);
335  //PhiEtaCoinThr2
336  n_Ly_hitOn = hist_PhiEtaCoinThr2->GetBinContent(ib + 1);
337  Ly_eff = float(n_Ly_hitOn) / float(n_Ly_TrPrj);
338 
339  Ly_effErr = calculateErr(n_Ly_hitOn, n_Ly_TrPrj);
340  hist_PhiEtaCoinThr_eff2->SetBinContent(ib + 1, Ly_eff);
341  hist_PhiEtaCoinThr_eff2->SetBinError(ib + 1, Ly_effErr);
342  //PhiEtaCoinThr3
343  n_Ly_hitOn = hist_PhiEtaCoinThr3->GetBinContent(ib + 1);
344  Ly_eff = float(n_Ly_hitOn) / float(n_Ly_TrPrj);
345 
346  Ly_effErr = calculateErr(n_Ly_hitOn, n_Ly_TrPrj);
347  hist_PhiEtaCoinThr_eff3->SetBinContent(ib + 1, Ly_eff);
348  hist_PhiEtaCoinThr_eff3->SetBinError(ib + 1, Ly_effErr);
349  //PhiEtaCoinThr4
350  n_Ly_hitOn = hist_PhiEtaCoinThr4->GetBinContent(ib + 1);
351  Ly_eff = float(n_Ly_hitOn) / float(n_Ly_TrPrj);
352 
353  Ly_effErr = calculateErr(n_Ly_hitOn, n_Ly_TrPrj);
354  hist_PhiEtaCoinThr_eff4->SetBinContent(ib + 1, Ly_eff);
355  hist_PhiEtaCoinThr_eff4->SetBinError(ib + 1, Ly_effErr);
356  //PhiEtaCoinThr5
357  n_Ly_hitOn = hist_PhiEtaCoinThr5->GetBinContent(ib + 1);
358  Ly_eff = float(n_Ly_hitOn) / float(n_Ly_TrPrj);
359 
360  Ly_effErr = calculateErr(n_Ly_hitOn, n_Ly_TrPrj);
361  hist_PhiEtaCoinThr_eff5->SetBinContent(ib + 1, Ly_eff);
362  hist_PhiEtaCoinThr_eff5->SetBinError(ib + 1, Ly_effErr);
363 
364  }
365 
366  // write out histogram
367  TDirectory* dir = f->GetDirectory(dir_trigger_track.c_str());
368  if (dir != 0) {
369  dir->cd();
370  hist_MuctpiThr_eff0->Write("", TObject::kOverwrite);
371  hist_MuctpiThr_eff1->Write("", TObject::kOverwrite);
372  hist_MuctpiThr_eff2->Write("", TObject::kOverwrite);
373  hist_MuctpiThr_eff3->Write("", TObject::kOverwrite);
374  hist_MuctpiThr_eff4->Write("", TObject::kOverwrite);
375  hist_MuctpiThr_eff5->Write("", TObject::kOverwrite);
376  hist_PadThr_eff0->Write("", TObject::kOverwrite);
377  hist_PadThr_eff1->Write("", TObject::kOverwrite);
378  hist_PadThr_eff2->Write("", TObject::kOverwrite);
379  hist_PadThr_eff3->Write("", TObject::kOverwrite);
380  hist_PadThr_eff4->Write("", TObject::kOverwrite);
381  hist_PadThr_eff5->Write("", TObject::kOverwrite);
382  hist_PhiEtaCoinThr_eff0->Write("", TObject::kOverwrite);
383  hist_PhiEtaCoinThr_eff1->Write("", TObject::kOverwrite);
384  hist_PhiEtaCoinThr_eff2->Write("", TObject::kOverwrite);
385  hist_PhiEtaCoinThr_eff3->Write("", TObject::kOverwrite);
386  hist_PhiEtaCoinThr_eff4->Write("", TObject::kOverwrite);
387  hist_PhiEtaCoinThr_eff5->Write("", TObject::kOverwrite);
388  }
389  }
390 
391 
392  // layer efficiency
393  std::string LyHit_name, LyPrj_name, LyEff_name;
394  LyHit_name = dir_glob_track + "Hit_on_Track_Layer";
395  LyPrj_name = dir_glob_track + "Track_Projected_on_Layer";
396  LyEff_name = dir_glob_track + "Layer_Efficiency";
397 
398  if (RPCCheckHistogram(f, LyHit_name.c_str()) &&
399  RPCCheckHistogram(f, LyPrj_name.c_str()) && RPCCheckHistogram(f, LyEff_name.c_str())) {
400  TH1I* hist_LyHit = (TH1I*) (f->Get(LyHit_name.c_str()));
401  TH1I* hist_LyPrj = (TH1I*) (f->Get(LyPrj_name.c_str()));
402  TH1F* hist_LyEff = (TH1F*) (f->Get(LyEff_name.c_str()));
403 
404  int nb = hist_LyEff->GetNbinsX();
405  double Ly_eff, Ly_effErr;
406  for (int ib = 0; ib != nb; ib++) {
407  float n_Ly_hitOn = hist_LyHit->GetBinContent(ib + 1);
408  float n_Ly_TrPrj = hist_LyPrj->GetBinContent(ib + 1);
409 
410  if (n_Ly_TrPrj > 0) {
411  Ly_eff = float(n_Ly_hitOn) / float(n_Ly_TrPrj);
412  Ly_effErr = sqrt(fabs(n_Ly_hitOn) / n_Ly_TrPrj) *
413  sqrt(1. - fabs(n_Ly_hitOn) / n_Ly_TrPrj) /
414  sqrt(n_Ly_TrPrj);
415  hist_LyEff->SetBinContent(ib + 1, Ly_eff);
416  hist_LyEff->SetBinError(ib + 1, Ly_effErr);
417  }
418  }
419 
420  // write out histogram
421  TDirectory* dir = f->GetDirectory(dir_glob_track.c_str());
422  writeToFile(dir, hist_LyEff);
423  }
424 
425 
426  // layer efficiency Side A
427  std::string LyHit_SideA_name, LyPrj_SideA_name, LyEff_SideA_name;
428  LyHit_SideA_name = dir_sideA_track + "Layer_HitOnTrack_sideA";
429  LyPrj_SideA_name = dir_sideA_track + "Layer_TrackProj_sideA";
430  LyEff_SideA_name = dir_sideA_track + "Layer_Efficiency_sideA";
431 
432  if (RPCCheckHistogram(f, LyHit_SideA_name.c_str()) &&
433  RPCCheckHistogram(f, LyPrj_SideA_name.c_str()) &&
434  RPCCheckHistogram(f, LyEff_SideA_name.c_str())) {
435  TH1I* hist_LyHit_SideA = (TH1I*) (f->Get(LyHit_SideA_name.c_str()));
436  TH1I* hist_LyPrj_SideA = (TH1I*) (f->Get(LyPrj_SideA_name.c_str()));
437  TH1F* hist_LyEff_SideA = (TH1F*) (f->Get(LyEff_SideA_name.c_str()));
438 
439  int nb = hist_LyEff_SideA->GetNbinsX();
440  double Ly_eff_SideA, Ly_effErr_SideA;
441  for (int ib = 0; ib != nb; ib++) {
442  float n_Ly_hitOn_SideA = hist_LyHit_SideA->GetBinContent(ib + 1);
443  float n_Ly_TrPrj_SideA = hist_LyPrj_SideA->GetBinContent(ib + 1);
444 
445  if (n_Ly_TrPrj_SideA > 0) {
446  Ly_eff_SideA = float(n_Ly_hitOn_SideA) / float(n_Ly_TrPrj_SideA);
447 
448  Ly_effErr_SideA = sqrt(fabs(n_Ly_hitOn_SideA) / n_Ly_TrPrj_SideA) *
449  sqrt(1. - fabs(n_Ly_hitOn_SideA) / n_Ly_TrPrj_SideA) /
450  sqrt(n_Ly_TrPrj_SideA);
451  hist_LyEff_SideA->SetBinContent(ib + 1, Ly_eff_SideA);
452  hist_LyEff_SideA->SetBinError(ib + 1, Ly_effErr_SideA);
453  }
454  }
455 
456  // write out histogram
457  TDirectory* dir = f->GetDirectory(dir_sideA_track.c_str());
458  writeToFile(dir, hist_LyEff_SideA);
459 
460  }
461 
462  // layer efficiency Side C
463  std::string LyHit_SideC_name, LyPrj_SideC_name, LyEff_SideC_name;
464  LyHit_SideC_name = dir_sideC_track + "Layer_HitOnTrack_sideC";
465  LyPrj_SideC_name = dir_sideC_track + "Layer_TrackProj_sideC";
466  LyEff_SideC_name = dir_sideC_track + "Layer_Efficiency_sideC";
467 
468  if (RPCCheckHistogram(f, LyHit_SideC_name.c_str()) &&
469  RPCCheckHistogram(f, LyPrj_SideC_name.c_str()) &&
470  RPCCheckHistogram(f, LyEff_SideC_name.c_str())) {
471  TH1I* hist_LyHit_SideC = (TH1I*) (f->Get(LyHit_SideC_name.c_str()));
472  TH1I* hist_LyPrj_SideC = (TH1I*) (f->Get(LyPrj_SideC_name.c_str()));
473  TH1F* hist_LyEff_SideC = (TH1F*) (f->Get(LyEff_SideC_name.c_str()));
474 
475  int nb = hist_LyEff_SideC->GetNbinsX();
476  double Ly_eff_SideC, Ly_effErr_SideC;
477  for (int ib = 0; ib != nb; ib++) {
478  float n_Ly_hitOn_SideC = hist_LyHit_SideC->GetBinContent(ib + 1);
479  float n_Ly_TrPrj_SideC = hist_LyPrj_SideC->GetBinContent(ib + 1);
480 
481  if (n_Ly_TrPrj_SideC > 0) {
482  Ly_eff_SideC = float(n_Ly_hitOn_SideC) / float(n_Ly_TrPrj_SideC);
483 
484  Ly_effErr_SideC = sqrt(fabs(n_Ly_hitOn_SideC) / n_Ly_TrPrj_SideC) *
485  sqrt(1. - fabs(n_Ly_hitOn_SideC) / n_Ly_TrPrj_SideC) /
486  sqrt(n_Ly_TrPrj_SideC);
487  hist_LyEff_SideC->SetBinContent(ib + 1, Ly_eff_SideC);
488  hist_LyEff_SideC->SetBinError(ib + 1, Ly_effErr_SideC);
489  }
490  }
491  // write out histogram
492  TDirectory* dir = f->GetDirectory(dir_sideC_track.c_str());
493  writeToFile(dir, hist_LyEff_SideC);
494 
495  }
496 
497 
498 
499  int rpc_eventstotal = 0;
500  if (RPCCheckHistogram(f, (dir_ov_raw + "Number_of_RPC_hits_per_event").c_str())) {
501  TH1I* rpc_hits = (TH1I*) (f->Get((dir_ov_raw + "Number_of_RPC_hits_per_event").c_str()));
502  rpc_eventstotal = int(rpc_hits->GetEntries());
503  }
504 
505 
506  // distribution plot all atlas
507  std::string AverageEff_C_name = dir_sideC_track + "Efficiency_Distribution_sideC";
508  std::string AverageEff_A_name = dir_sideA_track + "Efficiency_Distribution_sideA";
509  std::string AverageGapEff_C_name = dir_sideC_track + "GapEfficiency_Distribution_sideC";
510  std::string AverageGapEff_A_name = dir_sideA_track + "GapEfficiency_Distribution_sideA";
511  std::string AverageNoiseCorr_C_name = dir_sideC_track + "NoiseCorr_Distribution_sideC";
512  std::string AverageNoiseCorr_A_name = dir_sideA_track + "NoiseCorr_Distribution_sideA";
513  std::string AverageNoiseTot_C_name = dir_sideC_track + "NoiseTot_Distribution_sideC";
514  std::string AverageNoiseTot_A_name = dir_sideA_track + "NoiseTot_Distribution_sideA";
515  std::string AverageCS_C_name = dir_sideC_track + "CS_Distribution_sideC";
516  std::string AverageCS_A_name = dir_sideA_track + "CS_Distribution_sideA";
517  std::string AverageRes_CS1_C_name = dir_sideC_track + "Res_CS1_Distribution_sideC";
518  std::string AverageRes_CS1_A_name = dir_sideA_track + "Res_CS1_Distribution_sideA";
519  std::string AverageRes_CS2_C_name = dir_sideC_track + "Res_CS2_Distribution_sideC";
520  std::string AverageRes_CS2_A_name = dir_sideA_track + "Res_CS2_Distribution_sideA";
521  std::string AverageRes_CSmore2_C_name = dir_sideC_track + "Res_CSmore2_Distribution_sideC";
522  std::string AverageRes_CSmore2_A_name = dir_sideA_track + "Res_CSmore2_Distribution_sideA";
523  std::string AverageRes_CS1rms_C_name = dir_sideC_track + "Res_CS1rms_Distribution_sideC";
524  std::string AverageRes_CS1rms_A_name = dir_sideA_track + "Res_CS1rms_Distribution_sideA";
525  std::string AverageRes_CS2rms_C_name = dir_sideC_track + "Res_CS2rms_Distribution_sideC";
526  std::string AverageRes_CS2rms_A_name = dir_sideA_track + "Res_CS2rms_Distribution_sideA";
527  std::string AverageRes_CSmore2rms_C_name = dir_sideC_track + "Res_CSmore2rms_Distribution_sideC";
528  std::string AverageRes_CSmore2rms_A_name = dir_sideA_track + "Res_CSmore2rms_Distribution_sideA";
529  std::string AverageOccupancy_C_name = dir_sideC_track + "Occupancy_Distribution_sideC";
530  std::string AverageOccupancy_A_name = dir_sideA_track + "Occupancy_Distribution_sideA";
531  std::string AverageTime_C_name = dir_sideC_track + "Time_Distribution_sideC";
532  std::string AverageTime_A_name = dir_sideA_track + "Time_Distribution_sideA";
533 
534 
535  auto initialiseHisto = [f](const std::string& name) -> TH1F* {
536  TH1F* result = (TH1F*) (f->Get(name.c_str()));
537 
538  return result;
539  };
540 
541  TH1F* h_AverageEff_C = initialiseHisto(AverageEff_C_name);
542  TH1F* h_AverageEff_A = initialiseHisto(AverageEff_A_name);
543  TH1F* h_AverageGapEff_C = initialiseHisto(AverageGapEff_C_name);
544  TH1F* h_AverageGapEff_A = initialiseHisto(AverageGapEff_A_name);
545  TH1F* h_AverageNoiseCorr_C = initialiseHisto(AverageNoiseCorr_C_name);
546  TH1F* h_AverageNoiseCorr_A = initialiseHisto(AverageNoiseCorr_A_name);
547  TH1F* h_AverageNoiseTot_C = initialiseHisto(AverageNoiseTot_C_name);
548  TH1F* h_AverageNoiseTot_A = initialiseHisto(AverageNoiseTot_A_name);
549  TH1F* h_AverageCS_C = initialiseHisto(AverageCS_C_name);
550  TH1F* h_AverageCS_A = initialiseHisto(AverageCS_A_name);
551  TH1F* h_AverageRes_CS1_C = initialiseHisto(AverageRes_CS1_C_name);
552  TH1F* h_AverageRes_CS1_A = initialiseHisto(AverageRes_CS1_A_name);
553  TH1F* h_AverageRes_CS2_C = initialiseHisto(AverageRes_CS2_C_name);
554  TH1F* h_AverageRes_CS2_A = initialiseHisto(AverageRes_CS2_A_name);
555  TH1F* h_AverageRes_CSmore2_C = initialiseHisto(AverageRes_CSmore2_C_name);
556  TH1F* h_AverageRes_CSmore2_A = initialiseHisto(AverageRes_CSmore2_A_name);
557  TH1F* h_AverageRes_CS1rms_C = initialiseHisto(AverageRes_CS1rms_C_name);
558  TH1F* h_AverageRes_CS1rms_A = initialiseHisto(AverageRes_CS1rms_A_name);
559  TH1F* h_AverageRes_CS2rms_C = initialiseHisto(AverageRes_CS2rms_C_name);
560  TH1F* h_AverageRes_CS2rms_A = initialiseHisto(AverageRes_CS2rms_A_name);
561  TH1F* h_AverageRes_CSmore2rms_C = initialiseHisto(AverageRes_CSmore2rms_C_name);
562  TH1F* h_AverageRes_CSmore2rms_A = initialiseHisto(AverageRes_CSmore2rms_A_name);
563  TH1F* h_AverageOccupancy_C = initialiseHisto(AverageOccupancy_C_name);
564  TH1F* h_AverageOccupancy_A = initialiseHisto(AverageOccupancy_A_name);
565  TH1F* h_AverageTime_C = initialiseHisto(AverageTime_C_name);
566  TH1F* h_AverageTime_A = initialiseHisto(AverageTime_A_name);
567 
568  auto resetIfValid = [](TH1F* pH) -> void {
569  if (pH) pH->Reset();
570  return;
571  };
572 
573 
574 
575  resetIfValid(h_AverageEff_C);
576  resetIfValid(h_AverageEff_A);
577  resetIfValid(h_AverageGapEff_C);
578  resetIfValid(h_AverageGapEff_A);
579  resetIfValid(h_AverageNoiseCorr_C);
580  resetIfValid(h_AverageNoiseCorr_A);
581  resetIfValid(h_AverageNoiseTot_C);
582  resetIfValid(h_AverageNoiseTot_A);
583  resetIfValid(h_AverageCS_C);
584  resetIfValid(h_AverageCS_A);
585  resetIfValid(h_AverageRes_CS1_C);
586  resetIfValid(h_AverageRes_CS1_A);
587  resetIfValid(h_AverageRes_CS2_C);
588  resetIfValid(h_AverageRes_CS2_A);
589  resetIfValid(h_AverageRes_CSmore2_C);
590  resetIfValid(h_AverageRes_CSmore2_A);
591  resetIfValid(h_AverageRes_CS1rms_C);
592  resetIfValid(h_AverageRes_CS1rms_A);
593  resetIfValid(h_AverageRes_CS2rms_C);
594  resetIfValid(h_AverageRes_CS2rms_A);
595  resetIfValid(h_AverageRes_CSmore2rms_C);
596  resetIfValid(h_AverageRes_CSmore2rms_A);
597  resetIfValid(h_AverageOccupancy_C);
598  resetIfValid(h_AverageOccupancy_A);
599  resetIfValid(h_AverageTime_C);
600  resetIfValid(h_AverageTime_A);
601 
602  // summary plots
603  int countpanelindb = 0;
604  int countpaneleff0 = 0;
605  int countpaneltrack0 = 0;
606  for (int i_sec = 0; i_sec != 15 * 1 + 1; i_sec++) {
607  char sector_char[100];
608  std::string sector_name;
609  sprintf(sector_char, "_Sector%.2d", i_sec + 1); // sector number with 2 digits
610  sector_name = sector_char;
611  std::cout << " RPC sector_name processing " << sector_name << std::endl;
612 
613  std::string TrackProj_name = dir_sum_track + "SummaryTrackProj" + sector_name;
614  std::string HitOnTrack_name = dir_sum_track + "SummaryHitOnTrack" + sector_name;
615  std::string HitOnTrackCross_name = dir_sum_track + "SummaryHitOnTrack_withCrossStrip" + sector_name;
616  std::string Eff_name = dir_sum_track + "SummaryEfficiency" + sector_name;
617  std::string GapEff_name = dir_sum_track + "SummaryGapEfficiency" + sector_name;
618  std::string NoiseCorr_name = dir_sum_track + "SummaryNoiseCorr" + sector_name;
619  std::string NoiseCorr_s_name = dir_sum_track + "SummaryNoiseCorr_NotNorm" + sector_name;
620  std::string NoiseTot_name = dir_sum_track + "SummaryNoiseTot" + sector_name;
621  std::string NoiseTot_s_name = dir_sum_track + "SummaryNoiseTot_NotNorm" + sector_name;
622  std::string Res_CS1_name = dir_sum_track + "SummaryRes_CS1" + sector_name;
623  std::string Res_CS1_s_name = dir_sum_track + "SummaryRes_CS1_NotNorm" + sector_name;
624  std::string Res_CS1_square_name = dir_sum_track + "SummaryRes_CS1_square" + sector_name;
625  std::string Res_CS1_entries_name = dir_sum_track + "SummaryRes_CS1_entries" + sector_name;
626  std::string Res_CS2_name = dir_sum_track + "SummaryRes_CS2" + sector_name;
627  std::string Res_CS2_s_name = dir_sum_track + "SummaryRes_CS2_NotNorm" + sector_name;
628  std::string Res_CS2_square_name = dir_sum_track + "SummaryRes_CS2_square" + sector_name;
629  std::string Res_CS2_entries_name = dir_sum_track + "SummaryRes_CS2_entries" + sector_name;
630  std::string Res_CSmore2_name = dir_sum_track + "SummaryRes_CSmore2" + sector_name;
631  std::string Res_CSmore2_s_name = dir_sum_track + "SummaryRes_CSmore2_NotNorm" + sector_name;
632  std::string Res_CSmore2_square_name = dir_sum_track + "SummaryRes_CSmore2_square" + sector_name;
633  std::string Res_CSmore2_entries_name = dir_sum_track + "SummaryRes_CSmore2_entries" + sector_name;
634  std::string CS_name = dir_sum_track + "SummaryCS" + sector_name;
635  std::string CS_s_name = dir_sum_track + "SummaryCS_NotNorm" + sector_name;
636  std::string CS_square_name = dir_sum_track + "SummaryCS_square" + sector_name;
637  std::string CS_entries_name = dir_sum_track + "SummaryCS_entries" + sector_name;
638  std::string CS1_entries_name = dir_sum_track + "SummaryCS1_entries" + sector_name;
639  std::string CS2_entries_name = dir_sum_track + "SummaryCS2_entries" + sector_name;
640  std::string Time_name = dir_sum_track + "SummaryTime" + sector_name;
641  std::string Time_s_name = dir_sum_track + "SummaryTime_NotNorm" + sector_name;
642  std::string Time_square_name = dir_sum_track + "SummaryTime_square" + sector_name;
643  std::string Occupancy_name = dir_sum_track + "SummaryOccupancy" + sector_name;
644  std::string Occupancy_s_name = dir_sum_track + "SummaryOccupancy_NotNorm" + sector_name;
645  std::string PanelId_name = dir_sum_track + "SummaryPanelID" + sector_name;
646 
647  // distribution plot per sector
648  std::string EffSecDist_name = dir_sum_track + "SummaryEffDistriPerSector" + sector_name;
649  std::string GapEffSecDist_name = dir_sum_track + "SummaryGapEffDistriPerSector" + sector_name;
650  std::string NoiseCorrSecDist_name = dir_sum_track + "SummaryNoiseCorrDistriPerSector" + sector_name;
651  std::string NoiseTotSecDist_name = dir_sum_track + "SummaryNoiseTotDistriPerSector" + sector_name;
652  std::string CSSecDist_name = dir_sum_track + "SummaryCSDistriPerSector" + sector_name;
653  std::string Res_CS1SecDist_name = dir_sum_track + "SummaryRes_CS1DistriPerSector" + sector_name;
654  std::string Res_CS2SecDist_name = dir_sum_track + "SummaryRes_CS2DistriPerSector" + sector_name;
655  std::string Res_CSmore2SecDist_name = dir_sum_track + "SummaryRes_CSmore2DistriPerSector" + sector_name;
656  std::string Res_CS1_rmsSecDist_name = dir_sum_track + "SummaryRes_CS1rmsDistriPerSector" + sector_name;
657  std::string Res_CS2_rmsSecDist_name = dir_sum_track + "SummaryRes_CS2rmsDistriPerSector" + sector_name;
658  std::string Res_CSmore2_rmsSecDist_name = dir_sum_track + "SummaryRes_CSmore2rmsDistriPerSector" +
659  sector_name;
660  std::string TimeSecDist_name = dir_sum_track + "SummaryTimeDistriPerSector" + sector_name;
661  std::string OccupancySecDist_name = dir_sum_track + "SummaryOccupancyDistriPerSector" + sector_name;
662  //
663  auto initialiseHisto = [f](const std::string& name) -> TH1F* {
664  TH1F* result = (TH1F*) (f->Get(name.c_str()));
665 
666  return result;
667  };
668  TH1F* h_TrackProj = initialiseHisto(TrackProj_name);
669  TH1F* h_HitOnTrack = initialiseHisto(HitOnTrack_name);
670  TH1F* h_HitOnTrackCross = initialiseHisto(HitOnTrackCross_name);
671  TH1F* h_Eff = initialiseHisto(Eff_name);
672  TH1F* h_GapEff = initialiseHisto(GapEff_name);
673  TH1F* h_NoiseCorr = initialiseHisto(NoiseCorr_name);
674  TH1F* h_NoiseCorr_s = initialiseHisto(NoiseCorr_s_name);
675  TH1F* h_NoiseTot = initialiseHisto(NoiseTot_name);
676  TH1F* h_NoiseTot_s = initialiseHisto(NoiseTot_s_name);
677  TH1F* h_Res_CS1 = initialiseHisto(Res_CS1_name);
678  TH1F* h_Res_CS1_s = initialiseHisto(Res_CS1_s_name);
679  TH1F* h_Res_CS1_square = initialiseHisto(Res_CS1_square_name);
680  TH1F* h_Res_CS1_entries = initialiseHisto(Res_CS1_entries_name);
681  TH1F* h_Res_CS2 = initialiseHisto(Res_CS2_name);
682  TH1F* h_Res_CS2_s = initialiseHisto(Res_CS2_s_name);
683  TH1F* h_Res_CS2_square = initialiseHisto(Res_CS2_square_name);
684  TH1F* h_Res_CS2_entries = initialiseHisto(Res_CS2_entries_name);
685  TH1F* h_Res_CSmore2 = initialiseHisto(Res_CSmore2_name);
686  TH1F* h_Res_CSmore2_s = initialiseHisto(Res_CSmore2_s_name);
687  TH1F* h_Res_CSmore2_square = initialiseHisto(Res_CSmore2_square_name);
688  TH1F* h_Res_CSmore2_entries = initialiseHisto(Res_CSmore2_entries_name);
689  TH1F* h_CS = initialiseHisto(CS_name);
690  TH1F* h_CS_s = initialiseHisto(CS_s_name);
691  TH1F* h_CS_square = initialiseHisto(CS_square_name);
692  TH1F* h_CS_entries = initialiseHisto(CS_square_name);
693  TH1F* h_CS1_entries = initialiseHisto(CS1_entries_name);
694  TH1F* h_CS2_entries = initialiseHisto(CS2_entries_name);
695  TH1F* h_Time = initialiseHisto(Time_name);
696  TH1F* h_Time_s = initialiseHisto(Time_s_name);
697  TH1F* h_Time_square = initialiseHisto(Time_square_name);
698  TH1F* h_Occupancy = initialiseHisto(Occupancy_name);
699  TH1F* h_Occupancy_s = initialiseHisto(Occupancy_s_name);
700  TH1F* h_PanelId = initialiseHisto(PanelId_name);
701 
702  TH1F* h_EffSecDist = initialiseHisto(EffSecDist_name);
703  TH1F* h_GapEffSecDist = initialiseHisto(GapEffSecDist_name);
704  TH1F* h_NoiseCorrSecDist = initialiseHisto(NoiseCorrSecDist_name);
705  TH1F* h_NoiseTotSecDist = initialiseHisto(NoiseTotSecDist_name);
706  TH1F* h_CSSecDist = initialiseHisto(CSSecDist_name);
707  TH1F* h_Res_CS1SecDist = initialiseHisto(Res_CS1SecDist_name);
708  TH1F* h_Res_CS2SecDist = initialiseHisto(Res_CS2SecDist_name);
709  TH1F* h_Res_CSmore2SecDist = initialiseHisto(Res_CSmore2SecDist_name);
710  TH1F* h_Res_CS1_rmsSecDist = initialiseHisto(Res_CS1_rmsSecDist_name);
711  TH1F* h_Res_CS2_rmsSecDist = initialiseHisto(Res_CS2_rmsSecDist_name);
712  TH1F* h_Res_CSmore2_rmsSecDist = initialiseHisto(Res_CSmore2_rmsSecDist_name);
713  TH1F* h_TimeSecDist = initialiseHisto(TimeSecDist_name);
714  TH1F* h_OccupancySecDist = initialiseHisto(OccupancySecDist_name);
715 
716  auto resetIfValid = [](TH1F* pH) -> void {
717  if (pH) pH->Reset();
718  return;
719  };
720  resetIfValid(h_EffSecDist);
721  resetIfValid(h_GapEffSecDist);
722  resetIfValid(h_NoiseCorrSecDist);
723  resetIfValid(h_NoiseTotSecDist);
724  resetIfValid(h_CSSecDist);
725  resetIfValid(h_Res_CS1SecDist);
726  resetIfValid(h_Res_CS2SecDist);
727  resetIfValid(h_Res_CSmore2SecDist);
728  resetIfValid(h_Res_CS1_rmsSecDist);
729  resetIfValid(h_Res_CS2_rmsSecDist);
730  resetIfValid(h_Res_CSmore2_rmsSecDist);
731  resetIfValid(h_TimeSecDist);
732  resetIfValid(h_OccupancySecDist);
733  resetIfValid(h_Eff);
734 
735  // efficiency
736  if (h_TrackProj && h_HitOnTrack && h_Eff) {
737  for (int ib = 0; ib != h_TrackProj->GetNbinsX(); ib++) {
738  if (not panelOk(h_PanelId, ib)) continue;
739  n_hit_f = h_HitOnTrack->GetBinContent(ib + 1);
740  n_tr_p = h_TrackProj->GetBinContent(ib + 1);
741 
742  //if ( n_tr_p>50 ) {
743  if (n_tr_p != 0) {
744  panel_eff = n_hit_f / n_tr_p;
745  } else {
746  panel_eff = 0.;
747  }
748  if (n_tr_p != 0) {
749  panel_err_eff = sqrt(fabs(n_hit_f) / n_tr_p) *
750  sqrt(1. - fabs(n_hit_f) / n_tr_p) /
751  sqrt(n_tr_p);
752  } else {
753  panel_err_eff = 0.;
754  }
755  h_Eff->SetBinContent(ib + 1, panel_eff);
756  h_Eff->SetBinError(ib + 1, panel_err_eff);
757  if (h_EffSecDist) h_EffSecDist->Fill(panel_eff);
758  bool aSide = isASide(h_TrackProj, ib);
759  fillAorC(aSide, h_AverageEff_A, h_AverageEff_C, panel_eff);
760  }
761  // write out histogram
762  TDirectory* dir = f->GetDirectory(dir_sum_track.c_str());
763  writeToFile(dir, h_Eff, h_EffSecDist);
764  }
765 
766  // gap efficiency
767  if (h_TrackProj && h_HitOnTrack && h_HitOnTrackCross && h_GapEff) {
768  h_GapEff->Reset();
769  nEta = 0;
770  nPhi = 0;
771  nEtaPhi = 0;
772  int sign = 1;
773  int bmin = 0;
774  bmin = int( h_GapEff->GetXaxis()->GetXmin());
775  for (int ib = 0; ib != h_TrackProj->GetNbinsX(); ib++) {
776  if (not panelOk(h_PanelId, ib)) continue;
777 
778  if ((bmin + ib) % 2 != 0) continue; // Phi panel
779  sign = std::copysign(1, (bmin + ib));
780 
781  nEta = h_HitOnTrack->GetBinContent(ib + 1);
782  nPhi = h_HitOnTrack->GetBinContent(ib + 1 + sign);
783  nEtaPhi = h_HitOnTrackCross->GetBinContent(ib + 1);
784  n_tr_p = h_TrackProj->GetBinContent(ib + 1);
785 
786  if (n_tr_p > 0) {
787  gapEff = (nEta + nPhi - nEtaPhi) / n_tr_p;
788  gapErrEff = sqrt(fabs(nEta + nPhi - nEtaPhi) / n_tr_p) *
789  sqrt(1. - fabs(nEta + nPhi - nEtaPhi) / n_tr_p) /
790  sqrt(n_tr_p);
791  } else {
792  gapEff = 0.;
793  gapErrEff = 0.;
794  }
795  h_GapEff->SetBinContent(ib + 1, gapEff);
796  h_GapEff->SetBinError(ib + 1, gapErrEff);
797  const bool isA = isASide(h_TrackProj, ib);
798  fillAorC(isA, h_AverageGapEff_A, h_AverageGapEff_C, gapEff);
799  fillIfValid(h_GapEffSecDist, gapEff);
800  }
801  TDirectory* dir = f->GetDirectory(dir_sum_track.c_str());
802  writeToFile(dir, h_GapEff, h_GapEffSecDist);
803  }
804 
805 
806  //residuals CS = 1
807  res_mean = 0;
808  res2_mean = 0;
809  res_RMS = 0;
810 
811  if (h_Res_CS1 && h_Res_CS1_s && h_Res_CS1_square && h_Res_CS1_entries) {
812  for (int ib = 0; ib != h_Res_CS1->GetNbinsX(); ib++) {
813  if (not panelOk(h_PanelId, ib)) continue;
814  if ((h_Res_CS1_entries->GetBinContent(ib + 1)) != 0) {
815  res_mean = (h_Res_CS1_s->GetBinContent(ib + 1)) / (h_Res_CS1_entries->GetBinContent(ib + 1));
816  res2_mean = (h_Res_CS1_square->GetBinContent(ib + 1)) / (h_Res_CS1_entries->GetBinContent(ib + 1));
817  res_RMS = sqrt((fabs(res2_mean - res_mean * res_mean)) / (h_Res_CS1_entries->GetBinContent(ib + 1)));
818  h_Res_CS1->SetBinContent(ib + 1, res_mean);
819  h_Res_CS1->SetBinError(ib + 1, res_RMS);
820  fillIfValid(h_Res_CS1SecDist, res_mean);
821  fillIfValid(h_Res_CS1_rmsSecDist, res_RMS);
822  bool isA = isASide(h_Res_CS1, ib);
823  fillAorC(isA, h_AverageRes_CS1_A, h_AverageRes_CS1_C, res_mean);
824  fillAorC(isA, h_AverageRes_CS1rms_A, h_AverageRes_CS1rms_C, res_RMS);
825  }
826  } // end for bins
827  TDirectory* dirRes1 = f->GetDirectory(dir_sum_track.c_str());
828  writeToFile(dirRes1, h_Res_CS1, h_Res_CS1SecDist, h_Res_CS1_rmsSecDist);
829  }
830 
831  //residuals CS = 2
832  res_mean = 0;
833  res2_mean = 0;
834  res_RMS = 0;
835  if (h_Res_CS2 && h_Res_CS2_s && h_Res_CS2_square && h_Res_CS2_entries) {
836  for (int ib = 0; ib != h_Res_CS2->GetNbinsX(); ib++) {
837  if (not panelOk(h_PanelId, ib)) continue;
838  if ((h_Res_CS2_entries->GetBinContent(ib + 1)) != 0) {
839  res_mean = (h_Res_CS2_s->GetBinContent(ib + 1)) / (h_Res_CS2_entries->GetBinContent(ib + 1));
840  res2_mean = (h_Res_CS2_square->GetBinContent(ib + 1)) / (h_Res_CS2_entries->GetBinContent(ib + 1));
841  res_RMS = sqrt(fabs((res2_mean - res_mean * res_mean) / (h_Res_CS2_entries->GetBinContent(ib + 1))));
842  h_Res_CS2->SetBinContent(ib + 1, res_mean);
843  h_Res_CS2->SetBinError(ib + 1, res_RMS);
844  fillIfValid(h_Res_CS2SecDist, res_mean);
845  fillIfValid(h_Res_CS2_rmsSecDist, res_RMS);
846  bool isA = isASide(h_Res_CS2, ib);
847  fillAorC(isA, h_AverageRes_CS2_A, h_AverageRes_CS2_C, res_mean);
848  fillAorC(isA, h_AverageRes_CS2rms_A, h_AverageRes_CS2rms_C, res_RMS);
849  }
850  }
851  TDirectory* dirRes2 = f->GetDirectory(dir_sum_track.c_str());
852  writeToFile(dirRes2, h_Res_CS2, h_Res_CS2SecDist, h_Res_CS2_rmsSecDist);
853  }
854 
855  //residuals CS > 2
856  res_mean = 0;
857  res2_mean = 0;
858  res_RMS = 0;
859  if (h_Res_CSmore2 && h_Res_CSmore2_s && h_Res_CSmore2_square && h_Res_CSmore2_entries) {
860  for (int ib = 0; ib != h_Res_CSmore2->GetNbinsX(); ib++) {
861  if (not panelOk(h_PanelId, ib)) continue;
862  if ((h_Res_CSmore2_entries->GetBinContent(ib + 1)) != 0) {
863  res_mean = (h_Res_CSmore2_s->GetBinContent(ib + 1)) / (h_Res_CSmore2_entries->GetBinContent(ib + 1));
864  res2_mean = (h_Res_CSmore2_square->GetBinContent(ib + 1)) /
865  (h_Res_CSmore2_entries->GetBinContent(ib + 1));
866  res_RMS = sqrt(fabs((res2_mean - res_mean * res_mean) / (h_Res_CSmore2_entries->GetBinContent(
867  ib + 1))));
868 
869  h_Res_CSmore2->SetBinContent(ib + 1, res_mean);
870  h_Res_CSmore2->SetBinError(ib + 1, res_RMS);
871  fillIfValid(h_Res_CSmore2SecDist, res_mean);
872  fillIfValid(h_Res_CSmore2_rmsSecDist, res_RMS);
873  bool isA = isASide(h_Res_CSmore2, ib);
874  fillAorC(isA, h_AverageRes_CSmore2_A, h_AverageRes_CSmore2_C, res_mean);
875  fillAorC(isA, h_AverageRes_CSmore2rms_A, h_AverageRes_CSmore2rms_C, res_RMS);
876  }
877  }
878  TDirectory* dirResp2 = f->GetDirectory(dir_sum_track.c_str());
879  writeToFile(dirResp2, h_Res_CSmore2, h_Res_CSmore2SecDist, h_Res_CSmore2_rmsSecDist);
880  }
881 
882  // occupancy
883  if ((rpc_eventstotal > 0) && h_Occupancy && h_Occupancy_s) {
884  for (int ib = 0; ib != h_Occupancy->GetNbinsX(); ib++) {
885  if (not panelOk(h_PanelId, ib)) continue;
886  panel_occ = h_Occupancy_s->GetBinContent(ib + 1);
887  panel_occ = panel_occ / float(rpc_eventstotal);
888 
889  h_Occupancy->SetBinContent(ib + 1, panel_occ);
890  h_Occupancy->SetBinError(ib + 1, sqrt(panel_occ));
891  panel_occ = safelyTakeLog(panel_occ);
892  fillIfValid(h_OccupancySecDist, panel_occ);
893  bool isA = isASide(h_PanelId, ib);
894  fillAorC(isA, h_AverageOccupancy_A, h_AverageOccupancy_C, panel_occ);
895  }
896  // write occupancy histograms
897  TDirectory* dirOcc = f->GetDirectory(dir_sum_track.c_str());
898  writeToFile(dirOcc, h_Occupancy, h_OccupancySecDist);
899  }
900 
901 
902  // CS
903  if (h_CS && h_CS_s && h_CS_square && h_CS_entries) {
904  for (int ib = 0; ib != h_CS->GetNbinsX(); ib++) {
905  if (not panelOk(h_PanelId, ib)) continue;
906  panelCS_entries = h_CS_entries->GetBinContent(ib + 1);
907  panelCS = h_CS_s->GetBinContent(ib + 1);
908  panelCS2 = h_CS_square->GetBinContent(ib + 1);
909  if (panelCS_entries != 0) {
910  panelCS_mean = panelCS / panelCS_entries;
911  panelCS2_mean = panelCS2 / panelCS_entries;
912  panelCS_RMS = sqrt(fabs((panelCS2_mean - panelCS_mean * panelCS_mean) / panelCS_entries));
913  h_CS->SetBinContent(ib + 1, panelCS_mean);
914  h_CS->SetBinError(ib + 1, panelCS_RMS);
915  fillIfValid(h_CSSecDist, panelCS_mean);
916  bool isA = isASide(h_CS, ib);
917  fillAorC(isA, h_AverageCS_A, h_AverageCS_C, panelCS_mean);
918  }
919  }
920  // write CS histograms
921  TDirectory* dirCS = f->GetDirectory(dir_sum_track.c_str());
922  writeToFile(dirCS, h_CS, h_CSSecDist);
923  }
924 
925  // time
926  if (h_Time && h_Time_s && h_Time_square && h_CS_entries) {
927  for (int ib = 0; ib != h_Time->GetNbinsX(); ib++) {
928  if (not panelOk(h_PanelId, ib)) continue;
929  if (h_CS_entries->GetBinContent(ib + 1) != 0) {
930  Time_mean = (h_Time_s->GetBinContent(ib + 1)) / (h_CS_entries->GetBinContent(ib + 1));
931  Time2_mean = (h_Time_square->GetBinContent(ib + 1)) / (h_CS_entries->GetBinContent(ib + 1));
932  Time_RMS = sqrt(fabs((Time2_mean - Time_mean * Time_mean) / (h_CS_entries->GetBinContent(ib + 1))));
933 
934  h_Time->SetBinContent(ib + 1, Time_mean);
935  h_Time->SetBinError(ib + 1, Time_RMS);
936 
937  fillIfValid(h_TimeSecDist, Time_mean);
938  bool isA = isASide(h_Time, ib);
939  fillAorC(isA, h_AverageTime_A, h_AverageTime_C, Time_mean);
940  }
941  }
942  // write time histograms
943  TDirectory* dirTime = f->GetDirectory(dir_sum_track.c_str());
944  writeToFile(dirTime, h_Time, h_TimeSecDist);
945  }
946  // noise
947  noiseErrNorm = 18257.42;
948  if ((rpc_eventstotal > 0) && h_NoiseCorr && h_NoiseCorr_s && h_NoiseTot && h_NoiseTot_s && h_CS_entries) {
949  //std::cout << " Taglio Eventi " << std::endl;
950  for (int ib = 0; ib != h_NoiseCorr->GetNbinsX(); ib++) {
951  if (not panelOk(h_PanelId, ib)) continue;
952  if (h_CS_entries->GetBinContent(ib + 1) == 0) continue;
953  noiseCorr = h_NoiseCorr_s->GetBinContent(ib + 1);
954  noiseCorrErr = sqrt(noiseCorr) * noiseErrNorm / float(rpc_eventstotal);
955  noiseCorr = (noiseCorr * 1000000) / float(rpc_eventstotal);
956  h_NoiseCorr->SetBinContent(ib + 1, noiseCorr);
957  h_NoiseCorr->SetBinError(ib + 1, noiseCorrErr);
958  fillIfValid(h_NoiseCorrSecDist, noiseCorr);
959 
960  noiseTot = h_NoiseTot_s->GetBinContent(ib + 1);
961  noiseTotErr = sqrt(noiseTot) * noiseErrNorm / float(rpc_eventstotal);
962  noiseTot = (noiseTot * 1000000) / float(rpc_eventstotal);
963  h_NoiseTot->SetBinContent(ib + 1, noiseTot);
964  h_NoiseTot->SetBinError(ib + 1, noiseTotErr);
965 
966  fillIfValid(h_NoiseTotSecDist, noiseTot);
967  bool isA = isASide(h_NoiseCorr, ib);
968  fillAorC(isA, h_AverageNoiseTot_A, h_AverageNoiseTot_C, noiseTot);
969  fillAorC(isA, h_AverageNoiseCorr_A, h_AverageNoiseCorr_C, noiseCorr);
970  }
971  TDirectory* dirNoise = f->GetDirectory(dir_sum_track.c_str());
972  if (dirNoise != 0) {
973  dirNoise->cd();
974  h_NoiseCorr->Write("", TObject::kOverwrite);
975  h_NoiseTot->Write("", TObject::kOverwrite);
976  writeIfValid(h_NoiseCorrSecDist);
977  writeIfValid(h_NoiseTotSecDist);
978  }
979  }
980 
981 
983  // bool do_asciiCoolFile1 = true;
984  float effeta = -9999;
985  float effphi = -9999;
986  char arr_effeta [14] = {};
987  char arr_effphi [14] = {};
988  float erreffeta = -1;
989  float erreffphi = -1;
990  char arr_erreffeta [14] = {};
991  char arr_erreffphi [14] = {};
992  float reseta_cs1 = -9999;
993  float resphi_cs1 = -9999;
994  char arr_reseta_cs1 [14] = {};
995  char arr_resphi_cs1 [14] = {};
996  float errreseta_cs1 = -1;
997  float errresphi_cs1 = -1;
998  char arr_errreseta_cs1 [14] = {};
999  char arr_errresphi_cs1 [14] = {};
1000  float reseta_cs2 = -9999;
1001  float resphi_cs2 = -9999;
1002  char arr_reseta_cs2 [14] = {};
1003  char arr_resphi_cs2 [14] = {};
1004  float errreseta_cs2 = -1;
1005  float errresphi_cs2 = -1;
1006  char arr_errreseta_cs2 [14] = {};
1007  char arr_errresphi_cs2 [14] = {};
1008  float reseta_csother = -9999;
1009  float resphi_csother = -9999;
1010  char arr_reseta_csother [14] = {};
1011  char arr_resphi_csother [14] = {};
1012  float errreseta_csother = -1;
1013  float errresphi_csother = -1;
1014  char arr_errreseta_csother [14] = {};
1015  char arr_errresphi_csother [14] = {};
1016  float timeeta = -9999;
1017  float timephi = -9999;
1018  char arr_timeeta [14] = {};
1019  char arr_timephi [14] = {};
1020  float errtimeeta = -1;
1021  float errtimephi = -1;
1022  char arr_errtimeeta [14] = {};
1023  char arr_errtimephi [14] = {};
1024  float noiseeta = -9999;
1025  float noisephi = -9999;
1026  char arr_noiseeta [14] = {};
1027  char arr_noisephi [14] = {};
1028  float errnoiseeta = -1;
1029  float errnoisephi = -1;
1030  char arr_errnoiseeta [14] = {};
1031  char arr_errnoisephi [14] = {};
1032  float noiseeta_cor = -9999;
1033  float noisephi_cor = -9999;
1034  char arr_noiseeta_cor [14] = {};
1035  char arr_noisephi_cor [14] = {};
1036  float errnoiseeta_cor = -1;
1037  float errnoisephi_cor = -1;
1038  char arr_errnoiseeta_cor [14] = {};
1039  char arr_errnoisephi_cor [14] = {};
1040  float cl_sizeeta = -9999;
1041  float cl_sizephi = -9999;
1042  char arr_cl_sizeeta [14] = {};
1043  char arr_cl_sizephi [14] = {};
1044  float errcl_sizeeta = -1;
1045  float errcl_sizephi = -1;
1046  char arr_errcl_sizeeta [14] = {};
1047  char arr_errcl_sizephi [14] = {};
1048 
1049  float eta_effphi = 0;
1050  float phi_effeta = 0;
1051 
1052  int PanelCode = 0;
1053  int Binposition = 0;
1054  int TableVersion = 1; //Version of Cool Table Formatting according with Andrea Di Simone Table
1055  int n_tr_peta = 0; //Number of eta tracks reconstructed on a gas volume
1056  int n_tr_pphi = 0; //Number of phi tracks reconstructed on a gas volume
1057  int NumberOfInfo = 1; //Number of information for each variable 1= only pannel, >1 depending on tipy of
1058  // monitoring setting and strip pannel geometry
1059  int StripCluster = 0; //Number of strip that realize de reduction bin and the strip pannel geometry 0=no
1060  // strip info,if panel has 24 strip: 24=strip info, 3 = cluster of 8 strip, 6 =
1061  // cluster of 4 strip and so on
1062 
1063 
1064 
1065  coolrpc.coolDbFolder("sqlite://;schema=RPCDQMFOFFLINE.db;dbname=RPC_DQA", "/OFFLINE/OFFLINE_DQMF");
1066  int nbin = 0;
1067  if (h_Eff) nbin = h_Eff->GetNbinsX();
1068  auto writeToCString = [](float val, char* array0) -> void {
1069  //following two lines reproduce original behaviour
1070  sprintf(array0, "%f ", val); //unsafe!
1071  array0[5] = 0; //ugh!
1072  };
1073 
1074  for (int ibin = 1; ibin != nbin + 1; ibin++) {
1075  if (h_PanelId) PanelCode = (int) h_PanelId->GetBinContent(ibin);
1076  if (PanelCode == 0) continue;
1077  if (ibin % 2 == 0) {
1078  if (h_TrackProj) n_tr_pphi = (int) h_TrackProj->GetBinContent(ibin);
1079  if (n_tr_pphi < 1000) continue;
1080 
1081  effphi = getBinContentIfValid(h_Eff, ibin);
1082  writeToCString(effphi, arr_effphi);
1083  erreffphi = getBinErrorIfValid(h_Eff, ibin);
1084  writeToCString(erreffphi, arr_erreffphi);
1085 
1086  resphi_cs1 = getBinContentIfValid(h_Res_CS1, ibin);
1087  writeToCString(resphi_cs1, arr_resphi_cs1);
1088  errresphi_cs1 = getBinErrorIfValid(h_Res_CS1, ibin);
1089  writeToCString(errresphi_cs1, arr_errresphi_cs1);
1090 
1091  resphi_cs2 = getBinContentIfValid(h_Res_CS2, ibin);
1092  writeToCString(resphi_cs2, arr_resphi_cs2);
1093  errresphi_cs2 = getBinErrorIfValid(h_Res_CS2, ibin);
1094  writeToCString(errresphi_cs2, arr_errresphi_cs2);
1095 
1096  resphi_csother = getBinContentIfValid(h_Res_CSmore2, ibin);
1097  writeToCString(resphi_csother, arr_resphi_csother);
1098  errresphi_csother = getBinErrorIfValid(h_Res_CSmore2, ibin);
1099  writeToCString(errresphi_csother, arr_errresphi_csother);
1100 
1101  timephi = getBinContentIfValid(h_Time, ibin);
1102  writeToCString(timephi, arr_timephi);
1103  errtimephi = getBinErrorIfValid(h_Time, ibin);
1104  writeToCString(errtimephi, arr_errtimephi);
1105 
1106  noisephi = getBinContentIfValid(h_NoiseTot, ibin);
1107  writeToCString(noisephi, arr_noisephi);
1108  errnoisephi = getBinErrorIfValid(h_NoiseTot, ibin);
1109  writeToCString(errnoisephi, arr_errnoisephi);
1110 
1111  noisephi_cor = getBinContentIfValid(h_NoiseCorr, ibin);
1112  writeToCString(noisephi_cor, arr_noisephi_cor);
1113  errnoisephi_cor = getBinErrorIfValid(h_NoiseCorr, ibin);
1114  writeToCString(errnoisephi_cor, arr_errnoisephi_cor);
1115 
1116  cl_sizephi = getBinContentIfValid(h_CS, ibin);
1117  writeToCString(cl_sizephi, arr_cl_sizephi);
1118  errcl_sizephi = getBinErrorIfValid(h_CS, ibin);
1119  writeToCString(errcl_sizephi, arr_errcl_sizephi);
1120  } else {
1121  if (h_TrackProj) {
1122  n_tr_peta = (int) h_TrackProj->GetBinContent(ibin);
1123  }
1124  if (n_tr_peta < 1000) continue;
1125 
1126  effeta = getBinContentIfValid(h_Eff, ibin);
1127  writeToCString(effeta, arr_effeta);
1128  erreffeta = getBinErrorIfValid(h_Eff, ibin);
1129  writeToCString(erreffeta, arr_erreffeta);
1130 
1131  reseta_cs1 = getBinContentIfValid(h_Res_CS1, ibin);
1132  writeToCString(reseta_cs1, arr_reseta_cs1);
1133  errreseta_cs1 = getBinErrorIfValid(h_Res_CS1, ibin);
1134  writeToCString(errreseta_cs1, arr_errreseta_cs1);
1135 
1136  reseta_cs2 = getBinContentIfValid(h_Res_CS2, ibin);
1137  writeToCString(reseta_cs2, arr_reseta_cs2);
1138  errreseta_cs2 = getBinErrorIfValid(h_Res_CS2, ibin);
1139  writeToCString(errreseta_cs2, arr_errreseta_cs2);
1140 
1141  reseta_csother = getBinContentIfValid(h_Res_CSmore2, ibin);
1142  writeToCString(reseta_csother, arr_reseta_csother);
1143  errreseta_csother = getBinErrorIfValid(h_Res_CSmore2, ibin);
1144  writeToCString(errreseta_csother, arr_errreseta_csother);
1145 
1146  timeeta = getBinContentIfValid(h_Time, ibin);
1147  writeToCString(timeeta, arr_timeeta);
1148  errtimeeta = getBinErrorIfValid(h_Time, ibin);
1149  writeToCString(errtimeeta, arr_errtimeeta);
1150 
1151  noiseeta = getBinContentIfValid(h_NoiseTot, ibin);
1152  writeToCString(noiseeta, arr_noiseeta);
1153  errnoiseeta = getBinErrorIfValid(h_NoiseTot, ibin);
1154  writeToCString(errnoiseeta, arr_errnoiseeta);
1155 
1156  noiseeta_cor = getBinContentIfValid(h_NoiseCorr, ibin);
1157  writeToCString(noiseeta_cor, arr_noiseeta_cor);
1158  errnoiseeta_cor = getBinErrorIfValid(h_NoiseCorr, ibin);
1159  writeToCString(errnoiseeta_cor, arr_errnoiseeta_cor);
1160 
1161  cl_sizeeta = getBinContentIfValid(h_CS, ibin);
1162  writeToCString(cl_sizeeta, arr_cl_sizeeta);
1163  errcl_sizeeta = getBinErrorIfValid(h_CS, ibin);
1164  writeToCString(errcl_sizeeta, arr_errcl_sizeeta);
1165 
1166 
1167  //std::cout<<"PanelCode "<<PanelCode<<" etaprimo "<<"\n";
1168 
1169  char recEta [4000]; //eff_eta, res_cs1, res_cs2, res_csother, time, mean and rms
1170  char detEta [4000]; //noise, noise_corr, cs, mean and rms
1171  char recPhi1 [4000]; //eff_phi, res_cs1, res_cs2, res_csother, time, only mean
1172  char recPhi2 [4000]; //eff_phi, res_cs1, res_cs2, res_csother, time, only rms
1173  char detPhi1 [4000]; //noise, noise_corr, cs, mean and rms
1174  char detPhi2 [4000];
1175  sprintf(recEta, "%5d %5d %5d %5d %s %s %s %s %s %s %s %s %s %s ", TableVersion,
1176  n_tr_peta, NumberOfInfo, StripCluster, arr_effeta, arr_erreffeta, arr_reseta_cs1,
1177  arr_errreseta_cs1, arr_reseta_cs2, arr_errreseta_cs2, arr_reseta_csother,
1178  arr_errreseta_csother, arr_timeeta, arr_errtimeeta);
1179  sprintf(detEta, "%s %s %s %s %s %s ", arr_noiseeta, arr_errnoiseeta,
1180  arr_noiseeta_cor, arr_errnoiseeta_cor, arr_cl_sizeeta, arr_errcl_sizeeta);
1181  sprintf(recPhi1, "%5d %5d %5d %s %s %s %s %s ", n_tr_pphi, NumberOfInfo,
1182  StripCluster, arr_effphi, arr_resphi_cs1, arr_resphi_cs2, arr_resphi_csother,
1183  arr_timephi);
1184  sprintf(recPhi2, "%s %s %s %s %s ", arr_erreffphi, arr_errresphi_cs1,
1185  arr_errresphi_cs2, arr_errresphi_csother, arr_errtimephi);
1186  sprintf(detPhi1, "%s %s %s %s %s %s ", arr_noisephi, arr_errnoisephi,
1187  arr_noisephi_cor, arr_errnoisephi_cor, arr_cl_sizephi, arr_errcl_sizephi);
1188  sprintf(detPhi2, "0 ");
1189  std::string cool_tag = "Reco";
1190  coolrpc.setSince(0U, 0U);
1191  coolrpc.setUntil(4294967295U, 0U);
1192  coolrpc.insert_withTag(run_number * 0 + 429496729U, PanelCode, recEta, detEta, recPhi1, recPhi2,
1193  detPhi1, detPhi2, cool_tag);
1194  }
1195  }
1196 
1199 
1200  int TableVersionCondDB = 2; //RPC conditionDB table versioning
1201  float gapeffeta = -9999;
1202  char arr_gapeffeta [10];
1203  float errgapeffeta = -1;
1204  char arr_errgapeffeta [10];
1205  float gapeffphi = -9999;
1206  char arr_gapeffphi [10];
1207  float errgapeffphi = -1;
1208  char arr_errgapeffphi [10];
1209  float gapeff = -9999;
1210  float errgapeff = -1;
1211  float entriesCSeta = -1;
1212  int entriesCS1eta = -1;
1213  int entriesCS2eta = -1;
1214  float entriesCSphi = -1;
1215  int entriesCS1phi = -1;
1216  int entriesCS2phi = -1;
1217  float rateCS1eta = -1;
1218  char arr_rateCS1eta [10];
1219  float rateCS2eta = -1;
1220  char arr_rateCS2eta [10];
1221  float rateCSmore2eta = -1;
1222  char arr_rateCSmore2eta [10];
1223  float rateCS1phi = -1;
1224  char arr_rateCS1phi [10];
1225  float rateCS2phi = -1;
1226  char arr_rateCS2phi [10];
1227  float rateCSmore2phi = -1;
1228  char arr_rateCSmore2phi [10];
1229 
1230 
1231 
1232  coolrpc.coolDbFolder("sqlite://;schema=RPCConditionDB.db;dbname=RPC_DQA", "/OFFLINE/FINAL");
1233  std::string dir_cool_raw = run_dir + "/Muon/MuonRawDataMonitoring/RPC/CoolDB/";
1234  TDirectory* coolFolder = f->GetDirectory(dir_cool_raw.c_str());
1235 
1236  if (coolFolder != 0) {
1237  std::vector<std::string> layerList;
1238  layerList.push_back("LowPt0");
1239  layerList.push_back("LowPt1");
1240  layerList.push_back("Pivot0");
1241  layerList.push_back("Pivot1");
1242  layerList.push_back("HighPt0");
1243  layerList.push_back("HighPt1");
1244  int NumberLayerStrip = 0;
1245  int PanelStripId = 0;
1246  int StripProfileContenent = 0;
1247 
1248  auto stripValue=[](float occ){
1249  int stripVal = 0;
1250  if (occ == 0){
1251  stripVal = 0;
1252  } else if (occ > 0 && occ < 0.9) {
1253  stripVal = 5;
1254  } else if (occ > 0.9){
1255  stripVal = 9;
1256  }
1257  return stripVal;
1258  };
1259 
1260  for (std::vector<std::string>::const_iterator iter = layerList.begin(); iter != layerList.end(); ++iter) {
1261  for (int i_dblPhi = 0; i_dblPhi != 2 * 1 + 1; ++i_dblPhi) {
1262  char coolName[40];
1263  sprintf(coolName, "Sector%.2d_%s_dblPhi%d", i_sec + 1, (*iter).c_str(), i_dblPhi + 1);
1264  std::string stripId_name = dir_cool_raw + coolName + "_PanelId";
1265  std::string stripProfile_name = dir_cool_raw + coolName + "_Profile";
1266  TH1F* h_stripId = NULL;
1267  TH1F* h_stripProfile = NULL;
1268 
1269  if (RPCCheckHistogram(f, stripId_name.c_str())) {
1270  h_stripId = (TH1F*) (f->Get(stripId_name.c_str()));
1271  }
1272  if (RPCCheckHistogram(f, stripProfile_name.c_str())) {
1273  h_stripProfile = (TH1F*) (f->Get(stripProfile_name.c_str()));
1274  }
1275 
1276  if (h_stripId && h_stripProfile) {
1277  int SingleStripsValue = 0;
1278  int StripsOnPanel = 1; //number of strip on panel
1279  char SingleStripsStatus [80];
1280  char SingleStripsStatusOK[80];
1281  std::string PanelStripsStatus;
1282  std::string PanelStripsStatusOK;
1283 
1284  NumberLayerStrip = h_stripProfile->GetNbinsX();
1285  for (int Nstrips = 1; Nstrips != NumberLayerStrip + 1; Nstrips++) {
1286  PanelStripId = (int) h_stripId->GetBinContent(Nstrips);
1287  StripProfileContenent = (int) h_stripProfile->GetBinContent(Nstrips);
1288  float StripOccupancy = (float) (StripProfileContenent) / rpc_eventstotal;
1289  SingleStripsValue = stripValue(StripOccupancy);
1290 
1291  if (h_stripId->GetBinCenter(Nstrips) > 0) {
1292  sprintf(SingleStripsStatus, "%d 000.0 0.000|", SingleStripsValue);
1293  sprintf(SingleStripsStatusOK, "5 000.0 0.000|");
1294  } else {
1295  sprintf(SingleStripsStatus, "|000.0 0.000 %d", SingleStripsValue);
1296  sprintf(SingleStripsStatusOK, "|000.0 0.000 5");
1297  }
1298  PanelStripsStatus = PanelStripsStatus + SingleStripsStatus;
1299  PanelStripsStatusOK = PanelStripsStatusOK + SingleStripsStatusOK;
1300 
1301 
1302 
1303  if ((int) h_stripId->GetBinContent(Nstrips) ==
1304  (int) h_stripId->GetBinContent(Nstrips + 1)) StripsOnPanel++;
1305 
1306  if ((int) h_stripId->GetBinContent(Nstrips) != (int) h_stripId->GetBinContent(Nstrips + 1)) {
1307 
1308  if (h_stripId->GetBinCenter(Nstrips) < 0) {
1309  std::reverse(PanelStripsStatus.begin(), PanelStripsStatus.end());
1310  std::reverse(PanelStripsStatusOK.begin(), PanelStripsStatusOK.end());
1311  }
1312 
1313  for (int ibin = 1; ibin != nbin + 1; ibin++) {
1314  if (h_PanelId) PanelCode = (int) h_PanelId->GetBinContent(ibin);
1315  if (PanelCode != PanelStripId) continue;
1316  if (ibin % 2 != 0) {
1317  if (h_TrackProj) {
1318  n_tr_peta = (int) h_TrackProj->GetBinContent(ibin);
1319  }
1320  //if(n_tr_peta >0){
1321  if (h_PanelId) Binposition = (int) h_PanelId->GetBinCenter(ibin);
1322  int ibin_perp = (Binposition > 0) ? ibin + 1: ibin - 1;
1323  eta_effphi = getBinContentIfValid(h_Eff, ibin_perp);
1324 
1325  gapeff = getBinContentIfValid(h_GapEff, ibin);
1326  errgapeff = getBinErrorIfValid(h_GapEff, ibin);
1327  effeta = getBinContentIfValid(h_Eff, ibin);
1328  erreffeta = getBinErrorIfValid(h_Eff, ibin);
1329 
1330  gapeffeta = gapeff;
1331  errgapeffeta = errgapeff;
1332  EffThreshold = (effeta < Minimum_efficiency) || (eta_effphi < Minimum_efficiency);
1333 
1334  reseta_cs1 = getBinContentIfValid(h_Res_CS1, ibin);
1335  errreseta_cs1 = getBinErrorIfValid(h_Res_CS1, ibin);
1336 
1337  reseta_cs2 = getBinContentIfValid(h_Res_CS2, ibin);
1338  errreseta_cs2 = getBinErrorIfValid(h_Res_CS2, ibin);
1339 
1340  reseta_csother = getBinContentIfValid(h_Res_CSmore2, ibin);
1341  errreseta_csother = getBinErrorIfValid(h_Res_CSmore2, ibin);
1342 
1343  noiseeta = getBinContentIfValid(h_NoiseTot, ibin);
1344  errnoiseeta = getBinErrorIfValid(h_NoiseTot, ibin);
1345 
1346  noiseeta_cor = getBinContentIfValid(h_NoiseCorr, ibin);
1347  errnoiseeta_cor = getBinErrorIfValid(h_NoiseCorr, ibin);
1348 
1349  cl_sizeeta = getBinContentIfValid(h_CS, ibin);
1350  errcl_sizeeta = getBinErrorIfValid(h_CS, ibin);
1351 
1352  entriesCSeta = getBinContentIfValid(h_CS_entries, ibin);
1353  entriesCS1eta = getBinContentIfValid(h_CS1_entries, ibin);
1354  entriesCS2eta = getBinContentIfValid(h_CS2_entries, ibin);
1355 
1356  if (entriesCSeta > 0) {
1357  rateCS1eta = entriesCS1eta / entriesCSeta;
1358  rateCS2eta = entriesCS2eta / entriesCSeta;
1359  rateCSmore2eta = (entriesCSeta - (entriesCS1eta + entriesCS2eta)) / entriesCSeta;
1360  }
1361 
1362  if (applyEffThreshold) {
1363  if (effeta < Minimum_efficiency && eta_effphi < Minimum_efficiency) {
1364  effeta = Minimum_efficiency;
1365  gapeffeta = Minimum_efficiency;
1366  erreffeta = 0.1;
1367  errgapeffeta = 0.1;
1368  PanelStripsStatus = PanelStripsStatusOK;
1369  cl_sizeeta = 1;
1370  errcl_sizeeta = 0.1,
1371  rateCS1eta = 1;
1372  rateCS2eta = 0;
1373  rateCSmore2eta = 0;
1374  } else if (effeta < Minimum_efficiency && eta_effphi > Minimum_efficiency) {
1375  effeta = Minimum_efficiency;
1376  gapeffeta = eta_effphi;
1377  erreffeta = 0.1;
1378  errgapeffeta = 0.1;
1379  PanelStripsStatus = PanelStripsStatusOK;
1380  cl_sizeeta = 1;
1381  errcl_sizeeta = 0.1,
1382  rateCS1eta = 1;
1383  rateCS2eta = 0;
1384  rateCSmore2eta = 0;
1385  } else if (effeta > Minimum_efficiency && eta_effphi < Minimum_efficiency) {
1386  gapeffeta = effeta;
1387  errgapeffeta = 0.1;
1388  }
1389  }
1390  sprintf(arr_effeta, "%f ", effeta);
1391  arr_effeta [5] = 0;
1392  sprintf(arr_erreffeta, "%f ", erreffeta);
1393  arr_erreffeta [5] = 0;
1394  sprintf(arr_gapeffeta, "%f ", gapeffeta);
1395  arr_gapeffeta [5] = 0;
1396  sprintf(arr_errgapeffeta, "%f ", errgapeffeta);
1397  arr_errgapeffeta [5] = 0;
1398  sprintf(arr_reseta_cs1, "%f ", reseta_cs1);
1399  arr_reseta_cs1 [5] = 0;
1400  sprintf(arr_errreseta_cs1, "%f ", errreseta_cs1);
1401  arr_errreseta_cs1 [5] = 0;
1402  sprintf(arr_reseta_cs2, "%f ", reseta_cs2);
1403  arr_reseta_cs2 [5] = 0;
1404  sprintf(arr_errreseta_cs2, "%f ", errreseta_cs2);
1405  arr_errreseta_cs2 [5] = 0;
1406  sprintf(arr_reseta_csother, "%f ", reseta_csother);
1407  arr_reseta_csother [5] = 0;
1408  sprintf(arr_errreseta_csother, "%f ", errreseta_csother);
1409  arr_errreseta_csother[5] = 0;
1410  sprintf(arr_noiseeta, "%f ", noiseeta);
1411  arr_noiseeta [5] = 0;
1412  sprintf(arr_errnoiseeta, "%f ", errnoiseeta);
1413  arr_errnoiseeta [5] = 0;
1414  sprintf(arr_noiseeta_cor, "%f ", noiseeta_cor);
1415  arr_noiseeta_cor [5] = 0;
1416  sprintf(arr_errnoiseeta_cor, "%f ", errnoiseeta_cor);
1417  arr_errnoiseeta_cor [5] = 0;
1418  sprintf(arr_cl_sizeeta, "%f ", cl_sizeeta);
1419  arr_cl_sizeeta [5] = 0;
1420  sprintf(arr_errcl_sizeeta, "%f ", errcl_sizeeta);
1421  arr_errcl_sizeeta [5] = 0;
1422  sprintf(arr_rateCS1eta, "%f ", rateCS1eta);
1423  arr_rateCS1eta [5] = 0;
1424  sprintf(arr_rateCS2eta, "%f ", rateCS2eta);
1425  arr_rateCS2eta [5] = 0;
1426  sprintf(arr_rateCSmore2eta, "%f ", rateCSmore2eta);
1427  arr_rateCSmore2eta [5] = 0;
1428 
1429  char PanelRes [255]; //eff_eta, res_cs1, res_cs2, res_csother, time, mean and rms
1430  char StripStatus [4096]; //strips status 0 to 9 for dead noisy strips
1431 
1432  sprintf(PanelRes, "%d %d %d %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s",
1433  TableVersionCondDB, n_tr_peta, StripsOnPanel, arr_effeta, arr_erreffeta,
1434  arr_gapeffeta, arr_errgapeffeta, arr_reseta_cs1, arr_errreseta_cs1, arr_reseta_cs2,
1435  arr_errreseta_cs2, arr_reseta_csother, arr_errreseta_csother, arr_noiseeta,
1436  arr_errnoiseeta, arr_noiseeta_cor, arr_errnoiseeta_cor, arr_cl_sizeeta,
1437  arr_errcl_sizeeta, arr_rateCS1eta, arr_rateCS2eta, arr_rateCSmore2eta);
1438  sprintf(StripStatus, "%s", PanelStripsStatus.c_str());
1439  std::string cool_tagCondDB = "RecoCondDB";
1440  coolrpc.setSince(0U, 0U);
1441  coolrpc.setUntil(4294967295U, 0U);
1442  coolrpc.insertCondDB_withTag(run_number * 0 + 429496729U, PanelCode, PanelRes, StripStatus,
1443  cool_tagCondDB);
1444  if (printout and EffThreshold and h_GapEff) std::cout << stripProfile_name <<
1445  " under THR " << EffThreshold << " " << PanelCode << " ibin " << ibin << " h_EffEta " <<
1446  h_Eff->GetBinContent(ibin) << " h_EffPhi " << h_Eff->GetBinContent(ibin_perp) <<
1447  " h_GapEffEta " << h_GapEff->GetBinContent(ibin) << " h_GapEffPhi " <<
1448  h_GapEff->GetBinContent(ibin_perp) << " cool_EtaEff " << effeta << " cool_GapEffEta " <<
1449  gapeffeta << " --- Eta Summary " << PanelRes << " --- StripStatus " << StripStatus <<
1450  std::endl;
1451  if (printout &&
1452  EffThreshold) std::cout << "inCOOL_ETA_id_ntrk_panelEff_gapEff " << PanelCode << " " <<
1453  n_tr_peta << " " << (int) (n_tr_peta * effeta) << " " << (int) (n_tr_peta * gapeffeta) <<
1454  std::endl;
1455  countpanelindb++;
1456  if (effeta == 0.0) countpaneleff0++;
1457  if (n_tr_peta == 0) countpaneltrack0++;
1458  } else {
1459  if (h_TrackProj) n_tr_pphi = (int) h_TrackProj->GetBinContent(ibin);
1460  //if(n_tr_pphi >0){
1461 
1462  if (h_PanelId) Binposition = (int) h_PanelId->GetBinCenter(ibin);
1463  int ibin_perp = (Binposition > 0) ? ibin - 1: ibin + 1;
1464  gapeff = getBinContentIfValid(h_GapEff, ibin_perp);
1465  errgapeff = getBinErrorIfValid(h_GapEff, ibin_perp);
1466  phi_effeta = getBinContentIfValid(h_Eff, ibin_perp);
1467 
1468  effphi = getBinContentIfValid(h_Eff, ibin);
1469  erreffphi = getBinErrorIfValid(h_Eff, ibin);
1470  gapeffphi = gapeff;
1471  errgapeffphi = errgapeff;
1472  EffThreshold = (effphi < Minimum_efficiency) || (phi_effeta < Minimum_efficiency);
1473 
1474 
1475  resphi_cs1 = getBinContentIfValid(h_Res_CS1, ibin);
1476  errresphi_cs1 = getBinErrorIfValid(h_Res_CS1, ibin);
1477 
1478  resphi_cs2 = getBinContentIfValid(h_Res_CS2, ibin);
1479  errresphi_cs2 = getBinErrorIfValid(h_Res_CS2, ibin);
1480 
1481  resphi_csother = getBinContentIfValid(h_Res_CSmore2, ibin);
1482  errresphi_csother = getBinErrorIfValid(h_Res_CSmore2, ibin);
1483 
1484  noisephi = getBinContentIfValid(h_NoiseTot, ibin);
1485  errnoisephi = getBinErrorIfValid(h_NoiseTot, ibin);
1486 
1487  noisephi_cor = getBinContentIfValid(h_NoiseCorr, ibin);
1488  errnoisephi_cor = getBinErrorIfValid(h_NoiseCorr, ibin);
1489 
1490  cl_sizephi = getBinContentIfValid(h_CS, ibin);
1491  errcl_sizephi = getBinErrorIfValid(h_CS, ibin);
1492 
1493  entriesCSphi = getBinContentIfValid(h_CS_entries, ibin);
1494  entriesCS1phi = getBinContentIfValid(h_CS1_entries, ibin);
1495  entriesCS2phi = getBinContentIfValid(h_CS2_entries, ibin);
1496  if (entriesCSphi > 0) {
1497  rateCS1phi = entriesCS1phi / entriesCSphi;
1498  rateCS2phi = entriesCS2phi / entriesCSphi;
1499  rateCSmore2phi = (entriesCSphi - (entriesCS1phi + entriesCS2phi)) / entriesCSphi;
1500  }
1501 
1502 
1503  if (applyEffThreshold) {
1504  if (effphi < Minimum_efficiency && phi_effeta < Minimum_efficiency) {
1505  effphi = Minimum_efficiency;
1506  gapeffphi = Minimum_efficiency;
1507  erreffphi = 0.1;
1508  errgapeffphi = 0.1;
1509  PanelStripsStatus = PanelStripsStatusOK;
1510  cl_sizephi = 1;
1511  errcl_sizephi = 0.1,
1512  rateCS1phi = 1;
1513  rateCS2phi = 0;
1514  rateCSmore2phi = 0;
1515  } else if (effphi < Minimum_efficiency && phi_effeta > Minimum_efficiency) {
1516  effphi = Minimum_efficiency;
1517  gapeffphi = phi_effeta;
1518  erreffphi = 0.1;
1519  errgapeffphi = 0.1;
1520  PanelStripsStatus = PanelStripsStatusOK;
1521  cl_sizephi = 1;
1522  errcl_sizephi = 0.1,
1523  rateCS1phi = 1;
1524  rateCS2phi = 0;
1525  rateCSmore2phi = 0;
1526  } else if (effphi > Minimum_efficiency && phi_effeta < Minimum_efficiency) {
1527  gapeffphi = effphi;
1528  errgapeffphi = 0.1;
1529  PanelStripsStatus = PanelStripsStatusOK;
1530  }
1531  }
1532 
1533  sprintf(arr_effphi, "%f ", effphi);
1534  arr_effphi [5] = 0;
1535  sprintf(arr_erreffphi, "%f ", erreffphi);
1536  arr_erreffphi [5] = 0;
1537  sprintf(arr_gapeffphi, "%f ", gapeffphi);
1538  arr_gapeffphi [5] = 0;
1539  sprintf(arr_errgapeffphi, "%f ", errgapeffphi);
1540  arr_errgapeffphi [5] = 0;
1541  sprintf(arr_resphi_cs1, "%f ", resphi_cs1);
1542  arr_resphi_cs1 [5] = 0;
1543  sprintf(arr_errresphi_cs1, "%f ", errresphi_cs1);
1544  arr_errresphi_cs1 [5] = 0;
1545  sprintf(arr_resphi_cs2, "%f ", resphi_cs2);
1546  arr_resphi_cs2 [5] = 0;
1547  sprintf(arr_errresphi_cs2, "%f ", errresphi_cs2);
1548  arr_errresphi_cs2 [5] = 0;
1549  sprintf(arr_resphi_csother, "%f ", resphi_csother);
1550  arr_resphi_csother [5] = 0;
1551  sprintf(arr_errresphi_csother, "%f ", errresphi_csother);
1552  arr_errresphi_csother[5] = 0;
1553  sprintf(arr_noisephi, "%f ", noisephi);
1554  arr_noisephi [5] = 0;
1555  sprintf(arr_errnoisephi, "%f ", errnoisephi);
1556  arr_errnoisephi [5] = 0;
1557  sprintf(arr_noisephi_cor, "%f ", noisephi_cor);
1558  arr_noisephi_cor [5] = 0;
1559  sprintf(arr_errnoisephi_cor, "%f ", errnoisephi_cor);
1560  arr_errnoisephi_cor [5] = 0;
1561  sprintf(arr_cl_sizephi, "%f ", cl_sizephi);
1562  arr_cl_sizephi [5] = 0;
1563  sprintf(arr_errcl_sizephi, "%f ", errcl_sizephi);
1564  arr_errcl_sizephi [5] = 0;
1565  sprintf(arr_rateCS1phi, "%f ", rateCS1phi);
1566  arr_rateCS1phi [5] = 0;
1567  sprintf(arr_rateCS2phi, "%f ", rateCS2phi);
1568  arr_rateCS2phi [5] = 0;
1569  sprintf(arr_rateCSmore2phi, "%f ", rateCSmore2phi);
1570  arr_rateCSmore2phi [5] = 0;
1571 
1572  char PanelRes [255]; //eff_eta, res_cs1, res_cs2, res_csother, time, mean and rms
1573  char StripStatus [4096]; //strips status 0 to 9 for dead noisy strips
1574  sprintf(PanelRes, "%d %d %d %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s",
1575  TableVersionCondDB, n_tr_pphi,
1576  StripsOnPanel, arr_effphi, arr_erreffphi, arr_gapeffphi, arr_errgapeffphi,
1577  arr_resphi_cs1, arr_errresphi_cs1, arr_resphi_cs2,
1578  arr_errresphi_cs2, arr_resphi_csother, arr_errresphi_csother, arr_noisephi,
1579  arr_errnoisephi, arr_noisephi_cor, arr_errnoisephi_cor,
1580  arr_cl_sizephi, arr_errcl_sizephi, arr_rateCS1phi, arr_rateCS2phi,
1581  arr_rateCSmore2phi);
1582  sprintf(StripStatus, "%s", PanelStripsStatus.c_str());
1583  std::string cool_tag = "RecoCondDB";
1584  coolrpc.setSince(0U, 0U);
1585  coolrpc.setUntil(4294967295U, 0U);
1586  coolrpc.insertCondDB_withTag(run_number * 0 + 429496729U, PanelCode, PanelRes, StripStatus,
1587  cool_tag);
1588 
1589  if (printout &&
1590  EffThreshold) std::cout << stripProfile_name << " under THR " << EffThreshold << " " <<
1591  PanelCode << " ibin " << ibin << " h_EffPhi " << h_Eff->GetBinContent(ibin)
1592  << " h_EffEta " <<
1593  h_Eff->GetBinContent(ibin_perp) << " h_GapEffPhi " << h_GapEff->GetBinContent(ibin) <<
1594  " h_GapEffEta " << h_GapEff->GetBinContent(ibin_perp) << " cool_PhiEff "
1595  << effphi << " cool_GapEffPhi " << gapeffphi <<
1596  " --- Phi Summary " << PanelRes << " --- StripStatus " << StripStatus << std::endl;
1597 
1598  if (printout && EffThreshold) std::cout << "inCOOL_PHI_id_ntrk_panelEff_gapEff " << PanelCode << " " << n_tr_pphi << " " << (int) (n_tr_pphi * effphi) << " " << (int) (n_tr_pphi * gapeffphi) << std::endl;
1599  countpanelindb++;
1600  if (effphi == 0.0) countpaneleff0++;
1601  if (n_tr_pphi == 0) countpaneltrack0++;
1602  }
1603  StripsOnPanel = 1;
1604  PanelStripsStatus.clear();
1605  PanelStripsStatusOK.clear();
1606  }
1607  StripsOnPanel = 1;
1608  PanelStripsStatus.clear();
1609  PanelStripsStatusOK.clear();
1610  }
1611  }
1612  }
1613  } // end loop on DoubletPhi
1614  } // end loop on layers
1615  }// end Cool Folder
1616  std::cout << "Count RC panels in DB " << countpanelindb << " Count RPCpanels in DB with zero efficiency " << countpaneleff0 << " Count RPCpanels in DB with zero track " << countpaneltrack0 << std::endl;
1617  } // end for sectors
1618  std::cout << "Count RC panels in DB " << countpanelindb << " Count RPCpanels in DB with zero efficiency " << countpaneleff0 << " Count RPCpanels in DB with zero track " << countpaneltrack0 << std::endl;
1619  // write distribution plots all ATLAS
1620  TDirectory* dirA = f->GetDirectory(dir_sideA_track.c_str());
1621 
1622  if (dirA != 0) {
1623  dirA->cd();
1624  writeIfValid(h_AverageEff_A);
1625  writeIfValid(h_AverageGapEff_A);
1626  writeIfValid(h_AverageRes_CS1_A);
1627  writeIfValid(h_AverageRes_CS1rms_A);
1628  writeIfValid(h_AverageRes_CS2_A);
1629  writeIfValid(h_AverageRes_CS2rms_A);
1630  writeIfValid(h_AverageRes_CSmore2_A);
1631  writeIfValid(h_AverageRes_CSmore2rms_A);
1632  writeIfValid(h_AverageOccupancy_A);
1633  writeIfValid(h_AverageCS_A);
1634  writeIfValid(h_AverageTime_A);
1635  writeIfValid(h_AverageNoiseCorr_A);
1636  writeIfValid(h_AverageNoiseTot_A);
1637  }
1638  TDirectory* dirC = f->GetDirectory(dir_sideC_track.c_str());
1639  if (dirC != 0) {
1640  dirC->cd();
1641  writeIfValid(h_AverageEff_C);
1642  writeIfValid(h_AverageGapEff_C);
1643  writeIfValid(h_AverageRes_CS1_C);
1644  writeIfValid(h_AverageRes_CS1rms_C);
1645  writeIfValid(h_AverageRes_CS2_C);
1646  writeIfValid(h_AverageRes_CS2rms_C);
1647  writeIfValid(h_AverageRes_CSmore2_C);
1648  writeIfValid(h_AverageRes_CSmore2rms_C);
1649  writeIfValid(h_AverageOccupancy_C);
1650  writeIfValid(h_AverageCS_C);
1651  writeIfValid(h_AverageTime_C);
1652  writeIfValid(h_AverageNoiseCorr_C);
1653  writeIfValid(h_AverageNoiseTot_C);
1654  }
1655  }
1656  } else {
1657  delete obj_run;
1658  } // end if tdir_run !=0
1659  }
1660  f->Close();
1661  delete f;
1662  }
1663 
1664  bool
1666  RPCCheckHistogram(TFile* f, const char* HistoName) {
1667  if (!(f->Get(HistoName))) {
1668  return false;
1669  } else return true;
1670  }
1671 }
plotting.plot_kinematics.run_number
run_number
Definition: plot_kinematics.py:29
get_generator_info.result
result
Definition: get_generator_info.py:21
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
StringUtils.h
PlotCalibFromCool.ib
ib
Definition: PlotCalibFromCool.py:419
CoolRpc.h
TrigVSI::AlgConsts::nPhi
constexpr int nPhi
Default bin number of phi for vertex map.
Definition: Trigger/TrigTools/TrigVrtSecInclusive/TrigVrtSecInclusive/Constants.h:27
dqutils::CoolRpc::setUntil
void setUntil(cool::Int64 iovmax, cool::Int64 lumi)
DeMoUpdate.reverse
reverse
Definition: DeMoUpdate.py:563
systematicsTool.writeToFile
def writeToFile(histDict, fOut)
Definition: systematicsTool.py:1035
xAOD::StripCluster
StripCluster_v1 StripCluster
Define the version of the strip cluster class.
Definition: StripCluster.h:13
CalibDbCompareRT.cool_tag
cool_tag
Definition: CalibDbCompareRT.py:12
CheckAppliedSFs.bmin
bmin
Definition: CheckAppliedSFs.py:242
dqutils::CoolRpc
Definition: CoolRpc.h:77
dqutils::CoolRpc::coolDbFolder
void coolDbFolder(const std::string &dbStr, const std::string &folderStr)
dqutils::MonitoringFile::RPCPostProcess
static void RPCPostProcess(const std::string &inFilename, bool isIncremental=false)
Definition: MonitoringFile_RPCPostProcess.cxx:89
sign
int sign(int a)
Definition: TRT_StrawNeighbourSvc.h:107
hist_file_dump.f
f
Definition: hist_file_dump.py:135
dqutils::CoolRpc::insertCondDB_withTag
void insertCondDB_withTag(cool::Int64 run, cool::ChannelId channelId, const std::string &PanelRes, const std::string &StringStatus, const std::string &cool_tag)
dqutils
Definition: CoolMdt.h:76
dqutils::CoolRpc::insert_withTag
void insert_withTag(cool::Int64 run, cool::ChannelId channelId, const std::string &recEta, const std::string &DetEta, const std::string &recPhi1, const std::string &recPhi2, const std::string &detPhi1, const std::string &detPhi2, const std::string &cool_tag)
beamspotman.dir
string dir
Definition: beamspotman.py:623
dqutils::MonitoringFile::RPCCheckHistogram
static bool RPCCheckHistogram(TFile *f, const char *HistoName)
Definition: MonitoringFile_RPCPostProcess.cxx:1666
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
dqutils::CoolRpc::setSince
void setSince(cool::Int64 run, cool::Int64 lumi)
MonitoringFile.h
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
TrigVSI::AlgConsts::nEta
constexpr int nEta
Default bin number of eta for vertex map.
Definition: Trigger/TrigTools/TrigVrtSecInclusive/TrigVrtSecInclusive/Constants.h:26
hotSpotInTAG.nb
nb
Definition: hotSpotInTAG.py:164
readCCLHist.float
float
Definition: readCCLHist.py:83