CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

virtual void endJob ()
 
virtual bool filter (edm::Event &, const edm::EventSetup &)
 
 MCZll (const edm::ParameterSet &)
 
 ~MCZll ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

bool filter_
 
std::string label_
 
double leptonEtaMax_
 
double leptonEtaMin_
 
int leptonFlavour_
 
double leptonPtMax_
 
double leptonPtMin_
 
unsigned int nAccepted_
 
unsigned int nEvents_
 
std::pair< double, double > zMassRange_
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 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 38 of file MCZll.h.

Constructor & Destructor Documentation

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

Definition at line 13 of file MCZll.cc.

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

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

Definition at line 41 of file MCZll.cc.

42 {
43 
44  // do anything here that needs to be done at desctruction time
45  // (e.g. close files, deallocate resources etc.)
46 
47 }

Member Function Documentation

void MCZll::endJob ( void  )
virtual

Reimplemented from edm::EDFilter.

Definition at line 49 of file MCZll.cc.

References nAccepted_, and nEvents_.

50 {
51  edm::LogVerbatim("MCZllInfo") << "================MCZll report========================================\n"
52  << "Events read " << nEvents_ << " Events accepted " << nAccepted_ << "\nEfficiency " << ((double)nAccepted_)/((double)nEvents_)
53  << "\n====================================================================" << std::endl;
54 }
unsigned int nEvents_
Definition: MCZll.h:54
unsigned int nAccepted_
Definition: MCZll.h:55
bool MCZll::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDFilter.

Definition at line 57 of file MCZll.cc.

References funct::abs(), edm::EventID::event(), filter_, GenParticle::GenParticle, edm::Event::getByLabel(), edm::EventBase::id(), getDQMSummary::iter, label_, leptonEtaMax_, leptonEtaMin_, leptonFlavour_, leptonPtMax_, leptonPtMin_, LogDebug, nAccepted_, nEvents_, AlCaHLTBitMon_ParallelJobs::p, edm::Event::put(), and zMassRange_.

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

Member Data Documentation

bool MCZll::filter_
private

Definition at line 56 of file MCZll.h.

Referenced by filter(), and MCZll().

std::string MCZll::label_
private
double MCZll::leptonEtaMax_
private

Definition at line 52 of file MCZll.h.

Referenced by filter(), and MCZll().

double MCZll::leptonEtaMin_
private

Definition at line 51 of file MCZll.h.

Referenced by filter(), and MCZll().

int MCZll::leptonFlavour_
private

Definition at line 48 of file MCZll.h.

Referenced by filter(), and MCZll().

double MCZll::leptonPtMax_
private

Definition at line 50 of file MCZll.h.

Referenced by filter(), and MCZll().

double MCZll::leptonPtMin_
private

Definition at line 49 of file MCZll.h.

Referenced by filter(), and MCZll().

unsigned int MCZll::nAccepted_
private

Definition at line 55 of file MCZll.h.

Referenced by endJob(), and filter().

unsigned int MCZll::nEvents_
private

Definition at line 54 of file MCZll.h.

Referenced by endJob(), and filter().

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

Definition at line 53 of file MCZll.h.

Referenced by filter(), and MCZll().