-
Notifications
You must be signed in to change notification settings - Fork 4.6k
bug fix in vertex selection of L2TauTagNNProducer #37291
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
Changes from 8 commits
f1e90e9
6981053
7d0eef9
2475aeb
d8d790c
18448f4
c74d9c0
6b5abf0
074a706
c76cfb5
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 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -183,9 +183,10 @@ class L2TauNNProducer : public edm::stream::EDProducer<edm::GlobalCache<L2TauNNP | |||||||||
| const ZVertexSoA& patavtx_soa, | ||||||||||
| const reco::BeamSpot& beamspot, | ||||||||||
| const MagneticField* magfi); | ||||||||||
| std::vector<int> selectGoodVertices(const ZVertexSoA& patavtx_soa, | ||||||||||
| const pixelTrack::TrackSoA& patatracks_tsoa, | ||||||||||
| const std::vector<int>& TrackGood); | ||||||||||
| void selectGoodTracksAndVertices(const ZVertexSoA& patavtx_soa, | ||||||||||
| const pixelTrack::TrackSoA& patatracks_tsoa, | ||||||||||
| std::vector<int>& trkGood, | ||||||||||
| std::vector<int>& vtxGood); | ||||||||||
| std::pair<float, float> impactParameter(int it, | ||||||||||
| const pixelTrack::TrackSoA& patatracks_tsoa, | ||||||||||
| float patatrackPhi, | ||||||||||
|
|
@@ -210,11 +211,11 @@ class L2TauNNProducer : public edm::stream::EDProducer<edm::GlobalCache<L2TauNNP | |||||||||
| const edm::EDGetTokenT<PixelTrackHeterogeneous> pataTracksToken_; | ||||||||||
| const edm::EDGetTokenT<reco::BeamSpot> beamSpotToken_; | ||||||||||
| const unsigned int maxVtx_; | ||||||||||
| const double fractionSumPt2_; | ||||||||||
| const double minSumPt2_; | ||||||||||
| const double trackPtMin_; | ||||||||||
| const double trackPtMax_; | ||||||||||
| const double trackChi2Max_; | ||||||||||
| const float fractionSumPt2_; | ||||||||||
| const float minSumPt2_; | ||||||||||
| const float trackPtMin_; | ||||||||||
| const float trackPtMax_; | ||||||||||
| const float trackChi2Max_; | ||||||||||
| std::string inputTensorName_; | ||||||||||
| std::string outputTensorName_; | ||||||||||
| const L2TauNNProducerCacheData* L2cacheData_; | ||||||||||
|
|
@@ -340,21 +341,21 @@ void L2TauNNProducer::checknan(tensorflow::Tensor& tensor, int debugLevel) { | |||||||||
| edm::LogWarning("InputVar") << "var is nan \nvar name= " | ||||||||||
| << L2TauTagNNv1::varNameMap.at(static_cast<L2TauTagNNv1::NNInputs>(var_idx)) | ||||||||||
| << "\t var_idx = " << var_idx << "\t eta_idx = " << eta_idx | ||||||||||
| << "\t phi_idx = " << phi_idx << "\t tau_idx = " << tau_idx << std::endl; | ||||||||||
| << "\t phi_idx = " << phi_idx << "\t tau_idx = " << tau_idx; | ||||||||||
| if (debugLevel > 2) { | ||||||||||
| edm::LogWarning("InputVar") << "other vars in same cell \n"; | ||||||||||
| if (var_idx + 1 < tensor_shape.at(3)) | ||||||||||
| edm::LogWarning("InputVar") << L2TauTagNNv1::varNameMap.at(static_cast<NNInputs>(var_idx + 1)) | ||||||||||
| << "\t = " << getCell(static_cast<NNInputs>(var_idx + 1)) << std::endl; | ||||||||||
| << "\t = " << getCell(static_cast<NNInputs>(var_idx + 1)); | ||||||||||
| if (var_idx + 2 < tensor_shape.at(3)) | ||||||||||
| edm::LogWarning("InputVar") << L2TauTagNNv1::varNameMap.at(static_cast<NNInputs>(var_idx + 2)) | ||||||||||
| << "\t = " << getCell(static_cast<NNInputs>(var_idx + 2)) << std::endl; | ||||||||||
| << "\t = " << getCell(static_cast<NNInputs>(var_idx + 2)); | ||||||||||
| if (var_idx + 3 < tensor_shape.at(3)) | ||||||||||
| edm::LogWarning("InputVar") << L2TauTagNNv1::varNameMap.at(static_cast<NNInputs>(var_idx + 3)) | ||||||||||
| << "\t = " << getCell(static_cast<NNInputs>(var_idx + 3)) << std::endl; | ||||||||||
| << "\t = " << getCell(static_cast<NNInputs>(var_idx + 3)); | ||||||||||
| if (var_idx + 4 < tensor_shape.at(3)) | ||||||||||
| edm::LogWarning("InputVar") << L2TauTagNNv1::varNameMap.at(static_cast<NNInputs>(var_idx + 4)) | ||||||||||
| << "\t = " << getCell(static_cast<NNInputs>(var_idx + 4)) << std::endl; | ||||||||||
| << "\t = " << getCell(static_cast<NNInputs>(var_idx + 4)); | ||||||||||
| } | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
@@ -399,7 +400,8 @@ void L2TauNNProducer::standardizeTensor(tensorflow::Tensor& tensor) { | |||||||||
|
|
||||||||||
| void L2TauNNProducer::fillL1TauVars(tensorflow::Tensor& cellGridMatrix, const std::vector<l1t::TauRef>& allTaus) { | ||||||||||
| using NNInputs = L2TauTagNNv1::NNInputs; | ||||||||||
| const int nTaus = static_cast<int>(allTaus.size()); | ||||||||||
| //const int nTaus = static_cast<int>(allTaus.size()); | ||||||||||
| const int nTaus = allTaus.size(); | ||||||||||
| for (int tau_idx = 0; tau_idx < nTaus; tau_idx++) { | ||||||||||
| for (int eta_idx = 0; eta_idx < L2TauTagNNv1::nCellEta; eta_idx++) { | ||||||||||
| for (int phi_idx = 0; phi_idx < L2TauTagNNv1::nCellPhi; phi_idx++) { | ||||||||||
|
|
@@ -432,7 +434,8 @@ void L2TauNNProducer::fillCaloRecHits(tensorflow::Tensor& cellGridMatrix, | |||||||||
| const std::vector<l1t::TauRef>& allTaus, | ||||||||||
| const caloRecHitCollections& caloRecHits) { | ||||||||||
| using NNInputs = L2TauTagNNv1::NNInputs; | ||||||||||
| const int nTaus = static_cast<int>(allTaus.size()); | ||||||||||
| //const int nTaus = static_cast<int>(allTaus.size()); | ||||||||||
|
||||||||||
| //const int nTaus = static_cast<int>(allTaus.size()); |
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.
I would have expected continue rather than break (assuming this is the n-hits of one given track). No?
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.
this WAS the bug.
it is a guard
see for instance in
https://cmssdt.cern.ch/dxr/CMSSW/source/RecoPixelVertexing/PixelVertexFinding/plugins/gpuVertexFinder.cc#30
it will not be required anymore once #37281 is merged
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.
Okay, thanks for clarifying.
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 upper limit from maxVtx_ has been removed. Either re-instate it, or remove the corresponding configuration parameter (and class data member).
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.
I'm generally confused about the role of vtxGood, but obviously I'm not the expert here.
Is the order of the elements in vtxGood important?
- If not, why do you need to use the sorting from the input vertices (
soa.sortInd[j])? - If yes, since the sorting from the input vertices is used, shouldn't one use the f.o.m. that was used for that sorting? Is that the purpose of
pTSquaredSum(to match exactly the f.o.m. used for the original sorting)? If so, wouldn't that value already be available insoa.ptv2[sortInd[j]]?
Is vtxGood meant to mimic the "trimmed" pixel vertices? If yes, why not simply use those as (additional) input to this producer, without having to recompute all this and having to keep this whole source code aligned with the pixel reco?
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.
Is the order of the elements in
vtxGoodimportant?
- If not, why do you need to use the sorting from the input vertices (
soa.sortInd[j])?
No, the order is not important. patavtx_soa.sotrInd[vtx_idx] is needed to make track-vertex association, because patavtx_soa.idv[trk_idx] refers to sortInd instead of vtx_idx.
Is
vtxGoodmeant to mimic the "trimmed" pixel vertices? If yes, why not simply use those as (additional) input to this producer, without having to recompute all this and having to keep this whole source code aligned with the pixel reco?
In L2TauTag producer we prefer to avoid the use of legacy formats to eliminate unnecessary overhead from conversion and creation of the new collection. While indeed in the current version, the vertex selection mimics "trimmed" vertex producer logic, we plan to change the selection for future training (e.g. use soa.ptv2, review cuts applied to trkGood and vtxGood).
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.
No, the order is not important. [..]
In this particular loop, I don't see .idv, so it's not clear to me how [1] would differ from [2] if the order of vtxGood is not important.
[1]
for (int j = nv - 1; j >= 0; --j) {
auto vtx_idx = patavtx_soa.sortInd[j];
assert(vtx_idx < nv);
if (nTrkAssociated[vtx_idx] >= 2 && pTSquaredSum[vtx_idx] >= minFOM_fromFrac &&
pTSquaredSum[vtx_idx] > minSumPt2_) {
vtxGood.push_back(vtx_idx);
}
}[2]
for (int vtx_idx = nv - 1; vtx_idx >= 0; --vtx_idx) {
if (nTrkAssociated[vtx_idx] >= 2 && pTSquaredSum[vtx_idx] >= minFOM_fromFrac &&
pTSquaredSum[vtx_idx] > minSumPt2_) {
vtxGood.push_back(vtx_idx);
}
}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.
Sorry, I've misunderstood your original comment. Yes, in this particular loop [1] and [2] will result in equivalent NN inputs. So let's use [2] since it is simpler.
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.
Hm.. actually, as @valeriadamante pointed me out, after adding back maxVtx_ [1] and [2] will no longer be equivalent because if the number of potentially good vertices is greater than maxVtx_, we would want to keep the most energetic ones. However, the order in which they will be stored in vtxGood is not important.
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.
Right, I see. In principle, one could also fill vtxGood then use if (vtxGood.size > maxVtx_) vtxGood.resize(maxVtx_) afterwards (without having the if (vtxGood.size > maxVtx_) check inside the for loop). I don't know what's better and faster, it might depend on the typical value of vtxGood.size and maxVtx_. You are free to use the implementation you prefer, of course.
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.
Can one actually have nTrkAssociated < 2 for a vertex? If not, could/should nTrkAssociated be removed altogether? If not, should the threshold be configurable and not hard-coded to 2?
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.
@valeriadamante , I see you updated the PR, but I'd like to have a clarification on this question before restarting the tests.
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.
perhaps @VinInn can comment on this. For L2TauTag we copied this condition from here:
cmssw/RecoPixelVertexing/PixelVertexFinding/plugins/PixelVertexProducerFromSoA.cc
Lines 118 to 121 in 48409a2
| if (nt < 2) { | |
| itrk.clear(); | |
| continue; | |
| } // remove outliers |
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.
Okay, understood. If further changes are eventually made to this PR (or in a future one), you could consider adding comments on where these different cuts are taken from, and what they need to be kept aligned with.
Outdated
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.
| //const int nTaus = static_cast<int>(allTaus.size()); |
Outdated
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.
| //const int nTaus = static_cast<int>(allTaus.size()); |
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.