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 Member Functions | Private Attributes
ZmumuPFEmbedder Class Reference

#include <MyAna/ZmumuPFEmbedder/src/ZmumuPFEmbedder.cc>

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

Public Member Functions

 ZmumuPFEmbedder (const edm::ParameterSet &)
 
 ~ZmumuPFEmbedder ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- 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
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
void producePFCandColl (edm::Event &, const std::vector< reco::Particle::LorentzVector > *toBeAdded)
 
void produceTrackColl (edm::Event &, const std::vector< reco::Particle::LorentzVector > *toBeAdded)
 

Private Attributes

edm::InputTag _selectedMuons
 
edm::InputTag _tracks
 
bool _useCombinedCandidate
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- 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::EDProducer
CurrentProcessingContext const * currentContext () const
 
- 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

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 50 of file ZmumuPFEmbedder.cc.

Constructor & Destructor Documentation

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

Definition at line 81 of file ZmumuPFEmbedder.cc.

82  : _tracks(iConfig.getParameter<edm::InputTag>("tracks")),
83  _selectedMuons(iConfig.getParameter<edm::InputTag>("selectedMuons")),
84  _useCombinedCandidate(iConfig.getUntrackedParameter<bool>("useCombinedCandidate", false))
85 {
86 
87  //register your products
88  // produces< std::vector< reco::Muon > >("zMusExtracted"); //
89  produces<reco::TrackCollection>("tracks");
90  produces< std::vector< reco::PFCandidate > >("pfCands");
91 
92 
93 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::InputTag _tracks
edm::InputTag _selectedMuons
ZmumuPFEmbedder::~ZmumuPFEmbedder ( )

Definition at line 95 of file ZmumuPFEmbedder.cc.

96 {
97 
98  // do anything here that needs to be done at desctruction time
99  // (e.g. close files, deallocate resources etc.)
100 
101 }

Member Function Documentation

void ZmumuPFEmbedder::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 213 of file ZmumuPFEmbedder.cc.

214 {
215 }
void ZmumuPFEmbedder::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 219 of file ZmumuPFEmbedder.cc.

219  {
220 }
void ZmumuPFEmbedder::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 110 of file ZmumuPFEmbedder.cc.

References _selectedMuons, _useCombinedCandidate, edm::Event::getByLabel(), customizeTrackingMonitorSeedNumber::idx, producePFCandColl(), and produceTrackColl().

111 {
112  std::vector< reco::Particle::LorentzVector > toBeAdded;
113 
115  {
117  if (iEvent.getByLabel(_selectedMuons, combCandidatesHandle) && combCandidatesHandle->size()>0)
118  for (size_t idx = 0; idx < combCandidatesHandle->at(0).numberOfDaughters(); ++idx) // use only the first combined candidate
119  toBeAdded.push_back(combCandidatesHandle->at(0).daughter(idx)->p4());
120  }
121  else
122  {
123  edm::Handle< edm::View< reco::Muon > > selectedZMuonsHandle;
124  if (iEvent.getByLabel(_selectedMuons, selectedZMuonsHandle))
125  for (size_t idx = 0; idx < selectedZMuonsHandle->size(); ++idx)
126  toBeAdded.push_back(selectedZMuonsHandle->at(idx).p4());
127  }
128 
129  if (toBeAdded.size() == 0)
130  return;
131 
132  producePFCandColl(iEvent, &toBeAdded);
133  produceTrackColl(iEvent, &toBeAdded);
134 }
void produceTrackColl(edm::Event &, const std::vector< reco::Particle::LorentzVector > *toBeAdded)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
void producePFCandColl(edm::Event &, const std::vector< reco::Particle::LorentzVector > *toBeAdded)
edm::InputTag _selectedMuons
void ZmumuPFEmbedder::producePFCandColl ( edm::Event iEvent,
const std::vector< reco::Particle::LorentzVector > *  toBeAdded 
)
private

Definition at line 137 of file ZmumuPFEmbedder.cc.

References abs, reco::deltaR(), edm::Event::getByLabel(), and edm::Event::put().

Referenced by produce().

138 {
140  iEvent.getByLabel("particleFlow",pfIn);
141 
142  //std::vector< reco::Muon > toBeAdded;
143  // TODO - check col size
144  //reco::Muon l1 = *(toBeAdded->begin());
145  //reco::Muon l2 = *(toBeAdded->rbegin());
146 
147  std::auto_ptr<std::vector< reco::PFCandidate > > newCol(new std::vector< reco::PFCandidate > );
148 
149  //get selected muons
150  // iterate over pfcandidates, make copy if its not a selected muon
151  reco::PFCandidateConstIterator it = pfIn->begin();
152  reco::PFCandidateConstIterator itE = pfIn->end();
153 
154  for (;it!=itE;++it) {
155  int pdg = std::abs( it->pdgId() );
156  double minDR = 10;
157  /*
158  double dr1 = reco::deltaR( *it, l1);
159  double dr2 = reco::deltaR( *it, l2);
160  */
161  std::vector< reco::Particle::LorentzVector >::const_iterator itSelectedMu = toBeAdded->begin();
162  std::vector< reco::Particle::LorentzVector >::const_iterator itSelectedMuE = toBeAdded->end();
163  for (; itSelectedMu != itSelectedMuE; ++itSelectedMu ){
164  double dr = reco::deltaR( *it, *itSelectedMu);
165  if (dr < minDR) minDR = dr;
166  }
167 
168  //if ( pdg == 13 && (dr1 < 0.001 || dr2 < 0.002 ) ) { // it is a selected muon, do not copy
169  if ( pdg == 13 && (minDR < 0.001 ) ) { // it is a selected muon, do not copy
170 
171 
172  } else {
173  newCol->push_back(*it);
174  }
175  }
176 
177  iEvent.put(newCol, "pfCands");
178 }
#define abs(x)
Definition: mlp_lapack.h:159
PFCandidateCollection::const_iterator PFCandidateConstIterator
iterator
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
void ZmumuPFEmbedder::produceTrackColl ( edm::Event iEvent,
const std::vector< reco::Particle::LorentzVector > *  toBeAdded 
)
private

Definition at line 181 of file ZmumuPFEmbedder.cc.

References _tracks, gather_cfg::cout, reco::deltaR(), epsilon, edm::Event::getByLabel(), convertSQLiteXML::ok, and edm::Event::put().

Referenced by produce().

182 {
184  iEvent.getByLabel( _tracks, tks);
185 
186  std::auto_ptr< reco::TrackCollection > newCol(new reco::TrackCollection );
187 
188  double epsilon = 0.00001;
189  unsigned int nMatched = 0;
190 
191  for ( reco::TrackCollection::const_iterator it = tks->begin() ; it != tks->end(); ++it)
192  {
193  bool ok = true;
194  for ( std::vector< reco::Particle::LorentzVector >::const_iterator itTBA = toBeAdded->begin();
195  itTBA != toBeAdded->end();
196  ++itTBA)
197  {
198  double dr = reco::deltaR( *it, *itTBA);
199  //std::cout << "TTTT " << dr << std::endl;
200  if (dr < epsilon) {
201  ++ nMatched;
202  ok = false;
203  }
204  }
205  if (ok) newCol->push_back(*it);
206  }
207  if (nMatched!=toBeAdded->size() ) std::cout << "TTT ARGGGHGH " << nMatched << std::endl;
208 
209  iEvent.put(newCol, "tracks");
210 }
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
edm::InputTag _tracks
tuple cout
Definition: gather_cfg.py:121
const double epsilon

Member Data Documentation

edm::InputTag ZmumuPFEmbedder::_selectedMuons
private

Definition at line 63 of file ZmumuPFEmbedder.cc.

Referenced by produce().

edm::InputTag ZmumuPFEmbedder::_tracks
private

Definition at line 62 of file ZmumuPFEmbedder.cc.

Referenced by produceTrackColl().

bool ZmumuPFEmbedder::_useCombinedCandidate
private

Definition at line 64 of file ZmumuPFEmbedder.cc.

Referenced by produce().