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 typedef std::unordered_map<const GeomDet *, TrajectoryStateOnSurface> DetTsosAssoc;
107 const int charge = int(fcharge) ;
109 const double xmeas_phi = xmeas.
phi();
114 std::vector<SeedWithInfo>
result ;
116 mapTsos_fast_.clear();
117 mapTsos2_fast_.clear();
118 mapTsos_fast_.reserve(seeds->size()) ;
119 mapTsos2_fast_.reserve(seeds->size()) ;
121 for(
const auto&
seed : *seeds) {
123 if(
seed.nHits() > 9 ) {
124 edm::LogWarning(
"GsfElectronAlgo|UnexpectedSeed") <<
"We cannot deal with seeds having more than 9 hits." ;
129 for(
auto it = hits.first; it != hits.second; ++it ) {
130 hit_gp_map_.emplace_back(it->globalPosition());
133 for(
auto it1 = hits.first; it1 != hits.second; ++it1 ) {
134 if( !it1->isValid() )
continue;
135 const unsigned idx1 = std::distance(hits.first,it1);
136 const DetId id1 = it1->geographicalId();
137 const GeomDet *geomdet1 = it1->det();
141 DetTsosAssoc::iterator tsos1_itr = mapTsos_fast_.find(geomdet1);
142 if( tsos1_itr != mapTsos_fast_.end() ) {
143 tsos1 = &(tsos1_itr->second);
146 mapTsos_fast_.emplace(geomdet1,prop1stLayer->propagate(tsos,geomdet1->
surface()));
147 tsos1 = &(empl_result.first->second);
149 if( !tsos1->
isValid() )
continue;
150 std::pair<bool, double> est = ( id1.
subdetId() % 2 ?
151 meas1stBLayer.estimate(vprim, *tsos1, hit1Pos) :
152 meas1stFLayer.estimate(vprim, *tsos1, hit1Pos) );
153 if( !est.first )
continue;
158 const float dRz1 = ( id1.
subdetId()%2 ? pp1.dZ() : pp1.dPerp() );
159 const float dPhi1 = pp1.dPhi();
162 if (!useRecoVertex_) {
165 const double pxHit1z = hit1Pos.
z();
166 const double pxHit1x = hit1Pos.
x();
167 const double pxHit1y = hit1Pos.
y();
168 const double r1diff =
std::sqrt( (pxHit1x-vprim.
x())*(pxHit1x-vprim.
x()) +
169 (pxHit1y-vprim.
y())*(pxHit1y-vprim.
y()) );
170 const double r2diff =
std::sqrt( (xmeas.
x()-pxHit1x)*(xmeas.
x()-pxHit1x) +
171 (xmeas.
y()-pxHit1y)*(xmeas.
y()-pxHit1y) );
172 zVertex = pxHit1z - r1diff*(xmeas.
z()-pxHit1z)/r2diff;
180 for(
auto it2 = it1+1; it2 != hits.second; ++it2 ) {
181 if( !it2->isValid() )
continue;
182 const unsigned idx2 = std::distance(hits.first,it2);
183 const DetId id2 = it2->geographicalId();
184 const GeomDet *geomdet2 = it2->det();
185 const std::pair<const GeomDet*,GlobalPoint> det_key(geomdet2,hit1Pos);
187 PosTsosAssoc::iterator tsos2_itr = mapTsos2_fast_.find(det_key);
188 if( tsos2_itr != mapTsos2_fast_.end() ) {
189 tsos2 = &(tsos2_itr->second);
192 mapTsos2_fast_.emplace(det_key,prop2ndLayer->propagate(fts2,geomdet2->
surface()));
193 tsos2 = &(empl_result.first->second);
195 if( !tsos2->
isValid() )
continue;
197 std::pair<bool,double> est2 = ( id2.
subdetId()%2 ?
198 meas2ndBLayer.estimate(vertex, *tsos2,hit2Pos) :
199 meas2ndFLayer.estimate(vertex, *tsos2,hit2Pos) );
203 const float dRz2 = (subDet2%2==1)?pp2.dZ():pp2.dPerp();
204 const float dPhi2 = pp2.dPhi();
205 const unsigned char hitsMask = (1<<idx1)|(1<<idx2);
206 result.push_back(
SeedWithInfo(
seed,hitsMask,subDet2,dRz2,dPhi2,subDet1,dRz1,dPhi1)) ;
212 mapTsos_fast_.clear() ;
213 mapTsos2_fast_.clear() ;
220 vector< pair< RecHitWithDist, PixelHitMatcher::ConstRecHitPointer > >
224 float energy,
float fcharge,
228 float SCl_phi = xmeas.
phi();
230 int charge = int(fcharge);
232 vector<pair<RecHitWithDist, ConstRecHitPointer> >
result;
233 LogDebug(
"") <<
"[PixelHitMatcher::compatibleHits] entering .. ";
235 vector<TrajectoryMeasurement> validMeasurements;
236 vector<TrajectoryMeasurement> invalidMeasurements;
238 typedef vector<TrajectoryMeasurement>::const_iterator aMeas;
243 typedef vector<const BarrelDetLayer*>::const_iterator BarrelLayerIterator;
244 BarrelLayerIterator firstLayer = startLayers.firstBLayer();
252 vector<TrajectoryMeasurement> pixelMeasurements =
253 theLayerMeasurements.measurements(**firstLayer,tsos,
254 *prop1stLayer, meas1stBLayer);
256 LogDebug(
"") <<
"[PixelHitMatcher::compatibleHits] nbr of hits compatible with extrapolation to first layer: " << pixelMeasurements.size();
257 for (aMeas
m=pixelMeasurements.begin();
m!=pixelMeasurements.end();
m++){
258 if (
m->recHit()->isValid()) {
259 float localDphi =
normalized_phi(SCl_phi-
m->forwardPredictedState().globalPosition().phi()) ;
260 if(
std::abs(localDphi)>2.5)
continue;
261 CLHEP::Hep3Vector prediction(
m->forwardPredictedState().globalPosition().x(),
262 m->forwardPredictedState().globalPosition().y(),
263 m->forwardPredictedState().globalPosition().z());
264 LogDebug(
"") <<
"[PixelHitMatcher::compatibleHits] compatible hit position " <<
m->recHit()->globalPosition();
265 LogDebug(
"") <<
"[PixelHitMatcher::compatibleHits] predicted position " <<
m->forwardPredictedState().globalPosition();
266 pred1Meas.push_back( prediction);
268 validMeasurements.push_back(*
m);
270 LogDebug(
"") <<
"[PixelHitMatcher::compatibleHits] Found a rechit in layer ";
275 else LogDebug(
"") <<
"Could not downcast!!";
283 vector<TrajectoryMeasurement> pixel2Measurements =
284 theLayerMeasurements.measurements(**firstLayer,tsos,
285 *prop1stLayer, meas1stBLayer);
287 for (aMeas
m=pixel2Measurements.begin();
m!=pixel2Measurements.end();
m++){
288 if (
m->recHit()->isValid()) {
289 float localDphi =
normalized_phi(SCl_phi-
m->forwardPredictedState().globalPosition().phi()) ;
290 if(
std::abs(localDphi)>2.5)
continue;
291 CLHEP::Hep3Vector prediction(
m->forwardPredictedState().globalPosition().x(),
292 m->forwardPredictedState().globalPosition().y(),
293 m->forwardPredictedState().globalPosition().z());
294 pred1Meas.push_back( prediction);
295 LogDebug(
"") <<
"[PixelHitMatcher::compatibleHits] compatible hit position " <<
m->recHit()->globalPosition() << endl;
296 LogDebug(
"") <<
"[PixelHitMatcher::compatibleHits] predicted position " <<
m->forwardPredictedState().globalPosition() << endl;
298 validMeasurements.push_back(*
m);
299 LogDebug(
"") <<
"[PixelHitMatcher::compatibleHits] Found a rechit in layer ";
304 else LogDebug(
"") <<
"Could not downcast!!";
312 typedef vector<const ForwardDetLayer*>::const_iterator ForwardLayerIterator;
313 ForwardLayerIterator flayer;
318 for (
int i=0;
i<2;
i++) {
319 i == 0 ? flayer = startLayers.pos1stFLayer() : flayer = startLayers.neg1stFLayer();
321 if (
i==0 && xmeas.
z() < -100. )
continue;
322 if (
i==1 && xmeas.
z() > 100. )
continue;
324 vector<TrajectoryMeasurement> pixelMeasurements =
325 theLayerMeasurements.measurements(**flayer, tsosfwd,
326 *prop1stLayer, meas1stFLayer);
328 for (aMeas
m=pixelMeasurements.begin();
m!=pixelMeasurements.end();
m++){
329 if (
m->recHit()->isValid()) {
330 float localDphi =
normalized_phi(SCl_phi-
m->forwardPredictedState().globalPosition().phi());
331 if(
std::abs(localDphi)>2.5)
continue;
332 CLHEP::Hep3Vector prediction(
m->forwardPredictedState().globalPosition().x(),
333 m->forwardPredictedState().globalPosition().y(),
334 m->forwardPredictedState().globalPosition().z());
335 pred1Meas.push_back( prediction);
337 validMeasurements.push_back(*
m);
342 if (searchInTIDTEC_) {
345 vector<TrajectoryMeasurement> pixel2Measurements =
346 theLayerMeasurements.measurements(**flayer, tsosfwd,
347 *prop1stLayer, meas1stFLayer);
349 for (aMeas
m=pixel2Measurements.begin();
m!=pixel2Measurements.end();
m++){
350 if (
m->recHit()->isValid()) {
351 float localDphi =
normalized_phi(SCl_phi-
m->forwardPredictedState().globalPosition().phi()) ;
352 if(
std::abs(localDphi)>2.5)
continue;
353 CLHEP::Hep3Vector prediction(
m->forwardPredictedState().globalPosition().x(),
354 m->forwardPredictedState().globalPosition().y(),
355 m->forwardPredictedState().globalPosition().z());
356 pred1Meas.push_back( prediction);
358 validMeasurements.push_back(*
m);
367 for (
unsigned i=0;
i<validMeasurements.size();
i++){
369 const DetLayer * newLayer = theGeometricSearchTracker->detLayer(validMeasurements[
i].recHit()->det()->geographicalId());
377 validMeasurements[
i].recHit()->localPosition()).
z();
378 double pxHit1x = validMeasurements[
i].recHit()->det()->surface().toGlobal(
379 validMeasurements[
i].recHit()->localPosition()).x();
380 double pxHit1y = validMeasurements[
i].recHit()->det()->surface().toGlobal(
381 validMeasurements[
i].recHit()->localPosition()).y();
382 double r1diff = (pxHit1x-vprim.
x())*(pxHit1x-vprim.
x()) + (pxHit1y-vprim.
y())*(pxHit1y-vprim.
y());
384 double r2diff = (xmeas.
x()-pxHit1x)*(xmeas.
x()-pxHit1x) + (xmeas.
y()-pxHit1y)*(xmeas.
y()-pxHit1y);
386 zVertex = pxHit1z - r1diff*(xmeas.
z()-pxHit1z)/r2diff;
395 { vertex_ = zVertex; }
398 GlobalPoint hitPos( validMeasurements[
i].recHit()->det()->surface().toGlobal( validMeasurements[
i].recHit()->localPosition() ) ) ;
403 prop2ndLayer, &meas2ndBLayer,&meas2ndFLayer,
404 tTopo,navigationSchool,searchInTIDTEC_);
407 for (
unsigned it = 0; it < predictions.size(); it++) pred2Meas.push_back(predictions[it]);
425 pair<RecHitWithDist,ConstRecHitPointer> compatiblePair = pair<RecHitWithDist,ConstRecHitPointer>(rh,pxrh) ;
426 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.
TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer
void set2ndLayer(float dummyphi2minB, float dummyphi2maxB, float dummyphi2minF, float dummyphi2maxF)
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
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)
XYZPointD XYZPoint
point in space with cartesian internal representation
virtual const BoundCylinder & specificSurface() const
Extension of the interface.
virtual ~PixelHitMatcher()
std::vector< SeedWithInfo > compatibleSeeds(TrajectorySeedCollection *seeds, const GlobalPoint &xmeas, const GlobalPoint &vprim, float energy, float charge)
std::vector< CLHEP::Hep3Vector > predicted2Hits()
std::vector< std::pair< RecHitWithDist, ConstRecHitPointer > > compatibleHits(const GlobalPoint &xmeas, const GlobalPoint &vprim, float energy, float charge, const TrackerTopology *tTopo, const NavigationSchool &navigationSchool)
void setUseRecoVertex(bool val)