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 vector<SeedingHit> HitExtractorSTRP::hits(const SeedingLayer & sl, const edm::Event& ev, const edm::EventSetup& es) const
00044 {
00045 TrackerLayerIdAccessor accessor;
00046 std::vector<SeedingHit> result;
00047
00048
00049
00050
00051 if (theLayer->subDetector() == GeomDetEnumerators::TIB) {
00052 if (hasMatchedHits) {
00053 edm::Handle<SiStripMatchedRecHit2DCollection> matchedHits;
00054 ev.getByLabel( theMatchedHits, matchedHits);
00055 const SiStripMatchedRecHit2DCollection::range range =
00056 matchedHits->get(accessor.stripTIBLayer(theIdLayer) );
00057 for(SiStripMatchedRecHit2DCollection::const_iterator it=range.first; it!=range.second; it++){
00058 result.push_back( SeedingHit(&(*it), sl, es) );
00059 }
00060 }
00061 if (hasRPhiHits) {
00062 edm::Handle<SiStripRecHit2DCollection> rphiHits;
00063 ev.getByLabel( theRPhiHits, rphiHits);
00064 if (hasMatchedHits){
00065 if (!hasSimpleRphiHitsCleaner){
00066 const SiStripRecHit2DCollection::range range =
00067 rphiHits->get(accessor.stripTIBLayer(theIdLayer) );
00068 for(SiStripRecHit2DCollection::const_iterator it=range.first; it!=range.second; it++){
00069 result.push_back( SeedingHit(&(*it), sl, es) );
00070 }
00071 }
00072 } else {
00073 const SiStripRecHit2DCollection::range range =
00074 rphiHits->get(accessor.stripTIBLayer(theIdLayer) );
00075 for(SiStripRecHit2DCollection::const_iterator it=range.first; it!=range.second; it++){
00076 result.push_back( SeedingHit(&(*it), sl, es) );
00077 }
00078 }
00079 }
00080 if (hasStereoHits) {
00081 edm::Handle<SiStripRecHit2DCollection> stereoHits;
00082 ev.getByLabel( theStereoHits, stereoHits);
00083 const SiStripRecHit2DCollection::range range =
00084 stereoHits->get(accessor.stripTIBLayer(theIdLayer) );
00085 for(SiStripRecHit2DCollection::const_iterator it=range.first; it!=range.second; it++){
00086 result.push_back( SeedingHit(&(*it), sl, es) );
00087 }
00088 }
00089 }
00090
00091
00092
00093
00094 else if (theLayer->subDetector() == GeomDetEnumerators::TID) {
00095 if (hasMatchedHits) {
00096 edm::Handle<SiStripMatchedRecHit2DCollection> matchedHits;
00097 ev.getByLabel( theMatchedHits, matchedHits);
00098 const SiStripMatchedRecHit2DCollection::range range =
00099 matchedHits->get(accessor.stripTIDDisk(theSide,theIdLayer) );
00100 for(SiStripMatchedRecHit2DCollection::const_iterator it=range.first; it!=range.second; it++){
00101 int ring = TIDDetId( it->geographicalId() ).ring();
00102 if (ringRange(ring))result.push_back( SeedingHit(&(*it), sl, es) );
00103 }
00104 }
00105 if (hasRPhiHits) {
00106 edm::Handle<SiStripRecHit2DCollection> rphiHits;
00107 ev.getByLabel( theRPhiHits, rphiHits);
00108 const SiStripRecHit2DCollection::range range =
00109 rphiHits->get(accessor.stripTIDDisk(theSide,theIdLayer) );
00110 for(SiStripRecHit2DCollection::const_iterator it=range.first; it!=range.second; it++){
00111 int ring = TIDDetId( it->geographicalId() ).ring();
00112 if (ringRange(ring)){
00113 bool isInGlued = SiStripDetId(it->geographicalId() ).partnerDetId();
00114 if (hasMatchedHits){
00115 if (isInGlued){
00116
00117 if(!hasSimpleRphiHitsCleaner) result.push_back( SeedingHit(&(*it), sl, es) );
00118 }else{
00119 result.push_back( SeedingHit(&(*it), sl, es) );
00120 }
00121 } else {
00122 result.push_back( SeedingHit(&(*it), sl, es) );
00123 }
00124 }
00125 }
00126 }
00127 if (hasStereoHits) {
00128 edm::Handle<SiStripRecHit2DCollection> stereoHits;
00129 ev.getByLabel( theStereoHits, stereoHits);
00130 const SiStripRecHit2DCollection::range range =
00131 stereoHits->get(accessor.stripTIDDisk(theSide,theIdLayer) );
00132 for(SiStripRecHit2DCollection::const_iterator it=range.first; it!=range.second; it++){
00133 int ring = TIDDetId( it->geographicalId() ).ring();
00134 if (ringRange(ring))result.push_back( SeedingHit(&(*it), sl, es) );
00135 }
00136 }
00137 }
00138
00139
00140
00141 else if (theLayer->subDetector() == GeomDetEnumerators::TOB) {
00142 if (hasMatchedHits) {
00143 edm::Handle<SiStripMatchedRecHit2DCollection> matchedHits;
00144 ev.getByLabel( theMatchedHits, matchedHits);
00145 const SiStripMatchedRecHit2DCollection::range range =
00146 matchedHits->get(accessor.stripTOBLayer(theIdLayer) );
00147 for(SiStripMatchedRecHit2DCollection::const_iterator it=range.first; it!=range.second; it++){
00148 result.push_back( SeedingHit(&(*it), sl, es) );
00149 }
00150 }
00151 if (hasRPhiHits) {
00152 edm::Handle<SiStripRecHit2DCollection> rphiHits;
00153 ev.getByLabel( theRPhiHits, rphiHits);
00154 if (hasMatchedHits){
00155 if (!hasSimpleRphiHitsCleaner){
00156 const SiStripRecHit2DCollection::range range =
00157 rphiHits->get(accessor.stripTOBLayer(theIdLayer) );
00158 for(SiStripRecHit2DCollection::const_iterator it=range.first; it!=range.second; it++){
00159 result.push_back( SeedingHit(&(*it), sl, es) );
00160 }
00161 }
00162 } else {
00163 const SiStripRecHit2DCollection::range range =
00164 rphiHits->get(accessor.stripTOBLayer(theIdLayer) );
00165 for(SiStripRecHit2DCollection::const_iterator it=range.first; it!=range.second; it++){
00166 result.push_back( SeedingHit(&(*it), sl, es) );
00167 }
00168 }
00169 }
00170 if (hasStereoHits) {
00171 edm::Handle<SiStripRecHit2DCollection> stereoHits;
00172 ev.getByLabel( theStereoHits, stereoHits);
00173 const SiStripRecHit2DCollection::range range =
00174 stereoHits->get(accessor.stripTOBLayer(theIdLayer) );
00175 for(SiStripRecHit2DCollection::const_iterator it=range.first; it!=range.second; it++){
00176 result.push_back( SeedingHit(&(*it), sl, es) );
00177 }
00178 }
00179 }
00180
00181
00182
00183
00184 else if (theLayer->subDetector() == GeomDetEnumerators::TEC) {
00185
00186 if (hasMatchedHits) {
00187 edm::Handle<SiStripMatchedRecHit2DCollection> matchedHits;
00188 ev.getByLabel( theMatchedHits, matchedHits);
00189 const SiStripMatchedRecHit2DCollection::range range =
00190 matchedHits->get(accessor.stripTECDisk(theSide,theIdLayer) );
00191 for(SiStripMatchedRecHit2DCollection::const_iterator it=range.first; it!=range.second; it++){
00192 int ring = TECDetId( it->geographicalId() ).ring();
00193 if (ringRange(ring))result.push_back( SeedingHit(&(*it), sl, es) );
00194 }
00195 }
00196 if (hasRPhiHits) {
00197 edm::Handle<SiStripRecHit2DCollection> rphiHits;
00198 ev.getByLabel( theRPhiHits, rphiHits);
00199 const SiStripRecHit2DCollection::range range =
00200 rphiHits->get(accessor.stripTECDisk(theSide,theIdLayer) );
00201 for(SiStripRecHit2DCollection::const_iterator it=range.first; it!=range.second; it++){
00202 int ring = TECDetId( it->geographicalId() ).ring();
00203
00204 if (ringRange(ring)){
00205 bool isInGlued = SiStripDetId(it->geographicalId() ).partnerDetId();
00206 if (hasMatchedHits){
00207 if(isInGlued){
00208
00209 if (!hasSimpleRphiHitsCleaner) result.push_back( SeedingHit(&(*it), sl, es) );
00210 }else{
00211 result.push_back( SeedingHit(&(*it), sl, es) );
00212 }
00213 }else {
00214 result.push_back( SeedingHit(&(*it), sl, es) );
00215 }
00216 }
00217 }
00218 }
00219 if (hasStereoHits) {
00220 edm::Handle<SiStripRecHit2DCollection> stereoHits;
00221 ev.getByLabel( theStereoHits, stereoHits);
00222 const SiStripRecHit2DCollection::range range =
00223 stereoHits->get(accessor.stripTECDisk(theSide,theIdLayer) );
00224 for(SiStripRecHit2DCollection::const_iterator it=range.first; it!=range.second; it++){
00225 int ring = TECDetId( it->geographicalId() ).ring();
00226 if (ringRange(ring))result.push_back( SeedingHit(&(*it), sl, es) );
00227 }
00228 }
00229 }
00230
00231
00232 return result;
00233 }
00234
00235