CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/SimTracker/TrackHistory/interface/HistoryBase.h

Go to the documentation of this file.
00001 #ifndef HistoryBase_h
00002 #define HistoryBase_h
00003 
00004 #include <set>
00005 
00006 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
00007 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticleFwd.h"
00008 #include "SimDataFormats/TrackingAnalysis/interface/TrackingVertex.h"
00009 #include "SimDataFormats/TrackingAnalysis/interface/TrackingVertexContainer.h"
00010 
00012 class HistoryBase
00013 {
00014 
00015 public:
00016 
00018     typedef std::vector<const HepMC::GenParticle *> GenParticleTrail;
00019 
00021     typedef std::vector<const HepMC::GenVertex *> GenVertexTrail;
00022 
00024     typedef std::set<const HepMC::GenVertex *> GenVertexTrailHelper;
00025 
00027     typedef std::vector<TrackingParticleRef> SimParticleTrail;
00028 
00030     typedef std::vector<TrackingVertexRef> SimVertexTrail;
00031 
00032     // Default constructor
00033     HistoryBase()
00034     {
00035         // Default depth
00036         depth_ = -1;
00037     }
00038 
00040     /* Set TrackHistory to given depth. Positive values
00041        constrain the number of TrackingVertex visit in the history.
00042        Negatives values set the limit of the iteration over generated
00043        information i.e. (-1 -> status 1 or -2 -> status 2 particles).
00044 
00045        /param[in] depth the history
00046     */
00047     void depth(int d)
00048     {
00049         depth_ = d;
00050     }
00051 
00053     SimVertexTrail const & simVertexTrail() const
00054     {
00055         return simVertexTrail_;
00056     }
00057 
00059     SimParticleTrail const & simParticleTrail() const
00060     {
00061         return simParticleTrail_;
00062     }
00063 
00065     GenVertexTrail const & genVertexTrail() const
00066     {
00067         return genVertexTrail_;
00068     }
00069 
00071     GenParticleTrail const & genParticleTrail() const
00072     {
00073         return genParticleTrail_;
00074     }
00075 
00077     const TrackingParticleRef & simParticle() const
00078     {
00079         return simParticleTrail_[0];
00080     }
00081 
00083     const TrackingVertexRef & simVertex() const
00084     {
00085         return simVertexTrail_[0];
00086     }
00087 
00089     const HepMC::GenParticle * genParticle() const
00090     {
00091         if ( genParticleTrail_.empty() ) return 0;
00092         return genParticleTrail_[genParticleTrail_.size()-1];
00093     }
00094 
00095 protected:
00096 
00097     // History cointainers
00098     GenVertexTrail genVertexTrail_;
00099     GenParticleTrail genParticleTrail_;
00100     SimVertexTrail simVertexTrail_;
00101     SimParticleTrail simParticleTrail_;
00102 
00103     // Helper function to speedup search
00104     GenVertexTrailHelper genVertexTrailHelper_;
00105 
00107     /* Return false when the history cannot be determined upto a given depth.
00108        If not depth is pass to the function no restriction are apply to it.
00109 
00110        /param[in] TrackingParticleRef of a simulated track
00111        /param[in] depth of the track history
00112        /param[out] boolean that is true when history can be determined
00113     */
00114     bool evaluate(TrackingParticleRef tpr)
00115     {
00116         resetTrails(tpr);
00117         return traceSimHistory(tpr, depth_);
00118     }
00119 
00121     /* Return false when the history cannot be determined upto a given depth.
00122        If not depth is pass to the function no restriction are apply to it.
00123 
00124        /param[in] TrackingVertexRef of a simulated vertex
00125        /param[in] depth of the track history
00126        /param[out] boolean that is true when history can be determined
00127     */
00128     bool evaluate(TrackingVertexRef tvr)
00129     {
00130         resetTrails();
00131         return traceSimHistory(tvr, depth_);
00132     }
00133 
00134 private:
00135 
00136     int depth_;
00137 
00139     bool traceSimHistory (TrackingParticleRef const &, int);
00140 
00142     bool traceSimHistory (TrackingVertexRef const &, int);
00143 
00145     void traceGenHistory (HepMC::GenParticle const *);
00146 
00148     void traceGenHistory (HepMC::GenVertex const *);
00149 
00151     void resetTrails()
00152     {
00153         simParticleTrail_.clear();
00154         simVertexTrail_.clear();
00155         genVertexTrail_.clear();
00156         genParticleTrail_.clear();
00157         genVertexTrailHelper_.clear();
00158     }
00159 
00160     void resetTrails(TrackingParticleRef tpr)
00161     {
00162         resetTrails();
00163         simParticleTrail_.push_back(tpr);
00164     }
00165 };
00166 
00167 #endif