-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updates to precision timing integration in reconstruction and miniaod #20338
Changes from 47 commits
604ef34
96b03b9
22bda77
d3c2bd3
091885f
e8b4b67
7d80e04
cdd3a86
7f47d0a
b555e21
eaa2695
8956001
89a315f
4a37aac
d12c8a9
5107342
e4e879e
ee49778
d91029e
378e0e2
a2fe468
989dcce
6b92f6b
91645db
15b1308
e34878e
9ea1aff
b51de43
f21f833
2e207f8
e02bf9d
aeb1777
4b6fb7a
a4f4a18
e23adf9
253c0fa
813454e
bd5df20
e33b8ad
92e7a03
68d2027
caa0dcb
86878cb
1b346e3
8bfd57a
7ca1d5a
bf86758
2e974d5
e4cf917
96ee090
213e0b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,50 +4,102 @@ | |
#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" | ||
#include "DataFormats/Math/interface/deltaR.h" | ||
#include "TrackingTools/IPTools/interface/IPTools.h" | ||
|
||
#include "FWCore/Utilities/interface/isFinite.h" | ||
|
||
|
||
std::pair<int,PrimaryVertexAssignment::Quality> | ||
PrimaryVertexAssignment::chargedHadronVertex( const reco::VertexCollection& vertices, | ||
const reco::TrackRef& trackRef, | ||
const reco::Track* track, | ||
float time, | ||
float timeReso, // <0 if timing not available for this object | ||
const edm::View<reco::Candidate>& jets, | ||
const TransientTrackBuilder& builder) const { | ||
|
||
int iVertex = -1; | ||
size_t index=0; | ||
typedef reco::VertexCollection::const_iterator IV; | ||
typedef reco::Vertex::trackRef_iterator IT; | ||
|
||
int iVertex = -1; | ||
size_t index=0; | ||
float bestweight=0; | ||
for( auto const & vtx : vertices) { | ||
float w = vtx.trackWeight(trackRef); | ||
if (w > bestweight){ | ||
bestweight=w; | ||
iVertex=index; | ||
} | ||
bestweight=w; | ||
iVertex=index; | ||
} | ||
index++; | ||
} | ||
|
||
bool useTime = useTiming_; | ||
if (edm::isNotFinite(time) || timeReso<1e-6) { | ||
useTime = false; | ||
time = 0.; | ||
timeReso = -1.; | ||
} | ||
|
||
if (preferHighRanked_) { | ||
for(IV iv=vertices.begin(); iv!=vertices.end(); ++iv) { | ||
int ivtx = iv - vertices.begin(); | ||
if (iVertex == ivtx) return std::pair<int,PrimaryVertexAssignment::Quality>(ivtx,PrimaryVertexAssignment::UsedInFit); | ||
|
||
double dz = std::abs(track->dz(iv->position())); | ||
double dt = std::abs(time-iv->t()); | ||
|
||
bool useTimeVtx = useTime && iv->tError()>0.; | ||
|
||
if ((dz < maxDzForPrimaryAssignment_ or dz/track->dzError() < maxDzSigForPrimaryAssignment_ ) and (!useTimeVtx or dt/timeReso < maxDtSigForPrimaryAssignment_)) { | ||
return std::pair<int,PrimaryVertexAssignment::Quality>(ivtx,PrimaryVertexAssignment::PrimaryDz); | ||
} | ||
} | ||
} | ||
|
||
|
||
if(iVertex >= 0 ) return std::pair<int,PrimaryVertexAssignment::Quality>(iVertex,PrimaryVertexAssignment::UsedInFit); | ||
|
||
double dzmin = 1e99; | ||
int vtxIdMinDz = -1; | ||
for(IV iv=vertices.begin(); iv!=vertices.end(); ++iv) { | ||
double dz = std::abs(track->dz(iv->position())); | ||
if(dz<dzmin) { | ||
dzmin = dz; | ||
vtxIdMinDz = iv-vertices.begin(); | ||
} | ||
} | ||
|
||
double distmin = std::numeric_limits<double>::max(); | ||
double dzmin = std::numeric_limits<double>::max(); | ||
double dtmin = std::numeric_limits<double>::max(); | ||
int vtxIdMinDist = -1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. vtxIdMinSignif may be a more intuitive name. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is vestigial from the pre-timing version of the algorithm. Can we leave it for future cleanup? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
||
for(IV iv=vertices.begin(); iv!=vertices.end(); ++iv) { | ||
double dz = std::abs(track->dz(iv->position())); | ||
double dt = std::abs(time-iv->t()); | ||
|
||
double dzsig = dz/track->dzError(); | ||
double dist = dzsig*dzsig; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is the vertex uncertainty not a part of the computation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that is the reason. Actually I do recall now that the vertex uncertainty IS used in once place later in the file. Let me double check what the reason was. |
||
|
||
bool useTimeVtx = useTime && iv->tError()>0.; | ||
if (useTime && !useTimeVtx) { | ||
dt = timeReso; | ||
} | ||
|
||
if (useTime) { | ||
double dtsig = dt/timeReso; | ||
|
||
dist += dtsig*dtsig; | ||
} | ||
if(dist<distmin) { | ||
distmin = dist; | ||
dzmin = dz; | ||
dtmin = dt; | ||
vtxIdMinDist = iv-vertices.begin(); | ||
} | ||
} | ||
|
||
// first use "closest in Z" with tight cuts (targetting primary particles) | ||
float dzE=sqrt(track->dzError()*track->dzError()+vertices[vtxIdMinDz].covariance(2,2)); | ||
if(vtxIdMinDz>=0 and (dzmin < maxDzForPrimaryAssignment_ and dzmin/dzE < maxDzSigForPrimaryAssignment_ and track->dzError()<maxDzErrorForPrimaryAssignment_)) | ||
const float add_cov = vtxIdMinDist >= 0 ? vertices[vtxIdMinDist].covariance(2,2) : 0.f; | ||
const float dzE=sqrt(track->dzError()*track->dzError()+add_cov); | ||
if(vtxIdMinDist>=0 and | ||
(dzmin < maxDzForPrimaryAssignment_ and dzmin/dzE < maxDzSigForPrimaryAssignment_ and track->dzError()<maxDzErrorForPrimaryAssignment_) and | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is in fact a small issue which has been introduced here when forward porting this code to 93x and resolving merge conflicts with 9d480b8 It would not affect the non-timing vertices, but could have a small impact on the sorting of the 4d vertices. I'll commit a fix momentarily. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, that's not true, I was misreading/misremembering what this code does. Everything which is here is fine, with indeed a small inconsistency between the handling of z and t, since the vertex error is used here for z, but not for t. I would prefer to leave it like this for now, also because we need to study more closely the pulls on the time errors of the 4d vertices. |
||
(!useTime or dtmin/timeReso < maxDtSigForPrimaryAssignment_) ) | ||
{ | ||
iVertex=vtxIdMinDz; | ||
iVertex=vtxIdMinDist; | ||
} | ||
|
||
if(iVertex >= 0 ) return std::pair<int,PrimaryVertexAssignment::Quality>(iVertex,PrimaryVertexAssignment::PrimaryDz); | ||
|
||
|
||
|
||
// if track not assigned yet, it could be a b-decay secondary , use jet axis dist criterion | ||
// first find the closest jet within maxJetDeltaR_ | ||
int jetIdx = -1; | ||
|
@@ -94,14 +146,14 @@ PrimaryVertexAssignment::chargedHadronVertex( const reco::VertexCollection& vert | |
|
||
// if the track is not compatible with other PVs but is compatible with the BeamSpot, we may simply have not reco'ed the PV! | ||
// we still point it to the closest in Z, but flag it as possible orphan-primary | ||
if(std::abs(track->dxy(vertices[0].position()))<maxDxyForNotReconstructedPrimary_ && std::abs(track->dxy(vertices[0].position())/track->dxyError())<maxDxySigForNotReconstructedPrimary_) | ||
return std::pair<int,PrimaryVertexAssignment::Quality>(vtxIdMinDz,PrimaryVertexAssignment::NotReconstructedPrimary); | ||
if(!vertices.empty() && std::abs(track->dxy(vertices[0].position()))<maxDxyForNotReconstructedPrimary_ && std::abs(track->dxy(vertices[0].position())/track->dxyError())<maxDxySigForNotReconstructedPrimary_) | ||
return std::pair<int,PrimaryVertexAssignment::Quality>(vtxIdMinDist,PrimaryVertexAssignment::NotReconstructedPrimary); | ||
|
||
//FIXME: here we could better handle V0s and NucInt | ||
|
||
// all other tracks could be non-B secondaries and we just attach them with closest Z | ||
if(vtxIdMinDz>=0) | ||
return std::pair<int,PrimaryVertexAssignment::Quality>(vtxIdMinDz,PrimaryVertexAssignment::OtherDz); | ||
if(vtxIdMinDist>=0) | ||
return std::pair<int,PrimaryVertexAssignment::Quality>(vtxIdMinDist,PrimaryVertexAssignment::OtherDz); | ||
//If for some reason even the dz failed (when?) we consider the track not assigned | ||
return std::pair<int,PrimaryVertexAssignment::Quality>(-1,PrimaryVertexAssignment::Unassigned); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is the vertex error not a part of the significance computation here (it is in other places in this file)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the vertex supposedly has a time resolution at this point.
Shouldn't it be used as well in the significance computation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The vertex time error is only checked if it's >0 (ie to check that the vertex has valid timing info.)
The numerical value is intentionally not used in order to avoid preferring to assign tracks to vertices with large time uncertainty (and the logic is coherent for z and t).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(where the dz significance is used later in the code including the vertex error, it will not cause poor vertices to be favoured, because it is only checked against the closest vertex)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the reason to add the vtx z error was to "regularize" the selection for tracks with very small dzError. IIRC, values down to 5 um are possible which can simply kill a good track with respect to still rather reasonable vertices.