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 };
72 
80 template< typename T >
84 {
88 }
89 
91 template< typename T >
93 
95 template< typename T >
96 std::vector< edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > > TTClusterAssociationMap< T >::findTTClusterRefs( edm::Ptr< TrackingParticle > aTrackingParticle ) const
97 {
98  if ( trackingParticleToClusterVectorMap.find( aTrackingParticle ) != trackingParticleToClusterVectorMap.end() )
99  {
100  return trackingParticleToClusterVectorMap.find( aTrackingParticle )->second;
101  }
102 
103  std::vector< edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > > tempVector;
104  tempVector.clear();
105  return tempVector;
106 }
107 
108 template< typename T >
110 {
112  {
113  return clusterToTrackingParticleVectorMap.find( aCluster )->second;
114  }
115 
116  std::vector< edm::Ptr< TrackingParticle > > tempVector;
117  tempVector.clear();
118  return tempVector;
119 }
120 
121 
134 template< typename T >
136 {
138  std::vector< edm::Ptr< TrackingParticle > > theseTrackingParticles = this->findTrackingParticlePtrs( aCluster );
139 
141  if ( theseTrackingParticles.size() == 0 )
142  return false;
143 
145  unsigned int nullTPs = 0;
146  unsigned int goodDifferentTPs = 0;
147  std::vector< const TrackingParticle* > tpAddressVector;
148 
150  for ( unsigned int itp = 0; itp < theseTrackingParticles.size(); itp++ )
151  {
153  edm::Ptr< TrackingParticle > curTP = theseTrackingParticles.at(itp);
154 
156  if ( curTP.isNull() )
157  {
158  nullTPs++;
159  }
160  else
161  {
164  tpAddressVector.push_back( curTP.get() );
165  }
166  }
167 
169  std::sort( tpAddressVector.begin(), tpAddressVector.end() );
170  tpAddressVector.erase( std::unique( tpAddressVector.begin(), tpAddressVector.end() ), tpAddressVector.end() );
171  goodDifferentTPs = tpAddressVector.size();
172 
174  return ( nullTPs == 0 && goodDifferentTPs == 1 );
175 }
176 
177 template< typename T >
179 {
181  std::vector< edm::Ptr< TrackingParticle > > theseTrackingParticles = this->findTrackingParticlePtrs( aCluster );
182 
184  if ( theseTrackingParticles.size() == 0 )
185  return true;
186 
188  unsigned int goodDifferentTPs = 0;
189  std::vector< const TrackingParticle* > tpAddressVector;
190 
192  for ( unsigned int itp = 0; itp < theseTrackingParticles.size(); itp++ )
193  {
195  edm::Ptr< TrackingParticle > curTP = theseTrackingParticles.at(itp);
196 
198  if ( !curTP.isNull() )
199  {
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 
212  return ( goodDifferentTPs == 0 );
213 }
214 
215 template< typename T >
217 {
219  std::vector< edm::Ptr< TrackingParticle > > theseTrackingParticles = this->findTrackingParticlePtrs( aCluster );
220 
222  if ( theseTrackingParticles.size() == 0 )
223  return false;
224 
226  unsigned int nullTPs = 0;
227  unsigned int goodDifferentTPs = 0;
228  std::vector< const TrackingParticle* > tpAddressVector;
229 
231  for ( unsigned int itp = 0; itp < theseTrackingParticles.size(); itp++ )
232  {
234  edm::Ptr< TrackingParticle > curTP = theseTrackingParticles.at(itp);
235 
237  if ( curTP.isNull() )
238  {
239  nullTPs++;
240  }
241  else
242  {
245  tpAddressVector.push_back( curTP.get() );
246  }
247  }
248 
250  std::sort( tpAddressVector.begin(), tpAddressVector.end() );
251  tpAddressVector.erase( std::unique( tpAddressVector.begin(), tpAddressVector.end() ), tpAddressVector.end() );
252  goodDifferentTPs = tpAddressVector.size();
253 
256  return ( ( nullTPs == 0 && goodDifferentTPs > 1 ) || ( nullTPs > 0 && goodDifferentTPs > 0 ) );
257 }
258 
259 template< typename T >
261 {
262  if ( this->isGenuine( aCluster ) )
263  {
264  return this->findTrackingParticlePtrs( aCluster ).at(0);
265  }
266 
268  return *temp;
269 }
270 
271 #endif
272 
273 
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:160
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:165
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
vector< int > tempVector
Definition: DBlmapReader.cc:10