CMS 3D CMS Logo

TrackHistory.h

Go to the documentation of this file.
00001 /*
00002  *  TrackHistory.h
00003  *
00004  *  Created by Victor Eduardo Bazterra on 7/13/07.
00005  *  Copyright 2007 __MyCompanyName__. All rights reserved.
00006  *
00007  */
00008 
00009 #ifndef TrackHistory_h
00010 #define TrackHistory_h
00011 
00012 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00013 
00014 #include "FWCore/Framework/interface/Event.h"
00015 #include "FWCore/Framework/interface/ESHandle.h"
00016 #include "FWCore/Framework/interface/EventSetup.h"
00017 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00018 
00019 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
00020 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticleFwd.h"
00021 #include "SimDataFormats/TrackingAnalysis/interface/TrackingVertex.h"
00022 #include "SimDataFormats/TrackingAnalysis/interface/TrackingVertexContainer.h"
00023 
00024 #include "SimTracker/TrackAssociation/interface/TrackAssociatorBase.h"
00025 
00027 class TrackHistory
00028 {
00029 
00030 public:
00031 
00033     typedef std::vector<const HepMC::GenParticle *> GenParticleTrail;
00034 
00036     typedef std::vector<const HepMC::GenVertex *> GenVertexTrail;
00037 
00039     typedef std::vector<TrackingParticleRef> SimParticleTrail;
00040 
00042     typedef std::vector<TrackingVertexRef> SimVertexTrail;
00043 
00045     /* Creates a TrackHistory with association given by pset.
00046 
00047        /param[in] pset with the configuration values
00048     */
00049     TrackHistory(const edm::ParameterSet &);
00050 
00052     void newEvent(const edm::Event &, const edm::EventSetup &);
00053 
00055     /* Set TrackHistory to given depth. Positive values
00056        constrain the number of TrackingVertex visit in the history.
00057        Negatives values set the limit of the iteration over generated
00058        information i.e. (-1 -> status 1 or -2 -> status 2 particles).
00059 
00060        /param[in] depth the history
00061     */
00062     void depth(int d)
00063     {
00064         depth_ = d;
00065     }
00066 
00068     /* Return false when the history cannot be determined upto a given depth.
00069        If not depth is pass to the function no restriction are apply to it.
00070 
00071        /param[in] TrackingParticleRef of a simulated track
00072        /param[in] depth of the track history
00073        /param[out] boolean that is true when history can be determined
00074     */
00075     bool evaluate(TrackingParticleRef tpr)
00076     {
00077         resetTrails(tpr);
00078         return traceSimHistory(tpr, depth_);
00079     }
00080 
00082     /* Return false when the track association is not possible (fake track).
00083 
00084        /param[in] TrackRef to a reco::track
00085        /param[out] boolean that is false when a fake track is detected
00086     */
00087     bool evaluate (reco::TrackBaseRef);
00088 
00090     const TrackingParticleRef & simParticle() const
00091     {
00092         return simParticleTrail_[0];
00093     }
00094 
00096     const HepMC::GenParticle * genParticle() const
00097     {
00098         if ( genParticleTrail_.empty() ) return 0;
00099         return genParticleTrail_[genParticleTrail_.size()-1];
00100     }
00101 
00103     const SimVertexTrail & simVertexTrail() const
00104     {
00105         return simVertexTrail_;
00106     }
00107 
00109     const SimParticleTrail & simParticleTrail() const
00110     {
00111         return simParticleTrail_;
00112     }
00113 
00115     const GenVertexTrail & genVertexTrail() const
00116     {
00117         return genVertexTrail_;
00118     }
00119 
00121     const GenParticleTrail & genParticleTrail() const
00122     {
00123         return genParticleTrail_;
00124     }
00125 
00126 protected:
00127 
00128     int depth_;
00129 
00130     GenVertexTrail genVertexTrail_;
00131     GenParticleTrail genParticleTrail_;
00132     SimVertexTrail simVertexTrail_;
00133     SimParticleTrail simParticleTrail_;
00134 
00135 private:
00136 
00137     bool newEvent_;
00138 
00139     void resetTrails(TrackingParticleRef tpr)
00140     {
00141         // save the initial particle in the trail
00142         simParticleTrail_.clear();
00143         simParticleTrail_.push_back(tpr);
00144 
00145         // clear the remaining trails
00146         simVertexTrail_.clear();
00147         genVertexTrail_.clear();
00148         genParticleTrail_.clear();
00149     }
00150 
00151     void traceGenHistory (const HepMC::GenParticle *);
00152 
00153     bool traceSimHistory (TrackingParticleRef, int);
00154 
00155     bool bestMatchByMaxValue_;
00156 
00157     edm::InputTag trackProducer_;
00158 
00159     edm::InputTag trackingTruth_;
00160 
00161     std::string trackAssociator_;
00162 
00163     reco::RecoToSimCollection association_;
00164 
00165     TrackingParticleRef match ( reco::TrackBaseRef );
00166 };
00167 
00168 #endif

Generated on Tue Jun 9 17:47:58 2009 for CMSSW by  doxygen 1.5.4