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