Back to home page

Project CMSSW displayed by LXR

 
 

    


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