Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:56:36

0001 #ifndef __L1Trigger_VertexFinder_L1TrackTruthMatched_h__
0002 #define __L1Trigger_VertexFinder_L1TrackTruthMatched_h__
0003 
0004 #include <vector>
0005 
0006 #include "DataFormats/Common/interface/Ptr.h"
0007 #include "DataFormats/L1TrackTrigger/interface/TTTypes.h"
0008 #include "L1Trigger/VertexFinder/interface/L1Track.h"
0009 #include "L1Trigger/VertexFinder/interface/TP.h"
0010 // TTStubAssociationMap.h forgets to two needed files, so must include them here ...
0011 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
0012 #include "SimTracker/TrackTriggerAssociation/interface/TTTrackAssociationMap.h"
0013 
0014 class TrackerGeometry;
0015 class TrackerTopology;
0016 
0017 namespace l1tVertexFinder {
0018 
0019   class AnalysisSettings;
0020   class TP;
0021 
0022   typedef TTTrackAssociationMap<Ref_Phase2TrackerDigi_> TTTrackAssMap;
0023 
0024   //! Simple wrapper class for TTTrack, with match to a tracking particle
0025   class L1TrackTruthMatched : public L1Track {
0026   public:
0027     L1TrackTruthMatched(const edm::Ptr<TTTrack<Ref_Phase2TrackerDigi_>>& aTrack,
0028                         const std::map<edm::Ptr<TrackingParticle>, edm::RefToBase<TrackingParticle>>& tpPtrToRefMap,
0029                         const edm::ValueMap<TP>& tpValueMap,
0030                         edm::Handle<TTTrackAssMap> mcTruthTTTrackHandle)
0031         : L1Track(aTrack), matchedTPidx_(-1) {
0032       auto mcTruthTP = mcTruthTTTrackHandle->findTrackingParticlePtr(aTrack);
0033       if (!mcTruthTP.isNull()) {
0034         auto tpTranslation = tpPtrToRefMap.find(mcTruthTP);
0035         if (tpTranslation != tpPtrToRefMap.end()) {
0036           matchedTP_ = &tpValueMap[tpTranslation->second];
0037           matchedTPidx_ = std::distance(tpPtrToRefMap.begin(), tpTranslation);
0038         } else {
0039           matchedTP_ = nullptr;
0040         }
0041       } else {
0042         matchedTP_ = nullptr;
0043       }
0044     }
0045     ~L1TrackTruthMatched() {}
0046 
0047     // Get best matching tracking particle (=nullptr if none).
0048     const TP* getMatchedTP() const { return matchedTP_; }
0049 
0050     // Get the index of the matched TP in the map of TP particles with the use flag set
0051     const int getMatchedTPidx() const { return matchedTPidx_; }
0052 
0053   private:
0054     const TP* matchedTP_;
0055     int matchedTPidx_;
0056   };
0057 
0058 }  // namespace l1tVertexFinder
0059 
0060 #endif