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