9 #include "Pandora/AlgorithmHeaders.h" 11 #include "Persistency/BinaryFileReader.h" 12 #include "Persistency/XmlFileReader.h" 26 EventReadingAlgorithm::EventReadingAlgorithm() :
28 m_useLArCaloHits(true),
29 m_useLArMCParticles(true),
30 m_pEventFileReader(nullptr)
49 if (BINARY == geometryFileType)
52 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, fileReader.ReadGeometry());
54 else if (XML == geometryFileType)
57 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, fileReader.ReadGeometry());
61 return STATUS_CODE_FAILURE;
71 return STATUS_CODE_SUCCESS;
84 catch (
const StatusCodeException &)
89 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::RepeatEventPreparation(*
this));
92 return STATUS_CODE_SUCCESS;
100 throw StopProcessingException(
"All event files processed");
110 catch (
const StatusCodeException &)
123 std::cout <<
"EventReadingAlgorithm: Processing event file: " << fileName << std::endl;
124 const FileType eventFileType(this->
GetFileType(fileName));
126 if (BINARY == eventFileType)
130 else if (XML == eventFileType)
136 return STATUS_CODE_FAILURE;
145 return STATUS_CODE_SUCCESS;
152 std::string fileExtension(fileName.substr(fileName.find_last_of(
".")));
153 std::transform(fileExtension.begin(), fileExtension.end(), fileExtension.begin(), ::tolower);
155 if (std::string(
".xml") == fileExtension)
159 else if (std::string(
".pndr") == fileExtension)
165 std::cout <<
"EventReadingAlgorithm: Unknown file type specified " << fileName << std::endl;
166 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
176 if (this->ExternalParametersPresent())
180 if (!pExternalParameters)
181 return STATUS_CODE_FAILURE;
190 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"GeometryFileName",
m_geometryFileName));
199 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle,
"EventFileNameList",
m_eventFileNameVector));
209 if (pExternalParameters && pExternalParameters->
m_skipToEvent.IsInitialized())
215 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"SkipToEvent",
m_skipToEvent));
220 std::cout <<
"EventReadingAlgorithm - nothing to do; neither geometry nor event file specified." << std::endl;
221 return STATUS_CODE_NOT_INITIALIZED;
224 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
227 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
230 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.
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.
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.