Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-08-09 23:47:42

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 SimDataFormats_Associations_TTTrackAssociationMap_h
0019 #define SimDataFormats_Associations_TTTrackAssociationMap_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/Track/interface/SimTrack.h"
0033 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0034 #include "SimDataFormats/EncodedEventId/interface/EncodedEventId.h"
0035 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
0036 #include "SimDataFormats/Associations/interface/TTStubAssociationMap.h"
0037 
0038 // Templated aliases
0039 template <typename T>
0040 using MapL1TrackToTP = std::map<TTTrackPtrT<T>, TrackingParticlePtr>;
0041 template <typename T>
0042 using MapTPToVecL1Track = std::map<TrackingParticlePtr, std::vector<TTTrackPtrT<T>>>;
0043 
0044 template <typename T>
0045 class TTTrackAssociationMap {
0046 public:
0047   /// Constructors
0048   TTTrackAssociationMap();
0049 
0050   /// Destructor
0051   ~TTTrackAssociationMap();
0052 
0053   /// Get/set stub <-> truth association maps
0054 
0055   const MapL1TrackToTP<T>& getTTTrackToTrackingParticleMap() const { return trackToTrackingParticleMap_; }
0056   const MapTPToVecL1Track<T>& getTrackingParticleToTTTracksMap() const { return trackingParticleToTrackVectorMap_; }
0057 
0058   void setTTTrackToTrackingParticleMap(const MapL1TrackToTP<T>& aMap) { trackToTrackingParticleMap_ = aMap; }
0059   void setTrackingParticleToTTTracksMap(const MapTPToVecL1Track<T>& aMap) { trackingParticleToTrackVectorMap_ = aMap; }
0060 
0061   /// Set stub <-> truth association object.
0062   void setTTStubAssociationMap(edm::RefProd<TTStubAssociationMap<T>> aStubAssoMap) {
0063     theStubAssociationMap_ = aStubAssoMap;
0064   }
0065 
0066   /// Get principle TP associated to a L1 track. (Non-NULL if isLooselyGenuine() below is true).
0067   /// (N.B. There is no function returning all TP associated to a L1 track).
0068   const TrackingParticlePtr& findTrackingParticlePtr(TTTrackPtrT<T> aTrack) const;
0069 
0070   /// Get all L1 tracks associated to a TP.
0071   /// (Even if the TP just contributes to one cluster in one stub,
0072   /// and even if their are other such TP, it is still listed here).
0073   const std::vector<TTTrackPtrT<T>>& findTTTrackPtrs(TrackingParticlePtr aTrackingParticle) const;
0074 
0075   ///--- Get quality of L1 track based on truth info.
0076   /// (N.B. "genuine" tracks are used for official L1 track efficiency measurements).
0077 
0078   /// Exactly one (i.e. not 0 or >= 2) unique TP contributes to every stub on the track.
0079   /// (even if it is not the principle TP in a stub, or contributes to only one cluster
0080   /// in the stub, it still counts).
0081   /// N.B. If cfg param getAllowOneFalse2SStub() is true, then one incorrect stub in
0082   /// a 2S module is alowed
0083   /// ISSUE: a track with 4 stubs can be accepted if only 3 of its stubs are correct!
0084   /// ISSUE: isLooselyGenuine() must also be true. So if 2 TPs match track, one with
0085   /// an incorrect PS stub, both isGenuine() & isLooselyGenuine() will be false!
0086   bool isGenuine(TTTrackPtrT<T> aTrack) const;
0087   /// Same criteria as for "genuine" track, except that one incorrect stub in either
0088   /// PS or 2S module is allowed, irrespective of value of cfg param getAllowOneFalse2SStub().
0089   bool isLooselyGenuine(TTTrackPtrT<T> aTrack) const;
0090   /// More than one stub on track is "unknown".
0091   bool isUnknown(TTTrackPtrT<T> aTrack) const;
0092   /// Both isLooselyGenuine() & isUnknown() are false.
0093   bool isCombinatoric(TTTrackPtrT<T> aTrack) const;
0094 
0095   // Cfg param allowing one incorrect 2S stub in "genuine" tracks.
0096   void setAllowOneFalse2SStub(bool allowFalse2SStub);
0097   bool getAllowOneFalse2SStub();
0098 
0099 private:
0100   /// Data members
0101   MapL1TrackToTP<T> trackToTrackingParticleMap_;
0102   MapTPToVecL1Track<T> trackingParticleToTrackVectorMap_;
0103   edm::RefProd<TTStubAssociationMap<T>> theStubAssociationMap_;
0104 
0105   bool AllowOneFalse2SStub;
0106 
0107   // Allow functions to return reference to null.
0108   static const TrackingParticlePtr nullTrackingParticlePtr_;
0109   static const std::vector<TTTrackPtr> nullVecTTTrackPtr_;
0110 
0111 };  /// Close class
0112 
0113 /*! \brief   Implementation of methods
0114  *  \details Here, in the header file, the methods which do not depend
0115  *           on the specific type <T> that can fit the template.
0116  *           Other methods, with type-specific features, are implemented
0117  *           in the source file.
0118  */
0119 
0120 // Static constant data members.
0121 template <typename T>
0122 const TrackingParticlePtr TTTrackAssociationMap<T>::nullTrackingParticlePtr_;
0123 template <typename T>
0124 const std::vector<TTTrackPtr> TTTrackAssociationMap<T>::nullVecTTTrackPtr_;
0125 
0126 /// Default Constructor
0127 /// NOTE: to be used with setSomething(...) methods
0128 template <typename T>
0129 TTTrackAssociationMap<T>::TTTrackAssociationMap() {
0130   /// Set default data members
0131 }
0132 
0133 /// Destructor
0134 template <typename T>
0135 TTTrackAssociationMap<T>::~TTTrackAssociationMap() {}
0136 
0137 /// Operations
0138 template <>
0139 const TrackingParticlePtr& TTTrackAssociationMap<Ref_Phase2TrackerDigi_>::findTrackingParticlePtr(
0140     TTTrackPtr aTrack) const;
0141 
0142 template <>
0143 const std::vector<TTTrackPtr>& TTTrackAssociationMap<Ref_Phase2TrackerDigi_>::findTTTrackPtrs(
0144     TrackingParticlePtr aTrackingParticle) const;
0145 
0146 /// MC truth
0147 template <>
0148 bool TTTrackAssociationMap<Ref_Phase2TrackerDigi_>::isLooselyGenuine(TTTrackPtr aTrack) const;
0149 
0150 /// MC truth
0151 template <>
0152 bool TTTrackAssociationMap<Ref_Phase2TrackerDigi_>::isGenuine(TTTrackPtr aTrack) const;
0153 
0154 template <>
0155 bool TTTrackAssociationMap<Ref_Phase2TrackerDigi_>::isCombinatoric(TTTrackPtr aTrack) const;
0156 
0157 template <>
0158 bool TTTrackAssociationMap<Ref_Phase2TrackerDigi_>::isUnknown(TTTrackPtr aTrack) const;
0159 
0160 #endif