ATLAS Offline Software
Loading...
Searching...
No Matches
eSuperCellTowerMapper.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
7#include "GaudiKernel/MsgStream.h"
9#include <cmath> //std::round, etc
10
11// This is a class which is designed to receive in a list of supercells and a list of eTowers and match them together appropriately.
12
13
14/* VERY IMPORTANT NOTE. ARE YOU CONFUSED ABOUT SAMPLING IDs? WANT TO KNOW WHERE ON EARTH THEY COME FROM? FINDING OBSCURE VALUES THAT ARE APPARENTLY MEANINGLESS?
15
16LOOK HERE!: athena/Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.def
17
18*/
19
20
21namespace LVL1 {
22
23eSuperCellTowerMapper::eSuperCellTowerMapper(const std::string& type,const std::string& name,const IInterface* parent):
24 AthAlgTool(type,name,parent)
25{
26 declareInterface<IeSuperCellTowerMapper>(this);
27
28}
29
34
36{
37
38 ATH_CHECK( m_scellsCollectionSGKey.initialize() );
41 return StatusCode::SUCCESS;
42
43}
44
45StatusCode eSuperCellTowerMapper::AssignTriggerTowerMapper(std::unique_ptr<eTowerContainer> & my_eTowerContainerRaw) const {
46
47 static constexpr float pi_over_32 = M_PI/32;
48
50 if(!triggerTowerCollection.isValid()){
51 ATH_MSG_FATAL("Could not retrieve collection " << m_triggerTowerCollectionSGKey.key() );
52 return StatusCode::FAILURE;
53 }
54
55
56 for(auto eachTower : *triggerTowerCollection) {
57 if(std::abs(eachTower->eta())<1.5 && eachTower->sampling()==1) {
58 int i_phi = static_cast<int>(eachTower->phi()/pi_over_32);
59 int etaSign{-1};
60 int towerID_Modifier{100000};
61 if (eachTower->eta() > 0) {
62 etaSign = 1;
63 towerID_Modifier = 200000;
64 }
65 int i_eta = static_cast<int>(eachTower->eta() * 10) * etaSign;
66 if(i_eta * etaSign == -14) {
67 towerID_Modifier = 300000;
68 } else if (i_eta * etaSign == 14) {
69 towerID_Modifier = 400000;
70 }
71
72 int towerid = FindTowerIDForSuperCell(i_eta, i_phi) + towerID_Modifier;
73 LVL1::eTower * targetTower;
74 if((targetTower = my_eTowerContainerRaw->findTower(towerid))) {
75 if (targetTower->getET_float(4, 0) > 0) {
76 ATH_MSG_WARNING("\n==== eSuperCellTowerMapper ============ Hadronic layer energy filled more than once - it will be ignored. (Needs investigation). Please report this!");
77 }
78 targetTower->setET(10, static_cast<int>(eachTower->cpET()) * 500., 4); // cf 0.5 * 1000.0
79 } else {
80 ATH_MSG_WARNING("\n==== eSuperCellTowerMapper ============ Tower id is officially unknown - it will be ignored. (Needs investigation). Please report this!");
81 }
82 }
83 }
84 return StatusCode::SUCCESS;
85}
86
87
88 // works for real supercells from MC
89 StatusCode eSuperCellTowerMapper::AssignSuperCellsToTowers(std::unique_ptr<eTowerContainer> & my_eTowerContainerRaw) const
90{
91
92 bool doPrint = false;
93
95 if(!scellsCollection.isValid()){
96 ATH_MSG_FATAL("Could not retrieve collection " << m_scellsCollectionSGKey.key() );
97 return StatusCode::FAILURE;
98 }
99
100 //const CaloCell_Base_ID* idHelper = caloIdManager->getCaloCell_SuperCell_ID(); // getting the id helper class
101 const CaloCell_Base_ID* idHelper = nullptr;
102 ATH_CHECK( detStore()->retrieve (idHelper, "CaloCell_SuperCell_ID") );
103 for (const CaloCell* cell : * scellsCollection){
104
105 // Discard masked cells from monitoring
106 int SCprov = (cell)->provenance()&0xFFF;
107 bool isMasked = (SCprov&0x80)==0x80;
108
109 if (isMasked) continue;
110
111 const CaloSampling::CaloSample sample = (cell)->caloDDE()->getSampling();
112 const Identifier ID = (cell)->ID(); // super cell unique ID
113 int region = idHelper->region(ID);
114 float et = 12.5*std::round((cell)->energy()/(12.5*cosh((cell)->eta())));
115 int pos_neg = idHelper->pos_neg(ID);
116 //We need to explicitly avoid +/- 3 pos_neg supercells! These go beyond |eta| == 2.5
117 if(abs(pos_neg) == 3){ continue; }
118 // mapping with csv file
119 if(m_eFEXSuperCellTowerIdProviderTool->ifhaveinputfile()){
120 int towerid{ -1 };
121 int slot{ -1 };
122 bool doenergysplit { false };
123 ATH_CHECK( m_eFEXSuperCellTowerIdProviderTool->geteTowerIDandslot(ID.get_compact(), towerid, slot, doenergysplit) );
124 // ignore invalid SuperCell
125 if (towerid == -1) {
126 continue;
127 }
128 int layer_tem = -1;
129 // Layer 0: Cell 0
130 // Layer 1: Cell 1, 2, 3, 4
131 // Layer 2: Cell 5, 6, 7, 8
132 // Layer 3: Cell 9
133 // Layer 4: Cell 10 (HEC or TILE, if we have them!)
134 if (slot == 0) {
135 layer_tem = 0;
136 } else if (slot <= 4) {
137 layer_tem = 1;
138 } else if (slot <= 8) {
139 layer_tem = 2;
140 } else if (slot == 9) {
141 layer_tem = 3;
142 } else {
143 layer_tem = 4;
144 }
145
146 ConnectSuperCellToTower( my_eTowerContainerRaw, towerid, ID, slot, et, layer_tem, doenergysplit);
147 continue;
148 }
149 int layer = -1;
150 int eta_index = idHelper->eta(ID);
151 const int phi_index = idHelper->phi(ID);
152 int prov = (cell)->provenance();
153
154 /*
155 CaloSampling:
156 PreSamplerB 0
157 EMB1 1
158 EMB2 2
159 EMB3 3
160
161 PreSamplerE 4
162 EME1 5
163 EME2 6
164 EME3 7
165
166 HEC0 8
167 HEC1 9
168 HEC2 10
169 HEC3 11
170
171 TileBar0 12 (Tile Barrel)
172 TileBar1 13
173 TileBar2 14
174
175 TileGap1 15 (ITC and Scintillator)
176 TileGap2 16
177 TileGap3 17
178
179 TileExt0 18 (Tile Extended Barrel)
180 TileExt1 19
181 TileExt2 20
182
183 FCAL0 21 (Forward EM Endcap)
184 FCAL1 22
185 FCAL2 23
186
187 MINIFCAL0 24
188 MINIFCAL1 25
189 MINIFCAL2 26
190 MINIFCAL3 27
191
192 Unknown 28
193 */
194
195 // LOCAL TO GLOBAL ETA INDEX PATCH - USE A 'TOWER OFFSET' TO MARK THE START OF THE ETA_INDEX COUNTING (e.g. the rounded eta value of the innermost supercell)
196 switch(sample){
197 case CaloSampling::PreSamplerB: { break; }
198 case CaloSampling::EMB1: {
199 if(region == 1){ eta_index += 56; }
200 break;
201 }
202 case CaloSampling::EMB2: {
203 if(region == 1){ eta_index += 56; }
204 break;
205 }
206 case CaloSampling::EMB3: { break; }
207 case CaloSampling::PreSamplerE: { eta_index += 15; break; }
208 case CaloSampling::EME1: {
209 if(region == 0){ eta_index += 14; }
210 else if (region == 1){ /* doesn't exist */ }
211 else if (region == 2){ eta_index += 60; }
212 else if (region == 3){ eta_index += 108; } //6 supercell region
213 else if (region == 4){ eta_index += 80; }
214 else if (region == 5){ eta_index += 24; }
215 break;
216 }
217 case CaloSampling::EME2: {
218 if(region == 0){ eta_index += 14; }
219 else if (region == 1){ eta_index += 57; }
220 break;
221 }
222 case CaloSampling::EME3: { eta_index += 15; break; }
223 case CaloSampling::HEC0:
224 case CaloSampling::HEC1:
225 case CaloSampling::HEC2:
226 case CaloSampling::HEC3: { eta_index += 15; break; }
227 default: { /*ATH_MSG_DEBUG("Not doing anything since sample = " << sample);*/ break; }
228 }
229
230
231 FindAndConnectTower(my_eTowerContainerRaw,sample,region,layer,pos_neg,eta_index,phi_index,ID,et,prov,doPrint);
232 }
233
234 return StatusCode::SUCCESS;
235
236}
237
238
239void eSuperCellTowerMapper::ConnectSuperCellToTower(std::unique_ptr<eTowerContainer> & my_eTowerContainerRaw,int iETower, Identifier ID, int iCell, float et, int layer, bool doenergysplit) const {
240
241 LVL1::eTower * tmpTower = my_eTowerContainerRaw->findTower(iETower);
242
243 if(tmpTower){
244 tmpTower->setSCID(ID,iCell,et,layer,doenergysplit);
245 }
246
247}
248
249 int eSuperCellTowerMapper::FindAndConnectTower(std::unique_ptr<eTowerContainer> & my_eTowerContainerRaw,CaloSampling::CaloSample sample,const int region, int layer, const int pos_neg, const int eta_index, const int phi_index, Identifier ID, float et, int prov,bool doPrint) const
250{
251
252 // bool for the special case of 1.8 < eta < 2.0 only in the front layer
253 bool doenergysplit = false;
254
255 // bool as a flag to enable or disable the connection of supercells to towers according to their location and identities
256 bool validcell = true;
257
258 // We tell the eTower which supercell unique ID is in each of it's available 'slots'
259 int towereta = -99; // to be filled with tower eta value to help find it
260 int towerphi = -99; // to be filled with tower phi value to help find it
261 int iETower = -99; // The tower ID which the supercell will be assigned to
262 int iCell = -1; // The position within the Tower that the supercell will be assigned to
263 int towerID_Modifier = -999999999; // adjustable tower ID modifier to fit tower Id scheme
264
265 /*
266 ** iCell Numbering Scheme **
267
268 Let's use the following scheme (from low to high eta regardless of detector side):
269 Layer 0: Cell 0
270 Layer 1: Cell 1, 2, 3, 4
271 Layer 2: Cell 5, 6, 7, 8
272 Layer 3: Cell 9
273 Layer 4: Cell 10 (HEC or TILE, if we have them!)
274 */
275
276
277 /*
278 ** Structure of the EMB in Supercells **
279
280 0 < 1.4 in steps of 0.1 == 14 towers
281 1.4 < 1.52 in steps of 0.12 ==> THIS TOWER IS MOVED TO TRANS TOWER REGION
282 14 towers total (all by presampler)
283 64 towers in phi in total
284
285 896 towers in EMB per side
286 1792 towers in EMB total
287 */
288
289 /*
290 ** Structure of the TRANS in Supercells **
291
292 1.4 < 1.5, 1 special tower made from EMB and EME supercells together
293 1 tower in eta
294 64 towers in phi
295
296 64 towers in TRANS total
297 */
298
299 /*
300 ** Structure of the EMEC in Supercells **
301
302 1.375 < 1.5, funny behaviour, treated as 1 special tower ==> 1 tower === TRANSITION TOWER NOW!
303 1.5 < 1.8 standard towers by presampler ==> 3 towers
304 1.8 < 2.0 standard towers by back ==> 2 towers
305 2.0 < 2.4 standard towers by back ==> 4 towers
306 2.4 < 2.5 standard tower by back ==> 1 tower
307 2.5 < 3.1, funny behaviour, treated as 3 wide towers ==> 3 towers. Also wide in phi! ===> WE DON'T CARE ABOUT |ETA| > 2.5
308 3.1 < 3.2 standard tower by back ==> 1 tower. Also wide in phi! ===> WE DON'T CARE ABOUT |ETA| > 2.5
309 10 towers in eta in total (by different means) (IGNORING ABOVE |ETA| > 2.5)
310 64 towers initially in phi (IGNORING ABOVE |ETA| > 2.5)
311
312 640 towers in EME per side
313 1280 towers in EME total
314 */
315
316
317 /*
318 ** Structure of the HEC in Supercells **
319
320 1.5 - 2.5, [Region 0] standard towers by presampler ==> layer on top of existing towers
321
322 */
323
324 /*
325 ** Notes on overall structure **
326 Total number of expected towers can be as high as: 896+640 = 1536 per side + 64 transition region towers (TRANS) each side = 3200 total <=== This is the correct value!
327 */
328
329 /*
330 ** Notes on Tower ID Number Scheme **
331
332 Left Barrel IETower = 100000 + X
333 Right Barrel IETower = 200000 + X
334 Left TRANS IETower = 300000 + X;
335 Right TRANS IETower = 400000 + X;
336 Left Endcap IETower = 500000 + X
337 Right Endcap IETower = 600000 + X
338 Left Hadronic Endcap IETower = 11100000 + X --> These are just Layer 5 of Endcap Towers. They will never be generated as standalone eTowers.
339 Right Hadronic Endcap IETower = 22200000 + X --> These are just Layer 5 of Endcap Towers. They will never be generated as standalone eTowers.
340
341 */
342
343
344 //----------------------------------------------------------
345
346 // Begin assigning supercells to Towers
347
348 //----------------------------------------------------------
349
350 switch (sample) {
351 // E.M. Barrel (EMB)
352 case CaloSampling::PreSamplerB: { // DONE
353 // Presampler of the EMBarrel. Supercells are 0.1 x 0.1 unless stated otherwise
354 // Region 0 has 14 supercells in 0 < eta < 1.4 and 64 supercells in phi.
355 // Region 0 has 1 supercell (0.12 x 0.1) in 1.4 < eta < 1.52 and 64 supercells in phi. // Documentation describes this as Region 1 but the code does not. We go with Region 0.
356
357 layer = 0; // By definition
358
359 towereta = eta_index; // Layer 0 has super cells which are 0.1 x 0.1 - i.e. the full width of a tower - sothe eta_index matches up to the Tower Eta
360 towerphi = phi_index; // phi is standard also
361
362 if(eta_index == 14){ // special treatment for TRANSITION tower
363 if(pos_neg < 0){ towerID_Modifier = 300000; }
364 else if(pos_neg > 0){ towerID_Modifier = 400000; }
365 iCell = 0; // By definition
366 }
367 else{ // standard treatment for non-transition towers
368 if(pos_neg < 0){ towerID_Modifier = 100000; }
369 else if(pos_neg > 0){ towerID_Modifier = 200000; }
370 iCell = 0; // By definition
371 }
372
373 break;
374 }
375 case CaloSampling::EMB1:
376 case CaloSampling::EMB2: {
377 // Layer 1 of the EMBarrel. Supercells are 0.025 x 0.1 unless stated otherwise
378 // Region 0 has 56 supercells in 0 < eta < 1.4 and 64 supercells in phi.
379 // Region 1 has 3 supercells in 1.4 < eta < 1.475 and 64 supercells in phi.
380
381 // Layer 2 of the EMBarrel. Supercells are 0.025 x 0.1 unless stated otherwise
382 // Region 0 has 56 supercells in 0 < eta < 1.4 and 64 supercells in phi.
383 // Region 1 has 1 supercells (0.075 x 0.1) in 1.4 < eta < 1.475 and 64 supercells in phi.
384
385 if (region == 0) {
386 towereta = eta_index / 4; // this divides integers by 4 and truncates away the decimals (rounds DOWN to an integer)
387 towerphi = phi_index;
388 if(pos_neg < 0){ towerID_Modifier = 100000; }
389 else if(pos_neg > 0){ towerID_Modifier = 200000; }
390 }
391 else if (region == 1){
392 towereta = 14; // hardcoded but is correct
393 towerphi = phi_index;
394 if(pos_neg < 0){ towerID_Modifier = 300000; }
395 else if(pos_neg > 0){ towerID_Modifier = 400000; }
396 }
397 else {
398 ATH_MSG_DEBUG("[CaloSampling::EMB1 or CaloSampling::EMB2] -> invalid 'region' value: " << region << " (Under investigation) ");
399 }
400
401 switch(sample){
402 case CaloSampling::EMB1: {
403 iCell = (eta_index % 4) + 1;
404 layer = 1;
405 break;
406 }
407 case CaloSampling::EMB2: {
408 if (region == 0) { iCell = (eta_index % 4) + 5; }
409 else if (region == 1){ iCell = 5; }
410 layer = 2;
411 break;
412 }
413 default: {
414 ATH_MSG_DEBUG("CaloSampling::EMBX -> invalid sample for assigning iCell value! " << sample << " (Under investigation) ");
415 break;
416 }
417 }
418
419 break;
420 }
421 case CaloSampling::EMB3: {
422 // Layer 3 of the EMBarrel. Supercells are 0.1 x 0.1 unless stated otherwise
423 // Region 0 has 14 supercells in 0 < eta < 1.4 and 64 supercells in phi.
424 // Region 1 does not exist
425
426 layer = 3; // By definiton
427 towereta = eta_index; // Analogous to PreSamplerB
428 towerphi = phi_index;
429
430 iCell = 9; // By definition;
431
432 if(pos_neg < 0){ towerID_Modifier = 100000; }
433 else if(pos_neg > 0){ towerID_Modifier = 200000; }
434
435 break;
436 }
437 // E.M. End-cap (EMEC)
438 case CaloSampling::PreSamplerE: {
439 // Region 1 has 3 supercells in 1.5 < eta < 1.8, and 64 supercells in phi.
440 // Supercells are 0.1 x 0.1.
441
442 layer = 0;
443
444 towereta = eta_index;
445 towerphi = phi_index;
446
447 iCell = 0; // By definition
448
449 if(pos_neg < 0){ towerID_Modifier = 500000; }
450 else if(pos_neg > 0){ towerID_Modifier = 600000; }
451
452 break;
453 }
454 case CaloSampling::EME1: {
455 // Layer 1 of the EM End-Cap. Supercells very frequently change in size.
456 // Region 0 has 1 supercell in 1.375 < eta < 1.5, and 64 supercells in phi. Supercells are 0.125 x 0.1.
457 // Region 1 has 12 supercells in 1.5 < eta < 1.8, and 64 supercells in phi. Supercells are 0.025 x 0.1.
458 // Region 2 has 6 (now 12??) supercells in 1.8 < eta < 2.0, and 64 supercells in phi. Supercells are 0.0333 (0.016667 ???) x 0.1.
459 // Region 3 has 16 supercells in 2.0 < eta < 2.4, and 64 supercells in phi. Supercells are 0.025 x 0.1.
460 // Region 4 has 1 supercell in 2.4 < eta < 2.5, and 64 supercells in phi. Supercells are 0.1 x 0.1.
461 // Region 5 has 3 supercells in 2.5 < eta < 3.1, and 32 supercells in phi. Supercells are 0.2 x 0.2.
462 // Region 6 has 1 supercell in 3.1 < eta < 3.2, and 32 supercells in phi. Supercells are 0.1 x 0.2
463
464 // 1.375 < 1.5, funny behaviour, treated as 1 special tower ==> 1 tower
465 // 1.5 < 1.8 standard towers by presampler ==> 3 towers
466 // 1.8 < 2.0 standard towers by back ==> 2 towers
467 // 2.0 < 2.4 standard towers by back ==> 4 towers
468 // 2.4 < 2.5 standard tower by back ==> 1 tower
469 // 2.5 < 3.1, funny behaviour, treated as 3 wide towers ==> 3 towers
470 // 3.1 < 3.2, funny behaviour, treated as 1 tower ==> 1 tower
471 // 15 towers in total (by different means)
472
473 layer = 1; // By definition
474
475 switch (region) {
476 case 0: { // special treatment for transition region
477
478 towereta = eta_index;
479 towerphi = phi_index;
480
481 iCell = 4; // Placement based on advice from Alan Watson
482 break;
483 }
484 case 2: {
485
486 towereta = (eta_index / 4);
487 towerphi = phi_index;
488
489 iCell = (eta_index % 4) + 1;
490 break;
491 }
492 case 3: {
493
494 // calc ID
495 towereta = (eta_index / 6);
496 towerphi = phi_index;
497
498 iCell = (eta_index % 6) + 1;
499
500 if(iCell == 1){ iCell = 1; doenergysplit = false; }
501 else if( iCell == 2 ){ iCell = 1; doenergysplit = true; }
502 else if( iCell == 3 ){ iCell = 2; doenergysplit = false; }
503 else if( iCell == 4 ){ iCell = 3; doenergysplit = false; }
504 else if( iCell == 5 ){ iCell = 3; doenergysplit = true; }
505 else if( iCell == 6 ){ iCell = 4; doenergysplit = false; }
506
507 break;
508
509 // OUTDATED CODE LEFT HERE AS A FRIENDLY REMINDER OF SPECIAL STRUCTURE INCASE A FUTURE ISSUE ARISES======================
510 // Begin Dima---
511 // This is the special region, with 6 supercells per tower
512 // Idea here is to divide 2 out of 6 by 2 and add half ET to each of 2 "normal" SC
513 //iETower = (eta_index / 6) + 18;
514
515 // These are the cells we will split
516 //if (eta_index % 3 == 1) {
517 //iCell = (eta_index % 6 < 3 ? 0 : 2);
518 //iCell2 = iCell + 1;
519 //} else {
520 // These ones just need assigning to the correct location
521 // So that 0, 2, 3, 5 => 0, 1, 2, 3
522 //iCell = (eta_index % 6) / 1.45;
523 //}
524 // end DIMA---
525 // ======================================================================================================================
526 }
527 case 4: {
528
529 towereta = (eta_index / 4);
530 towerphi = phi_index;
531
532 iCell = (eta_index % 4) + 1;
533 break;
534 }
535 case 5: {
536
537 towereta = eta_index ;
538 towerphi = phi_index;
539
540 iCell = 1;
541 break;
542 }
543 default: {
544 // This should never fire because we don't go beyond 2.5
545 ATH_MSG_DEBUG("CaloSampling::EME1 -> invalid 'region' value: " << region << " (Under investigation) ");
546 break;
547 }
548 break;
549 }
550
551 if(region != 0){
552 if(pos_neg < 0){ towerID_Modifier = 500000; }
553 else if(pos_neg > 0){ towerID_Modifier = 600000; }
554 }
555 else if(region == 0){
556 // TRANSITION REGION TREATMENT!
557 if(pos_neg < 0){ towerID_Modifier = 300000; }
558 else if(pos_neg > 0){ towerID_Modifier = 400000; }
559 }
560
561 break;
562 }
563 case CaloSampling::EME2: {
564
565 // Layer 2 of the EM End-Cap. Supercells very frequently change in size.
566 // Region 0 has 1 supercell in 1.375 < eta < 1.425, and 64 supercells in phi. Supercells are 0.05 x 0.1.
567 // Region 0 also has 3 supercells in 1.425 < eta < 1.5, and 64 supercells in phi. Supercells are 0.025 x 0.1
568 // Region 1 has 12 supercells in 1.5 < eta < 1.8, and 64 supercells in phi. Supercells are 0.025 x 0.1.
569 // Region 2 has 8 supercells in 1.8 < eta < 2.0, and 64 supercells in phi. Supercells are 0.025 x 0.1.
570 // Region 3 has 16 supercells in 2.0 < eta < 2.4, and 64 supercells in phi. Supercells are 0.025 x 0.1.
571 // Region 4 has 4 supercells in 2.4 < eta < 2.5, and 64 supercells in phi. Supercells are 0.025 x 0.1.
572 // Region 5 has 3 supercells in 2.5 < eta < 3.1, and 32 supercells in phi. Supercells are 0.2 x 0.2.
573 // Region 6 has 1 supercell in 3.1 < eta < 3.2, and 32 supercells in phi. Supercells are 0.1 x 0.2
574
575 layer = 2;
576
577 switch (region) {
578 case 0: { // special treatment for TRANSITON region
579
580 layer = 3; // change layer label for ET threshold treatment since we are treating this as a layer3 cell - it's an extreme special case cell as part of the transition region
581
582 towereta = eta_index;
583 towerphi = phi_index;
584
585 iCell = 9;
586
587 break;
588 }
589 case 1: {
590
591 towereta = (eta_index / 4);
592 towerphi = phi_index;
593
594 iCell = (eta_index % 4) + 5;
595
596 break;
597 }
598 default: {
599 ATH_MSG_DEBUG("CaloSampling::EME2 -> invalid 'region' value: " << region << " (Under investigation) ");
600 break;
601 }
602 break;
603 }
604
605 if(region == 0){
606 // TRANSITION REGION TREATMENT!
607 if(pos_neg < 0){ towerID_Modifier = 300000; }
608 else if(pos_neg > 0){ towerID_Modifier = 400000; }
609 }
610 else {
611 if( (eta_index / 4) < 15 ){
612 if(pos_neg < 0){ towerID_Modifier = 300000; }
613 else if(pos_neg > 0){ towerID_Modifier = 400000; }
614 }
615 else{
616 if(pos_neg < 0){ towerID_Modifier = 500000; }
617 else if(pos_neg > 0){ towerID_Modifier = 600000; }
618 }
619 }
620
621 break;
622 }
623 case CaloSampling::EME3: {
624
625 // Layer 3 of the EM End-Cap. Supercells are 0.1 x 0.1 unless stated otherwise.
626 // Region 0 does not exist.
627 // Region 1 has 3 supercells in 1.5 < eta < 1.8, and 64 supercells in phi. Supercells are 0.1 x 0.1.
628 // Region 2 has 2 supercells in 1.8 < eta < 2.0, and 64 supercells in phi. Supercells are 0.1 x 0.1.
629 // Region 3 has 4 supercells in 2.0 < eta < 2.4, and 64 supercells in phi. Supercells are 0.1 x 0.1.
630 // Region 4 has 1 supercells in 2.4 < eta < 2.5, and 64 supercells in phi. Supercells are 0.1 x 0.1.
631 // No other Regions exist
632
633 layer = 3; // By definition
634
635 switch (region) {
636 case 0: {
637
638 towereta = eta_index;
639 towerphi = phi_index;
640
641 iCell = 9; // By definition
642
643 break;
644 }
645 default: {
646 ATH_MSG_DEBUG("CaloSampling::EME3 -> invalid 'region' value: " << region << " (Under investigation) ");
647 break;
648 }
649 break;
650 }
651
652 if(pos_neg < 0){ towerID_Modifier = 500000; }
653 else if(pos_neg > 0){ towerID_Modifier = 600000; }
654
655 break;
656 }
657 // Hadronic End-cap (HEC)
658 case CaloSampling::HEC0:
659 case CaloSampling::HEC1:
660 case CaloSampling::HEC2:
661 case CaloSampling::HEC3: {
662
663 // All Layers of the Hadronic End-Cap.
664 // Region 0 has 10 supercells in 1.5 < eta < 2.5, and 32 supercells in phi. Supercells are 0.1 x 0.1.
665 // Region 1 has 4 supercells in 2.5 < eta < 3.3, and 16 supercells in phi. Supercells are 0.2 x 0.2.
666
667 switch(region){
668 case 0: {
669
670 towereta = eta_index;
671 towerphi = phi_index;
672
673 layer = 4; // By definition
674
675 switch (sample){ // only one supercell per layer in all regions for HECX
676 case CaloSampling::HEC0: { iCell = 10; break; }
677 case CaloSampling::HEC1: { iCell = 11; break; }
678 case CaloSampling::HEC2: { iCell = 12; break; }
679 case CaloSampling::HEC3: { iCell = 13; break; }
680 //coverity[DEADCODE]
681 default: {
682 ATH_MSG_DEBUG("CaloSampling::HECX -> invalid sample for assigning iCell value! " << sample << " (Under investigation) ");
683 break;
684 }
685 }
686 break;
687
688 }
689 case 1: {
690 validcell = false; // any region 1 HEC cells are actually with eta > 2.5
691 //ATH_MSG_DEBUG("CaloSampling::HECX Region 1 invalid as outside of eta range!");
692 break;
693 }
694 default: { break; }
695 }
696
697 // Tower connection
698 if(pos_neg < 0){ towerID_Modifier = 500000; }
699 else if(pos_neg > 0){ towerID_Modifier = 600000; }
700
701 break;
702 }
703 case CaloSampling::TileBar0:
704 case CaloSampling::TileBar1:
705 case CaloSampling::TileBar2: {
706 REPORT_MESSAGE_WITH_CONTEXT (MSG::DEBUG, "eSuperCellTowerMapper") << "Supercell is from Tile Barrel - it will be ignored.";
707 validcell = false;
708 //ATH_MSG_DEBUG("\n==== eSuperCellTowerMapper ============ Supercell is from Tile Barrel - it will be ignored.");
709 break;
710 }
711 case CaloSampling::TileGap1:
712 case CaloSampling::TileGap2:
713 case CaloSampling::TileGap3: {
714 //ATH_MSG_DEBUG("\n==== eSuperCellTowerMapper ============ Supercell is from Tile Gap (ITC and scintillator) - it will be ignored.");
715 validcell = false;
716 break;
717 }
718 case CaloSampling::TileExt0:
719 case CaloSampling::TileExt1:
720 case CaloSampling::TileExt2: {
721 //ATH_MSG_DEBUG("\n==== eSuperCellTowerMapper ============ Supercell is from Tile Extended Barrel - it will be ignored.");
722 validcell = false;
723 break;
724 }
725 case CaloSampling::FCAL0:
726 case CaloSampling::FCAL1:
727 case CaloSampling::FCAL2: {
728 //ATH_MSG_DEBUG("\n==== eSuperCellTowerMapper ============ Supercell is from Forward EM endcap - it will be ignored.");
729 validcell = false;
730 break;
731 }
732 case CaloSampling::MINIFCAL0:
733 case CaloSampling::MINIFCAL1:
734 case CaloSampling::MINIFCAL2:
735 case CaloSampling::MINIFCAL3: {
736 //ATH_MSG_DEBUG("\n==== eSuperCellTowerMapper ============ Supercells is from MiniFCAL - it will be ignored.");
737 validcell = false;
738 break;
739 }
740 case CaloSampling::Unknown: {
741 //ATH_MSG_WARNING("\n==== eSuperCellTowerMapper ============ Supercell sampling is officially unknown - it will be ignored. (Needs investigation). Please report this!");
742 validcell = false;
743 break;
744 }
745 default: {
746 ATH_MSG_DEBUG("\n==== eSuperCellTowerMapper ============ Supercell has invalid CaloSampling value: " << sample << " (Needs investigation). Please report this!");
747 validcell = false;
748 break;
749 }
750 }
751
752 if(validcell){
753 iETower = FindTowerIDForSuperCell(towereta, towerphi) + towerID_Modifier;
754
755 // Identify eTowers at eta < 0 and re-order layer 1/2 cells manually
756 // Algorithms want order to be increasing eta, not increasing |eta|
757 if (iETower < 200000 || (iETower > 300000 && iETower < 400000) || (iETower > 500000 && iETower < 600000)) {
758 if (layer == 1) {
759 iCell = 5 - iCell;
760 if (doenergysplit) iCell -= 1; // Need special treatment here because of way energy splitting works
761 } else if (layer == 2) {
762 iCell = 13 - iCell;
763 }
764 }
765
766 // Only one layer-1 cell in the region 2.4 < |eta| < 2.5. Set the slot to zero to match the behaviour of the firmware.
767 int etaIndex = (iETower%100000)/64;
768 if (iETower > 500000 && etaIndex == 24 && iCell < 5) iCell = 0; // Map final layer 1 cell into layer 0 slot
769
770 if(doPrint){
771 PrintCellSpec(sample, layer, region, eta_index, phi_index, pos_neg, iETower, iCell, prov, ID, doenergysplit);
772 }
773 ConnectSuperCellToTower( my_eTowerContainerRaw, iETower, ID, iCell, et, layer, doenergysplit);
774 }
775
776 // END ITERATING OVER SUPER CELLS+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++
777
778 return 1;
779
780 }
781
782int eSuperCellTowerMapper::FindTowerIDForSuperCell(int towereta, int towerphi) const
783{
784 return (towerphi + (64 * towereta));
785}
786
787 void eSuperCellTowerMapper::PrintCellSpec(const CaloSampling::CaloSample sample, int layer, const int region, const int eta_index, const int phi_index, const int pos_neg, int iETower, int iCell, int prov, Identifier ID ,bool doenergysplit)
788const {
789
790 std::string sampleName = "";
791
792 switch (sample) {
793 case CaloSampling::PreSamplerB: { sampleName = "PreSamplerB"; break; }
794 case CaloSampling::EMB1: { sampleName = "EMB1"; break; }
795 case CaloSampling::EMB2: { sampleName = "EMB2"; break; }
796 case CaloSampling::EMB3: { sampleName = "EMB3"; break; }
797 case CaloSampling::PreSamplerE: { sampleName = "PreSamplerE"; break; }
798 case CaloSampling::EME1: { sampleName = "EME1"; break; }
799 case CaloSampling::EME2: { sampleName = "EME2"; break; }
800 case CaloSampling::EME3: { sampleName = "EME3"; break; }
801 case CaloSampling::HEC0: { sampleName = "HEC0"; break; }
802 case CaloSampling::HEC1: { sampleName = "HEC1"; break; }
803 case CaloSampling::HEC2: { sampleName = "HEC2"; break; }
804 case CaloSampling::HEC3: { sampleName = "HEC3"; break; }
805 default: {
806 ATH_MSG_DEBUG("\n==== eSuperCellTowerMapper ============ Supercell has invalid CaloSampling value: " << sample << " (Needs investigation). Please report this!");
807 break;
808 }
809 }
810
811 ATH_MSG_DEBUG("ASSIGNED CELL::: CASE: " << sampleName
812 << "\tSample: " << sample
813 << "\tLayer: " << layer
814 << "\tRegion: " << region
815 << "\tEta_Index: " << eta_index
816 << "\tPhi_Index: " << phi_index
817 << "\tPosNeg: " << pos_neg
818 << "\tiETower: " << iETower
819 << "\tiCell: " << iCell
820 << "\tDoEnergySplit: " << doenergysplit
821 << "\tProvenance: " << prov
822 << "\tID: " << ID
823 << " ");
824
825 return;
826}
827
829 std::string sampleName ="";
830 switch (sample) {
831 case CaloSampling::PreSamplerB: { sampleName = "PreSamplerB"; break; }
832 case CaloSampling::EMB1: { sampleName = "EMB1"; break; }
833 case CaloSampling::EMB2: { sampleName = "EMB2"; break; }
834 case CaloSampling::EMB3: { sampleName = "EMB3"; break; }
835 case CaloSampling::PreSamplerE: { sampleName = "PreSamplerE"; break; }
836 case CaloSampling::EME1: { sampleName = "EME1"; break; }
837 case CaloSampling::EME2: { sampleName = "EME2"; break; }
838 case CaloSampling::EME3: { sampleName = "EME3"; break; }
839 case CaloSampling::HEC0: { sampleName = "HEC0"; break; }
840 case CaloSampling::HEC1: { sampleName = "HEC1"; break; }
841 case CaloSampling::HEC2: { sampleName = "HEC2"; break; }
842 case CaloSampling::HEC3: { sampleName = "HEC3"; break; }
843 case CaloSampling::FCAL0: { sampleName = "FCAL0"; break; }
844 case CaloSampling::FCAL1: { sampleName = "FCAL1"; break; }
845 case CaloSampling::FCAL2: { sampleName = "FCAL2"; break; }
846 default: {
847 ATH_MSG_DEBUG("\n==== jSuperCellTowerMapper ============ Supercell has invalid CaloSampling value: " << sample << " (Needs investigation). Please report this!");
848 sampleName = "----";
849 break;
850 }
851 }
852 return sampleName;
853}
854
855} // end of LVL1 namespace
#define M_PI
Scalar eta() const
pseudorapidity method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Helpers for checking error return status codes and reporting errors.
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
Helper base class for offline cell identifiers.
int phi(const Identifier id) const
LAr field values (NOT_VALID == invalid request).
int region(const Identifier id) const
LAr field values (NOT_VALID == invalid request).
int pos_neg(const Identifier id) const
LAr field values (NOT_VALID == invalid request).
int eta(const Identifier id) const
LAr field values (NOT_VALID == invalid request).
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
virtual StatusCode AssignSuperCellsToTowers(std::unique_ptr< eTowerContainer > &my_eTowerContainerRaw) const override
std::string DectectorName(const CaloSampling::CaloSample sample) const
virtual void ConnectSuperCellToTower(std::unique_ptr< eTowerContainer > &my_eTowerContainerRaw, int iETower, Identifier ID, int iCell, float et, int layer, bool doenergysplit) const override
ToolHandle< eFEXSuperCellTowerIdProvider > m_eFEXSuperCellTowerIdProviderTool
virtual int FindAndConnectTower(std::unique_ptr< eTowerContainer > &my_eTowerContainerRaw, CaloSampling::CaloSample sample, const int region, int layer, const int pos_neg, const int eta_index, const int phi_index, Identifier ID, float et, int prov, bool doPrint) const override
SG::ReadHandleKey< CaloCellContainer > m_scellsCollectionSGKey
SG::ReadHandleKey< xAOD::TriggerTowerContainer > m_triggerTowerCollectionSGKey
virtual StatusCode initialize() override
standard Athena-Algorithm method
virtual void PrintCellSpec(const CaloSampling::CaloSample sample, int layer, const int region, const int eta_index, const int phi_index, const int pos_neg, int iETower, int iCell, int prov, Identifier ID, bool doenergysplit) const override
eSuperCellTowerMapper(const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode AssignTriggerTowerMapper(std::unique_ptr< eTowerContainer > &my_eTowerContainerRaw) const override
virtual int FindTowerIDForSuperCell(int towereta, int towerphi) const override
The eTower class is an interface object for eFEX trigger algorithms The purposes are twofold:
Definition eTower.h:38
float getET_float(unsigned int layer, int cell=0) const
Get ET of a specified cell in MeV FLOAT VERSION.
Definition eTower.cxx:183
void setET(int cell, float et, int layer, bool ignoreDisable=false)
Definition eTower.cxx:99
void setSCID(Identifier ID, int cell, float et, int layer, bool doenergysplit)
Set supercell position ID.
Definition eTower.cxx:110
virtual bool isValid() override final
Can the handle be successfully dereferenced?
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Extra patterns decribing particle interation process.