CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
MCZll Class Reference
Inheritance diagram for MCZll:
edm::global::EDFilter<> edm::global::EDFilterBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

bool filter (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 
 MCZll (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::global::EDFilter<>
 EDFilter ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDFilterBase
 EDFilterBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDFilterBase () 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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
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_
 
const edm::EDGetTokenT< edm::HepMCProducttoken_
 
std::pair< double, double > zMassRange_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDFilterBase
typedef EDFilterBase 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::global::EDFilterBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (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)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 36 of file MCZll.cc.

Constructor & Destructor Documentation

◆ MCZll()

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

Definition at line 56 of file MCZll.cc.

57  : token_(consumes<edm::HepMCProduct>(
58  edm::InputTag(iConfig.getUntrackedParameter("moduleLabel", std::string("generator")), "unsmeared"))) {
59  leptonFlavour_ = iConfig.getUntrackedParameter<int>("leptonFlavour", 11);
60  leptonPtMin_ = iConfig.getUntrackedParameter<double>("leptonPtMin", 5.);
61  leptonPtMax_ = iConfig.getUntrackedParameter<double>("leptonPtMax", 99999.);
62  leptonEtaMin_ = iConfig.getUntrackedParameter<double>("leptonEtaMin", 0.);
63  leptonEtaMax_ = iConfig.getUntrackedParameter<double>("leptonEtaMax", 2.7);
64  zMassRange_.first = iConfig.getUntrackedParameter<double>("zMassMin", 60.);
65  zMassRange_.second = iConfig.getUntrackedParameter<double>("zMassMax", 120.);
66  filter_ = iConfig.getUntrackedParameter<bool>("filter", true);
67  std::ostringstream str;
68  str << "=========================================================\n"
69  << "Filter MCZll being constructed with parameters: "
70  << "\nleptonFlavour " << leptonFlavour_ << "\nleptonPtMin " << leptonPtMin_ << "\nleptonPtMax " << leptonPtMax_
71  << "\nleptonEtaMin " << leptonEtaMin_ << "\nleptonEtaMax " << leptonEtaMax_ << "\nzMassMin " << zMassRange_.first
72  << "\nzMassMax " << zMassRange_.second << "\n=========================================================";
73  edm::LogVerbatim("MCZllInfo") << str.str();
74  if (filter_)
75  produces<HepMCProduct>();
76 }

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

Member Function Documentation

◆ filter()

bool MCZll::filter ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup  
) const
overridevirtual

Implements edm::global::EDFilterBase.

Definition at line 78 of file MCZll.cc.

78  {
79  std::unique_ptr<HepMCProduct> bare_product(new HepMCProduct());
80 
81  bool accepted = false;
83  iEvent.getByToken(token_, evt);
84  HepMC::GenEvent* myGenEvent = new HepMC::GenEvent(*(evt->GetEvent()));
85  HepMC::GenEvent* zEvent = new HepMC::GenEvent();
86 
87  if (myGenEvent->signal_process_id() != 1) {
88  delete myGenEvent;
89  delete zEvent;
90  return false;
91  }
92 
93  //found a prompt Z
94 
95  for (HepMC::GenEvent::particle_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end(); ++p) {
96  if (!accepted && ((*p)->pdg_id() == 23) && (*p)->status() == 3) {
97  accepted = true;
98  HepMC::GenVertex* zVertex = new HepMC::GenVertex();
99  HepMC::GenParticle* myZ = new HepMC::GenParticle(*(*p));
100  zVertex->add_particle_in(myZ);
101  // std::cout << (*p)->momentum().invariantMass() << std::endl;
102  if ((*p)->momentum().m() < zMassRange_.first || (*p)->momentum().m() > zMassRange_.second)
103  accepted = false;
104  std::vector<HepMC::GenParticle*> children;
105  HepMC::GenVertex* outVertex = (*p)->end_vertex();
106  for (HepMC::GenVertex::particles_out_const_iterator iter = outVertex->particles_out_const_begin();
107  iter != outVertex->particles_out_const_end();
108  iter++)
109  children.push_back(*iter);
110  std::vector<HepMC::GenParticle*>::const_iterator aDaughter;
111  for (aDaughter = children.begin(); aDaughter != children.end(); aDaughter++) {
112  HepMC::GenParticle* myDa = new HepMC::GenParticle(*(*aDaughter));
113  zVertex->add_particle_out(myDa);
114  if ((*aDaughter)->status() == 2)
115  continue;
116  // (*aDaughter)->print();
117 
118  if (!(abs((*aDaughter)->pdg_id()) == abs(leptonFlavour_)))
119  accepted = false;
120  // std::cout << (*aDaughter)->momentum().perp() << " " << (*aDaughter)->momentum().eta() << std::endl;
121  if ((*aDaughter)->momentum().perp() < leptonPtMin_)
122  accepted = false;
123  if ((*aDaughter)->momentum().perp() > leptonPtMax_)
124  accepted = false;
125  if (fabs((*aDaughter)->momentum().eta()) > leptonEtaMax_)
126  accepted = false;
127  if (fabs((*aDaughter)->momentum().eta()) < leptonEtaMin_)
128  accepted = false;
129  }
130  zEvent->add_vertex(zVertex);
131  if (accepted)
132  break;
133  }
134  }
135 
136  if (accepted) {
137  if (zEvent)
138  bare_product->addHepMCData(zEvent);
139  if (filter_)
140  iEvent.put(std::move(bare_product));
141  LogDebug("MCZll") << "Event " << iEvent.id().event() << " accepted" << std::endl;
142  delete myGenEvent;
143  return true;
144  }
145 
146  delete myGenEvent;
147  delete zEvent;
148  return false;
149 }

References funct::abs(), cms::dd::accepted(), class-composition::children, filter_, GenParticle::GenParticle, edm::HepMCProduct::GetEvent(), ZgammaFilter_cfi::HepMCProduct, iEvent, leptonEtaMax_, leptonEtaMin_, leptonFlavour_, leptonPtMax_, leptonPtMin_, LogDebug, eostools::move(), AlCaHLTBitMon_ParallelJobs::p, token_, zMassRange_, and HLT_FULL_cff::zVertex.

Member Data Documentation

◆ filter_

bool MCZll::filter_
private

Definition at line 50 of file MCZll.cc.

Referenced by filter(), and MCZll().

◆ leptonEtaMax_

double MCZll::leptonEtaMax_
private

Definition at line 48 of file MCZll.cc.

Referenced by filter(), and MCZll().

◆ leptonEtaMin_

double MCZll::leptonEtaMin_
private

Definition at line 47 of file MCZll.cc.

Referenced by filter(), and MCZll().

◆ leptonFlavour_

int MCZll::leptonFlavour_
private

Definition at line 44 of file MCZll.cc.

Referenced by filter(), and MCZll().

◆ leptonPtMax_

double MCZll::leptonPtMax_
private

Definition at line 46 of file MCZll.cc.

Referenced by filter(), and MCZll().

◆ leptonPtMin_

double MCZll::leptonPtMin_
private

Definition at line 45 of file MCZll.cc.

Referenced by filter(), and MCZll().

◆ token_

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

Definition at line 43 of file MCZll.cc.

Referenced by filter().

◆ zMassRange_

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

Definition at line 49 of file MCZll.cc.

Referenced by filter(), and MCZll().

MCZll::leptonEtaMax_
double leptonEtaMax_
Definition: MCZll.cc:48
MCZll::token_
const edm::EDGetTokenT< edm::HepMCProduct > token_
Definition: MCZll.cc:43
class-composition.children
children
Definition: class-composition.py:88
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
ZgammaFilter_cfi.HepMCProduct
HepMCProduct
Definition: ZgammaFilter_cfi.py:9
MCZll::leptonEtaMin_
double leptonEtaMin_
Definition: MCZll.cc:47
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::Handle
Definition: AssociativeIterator.h:50
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
MCZll::filter_
bool filter_
Definition: MCZll.cc:50
HLT_FULL_cff.zVertex
zVertex
Definition: HLT_FULL_cff.py:109725
MCZll::leptonPtMax_
double leptonPtMax_
Definition: MCZll.cc:46
cms::dd::accepted
bool accepted(std::vector< std::regex > const &, std::string_view)
str
#define str(s)
Definition: TestProcessor.cc:48
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::LogVerbatim
Definition: MessageLogger.h:297
edm::HepMCProduct::GetEvent
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:34
GenParticle.GenParticle
GenParticle
Definition: GenParticle.py:18
eostools.move
def move(src, dest)
Definition: eostools.py:511
MCZll::leptonPtMin_
double leptonPtMin_
Definition: MCZll.cc:45
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::InputTag
Definition: InputTag.h:15
MCZll::leptonFlavour_
int leptonFlavour_
Definition: MCZll.cc:44
MCZll::zMassRange_
std::pair< double, double > zMassRange_
Definition: MCZll.cc:49