186 std::set<unsigned int> whiteList;
187 std::set<reco::TrackRef> whiteListTk;
190 iEvent.getByToken(itoken, svWhiteListHandle);
192 for (
unsigned int i = 0;
i < svWhiteList.
size();
i++) {
194 for (
unsigned int j = 0;
j < svWhiteList[
i].numberOfSourceCandidatePtrs();
j++) {
197 whiteList.insert(
c.key());
200 for (
auto dau = svWhiteList[
i].
begin(); dau != svWhiteList[
i].
end(); dau++) {
202 if (chCand !=
nullptr) {
203 whiteListTk.insert(chCand->
track());
222 std::vector<pat::HcalDepthEnergyFractions> hcalDepthEnergyFractions;
223 hcalDepthEnergyFractions.reserve(
cands->size());
224 std::vector<pat::HcalDepthEnergyFractions> hcalDepthEnergyFractions_Ordered;
225 hcalDepthEnergyFractions_Ordered.reserve(
cands->size());
229 auto outPtrP = std::make_unique<std::vector<pat::PackedCandidate>>();
231 std::vector<int> mappingReverse(
cands->size());
232 std::vector<int> mappingTk(TKOrigs->size(), -1);
234 for (
unsigned int ic = 0, nc =
cands->size(); ic < nc; ++ic) {
237 if ((
abs(
cand.pdgId()) == 11 ||
cand.pdgId() == 22) &&
cand.gsfTrackRef().isNonnull()) {
238 ctrack = &*
cand.gsfTrackRef();
239 }
else if (
cand.trackRef().isNonnull()) {
240 ctrack = &*
cand.trackRef();
245 for (
size_t ii = 0;
ii < PVs->size();
ii++) {
268 float ptTrk = ctrack->
pt();
269 float etaAtVtx = ctrack->
eta();
270 float phiAtVtx = ctrack->
phi();
285 if (
cand.trackRef().isNonnull() && PVOrig.
isNonnull() && PVOrig->trackWeight(
cand.trackRef()) > 0.5 &&
290 outPtrP->back().setLostInnerHits(
lostHits);
292 whiteList.find(ic) != whiteList.end() ||
293 (
cand.trackRef().isNonnull() && whiteListTk.find(
cand.trackRef()) != whiteListTk.end())) {
295 if (
abs(outPtrP->back().pdgId()) == 22) {
299 outPtrP->back().setTrackProperties(*ctrack,
308 if (outPtrP->back().pt() > 0.5) {
310 outPtrP->back().setTrackProperties(*ctrack,
314 outPtrP->back().setTrackProperties(*ctrack,
321 outPtrP->back().setTrackHighPurity(
cand.trackRef().isNonnull() &&
323 if (
cand.muonRef().isNonnull()) {
324 outPtrP->back().setMuonID(
cand.muonRef()->isStandAloneMuon(),
cand.muonRef()->isGlobalMuon());
329 PVpos =
PV->position();
334 outPtrP->back().setAssociationQuality(
340 bool isIsolatedChargedHadron =
false;
343 isIsolatedChargedHadron =
345 outPtrP->back().setIsIsolatedChargedHadron(isIsolatedChargedHadron);
349 outPtrP->back().setHcalFraction(
cand.hcalEnergy() / (
cand.ecalEnergy() +
cand.hcalEnergy()));
350 }
else if (
cand.charge() &&
cand.pt() > 0.5) {
351 outPtrP->back().setHcalFraction(
cand.hcalEnergy() / (
cand.ecalEnergy() +
cand.hcalEnergy()));
352 outPtrP->back().setCaloFraction((
cand.hcalEnergy() +
cand.ecalEnergy()) /
cand.energy());
354 outPtrP->back().setHcalFraction(0);
355 outPtrP->back().setCaloFraction(0);
358 if (isIsolatedChargedHadron) {
359 outPtrP->back().setRawCaloFraction((
cand.rawEcalEnergy() +
cand.rawHcalEnergy()) /
cand.energy());
360 outPtrP->back().setRawHcalFraction(
cand.rawHcalEnergy() / (
cand.rawEcalEnergy() +
cand.rawHcalEnergy()));
362 outPtrP->back().setRawCaloFraction(0);
363 outPtrP->back().setRawHcalFraction(0);
366 std::vector<float> dummyVector;
374 fabs(outPtrP->back().eta()) > 1.3) {
377 std::vector<float> hcalDepthEnergyFractionTmp(
cand.hcalDepthEnergyFractions().begin(),
378 cand.hcalDepthEnergyFractions().end());
379 hcalDepthEFrac.reset(hcalDepthEnergyFractionTmp);
382 hcalDepthEnergyFractions.push_back(hcalDepthEFrac);
388 outPtrP->back().setGoodEgamma();
394 float puppiWeightVal = (*puppiWeight)[pkref];
395 float puppiWeightNoLepVal = (*puppiWeightNoLep)[pkref];
396 outPtrP->back().setPuppiWeight(puppiWeightVal, puppiWeightNoLepVal);
401 if (
cand.trackRef().isNonnull()) {
402 auto t0 = (*t0Map)[
cand.trackRef()];
403 auto t0Err = (*t0ErrMap)[
cand.trackRef()];
404 outPtrP->back().setTime(
t0, t0Err);
407 if (
cand.isTimeValid()) {
408 outPtrP->back().setTime(
cand.time(),
cand.timeError());
414 if (
cand.trackRef().isNonnull() &&
cand.trackRef().id() == TKOrigs.
id()) {
415 mappingTk[
cand.trackRef().key()] = ic;
419 auto outPtrPSorted = std::make_unique<std::vector<pat::PackedCandidate>>();
421 std::vector<size_t> reverseOrder(
order.size());
422 for (
size_t i = 0, nc =
cands->size();
i < nc;
i++) {
423 outPtrPSorted->push_back((*outPtrP)[
order[
i]]);
426 hcalDepthEnergyFractions_Ordered.push_back(hcalDepthEnergyFractions[
order[
i]]);
430 for (
size_t i = 0, ntk = mappingTk.size();
i < ntk;
i++) {
431 if (mappingTk[
i] >= 0)
432 mappingTk[
i] = reverseOrder[mappingTk[
i]];
438 auto pf2pc = std::make_unique<edm::Association<pat::PackedCandidateCollection>>(oh);
439 auto pc2pf = std::make_unique<edm::Association<reco::PFCandidateCollection>>(
cands);
442 pf2pcFiller.insert(
cands, mappingReverse.begin(), mappingReverse.end());
443 pc2pfFiller.insert(oh,
order.begin(),
order.end());
445 pf2pcFiller.insert(TKOrigs, mappingTk.begin(), mappingTk.end());
453 auto hcalDepthEnergyFractionsV = std::make_unique<edm::ValueMap<HcalDepthEnergyFractions>>();
455 fillerHcalDepthEnergyFractions.insert(
456 cands, hcalDepthEnergyFractions_Ordered.begin(), hcalDepthEnergyFractions_Ordered.end());
457 fillerHcalDepthEnergyFractions.fill();
460 iEvent.put(
std::move(hcalDepthEnergyFractionsV),
"hcalDepthEnergyFractions");