CMS 3D CMS Logo

Classes | Functions
EgAmbiguityTools Namespace Reference

Classes

struct  isInnerMost
 

Functions

bool isBetter (const reco::GsfElectron *, const reco::GsfElectron *)
 
int sharedDets (const reco::GsfTrackRef &, const reco::GsfTrackRef &)
 
float sharedEnergy (const reco::CaloCluster *, const reco::CaloCluster *, edm::Handle< EcalRecHitCollection > &barrelRecHits, edm::Handle< EcalRecHitCollection > &endcapRecHits)
 
float sharedEnergy (const reco::SuperClusterRef &, const reco::SuperClusterRef &, edm::Handle< EcalRecHitCollection > &barrelRecHits, edm::Handle< EcalRecHitCollection > &endcapRecHits)
 
int sharedHits (const reco::GsfTrackRef &, const reco::GsfTrackRef &)
 

Function Documentation

bool EgAmbiguityTools::isBetter ( const reco::GsfElectron e1,
const reco::GsfElectron e2 
)

Definition at line 20 of file EgAmbiguityTools.cc.

References funct::abs(), and reco::GsfElectron::eSuperClusterOverP().

Referenced by EgAmbiguityTools::isInnerMost::operator()(), and GsfElectronAlgo::setAmbiguityData().

21  { return (std::abs(e1->eSuperClusterOverP()-1) < std::abs(e2->eSuperClusterOverP() - 1)) ; }
float eSuperClusterOverP() const
Definition: GsfElectron.h:245
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int EgAmbiguityTools::sharedDets ( const reco::GsfTrackRef gsfTrackRef1,
const reco::GsfTrackRef gsfTrackRef2 
)

Definition at line 112 of file EgAmbiguityTools.cc.

References reco::HitPattern::getHitPattern().

113 {
114  //get the Hit Pattern for the gsfTracks
115  const HitPattern &gsfHitPattern1 = gsfTrackRef1->hitPattern();
116  const HitPattern &gsfHitPattern2 = gsfTrackRef2->hitPattern();
117 
118  unsigned int shared = 0;
119 
120  int gsfHitCounter1 = 0;
121  for(trackingRecHit_iterator elHitsIt1 = gsfTrackRef1->recHitsBegin();
122  elHitsIt1 != gsfTrackRef1->recHitsEnd(); elHitsIt1++, gsfHitCounter1++) {
123  if(!((**elHitsIt1).isValid())){
124  //count only valid Hits
125  continue;
126  }
127  //if (gsfHitCounter1>1) continue; // to test only the first hit of the track 1
128  uint32_t gsfHit = gsfHitPattern1.getHitPattern(HitPattern::TRACK_HITS, gsfHitCounter1);
129  if(!(HitPattern::pixelHitFilter(gsfHit)
130  || HitPattern::stripTIBHitFilter(gsfHit)
131  || HitPattern::stripTOBHitFilter(gsfHit)
132  || HitPattern::stripTECHitFilter(gsfHit)
133  || HitPattern::stripTIDHitFilter(gsfHit)))
134  {
135  continue;
136  }
137 
138  int gsfHitsCounter2 = 0;
139  for(trackingRecHit_iterator gsfHitsIt2 = gsfTrackRef2->recHitsBegin();
140  gsfHitsIt2 != gsfTrackRef2->recHitsEnd(); gsfHitsIt2++, gsfHitsCounter2++) {
141  if(!((**gsfHitsIt2).isValid())){
142  //count only valid Hits!
143  continue;
144  }
145 
146  uint32_t gsfHit2 = gsfHitPattern2.getHitPattern(HitPattern::TRACK_HITS, gsfHitsCounter2);
147  if(!(HitPattern::pixelHitFilter(gsfHit2)
148  || HitPattern::stripTIBHitFilter(gsfHit2)
149  || HitPattern::stripTOBHitFilter(gsfHit2)
150  || HitPattern::stripTECHitFilter(gsfHit2)
151  || HitPattern::stripTIDHitFilter(gsfHit2) )
152  ) continue;
153  if ((**elHitsIt1).geographicalId() == (**gsfHitsIt2).geographicalId()) shared++;
154  }//gsfHits2 iterator
155  }//gsfHits1 iterator
156 
157  //std::cout << "[sharedHits] number of shared dets " << shared << std::endl;
158  //return shared/min(gsfTrackRef1->numberOfValidHits(),gsfTrackRef2->numberOfValidHits());
159  return shared;
160 
161 }
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:516
float EgAmbiguityTools::sharedEnergy ( const reco::CaloCluster clu1,
const reco::CaloCluster clu2,
edm::Handle< EcalRecHitCollection > &  barrelRecHits,
edm::Handle< EcalRecHitCollection > &  endcapRecHits 
)

Definition at line 163 of file EgAmbiguityTools.cc.

References EcalBarrel, EcalEndcap, edm::SortedCollection< T, SORT >::end(), edm::SortedCollection< T, SORT >::find(), conversionTrackCandidates_cfi::fractionShared, and reco::CaloCluster::hitsAndFractions().

Referenced by RealisticHitToClusterAssociator::findAndMergeInvisibleClusters(), GsfElectronAlgo::setAmbiguityData(), and sharedEnergy().

165  {
166 
167  double fractionShared = 0;
168 
169  std::vector< std::pair<DetId, float> > v_id1 = clu1->hitsAndFractions();
170  std::vector< std::pair<DetId, float> > v_id2 = clu2->hitsAndFractions();
171  std::vector< std::pair<DetId, float> >::iterator ih1;
172  std::vector< std::pair<DetId, float> >::iterator ih2;
173 
174  for(ih1 = v_id1.begin();ih1 != v_id1.end(); ih1++) {
175 
176  for(ih2 = v_id2.begin();ih2 != v_id2.end(); ih2++) {
177 
178  if ( (*ih1).first != (*ih2).first ) continue;
179 
180  // here we have common Xtal id
182  if ((*ih1).first.subdetId() == EcalBarrel) {
183  if ((itt=barrelRecHits->find((*ih1).first))!=barrelRecHits->end())
184  fractionShared += itt->energy();
185  } else if ((*ih1).first.subdetId() == EcalEndcap) {
186  if ((itt=endcapRecHits->find((*ih1).first))!=endcapRecHits->end())
187  fractionShared += itt->energy();
188  }
189 
190  }
191  }
192 
193  //std::cout << "[sharedEnergy] shared energy /min(energy1,energy2) " << fractionShared << std::endl;
194  return fractionShared;
195 
196 }
std::vector< EcalRecHit >::const_iterator const_iterator
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:197
const_iterator end() const
iterator find(key_type k)
float EgAmbiguityTools::sharedEnergy ( const reco::SuperClusterRef sc1,
const reco::SuperClusterRef sc2,
edm::Handle< EcalRecHitCollection > &  barrelRecHits,
edm::Handle< EcalRecHitCollection > &  endcapRecHits 
)

Definition at line 198 of file EgAmbiguityTools.cc.

References sharedEnergy().

200  {
201 
202  double energyShared = 0;
203  for(CaloCluster_iterator icl1=sc1->clustersBegin();icl1!=sc1->clustersEnd(); icl1++) {
204  for(CaloCluster_iterator icl2=sc2->clustersBegin();icl2!=sc2->clustersEnd(); icl2++) {
205  energyShared += sharedEnergy(&(**icl1),&(**icl2),barrelRecHits,endcapRecHits );
206  }
207  }
208  return energyShared;
209 
210 }
float sharedEnergy(const reco::CaloCluster *, const reco::CaloCluster *, edm::Handle< EcalRecHitCollection > &barrelRecHits, edm::Handle< EcalRecHitCollection > &endcapRecHits)
int EgAmbiguityTools::sharedHits ( const reco::GsfTrackRef gsfTrackRef1,
const reco::GsfTrackRef gsfTrackRef2 
)

Definition at line 60 of file EgAmbiguityTools.cc.

References reco::HitPattern::getHitPattern(), and TrackingRecHit::some.

61 {
62  //get the Hit Pattern for the gsfTracks
63  const HitPattern &gsfHitPattern1 = gsfTrackRef1->hitPattern();
64  const HitPattern &gsfHitPattern2 = gsfTrackRef2->hitPattern();
65 
66  unsigned int shared = 0;
67 
68  int gsfHitCounter1 = 0;
69  for(trackingRecHit_iterator elHitsIt1 = gsfTrackRef1->recHitsBegin();
70  elHitsIt1 != gsfTrackRef1->recHitsEnd(); elHitsIt1++, gsfHitCounter1++) {
71  if(!(**elHitsIt1).isValid()){
72  //count only valid Hits
73  continue;
74  }
75  //if (gsfHitCounter1>1) continue; // test only the first hit of the track 1
76  uint32_t gsfHit = gsfHitPattern1.getHitPattern(HitPattern::TRACK_HITS, gsfHitCounter1);
77  if(!(HitPattern::pixelHitFilter(gsfHit)
78  || HitPattern::stripTIBHitFilter(gsfHit)
79  || HitPattern::stripTOBHitFilter(gsfHit)
80  || HitPattern::stripTECHitFilter(gsfHit)
81  || HitPattern::stripTIDHitFilter(gsfHit))){
82  continue;
83  }
84 
85  int gsfHitsCounter2 = 0;
86  for(trackingRecHit_iterator gsfHitsIt2 = gsfTrackRef2->recHitsBegin();
87  gsfHitsIt2 != gsfTrackRef2->recHitsEnd(); gsfHitsIt2++, gsfHitsCounter2++) {
88  if(!(**gsfHitsIt2).isValid()){
89  //count only valid Hits
90  continue;
91  }
92  uint32_t gsfHit2 = gsfHitPattern2.getHitPattern(HitPattern::TRACK_HITS, gsfHitsCounter2);
93  if(!(HitPattern::pixelHitFilter(gsfHit2)
94  || HitPattern::stripTIBHitFilter(gsfHit2)
95  || HitPattern::stripTOBHitFilter(gsfHit2)
96  || HitPattern::stripTECHitFilter(gsfHit2)
97  || HitPattern::stripTIDHitFilter(gsfHit2))){
98  continue;
99  }
100  if((**elHitsIt1).sharesInput(&(**gsfHitsIt2), TrackingRecHit::some)) {
101  //if (comp.equals(&(**elHitsIt1),&(**gsfHitsIt2))) {
103  shared++;
104  }
105  }//gsfHits2 iterator
106  }//gsfHits1 iterator
107 
108  //std::cout << "[sharedHits] number of shared hits " << shared << std::endl;
109  return shared;
110 }
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:516