ATLAS Offline Software
Loading...
Searching...
No Matches
ModuleEnergy.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 ModuleEnergy.cxx - description
6 -------------------
7 begin : Tues Sep 4 2007
8 Loosely based on Ed Moyse's JetEnergyModule
9 email : Alan.Watson@cern.ch
10 ***************************************************************************/
11
14
15#include <math.h>
16
17namespace LVL1 {
18
20 unsigned int module, int JEThresholdEtSum, int JEThresholdEtMiss, const std::map<int, int>* TEMasks, int slice):
21 m_jetElementThresholdEtSum(JEThresholdEtSum),
22 m_jetElementThresholdEtMiss(JEThresholdEtMiss),
23 m_Et(0),
24 m_Ex(0),
25 m_Ey(0),
26 m_signX(1),
27 m_signY(1),
30 m_debug(false)
31{
32 // Only fill ModuleEnergys where crate, module numbers valid
33 if (m_debug) std::cout << "Create ModuleEnergy for crate "
34 << crate << " module " << module << std::endl;
35 if (m_crate <= 1 && m_module <= 15) {
37 m_signY = ( (module < 8) ? 1 : -1 );
38 m_signX = ( (crate == 0) ? m_signY : -m_signY );
40 bool saturated = false;
42 std::vector<unsigned int> keys = get.jeKeys(crate, module);
43 for (unsigned int k : keys) {
44 xAOD::JetElementMap_t::const_iterator test=JEContainer->find(k);
45 if (test != JEContainer->end()) {
47 double eta = test->second->eta();
48 int ieta = int((eta + (eta>0 ? 0.005 : -0.005))/0.1);
50 if (TEMasks == 0 || TEMasks->find(ieta) == TEMasks->end()) {
52 if (test->second->isSaturated()) {
53 saturated = true;
54 }
55 else {
57 int jetElementET;
58 if (slice < 0) jetElementET = test->second->et();
59 else jetElementET = test->second->sliceET(slice);
61 if (jetElementET > m_jetElementThresholdEtMiss) {
63 double phi = test->second->phi();
64 int cosPhi = 0;
65 int sinPhi = 0;
66 getSinCos(eta,phi,cosPhi,sinPhi);
68 unsigned int EnergyX = ((jetElementET*cosPhi) & 0x7ffffc00);
69 unsigned int EnergyY = ((jetElementET*sinPhi) & 0x7ffffc00);
70 m_Ex += EnergyX;
71 m_Ey += EnergyY;
72 if (m_debug) std::cout << "JE phi = " << phi << ", ET = " << jetElementET
73 << ", Ex = " << (EnergyX>>10) << ", Ey = " << (EnergyY>>10) << std::endl;
74 }
76 if ( jetElementET > m_jetElementThresholdEtSum )
77 m_Et += jetElementET;
78 } // End of processing of unsaturated jetElement
79 } // End processing of unvetoed element
80 } // End check for end of container
81 } // End loop through keys
82
84 m_Ex = m_Ex>>12;
85 m_Ey = m_Ey>>12;
86
88 if (saturated || (m_Ex > (1<<m_EtBits)-1)) m_Ex = (1<<m_EtBits)-1;
89 if (saturated || (m_Ey > (1<<m_EtBits)-1)) m_Ey = (1<<m_EtBits)-1;
90 if (saturated || (m_Et > (1<<m_EtBits)-1)) m_Et = (1<<m_EtBits)-1;
91
92 if (m_debug) {
93 std::cout << "Crate " << crate << " Module " << module <<
94 " sums: " << std::endl;
95 std::cout << " Ex = " << static_cast<int>(m_Ex)*m_signX << std::endl;
96 std::cout << " Ey = " << static_cast<int>(m_Ey)*m_signY << std::endl;
97 std::cout << " Et = " << m_Et << std::endl;
98 }
99 }
100}
101
102ModuleEnergy::ModuleEnergy(unsigned int crate, unsigned int module,
103 unsigned int et, unsigned int ex,
104 unsigned int ey) :
107 m_Et(et),
108 m_Ex(ex),
109 m_Ey(ey),
110 m_signX(1),
111 m_signY(1),
112 m_crate(crate),
114 m_debug(false)
115{
116 // Only fill ModuleEnergys where crate, module numbers valid
117 if (m_debug) std::cout << "Create ModuleEnergy for crate "
118 << crate << " module " << module << std::endl;
119 if (m_crate <= 1 && m_module <= 15) {
121 m_signY = ( (module < 8) ? 1 : -1 );
122 m_signX = ( (crate == 0) ? m_signY : -m_signY );
123
125 if (m_Ex > (1<<m_EtBits)-1) m_Ex = (1<<m_EtBits)-1;
126 if (m_Ey > (1<<m_EtBits)-1) m_Ey = (1<<m_EtBits)-1;
127 if (m_Et > (1<<m_EtBits)-1) m_Et = (1<<m_EtBits)-1;
128
129 if (m_debug) {
130 std::cout << "Crate " << crate << " Module " << module <<
131 " sums: " << std::endl;
132 std::cout << " Ex = " << static_cast<int>(m_Ex)*m_signX << std::endl;
133 std::cout << " Ey = " << static_cast<int>(m_Ey)*m_signY << std::endl;
134 std::cout << " Et = " << m_Et << std::endl;
135 }
136 }
137}
138
139
142
144unsigned int ModuleEnergy::crate() const {
145 return m_crate;
146}
147
148unsigned int ModuleEnergy::module() const {
149 return m_module;
150}
151
153unsigned int ModuleEnergy::et() const {
154 return m_Et;
155}
156unsigned int ModuleEnergy::ex() const {
157 return m_Ex;
158}
159unsigned int ModuleEnergy::ey() const {
160 return m_Ey;
161}
162
165 return m_signX;
166}
168 return m_signY;
169}
170
172void ModuleEnergy::getSinCos(double eta, double phi, int& cosPhi, int& sinPhi) {
173
175 unsigned int SinCos[8] = {401,1187,1928,2594,3161,3607,3913,4070};
176 unsigned int fwdSinCos[4] = {794,2261,3384,3992};
177
179 float modPhi = fmod(phi, M_PI/2.);
180
182 if (fabs(eta) < 3.2) {
183 int phiBin = (int)(modPhi*16/M_PI);
184 if (m_crate > 0) {
185 cosPhi = SinCos[phiBin];
186 sinPhi = SinCos[7-phiBin];
187 }
188 else {
189 cosPhi = SinCos[7-phiBin];
190 sinPhi = SinCos[phiBin];
191 }
192 }
194 else {
195 int phiBin = (int)(modPhi*8/M_PI);
196 if (m_crate > 0) {
197 cosPhi = fwdSinCos[phiBin];
198 sinPhi = fwdSinCos[3-phiBin];
199 }
200 else {
201 cosPhi = fwdSinCos[3-phiBin];
202 sinPhi = fwdSinCos[phiBin];
203 }
204 }
205
206} // end of getSinCos
207
208} // end of namespace bracket
209
210
#define M_PI
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
The JetEnergyModuleKey object provides the key for each trigger tower depending on its eta-phi coords...
ModuleEnergy(const xAOD::JetElementMap_t *JEContainer, unsigned int crate, unsigned int module, int JEThresholdEtSum, int JEThresholdEtMiss, const std::map< int, int > *TEMasks=0, int slice=-1)
unsigned int crate() const
which module is this?
unsigned int m_Ex
unsigned int et() const
return the scalar & vector sums of all JE ETs (i.e sums the energies of up to 32 contained JEs)
unsigned int module() const
return module number
unsigned int m_Ey
unsigned int m_Et
unsigned int m_crate
static const unsigned int m_EtBits
void getSinCos(double eta, double phi, int &cosPhi, int &sinPhi)
return cos, sin coefficients for a given JetElement
unsigned int m_module
unsigned int ey() const
int signX() const
return signs of Ex and Ey for this module
unsigned int ex() const
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
std::map< int, const JetElement * > JetElementMap_t