CMS 3D CMS Logo

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

#include <MCZll.h>

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

Public Member Functions

void endJob () override
 
bool filter (edm::Event &, const edm::EventSetup &) override
 
 MCZll (const edm::ParameterSet &)
 
 ~MCZll () 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

bool filter_
 
double leptonEtaMax_
 
double leptonEtaMin_
 
int leptonFlavour_
 
double leptonPtMax_
 
double leptonPtMin_
 
unsigned int nAccepted_
 
unsigned int nEvents_
 
edm::EDGetTokenT< edm::HepMCProducttoken_
 
std::pair< double, double > zMassRange_
 

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::ProducerBase
ProducesCollector producesCollector ()
 
- 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

Definition at line 39 of file MCZll.h.

Constructor & Destructor Documentation

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

Definition at line 12 of file MCZll.cc.

References filter_, edm::ParameterSet::getUntrackedParameter(), leptonEtaMax_, leptonEtaMin_, leptonFlavour_, leptonPtMax_, leptonPtMin_, str, and zMassRange_.

13  : token_(consumes<edm::HepMCProduct>(
14  edm::InputTag(iConfig.getUntrackedParameter("moduleLabel", std::string("generator")), "unsmeared"))),
15  nEvents_(0),
16  nAccepted_(0) {
17  leptonFlavour_ = iConfig.getUntrackedParameter<int>("leptonFlavour", 11);
18  leptonPtMin_ = iConfig.getUntrackedParameter<double>("leptonPtMin", 5.);
19  leptonPtMax_ = iConfig.getUntrackedParameter<double>("leptonPtMax", 99999.);
20  leptonEtaMin_ = iConfig.getUntrackedParameter<double>("leptonEtaMin", 0.);
21  leptonEtaMax_ = iConfig.getUntrackedParameter<double>("leptonEtaMax", 2.7);
22  zMassRange_.first = iConfig.getUntrackedParameter<double>("zMassMin", 60.);
23  zMassRange_.second = iConfig.getUntrackedParameter<double>("zMassMax", 120.);
24  filter_ = iConfig.getUntrackedParameter<bool>("filter", true);
25  std::ostringstream str;
26  str << "=========================================================\n"
27  << "Filter MCZll being constructed with parameters: "
28  << "\nleptonFlavour " << leptonFlavour_ << "\nleptonPtMin " << leptonPtMin_ << "\nleptonPtMax " << leptonPtMax_
29  << "\nleptonEtaMin " << leptonEtaMin_ << "\nleptonEtaMax " << leptonEtaMax_ << "\nzMassMin " << zMassRange_.first
30  << "\nzMassMax " << zMassRange_.second << "\n=========================================================";
31  edm::LogVerbatim("MCZllInfo") << str.str();
32  if (filter_)
33  produces<HepMCProduct>();
34 }
edm::EDGetTokenT< edm::HepMCProduct > token_
Definition: MCZll.h:49
T getUntrackedParameter(std::string const &, T const &) const
bool filter_
Definition: MCZll.h:58
double leptonPtMin_
Definition: MCZll.h:51
double leptonEtaMin_
Definition: MCZll.h:53
int leptonFlavour_
Definition: MCZll.h:50
double leptonEtaMax_
Definition: MCZll.h:54
double leptonPtMax_
Definition: MCZll.h:52
std::pair< double, double > zMassRange_
Definition: MCZll.h:55
unsigned int nEvents_
Definition: MCZll.h:56
unsigned int nAccepted_
Definition: MCZll.h:57
#define str(s)
MCZll::~MCZll ( )
override

Definition at line 36 of file MCZll.cc.

36  {
37  // do anything here that needs to be done at desctruction time
38  // (e.g. close files, deallocate resources etc.)
39 }

Member Function Documentation

void MCZll::endJob ( void  )
overridevirtual

Reimplemented from edm::EDFilter.

Definition at line 41 of file MCZll.cc.

References nAccepted_, and nEvents_.

41  {
42  edm::LogVerbatim("MCZllInfo") << "================MCZll report========================================\n"
43  << "Events read " << nEvents_ << " Events accepted " << nAccepted_ << "\nEfficiency "
44  << ((double)nAccepted_) / ((double)nEvents_)
45  << "\n===================================================================="
46  << std::endl;
47 }
unsigned int nEvents_
Definition: MCZll.h:56
unsigned int nAccepted_
Definition: MCZll.h:57
bool MCZll::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 50 of file MCZll.cc.

References funct::abs(), cms::dd::accepted(), class-composition::children, edm::EventID::event(), filter_, GenParticle::GenParticle, edm::Event::getByToken(), edm::HepMCProduct::GetEvent(), GenLeadTrackFilter_cfi::HepMCProduct, edm::EventBase::id(), leptonEtaMax_, leptonEtaMin_, leptonFlavour_, leptonPtMax_, leptonPtMin_, LogDebug, eostools::move(), nAccepted_, nEvents_, AlCaHLTBitMon_ParallelJobs::p, edm::Event::put(), token_, zMassRange_, and HLT_FULL_cff::zVertex.

50  {
51  std::unique_ptr<HepMCProduct> bare_product(new HepMCProduct());
52 
53  nEvents_++;
54  using namespace edm;
55  bool accepted = false;
57  iEvent.getByToken(token_, evt);
58  HepMC::GenEvent* myGenEvent = new HepMC::GenEvent(*(evt->GetEvent()));
59  HepMC::GenEvent* zEvent = new HepMC::GenEvent();
60 
61  if (myGenEvent->signal_process_id() != 1) {
62  delete myGenEvent;
63  delete zEvent;
64  return false;
65  }
66 
67  //found a prompt Z
68 
69  for (HepMC::GenEvent::particle_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end(); ++p) {
70  if (!accepted && ((*p)->pdg_id() == 23) && (*p)->status() == 3) {
71  accepted = true;
72  HepMC::GenVertex* zVertex = new HepMC::GenVertex();
73  HepMC::GenParticle* myZ = new HepMC::GenParticle(*(*p));
74  zVertex->add_particle_in(myZ);
75  // std::cout << (*p)->momentum().invariantMass() << std::endl;
76  if ((*p)->momentum().m() < zMassRange_.first || (*p)->momentum().m() > zMassRange_.second)
77  accepted = false;
78  std::vector<HepMC::GenParticle*> children;
79  HepMC::GenVertex* outVertex = (*p)->end_vertex();
80  for (HepMC::GenVertex::particles_out_const_iterator iter = outVertex->particles_out_const_begin();
81  iter != outVertex->particles_out_const_end();
82  iter++)
83  children.push_back(*iter);
84  std::vector<HepMC::GenParticle*>::const_iterator aDaughter;
85  for (aDaughter = children.begin(); aDaughter != children.end(); aDaughter++) {
86  HepMC::GenParticle* myDa = new HepMC::GenParticle(*(*aDaughter));
87  zVertex->add_particle_out(myDa);
88  if ((*aDaughter)->status() == 2)
89  continue;
90  // (*aDaughter)->print();
91 
92  if (!(abs((*aDaughter)->pdg_id()) == abs(leptonFlavour_)))
93  accepted = false;
94  // std::cout << (*aDaughter)->momentum().perp() << " " << (*aDaughter)->momentum().eta() << std::endl;
95  if ((*aDaughter)->momentum().perp() < leptonPtMin_)
96  accepted = false;
97  if ((*aDaughter)->momentum().perp() > leptonPtMax_)
98  accepted = false;
99  if (fabs((*aDaughter)->momentum().eta()) > leptonEtaMax_)
100  accepted = false;
101  if (fabs((*aDaughter)->momentum().eta()) < leptonEtaMin_)
102  accepted = false;
103  }
104  zEvent->add_vertex(zVertex);
105  if (accepted)
106  break;
107  }
108  }
109 
110  if (accepted) {
111  if (zEvent)
112  bare_product->addHepMCData(zEvent);
113  if (filter_)
114  iEvent.put(std::move(bare_product));
115  nAccepted_++;
116  // std::cout << "+++++++++++++++++++++++++++++++++++++++++++++++++"<< std::endl;
117  LogDebug("MCZll") << "Event " << iEvent.id().event() << " accepted" << std::endl;
118  // std::cout << "+++++++++++++++++++++++++++++++++++++++++++++++++"<< std::endl;
119  // myGenEvent->print();
120  delete myGenEvent;
121  return true;
122  }
123 
124  delete myGenEvent;
125  delete zEvent;
126  return false;
127 }
#define LogDebug(id)
edm::EDGetTokenT< edm::HepMCProduct > token_
Definition: MCZll.h:49
EventNumber_t event() const
Definition: EventID.h:40
bool filter_
Definition: MCZll.h:58
double leptonPtMin_
Definition: MCZll.h:51
double leptonEtaMin_
Definition: MCZll.h:53
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
int leptonFlavour_
Definition: MCZll.h:50
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
double leptonEtaMax_
Definition: MCZll.h:54
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double leptonPtMax_
Definition: MCZll.h:52
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:34
bool accepted(std::vector< std::string_view > const &, std::string_view)
std::pair< double, double > zMassRange_
Definition: MCZll.h:55
unsigned int nEvents_
Definition: MCZll.h:56
edm::EventID id() const
Definition: EventBase.h:59
HLT enums.
unsigned int nAccepted_
Definition: MCZll.h:57
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

bool MCZll::filter_
private

Definition at line 58 of file MCZll.h.

Referenced by filter(), and MCZll().

double MCZll::leptonEtaMax_
private

Definition at line 54 of file MCZll.h.

Referenced by filter(), and MCZll().

double MCZll::leptonEtaMin_
private

Definition at line 53 of file MCZll.h.

Referenced by filter(), and MCZll().

int MCZll::leptonFlavour_
private

Definition at line 50 of file MCZll.h.

Referenced by filter(), and MCZll().

double MCZll::leptonPtMax_
private

Definition at line 52 of file MCZll.h.

Referenced by filter(), and MCZll().

double MCZll::leptonPtMin_
private

Definition at line 51 of file MCZll.h.

Referenced by filter(), and MCZll().

unsigned int MCZll::nAccepted_
private

Definition at line 57 of file MCZll.h.

Referenced by endJob(), and filter().

unsigned int MCZll::nEvents_
private

Definition at line 56 of file MCZll.h.

Referenced by endJob(), and filter().

edm::EDGetTokenT<edm::HepMCProduct> MCZll::token_
private

Definition at line 49 of file MCZll.h.

Referenced by filter().

std::pair<double, double> MCZll::zMassRange_
private

Definition at line 55 of file MCZll.h.

Referenced by filter(), and MCZll().