ATLAS Offline Software
Loading...
Searching...
No Matches
TRTMonitoringRun3RAW_Alg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#define FILLEVENTNORMALIZATION(NBINS, MIN, WIDTH, VALUE, VARPASSED, VAR, HISTGROUP) \
6for (int i = 1; i <= NBINS; i++) \
7 if (MIN + WIDTH*(i-1) >= VALUE || MIN + WIDTH*(i+1) <= VALUE) \
8 { \
9 VARPASSED = 0.0; \
10 VAR = i; \
11 fill(HISTGROUP, VARPASSED, VAR); \
12 }
13
15
23#include "TrkTrack/Track.h"
31
34
35#include <sstream>
36#include <iomanip>
37#include <memory>
38#include <cmath>
39#include <format>
40using namespace std;
41
42//Private Static Const data member initialization
43constexpr int TRTMonitoringRun3RAW_Alg::s_numberOfBarrelStacks = 32;
44constexpr int TRTMonitoringRun3RAW_Alg::s_numberOfEndCapStacks = 32;
45constexpr int TRTMonitoringRun3RAW_Alg::s_Straw_max[2] = {1642, 3840};
46constexpr int TRTMonitoringRun3RAW_Alg::s_iChip_max[2] = {104, 240};
47
48TRTMonitoringRun3RAW_Alg::TRTMonitoringRun3RAW_Alg( const std::string& name, ISvcLocator* pSvcLocator )
49:AthMonitorAlgorithm(name,pSvcLocator)
50{
51}
52
54
56 using namespace Monitored;
57
58 ATH_MSG_VERBOSE("Initializing TRT Monitoring");
59
60 // initialize superclass
62
63 // Retrieve detector manager.
64 ATH_CHECK( detStore()->retrieve(m_mgr, "TRT") );
65 // Get ID helper for TRT to access various detector components like straw, straw_layer, layer_or_wheel, phi_module, etc...
66 ATH_CHECK( detStore()->retrieve(m_pTRTHelper, "TRT_ID") );
67 ATH_CHECK( detStore()->retrieve(m_idHelper, "AtlasID") );
68
69 if (m_doExpert) {
70 // Retrieve the TRT_Straw Status Service.
71 if (m_sumTool.name().empty()) {
72 ATH_MSG_WARNING("TRT_StrawStatusTool not given.");
73 } else {
74 ATH_CHECK( m_sumTool.retrieve() );
75 }
76
77 Identifier ident;
78
79 if (m_sumTool.name() != "") {
80 ATH_MSG_VERBOSE("Trying " << m_sumTool << " isGood");
81 ATH_MSG_VERBOSE("TRT_StrawStatusTool reports status = " << m_sumTool->getStatus(ident, Gaudi::Hive::currentContext()));
82 }
83
84 // Retrieve the TRT_ByteStreamService.
85 if (m_BSSvc.name().empty()) {
86 ATH_MSG_WARNING("TRT_ByteStreamSvc not given.");
87 } else {
88 ATH_CHECK( m_BSSvc.retrieve() );
89 }
90 }//If do expert
91
92 // Get Track summary tool
93 if (m_TrackSummaryTool.retrieve().isFailure())
94 ATH_MSG_ERROR("Cannot get TrackSummaryTool");
95 else
96 ATH_MSG_DEBUG("Retrieved succesfully the track summary tool" << m_TrackSummaryTool);
97
98 // Retrieve TRTTrackHoleSearchTool
100 ATH_CHECK( m_trt_hole_finder.retrieve() );
101 }
102 else {
103 m_trt_hole_finder.disable();
104 }
105
106 // Initialization of VarHandleKeys
107 ATH_CHECK( m_rdoContainerKey.initialize() );
108 ATH_CHECK( m_TRT_BCIDCollectionKey.initialize() );
109 ATH_CHECK( m_combTrackCollectionKey.initialize() );
110 ATH_CHECK( m_trackCollectionKey.initialize() );
112
113 // InDetTrackSelectionTools initialization:
114 ATH_CHECK( m_trackSelTool.retrieve() );
115
116 // initialize chip lookup maps
117 ATH_CHECK( m_TRTStrawNeighbourSvc.retrieve() );
118
119 //loop over straw hash index to create straw number mapping for TRTViewer
120 unsigned int maxHash = m_pTRTHelper->straw_layer_hash_max();
121
122 for (int ibe = 0; ibe < 2; ibe++) { // ibe=0(barrel), ibe=1(endcap)
123 for (unsigned int index = 0; index < maxHash; index++) {
124 IdentifierHash idHash = index;
125 Identifier id = m_pTRTHelper->layer_id(idHash);
126 int idBarrelEndcap = m_pTRTHelper->barrel_ec(id);
127 int idLayerWheel = m_pTRTHelper->layer_or_wheel(id);
128 int idPhiModule = m_pTRTHelper->phi_module(id);
129 int idStrawLayer = m_pTRTHelper->straw_layer(id);
130 bool isBarrel = m_pTRTHelper->is_barrel(id);
131 int idSide;
132 int sectorflag = 0;
133 const InDetDD::TRT_BaseElement *element = nullptr;
134
135 if (ibe == 0) { // barrel
136 idSide = idBarrelEndcap ? 1 : -1;
137
138 if (isBarrel && (idBarrelEndcap == -1)) {
139 sectorflag = 1;
140 element = m_mgr->getBarrelElement(idSide, idLayerWheel, idPhiModule, idStrawLayer);
141 }
142 } else if (ibe == 1) { // endcap
143 idSide = idBarrelEndcap ? 1 : 0;
144
145 if (!isBarrel && ((idBarrelEndcap == -2) || (idBarrelEndcap == 2))) {
146 sectorflag = 1;
147 element = m_mgr->getEndcapElement(idSide, idLayerWheel, idStrawLayer, idPhiModule);//, idStrawLayer_ec);
148 }
149 }
150
151 if (sectorflag == 1) {
152 if (!element) continue;
153
154 for (unsigned int istraw = 0; istraw < element->nStraws(); istraw++) {
155 std::vector<Identifier> neighbourIDs;
156 Identifier strawID = m_pTRTHelper->straw_id(id, int(istraw));
157 int i_chip, i_pad;
158 m_TRTStrawNeighbourSvc->getChip(strawID, i_chip);
159 m_TRTStrawNeighbourSvc->getPad(id, i_pad);
160
161 if (ibe == 0) { //barrel
162 if (idLayerWheel == 1) i_chip += 21;
163
164 if (idLayerWheel == 2) i_chip += 54;
165
166 int tempStrawNumber = strawNumber(istraw, idStrawLayer, idLayerWheel);
167
168 if (tempStrawNumber < 0 || tempStrawNumber > (s_Straw_max[ibe] - 1)) {
169 ATH_MSG_WARNING("Found tempStrawNumber = " << tempStrawNumber << " out of range.");
170 } else {
171 m_mat_chip_B.at(idPhiModule).at(tempStrawNumber) = i_chip;
172 m_mat_chip_B.at(idPhiModule + 32).at(tempStrawNumber) = i_chip;
173 }
174 } else if (ibe == 1) { //endcap
175 ++i_chip -= 104;
176 int tempStrawNumber = strawNumberEndCap(istraw, idStrawLayer, idLayerWheel, idPhiModule, idSide);
177
178 if (tempStrawNumber < 0 || tempStrawNumber > (s_Straw_max[ibe] - 1)) {
179 ATH_MSG_WARNING("Found tempStrawNumber = " << tempStrawNumber << " out of range.");
180 } else {
181 m_mat_chip_E.at(idPhiModule).at(tempStrawNumber) = i_chip;
182 m_mat_chip_E.at(idPhiModule + 32).at(tempStrawNumber) = i_chip;
183 }
184 }
185 }
186 }
187 }
188 }
189
190 return StatusCode::SUCCESS;
191}
192
193//----------------------------------------------------------------------------------//
194std::vector<std::vector<std::vector<int>>> TRTMonitoringRun3RAW_Alg::initScaleVectors(const EventContext& ctx) const {
195//----------------------------------------------------------------------------------//
196// if (m_flagforscale == 0 ) return 0;
197 std::vector<std::vector<std::vector<int>>> scale_hHitWMap;
198 std::vector<std::vector<int>> scale_hHitWMap_B, scale_hHitWMap_EA, scale_hHitWMap_EC;
199 std::vector<int> scale_B_Xe, scale_B_Ar, scale_EA_Xe, scale_EA_Ar, scale_EC_Xe, scale_EC_Ar;
200
201 scale_hHitWMap.clear();
202 scale_hHitWMap_B.clear();
203 scale_hHitWMap_EA.clear();
204 scale_hHitWMap_EC.clear();
205 scale_B_Xe.clear();
206 scale_B_Ar.clear();
207 scale_EA_Xe.clear();
208 scale_EA_Ar.clear();
209 scale_EC_Xe.clear();
210 scale_EC_Ar.clear();
211
212 for (int i = 0; i < s_Straw_max[0]; i++) {
213 float countAr = 0;
214 float countXe = 0;
215 int sN, sLN, lN;
216 strawNumber_reverse(i, &sN, &sLN, &lN);
217
218 for (int side = -1 ; side < 2; side += 2 ) {
219 for (int j = 0; j < 32; j++ ) {
220 Identifier Dummy_Identifier;
221 Dummy_Identifier = m_pTRTHelper->straw_id(side, j, lN, sLN, sN);
222 bool isArgonStraw = (Straw_Gastype( m_sumTool->getStatusHT(Dummy_Identifier, ctx) ) == GasType::Ar);
223
224 if (isArgonStraw)
225 countAr += 1.0;
226 else
227 countXe += 1.0;
228 }
229 }
230 scale_B_Xe.push_back(countXe);
231 scale_B_Ar.push_back(countAr);
232 }
233
234 for (int i = 0; i < s_Straw_max[1]; i++) {
235 scale_EA_Xe.push_back(32);
236 scale_EA_Ar.push_back(32);
237 scale_EC_Xe.push_back(32);
238 scale_EC_Ar.push_back(32);
239 }
240
241 scale_hHitWMap_B.push_back(std::move(scale_B_Xe));
242 scale_hHitWMap_B.push_back(std::move(scale_B_Ar));
243 scale_hHitWMap_EA.push_back(std::move(scale_EA_Xe));
244 scale_hHitWMap_EA.push_back(std::move(scale_EA_Ar));
245 scale_hHitWMap_EC.push_back(std::move(scale_EC_Xe));
246 scale_hHitWMap_EC.push_back(std::move(scale_EC_Ar));
247 scale_hHitWMap.push_back(std::move(scale_hHitWMap_B));
248 scale_hHitWMap.push_back(std::move(scale_hHitWMap_EA));
249 scale_hHitWMap.push_back(std::move(scale_hHitWMap_EC));
250
251// m_flagforscale = 0;
252 return scale_hHitWMap;
253}
254
255
256//-------------------------------------------------------------------------------------------------//
258//-------------------------------------------------------------------------------------------------//
259 StatusCode sc = StatusCode::SUCCESS;
260
261 auto ChipBSErrorsVsLB_x = Monitored::Scalar<float>("ChipBSErrorsVsLB_x", 0.0);
262 auto ChipBSErrorsVsLB_y = Monitored::Scalar<float>("ChipBSErrorsVsLB_y", 0.0);
263 auto RobBSErrorsVsLB_x = Monitored::Scalar<float>("RobBSErrorsVsLB_x", 0.0);
264 auto RobBSErrorsVsLB_y = Monitored::Scalar<float>("RobBSErrorsVsLB_y", 0.0);
265
266 const TRT_BSErrContainer emptyErrCont;//Empty dummy instance for MC
267 const TRT_BSErrContainer* bsErrCont=&emptyErrCont;
268
269 if (!m_bsErrContKey.empty()) {
270 //Regular real-data case, get the byte-stream errors from SG
272 bsErrCont=bsErrContHdl.cptr();
273 }
274 else {
275 ATH_MSG_DEBUG("MC case, using dummy TRT_BSErrContainer");
276 }
277
278 const unsigned int lumiBlock = eventInfo.lumiBlock();
279 ATH_MSG_VERBOSE("This is lumiblock : " << lumiBlock);
280
281 //if ((int)lumiBlock != m_lastLumiBlock) {
282 // m_lastLumiBlock = lumiBlock;
283 //}
284
285 //Get BSConversion errors
286 const std::set<std::pair<uint32_t, uint32_t> > &L1IDErrorSet = bsErrCont->getL1ErrorSet();
287 const std::set<std::pair<uint32_t, uint32_t> > &BCIDErrorSet = bsErrCont->getBCIDErrorSet();
288 const std::set<uint32_t> &MissingErrorSet = bsErrCont->getMissingErrorSet();
289 const std::set<uint32_t> &SidErrorSet = bsErrCont->getSidErrorSet();
290 const std::set<std::pair<uint32_t, uint32_t> > &RobStatusErrorSet = bsErrCont->getRobErrorSet();
291
292 const unsigned int rod_id_base[2][2] = { { 0x310000, 0x320000 }, { 0x330000, 0x340000 } };
293 const unsigned int nChipsTotal[2][2] = { { 3328, 3328 }, { 7680, 7680 } };
294 const unsigned int nRobsTotal[2][2] = { { 32, 32 }, { 64, 64 } };
295 float nBSErrors[2][2] = { { 0, 0 }, { 0, 0 } };
296 float nRobErrors[2][2] = { { 0, 0 }, { 0, 0 } };
297
298 const std::set<std::pair<uint32_t, uint32_t> > *errorset1[2] = { &BCIDErrorSet, &L1IDErrorSet };
299
300 for (int iset = 0; iset < 2; ++iset) {
301 for (auto setIt = errorset1[iset]->begin(); setIt != errorset1[iset]->end(); ++setIt) {
302 for (int ibe = 0; ibe < 2; ++ibe) {
303 for (int iside = 0; iside < 2; ++iside) {
304 if (((setIt->first >> 8) & 0xFF0000) == rod_id_base[ibe][iside]) {
305 nBSErrors[ibe][iside] += 1. / nChipsTotal[ibe][iside];
306 }
307 }
308 }
309 }
310 }
311
312 const std::set<uint32_t> *errorset2[2] = { &MissingErrorSet, &SidErrorSet };
313
314 for (int iset = 0; iset < 2; ++iset) {
315 for (auto setIt = errorset2[iset]->begin(); setIt != errorset2[iset]->end(); ++setIt) {
316 for (int ibe = 0; ibe < 2; ++ibe) {
317 for (int iside = 0; iside < 2; ++iside) {
318 if (((*setIt >> 8) & 0xFF0000) == rod_id_base[ibe][iside]) {
319 nBSErrors[ibe][iside] += 1. / nChipsTotal[ibe][iside];
320 }
321 }
322 }
323 }
324 }
325
326 for (int ibe = 0; ibe < 2; ++ibe) {
327 for (int iside = 0; iside < 2; ++iside) {
328 ChipBSErrorsVsLB_x = lumiBlock;
329 ChipBSErrorsVsLB_y = nBSErrors[ibe][iside];
330 for (unsigned int i = 0; i < lumiBlock; i++) // we need this so the LastBinThreshold algorithm can find the last bin
331 fill(std::format("RDOShiftSmryRebinnedHistograms{}{}", ibe, iside), ChipBSErrorsVsLB_x, ChipBSErrorsVsLB_y);
332 }
333 }
334
335 for (auto setIt = RobStatusErrorSet.begin(); setIt != RobStatusErrorSet.end(); ++setIt) {
336 for (int ibe = 0; ibe < 2; ++ibe) {
337 for (int iside = 0; iside < 2; ++iside) {
338 if (setIt->first % rod_id_base[ibe][iside] < 0xffff) {
339 nRobErrors[ibe][iside] += 1. / nRobsTotal[ibe][iside];
340 }
341 }
342 }
343 }
344
345 for (int ibe = 0; ibe < 2; ++ibe) {
346 for (int iside = 0; iside < 2; ++iside) {
347 RobBSErrorsVsLB_x = lumiBlock;
348 RobBSErrorsVsLB_y = nRobErrors[ibe][iside];
349 for (unsigned int i = 0; i < lumiBlock; i++) // we need this so the LastBinThreshold algorithm can find the last bin
350 fill(std::format("RDOShiftSmryRebinnedHistograms{}{}", ibe, iside), RobBSErrorsVsLB_x, RobBSErrorsVsLB_y);
351 }
352 }
353
354 return sc;
355}
356
357
358//----------------------------------------------------------------------------------//
360//----------------------------------------------------------------------------------//
361 // return logical board index:
362 // 0 for Board 1S (has 10 chips) 0 - 9
363 // 1 for 1L (11) 10 - 20
364 // 2 for 2S (15) 21 - 35
365 // 3 for 2L, first 9 chips 36 - 44
366 // 4 for 2L, second 9 chips 45 - 53
367 // 5 for 3S, first 11 54 - 64
368 // 6 for 3S, second 12 65 - 76
369 // 7 for 3L, first 13 77 - 89
370 // 8 for 3L, second 14 90 - 103
371 const int list[] = {10, 11, 15, 9, 9, 11, 12, 13, 14};
372 int count = 0;
373 chip--;
374
375 for (int i = 0; i < 9; i++) {
376 count += list[i];
377
378 if (chip < count) return i + 1;
379 else if (chip == 104) return 9;
380 }
381
382 assert(count == 104);
383 assert(false); // should never come this far
384 return -1;
385}
386
387
388//----------------------------------------------------------------------------------//
390//----------------------------------------------------------------------------------//
391 const int remainder = (chip - 1) % 12;
392 const int Board = int(((chip - 1) - remainder) / 12);
393 return Board + 1;
394}
395
396
397
398// Check for EventBurst: Counts high level hits and returns true if the count is less than m_passEventBurstCut.
399// If m_EventBurstCut is less than zero, returns allways true
400//----------------------------------------------------------------------------------//
402//----------------------------------------------------------------------------------//
403 if (m_EventBurstCut <= 0) return true;
404
405 int nHLHits = 0;
406 TRT_RDO_Container::const_iterator RDO_CollectionBegin = rdoContainer.begin();
407 TRT_RDO_Container::const_iterator RDO_CollectionEnd = rdoContainer.end();
408
409 for (; RDO_CollectionBegin != RDO_CollectionEnd; ++RDO_CollectionBegin) {
410 const InDetRawDataCollection<TRT_RDORawData> *TRT_Collection(*RDO_CollectionBegin);
411
412 if (!TRT_Collection) continue;
413 else {
414 DataVector<TRT_RDORawData>::const_iterator p_rdo = TRT_Collection->begin();
415
416 for (; p_rdo != TRT_Collection->end(); ++p_rdo) {
417 const TRT_LoLumRawData *p_lolum = dynamic_cast<const TRT_LoLumRawData *>(*p_rdo);
418
419 if (!p_lolum) continue;
420
421 if (p_lolum->highLevel()) nHLHits++;
422 }
423 }
424 }
425
426 if (nHLHits > m_EventBurstCut) return false;
427 else return true;
428}
429
430
431
432// Returns the straw number (0-1641) given the layerNumber, strawlayerNumber, and strawNumber, all gotten from Athena IDHelper
433//----------------------------------------------------------------------------------//
434int TRTMonitoringRun3RAW_Alg::strawNumber(int strawNumber, int strawlayerNumber, int LayerNumber) const {
435//----------------------------------------------------------------------------------//
436 int addToStrawNumber = 0;
437 int addToStrawNumberNext = 0;
438 int i = 0;
439 const int numberOfStraws[75] = {
440 0,
441 15,
442 16, 16, 16, 16,
443 17, 17, 17, 17, 17,
444 18, 18, 18, 18, 18,
445 19, 19, 19,
446 18,
447 19,
448 20, 20, 20, 20, 20,
449 21, 21, 21, 21, 21,
450 22, 22, 22, 22, 22,
451 23, 23, 23, 23, 23,
452 24, 24,
453 23, 23,
454 24, 24, 24, 24,
455 25, 25, 25, 25, 25,
456 26, 26, 26, 26, 26,
457 27, 27, 27, 27, 27,
458 28, 28, 28, 28, 28,
459 29, 29, 29, 29,
460 28,
461 0
462 };
463
464 do {
465 i++;
466 addToStrawNumber += numberOfStraws[i - 1];
467 addToStrawNumberNext = addToStrawNumber + numberOfStraws[i];
468 } while (strawLayerNumber(strawlayerNumber, LayerNumber) != i - 1);
469
470 strawNumber = addToStrawNumberNext - strawNumber - 1;
471
472 if (strawNumber < 0 || strawNumber > s_Straw_max[0] - 1) {
473 ATH_MSG_WARNING("strawNumber = " << strawNumber << " out of range. Will set to 0.");
474 strawNumber = 0;
475 }
476
477 return strawNumber;
478}
479
480//----------------------------------------------------------------------------------//
481int TRTMonitoringRun3RAW_Alg::strawNumber_reverse (int inp_strawnumber, int *strawNumber, int *strawlayerNumber, int *LayerNumber) const {
482//----------------------------------------------------------------------------------//
483 const int numberOfStraws[75] = {
484 0,
485 15,
486 16, 16, 16, 16,
487 17, 17, 17, 17, 17,
488 18, 18, 18, 18, 18,
489 19, 19, 19,
490 18,
491 19,
492 20, 20, 20, 20, 20,
493 21, 21, 21, 21, 21,
494 22, 22, 22, 22, 22,
495 23, 23, 23, 23, 23,
496 24, 24,
497 23, 23,
498 24, 24, 24, 24,
499 25, 25, 25, 25, 25,
500 26, 26, 26, 26, 26,
501 27, 27, 27, 27, 27,
502 28, 28, 28, 28, 28,
503 29, 29, 29, 29,
504 28,
505 0
506 };
507 //ToDo check inp_strawnumber
508 int i = 1;
509
510 for (i = 1; inp_strawnumber >= 0; i++) {
511 inp_strawnumber -= numberOfStraws[i];
512 }
513
514 i -= 2;
515 strawLayerNumber_reverse(i, strawlayerNumber, LayerNumber);
516 *strawNumber = -inp_strawnumber - 1;
517 return 0;
518}
519
520//----------------------------------------------------------------------------------//
521int TRTMonitoringRun3RAW_Alg::strawNumberEndCap(int strawNumber, int strawLayerNumber, int LayerNumber, int phi_stack, int side) const {
522//----------------------------------------------------------------------------------//
523 // Before perfoming map, corrections need to be perfomed.
524 // apply special rotations for endcap mappings
525 // for eca, rotate triplets by 180 for stacks 9-16, and 25-32.
526 static const int TripletOrientation[2][32] = {
527 {
528 1, 1, 1, 1, 1, 1, 1, 1,
529 0, 0, 0, 0, 0, 0, 0, 0,
530 1, 1, 1, 1, 1, 1, 1, 1,
531 0, 0, 0, 0, 0, 0, 0, 0
532 },
533 {
534 1, 1, 1, 1, 1, 1, 1, 1,
535 0, 0, 0, 0, 0, 0, 0, 0,
536 1, 1, 1, 1, 1, 1, 1, 1,
537 0, 0, 0, 0, 0, 0, 0, 0
538 }
539 };
540 int phi1 = -1;
541
542 if (side == 2) phi1 = phi_stack, side = 1;
543 else if (side == -2) phi1 = 31 - phi_stack, side = 0;
544
545 if (phi1 > -1) {
546 if (TripletOrientation[side][phi1]) {
547 //Change straw number from 0-23 in straw layer to 0-192
549
551
552 strawNumber = (192 - 1) * TripletOrientation[side][phi1] + strawNumber * (1 - 2 * TripletOrientation[side][phi1]); //actual rotation
553
554 //take strawNumber back to 0-23
555 if (strawLayerNumber < 8) strawLayerNumber = int(strawNumber / 24);
556
557 if (strawLayerNumber > 7) strawLayerNumber = int(strawNumber / 24) + 8;
558
560 }
561
562 //Finish rotation
563 //Flip straw in layer.
564
565 if (side == 0) strawNumber = 23 - strawNumber;
566
567 //Finish Flipping
568 }
569
570 // Done with corrections
571 // Start mapping from athena identifiers to TRTViewer maps
572 int strawNumberNew = 0;
573
574 if (LayerNumber < 6 && strawLayerNumber > 7) {
575 strawNumberNew = strawNumberNew + (384 * LayerNumber);
576 strawNumberNew = strawNumberNew + 192 + (strawLayerNumber % 8) + (strawNumber * 8);
577 } else if (LayerNumber < 6 && strawLayerNumber < 8) {
578 strawNumberNew = strawNumberNew + (384 * LayerNumber);
579 strawNumberNew = strawNumberNew + (strawLayerNumber % 8) + (strawNumber * 8);
580 } else if (LayerNumber > 5 && strawLayerNumber > 7) {
581 strawNumberNew = strawNumberNew + 2304 + 192 * (LayerNumber - 6);
582 strawNumberNew = strawNumberNew + 192 + (strawLayerNumber % 8) + (8 * strawNumber);
583 } else if (LayerNumber > 5 && strawLayerNumber < 8) {
584 strawNumberNew = strawNumberNew + 2304 + 192 * (LayerNumber - 6);
585 strawNumberNew = strawNumberNew + (strawLayerNumber % 8) + (8 * strawNumber);
586 }
587
588 strawNumber = strawNumberNew;
589
590 if (strawNumber < 0 || strawNumber > s_Straw_max[1] - 1) {
591 ATH_MSG_WARNING("strawNumber = " << strawNumber << " out of range. Will set to 0.");
592 strawNumber = 0;
593 }
594
595 return strawNumber;
596}
597
598
599//----------------------------------------------------------------------------------//
601//----------------------------------------------------------------------------------//
602 switch (LayerNumber) {
603 case 0:
604 return strawLayerNumber;
605
606 case 1:
607 return strawLayerNumber + 19;
608
609 case 2:
610 return strawLayerNumber + 43;
611
612 default:
613 return strawLayerNumber;
614 }
615}
616
617//----------------------------------------------------------------------------------//
618int TRTMonitoringRun3RAW_Alg::strawLayerNumber_reverse(int strawLayerNumInp, int *strawLayerNumber, int *LayerNumber) const {
619//----------------------------------------------------------------------------------//
620 //Danger? There are no checks on input
621 //use with care
622 if (strawLayerNumInp < 19) {
623 *strawLayerNumber = strawLayerNumInp;
624 *LayerNumber = 0;
625 } else if (strawLayerNumInp < 43) {
626 *strawLayerNumber = strawLayerNumInp - 19;
627 *LayerNumber = 1;
628 } else {
629 *strawLayerNumber = strawLayerNumInp - 43;
630 *LayerNumber = 2;
631 }
632
633 return 0;
634}
635
636//----------------------------------------------------------------------------------//
637float TRTMonitoringRun3RAW_Alg::radToDegrees(float radValue) const{
638//----------------------------------------------------------------------------------//
639 float degreeValue = radValue / M_PI * 180;
640
641 if (degreeValue < 0) degreeValue += 360;
642
643 return degreeValue;
644}
645
654
665
679
693
700
701//Fill the TRT RDO Histograms
702//----------------------------------------------------------------------------------//
703StatusCode TRTMonitoringRun3RAW_Alg::fillTRTRDOs(const EventContext& ctx,
704 const TRT_RDO_Container& rdoContainer,
705 const xAOD::EventInfo& eventInfo,
706 const InDetTimeCollection* trtBCIDCollection) const {
707//----------------------------------------------------------------------------------//
708 ATH_MSG_DEBUG("Filling TRT RDO Histograms");
709
710 // TProfile
711 auto HitToTLongTrMapS_x = Monitored::Scalar<float>("HitToTLongTrMapS_x", 0.0);
712 auto HitToTLongTrMapS_y = Monitored::Scalar<float>("HitToTLongTrMapS_y", 0.0);
713 auto HitToTLongMapS_x = Monitored::Scalar<float>("HitToTLongMapS_x", 0.0);
714 auto HitToTLongMapS_y = Monitored::Scalar<float>("HitToTLongMapS_y", 0.0);
715 auto BCIDvsOcc_x = Monitored::Scalar<float>("BCIDvsOcc_x", 0.0);
716 auto BCIDvsOcc_y = Monitored::Scalar<float>("BCIDvsOcc_y", 0.0);
717 auto AvgHLOcc_side_x = Monitored::Scalar<float>("AvgHLOcc_side_x", 0.0);
718 auto AvgHLOcc_side_y = Monitored::Scalar<float>("AvgHLOcc_side_y", 0.0);
719 auto AvgLLOcc_side_x = Monitored::Scalar<float>("AvgLLOcc_side_x", 0.0);
720 auto AvgLLOcc_side_y = Monitored::Scalar<float>("AvgLLOcc_side_y", 0.0);
721 auto AvgLLOccMod_side_x = Monitored::Scalar<float>("AvgLLOccMod_side_x", 0.0);
722 auto AvgLLOccMod_side_y = Monitored::Scalar<float>("AvgLLOccMod_side_y", 0.0);
723 auto AvgHLOccMod_side_x = Monitored::Scalar<float>("AvgHLOccMod_side_x", 0.0);
724 auto AvgHLOccMod_side_y = Monitored::Scalar<float>("AvgHLOccMod_side_y", 0.0);
725 auto ChipBSErrorsVsLB_x = Monitored::Scalar<float>("ChipBSErrorsVsLB_x", 0.0);
726 auto ChipBSErrorsVsLB_y = Monitored::Scalar<float>("ChipBSErrorsVsLB_y", 0.0);
727 auto RobBSErrorsVsLB_x = Monitored::Scalar<float>("RobBSErrorsVsLB_x", 0.0);
728 auto RobBSErrorsVsLB_y = Monitored::Scalar<float>("RobBSErrorsVsLB_y", 0.0);
729 auto NHitsperLB_x = Monitored::Scalar<float>("NHitsperLB_x", 0.0);
730 auto NHitsperLB_y = Monitored::Scalar<float>("NHitsperLB_y", 0.0);
731 auto NHLHitsperLB_x = Monitored::Scalar<float>("NHLHitsperLB_x", 0.0);
732 auto NHLHitsperLB_y = Monitored::Scalar<float>("NHLHitsperLB_y", 0.0);
733
734 // TH1F
735 auto OccAll = Monitored::Scalar<float>("OccAll", 0.0);
736
737 // TH2F
738
739 // TEfficiency
740 auto HtoLMapS = Monitored::Scalar<float>("HtoLMapS", 0.0);
741 auto HtoLMapS_passed = Monitored::Scalar<bool>("HtoLMapS_passed", false);
742 auto HtoLMapC = Monitored::Scalar<float>("HtoLMapC", 0.0);
743 auto HtoLMapC_passed = Monitored::Scalar<bool>("HtoLMapC_passed", false);
744 auto OccupancyC = Monitored::Scalar<float>("OccupancyC", 0.0);
745 auto OccupancyC_passed = Monitored::Scalar<bool>("OccupancyC_passed", false);
746 auto StrawOcc = Monitored::Scalar<float>("StrawOcc", 0.0);
747 auto StrawOcc_passed = Monitored::Scalar<bool>("StrawOcc_passed", false);
748
749 const unsigned int lumiBlock = eventInfo.lumiBlock();
750 ATH_MSG_VERBOSE("This is lumiblock : " << lumiBlock);
751 auto good_bcid = eventInfo.bcid();
752
753 TRT_RDO_Container::const_iterator RDO_CollectionBegin = rdoContainer.begin();
754 TRT_RDO_Container::const_iterator RDO_CollectionEnd = rdoContainer.end();
755 //Check readout Integrity of TRT
757 int numberOfStacks_b[2]; //Total stack number of barrel and endcap
758 numberOfStacks_b[0] = s_numberOfBarrelStacks * 3;
759 numberOfStacks_b[1] = s_numberOfEndCapStacks * 2;
760 Identifier TRT_Identifier;
761 int numberOfStrawsMod[3]; // For barrel(number if straw in module)
762 numberOfStrawsMod[0] = 329;
763 numberOfStrawsMod[1] = 520;
764 numberOfStrawsMod[2] = 793;
765 int numberOfStrawsWheel[2]; // For endcap
766 numberOfStrawsWheel[0] = 2304; //6 layers (6*16=96) 96*24=2304 straws in wheel type A
767 numberOfStrawsWheel[1] = 1536; //8 layers (8*8=64) 64*24=1536 straws in wheel type B
768 int moduleHits_B[192];
769 int moduleHits_E[128];
770 int HLmoduleHits_B[192];
771 int HLmoduleHits_E[128];
772 int nHitsperLB_B = 0;
773 int nHLHitsperLB_B = 0;
774 int nHitsperLB_E[2] = {0, 0};
775 int nHLHitsperLB_E[2] = {0, 0};
776
777 for (int i = 0; i < 192; i++) {
778 moduleHits_B[i] = 0;
779 HLmoduleHits_B[i] = 0;
780 }
781
782 for (int i = 0; i < 128; i++) {
783 moduleHits_E[i] = 0;
784 HLmoduleHits_E[i] = 0;
785 }
786
787 auto scale_hHitWMap_B_passed = std::make_unique<short int[][s_Straw_max[0]]>(2);
788 auto scale_hHitWMap_E_passed = std::make_unique<short int[][2][s_Straw_max[1]]>(2);
789
790 auto scale_hHitHWMapS_B_passed = std::make_unique<short int[][s_Straw_max[0]]>(s_numberOfBarrelStacks*2);
791 auto scale_hHitHWMapC_B_passed = std::make_unique<short int[][s_iChip_max[0]]>(s_numberOfBarrelStacks*2);
792 auto scale_hHitWMapS_B_passed = std::make_unique<short int[][s_Straw_max[0]]>(s_numberOfBarrelStacks*2);
793 auto scale_hHitWMapC_B_passed = std::make_unique<short int[][s_iChip_max[0]]>(s_numberOfBarrelStacks*2);
794 auto scale_hHitAMapS_B_passed = std::make_unique<short int[][s_Straw_max[0]]>(s_numberOfBarrelStacks*2);
795 auto scale_hHitAMapC_B_passed = std::make_unique<short int[][s_iChip_max[0]]>(s_numberOfBarrelStacks*2);
796 auto scale_hHitAWMapS_B_passed = std::make_unique<short int[][s_Straw_max[0]]>(s_numberOfBarrelStacks*2);
797 auto scale_hHitAWMapC_B_passed = std::make_unique<short int[][s_iChip_max[0]]>(s_numberOfBarrelStacks*2);
798 auto scale_hHitHMapS_B_passed = std::make_unique<short int[][s_Straw_max[0]]>(s_numberOfBarrelStacks*2);
799 auto scale_hHitHMapC_B_passed = std::make_unique<short int[][s_iChip_max[0]]>(s_numberOfBarrelStacks*2);
800
801 auto scale_hHitHWMapS_E_passed = std::make_unique<short int[][s_Straw_max[1]]>(s_numberOfEndCapStacks*2);
802 auto scale_hHitHWMapC_E_passed = std::make_unique<short int[][s_iChip_max[1]]>(s_numberOfEndCapStacks*2);
803 auto scale_hHitWMapS_E_passed = std::make_unique<short int[][s_Straw_max[1]]>(s_numberOfEndCapStacks*2);
804 auto scale_hHitWMapC_E_passed = std::make_unique<short int[][s_iChip_max[1]]>(s_numberOfEndCapStacks*2);
805 auto scale_hHitAMapS_E_passed = std::make_unique<short int[][s_Straw_max[1]]>(s_numberOfEndCapStacks*2);
806 auto scale_hHitAMapC_E_passed = std::make_unique<short int[][s_iChip_max[1]]>(s_numberOfEndCapStacks*2);
807 auto scale_hHitAWMapS_E_passed = std::make_unique<short int[][s_Straw_max[1]]>(s_numberOfEndCapStacks*2);
808 auto scale_hHitAWMapC_E_passed = std::make_unique<short int[][s_iChip_max[1]]>(s_numberOfEndCapStacks*2);
809 auto scale_hHitHMapS_E_passed = std::make_unique<short int[][s_Straw_max[1]]>(s_numberOfEndCapStacks*2);
810 auto scale_hHitHMapC_E_passed = std::make_unique<short int[][s_iChip_max[1]]>(s_numberOfEndCapStacks*2);
811
812 int goodid_status = 0;
813 int prev_bcid = 0;
814
815 if (trtBCIDCollection) {
816 InDetTimeCollection::const_iterator itrt_bcid = trtBCIDCollection->begin();
817
818 while (goodid_status == 0 && itrt_bcid != trtBCIDCollection->end()) {
819
820 const unsigned int trt_bcid = (*itrt_bcid).second;
821
822 if (itrt_bcid > trtBCIDCollection->begin() && prev_bcid - trt_bcid == 0) {
823 goodid_status = 1;
824 } else if (itrt_bcid > trtBCIDCollection->begin() && prev_bcid - trt_bcid != 0) {
825 ATH_MSG_WARNING("TRT BCID is not consistent. TRT RODID is " <<
826 std::hex << (*itrt_bcid).first << " trt bcid from ROD is " <<
827 std::hex << trt_bcid);
828 }
829
830 prev_bcid = trt_bcid;
831 ++itrt_bcid;
832 }
833 }
834
835 // Test out the TRT_StrawStatusSummarySvc.
836 if (!m_sumTool.name().empty() && m_doExpert) {
837 ATH_MSG_VERBOSE("Trying " << m_sumTool << " isGood");
838 ATH_MSG_VERBOSE("TRT_StrawStatusTool reports status = " << m_sumTool->getStatus(TRT_Identifier, ctx));
839 }
840
841 // ibe = 0 (Barrel), ibe = 1 (Endcap)
842 int nTRTHits[2];
843 for (int ibe = 0; ibe < 2; ibe++) {
844 nTRTHits[ibe] = 0;
845
846 // Insert here
847 // Scaling for online environment
848
849 }
850
851 int nhitsall = 0;
852
853 std::map<int,std::map<int, std::vector<straw_struct>>> straw_map;
854 std::map<int,std::map<int, std::vector<chip_struct>>> chip_map;
855 std::map<int,std::vector<straw_shifter_struct>> straw_shifter_map;
856 std::map<int,std::map<int, std::vector<straw_struct_prob>>> straw_map_prob;
857 std::map<int,std::map<int, std::vector<chip_struct_prob>>> chip_map_prob;
858
859 std::vector<std::vector<std::vector<int>>> scale_hHitWMap = initScaleVectors(ctx);
860
861 for (; RDO_CollectionBegin != RDO_CollectionEnd; ++RDO_CollectionBegin) {
862 const InDetRawDataCollection<TRT_RDORawData> *TRT_Collection(*RDO_CollectionBegin);
863
864 if (!TRT_Collection) continue;
865
866 DataVector<TRT_RDORawData>::const_iterator p_rdo = TRT_Collection->begin();
867
868 for (; p_rdo != TRT_Collection->end(); ++p_rdo) {
869 int middleHTbit = (*p_rdo)->getWord() & 0x00020000;
870 //0x00020000 = 0000 0000 0000 0000 0000 0010 0000 0000 0000 0000
871 int hitinvaliditygate = (*p_rdo)->getWord() & 0x000DFE80;
872 //0x000DFE80 = 0000 0000 0000 0000 0000 1101 1111 1110 1000 0000 //
873 bool is_middleHTbit_high = (middleHTbit != 0);
874 bool is_anybininVgate_high = (hitinvaliditygate != 0);
875 TRT_Identifier = (*p_rdo)->identify();
876
877 if (m_doMaskStraws && m_sumTool->get_status(TRT_Identifier, ctx)) continue;
878
879 int barrel_ec = m_pTRTHelper->barrel_ec(TRT_Identifier);
880 //ToDo: Check TRT_LoLumRawData object
881 const TRT_LoLumRawData *p_lolum = dynamic_cast<const TRT_LoLumRawData *>(*p_rdo);
882
883 if (!p_lolum) continue;
884
885 nhitsall++;
886 int ibe = abs(barrel_ec) - 1;
887 int iside = barrel_ec > 0 ? 0 : 1;
888
889 //if barrel_ec is outof range go to next measurement in rdo_collection
890 if (ibe != 1 && ibe != 0) {
891 ATH_MSG_DEBUG("TRT part retrieved from TRT Identifier is not a barrel or an endcap");
892 continue;
893 }
894
895 int moduleNumber_barrel1[2];
896 int moduleNumber_barrel2[2];
897 int moduleNumber_barrel3[2];
898 int moduleNumber_endcapA[2];
899 int moduleNumber_endcapB[2];
900 // Get TRT Identifier
901 // Need to know phi module, module layer, straw layer, and straw # within the layer
902 // To get proper straw numbering
903 TRT_Identifier = p_lolum->identify();
904 //inline function checks m_ArgonXenonSplitter
905 const bool isArgonStraw = (Straw_Gastype( m_sumTool->getStatusHT(TRT_Identifier, ctx) ) == GasType::Ar);
906 int phi_module = m_pTRTHelper->phi_module(TRT_Identifier);
907 int layer_or_wheel = m_pTRTHelper->layer_or_wheel(TRT_Identifier);
908 int straw_layer = m_pTRTHelper->straw_layer(TRT_Identifier);
909 int straw = m_pTRTHelper->straw(TRT_Identifier);
910 int thisStrawNumber;
911 int chip = 0;
912 int board = -1;
913 //ToDo: Check if that is really neccessary
914 bool is_barrel = m_pTRTHelper->is_barrel(TRT_Identifier);
915
916 //Сheck straw number and find the correct chip and m_ board values
917 if ( is_barrel && ibe == 0 ) {
918 thisStrawNumber = strawNumber(straw, straw_layer, layer_or_wheel);
919
920 if (thisStrawNumber >= 0 && thisStrawNumber < s_Straw_max[ibe]) {
921 chip = m_mat_chip_B.at(phi_module).at(thisStrawNumber);
922 }
923
924 board = chipToBoard(chip);
925
926 } else if ( !is_barrel && ibe == 1 ) {
927 thisStrawNumber = strawNumberEndCap(straw, straw_layer, layer_or_wheel, phi_module, barrel_ec);
928
929 if (thisStrawNumber >= 0 && thisStrawNumber < s_Straw_max[ibe]) {
930 chip = m_mat_chip_E.at(phi_module).at(thisStrawNumber);
931 }
932
933 board = chipToBoard_EndCap(chip);
934 } else {
935 thisStrawNumber = -1;
936 }
937
938 if (thisStrawNumber < 0 || thisStrawNumber >= s_Straw_max[ibe]) {
939 ATH_MSG_WARNING("Found m_strawNumber = " << thisStrawNumber << " out of range.");
940 continue;
941 }
942 const int driftTimeBin = p_lolum->driftTimeBin();
943 const int trailingEdge = p_lolum->trailingEdge();
944 const bool highlevel = is_middleHTbit_high; //Hardcoded Middle Bit
945 const bool firstBinHigh = p_lolum->firstBinHigh(); // If the first time bin is up then the hit is out of time window
946 const bool lastBinHigh = p_lolum->lastBinHigh(); // If the last bin is up then the hit is out of time window.
947 const float timeOverThreshold = p_lolum->timeOverThreshold();
948 moduleNumber_barrel1[0] = phi_module;
949 moduleNumber_barrel1[1] = phi_module + 96;
950 moduleNumber_barrel2[0] = phi_module + s_numberOfBarrelStacks;
951 moduleNumber_barrel2[1] = phi_module + s_numberOfBarrelStacks + 96;
952 moduleNumber_barrel3[0] = phi_module + 2*s_numberOfBarrelStacks;
953 moduleNumber_barrel3[1] = phi_module + 2*s_numberOfBarrelStacks + 96;
954 moduleNumber_endcapA[0] = phi_module;
955 moduleNumber_endcapA[1] = phi_module + 64;
956 moduleNumber_endcapB[0] = phi_module + s_numberOfEndCapStacks;
957 moduleNumber_endcapB[1] = phi_module + s_numberOfEndCapStacks + 64;
958 int iphi_module = -999;
959
960 if (iside == 0) {
961 iphi_module = phi_module;
962 } else if (iside == 1) {
963 iphi_module = phi_module + 32;
964 }
965
966 if (m_doStraws) {
967 straw_shifter_struct& this_struct = straw_shifter_map[barrel_ec].emplace_back();
968 this_struct.strawNumber = thisStrawNumber;
969 this_struct.isAr = isArgonStraw;
970 this_struct.HitWMap_passed = true;
971 this_struct.HitWMap_Ar_passed = true;
972 if (abs(barrel_ec) == 1) scale_hHitWMap_B_passed[isArgonStraw ? 1 : 0][thisStrawNumber]++;
973 if (abs(barrel_ec) == 2) scale_hHitWMap_E_passed[barrel_ec < 0 ? 1 : 0][isArgonStraw ? 1 : 0][thisStrawNumber]++;
974 }
975
976 nTRTHits[ibe]++;
977 if (ibe == 0) {
978
979 if (m_doShift) {
980 nHitsperLB_B++;
981
982 if (highlevel) {
983 nHLHitsperLB_B++;
984 }
985 }
986 } else if (ibe == 1) {
987 nTRTHits[ibe]++;
988
989 if (m_doShift) {
990 nHitsperLB_E[iside]++;
991
992 if (highlevel) {
993 nHLHitsperLB_E[iside]++;
994 }
995 }
996 }
997
998 if (m_doExpert) {
999 if (m_doStraws) {
1000 straw_struct_prob& this_struct = straw_map_prob[ibe][iphi_module].emplace_back();
1001 this_struct.strawNumber = thisStrawNumber;
1002 this_struct.HitHWMapS_cut = highlevel && is_middleHTbit_high;
1003 this_struct.HitWMapS_cut = (driftTimeBin > 2) && (driftTimeBin < 17);
1004 this_struct.HitAMapS_cut = (firstBinHigh || lastBinHigh || (driftTimeBin > 0) || (trailingEdge < 23));
1005 this_struct.HitAWMapS_cut = is_anybininVgate_high;
1006 this_struct.HitHMapS_cut = highlevel;
1007 this_struct.HitHWMapS_passed = 1.;
1008 this_struct.HitWMapS_passed = 1.;
1009 this_struct.HitAMapS_passed = 1.;
1010 this_struct.HitAWMapS_passed = 1.;
1011 this_struct.HitHMapS_passed = 1.;
1012 if (ibe == 0) {
1013 if (highlevel && is_middleHTbit_high) scale_hHitHWMapS_B_passed[iphi_module][thisStrawNumber]++;
1014 if ((driftTimeBin > 2) && (driftTimeBin < 17)) scale_hHitWMapS_B_passed[iphi_module][thisStrawNumber]++;
1015 if (firstBinHigh || lastBinHigh || (driftTimeBin > 0) || (trailingEdge < 23)) scale_hHitAMapS_B_passed[iphi_module][thisStrawNumber]++;
1016 if (is_anybininVgate_high) scale_hHitAWMapS_B_passed[iphi_module][thisStrawNumber]++;
1017 if (highlevel) scale_hHitHMapS_B_passed[iphi_module][thisStrawNumber]++;
1018 }
1019 if (ibe == 1) {
1020 if (highlevel && is_middleHTbit_high) scale_hHitHWMapS_E_passed[iphi_module][thisStrawNumber]++;
1021 if ((driftTimeBin > 2) && (driftTimeBin < 17)) scale_hHitWMapS_E_passed[iphi_module][thisStrawNumber]++;
1022 if (firstBinHigh || lastBinHigh || (driftTimeBin > 0) || (trailingEdge < 23)) scale_hHitAMapS_E_passed[iphi_module][thisStrawNumber]++;
1023 if (is_anybininVgate_high) scale_hHitAWMapS_E_passed[iphi_module][thisStrawNumber]++;
1024 if (highlevel) scale_hHitHMapS_E_passed[iphi_module][thisStrawNumber]++;
1025 }
1026 }
1027
1028 float trailingEdgeScaled = (trailingEdge + 1)*3.125;
1029
1030 if (m_doStraws) {
1031 straw_struct& this_struct = straw_map[ibe][iphi_module].emplace_back();
1032 this_struct.strawNumber = thisStrawNumber;
1033 this_struct.HitTrMapS_y = trailingEdgeScaled;
1034 this_struct.HitToTMapS_y = timeOverThreshold;
1036 this_struct.HitTrWMapS_y = trailingEdgeScaled;
1037 this_struct.HitTrWMapS_cut = (trailingEdge < 23) && !lastBinHigh && !firstBinHigh;
1038
1039 if (highlevel) {
1040 HtoLMapS = thisStrawNumber;
1041 HtoLMapS_passed = 1.0;
1042 fill("RDOStackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), HtoLMapS_passed, HtoLMapS);
1043 } else {
1044 HtoLMapS = thisStrawNumber;
1045 HtoLMapS_passed = 0.0;
1046 fill("RDOStackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), HtoLMapS_passed, HtoLMapS);
1047 }
1048 }
1049
1050 if (m_doChips) {
1051 chip_struct_prob& this_struct = chip_map_prob[ibe][iphi_module].emplace_back();
1052 this_struct.chipNumber = chip - 1;
1053 this_struct.HitHWMapC_cut = highlevel && is_middleHTbit_high;
1054 this_struct.HitWMapC_cut = (driftTimeBin > 2) && (driftTimeBin < 17);
1055 this_struct.HitAMapC_cut = (firstBinHigh || lastBinHigh || (driftTimeBin > 0) || (trailingEdge < 23));
1056 this_struct.HitAWMapC_cut = is_anybininVgate_high;
1057 this_struct.HitHMapC_cut = highlevel;
1058 this_struct.HitHWMapC_passed = 1.;
1059 this_struct.HitWMapC_passed = 1.;
1060 this_struct.HitAMapC_passed = 1.;
1061 this_struct.HitAWMapC_passed = 1.;
1062 this_struct.HitHMapC_passed = 1.;
1063 if (ibe == 0) {
1064 if (highlevel && is_middleHTbit_high) scale_hHitHWMapC_B_passed[iphi_module][chip - 1]++;
1065 if ((driftTimeBin > 2) && (driftTimeBin < 17)) scale_hHitWMapC_B_passed[iphi_module][chip - 1]++;
1066 if (firstBinHigh || lastBinHigh || (driftTimeBin > 0) || (trailingEdge < 23)) scale_hHitAMapC_B_passed[iphi_module][chip - 1]++;
1067 if (is_anybininVgate_high) scale_hHitAWMapC_B_passed[iphi_module][chip - 1]++;
1068 if (highlevel) scale_hHitHMapC_B_passed[iphi_module][chip - 1]++;
1069 }
1070 if (ibe == 1) {
1071 if (highlevel && is_middleHTbit_high) scale_hHitHWMapC_E_passed[iphi_module][chip - 1]++;
1072 if ((driftTimeBin > 2) && (driftTimeBin < 17)) scale_hHitWMapC_E_passed[iphi_module][chip - 1]++;
1073 if (firstBinHigh || lastBinHigh || (driftTimeBin > 0) || (trailingEdge < 23)) scale_hHitAMapC_E_passed[iphi_module][chip - 1]++;
1074 if (is_anybininVgate_high) scale_hHitAWMapC_E_passed[iphi_module][chip - 1]++;
1075 if (highlevel) scale_hHitHMapC_E_passed[iphi_module][chip - 1]++;
1076 }
1077 }
1078
1079 if (m_doChips) {
1080 chip_struct& this_struct = chip_map[ibe][iphi_module].emplace_back();
1081 this_struct.chipNumber = chip - 1;
1082 this_struct.HitTrMapC_y = trailingEdgeScaled;
1083 this_struct.HitToTMapC_y = timeOverThreshold;
1084 this_struct.HitTrWMapC_cut = (trailingEdge < 23) && !lastBinHigh && !firstBinHigh;
1085 this_struct.HtoBCMap_cut = false;
1086 this_struct.HtoBCMapB_y = board - 1;
1087 this_struct.HtoBCMapC_x = -1;
1088 this_struct.HtoBCMapB_x = -1;
1089 if (p_lolum->highLevel(1)) {
1090 this_struct.HtoBCMapC_x = 0.;
1091 this_struct.HtoBCMapB_x = 0.;
1092 this_struct.HtoBCMap_cut=true;
1093 }
1094
1095 if (p_lolum->highLevel(2)) {
1096 this_struct.HtoBCMapC_x = 1.;
1097 this_struct.HtoBCMapB_x = 1.;
1098 this_struct.HtoBCMap_cut=true;
1099 }
1100
1101 if (p_lolum->highLevel(3)) {
1102 this_struct.HtoBCMapC_x = 2.;
1103 this_struct.HtoBCMapB_x = 2.;
1104 this_struct.HtoBCMap_cut=true;
1105 }
1106
1107 if (highlevel) {
1108 HtoLMapC = chip - 1;
1109 HtoLMapC_passed = 1.0;
1110 fill("RDOStackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), HtoLMapC_passed, HtoLMapC);
1111 } else {
1112 HtoLMapC = chip - 1;
1113 HtoLMapC_passed = 0.0;
1114 fill("RDOStackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), HtoLMapC_passed, HtoLMapC);
1115 }
1116 }
1117 }
1118
1119 //Set Module Numbers.
1120 int moduleNumber = -1;
1121
1122 if (ibe == 0) {
1123 if (layer_or_wheel == 0) {
1124 moduleNumber = moduleNumber_barrel1[iside];
1125 moduleHits_B[moduleNumber]++;
1126 } else if (layer_or_wheel == 1) {
1127 moduleNumber = moduleNumber_barrel2[iside];
1128 moduleHits_B[moduleNumber]++;
1129 } else if (layer_or_wheel == 2) {
1130 moduleNumber = moduleNumber_barrel3[iside];
1131 moduleHits_B[moduleNumber]++;
1132 }
1133
1134 if (highlevel) {
1135 if (layer_or_wheel == 0) {
1136 moduleNumber = moduleNumber_barrel1[iside];
1137 HLmoduleHits_B[moduleNumber]++;
1138 } else if (layer_or_wheel == 1) {
1139 moduleNumber = moduleNumber_barrel2[iside];
1140 HLmoduleHits_B[moduleNumber]++;
1141 } else if (layer_or_wheel == 2) {
1142 moduleNumber = moduleNumber_barrel3[iside];
1143 HLmoduleHits_B[moduleNumber]++;
1144 }
1145 }
1146 } else if (ibe == 1) {
1147 if (layer_or_wheel < 6) {
1148 moduleNumber = moduleNumber_endcapA[iside];
1149 moduleHits_E[moduleNumber]++;
1150 } else if (layer_or_wheel > 5) {
1151 moduleNumber = moduleNumber_endcapB[iside];
1152 moduleHits_E[moduleNumber]++;
1153 }
1154
1155 if (highlevel) {
1156 if (layer_or_wheel < 6) {
1157 moduleNumber = moduleNumber_endcapA[iside];
1158 HLmoduleHits_E[moduleNumber]++;
1159 } else if (layer_or_wheel > 5) {
1160 moduleNumber = moduleNumber_endcapB[iside];
1161 HLmoduleHits_E[moduleNumber]++;
1162 }
1163 }
1164 }
1165 }
1166 }
1167
1168 // Barrel straw normalization
1169 for (int k = 0; k < s_Straw_max[0]; k++) {
1170 for (int iGas = 0; iGas < 2; iGas++) {
1171 try {
1172 if (scale_hHitWMap[0][iGas].at(k) - scale_hHitWMap_B_passed[iGas][k] >= 0) {
1173 for (int j = 0; j < scale_hHitWMap[0][iGas].at(k) - scale_hHitWMap_B_passed[iGas][k]; j++) {
1174 if (m_doStraws) {
1175 straw_shifter_struct& this_struct = straw_shifter_map[1].emplace_back(); // index 1 is Barrel
1176 this_struct.strawNumber = k;
1177 this_struct.isAr = iGas > 0 ? true : false;
1178 this_struct.HitWMap_passed = false;
1179 this_struct.HitWMap_Ar_passed = false;
1180 }
1181 }
1182 } else {
1183 ATH_MSG_ERROR("Scale value " << scale_hHitWMap[0][iGas].at(k) - scale_hHitWMap_B_passed[iGas][k] <<
1184 " is less than zero in scaling for Barrel, iGas = " << iGas << ", k = " << k);
1185 }
1186 } catch (out_of_range &e) {
1187 ATH_MSG_ERROR("Index " << k << " out of range in scaling for Barrel");
1188 }
1189 }
1190 }
1191
1192 // Endcap straw normalization
1193 for (int k = 0; k < s_Straw_max[1]; k++) {
1194 for (int iside = 0; iside < 2; iside++) {
1195 for (int iGas = 0; iGas < 2; iGas++) {
1196 try {
1197 if (scale_hHitWMap[iside + 1][iGas].at(k) - scale_hHitWMap_E_passed[iside][iGas][k] >= 0) {
1198 for (int j = 0; j < scale_hHitWMap[iside + 1][iGas].at(k) - scale_hHitWMap_E_passed[iside][iGas][k]; j++) {
1199 if (m_doStraws) {
1200 straw_shifter_struct& this_struct = straw_shifter_map[iside == 0 ? 2 : -2].emplace_back(); // index 2 is EA, index -2 is EC
1201 this_struct.strawNumber = k;
1202 this_struct.isAr = iGas > 0 ? true : false;
1203 this_struct.HitWMap_passed = false;
1204 this_struct.HitWMap_Ar_passed = false;
1205 }
1206 }
1207 } else {
1208 ATH_MSG_ERROR("Scale value " << scale_hHitWMap[iside + 1][iGas].at(k) - scale_hHitWMap_E_passed[iside][iGas][k] <<
1209 " is less than zero in scaling for Endcap, iside = " << iside << ", iGas = " << iGas << ", k = " << k);
1210 }
1211 } catch (out_of_range &e) {
1212 ATH_MSG_ERROR("Index " << k << " out of range in scaling for Endcap");
1213 }
1214 }
1215 }
1216 }
1217
1218 if (m_doExpert) {
1219 // Barrel straw normalization
1220 for (int k = 0; k < s_Straw_max[0]; k++) {
1221 for (int iside = 0; iside < 2; iside++) {
1222 for (int phi_module = 0; phi_module < s_numberOfBarrelStacks; phi_module++) {
1223 int iphi_module = -999;;
1224 if (iside == 0) iphi_module = phi_module; else if (iside == 1) iphi_module = phi_module + 32;
1225 if (scale_hHitHWMapS_B_passed[iphi_module][k] < 2 || scale_hHitWMapS_B_passed[iphi_module][k] < 2 ||
1226 scale_hHitAMapS_B_passed[iphi_module][k] < 2 || scale_hHitAWMapS_B_passed[iphi_module][k] < 2 ||
1227 scale_hHitHMapS_B_passed[iphi_module][k] < 2) {
1228 for (int l = 0; l < 1 - scale_hHitHWMapS_B_passed[iphi_module][k]; l++){
1229 straw_struct_prob& this_struct = straw_map_prob[0][iphi_module].emplace_back(); // index 0 is Barrel, A and C are splitted by iphi_module
1230 this_struct.strawNumber = k;
1231 this_struct.HitHWMapS_cut = true;
1232 this_struct.HitHWMapS_passed = false;
1233 }
1234 for (int l = 0; l < 1 - scale_hHitWMapS_B_passed[iphi_module][k]; l++){
1235 straw_struct_prob& this_struct = straw_map_prob[0][iphi_module].emplace_back();
1236 this_struct.strawNumber = k;
1237 this_struct.HitWMapS_cut = true;
1238 this_struct.HitWMapS_passed = false;
1239 }
1240 for (int l = 0; l < 1 - scale_hHitAMapS_B_passed[iphi_module][k]; l++){
1241 straw_struct_prob& this_struct = straw_map_prob[0][iphi_module].emplace_back();
1242 this_struct.strawNumber = k;
1243 this_struct.HitAMapS_cut = true;
1244 this_struct.HitAMapS_passed = false;
1245 }
1246 for (int l = 0; l < 1 - scale_hHitAWMapS_B_passed[iphi_module][k]; l++){
1247 straw_struct_prob& this_struct = straw_map_prob[0][iphi_module].emplace_back();
1248 this_struct.strawNumber = k;
1249 this_struct.HitAWMapS_cut = true;
1250 this_struct.HitAWMapS_passed = false;
1251 }
1252 for (int l = 0; l < 1 - scale_hHitHMapS_B_passed[iphi_module][k]; l++){
1253 straw_struct_prob& this_struct = straw_map_prob[0][iphi_module].emplace_back();
1254 this_struct.strawNumber = k;
1255 this_struct.HitHMapS_cut = true;
1256 this_struct.HitHMapS_passed = false;
1257 }
1258 } else{
1259 ATH_MSG_ERROR("Scale value is less than zero in normalization for Barrel straw!");
1260 }
1261 }
1262 }
1263 }
1264
1265 // Barrel chip normalization
1266 for (int k = 0; k < s_iChip_max[0]; k++) {
1267 for (int iside = 0; iside < 2; iside++) {
1268 for (int phi_module = 0; phi_module < s_numberOfBarrelStacks; phi_module++) {
1269 int iphi_module = -999;;
1270 if (iside == 0) iphi_module = phi_module; else if (iside == 1) iphi_module = phi_module + 32;
1271 if (scale_hHitHWMapC_B_passed[iphi_module][k] < 17 || scale_hHitWMapC_B_passed[iphi_module][k] < 17 ||
1272 scale_hHitAMapC_B_passed[iphi_module][k] < 17 || scale_hHitAWMapC_B_passed[iphi_module][k] < 17 ||
1273 scale_hHitHMapC_B_passed[iphi_module][k] < 17) {
1274 for (int l = 0; l < 16*1. - scale_hHitHWMapC_B_passed[iphi_module][k]; l++){
1275 chip_struct_prob& this_struct = chip_map_prob[0][iphi_module].emplace_back(); // index 0 is Barrel, A and C are splitted by iphi_module
1276 this_struct.chipNumber = k;
1277 this_struct.HitHWMapC_cut = true;
1278 this_struct.HitHWMapC_passed = false;
1279 }
1280 for (int l = 0; l < 16*1. - scale_hHitWMapC_B_passed[iphi_module][k]; l++){
1281 chip_struct_prob& this_struct = chip_map_prob[0][iphi_module].emplace_back();
1282 this_struct.chipNumber = k;
1283 this_struct.HitWMapC_cut = true;
1284 this_struct.HitWMapC_passed = false;
1285 }
1286 for (int l = 0; l < 16*1. - scale_hHitAMapC_B_passed[iphi_module][k]; l++){
1287 chip_struct_prob& this_struct = chip_map_prob[0][iphi_module].emplace_back();
1288 this_struct.chipNumber = k;
1289 this_struct.HitAMapC_cut = true;
1290 this_struct.HitAMapC_passed = false;
1291 }
1292 for (int l = 0; l < 16*1. - scale_hHitAWMapC_B_passed[iphi_module][k]; l++){
1293 chip_struct_prob& this_struct = chip_map_prob[0][iphi_module].emplace_back();
1294 this_struct.chipNumber = k;
1295 this_struct.HitAWMapC_cut = true;
1296 this_struct.HitAWMapC_passed = false;
1297 }
1298 for (int l = 0; l < 16*1. - scale_hHitHMapC_B_passed[iphi_module][k]; l++){
1299 chip_struct_prob& this_struct = chip_map_prob[0][iphi_module].emplace_back();
1300 this_struct.chipNumber = k;
1301 this_struct.HitHMapC_cut = true;
1302 this_struct.HitHMapC_passed = false;
1303 }
1304 } else{
1305 ATH_MSG_ERROR("Scale value is less than zero in normalization for Barrel chip!");
1306 }
1307 }
1308 }
1309 }
1310
1311 // Endcap straw normalization
1312 for (int k = 0; k < s_Straw_max[1]; k++) {
1313 for (int iside = 0; iside < 2; iside++) {
1314 for (int phi_module = 0; phi_module < s_numberOfEndCapStacks; phi_module++) {
1315 int iphi_module = -999;;
1316 if (iside == 0) iphi_module = phi_module; else if (iside == 1) iphi_module = phi_module + 32;
1317 if (scale_hHitHWMapS_E_passed[iphi_module][k] < 2 || scale_hHitWMapS_E_passed[iphi_module][k] < 2 ||
1318 scale_hHitAMapS_E_passed[iphi_module][k] < 2 || scale_hHitAWMapS_E_passed[iphi_module][k] < 2 ||
1319 scale_hHitHMapS_E_passed[iphi_module][k] < 2) {
1320 for (int l = 0; l < 1. - scale_hHitHWMapS_E_passed[iphi_module][k]; l++){
1321 straw_struct_prob& this_struct = straw_map_prob[1][iphi_module].emplace_back(); // index 1 is Endcap, A and C are splitted by iphi_module
1322 this_struct.strawNumber = k;
1323 this_struct.HitHWMapS_cut = true;
1324 this_struct.HitHWMapS_passed = false;
1325 }
1326 for (int l = 0; l < 1. - scale_hHitWMapS_E_passed[iphi_module][k]; l++){
1327 straw_struct_prob& this_struct = straw_map_prob[1][iphi_module].emplace_back();
1328 this_struct.strawNumber = k;
1329 this_struct.HitWMapS_cut = true;
1330 this_struct.HitWMapS_passed = false;
1331 }
1332 for (int l = 0; l < 1. - scale_hHitAMapS_E_passed[iphi_module][k]; l++){
1333 straw_struct_prob& this_struct = straw_map_prob[1][iphi_module].emplace_back();
1334 this_struct.strawNumber = k;
1335 this_struct.HitAMapS_cut = true;
1336 this_struct.HitAMapS_passed = false;
1337 }
1338 for (int l = 0; l < 1. - scale_hHitAWMapS_E_passed[iphi_module][k]; l++){
1339 straw_struct_prob& this_struct = straw_map_prob[1][iphi_module].emplace_back();
1340 this_struct.strawNumber = k;
1341 this_struct.HitAWMapS_cut = true;
1342 this_struct.HitAWMapS_passed = false;
1343 }
1344 for (int l = 0; l < 1. - scale_hHitHMapS_E_passed[iphi_module][k]; l++){
1345 straw_struct_prob& this_struct = straw_map_prob[1][iphi_module].emplace_back();
1346 this_struct.strawNumber = k;
1347 this_struct.HitHMapS_cut = true;
1348 this_struct.HitHMapS_passed = false;
1349 }
1350 } else{
1351 ATH_MSG_ERROR("Scale value is less than zero in normalization for Endcap straw!");
1352 }
1353 }
1354 }
1355 }
1356
1357 // Endcap chip normalization
1358 for (int k = 0; k < s_iChip_max[1]; k++) {
1359 for (int iside = 0; iside < 2; iside++) {
1360 for (int phi_module = 0; phi_module < s_numberOfEndCapStacks; phi_module++) {
1361 int iphi_module = -999;;
1362 if (iside == 0) iphi_module = phi_module; else if (iside == 1) iphi_module = phi_module + 32;
1363 if (scale_hHitHWMapC_E_passed[iphi_module][k] < 17 || scale_hHitWMapC_E_passed[iphi_module][k] < 17 ||
1364 scale_hHitAMapC_E_passed[iphi_module][k] < 17 || scale_hHitAWMapC_E_passed[iphi_module][k] < 17 ||
1365 scale_hHitHMapC_E_passed[iphi_module][k] < 17) {
1366 for (int l = 0; l < 16*1. - scale_hHitHWMapC_E_passed[iphi_module][k]; l++){
1367 chip_struct_prob& this_struct = chip_map_prob[1][iphi_module].emplace_back(); // index 0 is Barrel, A and C are splitted by iphi_module
1368 this_struct.chipNumber = k;
1369 this_struct.HitHWMapC_cut = true;
1370 this_struct.HitHWMapC_passed = false;
1371 }
1372 for (int l = 0; l < 16*1. - scale_hHitWMapC_E_passed[iphi_module][k]; l++){
1373 chip_struct_prob& this_struct = chip_map_prob[1][iphi_module].emplace_back();
1374 this_struct.chipNumber = k;
1375 this_struct.HitWMapC_cut = true;
1376 this_struct.HitWMapC_passed = false;
1377 }
1378 for (int l = 0; l < 16*1. - scale_hHitAMapC_E_passed[iphi_module][k]; l++){
1379 chip_struct_prob& this_struct = chip_map_prob[1][iphi_module].emplace_back();
1380 this_struct.chipNumber = k;
1381 this_struct.HitAMapC_cut = true;
1382 this_struct.HitAMapC_passed = false;
1383 }
1384 for (int l = 0; l < 16*1. - scale_hHitAWMapC_E_passed[iphi_module][k]; l++){
1385 chip_struct_prob& this_struct = chip_map_prob[1][iphi_module].emplace_back();
1386 this_struct.chipNumber = k;
1387 this_struct.HitAWMapC_cut = true;
1388 this_struct.HitAWMapC_passed = false;
1389 }
1390 for (int l = 0; l < 16*1. - scale_hHitHMapC_E_passed[iphi_module][k]; l++){
1391 chip_struct_prob& this_struct = chip_map_prob[1][iphi_module].emplace_back();
1392 this_struct.chipNumber = k;
1393 this_struct.HitHMapC_cut = true;
1394 this_struct.HitHMapC_passed = false;
1395 }
1396 } else{
1397 ATH_MSG_ERROR("Scale value is less than zero in normalization for Endcap chip!");
1398 }
1399 }
1400 }
1401 }
1402 }
1403
1404 for (const auto& ibarrel_ecpair : straw_shifter_map) {
1405 int ibe = abs(ibarrel_ecpair.first) - 1;
1406 int iside = ibarrel_ecpair.first > 0 ? 0 : 1;
1407 auto strawNumber = Monitored::Collection("strawNumber", ibarrel_ecpair.second, [](const auto& s){return s.strawNumber;});
1408 auto HitWMap_passed = Monitored::Collection("HitWMap_passed", ibarrel_ecpair.second, [](const auto& s){return s.HitWMap_passed;});
1409 auto HitWMap_Ar_passed = Monitored::Collection("HitWMap_Ar_passed", ibarrel_ecpair.second, [](const auto& s){return s.HitWMap_Ar_passed;});
1410 auto isAr = Monitored::Collection("isAr", ibarrel_ecpair.second, [](const auto& s){return s.isAr;});
1411 auto isNotAr = Monitored::Collection("isNotAr", ibarrel_ecpair.second, [](const auto& s){return not s.isAr;});
1412 if (ibe == 0) {
1413 fill("RDOHistograms0", strawNumber, HitWMap_passed, HitWMap_Ar_passed, isAr, isNotAr);
1414 } else if (ibe == 1) {
1415 fill("RDOHistograms1"+std::to_string(iside), strawNumber, HitWMap_passed, HitWMap_Ar_passed, isAr, isNotAr);
1416 }
1417 }
1418
1419 if (m_doExpert) {
1420 for (const auto& ibepair : straw_map_prob) {
1421 for (const auto& iphi_modulepair : ibepair.second ) {
1422 auto strawNumber = Monitored::Collection("strawNumber", iphi_modulepair.second, [](const auto& s){return s.strawNumber;});
1423 auto HitHWMapS_passed = Monitored::Collection("HitHWMapS_passed", iphi_modulepair.second, [](const auto& s){return s.HitHWMapS_passed;});
1424 auto HitWMapS_passed = Monitored::Collection("HitWMapS_passed", iphi_modulepair.second, [](const auto& s){return s.HitWMapS_passed;});
1425 auto HitAMapS_passed = Monitored::Collection("HitAMapS_passed", iphi_modulepair.second, [](const auto& s){return s.HitAMapS_passed;});
1426 auto HitAWMapS_passed = Monitored::Collection("HitAWMapS_passed", iphi_modulepair.second, [](const auto& s){return s.HitAWMapS_passed;});
1427 auto HitHMapS_passed = Monitored::Collection("HitHMapS_passed", iphi_modulepair.second, [](const auto& s){return s.HitHMapS_passed;});
1428 auto HitHWMapS_cut = Monitored::Collection("HitHWMapS_cut", iphi_modulepair.second, [](const auto& s){return s.HitHWMapS_cut;});
1429 auto HitWMapS_cut = Monitored::Collection("HitWMapS_cut", iphi_modulepair.second, [](const auto& s){return s.HitWMapS_cut;});
1430 auto HitAMapS_cut = Monitored::Collection("HitAMapS_cut", iphi_modulepair.second, [](const auto& s){return s.HitAMapS_cut;});
1431 auto HitAWMapS_cut = Monitored::Collection("HitAWMapS_cut", iphi_modulepair.second, [](const auto& s){return s.HitAWMapS_cut;});
1432 auto HitHMapS_cut = Monitored::Collection("HitHMapS_cut", iphi_modulepair.second, [](const auto& s){return s.HitHMapS_cut;});
1433
1434 fill("RDOStackHistograms"+std::to_string(ibepair.first)+std::to_string(iphi_modulepair.first), strawNumber, HitHWMapS_passed, HitHWMapS_cut,
1435 HitWMapS_passed, HitWMapS_cut, HitAMapS_passed, HitAMapS_cut, HitAWMapS_passed, HitAWMapS_cut, HitHMapS_passed, HitHMapS_cut);
1436 }
1437 }
1438
1439 for (const auto& ibepair : chip_map_prob) {
1440 for (const auto& iphi_modulepair : ibepair.second ) {
1441 auto chipNumber = Monitored::Collection("chipNumber", iphi_modulepair.second, [](const auto& s){return s.chipNumber;});
1442 auto HitHWMapC_passed = Monitored::Collection("HitHWMapC_passed", iphi_modulepair.second, [](const auto& s){return s.HitHWMapC_passed;});
1443 auto HitWMapC_passed = Monitored::Collection("HitWMapC_passed", iphi_modulepair.second, [](const auto& s){return s.HitWMapC_passed;});
1444 auto HitAMapC_passed = Monitored::Collection("HitAMapC_passed", iphi_modulepair.second, [](const auto& s){return s.HitAMapC_passed;});
1445 auto HitAWMapC_passed = Monitored::Collection("HitAWMapC_passed", iphi_modulepair.second, [](const auto& s){return s.HitAWMapC_passed;});
1446 auto HitHMapC_passed = Monitored::Collection("HitHMapC_passed", iphi_modulepair.second, [](const auto& s){return s.HitHMapC_passed;});
1447 auto HitHWMapC_cut = Monitored::Collection("HitHWMapC_cut", iphi_modulepair.second, [](const auto& s){return s.HitHWMapC_cut;});
1448 auto HitWMapC_cut = Monitored::Collection("HitWMapC_cut", iphi_modulepair.second, [](const auto& s){return s.HitWMapC_cut;});
1449 auto HitAMapC_cut = Monitored::Collection("HitAMapC_cut", iphi_modulepair.second, [](const auto& s){return s.HitAMapC_cut;});
1450 auto HitAWMapC_cut = Monitored::Collection("HitAWMapC_cut", iphi_modulepair.second, [](const auto& s){return s.HitAWMapC_cut;});
1451 auto HitHMapC_cut = Monitored::Collection("HitHMapC_cut", iphi_modulepair.second, [](const auto& s){return s.HitHMapC_cut;});
1452
1453 fill("RDOStackHistograms"+std::to_string(ibepair.first)+std::to_string(iphi_modulepair.first), chipNumber, HitHWMapC_passed, HitHWMapC_cut,
1454 HitWMapC_passed, HitWMapC_cut, HitAMapC_passed, HitAMapC_cut, HitAWMapC_passed, HitAWMapC_cut, HitHMapC_passed, HitHMapC_cut);
1455 }
1456 }
1457 }
1458
1459 for (const auto& ibepair : straw_map) {
1460 for (const auto& iphi_modulepair : ibepair.second ) {
1461 auto strawNumber = Monitored::Collection("strawNumber", iphi_modulepair.second, [](const auto& s){return s.strawNumber;});
1462 auto HitTrMapS_y = Monitored::Collection("HitTrMapS_y", iphi_modulepair.second, [](const auto& s){return s.HitTrMapS_y;});
1463 auto HitToTMapS_y = Monitored::Collection("HitToTMapS_y", iphi_modulepair.second, [](const auto& s){return s.HitToTMapS_y;});
1464 auto HitToTLong_cut = Monitored::Collection("HitToTLong_cut", iphi_modulepair.second, [](const auto& s){return s.HitToTLong_cut;});
1465 auto HitTrWMapS_y = Monitored::Collection("HitTrWMapS_y", iphi_modulepair.second, [](const auto& s){return s.HitTrWMapS_y;});
1466 auto HitTrWMapS_cut = Monitored::Collection("HitTrWMapS_cut", iphi_modulepair.second, [](const auto& s){return s.HitTrWMapS_cut;});
1467
1468 fill("RDOStackHistograms"+std::to_string(ibepair.first)+std::to_string(iphi_modulepair.first), strawNumber,
1469 HitTrMapS_y, HitToTMapS_y, HitToTLong_cut, HitTrWMapS_y, HitTrWMapS_cut);
1470 }
1471 }
1472
1473 for (const auto& ibepair : chip_map) {
1474 for (const auto& iphi_modulepair : ibepair.second ) {
1475 auto chipNumber = Monitored::Collection("chipNumber", iphi_modulepair.second, [](const auto& s){return s.chipNumber;});
1476 auto HitTrMapC_y = Monitored::Collection("HitTrMapC_y", iphi_modulepair.second, [](const auto& s){return s.HitTrMapC_y;});
1477 auto HitToTMapC_y = Monitored::Collection("HitToTMapC_y", iphi_modulepair.second, [](const auto& s){return s.HitToTMapC_y;});
1478 auto HtoBCMapC_x = Monitored::Collection("HtoBCMapC_x", iphi_modulepair.second, [](const auto& s){return s.HtoBCMapC_x;});
1479 auto HtoBCMapB_x = Monitored::Collection("HtoBCMapB_x", iphi_modulepair.second, [](const auto& s){return s.HtoBCMapB_x;});
1480 auto HtoBCMapB_y = Monitored::Collection("HtoBCMapB_y", iphi_modulepair.second, [](const auto& s){return s.HtoBCMapB_y;});
1481 auto HtoBCMap_cut = Monitored::Collection("HtoBCMap_cut", iphi_modulepair.second, [](const auto& s){return s.HtoBCMap_cut;});
1482 auto HitTrWMapC_cut = Monitored::Collection("HitTrWMapC_cut", iphi_modulepair.second, [](const auto& s){return s.HitTrWMapC_cut;});
1483
1484 fill("RDOStackHistograms"+std::to_string(ibepair.first)+std::to_string(iphi_modulepair.first),
1485 chipNumber, HitTrMapC_y, HitToTMapC_y, HtoBCMapC_x, HtoBCMapB_x, HtoBCMapB_y, HtoBCMap_cut, HitTrWMapC_cut);
1486 }
1487 }
1488
1489 OccAll = nhitsall/350848.;
1490 fill("RDOHistograms0", OccAll);
1491
1492 //ToDo Explain this
1493 for (int ibe = 0; ibe < 2; ibe++) {
1494 if (m_doShift) {
1495 if (ibe == 0) {
1496 BCIDvsOcc_x = good_bcid;
1497 BCIDvsOcc_y = nTRTHits[ibe]/105088.0;
1498 fill("RDOHistograms0", BCIDvsOcc_x, BCIDvsOcc_y);
1499 } else if (ibe == 1) {
1500 BCIDvsOcc_x = good_bcid;
1501 BCIDvsOcc_y = nTRTHits[ibe]/245760.0;
1502 fill("RDOHistograms1", BCIDvsOcc_x, BCIDvsOcc_y);
1503 }
1504
1505 for (int iside = 0; iside < 2; iside++) {
1506 for (int i = 1; i <= numberOfStacks_b[ibe]; i++) {
1507
1508 int index_tmp = 0;
1509 int modulenum_tmp = 0;
1510
1511 if (iside == 0) {
1512 index_tmp = i - 1;
1513 modulenum_tmp = i - 1;
1514 } else if (iside == 1) {
1515 index_tmp = i + 31;
1516
1517 if (ibe == 0) modulenum_tmp = (i - 1) + 96;
1518 else if (ibe == 1) modulenum_tmp = (i - 1) + 64;
1519 }
1520
1521 int nclass = -1;
1522
1523 if (i <= s_numberOfBarrelStacks) {
1524 nclass = 0;
1525 } else if (i <= 2 * s_numberOfBarrelStacks && i > s_numberOfBarrelStacks) {
1526 nclass = 1;
1527 } else if (i > 2 * s_numberOfBarrelStacks) {
1528 nclass = 2;
1529 }
1530 int LLocc_index = index_tmp - 32 * nclass;
1531
1532 if (nclass >= 0) {
1533 if (ibe == 0) {
1534 // Tell clang to optimize assuming that FP operations may trap.
1536 float occLL = float(moduleHits_B[modulenum_tmp]) / float(numberOfStrawsMod[nclass]);
1537 float occHL = float(HLmoduleHits_B[modulenum_tmp]) / float(numberOfStrawsMod[nclass]);
1538 AvgLLOcc_side_x = i - (32 * nclass);
1539 AvgLLOcc_side_y = occLL;
1540 AvgHLOcc_side_x = i - (32 * nclass);
1541 AvgHLOcc_side_y = occHL;
1542 AvgLLOccMod_side_x = i;
1543 AvgLLOccMod_side_y = occLL;
1544 AvgHLOccMod_side_x = i;
1545 AvgHLOccMod_side_y = occHL;
1546 } else if (ibe == 1) {
1547 float occLL = float(moduleHits_E[modulenum_tmp]) / float(numberOfStrawsWheel[nclass]);
1548 float occHL = float(HLmoduleHits_E[modulenum_tmp]) / float(numberOfStrawsWheel[nclass]);
1549
1550 if (LLocc_index < 64) {
1551 } else {
1552 ATH_MSG_WARNING("m_LLOcc index out of bounds!"); // To satisfy Coverity defect CID 16514 which we believe is a false report.
1553 }
1554 AvgLLOcc_side_x = i - (32 * nclass);
1555 AvgLLOcc_side_y = occLL;
1556 AvgHLOcc_side_x = i - (32 * nclass);
1557 AvgHLOcc_side_y = occHL;
1558 AvgLLOccMod_side_x = i;
1559 AvgLLOccMod_side_y = occLL;
1560 AvgHLOccMod_side_x = i;
1561 AvgHLOccMod_side_y = occHL;
1562 }
1563 fill("RDOLLHLOccHistograms"+std::to_string(ibe)+std::to_string(iside), AvgLLOcc_side_x, AvgLLOcc_side_y, AvgHLOcc_side_x, AvgHLOcc_side_y,
1564 AvgLLOccMod_side_x, AvgLLOccMod_side_y, AvgHLOccMod_side_x, AvgHLOccMod_side_y);
1565 }
1566 }
1567 }
1568 }
1569 // Normalization for online environmenmet
1570 // Insert here
1571 }
1572
1573 if (m_doShift) {
1574 const unsigned int lumiBlock = eventInfo.lumiBlock();
1575 ATH_MSG_VERBOSE("This is lumiblock : " << lumiBlock);
1576 int lastLumiBlock = -99; // ToDo - last lumiblock calculation is not correct
1577 if ((int)lumiBlock != lastLumiBlock) {
1578 lastLumiBlock = lumiBlock;
1579 }
1580 float evtLumiBlock = 1.;
1581 float lumiBlockScale = (evtLumiBlock > 0) ? (1. / evtLumiBlock) : 0;
1582 const float barrelConst = 1. / 105088;
1583 const float endcapConst = 1. / 122880;
1584
1585 if (m_doTracksMon && evtLumiBlock > 0) {
1586 NHitsperLB_x = lastLumiBlock;
1587 NHitsperLB_y = (float)nHitsperLB_B * lumiBlockScale * barrelConst;
1588 fill("RDOShiftRebinnedBarrelHistograms0", NHitsperLB_x, NHitsperLB_y);
1589 NHLHitsperLB_x = lastLumiBlock;
1590 NHLHitsperLB_y = (float)nHLHitsperLB_B * lumiBlockScale * barrelConst;
1591 fill("RDOShiftRebinnedBarrelHistograms0", NHLHitsperLB_x, NHLHitsperLB_y);
1592
1593 for (int iside = 0; iside < 2; iside++) {
1594 NHitsperLB_x = lastLumiBlock;
1595 NHitsperLB_y = (float)nHitsperLB_E[iside] * lumiBlockScale * endcapConst;
1596 fill("RDOShiftRebinnedEndcapHistograms1"+std::to_string(iside), NHitsperLB_x, NHitsperLB_y);
1597 NHLHitsperLB_x = lastLumiBlock;
1598 NHLHitsperLB_y = (float)nHLHitsperLB_E[iside] * lumiBlockScale * endcapConst;
1599 fill("RDOShiftRebinnedEndcapHistograms1"+std::to_string(iside), NHLHitsperLB_x, NHLHitsperLB_y);
1600 }
1601
1602 nHitsperLB_B = 0;
1603 nHLHitsperLB_B = 0;
1604
1605 for (int iside = 0; iside < 2; iside++) {
1606 nHitsperLB_E[iside] = 0;
1607 nHLHitsperLB_E[iside] = 0;
1608 }
1609 }
1610 }
1611
1612 ATH_MSG_DEBUG("end of event and lumi block");
1613
1614 //Get BSConversion Errors from BSConditionsServices:
1615 std::set<std::pair<uint32_t, uint32_t> > *L1IDErrorSet = m_BSSvc->getIdErrorSet(TRTByteStreamErrors::L1IDError);
1616 std::set<std::pair<uint32_t, uint32_t> > *BCIDErrorSet = m_BSSvc->getIdErrorSet(TRTByteStreamErrors::BCIDError);
1617 std::set<uint32_t> *MissingErrorSet = m_BSSvc->getErrorSet(TRTByteStreamErrors::MISSINGError);
1618 std::set<uint32_t> *SidErrorSet = m_BSSvc->getErrorSet(TRTByteStreamErrors::SIDError);
1619 std::set<std::pair<uint32_t, uint32_t> > *RobStatusErrorSet = m_BSSvc->getRodRobErrorSet(TRTByteStreamErrors::RobStatusError);
1620 const unsigned int rod_id_base[2][2] = { { 0x310000, 0x320000 }, { 0x330000, 0x340000 } };
1621 const unsigned int nChipsTotal[2][2] = { { 3328, 3328 }, { 7680, 7680 } };
1622 const unsigned int nRobsTotal[2][2] = { { 32, 32 }, { 64, 64 } };
1623 float nBSErrors[2][2] = { { 0, 0 }, { 0, 0 } };
1624 float nRobErrors[2][2] = { { 0, 0 }, { 0, 0 } };
1625 const std::set<std::pair<uint32_t, uint32_t> > *errorset1[2] = { BCIDErrorSet, L1IDErrorSet };
1626
1627 for (int iset = 0; iset < 2; ++iset) {
1628 for (auto setIt = errorset1[iset]->begin(); setIt != errorset1[iset]->end(); ++setIt) {
1629 for (int ibe = 0; ibe < 2; ++ibe) {
1630 for (int iside = 0; iside < 2; ++iside) {
1631 if (((setIt->first >> 8) & 0xFF0000) == rod_id_base[ibe][iside]) {
1632 nBSErrors[ibe][iside] += 1. / nChipsTotal[ibe][iside];
1633 }
1634 }
1635 }
1636 }
1637 }
1638
1639 const std::set<uint32_t> *errorset2[2] = { MissingErrorSet, SidErrorSet };
1640
1641 for (int iset = 0; iset < 2; ++iset) {
1642 for (auto setIt = errorset2[iset]->begin(); setIt != errorset2[iset]->end(); ++setIt) {
1643 for (int ibe = 0; ibe < 2; ++ibe) {
1644 for (int iside = 0; iside < 2; ++iside) {
1645 if (((*setIt >> 8) & 0xFF0000) == rod_id_base[ibe][iside]) {
1646 nBSErrors[ibe][iside] += 1. / nChipsTotal[ibe][iside];
1647 }
1648 }
1649 }
1650 }
1651 }
1652
1653 for (int ibe = 0; ibe < 2; ++ibe) {
1654 for (int iside = 0; iside < 2; ++iside) {
1655 ChipBSErrorsVsLB_x = lumiBlock;
1656 ChipBSErrorsVsLB_y = nBSErrors[ibe][iside];
1657 for (unsigned int i = 0; i < lumiBlock; i++) {
1658 // we need this so the LastBinThreshold algorithm can find the last bin
1659 fill("RDOShiftSmryRebinnedHistograms"+std::to_string(ibe)+std::to_string(iside), ChipBSErrorsVsLB_x, ChipBSErrorsVsLB_y);
1660 }
1661 }
1662 }
1663
1664 for (auto setIt = RobStatusErrorSet->begin(); setIt != RobStatusErrorSet->end(); ++setIt) {
1665 for (int ibe = 0; ibe < 2; ++ibe) {
1666 for (int iside = 0; iside < 2; ++iside) {
1667 if (setIt->first % rod_id_base[ibe][iside] < 0xffff) {
1668 nRobErrors[ibe][iside] += 1. / nRobsTotal[ibe][iside];
1669 }
1670 }
1671 }
1672 }
1673
1674 for (int ibe = 0; ibe < 2; ++ibe) {
1675 for (int iside = 0; iside < 2; ++iside) {
1676 RobBSErrorsVsLB_x = lumiBlock;
1677 RobBSErrorsVsLB_y = nRobErrors[ibe][iside];
1678 for (unsigned int i = 0; i < lumiBlock; i++) {
1679 // we need this so the LastBinThreshold algorithm can find the last bin
1680 fill("RDOShiftSmryRebinnedHistograms"+std::to_string(ibe)+std::to_string(iside), RobBSErrorsVsLB_x, RobBSErrorsVsLB_y);
1681 }
1682 }
1683 }
1684
1685 ATH_MSG_VERBOSE("Leaving Fill TRT RDO Histograms");
1686 return StatusCode::SUCCESS;
1687}
1688
1689// Fill the TRT Efficiency Histograms
1690//----------------------------------------------------------------------------------//
1691StatusCode TRTMonitoringRun3RAW_Alg::fillTRTEfficiency(const EventContext& ctx,
1692 const TrackCollection& combTrackCollection) const {
1693//----------------------------------------------------------------------------------//
1694 ATH_MSG_VERBOSE("Filling TRT Efficiency Histograms");
1695
1696 // TEfficiency
1697 auto Efficiency_eta = Monitored::Scalar<float>("Efficiency_eta", 0.0);
1698 auto Efficiency_phi = Monitored::Scalar<float>("Efficiency_phi", 0.0);
1699 auto Efficiency_pt = Monitored::Scalar<float>("Efficiency_pt", 0.0);
1700 auto Efficiency_z0 = Monitored::Scalar<float>("Efficiency_z0", 0.0);
1701 auto EfficiencyBarrel_locR = Monitored::Scalar<float>("EfficiencyBarrel_locR", 0.0);
1702 auto EfficiencyBarrel_locR_Ar = Monitored::Scalar<float>("EfficiencyBarrel_locR_Ar", 0.0);
1703 auto EfficiencyBarrelMap = Monitored::Scalar<float>("EfficiencyBarrelMap", 0.0);
1704 auto EfficiencyEndCapMap = Monitored::Scalar<float>("EfficiencyEndCapMap", 0.0);
1705 auto EfficiencyEndCap_locR = Monitored::Scalar<float>("EfficiencyEndCap_locR", 0.0);
1706 auto EfficiencyEndCap_locR_Ar = Monitored::Scalar<float>("EfficiencyEndCap_locR_Ar", 0.0);
1707 auto EfficiencyS = Monitored::Scalar<float>("EfficiencyS", 0.0);
1708 auto EfficiencyC = Monitored::Scalar<float>("EfficiencyC", 0.0);
1709 auto Efficiency_eta_passed = Monitored::Scalar<float>("Efficiency_eta_passed", 0.0);
1710 auto Efficiency_phi_passed = Monitored::Scalar<float>("Efficiency_phi_passed", 0.0);
1711 auto Efficiency_pt_passed = Monitored::Scalar<float>("Efficiency_pt_passed", 0.0);
1712 auto Efficiency_z0_passed = Monitored::Scalar<float>("Efficiency_z0_passed", 0.0);
1713 auto EfficiencyBarrel_locR_passed = Monitored::Scalar<bool>("EfficiencyBarrel_locR_passed", false);
1714 auto EfficiencyBarrel_locR_Ar_passed = Monitored::Scalar<bool>("EfficiencyBarrel_locR_Ar_passed", false);
1715 auto EfficiencyBarrelMap_passed = Monitored::Scalar<bool>("EfficiencyBarrelMap_passed", false);
1716 auto EfficiencyEndCapMap_passed = Monitored::Scalar<bool>("EfficiencyEndCapMap_passed", false);
1717 auto EfficiencyEndCap_locR_passed = Monitored::Scalar<bool>("EfficiencyEndCap_locR_passed", false);
1718 auto EfficiencyEndCap_locR_Ar_passed = Monitored::Scalar<bool>("EfficiencyEndCap_locR_Ar_passed", false);
1719 auto EfficiencyS_passed = Monitored::Scalar<bool>("EfficiencyS_passed", false);
1720 auto EfficiencyC_passed = Monitored::Scalar<bool>("EfficiencyC_passed", false);
1721
1722 // Reduce unnecessary divisions
1723 const float invGeV = 1. / CLHEP::GeV;
1724 const float invmm = 1. / CLHEP::mm;
1725 int itrack = 0;
1726 float track_pt = 0;
1727 float track_eta = 0;
1728 float track_phi = 0;
1729 float track_d0 = 0;
1730 float track_z0 = 0;
1731 const std::string histoName{"TRTEfficiencyHistograms"};
1732 for (auto track = combTrackCollection.begin(); track != combTrackCollection.end(); ++track) {
1733 // Online: use all tracks, offline: use only every xth track, skip the rest
1734 if (m_environment != Environment_t::online && (itrack % m_every_xth_track) != 0) continue;
1735
1736 ++itrack;
1737 // Get perigee
1738 const Trk::Perigee *perigee = (*track)->perigeeParameters();
1739
1740 if (perigee) {
1741 track_pt = perigee->pT();
1742 track_eta = perigee->eta();
1743 track_phi = perigee->parameters()[Trk::phi0];
1744 track_d0 = perigee->parameters()[Trk::d0];
1745 track_z0 = perigee->parameters()[Trk::z0];
1746 ATH_MSG_DEBUG("This track has perigee parameters:\n"
1747 << " pT = " << track_pt * invGeV << " GeV" << "\n"
1748 << " eta = " << track_eta << "\n"
1749 << " phi0 = " << track_phi << "\n"
1750 << " d0 = " << track_d0 * invmm << "\n"
1751 << " z0 = " << track_z0 * invmm << "\n"
1752 << " theta = " << perigee->parameters()[Trk::theta] << "\n"
1753 << " qOverP = " << perigee->parameters()[Trk::qOverP]);
1754 } else {
1755 ATH_MSG_DEBUG("This track has null perigeeParameters.");
1756 continue;
1757 }
1758
1759 const Trk::TrackStates *track_states = (*track)->trackStateOnSurfaces();
1760
1761 if (track_states) {
1762 ATH_MSG_DEBUG("This track has " << track_states->size() << " track states on surface.");
1763 } else {
1764 ATH_MSG_DEBUG("This track has null track states on surface.");
1765 continue;
1766 }
1767
1768 const std::unique_ptr<const Trk::TrackSummary> summary(m_TrackSummaryTool->summary(ctx,*(*track)));
1769 int n_trt_hits = summary->get(Trk::numberOfTRTHits);
1770 int n_sct_hits = summary->get(Trk::numberOfSCTHits);
1771 int n_pixel_hits = summary->get(Trk::numberOfPixelHits);
1772 float p = 1.0e+08;
1773
1774 if (perigee) {
1775 p = (perigee->parameters()[Trk::qOverP] != 0.) ? std::abs(1. / (perigee->parameters()[Trk::qOverP])) : 1.0e+08;
1776 }
1777
1778
1779 // Preselect tracks
1780 const bool passed_track_preselection = (static_cast<bool>(m_trackSelTool->accept(**track)) || m_isCosmics) &&
1781 n_trt_hits >= m_min_trt_hits &&
1782 p > m_minP &&
1783 perigee->pT() > (m_isCosmics?m_min_pT.value() : 2.0 * CLHEP::GeV);
1784
1785 ATH_MSG_DEBUG("track has ntrt = " << n_trt_hits
1786 << " and nsct = " << n_sct_hits
1787 << " and npix = " << n_pixel_hits);
1788
1789 if (!passed_track_preselection) {
1790 ATH_MSG_DEBUG("This track failed preselection.");
1791 continue;
1792 }
1793
1794 ATH_MSG_DEBUG("This track passed preselection.");
1795
1796 for (auto it = track_states->begin(); it != track_states->end(); it++) {
1797 if ( !((*it)->type(Trk::TrackStateOnSurface::Measurement)) ) continue;
1798
1799 const Trk::TrackParameters *track_parameters = (*it)->trackParameters();
1800
1801 if (!track_parameters) continue;
1802
1804
1805 if ( !((m_pTRTHelper->is_trt(id)) )) continue;
1806
1807 float locR = track_parameters->parameters()[Trk::driftRadius];
1808 int barrel_ec = m_pTRTHelper->barrel_ec(id);
1809 int layer_or_wheel = m_pTRTHelper->layer_or_wheel(id);
1810 int phi_module = m_pTRTHelper->phi_module(id);
1811 int straw_layer = m_pTRTHelper->straw_layer(id);
1812 int straw = m_pTRTHelper->straw(id);
1813 const bool isArgonStraw = (Straw_Gastype( m_sumTool->getStatusHT(id, ctx) ) == GasType::Ar);
1814 // Assume always Xe if m_ArgonXenonSplitter is not enabled, otherwise check the straw status (good is Xe, non-good is Ar)
1815 int ibe = abs(barrel_ec) - 1; // ibe = 0 (Barrel), ibe = 1 (Endcap)
1816 int iside = barrel_ec > 0 ? 0 : 1; // iside = 0 (Side A), iside = 1 (Side C)
1817
1818 if (ibe == 0) {
1819 if (isArgonStraw) {
1820 EfficiencyBarrel_locR_Ar = locR;
1821 EfficiencyBarrel_locR_Ar_passed = 1.0;
1822 fill("TRTEfficiencyHistogramsBarrel", EfficiencyBarrel_locR_Ar_passed, EfficiencyBarrel_locR_Ar);
1823 } else {
1824 EfficiencyBarrel_locR = locR;
1825 EfficiencyBarrel_locR_passed = 1.0;
1826 fill("TRTEfficiencyHistogramsBarrel", EfficiencyBarrel_locR_passed, EfficiencyBarrel_locR);
1827 }
1828 } else if (ibe == 1) {
1829 if (isArgonStraw) {
1830 EfficiencyBarrel_locR_Ar = locR;
1831 EfficiencyBarrel_locR_Ar_passed = 1.0;
1832 fill("TRTEfficiencyHistogramsEndCap"+std::to_string(iside), EfficiencyBarrel_locR_Ar_passed, EfficiencyBarrel_locR_Ar);
1833 } else {
1834 EfficiencyEndCap_locR = locR;
1835 EfficiencyEndCap_locR_passed = 1.0;
1836 fill("TRTEfficiencyHistogramsEndCap"+std::to_string(iside), EfficiencyEndCap_locR_passed, EfficiencyEndCap_locR);
1837 }
1838 }
1839
1840 if (std::abs(locR) >= 1.3) continue;
1841
1842 int thisStrawNumber = 0;
1843 int chip = 0;
1844
1845 if (ibe == 0) {
1846 thisStrawNumber = strawNumber(straw, straw_layer, layer_or_wheel);
1847
1848 if (thisStrawNumber >= 0 && thisStrawNumber < s_Straw_max[ibe])
1849 chip = m_mat_chip_B.at(phi_module).at(thisStrawNumber);
1850 } else if (ibe == 1) {
1851 thisStrawNumber = strawNumberEndCap(straw, straw_layer, layer_or_wheel, phi_module, barrel_ec);
1852
1853 if (thisStrawNumber >= 0 && thisStrawNumber < s_Straw_max[ibe])
1854 chip = m_mat_chip_E.at(phi_module).at(thisStrawNumber);
1855 }
1856
1857 if (ibe == 0) {
1858 EfficiencyBarrelMap = thisStrawNumber;
1859 EfficiencyBarrelMap_passed = 1.0;
1860 fill("TRTEfficiencyHistogramsBarrel", EfficiencyBarrelMap_passed, EfficiencyBarrelMap);
1861 } else if (ibe == 1) {
1862 EfficiencyEndCapMap = thisStrawNumber;
1863 EfficiencyEndCapMap_passed = 1.0;
1864 fill("TRTEfficiencyHistogramsEndCap", EfficiencyEndCapMap_passed, EfficiencyEndCapMap);
1865 }
1866
1867 if (m_doExpert) {
1868 if (iside == 0) {
1869 EfficiencyS = thisStrawNumber;
1870 EfficiencyS_passed = 1.0;
1871 fill(histoName+std::to_string(ibe)+std::to_string(phi_module), EfficiencyS_passed, EfficiencyS);
1872 EfficiencyC = chip;
1873 EfficiencyC_passed = 1.0;
1874 fill(histoName+std::to_string(ibe)+std::to_string(phi_module), EfficiencyC_passed, EfficiencyC);
1875 } else if (iside == 1) {
1876 EfficiencyS = thisStrawNumber;
1877 EfficiencyS_passed = 1.0;
1878 fill(histoName+std::to_string(ibe)+std::to_string(phi_module + 32), EfficiencyS_passed, EfficiencyS);
1879 EfficiencyC = chip;
1880 EfficiencyC_passed = 1.0;
1881 fill(histoName+std::to_string(ibe)+std::to_string(phi_module + 32), EfficiencyC_passed, EfficiencyC);
1882 }
1883 }
1884
1885 Efficiency_eta_passed = track_eta;
1886 Efficiency_eta = 1.0;
1887 fill(histoName, Efficiency_eta_passed, Efficiency_eta);
1888 Efficiency_phi_passed = track_phi;
1889 Efficiency_phi = 1.0;
1890 fill(histoName, Efficiency_phi_passed, Efficiency_phi);
1891 Efficiency_pt_passed = track_pt*invGeV;
1892 Efficiency_pt = 1.0;
1893 fill(histoName, Efficiency_pt_passed, Efficiency_pt);
1894 Efficiency_z0_passed = track_z0;
1895 Efficiency_z0 = 1.0;
1896 fill(histoName, Efficiency_z0_passed, Efficiency_z0);
1897 }
1898
1899
1900 // Use hole finder to find holes on this track
1901 if (m_useHoleFinder) {
1902 std::unique_ptr<const Trk::TrackStates> holes (m_trt_hole_finder->getHolesOnTrack(*(*track)));
1903
1904 if (!holes) {
1905 ATH_MSG_WARNING("TRTTrackHoleSearchTool returned null results.");
1906 continue;
1907 } else {
1908 for (auto it = holes->begin(); it != holes->end(); ++it) { // holes->size() is always 0 for some reason
1909 if ( !((*it)->type(Trk::TrackStateOnSurface::Hole)) ) continue;
1910
1911 const Trk::TrackParameters *track_parameters = (*it)->trackParameters();
1912
1913 if (!track_parameters) continue;
1914
1916
1917 if ( !(m_pTRTHelper->is_trt(id)) ) continue;
1918
1919 float locR = track_parameters->parameters()[Trk::driftRadius];
1920 int barrel_ec = m_pTRTHelper->barrel_ec(id);
1921 int layer_or_wheel = m_pTRTHelper->layer_or_wheel(id);
1922 int phi_module = m_pTRTHelper->phi_module(id);
1923 int straw_layer = m_pTRTHelper->straw_layer(id);
1924 int straw = m_pTRTHelper->straw(id);
1925 const bool isArgonStraw = Straw_Gastype( m_sumTool->getStatusHT(id, ctx) ) == GasType::Ar;
1926 // Assume always Xe if m_ArgonXenonSplitter is not enabled, otherwise check the straw status (good is Xe, non-good is Ar)
1927 int ibe = abs(barrel_ec) - 1; // ibe = 0 (Barrel), ibe = 1 (Endcap)
1928 int iside = barrel_ec > 0 ? 0 : 1; // iside = 0 (Side A), iside = 1 (Side C)
1929
1930 if (ibe == 0) {
1931 if (isArgonStraw) {
1932 EfficiencyBarrel_locR_Ar = locR;
1933 EfficiencyBarrel_locR_Ar_passed = 0.0;
1934 fill(histoName, EfficiencyBarrel_locR_Ar_passed, EfficiencyBarrel_locR_Ar);
1935 } else {
1936 EfficiencyBarrel_locR = locR;
1937 EfficiencyBarrel_locR_passed = 0.0;
1938 fill(histoName, EfficiencyBarrel_locR_passed, EfficiencyBarrel_locR);
1939 }
1940 } else if (ibe == 1) {
1941 if (isArgonStraw) {
1942 EfficiencyEndCap_locR_Ar = locR;
1943 EfficiencyEndCap_locR_Ar_passed = 0.0;
1944 fill("TRTEfficiencyHistogramsEndCap"+std::to_string(iside), EfficiencyEndCap_locR_Ar_passed, EfficiencyEndCap_locR_Ar);
1945 } else {
1946 EfficiencyEndCap_locR = locR;
1947 EfficiencyEndCap_locR_passed = 0.0;
1948 fill("TRTEfficiencyHistogramsEndCap"+std::to_string(iside), EfficiencyEndCap_locR_passed, EfficiencyEndCap_locR);
1949 }
1950 }
1951
1952 if (std::abs(locR) >= 1.3) continue;
1953
1954 int thisStrawNumber = 0;
1955 int chip = 0;
1956
1957 if (ibe == 0) {
1958 thisStrawNumber = strawNumber(straw, straw_layer, layer_or_wheel);
1959
1960 if (thisStrawNumber >= 0 && thisStrawNumber < s_Straw_max[ibe]) {
1961 chip = m_mat_chip_B.at(phi_module).at(thisStrawNumber);
1962 }
1963 } else if (ibe == 1) {
1964 thisStrawNumber = strawNumberEndCap(straw, straw_layer, layer_or_wheel, phi_module, barrel_ec);
1965
1966 if (thisStrawNumber >= 0 && thisStrawNumber < s_Straw_max[ibe]) {
1967 chip = m_mat_chip_E.at(phi_module).at(thisStrawNumber);
1968 }
1969 }
1970
1971 if (ibe == 0) {
1972 EfficiencyBarrelMap = thisStrawNumber;
1973 EfficiencyBarrelMap_passed = 0.0;
1974 fill("TRTEfficiencyHistogramsBarrel", EfficiencyBarrelMap_passed, EfficiencyBarrelMap);
1975 } else if (ibe == 1) {
1976 EfficiencyEndCapMap = thisStrawNumber;
1977 EfficiencyEndCapMap_passed = 0.0;
1978 fill("TRTEfficiencyHistogramsEndCap", EfficiencyEndCapMap_passed, EfficiencyEndCapMap);
1979 }
1980
1981 if (m_doExpert) {
1982 if (iside == 0) {
1983 EfficiencyS = thisStrawNumber;
1984 EfficiencyS_passed = 0.0;
1985 fill(histoName+std::to_string(ibe)+std::to_string(phi_module), EfficiencyS_passed, EfficiencyS);
1986 EfficiencyC = chip;
1987 EfficiencyC_passed = 0.0;
1988 fill(histoName+std::to_string(ibe)+std::to_string(phi_module), EfficiencyC_passed, EfficiencyC);
1989 } else if (iside == 1) {
1990 EfficiencyS = thisStrawNumber;
1991 EfficiencyS_passed = 0.0;
1992 fill(histoName+std::to_string(ibe)+std::to_string(phi_module + 32), EfficiencyS_passed, EfficiencyS);
1993 EfficiencyC = chip;
1994 EfficiencyC_passed = 0.0;
1995 fill(histoName+std::to_string(ibe)+std::to_string(phi_module + 32), EfficiencyC_passed, EfficiencyC);
1996 }
1997 }
1998 Efficiency_eta_passed = track_eta;
1999 Efficiency_eta = 0.0;
2000 fill(histoName, Efficiency_eta_passed, Efficiency_eta);
2001 Efficiency_phi_passed = track_phi;
2002 Efficiency_phi = 0.0;
2003 fill(histoName, Efficiency_phi_passed, Efficiency_phi);
2004 Efficiency_pt_passed = track_pt*invGeV;
2005 Efficiency_pt = 0.0;
2006 fill(histoName, Efficiency_pt_passed, Efficiency_pt);
2007 Efficiency_z0_passed = track_z0;
2008 Efficiency_z0 = 0.0;
2009 fill(histoName, Efficiency_z0_passed, Efficiency_z0);
2010 }
2011 }
2012 }
2013 }
2014
2015 // Efficiency calculations
2016 // Insert here
2017
2018 return StatusCode::SUCCESS;
2019}
2020
2021
2027
2028// Fill TRT Hits histograms
2029//----------------------------------------------------------------------------------//
2030StatusCode TRTMonitoringRun3RAW_Alg::fillTRTHits(const EventContext& ctx,
2031 const TrackCollection& trackCollection) const {
2032//----------------------------------------------------------------------------------//
2033 ATH_MSG_VERBOSE("Filling TRT Tracks Histos");
2034
2035 // TH1F
2036 auto HLhitOnTrack_B = Monitored::Scalar<float>("HLhitOnTrack_B", 0.0);
2037 auto HLhitOnTrack_E = Monitored::Scalar<float>("HLhitOnTrack_E", 0.0);
2038 auto HtoLRatioOnTrack_B_Ar = Monitored::Scalar<float>("HtoLRatioOnTrack_B_Ar", 0.0);
2039 auto HtoLRatioOnTrack_B_Xe = Monitored::Scalar<float>("HtoLRatioOnTrack_B_Xe", 0.0);
2040 auto HtoLRatioOnTrack_B = Monitored::Scalar<float>("HtoLRatioOnTrack_B", 0.0);
2041 auto HtoLRatioOnTrack_E = Monitored::Scalar<float>("HtoLRatioOnTrack_E", 0.0);
2042 auto HtoLRatioOnTrack_E_Ar = Monitored::Scalar<float>("HtoLRatioOnTrack_E_Ar", 0.0);
2043 auto HtoLRatioOnTrack_E_Xe = Monitored::Scalar<float>("HtoLRatioOnTrack_E_Xe", 0.0);
2044 auto NumSwLLWoT_E = Monitored::Scalar<float>("NumSwLLWoT_E", 0.0);
2045 auto NumSwLLWoT_B = Monitored::Scalar<float>("NumSwLLWoT_B", 0.0);
2046 auto HitHWonTMapS = Monitored::Scalar<float>("HitHWonTMapS", 0.0);
2047 auto HitWonTMapS = Monitored::Scalar<float>("HitWonTMapS", 0.0);
2048 auto HitAonTMapS = Monitored::Scalar<float>("HitAonTMapS", 0.0);
2049 auto HitAWonTMapS = Monitored::Scalar<float>("HitAWonTMapS", 0.0);
2050 auto HitHonTMapS = Monitored::Scalar<float>("HitHonTMapS", 0.0);
2051 auto HitHWonTMapC = Monitored::Scalar<float>("HitHWonTMapC", 0.0);
2052 auto HitWonTMapC = Monitored::Scalar<float>("HitWonTMapC", 0.0);
2053 auto HitAonTMapC = Monitored::Scalar<float>("HitAonTMapC", 0.0);
2054 auto HitAWonTMapC = Monitored::Scalar<float>("HitAWonTMapC", 0.0);
2055 auto HitHonTMapC = Monitored::Scalar<float>("HitHonTMapC", 0.0);
2056
2057 // TEfficiency
2058 auto StrawEffDetPhi_B = Monitored::Scalar<float>("StrawEffDetPhi_B", 0.0);
2059 auto StrawEffDetPhi_B_passed = Monitored::Scalar<float>("StrawEffDetPhi_B_passed", 0.0);
2060 auto StrawEffDetPhi_E = Monitored::Scalar<float>("StrawEffDetPhi_E", 0.0);
2061 auto StrawEffDetPhi_E_passed = Monitored::Scalar<float>("StrawEffDetPhi_E_passed", 0.0);
2062 auto EfficiencyS = Monitored::Scalar<float>("EfficiencyS", 0.0);
2063 auto EfficiencyS_passed = Monitored::Scalar<bool>("EfficiencyS_passed", false);
2064 auto EfficiencyC = Monitored::Scalar<float>("EfficiencyC", 0.0);
2065 auto EfficiencyC_passed = Monitored::Scalar<bool>("EfficiencyC_passed", false);
2066 auto HtoLonTMapS = Monitored::Scalar<float>("HtoLonTMapS", 0.0);
2067 auto HtoLonTMapS_passed = Monitored::Scalar<bool>("HtoLonTMapS_passed", false);
2068 auto HtoLWonTMapS = Monitored::Scalar<float>("HtoLWonTMapS", 0.0);
2069 auto HtoLWonTMapS_passed = Monitored::Scalar<bool>("HtoLWonTMapS_passed", false);
2070 auto HtoLonTMapC = Monitored::Scalar<float>("HtoLonTMapC", 0.0);
2071 auto HtoLonTMapC_passed = Monitored::Scalar<bool>("HtoLonTMapC_passed", false);
2072 auto HtoLWonTMapC = Monitored::Scalar<float>("HtoLWonTMapC", 0.0);
2073 auto HtoLWonTMapC_passed = Monitored::Scalar<bool>("HtoLWonTMapC_passed", false);
2074 auto HitTronTMapC_x = Monitored::Scalar<float>("HitTronTMapC_x", 0.0);
2075 auto HitTronTMapC_y = Monitored::Scalar<float>("HitTronTMapC_y", 0.0);
2076 auto HitTronTMapS_x = Monitored::Scalar<float>("HitTronTMapS_x", 0.0);
2077 auto HitTronTMapS_y = Monitored::Scalar<float>("HitTronTMapS_y", 0.0);
2078 auto HitToTonTMapS_x = Monitored::Scalar<float>("HitToTonTMapS_x", 0.0);
2079 auto HitToTonTMapS_y = Monitored::Scalar<float>("HitToTonTMapS_y", 0.0);
2080 auto HitToTonTMapC_x = Monitored::Scalar<float>("HitToTonTMapC_x", 0.0);
2081 auto HitToTonTMapC_y = Monitored::Scalar<float>("HitToTonTMapC_y", 0.0);
2082
2083
2084
2085 // TProfile
2086 auto HitWonTMap_B_y = Monitored::Scalar<float>("HitWonTMap_B_y", 0.0);
2087 auto HitWonTMap_E_y = Monitored::Scalar<float>("HitWonTMap_E_y", 0.0);
2088
2089 auto scale_hHitWonTMap_B = std::make_unique<short int[]>(s_Straw_max[0]);
2090 auto scale_hHitWonTMap_E = std::make_unique<short int[][s_Straw_max[1]]>(2);
2091 auto scale_hHitWonTMap_B_passed = std::make_unique<short int[]>(s_Straw_max[0]);
2092 auto scale_hHitWonTMap_E_passed = std::make_unique<short int[][s_Straw_max[1]]>(2);
2093
2094 std::map<int,std::vector<straw_edge_struct>> straw_edge_map;
2095
2096 auto p_trk = trackCollection.begin();
2097
2098 const Trk::Perigee *mPer = nullptr;
2099 const DataVector<const Trk::TrackParameters> *AllTrkPar(nullptr);
2101
2102 int ntrackstack[2][64];
2103
2104 for (int ibe = 0; ibe < 2; ibe++) {
2105 std::fill(ntrackstack[ibe], ntrackstack[ibe] + 64, 0);
2106 }
2107
2108 for (; p_trk != trackCollection.end(); ++p_trk) {
2109 const std::unique_ptr<const Trk::TrackSummary> summary(m_TrackSummaryTool->summary(ctx,*(*p_trk)));
2110 int nTRTHits = summary->get(Trk::numberOfTRTHits);
2111
2112 if (nTRTHits < m_minTRThits) continue;
2113
2114 AllTrkPar = (*p_trk)->trackParameters();
2115
2116 // Search of MeasuredPerigee in TrackParameters
2117 // The following algorithm only finds the First perigee measurement.
2118 // As there should be one and only one perigee measurement then this assumption should be valid.
2119 // But no check is done to see if there is more than one perigee measurement.
2120 for (p_trkpariter = AllTrkPar->begin(); p_trkpariter != AllTrkPar->end(); ++p_trkpariter) {
2121 //if track parameter does have a measured perigee then the track parameter is a keeper and break out of the loop
2122 if ((mPer = dynamic_cast<const Trk::Perigee *>(*p_trkpariter))) break;
2123 }
2124
2125 if (!mPer) continue;
2126
2127 float theta = mPer->parameters()[Trk::theta];
2128 float p = (mPer->parameters()[Trk::qOverP] != 0.) ? std::abs(1. / (mPer->parameters()[Trk::qOverP])) : 10e7;
2129 float pT = (p * sin(theta));
2130 pT = pT * 1e-3; // GeV
2131
2132 if (p < m_minP) continue;
2133
2134 const Trk::TrackStates *trackStates = (**p_trk).trackStateOnSurfaces();
2135
2136 if (trackStates == nullptr) continue;
2137
2138 Trk::TrackStates::const_iterator TSOSItBegin0 = trackStates->begin();
2139 Trk::TrackStates::const_iterator TSOSItBegin = trackStates->begin();
2140 Trk::TrackStates::const_iterator TSOSItBeginTemp = trackStates->begin();
2141 Trk::TrackStates::const_iterator TSOSItEnd = trackStates->end();
2142
2143 const bool passed_track_preselection = (static_cast<bool>(m_trackSelTool->accept(**p_trk)) || m_isCosmics) &&
2144 summary->get(Trk::numberOfTRTHits) >= m_min_trt_hits &&
2145 mPer->pT() > (m_isCosmics?m_min_pT.value() : 2.0 * CLHEP::GeV);
2146
2147 if (!passed_track_preselection) continue;
2148
2149 int nTRTHitsW[2][2];
2150 int nTRTHitsW_Ar[2][2];
2151 int nTRTHitsW_Xe[2][2];
2152 int nTRTHLHitsW[2][2];
2153 int nTRTHLHitsW_Ar[2][2];
2154 int nTRTHLHitsW_Xe[2][2];
2155 int nTRTHits_side[2][2];
2156 int nTRTHitsW_perwheel[2][18];
2157 int hitontrack[2] = {0, 0};
2158 int hitontrack_E_side[2] = {0, 0};
2159
2160 for (int ibe = 0; ibe < 2; ibe++) {
2161 for (int iside = 0; iside < 2; iside++) {
2162 nTRTHits_side[ibe][iside] = -1;
2163 nTRTHitsW[ibe][iside] = 0;
2164 nTRTHitsW_Ar[ibe][iside] = 0;
2165 nTRTHitsW_Xe[ibe][iside] = 0;
2166 nTRTHLHitsW[ibe][iside] = 0;
2167 nTRTHLHitsW_Ar[ibe][iside] = 0;
2168 nTRTHLHitsW_Xe[ibe][iside] = 0;
2169 }
2170 std::fill(nTRTHitsW_perwheel[ibe], nTRTHitsW_perwheel[ibe] + 18, 0);
2171 }
2172
2173 bool isBarrelOnly = true;
2174 bool ECAhit = false;
2175 bool ECChit = false;
2176 bool Bhit = false;
2177 int barrel_ec = 0;
2178 int layer_or_wheel = 0;
2179 int phi_module = 0;
2180 int straw_layer = 0;
2181 int straw = 0;
2182 int nearest_straw_layer[2] = {100, 100};
2183 int nearest_straw[2] = {0, 0};
2184 int testLayer[2] = {100, 100};
2185 float phi2D[2] = {-100, -100};
2186
2187 for (TSOSItBeginTemp = TSOSItBegin0; TSOSItBeginTemp != TSOSItEnd; ++TSOSItBeginTemp) {
2188 if ((*TSOSItBeginTemp) == nullptr) continue;
2189
2190 if (! ((*TSOSItBeginTemp)->type(Trk::TrackStateOnSurface::Measurement)) ) continue;
2191 const InDet::TRT_DriftCircleOnTrack *trtCircle = dynamic_cast<const InDet::TRT_DriftCircleOnTrack *>((*TSOSItBeginTemp)->measurementOnTrack());
2192
2193 if (!trtCircle) continue;
2194 const Trk::TrackParameters *aTrackParam = dynamic_cast<const Trk::TrackParameters *>((*TSOSItBeginTemp)->trackParameters());
2195
2196 if (!aTrackParam) continue;
2197 Identifier DCoTId = trtCircle->identify();
2198 barrel_ec = m_pTRTHelper->barrel_ec(DCoTId);
2199 int ibe = std::abs(barrel_ec) - 1;
2200 layer_or_wheel = m_pTRTHelper->layer_or_wheel (DCoTId);
2201 straw_layer = m_pTRTHelper->straw_layer(DCoTId);
2202 straw = m_pTRTHelper->straw(DCoTId);
2203
2204 // Restrict ourselves to the inner most TRT layers To get detector phi.
2205 if (layer_or_wheel >= testLayer[ibe]) continue;
2206 testLayer[ibe] = layer_or_wheel;
2207
2208 if (straw_layer < nearest_straw_layer[ibe]) {
2209 nearest_straw_layer[ibe] = straw_layer;
2210 nearest_straw[ibe] = straw;
2211 const InDetDD::TRT_BaseElement *circleElement = nullptr;
2212 circleElement = trtCircle->detectorElement();
2213 phi2D[ibe] = radToDegrees(circleElement->strawCenter(nearest_straw[ibe]).phi());
2214 circleElement = nullptr;
2215 }
2216 }
2217
2218 if (phi2D[0] == -999) {
2219 ATH_MSG_DEBUG("Track did not go through inner layer of Barrel.");
2220 } else {
2221 ATH_MSG_VERBOSE("Track's closest approach is m_layer_or_wheel: " <<
2222 testLayer[0] << " m_straw_layer: " <<
2223 nearest_straw_layer[0] << " (in the Barrel).");
2224 }
2225
2226 if (phi2D[1] == -999) {
2227 ATH_MSG_DEBUG("Track did not go through any inner layer of EndCap A or C.");
2228 } else {
2229 ATH_MSG_VERBOSE("Track's closest approach is m_layer_or_wheel: " <<
2230 testLayer[1] << " m_straw_layer: " <<
2231 nearest_straw_layer[1] << " (in the EndCaps).");
2232 }
2233
2234 bool trackfound[2][64];
2235
2236 for (int i = 0; i < 2; i++) {
2237 std::fill(trackfound[i], trackfound[i] + 64, false);
2238 }
2239
2240 for (TSOSItBegin = TSOSItBegin0; TSOSItBegin != TSOSItEnd; ++TSOSItBegin) {
2241 // Select a TSOS which is non-empty, measurement type and contains both drift circle and track parameters informations
2242 if ((*TSOSItBegin) == nullptr) continue;
2243
2244 if ( !((*TSOSItBegin)->type(Trk::TrackStateOnSurface::Measurement)) ) continue;
2245
2246 const InDet::TRT_DriftCircleOnTrack *trtCircle = dynamic_cast<const InDet::TRT_DriftCircleOnTrack *>((*TSOSItBegin)->measurementOnTrack());
2247
2248 if (!trtCircle) continue;
2249
2250 const Trk::TrackParameters *aTrackParam = dynamic_cast<const Trk::TrackParameters *>((*TSOSItBegin)->trackParameters());
2251
2252 if (!aTrackParam) continue;
2253
2254 Identifier DCoTId = trtCircle->identify();
2255 barrel_ec = m_pTRTHelper->barrel_ec(DCoTId);
2256 layer_or_wheel = m_pTRTHelper->layer_or_wheel(DCoTId);
2257 phi_module = m_pTRTHelper->phi_module(DCoTId);
2258 straw_layer = m_pTRTHelper->straw_layer(DCoTId);
2259 straw = m_pTRTHelper->straw(DCoTId);
2260 int ibe = std::abs(barrel_ec) - 1; // ibe = 0 (Barrel), ibe = 1 (Endcap)
2261 int iside = barrel_ec > 0 ? 0 : 1; // iside = 0 (Side A), iside = 1 (Side C)
2262 int thisStrawNumber[2] = {-1, -1};
2263 int chip[2] = {0, 0};
2264
2265 if (ibe == 0) {
2266 thisStrawNumber[ibe] = strawNumber(straw, straw_layer, layer_or_wheel);
2267
2268 if (thisStrawNumber[ibe] >= 0 && thisStrawNumber[ibe] < s_Straw_max[ibe]) {
2269 chip[ibe] = m_mat_chip_B.at(phi_module).at(thisStrawNumber[ibe]);
2270 }
2271 } else if (ibe == 1) {
2272 thisStrawNumber[ibe] = strawNumberEndCap(straw, straw_layer, layer_or_wheel, phi_module, barrel_ec);
2273
2274 if (thisStrawNumber[ibe] >= 0 && thisStrawNumber[ibe] < s_Straw_max[ibe]) {
2275 chip[ibe] = m_mat_chip_E.at(phi_module).at(thisStrawNumber[ibe]);
2276 }
2277 } else {
2278 thisStrawNumber[ibe] = -1;
2279 }
2280
2281 if (thisStrawNumber[ibe] < 0 || thisStrawNumber[ibe] >= s_Straw_max[ibe]) continue;
2282
2283 if (ibe == 0) {
2284 Bhit = true;
2285 } else if (barrel_ec == 2) {
2286 isBarrelOnly = false;
2287 ECAhit = true;
2288 } else if (barrel_ec == -2) {
2289 isBarrelOnly = false;
2290 ECChit = true;
2291 }
2292
2293 Identifier surfaceID;
2294 surfaceID = trtCircle->identify();
2295 const bool isArgonStraw = ( Straw_Gastype( m_sumTool->getStatusHT(surfaceID, ctx) ) == GasType::Ar );
2296 // Assume always Xe if m_ArgonXenonSplitter is not enabled, otherwise check the straw status (good is Xe, non-good is Ar)
2297 float temp_locr = aTrackParam->parameters()[Trk::driftRadius];
2298 int iphi_module = -9999;
2299
2300 if (iside == 0) iphi_module = phi_module;
2301 else if (iside == 1) iphi_module = phi_module + 32;
2302
2303 trackfound[ibe][iphi_module] = true;
2304
2305 if (((ibe == 0) && (temp_locr < m_DistToStraw)) ||
2306 ((ibe == 1) && ((*TSOSItBegin)->type(Trk::TrackStateOnSurface::Measurement) ||
2307 (*TSOSItBegin)->type(Trk::TrackStateOnSurface::Outlier) ||
2308 (*TSOSItBegin)->type(Trk::TrackStateOnSurface::Hole)) &&
2309 (temp_locr < m_DistToStraw))) {
2310 if (m_idHelper->is_trt(DCoTId)) {
2311 if (ibe == 0) {
2312 hitontrack[ibe]++;
2313
2314 if (m_doShift) {
2315 StrawEffDetPhi_B_passed = phi_module;
2316 StrawEffDetPhi_B = 1.0;
2317 fill("ShiftTRTTrackHistograms"+std::to_string(ibe), StrawEffDetPhi_B_passed, StrawEffDetPhi_B);
2318
2319 if (m_doStraws) scale_hHitWonTMap_B[thisStrawNumber[ibe]]++;
2320 }
2321
2322 } else if (ibe == 1) {
2323 hitontrack[ibe]++;
2324 hitontrack_E_side[iside]++;
2325
2326 if (m_doShift) {
2327 StrawEffDetPhi_E_passed = phi_module;
2328 StrawEffDetPhi_E = 1.0;
2329 fill("ShiftTRTTrackHistograms"+std::to_string(ibe)+std::to_string(iside), StrawEffDetPhi_E_passed, StrawEffDetPhi_E);
2330
2331 if (m_doStraws) scale_hHitWonTMap_E[iside][thisStrawNumber[ibe]]++;
2332 }
2333 }
2334
2335 if (m_doStraws && m_doExpert) {
2336 EfficiencyS = thisStrawNumber[ibe];
2337 EfficiencyS_passed = 1.0;
2338 fill("TRTTrackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), EfficiencyS_passed, EfficiencyS);
2339 }
2340
2341 if (m_doChips && m_doExpert) {
2342 EfficiencyC = chip[ibe] - 1;
2343 EfficiencyC_passed = 1.0;
2344 fill("TRTTrackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), EfficiencyC_passed, EfficiencyC);
2345 }
2346 }
2347 } else {
2348 if (m_idHelper->is_trt(DCoTId)) { // ToDo: Is this really needed?
2349 if (ibe == 0) {
2350 if (m_doShift) {
2351 StrawEffDetPhi_B_passed = phi_module;
2352 StrawEffDetPhi_B = 0.0;
2353 fill("ShiftTRTTrackHistograms"+std::to_string(ibe), StrawEffDetPhi_B_passed, StrawEffDetPhi_B);
2354
2355 if (m_doStraws) scale_hHitWonTMap_B[thisStrawNumber[ibe]]++;
2356 }
2357 } else if (ibe == 1) {
2358 if (m_doShift) {
2359 StrawEffDetPhi_E_passed = phi_module;
2360 StrawEffDetPhi_E = 0.0;
2361 fill("ShiftTRTTrackHistograms"+std::to_string(ibe)+std::to_string(iside), StrawEffDetPhi_E_passed, StrawEffDetPhi_E);
2362
2363 if (m_doStraws) scale_hHitWonTMap_E[iside][thisStrawNumber[ibe]]++;
2364 }
2365 }
2366
2367 if (m_doStraws && m_doExpert) {
2368 EfficiencyS = thisStrawNumber[ibe];
2369 EfficiencyS_passed = 0.0;
2370 fill("TRTTrackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), EfficiencyS_passed, EfficiencyS);
2371 }
2372
2373 if (m_doChips && m_doExpert) {
2374 EfficiencyC = chip[ibe] - 1;
2375 EfficiencyC_passed = 0.0;
2376 fill("TRTTrackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), EfficiencyC_passed, EfficiencyC);
2377 }
2378 }
2379 }
2380 const InDet::TRT_DriftCircle *RawDriftCircle = dynamic_cast<const InDet::TRT_DriftCircle *>(trtCircle->prepRawData());
2381 if (RawDriftCircle) {
2382 nTRTHits_side[ibe][iside]++;
2383 float timeOverThreshold = RawDriftCircle->timeOverThreshold();
2384 int middleHTbit = RawDriftCircle->getWord() & 0x00020000;
2385 //0x00020000 = 0000 0000 0000 0000 0000 0010 0000 0000 0000 0000
2386 int hitinvaliditygate = RawDriftCircle->getWord() & 0x000DFE80;
2387 //0x000DFE80 = 0000 0000 0000 0000 0000 1101 1111 1110 1000 0000
2388 bool is_middleHTbit_high = (middleHTbit != 0);
2389 bool is_anybininVgate_high = (hitinvaliditygate != 0);
2390
2391 if (m_doExpert && m_doStraws) {
2392 HitToTonTMapS_x = thisStrawNumber[ibe];
2393 HitToTonTMapS_y = timeOverThreshold;
2394 fill("TRTTrackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), HitToTonTMapS_x, HitToTonTMapS_y);
2395 }
2396
2397 if (m_doExpert && m_doChips) {
2398 HitToTonTMapC_x = chip[ibe] - 1;
2399 HitToTonTMapC_y = timeOverThreshold;
2400 fill("TRTTrackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), HitToTonTMapC_x, HitToTonTMapC_y);
2401 }
2402
2403 if (m_doExpert && m_doStraws) {
2404 if (is_middleHTbit_high) {
2405 HitHonTMapS = thisStrawNumber[ibe];
2406 fill("TRTTrackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), HitHonTMapS);
2407 HitHWonTMapS = thisStrawNumber[ibe];
2408 fill("TRTTrackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), HitHWonTMapS);
2409
2410 HtoLonTMapS = thisStrawNumber[ibe];
2411 HtoLonTMapS_passed = 1.0;
2412 fill("TRTTrackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), HtoLonTMapS_passed, HtoLonTMapS);
2413 HtoLWonTMapS = thisStrawNumber[ibe];
2414 HtoLWonTMapS_passed = 1.0;
2415 fill("TRTTrackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), HtoLWonTMapS_passed, HtoLWonTMapS);
2416 }
2417 }
2418
2419 if (m_doExpert && m_doChips) {
2420 if (is_middleHTbit_high) {
2421 HitHWonTMapC = chip[ibe] - 1;
2422 fill("TRTTrackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), HitHWonTMapC);
2423 HitHonTMapC = chip[ibe] - 1;
2424 fill("TRTTrackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), HitHonTMapC);
2425 HtoLonTMapC = chip[ibe] - 1;
2426 HtoLonTMapC_passed = 1.0;
2427 fill("TRTTrackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), HtoLonTMapC_passed, HtoLonTMapC);
2428 HtoLWonTMapC = chip[ibe] - 1;
2429 HtoLWonTMapC_passed = 1.0;
2430 fill("TRTTrackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), HtoLWonTMapC_passed, HtoLWonTMapC);
2431 }
2432 }
2433
2434 const int driftTimeBin = RawDriftCircle->driftTimeBin();
2435
2436 if ( (driftTimeBin < 24) &&
2437 !(RawDriftCircle->lastBinHigh()) &&
2438 !(RawDriftCircle->firstBinHigh()) ) {
2439 if (m_doStraws && m_doShift) {
2440 if (ibe == 0) {
2441 straw_edge_struct& this_struct = straw_edge_map[1].emplace_back(); // index 1 is Barrel
2442 this_struct.strawNumber = thisStrawNumber[ibe];
2443 this_struct.HitWonTMap_B_y = 1.0;
2444 scale_hHitWonTMap_B_passed[thisStrawNumber[ibe]]++;
2445 } else if (ibe == 1) {
2446 straw_edge_struct& this_struct = straw_edge_map[iside == 0 ? 2 : -2].emplace_back(); // index 2 is EA, index -2 is EC
2447 this_struct.strawNumber = thisStrawNumber[ibe];
2448 this_struct.HitWonTMap_E_y = 1.0;
2449 scale_hHitWonTMap_E_passed[iside][thisStrawNumber[ibe]]++;
2450 }
2451 }
2452 }
2453
2454 if ((driftTimeBin > 2) && (driftTimeBin < 17)) {
2455 if (m_doExpert && m_doStraws) {
2456 HitWonTMapS = thisStrawNumber[ibe];
2457 fill("TRTTrackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), HitWonTMapS);
2458
2459 }
2460 if (m_doExpert && m_doChips) {
2461 HitWonTMapC = chip[ibe] - 1;
2462 fill("TRTTrackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), HitWonTMapC);
2463 }
2464 }
2465
2466 const int trailingEdge = RawDriftCircle->trailingEdge();
2467 float trailingEdgeScaled = (trailingEdge + 1) * 3.125;
2468
2469 if ((trailingEdge < 23) &&
2470 !(RawDriftCircle->lastBinHigh()) &&
2471 !(RawDriftCircle->firstBinHigh())) {
2472 if (m_doExpert && m_doStraws) {
2473 HitTronTMapS_x = thisStrawNumber[ibe];
2474 HitTronTMapS_y = trailingEdgeScaled;
2475 fill("TRTTrackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), HitTronTMapS_x, HitTronTMapS_y);
2476 }
2477
2478 if (m_doExpert && m_doChips) {
2479 HitTronTMapC_x = chip[ibe] - 1;
2480 HitTronTMapC_y = trailingEdgeScaled;
2481 fill("TRTTrackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), HitTronTMapC_x, HitTronTMapC_y);
2482 }
2483 }
2484
2485 const bool firstBinHigh = RawDriftCircle->firstBinHigh();
2486 const bool lastBinHigh = RawDriftCircle->lastBinHigh();
2487
2488 if (firstBinHigh || lastBinHigh || driftTimeBin > 0 || trailingEdge < 23) {
2489 if (m_doExpert && m_doStraws) {
2490 HitAonTMapS = thisStrawNumber[ibe];
2491 fill("TRTTrackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), HitAonTMapS);
2492
2493 if (!is_middleHTbit_high) {
2494 HtoLonTMapS = thisStrawNumber[ibe];
2495 HtoLonTMapS_passed = 0.0;
2496 fill("TRTTrackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), HtoLonTMapS_passed, HtoLonTMapS);
2497 }
2498 }
2499
2500 if (m_doExpert && m_doChips) {
2501 HitAonTMapC = chip[ibe] - 1;
2502 fill("TRTTrackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), HitAonTMapC);
2503 if (!is_middleHTbit_high) {
2504 HtoLonTMapC = chip[ibe] - 1;
2505 HtoLonTMapC_passed = 0.0;
2506 fill("TRTTrackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), HtoLonTMapC_passed, HtoLonTMapC);
2507 }
2508 }
2509
2510 nTRTHitsW[ibe][iside]++;
2511
2512 if (isArgonStraw) nTRTHitsW_Ar[ibe][iside]++;
2513 else nTRTHitsW_Xe[ibe][iside]++;
2514
2515 nTRTHitsW_perwheel[iside][layer_or_wheel]++;
2516
2517 if (is_middleHTbit_high) {
2518 nTRTHLHitsW[ibe][iside]++;
2519 if (isArgonStraw) nTRTHLHitsW_Ar[ibe][iside]++;
2520 else nTRTHLHitsW_Xe[ibe][iside]++;
2521 }
2522 }
2523
2524 if (is_anybininVgate_high) {
2525 if (m_doExpert && m_doStraws) {
2526 HitAWonTMapS = thisStrawNumber[ibe];
2527 fill("TRTTrackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), HitAWonTMapS);
2528
2529 if (!is_middleHTbit_high) {
2530 HtoLWonTMapS = thisStrawNumber[ibe];
2531 HtoLWonTMapS_passed = 0.0;
2532 fill("TRTTrackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), HtoLWonTMapS_passed, HtoLWonTMapS);
2533 }
2534 }
2535
2536 if (m_doExpert && m_doChips) {
2537 HitAWonTMapC = chip[ibe] - 1;
2538 fill("TRTTrackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), HitAWonTMapC);
2539
2540 if (!is_middleHTbit_high) {
2541 HtoLWonTMapC = chip[ibe] - 1;
2542 HtoLWonTMapC_passed = 0.0;
2543 fill("TRTTrackHistograms"+std::to_string(ibe)+std::to_string(iphi_module), HtoLWonTMapC_passed, HtoLWonTMapC);
2544 }
2545 }
2546 }
2547 }
2548 }
2549
2550 // ToDo: work on the part below
2551 for (int ibe = 0; ibe < 2; ibe++) {
2552 for (int i = 0; i < 64; i++)
2553 if (trackfound[ibe][i])
2554 ntrackstack[ibe][i]++;
2555
2556 if (phi2D[ibe] < 0) continue;
2557
2558
2559 if (m_doShift) {
2560 if (ibe == 0) {
2561 if (isBarrelOnly) {
2562 if (nTRTHitsW[ibe][0] > 0) {
2563 if (nTRTHitsW[ibe][1] > 0) {
2564 NumSwLLWoT_B = nTRTHitsW[ibe][0] + nTRTHitsW[ibe][1];
2565 fill("ShiftTRTTrackHistograms"+std::to_string(ibe), NumSwLLWoT_B);
2566 }
2567 else {
2568 NumSwLLWoT_B = nTRTHitsW[ibe][0];
2569 fill("ShiftTRTTrackHistograms"+std::to_string(ibe), NumSwLLWoT_B);
2570 }
2571 } else if (nTRTHitsW[ibe][1] > 0) {
2572 NumSwLLWoT_B = nTRTHitsW[ibe][1];
2573 fill("ShiftTRTTrackHistograms"+std::to_string(ibe), NumSwLLWoT_B);
2574 }
2575 }
2576
2577 if (nTRTHLHitsW[ibe][0] > 0) {
2578 if (nTRTHLHitsW[ibe][1] > 0) {
2579 HLhitOnTrack_B = nTRTHLHitsW[ibe][0] + nTRTHLHitsW[ibe][1];
2580 fill("ShiftTRTTrackHistograms"+std::to_string(ibe), HLhitOnTrack_B);
2581 } else {
2582 HLhitOnTrack_B = nTRTHLHitsW[ibe][0];
2583 fill("ShiftTRTTrackHistograms"+std::to_string(ibe), HLhitOnTrack_B);
2584 }
2585 } else if (nTRTHLHitsW[ibe][1] > 0) {
2586 HLhitOnTrack_B = nTRTHLHitsW[ibe][1];
2587 fill("ShiftTRTTrackHistograms"+std::to_string(ibe), HLhitOnTrack_B);
2588 }
2589
2590 if (nTRTHitsW[ibe][0] + nTRTHitsW[ibe][1] > 0) {
2591 HtoLRatioOnTrack_B = (float)(nTRTHLHitsW[ibe][0] + nTRTHLHitsW[ibe][1]) / (nTRTHitsW[ibe][0] + nTRTHitsW[ibe][1]);
2592 fill("ShiftTRTTrackHistograms"+std::to_string(ibe), HtoLRatioOnTrack_B);
2593 }
2594
2595 if (nTRTHitsW_Ar[ibe][0] + nTRTHitsW_Ar[ibe][1] > 0) {
2596 HtoLRatioOnTrack_B_Ar = (float)(nTRTHLHitsW_Ar[ibe][0] + nTRTHLHitsW_Ar[ibe][1]) / (nTRTHitsW_Ar[ibe][0] + nTRTHitsW_Ar[ibe][1]);
2597 fill("ShiftTRTTrackHistograms"+std::to_string(ibe), HtoLRatioOnTrack_B_Ar);
2598 }
2599
2600 if (nTRTHitsW_Xe[ibe][0] + nTRTHitsW_Xe[ibe][1] > 0) {
2601 HtoLRatioOnTrack_B_Xe = (float)(nTRTHLHitsW_Xe[ibe][0] + nTRTHLHitsW_Xe[ibe][1]) / (nTRTHitsW_Xe[ibe][0] + nTRTHitsW_Xe[ibe][1]);
2602 fill("ShiftTRTTrackHistograms"+std::to_string(ibe), HtoLRatioOnTrack_B_Xe);
2603 }
2604 } else if (ibe == 1) {
2605 if (nTRTHitsW[ibe][0] > 0) {
2606 if (nTRTHitsW[ibe][1] > 0) {
2607 if (ECAhit && !ECChit && !Bhit) {
2608 NumSwLLWoT_E = nTRTHitsW[ibe][0];
2609 fill("ShiftTRTTrackHistograms"+std::to_string(ibe)+"0", NumSwLLWoT_E);
2610 }
2611
2612 if (ECChit && !ECAhit && !Bhit) {
2613 NumSwLLWoT_E = nTRTHitsW[ibe][1];
2614 fill("ShiftTRTTrackHistograms"+std::to_string(ibe)+"1", NumSwLLWoT_E);
2615 }
2616 }
2617
2618 if (ECAhit && !ECChit && !Bhit) {
2619 NumSwLLWoT_E = nTRTHitsW[ibe][0];
2620 fill("ShiftTRTTrackHistograms"+std::to_string(ibe)+"0", NumSwLLWoT_E);
2621 }
2622 } else if (nTRTHitsW[ibe][1] > 0) {
2623 if (ECChit && !ECAhit && !Bhit) {
2624 NumSwLLWoT_E = nTRTHitsW[ibe][1];
2625 fill("ShiftTRTTrackHistograms"+std::to_string(ibe)+"1", NumSwLLWoT_E);
2626 }
2627 }
2628
2629 for (int iside = 0; iside < 2; iside++) {
2630 if (nTRTHLHitsW[ibe][iside] > 0) {
2631 HLhitOnTrack_E = nTRTHLHitsW[ibe][iside];
2632 fill("ShiftTRTTrackHistograms"+std::to_string(ibe)+std::to_string(iside), HLhitOnTrack_E);
2633 }
2634
2635 if ((nTRTHitsW[ibe][iside]) > 0) {
2636 HtoLRatioOnTrack_E = (float)(nTRTHLHitsW[ibe][iside]) / nTRTHitsW[ibe][iside];
2637 fill("ShiftTRTTrackHistograms"+std::to_string(ibe)+std::to_string(iside), HtoLRatioOnTrack_E);
2638
2639 if ((nTRTHitsW_Ar[ibe][iside]) > 0) {
2640 HtoLRatioOnTrack_E_Ar = (float)(nTRTHLHitsW_Ar[ibe][iside]) / nTRTHitsW_Ar[ibe][iside];
2641 fill("ShiftTRTTrackHistograms"+std::to_string(ibe)+std::to_string(iside), HtoLRatioOnTrack_E_Ar);
2642 }
2643
2644 if ((nTRTHitsW_Xe[ibe][iside]) > 0) {
2645 HtoLRatioOnTrack_E_Xe = (float)(nTRTHLHitsW_Xe[ibe][iside]) / nTRTHitsW_Xe[ibe][iside];
2646 fill("ShiftTRTTrackHistograms"+std::to_string(ibe)+std::to_string(iside), HtoLRatioOnTrack_E_Xe);
2647 }
2648 }
2649 }
2650 }
2651 }
2652 }
2653 }
2654
2655 // Barrel straw normalization
2656 for (int k = 0; k < s_Straw_max[0]; k++) {
2657 try {
2658 if (scale_hHitWonTMap_B[k] - scale_hHitWonTMap_B_passed[k] >= 0) {
2659 for (int j = 0; j < scale_hHitWonTMap_B[k] - scale_hHitWonTMap_B_passed[k]; j++) {
2660 if (m_doStraws) {
2661 straw_edge_struct& this_struct = straw_edge_map[1].emplace_back(); // index 1 is Barrel
2662 this_struct.strawNumber = k;
2663 this_struct.HitWonTMap_B_y = 0;
2664 }
2665 }
2666 } else {
2667 ATH_MSG_ERROR("Scale value " << scale_hHitWonTMap_B[k] - scale_hHitWonTMap_B_passed[k] <<
2668 " is less than zero in scaling for Barrel, k = " << k);
2669 }
2670 } catch (out_of_range &e) {
2671 ATH_MSG_ERROR("Index " << k << " out of range in scaling for Barrel");
2672 }
2673 }
2674
2675 // Endcap straw normalization
2676 for (int k = 0; k < s_Straw_max[1]; k++) {
2677 for (int iside = 0; iside < 2; iside++) {
2678 try {
2679 if (scale_hHitWonTMap_E[iside][k] - scale_hHitWonTMap_E_passed[iside][k] >= 0) {
2680 for (int j = 0; j < scale_hHitWonTMap_E[iside][k] - scale_hHitWonTMap_E_passed[iside][k]; j++) {
2681 if (m_doStraws) {
2682 straw_edge_struct& this_struct = straw_edge_map[iside == 0 ? 2 : -2].emplace_back(); // index 2 is EA, index -2 is EC
2683 this_struct.strawNumber = k;
2684 this_struct.HitWonTMap_E_y = 0;
2685 }
2686 }
2687 } else {
2688 ATH_MSG_ERROR("Scale value " << scale_hHitWonTMap_E[iside][k] - scale_hHitWonTMap_E_passed[iside][k] <<
2689 " is less than zero in scaling for Endcap, iside = " << iside << ", k = " << k);
2690 }
2691 } catch (out_of_range &e) {
2692 ATH_MSG_ERROR("Index " << k << " out of range in scaling for Endcap");
2693 }
2694 }
2695 }
2696
2697 for (const auto& ibarrel_ecpair : straw_edge_map) {
2698 int ibe = abs(ibarrel_ecpair.first) - 1;
2699 int iside = ibarrel_ecpair.first > 0 ? 0 : 1;
2700 auto strawNumber = Monitored::Collection("strawNumber", ibarrel_ecpair.second, [](const auto& s){return s.strawNumber;});
2701 auto HitWonTMap_B_y = Monitored::Collection("HitWonTMap_B_y", ibarrel_ecpair.second, [](const auto& s){return s.HitWonTMap_B_y;});
2702 auto HitWonTMap_E_y = Monitored::Collection("HitWonTMap_E_y", ibarrel_ecpair.second, [](const auto& s){return s.HitWonTMap_E_y;});
2703 if (ibe == 0) {
2704 fill("ShiftTRTTrackHistograms0", strawNumber, HitWonTMap_B_y);
2705 } else if (ibe == 1) {
2706 fill("ShiftTRTTrackHistograms1"+std::to_string(iside), strawNumber, HitWonTMap_E_y);
2707 }
2708 }
2709
2710 return StatusCode::SUCCESS;
2711}
2712
2713
2714StatusCode TRTMonitoringRun3RAW_Alg::fillHistograms( const EventContext& ctx ) const {
2715 using namespace Monitored;
2716 bool passEventBurst;
2717
2718 ATH_MSG_VERBOSE("Monitoring Histograms being filled");
2719
2721 SG::ReadHandle<xAOD::EventInfo> xAODEventInfo = GetEventInfo(ctx);
2725
2726 if (m_doRDOsMon) {
2727 if (!rdoContainer.isValid()) {
2728 ATH_MSG_ERROR("Could not find TRT Raw Data Object " << m_rdoContainerKey.key() <<
2729 " in store");
2730 return StatusCode::FAILURE;
2731 }
2732
2733 passEventBurst = checkEventBurst(*rdoContainer);
2734 if (passEventBurst) {
2735 if (!trtBCIDCollection.isValid()) {
2736 ATH_MSG_INFO("Could not find BCID collection " << m_TRT_BCIDCollectionKey.key() <<
2737 " in store");
2738 }
2739
2740 ATH_CHECK( fillTRTRDOs(ctx, *rdoContainer, *xAODEventInfo, trtBCIDCollection.ptr()) );
2741 }
2742 } else passEventBurst = true;
2743
2744 if (m_useHoleFinder) {
2745 if (!combTrackCollection.isValid()) {
2746 ATH_MSG_ERROR("Could not find track collection " << m_combTrackCollectionKey.key() <<
2747 " in store");
2748 return StatusCode::FAILURE;
2749 }
2750 ATH_CHECK( fillTRTEfficiency(ctx, *combTrackCollection) );
2751 }
2752
2753 if (m_doHitsMon) {
2754 if (!trackCollection.isValid()) {
2755 ATH_MSG_ERROR("Could not find track collection " << m_trackCollectionKey.key() <<
2756 " in store");
2757 return StatusCode::FAILURE;
2758 }
2759 if (passEventBurst) {
2760 ATH_CHECK( fillTRTHits(ctx, *trackCollection) );
2761 }
2762 }
2763
2764 return StatusCode::SUCCESS;
2765}
#define M_PI
Scalar theta() const
theta method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
An STL vector of pointers that by default owns its pointed-to elements.
abstract interface to TRT calibration constants
Abstract interface to information on straws electronic grouping.
abstract interface to TRT straw status constants
std::vector< std::pair< uint32_t, unsigned int > > InDetTimeCollection
static Double_t sc
constexpr float invGeV
This is an Identifier helper class for the TRT subdetector.
InDetRawDataContainer< InDetRawDataCollection< TRT_RDORawData > > TRT_RDO_Container
DataVector< Trk::Track > TrackCollection
This typedef represents a collection of Trk::Track objects.
const ServiceHandle< StoreGateSvc > & detStore() const
virtual StatusCode initialize() override
initialize
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.).
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
AthMonitorAlgorithm::Environment_t m_environment
Instance of the Environment_t enum.
Derived DataVector<T>.
Definition DataVector.h:795
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.
size_type size() const noexcept
Returns the number of elements in 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 base class of TRT readout elements.
unsigned int nStraws() const
Number of straws in the element.
const Amg::Vector3D & strawCenter(int straw) const
Straw Surface: Local -> global transform of the straw via integer.
virtual Identifier identify() const override final
Represents 'corrected' measurements from the TRT (for example, corrected for wire sag).
virtual const InDetDD::TRT_BaseElement * detectorElement() const override final
returns the detector element, assoicated with the PRD of this class
virtual const TRT_DriftCircle * prepRawData() const override final
returns the PrepRawData - is a TRT_DriftCircle in this scope
unsigned int getWord() const
returns the TRT dataword
int driftTimeBin() const
returns the leading edge bin defined as in TRT_LoLumRawData to be the first 0-1 transition
bool lastBinHigh() const
returns true if the last bin is high
bool firstBinHigh() const
returns true if the first bin is high
double timeOverThreshold() const
returns Time over threshold in ns
int trailingEdge() const
returns the trailing edge bin
Declare a monitored scalar variable.
const_pointer_type ptr()
Dereference the pointer.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
GasType Straw_Gastype(int stat) const
const AtlasDetectorID * m_idHelper
int strawLayerNumber(int strawLayerNumber, int LayerNumber) const
int strawLayerNumber_reverse(int strawLayerNumInp, int *strawLayerNumber, int *LayerNumber) const
ToolHandle< ITRT_StrawStatusSummaryTool > m_sumTool
std::vector< std::vector< std::vector< int > > > initScaleVectors(const EventContext &ctx) const
SG::ReadHandleKey< TRT_RDO_Container > m_rdoContainerKey
float radToDegrees(float radValue) const
SG::ReadHandleKey< TRT_BSErrContainer > m_bsErrContKey
StatusCode checkTRTReadoutIntegrity(const xAOD::EventInfo &eventInfo) const
StatusCode fillTRTRDOs(const EventContext &ctx, const TRT_RDO_Container &rdoContainer, const xAOD::EventInfo &eventInfo, const InDetTimeCollection *trtBCIDCollection) const
SG::ReadHandleKey< InDetTimeCollection > m_TRT_BCIDCollectionKey
bool checkEventBurst(const TRT_RDO_Container &rdoContainer) const
const InDetDD::TRT_DetectorManager * m_mgr
int strawNumber_reverse(int inp_strawnumber, int *strawNumber, int *strawlayerNumber, int *LayerNumber) const
StatusCode fillTRTHits(const EventContext &ctx, const TrackCollection &trackCollection) const
ToolHandle< Trk::ITrackHoleSearchTool > m_trt_hole_finder
SG::ReadHandleKey< TrackCollection > m_combTrackCollectionKey
std::vector< std::vector< unsigned char > > m_mat_chip_B
std::vector< std::vector< unsigned char > > m_mat_chip_E
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
ToolHandle< InDet::IInDetTrackSelectionTool > m_trackSelTool
int strawNumber(int strawNumber, int strawlayerNumber, int LayerNumber) const
StatusCode fillTRTEfficiency(const EventContext &ctx, const TrackCollection &combTrackCollection) const
SG::ReadHandleKey< TrackCollection > m_trackCollectionKey
ToolHandle< Trk::ITrackSummaryTool > m_TrackSummaryTool
ServiceHandle< ITRT_StrawNeighbourSvc > m_TRTStrawNeighbourSvc
int strawNumberEndCap(int strawNumber, int strawLayerNumber, int LayerNumber, int phi_stack, int side) const
TRTMonitoringRun3RAW_Alg(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize() override
initialize
ServiceHandle< ITRT_ByteStream_ConditionsSvc > m_BSSvc
const std::set< uint32_t > & getMissingErrorSet(void) const
const std::set< std::pair< uint32_t, uint32_t > > & getBCIDErrorSet() const
const std::set< std::pair< uint32_t, uint32_t > > & getRobErrorSet(void) const
const std::set< uint32_t > & getSidErrorSet(void) const
const std::set< std::pair< uint32_t, uint32_t > > & getL1ErrorSet() const
virtual double timeOverThreshold() const override final
bool firstBinHigh() const
bool lastBinHigh() const
virtual bool highLevel() const override final
int trailingEdge() const
virtual int driftTimeBin() const override final
double eta() const
Access method for pseudorapidity - from momentum.
virtual const Surface & associatedSurface() const override=0
Access to the Surface associated to the Parameters.
double pT() const
Access method for transverse momentum.
Identifier identify() const
return the identifier -extends MeasurementBase
Identifier associatedDetectorElementIdentifier() const
return Identifier of the associated Detector Element
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
@ Outlier
This TSoS contains an outlier, that is, it contains a MeasurementBase/RIO_OnTrack which was not used ...
@ Hole
A hole on the track - this is defined in the following way.
uint32_t lumiBlock() const
The current event's luminosity block number.
uint32_t bcid() const
The bunch crossing ID of the event.
std::vector< std::string > remainder(const std::vector< std::string > &v1, const std::vector< std::string > &v2)
int trailingEdge(unsigned int m_word)
Definition driftCircle.h:64
double timeOverThreshold(unsigned int m_word)
int driftTimeBin(unsigned int m_word)
Definition driftCircle.h:50
bool lastBinHigh(unsigned int m_word)
bool firstBinHigh(unsigned int m_word)
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:148
Generic monitoring tool for athena components.
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
DataVector< const Trk::TrackStateOnSurface > TrackStates
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
@ driftRadius
trt, straws
Definition ParamDefs.h:53
@ phi0
Definition ParamDefs.h:65
@ theta
Definition ParamDefs.h:66
@ qOverP
perigee
Definition ParamDefs.h:67
@ d0
Definition ParamDefs.h:63
@ z0
Definition ParamDefs.h:64
ParametersBase< TrackParametersDim, Charged > TrackParameters
@ numberOfPixelHits
number of pixel layers on track with absence of hits
Definition index.py:1
STL namespace.
EventInfo_v1 EventInfo
Definition of the latest event info version.
void fill(H5::Group &out_file, size_t iterations)
Tell the compiler to optimize assuming that FP may trap.
#define CXXUTILS_TRAPPING_FP
Definition trapping_fp.h:24