ATLAS Offline Software
MdtDeadNoisyUtils.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3  */
4 
6 //Method To Calculate MDT Dead Noisy Tubes
7 //Author Orin Harris omh@cern.ch University of Washington
8 // Justin Griffiths griffith@cern.ch University of Washington
9 //Aug 2009
12 #include <cmath>
13 #include <algorithm>
14 #include <TLine.h>
15 #include <TText.h>
16 
17 using std::sort;
18 using std::vector;
19 
20 #define STDDEV_POS 1.0
21 #define MARKER_POS_RED 0.6
22 #define MEZZ_POS 0.4
23 #define LAYER_POS 0.3
24 #define ML_POS 0.22
25 #define MARKER_POS_BLUE 0.15
26 
27 namespace dqutils_mdtdeadnoisy {
28  double sqr(double x) {
29  return x * x;
30  }
31 
32  void displayList(std::vector<int>& v) {
33  std::cout << "{ ";
34  if (v.size() > 1) {
35  if (v.at(0) + 1 != v.at(1)) std::cout << v.at(0) << ", ";
36  else if (v.at(0) + 1 == v.at(1)) std::cout << v.at(0) << "-";
37  for (unsigned int i = 1; i < v.size() - 1; i++) {
38  if (v.at(i) + 1 != v.at(i + 1)) std::cout << v.at(i) << ", ";
39  else if (v.at(i - 1) + 1 != v.at(i) && v.at(i) + 1 == v.at(i + 1)) std::cout << v.at(i) << "-";
40  }
41  std::cout << v.back();
42  } else if (v.size() > 0) std::cout << v.at(0);
43  std::cout << " }" << std::endl;
44  }
45 
46  void displayList(std::vector<int>& v, std::ofstream& outputfile) {
47  outputfile << "{ ";
48  if (v.size() > 1) {
49  if (v.at(0) + 1 != v.at(1)) outputfile << v.at(0) << ", ";
50  else if (v.at(0) + 1 == v.at(1)) outputfile << v.at(0) << "-";
51  for (unsigned int i = 1; i < v.size() - 1; i++) {
52  if (v.at(i) + 1 != v.at(i + 1)) outputfile << v.at(i) << ", ";
53  else if (v.at(i - 1) + 1 != v.at(i) && v.at(i) + 1 == v.at(i + 1)) outputfile << v.at(i) << "-";
54  }
55  outputfile << v.back();
56  } else if (v.size() > 0) outputfile << v.at(0);
57  outputfile << " }" << std::endl;
58  }
59 
60  void getDeadList(TH1F* h, std::vector<int>& v) {
61  v.clear();
62  for (int i = 1; i <= h->GetNbinsX(); i++) {
63  if (h->At(i) <= 0) v.push_back(i);
64  }
65  }
66 
67  bool find(std::vector<int>& v, unsigned int x) {
68  for (unsigned int i = 0; i < v.size(); i++)
69  if ((int) x == v.at(i)) return true;
70 
71  return false;
72  }
73 
74  void getSurelyDeadList(TH1F* h, std::vector<int>& v, std::vector<int>& betweenlist) {
75  v.clear();
76  if (h->At(1) <= 0 && h->At(2) != 0 && !find(betweenlist, 1)) v.push_back(1);
77  for (int i = 2; i <= h->GetNbinsX() - 1; i++) {
78  if (h->At(i - 1) > 0 && h->At(i) <= 0 && h->At(i + 1) > 0 && !find(betweenlist, i)) v.push_back(i);
79  }
80  if (h->At(h->GetNbinsX()) <= 0 && h->At(h->GetNbinsX() - 1) != 0 && !find(betweenlist, h->GetNbinsX())) v.push_back(
81  h->GetNbinsX());
82  }
83 
84  void getNotBetweenList(std::vector<int>& v, std::vector<int>& surely_v, std::vector<int>& betweenlist) {
85  surely_v.clear();
86  for (unsigned int i = 0; i < v.size(); i++) {
87  if (!find(betweenlist, v.at(i))) {
88  surely_v.push_back(v.at(i));
89  }
90  }
91  }
92 
93  void getAllBins(TH1F* h, std::vector<int>& v) {
94  v.clear();
95  for (int i = 1; i <= h->GetNbinsX(); i++)
96  v.push_back((int) (h->At(i)));
97  }
98 
99  void getAllBinsInRange(TH1F* h, std::vector<int>& v, int x1, int x2) {
100  v.clear();
101  if (x1 < 1 || x2 > h->GetNbinsX()) {
102  std::cout << "WARNING in " <<
103  ((TString) h->GetName())(0,
104  7) << ": in getAllBinsInRange: (" << x1 << "," << x2 << ") outside histo range!" <<
105  std::endl;
106  return;
107  }
108  for (int i = x1; i <= x2; i++)
109  v.push_back((int) (h->At(i)));
110  }
111 
112  void getAllBinsInRangeBelowCrustCutoff(TH1F* h, std::vector<int>& v, int crustCutoff, int x1, int x2) {
113  v.clear();
114  if (x1 < 1 || x2 > h->GetNbinsX()) {
115  std::cout << "WARNING in " <<
116  ((TString) h->GetName())(0,
117  7) << ": in getAllBinsInRangeBelowCrustCutoff: (" << x1 << "," << x2 <<
118  ") outside histo range!" << std::endl;
119  return;
120  }
121  for (int i = x1; i <= x2; ++i) {
122  if (h->At(i) < crustCutoff) v.push_back((int) (h->At(i)));
123  else v.push_back(crustCutoff);
124  }
125  }
126 
127  void getAllUnmaskedBinsInRangeBelowCrustCutoff(TH1F* h, std::vector<int>& v, int crustCutoff, int x1, int x2) {
128  vector<int> maskedTubes = GetMaskedTubesForDead(h);
129  v.clear();
130  if (x1 < 1 || x2 > h->GetNbinsX()) {
131  std::cout << "WARNING in " <<
132  ((TString) h->GetName())(0,
133  7) << ": in getAllUnmaskedBinsInRangeBelowCrustCutoff: (" << x1 << "," << x2 <<
134  ") outside histo range!" <<
135  std::endl;
136  return;
137  }
138  for (int i = x1; i <= x2; ++i) {
139  if ((h->At(i) < crustCutoff) && !AinB(i, maskedTubes)) v.push_back((int) (h->At(i)));
140  else v.push_back(crustCutoff);
141  }
142  }
143 
144  void getBins(TH1F* h, std::vector<int>& indices, std::vector<int>& content) {
145  content.clear();
146  for (unsigned int i = 0; i < indices.size(); ++i) {
147  content.push_back((int) (h->At(indices.at(i))));
148  }
149  }
150 
151  void removeZeros(std::vector<int>& v) {
152  std::vector<int> tmp;
153  for (unsigned int i = 0; i < v.size(); ++i) {
154  if (v.at(i) > 0) tmp.push_back(v.at(i));
155  }
156  v = std::move(tmp);
157  }
158 
159  void getNonEmptyBins(TH1F* h, std::vector<int>& v) {
160  v.clear();
161  for (int i = 1; i <= h->GetNbinsX(); ++i) {
162  if (h->At(i) > 0) v.push_back((int) (h->At(i)));
163  }
164  }
165 
166  void getAllTubes(TH1F* h, std::vector<int>& v) {
167  v.clear();
168  for (int i = 1; i <= h->GetNbinsX(); ++i) {
169  v.push_back(i);
170  }
171  }
172 
173  void getNonEmptyTubes(TH1F* h, std::vector<int>& v) {
174  v.clear();
175  for (int i = 1; i <= h->GetNbinsX(); ++i) {
176  if (h->At(i) > 0) v.push_back(i);
177  }
178  }
179 
180  void getNotMasked(std::vector<int>& v, TH1F* h) {
181  vector<int> maskedTubes = GetMaskedTubesForDead(h);
182 
183  if (maskedTubes.empty()) return;
184 
185  std::vector<int> tmp;
186  for (unsigned int i = 0; i < v.size(); ++i) {
187  if (!AinB(v.at(i), maskedTubes)) {
188  tmp.push_back(v.at(i));
189  }
190  }
191  v = std::move(tmp);
192  }
193 
194  void getNotInDeadMezz(std::vector<int>& v, std::vector<int>& deadMezz_v, const TString& hardware_name,
195  int totalTubes) {
196  if (deadMezz_v.empty()) return;
197 
198 // std::cout << "Mezz dead! Trying to mask out...\n";
199 
200  int groupsPerLayer;
201  std::vector<TubeRange> tubeRanges = getMezzRanges(hardware_name, totalTubes, groupsPerLayer);
202 
203  std::vector<int> tmp;
204  for (unsigned int i = 0; i < v.size(); ++i) {
205  if (!AinB(Get_Mezz_of_Tube(v.at(i), hardware_name /*,totalTubes*/, tubeRanges, groupsPerLayer), deadMezz_v)) {
206 // std::cout << "Mezz of tube " << v.at(i) << ": " <<
207 // Get_Mezz_of_Tube(v.at(i),hardware_name/*,totalTubes*/,tubeRanges,groupsPerLayer) << ", dead Mezz: " <<
208 // deadMezz_v.at(0) << std::endl;
209  tmp.push_back(v.at(i));
210  }
211  }
212  v = std::move(tmp);
213  }
214 
215  void getNotInDeadLayer(std::vector<int>& v, std::vector<int>& deadLayer_v, const TString& hardware_name,
216  int totalTubes) {
217  if (deadLayer_v.empty()) return;
218 
219  std::vector<int> tmp;
220  for (unsigned int i = 0; i < v.size(); ++i) {
221  if (!AinB(Get_Layer_of_Tube(v.at(i), hardware_name, totalTubes), deadLayer_v)) {
222  tmp.push_back(v.at(i));
223  }
224  }
225  v = std::move(tmp);
226  }
227 
228  void getNotInDeadML(std::vector<int>& v, std::vector<int>& deadML_v, const TString& hardware_name, int totalTubes) {
229  if (deadML_v.empty()) return;
230 
231 // std::cout << "ML dead! Trying to mask out...\n";
232  std::vector<int> tmp;
233  for (unsigned int i = 0; i < v.size(); ++i) {
234  if (!AinB(Get_ML_of_Tube(v.at(i), hardware_name, totalTubes), deadML_v)) {
235 // std::cout << "ML of tube " << v.at(i) << ": " << Get_ML_of_Tube(v.at(i),hardware_name,totalTubes) << ", dead ML: "
236 // << deadML_v.at(0) << std::endl;
237  tmp.push_back(v.at(i));
238  }
239  }
240  v = std::move(tmp);
241  }
242 
243  template <class T>
244  double getMean(std::vector<T>& v) {
245  double runningMean = 0;
246 
247  for (unsigned int i = 0; i < v.size(); i++) {
248  runningMean = (runningMean * (i) + v.at(i)) / (double) (i + 1);
249  }
250  return runningMean;
251  }
252 
253  double getMean_WithCut(std::vector<int>& v, double cut) {
254  double runningMean = 0;
255  int counter = 0;
256 
257  for (unsigned int i = 0; i < v.size(); ++i) {
258  if ((double) v.at(i) < cut) {
259  runningMean = (runningMean * (counter) + v.at(i)) / (double) (counter + 1);
260  counter++;
261  }
262  }
263  return runningMean;
264  }
265 
266  void getNoBetweens(TH1F* h, std::vector<int>& no_dead, std::vector<int>& no_betweens, std::vector<int>& betweenlist,
267  float minBinContent) {
268  no_betweens.clear();
269  betweenlist.clear();
270  std::vector<int> tmp_no_dead_pruned;
271  getNoBetweens_middle_aggressive(no_dead, tmp_no_dead_pruned);
272  double no_dead_mean = getMean(tmp_no_dead_pruned);
273  std::vector<int> tmp_no_betweens, tmp_betweenlist;
274  for (int i = 1; i <= h->GetNbinsX(); i++) {
275  if (h->At(i) > minBinContent * no_dead_mean) {
276  tmp_no_betweens.push_back((int) (h->At(i)));
277  tmp_betweenlist.push_back(i);
278  } else {
279  if (tmp_no_betweens.size() >= 1 && getMean_WithCut(tmp_no_betweens, 2. * no_dead_mean) < 0.25 * no_dead_mean) {
280  betweenlist.insert(betweenlist.end(), tmp_betweenlist.begin(), tmp_betweenlist.end());
281  tmp_no_betweens.clear();
282  tmp_betweenlist.clear();
283  } else if (tmp_no_betweens.size() >= 1) {
284  no_betweens.insert(no_betweens.end(), tmp_no_betweens.begin(), tmp_no_betweens.end());
285  tmp_no_betweens.clear();
286  tmp_betweenlist.clear();
287  }
288  betweenlist.push_back(i); // look into this -- shouldn't have 'else' for this somewhere?
289  // displayList(betweenlist) should get to the bottom if duplicates
290  }
291  }
292  if (tmp_no_betweens.size() >= 1 && getMean_WithCut(tmp_no_betweens, 2. * no_dead_mean) < 0.25 * no_dead_mean) {
293  betweenlist.insert(betweenlist.end(), tmp_betweenlist.begin(), tmp_betweenlist.end());
294  } else if (tmp_no_betweens.size() >= 1) {
295  no_betweens.insert(no_betweens.end(), tmp_no_betweens.begin(), tmp_no_betweens.end());
296  }
297  }
298 
299  void removeNonContiguous(std::vector<int>& betweenlist, unsigned int sz) {
300  std::vector<int> betweenlist_copy = betweenlist;
301  std::vector<int> tmp_betweenlist;
302  betweenlist.clear();
303  if (betweenlist_copy.size() <= 2) return;
304 
305  for (unsigned int i = 0; i < betweenlist_copy.size() - 1; i++) {
306  if (betweenlist_copy.at(i) + 1 == betweenlist_copy.at(i + 1)) {
307  tmp_betweenlist.push_back(betweenlist_copy.at(i));
308  if (i == betweenlist_copy.size() - 2) tmp_betweenlist.push_back(betweenlist_copy.at(i + 1));
309  } else {
310  if (tmp_betweenlist.size() >= 1) tmp_betweenlist.push_back(betweenlist_copy.at(i));
311  if (tmp_betweenlist.size() >= sz) betweenlist.insert(betweenlist.end(),
312  tmp_betweenlist.begin(), tmp_betweenlist.end());
313  tmp_betweenlist.clear();
314  }
315  }
316  if (tmp_betweenlist.size() >= sz) betweenlist.insert(betweenlist.end(),
317  tmp_betweenlist.begin(), tmp_betweenlist.end());
318  }
319 
320  void getNoBetweens_middle(std::vector<int> no_betweens, std::vector<int>& no_betweens_middle) {
321  no_betweens_middle.clear();
322  sort(no_betweens.begin(), no_betweens.end());
323  int crustSize = no_betweens.size() / 20;
324  no_betweens_middle.insert(no_betweens_middle.begin(), no_betweens.begin() + crustSize,
325  no_betweens.end() - crustSize);
326  }
327 
328  void getNoBetweens_lowmiddle(std::vector<int> no_betweens, std::vector<int>& no_betweens_lowmiddle) {
329  no_betweens_lowmiddle.clear();
330  sort(no_betweens.begin(), no_betweens.end());
331  int crustSize = no_betweens.size() / 4;
332  no_betweens_lowmiddle.insert(no_betweens_lowmiddle.begin(), no_betweens.begin() + crustSize,
333  no_betweens.begin() + 2 * crustSize);
334  }
335 
336  void getNoBetweens_middle_aggressive(std::vector<int> no_betweens, std::vector<int>& no_betweens_middle_aggressive) {
337  no_betweens_middle_aggressive.clear();
338  sort(no_betweens.begin(), no_betweens.end());
339  int crustSize = no_betweens.size() / 4;
340  no_betweens_middle_aggressive.insert(no_betweens_middle_aggressive.begin(),
341  no_betweens.begin() + crustSize, no_betweens.end() - crustSize);
342  }
343 
344  void getNoBetweens_middle_semiaggressive(std::vector<int> no_betweens,
345  std::vector<int>& no_betweens_middle_aggressive) {
346  no_betweens_middle_aggressive.clear();
347  sort(no_betweens.begin(), no_betweens.end());
348  int crustSize = no_betweens.size() / 8;
349  no_betweens_middle_aggressive.insert(no_betweens_middle_aggressive.begin(),
350  no_betweens.begin() + crustSize, no_betweens.end() - crustSize);
351  }
352 
353  void getNoBetweens_lowmiddle_aggressive(std::vector<int> no_betweens,
354  std::vector<int>& no_betweens_lowmiddle_aggressive) {
355  no_betweens_lowmiddle_aggressive.clear();
356  sort(no_betweens.begin(), no_betweens.end());
357  int crustSize = no_betweens.size() / 10;
358  no_betweens_lowmiddle_aggressive.insert(no_betweens_lowmiddle_aggressive.begin(),
359  no_betweens.begin() + crustSize, no_betweens.begin() + 2 * crustSize);
360  }
361 
362  void getNoBetweens_highmiddle_aggressive(std::vector<int> no_betweens,
363  std::vector<int>& no_betweens_lowmiddle_aggressive) {
364  no_betweens_lowmiddle_aggressive.clear();
365  sort(no_betweens.begin(), no_betweens.end());
366  int crustSize = no_betweens.size() / 10;
367  no_betweens_lowmiddle_aggressive.insert(no_betweens_lowmiddle_aggressive.begin(),
368  no_betweens.end() - 2 * crustSize, no_betweens.end() - crustSize);
369  }
370 
371  double getStandardDevFromMean(std::vector<int>& v, double mean) {
372  double sum = 0;
373 
374  for (unsigned int i = 0; i < v.size(); i++) {
375  double diff = (double) v.at(i) - mean;
376  if (diff > 100.0 * mean) // lines to avoid bias due to very noisy tubes
377  diff = 100.0 * mean;
378  sum += sqr(diff);
379  }
380  return std::sqrt(sum / (double) v.size());
381  }
382 
383  double getStandardDevFromMean_neg(std::vector<int>& v, double mean) {
384  double sum = 0;
385 
386  for (unsigned int i = 0; i < v.size(); i++) {
387  double diff = (double) v.at(i) - mean;
388  if (diff > 100.0 * mean) // avoid bias due to very noisy tubes
389  diff = 100.0 * mean;
390  if (diff < 0.) sum += sqr(diff);
391  }
392  return std::sqrt(sum / (double) v.size());
393  }
394 
395  double getStandardDevFromMean_pos(std::vector<int>& v, double mean) {
396  double sum = 0;
397 
398  for (unsigned int i = 0; i < v.size(); i++) {
399  double diff = (double) v.at(i) - mean;
400  if (diff > 100.0 * mean) // avoid bias due to very noisy tubes
401  diff = 100.0 * mean;
402  if (diff > 0.) sum += sqr(diff);
403  }
404  return std::sqrt(sum / (double) v.size());
405  }
406 
407  void getNoisyList(TH1F* h, std::vector<int>& no_betweens_middle, std::vector<int>& no_betweens_middle_aggressive,
408  double num_std_dev, std::vector<int>& noisylist) {
409  noisylist.clear();
410  double mean = getMean(no_betweens_middle_aggressive); // a fancy median
411  double stddev = getStandardDevFromMean(no_betweens_middle, mean);
412  for (int i = 1; i <= h->GetNbinsX(); i++) {
413  if (h->At(i) - mean > num_std_dev * stddev) noisylist.push_back(i);
414  }
415  }
416 
417  void getNoisyList2(TH1F* h, [[maybe_unused]] std::vector<int>& no_betweens_middle,
418  std::vector<int>& no_betweens_middle_aggressive, double num_pct, std::vector<int>& noisylist) {
419  noisylist.clear();
420  double mean = getMean(no_betweens_middle_aggressive); // a fancy median
421  if (mean > 0) {
422  for (int i = 1; i <= h->GetNbinsX(); i++) {
423  if (h->At(i) > (mean) * ((num_pct / 100.) + (500. - 25. * (num_pct / 100.)) / (mean * mean))) {
424  noisylist.push_back(i);
425  }
426  }
427  }
428  }
429 
430  void getIneffList(TH1F* h, std::vector<int>& no_betweens_middle, std::vector<int>& no_betweens_lowmiddle_aggressive,
431  double num_std_dev, std::vector<int>& inefflist) {
432  inefflist.clear();
433  double mean = getMean(no_betweens_lowmiddle_aggressive); // a fancy median
434  double stddev = getStandardDevFromMean(no_betweens_middle, mean);
435  for (int i = 1; i <= h->GetNbinsX(); i++) {
436  if (mean - h->At(i) > num_std_dev * stddev) inefflist.push_back(i);
437  }
438  }
439 
440  void getIneffList(TH1F* h, std::vector<int>& no_betweens_middle, std::vector<int>& no_betweens_lowmiddle_aggressive,
441  double num_std_dev_1, double num_std_dev_2, std::vector<int>& inefflist) {
442  inefflist.clear();
443  double mean = getMean(no_betweens_lowmiddle_aggressive); // a fancy median
444  double stddev = getStandardDevFromMean(no_betweens_middle, mean);
445  for (int i = 1; i <= h->GetNbinsX(); i++) {
446  if (mean - h->At(i) > num_std_dev_1 * stddev && mean - h->At(i) <= num_std_dev_2 * stddev) inefflist.push_back(i);
447 
448  }
449  }
450 
451  void getIneffList2(TH1F* h, [[maybe_unused]] std::vector<int>& no_betweens_middle,
452  std::vector<int>& no_betweens_lowmiddle_aggressive, double num_pct, std::vector<int>& inefflist) {
453  inefflist.clear();
454  double mean = getMean(no_betweens_lowmiddle_aggressive); // a fancy median
455  for (int i = 1; i <= h->GetNbinsX(); i++) {
456  if (h->At(i) < mean * num_pct / 100.) inefflist.push_back(i);
457  }
458  }
459 
460  void getIneffList2(std::vector<int>& indices, TH1F* h, [[maybe_unused]] std::vector<int>& no_betweens_middle,
461  std::vector<int>& no_betweens_lowmiddle_aggressive, double num_pct, std::vector<int>& inefflist) {
462  inefflist.clear();
463  double mean = getMean(no_betweens_lowmiddle_aggressive); // a fancy median
464  for (unsigned int i = 0; i < indices.size(); ++i) {
465  int index = indices.at(i);
466  if (h->At(index) < mean * num_pct / 100.) inefflist.push_back(index);
467  }
468  }
469 
470  void getIneffList2(TH1F* h, [[maybe_unused]] std::vector<int>& no_betweens_middle,
471  std::vector<int>& no_betweens_lowmiddle_aggressive, double num_pct_1, double num_pct_2,
472  std::vector<int>& inefflist) {
473  inefflist.clear();
474  double mean = getMean(no_betweens_lowmiddle_aggressive); // a fancy median
475  for (int i = 1; i <= h->GetNbinsX(); i++) {
476  if (h->At(i) < mean * num_pct_2 / 100. && h->At(i) > mean * num_pct_1 / 100.) inefflist.push_back(i);
477  }
478  }
479 
480  // for deads
481  bool validityCheckDead(std::vector<int>& no_betweens_middle, std::vector<int>& no_betweens_lowmiddle) {
482  bool isOK = true;
483  double mean = getMean(no_betweens_lowmiddle);
484 
485  if (no_betweens_middle.size() < 60) {
486 // std::cout << " WARNING: few non-empty bins" << std::endl;
487  isOK = false;
488  }
489 // std::cout << " " << mean << " " << getStandardDevFromMean_neg( no_betweens_middle, mean ) << std::endl;
490  if (mean < 25. ||
491  (mean < 50. &&
492  getStandardDevFromMean_neg(no_betweens_middle,
493  mean) > 0.2 * mean) ||
494  (mean < 100. && getStandardDevFromMean_neg(no_betweens_middle, mean) > 0.3 * mean)) {
495 // std::cout << " WARNING: low Mean" << std::endl;
496 // std::cout << " MEAN: " << mean << std::endl;
497 // std::cout << " STDV: " << getStandardDevFromMean_neg( no_betweens_middle, mean ) << std::endl;
498  isOK = false;
499  }
500  if (getStandardDevFromMean_neg(no_betweens_middle, mean) > 0.5 * mean) {
501 // std::cout << " WARNING: large Standard Dev relative to mean" << std::endl;
502  isOK = false;
503  }
504 
505  return isOK;
506  }
507 
508  // for noisy: this inlcudes max for the noisies only (even at low stat could have very noisy tube)
509  // the max parameter is not currently used.
510  bool validityCheckNoise(std::vector<int>& no_betweens_middle, std::vector<int>& no_betweens_middle_aggressive
511 /*, int max*/) {
512  bool isOK = true;
513  double mean = getMean(no_betweens_middle_aggressive);
514 
515 // std::cout << " val check mean: " << mean << std::endl;
516 // std::cout << " val check stdev: " << getStandardDevFromMean( no_betweens_middle, mean ) << std::endl;
517 
518  if (no_betweens_middle.size() < 60) {
519 // std::cout << " WARNING: few non-empty bins" << std::endl;
520  isOK = false;
521  }
522  if (mean < 5.) {
523 // std::cout << " WARNING: low Mean" << std::endl;
524  isOK = false;
525  }
526  if (getStandardDevFromMean(no_betweens_middle, mean) > 2. * mean) {
527 // std::cout << " WARNING: large Standard Dev relative to mean" << std::endl;
528  isOK = false;
529  }
530 
531  return isOK;
532  }
533 
534  void getNonEmptyNonNoisyTubes(TH1F* h_tube_fornoise, TH1F* h_tube, std::vector<int>& non_dead_non_noisy) {
535  std::vector<int> no_deads, non_noisy, no_betweens, no_betweens_middle, no_betweens_middle_aggressive,
536  no_betweens_highmiddle_aggressive, betweenlist, noisylist;
537  non_dead_non_noisy.clear();
538 
539  getNonEmptyBins(h_tube_fornoise, no_deads);
540  getNoBetweens(h_tube_fornoise, no_deads, no_betweens, betweenlist, .05);
541  getNoBetweens_middle(no_betweens, no_betweens_middle);
542  getNoBetweens_middle_aggressive(no_betweens, no_betweens_middle_aggressive);
543  getNoBetweens_highmiddle_aggressive(std::move(no_betweens), no_betweens_highmiddle_aggressive);
544  getNoisyList2(h_tube_fornoise, no_betweens_middle, no_betweens_highmiddle_aggressive, 300.0, noisylist);
545 
546  // std::cout << "h_tube->GetNbinsX(): " << h_tube->GetNbinsX() << ", noisylist.size(): " << noisylist.size() <<
547  // std::endl;
548  std::vector<int> tmp_non_dead_non_noisy;
549  for (int i = 1; i <= h_tube->GetNbinsX(); i++) {
550  if (h_tube->At(i) > 0) {
551  bool dopush = true;
552  for (unsigned int j = 0; j < noisylist.size(); j++) {
553  if (i == noisylist.at(j)) {
554  dopush = false;
555  break;
556  }
557  }
558  if (dopush) tmp_non_dead_non_noisy.push_back((int) h_tube->At(i));
559  }
560  }
561  non_dead_non_noisy = std::move(tmp_non_dead_non_noisy);
562  }
563 
564  void CatalogNoisyEff(TH1F* h_tube_bkd, TH1F* h_tube_fornoise, TH1F* num, TH1F* den, int nTriggers,
565  TH1F* EffVSNoise_num, TH1F* EffVSNoise_den, TH1F* EffVSNoise_ADCCut_num,
566  TH1F* EffVSNoise_ADCCut_den, TH1F* EffVSBkd_num, TH1F* EffVSBkd_den) {
567  TH1F* h = (TH1F*) h_tube_bkd->Clone();
568 
569  h->Scale(1. / nTriggers / 300. * 1e9);
570  TH1F* h2 = (TH1F*) h_tube_fornoise->Clone();
571  h2->Scale(1. / nTriggers / 300. * 1e9);
572 
573  for (int i = 1; i != h->GetNbinsX() + 1; ++i) {
574  if (den->At(i) > 0) {
575  EffVSNoise_ADCCut_num->Fill(h->At(i) / 1000., num->At(i));
576  EffVSNoise_ADCCut_den->Fill(h->At(i) / 1000., den->At(i));
577  if (h2->At(i) < 2000) {
578  EffVSBkd_num->Fill(h->At(i) / 1000., num->At(i));
579  EffVSBkd_den->Fill(h->At(i) / 1000., den->At(i));
580  }
581  EffVSNoise_num->Fill(h2->At(i) / 1000., num->At(i));
582  EffVSNoise_den->Fill(h2->At(i) / 1000., den->At(i));
583  }
584  }
585 
586  delete h;
587  delete h2;
588  }
589 
590  std::vector<int> GetNoisyTubes(TH1F* h_tube_fornoise, int nTriggers, float frequency) { //Simply determine noisy tubes
591  // from freq.
592  TH1F* h = (TH1F*) h_tube_fornoise->Clone();
593 
594  h->Scale(1. / nTriggers / 300. * 1e9);
595  std::vector<int> noisyTubes;
596  for (int i = 1; i != h->GetNbinsX() + 1; ++i) if (h->At(i) > frequency) noisyTubes.push_back(i);
597  delete h;
598  return noisyTubes;
599  }
600 
601  std::vector<int> GetNoisyTubes(TH1F* h_tube_fornoise, TH1F* h_tube, TString chamber, int& validity) {
602  validity = 1;
603 
604  // std::cout << "In GetNoisyTubes" << std::endl;
605  if (chamber == "TEST") std::cout << chamber << std::endl;
606  std::vector<int> no_deads, no_betweens, no_betweens_middle, no_betweens_middle_aggressive,
607  no_betweens_highmiddle_aggressive, betweenlist, noisylist;
608 
609  getNonEmptyBins(h_tube_fornoise, no_deads);
610  // std::cout << " no_deads for " << chamber << ": " << no_deads.size() << std::endl;
611  getNoBetweens(h_tube_fornoise, no_deads, no_betweens, betweenlist, .05);
612  // std::cout << " no_betweens for " << chamber << ": " << no_betweens.size() << std::endl;
613  // std::cout << " betweenlist for " << chamber << ": " << betweenlist.size() << std::endl;
614  getNoBetweens_middle(no_betweens, no_betweens_middle);
615  // std::cout << "no_betweens_middle for " << chamber << ": " << no_betweens_middle.size() << std::endl;
616  getNoBetweens_middle_aggressive(no_betweens, no_betweens_middle_aggressive);
617  // std::cout << "no_betweens_middle_aggressive for " << chamber <<": " << no_betweens_middle_aggressive.size() <<
618  // std::endl;
619  getNoBetweens_highmiddle_aggressive(std::move(no_betweens), no_betweens_highmiddle_aggressive);
620  // std::cout << "no_betweens_highmiddle_aggressive for " << chamber <<": " <<
621  // no_betweens_highmiddle_aggressive.size() << std::endl;
622  getNoisyList2(h_tube_fornoise, no_betweens_middle, no_betweens_highmiddle_aggressive, 300.0, noisylist);
623 
624  // std::cout << "Before Validity Check for " << chamber <<": " << std::endl;
625  // displayList(noisylist);
626  if (validityCheckNoise(no_betweens_middle,
627  no_betweens_middle_aggressive /*, (int) h_tube_fornoise->GetMaximum()*/)) {
628  return noisylist;
629  } else {
630  validity = 2;
631  // std::cout << " ... validity check failed for noisy, trying with h_tube" << std::endl;
632  // return GetNoisyTubes_WithoutForNoise( h_tube_fornoise, h_tube, chamber);
633  return GetNoisyTubes_WithoutForNoise(h_tube, validity, std::move(chamber));
634  }
635  }
636 
637  std::vector<int> GetNoisyTubes_WithoutForNoise(TH1F* h_tube, int& validity, TString chamber) {
638  // std::cout << "In GetNoisyTubes_withoutfornoise" << std::endl;
639  if (chamber == "TEST") std::cout << chamber << std::endl;
640 
641  std::vector<int> no_deads, no_betweens, no_betweens_middle, no_betweens_middle_aggressive,
642  no_betweens_highmiddle_aggressive, betweenlist, noisylist;
643 
644  getNonEmptyBins(h_tube, no_deads);
645  // std::cout << "no_deads for " << chamber << ": " << no_deads.size() << std::endl;
646  getNoBetweens(h_tube, no_deads, no_betweens, betweenlist, .05);
647  // std::cout << "no_betweens for " << chamber << ": " << no_betweens.size() << std::endl;
648  getNoBetweens_middle(no_betweens, no_betweens_middle);
649  // std::cout << "no_betweens_middle for " << chamber << ": " << no_betweens_middle.size() << std::endl;
650  getNoBetweens_middle_aggressive(no_betweens, no_betweens_middle_aggressive);
651  // std::cout << "no_betweens_middle_aggressive for " << chamber <<": " << no_betweens_middle_aggressive.size() <<
652  // std::endl;
653  getNoBetweens_highmiddle_aggressive(std::move(no_betweens), no_betweens_highmiddle_aggressive);
654  // std::cout << "no_betweens_highmiddle_aggressive for " << chamber <<": " <<
655  // no_betweens_highmiddle_aggressive.size() << std::endl;
656  getNoisyList2(h_tube, no_betweens_middle, no_betweens_highmiddle_aggressive, 500.0, noisylist); // <--- use a
657  // higher
658  // tolerance
659 
660 // std::cout << "(Without fornoise) Before Validity Check for " << chamber <<": " << std::endl;
661 // displayList(noisylist);
662  if (validityCheckNoise(no_betweens_middle, no_betweens_middle_aggressive /*, (int) h_tube->GetMaximum()*/)) {
663  return noisylist;
664  } else {
665  validity = 0;
666 // std::cout << " ... validity check failed for noisy." << std::endl;
667  }
668 
669  return std::vector<int>();
670  }
671 
672  int GetNumNonMaskedTubes(TH1F* h_tube) {
673  std::vector<int> tubes;
674 
675  // index-based
676  getAllTubes(h_tube, tubes);
677  getNotMasked(tubes, h_tube);
678 
679  return tubes.size();
680  }
681 
682  std::vector<int> GetDeadTubes(TH1F* h_tube, int& validity, std::vector<int>& deadML_v, std::vector<int>& deadLayer_v,
683  std::vector<int>& deadMezz_v) {
684  validity = 1;
685  TString chamber = ((TString) h_tube->GetName())(0, 7);
686  int totalTubes = h_tube->GetNbinsX();
687 
688  std::vector<int> non_empty, non_empty_non_noisy, no_betweens, no_betweens_middle, no_betweens_lowmiddle,
689  no_betweens_middle_aggressive, no_betweens_lowmiddle_aggressive, deadlist, surelydeadlist,
690  betweenlist, inefflist,
691  surelyinefflist;
692  std::vector<int> all_tubes_DeadRegionsRemoved;
693 
694  // index-based
695  getAllTubes(h_tube, all_tubes_DeadRegionsRemoved);
696  getNotInDeadML(all_tubes_DeadRegionsRemoved, deadML_v, chamber, totalTubes);
697  getNotInDeadLayer(all_tubes_DeadRegionsRemoved, deadLayer_v, chamber, totalTubes);
698  getNotInDeadMezz(all_tubes_DeadRegionsRemoved, deadMezz_v, chamber, totalTubes);
699  getNotMasked(all_tubes_DeadRegionsRemoved, h_tube);
700 
701  // bin-content-based (for calculation of mean)
702  getBins(h_tube, all_tubes_DeadRegionsRemoved, no_betweens);
703  removeZeros(no_betweens);
704  getNoBetweens_middle(no_betweens, no_betweens_middle);
705  getNoBetweens_lowmiddle(no_betweens, no_betweens_lowmiddle);
706  getNoBetweens_middle_aggressive(no_betweens, no_betweens_middle_aggressive);
707  getNoBetweens_lowmiddle_aggressive(std::move(no_betweens), no_betweens_lowmiddle_aggressive);
708 
709  // give indicies to consider, the histo (for bin-content), a couple vectors for mean calculation, the definition of
710  // a dead tube (percent of mode), and the vector to fill
711  getIneffList2(all_tubes_DeadRegionsRemoved, h_tube, no_betweens_middle, no_betweens_lowmiddle_aggressive, 10.0,
712  deadlist);
713 
714  // make sure the histo has enough statistics, etc
715  if (validityCheckDead(no_betweens_middle, no_betweens_lowmiddle)) {
716  return deadlist;
717  } else {
718  validity = 0;
719 // std::cout << " ... validity check failed for dead tubes in " << std::endl;
720  }
721 
722  return std::vector<int>();
723  }
724 
725  std::vector<int> GetMaskedTubesForDead(TH1F* h_tube) {
726  // std::cout << "In GetMaskedTubesForDead" << std::endl;
727 
728  TString hardware_name = ((TString) h_tube->GetName())(0, 7);
729  int numLayers = GetNumLayersPerML(hardware_name);
730 
731  if (hardware_name(0, 4) == "BMS4" || hardware_name(0, 4) == "BMS6") {//layer 1-4 tubeId 41-48 cut out
732  if (numLayers <= 3) {
733  int cutouts[] = {
734  41, 42, 43, 44, 45, 46, 47, 48, 89, 90, 91, 92, 93, 94, 95, 96, 137, 138, 139, 140, 141, 142, 143, 144
735  };
736  return std::vector<int>(cutouts, cutouts + 24);
737  }
738  }
739  if (hardware_name(0, 3) == "BIR" && numLayers <= 4) {
740  if (hardware_name(5, 2) == "11" || hardware_name(5, 2) == "15") {
741  if (hardware_name(3, 1) == "1") { //layer 1-4 tube id 1-6 cut out
742  int cutouts[] = {
743  1, 2, 3, 4, 5, 6, 31, 32, 33, 34, 35, 36, 61, 62, 63, 64, 65, 66, 91, 92, 93, 94, 95, 96
744  };
745  return std::vector<int>(cutouts, cutouts + 24);
746  }
747  if (hardware_name(3, 1) == "2") { //layer 1-4 tube id 28-30 cut out
748  int cutouts[] = {
749  28, 29, 30, 58, 59, 60, 88, 89, 90, 118, 119, 120
750  };
751  return std::vector<int>(cutouts, cutouts + 12);
752  }
753  if (hardware_name(3, 1) == "4") { //layer 1-4 tube id 1-3 cut out
754  int cutouts[] = {
755  1, 2, 3, 31, 32, 33, 61, 62, 63, 91, 92, 93
756  };
757  return std::vector<int>(cutouts, cutouts + 12);
758  }
759  if (hardware_name(3, 1) == "5") {//layer 1-4 tube id 22-24 cut out
760  int cutouts[] = {
761  22, 23, 24, 46, 47, 48, 70, 71, 72, 94, 95, 96
762  };
763  return std::vector<int>(cutouts, cutouts + 12);
764  }
765  }
766  }
767  if (hardware_name(0, 3) == "BIR" && hardware_name(3, 1) == "3") { //cut out on both ML
768  int cutouts[] = {
769  34, 35, 36, 70, 71, 72, 106, 107, 108, 142, 143, 144, 178, 179, 180, 214, 215, 216, 250, 251, 252, 286, 287, 288
770  };
771  return std::vector<int>(cutouts, cutouts + 24);
772  }
773 
774  return std::vector<int>();
775  }
776 
777  std::vector<int> GetMaskedTubesForNoisy(TH1F* h_tube_fornoise) {
778  // std::cout << "In GetMaskedTubesForNoisy" << std::endl;
779 
780  std::vector<int> no_deads, no_betweens, no_betweens_middle, no_betweens_middle_aggressive, betweenlist;
781 
782  getNonEmptyBins(h_tube_fornoise, no_deads);
783  // std::cout << " no_deads for " << chamber << ": " << no_deads.size() << std::endl;
784  getNoBetweens(h_tube_fornoise, no_deads, no_betweens, betweenlist, .05);
785  // std::cout << " no_betweens for " << chamber << ": " << no_betweens.size() << std::endl;
786  // std::cout << " betweenlist for " << chamber << ": " << betweenlist.size() << ": "; displayList(betweenlist);
787  // std::cout << std::endl;
788 
789  // if( validityCheckNoise(no_betweens_middle, no_betweens_middle_aggressive, (int) h_tube_fornoise->GetMaximum() )
790  // ) {
791  return betweenlist;
792  // } else {
793  // return std::vector<int>();
794  // }
795  }
796 
797  double GetMeanFromHist(TH1F* h_tube) {
798  // std::cout << "In GetMeanForDead" << std::endl;
799 
800  std::vector<int> non_empty, no_betweens, no_betweens_middle, no_betweens_middle_aggressive, betweenlist;
801 
802  getNonEmptyBins(h_tube, non_empty);
803  getNoBetweens(h_tube, non_empty, no_betweens, betweenlist, .05);
804  getNoBetweens_middle(no_betweens, no_betweens_middle);
805  getNoBetweens_middle_aggressive(std::move(no_betweens), no_betweens_middle_aggressive);
806 
807  double mean = getMean(no_betweens_middle_aggressive);
808  return mean;
809  }
810 
811  double GetStandardDevFromHist(TH1F* h_tube, double mean) {
812  // std::cout << "In GetStandardDevFromHist" << std::endl;
813 
814  std::vector<int> non_empty, no_betweens, no_betweens_middle, betweenlist;
815 
816  getNonEmptyBins(h_tube, non_empty);
817  getNoBetweens(h_tube, non_empty, no_betweens, betweenlist, .05);
818  getNoBetweens_middle(std::move(no_betweens), no_betweens_middle);
819 
820  return getStandardDevFromMean(no_betweens_middle, mean);
821  }
822 
823  int GetNumLayersPerML(const TString& hardware_name) {
824  // Get Number of X
825  int derived_NumLayerPerML = 1;
826 
827  if (hardware_name(0, 4) == "BIS8" /*&& hardware_name(5,2) == "12"*/) {
828  derived_NumLayerPerML = 3;
829  } else if (/*hardware_name(0,4) == "BIS8" ||*/ hardware_name(0, 3) == "BEE") {
830  derived_NumLayerPerML = 4;
831  } else if (hardware_name(0, 2) == "BI" || hardware_name(0, 2) == "EI") {
832  derived_NumLayerPerML = 4;
833  } else {
834  derived_NumLayerPerML = 3;
835  }
836 
837  return derived_NumLayerPerML;
838  }
839 
840  int GetNumTubesPerMezz(const TString& hardware_name, int mezz) {
841  if (hardware_name(0, 3) == "BIR") {
842  if (hardware_name(3, 1) == "2" && mezz == 5) return 12;
843  else if (hardware_name(3, 1) == "3" && (mezz == 6 || mezz == 12)) return 12;
844  else if (hardware_name(3, 1) == "4" && mezz == 1) return 12;
845  else if (hardware_name(3, 1) == "5" && mezz == 4) return 12;
846  }
847  return 24;
848  }
849 
850  int GetNumTubesPerML(const TString& hardware_name, int ML, int TotalTubes) {
851  if (hardware_name(0, 3) == "BIR" || hardware_name(0, 4) == "BMS4" || hardware_name(0, 4) == "BMS6") {
852  if (hardware_name(0, 4) == "BIR3") return 132;
853 
854  if (ML == 1) {
855  if (hardware_name(0, 3) == "BMS") return 120;
856 
857  if (hardware_name(3, 1) == "1") return 120;
858 
859  if (hardware_name(3, 1) == "2") return 108;
860 
861  if (hardware_name(3, 1) == "4") return 108;
862 
863  if (hardware_name(3, 1) == "5") return 84;
864  }
865  return (int) TotalTubes / GetNumML(hardware_name);
866  }
867  return (int) TotalTubes / GetNumML(hardware_name);
868  }
869 
870  int GetNumTubesPerLayer(const TString& hardware_name, int layer, int TotalTubes) {
871  if (hardware_name(0, 3) == "BIR" || hardware_name(0, 4) == "BMS4" || hardware_name(0, 4) == "BMS6") {
872  if (hardware_name(0, 4) == "BIR3") return 33;
873 
874  if (layer <= 4) {
875  if (hardware_name(0, 3) == "BMS") return 40;
876 
877  if (hardware_name(3, 1) == "1") return 24;
878 
879  if (hardware_name(3, 1) == "2") return 27;
880 
881  if (hardware_name(3, 1) == "4") return 27;
882 
883  if (hardware_name(3, 1) == "5") return 21;
884  }
885  return (int) TotalTubes / GetNumML(hardware_name) / GetNumLayersPerML(hardware_name);
886  }
887  return (int) TotalTubes / GetNumML(hardware_name) / GetNumLayersPerML(hardware_name);
888  }
889 
890  int GetNumML(const TString& hardware_name) {
891  int derived_NumML = 1;
892 
893  if (hardware_name(0, 4) == "BIS8" /*&& hardware_name(5,2) == "12"*/) {
894  derived_NumML = 1;
895  } else if (/*hardware_name(0,4) == "BIS8" ||*/ hardware_name(0, 3) == "BEE") {
896  derived_NumML = 1;
897  } else if (hardware_name(0, 2) == "BI" || hardware_name(0, 2) == "EI") {
898  derived_NumML = 2;
899  } else {
900  derived_NumML = 2;
901  }
902 
903  return derived_NumML;
904  }
905 
906  int getLastTubeInLayer(int& firstTubeInLayer, const TString& hardware_name, int totalTubes) {
907  int tubeID = firstTubeInLayer;
908 
909  // int derived_tube = 1;
910  int derived_layer = 1;
911  // int derived_ML = 1;
912 
913  // Get Number of X
914  int derived_NumTubePerLayer = 1;
915  // int derived_NumTubePerML = 1;
916  int derived_NumLayer = 1;
917  int derived_NumLayerPerML = 1;
918  int derived_NumML = 1;
919 
920  if (hardware_name(0, 4) == "BIS8" /*&& hardware_name(5,2) == "12"*/) {
921  derived_NumLayerPerML = 3;
922  derived_NumML = 1;
923  } else if (/*hardware_name(0,4) == "BIS8" ||*/ hardware_name(0, 3) == "BEE") {
924  derived_NumLayerPerML = 4;
925  derived_NumML = 1;
926  } else if (hardware_name(0, 2) == "BI" || hardware_name(0, 2) == "EI") {
927  derived_NumLayerPerML = 4;
928  derived_NumML = 2;
929  } else {
930  derived_NumLayerPerML = 3;
931  derived_NumML = 2;
932  }
933 
934  derived_NumLayer = derived_NumLayerPerML * derived_NumML;
935  // derived_NumTubePerML = totalTubes / derived_NumML;
936  derived_NumTubePerLayer = totalTubes / derived_NumLayer;
937 
938  // Corrections for derived_NumTubePerLayer
939  if (hardware_name(0, 4) == "BMS4" || hardware_name(0, 4) == "BMS6") derived_NumTubePerLayer = 48;
940  if ((hardware_name(5, 2) == "11" || hardware_name(5, 2) == "15")) {
941  if (hardware_name(0, 4) == "BIR1") derived_NumTubePerLayer = 30;
942  if (hardware_name(0, 4) == "BIR2") derived_NumTubePerLayer = 30;
943  if (hardware_name(0, 4) == "BIR3") derived_NumTubePerLayer = 36;
944  if (hardware_name(0, 4) == "BIR4") derived_NumTubePerLayer = 30;
945  if (hardware_name(0, 4) == "BIR5") derived_NumTubePerLayer = 24;
946  }
947 // if( hardware_name(0,4)=="EIL4" && ( hardware_name(5,2)=="09" || hardware_name(5,2)=="01" ) ) // possible
948 // MdtIdHelper problem
949 // derived_NumTubePerLayer = 54;
950 
951  // Now get X
952  // derived_ML = (tubeID-1)/derived_NumTubePerML + 1;
953  derived_layer = (tubeID - 1) / derived_NumTubePerLayer + 1;
954  // derived_tube = tubeID - (derived_layer - 1) * derived_NumTubePerLayer;
955  // if(derived_ML==2) derived_layer -= derived_NumLayerPerML;
956 
957  // final info
958  int lastTubeInLayer = -1;
959  if (derived_layer <= derived_NumLayer) lastTubeInLayer = tubeID + derived_NumTubePerLayer - 1;
960 
961  return lastTubeInLayer;
962  }
963 
964  int Get_ML_of_Layer(int& layer, const TString& hardware_name) {
965  int derived_ML = 1;
966 
967  // Get Number of X
968  // int derived_NumLayer = 1;
969  int derived_NumLayerPerML = 1;
970 
971  // int derived_NumML = 1;
972  if (hardware_name(0, 4) == "BIS8" /*&& hardware_name(5,2) == "12"*/) {
973  derived_NumLayerPerML = 3;
974  // derived_NumML = 1;
975  } else if (/*hardware_name(0,4) == "BIS8" ||*/ hardware_name(0, 3) == "BEE") {
976  derived_NumLayerPerML = 4;
977  // derived_NumML = 1;
978  } else if (hardware_name(0, 2) == "BI" || hardware_name(0, 2) == "EI") {
979  derived_NumLayerPerML = 4;
980  // derived_NumML = 2;
981  } else {
982  derived_NumLayerPerML = 3;
983  // derived_NumML = 2;
984  }
985  // derived_NumLayer = derived_NumLayerPerML * derived_NumML;
986 
987  // Now get X
988  derived_ML = (layer - 1) / derived_NumLayerPerML + 1;
989 
990  return derived_ML;
991  }
992 
993  int getLastTubeInML(int& firstTubeInML, const TString& hardware_name, int totalTubes) {
994  int tubeID = firstTubeInML;
995 
996  // int derived_tube = 1;
997  // int derived_layer = 1;
998  int derived_ML = 1;
999 
1000  // Get Number of X
1001  // int derived_NumTubePerLayer = 1;
1002  int derived_NumTubePerML = 1;
1003  // int derived_NumLayer = 1;
1004  // int derived_NumLayerPerML = 1;
1005  int derived_NumML = 1;
1006 
1007  if (hardware_name(0, 4) == "BIS8" /*&& hardware_name(5,2) == "12"*/) {
1008  //derived_NumLayerPerML = 3;
1009  derived_NumML = 1;
1010  } else if (/*hardware_name(0,4) == "BIS8" ||*/ hardware_name(0, 3) == "BEE") {
1011  //derived_NumLayerPerML = 4;
1012  derived_NumML = 1;
1013  } else if (hardware_name(0, 2) == "BI" || hardware_name(0, 2) == "EI") {
1014  //derived_NumLayerPerML = 4;
1015  derived_NumML = 2;
1016  } else {
1017  //derived_NumLayerPerML = 3;
1018  derived_NumML = 2;
1019  }
1020 
1021  // derived_NumLayer = derived_NumLayerPerML * derived_NumML;
1022  derived_NumTubePerML = totalTubes / derived_NumML;
1023  //derived_NumTubePerLayer = totalTubes / derived_NumLayer;
1024 
1025 #if 0
1026  // Corrections for derived_NumTubePerLayer
1027  if (hardware_name(0, 4) == "BMS4" || hardware_name(0, 4) == "BMS6") derived_NumTubePerLayer = 48;
1028  if ((hardware_name(5, 2) == "11" || hardware_name(5, 2) == "15")) {
1029  if (hardware_name(0, 4) == "BIR1") derived_NumTubePerLayer = 30;
1030  if (hardware_name(0, 4) == "BIR2") derived_NumTubePerLayer = 30;
1031  if (hardware_name(0, 4) == "BIR3") derived_NumTubePerLayer = 36;
1032  if (hardware_name(0, 4) == "BIR4") derived_NumTubePerLayer = 30;
1033  if (hardware_name(0, 4) == "BIR5") derived_NumTubePerLayer = 24;
1034  }
1035 // if( hardware_name(0,4)=="EIL4" && ( hardware_name(5,2)=="09" || hardware_name(5,2)=="01" ) ) // possible
1036 // MdtIdHelper problem
1037 // derived_NumTubePerLayer = 54;
1038 #endif
1039 
1040  // Now get X
1041  derived_ML = (tubeID - 1) / derived_NumTubePerML + 1;
1042  // derived_layer = (tubeID-1)/derived_NumTubePerLayer + 1;
1043  // derived_tube = tubeID - (derived_layer - 1) * derived_NumTubePerLayer;
1044  // if(derived_ML==2) derived_layer -= derived_NumLayerPerML;
1045 
1046  // final info
1047  int lastTubeInML = -1;
1048  if (derived_ML <= derived_NumML) lastTubeInML = tubeID + derived_NumTubePerML - 1;
1049 
1050  return lastTubeInML;
1051  }
1052 
1053  int GetNumMezz(TH1F* h_tube) {
1054  int totalTubes = h_tube->GetNbinsX();
1055  TString hardware_name = ((TString) h_tube->GetName())(0, 7);
1056  int groupsPerLayer;
1057 
1058  std::vector<TubeRange> tubeRange = getMezzRanges(hardware_name, totalTubes, groupsPerLayer);
1059  return tubeRange.size();
1060  }
1061 
1062  std::vector<TubeRange> getMezzRanges(const TString& hardware_name, int totalTubes, int& groupsPerLayer) {
1063  // Get Number of X
1064  int derived_NumTubePerLayer = 1;
1065  // int derived_NumTubePerML = 1;
1066  int derived_NumLayer = 1;
1067  int derived_NumLayerPerML = 1;
1068  int derived_NumML = 1;
1069 
1070  if (hardware_name(0, 4) == "BIS8" /*&& hardware_name(5,2) == "12"*/) {
1071  derived_NumLayerPerML = 3;
1072  derived_NumML = 1;
1073  } else if (/*hardware_name(0,4) == "BIS8" ||*/ hardware_name(0, 3) == "BEE") {
1074  derived_NumLayerPerML = 4;
1075  derived_NumML = 1;
1076  } else if (hardware_name(0, 2) == "BI" || hardware_name(0, 2) == "EI") {
1077  derived_NumLayerPerML = 4;
1078  derived_NumML = 2;
1079  } else {
1080  derived_NumLayerPerML = 3;
1081  derived_NumML = 2;
1082  }
1083 
1084  derived_NumLayer = derived_NumLayerPerML * derived_NumML;
1085  // derived_NumTubePerML = totalTubes / derived_NumML;
1086  derived_NumTubePerLayer = totalTubes / derived_NumLayer;
1087 
1088  // below is for the tube range
1089  int groupSize = 6;
1090  if (derived_NumLayerPerML == 3) groupSize = 8;
1091 
1092  groupsPerLayer = derived_NumTubePerLayer / groupSize;
1093 
1094 // if( hardware_name == "EIL4A01" ) std::cout << "Chamber: " << hardware_name << ", #T: " << totalTubes << ", #L: "
1095 // << derived_NumLayer << ", #T/ML: " << derived_NumTubePerML << ", #T/L: " << derived_NumTubePerLayer << ", #G/L: " <<
1096 // groupsPerLayer << ", GrpSz: " << groupSize << std::endl;
1097 
1098  int firstTubeID = 1;
1099  int lastTubeID = firstTubeID + groupSize - 1;
1100  std::vector<TubeRange> ranges;
1101  while (lastTubeID <= totalTubes) {
1102  TubeRange r(firstTubeID, lastTubeID);
1103  ranges.push_back(r);
1104  firstTubeID = lastTubeID + 1;
1105  lastTubeID += groupSize;
1106  }
1107 
1108  return ranges;
1109  }
1110 
1111  int Get_ML_of_Mezz_degenerate(int& mezz, const TString& hardware_name, int totalTubes) {
1112  // Get Number of X
1113  int derived_NumTubePerLayer = 1;
1114  // int derived_NumTubePerML = 1;
1115  int derived_NumLayer = 1;
1116  int derived_NumLayerPerML = 1;
1117  int derived_NumML = 1;
1118 
1119  if (hardware_name(0, 4) == "BIS8" /*&& hardware_name(5,2) == "12"*/) {
1120  derived_NumLayerPerML = 3;
1121  derived_NumML = 1;
1122  } else if (/*hardware_name(0,4) == "BIS8" ||*/ hardware_name(0, 3) == "BEE") {
1123  derived_NumLayerPerML = 4;
1124  derived_NumML = 1;
1125  } else if (hardware_name(0, 2) == "BI" || hardware_name(0, 2) == "EI") {
1126  derived_NumLayerPerML = 4;
1127  derived_NumML = 2;
1128  } else {
1129  derived_NumLayerPerML = 3;
1130  derived_NumML = 2;
1131  }
1132 
1133  derived_NumLayer = derived_NumLayerPerML * derived_NumML;
1134  // derived_NumTubePerML = totalTubes / derived_NumML;
1135  derived_NumTubePerLayer = totalTubes / derived_NumLayer;
1136 
1137  // below is for the tube range
1138  int groupSize = 6;
1139  if (derived_NumLayerPerML == 3) groupSize = 8;
1140 
1141  int groupsPerLayer = derived_NumTubePerLayer / groupSize;
1142 
1143  if (mezz > groupsPerLayer) {
1144  mezz -= groupsPerLayer;
1145  return 2;
1146  }
1147 
1148  return 1;
1149  }
1150 
1151  // This version does not account for multilayers (on purpose, so it is single-valued)
1152  int Get_ML_of_Mezz(int& mezz, const TString& hardware_name, int totalTubes) {
1153  // Get Number of X
1154  int derived_NumTubePerLayer = 1;
1155  // int derived_NumTubePerML = 1;
1156  int derived_NumLayer = 1;
1157  int derived_NumLayerPerML = 1;
1158  int derived_NumML = 1;
1159 
1160  if (hardware_name(0, 4) == "BIS8" /*&& hardware_name(5,2) == "12"*/) {
1161  derived_NumLayerPerML = 3;
1162  derived_NumML = 1;
1163  } else if (/*hardware_name(0,4) == "BIS8" ||*/ hardware_name(0, 3) == "BEE") {
1164  derived_NumLayerPerML = 4;
1165  derived_NumML = 1;
1166  } else if (hardware_name(0, 2) == "BI" || hardware_name(0, 2) == "EI") {
1167  derived_NumLayerPerML = 4;
1168  derived_NumML = 2;
1169  } else {
1170  derived_NumLayerPerML = 3;
1171  derived_NumML = 2;
1172  }
1173 
1174  derived_NumLayer = derived_NumLayerPerML * derived_NumML;
1175  // derived_NumTubePerML = totalTubes / derived_NumML;
1176  derived_NumTubePerLayer = totalTubes / derived_NumLayer;
1177 
1178  // below is for the tube range
1179  int groupSize = 6;
1180  if (derived_NumLayerPerML == 3) groupSize = 8;
1181 
1182  int groupsPerLayer = derived_NumTubePerLayer / groupSize;
1183 
1184  if (mezz > groupsPerLayer) {
1185  return 2;
1186  }
1187 
1188  return 1;
1189  }
1190 
1191  // This function does not account for multilayers (on purpose, so it is single-valued)
1192  int Get_Mezz_of_Tube(int& tubeID, const TString& hardware_name /*, int totalTubes*/,
1193  std::vector<TubeRange>& tubeRanges, int groupsPerLayer) {
1194  unsigned int rangeIndexOfTube = 9999;
1195 
1196  for (unsigned int i = 0; i < tubeRanges.size(); i++) {
1197  if (tubeRanges.at(i).InRange(tubeID)) {
1198  rangeIndexOfTube = i;
1199  break;
1200  }
1201  }
1202  if (rangeIndexOfTube == 9999) {
1203  std::cout << "ERROR: tubeRange problem in Get_Mezz_of_Tube()!" << std::endl;
1204  return 0;
1205  }
1206 
1207  unsigned int mezz = rangeIndexOfTube % groupsPerLayer + 1;
1208  unsigned int numML = GetNumML(hardware_name);
1209  if (numML == 2 && rangeIndexOfTube >= tubeRanges.size() / 2) {
1210  mezz += groupsPerLayer;
1211  }
1212 
1213  return mezz;
1214  }
1215 
1216  // This function does not account for multilayers (on purpose, so it is single-valued)
1217  int Get_Layer_of_Tube(int& tubeID, const TString& hardware_name, int totalTubes) {
1218  int derived_layer = 1;
1219 
1220  // Get Number of X
1221  int derived_NumTubePerLayer = 1;
1222  int derived_NumLayer = 1;
1223  int derived_NumLayerPerML = 1;
1224  int derived_NumML = 1;
1225 
1226  if (hardware_name(0, 4) == "BIS8" /*&& hardware_name(5,2) == "12"*/) {
1227  derived_NumLayerPerML = 3;
1228  derived_NumML = 1;
1229  } else if (/*hardware_name(0,4) == "BIS8" ||*/ hardware_name(0, 3) == "BEE") {
1230  derived_NumLayerPerML = 4;
1231  derived_NumML = 1;
1232  } else if (hardware_name(0, 2) == "BI" || hardware_name(0, 2) == "EI") {
1233  derived_NumLayerPerML = 4;
1234  derived_NumML = 2;
1235  } else {
1236  derived_NumLayerPerML = 3;
1237  derived_NumML = 2;
1238  }
1239 
1240  derived_NumLayer = derived_NumLayerPerML * derived_NumML;
1241  derived_NumTubePerLayer = totalTubes / derived_NumLayer;
1242 
1243  // Corrections for derived_NumTubePerLayer
1244  if (hardware_name(0, 4) == "BMS4" || hardware_name(0, 4) == "BMS6") derived_NumTubePerLayer = 48;
1245  if ((hardware_name(5, 2) == "11" || hardware_name(5, 2) == "15")) {
1246  if (hardware_name(0, 4) == "BIR1") derived_NumTubePerLayer = 30;
1247  if (hardware_name(0, 4) == "BIR2") derived_NumTubePerLayer = 30;
1248  if (hardware_name(0, 4) == "BIR3") derived_NumTubePerLayer = 36;
1249  if (hardware_name(0, 4) == "BIR4") derived_NumTubePerLayer = 30;
1250  if (hardware_name(0, 4) == "BIR5") derived_NumTubePerLayer = 24;
1251  }
1252 // if( hardware_name(0,4)=="EIL4" && ( hardware_name(5,2)=="09" || hardware_name(5,2)=="01" ) ) // possible
1253 // MdtIdHelper problem
1254 // derived_NumTubePerLayer = 54;
1255 
1256  // Now get X
1257  derived_layer = (tubeID - 1) / derived_NumTubePerLayer + 1;
1258 
1259  return derived_layer;
1260  }
1261 
1262  int Get_ML_of_Tube(int& tubeID, const TString& hardware_name, int totalTubes) {
1263  int derived_ML = 1;
1264 
1265  // Get Number of X
1266  int derived_NumTubePerML = 1;
1267  int derived_NumML = 1;
1268 
1269  if (hardware_name(0, 4) == "BIS8" /*&& hardware_name(5,2) == "12"*/) {
1270  derived_NumML = 1;
1271  } else if (/*hardware_name(0,4) == "BIS8" ||*/ hardware_name(0, 3) == "BEE") {
1272  derived_NumML = 1;
1273  } else if (hardware_name(0, 2) == "BI" || hardware_name(0, 2) == "EI") {
1274  derived_NumML = 2;
1275  } else {
1276  derived_NumML = 2;
1277  }
1278 
1279  derived_NumTubePerML = totalTubes / derived_NumML;
1280 
1281  // Now get X
1282  derived_ML = (tubeID - 1) / derived_NumTubePerML + 1;
1283 
1284  return derived_ML;
1285  }
1286 
1287  std::vector<TubeRange> getLayerRanges(const TString& hardware_name, int totalTubes) {
1288  int firstTubeID = 1;
1289  int lastTubeID;
1290 
1291  std::vector<TubeRange> ranges;
1292  while ((lastTubeID = getLastTubeInLayer(firstTubeID, hardware_name, totalTubes)) != -1) {
1293  TubeRange r(firstTubeID, lastTubeID);
1294  ranges.push_back(r);
1295  firstTubeID = lastTubeID + 1;
1296  }
1297  return ranges;
1298  }
1299 
1300  std::vector<TubeRange> getMLRanges(const TString& hardware_name, int totalTubes) {
1301  int firstTubeID = 1;
1302  int lastTubeID;
1303 
1304  std::vector<TubeRange> ranges;
1305  while ((lastTubeID = getLastTubeInML(firstTubeID, hardware_name, totalTubes)) != -1) {
1306  TubeRange r(firstTubeID, lastTubeID);
1307  ranges.push_back(r);
1308  firstTubeID = lastTubeID + 1;
1309  }
1310  return ranges;
1311  }
1312 
1313  std::vector<int>
1314  /*void*/ FindDeadMezz(TH1F* h_tube, const TString& hardware_name, std::vector<int>& deadML_v) {
1315 // std::cout << "In FindDeadMezz for " << hardware_name << std::endl;
1316 
1317  int totalTubes = h_tube->GetNbinsX();
1318  int groupsPerLayer;
1319  int numML = GetNumML(hardware_name);
1320 
1321  std::vector<TubeRange> tubeRange = getMezzRanges(hardware_name, totalTubes, groupsPerLayer);
1322  int numMezz = groupsPerLayer * numML;
1323  std::vector<double> means;
1324  std::vector<int> valuesAll;
1325  getAllBins(h_tube, valuesAll);
1326  sort(valuesAll.begin(), valuesAll.end());
1327  int crustSize = (valuesAll.size()) / 3;
1328  int crustCutoff = 0;
1329  if (valuesAll.size() > 0) crustCutoff = valuesAll.at(valuesAll.size() - 1 - crustSize);
1330  for (unsigned int i = 0; i < tubeRange.size(); i++) {
1331  std::vector<int> valuesInRange_crusted;
1332  getAllUnmaskedBinsInRangeBelowCrustCutoff(h_tube, valuesInRange_crusted, crustCutoff, tubeRange.at(
1333  i).x1, tubeRange.at(i).x2);
1334 // std::cout << " values in range:"; for(int j=0; j<valuesInRange_crusted.size(); ++j) std::cout << " " <<
1335 // valuesInRange_crusted.at(j); std::cout << std::endl;
1336  if (valuesInRange_crusted.size() > 0) {
1337  means.push_back(getMean(valuesInRange_crusted));
1338  } else means.push_back(crustCutoff);
1339 // std::cout << " mean in range (" << tubeRange.at(i).x1 << "-" << tubeRange.at(i).x2 << "), #" << i << ": " <<
1340 // means.at(i) << ", (crustCutoff = " << crustCutoff << ")" << std::endl;
1341  }
1342 
1343  // order into mezzes
1344  std::vector<std::vector<double> > mezz_means(numMezz); //outer vector indexes vectors of groups that belong to the
1345  // mezz with that index
1346 // std::cout << " mezz_means: " << mezz_means.size() << std::endl;
1347  for (unsigned int k = 0; k < means.size(); k++) {
1348  if (numML == 2 && k >= means.size() / 2) {
1349 // std::cout << " k: " << k << ", (k % groupsPerLayer): " << (k % groupsPerLayer) << ", groupsPerLayer: " <<
1350 // groupsPerLayer << " (this is 2nd ML)" << std::endl;
1351  mezz_means.at((k % groupsPerLayer) + groupsPerLayer).push_back(means.at(k));
1352  } else {
1353 // std::cout << " k: " << k << ", (k % groupsPerLayer): " << (k % groupsPerLayer) << ", groupsPerLayer: " <<
1354 // groupsPerLayer << std::endl;
1355  mezz_means.at((k % groupsPerLayer)).push_back(means.at(k));
1356  }
1357  }
1358 
1359  double mean_of_means = getMean(means);
1360  std::vector<int> deviant_mezz;
1361  for (unsigned int i = 0; i < mezz_means.size(); ++i) {
1362  int mezz = i + 1;
1363  bool deviant = true;
1364  for (unsigned int j = 0; j < mezz_means.at(i).size(); j++) {
1365 // std::cout << " mezz_means.at(" << i << ").at(" << j << "): " << mezz_means.at(i).at(j) << ", mean_of_means: " <<
1366 // mean_of_means << std::endl;
1367  if (!(mezz_means.at(i).at(j) < 0.25 * mean_of_means)) deviant = false;
1368  }
1369  if (deviant && !AinB(Get_ML_of_Mezz(mezz, hardware_name, totalTubes), deadML_v)) deviant_mezz.push_back(mezz);
1370  }
1371 // if( deviant_mezz.size() > 0 ) {
1372 // std::cout << "Dead mezz: "; displayList(deviant_mezz);
1373 // }
1374 
1375  return deviant_mezz;
1376  }
1377 
1378  std::vector<int>
1379  /*void*/ FindDeadLayer(TH1F* h_tube, const TString& hardware_name, std::vector<int>& deadML_v) {
1380  // std::cout << "In FindDeadLayer" << std::endl;
1381 
1382  int totalTubes = h_tube->GetNbinsX();
1383 
1384  std::vector<TubeRange> tubeRange = getLayerRanges(hardware_name, totalTubes);
1385  std::vector<double> means;
1386  std::vector<int> valuesAll;
1387 
1388  getAllBins(h_tube, valuesAll);
1389  sort(valuesAll.begin(), valuesAll.end());
1390 
1391  int crustSize = (valuesAll.size()) / 3;
1392  int crustCutoff = 0;
1393  if (valuesAll.size() > 0) crustCutoff = valuesAll.at(valuesAll.size() - 1 - crustSize);
1394 
1395  for (unsigned i = 0; i < tubeRange.size(); i++) {
1396  std::vector<int> valuesInRange_crusted;
1397  getAllUnmaskedBinsInRangeBelowCrustCutoff(h_tube, valuesInRange_crusted, crustCutoff, tubeRange.at(
1398  i).x1, tubeRange.at(i).x2);
1399  if (valuesInRange_crusted.size() > 0) {
1400  means.push_back(getMean(valuesInRange_crusted));
1401  } else means.push_back(crustCutoff);
1402  // std::cout << " mean " << i << ": " << means.at(i) << std::endl;
1403  }
1404 
1405  double mean_of_means = getMean(means);
1406  std::vector<int> deviant_layers;
1407  for (unsigned i = 0; i < means.size(); ++i) {
1408  if (means.at(i) < 0.25 * mean_of_means) {
1409  int layer = i + 1;
1410  if (!AinB(Get_ML_of_Layer(layer, hardware_name), deadML_v)) deviant_layers.push_back(layer);
1411  }
1412  }
1413  if (deviant_layers.size() > 0) {
1414  // std::cout << "Dead layers: "; displayList(deviant_layers);
1415  }
1416 
1417  return deviant_layers;
1418  }
1419 
1420  bool AinB(int A, std::vector<int>& B) {
1421  for (unsigned int i = 0; i < B.size(); ++i) {
1422  if (B.at(i) == A) return true;
1423  }
1424  return false;
1425  }
1426 
1427  bool AinB(int A, const std::vector<int>* B) {
1428  for (unsigned int i = 0; i < B->size(); ++i) {
1429  if (B->at(i) == A) return true;
1430  }
1431  return false;
1432  }
1433 
1434  std::vector<int>
1435  /*void*/ FindDeadML(TH1F* h_tube, const TString& hardware_name) {
1436  // std::cout << "In FindDeadML" << std::endl;
1437 
1438  int totalTubes = h_tube->GetNbinsX();
1439 
1440  std::vector<TubeRange> tubeRange = getMLRanges(hardware_name, totalTubes);
1441  std::vector<double> means;
1442  std::vector<int> valuesAll;
1443  getAllBins(h_tube, valuesAll);
1444  sort(valuesAll.begin(), valuesAll.end());
1445  int crustSize = (valuesAll.size()) / 3;
1446  int crustCutoff = 0;
1447  if (valuesAll.size() > 0) crustCutoff = valuesAll.at(valuesAll.size() - 1 - crustSize);
1448  for (unsigned int i = 0; i < tubeRange.size(); i++) {
1449  std::vector<int> valuesInRange_crusted;
1450  getAllUnmaskedBinsInRangeBelowCrustCutoff(h_tube, valuesInRange_crusted, crustCutoff, tubeRange.at(
1451  i).x1, tubeRange.at(i).x2);
1452  if (valuesInRange_crusted.size() > 0) {
1453  means.push_back(getMean(valuesInRange_crusted));
1454  } else means.push_back(crustCutoff);
1455  // std::cout << " mean " << i << ": " << means.at(i) << std::endl;
1456  }
1457 
1458  double mean_of_means = getMean(means);
1459  std::vector<int> deviant_ML;
1460  for (unsigned i = 0; i < means.size(); ++i) {
1461  if (means.at(i) < 0.25 * mean_of_means) deviant_ML.push_back(i + 1);
1462  }
1463  if (deviant_ML.size() > 0) {
1464  }
1465 
1466 
1467  return deviant_ML;
1468  }
1469 
1470  void FillPDF(const std::string& inFilename, TH1F* hDead, TH1F* hNoise, TCanvas* c,
1471  const vector<int>* deadTubes, const vector<int>* deadASD, const vector<int>* deadMEZZ,
1472  const vector<int>* deadLayer, const vector<int>* deadML,
1473  const vector<int>* noisyTubes, const vector<int>* noisyASD, const vector<int>* noisyMEZZ,
1474  const vector<int>* noisyLayer, const vector<int>* noisyML,
1475  int deadTubesChamberValidity, int noisyTubesChamberValidity,
1476  bool draw_Mezz_L_ML_guidlines, bool draw_mean, bool draw_masked_tubes, bool separate_dead_noisy_histos,
1477  bool draw_validity_message, bool draw_histo_if_nothing_to_report) {
1478  if (!noisyML) return;
1479 
1480  if (!noisyLayer) return;
1481 
1482  if (!noisyMEZZ) return;
1483 
1484  if (!noisyASD) return;
1485 
1486  if (!deadASD) return;
1487 
1488  if (!draw_histo_if_nothing_to_report && deadTubes->size() == 0 && noisyTubes->size() == 0 && deadML->size() == 0 &&
1489  deadLayer->size() == 0 && deadMEZZ->size() == 0) return;
1490 
1491  if (!hDead) return;
1492 
1493  if (!hNoise) return;
1494 
1495  c->Clear();
1496  if (separate_dead_noisy_histos) c->Divide(2, 1);
1497  TString chamberName = ((TString) hDead->GetName())(0, 7);
1498  c->SetTitle(chamberName);
1499 
1500  vector<int> maskedTubesForDead = GetMaskedTubesForDead(hDead);
1501  TH1F* hOnlyDead = new TH1F(hDead->GetName(), hDead->GetTitle(), hDead->GetNbinsX(), 1, hDead->GetNbinsX());
1502  TH1F* hOnlyNoise = new TH1F(hNoise->GetName(), hNoise->GetTitle(), hNoise->GetNbinsX(), 1, hNoise->GetNbinsX());
1503 
1504  TString maskedStr = hDead->GetName();
1505  maskedStr += "_masked";
1506  TH1F* hOnlyMaskedDead = new TH1F(maskedStr, hDead->GetTitle(), hDead->GetNbinsX(), 1, hDead->GetNbinsX());
1507 
1508  // fill the layer range histo
1509  std::vector<TLine> rangeLines;
1510  std::vector<TLine> rangeLines_onlyMLLMezz;
1511  std::vector<TubeRange> tubeRange = getLayerRanges(chamberName, hDead->GetNbinsX());
1512  for (unsigned int i = 0; i < tubeRange.size(); i++) {
1513  TLine l(hDead->GetBinLowEdge(tubeRange.at(i).x1) + hDead->GetBinWidth(tubeRange.at(
1514  i).x1) / 2.0, LAYER_POS, hDead->GetBinLowEdge(tubeRange.at(
1515  i).x2) + hDead->GetBinWidth(tubeRange.at(
1516  i).x2) / 2.0,
1517  LAYER_POS);
1518  if (i % 2 == 0) l.SetLineColor(kViolet);
1519  else l.SetLineColor(kViolet + 6);
1520  int layer = i + 1;
1521  l.SetLineWidth(3);
1522  rangeLines_onlyMLLMezz.push_back(l);
1523  if (AinB(layer, deadLayer)) { // mark dead if in dead list
1524  l.SetLineColor(kRed);
1525  l.SetLineWidth(6);
1526  rangeLines.push_back(l);
1527  } else if (draw_Mezz_L_ML_guidlines) {
1528  rangeLines.push_back(l);
1529  }
1530  }
1531  // fill the ML range histo
1532  tubeRange = getMLRanges(chamberName, hDead->GetNbinsX());
1533  for (unsigned int i = 0; i < tubeRange.size(); i++) {
1534  TLine l(hDead->GetBinLowEdge(tubeRange.at(i).x1) + hDead->GetBinWidth(tubeRange.at(
1535  i).x1) / 2.0, ML_POS, hDead->GetBinLowEdge(tubeRange.at(
1536  i).x2) + hDead->GetBinWidth(tubeRange.at(
1537  i).x2) / 2.0,
1538  ML_POS);
1539  if (i % 2 == 0) l.SetLineColor(kViolet);
1540  else l.SetLineColor(kViolet + 6);
1541  int multilayer = i + 1;
1542  l.SetLineWidth(3);
1543  rangeLines_onlyMLLMezz.push_back(l);
1544  if (AinB(multilayer, deadML)) { // mark dead if in dead list
1545  l.SetLineColor(kRed);
1546  l.SetLineWidth(6);
1547  rangeLines.push_back(l);
1548  } else if (draw_Mezz_L_ML_guidlines) {
1549  l.SetLineWidth(3);
1550  rangeLines.push_back(l);
1551  }
1552  }
1553  // fill the mezz range histo
1554  int groupsPerLayer;
1555  tubeRange = getMezzRanges(chamberName, hDead->GetNbinsX(), groupsPerLayer);
1556  for (unsigned int i = 0; i < tubeRange.size(); i++) {
1557  TLine l(hDead->GetBinLowEdge(tubeRange.at(i).x1) + hDead->GetBinWidth(tubeRange.at(
1558  i).x1) / 2.0, MEZZ_POS, hDead->GetBinLowEdge(tubeRange.at(
1559  i).x2) + hDead->GetBinWidth(tubeRange.at(
1560  i).x2) / 2.0,
1561  MEZZ_POS);
1562  l.SetLineColor(kViolet + (i % groupsPerLayer));
1563  int mezz = i % groupsPerLayer + 1;
1564  int numML = GetNumML(chamberName);
1565  if (numML == 2 && i >= tubeRange.size() / 2) {
1566  mezz += groupsPerLayer;
1567  }
1568  l.SetLineWidth(3);
1569  rangeLines_onlyMLLMezz.push_back(l);
1570  if (AinB(mezz, deadMEZZ)) { // mark dead if in dead list
1571  l.SetLineColor(kRed);
1572  l.SetLineWidth(6);
1573  rangeLines.push_back(l);
1574  } else if (draw_Mezz_L_ML_guidlines) {
1575  l.SetLineWidth(3);
1576  rangeLines.push_back(l);
1577  }
1578  }
1579 
1580  // draw the mean/stddev
1581  std::vector<TLine> rangeLines_dead;
1582  double mean = GetMeanFromHist(hDead);
1583  double stddev = GetStandardDevFromHist(hDead, mean);
1584  double dev_low = mean - stddev;
1585  double dev_high = mean + stddev;
1586  if (dev_low < 1.) dev_low = STDDEV_POS;
1587  if (dev_high > 2. * hDead->GetMaximum()) dev_high = 2. * hDead->GetMaximum() - 1.;
1588  if (mean > 1.) {
1589  TLine l_mean(hDead->GetBinLowEdge(1), mean, hDead->GetBinLowEdge(hDead->GetNbinsX()), mean);
1590  l_mean.SetLineColor(kGreen + 3);
1591  l_mean.SetLineWidth(2);
1592  rangeLines_dead.push_back(l_mean);
1593  TLine l_dev_low(hDead->GetBinLowEdge(1), dev_low, hDead->GetBinLowEdge(hDead->GetNbinsX()), dev_low);
1594  l_dev_low.SetLineColor(kGreen);
1595  l_dev_low.SetLineWidth(2);
1596  rangeLines_dead.push_back(l_dev_low);
1597  TLine l_dev_high(hDead->GetBinLowEdge(1), dev_high, hDead->GetBinLowEdge(hDead->GetNbinsX()), dev_high);
1598  l_dev_high.SetLineColor(kGreen);
1599  l_dev_high.SetLineWidth(2);
1600  rangeLines_dead.push_back(l_dev_high);
1601  }
1602  std::vector<TLine> rangeLines_noise;
1603  mean = GetMeanFromHist(hNoise);
1604  stddev = GetStandardDevFromHist(hNoise, mean);
1605  dev_low = mean - stddev;
1606  dev_high = mean + stddev;
1607  if (dev_low < 1.) dev_low = STDDEV_POS;
1608  if (dev_high > 2. * hNoise->GetMaximum()) dev_high = 2. * hNoise->GetMaximum() - 1.;
1609  if (mean > 1.) {
1610  TLine l_mean(hNoise->GetBinLowEdge(1), mean, hNoise->GetBinLowEdge(hNoise->GetNbinsX()), mean);
1611  l_mean.SetLineColor(kGreen + 3);
1612  l_mean.SetLineWidth(2);
1613  rangeLines_noise.push_back(l_mean);
1614  TLine l_dev_low(hNoise->GetBinLowEdge(1), dev_low, hNoise->GetBinLowEdge(hNoise->GetNbinsX()), dev_low);
1615  l_dev_low.SetLineColor(kGreen);
1616  l_dev_low.SetLineWidth(2);
1617  rangeLines_noise.push_back(l_dev_low);
1618  TLine l_dev_high(hNoise->GetBinLowEdge(1), dev_high, hNoise->GetBinLowEdge(hNoise->GetNbinsX()), dev_high);
1619  l_dev_high.SetLineColor(kGreen);
1620  l_dev_high.SetLineWidth(2);
1621  rangeLines_noise.push_back(l_dev_high);
1622  }
1623 
1624  // noisy tubes
1625  for (unsigned i = 0; i != noisyTubes->size(); ++i) {
1626  int TubeId = noisyTubes->at(i);
1627  if (hNoise->At(TubeId) < 1.) {
1628  hOnlyNoise->SetBinContent(TubeId, MARKER_POS_RED);
1629  hOnlyNoise->SetBinError(TubeId, 0.001);
1630  } else {
1631  if (separate_dead_noisy_histos) hOnlyNoise->SetBinContent(TubeId, hNoise->GetBinContent(TubeId));
1632  else hOnlyNoise->SetBinContent(TubeId, hDead->GetBinContent(TubeId));
1633  hOnlyNoise->SetBinError(TubeId, 0.001);
1634  }
1635  }
1636  // dead tubes
1637  for (unsigned i = 0; i != deadTubes->size(); ++i) {
1638  int TubeId = deadTubes->at(i);
1639  if (hDead->At(TubeId) < 1.) {
1640  hOnlyDead->SetBinContent(TubeId, MARKER_POS_RED);
1641  hOnlyDead->SetBinError(TubeId, 0.001);
1642  } else {
1643  hOnlyDead->SetBinContent(TubeId, hDead->GetBinContent(TubeId));
1644  hOnlyDead->SetBinError(TubeId, 0.001);
1645  }
1646  }
1647  // masked (cutouts)
1648  for (unsigned i = 0; i != maskedTubesForDead.size(); ++i) {
1649  int TubeId = maskedTubesForDead.at(i);
1650  if (hDead->At(TubeId) < 1.) {
1651  hOnlyMaskedDead->SetBinContent(TubeId, MARKER_POS_BLUE);
1652  hOnlyMaskedDead->SetBinError(TubeId, 0.001);
1653  } else {
1654  hOnlyMaskedDead->SetBinContent(TubeId, hDead->GetBinContent(TubeId));
1655  hOnlyMaskedDead->SetBinError(TubeId, 0.001);
1656  }
1657  }
1658 
1659 // for(unsigned i = 0; i!=maskedTubesForNoisy.size(); ++i){
1660 // int TubeId = maskedTubesForNoisy.at(i);
1661 // if( hNoise->At(TubeId) < 1. ) {
1662 // hOnlyMaskedNoisy->SetBinContent(TubeId, MARKER_POS_BLUE);
1663 // hOnlyMaskedNoisy->SetBinError(TubeId, 0.01);
1664 // }
1665 // else {
1666 // hOnlyMaskedNoisy->SetBinContent(TubeId, hNoise->GetBinContent(TubeId));
1667 // hOnlyMaskedNoisy->SetBinError(TubeId, 0.01);
1668 // }
1669 // }
1670 
1671  double maxy_dead = hDead->GetMaximum() + 1.1;
1672  hDead->SetAxisRange(0.1, 2 * maxy_dead, "y");
1673  hOnlyDead->SetMarkerColor(kRed);
1674  hOnlyDead->SetMarkerStyle(22);
1675  hOnlyDead->SetMarkerSize(1);
1676  hOnlyDead->SetAxisRange(0.1, 2 * maxy_dead, "y");
1677  hOnlyMaskedDead->SetMarkerColor(kBlue);
1678  hOnlyMaskedDead->SetMarkerStyle(21);
1679  hOnlyMaskedDead->SetMarkerSize(.5);
1680  hOnlyMaskedDead->SetAxisRange(0.1, 2 * maxy_dead, "y");
1681 
1682  double maxy_noise = hNoise->GetMaximum() + 1.1;
1683  hNoise->SetAxisRange(0.1, 2 * maxy_noise, "y");
1684  hOnlyNoise->SetMarkerColor(kRed);
1685  hOnlyNoise->SetMarkerStyle(22);
1686  hOnlyNoise->SetMarkerSize(1);
1687  hOnlyNoise->SetAxisRange(0.1, 2 * maxy_noise, "y");
1688 // hOnlyMaskedNoisy->SetMarkerColor(kBlue); hOnlyMaskedNoisy->SetMarkerStyle(21);
1689 // hOnlyMaskedNoisy->SetMarkerSize(.5); hOnlyMaskedNoisy->SetAxisRange(0.1,2*maxy_noise,"y");
1690 
1691  TText validityFailAll(1, 1, "FAILED VALIDITY CHECKS");
1692  TText validityFailDead(1, 1, "FAILED VALIDITY CHECKS FOR DEAD TUBES");
1693  TText validityFailNoise(2, 2, "FAILED VALIDITY CHECKS FOR NOISY TUBES");
1694  TText validityFailNoiseRetry(1, 1, "VALIDITY: USING ALL HITS HISTO");
1695 
1696  c->cd(1);
1697  gPad->SetLogy();
1698  hDead->Draw();
1699  if (draw_masked_tubes) hOnlyMaskedDead->Draw("same");
1700  hOnlyDead->Draw("same");
1701  for (unsigned int i = 0; i < rangeLines.size(); i++) rangeLines.at(i).Draw("same");
1702  if (draw_mean) {
1703  for (unsigned int i = 0; i < rangeLines_dead.size(); i++) rangeLines_dead.at(i).Draw("same");
1704  }
1705  if (deadTubesChamberValidity != 1 && draw_validity_message) validityFailDead.Draw("same");
1706  if (separate_dead_noisy_histos) {
1707  c->cd(2);
1708  gPad->SetLogy();
1709  hNoise->Draw();
1710  hOnlyNoise->Draw("same");
1711 // if( draw_masked_tubes ) hOnlyMaskedNoisy->Draw("same");
1712  for (unsigned int i = 0; i < rangeLines.size(); i++) rangeLines_onlyMLLMezz.at(i).Draw("same");
1713  if (draw_mean) {
1714  for (unsigned int i = 0; i < rangeLines_dead.size(); i++) rangeLines_noise.at(i).Draw("same");
1715  }
1716  if (draw_validity_message) {
1717  if (noisyTubesChamberValidity == 2) validityFailNoiseRetry.Draw("same");
1718  else if (noisyTubesChamberValidity != 1) validityFailAll.Draw("same");
1719  }
1720  } else {
1721  if (noisyTubesChamberValidity != 1 && draw_validity_message) validityFailNoise.Draw("same");
1722  hOnlyNoise->Draw("same");
1723  }
1724 
1725  std::ostringstream Out;
1726 
1727  TString ecapStr = "MDTBADead";
1728  if (chamberName(0, 1) == "B" && chamberName(4, 1) == "C") ecapStr = "MDTBCDead";
1729  else if (chamberName(0, 1) == "E" && chamberName(4, 1) == "A") ecapStr = "MDTEADead";
1730  else if (chamberName(0, 1) == "E" && chamberName(4, 1) == "C") ecapStr = "MDTECDead";
1731 
1732  Out << inFilename << "." << ecapStr << ".pdf";
1733 
1734  c->Print(Out.str().c_str(), "pdf");
1735  delete hOnlyNoise;
1736  delete hOnlyDead;
1737  delete hOnlyMaskedDead;
1738  }
1739 }
dqutils_mdtdeadnoisy::find
bool find(std::vector< int > &v, unsigned int x)
Definition: MdtDeadNoisyUtils.cxx:67
beamspotman.r
def r
Definition: beamspotman.py:676
dqutils_mdtdeadnoisy::getNotInDeadMezz
void getNotInDeadMezz(std::vector< int > &v, std::vector< int > &deadMezz_v, const TString &hardware_name, int totalTubes)
Definition: MdtDeadNoisyUtils.cxx:194
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
trigbs_pickEvents.ranges
ranges
Definition: trigbs_pickEvents.py:60
LAYER_POS
#define LAYER_POS
Definition: MdtDeadNoisyUtils.cxx:23
dqutils_mdtdeadnoisy::Get_ML_of_Mezz_degenerate
int Get_ML_of_Mezz_degenerate(int &mezz, const TString &hardware_name, int totalTubes)
Definition: MdtDeadNoisyUtils.cxx:1111
dqutils_mdtdeadnoisy::GetNumNonMaskedTubes
int GetNumNonMaskedTubes(TH1F *h_tube)
Definition: MdtDeadNoisyUtils.cxx:672
dqutils_mdtdeadnoisy::getNoisyList2
void getNoisyList2(TH1F *h, std::vector< int > &no_betweens_middle, std::vector< int > &no_betweens_middle_aggressive, double num_pct, std::vector< int > &noisylist)
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
fitman.sz
sz
Definition: fitman.py:527
dqutils_mdtdeadnoisy::getBins
void getBins(TH1F *h, std::vector< int > &indices, std::vector< int > &content)
Definition: MdtDeadNoisyUtils.cxx:144
dqutils_mdtdeadnoisy::GetNumTubesPerML
int GetNumTubesPerML(const TString &hardware_name, int layer, int TotalTubes)
Definition: MdtDeadNoisyUtils.cxx:850
dqutils_mdtdeadnoisy::getAllTubes
void getAllTubes(TH1F *h, std::vector< int > &v)
Definition: MdtDeadNoisyUtils.cxx:166
dqutils_mdtdeadnoisy::removeNonContiguous
void removeNonContiguous(std::vector< int > &betweenlist, unsigned int sz)
Definition: MdtDeadNoisyUtils.cxx:299
dqutils_mdtdeadnoisy::getLastTubeInLayer
int getLastTubeInLayer(int &firstTubeInLayer, const TString &hardware_name, int totalTubes)
Definition: MdtDeadNoisyUtils.cxx:906
calibdata.chamber
chamber
Definition: calibdata.py:32
index
Definition: index.py:1
Trk::indices
std::pair< long int, long int > indices
Definition: AlSymMatBase.h:24
dqutils_mdtdeadnoisy::GetNoisyTubes
std::vector< int > GetNoisyTubes(TH1F *h_tube_fornoise, int nTriggers, float frequency)
Definition: MdtDeadNoisyUtils.cxx:590
plotBeamSpotCompare.x2
x2
Definition: plotBeamSpotCompare.py:218
dqutils_mdtdeadnoisy::getStandardDevFromMean_pos
double getStandardDevFromMean_pos(std::vector< int > &v, double mean)
Definition: MdtDeadNoisyUtils.cxx:395
dqutils_mdtdeadnoisy::getNonEmptyNonNoisyTubes
void getNonEmptyNonNoisyTubes(TH1F *h_tube_fornoise, TH1F *h_tube, std::vector< int > &non_dead_non_noisy)
Definition: MdtDeadNoisyUtils.cxx:534
MEZZ_POS
#define MEZZ_POS
Definition: MdtDeadNoisyUtils.cxx:22
dqutils_mdtdeadnoisy::GetNumTubesPerMezz
int GetNumTubesPerMezz(const TString &hardware_name, int mezz)
Definition: MdtDeadNoisyUtils.cxx:840
dqutils_mdtdeadnoisy::getNoBetweens_lowmiddle_aggressive
void getNoBetweens_lowmiddle_aggressive(std::vector< int > no_betweens, std::vector< int > &no_betweens_lowmiddle_aggressive)
Definition: MdtDeadNoisyUtils.cxx:353
mc.diff
diff
Definition: mc.SFGenPy8_MuMu_DD.py:14
dqutils_mdtdeadnoisy::GetNumLayersPerML
int GetNumLayersPerML(const TString &hardware_name)
Definition: MdtDeadNoisyUtils.cxx:823
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
dqutils_mdtdeadnoisy::getNoBetweens
void getNoBetweens(TH1F *h, std::vector< int > &no_dead, std::vector< int > &no_betweens, std::vector< int > &betweenlist, float minBinContent)
Definition: MdtDeadNoisyUtils.cxx:266
dqutils_mdtdeadnoisy::getLayerRanges
std::vector< TubeRange > getLayerRanges(const TString &hardware_name, int totalTubes)
Definition: MdtDeadNoisyUtils.cxx:1287
dqutils_mdtdeadnoisy::GetDeadTubes
std::vector< int > GetDeadTubes(TH1F *h_tube, int &validity, std::vector< int > &deadML_v, std::vector< int > &deadLayer_v, std::vector< int > &deadMezz_v)
Definition: MdtDeadNoisyUtils.cxx:682
dqutils_mdtdeadnoisy::Get_ML_of_Layer
int Get_ML_of_Layer(int &layer, const TString &hardware_name)
Definition: MdtDeadNoisyUtils.cxx:964
x
#define x
dqutils_mdtdeadnoisy::getMezzRanges
std::vector< TubeRange > getMezzRanges(const TString &hardware_name, int totalTubes, int &groupsPerLayer)
Definition: MdtDeadNoisyUtils.cxx:1062
dqutils_mdtdeadnoisy::GetNumTubesPerLayer
int GetNumTubesPerLayer(const TString &hardware_name, int ML, int TotalTubes)
Definition: MdtDeadNoisyUtils.cxx:870
dqutils_mdtdeadnoisy::removeZeros
void removeZeros(std::vector< int > &v)
Definition: MdtDeadNoisyUtils.cxx:151
outputfile
ofstream outputfile
Definition: CellClusterLinkTool.h:25
grepfile.content
string content
Definition: grepfile.py:56
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
dqutils_mdtdeadnoisy::getAllBins
void getAllBins(TH1F *h, std::vector< int > &v)
Definition: MdtDeadNoisyUtils.cxx:93
dqutils_mdtdeadnoisy::FindDeadMezz
std::vector< int > FindDeadMezz(TH1F *h_tube, const TString &hardware_name, std::vector< int > &deadML_v)
Definition: MdtDeadNoisyUtils.cxx:1314
A
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
lumiFormat.i
int i
Definition: lumiFormat.py:85
dqutils_mdtdeadnoisy::CatalogNoisyEff
void CatalogNoisyEff(TH1F *h_tube_bkd, TH1F *h_tube_fornoise, TH1F *num, TH1F *den, int nTriggers, TH1F *EffVSNoise_num, TH1F *EffVSNoise_den, TH1F *EffVSNoise_ADCCut_num, TH1F *EffVSNoise_ADCCut_den, TH1F *EffVSBkd_num, TH1F *EffVSBkd_den)
Definition: MdtDeadNoisyUtils.cxx:564
vector< int >
extractSporadic.h
list h
Definition: extractSporadic.py:97
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
dqutils_mdtdeadnoisy::getStandardDevFromMean
double getStandardDevFromMean(std::vector< int > &v, double mean)
Definition: MdtDeadNoisyUtils.cxx:371
dqutils_mdtdeadnoisy::getAllBinsInRangeBelowCrustCutoff
void getAllBinsInRangeBelowCrustCutoff(TH1F *h, std::vector< int > &v, int crustCutoff, int x1, int x2)
Definition: MdtDeadNoisyUtils.cxx:112
dqutils_mdtdeadnoisy::getNotBetweenList
void getNotBetweenList(std::vector< int > &v, std::vector< int > &surely_v, std::vector< int > &betweenlist)
Definition: MdtDeadNoisyUtils.cxx:84
dqutils_mdtdeadnoisy::getNotMasked
void getNotMasked(std::vector< int > &v, TH1F *h)
Definition: MdtDeadNoisyUtils.cxx:180
BindingsTest.cut
cut
This script demonstrates how to call a C++ class from Python Also how to use PyROOT is shown.
Definition: BindingsTest.py:13
dqutils_mdtdeadnoisy::getNonEmptyBins
void getNonEmptyBins(TH1F *h, std::vector< int > &v)
Definition: MdtDeadNoisyUtils.cxx:159
STDDEV_POS
#define STDDEV_POS
Definition: MdtDeadNoisyUtils.cxx:20
dqutils_mdtdeadnoisy::getSurelyDeadList
void getSurelyDeadList(TH1F *h, std::vector< int > &v, std::vector< int > &betweenlist)
Definition: MdtDeadNoisyUtils.cxx:74
dqutils_mdtdeadnoisy::getNotInDeadLayer
void getNotInDeadLayer(std::vector< int > &v, std::vector< int > &deadLayer_v, const TString &hardware_name, int totalTubes)
Definition: MdtDeadNoisyUtils.cxx:215
dqutils_mdtdeadnoisy::getNoBetweens_middle_aggressive
void getNoBetweens_middle_aggressive(std::vector< int > no_betweens, std::vector< int > &no_betweens_middle_aggressive)
Definition: MdtDeadNoisyUtils.cxx:336
dqutils_mdtdeadnoisy::getMean_WithCut
double getMean_WithCut(std::vector< int > &v, double cut)
Definition: MdtDeadNoisyUtils.cxx:253
dqutils_mdtdeadnoisy::getMLRanges
std::vector< TubeRange > getMLRanges(const TString &hardware_name, int totalTubes)
Definition: MdtDeadNoisyUtils.cxx:1300
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
dqutils_mdtdeadnoisy::getNonEmptyTubes
void getNonEmptyTubes(TH1F *h, std::vector< int > &v)
Definition: MdtDeadNoisyUtils.cxx:173
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
dqutils_mdtdeadnoisy::Get_Mezz_of_Tube
int Get_Mezz_of_Tube(int &tubeID, const TString &hardware_name, std::vector< TubeRange > &tubeRanges, int groupsPerLayer)
Definition: MdtDeadNoisyUtils.cxx:1192
dqutils_mdtdeadnoisy::TubeRange
Definition: MdtDeadNoisyUtils.h:20
dqutils_mdtdeadnoisy::GetStandardDevFromHist
double GetStandardDevFromHist(TH1F *h_tube, double mean)
Definition: MdtDeadNoisyUtils.cxx:811
dqutils_mdtdeadnoisy::getNoBetweens_highmiddle_aggressive
void getNoBetweens_highmiddle_aggressive(std::vector< int > no_betweens, std::vector< int > &no_betweens_lowmiddle_aggressive)
Definition: MdtDeadNoisyUtils.cxx:362
trigbs_pickEvents.num
num
Definition: trigbs_pickEvents.py:76
dqutils_mdtdeadnoisy::Get_Layer_of_Tube
int Get_Layer_of_Tube(int &tubeID, const TString &hardware_name, int totalTubes)
Definition: MdtDeadNoisyUtils.cxx:1217
MARKER_POS_RED
#define MARKER_POS_RED
Definition: MdtDeadNoisyUtils.cxx:21
dqutils_mdtdeadnoisy::getStandardDevFromMean_neg
double getStandardDevFromMean_neg(std::vector< int > &v, double mean)
Definition: MdtDeadNoisyUtils.cxx:383
dqutils_mdtdeadnoisy::getNoisyList
void getNoisyList(TH1F *h, std::vector< int > &no_betweens_middle, std::vector< int > &no_betweens_middle_aggressive, double num_std_dev, std::vector< int > &noisylist)
Definition: MdtDeadNoisyUtils.cxx:407
dqutils_mdtdeadnoisy::AinB
bool AinB(int A, std::vector< int > &B)
Definition: MdtDeadNoisyUtils.cxx:1420
dqutils_mdtdeadnoisy::getLastTubeInML
int getLastTubeInML(int &firstTubeInML, const TString &hardware_name, int totalTubes)
Definition: MdtDeadNoisyUtils.cxx:993
dqutils_mdtdeadnoisy::GetNumML
int GetNumML(const TString &hardware_name)
Definition: MdtDeadNoisyUtils.cxx:890
dqutils_mdtdeadnoisy::Get_ML_of_Mezz
int Get_ML_of_Mezz(int &mezz, const TString &hardware_name, int totalTubes)
Definition: MdtDeadNoisyUtils.cxx:1152
dqutils_mdtdeadnoisy::FindDeadLayer
std::vector< int > FindDeadLayer(TH1F *h_tube, const TString &hardware_name, std::vector< int > &deadML_v)
Definition: MdtDeadNoisyUtils.cxx:1379
MdtDeadNoisyUtils.h
HI::TowerBins::numLayers
constexpr unsigned int numLayers()
Definition: HIEventDefs.h:23
dqutils_mdtdeadnoisy::getNotInDeadML
void getNotInDeadML(std::vector< int > &v, std::vector< int > &deadML_v, const TString &hardware_name, int totalTubes)
Definition: MdtDeadNoisyUtils.cxx:228
dqutils_mdtdeadnoisy::getNoBetweens_middle_semiaggressive
void getNoBetweens_middle_semiaggressive(std::vector< int > no_betweens, std::vector< int > &no_betweens_middle_aggressive)
Definition: MdtDeadNoisyUtils.cxx:344
dqutils_mdtdeadnoisy::getAllUnmaskedBinsInRangeBelowCrustCutoff
void getAllUnmaskedBinsInRangeBelowCrustCutoff(TH1F *h, std::vector< int > &v, int crustCutoff, int x1, int x2)
Definition: MdtDeadNoisyUtils.cxx:127
dqutils_mdtdeadnoisy::validityCheckNoise
bool validityCheckNoise(std::vector< int > &no_betweens_middle, std::vector< int > &no_betweens_middle_aggressive)
Definition: MdtDeadNoisyUtils.cxx:510
python.PyAthena.v
v
Definition: PyAthena.py:154
dqutils_mdtdeadnoisy::getIneffList2
void getIneffList2(TH1F *h, std::vector< int > &no_betweens_middle, std::vector< int > &no_betweens_lowmiddle_aggressive, double num_pct, std::vector< int > &inefflist)
dqutils_mdtdeadnoisy::FindDeadML
std::vector< int > FindDeadML(TH1F *h_tube, const TString &hardware_name)
Definition: MdtDeadNoisyUtils.cxx:1435
dqutils_mdtdeadnoisy::validityCheckDead
bool validityCheckDead(std::vector< int > &no_betweens_middle, std::vector< int > &no_betweens_middle_aggressive)
Definition: MdtDeadNoisyUtils.cxx:481
dqutils_mdtdeadnoisy::GetMeanFromHist
double GetMeanFromHist(TH1F *h_tube)
Definition: MdtDeadNoisyUtils.cxx:797
h
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
dqutils_mdtdeadnoisy::displayList
void displayList(std::vector< int > &v)
Definition: MdtDeadNoisyUtils.cxx:32
dqutils_mdtdeadnoisy::getMean
double getMean(std::vector< T > &v)
Definition: MdtDeadNoisyUtils.cxx:244
MARKER_POS_BLUE
#define MARKER_POS_BLUE
Definition: MdtDeadNoisyUtils.cxx:25
dqutils_mdtdeadnoisy::getDeadList
void getDeadList(TH1F *h, std::vector< int > &v)
Definition: MdtDeadNoisyUtils.cxx:60
ML_POS
#define ML_POS
Definition: MdtDeadNoisyUtils.cxx:24
dqutils_mdtdeadnoisy::GetMaskedTubesForDead
std::vector< int > GetMaskedTubesForDead(TH1F *h_tube)
Definition: MdtDeadNoisyUtils.cxx:725
dqutils_mdtdeadnoisy::GetMaskedTubesForNoisy
std::vector< int > GetMaskedTubesForNoisy(TH1F *h_tube_fornoise)
Definition: MdtDeadNoisyUtils.cxx:777
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
dqutils_mdtdeadnoisy::sqr
double sqr(double x)
Definition: MdtDeadNoisyUtils.cxx:28
dqutils_mdtdeadnoisy::getNoBetweens_lowmiddle
void getNoBetweens_lowmiddle(std::vector< int > no_betweens, std::vector< int > &no_betweens_lowmiddle)
Definition: MdtDeadNoisyUtils.cxx:328
dqutils_mdtdeadnoisy
Definition: MdtDeadNoisyUtils.h:19
dqutils_mdtdeadnoisy::getNoBetweens_middle
void getNoBetweens_middle(std::vector< int > no_betweens, std::vector< int > &no_betweens_middle)
Definition: MdtDeadNoisyUtils.cxx:320
dqutils_mdtdeadnoisy::getIneffList
void getIneffList(TH1F *h, std::vector< int > &no_betweens_middle, std::vector< int > &no_betweens_lowmiddle_aggressive, double num_std_dev, std::vector< int > &inefflist)
Definition: MdtDeadNoisyUtils.cxx:430
dqutils_mdtdeadnoisy::getAllBinsInRange
void getAllBinsInRange(TH1F *h, std::vector< int > &v, int x1, int x2)
Definition: MdtDeadNoisyUtils.cxx:99
test_pyathena.counter
counter
Definition: test_pyathena.py:15
dqutils_mdtdeadnoisy::GetNumMezz
int GetNumMezz(TH1F *h_tube)
Definition: MdtDeadNoisyUtils.cxx:1053
dqutils_mdtdeadnoisy::FillPDF
void FillPDF(const std::string &inFilename, TH1F *hDead, TH1F *hNoise, TCanvas *c, const std::vector< int > *deadTubes, const std::vector< int > *deadASD, const std::vector< int > *deadMEZZ, const std::vector< int > *deadLayer, const std::vector< int > *deadML, const std::vector< int > *noisyTubes, const std::vector< int > *noisyASD, const std::vector< int > *noisyMEZZ, const std::vector< int > *noisyLayer, const std::vector< int > *noisyML, int deadTubesChamberValidity, int noisyTubesChamberValidity, bool draw_Mezz_L_ML_guidlines, bool draw_mean, bool draw_masked_tubes, bool separate_dead_noisy_histos, bool draw_validity_message, bool draw_histo_if_nothing_to_report)
Definition: MdtDeadNoisyUtils.cxx:1470
RunTileMonitoring.frequency
frequency
Definition: RunTileMonitoring.py:162
python.compressB64.c
def c
Definition: compressB64.py:93
dqutils_mdtdeadnoisy::GetNoisyTubes_WithoutForNoise
std::vector< int > GetNoisyTubes_WithoutForNoise(TH1F *h_tube, int &validity, TString chamber)
Definition: MdtDeadNoisyUtils.cxx:637
fitman.k
k
Definition: fitman.py:528
dqutils_mdtdeadnoisy::Get_ML_of_Tube
int Get_ML_of_Tube(int &tubeID, const TString &hardware_name, int totalTubes)
Definition: MdtDeadNoisyUtils.cxx:1262