CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AlignmentTrackSelector.cc
Go to the documentation of this file.
2 
6 
8 
21 
29 
30 // constructor ----------------------------------------------------------------
31 
33  applyBasicCuts_( cfg.getParameter<bool>( "applyBasicCuts" ) ),
34  applyNHighestPt_( cfg.getParameter<bool>( "applyNHighestPt" ) ),
35  applyMultiplicityFilter_( cfg.getParameter<bool>( "applyMultiplicityFilter" ) ),
36  seedOnlyFromAbove_( cfg.getParameter<int>( "seedOnlyFrom" ) ),
37  applyIsolation_( cfg.getParameter<bool>( "applyIsolationCut" ) ),
38  chargeCheck_( cfg.getParameter<bool>( "applyChargeCheck" ) ),
39  nHighestPt_( cfg.getParameter<int>( "nHighestPt" ) ),
40  minMultiplicity_ ( cfg.getParameter<int>( "minMultiplicity" ) ),
41  maxMultiplicity_ ( cfg.getParameter<int>( "maxMultiplicity" ) ),
42  multiplicityOnInput_ ( cfg.getParameter<bool>( "multiplicityOnInput" ) ),
43  ptMin_( cfg.getParameter<double>( "ptMin" ) ),
44  ptMax_( cfg.getParameter<double>( "ptMax" ) ),
45  pMin_( cfg.getParameter<double>( "pMin" ) ),
46  pMax_( cfg.getParameter<double>( "pMax" ) ),
47  etaMin_( cfg.getParameter<double>( "etaMin" ) ),
48  etaMax_( cfg.getParameter<double>( "etaMax" ) ),
49  phiMin_( cfg.getParameter<double>( "phiMin" ) ),
50  phiMax_( cfg.getParameter<double>( "phiMax" ) ),
51  nHitMin_( cfg.getParameter<double>( "nHitMin" ) ),
52  nHitMax_( cfg.getParameter<double>( "nHitMax" ) ),
53  chi2nMax_( cfg.getParameter<double>( "chi2nMax" ) ),
54  d0Min_( cfg.getParameter<double>( "d0Min" ) ),
55  d0Max_( cfg.getParameter<double>( "d0Max" ) ),
56  dzMin_( cfg.getParameter<double>( "dzMin" ) ),
57  dzMax_( cfg.getParameter<double>( "dzMax" ) ),
58  theCharge_( cfg.getParameter<int>( "theCharge" ) ),
59  minHitChargeStrip_( cfg.getParameter<double>( "minHitChargeStrip" ) ),
60  minHitIsolation_( cfg.getParameter<double>( "minHitIsolation" ) ),
61  rphirecHitsTag_( cfg.getParameter<edm::InputTag>("rphirecHits") ),
62  matchedrecHitsTag_( cfg.getParameter<edm::InputTag>("matchedrecHits") ),
63  countStereoHitAs2D_( cfg.getParameter<bool>( "countStereoHitAs2D" ) ),
64  nHitMin2D_( cfg.getParameter<unsigned int>( "nHitMin2D" ) ),
65  // Ugly to use the same getParameter n times, but this allows const cut variables...
66  minHitsinTIB_(cfg.getParameter<edm::ParameterSet>( "minHitsPerSubDet" ).getParameter<int>( "inTIB" ) ),
67  minHitsinTOB_ (cfg.getParameter<edm::ParameterSet>( "minHitsPerSubDet" ).getParameter<int>( "inTOB" ) ),
68  minHitsinTID_ (cfg.getParameter<edm::ParameterSet>( "minHitsPerSubDet" ).getParameter<int>( "inTID" ) ),
69  minHitsinTEC_ (cfg.getParameter<edm::ParameterSet>( "minHitsPerSubDet" ).getParameter<int>( "inTEC" ) ),
70  minHitsinBPIX_ (cfg.getParameter<edm::ParameterSet>( "minHitsPerSubDet" ).getParameter<int>( "inBPIX" ) ),
71  minHitsinFPIX_ (cfg.getParameter<edm::ParameterSet>( "minHitsPerSubDet" ).getParameter<int>( "inFPIX" ) ),
72  minHitsinPIX_ (cfg.getParameter<edm::ParameterSet>( "minHitsPerSubDet" ).getParameter<int>( "inPIXEL" ) ),
73  minHitsinTIDplus_ (cfg.getParameter<edm::ParameterSet>( "minHitsPerSubDet" ).getParameter<int>( "inTIDplus" ) ),
74  minHitsinTIDminus_ (cfg.getParameter<edm::ParameterSet>( "minHitsPerSubDet" ).getParameter<int>( "inTIDminus" ) ),
75  minHitsinTECplus_ (cfg.getParameter<edm::ParameterSet>( "minHitsPerSubDet" ).getParameter<int>( "inTECplus" ) ),
76  minHitsinTECminus_ (cfg.getParameter<edm::ParameterSet>( "minHitsPerSubDet" ).getParameter<int>( "inTECminus" ) ),
77  minHitsinFPIXplus_ (cfg.getParameter<edm::ParameterSet>( "minHitsPerSubDet" ).getParameter<int>( "inFPIXplus" ) ),
78  minHitsinFPIXminus_ (cfg.getParameter<edm::ParameterSet>( "minHitsPerSubDet" ).getParameter<int>( "inFPIXminus" ) ),
79  minHitsinENDCAP_ (cfg.getParameter<edm::ParameterSet>( "minHitsPerSubDet" ).getParameter<int>( "inENDCAP" ) ),
80  minHitsinENDCAPplus_ (cfg.getParameter<edm::ParameterSet>( "minHitsPerSubDet" ).getParameter<int>( "inENDCAPplus" ) ),
81  minHitsinENDCAPminus_ (cfg.getParameter<edm::ParameterSet>( "minHitsPerSubDet" ).getParameter<int>( "inENDCAPminus" ) ),
82  maxHitDiffEndcaps_( cfg.getParameter<double>( "maxHitDiffEndcaps" ) ),
83  nLostHitMax_( cfg.getParameter<double>( "nLostHitMax" ) ),
84  clusterValueMapTag_(cfg.getParameter<edm::InputTag>("hitPrescaleMapTag")),
85  minPrescaledHits_( cfg.getParameter<int>("minPrescaledHits")),
86  applyPrescaledHitsFilter_(clusterValueMapTag_.encode().size() && minPrescaledHits_ > 0)
87 {
88 
89  //convert track quality from string to enum
90  std::vector<std::string> trkQualityStrings(cfg.getParameter<std::vector<std::string> >("trackQualities"));
91  std::string qualities;
92  if(trkQualityStrings.size()>0){
94  for (unsigned int i = 0; i < trkQualityStrings.size(); ++i) {
95  (qualities += trkQualityStrings[i]) += ", ";
96  trkQualities_.push_back(reco::TrackBase::qualityByName(trkQualityStrings[i]));
97  }
98  }
99  else applyTrkQualityCheck_=false;
100 
101  std::vector<std::string> trkIterStrings(cfg.getParameter<std::vector<std::string> >("iterativeTrackingSteps"));
102  if(trkIterStrings.size()>0){
103  applyIterStepCheck_=true;
104  std::string tracksteps;
105  for (unsigned int i = 0; i < trkIterStrings.size(); ++i) {
106  (tracksteps += trkIterStrings[i]) += ", ";
107  trkSteps_.push_back(reco::TrackBase::algoByName(trkIterStrings[i]));
108  }
109  }
110  else applyIterStepCheck_=false;
111 
112  if (applyBasicCuts_){
113  edm::LogInfo("AlignmentTrackSelector")
114  << "applying basic track cuts ..."
115  << "\nptmin,ptmax: " << ptMin_ << "," << ptMax_
116  << "\npmin,pmax: " << pMin_ << "," << pMax_
117  << "\netamin,etamax: " << etaMin_ << "," << etaMax_
118  << "\nphimin,phimax: " << phiMin_ << "," << phiMax_
119  << "\nnhitmin,nhitmax: " << nHitMin_ << "," << nHitMax_
120  << "\nnlosthitmax: " << nLostHitMax_
121  << "\nnhitmin2D: " << nHitMin2D_
122  << (countStereoHitAs2D_ ? "," : ", not") << " counting hits on SiStrip stereo modules as 2D"
123  << "\nchi2nmax: " << chi2nMax_;
124 
125  if (applyIsolation_)
126  edm::LogInfo("AlignmentTrackSelector")
127  << "only retain tracks isolated at least by " << minHitIsolation_ <<
128  " cm from other rechits";
129 
130  if (chargeCheck_)
131  edm::LogInfo("AlignmentTrackSelector")
132  << "only retain hits with at least " << minHitChargeStrip_ <<
133  " ADC counts of total cluster charge";
134 
135  edm::LogInfo("AlignmentTrackSelector")
136  << "Minimum number of hits in TIB/TID/TOB/TEC/BPIX/FPIX/PIXEL = "
137  << minHitsinTIB_ << "/" << minHitsinTID_ << "/" << minHitsinTOB_
138  << "/" << minHitsinTEC_ << "/" << minHitsinBPIX_ << "/" << minHitsinFPIX_ << "/" << minHitsinPIX_;
139 
140  edm::LogInfo("AlignmentTrackSelector")
141  << "Minimum number of hits in TID+/TID-/TEC+/TEC-/FPIX+/FPIX- = "
143  << "/" << minHitsinTECplus_ << "/" << minHitsinTECminus_
144  << "/" << minHitsinFPIXplus_ << "/" << minHitsinFPIXminus_;
145 
146  edm::LogInfo("AlignmentTrackSelector")
147  << "Minimum number of hits in EndCap (TID+TEC)/EndCap+/EndCap- = "
149 
150  edm::LogInfo("AlignmentTrackSelector")
151  << "Max value of |nHitsinENDCAPplus - nHitsinENDCAPminus| = "
153 
154  if (trkQualityStrings.size()) {
155  edm::LogInfo("AlignmentTrackSelector")
156  << "Select tracks with these qualities: " << qualities;
157  }
158  }
159 
160  if (applyNHighestPt_)
161  edm::LogInfo("AlignmentTrackSelector")
162  << "filter N tracks with highest Pt N=" << nHighestPt_;
163 
165  edm::LogInfo("AlignmentTrackSelector")
166  << "apply multiplicity filter N>= " << minMultiplicity_ << "and N<= " << maxMultiplicity_
167  << " on " << (multiplicityOnInput_ ? "input" : "output");
168 
170  edm::LogInfo("AlignmentTrackSelector")
171  << "apply cut on number of prescaled hits N>= " << minPrescaledHits_
172  << " (prescale info from " << clusterValueMapTag_ << ")";
173 
174  }
175 
176 }
177 
178 // destructor -----------------------------------------------------------------
179 
181 {}
182 
183 
184 // do selection ---------------------------------------------------------------
185 
187 AlignmentTrackSelector::select(const Tracks& tracks, const edm::Event& evt, const edm::EventSetup& eSetup) const
188 {
189 
191  (tracks.size() < static_cast<unsigned int>(minMultiplicity_)
192  || tracks.size() > static_cast<unsigned int>(maxMultiplicity_))) {
193  return Tracks(); // empty collection
194  }
195 
196  Tracks result = tracks;
197  // apply basic track cuts (if selected)
198  if (applyBasicCuts_) result= this->basicCuts(result, evt, eSetup);
199 
200  // filter N tracks with highest Pt (if selected)
201  if (applyNHighestPt_) result = this->theNHighestPtTracks(result);
202 
203  // apply minimum multiplicity requirement (if selected)
205  if (result.size() < static_cast<unsigned int>(minMultiplicity_)
206  || result.size() > static_cast<unsigned int>(maxMultiplicity_) ) {
207 
208  result.clear();
209  }
210  }
211 
213  result = this->checkPrescaledHits(result, evt);
214  }
215 
216  return result;
217 }
218 
221 {
223 
224 }
225 
226 
227 // make basic cuts ------------------------------------------------------------
228 
231 {
232  Tracks result;
233 
234  for (Tracks::const_iterator it=tracks.begin(); it != tracks.end(); ++it) {
235  const reco::Track* trackp=*it;
236  float pt=trackp->pt();
237  float p=trackp->p();
238  float eta=trackp->eta();
239  float phi=trackp->phi();
240  int nhit = trackp->numberOfValidHits();
241  int nlosthit = trackp->numberOfLostHits();
242  float chi2n = trackp->normalizedChi2();
243 
244  int q = trackp->charge();
245  bool isChargeOk = false;
246  if(theCharge_==-1 && q<0) isChargeOk = true;
247  else if (theCharge_==1 && q>0) isChargeOk = true;
248  else if (theCharge_==0) isChargeOk = true;
249 
250  float d0 = trackp->d0();
251  float dz = trackp->dz();
252 
253  // edm::LogDebug("AlignmentTrackSelector") << " pt,eta,phi,nhit: "
254  // <<pt<<","<<eta<<","<<phi<<","<<nhit;
255 
256  if (pt>ptMin_ && pt<ptMax_
257  && p>pMin_ && p<pMax_
258  && eta>etaMin_ && eta<etaMax_
259  && phi>phiMin_ && phi<phiMax_
260  && nhit>=nHitMin_ && nhit<=nHitMax_
261  && nlosthit<=nLostHitMax_
262  && chi2n<chi2nMax_
263  && isChargeOk
264  && d0>=d0Min_ && d0<=d0Max_
265  && dz>=dzMin_ && dz<=dzMax_) {
266  bool trkQualityOk=false ;
267  if (!applyTrkQualityCheck_ &&!applyIterStepCheck_)trkQualityOk=true ; // nothing required
268  else trkQualityOk = this->isOkTrkQuality(trackp);
269 
270  bool hitsCheckOk=this->detailedHitsCheck(trackp, evt, eSetup);
271 
272  if (trkQualityOk && hitsCheckOk ) result.push_back(trackp);
273  }
274  }
275 
276  return result;
277 }
278 
279 //-----------------------------------------------------------------------------
280 
281 bool AlignmentTrackSelector::detailedHitsCheck(const reco::Track *trackp, const edm::Event& evt, const edm::EventSetup& eSetup) const
282 {
283 
284  //Retrieve tracker topology from geometry
285  edm::ESHandle<TrackerTopology> tTopoHandle;
286  eSetup.get<IdealGeometryRecord>().get(tTopoHandle);
287  const TrackerTopology* const tTopo = tTopoHandle.product();
288 
289  // checking hit requirements beyond simple number of valid hits
290 
298  // any detailed hit cut is active, so have to check
299 
300  int nhitinTIB = 0, nhitinTOB = 0, nhitinTID = 0;
301  int nhitinTEC = 0, nhitinBPIX = 0, nhitinFPIX = 0, nhitinPIXEL=0;
302  int nhitinENDCAP = 0, nhitinENDCAPplus = 0, nhitinENDCAPminus = 0;
303  int nhitinTIDplus = 0, nhitinTIDminus = 0;
304  int nhitinFPIXplus = 0, nhitinFPIXminus = 0;
305  int nhitinTECplus = 0, nhitinTECminus = 0;
306  unsigned int nHit2D = 0;
307  unsigned int thishit = 0;
308 
309  for (trackingRecHit_iterator iHit = trackp->recHitsBegin(); iHit != trackp->recHitsEnd(); ++iHit) {
310  thishit++;
311  const DetId detId((*iHit)->geographicalId());
312  const int subdetId = detId.subdetId();
313 
314  // *** thishit == 1 means last hit in CTF ***
315  // (FIXME: assumption might change or not be valid for all tracking algorthms)
316  // ==> for cosmics
317  // seedOnlyFrom = 1 is TIB-TOB-TEC tracks only
318  // seedOnlyFrom = 2 is TOB-TEC tracks only
319  if (seedOnlyFromAbove_ == 1 && thishit == 1
320  && (subdetId == int(SiStripDetId::TOB) || subdetId == int(SiStripDetId::TEC))){
321  return false;
322  }
323  if (seedOnlyFromAbove_ == 2 && thishit == 1 && subdetId == int(SiStripDetId::TIB)) {
324  return false;
325  }
326 
327  if (!(*iHit)->isValid()) continue; // only real hits count as in trackp->numberOfValidHits()
328  if (detId.det() != DetId::Tracker) {
329  edm::LogError("DetectorMismatch") << "@SUB=AlignmentTrackSelector::detailedHitsCheck"
330  << "DetId.det() != DetId::Tracker (=" << DetId::Tracker
331  << "), but " << detId.det() << ".";
332  }
333  const TrackingRecHit* therechit = (*iHit).get();
334  if (chargeCheck_ && !(this->isOkCharge(therechit))) return false;
335  if (applyIsolation_ && (!this->isIsolated(therechit, evt))) return false;
336  if (SiStripDetId::TIB == subdetId) ++nhitinTIB;
337  else if (SiStripDetId::TOB == subdetId) ++nhitinTOB;
338  else if (SiStripDetId::TID == subdetId) {
339  ++nhitinTID;
340  ++nhitinENDCAP;
341 
342  if (tTopo->tidIsZMinusSide(detId)) {
343  ++nhitinTIDminus;
344  ++nhitinENDCAPminus;
345  }
346  else if (tTopo->tidIsZPlusSide(detId)) {
347  ++nhitinTIDplus;
348  ++nhitinENDCAPplus;
349  }
350  }
351  else if (SiStripDetId::TEC == subdetId) {
352  ++nhitinTEC;
353  ++nhitinENDCAP;
354 
355  if (tTopo->tecIsZMinusSide(detId)) {
356  ++nhitinTECminus;
357  ++nhitinENDCAPminus;
358  }
359  else if (tTopo->tecIsZPlusSide(detId)) {
360  ++nhitinTECplus;
361  ++nhitinENDCAPplus;
362  }
363  }
364  else if ( kBPIX == subdetId) {++nhitinBPIX;++nhitinPIXEL;}
365  else if ( kFPIX == subdetId) {
366  ++nhitinFPIX;
367  ++nhitinPIXEL;
368 
369  if (tTopo->pxfSide(detId)==1) ++nhitinFPIXminus;
370  else if (tTopo->pxfSide(detId)==2) ++nhitinFPIXplus;
371  }
372  // Do not call isHit2D(..) if already enough 2D hits for performance reason:
373  if (nHit2D < nHitMin2D_ && this->isHit2D(**iHit)) ++nHit2D;
374  } // end loop on hits
375 
376  return (nhitinTIB >= minHitsinTIB_ && nhitinTOB >= minHitsinTOB_
377  && nhitinTID >= minHitsinTID_ && nhitinTEC >= minHitsinTEC_
378  && nhitinENDCAP >= minHitsinENDCAP_ && nhitinENDCAPplus >= minHitsinENDCAPplus_ && nhitinENDCAPminus >= minHitsinENDCAPminus_
379  && std::abs(nhitinENDCAPplus-nhitinENDCAPminus) <= maxHitDiffEndcaps_
380  && nhitinTIDplus >= minHitsinTIDplus_ && nhitinTIDminus >= minHitsinTIDminus_
381  && nhitinFPIXplus >= minHitsinFPIXplus_ && nhitinFPIXminus >= minHitsinFPIXminus_
382  && nhitinTECplus >= minHitsinTECplus_ && nhitinTECminus >= minHitsinTECminus_
383  && nhitinBPIX >= minHitsinBPIX_
384  && nhitinFPIX >= minHitsinFPIX_ && nhitinPIXEL>=minHitsinPIX_
385  && nHit2D >= nHitMin2D_);
386  } else { // no cuts set, so we are just fine and can avoid loop on hits
387  return true;
388  }
389 
390 }
391 
392 //-----------------------------------------------------------------------------
393 
395 {
396  // we count SiStrip stereo modules as 2D if selected via countStereoHitAs2D_
397  // (since they provide theta information)
398  if (!hit.isValid() ||
399  (hit.dimension() < 2 && !countStereoHitAs2D_ && !dynamic_cast<const SiStripRecHit1D*>(&hit))){
400  return false; // real RecHit1D - but SiStripRecHit1D depends on countStereoHitAs2D_
401  } else {
402  const DetId detId(hit.geographicalId());
403  if (detId.det() == DetId::Tracker) {
404  if (detId.subdetId() == kBPIX || detId.subdetId() == kFPIX) {
405  return true; // pixel is always 2D
406  } else { // should be SiStrip now
407  const SiStripDetId stripId(detId);
408  if (stripId.stereo()) return countStereoHitAs2D_; // stereo modules
409  else if (dynamic_cast<const SiStripRecHit1D*>(&hit)
410  || dynamic_cast<const SiStripRecHit2D*>(&hit)) return false; // rphi modules hit
411  //the following two are not used any more since ages...
412  else if (dynamic_cast<const SiStripMatchedRecHit2D*>(&hit)) return true; // matched is 2D
413  else if (dynamic_cast<const ProjectedSiStripRecHit2D*>(&hit)) {
414  const ProjectedSiStripRecHit2D* pH = static_cast<const ProjectedSiStripRecHit2D*>(&hit);
415  return (countStereoHitAs2D_ && this->isHit2D(pH->originalHit())); // depends on original...
416  } else {
417  edm::LogError("UnkownType") << "@SUB=AlignmentTrackSelector::isHit2D"
418  << "Tracker hit not in pixel, neither SiStripRecHit[12]D nor "
419  << "SiStripMatchedRecHit2D nor ProjectedSiStripRecHit2D.";
420  return false;
421  }
422  }
423  } else { // not tracker??
424  edm::LogWarning("DetectorMismatch") << "@SUB=AlignmentTrackSelector::isHit2D"
425  << "Hit not in tracker with 'official' dimension >=2.";
426  return true; // dimension() >= 2 so accept that...
427  }
428  }
429  // never reached...
430 }
431 
432 //-----------------------------------------------------------------------------
433 
435 {
436  if (!hit || !hit->isValid()) return true;
437 
438  // check det and subdet
439  const DetId id(hit->geographicalId());
440  if (id.det() != DetId::Tracker) {
441  edm::LogWarning("DetectorMismatch") << "@SUB=isOkCharge" << "Hit not in tracker!";
442  return true;
443  }
444  if (id.subdetId() == kFPIX || id.subdetId() == kBPIX) {
445  return true; // might add some requirement...
446  }
447 
448  // We are in SiStrip now, so test normal hit:
449  const std::type_info &type = typeid(*hit);
450 
451 
452  if (type == typeid(SiStripRecHit2D)) {
453  const SiStripRecHit2D *stripHit2D = dynamic_cast<const SiStripRecHit2D*>(hit);
454  if (stripHit2D) {
455  return this->isOkChargeStripHit(*stripHit2D);
456  }
457  }
458  else if(type == typeid(SiStripRecHit1D)){
459  const SiStripRecHit1D *stripHit1D = dynamic_cast<const SiStripRecHit1D*>(hit);
460  if (stripHit1D) {
461  return this->isOkChargeStripHit(*stripHit1D);
462  }
463  }
464 
465  else if(type == typeid(SiStripMatchedRecHit2D)){ // or matched (should not occur anymore due to hit splitting since 20X)
466  const SiStripMatchedRecHit2D *matchedHit = dynamic_cast<const SiStripMatchedRecHit2D*>(hit);
467  if (matchedHit) {
468  return (this->isOkChargeStripHit(matchedHit->monoHit())
469  && this->isOkChargeStripHit(matchedHit->stereoHit()));
470  }
471  }
472  else if(type == typeid(ProjectedSiStripRecHit2D)){
473  // or projected (should not occur anymore due to hit splitting since 20X):
474  const ProjectedSiStripRecHit2D *projHit = dynamic_cast<const ProjectedSiStripRecHit2D*>(hit);
475  if (projHit) {
476  return this->isOkChargeStripHit(projHit->originalHit());
477  }
478  }
479  else{
480  edm::LogError("AlignmentTrackSelector")<< "@SUB=isOkCharge" <<"Unknown type of a valid tracker hit in Strips "
481  << " SubDet = "<<id.subdetId();
482  return false;
483  }
484 
485 
486 
487  // and now? SiTrackerMultiRecHit? Not here I guess!
488  // Should we throw instead?
489  edm::LogError("AlignmentTrackSelector")
490  << "@SUB=isOkCharge" << "Unknown valid tracker hit not in pixel, subdet " << id.subdetId()
491  << ", SiTrackerMultiRecHit " << dynamic_cast<const SiTrackerMultiRecHit*>(hit)
492  << ", BaseTrackerRecHit " << dynamic_cast<const BaseTrackerRecHit*>(hit);
493 
494  return true;
495 }
496 
497 
498 //-----------------------------------------------------------------------------
499 
500 bool AlignmentTrackSelector::isOkChargeStripHit(const SiStripRecHit2D & siStripRecHit2D) const
501 {
502  double charge = 0.;
503 
504  SiStripRecHit2D::ClusterRef cluster(siStripRecHit2D.cluster());
505  const std::vector<uint8_t> &amplitudes = cluster->amplitudes();
506 
507  for (size_t ia = 0; ia < amplitudes.size(); ++ia) {
508  charge += amplitudes[ia];
509  }
510 
511  return (charge >= minHitChargeStrip_);
512 }
513 
514 //-----------------------------------------------------------------------------
515 
516 bool AlignmentTrackSelector::isOkChargeStripHit(const SiStripRecHit1D & siStripRecHit1D) const
517 {
518  double charge = 0.;
519 
520  SiStripRecHit1D::ClusterRef cluster(siStripRecHit1D.cluster());
521  const std::vector<uint8_t> &amplitudes = cluster->amplitudes();
522 
523  for (size_t ia = 0; ia < amplitudes.size(); ++ia) {
524  charge += amplitudes[ia];
525  }
526 
527  return (charge >= minHitChargeStrip_);
528 }
529 
530 //-----------------------------------------------------------------------------
531 
532 bool AlignmentTrackSelector::isIsolated(const TrackingRecHit* therechit, const edm::Event& evt) const
533 {
534  // FIXME:
535  // adapt to changes after introduction of SiStripRecHit1D...
536  //
537  // edm::ESHandle<TrackerGeometry> tracker;
540  // es.get<TrackerDigiGeometryRecord>().get(tracker);
541  evt.getByLabel( rphirecHitsTag_, rphirecHits );
542  evt.getByLabel( matchedrecHitsTag_, matchedrecHits );
543 
546  const SiStripRecHit2DCollection::DataContainer& stripcollSt = rphirecHits->data();
547  const SiStripMatchedRecHit2DCollection::DataContainer& stripcollStm = matchedrecHits->data();
548 
549  DetId idet = therechit->geographicalId();
550 
551  // FIXME: instead of looping the full hit collection, we should explore the features of
552  // SiStripRecHit2DCollection::rangeRphi = rphirecHits.get(idet) and loop
553  // only from rangeRphi.first until rangeRphi.second
554  for( istripSt=stripcollSt.begin(); istripSt!=stripcollSt.end(); ++istripSt ) {
555  const SiStripRecHit2D *aHit = &*(istripSt);
556  DetId mydet1 = aHit->geographicalId();
557  if (idet.rawId() != mydet1.rawId()) continue;
558  float theDistance = ( therechit->localPosition() - aHit->localPosition() ).mag();
559  // std::cout << "theDistance1 = " << theDistance << "\n";
560  if (theDistance > 0.001 && theDistance < minHitIsolation_) return false;
561  }
562 
563  // FIXME: see above
564  for( istripStm=stripcollStm.begin(); istripStm!=stripcollStm.end(); ++istripStm ) {
565  const SiStripMatchedRecHit2D *aHit = &*(istripStm);
566  DetId mydet2 = aHit->geographicalId();
567  if (idet.rawId() != mydet2.rawId()) continue;
568  float theDistance = (therechit->localPosition() - aHit->localPosition()).mag();
569  // std::cout << "theDistance1 = " << theDistance << "\n";
570  if (theDistance > 0.001 && theDistance < minHitIsolation_) return false;
571  }
572  return true;
573 }
574 
575 //-----------------------------------------------------------------------------
576 
579 {
580  Tracks sortedTracks=tracks;
581  Tracks result;
582 
583  // sort in pt
584  std::sort(sortedTracks.begin(),sortedTracks.end(),ptComparator);
585 
586  // copy theTrackMult highest pt tracks to result vector
587  int n=0;
588  for (Tracks::const_iterator it=sortedTracks.begin();
589  it!=sortedTracks.end(); ++it) {
590  if (n<nHighestPt_) { result.push_back(*it); n++; }
591  }
592 
593  return result;
594 }
595 
596 //---------
597 
600 {
601  Tracks result;
602 
603  //take Cluster-Flag Assomap
605  evt.getByLabel( clusterValueMapTag_, fMap);
606  const AliClusterValueMap &flagMap=*fMap;
607 
608  //for each track loop on hits and count the number of taken hits
609  for (Tracks::const_iterator ittrk=tracks.begin(); ittrk != tracks.end(); ++ittrk) {
610  const reco::Track* trackp=*ittrk;
611  int ntakenhits=0;
612  // float pt=trackp->pt();
613 
614  for (trackingRecHit_iterator ith = trackp->recHitsBegin(), edh = trackp->recHitsEnd(); ith != edh; ++ith) {
615  const TrackingRecHit *hit = ith->get(); // ith is an iterator on edm::Ref to rechit
616  if(! hit->isValid())continue;
617  DetId detid = hit->geographicalId();
618  int subDet = detid.subdetId();
620 
621  bool isPixelHit=(subDet == kFPIX || subDet == kBPIX);
622 
623  if (!isPixelHit){
624  const std::type_info &type = typeid(*hit);
625 
626  if (type == typeid(SiStripRecHit2D)) {
627  const SiStripRecHit2D* striphit=dynamic_cast<const SiStripRecHit2D*>(hit);
628  if(striphit!=0){
629  SiStripRecHit2D::ClusterRef stripclust(striphit->cluster());
630  flag = flagMap[stripclust];
631  }
632  }
633  else if(type == typeid(SiStripRecHit1D)){
634  const SiStripRecHit1D* striphit = dynamic_cast<const SiStripRecHit1D*>(hit);
635  if(striphit!=0){
636  SiStripRecHit1D::ClusterRef stripclust(striphit->cluster());
637  flag = flagMap[stripclust];
638  }
639  }
640  else{
641  edm::LogError("AlignmentTrackSelector")<<"ERROR in <AlignmentTrackSelector::checkPrescaledHits>: Dynamic cast of Strip RecHit failed!"
642  <<" Skipping this hit.";
643  continue;
644  }
645 
646 
647 
648  }//end if hit in Strips
649  else{ // test explicitely BPIX/FPIX
650  const SiPixelRecHit* pixelhit= dynamic_cast<const SiPixelRecHit*>(hit);
651  if(pixelhit!=0){
652  SiPixelRecHit::ClusterRef pixclust(pixelhit->cluster());
653  flag = flagMap[pixclust];
654  }
655  else{
656  edm::LogError("AlignmentTrackSelector")<<"ERROR in <AlignmentTrackSelector::checkPrescaledHits>: Dynamic cast of Pixel RecHit failed! ";
657  }
658  }//end else hit is in Pixel
659 
660  if(flag.isTaken())ntakenhits++;
661 
662  }//end loop on hits
663  if(ntakenhits >= minPrescaledHits_)result.push_back(trackp);
664  }//end loop on tracks
665 
666  return result;
667 }//end checkPrescaledHits
668 
669 //-----------------------------------------------------------------
670 
672 {
673  bool qualityOk=false;
674  bool iterStepOk=false;
675 
676  //check iterative step
678  for (unsigned int i = 0; i < trkSteps_.size(); ++i) {
679  if (track->algo()==(trkSteps_[i])) {
680  iterStepOk=true;
681  }
682  }
683  }
684  else iterStepOk=true;
685 
686  //check track quality
688  for (unsigned int i = 0; i < trkQualities_.size(); ++i) {
689  if (track->quality(trkQualities_[i])) {
690  qualityOk=true;
691  }
692  }
693  }
694  else qualityOk=true;
695 
696  return qualityOk&&iterStepOk;
697 }//end check on track quality
double p() const
momentum vector magnitude
Definition: TrackBase.h:127
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
virtual int dimension() const =0
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
Tracks basicCuts(const Tracks &tracks, const edm::Event &evt, const edm::EventSetup &eSetup) const
apply basic cuts on pt,eta,phi,nhit
bool isIsolated(const TrackingRecHit *therechit, const edm::Event &evt) const
double d0() const
dxy parameter in perigee convention (d0 = - dxy)
Definition: TrackBase.h:121
uint32_t stereo() const
Definition: SiStripDetId.h:162
std::vector< data_type > DataContainer
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
Definition: TrackBase.h:109
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
std::vector< const reco::Track * > Tracks
Tracks checkPrescaledHits(const Tracks &tracks, const edm::Event &evt) const
std::vector< reco::TrackBase::TrackAlgorithm > trkSteps_
Tracks theNHighestPtTracks(const Tracks &tracks) const
filter the n highest pt tracks
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:137
unsigned short numberOfLostHits() const
number of cases where track crossed a layer without getting a hit.
Definition: TrackBase.h:232
std::vector< reco::TrackBase::TrackQuality > trkQualities_
const unsigned int nHitMin2D_
T eta() const
bool isOkChargeStripHit(const SiStripRecHit1D &siStripRecHit1D) const
double charge(const std::vector< uint8_t > &Ampls)
bool tecIsZMinusSide(const DetId &id) const
AlignmentTrackSelector(const edm::ParameterSet &cfg)
constructor
bool tidIsZMinusSide(const DetId &id) const
TrackAlgorithm algo() const
Definition: TrackBase.h:330
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
const int kFPIX
bool isHit2D(const TrackingRecHit &hit) const
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:139
double pt() const
track transverse momentum
Definition: TrackBase.h:129
tuple result
Definition: query.py:137
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
unsigned short numberOfValidHits() const
number of valid hits found
Definition: TrackBase.h:230
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:62
const edm::InputTag matchedrecHitsTag_
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
bool isOkTrkQuality(const reco::Track *track) const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
Definition: TrackBase.h:125
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:17
Definition: DetId.h:18
const double ptMin_
if true, cut min/maxMultiplicity on input instead of on final result
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:46
bool tidIsZPlusSide(const DetId &id) const
tuple tracks
Definition: testEve_cfg.py:39
const edm::InputTag clusterValueMapTag_
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
bool isValid() const
bool quality(const TrackQuality) const
Track quality.
Definition: TrackBase.h:375
bool detailedHitsCheck(const reco::Track *track, const edm::Event &evt, const edm::EventSetup &eSetup) const
checking hit requirements beyond simple number of valid hits
bool tecIsZPlusSide(const DetId &id) const
Tracks select(const Tracks &tracks, const edm::Event &evt, const edm::EventSetup &eSetup) const
select tracks
const edm::InputTag rphirecHitsTag_
bool isOkCharge(const TrackingRecHit *therechit) const
if valid, check for minimum charge (currently only in strip), if invalid give true ...
static TrackAlgorithm algoByName(const std::string &name)
Definition: TrackBase.cc:55
unsigned int pxfSide(const DetId &id) const
int charge() const
track electric charge
Definition: TrackBase.h:111
DetId geographicalId() const
volatile std::atomic< bool > shutdown_flag false
virtual LocalPoint localPosition() const =0
const SiStripRecHit2D & originalHit() const
tuple size
Write out results.
bool useThisFilter()
returns if any of the Filters is used.
Pixel Reconstructed Hit.
const int kBPIX
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:64
Definition: DDAxes.h:10