CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripElectronSeedGenerator.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EgammaElectronAlgos
4 // Class: SiStripElectronSeedGenerator.
5 //
11 //
12 //
13 
14 #include <vector>
15 #include <utility>
16 
19 
22 
24 
26 
28 
31 
37 
40 
43 
44 // files for retrieving hits using measurement tracker
45 
53 
55 
57 
59  : beamSpotTag_("offlineBeamSpot"),
60  theUpdator(0),thePropagator(0),theMeasurementTracker(0),
61  theSetup(0),pts_(0),theMatcher_(0),
62  cacheIDMagField_(0),cacheIDCkfComp_(0),cacheIDTrkGeom_(0),
63  tibOriginZCut_(pset.getParameter<double>("tibOriginZCut")),
64  tidOriginZCut_(pset.getParameter<double>("tidOriginZCut")),
65  tecOriginZCut_(pset.getParameter<double>("tecOriginZCut")),
66  monoOriginZCut_(pset.getParameter<double>("monoOriginZCut")),
67  tibDeltaPsiCut_(pset.getParameter<double>("tibDeltaPsiCut")),
68  tidDeltaPsiCut_(pset.getParameter<double>("tidDeltaPsiCut")),
69  tecDeltaPsiCut_(pset.getParameter<double>("tecDeltaPsiCut")),
70  monoDeltaPsiCut_(pset.getParameter<double>("monoDeltaPsiCut")),
71  tibPhiMissHit2Cut_(pset.getParameter<double>("tibPhiMissHit2Cut")),
72  tidPhiMissHit2Cut_(pset.getParameter<double>("tidPhiMissHit2Cut")),
73  tecPhiMissHit2Cut_(pset.getParameter<double>("tecPhiMissHit2Cut")),
74  monoPhiMissHit2Cut_(pset.getParameter<double>("monoPhiMissHit2Cut")),
75  tibZMissHit2Cut_(pset.getParameter<double>("tibZMissHit2Cut")),
76  tidRMissHit2Cut_(pset.getParameter<double>("tidRMissHit2Cut")),
77  tecRMissHit2Cut_(pset.getParameter<double>("tecRMissHit2Cut")),
78  tidEtaUsage_(pset.getParameter<double>("tidEtaUsage")),
79  tidMaxHits_(pset.getParameter<int>("tidMaxHits")),
80  tecMaxHits_(pset.getParameter<int>("tecMaxHits")),
81  monoMaxHits_(pset.getParameter<int>("monoMaxHits")),
82  maxSeeds_(pset.getParameter<int>("maxSeeds"))
83 {
84  // use of a theMeasurementTrackerName
85  if (pset.exists("measurementTrackerName"))
86  { theMeasurementTrackerName = pset.getParameter<std::string>("measurementTrackerName") ; }
87 
88  // new beamSpot tag
89  if (pset.exists("beamSpot"))
90  { beamSpotTag_ = pset.getParameter<edm::InputTag>("beamSpot") ; }
91 
92  theUpdator = new KFUpdator();
94 }
95 
96 
98  delete thePropagator;
99  delete theUpdator;
100 }
101 
102 
104 
107  cacheIDMagField_=setup.get<IdealMagneticFieldRecord>().cacheIdentifier();
108  if (thePropagator) delete thePropagator;
110  }
111 
114  cacheIDCkfComp_=setup.get<CkfComponentsRecord>().cacheIdentifier();
116  }
117 
120  cacheIDTrkGeom_=setup.get<TrackerDigiGeometryRecord>().cacheIdentifier();
121  }
122 
123 }
124 
128  theSetup= &setup;
131 
132  for (unsigned int i=0;i<clusters->size();++i) {
133  edm::Ref<reco::SuperClusterCollection> theClusB(clusters,i);
134  // Find the seeds
135  LogDebug ("run") << "new cluster, calling findSeedsFromCluster";
136  findSeedsFromCluster(theClusB,theBeamSpot,out);
137  }
138 
139  LogDebug ("run") << ": For event "<<e.id();
140  LogDebug ("run") <<"Nr of superclusters: "<<clusters->size()
141  <<", no. of ElectronSeeds found = " << out.size();
142 }
143 
144 
145 // Find seeds using a supercluster
150  {
151  // clear the member vectors of good hits
152  layer1Hits_.clear() ;
153  layer2Hits_.clear() ;
154  backupLayer2Hits_.clear() ;
155 
156  using namespace std;
157 
158  double sCenergy = seedCluster->energy();
159  math::XYZPoint sCposition = seedCluster->position();
160  double scEta = seedCluster->eta();
161 
162  double scz = sCposition.z();
163  double scr = sqrt(pow(sCposition.x(),2)+pow(sCposition.y(),2));
164 
165  double pT = sCenergy * seedCluster->position().rho()/sqrt(seedCluster->x()*seedCluster->x()+seedCluster->y()*seedCluster->y()+seedCluster->z()*seedCluster->z());
166 
167  double magneticField = 3.8;
168 
169  // cf Jackson p. 581-2, a little geometry
170  double phiVsRSlope = -3.00e-3 * magneticField / pT / 2.;
171 
172 
173  //Need to create TSOS to feed MeasurementTracker
174  GlobalPoint beamSpot(bs->x0(),bs->y0(),bs->z0());
175  GlobalPoint superCluster(sCposition.x(),sCposition.y(),sCposition.z());
176  double r0 = beamSpot.perp();
177  double z0 = beamSpot.z();
178 
179  //We need to pick a charge for the particle we want to reconstruct before hits can be retrieved
180  //Choosing both charges improves seeding efficiency by less than 0.5% for signal events
181  //If we pick a single charge, this reduces fake rate and CPU time
182  //So we pick a charge that is equally likely to be positive or negative
183 
184  int chargeHypothesis;
185  double chargeSelector = sCenergy - (int)sCenergy;
186  if(chargeSelector >= 0.5) chargeHypothesis = -1;
187  if(chargeSelector < 0.5) chargeHypothesis = 1;
188 
189  //Use BeamSpot and SC position to estimate 3rd point
190  double rFake = 25.;
191  double phiFake = phiDiff(superCluster.phi(),chargeHypothesis * phiVsRSlope * (scr - rFake));
192  double zFake = (rFake*(scz-z0)-r0*scz+scr*z0)/(scr-r0);
193  double xFake = rFake * cos(phiFake);
194  double yFake = rFake * sin(phiFake);
195  GlobalPoint fakePoint(xFake,yFake,zFake);
196 
197  //Use 3 points to make helix
198  FastHelix initialHelix(superCluster,fakePoint,beamSpot,*theSetup);
199 
200  //Use helix to get FTS
201  FreeTrajectoryState initialFTS = initialHelix.stateAtVertex();
202 
203  //Use FTS and BeamSpot to create TSOS
205  TrajectoryStateOnSurface initialTSOS = tipe->extrapolate(initialFTS,beamSpot);
206 
207  //Use GST to retrieve hits from various DetLayers using layerMeasurements class
208  const GeometricSearchTracker* gst = theMeasurementTracker->geometricSearchTracker();
209 
210  std::vector<BarrelDetLayer*> tibLayers = gst->tibLayers();
211  DetLayer* tib1 = tibLayers.at(0);
212  DetLayer* tib2 = tibLayers.at(1);
213 
214  std::vector<ForwardDetLayer*> tecLayers;
215  std::vector<ForwardDetLayer*> tidLayers;
216  if(scEta < 0){
217  tecLayers = gst->negTecLayers();
218  tidLayers = gst->negTidLayers();
219  }
220  if(scEta > 0){
221  tecLayers = gst->posTecLayers();
222  tidLayers = gst->posTidLayers();
223  }
224 
225  DetLayer* tid1 = tidLayers.at(0);
226  DetLayer* tid2 = tidLayers.at(1);
227  DetLayer* tid3 = tidLayers.at(2);
228  DetLayer* tec1 = tecLayers.at(0);
229  DetLayer* tec2 = tecLayers.at(1);
230  DetLayer* tec3 = tecLayers.at(2);
231 
232  //Figure out which DetLayers to use based on SC Eta
233  std::vector<bool> useDL = useDetLayer(scEta);
234  bool useTID = false;
235 
236  //Use counters to restrict the number of hits in TID and TEC layers
237  //This reduces seed multiplicity
238  int tid1MHC = 0;
239  int tid2MHC = 0;
240  int tid3MHC = 0;
241  int tid1BHC = 0;
242  int tid2BHC = 0;
243  int tid3BHC = 0;
244  int tec1MHC = 0;
245  int tec2MHC = 0;
246  int tec3MHC = 0;
247 
248  //Use counter to limit the allowed number of seeds
249  int seedCounter = 0;
250 
251  bool hasLay1Hit = false;
252  bool hasLay2Hit = false;
253  bool hasBackupHit = false;
254 
255  LayerMeasurements layerMeasurements(theMeasurementTracker);
256 
257  std::vector<TrajectoryMeasurement> tib1measurements;
258  if(useDL.at(0)) tib1measurements = layerMeasurements.measurements(*tib1,initialTSOS,*thePropagator,*theEstimator);
259  std::vector<TrajectoryMeasurement> tib2measurements;
260  if(useDL.at(1)) tib2measurements = layerMeasurements.measurements(*tib2,initialTSOS,*thePropagator,*theEstimator);
261 
262  //Basic idea: Retrieve hits from a given DetLayer
263  //Check if it is a Matched Hit and satisfies some cuts
264  //If yes, accept hit for seed making
265 
266  for(std::vector<TrajectoryMeasurement>::const_iterator tmIter = tib1measurements.begin(); tmIter != tib1measurements.end(); ++ tmIter){
267  ConstRecHitPointer hit = tmIter->recHit();
268  const SiStripMatchedRecHit2D* matchedHit = matchedHitConverter(hit);
269  if(matchedHit){
270  GlobalPoint position = trackerGeometryHandle->idToDet(matchedHit->geographicalId())->surface().toGlobal(matchedHit->localPosition());
271  if(preselection(position, superCluster, phiVsRSlope, 1)){
272  hasLay1Hit = true;
273  layer1Hits_.push_back(matchedHit);
274  }
275  }
276  }
277 
278  for(std::vector<TrajectoryMeasurement>::const_iterator tmIter = tib2measurements.begin(); tmIter != tib2measurements.end(); ++ tmIter){
279  ConstRecHitPointer hit = tmIter->recHit();
280  const SiStripMatchedRecHit2D* matchedHit = matchedHitConverter(hit);
281  if(matchedHit){
282  GlobalPoint position = trackerGeometryHandle->idToDet(matchedHit->geographicalId())->surface().toGlobal(matchedHit->localPosition());
283  if(preselection(position, superCluster, phiVsRSlope, 1)){
284  hasLay2Hit = true;
285  layer2Hits_.push_back(matchedHit);
286  }
287  }
288  }
289 
290  if(!(hasLay1Hit && hasLay2Hit)) useTID = true;
291  if(std::abs(scEta) > tidEtaUsage_) useTID = true;
292  std::vector<TrajectoryMeasurement> tid1measurements;
293  if(useDL.at(2) && useTID) tid1measurements = layerMeasurements.measurements(*tid1,initialTSOS,*thePropagator,*theEstimator);
294  std::vector<TrajectoryMeasurement> tid2measurements;
295  if(useDL.at(3) && useTID) tid2measurements = layerMeasurements.measurements(*tid2,initialTSOS,*thePropagator,*theEstimator);
296  std::vector<TrajectoryMeasurement> tid3measurements;
297  if(useDL.at(4) && useTID) tid3measurements = layerMeasurements.measurements(*tid3,initialTSOS,*thePropagator,*theEstimator);
298 
299  for(std::vector<TrajectoryMeasurement>::const_iterator tmIter = tid1measurements.begin(); tmIter != tid1measurements.end(); ++ tmIter){
300  if(tid1MHC < tidMaxHits_){
301  ConstRecHitPointer hit = tmIter->recHit();
302  const SiStripMatchedRecHit2D* matchedHit = matchedHitConverter(hit);
303  if(matchedHit){
304  GlobalPoint position = trackerGeometryHandle->idToDet(matchedHit->geographicalId())->surface().toGlobal(matchedHit->localPosition());
305  if(preselection(position, superCluster, phiVsRSlope, 2)){
306  tid1MHC++;
307  hasLay1Hit = true;
308  layer1Hits_.push_back(matchedHit);
309  hasLay2Hit = true;
310  layer2Hits_.push_back(matchedHit);
311  }
312  }else if(useDL.at(8) && tid1BHC < monoMaxHits_){
313  const SiStripRecHit2D* backupHit = backupHitConverter(hit);
314  if(backupHit){
315  GlobalPoint position = trackerGeometryHandle->idToDet(backupHit->geographicalId())->surface().toGlobal(backupHit->localPosition());
316  if(preselection(position, superCluster, phiVsRSlope, 4) && position.perp() > 37.){
317  tid1BHC++;
318  hasBackupHit = true;
319  backupLayer2Hits_.push_back(backupHit);
320  }
321  }
322  }
323  }
324  }
325 
326  for(std::vector<TrajectoryMeasurement>::const_iterator tmIter = tid2measurements.begin(); tmIter != tid2measurements.end(); ++ tmIter){
327  if(tid2MHC < tidMaxHits_){
328  ConstRecHitPointer hit = tmIter->recHit();
329  const SiStripMatchedRecHit2D* matchedHit = matchedHitConverter(hit);
330  if(matchedHit){
331  GlobalPoint position = trackerGeometryHandle->idToDet(matchedHit->geographicalId())->surface().toGlobal(matchedHit->localPosition());
332  if(preselection(position, superCluster, phiVsRSlope, 2)){
333  tid2MHC++;
334  hasLay1Hit = true;
335  layer1Hits_.push_back(matchedHit);
336  hasLay2Hit = true;
337  layer2Hits_.push_back(matchedHit);
338  }
339  }else if(useDL.at(8) && tid2BHC < monoMaxHits_){
340  const SiStripRecHit2D* backupHit = backupHitConverter(hit);
341  if(backupHit){
342  GlobalPoint position = trackerGeometryHandle->idToDet(backupHit->geographicalId())->surface().toGlobal(backupHit->localPosition());
343  if(preselection(position, superCluster, phiVsRSlope, 4) && position.perp() > 37.){
344  tid2BHC++;
345  hasBackupHit = true;
346  backupLayer2Hits_.push_back(backupHit);
347  }
348  }
349  }
350  }
351  }
352 
353  for(std::vector<TrajectoryMeasurement>::const_iterator tmIter = tid3measurements.begin(); tmIter != tid3measurements.end(); ++ tmIter){
354  if(tid3MHC < tidMaxHits_){
355  ConstRecHitPointer hit = tmIter->recHit();
356  const SiStripMatchedRecHit2D* matchedHit = matchedHitConverter(hit);
357  if(matchedHit){
358  GlobalPoint position = trackerGeometryHandle->idToDet(matchedHit->geographicalId())->surface().toGlobal(matchedHit->localPosition());
359  if(preselection(position, superCluster, phiVsRSlope, 2)){
360  tid3MHC++;
361  hasLay1Hit = true;
362  layer1Hits_.push_back(matchedHit);
363  hasLay2Hit = true;
364  layer2Hits_.push_back(matchedHit);
365  }
366  }else if(useDL.at(8) && tid3BHC < monoMaxHits_){
367  const SiStripRecHit2D* backupHit = backupHitConverter(hit);
368  if(backupHit){
369  GlobalPoint position = trackerGeometryHandle->idToDet(backupHit->geographicalId())->surface().toGlobal(backupHit->localPosition());
370  if(preselection(position, superCluster, phiVsRSlope, 4) && position.perp() > 37.){
371  tid3BHC++;
372  hasBackupHit = true;
373  backupLayer2Hits_.push_back(backupHit);
374  }
375  }
376  }
377  }
378  }
379 
380  std::vector<TrajectoryMeasurement> tec1measurements;
381  if(useDL.at(5)) tec1measurements = layerMeasurements.measurements(*tec1,initialTSOS,*thePropagator,*theEstimator);
382  std::vector<TrajectoryMeasurement> tec2measurements;
383  if(useDL.at(6)) tec2measurements = layerMeasurements.measurements(*tec2,initialTSOS,*thePropagator,*theEstimator);
384  std::vector<TrajectoryMeasurement> tec3measurements;
385  if(useDL.at(7)) tec3measurements = layerMeasurements.measurements(*tec3,initialTSOS,*thePropagator,*theEstimator);
386 
387  for(std::vector<TrajectoryMeasurement>::const_iterator tmIter = tec1measurements.begin(); tmIter != tec1measurements.end(); ++ tmIter){
388  if(tec1MHC < tecMaxHits_){
389  ConstRecHitPointer hit = tmIter->recHit();
390  const SiStripMatchedRecHit2D* matchedHit = matchedHitConverter(hit);
391  if(matchedHit){
392  GlobalPoint position = trackerGeometryHandle->idToDet(matchedHit->geographicalId())->surface().toGlobal(matchedHit->localPosition());
393  if(preselection(position, superCluster, phiVsRSlope, 3)){
394  tec1MHC++;
395  hasLay1Hit = true;
396  layer1Hits_.push_back(matchedHit);
397  hasLay2Hit = true;
398  layer2Hits_.push_back(matchedHit);
399  }
400  }
401  }
402  }
403 
404  for(std::vector<TrajectoryMeasurement>::const_iterator tmIter = tec2measurements.begin(); tmIter != tec2measurements.end(); ++ tmIter){
405  if(tec2MHC < tecMaxHits_){
406  ConstRecHitPointer hit = tmIter->recHit();
407  const SiStripMatchedRecHit2D* matchedHit = matchedHitConverter(hit);
408  if(matchedHit){
409  GlobalPoint position = trackerGeometryHandle->idToDet(matchedHit->geographicalId())->surface().toGlobal(matchedHit->localPosition());
410  if(preselection(position, superCluster, phiVsRSlope, 3)){
411  tec2MHC++;
412  hasLay1Hit = true;
413  layer1Hits_.push_back(matchedHit);
414  hasLay2Hit = true;
415  layer2Hits_.push_back(matchedHit);
416  }
417  }
418  }
419  }
420 
421  for(std::vector<TrajectoryMeasurement>::const_iterator tmIter = tec3measurements.begin(); tmIter != tec3measurements.end(); ++ tmIter){
422  if(tec3MHC < tecMaxHits_){
423  ConstRecHitPointer hit = tmIter->recHit();
424  const SiStripMatchedRecHit2D* matchedHit = matchedHitConverter(hit);
425  if(matchedHit){
426  GlobalPoint position = trackerGeometryHandle->idToDet(matchedHit->geographicalId())->surface().toGlobal(matchedHit->localPosition());
427  if(preselection(position, superCluster, phiVsRSlope, 3)){
428  tec3MHC++;
429  hasLay2Hit = true;
430  layer2Hits_.push_back(matchedHit);
431  }
432  }
433  }
434  }
435 
436  // We have 2 arrays of hits, combine them to form seeds
437  if( hasLay1Hit && hasLay2Hit ){
438 
439  for (std::vector<const SiStripMatchedRecHit2D*>::const_iterator hit1 = layer1Hits_.begin() ; hit1!= layer1Hits_.end(); ++hit1) {
440  for (std::vector<const SiStripMatchedRecHit2D*>::const_iterator hit2 = layer2Hits_.begin() ; hit2!= layer2Hits_.end(); ++hit2) {
441 
442  if(seedCounter < maxSeeds_){
443 
444  if(checkHitsAndTSOS(hit1,hit2,scr,scz,pT,scEta)) {
445 
446  seedCounter++;
447 
448  recHits_.clear();
449 
451  hit=new SiStripMatchedRecHit2D(*(dynamic_cast <const SiStripMatchedRecHit2D *> (*hit1) ) );
452  recHits_.push_back(hit);
453  hit=new SiStripMatchedRecHit2D(*(dynamic_cast <const SiStripMatchedRecHit2D *> (*hit2) ) );
454  recHits_.push_back(hit);
455 
457  reco::ElectronSeed seed(*pts_,recHits_,dir) ;
458  reco::ElectronSeed::CaloClusterRef caloCluster(seedCluster) ;
459  seed.setCaloCluster(caloCluster) ;
460  result.push_back(seed);
461 
462  delete pts_;
463  pts_=0;
464  }
465 
466  }
467 
468  }// end of hit 2 loop
469 
470  }// end of hit 1 loop
471 
472  }//end of seed making
473 
474  //Make seeds using TID Ring 3 if necessary
475 
476  if(hasLay1Hit && hasBackupHit && seedCounter == 0){
477 
478  for (std::vector<const SiStripMatchedRecHit2D*>::const_iterator hit1 = layer1Hits_.begin() ; hit1!= layer1Hits_.end(); ++hit1) {
479  for (std::vector<const SiStripRecHit2D*>::const_iterator hit2 = backupLayer2Hits_.begin() ; hit2!= backupLayer2Hits_.end(); ++hit2) {
480 
481  if(seedCounter < maxSeeds_){
482 
483  if(altCheckHitsAndTSOS(hit1,hit2,scr,scz,pT,scEta)) {
484 
485  seedCounter++;
486 
487  recHits_.clear();
488 
489  SiStripMatchedRecHit2D *innerHit;
490  innerHit=new SiStripMatchedRecHit2D(*(dynamic_cast <const SiStripMatchedRecHit2D *> (*hit1) ) );
491  recHits_.push_back(innerHit);
492  SiStripRecHit2D *outerHit;
493  outerHit=new SiStripRecHit2D(*(dynamic_cast <const SiStripRecHit2D *> (*hit2) ) );
494  recHits_.push_back(outerHit);
495 
497  reco::ElectronSeed seed(*pts_,recHits_,dir) ;
498  reco::ElectronSeed::CaloClusterRef caloCluster(seedCluster) ;
499  seed.setCaloCluster(caloCluster) ;
500  result.push_back(seed);
501 
502  delete pts_;
503  pts_=0;
504  }
505 
506  }
507 
508  }// end of hit 2 loop
509 
510  }// end of hit 1 loop
511 
512  }// end of backup seed making
513 
514 } // end of findSeedsFromCluster
515 
516 
517 
518 bool SiStripElectronSeedGenerator::checkHitsAndTSOS(std::vector<const SiStripMatchedRecHit2D*>::const_iterator hit1,
519  std::vector<const SiStripMatchedRecHit2D*>::const_iterator hit2,
520  double rc,double zc,double pT,double scEta) {
521 
522  bool seedCutsSatisfied = false;
523 
524  using namespace std;
525 
526  GlobalPoint hit1Pos = trackerGeometryHandle->idToDet((*hit1)->geographicalId())->surface().toGlobal((*hit1)->localPosition());
527  double r1 = sqrt(hit1Pos.x()*hit1Pos.x() + hit1Pos.y()*hit1Pos.y());
528  double phi1 = hit1Pos.phi();
529  double z1=hit1Pos.z();
530 
531  GlobalPoint hit2Pos = trackerGeometryHandle->idToDet((*hit2)->geographicalId())->surface().toGlobal((*hit2)->localPosition());
532  double r2 = sqrt(hit2Pos.x()*hit2Pos.x() + hit2Pos.y()*hit2Pos.y());
533  double phi2 = hit2Pos.phi();
534  double z2 = hit2Pos.z();
535 
536  if(r2 > r1 && (std::abs(z2) > std::abs(z1) || std::abs(scEta) < 0.25)) {
537 
538  //Consider the circle made of IP and Hit 1; Calculate it's radius using pT
539 
540  double curv = pT*100*.877;
541 
542  //Predict phi of hit 2
543  double a = (r2-r1)/(2*curv);
544  double b = phiDiff(phi2,phi1);
545  //UB added '=0' to avoid compiler warning
546  double phiMissHit2=0;
547  if(std::abs(b - a)<std::abs(b + a)) phiMissHit2 = b - a;
548  if(std::abs(b - a)>std::abs(b + a)) phiMissHit2 = b + a;
549 
550  double zMissHit2 = z2 - (r2*(zc-z1)-r1*zc+rc*z1)/(rc-r1);
551 
552  double rPredHit2 = r1 + (rc-r1)/(zc-z1)*(z2-z1);
553  double rMissHit2 = r2 - rPredHit2;
554 
555  int subdetector = whichSubdetector(hit2);
556 
557  bool zDiff = true;
558  double zVar1 = std::abs(z1);
559  double zVar2 = std::abs(z2 - z1);
560  if(zVar1 > 75 && zVar1 < 95 && (zVar2 > 18 || zVar2 < 5)) zDiff = false;
561  if(zVar1 > 100 && zVar1 < 110 && (zVar2 > 35 || zVar2 < 5)) zDiff = false;
562  if(zVar1 > 125 && zVar1 < 150 && (zVar2 > 18 || zVar2 < 5)) zDiff = false;
563 
564  if(subdetector == 1){
565  int tibExtraCut = 0;
566  if(r1 > 23 && r1 < 28 && r2 > 31 && r2 < 37) tibExtraCut = 1;
567  if(std::abs(phiMissHit2) < tibPhiMissHit2Cut_ && std::abs(zMissHit2) < tibZMissHit2Cut_ && tibExtraCut == 1) seedCutsSatisfied = true;
568  }else if(subdetector == 2){
569  int tidExtraCut = 0;
570  if(r1 > 23 && r1 < 34 && r2 > 26 && r2 < 42) tidExtraCut = 1;
571  if(std::abs(phiMissHit2) < tidPhiMissHit2Cut_ && std::abs(rMissHit2) < tidRMissHit2Cut_ && tidExtraCut == 1 && zDiff) seedCutsSatisfied = true;
572  }else if(subdetector == 3){
573  int tecExtraCut = 0;
574  if(r1 > 23 && r1 < 32 && r2 > 26 && r2 < 42) tecExtraCut = 1;
575  if(std::abs(phiMissHit2) < tecPhiMissHit2Cut_ && std::abs(rMissHit2) < tecRMissHit2Cut_ && tecExtraCut == 1 && zDiff) seedCutsSatisfied = true;
576  }
577 
578  }
579 
580  if(!seedCutsSatisfied) return false;
581 
582  // seed checks borrowed from pixel-based algoritm
583 
584  pts_=0;
585 
586  /* Some of this code could be better optimized. The Pixel algorithm natively
587  takes Transient rec hits, so to recycle code we have to build them.
588  */
589 
590  RecHitPointer hit1Trans = TSiStripMatchedRecHit::build(trackerGeometryHandle->idToDet((*hit1)->geographicalId()), *hit1, theMatcher_);
591  RecHitPointer hit2Trans = TSiStripMatchedRecHit::build(trackerGeometryHandle->idToDet((*hit2)->geographicalId()), *hit2, theMatcher_);
592 
594 
595  double vertexZ = z1 - (r1 * (zc - z1) ) / (rc - r1);
596  GlobalPoint eleVertex(0.,0.,vertexZ);
597 
598  // make a spiral
599  FastHelix helix(hit2Pos,hit1Pos,eleVertex,*theSetup);
600  if (!helix.isValid()) return false;
601 
602  FreeTrajectoryState fts = helix.stateAtVertex();
603  TSOS propagatedState = thePropagator->propagate(fts,hit1Trans->det()->surface());
604 
605  if (!propagatedState.isValid()) return false;
606 
607  TSOS updatedState = theUpdator->update(propagatedState, *hit1Trans);
608  TSOS propagatedState_out = thePropagator->propagate(fts,hit2Trans->det()->surface()) ;
609 
610  if (!propagatedState_out.isValid()) return false;
611 
612  // the seed has now passed all the cuts
613 
614  TSOS updatedState_out = theUpdator->update(propagatedState_out, *hit2Trans);
615 
616  pts_ = transformer_.persistentState(updatedState_out, hit2Trans->geographicalId().rawId());
617 
618  return true;
619 }
620 
621 bool SiStripElectronSeedGenerator::altCheckHitsAndTSOS(std::vector<const SiStripMatchedRecHit2D*>::const_iterator hit1,
622  std::vector<const SiStripRecHit2D*>::const_iterator hit2,
623  double rc,double zc,double pT,double scEta) {
624 
625  bool seedCutSatisfied = false;
626 
627  using namespace std;
628 
629  GlobalPoint hit1Pos = trackerGeometryHandle->idToDet((*hit1)->geographicalId())->surface().toGlobal((*hit1)->localPosition());
630  double r1 = sqrt(hit1Pos.x()*hit1Pos.x() + hit1Pos.y()*hit1Pos.y());
631  double phi1 = hit1Pos.phi();
632  double z1=hit1Pos.z();
633 
634  GlobalPoint hit2Pos = trackerGeometryHandle->idToDet((*hit2)->geographicalId())->surface().toGlobal((*hit2)->localPosition());
635  double r2 = sqrt(hit2Pos.x()*hit2Pos.x() + hit2Pos.y()*hit2Pos.y());
636  double phi2 = hit2Pos.phi();
637  double z2 = hit2Pos.z();
638 
639  if(r2 > r1 && std::abs(z2) > std::abs(z1)) {
640 
641  //Consider the circle made of IP and Hit 1; Calculate it's radius using pT
642 
643  double curv = pT*100*.877;
644 
645  //Predict phi of hit 2
646  double a = (r2-r1)/(2*curv);
647  double b = phiDiff(phi2,phi1);
648  double phiMissHit2 = 0;
649  if(std::abs(b - a)<std::abs(b + a)) phiMissHit2 = b - a;
650  if(std::abs(b - a)>std::abs(b + a)) phiMissHit2 = b + a;
651 
652  if(std::abs(phiMissHit2) < monoPhiMissHit2Cut_) seedCutSatisfied = true;
653 
654  }
655 
656  if(!seedCutSatisfied) return false;
657 
658  // seed checks borrowed from pixel-based algoritm
659 
660  pts_=0;
661 
662  /* Some of this code could be better optimized. The Pixel algorithm natively
663  takes Transient rec hits, so to recycle code we have to build them.
664  */
665 
666  RecHitPointer hit1Trans = TSiStripMatchedRecHit::build(trackerGeometryHandle->idToDet((*hit1)->geographicalId()), *hit1, theMatcher_);
667  RecHitPointer hit2Trans = TSiStripMatchedRecHit::build(trackerGeometryHandle->idToDet((*hit2)->geographicalId()), *hit2, theMatcher_);
668 
670 
671  double vertexZ = z1 - (r1 * (zc - z1) ) / (rc - r1);
672  GlobalPoint eleVertex(0.,0.,vertexZ);
673 
674  // make a spiral
675  FastHelix helix(hit2Pos,hit1Pos,eleVertex,*theSetup);
676  if (!helix.isValid()) return false;
677 
678  FreeTrajectoryState fts = helix.stateAtVertex();
679  TSOS propagatedState = thePropagator->propagate(fts,hit1Trans->det()->surface());
680 
681  if (!propagatedState.isValid()) return false;
682 
683  TSOS updatedState = theUpdator->update(propagatedState, *hit1Trans);
684  TSOS propagatedState_out = thePropagator->propagate(fts,hit2Trans->det()->surface()) ;
685 
686  if (!propagatedState_out.isValid()) return false;
687 
688  // the seed has now passed all the cuts
689 
690  TSOS updatedState_out = theUpdator->update(propagatedState_out, *hit2Trans);
691 
692  pts_ = transformer_.persistentState(updatedState_out, hit2Trans->geographicalId().rawId());
693 
694  return true;
695 }
696 
697 
698 bool SiStripElectronSeedGenerator::preselection(GlobalPoint position,GlobalPoint superCluster,double phiVsRSlope,int hitLayer){
699  double r = position.perp();
700  double phi = position.phi();
701  double z = position.z();
702  double scr = superCluster.perp();
703  double scphi = superCluster.phi();
704  double scz = superCluster.z();
705  double psi = phiDiff(phi,scphi);
706  double deltaPsi = psi - (scr-r)*phiVsRSlope;
707  double antiDeltaPsi = psi - (r-scr)*phiVsRSlope;
708  double dP;
709  if (std::abs(deltaPsi)<std::abs(antiDeltaPsi)){
710  dP = deltaPsi;
711  }else{
712  dP = antiDeltaPsi;
713  }
714  double originZ = (scr*z - r*scz)/(scr-r);
715 
716  bool result = false;
717 
718  if(hitLayer == 1){
719  if(std::abs(originZ) < tibOriginZCut_ && std::abs(dP) < tibDeltaPsiCut_) result = true;
720  }else if(hitLayer == 2){
721  if(std::abs(originZ) < tidOriginZCut_ && std::abs(dP) < tidDeltaPsiCut_) result = true;
722  }else if(hitLayer == 3){
723  if(std::abs(originZ) < tecOriginZCut_ && std::abs(dP) < tecDeltaPsiCut_) result = true;
724  }else if(hitLayer == 4){
725  if(std::abs(originZ) < monoOriginZCut_ && std::abs(dP) < monoDeltaPsiCut_) result = true;
726  }
727 
728  return result;
729 }
730 
731 // Helper algorithms
732 
733 int SiStripElectronSeedGenerator::whichSubdetector(std::vector<const SiStripMatchedRecHit2D*>::const_iterator hit){
734  int result = 0;
735  if(((*hit)->geographicalId()).subdetId() == StripSubdetector::TIB){
736  result = 1;
737  }else if(((*hit)->geographicalId()).subdetId() == StripSubdetector::TID){
738  result = 2;
739  }else if(((*hit)->geographicalId()).subdetId() == StripSubdetector::TEC){
740  result = 3;
741  }
742  return result;
743 }
744 
746  const TrackingRecHit* trh = crhp->hit();
747  const SiStripMatchedRecHit2D* matchedHit = dynamic_cast<const SiStripMatchedRecHit2D*>(trh);
748  return matchedHit;
749 }
750 
752  const TrackingRecHit* trh = crhp->hit();
753  const SiStripRecHit2D* backupHit = dynamic_cast<const SiStripRecHit2D*>(trh);
754  return backupHit;
755 }
756 
757 std::vector<bool> SiStripElectronSeedGenerator::useDetLayer(double scEta){
758  std::vector<bool> useDetLayer;
759  double variable = std::abs(scEta);
760  if(variable > 0 && variable < 1.8){
761  useDetLayer.push_back(true);
762  }else{
763  useDetLayer.push_back(false);
764  }
765  if(variable > 0 && variable < 1.5){
766  useDetLayer.push_back(true);
767  }else{
768  useDetLayer.push_back(false);
769  }
770  if(variable > 1 && variable < 2.1){
771  useDetLayer.push_back(true);
772  }else{
773  useDetLayer.push_back(false);
774  }
775  if(variable > 1 && variable < 2.2){
776  useDetLayer.push_back(true);
777  }else{
778  useDetLayer.push_back(false);
779  }
780  if(variable > 1 && variable < 2.3){
781  useDetLayer.push_back(true);
782  }else{
783  useDetLayer.push_back(false);
784  }
785  if(variable > 1.8 && variable < 2.5){
786  useDetLayer.push_back(true);
787  }else{
788  useDetLayer.push_back(false);
789  }
790  if(variable > 1.8 && variable < 2.5){
791  useDetLayer.push_back(true);
792  }else{
793  useDetLayer.push_back(false);
794  }
795  if(variable > 1.8 && variable < 2.5){
796  useDetLayer.push_back(true);
797  }else{
798  useDetLayer.push_back(false);
799  }
800  if(variable > 1.2 && variable < 1.6){
801  useDetLayer.push_back(true);
802  }else{
803  useDetLayer.push_back(false);
804  }
805  return useDetLayer;
806 }
807 
808 
809 
#define LogDebug(id)
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
std::vector< TrajectoryMeasurement > measurements(const DetLayer &layer, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
int i
Definition: DBlmapReader.cc:9
FTS stateAtVertex() const
Definition: FastHelix.cc:7
bool isValid() const
Definition: FastHelix.h:70
bool checkHitsAndTSOS(std::vector< const SiStripMatchedRecHit2D * >::const_iterator hit1, std::vector< const SiStripMatchedRecHit2D * >::const_iterator hit2, double scr, double scz, double pT, double scEta)
T perp() const
Definition: PV3DBase.h:66
std::vector< bool > useDetLayer(double scEta)
virtual void update(const edm::Event &) const
SiStripElectronSeedGenerator(const edm::ParameterSet &)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
const MeasurementTracker * theMeasurementTracker
Geom::Phi< T > phi() const
Definition: PV3DBase.h:63
edm::ESHandle< MagneticField > theMagField
bool exists(std::string const &parameterName) const
checks if a parameter exists
Chi2MeasurementEstimator * theEstimator
#define abs(x)
Definition: mlp_lapack.h:159
const SiStripMatchedRecHit2D * matchedHitConverter(ConstRecHitPointer crhp)
PropagationDirection
TrajectoryStateOnSurface TSOS
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
std::map< std::string, int, std::less< std::string > > psi
virtual LocalPoint localPosition() const
Definition: DDAxes.h:10
T sqrt(T t)
Definition: SSEVec.h:28
T z() const
Definition: PV3DBase.h:58
tuple result
Definition: query.py:137
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
tuple pset
Definition: CrabTask.py:85
PTrajectoryStateOnDet * persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid) const
std::vector< ElectronSeed > ElectronSeedCollection
collection of ElectronSeed objects
edm::ESHandle< TrackerGeometry > trackerGeometryHandle
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
edm::Handle< reco::BeamSpot > theBeamSpot
int whichSubdetector(std::vector< const SiStripMatchedRecHit2D * >::const_iterator hit)
bool preselection(GlobalPoint position, GlobalPoint superCluster, double phiVsRSlope, int hitLayer)
tuple out
Definition: dbtoconf.py:99
virtual TrajectoryStateOnSurface propagate(const TrajectoryStateOnSurface &tsos, const Plane &plane) const
const SiStripRecHit2D * backupHitConverter(ConstRecHitPointer crhp)
bool altCheckHitsAndTSOS(std::vector< const SiStripMatchedRecHit2D * >::const_iterator hit1, std::vector< const SiStripRecHit2D * >::const_iterator hit2, double scr, double scz, double pT, double scEta)
void setupES(const edm::EventSetup &setup)
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
const SiStripRecHitMatcher * theMatcher_
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
static RecHitPointer build(const GeomDet *geom, const TrackingRecHit *rh, const SiStripRecHitMatcher *matcher, const StripClusterParameterEstimator *cpe=0, float weight=1., float annealing=1., bool computeCoarseLocalPosition=false)
void findSeedsFromCluster(edm::Ref< reco::SuperClusterCollection >, edm::Handle< reco::BeamSpot >, reco::ElectronSeedCollection &)
double b
Definition: hdecay.h:120
double phiDiff(double phi1, double phi2)
edm::EventID id() const
Definition: EventBase.h:56
std::vector< BarrelDetLayer * > const & tibLayers() const
TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TransientTrackingRecHit &) const
Definition: KFUpdator.cc:10
double a
Definition: hdecay.h:121
edm::ESHandle< MeasurementTracker > measurementTrackerHandle
void run(edm::Event &, const edm::EventSetup &setup, const edm::Handle< reco::SuperClusterCollection > &, reco::ElectronSeedCollection &)
DetId geographicalId() const
dbl *** dir
Definition: mlp_gen.cc:35
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
Definition: DDAxes.h:10