From 4e8135d2789b9ed5ff906e6bf51b064dde090616 Mon Sep 17 00:00:00 2001 From: AdrianoDee Date: Fri, 28 May 2021 16:12:13 +0200 Subject: [PATCH 1/9] Adding tracks compatible with a Xi to lost tracks - add to lostTracks tracks consistent with coming from a Xi candidate decaying to LambdaPi - adding a flag to turn on the slection --- .../PatAlgos/plugins/PATLostTracks.cc | 34 +++++++++++++++---- .../python/slimming/lostTracks_cfi.py | 4 ++- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc b/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc index 6fc798eab4d11..0ce1d30ac3182 100644 --- a/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc +++ b/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc @@ -12,6 +12,8 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "CommonTools/Utils/interface/StringCutObjectSelector.h" +#include "TLorentzVector.h" + namespace { bool passesQuality(const reco::Track& trk, const std::vector& allowedQuals) { for (const auto& qual : allowedQuals) { @@ -68,6 +70,8 @@ namespace pat { const double maxDxyForNotReconstructedPrimary_; const double maxDxySigForNotReconstructedPrimary_; const bool useLegacySetup_; + const bool xiSelection_; + const double xiMassCut_; }; } // namespace pat @@ -100,7 +104,9 @@ pat::PATLostTracks::PATLostTracks(const edm::ParameterSet& iConfig) .getParameter("maxDxyForNotReconstructedPrimary")), maxDxySigForNotReconstructedPrimary_(iConfig.getParameter("pvAssignment") .getParameter("maxDxySigForNotReconstructedPrimary")), - useLegacySetup_(iConfig.getParameter("useLegacySetup")) { + useLegacySetup_(iConfig.getParameter("useLegacySetup")), + xiSelection_(iConfig.getParameter("xiSelection")), + xiMassCut_(iConfig.getParameter("xiMassCut")) { std::vector trkQuals(iConfig.getParameter>("qualsToAutoAccept")); std::transform( trkQuals.begin(), trkQuals.end(), std::back_inserter(qualsToAutoAccept_), reco::TrackBase::qualityByName); @@ -189,11 +195,27 @@ void pat::PATLostTracks::produce(edm::StreamID, edm::Event& iEvent, const edm::E trkStatus[key] = TrkStatus::VTX; } } - for (const auto& v0 : *lambdas) { - for (size_t dIdx = 0; dIdx < v0.numberOfDaughters(); dIdx++) { - size_t key = (dynamic_cast(v0.daughter(dIdx)))->track().key(); - if (trkStatus[key] == TrkStatus::NOTUSED) - trkStatus[key] = TrkStatus::VTX; + for (const auto& v0 : *lambdas){ + double protonCharge = 0; + for(size_t dIdx=0;dIdx(v0.daughter(dIdx)))->track().key(); + if(trkStatus[key]==TrkStatus::NOTUSED) trkStatus[key]=TrkStatus::VTX; + protonCharge += v0.daughter(dIdx)->charge() * v0.daughter(dIdx)->momentum().mag2(); + } + if (xiSelection_) + { + // selecting potential Xi- -> Lambda pi candidates + TLorentzVector p4Lambda; + p4Lambda.SetPtEtaPhiM(v0.pt(),v0.eta(),v0.phi(), v0.mass()); + for(unsigned int trkIndx=0; trkIndx < tracks->size(); trkIndx++){ + reco::TrackRef trk(tracks,trkIndx); + if ((*trk).charge() * protonCharge < 0) continue; + TLorentzVector p4pi; + p4pi.SetPtEtaPhiM((*trk).pt(),(*trk).eta(),(*trk).phi(), 0.13957061); + if ((p4Lambda+p4pi).M() < xiMassCut_){ // selecting potential Xi- candidates + if(trkStatus[trkIndx]==TrkStatus::NOTUSED) trkStatus[trkIndx]=TrkStatus::VTX; + } + } } } std::vector mapping(tracks->size(), -1); diff --git a/PhysicsTools/PatAlgos/python/slimming/lostTracks_cfi.py b/PhysicsTools/PatAlgos/python/slimming/lostTracks_cfi.py index e47fe5bf1db65..c55056f6780d0 100644 --- a/PhysicsTools/PatAlgos/python/slimming/lostTracks_cfi.py +++ b/PhysicsTools/PatAlgos/python/slimming/lostTracks_cfi.py @@ -22,7 +22,9 @@ minPtToStoreLowQualityProps = cms.double(0.0), passThroughCut = cms.string("pt>2"), pvAssignment = primaryVertexAssociation.assignment, - useLegacySetup = cms.bool(False) #When True: check only if track used to fit vertex[0] and do not store track detailed info for Pt between 0.5 and minPtToStoreProps GeV + useLegacySetup = cms.bool(False), #When True: check only if track used to fit vertex[0] and do not store track detailed info for Pt between 0.5 and minPtToStoreProps GeV + xiSelection = cms.bool(True), + xiMassCut = cms.bool(1.6) ) from Configuration.Eras.Modifier_phase1Pixel_cff import phase1Pixel phase1Pixel.toModify(lostTracks, covarianceVersion =1 ) From 28116a9cb3020aaa292e317f08d20202fbb9ddc1 Mon Sep 17 00:00:00 2001 From: AdrianoDee Date: Fri, 28 May 2021 16:16:30 +0200 Subject: [PATCH 2/9] Code checks and code formatting --- .../PatAlgos/plugins/PATLostTracks.cc | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc b/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc index 0ce1d30ac3182..dde554d7570e4 100644 --- a/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc +++ b/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc @@ -195,25 +195,27 @@ void pat::PATLostTracks::produce(edm::StreamID, edm::Event& iEvent, const edm::E trkStatus[key] = TrkStatus::VTX; } } - for (const auto& v0 : *lambdas){ + for (const auto& v0 : *lambdas) { double protonCharge = 0; - for(size_t dIdx=0;dIdx(v0.daughter(dIdx)))->track().key(); - if(trkStatus[key]==TrkStatus::NOTUSED) trkStatus[key]=TrkStatus::VTX; + for (size_t dIdx = 0; dIdx < v0.numberOfDaughters(); dIdx++) { + size_t key = (dynamic_cast(v0.daughter(dIdx)))->track().key(); + if (trkStatus[key] == TrkStatus::NOTUSED) + trkStatus[key] = TrkStatus::VTX; protonCharge += v0.daughter(dIdx)->charge() * v0.daughter(dIdx)->momentum().mag2(); } - if (xiSelection_) - { + if (xiSelection_) { // selecting potential Xi- -> Lambda pi candidates TLorentzVector p4Lambda; - p4Lambda.SetPtEtaPhiM(v0.pt(),v0.eta(),v0.phi(), v0.mass()); - for(unsigned int trkIndx=0; trkIndx < tracks->size(); trkIndx++){ - reco::TrackRef trk(tracks,trkIndx); - if ((*trk).charge() * protonCharge < 0) continue; + p4Lambda.SetPtEtaPhiM(v0.pt(), v0.eta(), v0.phi(), v0.mass()); + for (unsigned int trkIndx = 0; trkIndx < tracks->size(); trkIndx++) { + reco::TrackRef trk(tracks, trkIndx); + if ((*trk).charge() * protonCharge < 0) + continue; TLorentzVector p4pi; - p4pi.SetPtEtaPhiM((*trk).pt(),(*trk).eta(),(*trk).phi(), 0.13957061); - if ((p4Lambda+p4pi).M() < xiMassCut_){ // selecting potential Xi- candidates - if(trkStatus[trkIndx]==TrkStatus::NOTUSED) trkStatus[trkIndx]=TrkStatus::VTX; + p4pi.SetPtEtaPhiM((*trk).pt(), (*trk).eta(), (*trk).phi(), 0.13957061); + if ((p4Lambda + p4pi).M() < xiMassCut_) { // selecting potential Xi- candidates + if (trkStatus[trkIndx] == TrkStatus::NOTUSED) + trkStatus[trkIndx] = TrkStatus::VTX; } } } From 40e810ed095706954dfebb6e49d2bed37c792586 Mon Sep 17 00:00:00 2001 From: AdrianoDee Date: Sat, 29 May 2021 12:34:58 +0200 Subject: [PATCH 3/9] Lowering cut to 1.5 --- PhysicsTools/PatAlgos/python/slimming/lostTracks_cfi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PhysicsTools/PatAlgos/python/slimming/lostTracks_cfi.py b/PhysicsTools/PatAlgos/python/slimming/lostTracks_cfi.py index c55056f6780d0..6de7a9ed5aacb 100644 --- a/PhysicsTools/PatAlgos/python/slimming/lostTracks_cfi.py +++ b/PhysicsTools/PatAlgos/python/slimming/lostTracks_cfi.py @@ -24,7 +24,7 @@ pvAssignment = primaryVertexAssociation.assignment, useLegacySetup = cms.bool(False), #When True: check only if track used to fit vertex[0] and do not store track detailed info for Pt between 0.5 and minPtToStoreProps GeV xiSelection = cms.bool(True), - xiMassCut = cms.bool(1.6) + xiMassCut = cms.bool(1.5) ) from Configuration.Eras.Modifier_phase1Pixel_cff import phase1Pixel phase1Pixel.toModify(lostTracks, covarianceVersion =1 ) From 4f044f88540f3bcefd4765d9b3579a0bb04e5862 Mon Sep 17 00:00:00 2001 From: AdrianoDee Date: Mon, 31 May 2021 08:44:16 +0200 Subject: [PATCH 4/9] Moving to XYZTLorentz vectors --- PhysicsTools/PatAlgos/plugins/PATLostTracks.cc | 10 +++++----- .../PatAlgos/python/slimming/lostTracks_cfi.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc b/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc index dde554d7570e4..17ff4d2556c17 100644 --- a/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc +++ b/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc @@ -105,7 +105,7 @@ pat::PATLostTracks::PATLostTracks(const edm::ParameterSet& iConfig) maxDxySigForNotReconstructedPrimary_(iConfig.getParameter("pvAssignment") .getParameter("maxDxySigForNotReconstructedPrimary")), useLegacySetup_(iConfig.getParameter("useLegacySetup")), - xiSelection_(iConfig.getParameter("xiSelection")), + xiSelection_(iConfig.getParameter("xiSelection")), xiMassCut_(iConfig.getParameter("xiMassCut")) { std::vector trkQuals(iConfig.getParameter>("qualsToAutoAccept")); std::transform( @@ -205,14 +205,14 @@ void pat::PATLostTracks::produce(edm::StreamID, edm::Event& iEvent, const edm::E } if (xiSelection_) { // selecting potential Xi- -> Lambda pi candidates - TLorentzVector p4Lambda; - p4Lambda.SetPtEtaPhiM(v0.pt(), v0.eta(), v0.phi(), v0.mass()); + math::XYZTLorentzVector p4Lambda(v0.px(), v0.py(), v0.pz(), sqrt(v0.momentum().mag2() + v0.mass()*v0.mass())); + for (unsigned int trkIndx = 0; trkIndx < tracks->size(); trkIndx++) { reco::TrackRef trk(tracks, trkIndx); if ((*trk).charge() * protonCharge < 0) continue; - TLorentzVector p4pi; - p4pi.SetPtEtaPhiM((*trk).pt(), (*trk).eta(), (*trk).phi(), 0.13957061); + + math::XYZTLorentzVector p4pi(trk->px(), trk->py(), trk->pz(), trk->momentum().mag2() + 0.01947995518); // pion mass ^2 if ((p4Lambda + p4pi).M() < xiMassCut_) { // selecting potential Xi- candidates if (trkStatus[trkIndx] == TrkStatus::NOTUSED) trkStatus[trkIndx] = TrkStatus::VTX; diff --git a/PhysicsTools/PatAlgos/python/slimming/lostTracks_cfi.py b/PhysicsTools/PatAlgos/python/slimming/lostTracks_cfi.py index 6de7a9ed5aacb..93f75eb1cc3f8 100644 --- a/PhysicsTools/PatAlgos/python/slimming/lostTracks_cfi.py +++ b/PhysicsTools/PatAlgos/python/slimming/lostTracks_cfi.py @@ -24,7 +24,7 @@ pvAssignment = primaryVertexAssociation.assignment, useLegacySetup = cms.bool(False), #When True: check only if track used to fit vertex[0] and do not store track detailed info for Pt between 0.5 and minPtToStoreProps GeV xiSelection = cms.bool(True), - xiMassCut = cms.bool(1.5) + xiMassCut = cms.double(1.5) ) from Configuration.Eras.Modifier_phase1Pixel_cff import phase1Pixel phase1Pixel.toModify(lostTracks, covarianceVersion =1 ) From 93bcbbe8a3f7f5abb921132f1b82e8d3539fa7fa Mon Sep 17 00:00:00 2001 From: AdrianoDee Date: Mon, 31 May 2021 09:04:03 +0200 Subject: [PATCH 5/9] Header cleanup --- PhysicsTools/PatAlgos/plugins/PATLostTracks.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc b/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc index 17ff4d2556c17..faeba7d3fec4d 100644 --- a/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc +++ b/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc @@ -12,8 +12,6 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "CommonTools/Utils/interface/StringCutObjectSelector.h" -#include "TLorentzVector.h" - namespace { bool passesQuality(const reco::Track& trk, const std::vector& allowedQuals) { for (const auto& qual : allowedQuals) { From 592c219c899f4a113b5d4a72ac392c7c145569fb Mon Sep 17 00:00:00 2001 From: AdrianoDee Date: Mon, 31 May 2021 09:13:12 +0200 Subject: [PATCH 6/9] Code format --- PhysicsTools/PatAlgos/plugins/PATLostTracks.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc b/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc index faeba7d3fec4d..e8006a1deb144 100644 --- a/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc +++ b/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc @@ -203,14 +203,15 @@ void pat::PATLostTracks::produce(edm::StreamID, edm::Event& iEvent, const edm::E } if (xiSelection_) { // selecting potential Xi- -> Lambda pi candidates - math::XYZTLorentzVector p4Lambda(v0.px(), v0.py(), v0.pz(), sqrt(v0.momentum().mag2() + v0.mass()*v0.mass())); + math::XYZTLorentzVector p4Lambda(v0.px(), v0.py(), v0.pz(), sqrt(v0.momentum().mag2() + v0.mass() * v0.mass())); for (unsigned int trkIndx = 0; trkIndx < tracks->size(); trkIndx++) { reco::TrackRef trk(tracks, trkIndx); if ((*trk).charge() * protonCharge < 0) continue; - math::XYZTLorentzVector p4pi(trk->px(), trk->py(), trk->pz(), trk->momentum().mag2() + 0.01947995518); // pion mass ^2 + math::XYZTLorentzVector p4pi( + trk->px(), trk->py(), trk->pz(), trk->momentum().mag2() + 0.01947995518); // pion mass ^2 if ((p4Lambda + p4pi).M() < xiMassCut_) { // selecting potential Xi- candidates if (trkStatus[trkIndx] == TrkStatus::NOTUSED) trkStatus[trkIndx] = TrkStatus::VTX; From 743f900c2cf4ac67b151d94ab4bd6b7112a89dd6 Mon Sep 17 00:00:00 2001 From: AdrianoDee Date: Mon, 31 May 2021 09:53:49 +0200 Subject: [PATCH 7/9] Adding sqrt for energy mass conversion --- PhysicsTools/PatAlgos/plugins/PATLostTracks.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc b/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc index e8006a1deb144..7c634f8a09ba3 100644 --- a/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc +++ b/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc @@ -211,7 +211,7 @@ void pat::PATLostTracks::produce(edm::StreamID, edm::Event& iEvent, const edm::E continue; math::XYZTLorentzVector p4pi( - trk->px(), trk->py(), trk->pz(), trk->momentum().mag2() + 0.01947995518); // pion mass ^2 + trk->px(), trk->py(), trk->pz(), sqrt(trk->momentum().mag2() + 0.01947995518)); // pion mass ^2 if ((p4Lambda + p4pi).M() < xiMassCut_) { // selecting potential Xi- candidates if (trkStatus[trkIndx] == TrkStatus::NOTUSED) trkStatus[trkIndx] = TrkStatus::VTX; From 830b6f4deedb0fc2d94e7ddff7bb05dd501e8fef Mon Sep 17 00:00:00 2001 From: AdrianoDee Date: Mon, 31 May 2021 14:05:17 +0200 Subject: [PATCH 8/9] Moving the NOTUSED cut above --- PhysicsTools/PatAlgos/plugins/PATLostTracks.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc b/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc index 7c634f8a09ba3..d207f906b3bc2 100644 --- a/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc +++ b/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc @@ -205,17 +205,16 @@ void pat::PATLostTracks::produce(edm::StreamID, edm::Event& iEvent, const edm::E // selecting potential Xi- -> Lambda pi candidates math::XYZTLorentzVector p4Lambda(v0.px(), v0.py(), v0.pz(), sqrt(v0.momentum().mag2() + v0.mass() * v0.mass())); - for (unsigned int trkIndx = 0; trkIndx < tracks->size(); trkIndx++) { + for (unsigned int trkIndx = 0; trkIndx < tracks->size(); trkIndx++) + { reco::TrackRef trk(tracks, trkIndx); - if ((*trk).charge() * protonCharge < 0) + if ((*trk).charge() * protonCharge < 0 || trkStatus[trkIndx] != TrkStatus::NOTUSED) continue; math::XYZTLorentzVector p4pi( trk->px(), trk->py(), trk->pz(), sqrt(trk->momentum().mag2() + 0.01947995518)); // pion mass ^2 - if ((p4Lambda + p4pi).M() < xiMassCut_) { // selecting potential Xi- candidates - if (trkStatus[trkIndx] == TrkStatus::NOTUSED) - trkStatus[trkIndx] = TrkStatus::VTX; - } + if ((p4Lambda + p4pi).M() < xiMassCut_) + trkStatus[trkIndx] = TrkStatus::VTX; // selecting potential Xi- candidates } } } From 807d8e0ee81c17a1ea13ebf1c60038c17c8a4614 Mon Sep 17 00:00:00 2001 From: AdrianoDee Date: Mon, 31 May 2021 14:07:41 +0200 Subject: [PATCH 9/9] Code format --- PhysicsTools/PatAlgos/plugins/PATLostTracks.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc b/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc index d207f906b3bc2..7c5be135a21a2 100644 --- a/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc +++ b/PhysicsTools/PatAlgos/plugins/PATLostTracks.cc @@ -205,8 +205,7 @@ void pat::PATLostTracks::produce(edm::StreamID, edm::Event& iEvent, const edm::E // selecting potential Xi- -> Lambda pi candidates math::XYZTLorentzVector p4Lambda(v0.px(), v0.py(), v0.pz(), sqrt(v0.momentum().mag2() + v0.mass() * v0.mass())); - for (unsigned int trkIndx = 0; trkIndx < tracks->size(); trkIndx++) - { + for (unsigned int trkIndx = 0; trkIndx < tracks->size(); trkIndx++) { reco::TrackRef trk(tracks, trkIndx); if ((*trk).charge() * protonCharge < 0 || trkStatus[trkIndx] != TrkStatus::NOTUSED) continue; @@ -214,7 +213,7 @@ void pat::PATLostTracks::produce(edm::StreamID, edm::Event& iEvent, const edm::E math::XYZTLorentzVector p4pi( trk->px(), trk->py(), trk->pz(), sqrt(trk->momentum().mag2() + 0.01947995518)); // pion mass ^2 if ((p4Lambda + p4pi).M() < xiMassCut_) - trkStatus[trkIndx] = TrkStatus::VTX; // selecting potential Xi- candidates + trkStatus[trkIndx] = TrkStatus::VTX; // selecting potential Xi- candidates } } }