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();
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())) {
296 outPtrP->back().setTrkAlgo(static_cast<uint8_t>(ctrack->
algo()), static_cast<uint8_t>(ctrack->
originalAlgo()));
298 if (
abs(outPtrP->back().pdgId()) == 22) {
302 outPtrP->back().setTrackProperties(*ctrack,
313 outPtrP->back().setTrackProperties(*ctrack,
317 outPtrP->back().setTrackProperties(*ctrack,
324 outPtrP->back().setTrackHighPurity(
cand.trackRef().isNonnull() &&
326 if (
cand.muonRef().isNonnull()) {
327 outPtrP->back().setMuonID(
cand.muonRef()->isStandAloneMuon(),
cand.muonRef()->isGlobalMuon());
332 PVpos =
PV->position();
337 outPtrP->back().setAssociationQuality(
343 bool isIsolatedChargedHadron =
false;
346 isIsolatedChargedHadron =
348 outPtrP->back().setIsIsolatedChargedHadron(isIsolatedChargedHadron);
352 outPtrP->back().setHcalFraction(
cand.hcalEnergy() / (
cand.ecalEnergy() +
cand.hcalEnergy()));
353 }
else if ((
cand.charge() ||
abs(
cand.pdgId()) == 22) &&
cand.pt() > 0.5) {
354 outPtrP->back().setHcalFraction(
cand.hcalEnergy() / (
cand.ecalEnergy() +
cand.hcalEnergy()));
355 outPtrP->back().setCaloFraction((
cand.hcalEnergy() +
cand.ecalEnergy()) /
cand.energy());
357 outPtrP->back().setHcalFraction(0);
358 outPtrP->back().setCaloFraction(0);
361 if (isIsolatedChargedHadron) {
362 outPtrP->back().setRawCaloFraction((
cand.rawEcalEnergy() +
cand.rawHcalEnergy()) /
cand.energy());
363 outPtrP->back().setRawHcalFraction(
cand.rawHcalEnergy() / (
cand.rawEcalEnergy() +
cand.rawHcalEnergy()));
365 outPtrP->back().setRawCaloFraction(0);
366 outPtrP->back().setRawHcalFraction(0);
369 std::vector<float> dummyVector;
377 fabs(outPtrP->back().eta()) > 1.3) {
380 std::vector<float> hcalDepthEnergyFractionTmp(
cand.hcalDepthEnergyFractions().begin(),
381 cand.hcalDepthEnergyFractions().end());
382 hcalDepthEFrac.reset(hcalDepthEnergyFractionTmp);
385 hcalDepthEnergyFractions.push_back(hcalDepthEFrac);
391 outPtrP->back().setGoodEgamma();
397 float puppiWeightVal = (*puppiWeight)[pkref];
398 float puppiWeightNoLepVal = (*puppiWeightNoLep)[pkref];
399 outPtrP->back().setPuppiWeight(puppiWeightVal, puppiWeightNoLepVal);
404 if (
cand.trackRef().isNonnull()) {
405 auto t0 = (*t0Map)[
cand.trackRef()];
406 auto t0Err = (*t0ErrMap)[
cand.trackRef()];
407 outPtrP->back().setTime(
t0, t0Err);
410 if (
cand.isTimeValid()) {
411 outPtrP->back().setTime(
cand.time(),
cand.timeError());
417 if (
cand.trackRef().isNonnull() &&
cand.trackRef().id() == TKOrigs.
id()) {
418 mappingTk[
cand.trackRef().key()] = ic;
422 auto outPtrPSorted = std::make_unique<std::vector<pat::PackedCandidate>>();
424 std::vector<size_t> reverseOrder(
order.size());
425 for (
size_t i = 0, nc =
cands->size();
i < nc;
i++) {
426 outPtrPSorted->push_back((*outPtrP)[
order[
i]]);
429 hcalDepthEnergyFractions_Ordered.push_back(hcalDepthEnergyFractions[
order[
i]]);
433 for (
size_t i = 0, ntk = mappingTk.size();
i < ntk;
i++) {
434 if (mappingTk[
i] >= 0)
435 mappingTk[
i] = reverseOrder[mappingTk[
i]];
441 auto pf2pc = std::make_unique<edm::Association<pat::PackedCandidateCollection>>(oh);
442 auto pc2pf = std::make_unique<edm::Association<reco::PFCandidateCollection>>(
cands);
445 pf2pcFiller.insert(
cands, mappingReverse.begin(), mappingReverse.end());
446 pc2pfFiller.insert(oh,
order.begin(),
order.end());
448 pf2pcFiller.insert(TKOrigs, mappingTk.begin(), mappingTk.end());
456 auto hcalDepthEnergyFractionsV = std::make_unique<edm::ValueMap<HcalDepthEnergyFractions>>();
458 fillerHcalDepthEnergyFractions.insert(
459 cands, hcalDepthEnergyFractions_Ordered.begin(), hcalDepthEnergyFractions_Ordered.end());
460 fillerHcalDepthEnergyFractions.fill();
463 iEvent.put(
std::move(hcalDepthEnergyFractionsV),
"hcalDepthEnergyFractions");
int numberOfValidPixelHits() const
int numberOfLostHits(HitCategory category) const
T const * product() const
bool isNonnull() const
Checks for non-null.
static const int qualityMap[8]
conversion map from quality flags used in PV association and miniAOD one
const Point & referencePoint() const
Reference point on the track.
const edm::EDGetTokenT< reco::PFCandidateCollection > Cands_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
key_type key() const
Accessor for product key.
const edm::EDGetTokenT< edm::ValueMap< int > > PVAssoQuality_
const edm::EDGetTokenT< edm::ValueMap< float > > PuppiWeightNoLep_
const double minPtForTrackProperties_
double pt() const
track transverse momentum
TrackAlgorithm originalAlgo() 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...
const edm::EDGetTokenT< edm::ValueMap< float > > t0ErrMap_
reco::TrackRef track() const override
reference to a track
Abs< T >::type abs(const T &t)
const bool storeChargedHadronIsolation_
double phi() const
azimuthal angle of momentum vector
const bool timeFromValueMap_
static std::vector< size_t > sort_indexes(const std::vector< T > &v)
const edm::EDGetTokenT< reco::TrackCollection > TKOrigs_
const bool storeHcalDepthEndcapOnly_
edm::Ref< VertexCollection > VertexRef
persistent reference to a Vertex
uint16_t getHitPattern(HitCategory category, int position) const
const int covarianceVersion_
LostInnerHits
Enumerator specifying the.
double eta() const
pseudorapidity of momentum vector
const edm::EDGetTokenT< edm::ValueMap< bool > > ChargedHadronIsolation_
TrackAlgorithm algo() const
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
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
const edm::EDGetTokenT< edm::ValueMap< float > > PuppiWeight_
const edm::EDGetTokenT< reco::VertexCollection > PVOrigs_
Particle reconstructed by the particle flow algorithm.
std::vector< edm::EDGetTokenT< edm::View< reco::Candidate > > > SVWhiteLists_
const std::vector< int > pfCandidateTypesForHcalDepth_
const edm::EDGetTokenT< edm::Association< reco::VertexCollection > > PVAsso_
const edm::EDGetTokenT< reco::VertexCollection > PVs_
const double minPtForLowQualityTrackProperties_
const edm::EDGetTokenT< edm::ValueMap< float > > t0Map_
const_iterator end() const
bool hasValidHitInPixelLayer(enum PixelSubdetector::SubDetector, uint16_t layer) const
const double minPtForChargedHadronProperties_