CMS 3D CMS Logo

TTClusterAssociationMap.h
Go to the documentation of this file.
1 
13 #ifndef L1_TRACK_TRIGGER_CLUSTER_ASSOCIATION_FORMAT_H
14 #define L1_TRACK_TRIGGER_CLUSTER_ASSOCIATION_FORMAT_H
15 
31 
32 template <typename T>
34 public:
37 
40 
43 
45  std::map<edm::Ref<edmNew::DetSetVector<TTCluster<T> >, TTCluster<T> >, std::vector<edm::Ptr<TrackingParticle> > >
48  }
49  std::map<edm::Ptr<TrackingParticle>, std::vector<edm::Ref<edmNew::DetSetVector<TTCluster<T> >, TTCluster<T> > > >
52  }
53 
57  }
60  aMap) {
62  }
63 
65  std::vector<edm::Ptr<TrackingParticle> > findTrackingParticlePtrs(
69  std::vector<edm::Ref<edmNew::DetSetVector<TTCluster<T> >, TTCluster<T> > > findTTClusterRefs(
70  edm::Ptr<TrackingParticle> aTrackingParticle) const;
71 
76 
77 private:
79  std::map<edm::Ref<edmNew::DetSetVector<TTCluster<T> >, TTCluster<T> >, std::vector<edm::Ptr<TrackingParticle> > >
81  std::map<edm::Ptr<TrackingParticle>, std::vector<edm::Ref<edmNew::DetSetVector<TTCluster<T> >, TTCluster<T> > > >
83 
84  int nclus;
85 
86 };
87 
95 template <typename T>
100  clusterToTrackingParticleVectorMap.clear();
101  trackingParticleToClusterVectorMap.clear();
102  nclus = 0;
103 }
104 
106 template <typename T>
108 
110 template <typename T>
111 std::vector<edm::Ref<edmNew::DetSetVector<TTCluster<T> >, TTCluster<T> > >
113  if (trackingParticleToClusterVectorMap.find(aTrackingParticle) != trackingParticleToClusterVectorMap.end()) {
114  return trackingParticleToClusterVectorMap.find(aTrackingParticle)->second;
115  }
116 
117  std::vector<edm::Ref<edmNew::DetSetVector<TTCluster<T> >, TTCluster<T> > > tempVector;
118  tempVector.clear();
119  return tempVector;
120 }
121 
122 template <typename T>
123 std::vector<edm::Ptr<TrackingParticle> > TTClusterAssociationMap<T>::findTrackingParticlePtrs(
125  if (clusterToTrackingParticleVectorMap.find(aCluster) != clusterToTrackingParticleVectorMap.end()) {
126  return clusterToTrackingParticleVectorMap.find(aCluster)->second;
127  }
128 
129  std::vector<edm::Ptr<TrackingParticle> > tempVector;
130  tempVector.clear();
131  return tempVector;
132 }
133 
146 
155 
156 template <typename T>
159  std::vector<edm::Ptr<TrackingParticle> > theseTrackingParticles = this->findTrackingParticlePtrs(aCluster);
160 
162  if (theseTrackingParticles.empty())
163  return false;
164 
166  unsigned int nullTPs = 0;
167  unsigned int goodDifferentTPs = 0;
168  std::vector<const TrackingParticle*> tpAddressVector;
169 
170  std::vector<float> tp_mom;
171 
172  float tp_tot = 0;
173 
175  for (const auto& tp : theseTrackingParticles) {
177  const edm::Ptr<TrackingParticle>& curTP = tp;
178 
180  if (curTP.isNull()) {
181  // nullTPs++;
182  tp_mom.push_back(0);
183  } else {
184  tp_mom.push_back(curTP.get()->p4().pt());
185  tp_tot += curTP.get()->p4().pt();
186  }
187  }
188 
189  if (tp_tot == 0)
190  return false;
191 
192  for (unsigned int itp = 0; itp < theseTrackingParticles.size(); itp++) {
194  edm::Ptr<TrackingParticle> curTP = theseTrackingParticles.at(itp);
195 
197  if (tp_mom.at(itp) <= 0.01 * tp_tot) {
198  nullTPs++;
199  } else {
202  tpAddressVector.push_back(curTP.get());
203  }
204  }
205 
207  std::sort(tpAddressVector.begin(), tpAddressVector.end());
208  tpAddressVector.erase(std::unique(tpAddressVector.begin(), tpAddressVector.end()), tpAddressVector.end());
209  goodDifferentTPs = tpAddressVector.size();
210 
211  return (goodDifferentTPs == 1);
212 }
213 
214 template <typename T>
217  std::vector<edm::Ptr<TrackingParticle> > theseTrackingParticles = this->findTrackingParticlePtrs(aCluster);
218 
220  if (theseTrackingParticles.empty())
221  return true;
222 
224  unsigned int goodDifferentTPs = 0;
225  std::vector<const TrackingParticle*> tpAddressVector;
226 
228  for (unsigned int itp = 0; itp < theseTrackingParticles.size(); itp++) {
230  edm::Ptr<TrackingParticle> curTP = theseTrackingParticles.at(itp);
231 
233  if (!curTP.isNull()) {
236  tpAddressVector.push_back(curTP.get());
237  }
238  }
239 
241  std::sort(tpAddressVector.begin(), tpAddressVector.end());
242  tpAddressVector.erase(std::unique(tpAddressVector.begin(), tpAddressVector.end()), tpAddressVector.end());
243  goodDifferentTPs = tpAddressVector.size();
244 
246  return (goodDifferentTPs == 0);
247 }
248 
249 template <typename T>
253  std::vector<edm::Ptr<TrackingParticle> > theseTrackingParticles = this->findTrackingParticlePtrs(aCluster);
254 
256  if (theseTrackingParticles.empty())
257  return false;
258 
259  bool genuineClu = this->isGenuine(aCluster);
260  bool unknownClu = this->isUnknown(aCluster);
261 
262  if (genuineClu || unknownClu)
263  return false;
264 
265  return true;
266 
268  unsigned int nullTPs = 0;
269  unsigned int goodDifferentTPs = 0;
270  std::vector<const TrackingParticle*> tpAddressVector;
271 
273  for (unsigned int itp = 0; itp < theseTrackingParticles.size(); itp++) {
275  edm::Ptr<TrackingParticle> curTP = theseTrackingParticles.at(itp);
276 
278  if (curTP.isNull()) {
279  nullTPs++;
280  } else {
283  tpAddressVector.push_back(curTP.get());
284  }
285  }
286 
288  std::sort(tpAddressVector.begin(), tpAddressVector.end());
289  tpAddressVector.erase(std::unique(tpAddressVector.begin(), tpAddressVector.end()), tpAddressVector.end());
290  goodDifferentTPs = tpAddressVector.size();
291 
294  //return ( ( nullTPs == 0 && goodDifferentTPs > 1 ) || ( nullTPs > 0 && goodDifferentTPs > 0 ) );
295  return (goodDifferentTPs > 1);
296 }
297 
298 template <typename T>
301  if (this->isGenuine(aCluster)) {
302  return this->findTrackingParticlePtrs(aCluster).at(0);
303  }
304 
306  return *temp;
307 }
308 
309 #endif
TTClusterAssociationMap::findTTClusterRefs
std::vector< edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > > findTTClusterRefs(edm::Ptr< TrackingParticle > aTrackingParticle) const
Operations.
Definition: TTClusterAssociationMap.h:112
TTClusterAssociationMap::setTrackingParticleToTTClustersMap
void setTrackingParticleToTTClustersMap(std::map< edm::Ptr< TrackingParticle >, std::vector< edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > > > aMap)
Definition: TTClusterAssociationMap.h:58
TTClusterAssociationMap
NOTE: this is needed even if it seems not.
Definition: TTClusterAssociationMap.h:33
TTClusterAssociationMap::isGenuine
bool isGenuine(edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > aCluster) const
MC Truth methods.
Definition: TTClusterAssociationMap.h:157
TrackingParticle::p4
const LorentzVector & p4() const
Four-momentum Lorentz vector. Note this is taken from the first SimTrack only.
Definition: TrackingParticle.h:103
TTClusterAssociationMap::isUnknown
bool isUnknown(edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > aCluster) const
Definition: TTClusterAssociationMap.h:215
edm::Ptr::get
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:139
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
TTClusterAssociationMap::getTTClusterToTrackingParticlesMap
std::map< edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > >, std::vector< edm::Ptr< TrackingParticle > > > getTTClusterToTrackingParticlesMap() const
Maps.
Definition: TTClusterAssociationMap.h:46
edm::Ref
Definition: AssociativeIterator.h:58
TTClusterAssociationMap::setTTClusterToTrackingParticlesMap
void setTTClusterToTrackingParticlesMap(std::map< edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > >, std::vector< edm::Ptr< TrackingParticle > > > aMap)
Definition: TTClusterAssociationMap.h:54
TTClusterAssociationMap::getTrackingParticleToTTClustersMap
std::map< edm::Ptr< TrackingParticle >, std::vector< edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > > > getTrackingParticleToTTClustersMap() const
Definition: TTClusterAssociationMap.h:50
TTClusterAssociationMap::findTrackingParticlePtrs
std::vector< edm::Ptr< TrackingParticle > > findTrackingParticlePtrs(edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > aCluster) const
Operations.
Definition: TTClusterAssociationMap.h:123
TTClusterAssociationMap::clusterToTrackingParticleVectorMap
std::map< edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > >, std::vector< edm::Ptr< TrackingParticle > > > clusterToTrackingParticleVectorMap
Data members.
Definition: TTClusterAssociationMap.h:80
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
Phase2TrackerDigi.h
TTClusterAssociationMap::TTClusterAssociationMap
TTClusterAssociationMap()
Constructors.
Definition: TTClusterAssociationMap.h:98
Ptr.h
MeasurementPoint.h
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
DetSetVector.h
TTCluster.h
edm::Ptr< TrackingParticle >
TrackingParticle.h
TTClusterAssociationMap::trackingParticleToClusterVectorMap
std::map< edm::Ptr< TrackingParticle >, std::vector< edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > > > trackingParticleToClusterVectorMap
Definition: TTClusterAssociationMap.h:82
edmNew::DetSetVector
Definition: DetSetNew.h:13
Ref.h
tier0.unique
def unique(seq, keepstr=True)
Definition: tier0.py:24
DetId.h
TTClusterAssociationMap::nclus
int nclus
Definition: TTClusterAssociationMap.h:84
TTClusterAssociationMap::isCombinatoric
bool isCombinatoric(edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > aCluster) const
Definition: TTClusterAssociationMap.h:250
TTClusterAssociationMap::findTrackingParticlePtr
edm::Ptr< TrackingParticle > findTrackingParticlePtr(edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > aCluster) const
Definition: TTClusterAssociationMap.h:299
TTCluster
NOTE: this is needed even if it seems not.
Definition: TTCluster.h:27
TTClusterAssociationMap::~TTClusterAssociationMap
~TTClusterAssociationMap()
Destructor.
Definition: TTClusterAssociationMap.h:107
DetSet.h
genParticles_cff.map
map
Definition: genParticles_cff.py:11
SimTrack.h
GlobalPoint.h
SimTrackContainer.h
DetSetVectorNew.h
edm::Ptr::isNull
bool isNull() const
Checks for null.
Definition: Ptr.h:142
EncodedEventId.h