ATLAS Offline Software
MDTChamber.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "MDTChamber.h"
6 
7 #include <cmath>
8 #include <iostream>
9 #include <sstream>
10 
11 #include "LWHists/TH1F_LW.h"
12 #include "LWHists/TH2F_LW.h"
13 #include "TH2F.h"
14 
15 MDTChamber::MDTChamber(std::string_view name) :
16  mdttdc(nullptr),
17  mdttdccut_ML1(nullptr),
18  mdttdccut_ML2(nullptr),
19  mdtadc_onSegm_ML1(nullptr),
20  mdtadc_onSegm_ML2(nullptr),
21  // mdttdccut_RPCtrig_ML1(0),
22  // mdttdccut_TGCtrig_ML1(0),
23  // mdttdccut_RPCtrig_ML2(0),
24  // mdttdccut_TGCtrig_ML2(0),
25  mdtadc(nullptr),
26  mdttdcadc(nullptr),
27  // mdtmultil(0),
28  mdtlayer(nullptr),
29  mdttube(nullptr),
30  // mdttube_bkgrd(0),
31  // mdttube_fornoise(0),
32  mdttube_masked(nullptr),
33  mdtmezz(nullptr),
34  // NEW
35  mdt_effEntries(nullptr),
36  mdt_effCounts(nullptr),
37  mdt_effPerTube(nullptr),
38  mdt_DRvsDT(nullptr),
39  mdt_DRvsDRerr(nullptr),
40  mdt_DRvsSegD(nullptr),
41  mdttubenoise(nullptr),
42  mdttdctube(nullptr),
43  m_hardware_name(std::string(name)),
44  m_barrel_region(0),
45  m_layer_region(0),
46  m_station_eta(0),
47  m_station_phi(0),
48  m_crate(0),
49  m_crate_str("XXXX"),
50  m_mdthitsperchamber_InnerMiddleOuterLumi_bin(0),
51  m_mdthitsperchamber_InnerMiddleOuterLumi_binx(0),
52  m_mdthitsperchamber_InnerMiddleOuterLumi_biny(0),
53  m_mdthitspermultilayerLumi_bin_m1(0),
54  m_mdthitspermultilayerLumi_bin_m2(0),
55  m_mdthitspermultilayerLumi_bin_m1_binx(0),
56  m_mdthitspermultilayerLumi_bin_m1_biny(0),
57  m_mdthitspermultilayerLumi_bin_m2_biny(0),
58  m_mdthitsperML_byLayer_bin_m1(0),
59  m_mdthitsperML_byLayer_bin_m2(0),
60  m_binx(0),
61  m_biny_m1(0),
62  m_biny_m2(0)
63  {
64  if (name.size() >= 7) {
65  // BOS6A16
66  // 0123456
67  char Barrel = name.at(0);
68  char Side = name.at(4);
69 
70  // set m_barrel_region
71  if (Barrel == 'B' && (Side == 'A' || Side == 'B'))
72  m_barrel_region = 0;
73  else if (Barrel == 'B' && Side == 'C')
74  m_barrel_region = 1;
75  else if (Barrel == 'E' && (Side == 'A' || Side == 'B'))
76  m_barrel_region = 2;
77  else if (Barrel == 'E' && Side == 'C')
78  m_barrel_region = 3;
79  else {
80  // ATH_MSG_DEBUG("hardware_name doesn't make sense!" );
81  }
82 
83  std::stringstream ss;
84  // set m_layer_region
85  char layerName = m_hardware_name.at(1);
86  if (layerName == 'I')
87  m_layer_region = 0;
88  else if (layerName == 'M')
89  m_layer_region = 1;
90  else if (layerName == 'O')
91  m_layer_region = 2;
92  else if (layerName == 'E')
93  m_layer_region = 3;
94 
95  // set m_station_eta
96  ss << name.at(3);
97  ss >> m_station_eta;
98  ss.clear();
99 
100  // set m_station_phi
101  std::string_view statphi_s(name.substr(5, 2));
102  ss << statphi_s;
103  ss >> m_station_phi;
104  m_station_phi--;
105  ss.clear();
106  std::string_view name_v(m_hardware_name);
107  // First there were only BMF1,2,3, then BMGs were added which are between the BMFs, so doing the eta-station assignment by hand.
108  if (name_v.substr(0, 4) == "BMF2") m_station_eta = 3;
109  if (name_v.substr(0, 4) == "BMF3") m_station_eta = 5;
110 
111  // station_phi is used as an iterator, and is thus 1 less than its value (since it always starts at 01, not 00).
112 
113  if ((Barrel == 'B' && name.substr(0, 3) != "BEE" && name.substr(0, 3) != "BIS") ||
114  (name.substr(0, 3) == "BIS" && m_station_eta < 6)) {
115  if (m_station_phi < 4 || name.substr(0, 3) == "BME") {
116  m_crate = 1;
117  if (Side == 'A')
118  m_crate_str = "BA01";
119  else if (Side == 'C')
120  m_crate_str = "BC01";
121  } else if (m_station_phi < 8 && m_station_phi > 3) {
122  m_crate = 2;
123  if (Side == 'A')
124  m_crate_str = "BA02";
125  else if (Side == 'C')
126  m_crate_str = "BC02";
127  } else if (m_station_phi < 12 && m_station_phi > 7) {
128  m_crate = 3;
129  if (Side == 'A' || Side == 'B')
130  m_crate_str = "BA03";
131  else if (Side == 'C')
132  m_crate_str = "BC03";
133  } else if (m_station_phi > 11) {
134  m_crate = 4;
135  if (Side == 'A' || Side == 'B')
136  m_crate_str = "BA04";
137  else if (Side == 'C')
138  m_crate_str = "BC04";
139  }
140  } else if ((Barrel == 'E') || name.substr(0, 3) == "BEE" || (name.substr(0, 3) == "BIS" && m_station_eta > 5)) {
141  if (m_station_phi < 4) {
142  m_crate = 1;
143  if (Side == 'A')
144  m_crate_str = "EA01";
145  else if (Side == 'C')
146  m_crate_str = "EC01";
147  } else if (m_station_phi < 8 && m_station_phi > 3) {
148  m_crate = 2;
149  if (Side == 'A')
150  m_crate_str = "EA02";
151  else if (Side == 'C')
152  m_crate_str = "EC02";
153  } else if (m_station_phi < 12 && m_station_phi > 7) {
154  m_crate = 3;
155  if (Side == 'A')
156  m_crate_str = "EA03";
157  else if (Side == 'C')
158  m_crate_str = "EC03";
159  } else if (m_station_phi > 11) {
160  m_crate = 4;
161  if (Side == 'A')
162  m_crate_str = "EA04";
163  else if (Side == 'C')
164  m_crate_str = "EC04";
165  }
166  } else {
167  }
168  } else {
169  // ATH_MSG_DEBUG("BAD CHAMBER NAME");
170  }
171 }
172 
173 MDTChamber::~MDTChamber() = default;
174 
176  // Plots BEE Chambers at the edge BIS plots, and EES/EEL on EIS/EIL plots
177  // EIL goes up to EIL5 in hardware name but in reality there are only 4 eta stations!
178  std::string_view name_v(m_hardware_name);
179  std::string_view station_eta_s = name_v.substr(3, 1);
180  std::string_view statphi_s = name_v.substr(5, 2);
181  if (name_v.substr(0, 4) == "BMF2") station_eta_s = "3";
182  if (name_v.substr(0, 4) == "BMF3") station_eta_s = "5";
183 
184  std::string ecap_layer_IMO = std::string(name_v.substr(0, 1));
185  ecap_layer_IMO += name_v.substr(4, 1);
186  ecap_layer_IMO += station_eta_s;
187 
188  if (m_station_phi == 12 && (m_station_eta == 4 || m_station_eta == 5)) { // m_station_phi+1==actual phi station
189  if (name_v == "BML4A13") ecap_layer_IMO = "BA5";
190  if (name_v == "BML5A13") ecap_layer_IMO = "BA6";
191  if (name_v == "BML4C13") ecap_layer_IMO = "BC5";
192  if (name_v == "BML5C13") ecap_layer_IMO = "BC6";
193  }
194 
195  if (name_v == "BME1A14" || name_v == "BME1A13") { // protect against future fix in mdt helper
196  ecap_layer_IMO = "BA4";
197  statphi_s = "13";
198  }
199  if (name_v == "BME1C14" || name_v == "BME1C13") {
200  ecap_layer_IMO = "BC4";
201  statphi_s = "13";
202  }
203  // First there were only BMF1,2,3, then BMGs were added which are between the BMFs, so doing the ecap-layer assignment by hand.
204  if (name_v.substr(0, 5) == "BMF2A") ecap_layer_IMO = "BA3";
205  if (name_v.substr(0, 5) == "BMF3A") ecap_layer_IMO = "BA5";
206  if (name_v.substr(0, 5) == "BMF2C") ecap_layer_IMO = "BC3";
207  if (name_v.substr(0, 5) == "BMF3C") ecap_layer_IMO = "BC5";
208 
209  std::string statphi_IMO_s = std::string(name_v.substr(1, 1));
210  statphi_IMO_s += ',';
211  statphi_IMO_s += statphi_s;
212  // Separate pesky BIR/BIM 11,15
213  if (name_v.substr(0, 3) == "BIR" || name_v.substr(0, 3) == "BIM") {
214  statphi_IMO_s += ',';
215  statphi_IMO_s += name_v.at(2);
216  }
217 
218  int binx = h->GetXaxis()->FindBin(ecap_layer_IMO.c_str());
219  int biny = h->GetYaxis()->FindBin(statphi_IMO_s.c_str());
222  m_mdthitsperchamber_InnerMiddleOuterLumi_bin = h->GetBin(binx, biny);
223 }
224 
225 void MDTChamber::SetMDTHitsPerML_byLayer_Bins(TH2F* h_mdthitspermultilayerLumi, TH2F* h_mdthitsperML_byLayer) {
226  std::string statphi_s = m_hardware_name.substr(5, 2);
227 
228  if (m_hardware_name == "BME1A14" || m_hardware_name == "BME1C14") statphi_s = "13";
229  std::string_view name_v(m_hardware_name);
230  std::string statphi_ml1_s = statphi_s + ",1";
231  std::string statphi_ml2_s = statphi_s + ",2";
232 
233  // Separate pesky BIR/BIM 11,15
234  if (m_hardware_name.substr(0, 3) == "BIR" || m_hardware_name.substr(0, 3) == "BIM") {
235  statphi_ml1_s = statphi_ml1_s + "," + m_hardware_name.at(2);
236  statphi_ml2_s = statphi_ml2_s + "," + m_hardware_name.at(2);
237  }
238 
239  std::string stateta_s = m_hardware_name.substr(3, 1);
240  if (name_v.substr(0, 4) == "BMF2") stateta_s = "3";
241  if (name_v.substr(0, 4) == "BMF3") stateta_s = "5";
242  std::string ecap_layer = m_hardware_name.substr(0, 2) + m_hardware_name.at(4) + stateta_s;
243 
244  if (m_station_phi == 12 && (m_station_eta == 4 || m_station_eta == 5)) { // m_station_phi+1==actual phi station
245  if (m_hardware_name == "BML4A13") ecap_layer = "BMA5";
246  if (m_hardware_name == "BML5A13") ecap_layer = "BMA6";
247  if (m_hardware_name == "BML4C13") ecap_layer = "BMC5";
248  if (m_hardware_name == "BML5C13") ecap_layer = "BMC6";
249  }
250  if (m_hardware_name == "BME1A14" || m_hardware_name == "BME1A13") { ecap_layer = "BMA4"; }
251  if (m_hardware_name == "BME1C14" || m_hardware_name == "BME1C13") { ecap_layer = "BMC4"; }
252 
253  // Setting BMF by hand because of irregular naming convention. BMF and BMG chambers alternate; historical BMF naming is BMF1,2,3 but BMG
254  // it is 2,4,6
255  if (name_v.substr(0, 5) == "BMF2A") ecap_layer = "BMA3";
256  if (name_v.substr(0, 5) == "BMF3A") ecap_layer = "BMA5";
257  if (name_v.substr(0, 5) == "BMF2C") ecap_layer = "BMC3";
258  if (name_v.substr(0, 5) == "BMF3C") ecap_layer = "BMC5";
259 
260  int binx = h_mdthitspermultilayerLumi->GetXaxis()->FindBin(ecap_layer.c_str());
261  int biny_m1 = h_mdthitspermultilayerLumi->GetYaxis()->FindBin(statphi_ml1_s.c_str());
262  int biny_m2 = biny_m1;
263  if (!(TString(h_mdthitspermultilayerLumi->GetName()) == "NumberOfHitsInBAExtraPerMultiLayer_ADCCut" ||
264  TString(h_mdthitspermultilayerLumi->GetName()) == "NumberOfHitsInBCExtraPerMultiLayer_ADCCut"))
265  biny_m2 = h_mdthitspermultilayerLumi->GetYaxis()->FindBin(statphi_ml2_s.c_str()); // Do not create extra bins
266 
267  m_mdthitspermultilayerLumi_bin_m1 = h_mdthitspermultilayerLumi->GetBin(binx, biny_m1);
268  m_mdthitspermultilayerLumi_bin_m2 = h_mdthitspermultilayerLumi->GetBin(binx, biny_m2);
269 
273 
274  if ((statphi_ml1_s.substr(0, 2) == "11" || statphi_ml1_s.substr(0, 2) == "15") && m_hardware_name.at(0) == 'E' &&
275  (m_layer_region == 0 || m_layer_region == 3)) {
276  statphi_ml1_s += ",R"; // Correction for EIR/EIM
277  statphi_ml2_s += ",R"; // Correction for EIR/EIM
278  }
279 
280  m_binx = h_mdthitsperML_byLayer->GetXaxis()->FindBin(ecap_layer.c_str());
281  m_biny_m1 = h_mdthitsperML_byLayer->GetYaxis()->FindBin(statphi_ml1_s.c_str());
282  m_biny_m2 = h_mdthitsperML_byLayer->GetYaxis()->FindBin(statphi_ml2_s.c_str());
283 
284  m_mdthitsperML_byLayer_bin_m1 = h_mdthitsperML_byLayer->GetBin(binx, biny_m1);
285  m_mdthitsperML_byLayer_bin_m2 = h_mdthitsperML_byLayer->GetBin(binx, biny_m2);
286 }
TH1F_LW.h
TH2F_LW.h
MDTChamber::m_crate
int m_crate
Definition: MDTChamber.h:104
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
TH2F
Definition: rootspy.cxx:420
MDTChamber::m_barrel_region
short int m_barrel_region
Definition: MDTChamber.h:99
MDTChamber::m_crate_str
std::string m_crate_str
Definition: MDTChamber.h:107
MDTChamber::m_mdthitspermultilayerLumi_bin_m2_biny
short int m_mdthitspermultilayerLumi_bin_m2_biny
Definition: MDTChamber.h:117
MDTChamber::m_mdthitsperchamber_InnerMiddleOuterLumi_bin
short int m_mdthitsperchamber_InnerMiddleOuterLumi_bin
Definition: MDTChamber.h:110
MDTChamber::m_mdthitspermultilayerLumi_bin_m1_biny
short int m_mdthitspermultilayerLumi_bin_m1_biny
Definition: MDTChamber.h:116
MDTChamber::m_binx
short int m_binx
Definition: MDTChamber.h:120
MDTChamber::MDTChamber
MDTChamber(std::string_view name)
Definition: MDTChamber.cxx:15
MDTChamber::m_mdthitsperchamber_InnerMiddleOuterLumi_binx
short int m_mdthitsperchamber_InnerMiddleOuterLumi_binx
Definition: MDTChamber.h:111
DetType::Barrel
@ Barrel
Definition: DetType.h:14
MDTChamber::m_biny_m2
short int m_biny_m2
Definition: MDTChamber.h:122
MDTChamber::m_station_phi
short int m_station_phi
Definition: MDTChamber.h:102
MDTChamber::m_mdthitsperML_byLayer_bin_m1
short int m_mdthitsperML_byLayer_bin_m1
Definition: MDTChamber.h:118
MDTChamber::m_station_eta
short int m_station_eta
Definition: MDTChamber.h:101
MDTChamber::m_mdthitspermultilayerLumi_bin_m1
short int m_mdthitspermultilayerLumi_bin_m1
Definition: MDTChamber.h:113
Side
Definition: WaferTree.h:36
MDTChamber::m_mdthitsperchamber_InnerMiddleOuterLumi_biny
short int m_mdthitsperchamber_InnerMiddleOuterLumi_biny
Definition: MDTChamber.h:112
MDTChamber::m_layer_region
short int m_layer_region
Definition: MDTChamber.h:100
MDTChamber::m_hardware_name
std::string m_hardware_name
Definition: MDTChamber.h:97
MDTChamber::m_mdthitspermultilayerLumi_bin_m1_binx
short int m_mdthitspermultilayerLumi_bin_m1_binx
Definition: MDTChamber.h:115
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
MDTChamber::m_mdthitsperML_byLayer_bin_m2
short int m_mdthitsperML_byLayer_bin_m2
Definition: MDTChamber.h:119
h
MDTChamber::m_biny_m1
short int m_biny_m1
Definition: MDTChamber.h:121
MDTChamber::m_mdthitspermultilayerLumi_bin_m2
short int m_mdthitspermultilayerLumi_bin_m2
Definition: MDTChamber.h:114
MDTChamber::SetMDTHitsPerML_byLayer_Bins
void SetMDTHitsPerML_byLayer_Bins(TH2F *, TH2F *)
Definition: MDTChamber.cxx:225
MDTChamber::SetMDTHitsPerChamber_IMO_Bin
void SetMDTHitsPerChamber_IMO_Bin(TH2F *)
Definition: MDTChamber.cxx:175
MDTChamber::~MDTChamber
~MDTChamber()
MDTChamber.h