Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-27 09:20:25

0001 /**
0002  *  @file   PandoraSDK/include/Persistency/FileWriter.h
0003  *
0004  *  @brief  Header file for the file writer class.
0005  *
0006  *  $Log: $
0007  */
0008 #ifndef PANDORA_FILE_WRITER_H
0009 #define PANDORA_FILE_WRITER_H 1
0010 
0011 #include "Pandora/StatusCodes.h"
0012 
0013 #include "Persistency/PandoraIO.h"
0014 #include "Persistency/Persistency.h"
0015 
0016 #include <string>
0017 
0018 namespace pandora
0019 {
0020 
0021 class Pandora;
0022 
0023 //------------------------------------------------------------------------------------------------------------------------------------------
0024 
0025 /**
0026  *  @brief  FileWriter class
0027  */
0028 class FileWriter : public Persistency
0029 {
0030 public:
0031     /**
0032      *  @brief  Constructor
0033      *
0034      *  @param  algorithm the pandora instance to be used alongside the file writer
0035      *  @param  fileName the name of the output file
0036      *  @param  majorVersion the major version of the output file
0037      *  @param  minorVersion the minor version of the output file
0038      */
0039     FileWriter(const pandora::Pandora &pandora, const std::string &fileName, const unsigned int majorVersion = 1, const unsigned int minorVersion = 0);
0040 
0041     /**
0042      *  @brief  Destructor
0043      */
0044     virtual ~FileWriter();
0045 
0046     /**
0047      *  @brief  Write the global header to the file
0048      */
0049     StatusCode WriteGlobalHeader();
0050 
0051     /**
0052      *  @brief  Write the current geometry information to the file
0053      */
0054     StatusCode WriteGeometry();
0055 
0056     /**
0057      *  @brief  Write the specified event components to the file
0058      *
0059      *  @param  caloHitList the list of calo hits to write to the file
0060      *  @param  trackList the list of tracks to write to the file
0061      *  @param  mcParticleList the list of mc particles to write to the file
0062      *  @param  writeMCRelationships whether to write mc relationship information to the file
0063      *  @param  writeTrackRelationships whether to write track relationship information to the file
0064      */
0065     StatusCode WriteEvent(const CaloHitList &caloHitList, const TrackList &trackList, const MCParticleList &mcParticleList,
0066         const bool writeMCRelationships = true, const bool writeTrackRelationships = true);
0067 
0068 protected:
0069     /**
0070      *  @brief  Write the container header to the file
0071      *
0072      *  @param  containerId the container id
0073      */
0074     virtual StatusCode WriteHeader(const ContainerId containerId) = 0;
0075 
0076     /**
0077      *  @brief  Write the container footer to the file
0078      */
0079     virtual StatusCode WriteFooter() = 0;
0080 
0081     /**
0082      *  @brief  Write file version information to the file
0083      *
0084      */
0085     virtual StatusCode WriteVersion() = 0;
0086 
0087     /**
0088      *  @brief  Write a sub detector to the file
0089      *
0090      *  @param  pSubDetector address of the sub detector
0091      */
0092     virtual StatusCode WriteSubDetector(const SubDetector *const pSubDetector) = 0;
0093 
0094     /**
0095      *  @brief  Write a lar tpc to the file
0096      *
0097      *  @param  pLArTPC address of the lar tpc
0098      */
0099     virtual StatusCode WriteLArTPC(const LArTPC *const pLArTPC) = 0;
0100 
0101     /**
0102      *  @brief  Write the detector gap parameters to the file
0103      *
0104      *  @param  pDetectorGap address of the detector gap
0105      */
0106     virtual StatusCode WriteDetectorGap(const DetectorGap *const pDetectorGap) = 0;
0107 
0108     /**
0109      *  @brief  Write a calo hit to the current position in the file
0110      *
0111      *  @param  pCaloHit address of the calo hit
0112      */
0113     virtual StatusCode WriteCaloHit(const CaloHit *const pCaloHit) = 0;
0114 
0115     /**
0116      *  @brief  Write a track to the current position in the file
0117      *
0118      *  @param  pTrack address of the track
0119      */
0120     virtual StatusCode WriteTrack(const Track *const pTrack) = 0;
0121 
0122     /**
0123      *  @brief  Write a mc particle to the current position in the file
0124      *
0125      *  @param  pMCParticle address of the mc particle
0126      */
0127     virtual StatusCode WriteMCParticle(const MCParticle *const pMCParticle) = 0;
0128 
0129     /**
0130      *  @brief  Write a relationship between two objects with specified addresses
0131      *
0132      *  @param  relationshipId the relationship id
0133      *  @param  address1 first address to write
0134      *  @param  address2 second address to write
0135      */
0136     virtual StatusCode WriteRelationship(const RelationshipId relationshipId, const void *address1, const void *address2, const float weight = 1.f) = 0;
0137 
0138     /**
0139      *  @brief  Write event-level information
0140      *
0141      */
0142     virtual StatusCode WriteEventInformation() = 0;
0143 
0144     unsigned int m_fileMajorVersion; ///< Major version of the output file
0145     unsigned int m_fileMinorVersion; ///< Minor version of the output file
0146 
0147 private:
0148     /**
0149      *  @brief  Write the sub detector parameters to the file
0150      */
0151     StatusCode WriteSubDetectorList();
0152 
0153     /**
0154      *  @brief  Write the lar tpc parameters to the file
0155      */
0156     StatusCode WriteLArTPCList();
0157 
0158     /**
0159      *  @brief  Write the detector gap parameters to the file
0160      */
0161     StatusCode WriteDetectorGapList();
0162 
0163     /**
0164      *  @brief  Write a track list to the current position in the file
0165      *
0166      *  @param  trackList the track list
0167      */
0168     StatusCode WriteTrackList(const TrackList &trackList);
0169 
0170     /**
0171      *  @brief  Write a calo hit list to the current position in the file
0172      *
0173      *  @param  caloHitList the calo hit list
0174      */
0175     StatusCode WriteCaloHitList(const CaloHitList &caloHitList);
0176 
0177     /**
0178      *  @brief  Write a mc particle list to the current position in the file
0179      *
0180      *  @param  mcParticleList the mc particle list
0181      */
0182     StatusCode WriteMCParticleList(const MCParticleList &mcParticleList);
0183 
0184     /**
0185      *  @brief  Write calo hit to mc particle relationships for a specified calo hit list
0186      *
0187      *  @param  caloHitList the calo hit list
0188      */
0189     StatusCode WriteCaloHitToMCParticleRelationships(const CaloHitList &caloHitList);
0190 
0191     /**
0192      *  @brief  Write track to mc particle relationships for a specified track list
0193      *
0194      *  @param  trackList the track list
0195      */
0196     StatusCode WriteTrackToMCParticleRelationships(const TrackList &trackList);
0197 
0198     /**
0199      *  @brief  Write mc particle relationships for a specified mc particle list
0200      *
0201      *  @param  mcParticleList the mc particle list
0202      */
0203     StatusCode WriteMCParticleRelationships(const MCParticleList &mcParticleList);
0204 
0205     /**
0206      *  @brief  Write track relationships for a specified list of tracks
0207      *
0208      *  @param  trackList the track list
0209      */
0210     StatusCode WriteTrackRelationships(const TrackList &trackList);
0211 
0212     /**
0213      *  @brief  Write a calo hit to mc particle relationship to the current position in the file
0214      *
0215      *  @param  pCaloHit address of the calo hit
0216      */
0217     StatusCode WriteCaloHitToMCParticleRelationship(const CaloHit *const pCaloHit);
0218 
0219     /**
0220      *  @brief  Write a track to mc particle relationship to the current position in the file
0221      *
0222      *  @param  pTrack address of the track
0223      */
0224     StatusCode WriteTrackToMCParticleRelationship(const Track *const pTrack);
0225 
0226     /**
0227      *  @brief  Write a mc particle parent/daughter relationship to the current position in the file
0228      *
0229      *  @param  pMCParticle address of the mc particle
0230      */
0231     StatusCode WriteMCParticleRelationships(const MCParticle *const pMCParticle);
0232 
0233     /**
0234      *  @brief  Write a track sibling or parent/daughter relationship to the current position in the file
0235      *
0236      *  @param  pTrack address of the track
0237      */
0238     StatusCode WriteTrackRelationships(const Track *const pTrack);
0239 };
0240 
0241 } // namespace pandora
0242 
0243 #endif // #ifndef PANDORA_FILE_WRITER_H