Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:31:50

0001 #include "TrackingTools/TrajectoryFiltering/interface/ThresholdPtTrajectoryFilter.h"
0002 
0003 namespace {
0004   struct TLS {
0005     bool answerMemory = false;
0006     FreeTrajectoryState ftsMemory;
0007   };
0008 
0009   thread_local TLS tls;
0010 }  // namespace
0011 
0012 bool ThresholdPtTrajectoryFilter::test(const TrajectoryMeasurement& tm, int foundHits) const {
0013   //first check min number of hits
0014   if (foundHits < theMinHits) {
0015     return true;
0016   }
0017 
0018   // check for momentum below limit
0019   if (!tm.updatedState().isValid())
0020     return false;
0021   const FreeTrajectoryState& fts = *tm.updatedState().freeTrajectoryState();
0022 
0023   //avoid doing twice the check in TBC and QF
0024   // We make it thread local so that we avoid race conditions between
0025   // threads, and we make sure there is no cache contention between them.
0026   if (tls.ftsMemory.parameters().vector() == fts.parameters().vector()) {
0027     return tls.answerMemory;
0028   }
0029   tls.ftsMemory = fts;
0030 
0031   //if p_T is way too small: stop
0032   double pT = fts.momentum().perp();
0033   if (pT < 0.010) {
0034     tls.answerMemory = false;
0035     return false;
0036   }
0037   //if error is way too big: stop
0038   double invError = TrajectoryStateAccessor(fts).inversePtError();
0039   if (invError > 1.e10) {
0040     tls.answerMemory = false;
0041     return false;
0042   }
0043 
0044   //calculate the actual pT cut:
0045   if ((1 / pT + theNSigma * invError) < 1 / thePtThreshold) {
0046     tls.answerMemory = false;
0047     return false;
0048   }
0049   //    first term is the minimal value of pT (pT-N*sigma(pT))
0050   //    secon term is the cut
0051 
0052   tls.answerMemory = true;
0053   return true;
0054 }