ATLAS Offline Software
HitMapBuilder.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 // PixelCalibAlgs
6 #include "HitMapBuilder.h"
8 
9 // Gaudi
10 #include "GaudiKernel/ITHistSvc.h"
14 
15 // geometry
17 
18 // standard library
19 #include <string>
20 #include <sstream>
21 #include <fstream>
22 
23 
25 }
26 
27 std::string HitMapBuilder::getDCSIDFromPosition(int barrel_ec, int layer, int modPhi, int module_eta) {
28  for (unsigned int ii = 0; ii < m_pixelMapping.size(); ii++) {
29  if (m_pixelMapping[ii].second.size() != 4) {
30  ATH_MSG_FATAL("getDCSIDFromPosition: Vector size is not 4!");
31  return std::string("Error!");
32  }
33  if (m_pixelMapping[ii].second[0] != barrel_ec) continue;
34  if (m_pixelMapping[ii].second[1] != layer) continue;
35  if (m_pixelMapping[ii].second[2] != modPhi) continue;
36  if (m_pixelMapping[ii].second[3] != module_eta) continue;
37  return m_pixelMapping[ii].first;
38  }
39  ATH_MSG_FATAL("DCS ID is not found!");
40  return std::string("Error!");
41 }
42 
43 const std::string HitMapBuilder::histoSuffix(const int bec, const int layer) {
44  std::ostringstream out;
45  switch (bec) {
46  case 0:
47  if (layer==0) out << "IBL";
48  else out << "B" << layer-1;
49  break;
50  case +2: out << "Disk" << layer+1 << "A"; break;
51  case -2: out << "Disk" << layer+1 << "C"; break;
52  case +4: out << "DBM" << layer+1 << "A"; break;
53  case -4: out << "DBM" << layer+1 << "C"; break;
54  default: break;
55  }
56  return out.str();
57 }
58 
59 std::vector<std::string>& HitMapBuilder::splitter(const std::string &str, char delim, std::vector<std::string> &elems) {
60  std::stringstream ss(str);
61  std::string item;
62  while (std::getline(ss, item, delim)) {
63  elems.push_back(item);
64  }
65  return elems;
66 }
67 
68 std::vector<std::string> HitMapBuilder::splitter(const std::string &str, char delim) {
69  std::vector<std::string> elems;
70  splitter(str, delim, elems);
71  return elems;
72 }
73 
74 //=========================================================
75 //
76 // initialize
77 //
78 //=========================================================
80  ATH_MSG_INFO("Initializing HitMapBuilder");
81 
82  ATH_CHECK(m_pixelRDOKey.initialize());
83 
84  // retrieve THistSvc
85  StatusCode sc = m_tHistSvc.retrieve();
86  if (!sc.isSuccess()) {
87  ATH_MSG_FATAL("Unable to retrieve THistSvc");
88  return StatusCode::FAILURE;
89  }
90  // retrieve PixelDetectorManager
91  sc = detStore()->retrieve(m_pixman,"Pixel");
92  if (!sc.isSuccess()) {
93  ATH_MSG_FATAL("Unable to retrieve PixelDetectorManager");
94  return StatusCode::FAILURE;
95  }
96 
97  // retrieve PixelID helper
98  sc = detStore()->retrieve(m_pixelID, "PixelID");
99  if (!sc.isSuccess()) {
100  ATH_MSG_FATAL("Unable to retrieve PixelID helper");
101  return StatusCode::FAILURE;
102  }
103 
104  // resize vectors of histograms
106  ATH_MSG_DEBUG("PixelID maxHash = " << maxHash);
107  m_occupancyMaps.resize(maxHash+m_nIblFes);
109  m_TOTdistributions.resize(maxHash+m_nIblFes);
111  m_occupancyLB.resize(maxHash+m_nIblFes);
112 
113  // Resize vector of variables
114  m_nEventsLB.resize(m_hist_lbMax);
116 
117  return (registerHistograms());
118 }
119 
120 
122  const std::string mapFile = "PixelMapping_Run2.dat";
123 
124  std::vector<std::string> paths = splitter(std::getenv("DATAPATH"), ':');
125  bool found(false);
126  for (const auto& x : paths) {
127  std::ifstream infile((x+"/"+mapFile).c_str());
128  if (infile.is_open()) {
129  ATH_MSG_INFO("Mapping file '" << mapFile << "' found in " << x);
130 
131  int tmp_barrel_ec; int tmp_layer; int tmp_modPhi; int tmp_module_eta; std::string tmp_module_name;
132  std::vector<int> tmp_position;
133  tmp_position.resize(4);
134  while(infile >> tmp_barrel_ec >> tmp_layer >> tmp_modPhi >> tmp_module_eta >> tmp_module_name) {
135  tmp_position[0] = tmp_barrel_ec;
136  tmp_position[1] = tmp_layer;
137  tmp_position[2] = tmp_modPhi;
138  tmp_position[3] = tmp_module_eta;
139  m_pixelMapping.push_back(std::make_pair(tmp_module_name, tmp_position));
140  }
141 
142  found=true;
143  infile.close();
144  break;
145  }
146  }
147 
148  if (!found) {
149  ATH_MSG_FATAL("Mapping file '" << mapFile << "' not found in DATAPATH !!!");
150  return StatusCode::FAILURE;
151  }
152 
153  // Register event histogram
154  m_nEventsHist = std::make_unique<TH1F>("NEvents", "NEvents;;# events", 1, 0, 1);
155  m_nEventsLBHist = std::make_unique<TH1F>("NEventsLB", "NEventsLB;LB;# events", m_hist_lbMax, -0.5, m_hist_lbMax+0.5);
156 
157  // Regist TDirectory first
158  // HARD CODING, TODO do in a smarter way
159  std::vector<std::pair<int, int>> temp_bec_layer{std::make_pair(2, 3), std::make_pair(-2, 3), std::make_pair(0, 4)};
160  std::vector<std::string> temp_dir{"Occupancy2d", "OccupancyLb", "ToT"};
161  for (auto const& bl : temp_bec_layer) {
162  for (int l=0; l<bl.second; l++) {
163  for (auto const& d: temp_dir) {
164  std::string temp_str = "/histfile/All/" + d + "/" + histoSuffix(bl.first, l) + "/" + d + histoSuffix(bl.first, l);
165  std::unique_ptr<TH1F>temp_h1d = std::make_unique<TH1F>((d+histoSuffix(bl.first, l)).c_str(), (d+histoSuffix(bl.first, l)).c_str(), 1, 0, 1);
166  ATH_CHECK(m_tHistSvc->regHist(temp_str.c_str(), std::move(temp_h1d)));
167  ATH_CHECK(m_tHistSvc->deReg(temp_str));
168  }
169  }
170  }
171 
172  for (InDetDD::SiDetectorElementCollection::const_iterator iter=m_pixman->getDetectorElementBegin(); iter!=m_pixman->getDetectorElementEnd(); ++iter) {
173  const InDetDD::SiDetectorElement* element = *iter;
174  if (!element) continue;
175 
176  Identifier ident = element->identify();
177  if (!m_pixelID->is_pixel(ident)) continue;
178 
179  int bec = m_pixelID->barrel_ec(ident);
181  int modPhi = m_pixelID->phi_module(ident);
182  int modEta = m_pixelID->eta_module(ident);
183  int modHash = m_pixelID->wafer_hash(ident);
185 
186  if (abs(bec) == 4) continue; // Skip DBM
187 
188  int iblFeHash = -99;
189  // Use special fe chip index for IBL
190  // {0..3}: 3D C, C8_2, C8_1, C7_2, C7_1
191  // {4..15}: 2D C, C6_2, C6_1, ..., C1_2, C1_1
192  // {16..27}: 2D A, A1_1, A1_2, ..., A6_1, A6_2
193  // {28..31}: 3D A, A7_1, A7_2, A8_1, A8_2
194  if (bec == 0 && layer == 0) {
195  if (modEta <= -7) iblFeHash = modPhi*32 + (modEta+10); // 3D C
196  else if (-6<=modEta && modEta<=5) iblFeHash = modPhi*32 + ((modEta+6)*2+4); // 2D
197  else iblFeHash = modPhi*32 + (modEta+22); // 3D A
198  // iblFeHash, here, is even
199  }
200 
201  std::string onlineID = getDCSIDFromPosition(bec,layer,modPhi,modEta);
202 
203  std::ostringstream name;
204  std::string axisTitle;
205 
206  // Construct IBL Planar later
207  std::string LBCategory;
208  std::string occ2dDir = "Occupancy2d";
209  std::string occLBDir = "OccupancyLb";
210  std::string totDir = "ToT";
211 
212  // Category: All
213  LBCategory = "All";
214  if (bec == 0 && layer == 0 && -6 <= modEta && modEta <= 5) { // IBL 2D
215  for (unsigned chipId=0; chipId<=1; chipId++) { // FE chips in double module
216  int ibl2dHash;
217  if (chipId) {
218  if (modEta <= -1) ibl2dHash = maxHash + iblFeHash; // C side, '_2'
219  else ibl2dHash = maxHash + iblFeHash + chipId; // A side, '_2'
220  }
221  else {
222  if (modEta <= -1) ibl2dHash = maxHash + iblFeHash + 1; // C side, '_1'
223  else ibl2dHash = maxHash + iblFeHash; // A side, '_1'
224  }
225  std::string histTitle = onlineID + "_" + std::to_string(chipId+1);
226  // Occupancy Map
227  axisTitle = ";pixel_eta;pixel_phi;# hits/pixel/event";
228  m_occupancyMaps[ibl2dHash] = std::make_unique<TH2F>(histTitle.c_str(), (histTitle+axisTitle).c_str(), 80, -0.5, 79.5, 336, -0.5, 335.5);
229  name << "/histfile/" << LBCategory << "/" << occ2dDir << "/" << histoSuffix(bec,layer) << "/" << onlineID << "_" << chipId+1;
230  name.str(""); name.clear();
231  m_occupancyMaps[ibl2dHash]->SetOption("colz");
232 
233  // Occupancy vs. LB
234  axisTitle = ";LB;# hits/pixel/event";
235  m_occupancyLB[ibl2dHash] = std::make_unique<TH1F>(histTitle.c_str(), (histTitle+axisTitle).c_str(), m_hist_lbMax, -0.5, m_hist_lbMax-0.5);
236  name << "/histfile/" << LBCategory << "/" << occLBDir << "/" << histoSuffix(bec,layer) << "/" << onlineID << "_" << chipId+1;
237  name.str(""); name.clear();
238 
239  // ToT
240  axisTitle = ";ToT;# hits";
241  m_TOTdistributions[ibl2dHash] = std::make_unique<TH1F>(histTitle.c_str(), (histTitle+axisTitle).c_str(), 19, -0.5, 18.5);
242  name << "/histfile/" << LBCategory << "/" << totDir << "/" << histoSuffix(bec,layer) << "/" << onlineID << "_" << chipId+1;
243  name.str(""); name.clear();
244  }
245  }
246  else { // None IBL 2D
247  // Occupancy Map
248  axisTitle = ";pixel_eta;pixel_phi;# hits/pixel/event";
249  if (bec == 0 && layer == 0) {
250  m_occupancyMaps[modHash] = std::make_unique<TH2F>(onlineID.c_str(), (onlineID+axisTitle).c_str(), 80, -0.5, 79.5, 336, -0.5, 335.5); // IBL 3D
251  }
252  else {
253  m_occupancyMaps[modHash] = std::make_unique<TH2F>(onlineID.c_str(), (onlineID+axisTitle).c_str(), 144, -0.5, 143.5, 328, -0.5, 327.5);
254  }
255  name << "/histfile/" << LBCategory << "/" << occ2dDir << "/" << histoSuffix(bec,layer) << "/" << onlineID;
256  name.str(""); name.clear();
257  m_occupancyMaps[modHash].get()->SetOption("colz");
258 
259  // Occupancy vs. LB
260  axisTitle = ";LB;# hits/pixel/event";
261  m_occupancyLB[modHash] = std::make_unique<TH1F>(onlineID.c_str(), (onlineID+axisTitle).c_str(), m_hist_lbMax, -0.5, m_hist_lbMax-0.5);
262  name << "/histfile/" << LBCategory << "/" << occLBDir << "/" << histoSuffix(bec,layer) << "/" << onlineID;
263  name.str(""); name.clear();
264 
265  // ToT
266  axisTitle = ";ToT;# hits";
267  if (bec == 0 && layer == 0) {
268  m_TOTdistributions[modHash] = std::make_unique<TH1F>(onlineID.c_str(), (onlineID+axisTitle).c_str(), 19, -0.5, 18.5); // IBL 3D
269  }
270  else {
271  m_TOTdistributions[modHash] = std::make_unique<TH1F>(onlineID.c_str(), (onlineID+axisTitle).c_str(), 256, -0.5, 255.5);
272  }
273  name << "/histfile/" << LBCategory << "/" << totDir << "/" << histoSuffix(bec,layer) << "/" << onlineID;
274  name.str(""); name.clear();
275  } // End of if ibl 2d
276 
277  // Category: LB1-100, 101-200, ...
278  if (0 <= iblFeHash) { // IBL
279  for (int i=0; i<m_perLB_n; i++) {
280  LBCategory = "LB" + std::to_string(m_perLB_min+m_perLB_step*i+1) + "-" + std::to_string(m_perLB_min+m_perLB_step*(i+1));
281  if (-6 <= modEta && modEta <= 5) { // IBL 2D
282  for (int chipId=0; chipId<=1; chipId++) { // FE chips in double module
283  int ibl2dHash;
284  if (chipId) {
285  if (modEta <= -1) ibl2dHash = m_nIblFes*i + iblFeHash; // C side, '_2'
286  else ibl2dHash = m_nIblFes*i + iblFeHash + chipId; // A side, '_2'
287  }
288  else {
289  if (modEta <= -1) ibl2dHash = m_nIblFes*i + iblFeHash + 1; // C side, '_1'
290  else ibl2dHash = m_nIblFes*i + iblFeHash; // A side, '_1'
291  }
292  std::string histTitle = onlineID + "_" + std::to_string(chipId+1);
293  // Occupancy Map
294  axisTitle = ";pixel_eta;pixel_phi;# hits/pixel/event";
295  m_occupancyMapsIBL2dLB[ibl2dHash] = std::make_unique<TH2F>(histTitle.c_str(), (histTitle+axisTitle).c_str(), 80, -0.5, 79.5, 336, -0.5, 335.5);
296  name << "/histfile/" << LBCategory << "/" << occ2dDir << "/" << histoSuffix(bec,layer) << "/" << histTitle;
297  name.str(""); name.clear();
298  m_occupancyMapsIBL2dLB[ibl2dHash]->SetOption("colz");
299 
300  // ToT
301  axisTitle = ";ToT;# hits";
302  m_TOTdistributionsIBL2dLB[ibl2dHash] = std::make_unique<TH1F>(histTitle.c_str(), (histTitle+axisTitle).c_str(), 19, -0.5, 18.5);
303  name << "/histfile/" << LBCategory << "/" << totDir << "/" << histoSuffix(bec,layer) << "/" << histTitle;
304  name.str(""); name.clear();
305  }
306  }
307  else { // IBL 3D
308  int ibl2dHash = m_nIblFes*i + iblFeHash;
309  // Occupancy Map
310  axisTitle = ";pixel_eta;pixel_phi;# hits/pixel/event";
311  m_occupancyMapsIBL2dLB[ibl2dHash] = std::make_unique<TH2F>(onlineID.c_str(), (onlineID+axisTitle).c_str(), 80, -0.5, 79.5, 336, -0.5, 335.5);
312  name << "/histfile/" << LBCategory << "/" << occ2dDir << "/" << histoSuffix(bec,layer) << "/" << onlineID;
313  name.str(""); name.clear();
314  m_occupancyMapsIBL2dLB[ibl2dHash]->SetOption("colz");
315 
316  // ToT
317  axisTitle = ";ToT;# hits";
318  m_TOTdistributionsIBL2dLB[ibl2dHash] = std::make_unique<TH1F>(onlineID.c_str(), (onlineID+axisTitle).c_str(), 19, -0.5, 18.5);
319  name << "/histfile/" << LBCategory << "/" << totDir << "/" << histoSuffix(bec,layer) << "/" << onlineID;
320  name.str(""); name.clear();
321  } // End of if ibl 2d
322  } // End of loop of category: LB
323  } // End of if IBL
324  } // end loop in detector elements
325 
326  return StatusCode::SUCCESS;
327 }
328 
329 //=========================================================
330 //
331 // execute
332 //
333 //=========================================================
335  ATH_MSG_DEBUG( "Executing HitMapBuilder" );
336 
337  const EventContext& ctx = Gaudi::Hive::currentContext();
338 
339  // check LB is in allowed range
340  int LB = static_cast<int>(ctx.eventID().lumi_block());
341  if ((LB < m_evt_lbMin) || (m_evt_lbMax >= m_evt_lbMin && LB > m_evt_lbMax)) {
342  ATH_MSG_VERBOSE("Event in lumiblock " << LB << " not in selected range [" << m_evt_lbMin << "," << m_evt_lbMax << "] => skipped");
343  return StatusCode::SUCCESS;
344  }
345 
346  // Get max LB range
347  if (m_LBrange_max < LB) m_LBrange_max = LB;
348 
349 // retrieve PixelRDO container
351  ATH_MSG_DEBUG( "Pixel RDO container retrieved" );
352  // loop in RDO container
353  for (const auto pPixelRDOCollection: *pixelRDOs) {
354  if (pPixelRDOCollection) {
355  Identifier moduleID = pPixelRDOCollection->identify();
356  IdentifierHash modHash = m_pixelID->wafer_hash(moduleID);
357  ATH_MSG_VERBOSE("moduleID, modHash = " << moduleID << " , " << modHash);
358 
359  for (DataVector<PixelRDORawData>::const_iterator rdo=pPixelRDOCollection->begin(); rdo!=pPixelRDOCollection->end(); ++rdo) {
360  Identifier rdoID = (*rdo)->identify();
361  int bec = m_pixelID->barrel_ec(rdoID);
362  //
363  if (std::abs(bec) == 4) continue; // Skip DBM
364  //
365  unsigned int pixel_eta = m_pixelID->eta_index(rdoID);
366  unsigned int pixel_phi = m_pixelID->phi_index(rdoID);
367  int layer = m_pixelID->layer_disk(rdoID);
368  int modPhi = m_pixelID->phi_module(rdoID);
369  int modEta = m_pixelID->eta_module(rdoID);
371 
372 
373 
374  int iblFeHash = -99;
375  if (bec==0 && layer==0) { // IBL FE order: {0..3}: 3D C, {4..15}: 2D C, {16..27}: 2D A, {28..31}: 3D A
376  if (modEta <= -7) iblFeHash = modPhi*32 + (modEta+10); // 3D C
377  else if (-6<=modEta && modEta<=5) iblFeHash = modPhi*32 + ((modEta+6)*2+4); // 2D
378  else iblFeHash = modPhi*32 + (modEta+22); // 3D A
379  if (pixel_eta/80) iblFeHash++; // For 2D, C side '_1', or A side '_2' for pixel_eta 80~159
380  }
381 
382  int TOT = (*rdo)->getToT(); // it returns a 8 bits "word"
383 
384  // Category: All
385  if (bec == 0 && layer == 0 && -6 <= modEta && modEta <= 5) { // IBL 2D
386  int ibl2dHash = maxHash + iblFeHash;
387  m_occupancyMaps[ibl2dHash]->Fill(pixel_eta%80, pixel_phi);
388  m_occupancyLB[ibl2dHash]->Fill(LB);
389  m_TOTdistributions[ibl2dHash]->Fill(TOT);
390  }
391  else { // None IBL 2D
392  m_occupancyMaps[modHash]->Fill(pixel_eta, pixel_phi);
393  m_occupancyLB[modHash]->Fill(LB);
394  m_TOTdistributions[modHash]->Fill(TOT);
395  }
396 
397  // Category: LB
398  if (0 <= iblFeHash) { // IBL
399  for (int i=0; i<m_perLB_n; i++) {
400  if ((m_perLB_min+m_perLB_step*i < LB) && (LB <= m_perLB_min+m_perLB_step*(i+1))) { // LB
401  int ibl2dHash = m_nIblFes*i + iblFeHash;
402  m_occupancyMapsIBL2dLB[ibl2dHash]->Fill(pixel_eta%80, pixel_phi);
403  m_TOTdistributionsIBL2dLB[ibl2dHash]->Fill(TOT);
404  }
405  }
406  }
407  }
408  }
409  }
410  m_nEvents++;
411  m_nEventsHist->Fill(0.5);
412  m_nEventsLBHist->Fill(LB);
413 
414  m_nEventsLB[LB]++;
416 
417  return StatusCode::SUCCESS;
418 }
419 
420 //=========================================================
421 //
422 // finalize
423 //
424 //=========================================================
426  ATH_MSG_INFO("Finalizing HitMapBuilder");
427 
428  ATH_CHECK(m_tHistSvc->regHist("/histfile/NEvents", std::move(m_nEventsHist)));
429  ATH_CHECK(m_tHistSvc->regHist("/histfile/NEventsLB", std::move(m_nEventsLBHist)));
430 
431  //
432  // loop in detector elements
433  //
434  for (InDetDD::SiDetectorElementCollection::const_iterator iter=m_pixman->getDetectorElementBegin(); iter!=m_pixman->getDetectorElementEnd(); ++iter) {
435  const InDetDD::SiDetectorElement* element = *iter;
436  if (element == 0) continue;
437 
438  Identifier ident = element->identify();
439  if (!m_pixelID->is_pixel(ident)) continue;
440 
441  int bec = m_pixelID->barrel_ec (ident);
443  int modPhi = m_pixelID->phi_module(ident);
444  int modEta = m_pixelID->eta_module(ident);
445  int modHash = m_pixelID->wafer_hash(ident);
447 
448  if (abs(bec) == 4) continue; // Skip DBM
449 
450  int iblFeHash = -99;
451  if (bec==0 && layer==0) { // IBL FE order: {0..3}: 3D C, {4..15}: 2D C, {16..27}: 2D A, {28..31}: 3D A
452  if (modEta <= -7) iblFeHash = modPhi*32 + (modEta+10); // 3D C
453  else if (-6<=modEta && modEta<=5) iblFeHash = modPhi*32 + ((modEta+6)*2+4); // 2D
454  else iblFeHash = modPhi*32 + (modEta+22); // 3D A
455  }
456 
457  // Divide by events for Occupancy Map
458  // Category: All
459  if (bec == 0 && layer == 0 && -6 <= modEta && modEta <= 5) { // IBL 2D
460  int ibl2dHash = maxHash + iblFeHash;
461  for (int chipId=0; chipId<2; chipId++) { // 2 Fes in double module
462  //yosuke m_occupancyMaps[ibl2dHash+chipId]->Scale(1.0/(m_nEvents));
463  // Occupancy LB
464  int entries = m_occupancyLB[ibl2dHash+chipId]->GetEntries();
465  for (int lb=0; lb<m_hist_lbMax; lb++) {
466  if (m_nEventsLB[lb] == 0) continue;
467  m_occupancyLB[ibl2dHash+chipId]->SetBinContent(lb+1, m_occupancyLB[ibl2dHash+chipId]->GetBinContent(lb+1)/(m_nEventsLB[lb]*m_fei4bPixels)); // Also divide by fei4 pixels
468  }
469  m_occupancyLB[ibl2dHash+chipId]->SetEntries(entries);
470  m_occupancyLB[ibl2dHash+chipId]->SetBins(m_LBrange_max+100, -0.5, m_LBrange_max+99.5);
471  }
472  }
473  else { // None IBL 2D
474  //yosuke m_occupancyMaps[modHash]->Scale(1.0/(m_nEvents));
475  // Occupancy LB
476  int entries = m_occupancyLB[modHash]->GetEntries();
477  for (int lb=0; lb<m_hist_lbMax; lb++) {
478  if (m_nEventsLB[lb] == 0) continue;
479  if (0 <= iblFeHash) m_occupancyLB[modHash]->SetBinContent(lb+1, m_occupancyLB[modHash]->GetBinContent(lb+1)/(m_nEventsLB[lb]*m_fei4bPixels)); // IBL 3D, divide by fei4 pixels
480  else m_occupancyLB[modHash]->SetBinContent(lb+1, m_occupancyLB[modHash]->GetBinContent(lb+1)/(m_nEventsLB[lb]*m_pixModPixels)); // Pixel module, divide by pixel module pixels
481  }
482  m_occupancyLB[modHash]->SetEntries(entries);
483  m_occupancyLB[modHash]->SetBins(m_LBrange_max+100, -0.5, m_LBrange_max+99.5);
484  }
485 
486  std::string onlineID = getDCSIDFromPosition(bec,layer,modPhi,modEta);
487 
488  std::ostringstream name;
489  std::string axisTitle;
490 
491  // Construct IBL Planar later
492  std::string LBCategory;
493  std::string occ2dDir = "Occupancy2d";
494  std::string occLBDir = "OccupancyLb";
495  std::string totDir = "ToT";
496 
497  // Category: All
498  LBCategory = "All";
499  if (bec == 0 && layer == 0 && -6 <= modEta && modEta <= 5) { // IBL 2D
500  for (unsigned chipId=0; chipId<=1; chipId++) { // FE chips in double module
501  int ibl2dHash;
502  if (chipId) {
503  if (modEta <= -1) ibl2dHash = maxHash + iblFeHash; // C side, '_2'
504  else ibl2dHash = maxHash + iblFeHash + chipId; // A side, '_2'
505  }
506  else {
507  if (modEta <= -1) ibl2dHash = maxHash + iblFeHash + 1; // C side, '_1'
508  else ibl2dHash = maxHash + iblFeHash; // A side, '_1'
509  }
510  // Occupancy Map
511  axisTitle = ";pixel_eta;pixel_phi;# hits/pixel/event";
512  name << "/histfile/" << LBCategory << "/" << occ2dDir << "/" << histoSuffix(bec,layer) << "/" << onlineID << "_" << chipId+1;
513  ATH_CHECK(m_tHistSvc->regHist(name.str(), std::move(m_occupancyMaps[ibl2dHash])));
514  name.str(""); name.clear();
515 
516  // Occupancy vs. LB
517  axisTitle = ";LB;# hits/pixel/event";
518  name << "/histfile/" << LBCategory << "/" << occLBDir << "/" << histoSuffix(bec,layer) << "/" << onlineID << "_" << chipId+1;
519  ATH_CHECK(m_tHistSvc->regHist(name.str(), std::move(m_occupancyLB[ibl2dHash])));
520  name.str(""); name.clear();
521 
522  // ToT
523  axisTitle = ";ToT;# hits";
524  name << "/histfile/" << LBCategory << "/" << totDir << "/" << histoSuffix(bec,layer) << "/" << onlineID << "_" << chipId+1;
525  ATH_CHECK(m_tHistSvc->regHist(name.str(), std::move(m_TOTdistributions[ibl2dHash])));
526  name.str(""); name.clear();
527  }
528  }
529  else { // None IBL 2D
530  // Occupancy Map
531  axisTitle = ";pixel_eta;pixel_phi;# hits/pixel/event";
532  name << "/histfile/" << LBCategory << "/" << occ2dDir << "/" << histoSuffix(bec,layer) << "/" << onlineID;
533  ATH_CHECK(m_tHistSvc->regHist(name.str(), std::move(m_occupancyMaps[modHash])));
534  name.str(""); name.clear();
535 
536  // Occupancy vs. LB
537  axisTitle = ";LB;# hits/pixel/event";
538  name << "/histfile/" << LBCategory << "/" << occLBDir << "/" << histoSuffix(bec,layer) << "/" << onlineID;
539  ATH_CHECK(m_tHistSvc->regHist(name.str(), std::move(m_occupancyLB[modHash])));
540  name.str(""); name.clear();
541 
542  // ToT
543  axisTitle = ";ToT;# hits";
544  name << "/histfile/" << LBCategory << "/" << totDir << "/" << histoSuffix(bec,layer) << "/" << onlineID;
545  ATH_CHECK(m_tHistSvc->regHist(name.str(), std::move(m_TOTdistributions[modHash])));
546  name.str(""); name.clear();
547  } // End of if ibl 2d
548 
549  // Category: LB1-100, 101-200, ...
550  if (0 <= iblFeHash) { // IBL
551  for (int i=0; i<m_perLB_n; i++) {
552  LBCategory = "LB" + std::to_string(m_perLB_min+m_perLB_step*i+1) + "-" + std::to_string(m_perLB_min+m_perLB_step*(i+1));
553  if (-6 <= modEta && modEta <= 5) { // IBL 2D
554  for (int chipId=0; chipId<=1; chipId++) { // FE chips in double module
555  int ibl2dHash;
556  if (chipId) {
557  if (modEta <= -1) ibl2dHash = m_nIblFes*i + iblFeHash; // C side, '_2'
558  else ibl2dHash = m_nIblFes*i + iblFeHash + chipId; // A side, '_2'
559  }
560  else {
561  if (modEta <= -1) ibl2dHash = m_nIblFes*i + iblFeHash + 1; // C side, '_1'
562  else ibl2dHash = m_nIblFes*i + iblFeHash; // A side, '_1'
563  }
564  std::string histTitle = onlineID + "_" + std::to_string(chipId+1);
565  // Occupancy Map
566  axisTitle = ";pixel_eta;pixel_phi;# hits/pixel/event";
567  name << "/histfile/" << LBCategory << "/" << occ2dDir << "/" << histoSuffix(bec,layer) << "/" << histTitle;
568  ATH_CHECK(m_tHistSvc->regHist(name.str(), std::move(m_occupancyMapsIBL2dLB[ibl2dHash])));
569  name.str(""); name.clear();
570 
571  // ToT
572  axisTitle = ";ToT;# hits";
573  name << "/histfile/" << LBCategory << "/" << totDir << "/" << histoSuffix(bec,layer) << "/" << histTitle;
574  ATH_CHECK(m_tHistSvc->regHist(name.str(), std::move(m_TOTdistributionsIBL2dLB[ibl2dHash])));
575  name.str(""); name.clear();
576  }
577  }
578  else { // IBL 3D
579  int ibl2dHash = m_nIblFes*i + iblFeHash;
580  // Occupancy Map
581  axisTitle = ";pixel_eta;pixel_phi;# hits/pixel/event";
582  name << "/histfile/" << LBCategory << "/" << occ2dDir << "/" << histoSuffix(bec,layer) << "/" << onlineID;
583  ATH_CHECK(m_tHistSvc->regHist(name.str(), std::move(m_occupancyMapsIBL2dLB[ibl2dHash])));
584  name.str(""); name.clear();
585 
586  // ToT
587  axisTitle = ";ToT;# hits";
588  name << "/histfile/" << LBCategory << "/" << totDir << "/" << histoSuffix(bec,layer) << "/" << onlineID;
589  ATH_CHECK(m_tHistSvc->regHist(name.str(), std::move(m_TOTdistributionsIBL2dLB[ibl2dHash])));
590  name.str(""); name.clear();
591  } // End of if ibl 2d
592  } // End of loop of category: LB
593  } // End of if IBL
594  } // end loop in detector elements
595 
596  return StatusCode::SUCCESS;
597 
598 } // end finalize
HitMapBuilder::splitter
std::vector< std::string > & splitter(const std::string &str, char delim, std::vector< std::string > &elems)
Definition: HitMapBuilder.cxx:59
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
AtlasDetectorID::is_pixel
bool is_pixel(Identifier id) const
Definition: AtlasDetectorID.h:760
HitMapBuilder::m_nEventsLBCategory
std::vector< double > m_nEventsLBCategory
Definition: HitMapBuilder.h:78
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
HitMapBuilder::m_nEventsLBHist
std::unique_ptr< TH1F > m_nEventsLBHist
Definition: HitMapBuilder.h:81
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
HitMapBuilder::m_pixelID
const PixelID * m_pixelID
Definition: HitMapBuilder.h:71
PixelID::phi_index
int phi_index(const Identifier &id) const
Definition: PixelID.h:658
HitMapBuilder::m_tHistSvc
ServiceHandle< ITHistSvc > m_tHistSvc
Definition: HitMapBuilder.h:67
HitMapBuilder::m_evt_lbMin
Gaudi::Property< int > m_evt_lbMin
Definition: HitMapBuilder.h:89
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
run.infile
string infile
Definition: run.py:13
CaloCellTimeCorrFiller.LB
LB
Definition: CaloCellTimeCorrFiller.py:37
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
HitMapBuilder::m_perLB_min
const int m_perLB_min
Definition: HitMapBuilder.h:95
HitMapBuilder::histoSuffix
const std::string histoSuffix(const int bec, const int layer)
Definition: HitMapBuilder.cxx:43
ParticleGun_SamplingFraction.bec
int bec
Definition: ParticleGun_SamplingFraction.py:89
PixelID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: PixelID.h:619
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
hist_file_dump.d
d
Definition: hist_file_dump.py:137
HitMapBuilder::m_TOTdistributionsIBL2dLB
std::vector< std::unique_ptr< TH1F > > m_TOTdistributionsIBL2dLB
Definition: HitMapBuilder.h:85
HitMapBuilder::registerHistograms
StatusCode registerHistograms()
Definition: HitMapBuilder.cxx:121
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
HitMapBuilder::m_pixModPixels
const int m_pixModPixels
Definition: HitMapBuilder.h:99
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
x
#define x
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
PyPoolBrowser.item
item
Definition: PyPoolBrowser.py:129
HitMapBuilder::m_occupancyMapsIBL2dLB
std::vector< std::unique_ptr< TH2F > > m_occupancyMapsIBL2dLB
Definition: HitMapBuilder.h:83
HitMapBuilder::m_occupancyMaps
std::vector< std::unique_ptr< TH2F > > m_occupancyMaps
Definition: HitMapBuilder.h:82
PixelID::wafer_hash
IdentifierHash wafer_hash(Identifier wafer_id) const
wafer hash from id
Definition: PixelID.h:387
PixelDetectorManager.h
python.BunchSpacingUtils.lb
lb
Definition: BunchSpacingUtils.py:88
lumiFormat.i
int i
Definition: lumiFormat.py:92
HitMapBuilder::m_pixelMapping
std::vector< std::pair< std::string, std::vector< int > > > m_pixelMapping
Definition: HitMapBuilder.h:74
HitMapBuilder::m_TOTdistributions
std::vector< std::unique_ptr< TH1F > > m_TOTdistributions
Definition: HitMapBuilder.h:84
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
HitMapBuilder::m_perLB_step
const int m_perLB_step
Definition: HitMapBuilder.h:95
HitMapBuilder::m_nIblFes
const unsigned int m_nIblFes
Definition: HitMapBuilder.h:94
PixelID::eta_index
int eta_index(const Identifier &id) const
Definition: PixelID.h:664
InDetDD::PixelDetectorManager::getDetectorElementBegin
virtual SiDetectorElementCollection::const_iterator getDetectorElementBegin() const override
Definition: PixelDetectorManager.cxx:110
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
HitMapBuilder::initialize
StatusCode initialize()
Definition: HitMapBuilder.cxx:79
HitMapBuilder::execute
StatusCode execute()
Definition: HitMapBuilder.cxx:334
HitMapBuilder::m_nEvents
double m_nEvents
Definition: HitMapBuilder.h:76
HitMapBuilder::m_pixelRDOKey
SG::ReadHandleKey< PixelRDO_Container > m_pixelRDOKey
Definition: HitMapBuilder.h:68
HitMapBuilder::m_nEventsLB
std::vector< double > m_nEventsLB
Definition: HitMapBuilder.h:77
PixelID::layer_disk
int layer_disk(const Identifier &id) const
Definition: PixelID.h:626
HitMapBuilder::m_LBrange_max
int m_LBrange_max
Definition: HitMapBuilder.h:92
PixelID::eta_module
int eta_module(const Identifier &id) const
Definition: PixelID.h:651
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
HitMapBuilder::m_nEventsHist
std::unique_ptr< TH1F > m_nEventsHist
Definition: HitMapBuilder.h:80
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
PixelID::wafer_hash_max
size_type wafer_hash_max(void) const
Definition: PixelID.cxx:912
item
Definition: ItemListSvc.h:43
SiDetectorElementCollection.h
TRT::Hit::ident
@ ident
Definition: HitInfo.h:77
SiDetectorElement.h
HitMapBuilder::m_perLB_n
const int m_perLB_n
Definition: HitMapBuilder.h:96
HitMapBuilder.h
HitMapBuilder::m_hist_lbMax
Gaudi::Property< int > m_hist_lbMax
Definition: HitMapBuilder.h:88
PixelConvert.h
HitMapBuilder::finalize
StatusCode finalize()
Definition: HitMapBuilder.cxx:425
SCT_ConditionsAlgorithms::CoveritySafe::getenv
std::string getenv(const std::string &variableName)
get an environment variable
Definition: SCT_ConditionsUtilities.cxx:17
CondAlgsOpts.found
int found
Definition: CondAlgsOpts.py:101
HitMapBuilder::m_occupancyLB
std::vector< std::unique_ptr< TH1F > > m_occupancyLB
Definition: HitMapBuilder.h:86
HitMapBuilder::~HitMapBuilder
~HitMapBuilder()
Definition: HitMapBuilder.cxx:24
entries
double entries
Definition: listroot.cxx:49
HitMapBuilder::m_fei4bPixels
const int m_fei4bPixels
Definition: HitMapBuilder.h:98
Identifier::size_type
IDENTIFIER_TYPE size_type
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:41
InDetDD::PixelDetectorManager::getDetectorElementEnd
virtual SiDetectorElementCollection::const_iterator getDetectorElementEnd() const override
Definition: PixelDetectorManager.cxx:115
str
Definition: BTagTrackIpAccessor.cxx:11
IdentifierHash
Definition: IdentifierHash.h:38
PixelID::phi_module
int phi_module(const Identifier &id) const
Definition: PixelID.h:644
InDetDD::SolidStateDetectorElementBase::identify
virtual Identifier identify() const override final
identifier of this detector element (inline)
HitMapBuilder::getDCSIDFromPosition
std::string getDCSIDFromPosition(int bec, int layer, int modPhi, int modEta)
Definition: HitMapBuilder.cxx:27
HitMapBuilder::m_evt_lbMax
Gaudi::Property< int > m_evt_lbMax
Definition: HitMapBuilder.h:90
test_athena_ntuple_dumper.paths
paths
Definition: test_athena_ntuple_dumper.py:7
HitMapBuilder::m_pixman
const InDetDD::PixelDetectorManager * m_pixman
Definition: HitMapBuilder.h:70