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::SuperClusterRef &, const reco::SuperClusterRef &, edm::Handle< EcalRecHitCollection > &reducedEBRecHits, edm::Handle< EcalRecHitCollection > &reducedEERecHits)
float sharedEnergy (const reco::CaloCluster *, const reco::CaloCluster *, edm::Handle< EcalRecHitCollection > &reducedEBRecHits, edm::Handle< EcalRecHitCollection > &reducedEERecHits)
int sharedHits (const reco::GsfTrackRef &, const reco::GsfTrackRef &)

Function Documentation

bool EgAmbiguityTools::isBetter ( const reco::GsfElectron e1,
const reco::GsfElectron e2 
)
int EgAmbiguityTools::sharedDets ( const reco::GsfTrackRef gsfTrackRef1,
const reco::GsfTrackRef gsfTrackRef2 
)

Definition at line 151 of file EgAmbiguityTools.cc.

References reco::HitPattern::getHitPattern(), reco::HitPattern::pixelHitFilter(), reco::HitPattern::stripTECHitFilter(), reco::HitPattern::stripTIBHitFilter(), reco::HitPattern::stripTIDHitFilter(), and reco::HitPattern::stripTOBHitFilter().

                             {

  //get the Hit Pattern for the gsfTracks
  const HitPattern& gsfHitPattern1 = gsfTrackRef1->hitPattern();
  const HitPattern& gsfHitPattern2 = gsfTrackRef2->hitPattern();

  unsigned int shared = 0;

  int gsfHitCounter1 = 0;
  for(trackingRecHit_iterator elHitsIt1 = gsfTrackRef1->recHitsBegin();
      elHitsIt1 != gsfTrackRef1->recHitsEnd(); elHitsIt1++, gsfHitCounter1++) {
    if(!((**elHitsIt1).isValid()))  //count only valid Hits
      continue;
    //if (gsfHitCounter1>1) continue; // to test only the first hit of the track 1
    uint32_t gsfHit = gsfHitPattern1.getHitPattern(gsfHitCounter1);
    if(!(gsfHitPattern1.pixelHitFilter(gsfHit)
         || gsfHitPattern1.stripTIBHitFilter(gsfHit)
         || gsfHitPattern1.stripTOBHitFilter(gsfHit)
         || gsfHitPattern1.stripTECHitFilter(gsfHit)
         || gsfHitPattern1.stripTIDHitFilter(gsfHit) )
    ) continue;
    int gsfHitsCounter2 = 0;
    for(trackingRecHit_iterator gsfHitsIt2 = gsfTrackRef2->recHitsBegin();
        gsfHitsIt2 != gsfTrackRef2->recHitsEnd(); gsfHitsIt2++, gsfHitsCounter2++) {
      if(!((**gsfHitsIt2).isValid())) //count only valid Hits!
        continue;

      uint32_t gsfHit2 = gsfHitPattern2.getHitPattern(gsfHitsCounter2);
      if(!(gsfHitPattern2.pixelHitFilter(gsfHit2)
           || gsfHitPattern2.stripTIBHitFilter(gsfHit2)
           || gsfHitPattern1.stripTOBHitFilter(gsfHit2)
           || gsfHitPattern2.stripTECHitFilter(gsfHit2)
           || gsfHitPattern2.stripTIDHitFilter(gsfHit2) )
      ) continue;
      if ((**elHitsIt1).geographicalId() == (**gsfHitsIt2).geographicalId()) shared++;
    }//gsfHits2 iterator
  }//gsfHits1 iterator

  //std::cout << "[sharedHits] number of shared dets " << shared << std::endl;
  //return shared/min(gsfTrackRef1->numberOfValidHits(),gsfTrackRef2->numberOfValidHits());
  return shared;

}
float EgAmbiguityTools::sharedEnergy ( const reco::SuperClusterRef sc1,
const reco::SuperClusterRef sc2,
edm::Handle< EcalRecHitCollection > &  reducedEBRecHits,
edm::Handle< EcalRecHitCollection > &  reducedEERecHits 
)

Definition at line 231 of file EgAmbiguityTools.cc.

References sharedEnergy().

                                                            {

  double energyShared = 0;
  for(CaloCluster_iterator icl1=sc1->clustersBegin();icl1!=sc1->clustersEnd(); icl1++) {
    for(CaloCluster_iterator icl2=sc2->clustersBegin();icl2!=sc2->clustersEnd(); icl2++) {
      energyShared += sharedEnergy(&(**icl1),&(**icl2),reducedEBRecHits,reducedEERecHits );
    }
  }
  return energyShared;

}
float EgAmbiguityTools::sharedEnergy ( const reco::CaloCluster clu1,
const reco::CaloCluster clu2,
edm::Handle< EcalRecHitCollection > &  reducedEBRecHits,
edm::Handle< EcalRecHitCollection > &  reducedEERecHits 
)

Definition at line 196 of file EgAmbiguityTools.cc.

References EcalBarrel, EcalEndcap, and reco::CaloCluster::hitsAndFractions().

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

                                                            {

  double fractionShared = 0;

  std::vector< std::pair<DetId, float> > v_id1 = clu1->hitsAndFractions();
  std::vector< std::pair<DetId, float> > v_id2 = clu2->hitsAndFractions();
  std::vector< std::pair<DetId, float> >::iterator ih1;
  std::vector< std::pair<DetId, float> >::iterator ih2;

  for(ih1 = v_id1.begin();ih1 != v_id1.end(); ih1++) {

    for(ih2 = v_id2.begin();ih2 != v_id2.end(); ih2++) {

      if ( (*ih1).first != (*ih2).first ) continue;

      // here we have common Xtal id
      EcalRecHitCollection::const_iterator itt;
      if ((*ih1).first.subdetId() == EcalBarrel) {
        if ((itt=reducedEBRecHits->find((*ih1).first))!=reducedEBRecHits->end())
        fractionShared += itt->energy();
      } else if ((*ih1).first.subdetId() == EcalEndcap) {
        if ((itt=reducedEERecHits->find((*ih1).first))!=reducedEERecHits->end())
        fractionShared += itt->energy();
      }

    }
  }

  //std::cout << "[sharedEnergy] shared energy /min(energy1,energy2) " << fractionShared << std::endl;
  return fractionShared;

}
int EgAmbiguityTools::sharedHits ( const reco::GsfTrackRef gsfTrackRef1,
const reco::GsfTrackRef gsfTrackRef2 
)

Definition at line 104 of file EgAmbiguityTools.cc.

References reco::HitPattern::getHitPattern(), reco::HitPattern::pixelHitFilter(), TrackingRecHit::some, reco::HitPattern::stripTECHitFilter(), reco::HitPattern::stripTIBHitFilter(), reco::HitPattern::stripTIDHitFilter(), and reco::HitPattern::stripTOBHitFilter().

Referenced by CosmicMuonLinksProducer::mapTracks().

 {
  //get the Hit Pattern for the gsfTracks
  const HitPattern & gsfHitPattern1 = gsfTrackRef1->hitPattern() ;
  const HitPattern & gsfHitPattern2 = gsfTrackRef2->hitPattern() ;

  unsigned int shared = 0;

  int gsfHitCounter1 = 0;
  for(trackingRecHit_iterator elHitsIt1 = gsfTrackRef1->recHitsBegin();
      elHitsIt1 != gsfTrackRef1->recHitsEnd(); elHitsIt1++, gsfHitCounter1++) {
    if(!((**elHitsIt1).isValid()))  //count only valid Hits
      continue;
    //if (gsfHitCounter1>1) continue; // test only the first hit of the track 1
    uint32_t gsfHit = gsfHitPattern1.getHitPattern(gsfHitCounter1);
    if(!(gsfHitPattern1.pixelHitFilter(gsfHit)
         || gsfHitPattern1.stripTIBHitFilter(gsfHit)
         || gsfHitPattern1.stripTOBHitFilter(gsfHit)
         || gsfHitPattern1.stripTECHitFilter(gsfHit)
         || gsfHitPattern1.stripTIDHitFilter(gsfHit) )
    ) continue;
    int gsfHitsCounter2 = 0;
    for(trackingRecHit_iterator gsfHitsIt2 = gsfTrackRef2->recHitsBegin();
        gsfHitsIt2 != gsfTrackRef2->recHitsEnd(); gsfHitsIt2++, gsfHitsCounter2++) {
      if(!((**gsfHitsIt2).isValid())) //count only valid Hits!
        continue;

      uint32_t gsfHit2 = gsfHitPattern2.getHitPattern(gsfHitsCounter2);
      if(!(gsfHitPattern2.pixelHitFilter(gsfHit2)
         || gsfHitPattern2.stripTIBHitFilter(gsfHit2)
         || gsfHitPattern2.stripTOBHitFilter(gsfHit2)
         || gsfHitPattern2.stripTECHitFilter(gsfHit2)
         || gsfHitPattern2.stripTIDHitFilter(gsfHit2) )
      ) continue;
      if( (**elHitsIt1).sharesInput(&(**gsfHitsIt2), TrackingRecHit::some) ) {
//        if (comp.equals(&(**elHitsIt1),&(**gsfHitsIt2))) {
        //std::cout << "found shared hit " << gsfHit2 << std::endl;
        shared++;
      }
    }//gsfHits2 iterator
  }//gsfHits1 iterator

  //std::cout << "[sharedHits] number of shared hits " << shared << std::endl;
  return shared;

}