//////////////////////////////////////////////////////////////////// #ifndef __RAT_TrackNode__ #define __RAT_TrackNode__ #include namespace RAT { class TrackNode : public DS::MCTrackStep { public: TrackNode() { fIsTrackStart = true; fPrev = fNext = 0; }; virtual ~TrackNode() { if (fNext) delete fNext; for (unsigned i=0; i < fChild.size(); i++) if (fChild[i]) delete fChild[i]; }; /* True if this is the first step in the track */ virtual bool IsTrackStart() const { return fIsTrackStart; }; virtual void SetTrackStart(bool state=true) { fIsTrackStart = state; }; /* True if this is the last step in the track */ virtual bool IsTrackEnd() const { return fNext == 0; }; /* ID number for this track. * * Guaranteed to be unique for all tracks within this event, numbered * starting from 1. */ virtual int GetTrackID() const { return fTrackID; }; virtual void SetTrackID(int _trackID) { fTrackID = _trackID; }; /* ID number for this step */ virtual int GetStepID() const { return fStepID; }; virtual void SetStepID(int _stepID) { fStepID = _stepID; }; /* Particle type as defined in MCParticle::pdgcode. */ virtual int GetPDGCode() const { return fPDGCode; }; virtual void SetPDGCode(int _pdgcode) { fPDGCode = _pdgcode; }; /* Name of particle. * * Often this is more accurate than the pdgcode, which is used inconsistently. */ virtual const std::string& GetParticleName() const { return fParticleName; }; virtual void SetParticleName(const std::string &_particleName) { fParticleName = _particleName; } // Step information inherited from DS::MCTrackStep virtual TrackNode *GetPrev() const { return fPrev; }; virtual void SetPrev(TrackNode *_prev) { fPrev = _prev; }; virtual TrackNode *GetNext() const { return fNext; }; virtual void SetNext(TrackNode *_next) { fNext = _next; }; std::vector fChild; // Any additional tracks connected to this one // Not using TClonesArray because this object does not go into a TTree ever! // Util methods void AddNext(TrackNode *n) { n->fPrev = this;n->fIsTrackStart = false;fNext = n; }; void AddChild(TrackNode *c) {c->fPrev = this;c->fIsTrackStart = true;fChild.push_back(c);}; virtual TrackNode &operator= (const DS::MCTrackStep &rhs) { *dynamic_cast(this) = rhs; return *this; }; ClassDef(TrackNode,2); protected: bool fIsTrackStart; int fTrackID; int fStepID; int fPDGCode; std::string fParticleName; TrackNode *fPrev; TrackNode *fNext; // Next node for this same particle }; } // namespace RAT #endif