Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-06-03 00:12:41

0001 #ifndef SimTracker_TrackTriggerAssociation_StubAssociation_h
0002 #define SimTracker_TrackTriggerAssociation_StubAssociation_h
0003 
0004 #include "DataFormats/Common/interface/Ptr.h"
0005 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
0006 #include "L1Trigger/TrackTrigger/interface/Setup.h"
0007 
0008 #include <vector>
0009 #include <map>
0010 
0011 namespace tt {
0012 
0013   typedef edm::Ptr<TrackingParticle> TPPtr;
0014 
0015   /*! \class  tt::StubAssociation
0016    *  \brief  Class to associate reconstrucable TrackingParticles with TTStubs and vice versa.
0017    *          It may associate multiple TPs with a TTStub and can therefore be used to associate
0018    *          TTTracks with TrackingParticles.
0019    *  \author Thomas Schuh
0020    *  \date   2020, Apr
0021    */
0022   class StubAssociation {
0023   public:
0024     // configuration
0025     struct Config {
0026       int minLayersGood_;
0027       int minLayersGoodPS_;
0028       int maxLayersBad_;
0029       int maxLayersBadPS_;
0030     };
0031     StubAssociation() { setup_ = nullptr; }
0032     StubAssociation(const Config& iConfig, const Setup* setup);
0033     ~StubAssociation() = default;
0034     // insert a TPPtr and its associated collection of TTstubRefs into the underlayering maps
0035     void insert(const TPPtr& tpPtr, const std::vector<TTStubRef>& ttSTubRefs);
0036     // returns map containing TTStubRef and their associated collection of TPPtrs
0037     const std::map<TTStubRef, std::vector<TPPtr>>& getTTStubToTrackingParticlesMap() const {
0038       return mapTTStubRefsTPPtrs_;
0039     }
0040     // returns map containing TPPtr and their associated collection of TTStubRefs
0041     const std::map<TPPtr, std::vector<TTStubRef>>& getTrackingParticleToTTStubsMap() const {
0042       return mapTPPtrsTTStubRefs_;
0043     }
0044     // returns collection of TPPtrs associated to given TTstubRef
0045     std::vector<TPPtr> findTrackingParticlePtrs(const TTStubRef& ttStubRef) const;
0046     // returns collection of TTStubRefs associated to given TPPtr
0047     std::vector<TTStubRef> findTTStubRefs(const TPPtr& tpPtr) const;
0048     // total number of stubs associated with TPs
0049     int numStubs() const { return mapTTStubRefsTPPtrs_.size(); };
0050     // total number of TPs associated with stubs
0051     int numTPs() const { return mapTPPtrsTTStubRefs_.size(); };
0052     // Get all TPs that are matched to these stubs in at least 'tpMinLayers' layers and 'tpMinLayersPS' ps layers
0053     std::vector<TPPtr> associate(const std::vector<TTStubRef>& ttStubRefs) const;
0054     // Get all TPs that are matched to these stubs in at least 'tpMinLayers' layers and 'tpMinLayersPS' ps layers with not more then 'tpMaxBadStubs2S' not associated 2S stubs and not more then 'tpMaxBadStubsPS' associated PS stubs
0055     std::vector<TPPtr> associateFinal(const std::vector<TTStubRef>& ttStubRefs) const;
0056 
0057   private:
0058     // stores, calculates and provides run-time constants
0059     const Setup* setup_;
0060     // required number of layers a found track has to have in common with a TP to consider it matched
0061     int minLayersGood_;
0062     // required number of ps layers a found track has to have in common with a TP to consider it matched
0063     int minLayersGoodPS_;
0064     // max number of unassociated 2S stubs allowed to still associate TTTrack with TP
0065     int maxLayersBad_;
0066     // max number of unassociated PS stubs allowed to still associate TTTrack with TP
0067     int maxLayersBadPS_;
0068     // map containing TTStubRef and their associated collection of TPPtrs
0069     std::map<TTStubRef, std::vector<TPPtr>> mapTTStubRefsTPPtrs_;
0070     // map containing TPPtr and their associated collection of TTStubRefs
0071     std::map<TPPtr, std::vector<TTStubRef>> mapTPPtrsTTStubRefs_;
0072     // empty container of TPPtr
0073     const std::vector<TPPtr> emptyTPPtrs_;
0074     // empty container of TTStubRef
0075     const std::vector<TTStubRef> emptyTTStubRefs_;
0076   };
0077 
0078 }  // namespace tt
0079 
0080 #endif