Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /**
0002  *  @file   PandoraSDK/include/Objects/CaloHit.h
0003  * 
0004  *  @brief  Header file for the calo hit class.
0005  * 
0006  *  $Log: $
0007  */
0008 #ifndef PANDORA_CALO_HIT_H
0009 #define PANDORA_CALO_HIT_H 1
0010 
0011 #include "Pandora/ObjectCreation.h"
0012 #include "Pandora/StatusCodes.h"
0013 
0014 namespace pandora
0015 {
0016 
0017 template<typename T> class InputObjectManager;
0018 template<typename T, typename S> class PandoraObjectFactory;
0019 
0020 //------------------------------------------------------------------------------------------------------------------------------------------
0021 
0022 /**
0023  *  @brief  CaloHit class
0024  */
0025 class CaloHit
0026 {
0027 public:
0028     /**
0029      *  @brief  Get the position vector of center of calorimeter cell, units mm
0030      * 
0031      *  @return the position vector
0032      */
0033     const CartesianVector &GetPositionVector() const;
0034 
0035     /**
0036      *  @brief  For LArTPC usage, the x-coordinate shift associated with a drift time t0 shift, units mm
0037      * 
0038      *  @return the x-coordinate shift
0039      */
0040     float GetX0() const;
0041 
0042     /**
0043      *  @brief  Get the unit vector in direction of expected hit propagation
0044      * 
0045      *  @return the expected direction
0046      */
0047     const CartesianVector &GetExpectedDirection() const;
0048 
0049     /**
0050      *  @brief  Get the unit vector normal to the sampling layer, pointing outwards from the origin
0051      * 
0052      *  @return the normal vector
0053      */
0054     const CartesianVector &GetCellNormalVector() const;
0055 
0056     /**
0057      *  @brief  Get the cell geometry
0058      * 
0059      *  @return the cell geometry
0060      */
0061     CellGeometry GetCellGeometry() const;
0062 
0063     /**
0064      *  @brief  Get the cell size 0 [pointing: eta, rectangular: up in ENDCAP, along beam in BARREL, units mm]
0065      * 
0066      *  @return the cell size 0
0067      */
0068     float GetCellSize0() const;
0069 
0070     /**
0071      *  @brief  Get the cell size 1 [pointing: phi, rectangular: perpendicular to size 0 and thickness, units mm]
0072      * 
0073      *  @return the cell size 1
0074      */
0075     float GetCellSize1() const;
0076 
0077     /**
0078      *  @brief  Get the thickness of cell, units mm
0079      * 
0080      *  @return the thickness of cell
0081      */
0082     float GetCellThickness() const;
0083 
0084     /**
0085      *  @brief  Get the absorber material in front of cell, units radiation lengths
0086      * 
0087      *  @return the absorber material in front of cell in radiation lengths
0088      */
0089     float GetNCellRadiationLengths() const;
0090 
0091     /**
0092      *  @brief  Get the absorber material in front of cell, units interaction lengths
0093      * 
0094      *  @return the absorber material in front of cell in interaction lengths
0095      */
0096     float GetNCellInteractionLengths() const;
0097 
0098     /**
0099      *  @brief  Get the corrected energy of the calorimeter cell, units GeV, as supplied by the user
0100      * 
0101      *  @return the corrected energy of the calorimeter cell
0102      */
0103     float GetInputEnergy() const;
0104 
0105     /**
0106      *  @brief  Get the time of (earliest) energy deposition in this cell, units ns
0107      * 
0108      *  @return the time of (earliest) energy deposition in this cell
0109      */
0110     float GetTime() const;
0111 
0112     /**
0113      *  @brief  Whether cell should be treated as digital
0114      * 
0115      *  @return boolean
0116      */
0117     bool IsDigital() const;
0118 
0119     /**
0120      *  @brief  Get the calorimeter hit type
0121      * 
0122      *  @return the calorimeter hit type
0123      */
0124     HitType GetHitType() const;
0125 
0126     /**
0127      *  @brief  Get the region of the detector in which the calo hit is located
0128      * 
0129      *  @return the detector region
0130      */
0131     HitRegion GetHitRegion() const;
0132 
0133     /**
0134      *  @brief  Get the subdetector readout layer number
0135      * 
0136      *  @return the subdetector readout layer number
0137      */
0138     unsigned int GetLayer() const;
0139 
0140     /**
0141      *  @brief  Get pseudo layer for the calo hit
0142      * 
0143      *  @return the pseudo layer
0144      */
0145     unsigned int GetPseudoLayer() const;
0146 
0147     /**
0148      *  @brief  Whether cell is in one of the outermost detector sampling layers
0149      * 
0150      *  @return boolean
0151      */
0152     bool IsInOuterSamplingLayer() const;
0153 
0154     /**
0155      *  @brief  Get the calibrated mip equivalent energy
0156      * 
0157      *  @return the calibrated mip equivalent energy
0158      */
0159     float GetMipEquivalentEnergy() const;
0160 
0161     /**
0162      *  @brief  Get the calibrated electromagnetic energy measure
0163      * 
0164      *  @return the calibrated electromagnetic energy
0165      */
0166     float GetElectromagneticEnergy() const;
0167 
0168     /**
0169      *  @brief  Get the calibrated hadronic energy measure
0170      * 
0171      *  @return the calibrated hadronic energy
0172      */
0173     float GetHadronicEnergy() const;
0174 
0175     /**
0176      *  @brief  Get the typical length scale of cell, units mm
0177      * 
0178      *  @return the typical length scale of cell
0179      */
0180     float GetCellLengthScale() const;
0181 
0182     /**
0183      *  @brief  Whether the calo hit is flagged as a possible mip hit
0184      * 
0185      *  @return boolean
0186      */
0187     bool IsPossibleMip() const;
0188 
0189     /**
0190      *  @brief  Whether the calo hit is flagged as isolated
0191      * 
0192      *  @return boolean
0193      */
0194     bool IsIsolated() const;
0195 
0196     /**
0197      *  @brief  Get the calo hit weight, which may not be unity if the hit has been fragmented
0198      * 
0199      *  @return the calo hit weight
0200      */
0201     float GetWeight() const;
0202 
0203     /**
0204      *  @brief  Get mc particle weight map for the calo hit
0205      * 
0206      *  @return the mc particle weight map
0207      */
0208     const MCParticleWeightMap &GetMCParticleWeightMap() const;
0209 
0210     /**
0211      *  @brief  Get the address of the parent calo hit in the user framework
0212      */
0213     const void *GetParentAddress() const;
0214 
0215     /**
0216      *  @brief  Get the list of cartesian coordinates for the cell corners
0217      * 
0218      *  @param  cartesianPointVector to receive the cartesian coordinates of the cell corners
0219      */
0220     void GetCellCorners(CartesianPointVector &cartesianPointVector) const;
0221 
0222     /**
0223      *  @brief  operator< sorting by position, then energy
0224      * 
0225      *  @param  rhs the object for comparison
0226      * 
0227      *  @return boolean
0228      */
0229     bool operator< (const CaloHit &rhs) const;
0230 
0231 protected:
0232     /**
0233      *  @brief  Constructor
0234      * 
0235      *  @param  parameters the calo hit parameters
0236      */
0237     CaloHit(const object_creation::CaloHit::Parameters &parameters);
0238 
0239     /**
0240      *  @brief  Weighted copy constructor
0241      * 
0242      *  @param  parameters the calo hit fragmentation parameters
0243      */
0244     CaloHit(const object_creation::CaloHitFragment::Parameters &parameters);
0245 
0246     /**
0247      *  @brief  Destructor
0248      */
0249     virtual ~CaloHit();
0250 
0251     /**
0252      *  @brief  Alter the metadata information stored in a calo hit
0253      * 
0254      *  @param  metaData the metadata (only populated metadata fields will be propagated to the object)
0255      */
0256     StatusCode AlterMetadata(const object_creation::CaloHit::Metadata &metadata);
0257 
0258     /**
0259      *  @brief  Set the mc pseudo layer for the calo hit
0260      * 
0261      *  @param  pseudoLayer the pseudo layer
0262      */
0263     StatusCode SetPseudoLayer(const unsigned int pseudoLayer);
0264 
0265     /**
0266      *  @brief  Set the mc particles associated with the calo hit
0267      * 
0268      *  @param  mcParticleWeightMap the mc particle weight map
0269      */
0270     void SetMCParticleWeightMap(const MCParticleWeightMap &mcParticleWeightMap);
0271 
0272     /**
0273      *  @brief  Remove the mc particles associated with the calo hit
0274      */
0275     void RemoveMCParticles();
0276 
0277     /**
0278      *  @brief  Calculate the typical length scale of the cell, units mm
0279      * 
0280      *  @return the typical length scale of cell
0281      */
0282     float CalculateCellLengthScale() const;
0283 
0284     /**
0285      *  @brief  Get the list of cartesian coordinates for rectangular cell corners
0286      * 
0287      *  @param  cartesianPointVector to receive the cartesian coordinates of the cell corners
0288      */
0289     void GetRectangularCellCorners(CartesianPointVector &cartesianPointVector) const;
0290 
0291     /**
0292      *  @brief  Get the list of cartesian coordinates for pointing cell corners
0293      * 
0294      *  @param  cartesianPointVector to receive the cartesian coordinates of the cell corners
0295      */
0296     void GetPointingCellCorners(CartesianPointVector &cartesianPointVector) const;
0297 
0298     /**
0299      *  @brief  Whether the calo hit is available to be added to a cluster (access this function via PandoraContentAPI)
0300      * 
0301      *  @return boolean
0302      */
0303     bool IsAvailable() const;
0304 
0305     /**
0306      *  @brief  Set availability of calo hit to be added to a cluster
0307      * 
0308      *  @param  isAvailable the calo hit availability
0309      */
0310     void SetAvailability(bool isAvailable);
0311 
0312     CartesianVector         m_positionVector;           ///< Position vector of center of calorimeter cell, units mm
0313     float                   m_x0;                       ///< For LArTPC usage, the x-coordinate shift associated with a drift time t0 shift, units mm
0314     const CartesianVector   m_expectedDirection;        ///< Unit vector in direction of expected hit propagation
0315     const CartesianVector   m_cellNormalVector;         ///< Unit normal to the sampling layer, pointing outwards from the origin
0316     const CellGeometry      m_cellGeometry;             ///< The cell geometry type, pointing or rectangular
0317     const float             m_cellSize0;                ///< Cell size 0 [pointing: pseudo rapidity, eta, rectangular: up in ENDCAP, along beam in BARREL, units mm]
0318     const float             m_cellSize1;                ///< Cell size 1 [pointing: azimuthal angle, phi, rectangular: perpendicular to size 0 and thickness, units mm]
0319     const float             m_cellThickness;            ///< Thickness of cell, units mm
0320     const float             m_nCellRadiationLengths;    ///< Absorber material in front of cell, units radiation lengths
0321     const float             m_nCellInteractionLengths;  ///< Absorber material in front of cell, units interaction lengths
0322     const float             m_time;                     ///< Time of (earliest) energy deposition in this cell, units ns
0323     const float             m_inputEnergy;              ///< Corrected energy of calorimeter cell in user framework, units GeV
0324     const float             m_mipEquivalentEnergy;      ///< The calibrated mip equivalent energy, units mip
0325     const float             m_electromagneticEnergy;    ///< The calibrated electromagnetic energy measure, units GeV
0326     const float             m_hadronicEnergy;           ///< The calibrated hadronic energy measure, units GeV
0327     const bool              m_isDigital;                ///< Whether cell should be treated as digital (implies constant cell energy)
0328     const HitType           m_hitType;                  ///< The type of calorimeter hit
0329     const HitRegion         m_hitRegion;                ///< Region of the detector in which the calo hit is located
0330     const unsigned int      m_layer;                    ///< The subdetector readout layer number
0331     InputUInt               m_pseudoLayer;              ///< The pseudo layer to which the calo hit has been assigned
0332     const bool              m_isInOuterSamplingLayer;   ///< Whether cell is in one of the outermost detector sampling layers
0333     float                   m_cellLengthScale;          ///< Typical length scale [pointing: measured at cell mid-point, rectangular: std::sqrt(cellSize0 * cellSize1), units mm ]
0334     bool                    m_isPossibleMip;            ///< Whether the calo hit is a possible mip hit
0335     bool                    m_isIsolated;               ///< Whether the calo hit is isolated
0336     bool                    m_isAvailable;              ///< Whether the calo hit is available to be added to a cluster
0337     float                   m_weight;                   ///< The calo hit weight, which may not be unity if the hit has been fragmented
0338     MCParticleWeightMap     m_mcParticleWeightMap;      ///< The mc particle weight map
0339     const void             *m_pParentAddress;           ///< The address of the parent calo hit in the user framework
0340 
0341     friend class CaloHitMetadata;
0342     friend class CaloHitManager;
0343     friend class InputObjectManager<CaloHit>;
0344     friend class PandoraObjectFactory<object_creation::CaloHit::Parameters, object_creation::CaloHit::Object>;
0345     friend class PandoraObjectFactory<object_creation::CaloHitFragment::Parameters, object_creation::CaloHitFragment::Object>;
0346 };
0347 
0348 //------------------------------------------------------------------------------------------------------------------------------------------
0349 
0350 inline const CartesianVector &CaloHit::GetPositionVector() const
0351 {
0352     return m_positionVector;
0353 }
0354 
0355 //------------------------------------------------------------------------------------------------------------------------------------------
0356 
0357 inline float CaloHit::GetX0() const
0358 {
0359     return m_x0;
0360 }
0361 
0362 //------------------------------------------------------------------------------------------------------------------------------------------
0363 
0364 inline const CartesianVector &CaloHit::GetExpectedDirection() const
0365 {
0366     return m_expectedDirection;
0367 }
0368 
0369 //------------------------------------------------------------------------------------------------------------------------------------------
0370 
0371 inline const CartesianVector &CaloHit::GetCellNormalVector() const
0372 {
0373     return m_cellNormalVector;
0374 }
0375 
0376 //------------------------------------------------------------------------------------------------------------------------------------------
0377 
0378 inline CellGeometry CaloHit::GetCellGeometry() const
0379 {
0380     return m_cellGeometry;
0381 }
0382 
0383 //------------------------------------------------------------------------------------------------------------------------------------------
0384 
0385 inline float CaloHit::GetCellSize0() const
0386 {
0387     return m_cellSize0;
0388 }
0389 
0390 //------------------------------------------------------------------------------------------------------------------------------------------
0391 
0392 inline float CaloHit::GetCellSize1() const
0393 {
0394     return m_cellSize1;
0395 }
0396 
0397 //------------------------------------------------------------------------------------------------------------------------------------------
0398 
0399 inline float CaloHit::GetCellThickness() const
0400 {
0401     return m_cellThickness;
0402 }
0403 
0404 //------------------------------------------------------------------------------------------------------------------------------------------
0405 
0406 inline float CaloHit::GetNCellRadiationLengths() const
0407 {
0408     return m_nCellRadiationLengths;
0409 }
0410 
0411 //------------------------------------------------------------------------------------------------------------------------------------------
0412 
0413 inline float CaloHit::GetNCellInteractionLengths() const
0414 {
0415     return m_nCellInteractionLengths;
0416 }
0417 
0418 //------------------------------------------------------------------------------------------------------------------------------------------
0419 
0420 inline float CaloHit::GetInputEnergy() const
0421 {
0422     return m_inputEnergy;
0423 }
0424 
0425 //------------------------------------------------------------------------------------------------------------------------------------------
0426 
0427 inline float CaloHit::GetTime() const
0428 {
0429     return m_time;
0430 }
0431 
0432 //------------------------------------------------------------------------------------------------------------------------------------------
0433 
0434 inline bool CaloHit::IsDigital() const
0435 {
0436     return m_isDigital;
0437 }
0438 
0439 //------------------------------------------------------------------------------------------------------------------------------------------
0440 
0441 inline HitType CaloHit::GetHitType() const
0442 {
0443     return m_hitType;
0444 }
0445 
0446 //------------------------------------------------------------------------------------------------------------------------------------------
0447 
0448 inline HitRegion CaloHit::GetHitRegion() const
0449 {
0450     return m_hitRegion;
0451 }
0452 
0453 //------------------------------------------------------------------------------------------------------------------------------------------
0454 
0455 inline unsigned int CaloHit::GetLayer() const
0456 {
0457     return m_layer;
0458 }
0459 
0460 //------------------------------------------------------------------------------------------------------------------------------------------
0461 
0462 inline unsigned int CaloHit::GetPseudoLayer() const
0463 {
0464     return m_pseudoLayer.Get();
0465 }
0466 
0467 //------------------------------------------------------------------------------------------------------------------------------------------
0468 
0469 inline bool CaloHit::IsInOuterSamplingLayer() const
0470 {
0471     return m_isInOuterSamplingLayer;
0472 }
0473 
0474 //------------------------------------------------------------------------------------------------------------------------------------------
0475 
0476 inline float CaloHit::GetMipEquivalentEnergy() const
0477 {
0478     return m_mipEquivalentEnergy;
0479 }
0480 
0481 //------------------------------------------------------------------------------------------------------------------------------------------
0482 
0483 inline float CaloHit::GetElectromagneticEnergy() const
0484 {
0485     return m_electromagneticEnergy;
0486 }
0487 
0488 //------------------------------------------------------------------------------------------------------------------------------------------
0489 
0490 inline float CaloHit::GetHadronicEnergy() const
0491 {
0492     return m_hadronicEnergy;
0493 }
0494 
0495 //------------------------------------------------------------------------------------------------------------------------------------------
0496 
0497 inline float CaloHit::GetCellLengthScale() const
0498 {
0499     return m_cellLengthScale;
0500 }
0501 
0502 //------------------------------------------------------------------------------------------------------------------------------------------
0503 
0504 inline bool CaloHit::IsPossibleMip() const
0505 {
0506     return m_isPossibleMip;
0507 }
0508 
0509 //------------------------------------------------------------------------------------------------------------------------------------------
0510 
0511 inline float CaloHit::GetWeight() const
0512 {
0513     return m_weight;
0514 }
0515 
0516 //------------------------------------------------------------------------------------------------------------------------------------------
0517 
0518 inline bool CaloHit::IsIsolated() const
0519 {
0520     return m_isIsolated;
0521 }
0522 
0523 //------------------------------------------------------------------------------------------------------------------------------------------
0524 
0525 inline const MCParticleWeightMap &CaloHit::GetMCParticleWeightMap() const
0526 {
0527     return m_mcParticleWeightMap;
0528 }
0529 
0530 //------------------------------------------------------------------------------------------------------------------------------------------
0531 
0532 inline const void *CaloHit::GetParentAddress() const
0533 {
0534     return m_pParentAddress;
0535 }
0536 
0537 //------------------------------------------------------------------------------------------------------------------------------------------
0538 
0539 inline bool CaloHit::IsAvailable() const
0540 {
0541     return m_isAvailable;
0542 }
0543 
0544 //------------------------------------------------------------------------------------------------------------------------------------------
0545 
0546 inline void CaloHit::SetAvailability(bool isAvailable)
0547 {
0548     m_isAvailable = isAvailable;
0549 }
0550 
0551 } // namespace pandora
0552 
0553 #endif // #ifndef PANDORA_CALO_HIT_H