CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/RecoTracker/TkSeedingLayers/src/HitExtractorSTRP.cc

Go to the documentation of this file.
00001 #include "HitExtractorSTRP.h"
00002 #include "Geometry/TrackerGeometryBuilder/interface/TrackerLayerIdAccessor.h"
00003 #include "TrackingTools/DetLayers/interface/DetLayer.h"
00004 
00005 #include "DataFormats/Common/interface/Handle.h"
00006 #include "FWCore/Framework/interface/Event.h"
00007 
00008 #include "FWCore/Framework/interface/EventSetup.h"
00009 #include "FWCore/Framework/interface/ESHandle.h"
00010 #include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2DCollection.h"
00011 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2DCollection.h"
00012 
00013 #include "DataFormats/SiStripDetId/interface/TIBDetId.h"
00014 #include "DataFormats/SiStripDetId/interface/TIDDetId.h"
00015 #include "DataFormats/SiStripDetId/interface/TOBDetId.h"
00016 #include "DataFormats/SiStripDetId/interface/TECDetId.h"
00017 
00018 using namespace ctfseeding;
00019 using namespace std;
00020 using namespace edm;
00021 
00022 HitExtractorSTRP::HitExtractorSTRP( const DetLayer* detLayer, 
00023     SeedingLayer::Side & side, int idLayer)
00024   : theLayer(detLayer), theSide(side), theIdLayer(idLayer),
00025     hasMatchedHits(false), hasRPhiHits(false), hasStereoHits(false),
00026     hasRingSelector(false), theMinRing(1), theMaxRing(0), hasSimpleRphiHitsCleaner(true)
00027 { }
00028 
00029 void HitExtractorSTRP::useRingSelector(int minRing, int maxRing) 
00030 {
00031   hasRingSelector=true;
00032   theMinRing=minRing;
00033   theMaxRing=maxRing; 
00034 }
00035 
00036 bool HitExtractorSTRP::ringRange(int ring) const
00037 {
00038   if (!hasRingSelector) return true;
00039   else if ( ring >= theMinRing && ring <= theMaxRing) return true;
00040   else return false;
00041 }
00042 
00043 HitExtractor::Hits HitExtractorSTRP::hits(const SeedingLayer & sl, const edm::Event& ev, const edm::EventSetup& es) const
00044 {
00045   TrackerLayerIdAccessor accessor;
00046   HitExtractor::Hits result;
00047 
00048   //
00049   // TIB
00050   //
00051   if (theLayer->subDetector() == GeomDetEnumerators::TIB) {
00052     if (hasMatchedHits) {
00053       edm::Handle<SiStripMatchedRecHit2DCollection> matchedHits;
00054       ev.getByLabel( theMatchedHits, matchedHits);
00055       range2SeedingHits( *matchedHits, result, accessor.stripTIBLayer(theIdLayer), sl, es); 
00056     }
00057     if (hasRPhiHits) {
00058       edm::Handle<SiStripRecHit2DCollection> rphiHits;
00059       ev.getByLabel( theRPhiHits, rphiHits);
00060       if (hasMatchedHits){ 
00061         if (!hasSimpleRphiHitsCleaner){ // this is a brutal "cleaning". Add something smarter in the future
00062           range2SeedingHits( *rphiHits, result, accessor.stripTIBLayer(theIdLayer), sl, es); 
00063         }
00064       } else {
00065         range2SeedingHits( *rphiHits, result, accessor.stripTIBLayer(theIdLayer), sl, es); 
00066       }
00067     }
00068     if (hasStereoHits) {
00069       edm::Handle<SiStripRecHit2DCollection> stereoHits;
00070       ev.getByLabel( theStereoHits, stereoHits);
00071       range2SeedingHits( *stereoHits, result, accessor.stripTIBLayer(theIdLayer), sl, es); 
00072     }
00073   }
00074   
00075   //
00076   // TID
00077   //
00078   else if (theLayer->subDetector() == GeomDetEnumerators::TID) {
00079       if (hasMatchedHits) {
00080           edm::Handle<SiStripMatchedRecHit2DCollection> matchedHits;
00081           ev.getByLabel( theMatchedHits, matchedHits);
00082           std::pair<DetId,DetIdTIDSameDiskComparator> getter = accessor.stripTIDDisk(theSide,theIdLayer);
00083           SiStripMatchedRecHit2DCollection::Range range = matchedHits->equal_range(getter.first, getter.second);
00084           for (SiStripMatchedRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) {
00085               int ring = TIDDetId( it->detId() ).ring();  if (!ringRange(ring)) continue;
00086               for (SiStripMatchedRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) {
00087                   result.push_back( sl.hitBuilder()->build(hit) ); 
00088               }
00089           }
00090       }
00091       if (hasRPhiHits) {
00092           edm::Handle<SiStripRecHit2DCollection> rphiHits;
00093           ev.getByLabel( theRPhiHits, rphiHits);
00094           std::pair<DetId,DetIdTIDSameDiskComparator> getter = accessor.stripTIDDisk(theSide,theIdLayer);
00095           SiStripRecHit2DCollection::Range range = rphiHits->equal_range(getter.first, getter.second);
00096           for (SiStripRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) {
00097               int ring = TIDDetId( it->detId() ).ring();  if (!ringRange(ring)) continue;
00098               if ((SiStripDetId(it->detId()).partnerDetId() != 0) && hasSimpleRphiHitsCleaner) continue;  // this is a brutal "cleaning". Add something smarter in the future
00099               for (SiStripRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) {
00100                   result.push_back( sl.hitBuilder()->build(hit) );
00101               }
00102           }
00103       }
00104       if (hasStereoHits) {
00105           edm::Handle<SiStripRecHit2DCollection> stereoHits;
00106           ev.getByLabel( theStereoHits, stereoHits);
00107           std::pair<DetId,DetIdTIDSameDiskComparator> getter = accessor.stripTIDDisk(theSide,theIdLayer);
00108           SiStripRecHit2DCollection::Range range = stereoHits->equal_range(getter.first, getter.second);
00109           for (SiStripRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) {
00110               int ring = TIDDetId( it->detId() ).ring();  if (!ringRange(ring)) continue;
00111               for (SiStripRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) {
00112                   result.push_back( sl.hitBuilder()->build(hit) );
00113               }
00114           }
00115       }
00116   }
00117   //
00118   // TOB
00119   //
00120   else if (theLayer->subDetector() == GeomDetEnumerators::TOB) {
00121     if (hasMatchedHits) {
00122       edm::Handle<SiStripMatchedRecHit2DCollection> matchedHits;
00123       ev.getByLabel( theMatchedHits, matchedHits);
00124       range2SeedingHits( *matchedHits, result, accessor.stripTOBLayer(theIdLayer), sl, es); 
00125     }
00126     if (hasRPhiHits) {
00127       edm::Handle<SiStripRecHit2DCollection> rphiHits;
00128       ev.getByLabel( theRPhiHits, rphiHits);
00129       if (hasMatchedHits){ 
00130         if (!hasSimpleRphiHitsCleaner){ // this is a brutal "cleaning". Add something smarter in the future
00131           range2SeedingHits( *rphiHits, result, accessor.stripTOBLayer(theIdLayer), sl, es); 
00132         }
00133       } else {
00134         range2SeedingHits( *rphiHits, result, accessor.stripTOBLayer(theIdLayer), sl, es); 
00135       }
00136     }
00137     if (hasStereoHits) {
00138       edm::Handle<SiStripRecHit2DCollection> stereoHits;
00139       ev.getByLabel( theStereoHits, stereoHits);
00140       range2SeedingHits( *stereoHits, result, accessor.stripTOBLayer(theIdLayer), sl, es); 
00141     }
00142   }
00143 
00144   //
00145   // TEC
00146   //
00147   else if (theLayer->subDetector() == GeomDetEnumerators::TEC) {
00148       if (hasMatchedHits) {
00149           edm::Handle<SiStripMatchedRecHit2DCollection> matchedHits;
00150           ev.getByLabel( theMatchedHits, matchedHits);
00151           std::pair<DetId,DetIdTECSameDiskComparator> getter = accessor.stripTECDisk(theSide,theIdLayer);
00152           SiStripMatchedRecHit2DCollection::Range range = matchedHits->equal_range(getter.first, getter.second);
00153           for (SiStripMatchedRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) {
00154               int ring = TECDetId( it->detId() ).ring();  if (!ringRange(ring)) continue;
00155               for (SiStripMatchedRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) {
00156                   result.push_back(  sl.hitBuilder()->build(hit) );
00157               }
00158           }
00159       }
00160       if (hasRPhiHits) {
00161           edm::Handle<SiStripRecHit2DCollection> rphiHits;
00162           ev.getByLabel( theRPhiHits, rphiHits);
00163           std::pair<DetId,DetIdTECSameDiskComparator> getter = accessor.stripTECDisk(theSide,theIdLayer);
00164           SiStripRecHit2DCollection::Range range = rphiHits->equal_range(getter.first, getter.second);
00165           for (SiStripRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) {
00166               int ring = TECDetId( it->detId() ).ring();  if (!ringRange(ring)) continue;
00167               if ((SiStripDetId(it->detId()).partnerDetId() != 0) && hasSimpleRphiHitsCleaner) continue;  // this is a brutal "cleaning". Add something smarter in the future
00168               for (SiStripRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) {
00169                   result.push_back( sl.hitBuilder()->build(hit) );
00170               }
00171           }
00172 
00173       }
00174       if (hasStereoHits) {
00175           edm::Handle<SiStripRecHit2DCollection> stereoHits;
00176           ev.getByLabel( theStereoHits, stereoHits);
00177           std::pair<DetId,DetIdTECSameDiskComparator> getter = accessor.stripTECDisk(theSide,theIdLayer);
00178           SiStripRecHit2DCollection::Range range = stereoHits->equal_range(getter.first, getter.second);
00179           for (SiStripRecHit2DCollection::const_iterator it = range.first; it != range.second; ++it) {
00180               int ring = TECDetId( it->detId() ).ring();  if (!ringRange(ring)) continue;
00181               for (SiStripRecHit2DCollection::DetSet::const_iterator hit = it->begin(), end = it->end(); hit != end; ++hit) {
00182                   result.push_back( sl.hitBuilder()->build(hit) );
00183               }
00184           }
00185       }
00186   }
00187   
00188 
00189   return result;
00190 }
00191 
00192