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 
43 #include <vector>
44 #include <utility>
45 
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),
61  thePropagator(0),
62  theMeasurementTracker(0),
63  theSetup(0),
64  cacheIDMagField_(0),/*cacheIDGeom_(0),*/cacheIDNavSchool_(0),cacheIDCkfComp_(0),cacheIDTrkGeom_(0)
65  {
66  // so that deltaPhi1 = deltaPhi1Coef1_ + deltaPhi1Coef2_/clusterEnergyT
67  if (dynamicphiroad_)
68  {
71  }
72 
73  // use of a theMeasurementTrackerName
74  if (pset.exists("measurementTrackerName"))
75  { theMeasurementTrackerName = pset.getParameter<std::string>("measurementTrackerName") ; }
76 
77  // use of reco vertex
78  if (pset.exists("useRecoVertex"))
79  { useRecoVertex_ = pset.getParameter<bool>("useRecoVertex") ; }
80  if (pset.exists("vertices"))
81  { verticesTag_ = pset.getParameter<edm::InputTag>("vertices") ; }
82  if (pset.exists("deltaZ1WithVertex"))
83  { deltaZ1WithVertex_ = pset.getParameter<double>("deltaZ1WithVertex") ; }
84 
85  // new beamSpot tag
86  if (pset.exists("beamSpot"))
87  { beamSpotTag_ = pset.getParameter<edm::InputTag>("beamSpot") ; }
88 
89  // new B/F configurables
90  if (pset.exists("DeltaPhi2"))
91  { deltaPhi2B_ = deltaPhi2F_ = pset.getParameter<double>("DeltaPhi2") ; }
92  else
93  {
94  deltaPhi2B_ = pset.getParameter<double>("DeltaPhi2B") ;
95  deltaPhi2F_ = pset.getParameter<double>("DeltaPhi2F") ;
96  }
97  if (pset.exists("PhiMin2"))
98  { phiMin2B_ = phiMin2F_ = pset.getParameter<double>("PhiMin2") ; }
99  else
100  {
101  phiMin2B_ = pset.getParameter<double>("PhiMin2B") ;
102  phiMin2F_ = pset.getParameter<double>("PhiMin2F") ;
103  }
104  if (pset.exists("PhiMax2"))
105  { phiMax2B_ = phiMax2F_ = pset.getParameter<double>("PhiMax2") ; }
106  else
107  {
108  phiMax2B_ = pset.getParameter<double>("PhiMax2B") ;
109  phiMax2F_ = pset.getParameter<double>("PhiMax2F") ;
110  }
111 
112  // Instantiate the pixel hit matchers
114  ( pset.getParameter<double>("ePhiMin1"),
115  pset.getParameter<double>("ePhiMax1"),
117  pset.getParameter<double>("z2MinB"),
118  pset.getParameter<double>("z2MaxB"),
119  pset.getParameter<double>("r2MinF"),
120  pset.getParameter<double>("r2MaxF"),
121  pset.getParameter<double>("rMinI"),
122  pset.getParameter<double>("rMaxI"),
123  pset.getParameter<bool>("searchInTIDTEC") ) ;
124 
126  ( pset.getParameter<double>("pPhiMin1"),
127  pset.getParameter<double>("pPhiMax1"),
129  pset.getParameter<double>("z2MinB"),
130  pset.getParameter<double>("z2MaxB"),
131  pset.getParameter<double>("r2MinF"),
132  pset.getParameter<double>("r2MaxF"),
133  pset.getParameter<double>("rMinI"),
134  pset.getParameter<double>("rMaxI"),
135  pset.getParameter<bool>("searchInTIDTEC") ) ;
136 
137  theUpdator = new KFUpdator() ;
138  }
139 
141  {
142  delete myMatchEle ;
143  delete myMatchPos ;
144  delete thePropagator ;
145  delete theUpdator ;
146  }
147 
149 
150  // get records if necessary (called once per event)
151  bool tochange=false;
152 
155  cacheIDMagField_=setup.get<IdealMagneticFieldRecord>().cacheIdentifier();
156  if (thePropagator) delete thePropagator;
158  tochange=true;
159  }
160 
162  edm::ESHandle<MeasurementTracker> measurementTrackerHandle;
163  setup.get<CkfComponentsRecord>().get(theMeasurementTrackerName,measurementTrackerHandle);
164  cacheIDCkfComp_=setup.get<CkfComponentsRecord>().cacheIdentifier();
165  theMeasurementTracker = measurementTrackerHandle.product();
166  tochange=true;
167  }
168 
169  //edm::ESHandle<TrackerGeometry> trackerGeometryHandle;
171  cacheIDTrkGeom_=setup.get<TrackerDigiGeometryRecord>().cacheIdentifier();
173  tochange=true; //FIXME
174  }
175 
176  if (tochange) {
179  }
180 
183  setup.get<NavigationSchoolRecord>().get("SimpleNavigationSchool", nav);
184  cacheIDNavSchool_=setup.get<NavigationSchoolRecord>().cacheIdentifier();
186  }
187 
188 // if (cacheIDGeom_!=setup.get<TrackerRecoGeometryRecord>().cacheIdentifier()) {
189 // setup.get<TrackerRecoGeometryRecord>().get( theGeomSearchTracker );
190 // cacheIDGeom_=setup.get<TrackerRecoGeometryRecord>().cacheIdentifier();
191 // }
192 
193 }
194 
195 void display_seed( const std::string & title1, const std::string & title2, const reco::ElectronSeed & seed, edm::ESHandle<TrackerGeometry> trackerGeometry )
196  {
197  const PTrajectoryStateOnDet & startingState = seed.startingState() ;
198  const LocalTrajectoryParameters & parameters = startingState.parameters() ;
199  std::cout<<title1
200  <<" ("<<seed.subDet2()<<"/"<<seed.dRz2()<<"/"<<seed.dPhi2()<<")"
201  <<" ("<<seed.direction()<<"/"<<startingState.detId()<<"/"<<startingState.surfaceSide()<<"/"<<parameters.charge()<<"/"<<parameters.position()<<"/"<<parameters.momentum()<<")"
202  <<std::endl ;
203  }
204 
205 bool equivalent( const TrajectorySeed & s1, const TrajectorySeed & s2 )
206  {
207  if (s1.nHits()!=s2.nHits()) return false ;
208 
209  unsigned int nHits ;
210  TrajectorySeed::range r1 = s1.recHits(), r2 = s2.recHits() ;
212  for ( i1=r1.first, i2=r2.first, nHits=0 ; i1!=r1.second ; ++i1, ++i2, ++nHits )
213  {
214  if ( !i1->isValid() || !i2->isValid() ) return false ;
215  if ( i1->geographicalId()!=i2->geographicalId() ) return false ;
216  if ( ! ( i1->localPosition()==i2->localPosition() ) ) return false ;
217  }
218 
219  return true ;
220  }
221 
224  const reco::SuperClusterRefVector & sclRefs, const std::vector<float> & hoe1s, const std::vector<float> & hoe2s,
226  {
227  theInitialSeedColl = seeds ;
228 // bool duplicateTrajectorySeeds =false ;
229 // unsigned int i,j ;
230 // for (i=0;i<seeds->size();++i)
231 // for (j=i+1;j<seeds->size();++j)
232 // {
233 // const TrajectorySeed & s1 =(*seeds)[i] ;
234 // const TrajectorySeed & s2 =(*seeds)[j] ;
235 // if ( equivalent(s1,s2) )
236 // {
237 // const PTrajectoryStateOnDet & ss1 = s1.startingState() ;
238 // const LocalTrajectoryParameters & p1 = ss1.parameters() ;
239 // const PTrajectoryStateOnDet & ss2 = s2.startingState() ;
240 // const LocalTrajectoryParameters & p2 = ss2.parameters() ;
241 // duplicateTrajectorySeeds = true ;
242 // std::cout<<"Same hits for "
243 // <<"\n s["<<i<<"] ("<<s1.direction()<<"/"<<ss1.detId()<<"/"<<ss1.surfaceSide()<<"/"<<p1.charge()<<"/"<<p1.position()<<"/"<<p1.momentum()<<")"
244 // <<"\n s["<<j<<"] ("<<s2.direction()<<"/"<<ss2.detId()<<"/"<<ss2.surfaceSide()<<"/"<<p2.charge()<<"/"<<p2.position()<<"/"<<p2.momentum()<<")"
245 // <<std::endl ;
246 // }
247 // }
248 // if (duplicateTrajectorySeeds)
249 // { edm::LogWarning("ElectronSeedGenerator|DuplicateTrajectorySeeds")<<"We see several identical trajectory seeds." ; }
250 
251  //Retrieve tracker topology from geometry
253  setup.get<IdealGeometryRecord>().get(tTopoHand);
254  const TrackerTopology *tTopo=tTopoHand.product();
255 
256  theSetup= &setup;
257  NavigationSetter theSetter(*theNavigationSchool);
258 
259  // get initial TrajectorySeeds if necessary
260  // if (fromTrackerSeeds_) e.getByLabel(initialSeeds_, theInitialSeedColl);
261 
262  // get the beamspot from the Event:
263  //e.getByType(theBeamSpot);
264  e.getByLabel(beamSpotTag_,theBeamSpot);
265 
266  // if required get the vertices
267  if (useRecoVertex_) e.getByLabel(verticesTag_,theVertices);
268 
269  if (!fromTrackerSeeds_)
270  { theMeasurementTracker->update(e) ; }
271 
272  for (unsigned int i=0;i<sclRefs.size();++i) {
273  // Find the seeds
274  recHits_.clear();
275 
276  LogDebug ("run") << "new cluster, calling seedsFromThisCluster";
277  seedsFromThisCluster(sclRefs[i],hoe1s[i],hoe2s[i],out,tTopo);
278  }
279 
280  LogDebug ("run") << ": For event "<<e.id();
281  LogDebug ("run") <<"Nr of superclusters after filter: "<<sclRefs.size()
282  <<", no. of ElectronSeeds found = " << out.size();
283 }
284 
287  float hoe1, float hoe2,
288  reco::ElectronSeedCollection & out, const TrackerTopology *tTopo )
289 {
290  float clusterEnergy = seedCluster->energy() ;
291  GlobalPoint clusterPos
292  ( seedCluster->position().x(),
293  seedCluster->position().y(),
294  seedCluster->position().z() ) ;
295  reco::ElectronSeed::CaloClusterRef caloCluster(seedCluster) ;
296 
297  //LogDebug("") << "[ElectronSeedGenerator::seedsFromThisCluster] new supercluster with energy: " << clusterEnergy ;
298  //LogDebug("") << "[ElectronSeedGenerator::seedsFromThisCluster] and position: " << clusterPos ;
299 
300  if (dynamicphiroad_)
301  {
302  float clusterEnergyT = clusterEnergy / cosh( EleRelPoint(clusterPos,theBeamSpot->position()).eta() ) ;
303 
304  float deltaPhi1 ;
305  if (clusterEnergyT < lowPtThreshold_)
306  { deltaPhi1= deltaPhi1Low_ ; }
307  else if (clusterEnergyT > highPtThreshold_)
308  { deltaPhi1= deltaPhi1High_ ; }
309  else
310  { deltaPhi1 = deltaPhi1Coef1_ + deltaPhi1Coef2_/clusterEnergyT ; }
311 
312  float ephimin1 = -deltaPhi1*sizeWindowENeg_ ;
313  float ephimax1 = deltaPhi1*(1.-sizeWindowENeg_);
314  float pphimin1 = -deltaPhi1*(1.-sizeWindowENeg_);
315  float pphimax1 = deltaPhi1*sizeWindowENeg_;
316 
317  float phimin2B = -deltaPhi2B_/2. ;
318  float phimax2B = deltaPhi2B_/2. ;
319  float phimin2F = -deltaPhi2F_/2. ;
320  float phimax2F = deltaPhi2F_/2. ;
321 
322 
323  myMatchEle->set1stLayer(ephimin1,ephimax1);
324  myMatchPos->set1stLayer(pphimin1,pphimax1);
325  myMatchEle->set2ndLayer(phimin2B,phimax2B, phimin2F,phimax2F);
326  myMatchPos->set2ndLayer(phimin2B,phimax2B, phimin2F,phimax2F);
327  }
328 
330 
331  if (!useRecoVertex_) // here use the beam spot position
332  {
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;
338 
339  GlobalPoint vertexPos ;
340  ele_convert(theBeamSpot->position(),vertexPos) ;
341 
342  myMatchEle->set1stLayerZRange(myZmin1,myZmax1);
343  myMatchPos->set1stLayerZRange(myZmin1,myZmax1);
344 
345  if (!fromTrackerSeeds_)
346  {
347  // try electron
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) ;
353  // try positron
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) ;
358  }
359  else
360  {
361  // try electron
362  std::vector<SeedWithInfo> elePixelSeeds
363  = myMatchEle->compatibleSeeds(theInitialSeedColl,clusterPos,vertexPos,clusterEnergy,-1.) ;
364  seedsFromTrajectorySeeds(elePixelSeeds,caloCluster,hoe1,hoe2,out,false) ;
365  // try positron
366  std::vector<SeedWithInfo> posPixelSeeds
367  = myMatchPos->compatibleSeeds(theInitialSeedColl,clusterPos,vertexPos,clusterEnergy,1.) ;
368  seedsFromTrajectorySeeds(posPixelSeeds,caloCluster,hoe1,hoe2,out,true) ;
369  }
370 
371  }
372  else // here we use the reco vertices
373  {
374 
375  myMatchEle->setUseRecoVertex(true) ; //Hit matchers need to know that the vertex is known
376  myMatchPos->setUseRecoVertex(true) ;
377 
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++)
381  {
382 
383  GlobalPoint vertexPos(vtxIter->position().x(),vtxIter->position().y(),vtxIter->position().z());
384  double myZmin1, myZmax1 ;
385  if (vertexPos.z()==theBeamSpot->position().z())
386  { // in case vetex not found
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;
392  }
393  else
394  { // a vertex has been recoed
395  myZmin1=vtxIter->position().z()-deltaZ1WithVertex_;
396  myZmax1=vtxIter->position().z()+deltaZ1WithVertex_;
397  }
398 
399  myMatchEle->set1stLayerZRange(myZmin1,myZmax1);
400  myMatchPos->set1stLayerZRange(myZmin1,myZmax1);
401 
402  if (!fromTrackerSeeds_)
403  {
404  // try electron
405  std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > elePixelHits
406  = myMatchEle->compatibleHits(clusterPos,vertexPos,clusterEnergy,-1.,tTopo) ;
407  seedsFromRecHits(elePixelHits,dir,vertexPos,caloCluster,out,false) ;
408  // try positron
409  std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > posPixelHits
410  = myMatchPos->compatibleHits(clusterPos,vertexPos,clusterEnergy,1.,tTopo) ;
411  seedsFromRecHits(posPixelHits,dir,vertexPos,caloCluster,out,true) ;
412  }
413  else
414  {
415  // try electron
416  std::vector<SeedWithInfo> elePixelSeeds
417  = myMatchEle->compatibleSeeds(theInitialSeedColl,clusterPos,vertexPos,clusterEnergy,-1.) ;
418  seedsFromTrajectorySeeds(elePixelSeeds,caloCluster,hoe1,hoe2,out,false) ;
419  // try positron
420  std::vector<SeedWithInfo> posPixelSeeds
421  = myMatchPos->compatibleSeeds(theInitialSeedColl,clusterPos,vertexPos,clusterEnergy,1.) ;
422  seedsFromTrajectorySeeds(posPixelSeeds,caloCluster,hoe1,hoe2,out,true) ;
423  }
424  }
425  }
426 
427  return ;
428  }
429 
431  ( std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> > & pixelHits,
433  const GlobalPoint & vertexPos, const reco::ElectronSeed::CaloClusterRef & cluster,
435  bool positron )
436  {
437  if (!pixelHits.empty())
438  { LogDebug("ElectronSeedGenerator") << "Compatible "<<(positron?"positron":"electron")<<" hits found." ; }
439 
440  std::vector<std::pair<RecHitWithDist,ConstRecHitPointer> >::iterator v ;
441  for ( v = pixelHits.begin() ; v != pixelHits.end() ; v++ )
442  {
443  if (!positron)
444  { (*v).first.invert() ; }
445  if (!prepareElTrackSeed((*v).first.recHit(),(*v).second,vertexPos))
446  { continue ; }
447  reco::ElectronSeed seed(pts_,recHits_,dir) ;
448  seed.setCaloCluster(cluster) ;
449  addSeed(seed,0,positron,out) ;
450  }
451  }
452 
454  ( const std::vector<SeedWithInfo> & pixelSeeds,
455  const reco::ElectronSeed::CaloClusterRef & cluster,
456  float hoe1, float hoe2,
458  bool positron )
459  {
460  if (!pixelSeeds.empty())
461  { LogDebug("ElectronSeedGenerator") << "Compatible "<<(positron?"positron":"electron")<<" seeds found." ; }
462 
463  std::vector<SeedWithInfo>::const_iterator s;
464  for ( s = pixelSeeds.begin() ; s != pixelSeeds.end() ; s++ )
465  {
466  reco::ElectronSeed seed(s->seed()) ;
467  seed.setCaloCluster(cluster,s->hitsMask(),s->subDet2(),s->subDet1(),hoe1,hoe2) ;
468  addSeed(seed,&*s,positron,out) ;
469  }
470  }
471 
474  const SeedWithInfo * info,
475  bool positron,
477  {
478  if (!info)
479  { out.push_back(seed) ; return ; }
480 
481  if (positron)
482  { seed.setPosAttributes(info->dRz2(),info->dPhi2(),info->dRz1(),info->dPhi1()) ; }
483  else
484  { seed.setNegAttributes(info->dRz2(),info->dPhi2(),info->dRz1(),info->dPhi1()) ; }
485  reco::ElectronSeedCollection::iterator resItr ;
486  for ( resItr=out.begin() ; resItr!=out.end() ; ++resItr )
487  {
488  if ( (seed.caloCluster()==resItr->caloCluster()) &&
489  (seed.hitsMask()==resItr->hitsMask()) &&
490  equivalent(seed,*resItr) )
491  {
492  if (positron)
493  {
494  if ( resItr->dRz2Pos()==std::numeric_limits<float>::infinity() &&
495  resItr->dRz2()!=std::numeric_limits<float>::infinity() )
496  {
497  resItr->setPosAttributes(info->dRz2(),info->dPhi2(),info->dRz1(),info->dPhi1()) ;
498  seed.setNegAttributes(resItr->dRz2(),resItr->dPhi2(),resItr->dRz1(),resItr->dPhi1()) ;
499  break ;
500  }
501  else
502  {
503  if ( resItr->dRz2Pos()!=std::numeric_limits<float>::infinity() )
504  {
505  if ( resItr->dRz2Pos()!=seed.dRz2Pos() )
506  {
507  edm::LogWarning("ElectronSeedGenerator|BadValue")
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() ;
511  }
512 // else
513 // {
514 // edm::LogWarning("ElectronSeedGenerator|UnexpectedValue")
515 // <<"this old seed already knows its dRz2Pos, we suspect duplicates in input trajectry seeds"
516 // <<"\nold seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(unsigned int)resItr->hitsMask()<<"/"<<resItr->dRz2()<<"/"<<resItr->dPhi2()<<"/"<<resItr->dRz2Pos()<<"/"<<resItr->dPhi2Pos()
517 // <<"\nnew seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(unsigned int)seed.hitsMask()<<"/"<<seed.dRz2()<<"/"<<seed.dPhi2()<<"/"<<seed.dRz2Pos()<<"/"<<seed.dPhi2Pos() ;
518 // }
519  }
520 // if (resItr->dRz2()==std::numeric_limits<float>::infinity())
521 // {
522 // edm::LogWarning("ElectronSeedGenerator|BadValue")
523 // <<"this old seed has no dRz2, we suspect duplicates in input trajectry seeds"
524 // <<"\nold seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(unsigned int)resItr->hitsMask()<<"/"<<resItr->dRz2()<<"/"<<resItr->dPhi2()<<"/"<<resItr->dRz2Pos()<<"/"<<resItr->dPhi2Pos()
525 // <<"\nnew seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(unsigned int)seed.hitsMask()<<"/"<<seed.dRz2()<<"/"<<seed.dPhi2()<<"/"<<seed.dRz2Pos()<<"/"<<seed.dPhi2Pos() ;
526 // }
527  }
528  }
529  else
530  {
531  if ( resItr->dRz2()==std::numeric_limits<float>::infinity()
532  && resItr->dRz2Pos()!=std::numeric_limits<float>::infinity() )
533  {
534  resItr->setNegAttributes(info->dRz2(),info->dPhi2(),info->dRz1(),info->dPhi1()) ;
535  seed.setPosAttributes(resItr->dRz2Pos(),resItr->dPhi2Pos(),resItr->dRz1Pos(),resItr->dPhi1Pos()) ;
536  break ;
537  }
538  else
539  {
540  if ( resItr->dRz2()!=std::numeric_limits<float>::infinity() )
541  {
542  if (resItr->dRz2()!=seed.dRz2())
543  {
544  edm::LogWarning("ElectronSeedGenerator|BadValue")
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() ;
548  }
549  // else
550  // {
551  // edm::LogWarning("ElectronSeedGenerator|UnexpectedValue")
552  // <<"this old seed already knows its dRz2, we suspect duplicates in input trajectry seeds"
553  // <<"\nold seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(unsigned int)resItr->hitsMask()<<"/"<<resItr->dRz2()<<"/"<<resItr->dPhi2()<<"/"<<resItr->dRz2Pos()<<"/"<<resItr->dPhi2Pos()
554  // <<"\nnew seed mask/dRz2/dPhi2/dRz2Pos/dPhi2Pos: "<<(unsigned int)seed.hitsMask()<<"/"<<seed.dRz2()<<"/"<<seed.dPhi2()<<"/"<<seed.dRz2Pos()<<"/"<<seed.dPhi2Pos() ;
555  // seed.setPosAttributes(resItr->dRz2Pos(),resItr->dPhi2Pos(),resItr->dRz1Pos(),resItr->dPhi1Pos()) ;
556  // }
557  }
558 // if (resItr->dRz2Pos()==std::numeric_limits<float>::infinity())
559 // {
560 // edm::LogWarning("ElectronSeedGenerator|BadValue")
561 // <<"this old seed has no dRz2Pos"
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  }
566  }
567  }
568  }
569 
570  out.push_back(seed) ;
571  }
572 
574  ( ConstRecHitPointer innerhit,
575  ConstRecHitPointer outerhit,
576  const GlobalPoint& vertexPos )
577  {
578 
579  // debug prints
580  LogDebug("") <<"[ElectronSeedGenerator::prepareElTrackSeed] inner PixelHit x,y,z "<<innerhit->globalPosition();
581  LogDebug("") <<"[ElectronSeedGenerator::prepareElTrackSeed] outer PixelHit x,y,z "<<outerhit->globalPosition();
582 
583  recHits_.clear();
584 
585  SiPixelRecHit *pixhit=0;
586  SiStripMatchedRecHit2D *striphit=0;
587  const SiPixelRecHit* constpixhit = dynamic_cast <const SiPixelRecHit*> (innerhit->hit());
588  if (constpixhit) {
589  pixhit=new SiPixelRecHit(*constpixhit);
590  recHits_.push_back(pixhit);
591  } else return false;
592  constpixhit = dynamic_cast <const SiPixelRecHit *> (outerhit->hit());
593  if (constpixhit) {
594  pixhit=new SiPixelRecHit(*constpixhit);
595  recHits_.push_back(pixhit);
596  } else {
597  const SiStripMatchedRecHit2D * conststriphit=dynamic_cast <const SiStripMatchedRecHit2D *> (outerhit->hit());
598  if (conststriphit) {
599  striphit = new SiStripMatchedRecHit2D(*conststriphit);
600  recHits_.push_back(striphit);
601  } else return false;
602  }
603 
605 
606  // FIXME to be optimized outside the loop
608  theSetup->get<IdealMagneticFieldRecord>().get(bfield);
609  float nomField = bfield->nominalValue();
610 
611  // make a spiral
612  FastHelix helix(outerhit->globalPosition(),innerhit->globalPosition(),vertexPos,nomField,&*bfield);
613  if ( !helix.isValid()) {
614  return false;
615  }
616  FreeTrajectoryState fts(helix.stateAtVertex());
617  TSOS propagatedState = thePropagator->propagate(fts,innerhit->det()->surface()) ;
618  if (!propagatedState.isValid())
619  return false;
620  TSOS updatedState = theUpdator->update(propagatedState, *innerhit);
621 
622  TSOS propagatedState_out = thePropagator->propagate(updatedState,outerhit->det()->surface()) ;
623  if (!propagatedState_out.isValid())
624  return false;
625  TSOS updatedState_out = theUpdator->update(propagatedState_out, *outerhit);
626  // debug prints
627  LogDebug("") <<"[ElectronSeedGenerator::prepareElTrackSeed] final TSOS, position: "<<updatedState_out.globalPosition()<<" momentum: "<<updatedState_out.globalMomentum();
628  LogDebug("") <<"[ElectronSeedGenerator::prepareElTrackSeed] final TSOS Pt: "<<updatedState_out.globalMomentum().perp();
629  pts_ = trajectoryStateTransform::persistentState(updatedState_out, outerhit->geographicalId().rawId());
630 
631  return true;
632  }
#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
T perp() const
Definition: PV3DBase.h:72
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
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
CaloClusterRef caloCluster() const
Definition: ElectronSeed.h:70
float dPhi2() const
Definition: ElectronSeed.h:74
float dRz2Pos() const
Definition: ElectronSeed.h:75
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
ElectronSeedGenerator(const edm::ParameterSet &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
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
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
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
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
Pixel Reconstructed Hit.
unsigned char hitsMask() const
Definition: ElectronSeed.h:71
unsigned long long cacheIDCkfComp_