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