50 : dynamicphiroad_(pset.getParameter<bool>(
"dynamicPhiRoad")),
51 fromTrackerSeeds_(pset.getParameter<bool>(
"fromTrackerSeeds")),
52 useRecoVertex_(
false),
53 verticesTag_(ts.token_vtx),
54 beamSpotTag_(ts.token_bs),
55 lowPtThreshold_(pset.getParameter<double>(
"LowPtThreshold")),
56 highPtThreshold_(pset.getParameter<double>(
"HighPtThreshold")),
57 nSigmasDeltaZ1_(pset.getParameter<double>(
"nSigmasDeltaZ1")),
58 deltaZ1WithVertex_(0.5),
59 sizeWindowENeg_(pset.getParameter<double>(
"SizeWindowENeg")),
60 deltaPhi1Low_(pset.getParameter<double>(
"DeltaPhi1Low")),
61 deltaPhi1High_(pset.getParameter<double>(
"DeltaPhi1High")),
62 deltaPhi1Coef1_(0.), deltaPhi1Coef2_(0.),
63 myMatchEle(0), myMatchPos(0),
65 theMeasurementTracker(0),
67 cacheIDMagField_(0),cacheIDNavSchool_(0),cacheIDCkfComp_(0),cacheIDTrkGeom_(0)
77 if (pset.
exists(
"measurementTrackerName"))
84 if (pset.
exists(
"useRecoVertex"))
90 if (pset.
exists(
"deltaZ1WithVertex"))
100 if (pset.
exists(
"DeltaPhi2"))
107 if (pset.
exists(
"PhiMin2"))
114 if (pset.
exists(
"PhiMax2"))
222 for ( i1=r1.first, i2=
r2.first, nHits=0 ; i1!=r1.second ; ++i1, ++i2, ++nHits )
224 if ( !i1->isValid() || !i2->isValid() )
return false ;
225 if ( i1->geographicalId()!=i2->geographicalId() )
return false ;
226 if ( ! ( i1->localPosition()==i2->localPosition() ) )
return false ;
237 theInitialSeedColl = seeds ;
272 e.
getByLabel(theMeasurementTrackerEventTag, data);
273 myMatchEle->setEvent(*data);
274 myMatchPos->setEvent(*data);
284 if (useRecoVertex_) e.
getByToken(verticesTag_,theVertices);
286 if (!fromTrackerSeeds_)
287 {
throw cms::Exception(
"NotSupported") <<
"Here in ElectronSeedGenerator " << __FILE__ <<
":" << __LINE__ <<
" I would like to do theMeasurementTracker->update(e); but that no longer makes sense.\n";
290 for (
unsigned int i=0;
i<sclRefs.
size();++
i) {
294 LogDebug (
"run") <<
"new cluster, calling seedsFromThisCluster";
295 seedsFromThisCluster(sclRefs[
i],hoe1s[i],hoe2s[i],out,tTopo);
299 LogDebug (
"run") <<
"Nr of superclusters after filter: "<<sclRefs.
size()
300 <<
", no. of ElectronSeeds found = " << out.size();
305 float hoe1,
float hoe2,
308 float clusterEnergy = seedCluster->energy() ;
310 ( seedCluster->position().x(),
311 seedCluster->position().y(),
312 seedCluster->position().z() ) ;
320 float clusterEnergyT = clusterEnergy / cosh(
EleRelPoint(clusterPos,theBeamSpot->position()).
eta() ) ;
323 if (clusterEnergyT < lowPtThreshold_)
324 { deltaPhi1= deltaPhi1Low_ ; }
325 else if (clusterEnergyT > highPtThreshold_)
326 { deltaPhi1= deltaPhi1High_ ; }
328 { deltaPhi1 = deltaPhi1Coef1_ + deltaPhi1Coef2_/clusterEnergyT ; }
330 float ephimin1 = -deltaPhi1*sizeWindowENeg_ ;
331 float ephimax1 = deltaPhi1*(1.-sizeWindowENeg_);
332 float pphimin1 = -deltaPhi1*(1.-sizeWindowENeg_);
333 float pphimax1 = deltaPhi1*sizeWindowENeg_;
335 float phimin2B = -deltaPhi2B_/2. ;
336 float phimax2B = deltaPhi2B_/2. ;
337 float phimin2F = -deltaPhi2F_/2. ;
338 float phimax2F = deltaPhi2F_/2. ;
341 myMatchEle->set1stLayer(ephimin1,ephimax1);
342 myMatchPos->set1stLayer(pphimin1,pphimax1);
343 myMatchEle->set2ndLayer(phimin2B,phimax2B, phimin2F,phimax2F);
344 myMatchPos->set2ndLayer(phimin2B,phimax2B, phimin2F,phimax2F);
351 double sigmaZ=theBeamSpot->sigmaZ();
352 double sigmaZ0Error=theBeamSpot->sigmaZ0Error();
353 double sq=
sqrt(sigmaZ*sigmaZ+sigmaZ0Error*sigmaZ0Error);
354 double myZmin1=theBeamSpot->position().z()-nSigmasDeltaZ1_*sq;
355 double myZmax1=theBeamSpot->position().z()+nSigmasDeltaZ1_*sq;
360 myMatchEle->set1stLayerZRange(myZmin1,myZmax1);
361 myMatchPos->set1stLayerZRange(myZmin1,myZmax1);
363 if (!fromTrackerSeeds_)
366 std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > elePixelHits
367 = myMatchEle->compatibleHits(clusterPos,vertexPos,
368 clusterEnergy,-1., tTopo) ;
369 GlobalPoint eleVertex(theBeamSpot->position().x(),theBeamSpot->position().y(),myMatchEle->getVertex()) ;
370 seedsFromRecHits(elePixelHits,dir,eleVertex,caloCluster,out,
false) ;
372 std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > posPixelHits
373 = myMatchPos->compatibleHits(clusterPos,vertexPos,clusterEnergy,1.,tTopo) ;
374 GlobalPoint posVertex(theBeamSpot->position().x(),theBeamSpot->position().y(),myMatchPos->getVertex()) ;
375 seedsFromRecHits(posPixelHits,dir,posVertex,caloCluster,out,
true) ;
380 std::vector<SeedWithInfo> elePixelSeeds
381 = myMatchEle->compatibleSeeds(theInitialSeedColl,clusterPos,vertexPos,clusterEnergy,-1.) ;
382 seedsFromTrajectorySeeds(elePixelSeeds,caloCluster,hoe1,hoe2,out,
false) ;
384 std::vector<SeedWithInfo> posPixelSeeds
385 = myMatchPos->compatibleSeeds(theInitialSeedColl,clusterPos,vertexPos,clusterEnergy,1.) ;
386 seedsFromTrajectorySeeds(posPixelSeeds,caloCluster,hoe1,hoe2,out,
true) ;
393 myMatchEle->setUseRecoVertex(
true) ;
394 myMatchPos->setUseRecoVertex(
true) ;
396 const std::vector<reco::Vertex> * vtxCollection = theVertices.product() ;
397 std::vector<reco::Vertex>::const_iterator vtxIter ;
398 for (vtxIter = vtxCollection->begin(); vtxIter != vtxCollection->end() ; vtxIter++)
401 GlobalPoint vertexPos(vtxIter->position().x(),vtxIter->position().y(),vtxIter->position().z());
402 double myZmin1, myZmax1 ;
403 if (vertexPos.z()==theBeamSpot->position().z())
405 double sigmaZ=theBeamSpot->sigmaZ();
406 double sigmaZ0Error=theBeamSpot->sigmaZ0Error();
407 double sq=
sqrt(sigmaZ*sigmaZ+sigmaZ0Error*sigmaZ0Error);
408 myZmin1=theBeamSpot->position().z()-nSigmasDeltaZ1_*sq;
409 myZmax1=theBeamSpot->position().z()+nSigmasDeltaZ1_*sq;
413 myZmin1=vtxIter->position().z()-deltaZ1WithVertex_;
414 myZmax1=vtxIter->position().z()+deltaZ1WithVertex_;
417 myMatchEle->set1stLayerZRange(myZmin1,myZmax1);
418 myMatchPos->set1stLayerZRange(myZmin1,myZmax1);
420 if (!fromTrackerSeeds_)
423 std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > elePixelHits
424 = myMatchEle->compatibleHits(clusterPos,vertexPos,clusterEnergy,-1.,tTopo) ;
425 seedsFromRecHits(elePixelHits,dir,vertexPos,caloCluster,out,
false) ;
427 std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > posPixelHits
428 = myMatchPos->compatibleHits(clusterPos,vertexPos,clusterEnergy,1.,tTopo) ;
429 seedsFromRecHits(posPixelHits,dir,vertexPos,caloCluster,out,
true) ;
434 std::vector<SeedWithInfo> elePixelSeeds
435 = myMatchEle->compatibleSeeds(theInitialSeedColl,clusterPos,vertexPos,clusterEnergy,-1.) ;
436 seedsFromTrajectorySeeds(elePixelSeeds,caloCluster,hoe1,hoe2,out,
false) ;
438 std::vector<SeedWithInfo> posPixelSeeds
439 = myMatchPos->compatibleSeeds(theInitialSeedColl,clusterPos,vertexPos,clusterEnergy,1.) ;
440 seedsFromTrajectorySeeds(posPixelSeeds,caloCluster,hoe1,hoe2,out,
true) ;
449 ( std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > & pixelHits,
455 if (!pixelHits.empty())
456 {
LogDebug(
"ElectronSeedGenerator") <<
"Compatible "<<(positron?
"positron":
"electron")<<
" hits found." ; }
458 std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> >::iterator
v ;
459 for ( v = pixelHits.begin() ; v != pixelHits.end() ; v++ )
462 { (*v).first.invert() ; }
463 if (!prepareElTrackSeed((*v).first.recHit(),(*v).second,vertexPos))
467 addSeed(seed,0,positron,out) ;
472 (
const std::vector<SeedWithInfo> & pixelSeeds,
474 float hoe1,
float hoe2,
478 if (!pixelSeeds.empty())
479 {
LogDebug(
"ElectronSeedGenerator") <<
"Compatible "<<(positron?
"positron":
"electron")<<
" seeds found." ; }
481 std::vector<SeedWithInfo>::const_iterator
s;
482 for ( s = pixelSeeds.begin() ; s != pixelSeeds.end() ; s++ )
485 seed.
setCaloCluster(cluster,s->hitsMask(),s->subDet2(),s->subDet1(),hoe1,hoe2) ;
486 addSeed(seed,&*s,positron,out) ;
497 { out.push_back(seed) ;
return ; }
503 reco::ElectronSeedCollection::iterator resItr ;
504 for ( resItr=out.begin() ; resItr!=out.end() ; ++resItr )
506 if ( (seed.
caloCluster()==resItr->caloCluster()) &&
507 (seed.
hitsMask()==resItr->hitsMask()) &&
516 seed.
setNegAttributes(resItr->dRz2(),resItr->dPhi2(),resItr->dRz1(),resItr->dPhi1()) ;
523 if ( resItr->dRz2Pos()!=seed.
dRz2Pos() )
526 <<
"this similar old seed already has another dRz2Pos"
527 <<
"\nold seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(
unsigned int)resItr->hitsMask()<<
"/"<<resItr->dRz2()<<
"/"<<resItr->dPhi2()<<
"/"<<resItr->dRz2Pos()<<
"/"<<resItr->dPhi2Pos()
528 <<
"\nnew seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(
unsigned int)seed.
hitsMask()<<
"/"<<seed.
dRz2()<<
"/"<<seed.
dPhi2()<<
"/"<<seed.
dRz2Pos()<<
"/"<<seed.
dPhi2Pos() ;
553 seed.
setPosAttributes(resItr->dRz2Pos(),resItr->dPhi2Pos(),resItr->dRz1Pos(),resItr->dPhi1Pos()) ;
560 if (resItr->dRz2()!=seed.
dRz2())
563 <<
"this old seed already has another dRz2"
564 <<
"\nold seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(
unsigned int)resItr->hitsMask()<<
"/"<<resItr->dRz2()<<
"/"<<resItr->dPhi2()<<
"/"<<resItr->dRz2Pos()<<
"/"<<resItr->dPhi2Pos()
565 <<
"\nnew seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(
unsigned int)seed.
hitsMask()<<
"/"<<seed.
dRz2()<<
"/"<<seed.
dPhi2()<<
"/"<<seed.
dRz2Pos()<<
"/"<<seed.
dPhi2Pos() ;
588 out.push_back(seed) ;
598 LogDebug(
"") <<
"[ElectronSeedGenerator::prepareElTrackSeed] inner PixelHit x,y,z "<<innerhit->globalPosition();
599 LogDebug(
"") <<
"[ElectronSeedGenerator::prepareElTrackSeed] outer PixelHit x,y,z "<<outerhit->globalPosition();
604 SiStripMatchedRecHit2D *striphit=0;
608 recHits_.push_back(pixhit);
610 constpixhit = dynamic_cast <
const SiPixelRecHit *> (outerhit->hit());
613 recHits_.push_back(pixhit);
615 const SiStripMatchedRecHit2D * conststriphit=dynamic_cast <
const SiStripMatchedRecHit2D *> (outerhit->hit());
617 striphit =
new SiStripMatchedRecHit2D(*conststriphit);
618 recHits_.push_back(striphit);
627 float nomField = bfield->nominalValue();
630 FastHelix helix(outerhit->globalPosition(),innerhit->globalPosition(),vertexPos,nomField,&*bfield);
631 if ( !helix.isValid()) {
635 TSOS propagatedState = thePropagator->propagate(fts,innerhit->det()->surface()) ;
636 if (!propagatedState.isValid())
638 TSOS updatedState = theUpdator->update(propagatedState, *innerhit);
640 TSOS propagatedState_out = thePropagator->propagate(updatedState,outerhit->det()->surface()) ;
641 if (!propagatedState_out.
isValid())
643 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_
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
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.
void setES(const MagneticField *, const MeasurementTracker *theMeasurementTracker, const TrackerGeometry *trackerGeometry)
const NavigationSchool * theNavigationSchool
edm::InputTag theMeasurementTrackerEventTag
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
PropagatorWithMaterial * thePropagator
LocalVector momentum() const
Momentum vector in the local frame.
std::vector< ElectronSeed > ElectronSeedCollection
collection of ElectronSeed objects
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
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
return(e1-e2)*(e1-e2)+dp *dp
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_