33// Package: LHEPtFilter
44// Class: LHEPtFilter
55//
6- /*
6+ /*
77
8- Description: Filter to select events with pT in a given range.
8+ Description: Filter to select events with pT in a given range; includes a switch for sum type (vector or scalar) .
99 (Based on LHEGenericFilter)
1010
11-
11+
1212*/
1313//
1414
2727#include " FWCore/Framework/interface/Event.h"
2828#include " FWCore/Framework/interface/MakerMacros.h"
2929
30+ #include " FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
3031#include " FWCore/ParameterSet/interface/ParameterSet.h"
3132#include " SimDataFormats/GeneratorProducts/interface/LHEEventProduct.h"
3233
@@ -40,6 +41,7 @@ class LHEPtFilter : public edm::global::EDFilter<> {
4041 ~LHEPtFilter () override ;
4142
4243 bool filter (edm::StreamID, edm::Event&, const edm::EventSetup&) const override ;
44+ static void fillDescriptions (edm::ConfigurationDescriptions& descriptions);
4345
4446private:
4547 // ----------member data ---------------------------
@@ -49,6 +51,7 @@ class LHEPtFilter : public edm::global::EDFilter<> {
4951 std::set<int > pdgIds_; // Set of PDG Ids to include
5052 double ptMin_; // number of particles required to pass filter
5153 double ptMax_; // number of particles required to pass filter
54+ bool isScalar_; // true for scalar sum or false for vector sum
5255};
5356
5457using namespace edm ;
@@ -57,7 +60,8 @@ using namespace std;
5760LHEPtFilter::LHEPtFilter (const edm::ParameterSet& iConfig)
5861 : pdgIdVec_(iConfig.getParameter<std::vector<int >>(" selectedPdgIds" )),
5962 ptMin_(iConfig.getParameter<double >(" ptMin" )),
60- ptMax_(iConfig.getParameter<double >(" ptMax" )) {
63+ ptMax_(iConfig.getParameter<double >(" ptMax" )),
64+ isScalar_(iConfig.getParameter<bool >(" isScalar" )) {
6165 // here do whatever other initialization is needed
6266 src_ = consumes<LHEEventProduct>(iConfig.getParameter <edm::InputTag>(" src" ));
6367 pdgIds_ = std::set<int >(pdgIdVec_.begin (), pdgIdVec_.end ());
@@ -87,19 +91,39 @@ bool LHEPtFilter::filter(edm::StreamID, edm::Event& iEvent, const edm::EventSetu
8791 }
8892 }
8993 double vpt_ = -1 ;
90- if (!cands.empty ()) {
91- ROOT::Math::PxPyPzEVector tot = cands.at (0 );
92- for (unsigned icand = 1 ; icand < cands.size (); ++icand) {
93- tot += cands.at (icand);
94+ if (isScalar_) { // do the scalar sum
95+ if (!cands.empty ()) {
96+ double tot = cands.at (0 ).pt ();
97+ for (unsigned icand = 1 ; icand < cands.size (); ++icand) {
98+ tot += cands.at (icand).pt ();
99+ }
100+ vpt_ = tot;
101+ }
102+ if ((ptMax_ < 0 . || vpt_ <= ptMax_) && vpt_ > ptMin_) {
103+ return true ;
104+ } else {
105+ return false ;
106+ }
107+ } else { // else do the vector sum
108+ if (!cands.empty ()) {
109+ ROOT::Math::PxPyPzEVector tot = cands.at (0 );
110+ for (unsigned icand = 1 ; icand < cands.size (); ++icand) {
111+ tot += cands.at (icand);
112+ }
113+ vpt_ = tot.pt ();
114+ }
115+ if ((ptMax_ < 0 . || vpt_ <= ptMax_) && vpt_ > ptMin_) {
116+ return true ;
117+ } else {
118+ return false ;
94119 }
95- vpt_ = tot.pt ();
96- }
97- if ((ptMax_ < 0 . || vpt_ <= ptMax_) && vpt_ > ptMin_) {
98- return true ;
99- } else {
100- return false ;
101120 }
102121}
103122
123+ void LHEPtFilter::fillDescriptions (edm::ConfigurationDescriptions& descriptions) {
124+ edm::ParameterSetDescription desc;
125+ desc.add <bool >(" isScalar" , false ); // default is false
126+ }
127+
104128// define this as a plug-in
105129DEFINE_FWK_MODULE (LHEPtFilter);
0 commit comments