47 : dynamicphiroad_(pset.getParameter<bool>(
"dynamicPhiRoad")),
48 fromTrackerSeeds_(pset.getParameter<bool>(
"fromTrackerSeeds")),
49 useRecoVertex_(
false),
50 verticesTag_(
"offlinePrimaryVerticesWithBS"),
51 beamSpotTag_(
"offlineBeamSpot"),
52 lowPtThreshold_(pset.getParameter<double>(
"LowPtThreshold")),
53 highPtThreshold_(pset.getParameter<double>(
"HighPtThreshold")),
54 nSigmasDeltaZ1_(pset.getParameter<double>(
"nSigmasDeltaZ1")),
55 deltaZ1WithVertex_(0.5),
56 sizeWindowENeg_(pset.getParameter<double>(
"SizeWindowENeg")),
57 deltaPhi1Low_(pset.getParameter<double>(
"DeltaPhi1Low")),
58 deltaPhi1High_(pset.getParameter<double>(
"DeltaPhi1High")),
59 deltaPhi1Coef1_(0.), deltaPhi1Coef2_(0.),
60 myMatchEle(0), myMatchPos(0),
62 theMeasurementTracker(0),
64 cacheIDMagField_(0),cacheIDNavSchool_(0),cacheIDCkfComp_(0),cacheIDTrkGeom_(0)
74 if (pset.
exists(
"measurementTrackerName"))
78 if (pset.
exists(
"useRecoVertex"))
80 if (pset.
exists(
"vertices"))
82 if (pset.
exists(
"deltaZ1WithVertex"))
86 if (pset.
exists(
"beamSpot"))
90 if (pset.
exists(
"DeltaPhi2"))
97 if (pset.
exists(
"PhiMin2"))
104 if (pset.
exists(
"PhiMax2"))
212 for ( i1=r1.first, i2=
r2.first, nHits=0 ; i1!=r1.second ; ++i1, ++i2, ++nHits )
214 if ( !i1->isValid() || !i2->isValid() )
return false ;
215 if ( i1->geographicalId()!=i2->geographicalId() )
return false ;
216 if ( ! ( i1->localPosition()==i2->localPosition() ) )
return false ;
227 theInitialSeedColl = seeds ;
267 if (useRecoVertex_) e.
getByLabel(verticesTag_,theVertices);
269 if (!fromTrackerSeeds_)
270 { theMeasurementTracker->update(e) ; }
272 for (
unsigned int i=0;
i<sclRefs.
size();++
i) {
276 LogDebug (
"run") <<
"new cluster, calling seedsFromThisCluster";
277 seedsFromThisCluster(sclRefs[
i],hoe1s[i],hoe2s[i],out,tTopo);
281 LogDebug (
"run") <<
"Nr of superclusters after filter: "<<sclRefs.
size()
282 <<
", no. of ElectronSeeds found = " << out.size();
287 float hoe1,
float hoe2,
290 float clusterEnergy = seedCluster->energy() ;
292 ( seedCluster->position().x(),
293 seedCluster->position().y(),
294 seedCluster->position().z() ) ;
302 float clusterEnergyT = clusterEnergy / cosh(
EleRelPoint(clusterPos,theBeamSpot->position()).
eta() ) ;
305 if (clusterEnergyT < lowPtThreshold_)
306 { deltaPhi1= deltaPhi1Low_ ; }
307 else if (clusterEnergyT > highPtThreshold_)
308 { deltaPhi1= deltaPhi1High_ ; }
310 { deltaPhi1 = deltaPhi1Coef1_ + deltaPhi1Coef2_/clusterEnergyT ; }
312 float ephimin1 = -deltaPhi1*sizeWindowENeg_ ;
313 float ephimax1 = deltaPhi1*(1.-sizeWindowENeg_);
314 float pphimin1 = -deltaPhi1*(1.-sizeWindowENeg_);
315 float pphimax1 = deltaPhi1*sizeWindowENeg_;
317 float phimin2B = -deltaPhi2B_/2. ;
318 float phimax2B = deltaPhi2B_/2. ;
319 float phimin2F = -deltaPhi2F_/2. ;
320 float phimax2F = deltaPhi2F_/2. ;
323 myMatchEle->set1stLayer(ephimin1,ephimax1);
324 myMatchPos->set1stLayer(pphimin1,pphimax1);
325 myMatchEle->set2ndLayer(phimin2B,phimax2B, phimin2F,phimax2F);
326 myMatchPos->set2ndLayer(phimin2B,phimax2B, phimin2F,phimax2F);
333 double sigmaZ=theBeamSpot->sigmaZ();
334 double sigmaZ0Error=theBeamSpot->sigmaZ0Error();
335 double sq=
sqrt(sigmaZ*sigmaZ+sigmaZ0Error*sigmaZ0Error);
336 double myZmin1=theBeamSpot->position().z()-nSigmasDeltaZ1_*sq;
337 double myZmax1=theBeamSpot->position().z()+nSigmasDeltaZ1_*sq;
342 myMatchEle->set1stLayerZRange(myZmin1,myZmax1);
343 myMatchPos->set1stLayerZRange(myZmin1,myZmax1);
345 if (!fromTrackerSeeds_)
348 std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > elePixelHits
349 = myMatchEle->compatibleHits(clusterPos,vertexPos,
350 clusterEnergy,-1., tTopo) ;
351 GlobalPoint eleVertex(theBeamSpot->position().x(),theBeamSpot->position().y(),myMatchEle->getVertex()) ;
352 seedsFromRecHits(elePixelHits,dir,eleVertex,caloCluster,out,
false) ;
354 std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > posPixelHits
355 = myMatchPos->compatibleHits(clusterPos,vertexPos,clusterEnergy,1.,tTopo) ;
356 GlobalPoint posVertex(theBeamSpot->position().x(),theBeamSpot->position().y(),myMatchPos->getVertex()) ;
357 seedsFromRecHits(posPixelHits,dir,posVertex,caloCluster,out,
true) ;
362 std::vector<SeedWithInfo> elePixelSeeds
363 = myMatchEle->compatibleSeeds(theInitialSeedColl,clusterPos,vertexPos,clusterEnergy,-1.) ;
364 seedsFromTrajectorySeeds(elePixelSeeds,caloCluster,hoe1,hoe2,out,
false) ;
366 std::vector<SeedWithInfo> posPixelSeeds
367 = myMatchPos->compatibleSeeds(theInitialSeedColl,clusterPos,vertexPos,clusterEnergy,1.) ;
368 seedsFromTrajectorySeeds(posPixelSeeds,caloCluster,hoe1,hoe2,out,
true) ;
375 myMatchEle->setUseRecoVertex(
true) ;
376 myMatchPos->setUseRecoVertex(
true) ;
378 const std::vector<reco::Vertex> * vtxCollection = theVertices.product() ;
379 std::vector<reco::Vertex>::const_iterator vtxIter ;
380 for (vtxIter = vtxCollection->begin(); vtxIter != vtxCollection->end() ; vtxIter++)
383 GlobalPoint vertexPos(vtxIter->position().x(),vtxIter->position().y(),vtxIter->position().z());
384 double myZmin1, myZmax1 ;
385 if (vertexPos.z()==theBeamSpot->position().z())
387 double sigmaZ=theBeamSpot->sigmaZ();
388 double sigmaZ0Error=theBeamSpot->sigmaZ0Error();
389 double sq=
sqrt(sigmaZ*sigmaZ+sigmaZ0Error*sigmaZ0Error);
390 myZmin1=theBeamSpot->position().z()-nSigmasDeltaZ1_*sq;
391 myZmax1=theBeamSpot->position().z()+nSigmasDeltaZ1_*sq;
395 myZmin1=vtxIter->position().z()-deltaZ1WithVertex_;
396 myZmax1=vtxIter->position().z()+deltaZ1WithVertex_;
399 myMatchEle->set1stLayerZRange(myZmin1,myZmax1);
400 myMatchPos->set1stLayerZRange(myZmin1,myZmax1);
402 if (!fromTrackerSeeds_)
405 std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > elePixelHits
406 = myMatchEle->compatibleHits(clusterPos,vertexPos,clusterEnergy,-1.,tTopo) ;
407 seedsFromRecHits(elePixelHits,dir,vertexPos,caloCluster,out,
false) ;
409 std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > posPixelHits
410 = myMatchPos->compatibleHits(clusterPos,vertexPos,clusterEnergy,1.,tTopo) ;
411 seedsFromRecHits(posPixelHits,dir,vertexPos,caloCluster,out,
true) ;
416 std::vector<SeedWithInfo> elePixelSeeds
417 = myMatchEle->compatibleSeeds(theInitialSeedColl,clusterPos,vertexPos,clusterEnergy,-1.) ;
418 seedsFromTrajectorySeeds(elePixelSeeds,caloCluster,hoe1,hoe2,out,
false) ;
420 std::vector<SeedWithInfo> posPixelSeeds
421 = myMatchPos->compatibleSeeds(theInitialSeedColl,clusterPos,vertexPos,clusterEnergy,1.) ;
422 seedsFromTrajectorySeeds(posPixelSeeds,caloCluster,hoe1,hoe2,out,
true) ;
431 ( std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > & pixelHits,
437 if (!pixelHits.empty())
438 {
LogDebug(
"ElectronSeedGenerator") <<
"Compatible "<<(positron?
"positron":
"electron")<<
" hits found." ; }
440 std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> >::iterator
v ;
441 for ( v = pixelHits.begin() ; v != pixelHits.end() ; v++ )
444 { (*v).first.invert() ; }
445 if (!prepareElTrackSeed((*v).first.recHit(),(*v).second,vertexPos))
449 addSeed(seed,0,positron,out) ;
454 (
const std::vector<SeedWithInfo> & pixelSeeds,
456 float hoe1,
float hoe2,
460 if (!pixelSeeds.empty())
461 {
LogDebug(
"ElectronSeedGenerator") <<
"Compatible "<<(positron?
"positron":
"electron")<<
" seeds found." ; }
463 std::vector<SeedWithInfo>::const_iterator
s;
464 for ( s = pixelSeeds.begin() ; s != pixelSeeds.end() ; s++ )
467 seed.
setCaloCluster(cluster,s->hitsMask(),s->subDet2(),s->subDet1(),hoe1,hoe2) ;
468 addSeed(seed,&*s,positron,out) ;
479 { out.push_back(seed) ;
return ; }
485 reco::ElectronSeedCollection::iterator resItr ;
486 for ( resItr=out.begin() ; resItr!=out.end() ; ++resItr )
488 if ( (seed.
caloCluster()==resItr->caloCluster()) &&
489 (seed.
hitsMask()==resItr->hitsMask()) &&
498 seed.
setNegAttributes(resItr->dRz2(),resItr->dPhi2(),resItr->dRz1(),resItr->dPhi1()) ;
505 if ( resItr->dRz2Pos()!=seed.
dRz2Pos() )
508 <<
"this similar old seed already has another dRz2Pos"
509 <<
"\nold seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(
unsigned int)resItr->hitsMask()<<
"/"<<resItr->dRz2()<<
"/"<<resItr->dPhi2()<<
"/"<<resItr->dRz2Pos()<<
"/"<<resItr->dPhi2Pos()
510 <<
"\nnew seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(
unsigned int)seed.
hitsMask()<<
"/"<<seed.
dRz2()<<
"/"<<seed.
dPhi2()<<
"/"<<seed.
dRz2Pos()<<
"/"<<seed.
dPhi2Pos() ;
535 seed.
setPosAttributes(resItr->dRz2Pos(),resItr->dPhi2Pos(),resItr->dRz1Pos(),resItr->dPhi1Pos()) ;
542 if (resItr->dRz2()!=seed.
dRz2())
545 <<
"this old seed already has another dRz2"
546 <<
"\nold seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(
unsigned int)resItr->hitsMask()<<
"/"<<resItr->dRz2()<<
"/"<<resItr->dPhi2()<<
"/"<<resItr->dRz2Pos()<<
"/"<<resItr->dPhi2Pos()
547 <<
"\nnew seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(
unsigned int)seed.
hitsMask()<<
"/"<<seed.
dRz2()<<
"/"<<seed.
dPhi2()<<
"/"<<seed.
dRz2Pos()<<
"/"<<seed.
dPhi2Pos() ;
570 out.push_back(seed) ;
580 LogDebug(
"") <<
"[ElectronSeedGenerator::prepareElTrackSeed] inner PixelHit x,y,z "<<innerhit->globalPosition();
581 LogDebug(
"") <<
"[ElectronSeedGenerator::prepareElTrackSeed] outer PixelHit x,y,z "<<outerhit->globalPosition();
586 SiStripMatchedRecHit2D *striphit=0;
590 recHits_.push_back(pixhit);
592 constpixhit = dynamic_cast <
const SiPixelRecHit *> (outerhit->hit());
595 recHits_.push_back(pixhit);
597 const SiStripMatchedRecHit2D * conststriphit=dynamic_cast <
const SiStripMatchedRecHit2D *> (outerhit->hit());
599 striphit =
new SiStripMatchedRecHit2D(*conststriphit);
600 recHits_.push_back(striphit);
609 float nomField = bfield->nominalValue();
612 FastHelix helix(outerhit->globalPosition(),innerhit->globalPosition(),vertexPos,nomField,&*bfield);
613 if ( !helix.isValid()) {
617 TSOS propagatedState = thePropagator->propagate(fts,innerhit->det()->surface()) ;
618 if (!propagatedState.isValid())
620 TSOS updatedState = theUpdator->update(propagatedState, *innerhit);
622 TSOS propagatedState_out = thePropagator->propagate(updatedState,outerhit->det()->surface()) ;
623 if (!propagatedState_out.
isValid())
625 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)
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_
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
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
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
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
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
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
const LocalTrajectoryParameters & parameters() const
unsigned char hitsMask() const
unsigned long long cacheIDCkfComp_