9 #define LAR_CALO_HIT_H 1
11 #include "Objects/CaloHit.h"
13 #include "Pandora/ObjectCreation.h"
14 #include "Pandora/PandoraObjectFactories.h"
16 #include "Persistency/BinaryFileReader.h"
17 #include "Persistency/BinaryFileWriter.h"
18 #include "Persistency/XmlFileReader.h"
19 #include "Persistency/XmlFileWriter.h"
39 class LArCaloHit :
public object_creation::CaloHit::Object
110 class LArCaloHitFactory :
public pandora::ObjectFactory<object_creation::CaloHit::Parameters, object_creation::CaloHit::Object>
133 pandora::StatusCode
Read(
Parameters ¶meters, pandora::FileReader &fileReader)
const;
141 pandora::StatusCode
Write(
const Object *
const pObject, pandora::FileWriter &fileWriter)
const;
149 pandora::StatusCode
Create(
const Parameters ¶meters,
const Object *&pObject)
const;
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)
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();
203 parameters.m_pParentAddress =
static_cast<const void *
>(
this);
226 if (probability >= 0.f)
229 throw pandora::StatusCodeException(pandora::STATUS_CODE_INVALID_PARAMETER);
236 if (probability >= 0.f)
239 throw pandora::StatusCodeException(pandora::STATUS_CODE_INVALID_PARAMETER);
260 const LArCaloHitParameters &larCaloHitParameters(dynamic_cast<const LArCaloHitParameters &>(parameters));
261 pObject =
new LArCaloHit(larCaloHitParameters);
263 return pandora::STATUS_CODE_SUCCESS;
271 unsigned int larTPCVolumeId(std::numeric_limits<unsigned int>::max());
272 unsigned int daughterVolumeId(0);
274 if (pandora::BINARY == fileReader.GetFileType())
276 pandora::BinaryFileReader &binaryFileReader(dynamic_cast<pandora::BinaryFileReader &>(fileReader));
277 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, binaryFileReader.ReadVariable(larTPCVolumeId));
279 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, binaryFileReader.ReadVariable(daughterVolumeId));
281 else if (pandora::XML == fileReader.GetFileType())
283 pandora::XmlFileReader &xmlFileReader(dynamic_cast<pandora::XmlFileReader &>(fileReader));
284 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, xmlFileReader.ReadVariable(
"LArTPCVolumeId", larTPCVolumeId));
286 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, xmlFileReader.ReadVariable(
"DaughterVolumeId", daughterVolumeId));
290 return pandora::STATUS_CODE_INVALID_PARAMETER;
297 return pandora::STATUS_CODE_SUCCESS;
305 const LArCaloHit *
const pLArCaloHit(dynamic_cast<const LArCaloHit *>(pObject));
308 return pandora::STATUS_CODE_INVALID_PARAMETER;
310 if (pandora::BINARY == fileWriter.GetFileType())
312 pandora::BinaryFileWriter &binaryFileWriter(dynamic_cast<pandora::BinaryFileWriter &>(fileWriter));
313 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, binaryFileWriter.WriteVariable(pLArCaloHit->
GetLArTPCVolumeId()));
315 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, binaryFileWriter.WriteVariable(pLArCaloHit->
GetDaughterVolumeId()));
317 else if (pandora::XML == fileWriter.GetFileType())
319 pandora::XmlFileWriter &xmlFileWriter(dynamic_cast<pandora::XmlFileWriter &>(fileWriter));
320 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, xmlFileWriter.WriteVariable(
"LArTPCVolumeId", pLArCaloHit->
GetLArTPCVolumeId()));
322 PANDORA_RETURN_RESULT_IF(
323 pandora::STATUS_CODE_SUCCESS, !=, xmlFileWriter.WriteVariable(
"DaughterVolumeId", pLArCaloHit->
GetDaughterVolumeId()));
327 return pandora::STATUS_CODE_INVALID_PARAMETER;
330 return pandora::STATUS_CODE_SUCCESS;
335 #endif // #ifndef LAR_CALO_HIT_H
Parameters * NewParameters() const
Create new parameters instance on the heap (memory-management to be controlled by user) ...
void SetShowerProbability(const float probability)
Set the probability that the hit is shower-like.
pandora::StatusCode Read(Parameters ¶meters, pandora::FileReader &fileReader) const
Read any additional (derived class only) object parameters from file using the specified file reader...
pandora::InputFloat m_pTrack
The probability that the hit is track-like.
pandora::InputUInt m_larTPCVolumeId
The lar tpc volume id.
unsigned int GetLArTPCVolumeId() const
Get the lar tpc volume id.
unsigned int m_version
The LArCaloHit version.
pandora::InputFloat m_pShower
The probability that the hit is shower-like.
unsigned int m_larTPCVolumeId
The lar tpc volume id.
LArCaloHitFactory(const unsigned int version=1)
Constructor.
unsigned int m_daughterVolumeId
The daughter volume id.
float GetShowerProbability() const
Get the probability that the hit is shower-like.
pandora::InputUInt m_daughterVolumeId
The daughter volume id.
void FillParameters(LArCaloHitParameters ¶meters) const
Fill the parameters associated with this calo hit.
pandora::StatusCode Write(const Object *const pObject, pandora::FileWriter &fileWriter) const
Persist any additional (derived class only) object parameters using the specified file writer...
void SetTrackProbability(const float probability)
Set the probability that the hit is track-like.
fhicl::Table< sbnd::crt::CRTDetSimParams > Parameters
pandora::StatusCode Create(const Parameters ¶meters, const Object *&pObject) const
Create an object with the given parameters.
LArCaloHitFactory responsible for object creation.
unsigned int GetDaughterVolumeId() const
Get the daughter volume id.
LArCaloHit(const LArCaloHitParameters ¶meters)
Constructor.
float GetTrackProbability() const
Get the probability that the hit is track-like.