From b03407900bd5af2c0f098b1ccc26500961850575 Mon Sep 17 00:00:00 2001 From: Andre Govinda Stahl Leiton Date: Wed, 2 Oct 2024 16:28:49 +0200 Subject: [PATCH] Add HLT pixel thrust filter --- HLTrigger/special/plugins/BuildFile.xml | 1 + .../special/plugins/HLTPixelThrustFilter.cc | 79 +++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 HLTrigger/special/plugins/HLTPixelThrustFilter.cc diff --git a/HLTrigger/special/plugins/BuildFile.xml b/HLTrigger/special/plugins/BuildFile.xml index bb9a8e073b2e8..e4a71f8b463a8 100644 --- a/HLTrigger/special/plugins/BuildFile.xml +++ b/HLTrigger/special/plugins/BuildFile.xml @@ -54,4 +54,5 @@ + diff --git a/HLTrigger/special/plugins/HLTPixelThrustFilter.cc b/HLTrigger/special/plugins/HLTPixelThrustFilter.cc new file mode 100644 index 0000000000000..ce76fc590fe3d --- /dev/null +++ b/HLTrigger/special/plugins/HLTPixelThrustFilter.cc @@ -0,0 +1,79 @@ +#include "FWCore/Framework/interface/global/EDFilter.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "DataFormats/Candidate/interface/LeafCandidate.h" +#include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h" +#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h" +#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" +#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" +#include "PhysicsTools/CandUtils/interface/Thrust.h" + +// +// class declaration +// + +class HLTPixelThrustFilter : public edm::global::EDFilter<> { +public: + explicit HLTPixelThrustFilter(const edm::ParameterSet&); + ~HLTPixelThrustFilter() override = default; + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + bool filter(edm::StreamID, edm::Event&, edm::EventSetup const&) const final; + +private: + const edm::ESGetToken trackerGeometryRcdToken_; + const edm::EDGetTokenT > inputToken_; + const double min_thrust_; // minimum thrust + const double max_thrust_; // maximum thrust +}; + +// +// constructors and destructor +// + +HLTPixelThrustFilter::HLTPixelThrustFilter(const edm::ParameterSet& config) + : trackerGeometryRcdToken_(esConsumes()), + inputToken_(consumes >(config.getParameter("inputTag"))), + min_thrust_(config.getParameter("minThrust")), + max_thrust_(config.getParameter("maxThrust")) {} + +void HLTPixelThrustFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("inputTag", edm::InputTag("hltSiPixelClusters")); + desc.add("minThrust", 0); + desc.add("maxThrust", 0); + descriptions.add("hltPixelThrustFilter", desc); +} + +// +// member functions +// +// ------------ method called to produce the data ------------ +bool HLTPixelThrustFilter::filter(edm::StreamID, edm::Event& event, edm::EventSetup const& iSetup) const { + // get hold of products from Event + auto const& clusters = event.get(inputToken_); + auto const& trackerGeo = iSetup.getData(trackerGeometryRcdToken_); + + std::vector vec; + for (auto DSViter = clusters.begin(); DSViter != clusters.end(); DSViter++) { + auto const& pgdu = static_cast(trackerGeo.idToDetUnit(DSViter->detId())); + for (auto const& cluster : *DSViter) { + auto const& pos = pgdu->surface().toGlobal(pgdu->specificTopology().localPosition({cluster.x(), cluster.y()})); + auto const mag = std::sqrt(pos.x() * pos.x() + pos.y() * pos.y()); + vec.emplace_back(0, reco::Particle::LorentzVector(pos.x() / mag, pos.y() / mag, 0, 0)); + } + } + auto const thrust = Thrust(vec.begin(), vec.end()).thrust(); + + bool accept = (thrust >= min_thrust_); + if (max_thrust_ > 0) + accept &= (thrust <= max_thrust_); + // return with final filter decision + return accept; +} + +// define as a framework module +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(HLTPixelThrustFilter);