55 : dynamicphiroad_(pset.getParameter<bool>(
"dynamicPhiRoad")),
56 fromTrackerSeeds_(pset.getParameter<bool>(
"fromTrackerSeeds")),
57 useRecoVertex_(
false),
58 verticesTag_(
"offlinePrimaryVerticesWithBS"),
59 beamSpotTag_(
"offlineBeamSpot"),
60 lowPtThreshold_(pset.getParameter<double>(
"LowPtThreshold")),
61 highPtThreshold_(pset.getParameter<double>(
"HighPtThreshold")),
62 nSigmasDeltaZ1_(pset.getParameter<double>(
"nSigmasDeltaZ1")),
63 deltaZ1WithVertex_(0.5),
64 sizeWindowENeg_(pset.getParameter<double>(
"SizeWindowENeg")),
65 deltaPhi1Low_(pset.getParameter<double>(
"DeltaPhi1Low")),
66 deltaPhi1High_(pset.getParameter<double>(
"DeltaPhi1High")),
67 deltaPhi1Coef1_(0.), deltaPhi1Coef2_(0.),
68 myMatchEle(0), myMatchPos(0),
70 theMeasurementTracker(0),
72 cacheIDMagField_(0),cacheIDNavSchool_(0),cacheIDCkfComp_(0),cacheIDTrkGeom_(0)
82 if (pset.
exists(
"measurementTrackerName"))
86 if (pset.
exists(
"useRecoVertex"))
88 if (pset.
exists(
"vertices"))
90 if (pset.
exists(
"deltaZ1WithVertex"))
94 if (pset.
exists(
"beamSpot"))
98 if (pset.
exists(
"DeltaPhi2"))
105 if (pset.
exists(
"PhiMin2"))
112 if (pset.
exists(
"PhiMax2"))
220 for ( i1=r1.first, i2=r2.first, nHits=0 ; i1!=r1.second ; ++i1, ++i2, ++nHits )
222 if ( !i1->isValid() || !i2->isValid() )
return false ;
223 if ( i1->geographicalId()!=i2->geographicalId() )
return false ;
224 if ( ! ( i1->localPosition()==i2->localPosition() ) )
return false ;
235 theInitialSeedColl = seeds ;
271 if (useRecoVertex_) e.
getByLabel(verticesTag_,theVertices);
273 if (!fromTrackerSeeds_)
274 { theMeasurementTracker->update(e) ; }
276 for (
unsigned int i=0;
i<sclRefs.
size();++
i) {
280 LogDebug (
"run") <<
"new cluster, calling seedsFromThisCluster";
281 seedsFromThisCluster(sclRefs[
i],hoe1s[i],hoe2s[i],out);
285 LogDebug (
"run") <<
"Nr of superclusters after filter: "<<sclRefs.
size()
286 <<
", no. of ElectronSeeds found = " << out.size();
291 float hoe1,
float hoe2,
294 float clusterEnergy = seedCluster->energy() ;
296 ( seedCluster->position().x(),
297 seedCluster->position().y(),
298 seedCluster->position().z() ) ;
306 float clusterEnergyT = clusterEnergy / cosh(
EleRelPoint(clusterPos,theBeamSpot->position()).
eta() ) ;
309 if (clusterEnergyT < lowPtThreshold_)
310 { deltaPhi1= deltaPhi1Low_ ; }
311 else if (clusterEnergyT > highPtThreshold_)
312 { deltaPhi1= deltaPhi1High_ ; }
314 { deltaPhi1 = deltaPhi1Coef1_ + deltaPhi1Coef2_/clusterEnergyT ; }
316 float ephimin1 = -deltaPhi1*sizeWindowENeg_ ;
317 float ephimax1 = deltaPhi1*(1.-sizeWindowENeg_);
318 float pphimin1 = -deltaPhi1*(1.-sizeWindowENeg_);
319 float pphimax1 = deltaPhi1*sizeWindowENeg_;
321 float phimin2B = -deltaPhi2B_/2. ;
322 float phimax2B = deltaPhi2B_/2. ;
323 float phimin2F = -deltaPhi2F_/2. ;
324 float phimax2F = deltaPhi2F_/2. ;
327 myMatchEle->set1stLayer(ephimin1,ephimax1);
328 myMatchPos->set1stLayer(pphimin1,pphimax1);
329 myMatchEle->set2ndLayer(phimin2B,phimax2B, phimin2F,phimax2F);
330 myMatchPos->set2ndLayer(phimin2B,phimax2B, phimin2F,phimax2F);
337 double sigmaZ=theBeamSpot->sigmaZ();
338 double sigmaZ0Error=theBeamSpot->sigmaZ0Error();
339 double sq=
sqrt(sigmaZ*sigmaZ+sigmaZ0Error*sigmaZ0Error);
340 double myZmin1=theBeamSpot->position().z()-nSigmasDeltaZ1_*sq;
341 double myZmax1=theBeamSpot->position().z()+nSigmasDeltaZ1_*sq;
346 myMatchEle->set1stLayerZRange(myZmin1,myZmax1);
347 myMatchPos->set1stLayerZRange(myZmin1,myZmax1);
349 if (!fromTrackerSeeds_)
352 std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > elePixelHits
353 = myMatchEle->compatibleHits(clusterPos,vertexPos,clusterEnergy,-1.) ;
354 GlobalPoint eleVertex(theBeamSpot->position().x(),theBeamSpot->position().y(),myMatchEle->getVertex()) ;
355 seedsFromRecHits(elePixelHits,dir,eleVertex,caloCluster,out,
false) ;
357 std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > posPixelHits
358 = myMatchPos->compatibleHits(clusterPos,vertexPos,clusterEnergy,1.) ;
359 GlobalPoint posVertex(theBeamSpot->position().x(),theBeamSpot->position().y(),myMatchPos->getVertex()) ;
360 seedsFromRecHits(posPixelHits,dir,posVertex,caloCluster,out,
true) ;
365 std::vector<SeedWithInfo> elePixelSeeds
366 = myMatchEle->compatibleSeeds(theInitialSeedColl,clusterPos,vertexPos,clusterEnergy,-1.) ;
367 seedsFromTrajectorySeeds(elePixelSeeds,caloCluster,hoe1,hoe2,out,
false) ;
369 std::vector<SeedWithInfo> posPixelSeeds
370 = myMatchPos->compatibleSeeds(theInitialSeedColl,clusterPos,vertexPos,clusterEnergy,1.) ;
371 seedsFromTrajectorySeeds(posPixelSeeds,caloCluster,hoe1,hoe2,out,
true) ;
378 myMatchEle->setUseRecoVertex(
true) ;
379 myMatchPos->setUseRecoVertex(
true) ;
381 const std::vector<reco::Vertex> * vtxCollection = theVertices.product() ;
382 std::vector<reco::Vertex>::const_iterator vtxIter ;
383 for (vtxIter = vtxCollection->begin(); vtxIter != vtxCollection->end() ; vtxIter++)
386 GlobalPoint vertexPos(vtxIter->position().x(),vtxIter->position().y(),vtxIter->position().z());
387 double myZmin1, myZmax1 ;
388 if (vertexPos.z()==theBeamSpot->position().z())
390 double sigmaZ=theBeamSpot->sigmaZ();
391 double sigmaZ0Error=theBeamSpot->sigmaZ0Error();
392 double sq=
sqrt(sigmaZ*sigmaZ+sigmaZ0Error*sigmaZ0Error);
393 myZmin1=theBeamSpot->position().z()-nSigmasDeltaZ1_*sq;
394 myZmax1=theBeamSpot->position().z()+nSigmasDeltaZ1_*sq;
398 myZmin1=vtxIter->position().z()-deltaZ1WithVertex_;
399 myZmax1=vtxIter->position().z()+deltaZ1WithVertex_;
402 myMatchEle->set1stLayerZRange(myZmin1,myZmax1);
403 myMatchPos->set1stLayerZRange(myZmin1,myZmax1);
405 if (!fromTrackerSeeds_)
408 std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > elePixelHits
409 = myMatchEle->compatibleHits(clusterPos,vertexPos,clusterEnergy,-1.) ;
410 seedsFromRecHits(elePixelHits,dir,vertexPos,caloCluster,out,
false) ;
412 std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > posPixelHits
413 = myMatchPos->compatibleHits(clusterPos,vertexPos,clusterEnergy,1.) ;
414 seedsFromRecHits(posPixelHits,dir,vertexPos,caloCluster,out,
true) ;
419 std::vector<SeedWithInfo> elePixelSeeds
420 = myMatchEle->compatibleSeeds(theInitialSeedColl,clusterPos,vertexPos,clusterEnergy,-1.) ;
421 seedsFromTrajectorySeeds(elePixelSeeds,caloCluster,hoe1,hoe2,out,
false) ;
423 std::vector<SeedWithInfo> posPixelSeeds
424 = myMatchPos->compatibleSeeds(theInitialSeedColl,clusterPos,vertexPos,clusterEnergy,1.) ;
425 seedsFromTrajectorySeeds(posPixelSeeds,caloCluster,hoe1,hoe2,out,
true) ;
434 ( std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > & pixelHits,
440 if (!pixelHits.empty())
441 {
LogDebug(
"ElectronSeedGenerator") <<
"Compatible "<<(positron?
"positron":
"electron")<<
" hits found." ; }
443 std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> >::iterator
v ;
444 for ( v = pixelHits.begin() ; v != pixelHits.end() ; v++ )
447 { (*v).first.invert() ; }
448 if (!prepareElTrackSeed((*v).first.recHit(),(*v).second,vertexPos))
452 addSeed(seed,0,positron,out) ;
459 (
const std::vector<SeedWithInfo> & pixelSeeds,
461 float hoe1,
float hoe2,
465 if (!pixelSeeds.empty())
466 {
LogDebug(
"ElectronSeedGenerator") <<
"Compatible "<<(positron?
"positron":
"electron")<<
" seeds found." ; }
468 std::vector<SeedWithInfo>::const_iterator
s;
469 for ( s = pixelSeeds.begin() ; s != pixelSeeds.end() ; s++ )
472 seed.
setCaloCluster(cluster,s->hitsMask(),s->subDet2(),s->subDet1(),hoe1,hoe2) ;
473 addSeed(seed,&*s,positron,out) ;
484 { out.push_back(seed) ;
return ; }
490 reco::ElectronSeedCollection::iterator resItr ;
491 for ( resItr=out.begin() ; resItr!=out.end() ; ++resItr )
493 if ( (seed.
caloCluster()==resItr->caloCluster()) &&
494 (seed.
hitsMask()==resItr->hitsMask()) &&
503 seed.
setNegAttributes(resItr->dRz2(),resItr->dPhi2(),resItr->dRz1(),resItr->dPhi1()) ;
510 if ( resItr->dRz2Pos()!=seed.
dRz2Pos() )
513 <<
"this similar old seed already has another dRz2Pos"
514 <<
"\nold seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(
unsigned int)resItr->hitsMask()<<
"/"<<resItr->dRz2()<<
"/"<<resItr->dPhi2()<<
"/"<<resItr->dRz2Pos()<<
"/"<<resItr->dPhi2Pos()
515 <<
"\nnew seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(
unsigned int)seed.
hitsMask()<<
"/"<<seed.
dRz2()<<
"/"<<seed.
dPhi2()<<
"/"<<seed.
dRz2Pos()<<
"/"<<seed.
dPhi2Pos() ;
540 seed.
setPosAttributes(resItr->dRz2Pos(),resItr->dPhi2Pos(),resItr->dRz1Pos(),resItr->dPhi1Pos()) ;
547 if (resItr->dRz2()!=seed.
dRz2())
550 <<
"this old seed already has another dRz2"
551 <<
"\nold seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(
unsigned int)resItr->hitsMask()<<
"/"<<resItr->dRz2()<<
"/"<<resItr->dPhi2()<<
"/"<<resItr->dRz2Pos()<<
"/"<<resItr->dPhi2Pos()
552 <<
"\nnew seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(
unsigned int)seed.
hitsMask()<<
"/"<<seed.
dRz2()<<
"/"<<seed.
dPhi2()<<
"/"<<seed.
dRz2Pos()<<
"/"<<seed.
dPhi2Pos() ;
575 out.push_back(seed) ;
585 LogDebug(
"") <<
"[ElectronSeedGenerator::prepareElTrackSeed] inner PixelHit x,y,z "<<innerhit->globalPosition();
586 LogDebug(
"") <<
"[ElectronSeedGenerator::prepareElTrackSeed] outer PixelHit x,y,z "<<outerhit->globalPosition();
596 recHits_.push_back(pixhit);
598 constpixhit = dynamic_cast <
const SiPixelRecHit *> (outerhit->hit());
601 recHits_.push_back(pixhit);
606 recHits_.push_back(striphit);
613 FastHelix helix(outerhit->globalPosition(),innerhit->globalPosition(),vertexPos,*theSetup);
614 if ( !helix.isValid()) {
618 TSOS propagatedState = thePropagator->propagate(fts,innerhit->det()->surface()) ;
619 if (!propagatedState.
isValid())
621 TSOS updatedState = theUpdator->update(propagatedState, *innerhit);
623 TSOS propagatedState_out = thePropagator->propagate(updatedState,outerhit->det()->surface()) ;
624 if (!propagatedState_out.
isValid())
626 TSOS updatedState_out = theUpdator->update(propagatedState_out, *outerhit);
630 pts_ = transformer_.persistentState(updatedState_out, outerhit->geographicalId().rawId());
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)
LocalPoint position() const
Local x and y position coordinates.
void setES(const MagneticField *, const MeasurementTracker *theMeasurementTracker, const TrackerGeometry *trackerGeometry)
const NavigationSchool * theNavigationSchool
bool exists(std::string const ¶meterName) const
checks if a parameter exists
GlobalPoint globalPosition() const
unsigned long long cacheIDMagField_
TrajectoryStateOnSurface TSOS
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
edm::ESHandle< TrackerGeometry > theTrackerGeometry
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())
edm::InputTag beamSpotTag_
PropagatorWithMaterial * thePropagator
LocalVector momentum() const
Momentum vector in the local frame.
std::vector< ElectronSeed > ElectronSeedCollection
collection of ElectronSeed objects
ElectronSeedGenerator(const edm::ParameterSet &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
PixelHitMatcher * myMatchPos
const int surfaceSide() const
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)
PTrajectoryStateOnDet const & startingState() const
void addSeed(reco::ElectronSeed &seed, const SeedWithInfo *info, bool positron, reco::ElectronSeedCollection &out)
const unsigned int detId() const
T const * product() const
void seedsFromThisCluster(edm::Ref< reco::SuperClusterCollection > seedCluster, float hoe1, float hoe2, reco::ElectronSeedCollection &out)
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
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.
edm::InputTag verticesTag_
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
const LocalTrajectoryParameters & parameters() const
unsigned char hitsMask() const
unsigned long long cacheIDCkfComp_