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
PFCandidateMixer Class Reference

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

Inheritance diagram for PFCandidateMixer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 PFCandidateMixer (const edm::ParameterSet &)
 
 ~PFCandidateMixer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 

Private Attributes

edm::InputTag _col1
 
edm::InputTag _col2
 
edm::InputTag _trackCol
 

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
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

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

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

Definition at line 45 of file PFCandidateMixer.cc.

Constructor & Destructor Documentation

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

Definition at line 73 of file PFCandidateMixer.cc.

73  :
74  _col1(iConfig.getUntrackedParameter<edm::InputTag>("col1") ),
75  _col2(iConfig.getUntrackedParameter<edm::InputTag>("col2") ),
76  _trackCol(iConfig.getUntrackedParameter<edm::InputTag>("trackCol") )
77 {
78 
79  produces< std::vector< reco::PFCandidate > >();
80 
81 }
T getUntrackedParameter(std::string const &, T const &) const
edm::InputTag _col2
edm::InputTag _col1
edm::InputTag _trackCol
PFCandidateMixer::~PFCandidateMixer ( )

Definition at line 83 of file PFCandidateMixer.cc.

84 {
85 
86  // do anything here that needs to be done at desctruction time
87  // (e.g. close files, deallocate resources etc.)
88 
89 }

Member Function Documentation

void PFCandidateMixer::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 190 of file PFCandidateMixer.cc.

191 {
192 }
void PFCandidateMixer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 196 of file PFCandidateMixer.cc.

196  {
197 }
void PFCandidateMixer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 98 of file PFCandidateMixer.cc.

References _col1, _col2, _trackCol, gather_cfg::cout, reco::deltaR(), newFWLiteAna::found, edm::Event::getByLabel(), edm::Event::getProvenance(), i, edm::Provenance::moduleLabel(), edm::Provenance::processName(), edm::Provenance::productInstanceName(), edm::Event::put(), dt_dqm_sourceclient_common_cff::reco, reco::PFCandidate::setTrackRef(), and GlobalPosition_Frontier_DevDB_cff::tag.

99 {
100  using namespace edm;
101  using namespace reco;
102 
104  iEvent.getByLabel( _trackCol, trackCol);
105 
106 
107  std::vector< Handle<PFCandidateCollection> > colVec;
110  iEvent.getByLabel(_col1,pfIn1);
111  iEvent.getByLabel(_col2,pfIn2);
112 
113  colVec.push_back(pfIn1);
114  colVec.push_back(pfIn2);
115 
116  std::auto_ptr<std::vector< reco::PFCandidate > > pOut(new std::vector< reco::PFCandidate > );
117 
118  std::vector< Handle<PFCandidateCollection> >::iterator itCol= colVec.begin();
119  std::vector< Handle<PFCandidateCollection> >::iterator itColE= colVec.end();
120 
121  int iCol = 0;
122  for (;itCol!=itColE; ++itCol){
123  if (!itCol->isValid()) {
124  std::cout << "Whoops!" << std::endl;
125  }
126  PFCandidateConstIterator it = (*itCol)->begin();
127  PFCandidateConstIterator itE = (*itCol)->end();
128  for (;it!=itE;++it) {
129  PFCandidate cand(*it);
130  size_t i = 0;
131  bool found = false;
132  double minDR = 9999.;
133  int iMinDr = -1;
134  if (it->trackRef().isNonnull()) {
135  for ( i = 0 ; i < trackCol->size(); ++i){
136  if ( reco::deltaR( *(it->trackRef()), trackCol->at(i) )<0.001 ) {
137  found = true;
138  break;
139  }
140  double dr = reco::deltaR( *(it->trackRef()), trackCol->at(i) );
141  if ( dr < minDR) {
142  iMinDr = i;
143  minDR = dr;
144  }
145  }
146  }
147  if ( found ){ // ref was found, overwrite in PFCand
148  reco::TrackRef trref(trackCol,i);
149  cand.setTrackRef(trref);
150  //std::cout << " YY track ok"<<std::endl;
151 
152  } else { // keep orginall ref
153  if (it->trackRef().isNonnull()) {
154  std::cout << " XXXXXXXXXXX track not found "
155  << " col " << iCol
156  << " ch " << it->charge()
157  << " id " << it->pdgId()
158  << " pt " << it->pt()
159  << " track: eta " << it->trackRef()->eta()
160  << " pt: " << it->trackRef()->pt()
161  << " charge: " << it->trackRef()->charge()
162  << std::endl;
163  std::cout << " minDR=" << minDR << std::endl;
164  if ( iMinDr >= 0 ) {
165  std::cout
166  << " closest track pt=" << trackCol->at(iMinDr).pt()
167  << " ch=" << trackCol->at(iMinDr).charge()
168  << std::endl;
169  }
170  edm::Provenance prov=iEvent.getProvenance(it->trackRef().id());
172  std::cout << " trackref in PFCand came from: " << tag.encode() << std::endl;
173 
174 
175  }
176  }
177  pOut->push_back(cand);
178  }
179  ++iCol;
180  }
181 
182 
183  iEvent.put(pOut);
184 
185 
186 }
int i
Definition: DBlmapReader.cc:9
PFCandidateCollection::const_iterator PFCandidateConstIterator
iterator
std::string const & processName() const
Definition: Provenance.h:63
edm::InputTag _col2
double deltaR(double eta1, double phi1, double eta2, double phi2)
Definition: deltaR.h:19
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
edm::InputTag _col1
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
std::string const & moduleLabel() const
Definition: Provenance.h:62
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:33
edm::InputTag _trackCol
tuple cout
Definition: gather_cfg.py:121
std::string const & productInstanceName() const
Definition: Provenance.h:64
Provenance getProvenance(BranchID const &theID) const
Definition: Event.cc:60

Member Data Documentation

edm::InputTag PFCandidateMixer::_col1
private

Definition at line 55 of file PFCandidateMixer.cc.

Referenced by produce().

edm::InputTag PFCandidateMixer::_col2
private

Definition at line 56 of file PFCandidateMixer.cc.

Referenced by produce().

edm::InputTag PFCandidateMixer::_trackCol
private

Definition at line 57 of file PFCandidateMixer.cc.

Referenced by produce().