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