CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

ctfseeding::HitExtractorSTRP Class Reference

#include <HitExtractorSTRP.h>

Inheritance diagram for ctfseeding::HitExtractorSTRP:
ctfseeding::HitExtractor

List of all members.

Public Types

typedef SiStripRecHit2D::ClusterRef SiStripClusterRef

Public Member Functions

void cleanedOfClusters (const edm::Event &ev, HitExtractor::Hits &hits, bool matched, unsigned int cleanFrom=0) const
virtual HitExtractorSTRPclone () const
 HitExtractorSTRP (const DetLayer *detLayer, SeedingLayer::Side &side, int idLayer)
virtual HitExtractor::Hits hits (const SeedingLayer &sl, const edm::Event &, const edm::EventSetup &) const
void project (TransientTrackingRecHit::ConstRecHitPointer &ptr, const SiStripRecHit2D *hit, TransientTrackingRecHit::ConstRecHitPointer &replaceMe) const
void setNoProjection () const
bool skipThis (OmniClusterRef const &clus, edm::Handle< edm::ContainerMask< edmNew::DetSetVector< SiStripCluster > > > &stripClusterMask) const
bool skipThis (TransientTrackingRecHit::ConstRecHitPointer &ptr, edm::Handle< edm::ContainerMask< edmNew::DetSetVector< SiStripCluster > > > &stripClusterMask, TransientTrackingRecHit::ConstRecHitPointer &replaceMe) const
void useMatchedHits (const edm::InputTag &m)
void useRingSelector (int minRing, int maxRing)
void useRPhiHits (const edm::InputTag &m)
void useSimpleRphiHitsCleaner (bool use)
void useStereoHits (const edm::InputTag &m)
virtual ~HitExtractorSTRP ()

Private Member Functions

bool ringRange (int ring) const

Private Attributes

bool failProjection
bool hasMatchedHits
bool hasRingSelector
bool hasRPhiHits
bool hasSimpleRphiHitsCleaner
bool hasStereoHits
int theIdLayer
const DetLayertheLayer
edm::InputTag theMatchedHits
int theMaxRing
int theMinRing
edm::InputTag theRPhiHits
SeedingLayer::Side theSide
const SeedingLayertheSLayer
edm::InputTag theStereoHits

Detailed Description

Definition at line 19 of file HitExtractorSTRP.h.


Member Typedef Documentation

typedef SiStripRecHit2D::ClusterRef ctfseeding::HitExtractorSTRP::SiStripClusterRef

Definition at line 22 of file HitExtractorSTRP.h.


Constructor & Destructor Documentation

HitExtractorSTRP::HitExtractorSTRP ( const DetLayer detLayer,
SeedingLayer::Side side,
int  idLayer 
)

Definition at line 27 of file HitExtractorSTRP.cc.

Referenced by clone().

  : theLayer(detLayer), theSide(side), theIdLayer(idLayer),
    hasMatchedHits(false), hasRPhiHits(false), hasStereoHits(false),
    hasRingSelector(false), theMinRing(1), theMaxRing(0), hasSimpleRphiHitsCleaner(true)
{ }
virtual ctfseeding::HitExtractorSTRP::~HitExtractorSTRP ( ) [inline, virtual]

Definition at line 25 of file HitExtractorSTRP.h.

{}

Member Function Documentation

void HitExtractorSTRP::cleanedOfClusters ( const edm::Event ev,
HitExtractor::Hits hits,
bool  matched,
unsigned int  cleanFrom = 0 
) const

Definition at line 96 of file HitExtractorSTRP.cc.

References edm::Event::getByLabel(), LogDebug, skipThis(), and ctfseeding::HitExtractor::theSkipClusters.

Referenced by hits().

                                                                      {
  LogDebug("HitExtractorPIX")<<"getting: "<<hits.size()<<" in input.";
  edm::Handle<edm::ContainerMask<edmNew::DetSetVector<SiStripCluster> > > stripClusterMask;
  ev.getByLabel(theSkipClusters,stripClusterMask);
  HitExtractor::Hits newHits;
  unsigned int skipped=0;
  unsigned int projected=0;
  newHits.reserve(hits.size());
  TransientTrackingRecHit::ConstRecHitPointer replaceMe;
  for (unsigned int iH=cleanFrom;iH<hits.size();++iH){
    if (!hits[iH]->isValid()) continue;
    replaceMe=hits[iH];
    if (matched && skipThis(hits[iH],stripClusterMask,replaceMe)){
      LogDebug("HitExtractorSTRP")<<"skipping a matched hit on :"<<hits[iH]->hit()->geographicalId().rawId();
      skipped++;
      continue;
    }
    if (!matched && skipThis( ((TrackerSingleRecHit const *)(hits[iH]->hit()))->omniClusterRef(),stripClusterMask)){
        LogDebug("HitExtractorSTRP")<<"skipping a hit on :"<<hits[iH]->hit()->geographicalId().rawId()<<" key: ";
        skipped++;
        continue;
      }
    if (replaceMe!=hits[iH]) projected++;
    newHits.push_back(replaceMe);
  }
  LogDebug("HitExtractorPIX")<<"skipped :"<<skipped<<" strip rechits because of clusters and projected: "<<projected;
  hits.swap(newHits);
}
virtual HitExtractorSTRP* ctfseeding::HitExtractorSTRP::clone ( void  ) const [inline, virtual]

Definition at line 28 of file HitExtractorSTRP.h.

References HitExtractorSTRP().

{ return new HitExtractorSTRP(*this); }
HitExtractor::Hits HitExtractorSTRP::hits ( const SeedingLayer sl,
const edm::Event ev,
const edm::EventSetup es 
) const [virtual]

Implements ctfseeding::HitExtractor.

Definition at line 127 of file HitExtractorSTRP.cc.

References TransientTrackingRecHitBuilder::build(), cleanedOfClusters(), end, edm::Event::getByLabel(), hasMatchedHits, hasRPhiHits, hasSimpleRphiHitsCleaner, hasStereoHits, ctfseeding::SeedingLayer::hitBuilder(), LogDebug, ctfseeding::range2SeedingHits(), query::result, relativeConstraints::ring, ringRange(), ctfseeding::HitExtractor::skipClusters, TrackerLayerIdAccessor::stripTECDisk(), TrackerLayerIdAccessor::stripTIBLayer(), TrackerLayerIdAccessor::stripTIDDisk(), TrackerLayerIdAccessor::stripTOBLayer(), DetLayer::subDetector(), sistripsummary::TEC, theIdLayer, theLayer, theMatchedHits, theRPhiHits, theSide, theSLayer, theStereoHits, sistripsummary::TIB, sistripsummary::TID, and sistripsummary::TOB.

{
  HitExtractor::Hits result;
  TrackerLayerIdAccessor accessor;
  theSLayer=&sl;
  unsigned int cleanFrom=0;
  //
  // TIB
  //
  if (theLayer->subDetector() == GeomDetEnumerators::TIB) {
    if (hasMatchedHits) {
      edm::Handle<SiStripMatchedRecHit2DCollection> matchedHits;
      ev.getByLabel( theMatchedHits, matchedHits);
      if (skipClusters) cleanFrom=result.size();
      range2SeedingHits( *matchedHits, result, accessor.stripTIBLayer(theIdLayer), sl, es); 
      if (skipClusters) cleanedOfClusters(ev,result,true,cleanFrom);
    }
    if (hasRPhiHits) {
      edm::Handle<SiStripRecHit2DCollection> rphiHits;
      ev.getByLabel( theRPhiHits, rphiHits);
      if (hasMatchedHits){ 
        if (!hasSimpleRphiHitsCleaner){ // this is a brutal "cleaning". Add something smarter in the future
          if (skipClusters) cleanFrom=result.size();
          range2SeedingHits( *rphiHits, result, accessor.stripTIBLayer(theIdLayer), sl, es); 
          if (skipClusters) cleanedOfClusters(ev,result,false,cleanFrom);
        }
      } else {
        if (skipClusters) cleanFrom=result.size();
        range2SeedingHits( *rphiHits, result, accessor.stripTIBLayer(theIdLayer), sl, es); 
        if (skipClusters) cleanedOfClusters(ev,result,false,cleanFrom);
      }
    }
    if (hasStereoHits) {
      edm::Handle<SiStripRecHit2DCollection> stereoHits;
      ev.getByLabel( theStereoHits, stereoHits);
      if (skipClusters) cleanFrom=result.size();
      range2SeedingHits( *stereoHits, result, accessor.stripTIBLayer(theIdLayer), sl, es); 
      if (skipClusters) cleanedOfClusters(ev,result,false,cleanFrom);
    }
  }
  
  //
  // TID
  //
  else if (theLayer->subDetector() == GeomDetEnumerators::TID) {
      if (hasMatchedHits) {
          edm::Handle<SiStripMatchedRecHit2DCollection> matchedHits;
          ev.getByLabel( theMatchedHits, matchedHits);
          if (skipClusters) cleanFrom=result.size();
          std::pair<DetId,DetIdTIDSameDiskComparator> getter = accessor.stripTIDDisk(theSide,theIdLayer);
          SiStripMatchedRecHit2DCollection::Range range = matchedHits->equal_range(getter.first, getter.second);
          for (SiStripMatchedRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) {
              int ring = TIDDetId( it->detId() ).ring();  if (!ringRange(ring)) continue;
              for (SiStripMatchedRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) {
                result.push_back( sl.hitBuilder()->build(hit) ); 
              }
          }
          if (skipClusters) cleanedOfClusters(ev,result,true,cleanFrom);
      }
      if (hasRPhiHits) {
          edm::Handle<SiStripRecHit2DCollection> rphiHits;
          ev.getByLabel( theRPhiHits, rphiHits);
          if (skipClusters) cleanFrom=result.size();
          std::pair<DetId,DetIdTIDSameDiskComparator> getter = accessor.stripTIDDisk(theSide,theIdLayer);
          SiStripRecHit2DCollection::Range range = rphiHits->equal_range(getter.first, getter.second);
          for (SiStripRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) {
              int ring = TIDDetId( it->detId() ).ring();  if (!ringRange(ring)) continue;
              if ((SiStripDetId(it->detId()).partnerDetId() != 0) && hasSimpleRphiHitsCleaner) continue;  // this is a brutal "cleaning". Add something smarter in the future
              for (SiStripRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) {
                  result.push_back( sl.hitBuilder()->build(hit) );
              }
          }
          if (skipClusters) cleanedOfClusters(ev,result,false,cleanFrom);
      }
      if (hasStereoHits) {
          edm::Handle<SiStripRecHit2DCollection> stereoHits;
          ev.getByLabel( theStereoHits, stereoHits);
          if (skipClusters) cleanFrom=result.size();
          std::pair<DetId,DetIdTIDSameDiskComparator> getter = accessor.stripTIDDisk(theSide,theIdLayer);
          SiStripRecHit2DCollection::Range range = stereoHits->equal_range(getter.first, getter.second);
          for (SiStripRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) {
              int ring = TIDDetId( it->detId() ).ring();  if (!ringRange(ring)) continue;
              for (SiStripRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) {
                  result.push_back( sl.hitBuilder()->build(hit) );
              }
          }
          if (skipClusters) cleanedOfClusters(ev,result,false,cleanFrom);
      }
  }
  //
  // TOB
  //
  else if (theLayer->subDetector() == GeomDetEnumerators::TOB) {
    if (hasMatchedHits) {
      edm::Handle<SiStripMatchedRecHit2DCollection> matchedHits;
      ev.getByLabel( theMatchedHits, matchedHits);
      if (skipClusters) cleanFrom=result.size();
      range2SeedingHits( *matchedHits, result, accessor.stripTOBLayer(theIdLayer), sl, es); 
      if (skipClusters) cleanedOfClusters(ev,result,true,cleanFrom);
    }
    if (hasRPhiHits) {
      edm::Handle<SiStripRecHit2DCollection> rphiHits;
      ev.getByLabel( theRPhiHits, rphiHits);
      if (hasMatchedHits){ 
        if (!hasSimpleRphiHitsCleaner){ // this is a brutal "cleaning". Add something smarter in the future
          if (skipClusters) cleanFrom=result.size();
          range2SeedingHits( *rphiHits, result, accessor.stripTOBLayer(theIdLayer), sl, es); 
          if (skipClusters) cleanedOfClusters(ev,result,false,cleanFrom);
        }
      } else {
        if (skipClusters) cleanFrom=result.size();
        range2SeedingHits( *rphiHits, result, accessor.stripTOBLayer(theIdLayer), sl, es); 
        if (skipClusters) cleanedOfClusters(ev,result,false,cleanFrom);
      }
    }
    if (hasStereoHits) {
      edm::Handle<SiStripRecHit2DCollection> stereoHits;
      ev.getByLabel( theStereoHits, stereoHits);
      if (skipClusters) cleanFrom=result.size();
      range2SeedingHits( *stereoHits, result, accessor.stripTOBLayer(theIdLayer), sl, es); 
      if (skipClusters) cleanedOfClusters(ev,result,false,cleanFrom);
    }
  }

  //
  // TEC
  //
  else if (theLayer->subDetector() == GeomDetEnumerators::TEC) {
      if (hasMatchedHits) {
          edm::Handle<SiStripMatchedRecHit2DCollection> matchedHits;
          ev.getByLabel( theMatchedHits, matchedHits);
          if (skipClusters) cleanFrom=result.size();
          std::pair<DetId,DetIdTECSameDiskComparator> getter = accessor.stripTECDisk(theSide,theIdLayer);
          SiStripMatchedRecHit2DCollection::Range range = matchedHits->equal_range(getter.first, getter.second);
          for (SiStripMatchedRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) {
              int ring = TECDetId( it->detId() ).ring();  if (!ringRange(ring)) continue;
              for (SiStripMatchedRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) {
                  result.push_back(  sl.hitBuilder()->build(hit) );
              }
          }
          if (skipClusters) cleanedOfClusters(ev,result,true,cleanFrom);
      }
      if (hasRPhiHits) {
          edm::Handle<SiStripRecHit2DCollection> rphiHits;
          ev.getByLabel( theRPhiHits, rphiHits);
          if (skipClusters) cleanFrom=result.size();
          std::pair<DetId,DetIdTECSameDiskComparator> getter = accessor.stripTECDisk(theSide,theIdLayer);
          SiStripRecHit2DCollection::Range range = rphiHits->equal_range(getter.first, getter.second);
          for (SiStripRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) {
              int ring = TECDetId( it->detId() ).ring();  if (!ringRange(ring)) continue;
              if ((SiStripDetId(it->detId()).partnerDetId() != 0) && hasSimpleRphiHitsCleaner) continue;  // this is a brutal "cleaning". Add something smarter in the future
              for (SiStripRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) {
                  result.push_back( sl.hitBuilder()->build(hit) );
              }
          }
          if (skipClusters) cleanedOfClusters(ev,result,false,cleanFrom);

      }
      if (hasStereoHits) {
          edm::Handle<SiStripRecHit2DCollection> stereoHits;
          ev.getByLabel( theStereoHits, stereoHits);
          if (skipClusters) cleanFrom=result.size();
          std::pair<DetId,DetIdTECSameDiskComparator> getter = accessor.stripTECDisk(theSide,theIdLayer);
          SiStripRecHit2DCollection::Range range = stereoHits->equal_range(getter.first, getter.second);
          for (SiStripRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) {
              int ring = TECDetId( it->detId() ).ring();  if (!ringRange(ring)) continue;
              for (SiStripRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) {
                  result.push_back( sl.hitBuilder()->build(hit) );
              }
          }
          if (skipClusters) cleanedOfClusters(ev,result,false,cleanFrom);
      }
  }
  LogDebug("HitExtractorSTRP")<<" giving: "<<result.size()<<" out";
  return result;
}
void HitExtractorSTRP::project ( TransientTrackingRecHit::ConstRecHitPointer ptr,
const SiStripRecHit2D *  hit,
TransientTrackingRecHit::ConstRecHitPointer replaceMe 
) const
bool HitExtractorSTRP::ringRange ( int  ring) const [private]

Definition at line 41 of file HitExtractorSTRP.cc.

References hasRingSelector, theMaxRing, and theMinRing.

Referenced by hits().

{
  if (!hasRingSelector) return true;
  else if ( ring >= theMinRing && ring <= theMaxRing) return true;
  else return false;
}
void ctfseeding::HitExtractorSTRP::setNoProjection ( ) const [inline]

Definition at line 46 of file HitExtractorSTRP.h.

References failProjection.

{failProjection=true;};
bool HitExtractorSTRP::skipThis ( TransientTrackingRecHit::ConstRecHitPointer ptr,
edm::Handle< edm::ContainerMask< edmNew::DetSetVector< SiStripCluster > > > &  stripClusterMask,
TransientTrackingRecHit::ConstRecHitPointer replaceMe 
) const

Definition at line 67 of file HitExtractorSTRP.cc.

References LogDebug, m, project(), and alignCSCRings::s.

Referenced by cleanedOfClusters().

                                                                                             {
  const SiStripMatchedRecHit2D * hit = (SiStripMatchedRecHit2D *) ptr->hit();

  bool rejectSt   = skipThis(hit->stereoClusterRef(), stripClusterMask);
  bool rejectMono = skipThis(hit->monoClusterRef(),  stripClusterMask);

  if (rejectSt&&rejectMono){
    //only skip if both hits are done
    return true;
  }
  else{
    //FIX use clusters directly
    auto const & s= hit->stereoHit();
    auto const & m= hit->monoHit();
    if (rejectSt) project(ptr,&s,replaceMe);
    else if (rejectMono) project(ptr,&m,replaceMe);
    if (!replaceMe) return true; //means that the projection failed, and needs to be skipped
    if (rejectSt)
      LogDebug("HitExtractorSTRP")<<"a matched hit is partially masked, and the mono hit got projected onto: "<<replaceMe->hit()->geographicalId().rawId()<<" key: "<<hit->monoClusterRef().key();
    else if (rejectMono)
      LogDebug("HitExtractorSTRP")<<"a matched hit is partially masked, and the stereo hit got projected onto: "<<replaceMe->hit()->geographicalId().rawId()<<" key: "<<hit->stereoClusterRef().key();
    return false; //means the projection succeeded or nothing to be masked, no need to skip and replaceMe is going to be used anyways.
  }
  return false;
}
bool HitExtractorSTRP::skipThis ( OmniClusterRef const &  clus,
edm::Handle< edm::ContainerMask< edmNew::DetSetVector< SiStripCluster > > > &  stripClusterMask 
) const

Definition at line 48 of file HitExtractorSTRP.cc.

References OmniClusterRef::key().

                                                                                                                            {
  //  if (!hit->isValid())  return false;

  return stripClusterMask->mask(clus.key());
}
void ctfseeding::HitExtractorSTRP::useMatchedHits ( const edm::InputTag m) [inline]

Definition at line 30 of file HitExtractorSTRP.h.

References hasMatchedHits, m, and theMatchedHits.

void HitExtractorSTRP::useRingSelector ( int  minRing,
int  maxRing 
)

Definition at line 34 of file HitExtractorSTRP.cc.

References hasRingSelector, theMaxRing, and theMinRing.

{
  hasRingSelector=true;
  theMinRing=minRing;
  theMaxRing=maxRing; 
}
void ctfseeding::HitExtractorSTRP::useRPhiHits ( const edm::InputTag m) [inline]

Definition at line 31 of file HitExtractorSTRP.h.

References hasRPhiHits, m, and theRPhiHits.

{ hasRPhiHits    = true; theRPhiHits = m; }
void ctfseeding::HitExtractorSTRP::useSimpleRphiHitsCleaner ( bool  use) [inline]

Definition at line 34 of file HitExtractorSTRP.h.

References hasSimpleRphiHitsCleaner.

void ctfseeding::HitExtractorSTRP::useStereoHits ( const edm::InputTag m) [inline]

Definition at line 32 of file HitExtractorSTRP.h.

References hasStereoHits, m, and theStereoHits.

{ hasStereoHits = true; theStereoHits = m; }

Member Data Documentation

Definition at line 59 of file HitExtractorSTRP.h.

Referenced by project(), and setNoProjection().

Definition at line 54 of file HitExtractorSTRP.h.

Referenced by hits(), and useMatchedHits().

Definition at line 57 of file HitExtractorSTRP.h.

Referenced by ringRange(), and useRingSelector().

Definition at line 55 of file HitExtractorSTRP.h.

Referenced by hits(), and useRPhiHits().

Definition at line 58 of file HitExtractorSTRP.h.

Referenced by hits(), and useSimpleRphiHitsCleaner().

Definition at line 56 of file HitExtractorSTRP.h.

Referenced by hits(), and useStereoHits().

Definition at line 53 of file HitExtractorSTRP.h.

Referenced by hits().

Definition at line 50 of file HitExtractorSTRP.h.

Referenced by hits().

Definition at line 54 of file HitExtractorSTRP.h.

Referenced by hits(), and useMatchedHits().

Definition at line 57 of file HitExtractorSTRP.h.

Referenced by ringRange(), and useRingSelector().

Definition at line 57 of file HitExtractorSTRP.h.

Referenced by ringRange(), and useRingSelector().

Definition at line 55 of file HitExtractorSTRP.h.

Referenced by hits(), and useRPhiHits().

Definition at line 51 of file HitExtractorSTRP.h.

Referenced by hits().

Definition at line 52 of file HitExtractorSTRP.h.

Referenced by hits(), and project().

Definition at line 56 of file HitExtractorSTRP.h.

Referenced by hits(), and useStereoHits().