Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-10-03 05:27:08

0001 #include "FWCore/Framework/interface/global/EDFilter.h"
0002 #include "FWCore/Framework/interface/Event.h"
0003 #include "FWCore/Framework/interface/EventSetup.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0007 #include "DataFormats/Candidate/interface/LeafCandidate.h"
0008 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
0009 #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
0010 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0011 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0012 #include "PhysicsTools/CandUtils/interface/Thrust.h"
0013 
0014 //
0015 // class declaration
0016 //
0017 
0018 class HLTPixelThrustFilter : public edm::global::EDFilter<> {
0019 public:
0020   explicit HLTPixelThrustFilter(const edm::ParameterSet&);
0021   ~HLTPixelThrustFilter() override = default;
0022   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0023   bool filter(edm::StreamID, edm::Event&, edm::EventSetup const&) const final;
0024 
0025 private:
0026   const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> trackerGeometryRcdToken_;
0027   const edm::EDGetTokenT<edmNew::DetSetVector<SiPixelCluster> > inputToken_;
0028   const double min_thrust_;  // minimum thrust
0029   const double max_thrust_;  // maximum thrust
0030 };
0031 
0032 //
0033 // constructors and destructor
0034 //
0035 
0036 HLTPixelThrustFilter::HLTPixelThrustFilter(const edm::ParameterSet& config)
0037     : trackerGeometryRcdToken_(esConsumes()),
0038       inputToken_(consumes<edmNew::DetSetVector<SiPixelCluster> >(config.getParameter<edm::InputTag>("inputTag"))),
0039       min_thrust_(config.getParameter<double>("minThrust")),
0040       max_thrust_(config.getParameter<double>("maxThrust")) {}
0041 
0042 void HLTPixelThrustFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0043   edm::ParameterSetDescription desc;
0044   desc.add<edm::InputTag>("inputTag", edm::InputTag("hltSiPixelClusters"));
0045   desc.add<double>("minThrust", 0);
0046   desc.add<double>("maxThrust", 0);
0047   descriptions.add("hltPixelThrustFilter", desc);
0048 }
0049 
0050 //
0051 // member functions
0052 //
0053 // ------------ method called to produce the data  ------------
0054 bool HLTPixelThrustFilter::filter(edm::StreamID, edm::Event& event, edm::EventSetup const& iSetup) const {
0055   // get hold of products from Event
0056   auto const& clusters = event.get(inputToken_);
0057   auto const& trackerGeo = iSetup.getData(trackerGeometryRcdToken_);
0058 
0059   std::vector<reco::LeafCandidate> vec;
0060   for (auto DSViter = clusters.begin(); DSViter != clusters.end(); DSViter++) {
0061     auto const& pgdu = static_cast<const PixelGeomDetUnit*>(trackerGeo.idToDetUnit(DSViter->detId()));
0062     for (auto const& cluster : *DSViter) {
0063       auto const& pos = pgdu->surface().toGlobal(pgdu->specificTopology().localPosition({cluster.x(), cluster.y()}));
0064       auto const mag = std::sqrt(pos.x() * pos.x() + pos.y() * pos.y());
0065       vec.emplace_back(0, reco::Particle::LorentzVector(pos.x() / mag, pos.y() / mag, 0, 0));
0066     }
0067   }
0068   auto const thrust = Thrust(vec.begin(), vec.end()).thrust();
0069 
0070   bool accept = (thrust >= min_thrust_);
0071   if (max_thrust_ > 0)
0072     accept &= (thrust <= max_thrust_);
0073   // return with final filter decision
0074   return accept;
0075 }
0076 
0077 // define as a framework module
0078 #include "FWCore/Framework/interface/MakerMacros.h"
0079 DEFINE_FWK_MODULE(HLTPixelThrustFilter);