ATLAS Offline Software
TileHitInfoFillerTool.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 // $Id$
13 #include "TileHitInfoFillerTool.h"
14 #include "TileSimEvent/TileHit.h"
17 #include "StoreGate/StoreGateSvc.h"
18 #include "CaloIdentifier/TileID.h"
19 
20 #include <sstream>
21 
22 
23 namespace D3PD {
24 
25 
33  (const std::string& type,
34  const std::string& name,
35  const IInterface* parent)
37 {
38 
39  declareProperty("TimeMin",m_timeMin = -12.5);
40  declareProperty("TimeMax",m_timeMax = 12.5);
41  declareProperty("TimeOut",m_timeOut = 99990.);
42 
43  TileHitInfoFillerTool::book().ignore(); // Avoid coverity warnings
44 }
45 
46 
51 {
52 
53  CHECK(addVariable("energy", m_energy ));
54  CHECK(addVariable("eBefore", m_eBefore ));
55  CHECK(addVariable("eInTime", m_eInTime ));
56  CHECK(addVariable("eAfter", m_eAfter ));
57  CHECK(addVariable("eOutTime", m_eOutTime ));
58  CHECK(addVariable("time", m_time ));
59  CHECK(addVariable("tBefore", m_tBefore ));
60  CHECK(addVariable("tInTime", m_tInTime ));
61  CHECK(addVariable("tAfter", m_tAfter ));
62  CHECK(addVariable("tOutTime", m_tOutTime ));
63  CHECK(addVariable("nHit", m_nHit ));
64  CHECK(addVariable("nHitBefore", m_nHitBefore ));
65  CHECK(addVariable("nHitInTime", m_nHitInTime ));
66  CHECK(addVariable("nHitAfter", m_nHitAfter ));
67  CHECK(addVariable("nHitOutTime", m_nHitOutTime ));
68  CHECK(addVariable("nChan", m_nChan ));
69  CHECK(addVariable("nChanBefore", m_nChanBefore ));
70  CHECK(addVariable("nChanInTime", m_nChanInTime ));
71  CHECK(addVariable("nChanAfter", m_nChanAfter ));
72  CHECK(addVariable("nChanOutTime",m_nChanOutTime));
73 
74  return StatusCode::SUCCESS;
75 }
76 
77 
87 {
88  *m_energy = 0.0;
89  *m_eInTime = 0.0;
90  *m_eBefore = 0.0;
91  *m_eAfter = 0.0;
92  *m_eOutTime = 0.0;
93  *m_time = 0.0;
94  *m_tInTime = 0.0;
95  *m_tBefore = 0.0;
96  *m_tAfter = 0.0;
97  *m_tOutTime = 0.0;
98  *m_nHit = 0;
99  *m_nHitInTime = 0;
100  *m_nHitBefore = 0;
101  *m_nHitAfter = 0;
102  *m_nHitOutTime = 0;
103  *m_nChan = 0;
104  *m_nChanInTime = 0;
105  *m_nChanBefore = 0;
106  *m_nChanAfter = 0;
107  *m_nChanOutTime = 0;
108 
109  TileHitVector::const_iterator itr = hitCont.begin();
110  TileHitVector::const_iterator itrLast = hitCont.end();
111 
112  double eInTime=0.0;
113  double eBefore=0.0;
114  double eAfter=0.0;
115  double eOutTime=0.0;
116  double tInTime=0.0;
117  double tBefore=0.0;
118  double tAfter=0.0;
119  double tOutTime=0.0;
120 
121  for ( ; itr!=itrLast; ++itr) {
122 
123  int inTime=0;
124  int before=0;
125  int after=0;
126  int outTime=0;
127 
128  const TileHit & hit = (*itr) ;
129 
130  int size=hit.size();
131  for(int i=0;i<size;++i) {
132  double energy = hit.energy(i);
133  float time = hit.time(i);
134 
135  if (time>m_timeOut) {
136  ++outTime;
137  eOutTime += energy;
138  tOutTime += energy*time;
139  } else if (time>m_timeMax) {
140  ++after;
141  eAfter += energy;
142  tAfter += energy*time;
143  } else if (time<m_timeMin) {
144  ++before;
145  eBefore += energy;
146  tBefore += energy*time;
147  } else {
148  ++inTime;
149  eInTime += energy;
150  tInTime += energy*time;
151  }
152  }
153 
154  (*m_nHit) += size;
155  (*m_nChan) += 1;
156 
157  if (outTime) {
158  (*m_nHitOutTime) += outTime;
159  (*m_nChanOutTime) += 1;
160  }
161  if (after) {
162  (*m_nHitAfter) += after;
163  (*m_nChanAfter) += 1;
164  }
165  if (before) {
166  (*m_nHitBefore) += before;
167  (*m_nChanBefore) += 1;
168  }
169  if (inTime) {
170  (*m_nHitInTime) += inTime;
171  (*m_nChanInTime) += 1;
172  }
173 
174  }
175 
176  if (*m_nChan) {
177 
178  double energy = 0.0;
179  double time = 0.0;
180 
181  if (eBefore!=0.0) {
182  *m_eBefore = eBefore;
183  *m_tBefore = tBefore / eBefore;
184  energy += eBefore;
185  time += tBefore;
186  }
187 
188  if (eAfter!=0.0) {
189  *m_eAfter = eAfter;
190  *m_tAfter = tAfter / eAfter;
191  energy += eAfter;
192  time += tAfter;
193  }
194 
195  if (eInTime!=0.0) {
196  *m_eInTime = eInTime;
197  *m_tInTime = tInTime / eInTime;
198  energy += eInTime;
199  time += tInTime;
200  }
201 
202  if (energy!=0.0) {
203  *m_energy = energy;
204  *m_time = time / energy;
205  }
206 
207  if (eOutTime!=0.0) {
208  *m_eOutTime = eOutTime;
209  *m_tOutTime = tOutTime / eOutTime;
210  if (energy != 0.0) {
211  *m_energy += eOutTime;
212  // do not use out-of-time in time calculations
213  } else {
214  *m_energy = *m_eOutTime;
215  *m_time = *m_tOutTime; // only out-of-time energy
216  }
217  }
218 
219 
220  }
221 
222  ATH_MSG_DEBUG(" Tile hits: "<< *m_nChan << " / " << *m_nHit
223  <<" energy " << *m_energy << " time " << *m_time );
224 
225  return StatusCode::SUCCESS;
226 }
227 
228 
229 } // namespace D3PD
D3PD::TileHitInfoFillerTool::m_timeMin
float m_timeMin
Definition: TileHitInfoFillerTool.h:88
D3PD::TileHitInfoFillerTool::m_energy
float * m_energy
Definition: TileHitInfoFillerTool.h:63
D3PD::TileHitInfoFillerTool::m_tBefore
float * m_tBefore
Definition: TileHitInfoFillerTool.h:71
D3PD::TileHitInfoFillerTool::m_eBefore
float * m_eBefore
Definition: TileHitInfoFillerTool.h:65
D3PD::TileHitInfoFillerTool::m_tInTime
float * m_tInTime
Definition: TileHitInfoFillerTool.h:70
D3PD::TileHitInfoFillerTool::m_time
float * m_time
Definition: TileHitInfoFillerTool.h:69
D3PD::TileHitInfoFillerTool::m_eOutTime
float * m_eOutTime
Definition: TileHitInfoFillerTool.h:67
D3PD::TileHitInfoFillerTool::m_eAfter
float * m_eAfter
Definition: TileHitInfoFillerTool.h:66
D3PD::TileHitInfoFillerTool::m_nHitAfter
int * m_nHitAfter
Definition: TileHitInfoFillerTool.h:78
D3PD::TileHitInfoFillerTool::m_tAfter
float * m_tAfter
Definition: TileHitInfoFillerTool.h:72
AtlasHitsVector
Definition: AtlasHitsVector.h:33
D3PD::AddVariable::addVariable
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
Add a variable to the tuple.
Definition: AddVariable.cxx:85
D3PD::TileHitInfoFillerTool::m_nChanInTime
int * m_nChanInTime
Definition: TileHitInfoFillerTool.h:82
D3PD::TileHitInfoFillerTool::book
virtual StatusCode book()
Book variables for this block.
Definition: TileHitInfoFillerTool.cxx:50
AtlasHitsVector::begin
const_iterator begin() const
Definition: AtlasHitsVector.h:131
TileHit::size
int size(void) const
Return length of energy/time vectors
Definition: TileSimEvent/TileSimEvent/TileHit.h:94
AtlasHitsVector::const_iterator
CONT::const_iterator const_iterator
Definition: AtlasHitsVector.h:43
TileID.h
D3PD::TileHitInfoFillerTool::m_nChanBefore
int * m_nChanBefore
Definition: TileHitInfoFillerTool.h:83
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
D3PD
Block filler tool for noisy FEB information.
Definition: InnerDetector/InDetMonitoring/InDetGlobalMonitoring/macros/EnhancedPrimaryVertexMonitoring/TrigD3PD/ChainGroup.h:21
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
lumiFormat.i
int i
Definition: lumiFormat.py:92
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
test_pyathena.parent
parent
Definition: test_pyathena.py:15
D3PD::BlockFillerTool
Type-safe wrapper for block filler tools.
Definition: BlockFillerTool.h:68
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
D3PD::TileHitInfoFillerTool::m_tOutTime
float * m_tOutTime
Definition: TileHitInfoFillerTool.h:73
D3PD::TileHitInfoFillerTool::m_nHitBefore
int * m_nHitBefore
Definition: TileHitInfoFillerTool.h:77
D3PD::TileHitInfoFillerTool::m_nHitOutTime
int * m_nHitOutTime
Definition: TileHitInfoFillerTool.h:79
D3PD::TileHitInfoFillerTool::m_nChanAfter
int * m_nChanAfter
Definition: TileHitInfoFillerTool.h:84
D3PD::TileHitInfoFillerTool::m_timeOut
float m_timeOut
Definition: TileHitInfoFillerTool.h:90
TileHitVector.h
TileHit.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
errorcheck.h
Helpers for checking error return status codes and reporting errors.
TileHit
Definition: TileSimEvent/TileSimEvent/TileHit.h:30
D3PD::TileHitInfoFillerTool::m_nHitInTime
int * m_nHitInTime
Definition: TileHitInfoFillerTool.h:76
TileHitInfoFillerTool.h
D3PD::TileHitInfoFillerTool::m_nChanOutTime
int * m_nChanOutTime
Definition: TileHitInfoFillerTool.h:85
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
TileHit::energy
float energy(int ind=0) const
Return energy of ind-th sub-hit
Definition: TileSimEvent/TileSimEvent/TileHit.h:90
AtlasHitsVector::end
const_iterator end() const
Definition: AtlasHitsVector.h:134
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
D3PD::TileHitInfoFillerTool::TileHitInfoFillerTool
TileHitInfoFillerTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
Definition: TileHitInfoFillerTool.cxx:33
D3PD::TileHitInfoFillerTool::m_nChan
int * m_nChan
Definition: TileHitInfoFillerTool.h:81
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
D3PD::TileHitInfoFillerTool::m_nHit
int * m_nHit
Definition: TileHitInfoFillerTool.h:75
D3PD::TileHitInfoFillerTool::m_timeMax
float m_timeMax
Definition: TileHitInfoFillerTool.h:89
TileHit::time
float time(int ind=0) const
Return time of ind-th sub-hit
Definition: TileSimEvent/TileSimEvent/TileHit.h:92
D3PD::TileHitInfoFillerTool::m_eInTime
float * m_eInTime
Definition: TileHitInfoFillerTool.h:64
StoreGateSvc.h
D3PD::TileHitInfoFillerTool::fill
virtual StatusCode fill(const TileHitVector &p)
Fill one block — type-safe version.
Definition: TileHitInfoFillerTool.cxx:86