CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
PythiaFilterHT Class Reference

#include <IOMC/PythiaFilterHT/src/PythiaFilterHT.cc>

Inheritance diagram for PythiaFilterHT:
edm::EDFilter edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

bool filter (edm::Event &, const edm::EventSetup &) override
 
 PythiaFilterHT (const edm::ParameterSet &)
 
 ~PythiaFilterHT () override
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDFilter () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

edm::EDGetTokenT< edm::HepMCProductlabel_
 
double maxetacut
 
int maxnumberofeventsinrun
 
double maxpcut
 
double maxphicut
 
double maxptcut
 
double maxrapcut
 
double minetacut
 
double minhtcut
 
double minpcut
 
double minphicut
 
double minptcut
 
double minrapcut
 
int motherID
 
int particleID
 
int processID
 
double rapidity
 
int status
 
int theNumberOfSelected
 
int theNumberOfTestedEvt
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 41 of file PythiaFilterHT.h.

Constructor & Destructor Documentation

PythiaFilterHT::PythiaFilterHT ( const edm::ParameterSet iConfig)
explicit

Definition at line 9 of file PythiaFilterHT.cc.

References gather_cfg::cout, minhtcut, motherID, theNumberOfSelected, and theNumberOfTestedEvt.

9  :
10  label_(consumes<edm::HepMCProduct>(edm::InputTag(iConfig.getUntrackedParameter("moduleLabel",std::string("generator")),"unsmeared"))),
11  /*minpcut(iConfig.getUntrackedParameter("MinP", 0.)),
12  maxpcut(iConfig.getUntrackedParameter("MaxP", 10000.)),
13  minptcut(iConfig.getUntrackedParameter("MinPt", 0.)),
14  maxptcut(iConfig.getUntrackedParameter("MaxPt", 10000.)),
15  minetacut(iConfig.getUntrackedParameter("MinEta", -10.)),
16  maxetacut(iConfig.getUntrackedParameter("MaxEta", 10.)),
17  minrapcut(iConfig.getUntrackedParameter("MinRapidity", -20.)),
18  maxrapcut(iConfig.getUntrackedParameter("MaxRapidity", 20.)),
19  minphicut(iConfig.getUntrackedParameter("MinPhi", -3.5)),
20  maxphicut(iConfig.getUntrackedParameter("MaxPhi", 3.5)),*/
21  minhtcut(iConfig.getUntrackedParameter("MinHT", 0.)),
22  motherID(iConfig.getUntrackedParameter("MotherID", 0)) {
23 
26 
27  cout << " Cut Definition: " << endl;
28  /*cout << " MinP = " << minpcut << endl;
29  cout << " MaxP = " << maxpcut << endl;
30  cout << " MinPt = " << minptcut << endl;
31  cout << " MaxPt = " << maxptcut << endl;
32  cout << " MinEta = " << minetacut << endl;
33  cout << " MaxEta = " << maxetacut << endl;
34  cout << " MinRapidity = " << minrapcut << endl;
35  cout << " MaxRapidity = " << maxrapcut << endl;
36  cout << " MinPhi = " << minphicut << endl;
37  cout << " MaxPhi = " << maxphicut << endl;*/
38  cout << " MinHT = " << minhtcut << endl;
39  cout << " MotherID = " << motherID << endl;
40 
41 }
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::HepMCProduct > label_
PythiaFilterHT::~PythiaFilterHT ( )
override

Definition at line 44 of file PythiaFilterHT.cc.

References gather_cfg::cout, theNumberOfSelected, and theNumberOfTestedEvt.

44  {
45  std::cout << "Total number of tested events = " << theNumberOfTestedEvt << std::endl;
46  std::cout << "Total number of accepted events = " << theNumberOfSelected << std::endl;
47 }

Member Function Documentation

bool PythiaFilterHT::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 55 of file PythiaFilterHT.cc.

References funct::abs(), cms::dd::accepted(), gather_cfg::cout, GenParticle::GenParticle, edm::Event::getByToken(), edm::HepMCProduct::GetEvent(), label_, minhtcut, motherID, AlCaHLTBitMon_ParallelJobs::p, theNumberOfSelected, and theNumberOfTestedEvt.

55  {
56 
58  if(theNumberOfTestedEvt%1000 == 0) cout << "Number of tested events = " << theNumberOfTestedEvt << endl;
59 
60  bool accepted = false;
62  iEvent.getByToken(label_, evt);
63 
64  const HepMC::GenEvent * myGenEvent = evt->GetEvent();
65 
66  double HT = 0;
67 
68  for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end(); ++p ) {
69 
70  if ( ( (*p)->status() == 23 ) && ( ( abs( (*p)->pdg_id() ) < 6 ) || ( (*p)->pdg_id() == 21 ) ) ) {
71 
72  /*rapidity = 0.5*log( ((*p)->momentum().e()+(*p)->momentum().pz()) / ((*p)->momentum().e()-(*p)->momentum().pz()) );
73 
74  if ( (*p)->momentum().rho() > minpcut
75  && (*p)->momentum().rho() < maxpcut
76  && (*p)->momentum().perp() > minptcut
77  && (*p)->momentum().perp() < maxptcut
78  && (*p)->momentum().eta() > minetacut
79  && (*p)->momentum().eta() < maxetacut
80  && rapidity > minrapcut
81  && rapidity < maxrapcut
82  && (*p)->momentum().phi() > minphicut
83  && (*p)->momentum().phi() < maxphicut ) {*/
84 
85  if ( motherID == 0 ) {
86  HT += (*p)->momentum().perp();
87  } else {
88  HepMC::GenParticle* mother = (*((*p)->production_vertex()->particles_in_const_begin()));
89  if (abs(mother->pdg_id()) == abs(motherID)) {
90  HT += (*p)->momentum().perp();
91  }
92  }
93  //}
94  }
95  }
96  if ( HT > minhtcut ) accepted = true;
97 
98  if (accepted){
100  cout << "========> Event preselected " << theNumberOfSelected << " HT = " << HT << endl;
101  return true;
102  } else {
103  //cout << "========> Event rejected HT = " << HT << endl;
104  return false;
105  }
106 
107 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:38
bool accepted(std::vector< std::string_view > const &, std::string_view)
edm::EDGetTokenT< edm::HepMCProduct > label_
Definition: HT.h:21

Member Data Documentation

edm::EDGetTokenT<edm::HepMCProduct> PythiaFilterHT::label_
private
double PythiaFilterHT::maxetacut
private

Definition at line 59 of file PythiaFilterHT.h.

int PythiaFilterHT::maxnumberofeventsinrun
private

Definition at line 72 of file PythiaFilterHT.h.

double PythiaFilterHT::maxpcut
private

Definition at line 54 of file PythiaFilterHT.h.

double PythiaFilterHT::maxphicut
private

Definition at line 62 of file PythiaFilterHT.h.

double PythiaFilterHT::maxptcut
private

Definition at line 57 of file PythiaFilterHT.h.

double PythiaFilterHT::maxrapcut
private

Definition at line 61 of file PythiaFilterHT.h.

double PythiaFilterHT::minetacut
private

Definition at line 58 of file PythiaFilterHT.h.

double PythiaFilterHT::minhtcut
private

Definition at line 56 of file PythiaFilterHT.h.

Referenced by filter(), and PythiaFilterHT().

double PythiaFilterHT::minpcut
private

Definition at line 53 of file PythiaFilterHT.h.

double PythiaFilterHT::minphicut
private

Definition at line 63 of file PythiaFilterHT.h.

double PythiaFilterHT::minptcut
private

Definition at line 55 of file PythiaFilterHT.h.

double PythiaFilterHT::minrapcut
private

Definition at line 60 of file PythiaFilterHT.h.

int PythiaFilterHT::motherID
private

Definition at line 68 of file PythiaFilterHT.h.

Referenced by filter(), and PythiaFilterHT().

int PythiaFilterHT::particleID
private

Definition at line 52 of file PythiaFilterHT.h.

int PythiaFilterHT::processID
private

Definition at line 69 of file PythiaFilterHT.h.

double PythiaFilterHT::rapidity
private

Definition at line 65 of file PythiaFilterHT.h.

int PythiaFilterHT::status
private
int PythiaFilterHT::theNumberOfSelected
private

Definition at line 71 of file PythiaFilterHT.h.

Referenced by filter(), PythiaFilterHT(), and ~PythiaFilterHT().

int PythiaFilterHT::theNumberOfTestedEvt
private

Definition at line 70 of file PythiaFilterHT.h.

Referenced by filter(), PythiaFilterHT(), and ~PythiaFilterHT().