CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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
 
 EDFilter (const EDFilter &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDFilteroperator= (const EDFilter &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
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)
 
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 ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

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.

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

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 }
Log< level::Info, true > LogVerbatim
bool filter_
Definition: MCZll.cc:50
double leptonPtMin_
Definition: MCZll.cc:45
double leptonEtaMin_
Definition: MCZll.cc:47
int leptonFlavour_
Definition: MCZll.cc:44
double leptonEtaMax_
Definition: MCZll.cc:48
const edm::EDGetTokenT< edm::HepMCProduct > token_
Definition: MCZll.cc:43
T getUntrackedParameter(std::string const &, T const &) const
double leptonPtMax_
Definition: MCZll.cc:46
std::pair< double, double > zMassRange_
Definition: MCZll.cc:49
#define str(s)

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.

References funct::abs(), 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_, and zMassRange_.

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 }
bool filter_
Definition: MCZll.cc:50
double leptonPtMin_
Definition: MCZll.cc:45
double leptonEtaMin_
Definition: MCZll.cc:47
int leptonFlavour_
Definition: MCZll.cc:44
double leptonEtaMax_
Definition: MCZll.cc:48
const edm::EDGetTokenT< edm::HepMCProduct > token_
Definition: MCZll.cc:43
int iEvent
Definition: GenABIO.cc:224
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double leptonPtMax_
Definition: MCZll.cc:46
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:37
std::pair< double, double > zMassRange_
Definition: MCZll.cc:49
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)

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().