172 std::vector<reco::CandidatePtr> puppiCandsNoLepPtrs;
179 for (
auto pup : *puppiCandsNoLep) {
180 puppiCandsNoLepPtrs.push_back(pup.sourceCandidatePtr(0));
183 std::vector<int> mappingPuppi(
usePuppi_ ? puppiCands->size() : 0);
199 std::set<unsigned int> whiteList;
200 std::set<reco::TrackRef> whiteListTk;
205 for (
unsigned int i = 0;
i < svWhiteList.
size();
i++) {
207 for (
unsigned int j = 0;
j < svWhiteList[
i].numberOfSourceCandidatePtrs();
j++) {
209 if (c.
id() == cands.
id())
210 whiteList.insert(c.
key());
213 for (
auto dau = svWhiteList[
i].
begin(); dau != svWhiteList[
i].
end(); dau++) {
215 if (chCand !=
nullptr) {
216 whiteListTk.insert(chCand->
track());
228 std::vector<pat::HcalDepthEnergyFractions> hcalDepthEnergyFractions;
229 hcalDepthEnergyFractions.reserve(cands->size());
230 std::vector<pat::HcalDepthEnergyFractions> hcalDepthEnergyFractions_Ordered;
231 hcalDepthEnergyFractions_Ordered.reserve(cands->size());
235 auto outPtrP = std::make_unique<std::vector<pat::PackedCandidate>>();
236 std::vector<int>
mapping(cands->size());
237 std::vector<int> mappingReverse(cands->size());
238 std::vector<int> mappingTk(TKOrigs->size(), -1);
240 for (
unsigned int ic = 0, nc = cands->size(); ic < nc; ++ic) {
251 for (
size_t ii = 0;
ii < PVs->size();
ii++) {
274 float ptTrk = ctrack->
pt();
275 float etaAtVtx = ctrack->
eta();
276 float phiAtVtx = ctrack->
phi();
296 outPtrP->back().setLostInnerHits(lostHits);
298 whiteList.find(ic) != whiteList.end() ||
301 if (
abs(outPtrP->back().pdgId()) == 22) {
305 outPtrP->back().setTrackProperties(*ctrack,
314 if (outPtrP->back().pt() > 0.5) {
316 outPtrP->back().setTrackProperties(*ctrack,
320 outPtrP->back().setTrackProperties(*ctrack,
330 outPtrP->back().setMuonID(cand.
muonRef()->isStandAloneMuon(), cand.
muonRef()->isGlobalMuon());
335 PVpos =
PV->position();
340 outPtrP->back().setAssociationQuality(
346 bool isIsolatedChargedHadron =
false;
349 isIsolatedChargedHadron =
351 outPtrP->back().setIsIsolatedChargedHadron(isIsolatedChargedHadron);
356 }
else if (cand.
charge() && cand.
pt() > 0.5) {
360 outPtrP->back().setHcalFraction(0);
361 outPtrP->back().setCaloFraction(0);
364 if (isIsolatedChargedHadron) {
368 outPtrP->back().setRawCaloFraction(0);
369 outPtrP->back().setRawHcalFraction(0);
372 std::vector<float> dummyVector;
380 fabs(outPtrP->back().eta()) > 1.3) {
385 hcalDepthEFrac.reset(hcalDepthEnergyFractionTmp);
388 hcalDepthEnergyFractions.push_back(hcalDepthEFrac);
394 outPtrP->back().setGoodEgamma();
401 float puppiWeightVal = (*puppiWeight)[pkref];
402 float puppiWeightNoLepVal = 0.0;
406 if (puppiWeightNoLep.
isValid()) {
408 auto pkrefPtr = pkref->sourceCandidatePtr(0);
410 bool foundNoLep =
false;
411 for (
size_t ipcnl = 0; ipcnl < puppiCandsNoLepPtrs.size(); ipcnl++) {
412 if (puppiCandsNoLepPtrs[ipcnl] == pkrefPtr) {
414 puppiWeightNoLepVal =
415 puppiCandsNoLep->at(ipcnl).pt() / cand.
pt();
419 if (!foundNoLep || puppiWeightNoLepVal > 1) {
420 puppiWeightNoLepVal = 1.0;
423 outPtrP->back().setPuppiWeight(puppiWeightVal, puppiWeightNoLepVal);
425 mappingPuppi[((*puppiCandsMap)[pkref]).
key()] = ic;
438 auto outPtrPSorted = std::make_unique<std::vector<pat::PackedCandidate>>();
440 std::vector<size_t> reverseOrder(order.size());
441 for (
size_t i = 0, nc = cands->size();
i < nc;
i++) {
442 outPtrPSorted->push_back((*outPtrP)[order[
i]]);
443 reverseOrder[order[
i]] =
i;
444 mappingReverse[order[
i]] =
i;
445 hcalDepthEnergyFractions_Ordered.push_back(hcalDepthEnergyFractions[order[i]]);
449 for (
size_t i = 0, ntk = mappingTk.size(); i < ntk; i++) {
450 if (mappingTk[i] >= 0)
451 mappingTk[
i] = reverseOrder[mappingTk[
i]];
454 for (
size_t i = 0, ntk = mappingPuppi.size(); i < ntk; i++) {
455 mappingPuppi[
i] = reverseOrder[mappingPuppi[
i]];
461 auto pf2pc = std::make_unique<edm::Association<pat::PackedCandidateCollection>>(oh);
462 auto pc2pf = std::make_unique<edm::Association<reco::PFCandidateCollection>>(
cands);
465 pf2pcFiller.insert(cands, mappingReverse.begin(), mappingReverse.end());
466 pc2pfFiller.insert(oh, order.begin(), order.end());
468 pf2pcFiller.insert(TKOrigs, mappingTk.begin(), mappingTk.end());
470 pf2pcFiller.insert(puppiCands, mappingPuppi.begin(), mappingPuppi.end());
478 auto hcalDepthEnergyFractionsV = std::make_unique<edm::ValueMap<HcalDepthEnergyFractions>>();
480 fillerHcalDepthEnergyFractions.insert(
481 cands, hcalDepthEnergyFractions_Ordered.begin(), hcalDepthEnergyFractions_Ordered.end());
482 fillerHcalDepthEnergyFractions.fill();
485 iEvent.
put(
std::move(hcalDepthEnergyFractionsV),
"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
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
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 std::array< float, 7 > & hcalDepthEnergyFractions() const
fraction of hcal energy at a given depth (index 0..6 for depth 1..7)
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