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//=========================================================
299StatusCode OccupancyMapMaker::execute(const EventContext& ctx){
300 ATH_MSG_DEBUG( "Executing OccupancyMapMaker" );
301
302
303 // check LB is in allowed range
304 unsigned int LB = ctx.eventID().lumi_block();
305 if( (LB < m_evt_lbMin) || (m_evt_lbMax >= m_evt_lbMin && LB > m_evt_lbMax) ){
306 ATH_MSG_VERBOSE("Event in lumiblock " << LB <<
307 " not in selected range [" << m_evt_lbMin << "," << m_evt_lbMax << "] => skipped");
308 return StatusCode::SUCCESS;
309 }
310
311 // retrieve PixelRDO container
312 const PixelRDO_Container* pixelRDOs = nullptr;
313 StatusCode sc = evtStore()->retrieve(pixelRDOs, m_pixelRDOKey);
314 if( !sc.isSuccess() ){
315 ATH_MSG_FATAL( "Unable to retrieve pixel RDO container at " << m_pixelRDOKey );
316 return StatusCode::FAILURE;
317 } ATH_MSG_DEBUG( "Pixel RDO container retrieved" );
318
319 // loop in RDO container
320 for(PixelRDO_Container::const_iterator coll=pixelRDOs->begin();
321 coll!=pixelRDOs->end(); ++coll){
322
323 const InDetRawDataCollection<PixelRDORawData>* PixelRDOCollection(*coll);
324 if(PixelRDOCollection != 0){
325 Identifier moduleID = PixelRDOCollection->identify();
326 IdentifierHash modHash = m_pixelID->wafer_hash(moduleID);
327 ATH_MSG_VERBOSE("moduleID, modHash = " << moduleID << " , " << modHash);
328
329 // exclude module if reported as not good by PixelConditionsSummaryTool
330 if( !(m_pixelConditionsTool->isGood(modHash, ctx)) ) {
331 ATH_MSG_VERBOSE("Module excluded as reported not good by PixelConditionsSummaryTool");
332 continue;
333 }
334
335 // exclude module if containg FE synch errors
336 if (m_pixelConditionsTool->hasBSError(modHash, ctx)) {
337 ATH_MSG_VERBOSE("Module excluded as containing FE synch errors");
338 continue;
339 }
340
341 for(DataVector<PixelRDORawData>::const_iterator rdo = PixelRDOCollection->begin();
342 rdo!=PixelRDOCollection->end(); ++rdo){
343 Identifier rdoID = (*rdo)->identify();
344 unsigned int pixel_eta = m_pixelID->eta_index(rdoID);
345 unsigned int pixel_phi = m_pixelID->phi_index(rdoID);
346
347 int TOT = (*rdo)->getToT(); // it returns a 8 bits "word"
348 int BCID = (*rdo)->getBCID();
349
350 m_hitMaps[modHash]->Fill(pixel_eta, pixel_phi);
351 m_LBdependence[modHash]->Fill(LB);
352 m_BCIDdependence[modHash]->Fill(BCID);
353 m_TOTdistributions[modHash]->Fill(TOT);
354 }
355 }
356 }
357
358
359 // [sgs] why is this done in every event ???
360 for(unsigned int moduleHash = 0; moduleHash < m_pixelID->wafer_hash_max(); moduleHash++) {
361 if( !m_pixelConditionsTool->isActive( moduleHash, ctx ) ){
362 m_disabledModules->Fill( moduleHash );
363 }
364 }
365
366 m_nEvents++;
367 m_nEventsHist->Fill(0.5);
368 m_nEventsLBHist->Fill(LB);
369
370 return StatusCode::SUCCESS;
371}
372
373
374//=========================================================
375//
376// finalize
377//
378//=========================================================
380 ATH_MSG_INFO("Finalizing OccupancyMapMaker");
381
384
385 const int minLogOccupancy = 8;
386 const double minOccupancy = pow(10.,-minLogOccupancy);
387
388 TH1D* globalOccupancy= new TH1D("occupancy", "Pixel occupancy", minLogOccupancy*10, -minLogOccupancy, 0.);
389 m_tHistSvc->regHist("/histfile/occupancy",globalOccupancy).ignore();
390
391 std::map<std::string, TH1D*> h_occupancy;
392
393 // occupancy histograms for different components of the Pixel detector
394 std::vector<std::string> vcomponent;
395 vcomponent.push_back("Disk1A");
396 vcomponent.push_back("Disk2A");
397 vcomponent.push_back("Disk3A");
398 vcomponent.push_back("Disk1C");
399 vcomponent.push_back("Disk2C");
400 vcomponent.push_back("Disk3C");
401 vcomponent.push_back("IBL");
402 vcomponent.push_back("B-layer");
403 vcomponent.push_back("Layer1");
404 vcomponent.push_back("Layer2");
405 vcomponent.push_back("DBMA");
406 vcomponent.push_back("DBMC");
407
408 for(std::vector<std::string>::const_iterator cit=vcomponent.begin(); cit!=vcomponent.end(); ++cit) {
409 const std::string comp = (*cit);
410 h_occupancy[comp] = new TH1D( ("occupancy"+comp).c_str(), ("Pixel occupancy "+comp).c_str(),
411 minLogOccupancy*10, -minLogOccupancy, 0);
412 m_tHistSvc->regHist(("/histfile/occupancy"+comp).c_str(), h_occupancy[comp]).ignore();
413 }
414 vcomponent.clear();
415
416 // occupancy histograms for different pixel types
417 std::vector<std::string> vtype;
418 vtype.push_back("Normal");
419 vtype.push_back("Ganged");
420 vtype.push_back("InterGanged");
421 vtype.push_back("Long");
422 vtype.push_back("Long-Ganged");
423 vtype.push_back("Long-InterGanged");
424 for(std::vector<std::string>::const_iterator cit=vtype.begin(); cit!=vtype.end(); ++cit){
425 const std::string type = (*cit);
426 h_occupancy[type] =
427 new TH1D( ("occupancy"+type).c_str(), ("Pixel occupancy "+type).c_str(),
428 minLogOccupancy*10, -minLogOccupancy, 0);
429 m_tHistSvc->regHist(("/histfile/occupancy"+type).c_str(), h_occupancy[type]).ignore();
430 }
431 vtype.clear();
432
433 //------------------------
434 // number of hits
435 //------------------------
436
437 // IBL
438 TH2F* nhitsPlotBI=new TH2F("nhitsPlotBI", "Number of hits BI;module_eta;module_phi", 20, -10, 10, 14, -0.5, 13.5);
439 m_tHistSvc->regHist("/histfile/nhitsPlotBI",nhitsPlotBI).ignore();
440
441 // B-layer
442 TH2F* nhitsPlotB0=new TH2F("nhitsPlotB0", "Number of hits B0;module_eta;module_phi", 13, -6.5, 6.5, 22, -0.5, 21.5);
443 m_tHistSvc->regHist("/histfile/nhitsPlotB0",nhitsPlotB0).ignore();
444
445 // barrel layer 1
446 TH2F* nhitsPlotB1=new TH2F("nhitsPlotB1", "Number of hits B1;module_eta;module_phi", 13, -6.5, 6.5, 38, -0.5, 37.5);
447 m_tHistSvc->regHist("/histfile/nhitsPlotB1",nhitsPlotB1).ignore();
448
449 // barrel layer 2
450 TH2F* nhitsPlotB2=new TH2F("nhitsPlotB2", "Number of hits B2;module_eta;module_phi", 13,- 6.5, 6.5, 52, -0.5, 51.5);
451 m_tHistSvc->regHist("/histfile/nhitsPlotB2",nhitsPlotB2).ignore();
452
453 // endcap
454 TH2F* nhitsPlotEC=new TH2F("nhitsPlotEC", "Number of hits Endcap;Disk;module_phi", 7, -3.5, 3.5, 48, -0.5, 47.5);
455 m_tHistSvc->regHist("/histfile/nhitsPlotEC",nhitsPlotEC).ignore();
456
457 // DBM
458 TH2F* nhitsPlotDBM=new TH2F("nhitsPlotDBM", "Number of hits DBM;Layer;module_phi",7,-3.5,3.5,4,-0.5,3.5);
459 m_tHistSvc->regHist("/histfile/nhitsPlotDBM",nhitsPlotDBM).ignore();
460
461 //------------------------
462 // hits w/o noise
463 //------------------------
464
465 // IBL
466 TH2F* nhitsNoNoisePlotBI=new TH2F("nhitsNoNoisePlotBI","Number of hits without Noise BI;module_eta;module_phi", 20, -10, 10, 14, -0.5, 13.5);
467 m_tHistSvc->regHist("/histfile/nhitsNoNoisePlotBI",nhitsNoNoisePlotBI).ignore();
468
469 // B-layer
470 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);
471 m_tHistSvc->regHist("/histfile/nhitsNoNoisePlotB0",nhitsNoNoisePlotB0).ignore();
472
473 // barrel layer 1
474 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);
475 m_tHistSvc->regHist("/histfile/nhitsNoNoisePlotB1",nhitsNoNoisePlotB1).ignore();
476
477 // barrel layer 2
478 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);
479 m_tHistSvc->regHist("/histfile/nhitsNoNoisePlotB2",nhitsNoNoisePlotB2).ignore();
480
481 //------------------------
482 // disabled pixels
483 //------------------------
484
485 // IBL
486 TH2F* disablePlotBI=new TH2F("disablePlotBI", "Disabled pixels BI;module_eta;module_phi", 20, -10, 10, 14, -0.5, 13.5);
487 m_tHistSvc->regHist("/histfile/disablePlotBI",disablePlotBI).ignore();
488
489 // B-layer
490 TH2F* disablePlotB0=new TH2F("disablePlotB0", "Disabled pixels B0;module_eta;module_phi", 13,- 6.5, 6.5, 22, -0.5, 21.5);
491 m_tHistSvc->regHist("/histfile/disablePlotB0",disablePlotB0).ignore();
492
493 // barrel layer 1
494 TH2F* disablePlotB1=new TH2F("disablePlotB1", "Disabled pixels B1;module_eta;module_phi", 13, -6.5, 6.5, 38, -0.5, 37.5);
495 m_tHistSvc->regHist("/histfile/disablePlotB1",disablePlotB1).ignore();
496
497 // barrel layer 2
498 TH2F* disablePlotB2=new TH2F("disablePlotB2", "Disabled pixels B2;module_eta;module_phi", 13, -6.5, 6.5, 52, -0.5, 51.5);
499 m_tHistSvc->regHist("/histfile/disablePlotB2",disablePlotB2).ignore();
500
501 // endcap
502 TH2F* disablePlotEC=new TH2F("disablePlotEC", "Disabled pixels Endcap;Disk;module_phi", 7, -3.5, 3.5, 48, -0.5, 47.5);
503 m_tHistSvc->regHist("/histfile/disablePlotEC",disablePlotEC).ignore();
504
505 // DBM
506 TH2F* disablePlotDBM=new TH2F("disablePlotDBM", "Disabled pixels DBM;Layer;module_phi", 7, -3.5, 3.5, 4, -0.5, 3.5);
507 m_tHistSvc->regHist("/histfile/disablePlotDBM",disablePlotDBM).ignore();
508
509 TH1D* maskedPlot= new TH1D("maskedPlot","Disabled pixel per module",50,0.5,50.5);
510 m_tHistSvc->regHist("/histfile/maskedPlot",maskedPlot).ignore();
511
512 int totalDisabledPixels=0;
513 int totalDisabledModules=0;
514 int modulesWithHits=0;
515 int modulesWithDisabledPixels=0;
516
517 const EventContext& ctx{Gaudi::Hive::currentContext()};
518 for (PixelID::const_id_iterator wafer_it=m_pixelID->wafer_begin(); wafer_it!=m_pixelID->wafer_end(); ++wafer_it) {
519 Identifier ident = *wafer_it;
520 if(!m_pixelID->is_pixel(ident)) continue;
521
522 int bec = m_pixelID->barrel_ec (ident);
523 int layer = m_pixelID->layer_disk(ident);
524 int modPhi = m_pixelID->phi_module(ident);
525 int modEta = m_pixelID->eta_module(ident);
526 int modHash = m_pixelID->wafer_hash(ident);
527 int phi_max = m_pixelID->phi_index_max(ident);
528 int eta_max = m_pixelID->eta_index_max(ident);
529
530 TH2F* nhitsNoNoisePlot=0;
531 std::string comp;
532 double cut = 0.;
533
534 if(bec != 0) { // Disk or DBM
535 if(bec == 2) {
536 if(layer == 0) {cut=m_disk1ACut; comp="Disk1A"; }
537 else if(layer == 1) {cut=m_disk2ACut; comp="Disk2A"; }
538 else if(layer == 2) {cut=m_disk3ACut; comp="Disk3A"; }
539 }
540 else if(bec == -2) {
541 if(layer == 0) { cut=m_disk1CCut; comp="Disk1C"; }
542 else if(layer == 1) { cut=m_disk2CCut; comp="Disk2C"; }
543 else if(layer == 2) { cut=m_disk3CCut; comp="Disk3C"; }
544 }
545 else if(bec == 4) { cut=m_dbmCut; comp="DBMA"; }
546 else if(bec == -4) { cut=m_dbmCut; comp="DBMC"; }
547 }
548 else if(bec == 0) { // Barrel
549 if(layer == 0) { cut=m_iblCut; nhitsNoNoisePlot=nhitsNoNoisePlotBI; comp="IBL"; }
550 else if(layer == 1) { cut=m_bLayerCut; nhitsNoNoisePlot=nhitsNoNoisePlotB0; comp="B-layer"; }
551 else if(layer == 2) { cut=m_layer1Cut; nhitsNoNoisePlot=nhitsNoNoisePlotB1; comp="Layer1"; }
552 else if(layer == 3) { cut=m_layer2Cut; nhitsNoNoisePlot=nhitsNoNoisePlotB2; comp="Layer2"; }
553 }
554
555 if (!m_pixelConditionsTool->hasBSError(modHash, ctx) && m_hitMaps[modHash]->GetEntries()==0) {
556 if(bec == 0) {
557 if(layer == 0) { disablePlotBI->Fill(modEta, modPhi, -1); }
558 else if(layer == 1) { disablePlotB0->Fill(modEta, modPhi, -1); }
559 else if(layer == 2) { disablePlotB1->Fill(modEta, modPhi, -1); }
560 else if(layer == 3) { disablePlotB2->Fill(modEta, modPhi, -1); }
561 }
562 else if(bec == 2) { disablePlotEC->Fill(layer+1, modPhi, -1); }
563 else if(bec == -2) { disablePlotEC->Fill(-(layer+1), modPhi, -1); }
564 else if(bec == 4) { disablePlotDBM->Fill(layer+1, modPhi, -1); }
565 else if(bec == -4) { disablePlotDBM->Fill(-(layer+1), modPhi, -1); }
566
567 totalDisabledModules++;
568 continue;
569 }
570 else if( m_hitMaps[modHash]->GetEntries() != 0 ) {
571 if(bec == 0) {
572 if(layer == 0) { nhitsPlotBI->Fill(modEta, modPhi, m_hitMaps[modHash]->GetEntries()); }
573 else if(layer == 1) { nhitsPlotB0->Fill(modEta, modPhi, m_hitMaps[modHash]->GetEntries()); }
574 else if(layer == 2) { nhitsPlotB1->Fill(modEta, modPhi, m_hitMaps[modHash]->GetEntries()); }
575 else if(layer == 3) { nhitsPlotB2->Fill(modEta, modPhi, m_hitMaps[modHash]->GetEntries()); }
576 }
577 else if(bec == 2) { nhitsPlotEC->Fill(layer+1, modPhi, m_hitMaps[modHash]->GetEntries()); }
578 else if(bec == -2) { nhitsPlotEC->Fill(-(layer+1), modPhi, m_hitMaps[modHash]->GetEntries()); }
579 else if(bec == 4) { nhitsPlotDBM->Fill(layer+1, modPhi, m_hitMaps[modHash]->GetEntries()); }
580 else if(bec == -4) { nhitsPlotDBM->Fill(-(layer+1), modPhi, m_hitMaps[modHash]->GetEntries()); }
581
582 modulesWithHits++;
583 }
584
585 int thisModuleCut = 0;
586 bool isIBL3D = ( bec==0 && layer==0 && (modEta <= -7 || modEta >= 6) ) ? true : false;
587
588 for(int pixel_eta=0; pixel_eta<=eta_max; pixel_eta++){
589 for(int pixel_phi=0; pixel_phi<=phi_max; pixel_phi++){
590
591 // kazuki added from here
592 int pixel_eta_on_chip = (bec==0 && layer==0) ? pixel_eta % 80 : pixel_eta % 18; // column
593 int pixel_phi_on_chip = (pixel_phi <= 163) ? pixel_phi : 327 - pixel_phi; // eta
594 if (bec == 0 && layer == 0) pixel_phi_on_chip = pixel_phi;
595 int pixelType = 0;
596
597 if (bec == 0 && layer == 0) { // ----- IBL ----- //
598 if( !isIBL3D && (pixel_eta_on_chip == 0 || pixel_eta_on_chip == 80 - 1) ){
599 pixelType = 1; // long
600 }
601 else { // pixel size = 50x250 um2
602 pixelType = 0; // normal
603 }
604 } else { // Pixel
605 if(pixel_eta_on_chip > 0 && pixel_eta_on_chip < 18 - 1){ // pixel size = 50x400 um2
606 pixelType = 0; // normal
607 for(int kk = 0; kk < 3; kk++){
608 // row 154,156,158 = inter-ganged
609 // row 153,155,157,159, 160,161,162,163 = ganged
610 if(pixel_phi_on_chip == (153 + 2 * kk + 1)){
611 pixelType = 5; // inter-ganged (dealt as normal)
612 break;
613 }
614 if(pixel_phi_on_chip == (153 + 2 * kk) || pixel_phi_on_chip >= 159){
615 pixelType = 2; // ganged
616 break;
617 }
618 }
619 }
620 else if(pixel_eta_on_chip == 0 || pixel_eta_on_chip == 18 - 1){
621 pixelType = 1; //long
622 for(int kk = 0; kk < 3; kk++){
623 if(pixel_phi_on_chip == (153 + 2 * kk + 1)){
624 pixelType = 6; // long inter-ganged (dealt as long)
625 break;
626 }
627 if(pixel_phi_on_chip == (153 + 2 * kk) || pixel_phi_on_chip >= 159){
628 pixelType = 3; // long ganged
629 break;
630 }
631 }
632 }
633 else
634 pixelType = 8; //invalid pixel_phi/pixel_eta pair
635 }
636 // to here
637
638 std::string type;
639
640
641 switch(pixelType) {
642 case 0:
643 type = "Normal";
644 break;
645 case 1:
646 type = "Long";
647 break;
648 case 2:
649 type = "Ganged";
650 break;
651 case 3:
652 type = "Long-Ganged";
653 break;
654 case 5:
655 type = "Long-InterGanged";
656 break;
657 case 6:
658 type = "InterGanged";
659 break;
660 case 8:
661 default:
662 type = "Invalid";
663 break;
664 }
665
666 double thiscut = cut;
667 if( type == "Ganged" ) thiscut *= m_gangedPixelMultiplier;
668 else if( type == "Long" ) thiscut *= m_longPixelMultiplier;
669 else if( type == "Long-InterGanged" ) thiscut *= m_longPixelMultiplier;
670 else if( type == "Long-Ganged" ) thiscut *= m_longPixelMultiplier * m_gangedPixelMultiplier;
671
672 if( type != "Invalid" ){
673 double occupancy = 0;
674 if( m_nEvents != 0 )
675 occupancy = static_cast<double>(m_hitMaps[modHash]->GetBinContent(pixel_eta+1, pixel_phi+1)) /
676 static_cast<double>(m_nEvents);
677
678 if( occupancy < minOccupancy ) occupancy = minOccupancy;
679 globalOccupancy->Fill(log10(occupancy));
680 h_occupancy[comp]->Fill(log10(occupancy));
681 h_occupancy[type]->Fill(log10(occupancy));
682
683 if( occupancy > thiscut ) {
684 thisModuleCut++;
685
687 m_noiseMaps[modHash]->Fill(pixel_eta, pixel_phi);
688 if (comp == "IBL") {
689 if(modEta >= -6 && modEta <= 5) m_overlayedIBLDCNoiseMap->Fill(pixel_eta, pixel_phi); // Planar
690 if(modEta <= -7 || modEta >= 6) m_overlayedIBLSCNoiseMap->Fill(pixel_eta, pixel_phi); // 3D
691 }
692 else m_overlayedPixelNoiseMap->Fill(pixel_eta, pixel_phi);
693 }
694 } else {
695 if(bec == 0) nhitsNoNoisePlot->Fill(modEta, modPhi, m_hitMaps[modHash]->GetBinContent(pixel_eta+1, pixel_phi+1));
696 }
697 } // end if ( type != "Invalid" )
698 } // end for loop on pixel_phi
699 } // end for loop on pixel_eta
700
701 if ( thisModuleCut > 0 ) {
702 totalDisabledPixels+=thisModuleCut;
703 maskedPlot->Fill( static_cast<double>(thisModuleCut) );
704 modulesWithDisabledPixels++;
705
706 if(bec == 0) {
707 if(layer == 0) { disablePlotBI->Fill(modEta, modPhi, thisModuleCut); }
708 else if(layer == 1) { disablePlotB0->Fill(modEta, modPhi, thisModuleCut); }
709 else if(layer == 2) { disablePlotB1->Fill(modEta, modPhi, thisModuleCut); }
710 else if(layer == 3) { disablePlotB2->Fill(modEta, modPhi, thisModuleCut); }
711 }
712 else if(bec == 2) { disablePlotEC->Fill(layer+1, modPhi, thisModuleCut); }
713 else if(bec == -2) { disablePlotEC->Fill(-(layer+1), modPhi, thisModuleCut); }
714 }
715 } // end loop in detector elements
716
717 ATH_MSG_INFO("Modules disabled = " << totalDisabledModules);
718 ATH_MSG_INFO("Modules with hits = " << modulesWithHits);
719 ATH_MSG_INFO("Modules with disabled pixels = " << modulesWithDisabledPixels);
720 ATH_MSG_INFO("Total disabled pixels = " << totalDisabledPixels);
721
722 return StatusCode::SUCCESS;
723
724} // end finalize
725
#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
Define macros for attributes used to control the static checker.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
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)
StatusCode execute(const EventContext &ctx)
Execute method.
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:74