#include <MyAna/PFCandidateMixer/src/PFCandidateMixer.cc>
Public Member Functions | |
PFCandidateMixer (const edm::ParameterSet &) | |
~PFCandidateMixer () | |
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 |
Description: <one line="" class="" summary>="">
Implementation: <Notes on="" implementation>="">
Definition at line 45 of file PFCandidateMixer.cc.
PFCandidateMixer::PFCandidateMixer | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 73 of file PFCandidateMixer.cc.
: _col1(iConfig.getUntrackedParameter<edm::InputTag>("col1") ), _col2(iConfig.getUntrackedParameter<edm::InputTag>("col2") ), _trackCol(iConfig.getUntrackedParameter<edm::InputTag>("trackCol") ) { produces< std::vector< reco::PFCandidate > >(); }
PFCandidateMixer::~PFCandidateMixer | ( | ) |
Definition at line 83 of file PFCandidateMixer.cc.
{ // do anything here that needs to be done at desctruction time // (e.g. close files, deallocate resources etc.) }
void PFCandidateMixer::beginJob | ( | void | ) | [private, virtual] |
void PFCandidateMixer::endJob | ( | void | ) | [private, virtual] |
void PFCandidateMixer::produce | ( | edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
Implements edm::EDProducer.
Definition at line 98 of file PFCandidateMixer.cc.
References _col1, _col2, _trackCol, gather_cfg::cout, reco::deltaR(), 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.
{ using namespace edm; using namespace reco; Handle< std::vector<reco::Track> > trackCol; iEvent.getByLabel( _trackCol, trackCol); std::vector< Handle<PFCandidateCollection> > colVec; Handle<PFCandidateCollection> pfIn1; Handle<PFCandidateCollection> pfIn2; iEvent.getByLabel(_col1,pfIn1); iEvent.getByLabel(_col2,pfIn2); colVec.push_back(pfIn1); colVec.push_back(pfIn2); std::auto_ptr<std::vector< reco::PFCandidate > > pOut(new std::vector< reco::PFCandidate > ); std::vector< Handle<PFCandidateCollection> >::iterator itCol= colVec.begin(); std::vector< Handle<PFCandidateCollection> >::iterator itColE= colVec.end(); int iCol = 0; for (;itCol!=itColE; ++itCol){ if (!itCol->isValid()) { std::cout << "Whoops!" << std::endl; } PFCandidateConstIterator it = (*itCol)->begin(); PFCandidateConstIterator itE = (*itCol)->end(); for (;it!=itE;++it) { PFCandidate cand(*it); size_t i = 0; bool found = false; double minDR = 9999.; int iMinDr = -1; if (it->trackRef().isNonnull()) { for ( i = 0 ; i < trackCol->size(); ++i){ if ( reco::deltaR( *(it->trackRef()), trackCol->at(i) )<0.001 ) { found = true; break; } double dr = reco::deltaR( *(it->trackRef()), trackCol->at(i) ); if ( dr < minDR) { iMinDr = i; minDR = dr; } } } if ( found ){ // ref was found, overwrite in PFCand reco::TrackRef trref(trackCol,i); cand.setTrackRef(trref); //std::cout << " YY track ok"<<std::endl; } else { // keep orginall ref if (it->trackRef().isNonnull()) { std::cout << " XXXXXXXXXXX track not found " << " col " << iCol << " ch " << it->charge() << " id " << it->pdgId() << " pt " << it->pt() << " track: eta " << it->trackRef()->eta() << " pt: " << it->trackRef()->pt() << " charge: " << it->trackRef()->charge() << std::endl; std::cout << " minDR=" << minDR << std::endl; if ( iMinDr >= 0 ) { std::cout << " closest track pt=" << trackCol->at(iMinDr).pt() << " ch=" << trackCol->at(iMinDr).charge() << std::endl; } edm::Provenance prov=iEvent.getProvenance(it->trackRef().id()); edm::InputTag tag(prov.moduleLabel(), prov.productInstanceName(), prov.processName()); std::cout << " trackref in PFCand came from: " << tag.encode() << std::endl; } } pOut->push_back(cand); } ++iCol; } iEvent.put(pOut); }
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().