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