Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /**
0002  *  @file   PandoraSDK/include/Pandora/ObjectCreation.h
0003  * 
0004  *  @brief  Header file for pandora object creation classes
0005  * 
0006  *  $Log: $
0007  */
0008 #ifndef PANDORA_OBJECT_CREATION_H
0009 #define PANDORA_OBJECT_CREATION_H 1
0010 
0011 #include "Pandora/PandoraInternal.h"
0012 #include "Pandora/PandoraInputTypes.h"
0013 #include "Pandora/StatusCodes.h"
0014 
0015 namespace pandora
0016 {
0017     class Algorithm; class Pandora;
0018     template <typename Parameters, typename Object> class ObjectFactory;
0019     template <typename Parameters, typename Object> class PandoraObjectFactory;
0020 }
0021 
0022 //------------------------------------------------------------------------------------------------------------------------------------------
0023 
0024 namespace object_creation
0025 {
0026 
0027 /**
0028  *  @brief  Object creation helper class
0029  * 
0030  *  @param  PARAMETERS the type of object parameters
0031  *  @param  METADATA the type of object metadata
0032  *  @param  OBJECT the type of object
0033  */
0034 template <typename PARAMETERS, typename METADATA, typename OBJECT>
0035 class ObjectCreationHelper
0036 {
0037 public:
0038     typedef PARAMETERS Parameters;
0039     typedef METADATA Metadata;
0040     typedef OBJECT Object;
0041 
0042     /**
0043      *  @brief  Create a new object from a user factory
0044      *
0045      *  @param  pandora the pandora instance to create the new object
0046      *  @param  parameters the object parameters
0047      *  @param  factory the factory that performs the object allocation
0048      */
0049     static pandora::StatusCode Create(const pandora::Pandora &pandora, const Parameters &parameters,
0050         const pandora::ObjectFactory<Parameters, Object> &factory = pandora::PandoraObjectFactory<Parameters, Object>());
0051 
0052     /**
0053      *  @brief  Create a new object from a user factory, receiving the address of the object created
0054      *
0055      *  @param  algorithm the algorithm calling this function
0056      *  @param  parameters the object parameters
0057      *  @param  pObject to receive the address of the object created
0058      *  @param  factory the factory that performs the object allocation
0059      */
0060     static pandora::StatusCode Create(const pandora::Algorithm &algorithm, const Parameters &parameters,
0061         const Object *&pObject, const pandora::ObjectFactory<Parameters, Object> &factory = pandora::PandoraObjectFactory<Parameters, Object>());
0062 
0063     /**
0064      *  @brief  Alter the metadata information stored in an object
0065      * 
0066      *  @param  algorithm the algorithm calling this function
0067      *  @param  pObject address of the object to modify
0068      *  @param  metaData the metadata (only populated metadata fields will be propagated to the object)
0069      */
0070     static pandora::StatusCode AlterMetadata(const pandora::Algorithm &algorithm, const Object *const pObject, const Metadata &metadata);
0071 };
0072 
0073 //------------------------------------------------------------------------------------------------------------------------------------------
0074 
0075 /**
0076  *  @brief  ObjectMetadata class
0077  */
0078 class ObjectMetadata
0079 {
0080 public:
0081     /**
0082      *  @param  virtual destructor to allow polymorphic behaviour of api metadata classes
0083      */
0084     virtual ~ObjectMetadata();
0085 };
0086 
0087 //------------------------------------------------------------------------------------------------------------------------------------------
0088 
0089 /**
0090  *  @brief  ObjectParameters class
0091  */
0092 class ObjectParameters
0093 {
0094 public:
0095     /**
0096      *  @param  virtual destructor to allow polymorphic behaviour of api parameters classes
0097      */
0098     virtual ~ObjectParameters();
0099 };
0100 
0101 //------------------------------------------------------------------------------------------------------------------------------------------
0102 
0103 /**
0104  *  @brief  CaloHitMetadata class
0105  */
0106 class CaloHitMetadata : public ObjectMetadata
0107 {
0108 public:
0109     pandora::InputFloat                 m_x0;                       ///< For LArTPC usage, the x-coordinate shift associated with a drift time t0 shift, units mm
0110     pandora::InputBool                  m_isIsolated;               ///< The calo hit isolation flag
0111     pandora::InputBool                  m_isPossibleMip;            ///< The calo hit minimum ionising particle flag
0112 };
0113 
0114 /**
0115  *  @brief  CaloHitParameters class
0116  */
0117 class CaloHitParameters : public ObjectParameters
0118 {
0119 public:
0120     pandora::InputCartesianVector       m_positionVector;           ///< Position vector of center of calorimeter cell, units mm
0121     pandora::InputCartesianVector       m_expectedDirection;        ///< Unit vector in direction of expected hit propagation
0122     pandora::InputCartesianVector       m_cellNormalVector;         ///< Unit normal to sampling layer, pointing outwards from the origin
0123     pandora::InputCellGeometry          m_cellGeometry;             ///< The cell geometry type, pointing or rectangular
0124     pandora::InputFloat                 m_cellSize0;                ///< Cell size 0 [pointing: eta, rectangular: up in ENDCAP, along beam in BARREL, units mm]
0125     pandora::InputFloat                 m_cellSize1;                ///< Cell size 1 [pointing: phi, rectangular: perpendicular to size 0 and thickness, units mm]
0126     pandora::InputFloat                 m_cellThickness;            ///< Cell thickness, units mm
0127     pandora::InputFloat                 m_nCellRadiationLengths;    ///< Absorber material in front of cell, units radiation lengths
0128     pandora::InputFloat                 m_nCellInteractionLengths;  ///< Absorber material in front of cell, units interaction lengths
0129     pandora::InputFloat                 m_time;                     ///< Time of (earliest) energy deposition in this cell, units ns
0130     pandora::InputFloat                 m_inputEnergy;              ///< Corrected energy of calorimeter cell in user framework, units GeV
0131     pandora::InputFloat                 m_mipEquivalentEnergy;      ///< The calibrated mip equivalent energy, units mip
0132     pandora::InputFloat                 m_electromagneticEnergy;    ///< The calibrated electromagnetic energy measure, units GeV
0133     pandora::InputFloat                 m_hadronicEnergy;           ///< The calibrated hadronic energy measure, units GeV
0134     pandora::InputBool                  m_isDigital;                ///< Whether cell should be treated as digital
0135     pandora::InputHitType               m_hitType;                  ///< The type of calorimeter hit
0136     pandora::InputHitRegion             m_hitRegion;                ///< Region of the detector in which the calo hit is located
0137     pandora::InputUInt                  m_layer;                    ///< The subdetector readout layer number
0138     pandora::InputBool                  m_isInOuterSamplingLayer;   ///< Whether cell is in one of the outermost detector sampling layers
0139     pandora::InputAddress               m_pParentAddress;           ///< Address of the parent calo hit in the user framework
0140 };
0141 
0142 typedef ObjectCreationHelper<CaloHitParameters, CaloHitMetadata, pandora::CaloHit> CaloHit;
0143 
0144 //------------------------------------------------------------------------------------------------------------------------------------------
0145 
0146 /**
0147  *  @brief  MCParticleParameters class
0148  */
0149 class MCParticleParameters : public ObjectParameters
0150 {
0151 public:
0152     pandora::InputFloat                 m_energy;                   ///< The energy of the MC particle, units GeV
0153     pandora::InputCartesianVector       m_momentum;                 ///< The momentum of the MC particle, units GeV
0154     pandora::InputCartesianVector       m_vertex;                   ///< The production vertex of the MC particle, units mm
0155     pandora::InputCartesianVector       m_endpoint;                 ///< The endpoint of the MC particle, units mm
0156     pandora::InputInt                   m_particleId;               ///< The MC particle's ID (PDG code)
0157     pandora::InputMCParticleType        m_mcParticleType;           ///< The type of mc particle, e.g. vertex, 2D-projection, etc.
0158     pandora::InputAddress               m_pParentAddress;           ///< Address of the parent MC particle in the user framework
0159 };
0160 
0161 typedef ObjectCreationHelper<MCParticleParameters, ObjectMetadata, pandora::MCParticle> MCParticle;
0162 
0163 //------------------------------------------------------------------------------------------------------------------------------------------
0164 
0165 /**
0166  *  @brief  TrackParameters class
0167  */
0168 class TrackParameters : public ObjectParameters
0169 {
0170 public:
0171     pandora::InputFloat                 m_d0;                       ///< The 2D impact parameter wrt (0,0), units mm
0172     pandora::InputFloat                 m_z0;                       ///< The z coordinate at the 2D distance of closest approach, units mm
0173     pandora::InputInt                   m_particleId;               ///< The PDG code of the tracked particle
0174     pandora::InputInt                   m_charge;                   ///< The charge of the tracked particle
0175     pandora::InputFloat                 m_mass;                     ///< The mass of the tracked particle, units GeV
0176     pandora::InputCartesianVector       m_momentumAtDca;            ///< Track momentum at the 2D distance of closest approach, units GeV
0177     pandora::InputTrackState            m_trackStateAtStart;        ///< Track state at the start of the track, units mm and GeV
0178     pandora::InputTrackState            m_trackStateAtEnd;          ///< Track state at the end of the track, units mm and GeV
0179     pandora::InputTrackState            m_trackStateAtCalorimeter;  ///< The (sometimes projected) track state at the calorimeter, units mm and GeV
0180     pandora::InputFloat                 m_timeAtCalorimeter;        ///< The (sometimes projected) time at the calorimeter, units ns
0181     pandora::InputBool                  m_reachesCalorimeter;       ///< Whether the track actually reaches the calorimeter
0182     pandora::InputBool                  m_isProjectedToEndCap;      ///< Whether the calorimeter projection is to an endcap
0183     pandora::InputBool                  m_canFormPfo;               ///< Whether track should form a pfo, if it has an associated cluster
0184     pandora::InputBool                  m_canFormClusterlessPfo;    ///< Whether track should form a pfo, even if it has no associated cluster
0185     pandora::InputAddress               m_pParentAddress;           ///< Address of the parent track in the user framework
0186 };
0187 
0188 typedef ObjectCreationHelper<TrackParameters, ObjectMetadata, pandora::Track> Track;
0189 
0190 //------------------------------------------------------------------------------------------------------------------------------------------
0191 
0192 /**
0193  *  @brief  Geometry class
0194  */
0195 class Geometry
0196 {
0197 public:
0198     /**
0199      *  @brief  LayerParameters class
0200      */
0201     class LayerParameters : public ObjectParameters
0202     {
0203     public:
0204         pandora::InputFloat             m_closestDistanceToIp;      ///< Closest distance of the layer from the interaction point, units mm
0205         pandora::InputFloat             m_nRadiationLengths;        ///< Absorber material in front of layer, units radiation lengths
0206         pandora::InputFloat             m_nInteractionLengths;      ///< Absorber material in front of layer, units interaction lengths
0207     };
0208 
0209     typedef std::vector<LayerParameters> LayerParametersVector;
0210 
0211     /**
0212      *  @brief  SubDetectorParameters class
0213      */
0214     class SubDetectorParameters : public ObjectParameters
0215     {
0216     public:
0217         pandora::InputString            m_subDetectorName;          ///< The sub detector name, must uniquely specify a single sub detector
0218         pandora::InputSubDetectorType   m_subDetectorType;          ///< The sub detector type, e.g. ECAL_BARREL, HCAL_ENDCAP, TPC, etc.
0219         pandora::InputFloat             m_innerRCoordinate;         ///< Inner cylindrical polar r coordinate, origin interaction point, units mm
0220         pandora::InputFloat             m_innerZCoordinate;         ///< Inner cylindrical polar z coordinate, origin interaction point, units mm
0221         pandora::InputFloat             m_innerPhiCoordinate;       ///< Inner cylindrical polar phi coordinate (angle wrt cartesian x axis)
0222         pandora::InputUInt              m_innerSymmetryOrder;       ///< Order of symmetry of the innermost edge of subdetector
0223         pandora::InputFloat             m_outerRCoordinate;         ///< Outer cylindrical polar r coordinate, origin interaction point, units mm
0224         pandora::InputFloat             m_outerZCoordinate;         ///< Outer cylindrical polar z coordinate, origin interaction point, units mm
0225         pandora::InputFloat             m_outerPhiCoordinate;       ///< Outer cylindrical polar phi coordinate (angle wrt cartesian x axis)
0226         pandora::InputUInt              m_outerSymmetryOrder;       ///< Order of symmetry of the outermost edge of subdetector
0227         pandora::InputBool              m_isMirroredInZ;            ///< Whether to construct a second subdetector, via reflection in z=0 plane
0228         pandora::InputUInt              m_nLayers;                  ///< The number of layers in the detector section
0229         LayerParametersVector           m_layerParametersVector;    ///< The vector of layer parameters for the detector section
0230     };
0231 
0232     typedef ObjectCreationHelper<SubDetectorParameters, ObjectMetadata, pandora::SubDetector> SubDetector;
0233 
0234     /**
0235      *  @brief  LArTPCParameters class
0236      */
0237     class LArTPCParameters : public ObjectParameters
0238     {
0239     public:
0240         pandora::InputUInt              m_larTPCVolumeId;           ///< The lar tpc volume id, must uniquely specify a single lar tpc
0241         pandora::InputFloat             m_centerX;                  ///< The center in x, units mm
0242         pandora::InputFloat             m_centerY;                  ///< The center in y, units mm
0243         pandora::InputFloat             m_centerZ;                  ///< The center in z, units mm
0244         pandora::InputFloat             m_widthX;                   ///< The width in x, units mm
0245         pandora::InputFloat             m_widthY;                   ///< The width in y, units mm
0246         pandora::InputFloat             m_widthZ;                   ///< The width in z, units mm
0247         pandora::InputFloat             m_wirePitchU;               ///< The u wire pitch, units mm
0248         pandora::InputFloat             m_wirePitchV;               ///< The v wire pitch, units mm
0249         pandora::InputFloat             m_wirePitchW;               ///< The w wire pitch, units mm
0250         pandora::InputFloat             m_wireAngleU;               ///< The u wire angle to the vertical, units radians
0251         pandora::InputFloat             m_wireAngleV;               ///< The v wire angle to the vertical, units radians
0252         pandora::InputFloat             m_wireAngleW;               ///< The w wire angle to the vertical, units radians
0253         pandora::InputFloat             m_sigmaUVW;                 ///< The u, v, w resolution, units mm
0254         pandora::InputBool              m_isDriftInPositiveX;       ///< Whether the electron drift is in the positive x direction
0255     };
0256 
0257     typedef ObjectCreationHelper<LArTPCParameters, ObjectMetadata, pandora::LArTPC> LArTPC;
0258 
0259     /**
0260      *  @brief  LineGapParameters class
0261      */
0262     class LineGapParameters : public ObjectParameters
0263     {
0264     public:
0265         pandora::InputLineGapType       m_lineGapType;              ///< The type of line gap, e.g. TPC wire-type gap (u, v, w), or drift-type gap
0266         pandora::InputFloat             m_lineStartX;               ///< The line start x coordinate, units mm
0267         pandora::InputFloat             m_lineEndX;                 ///< The line end x coordinate, units mm
0268         pandora::InputFloat             m_lineStartZ;               ///< The line start z coordinate, units mm
0269         pandora::InputFloat             m_lineEndZ;                 ///< The line end z coordinate, units mm
0270     };
0271 
0272     typedef ObjectCreationHelper<LineGapParameters, ObjectMetadata, pandora::LineGap> LineGap;
0273 
0274     /**
0275      *  @brief  BoxGapParameters class
0276      */
0277     class BoxGapParameters : public ObjectParameters
0278     {
0279     public:
0280         pandora::InputCartesianVector   m_vertex;                   ///< Cartesian coordinates of a gap vertex, units mm
0281         pandora::InputCartesianVector   m_side1;                    ///< Cartesian vector describing first side meeting vertex, units mm
0282         pandora::InputCartesianVector   m_side2;                    ///< Cartesian vector describing second side meeting vertex, units mm
0283         pandora::InputCartesianVector   m_side3;                    ///< Cartesian vector describing third side meeting vertex, units mm
0284     };
0285 
0286     typedef ObjectCreationHelper<BoxGapParameters, ObjectMetadata, pandora::BoxGap> BoxGap;
0287 
0288     /**
0289      *  @brief  ConcentricGapParameters class
0290      */
0291     class ConcentricGapParameters : public ObjectParameters
0292     {
0293     public:
0294         pandora::InputFloat             m_minZCoordinate;           ///< Min cylindrical polar z coordinate, origin interaction point, units mm
0295         pandora::InputFloat             m_maxZCoordinate;           ///< Max cylindrical polar z coordinate, origin interaction point, units mm
0296         pandora::InputFloat             m_innerRCoordinate;         ///< Inner cylindrical polar r coordinate, origin interaction point, units mm
0297         pandora::InputFloat             m_innerPhiCoordinate;       ///< Inner cylindrical polar phi coordinate (angle wrt cartesian x axis)
0298         pandora::InputUInt              m_innerSymmetryOrder;       ///< Order of symmetry of the innermost edge of gap
0299         pandora::InputFloat             m_outerRCoordinate;         ///< Outer cylindrical polar r coordinate, origin interaction point, units mm
0300         pandora::InputFloat             m_outerPhiCoordinate;       ///< Outer cylindrical polar phi coordinate (angle wrt cartesian x axis)
0301         pandora::InputUInt              m_outerSymmetryOrder;       ///< Order of symmetry of the outermost edge of gap
0302     };
0303 
0304     typedef ObjectCreationHelper<ConcentricGapParameters, ObjectMetadata, pandora::ConcentricGap> ConcentricGap;
0305 };
0306 
0307 //------------------------------------------------------------------------------------------------------------------------------------------
0308 
0309 /**
0310  *  @brief  ClusterMetadata class
0311  */
0312 class ClusterMetadata : public ObjectMetadata
0313 {
0314 public:
0315     pandora::InputInt                   m_particleId;               ///< The cluster id (PDG code)
0316 };
0317 
0318 /**
0319  *  @brief  ClusterParameters class. To build a cluster must provide at least one hit (which may be isolated) or a track address.
0320  */
0321 class ClusterParameters : public ObjectParameters
0322 {
0323 public:
0324     pandora::CaloHitList                m_caloHitList;              ///< The calo hit(s) to include
0325     pandora::CaloHitList                m_isolatedCaloHitList;      ///< The isolated calo hit(s) to include
0326     pandora::InputTrackAddress          m_pTrack;                   ///< The address of the track seeding the cluster
0327 };
0328 
0329 typedef ObjectCreationHelper<ClusterParameters, ClusterMetadata, pandora::Cluster> Cluster;
0330 
0331 //------------------------------------------------------------------------------------------------------------------------------------------
0332 
0333 /**
0334  *  @brief  ParticleFlowObjectMetadata class
0335  */
0336 class ParticleFlowObjectMetadata : public ObjectMetadata
0337 {
0338 public:
0339     pandora::InputInt                   m_particleId;               ///< The particle flow object id (PDG code)
0340     pandora::InputInt                   m_charge;                   ///< The particle flow object charge
0341     pandora::InputFloat                 m_mass;                     ///< The particle flow object mass
0342     pandora::InputFloat                 m_energy;                   ///< The particle flow object energy
0343     pandora::InputCartesianVector       m_momentum;                 ///< The particle flow object momentum
0344     pandora::PropertiesMap              m_propertiesToAdd;          ///< The mapping from pfo property names to new values
0345     pandora::StringVector               m_propertiesToRemove;       ///< The vector of pfo property names to remove
0346 };
0347 
0348 /**
0349  *  @brief  ParticleFlowObjectCreation class
0350  */
0351 class ParticleFlowObjectCreation : public ParticleFlowObjectMetadata, public ObjectParameters
0352 {
0353 public:
0354     pandora::ClusterList                m_clusterList;              ///< The clusters in the particle flow object
0355     pandora::TrackList                  m_trackList;                ///< The tracks in the particle flow object
0356     pandora::VertexList                 m_vertexList;               ///< The vertices in the particle flow object
0357 };
0358 
0359 typedef ObjectCreationHelper<ParticleFlowObjectCreation, ParticleFlowObjectMetadata, pandora::ParticleFlowObject> ParticleFlowObject;
0360 
0361 //------------------------------------------------------------------------------------------------------------------------------------------
0362 
0363 /**
0364  *  @brief  VertexMetadata class
0365  */
0366 class VertexMetadata : public ObjectMetadata
0367 {
0368 public:
0369     pandora::InputFloat                 m_x0;                       ///< For LArTPC usage, the x-coordinate shift associated with a drift time t0 shift, units mm
0370     pandora::InputVertexLabel           m_vertexLabel;              ///< The vertex label (interaction, start, end, etc.)
0371     pandora::InputVertexType            m_vertexType;               ///< The vertex type (3d, view u, v, w, etc.)
0372 };
0373 
0374 /**
0375  *  @brief  Vertex creation class
0376  */
0377 class VertexParameters : public VertexMetadata, public ObjectParameters
0378 {
0379 public:
0380     pandora::InputCartesianVector       m_position;                 ///< The vertex position
0381 };
0382 
0383 typedef ObjectCreationHelper<VertexParameters, VertexMetadata, pandora::Vertex> Vertex;
0384 
0385 //------------------------------------------------------------------------------------------------------------------------------------------
0386 
0387 /**
0388  *  @brief  Type definition helper class
0389  * 
0390  *  @param  PARAMETERS the type of object parameters
0391  *  @param  OBJECT the type of object
0392  */
0393 template <typename PARAMETERS, typename OBJECT>
0394 class TypedefHelper
0395 {
0396 public:
0397     typedef PARAMETERS Parameters;
0398     typedef OBJECT Object;
0399 };
0400 
0401 //------------------------------------------------------------------------------------------------------------------------------------------
0402 
0403 /**
0404  *  @brief  CaloHit fragment creation class
0405  */
0406 class CaloHitFragmentParameters : public ObjectParameters
0407 {
0408 public:
0409     const pandora::CaloHit             *m_pOriginalCaloHit;         ///< The address of the original calo hit
0410     pandora::InputFloat                 m_weight;                   ///< The weight to be assigned to the fragment
0411 };
0412 
0413 typedef TypedefHelper<CaloHitFragmentParameters, pandora::CaloHit> CaloHitFragment;
0414 
0415 //------------------------------------------------------------------------------------------------------------------------------------------
0416 //------------------------------------------------------------------------------------------------------------------------------------------
0417 
0418 inline ObjectMetadata::~ObjectMetadata()
0419 {
0420 }
0421 
0422 //------------------------------------------------------------------------------------------------------------------------------------------
0423 //------------------------------------------------------------------------------------------------------------------------------------------
0424 
0425 inline ObjectParameters::~ObjectParameters()
0426 {
0427 }
0428 
0429 } // namespace object_creation
0430 
0431 #endif // #ifndef PANDORA_OBJECT_CREATION_H