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