diff --git a/DQM/TrackingMonitorSource/plugins/V0EventSelector.cc b/DQM/TrackingMonitorSource/plugins/V0EventSelector.cc index 2a7b0066650f5..7acf591543980 100644 --- a/DQM/TrackingMonitorSource/plugins/V0EventSelector.cc +++ b/DQM/TrackingMonitorSource/plugins/V0EventSelector.cc @@ -2,11 +2,13 @@ #include #include "DataFormats/Common/interface/Handle.h" #include "DataFormats/Common/interface/View.h" +#include "DataFormats/Common/interface/Ref.h" #include "DataFormats/Candidate/interface/VertexCompositeCandidate.h" #include "FWCore/Framework/interface/stream/EDFilter.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/InputTag.h" class V0EventSelector : public edm::stream::EDFilter<> { public: @@ -19,25 +21,45 @@ class V0EventSelector : public edm::stream::EDFilter<> { private: const edm::EDGetTokenT vccToken_; const unsigned int minNumCandidates_; + const double massMin_; + const double massMax_; }; V0EventSelector::V0EventSelector(const edm::ParameterSet& iConfig) : vccToken_{consumes( iConfig.getParameter("vertexCompositeCandidates"))}, - minNumCandidates_{iConfig.getParameter("minCandidates")} {} + minNumCandidates_{iConfig.getParameter("minCandidates")}, + massMin_{iConfig.getParameter("massMin")}, + massMax_{iConfig.getParameter("massMax")} { + produces(); +} bool V0EventSelector::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) { edm::Handle vccHandle; iEvent.getByToken(vccToken_, vccHandle); - return vccHandle->size() >= minNumCandidates_; + auto filteredVCC = std::make_unique(); + + for (const auto& vcc : *vccHandle) { + if (vcc.mass() >= massMin_ && vcc.mass() <= massMax_) { + filteredVCC->push_back(vcc); + } + } + + bool pass = filteredVCC->size() >= minNumCandidates_; + iEvent.put(std::move(filteredVCC)); + + return pass; } void V0EventSelector::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; desc.add("vertexCompositeCandidates", edm::InputTag("generalV0Candidates:Kshort")); - desc.add("minCandidates", 1); // Change '1' to your desired minimum number of candidates + desc.add("minCandidates", 1)->setComment("Minimum number of candidates required"); + desc.add("massMin", 0.0)->setComment("Minimum mass in GeV"); + desc.add("massMax", std::numeric_limits::max())->setComment("Maximum mass in GeV"); descriptions.addWithDefaultLabel(desc); } +// Define this module as a plug-in DEFINE_FWK_MODULE(V0EventSelector); diff --git a/DQM/TrackingMonitorSource/python/TrackingDataMCValidation_Standalone_cff.py b/DQM/TrackingMonitorSource/python/TrackingDataMCValidation_Standalone_cff.py index 6c94d59f19fd7..3317497b47d03 100644 --- a/DQM/TrackingMonitorSource/python/TrackingDataMCValidation_Standalone_cff.py +++ b/DQM/TrackingMonitorSource/python/TrackingDataMCValidation_Standalone_cff.py @@ -94,7 +94,7 @@ ttbarEventSelector = cms.EDFilter("ttbarEventSelector") ttbarTracks = cms.EDProducer("TtbarTrackProducer") -# Added modules for V0Monitoring +# Added modules for V0Monitoring (standard) KshortMonitor = v0Monitor.clone() KshortMonitor.FolderName = "StandaloneTrackMonitor/V0Monitoring/Ks" KshortMonitor.v0 = "generalV0Candidates:Kshort" @@ -108,6 +108,18 @@ LambdaMonitor.histoPSet.massPSet = cms.PSet(nbins = cms.int32(100), xmin = cms.double(1.050), xmax = cms.double(1.250)) + +# Added modules for V0Monitoring (for restricted mass candidates) +SelectedKshortMonitor = KshortMonitor.clone( + FolderName = "StandaloneTrackMonitor/V0Monitoring/SelectedKs", + v0 = "KShortEventSelector" +) + +SelectedLambdaMonitor = LambdaMonitor.clone( + FolderName = "StandaloneTrackMonitor/V0Monitoring/SelectedLambda", + v0 = "LambdaEventSelector" +) + ################## # For MinBias ################## @@ -171,7 +183,7 @@ * KShortEventSelector * KshortTracks * standaloneTrackMonitorK0 - * KshortMonitor) + * SelectedKshortMonitor) standaloneValidationK0sMC = cms.Sequence( hltPathFilter @@ -179,7 +191,7 @@ * KShortEventSelector * KshortTracks * standaloneTrackMonitorK0MC - * KshortMonitor) + * SelectedKshortMonitor) standaloneValidationLambdas = cms.Sequence( hltPathFilter @@ -187,7 +199,7 @@ * LambdaEventSelector * LambdaTracks * standaloneTrackMonitorLambda - * LambdaMonitor) + * SelectedLambdaMonitor) standaloneValidationLambdasMC = cms.Sequence( hltPathFilter @@ -195,7 +207,7 @@ * LambdaEventSelector * LambdaTracks * standaloneTrackMonitorLambdaMC - * LambdaMonitor) + * SelectedLambdaMonitor) ################## # For ZtoEE diff --git a/DQM/TrackingMonitorSource/python/V0Selections_cfi.py b/DQM/TrackingMonitorSource/python/V0Selections_cfi.py index 45df833be8995..737287db892b6 100644 --- a/DQM/TrackingMonitorSource/python/V0Selections_cfi.py +++ b/DQM/TrackingMonitorSource/python/V0Selections_cfi.py @@ -1,12 +1,21 @@ from DQM.TrackingMonitorSource.v0EventSelector_cfi import * from DQM.TrackingMonitorSource.v0VertexTrackProducer_cfi import * -KShortEventSelector = v0EventSelector.clone() +KShortEventSelector = v0EventSelector.clone( + vertexCompositeCandidates = "generalV0Candidates:Kshort", + massMin = 0.47, + massMax = 0.52, +) + LambdaEventSelector = v0EventSelector.clone( - vertexCompositeCandidates = "generalV0Candidates:Lambda" + vertexCompositeCandidates = "generalV0Candidates:Lambda", + massMin = 1.11, + massMax = 1.128 ) -KshortTracks = v0VertexTrackProducer.clone() +KshortTracks = v0VertexTrackProducer.clone( + vertexCompositeCandidates = "KShortEventSelector" +) LambdaTracks = v0VertexTrackProducer.clone( - vertexCompositeCandidates = "generalV0Candidates:Lambda" + vertexCompositeCandidates = "LambdaEventSelector" )