ATLAS Offline Software
Loading...
Searching...
No Matches
PixelAthMonitoringBase.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
10
11
17 float value) {
18 m_pm[layer].push_back(m_host.m_pixelid->phi_module(id));
19 int ld = m_host.m_pixelid->layer_disk(id);
20 int em = ld;
21 m_val[layer].push_back(value);
22
23 bool copy = false;
24 if (m_host.m_pixelid->barrel_ec(id) == 0) {
25 em = m_host.m_pixelid->eta_module(id);
26 if (ld == 0) {
27 int feid = 0;
28 int emf = 0;
29 if (em < -6) {
30 emf = em - 6;
31 } else if (em > -7 && em < 6) {
32 if (m_host.m_pixelid->eta_index(id) >= 80) feid = 1;
33 emf = 2 * em + feid;
34 copy = true;
35 } else {
36 emf = em + 6;
37 }
38 em = emf;
39 }
40 }
41 m_em[layer].push_back(em);
42
43 if (m_copy2DFEval && copy) {
44 ++em;
45 m_pm[layer].push_back(m_host.m_pixelid->phi_module(id));
46 m_em[layer].push_back(em);
47 m_val[layer].push_back(value);
48 }
49}
50
56 int iFE, float value) {
57 // value
58 m_val[layer].push_back(value);
59
60 // for old pixel see https://twiki.cern.ch/twiki/pub/Atlas/PixelCOOLoffline/pixel_modules_sketch.png
61 //
62 // phi (Y) coordinate
63 if (layer == PixLayers::kIBL) m_pm[layer].push_back(m_host.m_pixelid->phi_module(id));
64 else {
65 if ((layer == PixLayers::kECA || layer == PixLayers::kECC) && (m_host.m_pixelid->phi_module(id) % 2 == 0)) {
66 // even disk modules
67 m_pm[layer].push_back(m_host.m_pixelid->phi_module(id) * 2 + iFE / 8);
68 } else {
69 m_pm[layer].push_back(m_host.m_pixelid->phi_module(id) * 2 + 1 - iFE / 8);
70 }
71 }
72 // eta (X) coordinate
73 int ld = m_host.m_pixelid->layer_disk(id);
74 int em(0);
75 // endcaps
76 em = ld * 8;
77 if (iFE < 8) em += (7 - iFE % 8);
78 else em += iFE % 8;
79
80 // barrel
81 //
82 if (m_host.m_pixelid->barrel_ec(id) == 0) {
83 if (ld == 0) { //ibl
84 em = m_host.m_pixelid->eta_module(id);
85 int emf;
86 if (em < -6) {
87 emf = em - 6;
88 } else if (em > -7 && em < 6) {
89 emf = 2 * em + iFE;
90 } else {
91 emf = em + 6;
92 }
93 em = emf;
94 } else {
95 em = m_host.m_pixelid->eta_module(id) * 8 - 4;
96 if (iFE < 8) em += (7 - iFE % 8);
97 else em += iFE % 8;
98 }
99 } // end barrel
100 m_em[layer].push_back(em);
101}
102
105 ATH_CHECK( m_pixelCondSummaryTool.retrieve( DisableTool{ !m_pixelDetElStatus.empty() && !m_pixelDetElStatusActiveOnly.empty() && !VALIDATE_STATUS_ARRAY_ACTIVATED} ) );
107 ATH_CHECK( m_pixelReadout.retrieve() );
108 }
109 ATH_CHECK(detStore()->retrieve(m_pixelid, "PixelID"));
110 ATH_CHECK( m_pixelDetElStatus.initialize( !m_pixelDetElStatus.empty()) );
112 return StatusCode::SUCCESS;
113}
114
119void PixelAthMonitoringBase::fill2DProfLayerAccum(const VecAccumulator2DMap& accumulator) const {
120 // iterate over all actually filled layers
121 for (const auto& itr : accumulator.m_pm) {
122 // Define the monitored variables
123 int layer = itr.first;
124 auto pm = Monitored::Collection(accumulator.m_prof2Dname + "_pm", accumulator.m_pm.at(layer));
125 auto val = Monitored::Collection(accumulator.m_prof2Dname + "_val", accumulator.m_val.at(layer));
126 auto em = Monitored::Collection(accumulator.m_prof2Dname + "_em", accumulator.m_em.at(layer));
127 fill(pixBaseLayersLabel[layer], pm, em, val);
128 }
129}
130
135void PixelAthMonitoringBase::fill1DModProfAccum(const VecAccumulator2DMap& accumulator, int lumiblock) const {
136 auto lb = Monitored::Scalar<int>("pixmvamontool_lb", lumiblock);
137 const int em_offsets[PixLayers::NBASELAYERS] = { 0, 0, 6, 6, 6, 16};
138 // iterate over all actually filled layers
139 //
140 for (const auto& itr : accumulator.m_pm) {
141 int layer = itr.first;
142 auto pm_v = accumulator.m_pm.at(layer);
143 auto em_v = accumulator.m_em.at(layer);
144 auto val_v = accumulator.m_val.at(layer);
145 auto pi = pm_v.begin();
146 auto ei = em_v.begin();
147 auto vi = val_v.begin();
148 while (pi!=pm_v.end() and ei!=em_v.end() and vi!=val_v.end() )
149 {
150 auto pm = *pi++;
151 auto em = em_offsets[layer] + *ei++;
152 pm += em*PixMon::pixPhiSteps[layer];
153 auto val = Monitored::Scalar<float>(accumulator.m_prof2Dname + "_val", *vi++);
154 fill( m_tools[m_modData[layer].at(pm)], lb, val);
155 }
156 }
157}
158
159
163void PixelAthMonitoringBase::fill1DProfLumiLayers(const std::string& prof1Dname, int lumiblock, float* values,
164 int nlayers) const {
165 ATH_MSG_VERBOSE("in fill1DProfLumiLayers()");
166
167 // Define the monitored variables
168 auto lb = Monitored::Scalar<int>(prof1Dname + "_lb", lumiblock);
169 auto val = Monitored::Scalar<float>(prof1Dname + "_val", 1.0);
170
171 int i_start = 0;
172 int i_end = PixLayers::COUNT;
173 if (nlayers == PixLayers::NFEI3LAYERS) i_end = nlayers;
175 for (int i = i_start; i < i_end; i++) {
176 val = values[i];
177 fill(pixLayersLabel[i], lb, val);
178 }
179}
180
182
186void PixelAthMonitoringBase::fill2DProfLumiLayers(const std::string& prof2Dname, int lumiblock,
187 float(*values)[PixLayers::COUNT], const int* nCategories) const {
188 ATH_MSG_VERBOSE("in fill2DProfLumiLayers()");
189
190 // Define the monitored variables
191 auto lb = Monitored::Scalar<int>(prof2Dname + "_lb", lumiblock);
192 auto val = Monitored::Scalar<float>(prof2Dname + "_val", 1.0);
193 auto cat = Monitored::Scalar<int>(prof2Dname + "_cat");
194
195 for (int i = 0; i < PixLayers::COUNT; i++) {
196 for (cat = 0; cat < nCategories[i]; cat++) {
197 val = values[cat][i];
198 fill(pixLayersLabel[i], lb, cat, val);
199 }
200 }
201}
202
204
205
209void PixelAthMonitoringBase::fillFromArrays(const std::string& namePP0, AccumulatorArrays& pixarrays,
210 const std::string& name2DMap) const {
211 ATH_MSG_VERBOSE("in fillFromArrays()");
212
213 const float weightPix = 1.0 / 46080.0;
214 const float weightIBL = 1.0 / 26880.0;
215
216 bool fillPP0only(name2DMap == "");
217 std::string pospp0varx = namePP0 + "_pospp0x";
218 std::string valvarp = namePP0 + "_val";
219 std::string posvarx = name2DMap + "_em";
220 std::string posvary = name2DMap + "_pm";
221 std::string valvarm = name2DMap + "_val";
222
223 for (unsigned int a = 0; a < PixMon::kNumModulesDisk; ++a) {
224 auto posy = Monitored::Scalar<int>(posvary, a);
225 for (unsigned int b = 0; b < PixMon::kNumLayersDisk; ++b) {
226 // to find out (and fill together into one PP0-histogram bin)
227 // array content of the modules belonging to the same sector (or PP0)
228 // the translation (a-1)/6 is used
229 // to show PP0 values from other disks of the same endcap
230 // in the same plot
231 // the shift (b-1)*8 applies per disk counter b
232 // (there are in total 8 sectors/disk)
233 auto pospp0x = Monitored::Scalar<int>(pospp0varx, a / 6 + b * 8);
234 auto posx = Monitored::Scalar<int>(posvarx, b);
235 auto valp = Monitored::Scalar<float>(valvarp, pixarrays.DA[a][b]);
236 auto valm = Monitored::Scalar<float>(valvarm, pixarrays.DA[a][b] * weightPix);
237 if (pixarrays.DA[a][b] > -1) {
238 fill("ECA", pospp0x, valp);
239 if (!fillPP0only) fill("ECA", posx, posy, valm);
240 }
241 valp = pixarrays.DC[a][b];
242 valm = pixarrays.DC[a][b] * weightPix;
243 if (pixarrays.DC[a][b] > -1) {
244 fill("ECC", pospp0x, valp);
245 if (!fillPP0only) fill("ECC", posx, posy, valm);
246 }
247 }
248 }
249
250 for (unsigned int b = 0; b < PixMon::kNumModulesBarrel; ++b) {
251 // translating array index into old Pixel module eta on a stave
252 // i.e. 0..12 into -6..6 so that standard per-layer histograms
253 // declared by define2DProfHist method can be filled
254 auto posx = Monitored::Scalar<int>(posvarx, b - 6);
255
256 for (unsigned int a = 0; a < PixMon::kNumStavesL0; ++a) {
257 auto posy = Monitored::Scalar<int>(posvary, a);
258 auto pospp0x = Monitored::Scalar<int>(pospp0varx, a);
259 auto valp = Monitored::Scalar<float>(valvarp, pixarrays.B0[a][b]);
260 auto valm = Monitored::Scalar<float>(valvarm, pixarrays.B0[a][b] * weightPix);
261 if (pixarrays.B0[a][b] > -1) {
262 fill("BLayer", pospp0x, valp);
263 if (!fillPP0only) fill("BLayer", posx, posy, valm);
264 }
265 }
266 for (unsigned int a = 0; a < PixMon::kNumStavesL1; ++a) {
267 auto posy = Monitored::Scalar<int>(posvary, a);
268 auto pospp0x = Monitored::Scalar<int>(pospp0varx, a);
269 auto valp = Monitored::Scalar<float>(valvarp, pixarrays.B1[a][b]);
270 auto valm = Monitored::Scalar<float>(valvarm, pixarrays.B1[a][b] * weightPix);
271 if (pixarrays.B1[a][b] > -1) {
272 fill("Layer1", pospp0x, valp);
273 if (!fillPP0only) fill("Layer1", posx, posy, valm);
274 }
275 }
276 for (unsigned int a = 0; a < PixMon::kNumStavesL2; ++a) {
277 auto posy = Monitored::Scalar<int>(posvary, a);
278 auto pospp0x = Monitored::Scalar<int>(pospp0varx, a);
279 auto valp = Monitored::Scalar<float>(valvarp, pixarrays.B2[a][b]);
280 auto valm = Monitored::Scalar<float>(valvarm, pixarrays.B2[a][b] * weightPix);
281 if (pixarrays.B2[a][b] > -1) {
282 fill("Layer2", pospp0x, valp);
283 if (!fillPP0only) fill("Layer2", posx, posy, valm);
284 }
285 }
286 }
287 unsigned int nbina = PixMon::kNumStavesIBL;
288 unsigned int nbinb = PixMon::kNumFEsIBL;
289 for (unsigned int a = 0; a < nbina; ++a) {
290 auto posy = Monitored::Scalar<int>(posvary, a);
291 auto pospp0x = Monitored::Scalar<int>(pospp0varx, a);
292 for (unsigned int b = 0; b < nbinb; ++b) {
293 // translating array index into IBL frontend eta on a stave
294 // i.e. 0..31 into -16..15 so that standard per-layer histograms
295 // declared by define2DProfHist method can be filled
296 auto posx = Monitored::Scalar<int>(posvarx, b - 16);
297 auto valp = Monitored::Scalar<float>(valvarp, pixarrays.IBL[a][b]);
298 auto valm = Monitored::Scalar<float>(valvarm, pixarrays.IBL[a][b] * weightIBL);
299 if (pixarrays.IBL[a][b] > -1) {
300 if (b > (0.5 * nbinb - 1)) {
301 fill("IBLA", pospp0x, valp);
302 } else {
303 fill("IBLC", pospp0x, valp);
304 }
305 if (!fillPP0only) fill("IBL", posx, posy, valm);
306 }
307 }
308 }
309}
310
312
313
317int PixelAthMonitoringBase::getPixLayersID(int ec, int ld) const {
318 int layer = 99;
319
320 if (ec == 2) {
321 layer = PixLayers::kECA;
322 } else if (ec == -2) {
323 layer = PixLayers::kECC;
324 } else if (ec == 0) {
325 if (ld == 0) layer = PixLayers::kIBL;
326 if (ld == 1) layer = PixLayers::kBLayer;
327 if (ld == 2) layer = PixLayers::kLayer1;
328 if (ld == 3) layer = PixLayers::kLayer2;
329 }
330 return layer;
331}
332
336bool PixelAthMonitoringBase::isIBL2D(int hashID) const {
337 bool result(false);
338 if ( hashID>=156 && hashID<=435 ) // IBL
339 {
340 int module = (hashID-156) % 20;
341 if (module>3 && module<16)
342 {
343 result = true;
344 }
345 }
346 return result;
347}
348
350
354bool PixelAthMonitoringBase::isIBL3D(int hashID) const {
355 bool result(false);
356 if ( hashID>=156 && hashID<=435 ) // IBL
357 {
358 int module = (hashID-156) % 20;
359 if (module<4 || module>15)
360 {
361 result = true;
362 }
363 }
364 return result;
365}
366
368
372int PixelAthMonitoringBase::getNumberOfFEs(int pixlayer, int etaMod) const {
373 int nFE(16);
374
375 if (pixlayer == PixLayers::kIBL) {
376 nFE = 1; // IBL 3D
377 if (etaMod > -7 && etaMod < 6) nFE = 2; // IBL Planar
378 }
379 return nFE;
380}
381
383
384
388void PixelAthMonitoringBase::getPhiEtaMod(Identifier& id, int& phiMod, int& etaMod,
389 bool& copyFE) const {
390 phiMod = m_pixelid->phi_module(id);
391
392 int layerDisk = m_pixelid->layer_disk(id);
393 etaMod = layerDisk;
394 copyFE = false;
395 if (m_pixelid->barrel_ec(id) == 0) {
396 etaMod = m_pixelid->eta_module(id);
397 if (layerDisk == 0) {
398 if (etaMod < -6) {
399 etaMod = etaMod - 6;
400 } else if (etaMod > -7 && etaMod < 6) {
401 int feid = 0;
402 if (m_pixelid->eta_index(id) >= 80) feid = 1;
403 etaMod = 2 * etaMod + feid;
404 copyFE = true;
405 } else {
406 etaMod = etaMod + 6;
407 }
408 etaMod = etaMod + 16;
409 } else etaMod = etaMod + 6;
410 }
411}
412
417
418bool PixelAthMonitoringBase::isHitOnTrack(Identifier id, std::vector<Identifier> const& RDOIDs) const {
419 return binary_search(RDOIDs.begin(), RDOIDs.end(), id);
420
421 ;
422}
423
425
426
430
432 double> > const& ClusterIDs) const {
433 bool onTrack = false;
434
435 std::pair<Identifier, double> searchVal = std::make_pair(id, -1.0);
436 onTrack = std::binary_search(ClusterIDs.begin(), ClusterIDs.end(), searchVal,
437 [](std::pair<Identifier, double> l, std::pair<Identifier, double> r) -> bool {
438 return l.first < r.first;
439 });
440 return onTrack;
441}
442
444
449 double> > const& ClusterIDs,
450 double& cosalpha) const {
451 bool onTrack(false);
452
453 std::pair<Identifier, double> searchVal = std::make_pair(id, -1.0);
454 auto it = std::lower_bound(ClusterIDs.begin(), ClusterIDs.end(), searchVal,
455 [](std::pair<Identifier, double> l, std::pair<Identifier, double> r) -> bool {
456 return l.first < r.first;
457 });
458
459 if (it != ClusterIDs.end() && !(id < (*it).first)) {
460 onTrack = true;
461 cosalpha = (*it).second;
462 }
463 return onTrack;
464}
465
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
static Double_t a
const std::string pixBaseLayersLabel[PixLayers::NBASELAYERS]
const std::string pixLayersLabel[PixLayers::COUNT]
#define VALIDATE_STATUS_ARRAY_ACTIVATED
#define pi
const ServiceHandle< StoreGateSvc > & detStore() const
virtual StatusCode initialize() override
initialize
ToolHandleArray< GenericMonitoringTool > m_tools
Array of Generic Monitoring Tools.
Declare a monitored scalar variable.
void fill2DProfLayerAccum(const VecAccumulator2DMap &accumulator) const
take VecAccumulator2DMap and fill the corresponding group
SG::ReadHandleKey< InDet::SiDetectorElementStatus > m_pixelDetElStatusActiveOnly
Optional read handle to get status data to test whether a pixel detector element is active.
int getNumberOfFEs(int pixlayer, int etaMod) const
helper function to get number of FEs per module
ToolHandle< IInDetConditionsTool > m_pixelCondSummaryTool
bool isClusterOnTrack(Identifier id, std::vector< std::pair< Identifier, double > > const &ClusterIDs) const
checks if cluster is on track
void fill2DProfLumiLayers(const std::string &prof2Dname, int lb, float(*weights)[PixLayers::COUNT], const int *nCategories) const
filling 2DProf per-lumi per-layer histograms ["ECA","ECC","BLayer","Layer1","Layer2",...
bool isHitOnTrack(Identifier id, std::vector< Identifier > const &RDOIDs) const
checks if hit is on track
void getPhiEtaMod(Identifier &id, int &phiMod, int &etaMod, bool &copyFE) const
helper function to get eta phi coordinates of per-layer arrays
bool isIBL3D(int hashID) const
helper function to check if module is IBL 3D based on pixel hash ID
void fill1DModProfAccum(const VecAccumulator2DMap &accumulator, int lumiblock) const
take VecAccumulator2DMap and fill 3D arrays [layer, pm, em] with its values and lumiblock
ServiceHandle< InDetDD::IPixelReadoutManager > m_pixelReadout
void fill1DProfLumiLayers(const std::string &prof1Dname, int lb, float *weights, int nlayers=PixLayers::COUNT) const
filling 1DProf per-lumi per-layer histograms ["ECA","ECC","BLayer","Layer1","Layer2",...
int getPixLayersID(int ec, int ld) const
helper function to get layers ID
std::vector< int > m_modData[PixLayers::NBASELAYERS]
bool isIBL2D(int hashID) const
helper function to check if module is IBL planar based on pixel hash ID
SG::ReadHandleKey< InDet::SiDetectorElementStatus > m_pixelDetElStatus
Optional read handle to get status data to test whether a pixel detector element is good.
void fillFromArrays(const std::string &namePP0, AccumulatorArrays &pixarrays, const std::string &name2DMap="") const
filling 1DProfile per-pp0(ROD) histograms for ["ECA","ECC","BLayer","Layer1","Layer2",...
virtual StatusCode initialize() override
initialize
int lb
Definition globals.cxx:23
int r
Definition globals.cxx:22
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
const int pixPhiSteps[PixLayers::NBASELAYERS]
const unsigned int kNumStavesL0
const unsigned int kNumStavesL1
const unsigned int kNumFEsIBL
const unsigned int kNumStavesIBL
const unsigned int kNumModulesDisk
const unsigned int kNumStavesL2
const unsigned int kNumLayersDisk
const unsigned int kNumModulesBarrel
std::unordered_map< int, std::vector< float > > m_val
void add(const int layer, const Identifier &id, float value=1.0)
helper class to accumulate points to fill a 2D per-module plot with
std::unordered_map< int, std::vector< int > > m_pm
std::unordered_map< int, std::vector< int > > m_em
void fill(H5::Group &out_file, size_t iterations)