Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-27 09:15:19

0001 /**
0002  *  @file   PandoraSDK/include/Managers/Metadata.h
0003  * 
0004  *  @brief  Header file for metadata classes.
0005  * 
0006  *  $Log: $
0007  */
0008 #ifndef PANDORA_METADATA_MANAGER_H
0009 #define PANDORA_METADATA_MANAGER_H 1
0010 
0011 #include "Objects/CaloHit.h"
0012 
0013 #include "Pandora/PandoraInternal.h"
0014 #include "Pandora/StatusCodes.h"
0015 
0016 namespace pandora
0017 {
0018 
0019 /**
0020  *  @brief  CaloHitReplacement class
0021  */
0022 class CaloHitReplacement
0023 {
0024 public:
0025     CaloHitList             m_oldCaloHits;              ///< The list of old calo hits, to be replaced
0026     CaloHitList             m_newCaloHits;              ///< The list new calo hits, to act as replacements
0027 };
0028 
0029 typedef std::vector<CaloHitReplacement *> CaloHitReplacementList;
0030 typedef std::unordered_map<const CaloHit *, bool> CaloHitUsageMap;
0031 
0032 //------------------------------------------------------------------------------------------------------------------------------------------
0033 //------------------------------------------------------------------------------------------------------------------------------------------
0034 
0035 /**
0036  *  @brief  CaloHitMetadata class
0037  */
0038 class CaloHitMetadata
0039 {
0040 public:
0041     /**
0042      *  @brief  Constructor
0043      * 
0044      *  @param  pCaloHitList address of the associated calo hit list
0045      *  @param  caloHitListName name of the associated calo hit list
0046      *  @param  initialHitAvailability the initial availability of the calo hits
0047      */
0048     CaloHitMetadata(CaloHitList *const pCaloHitList, const std::string &caloHitListName, const bool initialHitAvailability);
0049 
0050     /**
0051      *  @brief  Destructor
0052      */
0053     ~CaloHitMetadata();
0054 
0055     /**
0056      *  @brief  Is a calo hit, or a list of calo hits, available to add to a cluster
0057      * 
0058      *  @param  pT address of the object or object list
0059      * 
0060      *  @return boolean
0061      */
0062     template <typename T>
0063     bool IsAvailable(const T *const pT) const;
0064 
0065     /**
0066      *  @brief  Set availability of a calo hit, or a list of calo hits, to be added to a cluster
0067      * 
0068      *  @param  pT the address of the object or object list
0069      *  @param  isAvailable the availability
0070      */
0071     template <typename T>
0072     StatusCode SetAvailability(const T *const pT, bool isAvailable);
0073 
0074     /**
0075      *  @brief  Update metadata to account for changes by daughter recluster processes
0076      * 
0077      *  @param  caloHitMetadata description of the changes made by daughter reclustering processes
0078      */
0079     StatusCode Update(const CaloHitMetadata &caloHitMetadata);
0080 
0081     /**
0082      *  @brief  Update metadata to account for a specific calo hit replacement
0083      * 
0084      *  @param  caloHitReplacement the calo hit replacement
0085      */
0086     StatusCode Update(const CaloHitReplacement &caloHitReplacement);
0087 
0088     /**
0089      *  @brief  Clear all metadata content
0090      */
0091     void Clear();
0092 
0093     /**
0094      *  @brief  Get the calo hit usage map
0095      * 
0096      *  @return the calo hit usage map
0097      */
0098     const CaloHitUsageMap &GetCaloHitUsageMap() const;
0099 
0100     /**
0101      *  @brief  Get the calo hit replacement list
0102      * 
0103      *  @return the calo hit replacement list
0104      */
0105     const CaloHitReplacementList &GetCaloHitReplacementList() const;
0106 
0107 private:
0108     CaloHitList                *m_pCaloHitList;                     ///< Address of the associated calo hit list
0109     std::string                 m_caloHitListName;                  ///< The name of the associated calo hit list
0110     CaloHitUsageMap             m_caloHitUsageMap;                  ///< The calo hit usage map
0111     CaloHitReplacementList      m_caloHitReplacementList;           ///< The calo hit replacement list
0112 };
0113 
0114 //------------------------------------------------------------------------------------------------------------------------------------------
0115 //------------------------------------------------------------------------------------------------------------------------------------------
0116 
0117 /**
0118  *  @brief  ReclusterMetadata class
0119  */
0120 class ReclusterMetadata
0121 {
0122 public:
0123     /**
0124      *  @brief  Constructor
0125      * 
0126      *  @param  pCaloHitList address of the initial calo hit list, copies of which will be used during reclustering
0127      */
0128     ReclusterMetadata(CaloHitList *const pCaloHitList);
0129 
0130     /**
0131      *  @brief  Destructor
0132      */
0133     ~ReclusterMetadata();
0134 
0135     /**
0136      *  @brief  Create new calo hit metadata, associated with a new reclustering option for the calo hits
0137      * 
0138      *  @param  pCaloHitList address of the calo hit list associated with the reclustering option
0139      *  @param  caloHitListName name of the calo hit list associated with the reclustering option
0140      *  @param  reclusterListName the name of the reclustering option
0141      *  @param  initialHitAvailability the initial availability of the calo hits
0142      */
0143     StatusCode CreateCaloHitMetadata(CaloHitList *const pCaloHitList, const std::string &caloHitListName, const std::string &reclusterListName,
0144         const bool initialHitAvailability);
0145 
0146     /**
0147      *  @brief  Extract specific calo hit metadata, removing entry from map and receiving a pointer to the metadata
0148      * 
0149      *  @param  reclusterListName the key/name matching the desired metadata
0150      *  @param  pCaloHitMetaData to receive the pointer to the metadata
0151      */
0152     StatusCode ExtractCaloHitMetadata(const std::string &reclusterListName, CaloHitMetadata *&pCaloHitMetaData);
0153 
0154     /**
0155      *  @brief  Get the initial calo hit list
0156      * 
0157      *  @return the initial calo hit list
0158      */
0159     const CaloHitList &GetCaloHitList() const;
0160 
0161     /**
0162      *  @brief  Get the current calo hit metadata
0163      * 
0164      *  @return the current calo hit metadata
0165      */
0166     CaloHitMetadata *GetCurrentCaloHitMetadata();
0167 
0168 private:
0169     typedef std::map<std::string, CaloHitMetadata *> NameToMetadataMap;
0170 
0171     CaloHitMetadata            *m_pCurrentCaloHitMetadata;          ///< Address of the current calo hit metadata
0172     CaloHitList                 m_caloHitList;                      ///< Copy of the reclustering input calo hit list
0173     NameToMetadataMap           m_nameToMetadataMap;                ///< The recluster list name to metadata map
0174 };
0175 
0176 typedef std::vector<ReclusterMetadata *> ReclusterMetadataList;
0177 
0178 //------------------------------------------------------------------------------------------------------------------------------------------
0179 //------------------------------------------------------------------------------------------------------------------------------------------
0180 
0181 inline const CaloHitUsageMap &CaloHitMetadata::GetCaloHitUsageMap() const
0182 {
0183     return m_caloHitUsageMap;
0184 }
0185 
0186 //------------------------------------------------------------------------------------------------------------------------------------------
0187 
0188 inline const CaloHitReplacementList &CaloHitMetadata::GetCaloHitReplacementList() const
0189 {
0190     return m_caloHitReplacementList;
0191 }
0192 
0193 //------------------------------------------------------------------------------------------------------------------------------------------
0194 //------------------------------------------------------------------------------------------------------------------------------------------
0195 
0196 inline const CaloHitList &ReclusterMetadata::GetCaloHitList() const
0197 {
0198     return m_caloHitList;
0199 }
0200 
0201 //------------------------------------------------------------------------------------------------------------------------------------------
0202 
0203 inline CaloHitMetadata *ReclusterMetadata::GetCurrentCaloHitMetadata()
0204 {
0205     return m_pCurrentCaloHitMetadata;
0206 }
0207 
0208 } // namespace pandora
0209 
0210 #endif // #ifndef PANDORA_METADATA_MANAGER_H