ATLAS Offline Software
Loading...
Searching...
No Matches
OccupancyMapMaker.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5// PixelCalibAlgs
8
9// Gaudi
10#include "GaudiKernel/ITHistSvc.h"
11
12// EDM
14
15// geometry
17
18// Thread safety check
20
21// ROOT
22#include "TH2.h"
23#include "TString.h"
24
25// standard library
26#include <string>
27#include <sstream>
28#include <algorithm>
29#include <map>
30#include <fstream>
31#include <cstdlib>
32
33OccupancyMapMaker::OccupancyMapMaker(const std::string& name, ISvcLocator* pSvcLocator) :
34 AthAlgorithm(name, pSvcLocator),
35 m_tHistSvc("THistSvc", name),
36 m_pixelID(0),
37 m_pixelRDOKey("PixelRDOs"),
38 m_nEvents(0.),
39 m_nEventsHist(nullptr),
40 m_nEventsLBHist(nullptr),
41 m_disabledModules(nullptr),
45 m_disk1ACut(1.e-3),
46 m_disk2ACut(1.e-3),
47 m_disk3ACut(1.e-3),
48 m_disk1CCut(1.e-3),
49 m_disk2CCut(1.e-3),
50 m_disk3CCut(1.e-3),
51 m_iblCut(1.e-3),
52 m_bLayerCut(1.e-3),
53 m_layer1Cut(1.e-3),
54 m_layer2Cut(1.e-3),
55 m_dbmCut(1.e-3),
56 m_hist_lbMax(3001),
59 m_occupancyPerBC(true),
60 m_nBCReadout(2),
61 m_evt_lbMin(0),
62 m_evt_lbMax(-1),
64 m_mapFile("PixelMapping_Run2.dat")
65{
66 declareProperty("PixelRDOKey", m_pixelRDOKey, "StoreGate key of pixel RDOs");
67 declareProperty("Disk1ACut", m_disk1ACut, "Occupancy cut for Disk1A pixels");
68 declareProperty("Disk2ACut", m_disk2ACut, "Occupancy cut for Disk2A pixels");
69 declareProperty("Disk3ACut", m_disk3ACut, "Occupancy cut for Disk3A pixels");
70 declareProperty("Disk1CCut", m_disk1CCut, "Occupancy cut for Disk1C pixels");
71 declareProperty("Disk2CCut", m_disk2CCut, "Occupancy cut for Disk2C pixels");
72 declareProperty("Disk3CCut", m_disk3CCut, "Occupancy cut for Disk3C pixels");
73 declareProperty("BLayerCut", m_bLayerCut, "Occupancy cut for BLayer pixels");
74 declareProperty("Layer1Cut", m_layer1Cut, "Occupancy cut for Layer1 pixels");
75 declareProperty("Layer2Cut", m_layer2Cut, "Occupancy cut for Layer2 pixels");
76 declareProperty("IBLCut", m_dbmCut, "Occupancy cut for DBM pixels");
77 declareProperty("nLBmax", m_hist_lbMax, "Maximum number of LB (for histograms binning)");
78 declareProperty("NBCReadout", m_nBCReadout, "Number of bunch crossings read out");
79 declareProperty("LBMin", m_evt_lbMin, "First lumi block to consider");
80 declareProperty("LBMax", m_evt_lbMax, "Last lumi block to consider");
81 declareProperty("LongPixelMultiplier", m_longPixelMultiplier, "Multiplier for long pixels");
82 declareProperty("GangedPixelMultiplier", m_gangedPixelMultiplier, "Multiplier for ganged pixels");
83 declareProperty("OccupancyPerBC", m_occupancyPerBC, "Calculate occupancy per BC or per event");
84 declareProperty("CalculateNoiseMaps", m_calculateNoiseMaps, "If false only build hit maps");
85 declareProperty("InputPixelMap", m_mapFile);
86 declareProperty("THistSvc", m_tHistSvc, "THistSvc");
87}
88
90
92 ATH_MSG_INFO("Initializing OccupancyMapMaker");
93
94 ATH_CHECK(m_tHistSvc.retrieve());
96 ATH_CHECK(detStore()->retrieve(m_pixelID, "PixelID"));
97
98 // resize vectors of histograms
99 const Identifier::size_type maxHash = m_pixelID->wafer_hash_max();
100 ATH_MSG_INFO("PixelID maxHash = " << maxHash);
101 m_hitMaps.resize(maxHash);
102 m_LBdependence.resize(maxHash);
103 m_BCIDdependence.resize(maxHash);
104 m_TOTdistributions.resize(maxHash);
106 m_noiseMaps.resize(maxHash);
107 }
108 return registerHistograms();
109}
110
111std::string OccupancyMapMaker::getDCSIDFromPosition (int barrel_ec, int layer, int modPhi, int module_eta){
112 for(unsigned int ii = 0; ii < m_pixelMapping.size(); ii++) {
113 if (m_pixelMapping[ii].second.size() != 4) {
114 ATH_MSG_WARNING( "getDCSIDFromPosition: Vector size is not 4!" );
115 return std::string("Error!");
116 }
117 if (m_pixelMapping[ii].second[0] != barrel_ec) continue;
118 if (m_pixelMapping[ii].second[1] != layer) continue;
119 if (m_pixelMapping[ii].second[2] != modPhi) continue;
120 if (m_pixelMapping[ii].second[3] != module_eta) continue;
121 return m_pixelMapping[ii].first;
122 }
123 ATH_MSG_WARNING( "Not found!" );
124 return std::string("Error!");
125}
126
127const std::string OccupancyMapMaker::histoSuffix(const int bec, const int layer){
128 std::ostringstream out;
129
130 switch(bec) {
131 case 0:
132 out << "barrel/";
133 if(layer==0) { out << "IBL"; }
134 else if(layer==1) { out << "B-layer"; }
135 else { out << "Layer" << layer-1; }
136 break;
137 case +2: out << "endcapA/Disk" << layer+1; break;
138 case -2: out << "endcapC/Disk" << layer+1; break;
139 case +4: out << "DBMA/Layer" << layer+1; break;
140 case -4: out << "DBMC/Layer" << layer+1; break;
141 default: break;
142 }
143 return out.str();
144}
145
146std::vector<std::string>& OccupancyMapMaker::splitter(const std::string &str,
147 char delim,
148 std::vector<std::string> &elems) {
149 std::stringstream ss(str);
150 std::string item;
151 while (std::getline(ss, item, delim)) {
152 elems.push_back(item);
153 }
154 return elems;
155}
156
157std::vector<std::string> OccupancyMapMaker::splitter(const std::string &str,
158 char delim) {
159 std::vector<std::string> elems;
160 splitter(str, delim, elems);
161 return elems;
162}
163
165
166 char* getenvPath = std::getenv("DATAPATH");
167 const unsigned int maxPathStringLength{3000};
168 if((not getenvPath) or (strlen(getenvPath) > maxPathStringLength) ){
169 ATH_MSG_FATAL( "Unable to retrieve environmental DATAPATH" );
170 return StatusCode::FAILURE;
171 }
172 std::stringstream tmpSstr{};
173 tmpSstr<<getenvPath;
174 std::string tmppath(tmpSstr.str());
175
176 std::vector<std::string> paths = splitter(tmppath, ':');
177 bool found(false);
178 for(const auto& x : paths){
179 std::ifstream infile( (x+"/"+m_mapFile).c_str() );
180 if( infile.is_open() ){
181 ATH_MSG_INFO("Mapping file '" << m_mapFile << "' found in " << x);
182
183 int tmp_barrel_ec; int tmp_layer; int tmp_modPhi; int tmp_module_eta; std::string tmp_module_name;
184 std::vector<int> tmp_position;
185 tmp_position.resize(4);
186 while(infile >> tmp_barrel_ec >> tmp_layer >> tmp_modPhi >> tmp_module_eta >> tmp_module_name) {
187 tmp_position[0] = tmp_barrel_ec;
188 tmp_position[1] = tmp_layer;
189 tmp_position[2] = tmp_modPhi;
190 tmp_position[3] = tmp_module_eta;
191 m_pixelMapping.push_back(std::make_pair(tmp_module_name, tmp_position));
192 }
193
194 found=true;
195 infile.close();
196 break;
197 }
198 }
199
200 if( !found ){
201 ATH_MSG_FATAL("Mapping file '" << m_mapFile << "' not found in DATAPATH !!!");
202 return StatusCode::FAILURE;
203 }
204
205 m_nEventsHist = new TH1D("NEvents", "NEvents", 1, 0, 1);
206 m_tHistSvc->regHist("/histfile/NEvents", m_nEventsHist).ignore();
207
208 m_nEventsLBHist = new TH1D("NEventsLB", "NEventsLB", m_hist_lbMax, -0.5, m_hist_lbMax+0.5);
209 m_tHistSvc->regHist("/histfile/NEventsLB", m_nEventsLBHist).ignore();
210
211 for (PixelID::const_id_iterator wafer_it=m_pixelID->wafer_begin(); wafer_it!=m_pixelID->wafer_end(); ++wafer_it) {
212 Identifier ident = *wafer_it;
213 if(!m_pixelID->is_pixel(ident)) continue;
214
215 //const InDetDD::PixelModuleDesign* design = dynamic_cast<const InDetDD::PixelModuleDesign*>(&element->design());
216 //if(!design) continue;
217 //unsigned int mchips = design->numberOfCircuits();
218
219 int bec = m_pixelID->barrel_ec(ident);
220 int layer = m_pixelID->layer_disk(ident);
221 int modPhi = m_pixelID->phi_module(ident);
222 int module_eta = m_pixelID->eta_module(ident);
223 int modHash = m_pixelID->wafer_hash(ident);
224
225 std::string onlineID =
226 getDCSIDFromPosition(bec,layer,modPhi,module_eta);
227
228 std::ostringstream name;
229
230 // hitmap
231 if( bec == 0 && layer == 0) // IBL
232 m_hitMaps[modHash] = new TH2D(onlineID.c_str(), onlineID.c_str(), 160, 0, 160, 336, 0, 336);
233 else if( abs(bec) == 4 ) // DBM
234 m_hitMaps[modHash] = new TH2D(onlineID.c_str(), onlineID.c_str(), 80, 0, 80, 336, 0, 336);
235 else
236 m_hitMaps[modHash] = new TH2D(onlineID.c_str(), onlineID.c_str(), 144, 0, 144, 328, 0, 328);
237 name << "/histfile/hitMaps_" << histoSuffix(bec,layer) << "/" << onlineID;
238 m_tHistSvc->regHist(name.str().c_str(), m_hitMaps[modHash]).ignore();
239 name.str(""); name.clear();
240
241
242 // LB dependence
243 m_LBdependence[modHash] = new TH1D(onlineID.c_str(), onlineID.c_str(), m_hist_lbMax, -0.5, m_hist_lbMax + 0.5);
244 name << "/histfile/LBdep_" << histoSuffix(bec,layer) << "/" << onlineID;
245 m_tHistSvc->regHist(name.str().c_str(), m_LBdependence[modHash]).ignore();
246 name.str(""); name.clear();
247
248 // BCID dependence
249 m_BCIDdependence[modHash] = new TH1D(onlineID.c_str(), onlineID.c_str(), 301, -0.5, 300.5);
250 name << "/histfile/BCIDdep_" << histoSuffix(bec,layer) << "/" << onlineID;
251 m_tHistSvc->regHist(name.str().c_str(), m_BCIDdependence[modHash]).ignore();
252 name.str(""); name.clear();
253
254 // TOT
255 if( bec == 0 && layer == 0) // IBL
256 m_TOTdistributions[modHash] = new TH1D(onlineID.c_str(), onlineID.c_str(), 19, -0.5, 18.5);
257 else
258 m_TOTdistributions[modHash] = new TH1D(onlineID.c_str(), onlineID.c_str(), 256, -0.5, 255.5);
259 name << "/histfile/TOT_" << histoSuffix(bec,layer) << "/" << onlineID;
260 m_tHistSvc->regHist(name.str().c_str(), m_TOTdistributions[modHash]).ignore();
261 name.str(""); name.clear();
262
263 // noisemap
265 if( bec == 0 && layer == 0) // IBL
266 m_noiseMaps[modHash] = new TH2C(onlineID.c_str(), onlineID.c_str(), 160, 0, 160, 336, 0, 336);
267 else if( abs(bec) == 4 ) // DBM
268 m_noiseMaps[modHash] = new TH2C(onlineID.c_str(), onlineID.c_str(), 80, 0, 80, 336, 0, 336);
269 else
270 m_noiseMaps[modHash] = new TH2C(onlineID.c_str(), onlineID.c_str(), 144, 0, 144, 328, 0, 328);
271 name << "/histfile/noiseMaps_" << histoSuffix(bec,layer) << "/" << onlineID;
272 m_tHistSvc->regHist(name.str().c_str(), m_noiseMaps[modHash]).ignore();
273 name.str(""); name.clear();
274 }
275 } // end loop in detector elements
276
277 m_disabledModules = new TH1D("DisabledModules", "Number of events disabled vs. IdentifierHash", 2048, 0, 2048);
278 m_tHistSvc->regHist("/histfile/DisabledModules", m_disabledModules).ignore();
279
281 m_overlayedPixelNoiseMap = new TH2D("overlayedPixelNoiseMap", "Noisy pixel map overlayed all Pixel modules", 144, 0, 144, 328, 0, 328);
282 m_tHistSvc->regHist("/histfile/overlayedPixelNoiseMap", m_overlayedPixelNoiseMap).ignore();
283
284 m_overlayedIBLDCNoiseMap = new TH2D("overlayedIBLDCNoiseMap", "Noisy pixel map overlayed all IBL Planar modules", 160, 0, 160, 336, 0, 336);
285 m_tHistSvc->regHist("/histfile/overlayedIBLDCNoiseMap", m_overlayedIBLDCNoiseMap).ignore();
286
287 m_overlayedIBLSCNoiseMap = new TH2D("overlayedIBLSCNoiseMap", "Noisy pixel map overlayed all IBL 3D modules", 80, 0, 80, 336, 0, 336);
288 m_tHistSvc->regHist("/histfile/overlayedIBLSCNoiseMap", m_overlayedIBLSCNoiseMap).ignore();
289 }
290
291 return StatusCode::SUCCESS;
292}
293
294//=========================================================
295//
296// execute
297//
298//=========================================================
300 ATH_MSG_DEBUG( "Executing OccupancyMapMaker" );
301
302 const EventContext& ctx = Gaudi::Hive::currentContext();
303
304 // check LB is in allowed range
305 unsigned int LB = ctx.eventID().lumi_block();
306 if( (LB < m_evt_lbMin) || (m_evt_lbMax >= m_evt_lbMin && LB > m_evt_lbMax) ){
307 ATH_MSG_VERBOSE("Event in lumiblock " << LB <<
308 " not in selected range [" << m_evt_lbMin << "," << m_evt_lbMax << "] => skipped");
309 return StatusCode::SUCCESS;
310 }
311
312 // retrieve PixelRDO container
313 const PixelRDO_Container* pixelRDOs = nullptr;
314 StatusCode sc = evtStore()->retrieve(pixelRDOs, m_pixelRDOKey);
315 if( !sc.isSuccess() ){
316 ATH_MSG_FATAL( "Unable to retrieve pixel RDO container at " << m_pixelRDOKey );
317 return StatusCode::FAILURE;
318 } ATH_MSG_DEBUG( "Pixel RDO container retrieved" );
319
320 // loop in RDO container
321 for(PixelRDO_Container::const_iterator coll=pixelRDOs->begin();
322 coll!=pixelRDOs->end(); ++coll){
323
324 const InDetRawDataCollection<PixelRDORawData>* PixelRDOCollection(*coll);
325 if(PixelRDOCollection != 0){
326 Identifier moduleID = PixelRDOCollection->identify();
327 IdentifierHash modHash = m_pixelID->wafer_hash(moduleID);
328 ATH_MSG_VERBOSE("moduleID, modHash = " << moduleID << " , " << modHash);
329
330 // exclude module if reported as not good by PixelConditionsSummaryTool
331 if( !(m_pixelConditionsTool->isGood(modHash, ctx)) ) {
332 ATH_MSG_VERBOSE("Module excluded as reported not good by PixelConditionsSummaryTool");
333 continue;
334 }
335
336 // exclude module if containg FE synch errors
337 if (m_pixelConditionsTool->hasBSError(modHash, ctx)) {
338 ATH_MSG_VERBOSE("Module excluded as containing FE synch errors");
339 continue;
340 }
341
342 for(DataVector<PixelRDORawData>::const_iterator rdo = PixelRDOCollection->begin();
343 rdo!=PixelRDOCollection->end(); ++rdo){
344 Identifier rdoID = (*rdo)->identify();
345 unsigned int pixel_eta = m_pixelID->eta_index(rdoID);
346 unsigned int pixel_phi = m_pixelID->phi_index(rdoID);
347
348 int TOT = (*rdo)->getToT(); // it returns a 8 bits "word"
349 int BCID = (*rdo)->getBCID();
350
351 m_hitMaps[modHash]->Fill(pixel_eta, pixel_phi);
352 m_LBdependence[modHash]->Fill(LB);
353 m_BCIDdependence[modHash]->Fill(BCID);
354 m_TOTdistributions[modHash]->Fill(TOT);
355 }
356 }
357 }
358
359
360 // [sgs] why is this done in every event ???
361 for(unsigned int moduleHash = 0; moduleHash < m_pixelID->wafer_hash_max(); moduleHash++) {
362 if( !m_pixelConditionsTool->isActive( moduleHash, ctx ) ){
363 m_disabledModules->Fill( moduleHash );
364 }
365 }
366
367 m_nEvents++;
368 m_nEventsHist->Fill(0.5);
369 m_nEventsLBHist->Fill(LB);
370
371 return StatusCode::SUCCESS;
372}
373
374
375//=========================================================
376//
377// finalize
378//
379//=========================================================
381 ATH_MSG_INFO("Finalizing OccupancyMapMaker");
382
385
386 const int minLogOccupancy = 8;
387 const double minOccupancy = pow(10.,-minLogOccupancy);
388
389 TH1D* globalOccupancy= new TH1D("occupancy", "Pixel occupancy", minLogOccupancy*10, -minLogOccupancy, 0.);
390 m_tHistSvc->regHist("/histfile/occupancy",globalOccupancy).ignore();
391
392 std::map<std::string, TH1D*> h_occupancy;
393
394 // occupancy histograms for different components of the Pixel detector
395 std::vector<std::string> vcomponent;
396 vcomponent.push_back("Disk1A");
397 vcomponent.push_back("Disk2A");
398 vcomponent.push_back("Disk3A");
399 vcomponent.push_back("Disk1C");
400 vcomponent.push_back("Disk2C");
401 vcomponent.push_back("Disk3C");
402 vcomponent.push_back("IBL");
403 vcomponent.push_back("B-layer");
404 vcomponent.push_back("Layer1");
405 vcomponent.push_back("Layer2");
406 vcomponent.push_back("DBMA");
407 vcomponent.push_back("DBMC");
408
409 for(std::vector<std::string>::const_iterator cit=vcomponent.begin(); cit!=vcomponent.end(); ++cit) {
410 const std::string comp = (*cit);
411 h_occupancy[comp] = new TH1D( ("occupancy"+comp).c_str(), ("Pixel occupancy "+comp).c_str(),
412 minLogOccupancy*10, -minLogOccupancy, 0);
413 m_tHistSvc->regHist(("/histfile/occupancy"+comp).c_str(), h_occupancy[comp]).ignore();
414 }
415 vcomponent.clear();
416
417 // occupancy histograms for different pixel types
418 std::vector<std::string> vtype;
419 vtype.push_back("Normal");
420 vtype.push_back("Ganged");
421 vtype.push_back("InterGanged");
422 vtype.push_back("Long");
423 vtype.push_back("Long-Ganged");
424 vtype.push_back("Long-InterGanged");
425 for(std::vector<std::string>::const_iterator cit=vtype.begin(); cit!=vtype.end(); ++cit){
426 const std::string type = (*cit);
427 h_occupancy[type] =
428 new TH1D( ("occupancy"+type).c_str(), ("Pixel occupancy "+type).c_str(),
429 minLogOccupancy*10, -minLogOccupancy, 0);
430 m_tHistSvc->regHist(("/histfile/occupancy"+type).c_str(), h_occupancy[type]).ignore();
431 }
432 vtype.clear();
433
434 //------------------------
435 // number of hits
436 //------------------------
437
438 // IBL
439 TH2F* nhitsPlotBI=new TH2F("nhitsPlotBI", "Number of hits BI;module_eta;module_phi", 20, -10, 10, 14, -0.5, 13.5);
440 m_tHistSvc->regHist("/histfile/nhitsPlotBI",nhitsPlotBI).ignore();
441
442 // B-layer
443 TH2F* nhitsPlotB0=new TH2F("nhitsPlotB0", "Number of hits B0;module_eta;module_phi", 13, -6.5, 6.5, 22, -0.5, 21.5);
444 m_tHistSvc->regHist("/histfile/nhitsPlotB0",nhitsPlotB0).ignore();
445
446 // barrel layer 1
447 TH2F* nhitsPlotB1=new TH2F("nhitsPlotB1", "Number of hits B1;module_eta;module_phi", 13, -6.5, 6.5, 38, -0.5, 37.5);
448 m_tHistSvc->regHist("/histfile/nhitsPlotB1",nhitsPlotB1).ignore();
449
450 // barrel layer 2
451 TH2F* nhitsPlotB2=new TH2F("nhitsPlotB2", "Number of hits B2;module_eta;module_phi", 13,- 6.5, 6.5, 52, -0.5, 51.5);
452 m_tHistSvc->regHist("/histfile/nhitsPlotB2",nhitsPlotB2).ignore();
453
454 // endcap
455 TH2F* nhitsPlotEC=new TH2F("nhitsPlotEC", "Number of hits Endcap;Disk;module_phi", 7, -3.5, 3.5, 48, -0.5, 47.5);
456 m_tHistSvc->regHist("/histfile/nhitsPlotEC",nhitsPlotEC).ignore();
457
458 // DBM
459 TH2F* nhitsPlotDBM=new TH2F("nhitsPlotDBM", "Number of hits DBM;Layer;module_phi",7,-3.5,3.5,4,-0.5,3.5);
460 m_tHistSvc->regHist("/histfile/nhitsPlotDBM",nhitsPlotDBM).ignore();
461
462 //------------------------
463 // hits w/o noise
464 //------------------------
465
466 // IBL
467 TH2F* nhitsNoNoisePlotBI=new TH2F("nhitsNoNoisePlotBI","Number of hits without Noise BI;module_eta;module_phi", 20, -10, 10, 14, -0.5, 13.5);
468 m_tHistSvc->regHist("/histfile/nhitsNoNoisePlotBI",nhitsNoNoisePlotBI).ignore();
469
470 // B-layer
471 TH2F* nhitsNoNoisePlotB0=new TH2F("nhitsNoNoisePlotB0","Number of hits without Noise B0;module_eta;module_phi", 13, -6.5, 6.5, 22, -0.5, 21.5);
472 m_tHistSvc->regHist("/histfile/nhitsNoNoisePlotB0",nhitsNoNoisePlotB0).ignore();
473
474 // barrel layer 1
475 TH2F* nhitsNoNoisePlotB1=new TH2F("nhitsNoNoisePlotB1","Number of hits without Noise B1;module_eta;module_phi", 13, -6.5, 6.5, 38, -0.5, 37.5);
476 m_tHistSvc->regHist("/histfile/nhitsNoNoisePlotB1",nhitsNoNoisePlotB1).ignore();
477
478 // barrel layer 2
479 TH2F* nhitsNoNoisePlotB2=new TH2F("nhitsNoNoisePlotB2","Number of hits without Noise B2;module_eta;module_phi", 13, -6.5, 6.5, 52, -0.5, 51.5);
480 m_tHistSvc->regHist("/histfile/nhitsNoNoisePlotB2",nhitsNoNoisePlotB2).ignore();
481
482 //------------------------
483 // disabled pixels
484 //------------------------
485
486 // IBL
487 TH2F* disablePlotBI=new TH2F("disablePlotBI", "Disabled pixels BI;module_eta;module_phi", 20, -10, 10, 14, -0.5, 13.5);
488 m_tHistSvc->regHist("/histfile/disablePlotBI",disablePlotBI).ignore();
489
490 // B-layer
491 TH2F* disablePlotB0=new TH2F("disablePlotB0", "Disabled pixels B0;module_eta;module_phi", 13,- 6.5, 6.5, 22, -0.5, 21.5);
492 m_tHistSvc->regHist("/histfile/disablePlotB0",disablePlotB0).ignore();
493
494 // barrel layer 1
495 TH2F* disablePlotB1=new TH2F("disablePlotB1", "Disabled pixels B1;module_eta;module_phi", 13, -6.5, 6.5, 38, -0.5, 37.5);
496 m_tHistSvc->regHist("/histfile/disablePlotB1",disablePlotB1).ignore();
497
498 // barrel layer 2
499 TH2F* disablePlotB2=new TH2F("disablePlotB2", "Disabled pixels B2;module_eta;module_phi", 13, -6.5, 6.5, 52, -0.5, 51.5);
500 m_tHistSvc->regHist("/histfile/disablePlotB2",disablePlotB2).ignore();
501
502 // endcap
503 TH2F* disablePlotEC=new TH2F("disablePlotEC", "Disabled pixels Endcap;Disk;module_phi", 7, -3.5, 3.5, 48, -0.5, 47.5);
504 m_tHistSvc->regHist("/histfile/disablePlotEC",disablePlotEC).ignore();
505
506 // DBM
507 TH2F* disablePlotDBM=new TH2F("disablePlotDBM", "Disabled pixels DBM;Layer;module_phi", 7, -3.5, 3.5, 4, -0.5, 3.5);
508 m_tHistSvc->regHist("/histfile/disablePlotDBM",disablePlotDBM).ignore();
509
510 TH1D* maskedPlot= new TH1D("maskedPlot","Disabled pixel per module",50,0.5,50.5);
511 m_tHistSvc->regHist("/histfile/maskedPlot",maskedPlot).ignore();
512
513 int totalDisabledPixels=0;
514 int totalDisabledModules=0;
515 int modulesWithHits=0;
516 int modulesWithDisabledPixels=0;
517
518 const EventContext& ctx{Gaudi::Hive::currentContext()};
519 for (PixelID::const_id_iterator wafer_it=m_pixelID->wafer_begin(); wafer_it!=m_pixelID->wafer_end(); ++wafer_it) {
520 Identifier ident = *wafer_it;
521 if(!m_pixelID->is_pixel(ident)) continue;
522
523 int bec = m_pixelID->barrel_ec (ident);
524 int layer = m_pixelID->layer_disk(ident);
525 int modPhi = m_pixelID->phi_module(ident);
526 int modEta = m_pixelID->eta_module(ident);
527 int modHash = m_pixelID->wafer_hash(ident);
528 int phi_max = m_pixelID->phi_index_max(ident);
529 int eta_max = m_pixelID->eta_index_max(ident);
530
531 TH2F* nhitsNoNoisePlot=0;
532 std::string comp;
533 double cut = 0.;
534
535 if(bec != 0) { // Disk or DBM
536 if(bec == 2) {
537 if(layer == 0) {cut=m_disk1ACut; comp="Disk1A"; }
538 else if(layer == 1) {cut=m_disk2ACut; comp="Disk2A"; }
539 else if(layer == 2) {cut=m_disk3ACut; comp="Disk3A"; }
540 }
541 else if(bec == -2) {
542 if(layer == 0) { cut=m_disk1CCut; comp="Disk1C"; }
543 else if(layer == 1) { cut=m_disk2CCut; comp="Disk2C"; }
544 else if(layer == 2) { cut=m_disk3CCut; comp="Disk3C"; }
545 }
546 else if(bec == 4) { cut=m_dbmCut; comp="DBMA"; }
547 else if(bec == -4) { cut=m_dbmCut; comp="DBMC"; }
548 }
549 else if(bec == 0) { // Barrel
550 if(layer == 0) { cut=m_iblCut; nhitsNoNoisePlot=nhitsNoNoisePlotBI; comp="IBL"; }
551 else if(layer == 1) { cut=m_bLayerCut; nhitsNoNoisePlot=nhitsNoNoisePlotB0; comp="B-layer"; }
552 else if(layer == 2) { cut=m_layer1Cut; nhitsNoNoisePlot=nhitsNoNoisePlotB1; comp="Layer1"; }
553 else if(layer == 3) { cut=m_layer2Cut; nhitsNoNoisePlot=nhitsNoNoisePlotB2; comp="Layer2"; }
554 }
555
556 if (!m_pixelConditionsTool->hasBSError(modHash, ctx) && m_hitMaps[modHash]->GetEntries()==0) {
557 if(bec == 0) {
558 if(layer == 0) { disablePlotBI->Fill(modEta, modPhi, -1); }
559 else if(layer == 1) { disablePlotB0->Fill(modEta, modPhi, -1); }
560 else if(layer == 2) { disablePlotB1->Fill(modEta, modPhi, -1); }
561 else if(layer == 3) { disablePlotB2->Fill(modEta, modPhi, -1); }
562 }
563 else if(bec == 2) { disablePlotEC->Fill(layer+1, modPhi, -1); }
564 else if(bec == -2) { disablePlotEC->Fill(-(layer+1), modPhi, -1); }
565 else if(bec == 4) { disablePlotDBM->Fill(layer+1, modPhi, -1); }
566 else if(bec == -4) { disablePlotDBM->Fill(-(layer+1), modPhi, -1); }
567
568 totalDisabledModules++;
569 continue;
570 }
571 else if( m_hitMaps[modHash]->GetEntries() != 0 ) {
572 if(bec == 0) {
573 if(layer == 0) { nhitsPlotBI->Fill(modEta, modPhi, m_hitMaps[modHash]->GetEntries()); }
574 else if(layer == 1) { nhitsPlotB0->Fill(modEta, modPhi, m_hitMaps[modHash]->GetEntries()); }
575 else if(layer == 2) { nhitsPlotB1->Fill(modEta, modPhi, m_hitMaps[modHash]->GetEntries()); }
576 else if(layer == 3) { nhitsPlotB2->Fill(modEta, modPhi, m_hitMaps[modHash]->GetEntries()); }
577 }
578 else if(bec == 2) { nhitsPlotEC->Fill(layer+1, modPhi, m_hitMaps[modHash]->GetEntries()); }
579 else if(bec == -2) { nhitsPlotEC->Fill(-(layer+1), modPhi, m_hitMaps[modHash]->GetEntries()); }
580 else if(bec == 4) { nhitsPlotDBM->Fill(layer+1, modPhi, m_hitMaps[modHash]->GetEntries()); }
581 else if(bec == -4) { nhitsPlotDBM->Fill(-(layer+1), modPhi, m_hitMaps[modHash]->GetEntries()); }
582
583 modulesWithHits++;
584 }
585
586 int thisModuleCut = 0;
587 bool isIBL3D = ( bec==0 && layer==0 && (modEta <= -7 || modEta >= 6) ) ? true : false;
588
589 for(int pixel_eta=0; pixel_eta<=eta_max; pixel_eta++){
590 for(int pixel_phi=0; pixel_phi<=phi_max; pixel_phi++){
591
592 // kazuki added from here
593 int pixel_eta_on_chip = (bec==0 && layer==0) ? pixel_eta % 80 : pixel_eta % 18; // column
594 int pixel_phi_on_chip = (pixel_phi <= 163) ? pixel_phi : 327 - pixel_phi; // eta
595 if (bec == 0 && layer == 0) pixel_phi_on_chip = pixel_phi;
596 int pixelType = 0;
597
598 if (bec == 0 && layer == 0) { // ----- IBL ----- //
599 if( !isIBL3D && (pixel_eta_on_chip == 0 || pixel_eta_on_chip == 80 - 1) ){
600 pixelType = 1; // long
601 }
602 else { // pixel size = 50x250 um2
603 pixelType = 0; // normal
604 }
605 } else { // Pixel
606 if(pixel_eta_on_chip > 0 && pixel_eta_on_chip < 18 - 1){ // pixel size = 50x400 um2
607 pixelType = 0; // normal
608 for(int kk = 0; kk < 3; kk++){
609 // row 154,156,158 = inter-ganged
610 // row 153,155,157,159, 160,161,162,163 = ganged
611 if(pixel_phi_on_chip == (153 + 2 * kk + 1)){
612 pixelType = 5; // inter-ganged (dealt as normal)
613 break;
614 }
615 if(pixel_phi_on_chip == (153 + 2 * kk) || pixel_phi_on_chip >= 159){
616 pixelType = 2; // ganged
617 break;
618 }
619 }
620 }
621 else if(pixel_eta_on_chip == 0 || pixel_eta_on_chip == 18 - 1){
622 pixelType = 1; //long
623 for(int kk = 0; kk < 3; kk++){
624 if(pixel_phi_on_chip == (153 + 2 * kk + 1)){
625 pixelType = 6; // long inter-ganged (dealt as long)
626 break;
627 }
628 if(pixel_phi_on_chip == (153 + 2 * kk) || pixel_phi_on_chip >= 159){
629 pixelType = 3; // long ganged
630 break;
631 }
632 }
633 }
634 else
635 pixelType = 8; //invalid pixel_phi/pixel_eta pair
636 }
637 // to here
638
639 std::string type;
640
641
642 switch(pixelType) {
643 case 0:
644 type = "Normal";
645 break;
646 case 1:
647 type = "Long";
648 break;
649 case 2:
650 type = "Ganged";
651 break;
652 case 3:
653 type = "Long-Ganged";
654 break;
655 case 5:
656 type = "Long-InterGanged";
657 break;
658 case 6:
659 type = "InterGanged";
660 break;
661 case 8:
662 default:
663 type = "Invalid";
664 break;
665 }
666
667 double thiscut = cut;
668 if( type == "Ganged" ) thiscut *= m_gangedPixelMultiplier;
669 else if( type == "Long" ) thiscut *= m_longPixelMultiplier;
670 else if( type == "Long-InterGanged" ) thiscut *= m_longPixelMultiplier;
671 else if( type == "Long-Ganged" ) thiscut *= m_longPixelMultiplier * m_gangedPixelMultiplier;
672
673 if( type != "Invalid" ){
674 double occupancy = 0;
675 if( m_nEvents != 0 )
676 occupancy = static_cast<double>(m_hitMaps[modHash]->GetBinContent(pixel_eta+1, pixel_phi+1)) /
677 static_cast<double>(m_nEvents);
678
679 if( occupancy < minOccupancy ) occupancy = minOccupancy;
680 globalOccupancy->Fill(log10(occupancy));
681 h_occupancy[comp]->Fill(log10(occupancy));
682 h_occupancy[type]->Fill(log10(occupancy));
683
684 if( occupancy > thiscut ) {
685 thisModuleCut++;
686
688 m_noiseMaps[modHash]->Fill(pixel_eta, pixel_phi);
689 if (comp == "IBL") {
690 if(modEta >= -6 && modEta <= 5) m_overlayedIBLDCNoiseMap->Fill(pixel_eta, pixel_phi); // Planar
691 if(modEta <= -7 || modEta >= 6) m_overlayedIBLSCNoiseMap->Fill(pixel_eta, pixel_phi); // 3D
692 }
693 else m_overlayedPixelNoiseMap->Fill(pixel_eta, pixel_phi);
694 }
695 } else {
696 if(bec == 0) nhitsNoNoisePlot->Fill(modEta, modPhi, m_hitMaps[modHash]->GetBinContent(pixel_eta+1, pixel_phi+1));
697 }
698 } // end if ( type != "Invalid" )
699 } // end for loop on pixel_phi
700 } // end for loop on pixel_eta
701
702 if ( thisModuleCut > 0 ) {
703 totalDisabledPixels+=thisModuleCut;
704 maskedPlot->Fill( static_cast<double>(thisModuleCut) );
705 modulesWithDisabledPixels++;
706
707 if(bec == 0) {
708 if(layer == 0) { disablePlotBI->Fill(modEta, modPhi, thisModuleCut); }
709 else if(layer == 1) { disablePlotB0->Fill(modEta, modPhi, thisModuleCut); }
710 else if(layer == 2) { disablePlotB1->Fill(modEta, modPhi, thisModuleCut); }
711 else if(layer == 3) { disablePlotB2->Fill(modEta, modPhi, thisModuleCut); }
712 }
713 else if(bec == 2) { disablePlotEC->Fill(layer+1, modPhi, thisModuleCut); }
714 else if(bec == -2) { disablePlotEC->Fill(-(layer+1), modPhi, thisModuleCut); }
715 }
716 } // end loop in detector elements
717
718 ATH_MSG_INFO("Modules disabled = " << totalDisabledModules);
719 ATH_MSG_INFO("Modules with hits = " << modulesWithHits);
720 ATH_MSG_INFO("Modules with disabled pixels = " << modulesWithDisabledPixels);
721 ATH_MSG_INFO("Total disabled pixels = " << totalDisabledPixels);
722
723 return StatusCode::SUCCESS;
724
725} // end finalize
726
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static Double_t ss
static Double_t sc
This is an Identifier helper class for the Pixel subdetector.
InDetRawDataContainer< InDetRawDataCollection< PixelRDORawData > > PixelRDO_Container
TGraphErrors * GetEntries(TH2F *histo)
#define x
constexpr int pow(int base, int exp) noexcept
Define macros for attributes used to control the static checker.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
const_iterator end() const
return const_iterator for end of container
const_iterator begin() const
return const_iterator for first entry
This is a "hash" representation of an Identifier.
virtual Identifier identify() const override final
const std::string histoSuffix(const int bec, const int layer)
std::vector< std::string > & splitter(const std::string &str, char delim, std::vector< std::string > &elems)
std::string getDCSIDFromPosition(int bec, int layer, int modPhi, int modEta)
std::vector< TH1D * > m_TOTdistributions
std::string m_pixelRDOKey
std::vector< std::pair< std::string, std::vector< int > > > m_pixelMapping
ToolHandle< IInDetConditionsTool > m_pixelConditionsTool
const PixelID * m_pixelID
unsigned int m_nBCReadout
std::vector< TH1D * > m_LBdependence
std::vector< TH1D * > m_BCIDdependence
OccupancyMapMaker(const std::string &name, ISvcLocator *pSvcLocator)
std::vector< TH2D * > m_hitMaps
StatusCode registerHistograms()
ServiceHandle< ITHistSvc > m_tHistSvc
std::vector< TH2C * > m_noiseMaps
unsigned int m_evt_lbMin
std::vector< Identifier >::const_iterator const_id_iterator
Definition PixelID.h:72