188 std::set<unsigned int> whiteList;
189 std::set<reco::TrackRef> whiteListTk;
192 iEvent.getByToken(itoken, svWhiteListHandle);
194 for (
unsigned int i = 0;
i < svWhiteList.
size();
i++) {
196 for (
unsigned int j = 0;
j < svWhiteList[
i].numberOfSourceCandidatePtrs();
j++) {
199 whiteList.insert(
c.key());
202 for (
auto dau = svWhiteList[
i].begin(); dau != svWhiteList[
i].
end(); dau++) {
204 if (chCand !=
nullptr) {
205 whiteListTk.insert(chCand->
track());
224 std::vector<pat::HcalDepthEnergyFractions> hcalDepthEnergyFractions;
225 hcalDepthEnergyFractions.reserve(
cands->size());
226 std::vector<pat::HcalDepthEnergyFractions> hcalDepthEnergyFractions_Ordered;
227 hcalDepthEnergyFractions_Ordered.reserve(
cands->size());
231 auto outPtrP = std::make_unique<std::vector<pat::PackedCandidate>>();
233 std::vector<int> mappingReverse(
cands->size());
234 std::vector<int> mappingTk(TKOrigs->size(), -1);
236 for (
unsigned int ic = 0, nc =
cands->size(); ic < nc; ++ic) {
239 if ((
abs(
cand.pdgId()) == 11 ||
cand.pdgId() == 22) &&
cand.gsfTrackRef().isNonnull()) {
240 ctrack = &*
cand.gsfTrackRef();
241 }
else if (
cand.trackRef().isNonnull()) {
242 ctrack = &*
cand.trackRef();
247 for (
size_t ii = 0;
ii < PVs->size();
ii++) {
270 float ptTrk = ctrack->
pt();
271 float etaAtVtx = ctrack->
eta();
272 float phiAtVtx = ctrack->
phi();
287 if (
cand.trackRef().isNonnull() && PVOrig.
isNonnull() && PVOrig->trackWeight(
cand.trackRef()) > 0.5 &&
292 outPtrP->back().setLostInnerHits(
lostHits);
294 whiteList.find(ic) != whiteList.end() ||
295 (
cand.trackRef().isNonnull() && whiteListTk.find(
cand.trackRef()) != whiteListTk.end())) {
297 if (
abs(outPtrP->back().pdgId()) == 22) {
301 outPtrP->back().setTrackProperties(*ctrack,
312 outPtrP->back().setTrackProperties(*ctrack,
316 outPtrP->back().setTrackProperties(*ctrack,
323 outPtrP->back().setTrackHighPurity(
cand.trackRef().isNonnull() &&
325 if (
cand.muonRef().isNonnull()) {
326 outPtrP->back().setMuonID(
cand.muonRef()->isStandAloneMuon(),
cand.muonRef()->isGlobalMuon());
331 PVpos =
PV->position();
336 outPtrP->back().setAssociationQuality(
342 bool isIsolatedChargedHadron =
false;
345 isIsolatedChargedHadron =
347 outPtrP->back().setIsIsolatedChargedHadron(isIsolatedChargedHadron);
351 outPtrP->back().setHcalFraction(
cand.hcalEnergy() / (
cand.ecalEnergy() +
cand.hcalEnergy()));
352 }
else if ((
cand.charge() ||
abs(
cand.pdgId()) == 22) &&
cand.pt() > 0.5) {
353 outPtrP->back().setHcalFraction(
cand.hcalEnergy() / (
cand.ecalEnergy() +
cand.hcalEnergy()));
354 outPtrP->back().setCaloFraction((
cand.hcalEnergy() +
cand.ecalEnergy()) /
cand.energy());
356 outPtrP->back().setHcalFraction(0);
357 outPtrP->back().setCaloFraction(0);
360 if (isIsolatedChargedHadron) {
361 outPtrP->back().setRawCaloFraction((
cand.rawEcalEnergy() +
cand.rawHcalEnergy()) /
cand.energy());
362 outPtrP->back().setRawHcalFraction(
cand.rawHcalEnergy() / (
cand.rawEcalEnergy() +
cand.rawHcalEnergy()));
364 outPtrP->back().setRawCaloFraction(0);
365 outPtrP->back().setRawHcalFraction(0);
368 std::vector<float> dummyVector;
376 fabs(outPtrP->back().eta()) > 1.3) {
379 std::vector<float> hcalDepthEnergyFractionTmp(
cand.hcalDepthEnergyFractions().begin(),
380 cand.hcalDepthEnergyFractions().end());
381 hcalDepthEFrac.reset(hcalDepthEnergyFractionTmp);
384 hcalDepthEnergyFractions.push_back(hcalDepthEFrac);
390 outPtrP->back().setGoodEgamma();
396 float puppiWeightVal = (*puppiWeight)[pkref];
397 float puppiWeightNoLepVal = (*puppiWeightNoLep)[pkref];
398 outPtrP->back().setPuppiWeight(puppiWeightVal, puppiWeightNoLepVal);
403 if (
cand.trackRef().isNonnull()) {
404 auto t0 = (*t0Map)[
cand.trackRef()];
405 auto t0Err = (*t0ErrMap)[
cand.trackRef()];
406 outPtrP->back().setTime(
t0, t0Err);
409 if (
cand.isTimeValid()) {
410 outPtrP->back().setTime(
cand.time(),
cand.timeError());
416 if (
cand.trackRef().isNonnull() &&
cand.trackRef().id() == TKOrigs.
id()) {
417 mappingTk[
cand.trackRef().key()] = ic;
421 auto outPtrPSorted = std::make_unique<std::vector<pat::PackedCandidate>>();
423 std::vector<size_t> reverseOrder(
order.size());
424 for (
size_t i = 0, nc =
cands->size();
i < nc;
i++) {
425 outPtrPSorted->push_back((*outPtrP)[
order[
i]]);
428 hcalDepthEnergyFractions_Ordered.push_back(hcalDepthEnergyFractions[
order[
i]]);
432 for (
size_t i = 0, ntk = mappingTk.size();
i < ntk;
i++) {
433 if (mappingTk[
i] >= 0)
434 mappingTk[
i] = reverseOrder[mappingTk[
i]];
440 auto pf2pc = std::make_unique<edm::Association<pat::PackedCandidateCollection>>(oh);
441 auto pc2pf = std::make_unique<edm::Association<reco::PFCandidateCollection>>(
cands);
444 pf2pcFiller.insert(
cands, mappingReverse.begin(), mappingReverse.end());
445 pc2pfFiller.insert(oh,
order.begin(),
order.end());
447 pf2pcFiller.insert(TKOrigs, mappingTk.begin(), mappingTk.end());
455 auto hcalDepthEnergyFractionsV = std::make_unique<edm::ValueMap<HcalDepthEnergyFractions>>();
457 fillerHcalDepthEnergyFractions.insert(
458 cands, hcalDepthEnergyFractions_Ordered.begin(), hcalDepthEnergyFractions_Ordered.end());
459 fillerHcalDepthEnergyFractions.fill();
462 iEvent.put(
std::move(hcalDepthEnergyFractionsV),
"hcalDepthEnergyFractions");