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