Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:07

0001 /*! \class   TTTrackAssociationMap
0002  *  \brief   Stores association of Truth Particles (TP) to L1 Track-Trigger Tracks
0003  * 
0004  *  \details Contains two maps. One associates each L1 track its principle TP.
0005  *           (i.e. Not to all TP that contributed to it). 
0006  *           The other associates each TP to a vector of all L1 tracks 
0007  *           it contributed to. The two maps are therefore not
0008  *           forward-backward symmetric.
0009  *
0010  *           (The template structure is used to accomodate types
0011  *           other than PixelDigis, in case they are needed in future). 
0012  *
0013  *  \author Nicola Pozzobon
0014  *  \date   2013, Jul 19
0015  *  (tidy up: Ian Tomalin, 2020)
0016  */
0017 
0018 #ifndef L1_TRACK_TRIGGER_TRACK_ASSOCIATION_FORMAT_H
0019 #define L1_TRACK_TRIGGER_TRACK_ASSOCIATION_FORMAT_H
0020 
0021 #include "DataFormats/Common/interface/Ref.h"
0022 #include "DataFormats/Common/interface/Ptr.h"
0023 #include "DataFormats/L1TrackTrigger/interface/TTTypes.h"
0024 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticleFwd.h"
0025 #include "DataFormats/Common/interface/DetSet.h"
0026 #include "DataFormats/Common/interface/DetSetVector.h"
0027 #include "DataFormats/Common/interface/DetSetVectorNew.h"
0028 #include "DataFormats/DetId/interface/DetId.h"
0029 #include "DataFormats/Phase2TrackerDigi/interface/Phase2TrackerDigi.h"
0030 #include "DataFormats/GeometryCommonDetAlgo/interface/MeasurementPoint.h"
0031 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"  /// NOTE: this is needed even if it seems not
0032 #include "SimDataFormats/TrackerDigiSimLink/interface/PixelDigiSimLink.h"
0033 #include "SimDataFormats/Track/interface/SimTrack.h"
0034 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0035 #include "SimDataFormats/EncodedEventId/interface/EncodedEventId.h"
0036 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
0037 #include "SimTracker/TrackTriggerAssociation/interface/TTStubAssociationMap.h"
0038 
0039 // Templated aliases
0040 template <typename T>
0041 using MapL1TrackToTP = std::map<TTTrackPtrT<T>, TrackingParticlePtr>;
0042 template <typename T>
0043 using MapTPToVecL1Track = std::map<TrackingParticlePtr, std::vector<TTTrackPtrT<T>>>;
0044 
0045 template <typename T>
0046 class TTTrackAssociationMap {
0047 public:
0048   /// Constructors
0049   TTTrackAssociationMap();
0050 
0051   /// Destructor
0052   ~TTTrackAssociationMap();
0053 
0054   /// Get/set stub <-> truth association maps
0055 
0056   const MapL1TrackToTP<T>& getTTTrackToTrackingParticleMap() const { return trackToTrackingParticleMap_; }
0057   const MapTPToVecL1Track<T>& getTrackingParticleToTTTracksMap() const { return trackingParticleToTrackVectorMap_; }
0058 
0059   void setTTTrackToTrackingParticleMap(const MapL1TrackToTP<T>& aMap) { trackToTrackingParticleMap_ = aMap; }
0060   void setTrackingParticleToTTTracksMap(const MapTPToVecL1Track<T>& aMap) { trackingParticleToTrackVectorMap_ = aMap; }
0061 
0062   /// Set stub <-> truth association object.
0063   void setTTStubAssociationMap(edm::RefProd<TTStubAssociationMap<T>> aStubAssoMap) {
0064     theStubAssociationMap_ = aStubAssoMap;
0065   }
0066 
0067   /// Get principle TP associated to a L1 track. (Non-NULL if isLooselyGenuine() below is true).
0068   /// (N.B. There is no function returning all TP associated to a L1 track).
0069   const TrackingParticlePtr& findTrackingParticlePtr(TTTrackPtrT<T> aTrack) const;
0070 
0071   /// Get all L1 tracks associated to a TP.
0072   /// (Even if the TP just contributes to one cluster in one stub,
0073   /// and even if their are other such TP, it is still listed here).
0074   const std::vector<TTTrackPtrT<T>>& findTTTrackPtrs(TrackingParticlePtr aTrackingParticle) const;
0075 
0076   ///--- Get quality of L1 track based on truth info.
0077   /// (N.B. "genuine" tracks are used for official L1 track efficiency measurements).
0078 
0079   /// Exactly one (i.e. not 0 or >= 2) unique TP contributes to every stub on the track.
0080   /// (even if it is not the principle TP in a stub, or contributes to only one cluster
0081   /// in the stub, it still counts).
0082   /// N.B. If cfg param getAllowOneFalse2SStub() is true, then one incorrect stub in
0083   /// a 2S module is alowed
0084   /// ISSUE: a track with 4 stubs can be accepted if only 3 of its stubs are correct!
0085   /// ISSUE: isLooselyGenuine() must also be true. So if 2 TPs match track, one with
0086   /// an incorrect PS stub, both isGenuine() & isLooselyGenuine() will be false!
0087   bool isGenuine(TTTrackPtrT<T> aTrack) const;
0088   /// Same criteria as for "genuine" track, except that one incorrect stub in either
0089   /// PS or 2S module is allowed, irrespective of value of cfg param getAllowOneFalse2SStub().
0090   bool isLooselyGenuine(TTTrackPtrT<T> aTrack) const;
0091   /// More than one stub on track is "unknown".
0092   bool isUnknown(TTTrackPtrT<T> aTrack) const;
0093   /// Both isLooselyGenuine() & isUnknown() are false.
0094   bool isCombinatoric(TTTrackPtrT<T> aTrack) const;
0095 
0096   // Cfg param allowing one incorrect 2S stub in "genuine" tracks.
0097   void setAllowOneFalse2SStub(bool allowFalse2SStub);
0098   bool getAllowOneFalse2SStub();
0099 
0100 private:
0101   /// Data members
0102   MapL1TrackToTP<T> trackToTrackingParticleMap_;
0103   MapTPToVecL1Track<T> trackingParticleToTrackVectorMap_;
0104   edm::RefProd<TTStubAssociationMap<T>> theStubAssociationMap_;
0105 
0106   bool AllowOneFalse2SStub;
0107 
0108   // Allow functions to return reference to null.
0109   static const TrackingParticlePtr nullTrackingParticlePtr_;
0110   static const std::vector<TTTrackPtr> nullVecTTTrackPtr_;
0111 
0112 };  /// Close class
0113 
0114 /*! \brief   Implementation of methods
0115  *  \details Here, in the header file, the methods which do not depend
0116  *           on the specific type <T> that can fit the template.
0117  *           Other methods, with type-specific features, are implemented
0118  *           in the source file.
0119  */
0120 
0121 // Static constant data members.
0122 template <typename T>
0123 const TrackingParticlePtr TTTrackAssociationMap<T>::nullTrackingParticlePtr_;
0124 template <typename T>
0125 const std::vector<TTTrackPtr> TTTrackAssociationMap<T>::nullVecTTTrackPtr_;
0126 
0127 /// Default Constructor
0128 /// NOTE: to be used with setSomething(...) methods
0129 template <typename T>
0130 TTTrackAssociationMap<T>::TTTrackAssociationMap() {
0131   /// Set default data members
0132 }
0133 
0134 /// Destructor
0135 template <typename T>
0136 TTTrackAssociationMap<T>::~TTTrackAssociationMap() {}
0137 
0138 /// Operations
0139 template <>
0140 const TrackingParticlePtr& TTTrackAssociationMap<Ref_Phase2TrackerDigi_>::findTrackingParticlePtr(
0141     TTTrackPtr aTrack) const;
0142 
0143 template <>
0144 const std::vector<TTTrackPtr>& TTTrackAssociationMap<Ref_Phase2TrackerDigi_>::findTTTrackPtrs(
0145     TrackingParticlePtr aTrackingParticle) const;
0146 
0147 /// MC truth
0148 template <>
0149 bool TTTrackAssociationMap<Ref_Phase2TrackerDigi_>::isLooselyGenuine(TTTrackPtr aTrack) const;
0150 
0151 /// MC truth
0152 template <>
0153 bool TTTrackAssociationMap<Ref_Phase2TrackerDigi_>::isGenuine(TTTrackPtr aTrack) const;
0154 
0155 template <>
0156 bool TTTrackAssociationMap<Ref_Phase2TrackerDigi_>::isCombinatoric(TTTrackPtr aTrack) const;
0157 
0158 template <>
0159 bool TTTrackAssociationMap<Ref_Phase2TrackerDigi_>::isUnknown(TTTrackPtr aTrack) const;
0160 
0161 #endif