Go to the documentation of this file.00001 #include "RecoPixelVertexing/PixelLowPtUtilities/interface/PixelTripletLowPtGenerator.h"
00002 #include "RecoPixelVertexing/PixelLowPtUtilities/interface/ThirdHitPrediction.h"
00003 #include "RecoPixelVertexing/PixelLowPtUtilities/interface/TripletFilter.h"
00004 #include "RecoPixelVertexing/PixelLowPtUtilities/interface/HitInfo.h"
00005
00006 #include "RecoTracker/TkMSParametrization/interface/PixelRecoPointRZ.h"
00007
00008 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00009 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00010 #include "FWCore/Framework/interface/ESHandle.h"
00011
00012 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
00013 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00014
00015 #undef Debug
00016
00017 using namespace std;
00018 using namespace ctfseeding;
00019
00020
00021 void PixelTripletLowPtGenerator::init(const HitPairGenerator & pairs,
00022 const vector<SeedingLayer> & layers,
00023 LayerCacheType* layerCache)
00024 {
00025 thePairGenerator = pairs.clone();
00026 theLayers = layers;
00027 theLayerCache = layerCache;
00028
00029 checkMultipleScattering = ps.getParameter<bool>("checkMultipleScattering");
00030 nSigMultipleScattering = ps.getParameter<double>("nSigMultipleScattering");
00031 checkClusterShape = ps.getParameter<bool>("checkClusterShape");
00032 rzTolerance = ps.getParameter<double>("rzTolerance");
00033 maxAngleRatio = ps.getParameter<double>("maxAngleRatio");
00034 builderName = ps.getParameter<string>("TTRHBuilder");
00035 }
00036
00037
00038 void PixelTripletLowPtGenerator::getTracker
00039 (const edm::EventSetup& es)
00040 {
00041 if(theTracker == 0)
00042 {
00043
00044 edm::ESHandle<TrackerGeometry> tracker;
00045 es.get<TrackerDigiGeometryRecord>().get(tracker);
00046
00047 theTracker = tracker.product();
00048 }
00049
00050 if(theFilter == 0)
00051 {
00052 theFilter = new TripletFilter(es);
00053 }
00054 }
00055
00056
00057 GlobalPoint PixelTripletLowPtGenerator::getGlobalPosition
00058 (const TrackingRecHit* recHit)
00059 {
00060 DetId detId = recHit->geographicalId();
00061
00062 return
00063 theTracker->idToDet(detId)->toGlobal(recHit->localPosition());
00064 }
00065
00066
00067 void PixelTripletLowPtGenerator::hitTriplets(
00068 const TrackingRegion& region,
00069 OrderedHitTriplets & result,
00070 const edm::Event & ev,
00071 const edm::EventSetup& es)
00072 {
00073
00074
00075 edm::ESHandle<TrackerTopology> tTopoHand;
00076 es.get<IdealGeometryRecord>().get(tTopoHand);
00077 const TrackerTopology *tTopo=tTopoHand.product();
00078
00079
00080 OrderedHitPairs pairs; pairs.reserve(30000);
00081 thePairGenerator->hitPairs(region,pairs,ev,es);
00082
00083 if (pairs.size() == 0) return;
00084
00085 int size = theLayers.size();
00086
00087
00088 const RecHitsSortedInPhi **thirdHitMap = new const RecHitsSortedInPhi*[size];
00089 for(int il=0; il<size; il++)
00090 thirdHitMap[il] = &(*theLayerCache)(&theLayers[il], region, ev, es);
00091
00092
00093 getTracker(es);
00094
00095
00096 for(OrderedHitPairs::const_iterator ip = pairs.begin();
00097 ip!= pairs.end(); ip++)
00098 {
00099
00100 vector<const TrackingRecHit*> recHits(3);
00101 vector<GlobalPoint> points(3);
00102
00103 recHits[0] = (*ip).inner()->hit();
00104 recHits[1] = (*ip).outer()->hit();
00105
00106 #ifdef Debug
00107 cerr << " RecHits " + HitInfo::getInfo(*recHits[0]) +
00108 HitInfo::getInfo(*recHits[1]) << endl;
00109 #endif
00110
00111 for(int i=0; i<2; i++)
00112 points[i] = getGlobalPosition(recHits[i]);
00113
00114
00115 ThirdHitPrediction
00116 thePrediction(region,
00117 points[0],points[1], es,
00118 nSigMultipleScattering,maxAngleRatio,builderName);
00119
00120
00121 for(int il=0; il<size; il++)
00122 {
00123 const SeedingLayer & layerwithhits = theLayers[il];
00124 const DetLayer * layer = layerwithhits.detLayer();
00125
00126 #ifdef Debug
00127 cerr << " check layer " << layer->subDetector()
00128 << " " << layer->location() << endl;
00129 #endif
00130
00131
00132 float phi[2],rz[2];
00133 thePrediction.getRanges(layer, phi,rz);
00134
00135 PixelRecoRange<float> phiRange(phi[0] , phi[1] );
00136 PixelRecoRange<float> rzRange( rz[0] - rzTolerance, rz[1] + rzTolerance);
00137
00138
00139 typedef RecHitsSortedInPhi::Hit Hit;
00140 vector<Hit> thirdHits = thirdHitMap[il]->hits(phiRange.min(),phiRange.max());
00141 typedef vector<Hit>::const_iterator IH;
00142
00143 for (IH th=thirdHits.begin(), eh=thirdHits.end(); th < eh; ++th)
00144 {
00145
00146 recHits[2] = (*th)->hit();
00147 points[2] = getGlobalPosition(recHits[2]);
00148
00149 #ifdef Debug
00150 cerr << " third hit " + HitInfo::getInfo(*recHits[2]) << endl;
00151 #endif
00152
00153
00154 vector<GlobalVector> globalDirs;
00155 if(thePrediction.isCompatibleWithMultipleScattering
00156 (points[2], recHits, globalDirs, es) == false)
00157 {
00158 #ifdef Debug
00159 cerr << " not compatible: multiple scattering" << endl;
00160 #endif
00161 if(checkMultipleScattering) continue;
00162 }
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179 if(checkClusterShape)
00180 {
00181 if(! theFilter->checkTrack(recHits,globalDirs,tTopo))
00182 {
00183 #ifdef Debug
00184 cerr << " not compatible: cluster shape" << endl;
00185 #endif
00186 continue;
00187 }
00188 }
00189
00190
00191 result.push_back(OrderedHitTriplet((*ip).inner(),(*ip).outer(),*th));
00192 }
00193 }
00194 }
00195 delete [] thirdHitMap;
00196
00197 return;
00198 }
00199
00200