15 using namespace reco ;
19 (
float phi1min,
float phi1max,
20 float phi2minB,
float phi2maxB,
float phi2minF,
float phi2maxF,
21 float z2minB,
float z2maxB,
float r2minF,
float r2maxF,
22 float rMinI,
float rMaxI,
bool searchInTIDTEC)
24 meas1stBLayer(phi1min,phi1max,0.,0.), meas2ndBLayer(phi2minB,phi2maxB,z2minB,z2maxB),
25 meas1stFLayer(phi1min,phi1max,0.,0.), meas2ndFLayer(phi2minF,phi2maxF,r2minF,r2maxF),
27 prop1stLayer(0), prop2ndLayer(0),theGeometricSearchTracker(0),theLayerMeasurements(0),vertex_(0.),
28 searchInTIDTEC_(searchInTIDTEC), useRecoVertex_(
false)
30 meas1stFLayer.setRRangeI(rMinI,rMaxI) ;
31 meas2ndFLayer.setRRangeI(rMinI,rMaxI) ;
38 delete theLayerMeasurements ;
43 meas1stBLayer.setPhiRange(dummyphi1min,dummyphi1max) ;
44 meas1stFLayer.setPhiRange(dummyphi1min,dummyphi1max) ;
49 meas1stBLayer.setZRange(zmin1,zmax1) ;
50 meas1stFLayer.setRRange(zmin1,zmax1) ;
55 meas2ndBLayer.setPhiRange(dummyphi2minB,dummyphi2maxB) ;
56 meas2ndFLayer.setPhiRange(dummyphi2minF,dummyphi2maxF) ;
60 { useRecoVertex_ = val ; }
67 if (theMeasurementTracker)
69 theGeometricSearchTracker=theMeasurementTracker->geometricSearchTracker() ;
70 startLayers.setup(theGeometricSearchTracker) ;
71 if (theLayerMeasurements )
delete theLayerMeasurements ;
75 theMagField = magField ;
76 theTrackerGeometry = trackerGeometry ;
78 if (prop1stLayer)
delete prop1stLayer ;
80 if (prop2ndLayer)
delete prop2ndLayer ;
85 {
return pred1Meas ; }
88 {
return pred2Meas ; }
96 std::vector<SeedWithInfo>
101 int charge = int(fcharge) ;
107 std::vector<SeedWithInfo>
result ;
110 mapTsos_.reserve(seeds->size()) ;
111 mapTsos2_.reserve(seeds->size()) ;
113 for (
unsigned int i=0;
i<seeds->size();++
i)
115 if ((*seeds)[
i].nHits()>9)
117 edm::LogWarning(
"GsfElectronAlgo|UnexpectedSeed") <<
"We cannot deal with seeds having more than 9 hits." ;
123 unsigned char rank1, rank2, hitsMask ;
125 for ( rank1=0, it1=rhits.first ; it1!=rhits.second ; rank1++, it1++ )
127 for ( rank2=rank1+1, it2=it1+1 ; it2!=rhits.second ; rank2++, it2++ )
133 if (!(*it).isValid())
continue;
134 DetId id=(*it).geographicalId();
135 const GeomDet *geomdet=theTrackerGeometry->idToDet((*it).geographicalId());
141 std::vector<std::pair<const GeomDet *, TrajectoryStateOnSurface> >::iterator itTsos ;
142 for (itTsos=mapTsos_.begin();itTsos!=mapTsos_.end();++itTsos)
144 if ((*itTsos).first==geomdet)
145 { found=
true ; break ; }
149 tsos1 = prop1stLayer->propagate(tsos,geomdet->
surface()) ;
150 mapTsos_.push_back(std::pair<const GeomDet *, TrajectoryStateOnSurface>(geomdet,tsos1));
153 { tsos1=(*itTsos).second ; }
157 std::pair<bool,double> est;
158 if (
id.subdetId()%2==1) est=meas1stBLayer.estimate(vprim, tsos1,hitPos);
159 else est=meas1stFLayer.estimate(vprim, tsos1,hitPos);
160 if (!est.first) continue ;
164 int subDet1 =
id.subdetId() ;
165 float dRz1 = (subDet1%2==1)?pp1.
dZ():pp1.dPerp() ;
166 float dPhi1 = pp1.dPhi() ;
172 if (!(*it).isValid())
continue ;
174 DetId id2=(*it).geographicalId();
175 const GeomDet *geomdet2=theTrackerGeometry->idToDet((*it).geographicalId());
182 double pxHit1z = hitPos.
z();
183 double pxHit1x = hitPos.
x();
184 double pxHit1y = hitPos.
y();
185 double r1diff = (pxHit1x-vprim.
x())*(pxHit1x-vprim.
x()) + (pxHit1y-vprim.
y())*(pxHit1y-vprim.
y()) ;
186 r1diff=
sqrt(r1diff) ;
187 double r2diff = (xmeas.
x()-pxHit1x)*(xmeas.
x()-pxHit1x) + (xmeas.
y()-pxHit1y)*(xmeas.
y()-pxHit1y) ;
189 zVertex = pxHit1z - r1diff*(xmeas.
z()-pxHit1z)/r2diff;
192 { zVertex = vprim.
z() ; }
199 for (itTsos2=mapTsos2_.begin();itTsos2!=mapTsos2_.end();++itTsos2)
201 if (((*itTsos2).first).first==geomdet2 &&
202 (((*itTsos2).first).
second).x()==hitPos.
x() &&
203 (((*itTsos2).first).
second).y()==hitPos.
y() &&
204 (((*itTsos2).first).
second).z()==hitPos.
z() )
212 tsos2 = prop2ndLayer->propagate(fts2,geomdet2->
surface()) ;
213 std::pair<const GeomDet *,GlobalPoint> pair(geomdet2,hitPos);
217 { tsos2=(*itTsos2).second ; }
223 std::pair<bool,double> est2 ;
224 if (id2.
subdetId()%2==1) est2=meas2ndBLayer.estimate(vertex, tsos2,hitPos2) ;
225 else est2=meas2ndFLayer.estimate(vertex, tsos2,hitPos2) ;
230 float dRz2 = (subDet2%2==1)?pp2.dZ():pp2.dPerp() ;
231 float dPhi2 = pp2.dPhi() ;
232 hitsMask = (1<<rank1)|(1<<rank2) ;
233 result.push_back(
SeedWithInfo((*seeds)[
i],hitsMask,subDet2,dRz2,dPhi2,subDet1,dRz1,dPhi1)) ;
249 vector< pair< RecHitWithDist, PixelHitMatcher::ConstRecHitPointer > >
253 float energy,
float fcharge,
256 float SCl_phi = xmeas.
phi();
258 int charge = int(fcharge);
260 vector<pair<RecHitWithDist, ConstRecHitPointer> >
result;
261 LogDebug(
"") <<
"[PixelHitMatcher::compatibleHits] entering .. ";
263 vector<TrajectoryMeasurement> validMeasurements;
264 vector<TrajectoryMeasurement> invalidMeasurements;
266 typedef vector<TrajectoryMeasurement>::const_iterator aMeas;
271 typedef vector<BarrelDetLayer*>::const_iterator BarrelLayerIterator;
272 BarrelLayerIterator firstLayer = startLayers.firstBLayer();
281 vector<TrajectoryMeasurement> pixelMeasurements =
282 theLayerMeasurements->measurements(**firstLayer,tsos,
283 *prop1stLayer, meas1stBLayer);
285 LogDebug(
"") <<
"[PixelHitMatcher::compatibleHits] nbr of hits compatible with extrapolation to first layer: " << pixelMeasurements.size();
286 for (aMeas
m=pixelMeasurements.begin();
m!=pixelMeasurements.end();
m++){
287 if (
m->recHit()->isValid()) {
288 float localDphi =
normalized_phi(SCl_phi-
m->forwardPredictedState().globalPosition().phi()) ;
289 if(
std::abs(localDphi)>2.5)
continue;
290 CLHEP::Hep3Vector prediction(
m->forwardPredictedState().globalPosition().x(),
291 m->forwardPredictedState().globalPosition().y(),
292 m->forwardPredictedState().globalPosition().z());
293 LogDebug(
"") <<
"[PixelHitMatcher::compatibleHits] compatible hit position " <<
m->recHit()->globalPosition();
294 LogDebug(
"") <<
"[PixelHitMatcher::compatibleHits] predicted position " <<
m->forwardPredictedState().globalPosition();
295 pred1Meas.push_back( prediction);
297 validMeasurements.push_back(*
m);
299 LogDebug(
"") <<
"[PixelHitMatcher::compatibleHits] Found a rechit in layer ";
304 else LogDebug(
"") <<
"Could not downcast!!";
312 vector<TrajectoryMeasurement> pixel2Measurements =
313 theLayerMeasurements->measurements(**firstLayer,tsos,
314 *prop1stLayer, meas1stBLayer);
316 for (aMeas
m=pixel2Measurements.begin();
m!=pixel2Measurements.end();
m++){
317 if (
m->recHit()->isValid()) {
318 float localDphi =
normalized_phi(SCl_phi-
m->forwardPredictedState().globalPosition().phi()) ;
319 if(
std::abs(localDphi)>2.5)
continue;
320 CLHEP::Hep3Vector prediction(
m->forwardPredictedState().globalPosition().x(),
321 m->forwardPredictedState().globalPosition().y(),
322 m->forwardPredictedState().globalPosition().z());
323 pred1Meas.push_back( prediction);
324 LogDebug(
"") <<
"[PixelHitMatcher::compatibleHits] compatible hit position " <<
m->recHit()->globalPosition() << endl;
325 LogDebug(
"") <<
"[PixelHitMatcher::compatibleHits] predicted position " <<
m->forwardPredictedState().globalPosition() << endl;
327 validMeasurements.push_back(*
m);
328 LogDebug(
"") <<
"[PixelHitMatcher::compatibleHits] Found a rechit in layer ";
333 else LogDebug(
"") <<
"Could not downcast!!";
341 typedef vector<ForwardDetLayer*>::const_iterator ForwardLayerIterator;
342 ForwardLayerIterator flayer;
347 for (
int i=0;
i<2;
i++) {
348 i == 0 ? flayer = startLayers.pos1stFLayer() : flayer = startLayers.neg1stFLayer();
350 if (
i==0 && xmeas.
z() < -100. )
continue;
351 if (
i==1 && xmeas.
z() > 100. )
continue;
353 vector<TrajectoryMeasurement> pixelMeasurements =
354 theLayerMeasurements->measurements(**flayer, tsosfwd,
355 *prop1stLayer, meas1stFLayer);
357 for (aMeas
m=pixelMeasurements.begin();
m!=pixelMeasurements.end();
m++){
358 if (
m->recHit()->isValid()) {
359 float localDphi =
normalized_phi(SCl_phi-
m->forwardPredictedState().globalPosition().phi());
360 if(
std::abs(localDphi)>2.5)
continue;
361 CLHEP::Hep3Vector prediction(
m->forwardPredictedState().globalPosition().x(),
362 m->forwardPredictedState().globalPosition().y(),
363 m->forwardPredictedState().globalPosition().z());
364 pred1Meas.push_back( prediction);
366 validMeasurements.push_back(*
m);
371 if (searchInTIDTEC_) {
374 vector<TrajectoryMeasurement> pixel2Measurements =
375 theLayerMeasurements->measurements(**flayer, tsosfwd,
376 *prop1stLayer, meas1stFLayer);
378 for (aMeas
m=pixel2Measurements.begin();
m!=pixel2Measurements.end();
m++){
379 if (
m->recHit()->isValid()) {
380 float localDphi =
normalized_phi(SCl_phi-
m->forwardPredictedState().globalPosition().phi()) ;
381 if(
std::abs(localDphi)>2.5)
continue;
382 CLHEP::Hep3Vector prediction(
m->forwardPredictedState().globalPosition().x(),
383 m->forwardPredictedState().globalPosition().y(),
384 m->forwardPredictedState().globalPosition().z());
385 pred1Meas.push_back( prediction);
387 validMeasurements.push_back(*
m);
396 for (
unsigned i=0;
i<validMeasurements.size();
i++){
398 const DetLayer * newLayer = theGeometricSearchTracker->detLayer(validMeasurements[
i].recHit()->det()->geographicalId());
406 validMeasurements[
i].recHit()->localPosition()).
z();
407 double pxHit1x = validMeasurements[
i].recHit()->det()->surface().toGlobal(
408 validMeasurements[
i].recHit()->localPosition()).x();
409 double pxHit1y = validMeasurements[
i].recHit()->det()->surface().toGlobal(
410 validMeasurements[
i].recHit()->localPosition()).y();
411 double r1diff = (pxHit1x-vprim.
x())*(pxHit1x-vprim.
x()) + (pxHit1y-vprim.
y())*(pxHit1y-vprim.
y());
413 double r2diff = (xmeas.
x()-pxHit1x)*(xmeas.
x()-pxHit1x) + (xmeas.
y()-pxHit1y)*(xmeas.
y()-pxHit1y);
415 zVertex = pxHit1z - r1diff*(xmeas.
z()-pxHit1z)/r2diff;
424 { vertex_ = zVertex; }
427 GlobalPoint hitPos( validMeasurements[
i].recHit()->det()->surface().toGlobal( validMeasurements[
i].recHit()->localPosition() ) ) ;
432 prop2ndLayer, &meas2ndBLayer,&meas2ndFLayer,
433 tTopo,searchInTIDTEC_);
436 for (
unsigned it = 0; it < predictions.size(); it++) pred2Meas.push_back(predictions[it]);
454 pair<RecHitWithDist,ConstRecHitPointer> compatiblePair = pair<RecHitWithDist,ConstRecHitPointer>(rh,pxrh) ;
455 result.push_back(compatiblePair);
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
void setES(const MagneticField *, const MeasurementTracker *theMeasurementTracker, const TrackerGeometry *trackerGeometry)
Geom::Phi< T > phi() const
std::vector< CLHEP::Hep3Vector > predictionInNextLayers() const
const Plane & surface() const
The nominal surface of the GeomDet.
void set2ndLayer(float dummyphi2minB, float dummyphi2maxB, float dummyphi2minF, float dummyphi2maxF)
U second(std::pair< T, U > const &p)
void set1stLayerZRange(float zmin1, float zmax1)
PixelHitMatcher(float phi1min, float phi1max, float phi2minB, float phi2maxB, float phi2minF, float phi2maxF, float z2minB, float z2maxB, float r2minF, float r2maxF, float rMinI, float rMaxI, bool searchInTIDTEC)
std::vector< TrajectorySeed > TrajectorySeedCollection
recHitContainer::const_iterator const_iterator
RealType normalized_phi(RealType phi)
std::pair< const_iterator, const_iterator > range
std::vector< CLHEP::Hep3Vector > predicted1Hits()
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
GlobalVector momentum() const
GlobalPoint position() const
GlobalPoint position() const
std::vector< TrajectoryMeasurement > measurementsInNextLayers() const
const GlobalTrajectoryParameters & globalParameters() const
void set1stLayer(float dummyphi1min, float dummyphi1max)
std::vector< std::pair< RecHitWithDist, ConstRecHitPointer > > compatibleHits(const GlobalPoint &xmeas, const GlobalPoint &vprim, float energy, float charge, const TrackerTopology *tTopo)
virtual ~PixelHitMatcher()
std::vector< SeedWithInfo > compatibleSeeds(TrajectorySeedCollection *seeds, const GlobalPoint &xmeas, const GlobalPoint &vprim, float energy, float charge)
std::vector< CLHEP::Hep3Vector > predicted2Hits()
virtual const BoundCylinder & specificSurface() const GCC11_FINAL
Extension of the interface.
void setUseRecoVertex(bool val)