16 using namespace reco ;
20 (
float phi1min,
float phi1max,
21 float phi2minB,
float phi2maxB,
float phi2minF,
float phi2maxF,
22 float z2minB,
float z2maxB,
float r2minF,
float r2maxF,
23 float rMinI,
float rMaxI,
bool searchInTIDTEC)
25 meas1stBLayer(phi1min,phi1max,0.,0.), meas2ndBLayer(phi2minB,phi2maxB,z2minB,z2maxB),
26 meas1stFLayer(phi1min,phi1max,0.,0.), meas2ndFLayer(phi2minF,phi2maxF,r2minF,r2maxF),
28 prop1stLayer(0), prop2ndLayer(0),theGeometricSearchTracker(0),theTrackerEvent(0),theTracker(0),vertex_(0.),
29 searchInTIDTEC_(searchInTIDTEC), useRecoVertex_(
false)
31 meas1stFLayer.setRRangeI(rMinI,rMaxI) ;
32 meas2ndFLayer.setRRangeI(rMinI,rMaxI) ;
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 ; }
64 theTrackerEvent = & trackerData;
72 if (theMeasurementTracker)
74 theTracker = theMeasurementTracker;
75 theGeometricSearchTracker=theMeasurementTracker->geometricSearchTracker() ;
76 startLayers.setup(theGeometricSearchTracker) ;
79 theMagField = magField ;
80 theTrackerGeometry = trackerGeometry ;
82 if (prop1stLayer)
delete prop1stLayer ;
84 if (prop2ndLayer)
delete prop2ndLayer ;
89 {
return pred1Meas ; }
92 {
return pred2Meas ; }
100 std::vector<SeedWithInfo>
105 int charge = int(fcharge) ;
111 std::vector<SeedWithInfo>
result ;
114 mapTsos_.reserve(seeds->size()) ;
115 mapTsos2_.reserve(seeds->size()) ;
117 for (
unsigned int i=0;
i<seeds->size();++
i)
119 if ((*seeds)[
i].nHits()>9)
121 edm::LogWarning(
"GsfElectronAlgo|UnexpectedSeed") <<
"We cannot deal with seeds having more than 9 hits." ;
127 unsigned char rank1, rank2, hitsMask ;
129 for ( rank1=0, it1=rhits.first ; it1!=rhits.second ; rank1++, it1++ )
131 for ( rank2=rank1+1, it2=it1+1 ; it2!=rhits.second ; rank2++, it2++ )
137 if (!(*it).isValid())
continue;
138 DetId id=(*it).geographicalId();
139 const GeomDet *geomdet=theTrackerGeometry->idToDet((*it).geographicalId());
145 std::vector<std::pair<const GeomDet *, TrajectoryStateOnSurface> >::iterator itTsos ;
146 for (itTsos=mapTsos_.begin();itTsos!=mapTsos_.end();++itTsos)
148 if ((*itTsos).first==geomdet)
149 { found=
true ; break ; }
153 tsos1 = prop1stLayer->propagate(tsos,geomdet->
surface()) ;
154 mapTsos_.push_back(std::pair<const GeomDet *, TrajectoryStateOnSurface>(geomdet,tsos1));
157 { tsos1=(*itTsos).second ; }
161 std::pair<bool,double> est;
162 if (
id.subdetId()%2==1) est=meas1stBLayer.estimate(vprim, tsos1,hitPos);
163 else est=meas1stFLayer.estimate(vprim, tsos1,hitPos);
164 if (!est.first) continue ;
168 int subDet1 =
id.subdetId() ;
169 float dRz1 = (subDet1%2==1)?pp1.
dZ():pp1.dPerp() ;
170 float dPhi1 = pp1.dPhi() ;
176 if (!(*it).isValid())
continue ;
178 DetId id2=(*it).geographicalId();
179 const GeomDet *geomdet2=theTrackerGeometry->idToDet((*it).geographicalId());
186 double pxHit1z = hitPos.
z();
187 double pxHit1x = hitPos.
x();
188 double pxHit1y = hitPos.
y();
189 double r1diff = (pxHit1x-vprim.
x())*(pxHit1x-vprim.
x()) + (pxHit1y-vprim.
y())*(pxHit1y-vprim.
y()) ;
190 r1diff=
sqrt(r1diff) ;
191 double r2diff = (xmeas.
x()-pxHit1x)*(xmeas.
x()-pxHit1x) + (xmeas.
y()-pxHit1y)*(xmeas.
y()-pxHit1y) ;
193 zVertex = pxHit1z - r1diff*(xmeas.
z()-pxHit1z)/r2diff;
196 { zVertex = vprim.
z() ; }
203 for (itTsos2=mapTsos2_.begin();itTsos2!=mapTsos2_.end();++itTsos2)
205 if (((*itTsos2).first).first==geomdet2 &&
206 (((*itTsos2).first).
second).x()==hitPos.
x() &&
207 (((*itTsos2).first).
second).y()==hitPos.
y() &&
208 (((*itTsos2).first).
second).z()==hitPos.
z() )
216 tsos2 = prop2ndLayer->propagate(fts2,geomdet2->
surface()) ;
217 std::pair<const GeomDet *,GlobalPoint> pair(geomdet2,hitPos);
221 { tsos2=(*itTsos2).second ; }
227 std::pair<bool,double> est2 ;
228 if (id2.
subdetId()%2==1) est2=meas2ndBLayer.estimate(vertex, tsos2,hitPos2) ;
229 else est2=meas2ndFLayer.estimate(vertex, tsos2,hitPos2) ;
234 float dRz2 = (subDet2%2==1)?pp2.dZ():pp2.dPerp() ;
235 float dPhi2 = pp2.dPhi() ;
236 hitsMask = (1<<rank1)|(1<<rank2) ;
237 result.push_back(
SeedWithInfo((*seeds)[
i],hitsMask,subDet2,dRz2,dPhi2,subDet1,dRz1,dPhi1)) ;
253 vector< pair< RecHitWithDist, PixelHitMatcher::ConstRecHitPointer > >
257 float energy,
float fcharge,
260 float SCl_phi = xmeas.
phi();
262 int charge = int(fcharge);
264 vector<pair<RecHitWithDist, ConstRecHitPointer> >
result;
265 LogDebug(
"") <<
"[PixelHitMatcher::compatibleHits] entering .. ";
267 vector<TrajectoryMeasurement> validMeasurements;
268 vector<TrajectoryMeasurement> invalidMeasurements;
270 typedef vector<TrajectoryMeasurement>::const_iterator aMeas;
275 typedef vector<BarrelDetLayer*>::const_iterator BarrelLayerIterator;
276 BarrelLayerIterator firstLayer = startLayers.firstBLayer();
284 vector<TrajectoryMeasurement> pixelMeasurements =
285 theLayerMeasurements.measurements(**firstLayer,tsos,
286 *prop1stLayer, meas1stBLayer);
288 LogDebug(
"") <<
"[PixelHitMatcher::compatibleHits] nbr of hits compatible with extrapolation to first layer: " << pixelMeasurements.size();
289 for (aMeas
m=pixelMeasurements.begin();
m!=pixelMeasurements.end();
m++){
290 if (
m->recHit()->isValid()) {
291 float localDphi =
normalized_phi(SCl_phi-
m->forwardPredictedState().globalPosition().phi()) ;
292 if(
std::abs(localDphi)>2.5)
continue;
293 CLHEP::Hep3Vector prediction(
m->forwardPredictedState().globalPosition().x(),
294 m->forwardPredictedState().globalPosition().y(),
295 m->forwardPredictedState().globalPosition().z());
296 LogDebug(
"") <<
"[PixelHitMatcher::compatibleHits] compatible hit position " <<
m->recHit()->globalPosition();
297 LogDebug(
"") <<
"[PixelHitMatcher::compatibleHits] predicted position " <<
m->forwardPredictedState().globalPosition();
298 pred1Meas.push_back( prediction);
300 validMeasurements.push_back(*
m);
302 LogDebug(
"") <<
"[PixelHitMatcher::compatibleHits] Found a rechit in layer ";
307 else LogDebug(
"") <<
"Could not downcast!!";
315 vector<TrajectoryMeasurement> pixel2Measurements =
316 theLayerMeasurements.measurements(**firstLayer,tsos,
317 *prop1stLayer, meas1stBLayer);
319 for (aMeas
m=pixel2Measurements.begin();
m!=pixel2Measurements.end();
m++){
320 if (
m->recHit()->isValid()) {
321 float localDphi =
normalized_phi(SCl_phi-
m->forwardPredictedState().globalPosition().phi()) ;
322 if(
std::abs(localDphi)>2.5)
continue;
323 CLHEP::Hep3Vector prediction(
m->forwardPredictedState().globalPosition().x(),
324 m->forwardPredictedState().globalPosition().y(),
325 m->forwardPredictedState().globalPosition().z());
326 pred1Meas.push_back( prediction);
327 LogDebug(
"") <<
"[PixelHitMatcher::compatibleHits] compatible hit position " <<
m->recHit()->globalPosition() << endl;
328 LogDebug(
"") <<
"[PixelHitMatcher::compatibleHits] predicted position " <<
m->forwardPredictedState().globalPosition() << endl;
330 validMeasurements.push_back(*
m);
331 LogDebug(
"") <<
"[PixelHitMatcher::compatibleHits] Found a rechit in layer ";
336 else LogDebug(
"") <<
"Could not downcast!!";
344 typedef vector<ForwardDetLayer*>::const_iterator ForwardLayerIterator;
345 ForwardLayerIterator flayer;
350 for (
int i=0;
i<2;
i++) {
351 i == 0 ? flayer = startLayers.pos1stFLayer() : flayer = startLayers.neg1stFLayer();
353 if (
i==0 && xmeas.
z() < -100. )
continue;
354 if (
i==1 && xmeas.
z() > 100. )
continue;
356 vector<TrajectoryMeasurement> pixelMeasurements =
357 theLayerMeasurements.measurements(**flayer, tsosfwd,
358 *prop1stLayer, meas1stFLayer);
360 for (aMeas
m=pixelMeasurements.begin();
m!=pixelMeasurements.end();
m++){
361 if (
m->recHit()->isValid()) {
362 float localDphi =
normalized_phi(SCl_phi-
m->forwardPredictedState().globalPosition().phi());
363 if(
std::abs(localDphi)>2.5)
continue;
364 CLHEP::Hep3Vector prediction(
m->forwardPredictedState().globalPosition().x(),
365 m->forwardPredictedState().globalPosition().y(),
366 m->forwardPredictedState().globalPosition().z());
367 pred1Meas.push_back( prediction);
369 validMeasurements.push_back(*
m);
374 if (searchInTIDTEC_) {
377 vector<TrajectoryMeasurement> pixel2Measurements =
378 theLayerMeasurements.measurements(**flayer, tsosfwd,
379 *prop1stLayer, meas1stFLayer);
381 for (aMeas
m=pixel2Measurements.begin();
m!=pixel2Measurements.end();
m++){
382 if (
m->recHit()->isValid()) {
383 float localDphi =
normalized_phi(SCl_phi-
m->forwardPredictedState().globalPosition().phi()) ;
384 if(
std::abs(localDphi)>2.5)
continue;
385 CLHEP::Hep3Vector prediction(
m->forwardPredictedState().globalPosition().x(),
386 m->forwardPredictedState().globalPosition().y(),
387 m->forwardPredictedState().globalPosition().z());
388 pred1Meas.push_back( prediction);
390 validMeasurements.push_back(*
m);
399 for (
unsigned i=0;
i<validMeasurements.size();
i++){
401 const DetLayer * newLayer = theGeometricSearchTracker->detLayer(validMeasurements[
i].recHit()->det()->geographicalId());
409 validMeasurements[
i].recHit()->localPosition()).
z();
410 double pxHit1x = validMeasurements[
i].recHit()->det()->surface().toGlobal(
411 validMeasurements[
i].recHit()->localPosition()).x();
412 double pxHit1y = validMeasurements[
i].recHit()->det()->surface().toGlobal(
413 validMeasurements[
i].recHit()->localPosition()).y();
414 double r1diff = (pxHit1x-vprim.
x())*(pxHit1x-vprim.
x()) + (pxHit1y-vprim.
y())*(pxHit1y-vprim.
y());
416 double r2diff = (xmeas.
x()-pxHit1x)*(xmeas.
x()-pxHit1x) + (xmeas.
y()-pxHit1y)*(xmeas.
y()-pxHit1y);
418 zVertex = pxHit1z - r1diff*(xmeas.
z()-pxHit1z)/r2diff;
427 { vertex_ = zVertex; }
430 GlobalPoint hitPos( validMeasurements[
i].recHit()->det()->surface().toGlobal( validMeasurements[
i].recHit()->localPosition() ) ) ;
435 prop2ndLayer, &meas2ndBLayer,&meas2ndFLayer,
436 tTopo,searchInTIDTEC_);
439 for (
unsigned it = 0; it < predictions.size(); it++) pred2Meas.push_back(predictions[it]);
457 pair<RecHitWithDist,ConstRecHitPointer> compatiblePair = pair<RecHitWithDist,ConstRecHitPointer>(rh,pxrh) ;
458 result.push_back(compatiblePair);
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
static FreeTrajectoryState get(MagneticField const &magField, GlobalPoint const &xmeas, GlobalPoint const &xvert, float momentum, TrackCharge charge)
void setEvent(const MeasurementTrackerEvent &event)
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)
Abs< T >::type abs(const T &t)
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)