File indexing completed on 2024-08-09 23:47:42
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #ifndef SimDataFormats_Associations_TTStubAssociationMap_h
0019 #define SimDataFormats_Associations_TTStubAssociationMap_h
0020
0021 #include "DataFormats/Common/interface/Ref.h"
0022 #include "DataFormats/Common/interface/RefProd.h"
0023 #include "DataFormats/Common/interface/Ptr.h"
0024 #include "DataFormats/L1TrackTrigger/interface/TTTypes.h"
0025 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticleFwd.h"
0026 #include "DataFormats/Common/interface/DetSet.h"
0027 #include "DataFormats/Common/interface/DetSetVector.h"
0028 #include "DataFormats/Common/interface/DetSetVectorNew.h"
0029 #include "DataFormats/DetId/interface/DetId.h"
0030 #include "DataFormats/Phase2TrackerDigi/interface/Phase2TrackerDigi.h"
0031 #include "DataFormats/GeometryCommonDetAlgo/interface/MeasurementPoint.h"
0032 #include "DataFormats/GeometryVector/interface/GlobalPoint.h" /// NOTE: this is needed even if it seems not
0033 #include "DataFormats/L1TrackTrigger/interface/TTStub.h"
0034 #include "SimDataFormats/Track/interface/SimTrack.h"
0035 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0036 #include "SimDataFormats/EncodedEventId/interface/EncodedEventId.h"
0037 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
0038 #include "SimDataFormats/Associations/interface/TTClusterAssociationMap.h"
0039
0040
0041 template <typename T>
0042 using MapStubToTP = std::map<TTStubRefT<T>, TrackingParticlePtr>;
0043 template <typename T>
0044 using MapTPToVecStub = std::map<TrackingParticlePtr, std::vector<TTStubRefT<T>>>;
0045
0046 template <typename T>
0047 class TTStubAssociationMap {
0048 public:
0049
0050 TTStubAssociationMap();
0051
0052
0053 ~TTStubAssociationMap();
0054
0055
0056
0057 const MapStubToTP<T>& getTTStubToTrackingParticleMap() const { return stubToTrackingParticleMap_; }
0058 const MapTPToVecStub<T>& getTrackingParticleToTTStubsMap() const { return trackingParticleToStubVectorMap_; }
0059
0060 void setTTStubToTrackingParticleMap(const MapStubToTP<T>& aMap) { stubToTrackingParticleMap_ = aMap; }
0061 void setTrackingParticleToTTStubsMap(const MapTPToVecStub<T>& aMap) { trackingParticleToStubVectorMap_ = aMap; }
0062
0063
0064 void setTTClusterAssociationMap(edm::RefProd<TTClusterAssociationMap<T>> aCluAssoMap) {
0065 theClusterAssociationMap_ = aCluAssoMap;
0066 }
0067
0068
0069
0070
0071
0072 const TrackingParticlePtr& findTrackingParticlePtr(TTStubRefT<T> aStub) const;
0073
0074
0075
0076
0077 const std::vector<TTStubRefT<T>>& findTTStubRefs(TrackingParticlePtr aTrackingParticle) const;
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095 bool isGenuine(TTStubRefT<T> aStub) const;
0096 bool isCombinatoric(TTStubRefT<T> aStub) const;
0097 bool isUnknown(TTStubRefT<T> aStub) const;
0098
0099 private:
0100
0101 MapStubToTP<T> stubToTrackingParticleMap_;
0102 MapTPToVecStub<T> trackingParticleToStubVectorMap_;
0103 edm::RefProd<TTClusterAssociationMap<T>> theClusterAssociationMap_;
0104
0105
0106 static const TrackingParticlePtr nullTrackingParticlePtr_;
0107 static const std::vector<TTStubRefT<T>> nullVecStubRef_;
0108
0109 };
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119 template <typename T>
0120 const TrackingParticlePtr TTStubAssociationMap<T>::nullTrackingParticlePtr_;
0121 template <typename T>
0122 const std::vector<TTStubRefT<T>> TTStubAssociationMap<T>::nullVecStubRef_;
0123
0124
0125
0126 template <typename T>
0127 TTStubAssociationMap<T>::TTStubAssociationMap() {
0128
0129 }
0130
0131
0132 template <typename T>
0133 TTStubAssociationMap<T>::~TTStubAssociationMap() {}
0134
0135
0136 template <typename T>
0137 const TrackingParticlePtr& TTStubAssociationMap<T>::findTrackingParticlePtr(TTStubRefT<T> aStub) const {
0138 if (stubToTrackingParticleMap_.find(aStub) != stubToTrackingParticleMap_.end()) {
0139 return stubToTrackingParticleMap_.find(aStub)->second;
0140 } else {
0141 return nullTrackingParticlePtr_;
0142 }
0143 }
0144
0145 template <typename T>
0146 const std::vector<TTStubRefT<T>>& TTStubAssociationMap<T>::findTTStubRefs(TrackingParticlePtr aTrackingParticle) const {
0147 if (trackingParticleToStubVectorMap_.find(aTrackingParticle) != trackingParticleToStubVectorMap_.end()) {
0148 return trackingParticleToStubVectorMap_.find(aTrackingParticle)->second;
0149 } else {
0150 return nullVecStubRef_;
0151 }
0152 }
0153
0154
0155 template <typename T>
0156 bool TTStubAssociationMap<T>::isGenuine(TTStubRefT<T> aStub) const {
0157
0158 if ((this->findTrackingParticlePtr(aStub)).isNull())
0159 return false;
0160
0161 return true;
0162 }
0163
0164 template <typename T>
0165 bool TTStubAssociationMap<T>::isCombinatoric(TTStubRefT<T> aStub) const {
0166
0167 if (this->isGenuine(aStub))
0168 return false;
0169
0170 if (this->isUnknown(aStub))
0171 return false;
0172
0173 return true;
0174 }
0175
0176 template <typename T>
0177 bool TTStubAssociationMap<T>::isUnknown(TTStubRefT<T> aStub) const {
0178
0179
0180
0181 if (theClusterAssociationMap_.isNull()) {
0182 return true;
0183 }
0184
0185 if (theClusterAssociationMap_->isUnknown(aStub->clusterRef(0)) &&
0186 theClusterAssociationMap_->isUnknown(aStub->clusterRef(1)))
0187 return true;
0188
0189 return false;
0190 }
0191
0192 #endif