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