Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-02-05 23:51:51

0001 #ifndef TrackHistory_h
0002 #define TrackHistory_h
0003 
0004 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0005 
0006 #include "FWCore/Framework/interface/ConsumesCollector.h"
0007 #include "FWCore/Framework/interface/ESHandle.h"
0008 #include "FWCore/Framework/interface/Event.h"
0009 #include "FWCore/Framework/interface/EventSetup.h"
0010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0012 
0013 #include "SimDataFormats/Associations/interface/TrackToTrackingParticleAssociator.h"
0014 #include "SimTracker/TrackHistory/interface/HistoryBase.h"
0015 #include "SimTracker/TrackHistory/interface/Utils.h"
0016 
0017 //! This class traces the simulated and generated history of a given track.
0018 class TrackHistory : public HistoryBase {
0019 public:
0020   //! Constructor by pset.
0021   /* Creates a TrackHistory with association given by pset.
0022 
0023      /param[in] pset with the configuration values
0024   */
0025   TrackHistory(const edm::ParameterSet &, edm::ConsumesCollector &&);
0026 
0027   //! Pre-process event information (for accessing reconstruction information)
0028   void newEvent(const edm::Event &, const edm::EventSetup &);
0029 
0030   //! Evaluate track history using a TrackingParticleRef.
0031   /* Return false when the history cannot be determined upto a given depth.
0032      If not depth is pass to the function no restriction are apply to it.
0033 
0034      /param[in] TrackingParticleRef of a simulated track
0035      /param[in] depth of the track history
0036      /param[out] boolean that is true when history can be determined
0037   */
0038   bool evaluate(TrackingParticleRef tpr) {
0039     if (enableSimToReco_) {
0040       std::pair<reco::TrackBaseRef, double> result = match(tpr, simToReco_, bestMatchByMaxValue_);
0041       recotrack_ = result.first;
0042       quality_ = result.second;
0043     }
0044     return HistoryBase::evaluate(tpr);
0045   }
0046 
0047   //! Evaluate reco::Track history using a given association.
0048   /* Return false when the track association is not possible (fake track).
0049 
0050      /param[in] TrackRef to a reco::track
0051      /param[out] boolean that is false when a fake track is detected
0052   */
0053   bool evaluate(reco::TrackBaseRef);
0054 
0055   //! Return a reference to the reconstructed track.
0056   const reco::TrackBaseRef &recoTrack() const { return recotrack_; }
0057 
0058   // return the TrackingParticle to which the Track was matched
0059   const std::pair<TrackingParticleRef, double> getMatchedTrackingParticle() const {
0060     std::pair<TrackingParticleRef, double> result;
0061     result.first = trackingParticle_;
0062     result.second = quality_;
0063 
0064     return result;
0065   }
0066 
0067   double quality() const { return quality_; }
0068 
0069   static void fillPSetDescription(edm::ParameterSetDescription &desc);
0070 
0071 private:
0072   bool newEvent_;
0073 
0074   bool bestMatchByMaxValue_;
0075 
0076   bool enableRecoToSim_, enableSimToReco_;
0077 
0078   double quality_;
0079 
0080   edm::InputTag trackProducer_;
0081 
0082   edm::InputTag trackingTruth_;
0083 
0084   edm::InputTag trackAssociator_;
0085 
0086   reco::TrackBaseRef recotrack_;
0087 
0088   TrackingParticleRef trackingParticle_;
0089 
0090   reco::RecoToSimCollection recoToSim_;
0091 
0092   reco::SimToRecoCollection simToReco_;
0093 };
0094 
0095 #endif