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 Types | Static Private Member Functions | Private Attributes
MCParticleReplacer Class Reference

#include <MCParticleReplacer.h>

Inheritance diagram for MCParticleReplacer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginJob ()
 
virtual void beginRun (edm::Run &, const edm::EventSetup &)
 
template<typename T >
void call_produces (const std::string &instanceName)
 
template<typename T >
void call_put (T &product, const std::string &instanceName)
 
virtual void endJob ()
 
virtual void endRun ()
 
edm::StreamID getStreamID () const
 
 MCParticleReplacer (const edm::ParameterSet &)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
 ~MCParticleReplacer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- 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 (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 Types

enum  HepMcMode { kInvalid = 0, kNew, kReplace }
 

Static Private Member Functions

static HepMcMode stringToHepMcMode (const std::string &name)
 

Private Attributes

edm::Eventevt_
 
HepMcMode hepMcMode_
 
ParticleReplacerBasereplacer_
 
edm::InputTag src_
 
edm::InputTag srcHepMC_
 
int verbosity_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer 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::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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

Replace muons reconstructed in selected Z –> mu+ mu- events by generator level particles, which will be passed to detector simulation & reconstruction modules to create "hybrid" events ("embedded" leptons from Monte Carlo simulation, rest of the event taken from data)

Per default, the reconstructed muons are replaced by generator level tau leptons, which are passed to TAUOLA in order to produce generator level tau decay products.

For systematic/background studies, it is possible also to:

Author
Manuel Zeise
Version
Revision:
1.3
Id:
MCParticleReplacer.h,v 1.3 2013/01/31 09:07:18 veelken Exp

Definition at line 35 of file MCParticleReplacer.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

MCParticleReplacer::MCParticleReplacer ( const edm::ParameterSet cfg)
explicit

Definition at line 19 of file MCParticleReplacer.cc.

References HLT_25ns14e33_v1_cff::algorithm, edm::ParameterSet::exists(), reco::get(), edm::ParameterSet::getParameter(), replacer_, AlCaHLTBitMon_QueryRunRegistry::string, and verbosity_.

20  : src_(cfg.getParameter<edm::InputTag>("src")),
21  srcHepMC_(cfg.getParameter<edm::InputTag>("hepMcSrc")),
23  replacer_(0),
24  evt_(0)
25 {
26  std::string algorithm = cfg.getParameter<std::string>("algorithm");
28  std::string pluginType = cfg.getParameter<std::string>("pluginType");
29  replacer_ = ParticleReplacerPluginFactory::get()->create(pluginType, cfgAlgorithm);
30 
31  verbosity_ = ( cfg.exists("verbosity") ) ?
32  cfg.getParameter<int>("verbosity") : 0;
33 
34  produces<edm::HepMCProduct>();
35  produces<GenFilterInfo>("minVisPtFilter");
36  replacer_->declareExtraProducts(this);
37 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
static HepMcMode stringToHepMcMode(const std::string &name)
edm::InputTag srcHepMC_
ParticleReplacerBase * replacer_
T get(const Candidate &c)
Definition: component.h:55
MCParticleReplacer::~MCParticleReplacer ( )

Definition at line 39 of file MCParticleReplacer.cc.

References replacer_.

40 {
41  delete replacer_;
42 }
ParticleReplacerBase * replacer_

Member Function Documentation

void MCParticleReplacer::beginJob ( void  )
virtual

Reimplemented from edm::EDProducer.

Definition at line 104 of file MCParticleReplacer.cc.

References ParticleReplacerBase::beginJob(), and replacer_.

105 {
106 
107  replacer_->beginJob();
108 }
ParticleReplacerBase * replacer_
void MCParticleReplacer::beginRun ( edm::Run run,
const edm::EventSetup es 
)
virtual

Definition at line 93 of file MCParticleReplacer.cc.

References ParticleReplacerBase::beginRun(), and replacer_.

94 {
95  replacer_->beginRun(run, es);
96 }
virtual void beginRun(edm::Run &run, const edm::EventSetup &es)
ParticleReplacerBase * replacer_
template<typename T >
void MCParticleReplacer::call_produces ( const std::string &  instanceName)
inline

Definition at line 48 of file MCParticleReplacer.h.

Referenced by ParticleReplacerZtautau::declareExtraProducts().

49  {
50  produces<T>(instanceName);
51  }
template<typename T >
void MCParticleReplacer::call_put ( T product,
const std::string &  instanceName 
)
inline

Definition at line 54 of file MCParticleReplacer.h.

References evt_, and edm::Event::put().

Referenced by ParticleReplacerZtautau::produce().

55  {
56  evt_->put(product, instanceName);
57  }
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:115
void MCParticleReplacer::endJob ( void  )
virtual

Reimplemented from edm::EDProducer.

Definition at line 111 of file MCParticleReplacer.cc.

References ParticleReplacerBase::endJob(), and replacer_.

112 {
113  replacer_->endJob();
114 }
ParticleReplacerBase * replacer_
void MCParticleReplacer::endRun ( void  )
virtual

Definition at line 98 of file MCParticleReplacer.cc.

References ParticleReplacerBase::endRun(), and replacer_.

99 {
100  replacer_->endRun();
101 }
ParticleReplacerBase * replacer_
edm::StreamID MCParticleReplacer::getStreamID ( ) const
inline

Definition at line 59 of file MCParticleReplacer.h.

References assert(), evt_, and edm::Event::streamID().

Referenced by ParticleReplacerZtautau::produce().

59 { assert(evt_ != nullptr); return evt_->streamID(); }
assert(m_qm.get())
StreamID streamID() const
Definition: Event.h:74
void MCParticleReplacer::produce ( edm::Event evt,
const edm::EventSetup es 
)
virtual

Implements edm::EDProducer.

Definition at line 53 of file MCParticleReplacer.cc.

References reco::Candidate::charge(), evt_, edm::hlt::Exception, edm::Event::getByLabel(), getSelMuons(), getTheMuMinus(), getTheMuPlus(), hepMcMode_, info(), edm::RefToBase< T >::isNonnull(), kNew, kReplace, patZpeak::muons, reco::Candidate::p4(), ParticleReplacerBase::passed_, ParticleReplacerBase::produce(), edm::Event::put(), replacer_, src_, srcHepMC_, AlCaHLTBitMon_QueryRunRegistry::string, ParticleReplacerBase::tried_, and reco::Candidate::vertex().

54 {
55  std::vector<reco::CandidateBaseRef> selMuons = getSelMuons(evt, src_);
56  const reco::CandidateBaseRef muPlus = getTheMuPlus(selMuons);
57  const reco::CandidateBaseRef muMinus = getTheMuMinus(selMuons);
58 
59  std::vector<reco::Particle> muons;
60  if ( muPlus.isNonnull() ) muons.push_back(reco::Particle(muPlus->charge(), muPlus->p4(), muPlus->vertex(), -15, 0, true));
61  if ( muMinus.isNonnull() ) muons.push_back(reco::Particle(muMinus->charge(), muMinus->p4(), muMinus->vertex(), +15, 0, true));
62 
63  if ( muons.size() == 0 ) {
64  edm::LogError("MCParticleReplacer")
65  << "No Z->mumu candidates or muons found !!" << std::endl;
66  return;
67  }
68 
69  evt_ = &evt;
70 
71  std::auto_ptr<HepMC::GenEvent> hepMC;
72  if ( hepMcMode_ == kReplace ) {
73  edm::Handle<edm::HepMCProduct> HepMCHandle;
74  evt.getByLabel(srcHepMC_, HepMCHandle);
75  hepMC = replacer_->produce(muons, 0, HepMCHandle->GetEvent(), this);
76  } else if( hepMcMode_ == kNew ) {
77  hepMC = replacer_->produce(muons, 0, 0, this);
78  } else
79  throw cms::Exception("LogicError")
80  << "Invalid hepMcMode " << hepMcMode_ << " !!" << std::endl;
81 
82  if ( hepMC.get() != 0 ) {
83  std::auto_ptr<edm::HepMCProduct> bare_product(new edm::HepMCProduct());
84  bare_product->addHepMCData(hepMC.release()); // transfer ownership of the HepMC:GenEvent to bare_product
85 
86  evt.put(bare_product);
87 
88  std::auto_ptr<GenFilterInfo> info(new GenFilterInfo(replacer_->tried_, replacer_->passed_));
89  evt.put(info, std::string("minVisPtFilter"));
90  }
91 }
reco::CandidateBaseRef getTheMuMinus(const std::vector< reco::CandidateBaseRef > &)
static const TGPicture * info(bool iBackgroundIsBlack)
bool isNonnull() const
Checks for non-null.
Definition: RefToBase.h:330
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:115
virtual std::auto_ptr< HepMC::GenEvent > produce(const std::vector< reco::Particle > &, const reco::Vertex *evtVtx=0, const HepMC::GenEvent *genEvt=0, MCParticleReplacer *=0)=0
virtual const Point & vertex() const =0
vertex position
edm::InputTag srcHepMC_
virtual int charge() const =0
electric charge
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:413
ParticleReplacerBase * replacer_
tuple muons
Definition: patZpeak.py:38
std::vector< reco::CandidateBaseRef > getSelMuons(const edm::Event &, const edm::InputTag &)
reco::CandidateBaseRef getTheMuPlus(const std::vector< reco::CandidateBaseRef > &)
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
MCParticleReplacer::HepMcMode MCParticleReplacer::stringToHepMcMode ( const std::string &  name)
staticprivate

Definition at line 44 of file MCParticleReplacer.cc.

References edm::hlt::Exception, kNew, and kReplace.

45 {
46  if ( name == "new" ) return kNew;
47  else if ( name == "replace" ) return kReplace;
48  else throw cms::Exception("Configuration")
49  << "Unsupported hepMcMode " << name << ": should be either 'new' or 'replace' !!\n" << std::endl;
50 }

Member Data Documentation

edm::Event* MCParticleReplacer::evt_
private

Definition at line 69 of file MCParticleReplacer.h.

Referenced by call_put(), getStreamID(), and produce().

HepMcMode MCParticleReplacer::hepMcMode_
private

Definition at line 67 of file MCParticleReplacer.h.

Referenced by produce().

ParticleReplacerBase* MCParticleReplacer::replacer_
private
edm::InputTag MCParticleReplacer::src_
private

Definition at line 65 of file MCParticleReplacer.h.

Referenced by produce().

edm::InputTag MCParticleReplacer::srcHepMC_
private

Definition at line 66 of file MCParticleReplacer.h.

Referenced by produce().

int MCParticleReplacer::verbosity_
private

Definition at line 71 of file MCParticleReplacer.h.

Referenced by MCParticleReplacer().