CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ElectronSeedGenerator.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EgammaElectronAlgos
4 // Class: ElectronSeedGenerator.
5 //
13 //
14 // Original Author: Ursula Berthon, Claude Charlot
15 // Created: Mon Mar 27 13:22:06 CEST 2006
16 //
17 
20 
26 
27 //#include "DataFormats/EgammaReco/interface/EcalCluster.h"
29 
31 //#include "DataFormats/BeamSpot/interface/BeamSpot.h"
32 //#include "DataFormats/Common/interface/Handle.h"
33 
36 
40 
42 
44 
45 
46 #include <vector>
47 #include <utility>
48 
51  : dynamicphiroad_(pset.getParameter<bool>("dynamicPhiRoad")),
52  fromTrackerSeeds_(pset.getParameter<bool>("fromTrackerSeeds")),
53  useRecoVertex_(false),
54  verticesTag_(ts.token_vtx),
55  beamSpotTag_(ts.token_bs),
56  lowPtThreshold_(pset.getParameter<double>("LowPtThreshold")),
57  highPtThreshold_(pset.getParameter<double>("HighPtThreshold")),
58  nSigmasDeltaZ1_(pset.getParameter<double>("nSigmasDeltaZ1")),
59  deltaZ1WithVertex_(0.5),
60  sizeWindowENeg_(pset.getParameter<double>("SizeWindowENeg")),
61  deltaPhi1Low_(pset.getParameter<double>("DeltaPhi1Low")),
62  deltaPhi1High_(pset.getParameter<double>("DeltaPhi1High")),
63  deltaPhi1Coef1_(0.), deltaPhi1Coef2_(0.),
64  myMatchEle(0), myMatchPos(0),
65  thePropagator(0),
66  theMeasurementTracker(0),
67  theMeasurementTrackerEventTag(ts.token_measTrkEvt),
68  theSetup(0),
69  cacheIDMagField_(0),/*cacheIDGeom_(0),*/cacheIDNavSchool_(0),cacheIDCkfComp_(0),cacheIDTrkGeom_(0)
70  {
71  // so that deltaPhi1 = deltaPhi1Coef1_ + deltaPhi1Coef2_/clusterEnergyT
72  if (dynamicphiroad_)
73  {
76  }
77 
78  // use of a theMeasurementTrackerName
79  if (pset.exists("measurementTrackerName"))
80  { theMeasurementTrackerName = pset.getParameter<std::string>("measurementTrackerName") ; }
81 
82  // use of reco vertex
83  if (pset.exists("useRecoVertex"))
84  { useRecoVertex_ = pset.getParameter<bool>("useRecoVertex") ; }
85  /*
86  if (pset.exists("vertices"))
87  { verticesTag_ = pset.getParameter<edm::InputTag>("vertices") ; }
88  */
89  if (pset.exists("deltaZ1WithVertex"))
90  { deltaZ1WithVertex_ = pset.getParameter<double>("deltaZ1WithVertex") ; }
91 
92  // new beamSpot tag
93  /*
94  if (pset.exists("beamSpot"))
95  { beamSpotTag_ = pset.getParameter<edm::InputTag>("beamSpot") ; }
96  */
97 
98  // new B/F configurables
99  if (pset.exists("DeltaPhi2"))
100  { deltaPhi2B_ = deltaPhi2F_ = pset.getParameter<double>("DeltaPhi2") ; }
101  else
102  {
103  deltaPhi2B_ = pset.getParameter<double>("DeltaPhi2B") ;
104  deltaPhi2F_ = pset.getParameter<double>("DeltaPhi2F") ;
105  }
106  if (pset.exists("PhiMin2"))
107  { phiMin2B_ = phiMin2F_ = pset.getParameter<double>("PhiMin2") ; }
108  else
109  {
110  phiMin2B_ = pset.getParameter<double>("PhiMin2B") ;
111  phiMin2F_ = pset.getParameter<double>("PhiMin2F") ;
112  }
113  if (pset.exists("PhiMax2"))
114  { phiMax2B_ = phiMax2F_ = pset.getParameter<double>("PhiMax2") ; }
115  else
116  {
117  phiMax2B_ = pset.getParameter<double>("PhiMax2B") ;
118  phiMax2F_ = pset.getParameter<double>("PhiMax2F") ;
119  }
120 
121  // Instantiate the pixel hit matchers
123  ( pset.getParameter<double>("ePhiMin1"),
124  pset.getParameter<double>("ePhiMax1"),
126  pset.getParameter<double>("z2MinB"),
127  pset.getParameter<double>("z2MaxB"),
128  pset.getParameter<double>("r2MinF"),
129  pset.getParameter<double>("r2MaxF"),
130  pset.getParameter<double>("rMinI"),
131  pset.getParameter<double>("rMaxI"),
132  pset.getParameter<bool>("searchInTIDTEC") ) ;
133 
135  ( pset.getParameter<double>("pPhiMin1"),
136  pset.getParameter<double>("pPhiMax1"),
138  pset.getParameter<double>("z2MinB"),
139  pset.getParameter<double>("z2MaxB"),
140  pset.getParameter<double>("r2MinF"),
141  pset.getParameter<double>("r2MaxF"),
142  pset.getParameter<double>("rMinI"),
143  pset.getParameter<double>("rMaxI"),
144  pset.getParameter<bool>("searchInTIDTEC") ) ;
145 
146  theUpdator = new KFUpdator() ;
147  }
148 
150  {
151  delete myMatchEle ;
152  delete myMatchPos ;
153  delete thePropagator ;
154  delete theUpdator ;
155  }
156 
158 
159  // get records if necessary (called once per event)
160  bool tochange=false;
161 
164  cacheIDMagField_=setup.get<IdealMagneticFieldRecord>().cacheIdentifier();
165  if (thePropagator) delete thePropagator;
167  tochange=true;
168  }
169 
171  edm::ESHandle<MeasurementTracker> measurementTrackerHandle;
172  setup.get<CkfComponentsRecord>().get(theMeasurementTrackerName,measurementTrackerHandle);
173  cacheIDCkfComp_=setup.get<CkfComponentsRecord>().cacheIdentifier();
174  theMeasurementTracker = measurementTrackerHandle.product();
175  tochange=true;
176  }
177 
178  //edm::ESHandle<TrackerGeometry> trackerGeometryHandle;
180  cacheIDTrkGeom_=setup.get<TrackerDigiGeometryRecord>().cacheIdentifier();
182  tochange=true; //FIXME
183  }
184 
185  if (tochange) {
188  }
189 
192  setup.get<NavigationSchoolRecord>().get("SimpleNavigationSchool", nav);
193  cacheIDNavSchool_=setup.get<NavigationSchoolRecord>().cacheIdentifier();
195  }
196 
197 // if (cacheIDGeom_!=setup.get<TrackerRecoGeometryRecord>().cacheIdentifier()) {
198 // setup.get<TrackerRecoGeometryRecord>().get( theGeomSearchTracker );
199 // cacheIDGeom_=setup.get<TrackerRecoGeometryRecord>().cacheIdentifier();
200 // }
201 
202 }
203 
204 void display_seed( const std::string & title1, const std::string & title2, const reco::ElectronSeed & seed, edm::ESHandle<TrackerGeometry> trackerGeometry )
205  {
206  const PTrajectoryStateOnDet & startingState = seed.startingState() ;
207  const LocalTrajectoryParameters & parameters = startingState.parameters() ;
208  std::cout<<title1
209  <<" ("<<seed.subDet2()<<"/"<<seed.dRz2()<<"/"<<seed.dPhi2()<<")"
210  <<" ("<<seed.direction()<<"/"<<startingState.detId()<<"/"<<startingState.surfaceSide()<<"/"<<parameters.charge()<<"/"<<parameters.position()<<"/"<<parameters.momentum()<<")"
211  <<std::endl ;
212  }
213 
214 bool equivalent( const TrajectorySeed & s1, const TrajectorySeed & s2 )
215  {
216  if (s1.nHits()!=s2.nHits()) return false ;
217 
218  unsigned int nHits ;
219  TrajectorySeed::range r1 = s1.recHits(), r2 = s2.recHits() ;
221  for ( i1=r1.first, i2=r2.first, nHits=0 ; i1!=r1.second ; ++i1, ++i2, ++nHits )
222  {
223  if ( !i1->isValid() || !i2->isValid() ) return false ;
224  if ( i1->geographicalId()!=i2->geographicalId() ) return false ;
225  if ( ! ( i1->localPosition()==i2->localPosition() ) ) return false ;
226  }
227 
228  return true ;
229  }
230 
233  const reco::SuperClusterRefVector & sclRefs, const std::vector<float> & hoe1s, const std::vector<float> & hoe2s,
235  {
236  theInitialSeedColl = seeds ;
237 // bool duplicateTrajectorySeeds =false ;
238 // unsigned int i,j ;
239 // for (i=0;i<seeds->size();++i)
240 // for (j=i+1;j<seeds->size();++j)
241 // {
242 // const TrajectorySeed & s1 =(*seeds)[i] ;
243 // const TrajectorySeed & s2 =(*seeds)[j] ;
244 // if ( equivalent(s1,s2) )
245 // {
246 // const PTrajectoryStateOnDet & ss1 = s1.startingState() ;
247 // const LocalTrajectoryParameters & p1 = ss1.parameters() ;
248 // const PTrajectoryStateOnDet & ss2 = s2.startingState() ;
249 // const LocalTrajectoryParameters & p2 = ss2.parameters() ;
250 // duplicateTrajectorySeeds = true ;
251 // std::cout<<"Same hits for "
252 // <<"\n s["<<i<<"] ("<<s1.direction()<<"/"<<ss1.detId()<<"/"<<ss1.surfaceSide()<<"/"<<p1.charge()<<"/"<<p1.position()<<"/"<<p1.momentum()<<")"
253 // <<"\n s["<<j<<"] ("<<s2.direction()<<"/"<<ss2.detId()<<"/"<<ss2.surfaceSide()<<"/"<<p2.charge()<<"/"<<p2.position()<<"/"<<p2.momentum()<<")"
254 // <<std::endl ;
255 // }
256 // }
257 // if (duplicateTrajectorySeeds)
258 // { edm::LogWarning("ElectronSeedGenerator|DuplicateTrajectorySeeds")<<"We see several identical trajectory seeds." ; }
259 
260  //Retrieve tracker topology from geometry
262  setup.get<IdealGeometryRecord>().get(tTopoHand);
263  const TrackerTopology *tTopo=tTopoHand.product();
264 
265  theSetup= &setup;
266 
267 
268  // Step A: set Event for the TrajectoryBuilder
270  e.getByToken(theMeasurementTrackerEventTag, data);
271  myMatchEle->setEvent(*data);
272  myMatchPos->setEvent(*data);
273 
274  // get initial TrajectorySeeds if necessary
275  // if (fromTrackerSeeds_) e.getByToken(initialSeeds_, theInitialSeedColl);
276 
277  // get the beamspot from the Event:
278  //e.getByType(theBeamSpot);
279  e.getByToken(beamSpotTag_,theBeamSpot);
280 
281  // if required get the vertices
282  if (useRecoVertex_) e.getByToken(verticesTag_,theVertices);
283 
284  if (!fromTrackerSeeds_)
285  { throw cms::Exception("NotSupported") << "Here in ElectronSeedGenerator " << __FILE__ << ":" << __LINE__ << " I would like to do theMeasurementTracker->update(e); but that no longer makes sense.\n";
286  }
287 
288  for (unsigned int i=0;i<sclRefs.size();++i) {
289  // Find the seeds
290  recHits_.clear();
291 
292  LogDebug ("run") << "new cluster, calling seedsFromThisCluster";
293  seedsFromThisCluster(sclRefs[i],hoe1s[i],hoe2s[i],out,tTopo);
294  }
295 
296  LogDebug ("run") << ": For event "<<e.id();
297  LogDebug ("run") <<"Nr of superclusters after filter: "<<sclRefs.size()
298  <<", no. of ElectronSeeds found = " << out.size();
299 }
300 
303  float hoe1, float hoe2,
304  reco::ElectronSeedCollection & out, const TrackerTopology *tTopo )
305 {
306  float clusterEnergy = seedCluster->energy() ;
307  GlobalPoint clusterPos
308  ( seedCluster->position().x(),
309  seedCluster->position().y(),
310  seedCluster->position().z() ) ;
311  reco::ElectronSeed::CaloClusterRef caloCluster(seedCluster) ;
312 
313  //LogDebug("") << "[ElectronSeedGenerator::seedsFromThisCluster] new supercluster with energy: " << clusterEnergy ;
314  //LogDebug("") << "[ElectronSeedGenerator::seedsFromThisCluster] and position: " << clusterPos ;
315 
316  if (dynamicphiroad_)
317  {
318  float clusterEnergyT = clusterEnergy / cosh( EleRelPoint(clusterPos,theBeamSpot->position()).eta() ) ;
319 
320  float deltaPhi1 ;
321  if (clusterEnergyT < lowPtThreshold_)
322  { deltaPhi1= deltaPhi1Low_ ; }
323  else if (clusterEnergyT > highPtThreshold_)
324  { deltaPhi1= deltaPhi1High_ ; }
325  else
326  { deltaPhi1 = deltaPhi1Coef1_ + deltaPhi1Coef2_/clusterEnergyT ; }
327 
328  float ephimin1 = -deltaPhi1*sizeWindowENeg_ ;
329  float ephimax1 = deltaPhi1*(1.-sizeWindowENeg_);
330  float pphimin1 = -deltaPhi1*(1.-sizeWindowENeg_);
331  float pphimax1 = deltaPhi1*sizeWindowENeg_;
332 
333  float phimin2B = -deltaPhi2B_/2. ;
334  float phimax2B = deltaPhi2B_/2. ;
335  float phimin2F = -deltaPhi2F_/2. ;
336  float phimax2F = deltaPhi2F_/2. ;
337 
338 
339  myMatchEle->set1stLayer(ephimin1,ephimax1);
340  myMatchPos->set1stLayer(pphimin1,pphimax1);
341  myMatchEle->set2ndLayer(phimin2B,phimax2B, phimin2F,phimax2F);
342  myMatchPos->set2ndLayer(phimin2B,phimax2B, phimin2F,phimax2F);
343  }
344 
346 
347  if (!useRecoVertex_) // here use the beam spot position
348  {
349  double sigmaZ=theBeamSpot->sigmaZ();
350  double sigmaZ0Error=theBeamSpot->sigmaZ0Error();
351  double sq=sqrt(sigmaZ*sigmaZ+sigmaZ0Error*sigmaZ0Error);
352  double myZmin1=theBeamSpot->position().z()-nSigmasDeltaZ1_*sq;
353  double myZmax1=theBeamSpot->position().z()+nSigmasDeltaZ1_*sq;
354 
355  GlobalPoint vertexPos ;
356  ele_convert(theBeamSpot->position(),vertexPos) ;
357 
358  myMatchEle->set1stLayerZRange(myZmin1,myZmax1);
359  myMatchPos->set1stLayerZRange(myZmin1,myZmax1);
360 
361  if (!fromTrackerSeeds_)
362  {
363  // try electron
364  std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > elePixelHits
365  = myMatchEle->compatibleHits(clusterPos,vertexPos,
366  clusterEnergy,-1., tTopo, *theNavigationSchool) ;
367  GlobalPoint eleVertex(theBeamSpot->position().x(),theBeamSpot->position().y(),myMatchEle->getVertex()) ;
368  seedsFromRecHits(elePixelHits,dir,eleVertex,caloCluster,out,false) ;
369  // try positron
370  std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > posPixelHits
371  = myMatchPos->compatibleHits(clusterPos,vertexPos,clusterEnergy,1.,tTopo, *theNavigationSchool) ;
372  GlobalPoint posVertex(theBeamSpot->position().x(),theBeamSpot->position().y(),myMatchPos->getVertex()) ;
373  seedsFromRecHits(posPixelHits,dir,posVertex,caloCluster,out,true) ;
374  }
375  else
376  {
377  // try electron
378  std::vector<SeedWithInfo> elePixelSeeds
379  = myMatchEle->compatibleSeeds(theInitialSeedColl,clusterPos,vertexPos,clusterEnergy,-1.) ;
380  seedsFromTrajectorySeeds(elePixelSeeds,caloCluster,hoe1,hoe2,out,false) ;
381  // try positron
382  std::vector<SeedWithInfo> posPixelSeeds
383  = myMatchPos->compatibleSeeds(theInitialSeedColl,clusterPos,vertexPos,clusterEnergy,1.) ;
384  seedsFromTrajectorySeeds(posPixelSeeds,caloCluster,hoe1,hoe2,out,true) ;
385  }
386 
387  }
388  else // here we use the reco vertices
389  {
390 
391  myMatchEle->setUseRecoVertex(true) ; //Hit matchers need to know that the vertex is known
392  myMatchPos->setUseRecoVertex(true) ;
393 
394  const std::vector<reco::Vertex> * vtxCollection = theVertices.product() ;
395  std::vector<reco::Vertex>::const_iterator vtxIter ;
396  for (vtxIter = vtxCollection->begin(); vtxIter != vtxCollection->end() ; vtxIter++)
397  {
398 
399  GlobalPoint vertexPos(vtxIter->position().x(),vtxIter->position().y(),vtxIter->position().z());
400  double myZmin1, myZmax1 ;
401  if (vertexPos.z()==theBeamSpot->position().z())
402  { // in case vetex not found
403  double sigmaZ=theBeamSpot->sigmaZ();
404  double sigmaZ0Error=theBeamSpot->sigmaZ0Error();
405  double sq=sqrt(sigmaZ*sigmaZ+sigmaZ0Error*sigmaZ0Error);
406  myZmin1=theBeamSpot->position().z()-nSigmasDeltaZ1_*sq;
407  myZmax1=theBeamSpot->position().z()+nSigmasDeltaZ1_*sq;
408  }
409  else
410  { // a vertex has been recoed
411  myZmin1=vtxIter->position().z()-deltaZ1WithVertex_;
412  myZmax1=vtxIter->position().z()+deltaZ1WithVertex_;
413  }
414 
415  myMatchEle->set1stLayerZRange(myZmin1,myZmax1);
416  myMatchPos->set1stLayerZRange(myZmin1,myZmax1);
417 
418  if (!fromTrackerSeeds_)
419  {
420  // try electron
421  std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > elePixelHits
422  = myMatchEle->compatibleHits(clusterPos,vertexPos,clusterEnergy,-1.,tTopo, *theNavigationSchool) ;
423  seedsFromRecHits(elePixelHits,dir,vertexPos,caloCluster,out,false) ;
424  // try positron
425  std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > posPixelHits
426  = myMatchPos->compatibleHits(clusterPos,vertexPos,clusterEnergy,1.,tTopo, *theNavigationSchool) ;
427  seedsFromRecHits(posPixelHits,dir,vertexPos,caloCluster,out,true) ;
428  }
429  else
430  {
431  // try electron
432  std::vector<SeedWithInfo> elePixelSeeds
433  = myMatchEle->compatibleSeeds(theInitialSeedColl,clusterPos,vertexPos,clusterEnergy,-1.) ;
434  seedsFromTrajectorySeeds(elePixelSeeds,caloCluster,hoe1,hoe2,out,false) ;
435  // try positron
436  std::vector<SeedWithInfo> posPixelSeeds
437  = myMatchPos->compatibleSeeds(theInitialSeedColl,clusterPos,vertexPos,clusterEnergy,1.) ;
438  seedsFromTrajectorySeeds(posPixelSeeds,caloCluster,hoe1,hoe2,out,true) ;
439  }
440  }
441  }
442 
443  return ;
444  }
445 
447  ( std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > & pixelHits,
449  const GlobalPoint & vertexPos, const reco::ElectronSeed::CaloClusterRef & cluster,
451  bool positron )
452  {
453  if (!pixelHits.empty())
454  { LogDebug("ElectronSeedGenerator") << "Compatible "<<(positron?"positron":"electron")<<" hits found." ; }
455 
456  std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> >::iterator v ;
457  for ( v = pixelHits.begin() ; v != pixelHits.end() ; v++ )
458  {
459  if (!positron)
460  { (*v).first.invert() ; }
461  if (!prepareElTrackSeed((*v).first.recHit(),(*v).second,vertexPos))
462  { continue ; }
463  reco::ElectronSeed seed(pts_,recHits_,dir) ;
464  seed.setCaloCluster(cluster) ;
465  addSeed(seed,0,positron,out) ;
466  }
467  }
468 
470  ( const std::vector<SeedWithInfo> & pixelSeeds,
471  const reco::ElectronSeed::CaloClusterRef & cluster,
472  float hoe1, float hoe2,
474  bool positron )
475  {
476  if (!pixelSeeds.empty())
477  { LogDebug("ElectronSeedGenerator") << "Compatible "<<(positron?"positron":"electron")<<" seeds found." ; }
478 
479  std::vector<SeedWithInfo>::const_iterator s;
480  for ( s = pixelSeeds.begin() ; s != pixelSeeds.end() ; s++ )
481  {
482  reco::ElectronSeed seed(s->seed()) ;
483  seed.setCaloCluster(cluster,s->hitsMask(),s->subDet2(),s->subDet1(),hoe1,hoe2) ;
484  addSeed(seed,&*s,positron,out) ;
485  }
486  }
487 
490  const SeedWithInfo * info,
491  bool positron,
493  {
494  if (!info)
495  { out.push_back(seed) ; return ; }
496 
497  if (positron)
498  { seed.setPosAttributes(info->dRz2(),info->dPhi2(),info->dRz1(),info->dPhi1()) ; }
499  else
500  { seed.setNegAttributes(info->dRz2(),info->dPhi2(),info->dRz1(),info->dPhi1()) ; }
501  reco::ElectronSeedCollection::iterator resItr ;
502  for ( resItr=out.begin() ; resItr!=out.end() ; ++resItr )
503  {
504  if ( (seed.caloCluster()==resItr->caloCluster()) &&
505  (seed.hitsMask()==resItr->hitsMask()) &&
506  equivalent(seed,*resItr) )
507  {
508  if (positron)
509  {
510  if ( resItr->dRz2Pos()==std::numeric_limits<float>::infinity() &&
511  resItr->dRz2()!=std::numeric_limits<float>::infinity() )
512  {
513  resItr->setPosAttributes(info->dRz2(),info->dPhi2(),info->dRz1(),info->dPhi1()) ;
514  seed.setNegAttributes(resItr->dRz2(),resItr->dPhi2(),resItr->dRz1(),resItr->dPhi1()) ;
515  break ;
516  }
517  else
518  {
519  if ( resItr->dRz2Pos()!=std::numeric_limits<float>::infinity() )
520  {
521  if ( resItr->dRz2Pos()!=seed.dRz2Pos() )
522  {
523  edm::LogWarning("ElectronSeedGenerator|BadValue")
524  <<"this similar old seed already has another dRz2Pos"
525  <<"\nold seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(unsigned int)resItr->hitsMask()<<"/"<<resItr->dRz2()<<"/"<<resItr->dPhi2()<<"/"<<resItr->dRz2Pos()<<"/"<<resItr->dPhi2Pos()
526  <<"\nnew seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(unsigned int)seed.hitsMask()<<"/"<<seed.dRz2()<<"/"<<seed.dPhi2()<<"/"<<seed.dRz2Pos()<<"/"<<seed.dPhi2Pos() ;
527  }
528 // else
529 // {
530 // edm::LogWarning("ElectronSeedGenerator|UnexpectedValue")
531 // <<"this old seed already knows its dRz2Pos, we suspect duplicates in input trajectry seeds"
532 // <<"\nold seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(unsigned int)resItr->hitsMask()<<"/"<<resItr->dRz2()<<"/"<<resItr->dPhi2()<<"/"<<resItr->dRz2Pos()<<"/"<<resItr->dPhi2Pos()
533 // <<"\nnew seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(unsigned int)seed.hitsMask()<<"/"<<seed.dRz2()<<"/"<<seed.dPhi2()<<"/"<<seed.dRz2Pos()<<"/"<<seed.dPhi2Pos() ;
534 // }
535  }
536 // if (resItr->dRz2()==std::numeric_limits<float>::infinity())
537 // {
538 // edm::LogWarning("ElectronSeedGenerator|BadValue")
539 // <<"this old seed has no dRz2, we suspect duplicates in input trajectry seeds"
540 // <<"\nold seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(unsigned int)resItr->hitsMask()<<"/"<<resItr->dRz2()<<"/"<<resItr->dPhi2()<<"/"<<resItr->dRz2Pos()<<"/"<<resItr->dPhi2Pos()
541 // <<"\nnew seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(unsigned int)seed.hitsMask()<<"/"<<seed.dRz2()<<"/"<<seed.dPhi2()<<"/"<<seed.dRz2Pos()<<"/"<<seed.dPhi2Pos() ;
542 // }
543  }
544  }
545  else
546  {
547  if ( resItr->dRz2()==std::numeric_limits<float>::infinity()
548  && resItr->dRz2Pos()!=std::numeric_limits<float>::infinity() )
549  {
550  resItr->setNegAttributes(info->dRz2(),info->dPhi2(),info->dRz1(),info->dPhi1()) ;
551  seed.setPosAttributes(resItr->dRz2Pos(),resItr->dPhi2Pos(),resItr->dRz1Pos(),resItr->dPhi1Pos()) ;
552  break ;
553  }
554  else
555  {
556  if ( resItr->dRz2()!=std::numeric_limits<float>::infinity() )
557  {
558  if (resItr->dRz2()!=seed.dRz2())
559  {
560  edm::LogWarning("ElectronSeedGenerator|BadValue")
561  <<"this old seed already has another dRz2"
562  <<"\nold seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(unsigned int)resItr->hitsMask()<<"/"<<resItr->dRz2()<<"/"<<resItr->dPhi2()<<"/"<<resItr->dRz2Pos()<<"/"<<resItr->dPhi2Pos()
563  <<"\nnew seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(unsigned int)seed.hitsMask()<<"/"<<seed.dRz2()<<"/"<<seed.dPhi2()<<"/"<<seed.dRz2Pos()<<"/"<<seed.dPhi2Pos() ;
564  }
565  // else
566  // {
567  // edm::LogWarning("ElectronSeedGenerator|UnexpectedValue")
568  // <<"this old seed already knows its dRz2, we suspect duplicates in input trajectry seeds"
569  // <<"\nold seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(unsigned int)resItr->hitsMask()<<"/"<<resItr->dRz2()<<"/"<<resItr->dPhi2()<<"/"<<resItr->dRz2Pos()<<"/"<<resItr->dPhi2Pos()
570  // <<"\nnew seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(unsigned int)seed.hitsMask()<<"/"<<seed.dRz2()<<"/"<<seed.dPhi2()<<"/"<<seed.dRz2Pos()<<"/"<<seed.dPhi2Pos() ;
571  // seed.setPosAttributes(resItr->dRz2Pos(),resItr->dPhi2Pos(),resItr->dRz1Pos(),resItr->dPhi1Pos()) ;
572  // }
573  }
574 // if (resItr->dRz2Pos()==std::numeric_limits<float>::infinity())
575 // {
576 // edm::LogWarning("ElectronSeedGenerator|BadValue")
577 // <<"this old seed has no dRz2Pos"
578 // <<"\nold seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(unsigned int)resItr->hitsMask()<<"/"<<resItr->dRz2()<<"/"<<resItr->dPhi2()<<"/"<<resItr->dRz2Pos()<<"/"<<resItr->dPhi2Pos()
579 // <<"\nnew seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(unsigned int)seed.hitsMask()<<"/"<<seed.dRz2()<<"/"<<seed.dPhi2()<<"/"<<seed.dRz2Pos()<<"/"<<seed.dPhi2Pos() ;
580 // }
581  }
582  }
583  }
584  }
585 
586  out.push_back(seed) ;
587  }
588 
590  ( ConstRecHitPointer innerhit,
591  ConstRecHitPointer outerhit,
592  const GlobalPoint& vertexPos )
593  {
594 
595  // debug prints
596  LogDebug("") <<"[ElectronSeedGenerator::prepareElTrackSeed] inner PixelHit x,y,z "<<innerhit->globalPosition();
597  LogDebug("") <<"[ElectronSeedGenerator::prepareElTrackSeed] outer PixelHit x,y,z "<<outerhit->globalPosition();
598 
599  recHits_.clear();
600 
601  SiPixelRecHit *pixhit=0;
602  SiStripMatchedRecHit2D *striphit=0;
603  const SiPixelRecHit* constpixhit = dynamic_cast <const SiPixelRecHit*> (innerhit->hit());
604  if (constpixhit) {
605  pixhit=new SiPixelRecHit(*constpixhit);
606  recHits_.push_back(pixhit);
607  } else return false;
608  constpixhit = dynamic_cast <const SiPixelRecHit *> (outerhit->hit());
609  if (constpixhit) {
610  pixhit=new SiPixelRecHit(*constpixhit);
611  recHits_.push_back(pixhit);
612  } else {
613  const SiStripMatchedRecHit2D * conststriphit=dynamic_cast <const SiStripMatchedRecHit2D *> (outerhit->hit());
614  if (conststriphit) {
615  striphit = new SiStripMatchedRecHit2D(*conststriphit);
616  recHits_.push_back(striphit);
617  } else return false;
618  }
619 
621 
622  // FIXME to be optimized outside the loop
624  theSetup->get<IdealMagneticFieldRecord>().get(bfield);
625  float nomField = bfield->nominalValue();
626 
627  // make a spiral
628  FastHelix helix(outerhit->globalPosition(),innerhit->globalPosition(),vertexPos,nomField,&*bfield);
629  if ( !helix.isValid()) {
630  return false;
631  }
632  FreeTrajectoryState fts(helix.stateAtVertex());
633  TSOS propagatedState = thePropagator->propagate(fts,innerhit->det()->surface()) ;
634  if (!propagatedState.isValid())
635  return false;
636  TSOS updatedState = theUpdator->update(propagatedState, *innerhit);
637 
638  TSOS propagatedState_out = thePropagator->propagate(updatedState,outerhit->det()->surface()) ;
639  if (!propagatedState_out.isValid())
640  return false;
641  TSOS updatedState_out = theUpdator->update(propagatedState_out, *outerhit);
642  // debug prints
643  LogDebug("") <<"[ElectronSeedGenerator::prepareElTrackSeed] final TSOS, position: "<<updatedState_out.globalPosition()<<" momentum: "<<updatedState_out.globalMomentum();
644  LogDebug("") <<"[ElectronSeedGenerator::prepareElTrackSeed] final TSOS Pt: "<<updatedState_out.globalMomentum().perp();
645  pts_ = trajectoryStateTransform::persistentState(updatedState_out, outerhit->geographicalId().rawId());
646 
647  return true;
648  }
#define LogDebug(id)
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())
Definition: ElectronSeed.cc:71
T getParameter(std::string const &) const
unsigned long long cacheIdentifier() const
unsigned long long cacheIDNavSchool_
int i
Definition: DBlmapReader.cc:9
dictionary parameters
Definition: Parameters.py:2
static const TGPicture * info(bool iBackgroundIsBlack)
T perp() const
Definition: PV3DBase.h:72
PixelHitMatcher * myMatchEle
void setupES(const edm::EventSetup &setup)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
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
float dRz1() const
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
bool exists(std::string const &parameterName) const
checks if a parameter exists
float dRz2() const
GlobalPoint globalPosition() const
unsigned long long cacheIDMagField_
PropagationDirection
T eta() const
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_
tuple s2
Definition: indexGen.py:106
return((rh^lh)&mask)
CaloClusterRef caloCluster() const
Definition: ElectronSeed.h:70
float dPhi2() const
Definition: ElectronSeed.h:74
float dRz2Pos() const
Definition: ElectronSeed.h:75
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
T sqrt(T t)
Definition: SSEVec.h:48
const double infinity
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())
Definition: ElectronSeed.cc:86
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
tuple out
Definition: dbtoconf.py:99
float dRz2() const
Definition: ElectronSeed.h:73
void seedsFromRecHits(std::vector< std::pair< RecHitWithDist, ConstRecHitPointer > > &elePixelHits, PropagationDirection &dir, const GlobalPoint &vertexPos, const reco::ElectronSeed::CaloClusterRef &cluster, reco::ElectronSeedCollection &out, bool positron)
float dPhi1() const
float dPhi2() const
bool prepareElTrackSeed(ConstRecHitPointer outerhit, ConstRecHitPointer innerhit, const GlobalPoint &vertexPos)
TrajectoryStateOnSurface TSOS
Definition: TestHits.cc:19
PTrajectoryStateOnDet const & startingState() const
float dPhi2Pos() const
Definition: ElectronSeed.h:76
void addSeed(reco::ElectronSeed &seed, const SeedWithInfo *info, bool positron, reco::ElectronSeedCollection &out)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
range recHits() 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
edm::EventID id() const
Definition: EventBase.h:56
bool equivalent(const TrajectorySeed &s1, const TrajectorySeed &s2)
unsigned int nHits() const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
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.
Definition: RefVector.h:89
int subDet2() const
Definition: ElectronSeed.h:72
tuple cout
Definition: gather_cfg.py:121
dbl *** dir
Definition: mlp_gen.cc:35
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())
Definition: ElectronSeed.cc:95
void seedsFromTrajectorySeeds(const std::vector< SeedWithInfo > &elePixelSeeds, const reco::ElectronSeed::CaloClusterRef &cluster, float hoe1, float hoe2, reco::ElectronSeedCollection &out, bool positron)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
const LocalTrajectoryParameters & parameters() const
Our base class.
Definition: SiPixelRecHit.h:23
unsigned char hitsMask() const
Definition: ElectronSeed.h:71
unsigned long long cacheIDCkfComp_