Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /**
0002  *  @file   PandoraSDK/include/Managers/MCManager.h
0003  * 
0004  *  @brief  Header file for the mc particle manager class.
0005  * 
0006  *  $Log: $
0007  */
0008 #ifndef PANDORA_MC_MANAGER_H
0009 #define PANDORA_MC_MANAGER_H 1
0010 
0011 #include "Managers/InputObjectManager.h"
0012 
0013 #include "Pandora/ObjectCreation.h"
0014 #include "Pandora/PandoraInternal.h"
0015 
0016 namespace pandora
0017 {
0018 
0019 /**
0020  *    @brief MCManager class
0021  */
0022 class MCManager : public InputObjectManager<MCParticle>
0023 {
0024 public:
0025     /**
0026      *  @brief  Constructor
0027      * 
0028      *  @param  pPandora address of the associated pandora object
0029      */
0030     MCManager(const Pandora *const pPandora);
0031 
0032     /**
0033      *  @brief  Destructor
0034      */
0035     ~MCManager();
0036 
0037 private:
0038     /**
0039      *  @brief  Create a mc particle
0040      * 
0041      *  @param  parameters the mc particle parameters
0042      *  @param  pMCParticle address of the mc particle
0043      *  @param  factory the factory that performs the object allocation
0044      */
0045     StatusCode Create(const object_creation::MCParticle::Parameters &parameters, const MCParticle *&pMCParticle,
0046         const ObjectFactory<object_creation::MCParticle::Parameters, object_creation::MCParticle::Object> &factory);
0047 
0048     /**
0049      *  @brief  Erase all mc manager content
0050      */
0051     StatusCode EraseAllContent();
0052 
0053     /**
0054      *  @brief  Set mc particle relationship
0055      * 
0056      *  @param  parentUid the parent unique identifier
0057      *  @param  daughterUid the daughter unique identifier
0058      */
0059     StatusCode SetMCParentDaughterRelationship(const Uid parentUid, const Uid daughterUid);
0060 
0061     /**
0062      *  @brief  Set calo hit to mc particle relationship
0063      * 
0064      *  @param  caloHitUid the calo hit unique identifier
0065      *  @param  mcParticleUid the mc particle unique identifier
0066      *  @param  mcParticleWeight weighting to assign to the mc particle
0067      */
0068     StatusCode SetCaloHitToMCParticleRelationship(const Uid caloHitUid, const Uid mcParticleUid, const float mcParticleWeight);
0069 
0070     /**
0071      *  @brief  Set track to mc particle relationship
0072      * 
0073      *  @param  trackUid the track unique identifier
0074      *  @param  mcParticleUid the mc particle unique identifier
0075      *  @param  mcParticleWeight weighting to assign to the mc particle
0076      */
0077     StatusCode SetTrackToMCParticleRelationship(const Uid trackUid, const Uid mcParticleUid, const float mcParticleWeight);
0078 
0079     /**
0080      *  @brief  Identify pfo targets
0081      */
0082     StatusCode IdentifyPfoTargets();
0083 
0084     /**
0085      *  @brief  Select pfo targets
0086      */
0087     StatusCode SelectPfoTargets();
0088 
0089     /**
0090      *  @brief  Apply mc pfo selection rules 
0091      *
0092      *  @param  mcRootParticle address of the mc root particle
0093      *  @param  mcPfoSet set of all MCPFOs selected so far
0094      */
0095     StatusCode ApplyPfoSelectionRules(const MCParticle *const mcRootParticle, MCParticleSet &mcPfoSet) const;
0096 
0097     /**
0098      *  @brief  Set pfo target for a mc tree
0099      * 
0100      *  @param  pMCParticle address of a particle in the mc tree
0101      *  @param  pPfoTarget address of the pfo target
0102      *  @param  onlyDaughters if "true" go through daughters only, if false go through parents as well
0103      */
0104     StatusCode SetPfoTargetInTree(const MCParticle *const pMCParticle, const MCParticle *const pPfoTarget, bool onlyDaughters = false) const;
0105 
0106    /**
0107      *  @brief  Create a map relating calo hit uid to mc pfo target
0108      * 
0109      *  @param  caloHitToPfoTargetMap to receive the calo hit uid to mc pfo target map
0110      */
0111     StatusCode CreateCaloHitToPfoTargetsMap(UidToMCParticleWeightMap &caloHitToPfoTargetsMap) const;
0112 
0113    /**
0114      *  @brief  Create a map relating track uid to mc pfo target
0115      * 
0116      *  @param  trackToPfoTargetMap to receive the track uid to mc pfo target map
0117      */
0118     StatusCode CreateTrackToPfoTargetsMap(UidToMCParticleWeightMap &trackToPfoTargetsMap) const;
0119 
0120     /**
0121      *  @brief  Apply mc particle associations (parent-daughter) that have been registered with the mc manager
0122      */
0123     StatusCode AddMCParticleRelationships() const;
0124 
0125     /**
0126      *  @brief  Remove all mc particle associations that have been registered with the mc manager
0127      */
0128     StatusCode RemoveAllMCParticleRelationships();
0129 
0130     /**
0131      *  @brief  Remove all parent/daughter particle links from a mc particle and from its (previously) linked particles
0132      * 
0133      *  @param  pMCParticle address of the mc particle
0134      */
0135     StatusCode RemoveMCParticleRelationships(const MCParticle *const pMCParticle) const;
0136 
0137     typedef std::unordered_map<Uid, float> UidToWeightMap;
0138     typedef std::unordered_map<Uid, UidToWeightMap> ObjectRelationMap;
0139     typedef std::unordered_multimap<Uid, Uid> MCParticleRelationMap;
0140 
0141     /**
0142      *  @brief  Set an object (e.g. calo hit or track) to mc particle relationship
0143      * 
0144      *  @param  uid the unique identifier of the object
0145      *  @param  mcParticleUid the mc particle unique identifier
0146      *  @param  mcParticleWeight weighting to assign to the mc particle
0147      *  @param  objectRelationMap the uid relation map to populate
0148      */
0149     StatusCode SetUidToMCParticleRelationship(const Uid objectUid, const Uid mcParticleUid, const float mcParticleWeight,
0150         ObjectRelationMap &objectRelationMap) const;
0151 
0152    /**
0153      *  @brief  Create a map relating an object (calo hit or track) uid to mc pfo targets
0154      * 
0155      *  @param  uidToMCParticleWeightMap to receive the calo hit uid to mc pfo target map
0156      *  @param  objectRelationMap the object relation map containing the information
0157      */
0158     StatusCode CreateUidToPfoTargetsMap(UidToMCParticleWeightMap &uidToMCParticleWeightMap, const ObjectRelationMap &objectRelationMap) const;
0159 
0160     const std::string               m_selectedListName;                 ///< The name of the selected list
0161 
0162     UidToMCParticleMap              m_uidToMCParticleMap;               ///< The uid to mc particle map
0163     MCParticleRelationMap           m_parentDaughterRelationMap;        ///< The mc particle parent-daughter relation map
0164     ObjectRelationMap               m_caloHitToMCParticleMap;           ///< The calo hit to mc particle relation map
0165     ObjectRelationMap               m_trackToMCParticleMap;             ///< The track to mc particle relation map
0166 
0167     friend class PandoraApiImpl;
0168     friend class PandoraContentApiImpl;
0169     friend class PandoraImpl;
0170 };
0171 
0172 //------------------------------------------------------------------------------------------------------------------------------------------
0173 
0174 inline StatusCode MCManager::SetCaloHitToMCParticleRelationship(const Uid caloHitUid, const Uid mcParticleUid, const float mcParticleWeight)
0175 {
0176     return this->SetUidToMCParticleRelationship(caloHitUid, mcParticleUid, mcParticleWeight, m_caloHitToMCParticleMap);
0177 }
0178 
0179 //------------------------------------------------------------------------------------------------------------------------------------------
0180 
0181 inline StatusCode MCManager::SetTrackToMCParticleRelationship(const Uid trackUid, const Uid mcParticleUid, const float mcParticleWeight)
0182 {
0183     return this->SetUidToMCParticleRelationship(trackUid, mcParticleUid, mcParticleWeight, m_trackToMCParticleMap);
0184 }
0185 
0186 //------------------------------------------------------------------------------------------------------------------------------------------
0187 
0188 inline StatusCode MCManager::CreateCaloHitToPfoTargetsMap(UidToMCParticleWeightMap &caloHitToPfoTargetsMap) const
0189 {
0190     return this->CreateUidToPfoTargetsMap(caloHitToPfoTargetsMap, m_caloHitToMCParticleMap);
0191 }
0192 
0193 //------------------------------------------------------------------------------------------------------------------------------------------
0194 
0195 inline StatusCode MCManager::CreateTrackToPfoTargetsMap(UidToMCParticleWeightMap &trackToPfoTargetsMap) const
0196 {
0197     return this->CreateUidToPfoTargetsMap(trackToPfoTargetsMap, m_trackToMCParticleMap);
0198 }
0199 
0200 } // namespace pandora
0201 
0202 #endif // #ifndef PANDORA_MC_MANAGER_H