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 {
35  public:
38 
41 
44 
46  std::map< edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > >, std::vector< edm::Ptr< TrackingParticle > > > getTTClusterToTrackingParticlesMap() const
48  std::map< edm::Ptr< TrackingParticle >, std::vector< edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > > > getTrackingParticleToTTClustersMap() const
50 
51  void setTTClusterToTrackingParticlesMap( std::map< edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > >, std::vector< edm::Ptr< TrackingParticle > > > aMap )
53  void setTrackingParticleToTTClustersMap( std::map< edm::Ptr< TrackingParticle >, std::vector< edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > > > aMap )
55 
57  std::vector< edm::Ptr< TrackingParticle > > findTrackingParticlePtrs( edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > aCluster ) const;
58  edm::Ptr< TrackingParticle > findTrackingParticlePtr( edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > aCluster ) const;
59  std::vector< edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > > findTTClusterRefs( edm::Ptr< TrackingParticle > aTrackingParticle ) const;
60 
62  bool isGenuine( edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > aCluster ) const;
63  bool isCombinatoric( edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > aCluster ) const;
64  bool isUnknown( edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > aCluster ) const;
65 
66  private:
68  std::map< edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > >, std::vector< edm::Ptr< TrackingParticle > > > clusterToTrackingParticleVectorMap;
69  std::map< edm::Ptr< TrackingParticle >, std::vector< edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > > > trackingParticleToClusterVectorMap;
70 
71  int nclus;
72 
73 };
74 
82 template< typename T >
86 {
90  nclus=0;
91 }
92 
94 template< typename T >
96 
98 template< typename T >
99 std::vector< edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > > TTClusterAssociationMap< T >::findTTClusterRefs( edm::Ptr< TrackingParticle > aTrackingParticle ) const
100 {
101  if ( trackingParticleToClusterVectorMap.find( aTrackingParticle ) != trackingParticleToClusterVectorMap.end() )
102  {
103  return trackingParticleToClusterVectorMap.find( aTrackingParticle )->second;
104  }
105 
106  std::vector< edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > > tempVector;
107  tempVector.clear();
108  return tempVector;
109 }
110 
111 template< typename T >
113 {
115  {
116  return clusterToTrackingParticleVectorMap.find( aCluster )->second;
117  }
118 
119  std::vector< edm::Ptr< TrackingParticle > > tempVector;
120  tempVector.clear();
121  return tempVector;
122 }
123 
124 
137 
146 
147 template< typename T >
149 {
150 
151 
153  std::vector< edm::Ptr< TrackingParticle > > theseTrackingParticles = this->findTrackingParticlePtrs( aCluster );
154 
155 
156 
158  if ( theseTrackingParticles.empty() )
159  return false;
160 
162  unsigned int nullTPs = 0;
163  unsigned int goodDifferentTPs = 0;
164  std::vector< const TrackingParticle* > tpAddressVector;
165 
166  std::vector<float> tp_mom;
167 
168  float tp_tot=0;
169 
171  for ( const auto& tp : theseTrackingParticles )
172  {
174  edm::Ptr< TrackingParticle > curTP = tp;
175 
177  if ( curTP.isNull() )
178  {
179  // nullTPs++;
180  tp_mom.push_back(0);
181  }
182  else
183  {
184  tp_mom.push_back(curTP.get()->p4().pt());
185  tp_tot+=curTP.get()->p4().pt();
186  }
187  }
188 
189  if (tp_tot==0) return false;
190 
191  for ( unsigned int itp = 0; itp < theseTrackingParticles.size(); itp++ )
192  {
194  edm::Ptr< TrackingParticle > curTP = theseTrackingParticles.at(itp);
195 
197  if ( tp_mom.at(itp) <= 0.01*tp_tot)
198  {
199  nullTPs++;
200  }
201  else
202  {
205  tpAddressVector.push_back( curTP.get() );
206  }
207  }
208 
209 
211  std::sort( tpAddressVector.begin(), tpAddressVector.end() );
212  tpAddressVector.erase( std::unique( tpAddressVector.begin(), tpAddressVector.end() ), tpAddressVector.end() );
213  goodDifferentTPs = tpAddressVector.size();
214 
215  return ( goodDifferentTPs == 1 );
216 }
217 
218 template< typename T >
220 {
222  std::vector< edm::Ptr< TrackingParticle > > theseTrackingParticles = this->findTrackingParticlePtrs( aCluster );
223 
225  if ( theseTrackingParticles.empty() )
226  return true;
227 
229  unsigned int goodDifferentTPs = 0;
230  std::vector< const TrackingParticle* > tpAddressVector;
231 
233  for ( unsigned int itp = 0; itp < theseTrackingParticles.size(); itp++ )
234  {
236  edm::Ptr< TrackingParticle > curTP = theseTrackingParticles.at(itp);
237 
239  if ( !curTP.isNull() )
240  {
243  tpAddressVector.push_back( curTP.get() );
244  }
245  }
246 
248  std::sort( tpAddressVector.begin(), tpAddressVector.end() );
249  tpAddressVector.erase( std::unique( tpAddressVector.begin(), tpAddressVector.end() ), tpAddressVector.end() );
250  goodDifferentTPs = tpAddressVector.size();
251 
253  return ( goodDifferentTPs == 0 );
254 }
255 
256 template< typename T >
258 {
260  std::vector< edm::Ptr< TrackingParticle > > theseTrackingParticles = this->findTrackingParticlePtrs( aCluster );
261 
263  if ( theseTrackingParticles.empty())
264  return false;
265 
266 
267  bool genuineClu = this->isGenuine( aCluster );
268  bool unknownClu = this->isUnknown( aCluster );
269 
270  if (genuineClu || unknownClu) return false;
271 
272  return true;
273 
275  unsigned int nullTPs = 0;
276  unsigned int goodDifferentTPs = 0;
277  std::vector< const TrackingParticle* > tpAddressVector;
278 
280  for ( unsigned int itp = 0; itp < theseTrackingParticles.size(); itp++ )
281  {
283  edm::Ptr< TrackingParticle > curTP = theseTrackingParticles.at(itp);
284 
286  if ( curTP.isNull() )
287  {
288  nullTPs++;
289  }
290  else
291  {
294  tpAddressVector.push_back( curTP.get() );
295  }
296  }
297 
299  std::sort( tpAddressVector.begin(), tpAddressVector.end() );
300  tpAddressVector.erase( std::unique( tpAddressVector.begin(), tpAddressVector.end() ), tpAddressVector.end() );
301  goodDifferentTPs = tpAddressVector.size();
302 
305  //return ( ( nullTPs == 0 && goodDifferentTPs > 1 ) || ( nullTPs > 0 && goodDifferentTPs > 0 ) );
306  return (goodDifferentTPs > 1);
307 }
308 
309 template< typename T >
311 {
312  if ( this->isGenuine( aCluster ) )
313  {
314  return this->findTrackingParticlePtrs( aCluster ).at(0);
315  }
316 
318  return *temp;
319 }
320 
321 #endif
322 
323 
const LorentzVector & p4() const
Four-momentum Lorentz vector. Note this is taken from the first SimTrack only.
std::vector< edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > > findTTClusterRefs(edm::Ptr< TrackingParticle > aTrackingParticle) const
Operations.
void setTrackingParticleToTTClustersMap(std::map< edm::Ptr< TrackingParticle >, std::vector< edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > > > aMap)
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:159
std::map< edm::Ptr< TrackingParticle >, std::vector< edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > > > trackingParticleToClusterVectorMap
bool isGenuine(edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > aCluster) const
MC Truth methods.
void setTTClusterToTrackingParticlesMap(std::map< edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > >, std::vector< edm::Ptr< TrackingParticle > > > aMap)
NOTE: this is needed even if it seems not.
TTClusterAssociationMap()
Constructors.
std::vector< edm::Ptr< TrackingParticle > > findTrackingParticlePtrs(edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > aCluster) const
Operations.
def unique(seq, keepstr=True)
Definition: tier0.py:24
bool isCombinatoric(edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > aCluster) const
bool isNull() const
Checks for null.
Definition: Ptr.h:164
std::map< edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > >, std::vector< edm::Ptr< TrackingParticle > > > clusterToTrackingParticleVectorMap
Data members.
edm::Ptr< TrackingParticle > findTrackingParticlePtr(edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > aCluster) const
std::map< edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > >, std::vector< edm::Ptr< TrackingParticle > > > getTTClusterToTrackingParticlesMap() const
Maps.
NOTE: this is needed even if it seems not.
Definition: TTCluster.h:27
bool isUnknown(edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > aCluster) const
std::map< edm::Ptr< TrackingParticle >, std::vector< edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > > > getTrackingParticleToTTClustersMap() const