ATLAS Offline Software
TrigMissingET.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include "CxxUtils/StrFormat.h"
8 
9 #include <string>
10 #include <stdio.h>
11 #include <string.h>
12 #include <cmath>
13 
15  m_ex(0), m_ey(0), m_ez(0), m_sum_et(0), m_sum_e(0),
16  m_flag(0), m_roiWord(0)
17 {
18 }
19 
20 
22  m_ex(0), m_ey(0), m_ez(0), m_sum_et(0), m_sum_e(0),
23  m_flag(0), m_roiWord(0)
24 {
26  // 1. muons + all calo samplings in barrel + calo samplings in both end-caps
27  char names25[25][6] = {"EMB0", "EMB1", "EMB2", "EMB3",
28  "EME0", "EME1", "EME2", "EME3",
29  "HEC0", "HEC1", "HEC2", "HEC3",
30  "TiB0", "TiB1", "TiB2",
31  "TiG1", "TiG2", "TiG3",
32  "TiE0", "TiE1", "TiE2",
33  "FCa0", "FCa1", "FCa2",
34  "Muon"};
35 
36  // 2. only muons
37  char names1[1][6] = {"Muon"};
38 
39  // 3. muons + sum of all EM + sum of all HAD
40  char names3[3][6] = {"Muon", "E.M.", "Had."};
41 
42  // 4. muons + EM_barrel + EM_endcaps + HAD_barrel + HAD_endcaps
43  char names5[5][6] = {"Muon", "EM_B", "EM_E", "HadB", "HadE"};
44 
45  if (n>0) m_compVec.reserve(n);
46  for (int i=0; i<n; ++i) {
48  if (n==25) {
49  c.setName(names25[i]);
50  } else if (n==1) {
51  c.setName(names1[i]);
52  } else if (n==3) {
53  c.setName(names3[i]);
54  } else if (n==5) {
55  c.setName(names5[i]);
56  } else {
57  c.setName("????");
58  }
59  m_compVec.push_back(c);
60  }
61 }
62 
63 
64 TrigMissingET::TrigMissingET(std::vector< TrigMissingEtComponent >&& compVec)
65  : m_ex(0), m_ey(0), m_ez(0), m_sum_et(0), m_sum_e(0),
66  m_flag(0), m_roiWord(0),
67  m_compVec (std::move(compVec))
68 {
69 }
70 
71 
73 
74 
76 {
77 
78  m_ex=0;
79  m_ey=0;
80  m_ez=0;
81  m_sum_et=0;
82  m_sum_e=0;
83  m_flag=0;
84 
85  for (unsigned int i=0; i<m_compVec.size(); ++i) {
86  m_compVec[i].reset();
87  }
88 
89 }
90 
91 
92 std::string TrigMissingET::getNameOfComponent(unsigned int index) const
93 {
94  if (index < m_compVec.size())
95  return m_compVec[index].name();
96  else
97  return std::string("WRONG INDEX!");
98 }
99 
100 
101 float TrigMissingET::getExComponent(unsigned int index) const{
102  if (index < m_compVec.size())
103  return m_compVec[index].ex();
104  else
105  return 0; //<! safe but silent!
106 }
107 
108 
109 float TrigMissingET::getEyComponent(unsigned int index) const{
110  if (index < m_compVec.size())
111  return m_compVec[index].ey();
112  else
113  return 0; //<! safe but silent!
114 }
115 
116 
117 float TrigMissingET::getEzComponent(unsigned int index) const{
118  if (index < m_compVec.size())
119  return m_compVec[index].ez();
120  else
121  return 0; //<! safe but silent!
122 }
123 
124 
125 float TrigMissingET::getSumEtComponent(unsigned int index) const{
126  if (index < m_compVec.size())
127  return m_compVec[index].sumEt();
128  else
129  return 0; //<! safe but silent!
130 }
131 
132 
133 float TrigMissingET::getSumEComponent(unsigned int index) const{
134  if (index < m_compVec.size())
135  return m_compVec[index].sumE();
136  else
137  return 0; //<! safe but silent!
138 }
139 
140 
141 short TrigMissingET::getSumOfSigns(unsigned int index) const{
142  if (index < m_compVec.size())
143  return m_compVec[index].sumOfSigns();
144  else
145  return 0; //<! safe but silent!
146 }
147 
148 
149 unsigned short TrigMissingET::getUsedChannels(unsigned int index) const{
150  if (index < m_compVec.size())
151  return m_compVec[index].usedChannels();
152  else
153  return 0; //<! safe but silent!
154 }
155 
156 
157 short TrigMissingET::getStatus(unsigned int index) const{
158  if (index < m_compVec.size())
159  return m_compVec[index].status();
160  else
161  return 0; //<! safe but silent!
162 }
163 
164 
165 float TrigMissingET::getComponentCalib0(unsigned int index) const{
166  if (index < m_compVec.size())
167  return m_compVec[index].calib0();
168  else
169  return 0; //<! safe but silent!
170 }
171 
172 
173 float TrigMissingET::getComponentCalib1(unsigned int index) const{
174  if (index < m_compVec.size())
175  return m_compVec[index].calib1();
176  else
177  return 0; //<! safe but silent!
178 }
179 
180 
181 
182 
183 void TrigMissingET::setNameOfComponent(unsigned int index, const char* str){
184  if (index < m_compVec.size()) m_compVec[index].setName(str);
185 }
186 
187 
188 void TrigMissingET::setExComponent(unsigned int index, float value){
189  if (index < m_compVec.size()) m_compVec[index].setEx(value);
190 }
191 
192 
193 void TrigMissingET::setEyComponent(unsigned int index, float value){
194  if (index < m_compVec.size()) m_compVec[index].setEy(value);
195 }
196 
197 
198 void TrigMissingET::setEzComponent(unsigned int index, float value){
199  if (index < m_compVec.size()) m_compVec[index].setEz(value);
200 }
201 
202 
203 void TrigMissingET::setSumEtComponent(unsigned int index, float value){
204  if (index < m_compVec.size()) m_compVec[index].setSumEt(value);
205 }
206 
207 
208 void TrigMissingET::setSumEComponent(unsigned int index, float value){
209  if (index < m_compVec.size()) m_compVec[index].setSumE(value);
210 }
211 
212 
214  if (index < m_compVec.size()) m_compVec[index].setCalib0(value);
215 }
216 
217 
219  if (index < m_compVec.size()) m_compVec[index].setCalib1(value);
220 }
221 
222 
223 void TrigMissingET::setSumOfSigns(unsigned int index, short value){
224  if (index < m_compVec.size()) m_compVec[index].setSumOfSigns(value);
225 }
226 
227 
228 void TrigMissingET::setUsedChannels(unsigned int index, unsigned short value){
229  if (index < m_compVec.size()) m_compVec[index].setUsedChannels(value);
230 }
231 
232 
233 void TrigMissingET::setStatus(unsigned int index, short value){
234  if (index < m_compVec.size()) m_compVec[index].setStatus(value);
235 }
236 
237 
238 
239 
240 
241 bool operator== ( const TrigMissingET& a, const TrigMissingET& b ) {
242 
243  const double DELTA=1e-3; // distance used to compare floats
244 
245  if( a.getNumOfComponents() != b.getNumOfComponents() )
246  return false;
247  if( a.getFlag() != b.getFlag() )
248  return false;
249  if( a.RoIword() != b.RoIword() )
250  return false;
251 
252  if( fabsf(a.ex() - b.ex()) > DELTA )
253  return false;
254  if( fabsf(a.ey() - b.ey()) > DELTA )
255  return false;
256  if( fabsf(a.ez() - b.ez()) > DELTA )
257  return false;
258  if( fabsf(a.sumEt() - b.sumEt()) > DELTA )
259  return false;
260  if( fabsf(a.sumE() - b.sumE()) > DELTA )
261  return false;
262 
263  for (unsigned u=0; u<a.getNumOfComponents(); ++u) {
264  if( a.getNameOfComponent(u) != b.getNameOfComponent(u) )
265  return false;
266  if( a.getStatus(u) != b.getStatus(u) )
267  return false;
268  if( a.getSumOfSigns(u) != b.getSumOfSigns(u) )
269  return false;
270  if( a.getUsedChannels(u) != b.getUsedChannels(u) )
271  return false;
272  if( fabsf(a.getExComponent(u) - b.getExComponent(u)) > DELTA )
273  return false;
274  if( fabsf(a.getEyComponent(u) - b.getEyComponent(u)) > DELTA )
275  return false;
276  if( fabsf(a.getEzComponent(u) - b.getEzComponent(u)) > DELTA )
277  return false;
278  if( fabsf(a.getSumEtComponent(u) - b.getSumEtComponent(u)) > DELTA )
279  return false;
280  if( fabsf(a.getSumEComponent(u) - b.getSumEComponent(u)) > DELTA )
281  return false;
282  if( fabsf(a.getComponentCalib0(u) - b.getComponentCalib0(u)) > DELTA )
283  return false;
284  if( fabsf(a.getComponentCalib1(u) - b.getComponentCalib1(u)) > DELTA )
285  return false;
286  }
287 
288  return true;
289 }
290 
291 
292 std::string str (const TrigMissingET& a){
293  std::string s="";
294 
295  using CxxUtils::strformat;
296 
297  s += strformat("MEx = %10.2f MeV\n", a.ex());
298  s += strformat("MEy = %10.2f MeV\n", a.ey());
299  s += strformat("MEz = %10.2f MeV\n", a.ez());
300 
301  float et = std::sqrt(a.ex()*a.ex()+a.ey()*a.ey());
302  s += strformat("MEt = %10.2f MeV\n", et);
303  s += strformat("SumEt = %10.2f MeV\n", a.sumEt());
304  s += strformat("SumE = %10.2f MeV\n", a.sumE());
305 
306  s += strformat("Event status = 0x%08x\n", (unsigned)a.getFlag());
307  unsigned int N = a.getNumOfComponents();
308  s += strformat("Auxiliary components = %4u\n", N);
309 
310  if (N==0) return s; // basic info only
311 
312  // header
313  s += "__name_____status__usedCh.__sumOfSigns__calib1_calib0";
314  s += "/MeV___Ex/MeV_____Ey/MeV_____Ez/MeV___SumE/MeV__SumEt/MeV\n";
315 
316  for (unsigned int i=0; i<N; ++i){
317  s += strformat(
318  "%10s 0x%04x %8d %11d %7.2f %8.2f %10.2f %10.2f %10.2f %10.2f %10.2f\n",
319  a.getNameOfComponent(i).c_str(),
320  (unsigned)a.getStatus(i),
321  a.getUsedChannels(i),
322  a.getSumOfSigns(i),
323  a.getComponentCalib1(i),
324  a.getComponentCalib0(i),
325  a.getExComponent(i),
326  a.getEyComponent(i),
327  a.getEzComponent(i),
328  a.getSumEComponent(i),
329  a.getSumEtComponent(i));
330  }
331 
332  return s;
333 }
334 
335 
336 MsgStream& operator<< (MsgStream& m, const TrigMissingET& d) {
337  return ( m << str( d ) );
338 }
339 
340 
341 
342 void diff(const TrigMissingET& a, const TrigMissingET& b,
343  std::map<std::string, double>& variableChange){
344 
345  const double DELTA=1e-3; // distance used to compare floats
346 
347  int Na = a.getNumOfComponents();
348  int Nb = b.getNumOfComponents();
349  if( Na != Nb )
350  variableChange[ "NumOfComponents" ] = Na - Nb;
351 
352  unsigned aFlag = (unsigned) a.getFlag();
353  unsigned bFlag = (unsigned) b.getFlag();
354  if( aFlag != bFlag )
355  variableChange[ "FlagsXOR" ] = aFlag ^ bFlag;
356 
357  unsigned long aRoI = (unsigned long) a.RoIword();
358  unsigned long bRoI = (unsigned long) b.RoIword();
359  if( aRoI != bRoI )
360  variableChange[ "RoIwordsXOR" ] = aRoI ^ bRoI;
361 
362  float aEx = a.ex();
363  float bEx = b.ex();
364  if( fabsf(aEx - bEx) > DELTA )
365  variableChange[ "Ex" ] = aEx - bEx;
366 
367  float aEy = a.ey();
368  float bEy = b.ey();
369  if( fabsf(aEy - bEy) > DELTA )
370  variableChange[ "Ey" ] = aEy - bEy;
371 
372  float aEz = a.ez();
373  float bEz = b.ez();
374  if( fabsf(aEz - bEz) > DELTA )
375  variableChange[ "Ez" ] = aEz - bEz;
376 
377  float aSumEt = a.sumEt();
378  float bSumEt = b.sumEt();
379  if( fabsf(aSumEt - bSumEt) > DELTA )
380  variableChange[ "sumEt" ] = aSumEt - bSumEt;
381 
382  float aSumE = a.sumE();
383  float bSumE = b.sumE();
384  if( fabsf(aSumE - bSumE) > DELTA )
385  variableChange[ "sumE" ] = aSumE - bSumE;
386 
387  for (unsigned u=0; u<a.getNumOfComponents(); ++u) {
388  std::string num = CxxUtils::strformat("%02u", u);
389  std::string key;
390 
391  if( a.getNameOfComponent(u) != b.getNameOfComponent(u) ) {
392  key="CompNameStrCmp"; key+=num;
393  variableChange[ key.c_str() ] =
394  strcmp(a.getNameOfComponent(u).c_str(),
395  b.getNameOfComponent(u).c_str());
396  }
397 
398  unsigned aFlag = (unsigned) a.getStatus(u);
399  unsigned bFlag = (unsigned) b.getStatus(u);
400  if( aFlag != bFlag ) {
401  key="CompStatusXOR"; key+=num;
402  variableChange[ key.c_str() ] = aFlag ^ bFlag;
403  }
404 
405  int aSigns = a.getSumOfSigns(u);
406  int bSigns = b.getSumOfSigns(u);
407  if( aSigns != bSigns ) {
408  key="CompSumSigns"; key+=num;
409  variableChange[ key.c_str() ] = aSigns - bSigns;
410  }
411 
412  int aChans = a.getUsedChannels(u);
413  int bChans = b.getUsedChannels(u);
414  if( aChans != bChans ) {
415  key="CompUsedChans"; key+=num;
416  variableChange[ key.c_str() ] = aChans - bChans;
417  }
418 
419  float aEx = a.getExComponent(u);
420  float bEx = b.getExComponent(u);
421  if( fabsf(aEx - bEx) > DELTA ) {
422  key="CompEx"; key+=num;
423  variableChange[ key.c_str() ] = aEx - bEx;
424  }
425 
426  float aEy = a.getEyComponent(u);
427  float bEy = b.getEyComponent(u);
428  if( fabsf(aEy - bEy) > DELTA ) {
429  key="CompEy"; key+=num;
430  variableChange[ key.c_str() ] = aEy - bEy;
431  }
432 
433  float aEz = a.getEzComponent(u);
434  float bEz = b.getEzComponent(u);
435  if( fabsf(aEz - bEz) > DELTA ) {
436  key="CompEz"; key+=num;
437  variableChange[ key.c_str() ] = aEz - bEz;
438  }
439 
440  float aSumEt = a.getSumEtComponent(u);
441  float bSumEt = b.getSumEtComponent(u);
442  if( fabsf(aSumEt - bSumEt) > DELTA ) {
443  key="CompSumEt"; key+=num;
444  variableChange[ key.c_str() ] = aSumEt - bSumEt;
445  }
446 
447  float aSumE = a.getSumEComponent(u);
448  float bSumE = b.getSumEComponent(u);
449  if( fabsf(aSumE - bSumE) > DELTA ) {
450  key="CompSumE"; key+=num;
451  variableChange[ key.c_str() ] = aSumE - bSumE;
452  }
453 
454  float aCalib0 = a.getComponentCalib0(u);
455  float bCalib0 = b.getComponentCalib0(u);
456  if( fabsf(aCalib0 - bCalib0) > DELTA ) {
457  key="CompCalib0_"; key+=num;
458  variableChange[ key.c_str() ] = aCalib0 - bCalib0;
459  }
460 
461  float aCalib1 = a.getComponentCalib1(u);
462  float bCalib1 = b.getComponentCalib1(u);
463  if( fabsf(aCalib1 - bCalib1) > DELTA ) {
464  key="CompCalib1_"; key+=num;
465  variableChange[ key.c_str() ] = aCalib1 - bCalib1;
466  }
467  }
468 
469  return;
470 }
471 
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
TrigMissingET::getStatus
short getStatus(unsigned int index) const
get status flag for component ‘index’
Definition: TrigMissingET.cxx:157
TrigMissingET::m_compVec
std::vector< TrigMissingEtComponent > m_compVec
Auxiliary information: components from different calo layers and muons.
Definition: Trigger/TrigEvent/TrigMissingEtEvent/TrigMissingEtEvent/TrigMissingET.h:169
et
Extra patterns decribing particle interation process.
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
TrigMissingET::m_sum_et
float m_sum_et
Basic information: scalar sum of Et.
Definition: Trigger/TrigEvent/TrigMissingEtEvent/TrigMissingEtEvent/TrigMissingET.h:159
TrigMissingET::m_ez
float m_ez
Basic information: Ez component.
Definition: Trigger/TrigEvent/TrigMissingEtEvent/TrigMissingEtEvent/TrigMissingET.h:157
TrigMissingEtComponent
MET trigger slice components (auxiliary information for TrigMissingET)
Definition: TrigMissingEtEvent/TrigMissingEtEvent/TrigMissingEtComponent.h:27
index
Definition: index.py:1
hist_file_dump.d
d
Definition: hist_file_dump.py:137
TrigMissingET::getUsedChannels
unsigned short getUsedChannels(unsigned int index) const
get number of used channes in component ‘index’
Definition: TrigMissingET.cxx:149
TrigMissingET::setStatus
void setStatus(unsigned int index, short value)
set status flag of component ‘index’
Definition: TrigMissingET.cxx:233
diff
void diff(const TrigMissingET &a, const TrigMissingET &b, std::map< std::string, double > &variableChange)
Comparison with feedback.
Definition: TrigMissingET.cxx:342
athena.value
value
Definition: athena.py:124
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
TrigMissingET::setNameOfComponent
void setNameOfComponent(unsigned int index, const char *str)
set name of component ‘index’
Definition: TrigMissingET.cxx:183
TrigMissingET::clear
void clear()
reset contents
Definition: TrigMissingET.cxx:75
xAOD::unsigned
unsigned
Definition: RingSetConf_v1.cxx:662
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
TrigMissingET::m_ey
float m_ey
Basic information: Ey component.
Definition: Trigger/TrigEvent/TrigMissingEtEvent/TrigMissingEtEvent/TrigMissingET.h:155
TrigMissingET::getEyComponent
float getEyComponent(unsigned int index) const
get Ey from component ‘index’
Definition: TrigMissingET.cxx:109
TrigMissingET::setSumOfSigns
void setSumOfSigns(unsigned int index, short value)
set sum of energy signs for calibration of component ‘index’
Definition: TrigMissingET.cxx:223
StrFormat.h
Provide helper functions to create formatted strings.
TrigMissingET::getNameOfComponent
std::string getNameOfComponent(unsigned int index) const
get name of component ‘index’
Definition: TrigMissingET.cxx:92
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
TrigMissingET::getComponentCalib1
float getComponentCalib1(unsigned int index) const
get scale for calibration of component ‘index’
Definition: TrigMissingET.cxx:173
TrigMissingET::getExComponent
float getExComponent(unsigned int index) const
get Ex from component ‘index’
Definition: TrigMissingET.cxx:101
TrigMissingEtComponent.h
TrigMissingET::setUsedChannels
void setUsedChannels(unsigned int index, unsigned short value)
set number of used channels in component ‘index’
Definition: TrigMissingET.cxx:228
operator==
bool operator==(const TrigMissingET &a, const TrigMissingET &b)
Operator comparing two objects for equality.
Definition: TrigMissingET.cxx:241
TrigMissingET::getComponentCalib0
float getComponentCalib0(unsigned int index) const
get constant term for calibration of component ‘index’
Definition: TrigMissingET.cxx:165
operator<<
MsgStream & operator<<(MsgStream &m, const TrigMissingET &d)
Definition: TrigMissingET.cxx:336
TrigMissingET::setSumEComponent
void setSumEComponent(unsigned int index, float value)
set sum of |E| for component ‘index’
Definition: TrigMissingET.cxx:208
TrigMissingET::setEzComponent
void setEzComponent(unsigned int index, float value)
set Ez for component ‘index’
Definition: TrigMissingET.cxx:198
trigbs_pickEvents.num
num
Definition: trigbs_pickEvents.py:76
TrigMissingET
Class for LVL2/EF MissingET trigger.
Definition: Trigger/TrigEvent/TrigMissingEtEvent/TrigMissingEtEvent/TrigMissingET.h:35
CxxUtils::strformat
std::string strformat(const char *fmt,...)
return a std::string according to a format fmt and varargs
Definition: StrFormat.cxx:49
TrigMissingET::getSumEtComponent
float getSumEtComponent(unsigned int index) const
get sum of |Et| from component ‘index’
Definition: TrigMissingET.cxx:125
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
TrigMissingET::setComponentCalib0
void setComponentCalib0(unsigned int index, float value)
set constant term for calibration of component ‘index’
Definition: TrigMissingET.cxx:213
TrigMissingET::TrigMissingET
TrigMissingET()
default constructor
Definition: TrigMissingET.cxx:14
TrigMissingET::setEyComponent
void setEyComponent(unsigned int index, float value)
set Ey for component ‘index’
Definition: TrigMissingET.cxx:193
DeMoScan.index
string index
Definition: DeMoScan.py:364
TrigMissingET::setComponentCalib1
void setComponentCalib1(unsigned int index, float value)
set scale for calibration of component ‘index’
Definition: TrigMissingET.cxx:218
TrigMissingET::getEzComponent
float getEzComponent(unsigned int index) const
get Ez from component ‘index’
Definition: TrigMissingET.cxx:117
a
TList * a
Definition: liststreamerinfos.cxx:10
TrigMissingET::setExComponent
void setExComponent(unsigned int index, float value)
set Ex for component ‘index’
Definition: TrigMissingET.cxx:188
TrigMissingET::m_sum_e
float m_sum_e
Basic information: scalar sum of E.
Definition: Trigger/TrigEvent/TrigMissingEtEvent/TrigMissingEtEvent/TrigMissingET.h:161
str
std::string str(const TrigMissingET &a)
conversion to formatted string: multi-line!
Definition: TrigMissingET.cxx:292
TrigMissingET::getSumOfSigns
short getSumOfSigns(unsigned int index) const
get sum of energy signs for calibration of component ‘index’
Definition: TrigMissingET.cxx:141
str
Definition: BTagTrackIpAccessor.cxx:11
TrigMissingET::getSumEComponent
float getSumEComponent(unsigned int index) const
get sum of |E| from component ‘index’
Definition: TrigMissingET.cxx:133
python.compressB64.c
def c
Definition: compressB64.py:93
TrigMissingET.h
TrigMissingET::~TrigMissingET
~TrigMissingET()
destructor
Definition: TrigMissingET.cxx:72
TrigMissingET::m_flag
int m_flag
Basic information: event status flag: 0 (default) means OK.
Definition: Trigger/TrigEvent/TrigMissingEtEvent/TrigMissingEtEvent/TrigMissingET.h:163
TrigMissingET::m_ex
float m_ex
Basic information: Ex component.
Definition: Trigger/TrigEvent/TrigMissingEtEvent/TrigMissingEtEvent/TrigMissingET.h:153
TrigMissingET::setSumEtComponent
void setSumEtComponent(unsigned int index, float value)
set sum of |Et| for component ‘index’
Definition: TrigMissingET.cxx:203
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37