Skip to content

Commit

Permalink
Add HLT pixel thrust filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Govinda Stahl Leiton committed Oct 2, 2024
1 parent 40eedd1 commit b034079
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
1 change: 1 addition & 0 deletions HLTrigger/special/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@
<use name="RecoEcal/EgammaCoreTools"/>
<use name="TrackingTools/Records"/>
<use name="TrackingTools/TransientTrack"/>
<use name="PhysicsTools/CandUtils"/>
<flags EDM_PLUGIN="1"/>
79 changes: 79 additions & 0 deletions HLTrigger/special/plugins/HLTPixelThrustFilter.cc
Original file line number Diff line number Diff line change
@@ -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<TrackerGeometry, TrackerDigiGeometryRecord> trackerGeometryRcdToken_;
const edm::EDGetTokenT<edmNew::DetSetVector<SiPixelCluster> > 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<edmNew::DetSetVector<SiPixelCluster> >(config.getParameter<edm::InputTag>("inputTag"))),
min_thrust_(config.getParameter<double>("minThrust")),
max_thrust_(config.getParameter<double>("maxThrust")) {}

void HLTPixelThrustFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("inputTag", edm::InputTag("hltSiPixelClusters"));
desc.add<double>("minThrust", 0);
desc.add<double>("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<reco::LeafCandidate> vec;
for (auto DSViter = clusters.begin(); DSViter != clusters.end(); DSViter++) {
auto const& pgdu = static_cast<const PixelGeomDetUnit*>(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);

0 comments on commit b034079

Please sign in to comment.