Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
LArCaloHit.h
Go to the documentation of this file.
1
8#ifndef LAR_CALO_HIT_H
9#define LAR_CALO_HIT_H 1
10
11#include "Objects/CaloHit.h"
12
15
20
21namespace lar_content
22{
23
33
34//------------------------------------------------------------------------------------------------------------------------------------------
35
40{
41public:
47 LArCaloHit(const LArCaloHitParameters &parameters);
48
54 unsigned int GetLArTPCVolumeId() const;
55
61 unsigned int GetDaughterVolumeId() const;
62
68 void FillParameters(LArCaloHitParameters &parameters) const;
69
75 float GetTrackProbability() const;
76
82 float GetShowerProbability() const;
83
89 void SetTrackProbability(const float probability);
90
96 void SetShowerProbability(const float probability);
97
98private:
99 unsigned int m_larTPCVolumeId;
100 unsigned int m_daughterVolumeId;
103};
104
105//------------------------------------------------------------------------------------------------------------------------------------------
106
110class LArCaloHitFactory : public pandora::ObjectFactory<object_creation::CaloHit::Parameters, object_creation::CaloHit::Object>
111{
112public:
118 LArCaloHitFactory(const unsigned int version = 1);
119
125 Parameters *NewParameters() const;
126
133 pandora::StatusCode Read(Parameters &parameters, pandora::FileReader &fileReader) const;
134
141 pandora::StatusCode Write(const Object *const pObject, pandora::FileWriter &fileWriter) const;
142
149 pandora::StatusCode Create(const Parameters &parameters, const Object *&pObject) const;
150
151private:
152 unsigned int m_version;
153};
154
155//------------------------------------------------------------------------------------------------------------------------------------------
156//------------------------------------------------------------------------------------------------------------------------------------------
157
159 object_creation::CaloHit::Object(parameters),
160 m_larTPCVolumeId(parameters.m_larTPCVolumeId.Get()),
161 m_daughterVolumeId(parameters.m_daughterVolumeId.IsInitialized() ? parameters.m_daughterVolumeId.Get() : 0)
162{
163}
164
165//------------------------------------------------------------------------------------------------------------------------------------------
166
167inline unsigned int LArCaloHit::GetLArTPCVolumeId() const
168{
169 return m_larTPCVolumeId;
170}
171
172//------------------------------------------------------------------------------------------------------------------------------------------
173
174inline unsigned int LArCaloHit::GetDaughterVolumeId() const
175{
176 return m_daughterVolumeId;
177}
178
179//------------------------------------------------------------------------------------------------------------------------------------------
180
182{
183 parameters.m_positionVector = this->GetPositionVector();
184 parameters.m_expectedDirection = this->GetExpectedDirection();
185 parameters.m_cellNormalVector = this->GetCellNormalVector();
186 parameters.m_cellGeometry = this->GetCellGeometry();
187 parameters.m_cellSize0 = this->GetCellSize0();
188 parameters.m_cellSize1 = this->GetCellSize1();
189 parameters.m_cellThickness = this->GetCellThickness();
190 parameters.m_nCellRadiationLengths = this->GetNCellRadiationLengths();
191 parameters.m_nCellInteractionLengths = this->GetNCellInteractionLengths();
192 parameters.m_time = this->GetTime();
193 parameters.m_inputEnergy = this->GetInputEnergy();
194 parameters.m_mipEquivalentEnergy = this->GetMipEquivalentEnergy();
195 parameters.m_electromagneticEnergy = this->GetElectromagneticEnergy();
196 parameters.m_hadronicEnergy = this->GetHadronicEnergy();
197 parameters.m_isDigital = this->IsDigital();
198 parameters.m_hitType = this->GetHitType();
199 parameters.m_hitRegion = this->GetHitRegion();
200 parameters.m_layer = this->GetLayer();
201 parameters.m_isInOuterSamplingLayer = this->IsInOuterSamplingLayer();
202 // ATTN Set the parent address to the original owner of the calo hit
203 parameters.m_pParentAddress = static_cast<const void *>(this);
204 parameters.m_larTPCVolumeId = this->GetLArTPCVolumeId();
205 parameters.m_daughterVolumeId = this->GetDaughterVolumeId();
206}
207
208//------------------------------------------------------------------------------------------------------------------------------------------
209
211{
212 return m_pTrack.Get();
213}
214
215//------------------------------------------------------------------------------------------------------------------------------------------
216
218{
219 return m_pShower.Get();
220}
221
222//------------------------------------------------------------------------------------------------------------------------------------------
223
224inline void LArCaloHit::SetTrackProbability(const float probability)
225{
226 if (probability >= 0.f)
227 m_pTrack = probability;
228 else
229 throw pandora::StatusCodeException(pandora::STATUS_CODE_INVALID_PARAMETER);
230}
231
232//------------------------------------------------------------------------------------------------------------------------------------------
233
234inline void LArCaloHit::SetShowerProbability(const float probability)
235{
236 if (probability >= 0.f)
237 m_pShower = probability;
238 else
239 throw pandora::StatusCodeException(pandora::STATUS_CODE_INVALID_PARAMETER);
240}
241
242//------------------------------------------------------------------------------------------------------------------------------------------
243//------------------------------------------------------------------------------------------------------------------------------------------
244
245inline LArCaloHitFactory::LArCaloHitFactory(const unsigned int version) : m_version(version)
246{
247}
248
249//------------------------------------------------------------------------------------------------------------------------------------------
250
255
256//------------------------------------------------------------------------------------------------------------------------------------------
257
258inline pandora::StatusCode LArCaloHitFactory::Create(const Parameters &parameters, const Object *&pObject) const
259{
260 const LArCaloHitParameters &larCaloHitParameters(dynamic_cast<const LArCaloHitParameters &>(parameters));
261 pObject = new LArCaloHit(larCaloHitParameters);
262
263 return pandora::STATUS_CODE_SUCCESS;
264}
265
266//------------------------------------------------------------------------------------------------------------------------------------------
267
269{
270 // ATTN: To receive this call-back must have already set file reader mc particle factory to this factory
271 unsigned int larTPCVolumeId(std::numeric_limits<unsigned int>::max());
272 unsigned int daughterVolumeId(0);
273
274 if (pandora::BINARY == fileReader.GetFileType())
275 {
276 pandora::BinaryFileReader &binaryFileReader(dynamic_cast<pandora::BinaryFileReader &>(fileReader));
277 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, binaryFileReader.ReadVariable(larTPCVolumeId));
278 if (m_version > 1)
279 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, binaryFileReader.ReadVariable(daughterVolumeId));
280 }
281 else if (pandora::XML == fileReader.GetFileType())
282 {
283 pandora::XmlFileReader &xmlFileReader(dynamic_cast<pandora::XmlFileReader &>(fileReader));
284 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, xmlFileReader.ReadVariable("LArTPCVolumeId", larTPCVolumeId));
285 if (m_version > 1)
286 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, xmlFileReader.ReadVariable("DaughterVolumeId", daughterVolumeId));
287 }
288 else
289 {
290 return pandora::STATUS_CODE_INVALID_PARAMETER;
291 }
292
293 LArCaloHitParameters &larCaloHitParameters(dynamic_cast<LArCaloHitParameters &>(parameters));
294 larCaloHitParameters.m_larTPCVolumeId = larTPCVolumeId;
295 larCaloHitParameters.m_daughterVolumeId = daughterVolumeId;
296
297 return pandora::STATUS_CODE_SUCCESS;
298}
299
300//------------------------------------------------------------------------------------------------------------------------------------------
301
302inline pandora::StatusCode LArCaloHitFactory::Write(const Object *const pObject, pandora::FileWriter &fileWriter) const
303{
304 // ATTN: To receive this call-back must have already set file writer mc particle factory to this factory
305 const LArCaloHit *const pLArCaloHit(dynamic_cast<const LArCaloHit *>(pObject));
306
307 if (!pLArCaloHit)
308 return pandora::STATUS_CODE_INVALID_PARAMETER;
309
310 if (pandora::BINARY == fileWriter.GetFileType())
311 {
312 pandora::BinaryFileWriter &binaryFileWriter(dynamic_cast<pandora::BinaryFileWriter &>(fileWriter));
313 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, binaryFileWriter.WriteVariable(pLArCaloHit->GetLArTPCVolumeId()));
314 if (m_version > 1)
315 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, binaryFileWriter.WriteVariable(pLArCaloHit->GetDaughterVolumeId()));
316 }
317 else if (pandora::XML == fileWriter.GetFileType())
318 {
319 pandora::XmlFileWriter &xmlFileWriter(dynamic_cast<pandora::XmlFileWriter &>(fileWriter));
320 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, xmlFileWriter.WriteVariable("LArTPCVolumeId", pLArCaloHit->GetLArTPCVolumeId()));
321 if (m_version > 1)
323 pandora::STATUS_CODE_SUCCESS, !=, xmlFileWriter.WriteVariable("DaughterVolumeId", pLArCaloHit->GetDaughterVolumeId()));
324 }
325 else
326 {
327 return pandora::STATUS_CODE_INVALID_PARAMETER;
328 }
329
330 return pandora::STATUS_CODE_SUCCESS;
331}
332
333} // namespace lar_content
334
335#endif // #ifndef LAR_CALO_HIT_H
Header file for the binary file reader class.
Header file for the binary file writer class.
Header file for the calo hit class.
Header file for pandora object creation classes.
Header file for the pandora object factories classes.
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
Definition StatusCodes.h:19
Header file for the xml file reader class.
Header file for the xml file writer class.
Parameters class.
Definition Validation.h:20
LArCaloHitFactory responsible for object creation.
Definition LArCaloHit.h:111
unsigned int m_version
The LArCaloHit version.
Definition LArCaloHit.h:152
pandora::StatusCode Read(Parameters &parameters, pandora::FileReader &fileReader) const
Read any additional (derived class only) object parameters from file using the specified file reader.
Definition LArCaloHit.h:268
pandora::StatusCode Write(const Object *const pObject, pandora::FileWriter &fileWriter) const
Persist any additional (derived class only) object parameters using the specified file writer.
Definition LArCaloHit.h:302
Parameters * NewParameters() const
Create new parameters instance on the heap (memory-management to be controlled by user)
Definition LArCaloHit.h:251
LArCaloHitFactory(const unsigned int version=1)
Constructor.
Definition LArCaloHit.h:245
pandora::StatusCode Create(const Parameters &parameters, const Object *&pObject) const
Create an object with the given parameters.
Definition LArCaloHit.h:258
LAr calo hit class.
Definition LArCaloHit.h:40
LArCaloHit(const LArCaloHitParameters &parameters)
Constructor.
Definition LArCaloHit.h:158
float GetTrackProbability() const
Get the probability that the hit is track-like.
Definition LArCaloHit.h:210
unsigned int GetLArTPCVolumeId() const
Get the lar tpc volume id.
Definition LArCaloHit.h:167
void SetTrackProbability(const float probability)
Set the probability that the hit is track-like.
Definition LArCaloHit.h:224
pandora::InputFloat m_pShower
The probability that the hit is shower-like.
Definition LArCaloHit.h:102
void SetShowerProbability(const float probability)
Set the probability that the hit is shower-like.
Definition LArCaloHit.h:234
pandora::InputFloat m_pTrack
The probability that the hit is track-like.
Definition LArCaloHit.h:101
unsigned int GetDaughterVolumeId() const
Get the daughter volume id.
Definition LArCaloHit.h:174
float GetShowerProbability() const
Get the probability that the hit is shower-like.
Definition LArCaloHit.h:217
unsigned int m_larTPCVolumeId
The lar tpc volume id.
Definition LArCaloHit.h:99
void FillParameters(LArCaloHitParameters &parameters) const
Fill the parameters associated with this calo hit.
Definition LArCaloHit.h:181
unsigned int m_daughterVolumeId
The daughter volume id.
Definition LArCaloHit.h:100
LAr calo hit parameters.
Definition LArCaloHit.h:28
pandora::InputUInt m_daughterVolumeId
The daughter volume id.
Definition LArCaloHit.h:31
pandora::InputUInt m_larTPCVolumeId
The lar tpc volume id.
Definition LArCaloHit.h:30
BinaryFileReader class.
StatusCode ReadVariable(T &t)
Read a variable from the file.
BinaryFileWriter class.
StatusCode WriteVariable(const T &t)
Write a variable to the file.
CaloHit class.
Definition CaloHit.h:26
FileReader class.
Definition FileReader.h:29
FileWriter class.
Definition FileWriter.h:29
ObjectFactory class responsible for extended pandora object creation.
const T & Get() const
Get the value held by the pandora type.
FileType GetFileType() const
Get the file type.
Definition Persistency.h:97
StatusCodeException class.
XmlFileReader class.
StatusCode ReadVariable(const std::string &xmlKey, T &t)
Read a variable from the file.
XmlFileWriter class.
StatusCode WriteVariable(const std::string &xmlKey, const T &t)
Write a variable to the file.
StatusCode
The StatusCode enum.