ATLAS Offline Software
Loading...
Searching...
No Matches
eFexTower_v1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5// EDM includes(s):
7
8// Local include(s):
10
11namespace xAOD{
12
13 AUXSTORE_OBJECT_SETTER_AND_GETTER( eFexTower_v1 , std::vector<uint16_t> , et_count , setEt_count )
14 AUXSTORE_OBJECT_MOVE( eFexTower_v1 , std::vector<uint16_t> , et_count , setEt_count )
20 AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( eFexTower_v1, uint32_t , had_status , setHad_status )
21
22
24 // Calculate ID by hand from coordinate
25 float eta = this->eta(); float phi = this->phi();
26 int posneg = (eta >= 0 ? 1 : -1);
27 int towereta = std::abs(eta+0.025)/0.1;
28 if (phi < 0) phi += 2*M_PI;
29 int towerphi = int(32*(phi+0.025)/M_PI);
30 unsigned int tower_id = towerphi + 64*towereta;
31
32 if (towereta < 14) {
33 tower_id += (posneg > 0 ? 200000 : 100000);
34 }
35 else if (towereta == 14) {
36 tower_id += (posneg > 0 ? 400000 : 300000);
37 }
38 else {
39 tower_id += (posneg > 0 ? 600000 : 500000);
40 }
41
42 return tower_id;
43 }
44
45
47 void eFexTower_v1::initialize(const float Eta,const float Phi)
48 {
49 setEta( Eta );
50 setPhi( Phi );
51 }
52
53 void eFexTower_v1::initialize(const float Eta,const float Phi,
54 const std::vector<uint16_t>& Et_count,
55 const uint8_t Module,
56 const uint8_t Fpga,
57 const uint32_t Em_status,
58 const uint32_t Had_status)
59 {
60 setEta( Eta );
61 setPhi( Phi );
62 setEt_count( Et_count );
63 setModule( Module );
64 setFpga( Fpga );
65 setEm_status( Em_status );
66 setHad_status( Had_status );
67 }
68
69 int32_t eFexTower_v1::id() const {
70 int etaIndex = int( (eta()+0.025)*10 ) + (((eta()+0.025)<0) ? -1 : 1); // runs from -25 to 25 (excluding 0)
71 int phiIndex = int( (phi()+0.025)*32./ROOT::Math::Pi() ) + ((phi()+0.025)<0 ? 63 : 0); // runs from 0 to 63
72 int modIndex = ( module()>23 ) ? 99 : module(); // module runs from 0 to 23 or otherwise takes value 99
73 int fpgaIndex = ( fpga() > 3 ) ? 9 : fpga(); //from runs from 0 to 3 or otherwise takes value 9
74 return (std::abs(etaIndex)*100000 + phiIndex*1000 + modIndex*10 +fpgaIndex)*(etaIndex<0 ? -1 : 1);
75 }
76
77 bool eFexTower_v1::disconnectedCount(size_t idx) const {
78 if(idx>11) return true;
79 int mod = eFexTower_v1::module();
80 double eta = eFexTower_v1::eta() + 0.025;
81 double phi = eFexTower_v1::phi() + 0.025;
82
83 if ( std::abs(eta)>1.8 && idx==0 ) return true; // no PS beyond 1.8
84 if ( std::abs(eta)>2.4 && idx>0 && idx<5 ) return idx!=4; // only the 'last' l1 is connected
85
86 if (mod>23) return false; // all emulated towers are connected
87
88 // extremities of the real modules are disconnected
89 // em inputs at most extreme phi of module are all disconnected
90 // as well as the last two in eta of each module (modules centered at eta = -1.6,0,1.6 ... extent in em inputs is +/- 1.0 (1.1 ish for the A/C modules) )
91 // exception is the eta=+/-2.45 inputs at the extreme of efex environment, which are present in the most extreme phi still.
92 // meaning |eta|>2.4 is all connected
93
94 double module_central_eta = 1.6*(mod%3-1);
95
96 if( std::abs(eta)<2.4 &&
97 idx!=11 &&
98 (std::abs(std::remainder(phi - (M_PI/32)*(8*(mod/3) + 6 - (mod>11)*64),2*M_PI)) > 5.*M_PI/32 || std::abs( module_central_eta - (eta) ) > 1.0 )
99 ) {
100 return true;
101 }
102
103 // finally, we also treat any input tower that is too far away from the centre of the module it is feeding as 'disconnected'
104 // it shouldn't be in use by any algorithm at least
105 double fpga_central_eta = module_central_eta + 0.4*(int(fpga())-2) + 0.2;
106 if ( std::abs(fpga_central_eta - eta) > 0.3 ) return true;
107
108 return false;
109 };
110
111 size_t eFexTower_v1::cellIdx(uint32_t layer, uint32_t cell) const {
112
113 if(cell > 3 || (layer!=1 && layer!=2 && cell>0)) return et_count().size();
114 // for |eta|>2.4 towers, the l1 energy (which is in the last slot) is treated as ps
115 if(layer==0 && std::abs(eta()+0.025)>2.4) return 4;
116 return (layer>0)*1 + (layer>1)*4 + (layer>2)*4 + (layer>3)*1 + cell;
117
118 }
119
120 int eFexTower_v1::cellEt(uint32_t layer, uint32_t cell) const {
121
122 auto idx = cellIdx(layer,cell);
123 if(idx == et_count().size()) return 0;
124 if(disconnectedCount(idx)) return 0;
125 auto count = et_count().at(idx);
126 // convert count to MeV using either LATOME or Tile energy scales
127 if (layer==4 && std::abs(eta()+0.025)<1.5) {
128 // Tile energy scale (500MeV per count)
129 return count*500;
130 }
131
132 // Deal with special codes first:
133 if (count == 0) return 0; // NoData
134 if (count == 1021 || count == 1022 || count > 1023) return 0; // Reserved || Invalid || OutOfRange
135 if (count == 1023) return 65535*25; // Saturated case, return saturated value;
136
137 if (count >= 768) return 44000 + (count-768)*400;
138 if (count >= 512) return 18400 + (count-512)*100;
139 if (count >= 256) return 5600 + (count-256)*50;
140 return -750 + (count-2)*25;
141 }
142
143} // namespace xAOD
#define M_PI
Scalar eta() const
pseudorapidity method
#define AUXSTORE_OBJECT_MOVE(CL, TYPE, NAME, SETTER)
Macro creating a move accessor for complex auxiliary properties.
#define AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(CL, TYPE, NAME, SETTER)
Macro creating the accessors of primitive auxiliary properties.
#define AUXSTORE_OBJECT_SETTER_AND_GETTER(CL, TYPE, NAME, SETTER)
Macro creating the accessors of complex auxiliary properties.
Class describing input data of a LVL1 eFEX.
void setEta(float)
getter for the global eta value (float)
void setFpga(uint8_t)
getter for the fpga number [0-3] inclusive
void initialize(const float Eta, const float Phi)
getter for the etower simulation ID
void setPhi(float)
getter for the global phi value (float)
uint32_t eFEXtowerID() const
setter for the above
const std::vector< uint16_t > & et_count() const
get Energy Counts
float phi() const
setter for the above
int32_t id() const
setter for the above
size_t cellIdx(uint32_t layer, uint32_t cell=0) const
Obtain the index in the count vector of a given supercell returns et_count().size() if cell is invali...
void setEt_count(const std::vector< uint16_t > &)
getter for the 11 energy counts
uint8_t module() const
setter for the above
void setHad_status(uint32_t)
getter for hadronic status bit
int cellEt(uint32_t layer, uint32_t cell=0) const
supercell Et in MeV layer: 0-4 (ps,l1,l2,l3,had) cell: 0-3 for l1,l2, 0 otherwise will return 0 if th...
uint8_t fpga() const
setter for the above
bool disconnectedCount(size_t idx) const
setter for the above
void setModule(uint8_t)
getter for the module number [0-23] inclusive
void setEm_status(uint32_t)
getter for the electromagnetic status bit
float eta() const
The pseudorapidity ( )
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
setRawEt setRawPhi int
setEventNumber uint32_t