00001 #include "RecoTracker/TkHitPairs/interface/CosmicHitPairGeneratorFromLayerPair.h"
00002 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegion.h"
00003 #include "TrackingTools/DetLayers/interface/DetLayer.h"
00004 #include "RecoTracker/TkHitPairs/interface/OrderedHitPairs.h"
00005 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007 #include "TrackingTools/DetLayers/interface/BarrelDetLayer.h"
00008
00009 using namespace std;
00010 typedef ctfseeding::SeedingHit TkHitPairsCachedHit;
00011
00012 CosmicHitPairGeneratorFromLayerPair::CosmicHitPairGeneratorFromLayerPair(const LayerWithHits* inner,
00013 const LayerWithHits* outer,
00014
00015 const edm::EventSetup& iSetup)
00016 : TTRHbuilder(0),trackerGeometry(0),
00017
00018 theOuterLayer(outer), theInnerLayer(inner)
00019 {
00020
00021 edm::ESHandle<TrackerGeometry> tracker;
00022 iSetup.get<TrackerDigiGeometryRecord>().get(tracker);
00023 trackerGeometry = tracker.product();
00024 }
00025 void CosmicHitPairGeneratorFromLayerPair::hitPairs(
00026 const TrackingRegion & region, OrderedHitPairs & result,
00027 const edm::EventSetup& iSetup)
00028 {
00029
00030
00031
00032 typedef OrderedHitPair::InnerHit InnerHit;
00033 typedef OrderedHitPair::OuterHit OuterHit;
00034
00035
00036 if (theInnerLayer->recHits().empty()) return;
00037
00038 if (theOuterLayer->recHits().empty()) return;
00039
00040
00041
00042
00043
00044
00045 const DetLayer* blay1;
00046 const DetLayer* blay2;
00047 blay1 = dynamic_cast<const BarrelDetLayer*>(theInnerLayer->layer());
00048 blay2 = dynamic_cast<const BarrelDetLayer*>(theOuterLayer->layer());
00049
00050
00051 bool seedfromoverlaps= false;
00052 bool InTheBarrel = false;
00053 bool InTheForward = false;
00054 if (blay1 && blay2) {
00055 InTheBarrel = true;
00056 }
00057 else InTheForward = true;
00058
00059 if (InTheBarrel){
00060 float radius1 =dynamic_cast<const BarrelDetLayer*>(theInnerLayer->layer())->specificSurface().radius();
00061 float radius2 =dynamic_cast<const BarrelDetLayer*>(theOuterLayer->layer())->specificSurface().radius();
00062 seedfromoverlaps=(abs(radius1-radius2)<0.1) ? true : false;
00063 }
00064
00065
00066 vector<OrderedHitPair> allthepairs;
00067
00068
00069
00070 std::vector<const TrackingRecHit*>::const_iterator ohh;
00071 for(ohh=theOuterLayer->recHits().begin();ohh!=theOuterLayer->recHits().end();ohh++){
00072 const TkHitPairsCachedHit * oh=new TkHitPairsCachedHit(*ohh,iSetup);
00073 std::vector<const TrackingRecHit*>::const_iterator ihh;
00074 for(ihh=theInnerLayer->recHits().begin();ihh!=theInnerLayer->recHits().end();ihh++){
00075 const TkHitPairsCachedHit * ih=new TkHitPairsCachedHit(*ihh,iSetup);
00076
00077 float z_diff =ih->z()-oh->z();
00078 float inny=ih->r()*sin(ih->phi());
00079 float outy=oh->r()*sin(oh->phi());
00080 float innx=ih->r()*cos(ih->phi());
00081 float outx=oh->r()*cos(oh->phi());
00082 float dxdy=abs((outx-innx)/(outy-inny));
00083 float DeltaR=oh->r()-ih->r();
00084
00085 if( InTheBarrel && (abs(z_diff)<30)
00086
00087 &&(dxdy<2)
00088 &&(inny*outy>0)
00089 && (abs(DeltaR)>0)) {
00090
00091
00092 if (seedfromoverlaps){
00093
00094
00095
00096
00097 if ((DeltaR<0)&&(abs(z_diff)<18)&&(abs(ih->phi()-oh->phi())<0.05)&&(dxdy<2)) result.push_back( OrderedHitPair(*ih, *oh));
00098 }
00099 else result.push_back( OrderedHitPair(*ih, *oh));
00100
00101
00102
00103
00104 }
00105 if( InTheForward && (abs(z_diff) > 1.)) {
00106
00107 result.push_back( OrderedHitPair(*ih, *oh));
00108 }
00109 delete ih;
00110 }
00111 delete oh;
00112 }
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126 }
00127