86 _col1(iConfig.getUntrackedParameter<edm::
InputTag>(
"col1") ),
87 _col2(iConfig.getUntrackedParameter<edm::
InputTag>(
"col2") ),
88 _trackCol(iConfig.getUntrackedParameter<edm::
InputTag>(
"trackCol") ),
89 _muonCol(iConfig.getUntrackedParameter<edm::
InputTag>(
"muons") ),
90 _electronCol(iConfig.getUntrackedParameter<edm::
InputTag>(
"gsfElectrons"))
92 produces< std::vector< reco::PFCandidate > >();
129 throw cms::Exception(
"PFCandidateMixer") <<
"Muon Collection not found!";
132 throw cms::Exception(
"PFCandidateMixer") <<
"GsfElectron Collection not found!";
139 mix(iEvent, trackCol, muonCol, electronCol, *pfIn1, *pfIn2);
145 using namespace reco;
147 std::vector<const reco::PFCandidateCollection*> colVec;
149 colVec.push_back(&pfIn1);
150 colVec.push_back(&pfIn2);
152 std::auto_ptr<std::vector< reco::PFCandidate > > pOut(
new std::vector< reco::PFCandidate > );
154 std::vector<const reco::PFCandidateCollection*>::iterator itCol= colVec.begin();
155 std::vector<const reco::PFCandidateCollection*>::iterator itColE= colVec.end();
157 std::map<reco::GsfElectronRef, reco::PFCandidatePtr> electronCandidateMap;
160 for (;itCol!=itColE; ++itCol){
163 for (;it!=itE;++it) {
173 if (electronCol.
isValid() && iselectron) {
176 std::vector<reco::GsfElectron>::const_iterator itcheck=find_if(electronCol->begin(), electronCol->end(), myEqual);
177 if(itcheck==electronCol->end())
178 throw cms::Exception(
"PFCandidateMixer") <<
"GsfElectron for candidate not found!";
181 cand.setGsfElectronRef(electronRef);
182 cand.setSuperClusterRef(electronRef->superCluster());
183 electronCandidateMap[electronRef] = candPtr;
191 double minDR = 9999.;
193 if (it->trackRef().isNonnull()) {
194 for ( i = 0 ; i < trackCol->size(); ++
i){
195 if (
reco::deltaR( *(it->trackRef()), (*trackCol)[
i] )<0.001 ) {
199 double dr =
reco::deltaR( *(it->trackRef()), (*trackCol)[
i] );
208 cand.setTrackRef(trref);
212 if (it->trackRef().isNonnull()) {
213 std::cout <<
" XXXXXXXXXXX track not found "
215 <<
" ch " << it->charge()
216 <<
" id " << it->pdgId()
217 <<
" pt " << it->pt()
218 <<
" track: eta " << it->trackRef()->eta()
219 <<
" pt: " << it->trackRef()->pt()
220 <<
" charge: " << it->trackRef()->charge()
222 std::cout <<
" minDR=" << minDR << std::endl;
225 <<
" closest track pt=" << (*trackCol)[iMinDr].pt()
226 <<
" ch=" << (*trackCol)[iMinDr].charge()
231 std::cout <<
" trackref in PFCand came from: " <<
tag.encode() << std::endl;
234 pOut->push_back(cand);
244 std::vector<reco::PFCandidatePtr>
values(electronCol->size());
245 for(
unsigned int i = 0;
i < electronCol->size(); ++
i)
248 std::map<reco::GsfElectronRef, reco::PFCandidatePtr>::const_iterator iter = electronCandidateMap.find(objRef);
251 if(iter != electronCandidateMap.end())
260 iEvent.
put(pfMap_p,
"electrons");
#define DEFINE_FWK_MODULE(type)
edm::InputTag _electronCol
void insert(const H &h, I begin, I end)
double deltaR(const T1 &t1, const T2 &t2)
virtual void produce(edm::Event &, const edm::EventSetup &)
PFCandidateCollection::const_iterator PFCandidateConstIterator
iterator
std::string const & processName() const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
TypeLabelItem const & produces()
declare what type of product will make and with which optional label
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
std::string const & moduleLabel() const
Particle reconstructed by the particle flow algorithm.
PFCandidateMixer(const edm::ParameterSet &)
std::string const & productInstanceName() const
Provenance getProvenance(BranchID const &theID) const
void mix(edm::Event &iEvent, const edm::Handle< reco::TrackCollection > &trackCol, const edm::Handle< reco::MuonCollection > &muonCol, const edm::Handle< reco::GsfElectronCollection > &electronCol, const reco::PFCandidateCollection &pfIn1, const reco::PFCandidateCollection &pfIn2)