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