52 : dynamicphiroad_(pset.getParameter<bool>(
"dynamicPhiRoad")),
53 fromTrackerSeeds_(pset.getParameter<bool>(
"fromTrackerSeeds")),
54 useRecoVertex_(
false),
55 verticesTag_(ts.token_vtx),
56 beamSpotTag_(ts.token_bs),
57 lowPtThreshold_(pset.getParameter<double>(
"LowPtThreshold")),
58 highPtThreshold_(pset.getParameter<double>(
"HighPtThreshold")),
59 nSigmasDeltaZ1_(pset.getParameter<double>(
"nSigmasDeltaZ1")),
60 deltaZ1WithVertex_(0.5),
61 sizeWindowENeg_(pset.getParameter<double>(
"SizeWindowENeg")),
62 deltaPhi1Low_(pset.getParameter<double>(
"DeltaPhi1Low")),
63 deltaPhi1High_(pset.getParameter<double>(
"DeltaPhi1High")),
64 deltaPhi1Coef1_(0.), deltaPhi1Coef2_(0.),
65 myMatchEle(0), myMatchPos(0),
67 theMeasurementTracker(0),
68 theMeasurementTrackerEventTag(ts.token_measTrkEvt),
70 cacheIDMagField_(0),cacheIDNavSchool_(0),cacheIDCkfComp_(0),cacheIDTrkGeom_(0)
99 phiMin2B_, phiMax2B_, phiMin2F_, phiMax2F_,
111 phiMin2B_, phiMax2B_, phiMin2F_, phiMax2F_,
195 for ( i1=r1.first, i2=
r2.first, nHits=0 ; i1!=r1.second ; ++i1, ++i2, ++nHits )
197 if ( !i1->isValid() || !i2->isValid() )
return false ;
198 if ( i1->geographicalId()!=i2->geographicalId() )
return false ;
199 if ( ! ( i1->localPosition()==i2->localPosition() ) )
return false ;
210 theInitialSeedColl = seeds ;
244 e.
getByToken(theMeasurementTrackerEventTag, data);
245 myMatchEle->setEvent(*data);
246 myMatchPos->setEvent(*data);
256 if (useRecoVertex_) e.
getByToken(verticesTag_,theVertices);
258 if (!fromTrackerSeeds_)
259 {
throw cms::Exception(
"NotSupported") <<
"Here in ElectronSeedGenerator " << __FILE__ <<
":" << __LINE__ <<
" I would like to do theMeasurementTracker->update(e); but that no longer makes sense.\n";
262 for (
unsigned int i=0;
i<sclRefs.
size();++
i) {
266 LogDebug (
"run") <<
"new cluster, calling seedsFromThisCluster";
267 seedsFromThisCluster(sclRefs[
i],hoe1s[i],hoe2s[i],out,tTopo);
271 LogDebug (
"run") <<
"Nr of superclusters after filter: "<<sclRefs.
size()
272 <<
", no. of ElectronSeeds found = " << out.size();
277 float hoe1,
float hoe2,
280 float clusterEnergy = seedCluster->energy() ;
282 ( seedCluster->position().x(),
283 seedCluster->position().y(),
284 seedCluster->position().z() ) ;
292 float clusterEnergyT = clusterEnergy / cosh(
EleRelPoint(clusterPos,theBeamSpot->position()).
eta() ) ;
295 if (clusterEnergyT < lowPtThreshold_)
296 { deltaPhi1= deltaPhi1Low_ ; }
297 else if (clusterEnergyT > highPtThreshold_)
298 { deltaPhi1= deltaPhi1High_ ; }
300 { deltaPhi1 = deltaPhi1Coef1_ + deltaPhi1Coef2_/clusterEnergyT ; }
302 float ephimin1 = -deltaPhi1*sizeWindowENeg_ ;
303 float ephimax1 = deltaPhi1*(1.-sizeWindowENeg_);
304 float pphimin1 = -deltaPhi1*(1.-sizeWindowENeg_);
305 float pphimax1 = deltaPhi1*sizeWindowENeg_;
307 float phimin2B = -deltaPhi2B_/2. ;
308 float phimax2B = deltaPhi2B_/2. ;
309 float phimin2F = -deltaPhi2F_/2. ;
310 float phimax2F = deltaPhi2F_/2. ;
313 myMatchEle->set1stLayer(ephimin1,ephimax1);
314 myMatchPos->set1stLayer(pphimin1,pphimax1);
315 myMatchEle->set2ndLayer(phimin2B,phimax2B, phimin2F,phimax2F);
316 myMatchPos->set2ndLayer(phimin2B,phimax2B, phimin2F,phimax2F);
323 double sigmaZ=theBeamSpot->sigmaZ();
324 double sigmaZ0Error=theBeamSpot->sigmaZ0Error();
325 double sq=
sqrt(sigmaZ*sigmaZ+sigmaZ0Error*sigmaZ0Error);
326 double myZmin1=theBeamSpot->position().z()-nSigmasDeltaZ1_*sq;
327 double myZmax1=theBeamSpot->position().z()+nSigmasDeltaZ1_*sq;
332 myMatchEle->set1stLayerZRange(myZmin1,myZmax1);
333 myMatchPos->set1stLayerZRange(myZmin1,myZmax1);
335 if (!fromTrackerSeeds_)
338 std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > elePixelHits
339 = myMatchEle->compatibleHits(clusterPos,vertexPos,
340 clusterEnergy,-1., tTopo, *theNavigationSchool) ;
341 GlobalPoint eleVertex(theBeamSpot->position().x(),theBeamSpot->position().y(),myMatchEle->getVertex()) ;
342 seedsFromRecHits(elePixelHits,dir,eleVertex,caloCluster,out,
false) ;
344 std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > posPixelHits
345 = myMatchPos->compatibleHits(clusterPos,vertexPos,clusterEnergy,1.,tTopo, *theNavigationSchool) ;
346 GlobalPoint posVertex(theBeamSpot->position().x(),theBeamSpot->position().y(),myMatchPos->getVertex()) ;
347 seedsFromRecHits(posPixelHits,dir,posVertex,caloCluster,out,
true) ;
352 std::vector<SeedWithInfo> elePixelSeeds
353 = myMatchEle->compatibleSeeds(theInitialSeedColl,clusterPos,vertexPos,clusterEnergy,-1.) ;
354 seedsFromTrajectorySeeds(elePixelSeeds,caloCluster,hoe1,hoe2,out,
false) ;
356 std::vector<SeedWithInfo> posPixelSeeds
357 = myMatchPos->compatibleSeeds(theInitialSeedColl,clusterPos,vertexPos,clusterEnergy,1.) ;
358 seedsFromTrajectorySeeds(posPixelSeeds,caloCluster,hoe1,hoe2,out,
true) ;
365 myMatchEle->setUseRecoVertex(
true) ;
366 myMatchPos->setUseRecoVertex(
true) ;
368 const std::vector<reco::Vertex> * vtxCollection = theVertices.product() ;
369 std::vector<reco::Vertex>::const_iterator vtxIter ;
370 for (vtxIter = vtxCollection->begin(); vtxIter != vtxCollection->end() ; vtxIter++)
373 GlobalPoint vertexPos(vtxIter->position().x(),vtxIter->position().y(),vtxIter->position().z());
374 double myZmin1, myZmax1 ;
375 if (vertexPos.z()==theBeamSpot->position().z())
377 double sigmaZ=theBeamSpot->sigmaZ();
378 double sigmaZ0Error=theBeamSpot->sigmaZ0Error();
379 double sq=
sqrt(sigmaZ*sigmaZ+sigmaZ0Error*sigmaZ0Error);
380 myZmin1=theBeamSpot->position().z()-nSigmasDeltaZ1_*sq;
381 myZmax1=theBeamSpot->position().z()+nSigmasDeltaZ1_*sq;
385 myZmin1=vtxIter->position().z()-deltaZ1WithVertex_;
386 myZmax1=vtxIter->position().z()+deltaZ1WithVertex_;
389 myMatchEle->set1stLayerZRange(myZmin1,myZmax1);
390 myMatchPos->set1stLayerZRange(myZmin1,myZmax1);
392 if (!fromTrackerSeeds_)
395 std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > elePixelHits
396 = myMatchEle->compatibleHits(clusterPos,vertexPos,clusterEnergy,-1.,tTopo, *theNavigationSchool) ;
397 seedsFromRecHits(elePixelHits,dir,vertexPos,caloCluster,out,
false) ;
399 std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > posPixelHits
400 = myMatchPos->compatibleHits(clusterPos,vertexPos,clusterEnergy,1.,tTopo, *theNavigationSchool) ;
401 seedsFromRecHits(posPixelHits,dir,vertexPos,caloCluster,out,
true) ;
406 std::vector<SeedWithInfo> elePixelSeeds
407 = myMatchEle->compatibleSeeds(theInitialSeedColl,clusterPos,vertexPos,clusterEnergy,-1.) ;
408 seedsFromTrajectorySeeds(elePixelSeeds,caloCluster,hoe1,hoe2,out,
false) ;
410 std::vector<SeedWithInfo> posPixelSeeds
411 = myMatchPos->compatibleSeeds(theInitialSeedColl,clusterPos,vertexPos,clusterEnergy,1.) ;
412 seedsFromTrajectorySeeds(posPixelSeeds,caloCluster,hoe1,hoe2,out,
true) ;
421 ( std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > & pixelHits,
427 if (!pixelHits.empty())
428 {
LogDebug(
"ElectronSeedGenerator") <<
"Compatible "<<(positron?
"positron":
"electron")<<
" hits found." ; }
430 std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> >::iterator
v ;
431 for ( v = pixelHits.begin() ; v != pixelHits.end() ; v++ )
434 { (*v).first.invert() ; }
435 if (!prepareElTrackSeed((*v).first.recHit(),(*v).second,vertexPos))
439 addSeed(seed,0,positron,out) ;
444 (
const std::vector<SeedWithInfo> & pixelSeeds,
446 float hoe1,
float hoe2,
450 if (!pixelSeeds.empty())
451 {
LogDebug(
"ElectronSeedGenerator") <<
"Compatible "<<(positron?
"positron":
"electron")<<
" seeds found." ; }
453 std::vector<SeedWithInfo>::const_iterator
s;
454 for ( s = pixelSeeds.begin() ; s != pixelSeeds.end() ; s++ )
457 seed.setCaloCluster(cluster,s->hitsMask(),s->subDet2(),s->subDet1(),hoe1,hoe2) ;
458 addSeed(
seed,&*s,positron,out) ;
469 { out.push_back(seed) ;
return ; }
475 reco::ElectronSeedCollection::iterator resItr ;
476 for ( resItr=out.begin() ; resItr!=out.end() ; ++resItr )
478 if ( (seed.
caloCluster()==resItr->caloCluster()) &&
479 (seed.
hitsMask()==resItr->hitsMask()) &&
488 seed.
setNegAttributes(resItr->dRz2(),resItr->dPhi2(),resItr->dRz1(),resItr->dPhi1()) ;
495 if ( resItr->dRz2Pos()!=seed.
dRz2Pos() )
498 <<
"this similar old seed already has another dRz2Pos"
499 <<
"\nold seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(
unsigned int)resItr->hitsMask()<<
"/"<<resItr->dRz2()<<
"/"<<resItr->dPhi2()<<
"/"<<resItr->dRz2Pos()<<
"/"<<resItr->dPhi2Pos()
500 <<
"\nnew seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(
unsigned int)seed.
hitsMask()<<
"/"<<seed.
dRz2()<<
"/"<<seed.
dPhi2()<<
"/"<<seed.
dRz2Pos()<<
"/"<<seed.
dPhi2Pos() ;
525 seed.
setPosAttributes(resItr->dRz2Pos(),resItr->dPhi2Pos(),resItr->dRz1Pos(),resItr->dPhi1Pos()) ;
532 if (resItr->dRz2()!=seed.
dRz2())
535 <<
"this old seed already has another dRz2"
536 <<
"\nold seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(
unsigned int)resItr->hitsMask()<<
"/"<<resItr->dRz2()<<
"/"<<resItr->dPhi2()<<
"/"<<resItr->dRz2Pos()<<
"/"<<resItr->dPhi2Pos()
537 <<
"\nnew seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(
unsigned int)seed.
hitsMask()<<
"/"<<seed.
dRz2()<<
"/"<<seed.
dPhi2()<<
"/"<<seed.
dRz2Pos()<<
"/"<<seed.
dPhi2Pos() ;
560 out.push_back(seed) ;
570 LogDebug(
"") <<
"[ElectronSeedGenerator::prepareElTrackSeed] inner PixelHit x,y,z "<<innerhit->globalPosition();
571 LogDebug(
"") <<
"[ElectronSeedGenerator::prepareElTrackSeed] outer PixelHit x,y,z "<<outerhit->globalPosition();
580 recHits_.push_back(pixhit);
582 constpixhit = dynamic_cast <
const SiPixelRecHit *> (outerhit->hit());
585 recHits_.push_back(pixhit);
590 recHits_.push_back(striphit);
599 float nomField = bfield->nominalValue();
602 FastHelix helix(outerhit->globalPosition(),innerhit->globalPosition(),vertexPos,nomField,&*bfield);
603 if ( !helix.isValid()) {
607 TSOS propagatedState = thePropagator->propagate(fts,innerhit->det()->surface()) ;
608 if (!propagatedState.isValid())
610 TSOS updatedState = theUpdator->update(propagatedState, *innerhit);
612 TSOS propagatedState_out = thePropagator->propagate(updatedState,outerhit->det()->
surface()) ;
613 if (!propagatedState_out.
isValid())
615 TSOS updatedState_out = theUpdator->update(propagatedState_out, *outerhit);
PropagationDirection direction() const
void setCaloCluster(const CaloClusterRef &, unsigned char hitsMask=0, int subDet2=0, int subDet1=0, float hoe1=std::numeric_limits< float >::infinity(), float hoe2=std::numeric_limits< float >::infinity())
T getParameter(std::string const &) const
unsigned long long cacheIdentifier() const
unsigned long long cacheIDNavSchool_
PixelHitMatcher * myMatchEle
void setupES(const edm::EventSetup &setup)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
LocalPoint position() const
Local x and y position coordinates.
TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer
void setES(const MagneticField *, const MeasurementTracker *theMeasurementTracker, const TrackerGeometry *trackerGeometry)
const NavigationSchool * theNavigationSchool
GlobalPoint globalPosition() const
unsigned long long cacheIDMagField_
void run(edm::Event &, const edm::EventSetup &setup, const reco::SuperClusterRefVector &, const std::vector< float > &hoe1s, const std::vector< float > &hoe2s, TrajectorySeedCollection *seeds, reco::ElectronSeedCollection &)
unsigned long long cacheIDTrkGeom_
CaloClusterRef caloCluster() const
const SurfaceType & surface() const
edm::ESHandle< TrackerGeometry > theTrackerGeometry
void seedsFromThisCluster(edm::Ref< reco::SuperClusterCollection > seedCluster, float hoe1, float hoe2, reco::ElectronSeedCollection &out, const TrackerTopology *tTopo)
std::vector< TrajectorySeed > TrajectorySeedCollection
recHitContainer::const_iterator const_iterator
std::pair< const_iterator, const_iterator > range
void setNegAttributes(float dRz2=std::numeric_limits< float >::infinity(), float dPhi2=std::numeric_limits< float >::infinity(), float dRz1=std::numeric_limits< float >::infinity(), float dPhi1=std::numeric_limits< float >::infinity())
unsigned int detId() const
PropagatorWithMaterial * thePropagator
LocalVector momentum() const
Momentum vector in the local frame.
std::vector< ElectronSeed > ElectronSeedCollection
collection of ElectronSeed objects
PixelHitMatcher * myMatchPos
void seedsFromRecHits(std::vector< std::pair< RecHitWithDist, ConstRecHitPointer > > &elePixelHits, PropagationDirection &dir, const GlobalPoint &vertexPos, const reco::ElectronSeed::CaloClusterRef &cluster, reco::ElectronSeedCollection &out, bool positron)
bool prepareElTrackSeed(ConstRecHitPointer outerhit, ConstRecHitPointer innerhit, const GlobalPoint &vertexPos)
TrajectoryStateOnSurface TSOS
PTrajectoryStateOnDet const & startingState() const
void addSeed(reco::ElectronSeed &seed, const SeedWithInfo *info, bool positron, reco::ElectronSeedCollection &out)
T const * product() const
ElectronSeedGenerator(const edm::ParameterSet &, const Tokens &)
void ele_convert(const Type1 &obj1, Type2 &obj2)
TrackCharge charge() const
Charge (-1, 0 or 1)
edm::ESHandle< MagneticField > theMagField
bool equivalent(const TrajectorySeed &s1, const TrajectorySeed &s2)
unsigned int nHits() const
char data[epos_bytes_allocation]
GlobalVector globalMomentum() const
void display_seed(const std::string &title1, const std::string &title2, const reco::ElectronSeed &seed, edm::ESHandle< TrackerGeometry > trackerGeometry)
const MeasurementTracker * theMeasurementTracker
size_type size() const
Size of the RefVector.
volatile std::atomic< bool > shutdown_flag false
void setPosAttributes(float dRz2=std::numeric_limits< float >::infinity(), float dPhi2=std::numeric_limits< float >::infinity(), float dRz1=std::numeric_limits< float >::infinity(), float dPhi1=std::numeric_limits< float >::infinity())
void seedsFromTrajectorySeeds(const std::vector< SeedWithInfo > &elePixelSeeds, const reco::ElectronSeed::CaloClusterRef &cluster, float hoe1, float hoe2, reco::ElectronSeedCollection &out, bool positron)
std::string theMeasurementTrackerName
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
const LocalTrajectoryParameters & parameters() const
unsigned char hitsMask() const
unsigned long long cacheIDCkfComp_