Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4327 from ktf/backport-tls-fixes
Backport TLS fixes from #4293 to CMSSW_7_1_X
- Loading branch information
Showing
7 changed files
with
114 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
TrackingTools/TrajectoryFiltering/src/MinPtTrajectoryFilter.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,50 @@ | ||
#include "TrackingTools/TrajectoryFiltering/interface/MinPtTrajectoryFilter.h" | ||
|
||
namespace { | ||
struct TLS { | ||
bool answerMemory=false; | ||
GlobalVector ftsMemory; | ||
|
||
}; | ||
|
||
thread_local TLS tls; | ||
} | ||
|
||
|
||
bool MinPtTrajectoryFilter::test( const TrajectoryMeasurement & tm, int foundHits) const | ||
{ | ||
//first check min number of hits | ||
if (foundHits < theMinHits ){ return true;} | ||
|
||
// check for momentum below limit | ||
// const FreeTrajectoryState& fts = *tm.updatedState().freeTrajectoryState(); | ||
|
||
auto const & tsos = tm.updatedState(); | ||
GlobalVector gtp = tsos.globalMomentum(); | ||
|
||
//avoid doing twice the check in TBC and QF | ||
|
||
|
||
if ( gtp == tls.ftsMemory) { return tls.answerMemory;} | ||
tls.ftsMemory= gtp; | ||
|
||
auto pT2 = gtp.perp2(); | ||
|
||
//if p_T is way too small: stop | ||
if (pT2<0.0010f) {tls.answerMemory=false; return false;} | ||
|
||
// if large enouth go | ||
if (pT2> thePtMin2) { tls.answerMemory=true; return true;} | ||
|
||
//if error is way too big: stop | ||
float invError = TrajectoryStateAccessor(*tsos.freeTrajectoryState()).inversePtError(); | ||
if (invError > 1.e10f) {tls.answerMemory=false;return false;} | ||
|
||
//calculate the actual pT cut: | ||
if ((1.f/std::sqrt(pT2) - theNSigma*invError) > theInvPtMin ) {tls.answerMemory=false; return false;} | ||
// first term if the max value of pT (pT+N*sigma(pT)) | ||
// second tern is the cut | ||
|
||
tls.answerMemory=true; return true; | ||
} | ||
|
40 changes: 40 additions & 0 deletions
40
TrackingTools/TrajectoryFiltering/src/ThresholdPtTrajectoryFilter.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,41 @@ | ||
#include "TrackingTools/TrajectoryFiltering/interface/ThresholdPtTrajectoryFilter.h" | ||
|
||
namespace { | ||
struct TLS { | ||
bool answerMemory=false; | ||
FreeTrajectoryState ftsMemory; | ||
|
||
}; | ||
|
||
thread_local TLS tls; | ||
} | ||
|
||
bool ThresholdPtTrajectoryFilter::test( const TrajectoryMeasurement & tm, int foundHits) const | ||
{ | ||
//first check min number of hits | ||
if (foundHits < theMinHits ){ return true;} | ||
|
||
// check for momentum below limit | ||
const FreeTrajectoryState& fts = *tm.updatedState().freeTrajectoryState(); | ||
|
||
//avoid doing twice the check in TBC and QF | ||
// We make it thread local so that we avoid race conditions between | ||
// threads, and we make sure there is no cache contention between them. | ||
if (tls.ftsMemory.parameters().vector() == fts.parameters().vector()) { return tls.answerMemory;} | ||
tls.ftsMemory=fts; | ||
|
||
//if p_T is way too small: stop | ||
double pT = fts.momentum().perp(); | ||
if (pT<0.010) {tls.answerMemory=false; return false;} | ||
//if error is way too big: stop | ||
double invError = TrajectoryStateAccessor(fts).inversePtError(); | ||
if (invError > 1.e10) {tls.answerMemory=false;return false;} | ||
|
||
//calculate the actual pT cut: | ||
if ((1/pT + theNSigma*invError ) < 1/thePtThreshold ) {tls.answerMemory=false; return false;} | ||
// first term is the minimal value of pT (pT-N*sigma(pT)) | ||
// secon term is the cut | ||
|
||
tls.answerMemory=true; return true; | ||
} | ||
|