test
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
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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 (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &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_
 
double leptonEtaMax_
 
double leptonEtaMin_
 
int leptonFlavour_
 
double leptonPtMax_
 
double leptonPtMin_
 
unsigned int nAccepted_
 
unsigned int nEvents_
 
edm::EDGetTokenT
< edm::HepMCProduct
token_
 
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
 
- 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 &)
 
- 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 41 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  token_(consumes<edm::HepMCProduct>(edm::InputTag(iConfig.getUntrackedParameter("moduleLabel",std::string("generator")),"unsmeared"))),
15  nEvents_(0),
16  nAccepted_(0)
17 {
18  leptonFlavour_ = iConfig.getUntrackedParameter<int>("leptonFlavour",11);
19  leptonPtMin_ = iConfig.getUntrackedParameter<double>("leptonPtMin",5.);
20  leptonPtMax_ = iConfig.getUntrackedParameter<double>("leptonPtMax",99999.);
21  leptonEtaMin_ = iConfig.getUntrackedParameter<double>("leptonEtaMin",0.);
22  leptonEtaMax_ = iConfig.getUntrackedParameter<double>("leptonEtaMax",2.7);
23  zMassRange_.first = iConfig.getUntrackedParameter<double>("zMassMin",60.);
24  zMassRange_.second = iConfig.getUntrackedParameter<double>("zMassMax",120.);
25  filter_ = iConfig.getUntrackedParameter<bool>("filter",true);
26  std::ostringstream str;
27  str << "=========================================================\n"
28  << "Filter MCZll being constructed with parameters: "
29  << "\nleptonFlavour " << leptonFlavour_
30  << "\nleptonPtMin " << leptonPtMin_
31  << "\nleptonPtMax " << leptonPtMax_
32  << "\nleptonEtaMin " << leptonEtaMin_
33  << "\nleptonEtaMax " << leptonEtaMax_
34  << "\nzMassMin " << zMassRange_.first
35  << "\nzMassMax " << zMassRange_.second
36  << "\n=========================================================" ;
37  edm::LogVerbatim("MCZllInfo") << str.str() ;
38  if (filter_)
39  produces<HepMCProduct>();
40 }
edm::EDGetTokenT< edm::HepMCProduct > token_
Definition: MCZll.h:50
T getUntrackedParameter(std::string const &, T const &) const
bool filter_
Definition: MCZll.h:59
double leptonPtMin_
Definition: MCZll.h:52
double leptonEtaMin_
Definition: MCZll.h:54
int leptonFlavour_
Definition: MCZll.h:51
double leptonEtaMax_
Definition: MCZll.h:55
double leptonPtMax_
Definition: MCZll.h:53
unsigned int nEvents_
Definition: MCZll.h:57
unsigned int nAccepted_
Definition: MCZll.h:58
std::pair< double, double > zMassRange_
Definition: MCZll.h:56
MCZll::~MCZll ( )

Definition at line 43 of file MCZll.cc.

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

Member Function Documentation

void MCZll::endJob ( void  )
virtual

Reimplemented from edm::EDFilter.

Definition at line 51 of file MCZll.cc.

References nAccepted_, and nEvents_.

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

Implements edm::EDFilter.

Definition at line 59 of file MCZll.cc.

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

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

Member Data Documentation

bool MCZll::filter_
private

Definition at line 59 of file MCZll.h.

Referenced by filter(), and MCZll().

double MCZll::leptonEtaMax_
private

Definition at line 55 of file MCZll.h.

Referenced by filter(), and MCZll().

double MCZll::leptonEtaMin_
private

Definition at line 54 of file MCZll.h.

Referenced by filter(), and MCZll().

int MCZll::leptonFlavour_
private

Definition at line 51 of file MCZll.h.

Referenced by filter(), and MCZll().

double MCZll::leptonPtMax_
private

Definition at line 53 of file MCZll.h.

Referenced by filter(), and MCZll().

double MCZll::leptonPtMin_
private

Definition at line 52 of file MCZll.h.

Referenced by filter(), and MCZll().

unsigned int MCZll::nAccepted_
private

Definition at line 58 of file MCZll.h.

Referenced by endJob(), and filter().

unsigned int MCZll::nEvents_
private

Definition at line 57 of file MCZll.h.

Referenced by endJob(), and filter().

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

Definition at line 50 of file MCZll.h.

Referenced by filter().

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

Definition at line 56 of file MCZll.h.

Referenced by filter(), and MCZll().