211 std::vector<reco::CandidatePtr> puppiCandsNoLepPtrs;
218 for (
auto pup : *puppiCandsNoLep) {
219 puppiCandsNoLepPtrs.push_back(pup.sourceCandidatePtr(0));
222 std::vector<int> mappingPuppi(
usePuppi_ ? puppiCands->size() : 0);
239 std::set<unsigned int> whiteList;
240 std::set<reco::TrackRef> whiteListTk;
245 *(svWhiteListHandle.
product());
246 for (
unsigned int i = 0;
i < svWhiteList.
size();
i++) {
248 for (
unsigned int j = 0; j < svWhiteList[
i].numberOfSourceCandidatePtrs();
251 svWhiteList[
i].sourceCandidatePtr(j);
252 if (c.
id() == cands.
id())
253 whiteList.insert(c.
key());
256 for (
auto dau = svWhiteList[
i].
begin(); dau != svWhiteList[
i].
end();
260 if (chCand !=
nullptr) {
261 whiteListTk.insert(chCand->
track());
273 std::vector<pat::HcalDepthEnergyFractions> hcalDepthEnergyFractions;
274 hcalDepthEnergyFractions.reserve(cands->size());
275 std::vector<pat::HcalDepthEnergyFractions> hcalDepthEnergyFractions_Ordered;
276 hcalDepthEnergyFractions_Ordered.reserve(cands->size());
280 auto outPtrP = std::make_unique<std::vector<pat::PackedCandidate>>();
281 std::vector<int>
mapping(cands->size());
282 std::vector<int> mappingReverse(cands->size());
283 std::vector<int> mappingTk(TKOrigs->size(), -1);
285 for (
unsigned int ic = 0, nc = cands->size(); ic < nc; ++ic) {
297 for (
size_t ii = 0;
ii < PVs->size();
ii++) {
324 float ptTrk = ctrack->
pt();
325 float etaAtVtx = ctrack->
eta();
326 float phiAtVtx = ctrack->
phi();
341 etaAtVtx, phiAtVtx, cand.
pdgId(),
342 PVRefProd,
PV.key()));
343 outPtrP->back().setAssociationQuality(
347 PVOrig->trackWeight(cand.
trackRef()) > 0.5 && quality == 7) {
348 outPtrP->back().setAssociationQuality(
352 outPtrP->back().setLostInnerHits(lostHits);
355 whiteList.find(ic) != whiteList.end() ||
357 whiteListTk.find(cand.
trackRef()) != whiteListTk.end())) {
360 if (
abs(outPtrP->back().pdgId()) == 22) {
361 outPtrP->back().setTrackProperties(
365 outPtrP->back().setTrackProperties(
369 outPtrP->back().setTrackProperties(
375 if (outPtrP->back().pt() > 0.5) {
377 outPtrP->back().setTrackProperties(
381 outPtrP->back().setTrackProperties(
388 outPtrP->back().setTrackHighPurity(
392 outPtrP->back().setMuonID(cand.
muonRef()->isStandAloneMuon(),
393 cand.
muonRef()->isGlobalMuon());
398 PVpos =
PV->position();
403 cand.
phi(), cand.
pdgId(), PVRefProd,
PV.key()));
404 outPtrP->back().setAssociationQuality(
411 bool isIsolatedChargedHadron =
false;
414 *(chargedHadronIsolationHandle.
product());
415 isIsolatedChargedHadron =
418 outPtrP->back().setIsIsolatedChargedHadron(isIsolatedChargedHadron);
422 outPtrP->back().setHcalFraction(cand.
hcalEnergy() /
425 outPtrP->back().setHcalFraction(cand.
hcalEnergy() /
430 outPtrP->back().setHcalFraction(0);
431 outPtrP->back().setCaloFraction(0);
434 if (isIsolatedChargedHadron) {
435 outPtrP->back().setRawCaloFraction(
437 outPtrP->back().setRawHcalFraction(
440 outPtrP->back().setRawCaloFraction(0);
441 outPtrP->back().setRawHcalFraction(0);
444 std::vector<float> dummyVector;
453 fabs(outPtrP->back().eta()) >
457 std::vector<float> hcalDepthEnergyFractionTmp(
460 hcalDepthEFrac.reset(hcalDepthEnergyFractionTmp);
463 hcalDepthEnergyFractions.push_back(hcalDepthEFrac);
470 outPtrP->back().setGoodEgamma();
477 float puppiWeightVal = (*puppiWeight)[pkref];
478 float puppiWeightNoLepVal = 0.0;
482 if (puppiWeightNoLep.
isValid()) {
484 auto pkrefPtr = pkref->sourceCandidatePtr(0);
486 bool foundNoLep =
false;
487 for (
size_t ipcnl = 0; ipcnl < puppiCandsNoLepPtrs.size(); ipcnl++) {
488 if (puppiCandsNoLepPtrs[ipcnl] == pkrefPtr) {
490 puppiWeightNoLepVal =
491 puppiCandsNoLep->at(ipcnl).pt() /
496 if (!foundNoLep || puppiWeightNoLepVal > 1) {
497 puppiWeightNoLepVal = 1.0;
500 outPtrP->back().setPuppiWeight(puppiWeightVal, puppiWeightNoLepVal);
502 mappingPuppi[((*puppiCandsMap)[pkref]).
key()] = ic;
515 auto outPtrPSorted = std::make_unique<std::vector<pat::PackedCandidate>>();
517 std::vector<size_t> reverseOrder(order.size());
518 for (
size_t i = 0, nc = cands->size();
i < nc;
i++) {
519 outPtrPSorted->push_back((*outPtrP)[order[
i]]);
520 reverseOrder[order[
i]] =
i;
521 mappingReverse[order[
i]] =
i;
522 hcalDepthEnergyFractions_Ordered.push_back(
523 hcalDepthEnergyFractions[order[i]]);
527 for (
size_t i = 0, ntk = mappingTk.size(); i < ntk; i++) {
528 if (mappingTk[i] >= 0)
529 mappingTk[
i] = reverseOrder[mappingTk[
i]];
532 for (
size_t i = 0, ntk = mappingPuppi.size(); i < ntk; i++) {
533 mappingPuppi[
i] = reverseOrder[mappingPuppi[
i]];
541 std::make_unique<edm::Association<pat::PackedCandidateCollection>>(oh);
543 std::make_unique<edm::Association<reco::PFCandidateCollection>>(
cands);
546 pf2pcFiller.insert(cands, mappingReverse.begin(), mappingReverse.end());
547 pc2pfFiller.insert(oh, order.begin(), order.end());
549 pf2pcFiller.insert(TKOrigs, mappingTk.begin(), mappingTk.end());
551 pf2pcFiller.insert(puppiCands, mappingPuppi.begin(), mappingPuppi.end());
559 auto hcalDepthEnergyFractionsV =
560 std::make_unique<edm::ValueMap<HcalDepthEnergyFractions>>();
562 fillerHcalDepthEnergyFractions(*hcalDepthEnergyFractionsV);
563 fillerHcalDepthEnergyFractions.insert(
564 cands, hcalDepthEnergyFractions_Ordered.begin(),
565 hcalDepthEnergyFractions_Ordered.end());
566 fillerHcalDepthEnergyFractions.fill();
570 "hcalDepthEnergyFractions");
double ecalEnergy() const
return corrected Ecal energy
int pdgId() const final
PDG identifier.
const Point & referencePoint() const
Reference point on the track.
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool isNonnull() const
Checks for non-null.
double eta() const final
momentum pseudorapidity
const PolarLorentzVector & polarP4() const final
four-momentum Lorentz vector
double rawEcalEnergy() const
return corrected Ecal energy
bool hasValidHitInPixelLayer(enum PixelSubdetector::SubDetector, uint16_t layer) const
const edm::EDGetTokenT< std::vector< reco::PFCandidate > > PuppiCandsNoLep_
float mva_nothing_gamma() const
mva for gamma detection
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const std::array< float, 7 > & hcalDepthEnergyFractions() const
fraction of hcal energy at a given depth (index 0..6 for depth 1..7)
double phi() const
azimuthal angle of momentum vector
double pt() const final
transverse momentum
int charge() const final
electric charge
static const int qualityMap[8]
conversion map from quality flags used in PV association and miniAOD one
const edm::EDGetTokenT< reco::PFCandidateCollection > Cands_
key_type key() const
Accessor for product key.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
ProductID id() const
Accessor for product ID.
const edm::EDGetTokenT< edm::ValueMap< int > > PVAssoQuality_
const edm::EDGetTokenT< edm::ValueMap< float > > PuppiWeightNoLep_
reco::TrackRef trackRef() const
const double minPtForTrackProperties_
const Point & vertex() const override
vertex position (overwritten by PF...)
bool isTimeValid() const
do we have a valid time information
double eta() const
pseudorapidity of momentum vector
double pt() const
track transverse momentum
const bool storePfGammaEnFr_
double energy() const final
energy
Abs< T >::type abs(const T &t)
const bool storeChargedHadronIsolation_
const edm::EDGetTokenT< std::vector< reco::PFCandidate > > PuppiCands_
reco::TrackRef track() const override
reference to a track
static std::vector< size_t > sort_indexes(const std::vector< T > &v)
const edm::EDGetTokenT< reco::TrackCollection > TKOrigs_
const bool storeHcalDepthEndcapOnly_
const edm::EDGetTokenT< edm::ValueMap< reco::CandidatePtr > > PuppiCandsMap_
edm::Ref< VertexCollection > VertexRef
persistent reference to a Vertex
const int covarianceVersion_
reco::MuonRef muonRef() const
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
LostInnerHits
Enumerator specifying the.
const edm::EDGetTokenT< edm::ValueMap< bool > > ChargedHadronIsolation_
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
T const * product() const
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
const std::vector< int > covariancePackingSchemas_
XYZPointD XYZPoint
point in space with cartesian internal representation
ProductID id() const
Accessor for product ID.
const edm::EDGetTokenT< edm::ValueMap< float > > PuppiWeight_
const edm::EDGetTokenT< reco::VertexCollection > PVOrigs_
int numberOfLostHits(HitCategory category) const
Particle reconstructed by the particle flow algorithm.
std::vector< edm::EDGetTokenT< edm::View< reco::Candidate > > > SVWhiteLists_
reco::GsfTrackRef gsfTrackRef() const
const std::vector< int > pfCandidateTypesForHcalDepth_
double hcalEnergy() const
return corrected Hcal energy
int numberOfValidPixelHits() const
const_iterator end() const
const edm::EDGetTokenT< edm::Association< reco::VertexCollection > > PVAsso_
const edm::EDGetTokenT< reco::VertexCollection > PVs_
virtual ParticleType particleId() const
uint16_t getHitPattern(HitCategory category, int position) const
double phi() const final
momentum azimuthal angle
const double minPtForChargedHadronProperties_
double rawHcalEnergy() const
return raw Hcal energy