/// /// For questions or suggestions about this module please contact the /// current responsible and CC in the oaAnalysis package manager. /// /// 21-Jul-2010: Current responsible for this module is, /// Glenn Lopez (glopez [*a*t*] nngroup.physics.sunysb.edu) /// /// 14-Feb-2012: Current responsible for this module is, /// Ian Taylor (itaylor [*a*t*] nngroup.physics.sunysb.edu) /// #ifndef TP0DReconModule_hxx_seen #define TP0DReconModule_hxx_seen #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "IAnalysisReconModuleBase.hxx" namespace COMET { class IP0DReconModule; }; /// Summary information about the P0D reconstruction.. class COMET::IP0DReconModule : public IAnalysisReconModuleBase { public: /// A struct for the Object ID, containing an short and a type. struct ObjectID { short id; enum OType_t {kBlank = 0, kVertex, kParticle, kTrack, kShower, kCluster, kHit}; OType_t type; ObjectID() { id = -1; type = kBlank; } }; //################################################### /// An object to describe a Algorithm Result. class IP0DAlgoRes : public TObject { public: virtual ~IP0DAlgoRes(); //################################################### // These items are used by templated code, and must be the same // for all of: P0DAlgoRes, P0DVertex, P0DParticle, P0DTrack, // P0DShower and P0DCluster. //################################################### std::string AlgorithmName; ///< The name of the algorithm that created this object. //################################################### short Cycle; ///< The cycle number, based on the first hit. //################################################### std::vector Vertices; ///< A vector of vertices associated with this object. std::vector Particles; ///< A vector of particles associated with this object. std::vector Tracks; ///< A vector of tracks associated with this object. std::vector Showers; ///< A vector of showers associated with this object. std::vector Clusters; ///< A vector of clusters associated with this object. std::vector Nodes; ///< A vector of nodes associated with this object. std::vector Hits; ///< A vector of hits associated with this object. short NHits; ///< A count of the Hits associated with this object. //################################################### /// Unique id for the object. This field can be used to link to /// global reconstruction objects. UInt_t UniqueID; ///< Unique id for the object. //################################################### // Objects below here are unique to their individual classes. //################################################### std::string FullName; ///< The name of the algorithm that created this result. std::vector AlgoResults; ///< A vector of results beneath this result short Parent; ///< The ID of the parent algorithm result (-1 for highest result) short UsedHitCluster; ///< The ID of the cluster of used hits for this algo result short UnusedHitCluster; ///< The ID of the cluster of unused hits for this algo result ClassDef(IP0DReconModule::IP0DAlgoRes, 5); }; //################################################### class IP0DVertex : public TObject { /// An object to describe a vertex. public: virtual ~IP0DVertex(); //################################################### // These items are used by templated code, and must be the same // for all of: P0DAlgoRes, P0DVertex, P0DParticle, P0DTrack, // P0DShower and P0DCluster. //################################################### std::string AlgorithmName; ///< The name of the algorithm that created this object. //################################################### short Cycle; ///< The cycle number, based on the first hit. //################################################### std::vector Vertices; ///< A vector of vertices associated with this object. std::vector Particles; ///< A vector of particles associated with this object. std::vector Tracks; ///< A vector of tracks associated with this object. std::vector Showers; ///< A vector of showers associated with this object. std::vector Clusters; ///< A vector of clusters associated with this object. std::vector Nodes; ///< A vector of nodes associated with this object. std::vector Hits; ///< A vector of hits associated with this object. short NHits; ///< A count of the Hits associated with this object. //################################################### /// Unique id for the object. This field can be used to link to /// global reconstruction objects. UInt_t UniqueID;///< Unique id for the object //################################################### // Objects below here are unique to their individual classes. //################################################### int Status; ///< The status for the fit. float Quality; ///< The quality of the fit. int NDOF; ///< The number of degrees of freedom. // Truth level hit information. For the MC hits in an object we // store: the true trajectory IDs, the number of hits contributed // by each and the charge share. /// The vector of Primary Trajectory IDs. N.B. These are /// 'pseudo-primaries', which may or may not be primaries for a /// vertex. It is the 'interesting' primary that is defined by /// SimG4, and can include particles such as photons from pi0 /// decay and michel electrons from muon decay. If you want to be /// sure of finding a vertex, use the Truth_TrajIDs list and get /// primary ID from the trajectories. std::vector Truth_PrimaryTrajIDs; // The vector of Primary Trajectory IDs. std::vector Truth_TrajIDs; ///< The vector of Trajectory IDs /// The vector of hit counts. N.B. This doesn't have to equal the /// number of hits, hits can be shared and some hits may not have /// associated trajectories. std::vector Truth_HitCount; // The vector of hit counts. /// The vector of charge shares. For each hit, a trajectory will /// receive a proportional share of the charge, based on the total /// of true trajectory charge. std::vector Truth_ChargeShare; // The vector of charge shares. TLorentzVector Position; ///< The position of the vertex. TLorentzVector PosVariance; ///< The position variance; /// The number of valid dimensions for the object. This has bits /// 0 (x), 1 (y) and 2 (z) set for each valid dimension. This /// means that for a 3D object, the value is 7 and for a 2D /// object, the value will be 3 (xy), 5 (xz), or 6 (yz). short ValidDimensions; // The number of valid dimensions for the object. float Fiducial; //< The distance to the outside of the fiducial volume (negative if the vertex is outside). ClassDef(IP0DReconModule::IP0DVertex, 4); }; /// An object to describe a particle, including potential IDs // Do NOT access nodes for a IP0DParticle. Instead // access the IP0DTrack or IP0DShower associated // with the IP0DParticle and access the TP0DNodes // associated with those objects. Currently, IP0DParticle's // Nodes are not filled correctly. class IP0DParticle : public TObject { public: virtual ~IP0DParticle(); //################################################### // These items are used by templated code, and must be the same // for all of: P0DAlgoRes, P0DVertex, P0DParticle, P0DTrack, // P0DShower and P0DCluster. //################################################### std::string AlgorithmName; ///< The name of the algorithm that created this object. //################################################### short Cycle; ///< The cycle number, based on the first hit. //################################################### std::vector Vertices; ///< A vector of vertices associated with this object. std::vector Particles; ///< A vector of particles associated with this object. std::vector Tracks; ///< A vector of tracks associated with this object. std::vector Showers; ///< A vector of showers associated with this object. std::vector Clusters; ///< A vector of clusters associated with this object. std::vector Nodes; ///< A vector of nodes associated with this object. std::vector Hits; ///< A vector of hits associated with this object. short NHits; ///< A count of the Hits associated with this object. //################################################### /// Unique id for the object. This field can be used to link to /// global reconstruction objects. UInt_t UniqueID; // Unique id for the object. //################################################### // Objects below here are unique to their individual classes. //################################################### int Status; ///< The status for the fit. float Quality; ///< The quality of the fit. int NDOF; ///< The number of degrees of freedom. // Truth level hit information. For the MC hits in an object we // store: the true trajectory IDs, the number of hits contributed // by each and the charge share. /// The vector of Primary Trajectory IDs. N.B. These are /// 'pseudo-primaries', which may or may not be primaries for a /// vertex. It is the 'interesting' primary that is defined by /// SimG4, and can include particles such as photons from pi0 /// decay and michel electrons from muon decay. If you want to be /// sure of finding a vertex, use the Truth_TrajIDs list and get /// primary ID from the trajectories. std::vector Truth_PrimaryTrajIDs;// The vector of Primary Trajectory IDs. std::vector Truth_TrajIDs; ///< The vector of Trajectory IDs /// The vector of hit counts. N.B. This doesn't have to equal the /// number of hits, hits can be shared and some hits may not have /// associated trajectories. std::vector Truth_HitCount; // The vector of hit counts. /// The vector of charge shares. For each hit, a trajectory will /// receive a proportional share of the charge, based on the total /// of true trajectory charge. std::vector Truth_ChargeShare; // The vector of charge shares. float SideDeposit; ///< The deposited charge in the side bars. float EndDeposit; ///< The deposited charge in the end p0dules. TLorentzVector Position; ///< The start position of the object. TLorentzVector PosVariance; ///< The position variance; /// The number of valid dimensions for the object. This has bits /// 0 (x), 1 (y) and 2 (z) set for each valid dimension. This /// means that for a 3D object, the value is 7 and for a 2D /// object, the value will be 3 (xy), 5 (xz), or 6 (yz). short ValidDimensions; // The number of valid dimensions for the object TVector3 Direction; ///< The direction of the object. TVector3 DirVariance; float Momentum; ///< The momentum of the object. float Charge; ///< The charge of the identified particle. std::vector realPIDNames; ///< Names for the stored PID variables based on TRealDatums std::vector > realPIDValues; ///< Values for the stored PID variables based on TRealDatums std::vector integerPIDNames; ///< Names for the stored PID variables based on TIntegerDatums std::vector > integerPIDValues; ///< Values for the stored PID variables based on TIntegerDatums std::vector PID; ///< A vector of potential PIDs, sorted by weight std::vector PID_weight; ClassDef(IP0DReconModule::IP0DParticle, 5); }; /// An object to describe a shower. class IP0DShower : public TObject { public: virtual ~IP0DShower(); //################################################### // These items are used by templated code, and must be the same // for all of: P0DAlgoRes, P0DVertex, P0DParticle, P0DTrack, // P0DShower and P0DCluster. //################################################### std::string AlgorithmName; ///< The name of the algorithm that created this object. //################################################### short Cycle; ///< The cycle number, based on the first hit. //################################################### std::vector Vertices; ///< A vector of vertices associated with this object. std::vector Particles; ///< A vector of particles associated with this object. std::vector Tracks; ///< A vector of tracks associated with this object. std::vector Showers; ///< A vector of showers associated with this object. std::vector Clusters; ///< A vector of clusters associated with this object. std::vector Nodes; ///< A vector of nodes associated with this object. std::vector Hits; ///< A vector of hits associated with this object. short NHits; ///< A count of the Hits associated with this object. //################################################### /// Unique id for the object. This field can be used to link to /// global reconstruction objects. UInt_t UniqueID; // The number of valid dimensions for the object //################################################### // Objects below here are unique to their individual classes. //################################################### int Status; ///< The status for the fit. float Quality; ///< The quality of the fit. int NDOF; ///< The number of degrees of freedom. // Truth level hit information. For the MC hits in an object we // store: the true trajectory IDs, the number of hits contributed // by each and the charge share. /// The vector of Primary Trajectory IDs. N.B. These are /// 'pseudo-primaries', which may or may not be primaries for a /// vertex. It is the 'interesting' primary that is defined by /// SimG4, and can include particles such as photons from pi0 /// decay and michel electrons from muon decay. If you want to be /// sure of finding a vertex, use the Truth_TrajIDs list and get /// primary ID from the trajectories. std::vector Truth_PrimaryTrajIDs; // The vector of Primary Trajectory IDs. std::vector Truth_TrajIDs; ///< The vector of Trajectory IDs /// The vector of hit counts. N.B. This doesn't have to equal the /// number of hits, hits can be shared and some hits may not have /// associated trajectories. std::vector Truth_HitCount; // The vector of hit counts. /// The vector of charge shares. For each hit, a trajectory will /// receive a proportional share of the charge, based on the total /// of true trajectory charge. std::vector Truth_ChargeShare;// The vector of charge shares. float EDeposit; ///< The deposited charge for the shower. float SideDeposit; ///< The deposited charge in the side bars. // The deposited charge in the end p0dules. float EndDeposit; TLorentzVector Position; ///< The start position of the object. TLorentzVector PosVariance; /// The number of valid dimensions for the object. This has bits /// 0 (x), 1 (y) and 2 (z) set for each valid dimension. This /// means that for a 3D object, the value is 7 and for a 2D /// object, the value will be 3 (xy), 5 (xz), or 6 (yz). short ValidDimensions; // The number of valid dimensions for the object. TVector3 Direction; ///< The direction of the object. TVector3 DirVariance; float Cone; ///< The opening angle of the cone. float Width; ///< The width of the shower (perpendicular to the direction) /// The length of the shower (RMS) float Length; ClassDef(IP0DReconModule::IP0DShower, 5); }; class IP0DCluster : public TObject { public: virtual ~IP0DCluster(); //################################################### // These items are used by templated code, and must be the same // for all of: P0DAlgoRes, P0DVertex, P0DParticle, P0DTrack, // P0DShower and P0DCluster. //################################################### std::string AlgorithmName; ///< The name of the algorithm that created this object. //################################################### short Cycle; ///< The cycle number, based on the first hit. //################################################### std::vector Vertices; ///< A vector of vertices associated with this object. std::vector Particles; ///< A vector of particles associated with this object. std::vector Tracks; ///< A vector of tracks associated with this object. std::vector Showers; ///< A vector of showers associated with this object. std::vector Clusters; ///< A vector of clusters associated with this object. std::vector Nodes; ///< A vector of nodes associated with this object. std::vector Hits; ///< A vector of hits associated with this object. short NHits; ///< A count of the Hits associated with this object. //################################################### /// Unique id for the object. This field can be used to link to /// global reconstruction objects. UInt_t UniqueID; // Unique id for the object. //################################################### // Objects below here are unique to their individual classes. //################################################### // Truth level hit information. For the MC hits in an object we // store: the true trajectory IDs, the number of hits contributed // by each and the charge share. /// The vector of Primary Trajectory IDs. N.B. These are /// 'pseudo-primaries', which may or may not be primaries for a /// vertex. It is the 'interesting' primary that is defined by /// SimG4, and can include particles such as photons from pi0 /// decay and michel electrons from muon decay. If you want to be /// sure of finding a vertex, use the Truth_TrajIDs list and get /// primary ID from the trajectories. std::vector Truth_PrimaryTrajIDs; // The vector of Primary Trajectory IDs. std::vector Truth_TrajIDs; ///< The vector of Trajectory IDs /// The vector of hit counts. N.B. This doesn't have to equal the /// number of hits, hits can be shared and some hits may not have /// associated trajectories. std::vector Truth_HitCount; // The vector of hit counts. /// The vector of charge shares. For each hit, a trajectory will /// receive a proportional share of the charge, based on the total /// of true trajectory charge. std::vector Truth_ChargeShare; // The vector of charge shares. short NFiducialHits; ///< The number of fiducial hits. float EDeposit; ///< The deposited charge for the shower. TLorentzVector Position; ///< The start position of the object. TLorentzVector PosVariance; ///< The position variance; /// The number of valid dimensions for the object. This has bits /// 0 (x), 1 (y) and 2 (z) set for each valid dimension. This /// means that for a 3D object, the value is 7 and for a 2D /// object, the value will be 3 (xy), 5 (xz), or 6 (yz). short ValidDimensions; // The number of valid dimensions for the object. /// Moments of the Cluster. // I wanted to copy the TMatrixTSym, but apparently that // was not possible. For now, I'm going low-tech. static const int arraySize = 9; float Moments[arraySize]; ///< Moments of the Cluster.(arraySize = 9) ClassDef(IP0DReconModule::IP0DCluster, 7); }; /// An object to describe a track. class IP0DTrack : public TObject { public: virtual ~IP0DTrack(); //################################################### // These items are used by templated code, and must be the same // for all of: P0DAlgoRes, P0DVertex, P0DParticle, P0DTrack, // P0DShower and P0DCluster. //################################################### std::string AlgorithmName; ///< The name of the algorithm that created this object. //################################################### short Cycle; ///< The cycle number, based on the first hit. //################################################### std::vector Vertices; ///< A vector of vertices associated with this object. std::vector Particles; ///< A vector of particles associated with this object. std::vector Tracks; ///< A vector of tracks associated with this object. std::vector Showers; ///< A vector of showers associated with this object. std::vector Clusters; ///< A vector of clusters associated with this object. std::vector Nodes; ///< A vector of nodes associated with this object. std::vector Hits; ///< A vector of hits associated with this object. short NHits; ///< A count of the Hits associated with this object. //################################################### /// Unique id for the object. This field can be used to link to /// global reconstruction objects. UInt_t UniqueID; // Unique id for the object. //################################################### // Objects below here are unique to their individual classes. //################################################### int Status; ///< The status for the fit. float Quality; ///< The quality of the fit. int NDOF; ///< The number of degrees of freedom. // Truth level hit information. For the MC hits in an object we // store: the true trajectory IDs, the number of hits contributed // by each and the charge share. /// The vector of Primary Trajectory IDs. N.B. These are /// 'pseudo-primaries', which may or may not be primaries for a /// vertex. It is the 'interesting' primary that is defined by /// SimG4, and can include particles such as photons from pi0 /// decay and michel electrons from muon decay. If you want to be /// sure of finding a vertex, use the Truth_TrajIDs list and get /// primary ID from the trajectories. std::vector Truth_PrimaryTrajIDs; // The vector of Primary Trajectory IDs. std::vector Truth_TrajIDs; ///< The vector of Trajectory IDs /// The vector of hit counts. N.B. This doesn't have to equal the /// number of hits, hits can be shared and some hits may not have /// associated trajectories. std::vector Truth_HitCount; // The vector of hit counts. /// The vector of charge shares. For each hit, a trajectory will /// receive a proportional share of the charge, based on the total /// of true trajectory charge. std::vector Truth_ChargeShare;// The vector of charge shares. float EDeposit; ///< The deposited charge for the track. float SideDeposit; ///< The deposited charge in the side bars. float EndDeposit; ///< The deposited charge in the end p0dules. TLorentzVector Position; ///< The position of the track. TLorentzVector PosVariance; /// The number of valid dimensions for the object. This has bits /// 0 (x), 1 (y) and 2 (z) set for each valid dimension. This /// means that for a 3D object, the value is 7 and for a 2D /// object, the value will be 3 (xy), 5 (xz), or 6 (yz). short ValidDimensions; // The number of valid dimensions for the object. TVector3 Direction; ///< The direction of the track. TVector3 DirVariance; float Length; ///< The length of the track in the P0D ClassDef(IP0DReconModule::IP0DTrack, 6); }; /// An object to describe a track node. class IP0DNode : public TObject { public: virtual ~IP0DNode(); std::vector Hits; ///< A vector of hits associated with this object. // Truth level hit information. For the MC hits in an object we // store: the true trajectory IDs, the number of hits contributed // by each and the charge share. /// The vector of Primary Trajectory IDs. N.B. These are /// 'pseudo-primaries', which may or may not be primaries for a /// vertex. It is the 'interesting' primary that is defined by /// SimG4, and can include particles such as photons from pi0 /// decay and michel electrons from muon decay. If you want to be /// sure of finding a vertex, use the Truth_TrajIDs list and get /// primary ID from the trajectories. std::vector Truth_PrimaryTrajIDs; // The vector of Primary Trajectory IDs. std::vector Truth_TrajIDs; ///< The vector of Trajectory IDs /// The vector of hit counts. N.B. This doesn't have to equal the /// number of hits, hits can be shared and some hits may not have /// associated trajectories. std::vector Truth_HitCount; // The vector of hit counts. /// The vector of charge shares. For each hit, a trajectory will /// receive a proportional share of the charge, based on the total /// of true trajectory charge. std::vector Truth_ChargeShare;// The vector of charge shares. float EDeposit; ///< The deposited charge for the node. TLorentzVector Position; ///< The position of the track. TLorentzVector PosVariance; /// The number of valid dimensions for the object. This has bits /// 0 (x), 1 (y) and 2 (z) set for each valid dimension. This /// means that for a 3D object, the value is 7 and for a 2D /// object, the value will be 3 (xy), 5 (xz), or 6 (yz). short ValidDimensions;// The number of valid dimensions for the object. TVector3 Direction; ///< The direction of the track. TVector3 DirVariance; ClassDef(IP0DReconModule::IP0DNode, 5); }; class IP0DHit : public TObject { public: virtual ~IP0DHit() {} UInt_t GeomID; ///< Geometry ID UInt_t ChanID; ///< Channel ID float Charge; ///< Hit charge without attenuation correction float Time; ///< Hit time as reported by hit->GetTime() ClassDef(IP0DReconModule::IP0DHit, 1); }; public: IP0DReconModule(const char *name = "P0D", const char *title = "P0D Recon Module"); virtual ~IP0DReconModule(); virtual EType GetTreeType() const { return kRecon;} virtual Bool_t ProcessFirstEvent(COMET::ICOMETEvent&); protected: virtual void InitializeModule(); virtual void InitializeBranches(); virtual bool FillTree(COMET::ICOMETEvent&); virtual short FillAlgorithmResult(const COMET::IHandle, short); template void FillBaseObject(T basePtr, COMET::IHandle baseObject, bool saveHits); virtual ObjectID FillReconObject(const COMET::IHandle, bool saveHits); virtual ObjectID FillVertexObject(const COMET::IHandle, bool saveHits); virtual ObjectID FillParticleObject(const COMET::IHandle, bool saveHits); virtual ObjectID FillTrackObject(const COMET::IHandle, bool saveHits); virtual ObjectID FillShowerObject(const COMET::IHandle, bool saveHits); virtual ObjectID FillClusterObject(const COMET::IHandle, bool saveHits); virtual std::map< int, std::pair > HitTruthInfo(const COMET::IHandle); virtual std::vector HitTruthPrimaryInfo(const COMET::IHandle); virtual short FillNode(const COMET::IHandle, bool saveHits); short FillHit(const COMET::IHandle); short GetCycle(const COMET::IHandle); short CountValidDimensions(TVector3 posVar); public: //Tree Entries Short_t fNAlgoResults; ///< The number of Algorithm Results Short_t fNVertices; ///< The number of added vertices Short_t fNParticles; ///< The number of particles Short_t fNShowers; ///< The number of showers Short_t fNTracks; ///< The number of tracks Short_t fNNodes; ///< The number of track nodes Short_t fNClusters; ///< The number of clusters Short_t fNHits; ///< The number of hits that are saved TClonesArray *fAlgoResults; ///< The IP0DAlgoRes vector of Algorithm Results. TClonesArray *fVertices; ///< The IP0DVertex vector of vertices. TClonesArray *fParticles; ///< The IP0DParticle vector of particles. TClonesArray *fShowers; ///< The IP0DShower vector of showers. TClonesArray *fTracks; ///< The IP0DTrack vector of tracks. TClonesArray *fNodes; ///< The IP0DNode vector of nodes. TClonesArray *fHits; ///< The IP0DHit vector of hits. TClonesArray *fClusters; ///< The IP0DCluster vector of clusters private: std::vector fRejectAlgoResultList; std::map fTempHitMap; ClassDef(IP0DReconModule,5); }; #endif