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
54 unsigned int GetLArTPCVolumeId()
const;
61 unsigned int GetDaughterVolumeId()
const;
75 float GetTrackProbability()
const;
82 float GetShowerProbability()
const;
89 void SetTrackProbability(
const float probability);
96 void SetShowerProbability(
const float probability);
110 class LArCaloHitFactory :
public pandora::ObjectFactory<object_creation::CaloHit::Parameters, object_creation::CaloHit::Object>
125 Parameters *NewParameters()
const;
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),
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);
261 const LArCaloHitParameters &larCaloHitParameters(dynamic_cast<const LArCaloHitParameters &>(parameters));
262 pObject =
new LArCaloHit(larCaloHitParameters);
264 return pandora::STATUS_CODE_SUCCESS;
272 unsigned int larTPCVolumeId(std::numeric_limits<unsigned int>::max());
273 unsigned int daughterVolumeId(0);
275 if (pandora::BINARY == fileReader.GetFileType())
277 pandora::BinaryFileReader &binaryFileReader(dynamic_cast<pandora::BinaryFileReader &>(fileReader));
278 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, binaryFileReader.ReadVariable(larTPCVolumeId));
280 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, binaryFileReader.ReadVariable(daughterVolumeId));
282 else if (pandora::XML == fileReader.GetFileType())
284 pandora::XmlFileReader &xmlFileReader(dynamic_cast<pandora::XmlFileReader &>(fileReader));
285 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, xmlFileReader.ReadVariable(
"LArTPCVolumeId", larTPCVolumeId));
287 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, xmlFileReader.ReadVariable(
"DaughterVolumeId", daughterVolumeId));
291 return pandora::STATUS_CODE_INVALID_PARAMETER;
298 return pandora::STATUS_CODE_SUCCESS;
306 const LArCaloHit *
const pLArCaloHit(dynamic_cast<const LArCaloHit *>(pObject));
309 return pandora::STATUS_CODE_INVALID_PARAMETER;
311 if (pandora::BINARY == fileWriter.GetFileType())
313 pandora::BinaryFileWriter &binaryFileWriter(dynamic_cast<pandora::BinaryFileWriter &>(fileWriter));
314 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, binaryFileWriter.WriteVariable(pLArCaloHit->
GetLArTPCVolumeId()));
316 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, binaryFileWriter.WriteVariable(pLArCaloHit->
GetDaughterVolumeId()));
318 else if (pandora::XML == fileWriter.GetFileType())
320 pandora::XmlFileWriter &xmlFileWriter(dynamic_cast<pandora::XmlFileWriter &>(fileWriter));
321 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, xmlFileWriter.WriteVariable(
"LArTPCVolumeId", pLArCaloHit->
GetLArTPCVolumeId()));
323 PANDORA_RETURN_RESULT_IF(
324 pandora::STATUS_CODE_SUCCESS, !=, xmlFileWriter.WriteVariable(
"DaughterVolumeId", pLArCaloHit->
GetDaughterVolumeId()));
328 return pandora::STATUS_CODE_INVALID_PARAMETER;
331 return pandora::STATUS_CODE_SUCCESS;
336 #endif // #ifndef LAR_CALO_HIT_H
Read("Flexi","livermore")
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.
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
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.
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.