ATLAS Offline Software
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 
17 namespace LVL1 {
18 
19 ModuleEnergy::ModuleEnergy(const xAOD::JetElementMap_t* JEContainer, unsigned int crate,
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),
28  m_crate(crate),
29  m_module(module),
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 
102 ModuleEnergy::ModuleEnergy(unsigned int crate, unsigned int module,
103  unsigned int et, unsigned int ex,
104  unsigned int ey) :
105  m_jetElementThresholdEtSum(0),
106  m_jetElementThresholdEtMiss(0),
107  m_Et(et),
108  m_Ex(ex),
109  m_Ey(ey),
110  m_signX(1),
111  m_signY(1),
112  m_crate(crate),
113  m_module(module),
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 
141 }
142 
144 unsigned int ModuleEnergy::crate() const {
145  return m_crate;
146 }
148 unsigned int ModuleEnergy::module() const {
149  return m_module;
150 }
151 
153 unsigned int ModuleEnergy::et() const {
154  return m_Et;
155 }
156 unsigned int ModuleEnergy::ex() const {
157  return m_Ex;
158 }
159 unsigned int ModuleEnergy::ey() const {
160  return m_Ey;
161 }
162 
164 int ModuleEnergy::signX() const {
165  return m_signX;
166 }
167 int ModuleEnergy::signY() const {
168  return m_signY;
169 }
170 
172 void 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 
et
Extra patterns decribing particle interation process.
LVL1::JetEnergyModuleKey
The JetEnergyModuleKey object provides the key for each trigger tower depending on its eta-phi coords...
Definition: JetEnergyModuleKey.h:40
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
LVL1::ModuleEnergy::signX
int signX() const
return signs of Ex and Ey for this module
Definition: ModuleEnergy.cxx:170
LVL1::ModuleEnergy::ex
unsigned int ex() const
Definition: ModuleEnergy.cxx:162
LVL1::ModuleEnergy::~ModuleEnergy
~ModuleEnergy()
Definition: ModuleEnergy.cxx:146
ModuleEnergy.h
LVL1::ModuleEnergy::m_Et
unsigned int m_Et
Definition: ModuleEnergy.h:75
M_PI
#define M_PI
Definition: ActiveFraction.h:11
LVL1::ModuleEnergy::crate
unsigned int crate() const
which module is this?
Definition: ModuleEnergy.cxx:150
LVL1::ModuleEnergy::ey
unsigned int ey() const
Definition: ModuleEnergy.cxx:165
TrigInDetValidation_Base.test
test
Definition: TrigInDetValidation_Base.py:144
LVL1::ModuleEnergy::m_Ex
unsigned int m_Ex
Definition: ModuleEnergy.h:76
LVL1::ModuleEnergy::signY
int signY() const
Definition: ModuleEnergy.cxx:173
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
LVL1::ModuleEnergy::m_crate
unsigned int m_crate
Definition: ModuleEnergy.h:80
LVL1::ModuleEnergy::ModuleEnergy
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)
Definition: ModuleEnergy.cxx:25
python.PyAthena.module
module
Definition: PyAthena.py:134
xAOD::saturated
setScaleOne setStatusOne saturated
Definition: gFexGlobalRoI_v1.cxx:51
xAOD::JetElementMap_t
std::map< int, const JetElement * > JetElementMap_t
Definition: Event/xAOD/xAODTrigL1Calo/xAODTrigL1Calo/JetElement.h:18
perfmonmt-refit.slice
slice
Definition: perfmonmt-refit.py:52
LVL1::ModuleEnergy::m_module
unsigned int m_module
Definition: ModuleEnergy.h:81
LVL1::ModuleEnergy::m_signX
int m_signX
Definition: ModuleEnergy.h:78
LVL1::ModuleEnergy::m_Ey
unsigned int m_Ey
Definition: ModuleEnergy.h:77
LVL1::ModuleEnergy::module
unsigned int module() const
return module number
Definition: ModuleEnergy.cxx:154
xAOD::phiBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setPhiMap phiBin
Definition: L2StandAloneMuon_v2.cxx:144
QuadLinear.h
LVL1::ModuleEnergy::m_signY
int m_signY
Definition: ModuleEnergy.h:79
LVL1::ModuleEnergy::et
unsigned int et() const
return the scalar & vector sums of all JE ETs (i.e sums the energies of up to 32 contained JEs)
Definition: ModuleEnergy.cxx:159
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
LVL1::ModuleEnergy::getSinCos
void getSinCos(double eta, double phi, int &cosPhi, int &sinPhi)
return cos, sin coefficients for a given JetElement
Definition: ModuleEnergy.cxx:178
fitman.k
k
Definition: fitman.py:528