9 #include "Pandora/AlgorithmHeaders.h" 11 #include "Persistency/BinaryFileReader.h" 12 #include "Persistency/XmlFileReader.h" 26 EventReadingAlgorithm::EventReadingAlgorithm() :
28 m_useLArCaloHits(true),
29 m_larCaloHitVersion(1),
30 m_useLArMCParticles(true),
31 m_larMCParticleVersion(2),
32 m_pEventFileReader(nullptr)
51 if (BINARY == geometryFileType)
54 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, fileReader.ReadGeometry());
56 else if (XML == geometryFileType)
59 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, fileReader.ReadGeometry());
63 return STATUS_CODE_FAILURE;
73 return STATUS_CODE_SUCCESS;
86 catch (
const StatusCodeException &)
91 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::RepeatEventPreparation(*
this));
94 return STATUS_CODE_SUCCESS;
102 throw StopProcessingException(
"All event files processed");
112 catch (
const StatusCodeException &)
125 std::cout <<
"EventReadingAlgorithm: Processing event file: " << fileName << std::endl;
126 const FileType eventFileType(this->
GetFileType(fileName));
128 if (BINARY == eventFileType)
132 else if (XML == eventFileType)
138 return STATUS_CODE_FAILURE;
147 return STATUS_CODE_SUCCESS;
154 std::string fileExtension(fileName.substr(fileName.find_last_of(
".")));
155 std::transform(fileExtension.begin(), fileExtension.end(), fileExtension.begin(), ::tolower);
157 if (std::string(
".xml") == fileExtension)
161 else if (std::string(
".pndr") == fileExtension)
167 std::cout <<
"EventReadingAlgorithm: Unknown file type specified " << fileName << std::endl;
168 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
178 if (this->ExternalParametersPresent())
182 if (!pExternalParameters)
183 return STATUS_CODE_FAILURE;
192 PANDORA_RETURN_RESULT_IF_AND_IF(
193 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"GeometryFileName",
m_geometryFileName));
202 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
213 if (pExternalParameters && pExternalParameters->
m_skipToEvent.IsInitialized())
219 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"SkipToEvent",
m_skipToEvent));
224 std::cout <<
"EventReadingAlgorithm - nothing to do; neither geometry nor event file specified." << std::endl;
225 return STATUS_CODE_NOT_INITIALIZED;
228 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"UseLArCaloHits",
m_useLArCaloHits));
230 PANDORA_RETURN_RESULT_IF_AND_IF(
231 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"LArCaloHitVersion",
m_larCaloHitVersion));
233 PANDORA_RETURN_RESULT_IF_AND_IF(
234 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"LArMCParticleVersion",
m_larMCParticleVersion));
236 PANDORA_RETURN_RESULT_IF_AND_IF(
237 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"UseLArMCParticles",
m_useLArMCParticles));
239 return STATUS_CODE_SUCCESS;
std::string m_geometryFileName
Name of the file containing geometry information.
bool m_useLArMCParticles
Whether to read lar mc particles, or standard pandora mc particles.
Header file for the lar calo hit class.
unsigned int m_larCaloHitVersion
LArCaloHit version for LArCaloHitFactory.
pandora::StatusCode ReplaceEventFileReader(const std::string &fileName)
Replace the current event file reader with a new reader for the specified file.
pandora::StringVector m_eventFileNameVector
Vector of file names to be processed.
unsigned int m_skipToEvent
Index of first event to consider in first input file.
pandora::InputUInt m_skipToEvent
Index of first event to consider in input file.
External event reading parameters class.
pandora::StatusCode Run()
std::string m_geometryFileName
Name of the file containing geometry information.
bool m_useLArCaloHits
Whether to read lar calo hits, or standard pandora calo hits.
pandora::FileType GetFileType(const std::string &fileName) const
Analyze a provided file name to extract the file type/extension.
Header file for the lar mc particle class.
std::string m_eventFileNameList
Colon-separated list of file names to be processed.
LArMCParticleFactory responsible for object creation.
pandora::FileReader * m_pEventFileReader
Address of the event file reader.
~EventReadingAlgorithm()
Destructor.
Header file for the event reading algorithm class.
unsigned int m_larMCParticleVersion
LArMCParticle version for LArMCParticleFactory.
pandora::StatusCode Initialize()
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
LArCaloHitFactory responsible for object creation.
std::string m_eventFileName
Name of the current file containing event information.
void MoveToNextEventFile()
Proceed to process next event file named in the input list.