297 std::vector<edm::Handle<edm::ValueMap<float>>> idhandles;
298 std::vector<pat::Electron::IdPair>
ids;
313 bool beamSpotIsValid =
false;
314 bool primaryVertexIsValid =
false;
328 if (pvHandle.
isValid() && !pvHandle->empty()) {
329 primaryVertex = pvHandle->at(0);
330 primaryVertexIsValid =
true;
333 <<
"No primary vertex available from EventSetup, not adding high level selection \n";
355 std::vector<Electron>*
patElectrons =
new std::vector<Electron>();
370 bool MatchedToAmbiguousGsfTrack =
false;
373 unsigned int idx = itElectron - electrons->begin();
374 auto elePtr = electrons->ptrAt(idx);
375 if (Matched || MatchedToAmbiguousGsfTrack)
380 if (itElectron->gsfTrack() ==
i->gsfTrackRef()) {
384 it != itElectron->ambiguousGsfTracksEnd();
386 MatchedToAmbiguousGsfTrack |= (
bool)(
i->gsfTrackRef() == (*it));
390 if (Matched || MatchedToAmbiguousGsfTrack) {
397 anElectron.setPFCandidateRef(pfRef);
399 anElectron.setIsolationPUPPI((*PUPPIIsolation_charged_hadrons)[elePtr],
400 (*PUPPIIsolation_neutral_hadrons)[elePtr],
401 (*PUPPIIsolation_photons)[elePtr]);
402 anElectron.setIsolationPUPPINoLeptons((*PUPPINoLeptonsIsolation_charged_hadrons)[elePtr],
403 (*PUPPINoLeptonsIsolation_neutral_hadrons)[elePtr],
404 (*PUPPINoLeptonsIsolation_photons)[elePtr]);
406 anElectron.setIsolationPUPPI(-999., -999., -999.);
407 anElectron.setIsolationPUPPINoLeptons(-999., -999., -999.);
411 anElectron.setIsPF(
true);
414 anElectron.embedPFCandidate();
430 embedHighLevel(anElectron, track, tt, primaryVertex, primaryVertexIsValid, beamSpot, beamSpotIsValid);
433 ip3d = ip3dpv.second.value();
442 ids[
i].second = (*idhandles[
i])[elecsRef];
445 ids.push_back(std::make_pair(
"pf_evspi", pfRef->mva_e_pi()));
446 ids.push_back(std::make_pair(
"pf_evsmu", pfRef->mva_e_mu()));
447 anElectron.setElectronIDs(ids);
452 std::vector<float> vCov = lazyTools.localCovariances(*(itElectron->superCluster()->seed()));
453 anElectron.setMvaVariables(vCov[1], ip3d);
465 anElectron.setPfIsolationVariables(newPFIsol);
468 std::vector<DetId> selectedCells;
469 bool barrel = itElectron->isEB();
473 clusIt != itElectron->superCluster()->clustersEnd();
476 DetId seed = lazyTools.getMaximum(**clusIt).first;
478 std::vector<DetId> dets5x5 =
481 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
484 for (
const std::pair<DetId, float>&
hit : (*clusIt)->hitsAndFractions()) {
485 selectedCells.push_back(
hit.first);
492 clusIt != itElectron->parentSuperCluster()->clustersEnd();
495 DetId seed = lazyTools.getMaximum(**clusIt).first;
497 std::vector<DetId> dets5x5 =
500 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
503 for (
const std::pair<DetId, float>&
hit : (*clusIt)->hitsAndFractions()) {
504 selectedCells.push_back(
hit.first);
510 std::sort(selectedCells.begin(), selectedCells.end());
511 std::unique(selectedCells.begin(), selectedCells.end());
524 unsigned nSelectedCells = selectedCells.size();
525 for (
unsigned icell = 0; icell < nSelectedCells; ++icell) {
527 if (it != recHits->
end()) {
531 selectedRecHits.
sort();
533 anElectron.embedRecHits(&selectedRecHits);
536 bool passconversionveto =
false;
547 anElectron.setPassConversionVeto(passconversionveto);
568 patElectrons->push_back(anElectron);
579 bool pfCandsPresent =
false, valMapPresent =
false;
591 unsigned int idx = itElectron - electrons->begin();
595 auto elePtr = electrons->ptrAt(idx);
604 anElectron.setPFCandidateRef(
pf);
608 }
else if (pfCandsPresent) {
616 if (trkRef == pfTrkRef) {
619 anElectron.setPFCandidateRef(pfRef);
623 }
else if (valMapPresent) {
628 pfId = pfElePtr.isNonnull();
631 anElectron.setIsPF(pfId);
644 anElectron.setIsolation(it->first, it->second);
648 for (
size_t j = 0, nd =
deposits.size();
j < nd; ++
j) {
655 ids[
i].second = (*idhandles[
i])[elecsRef];
657 anElectron.setElectronIDs(ids);
674 embedHighLevel(anElectron, track, tt, primaryVertex, primaryVertexIsValid, beamSpot, beamSpotIsValid);
677 ip3d = ip3dpv.second.value();
683 std::vector<float> vCov = lazyTools.localCovariances(*(itElectron->superCluster()->seed()));
684 anElectron.setMvaVariables(vCov[1], ip3d);
697 anElectron.setPfIsolationVariables(newPFIsol);
701 anElectron.setIsolationPUPPI((*PUPPIIsolation_charged_hadrons)[elePtr],
702 (*PUPPIIsolation_neutral_hadrons)[elePtr],
703 (*PUPPIIsolation_photons)[elePtr]);
704 anElectron.setIsolationPUPPINoLeptons((*PUPPINoLeptonsIsolation_charged_hadrons)[elePtr],
705 (*PUPPINoLeptonsIsolation_neutral_hadrons)[elePtr],
706 (*PUPPINoLeptonsIsolation_photons)[elePtr]);
708 anElectron.setIsolationPUPPI(-999., -999., -999.);
709 anElectron.setIsolationPUPPINoLeptons(-999., -999., -999.);
712 std::vector<DetId> selectedCells;
713 bool barrel = itElectron->isEB();
717 clusIt != itElectron->superCluster()->clustersEnd();
720 DetId seed = lazyTools.getMaximum(**clusIt).first;
722 std::vector<DetId> dets5x5 =
725 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
728 for (
const std::pair<DetId, float>&
hit : (*clusIt)->hitsAndFractions()) {
729 selectedCells.push_back(
hit.first);
736 clusIt != itElectron->parentSuperCluster()->clustersEnd();
739 DetId seed = lazyTools.getMaximum(**clusIt).first;
741 std::vector<DetId> dets5x5 =
744 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
747 for (
const std::pair<DetId, float>&
hit : (*clusIt)->hitsAndFractions()) {
748 selectedCells.push_back(
hit.first);
754 std::sort(selectedCells.begin(), selectedCells.end());
755 std::unique(selectedCells.begin(), selectedCells.end());
768 unsigned nSelectedCells = selectedCells.
size();
769 for (
unsigned icell = 0; icell < nSelectedCells; ++icell) {
771 if (it != recHits->
end()) {
775 selectedRecHits.
sort();
777 anElectron.embedRecHits(&selectedRecHits);
780 bool passconversionveto =
false;
790 anElectron.setPassConversionVeto(passconversionveto);
799 patElectrons->push_back(anElectron);
804 std::sort(patElectrons->begin(), patElectrons->end(),
pTComparator_);
807 std::unique_ptr<std::vector<Electron>> ptr(patElectrons);
bool enabled() const
'true' if this there is at least one efficiency configured
void newEvent(const edm::Event &event)
To be called for each new event, reads in the ValueMaps for efficiencies.
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
const edm::EDGetTokenT< reco::ConversionCollection > hConversionsToken_
bool isNonnull() const
Checks for non-null.
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_charged_hadrons_
const GreaterByPt< Electron > pTComparator_
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_charged_hadrons_
const bool useParticleFlow_
pflow specific
const edm::EDGetTokenT< reco::PFCandidateCollection > pfElecToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_neutral_hadrons_
const edm::EDGetTokenT< edm::ValueMap< float > > ecalPFClusterIsoT_
IsolationLabels isoDepositLabels_
const bool embedPFCandidate_
void embedHighLevel(pat::Electron &anElectron, reco::GsfTrackRef track, reco::TransientTrack &tt, reco::Vertex &primaryVertex, bool primaryVertexIsValid, reco::BeamSpot &beamspot, bool beamspotIsValid)
std::vector< EcalRecHit >::const_iterator const_iterator
reco::TransientTrack build(const reco::Track *p) const
void fillElectron(Electron &aElectron, const ElectronBaseRef &electronRef, const reco::CandidateBaseRef &baseRef, const GenAssociations &genMatches, const IsoDepositMaps &deposits, const bool pfId, const IsolationValueMaps &isolationValues, const IsolationValueMaps &isolationValuesNoPFId) const
common electron filling, for both the standard and PF2PAT case
void push_back(T const &t)
const edm::EDGetTokenT< edm::ValueMap< float > > hcalPFClusterIsoT_
const bool embedBasicClusters_
PFCandidateCollection::const_iterator PFCandidateConstIterator
iterator
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > elecIDTokens_
const edm::EDGetTokenT< edm::View< reco::GsfElectron > > electronToken_
const bool addMVAVariables_
mva input variables
bool enabled() const
'true' if this there is at least one efficiency configured
const edm::EDGetTokenT< std::vector< reco::Vertex > > pvToken_
bool enabled() const
True if it has a non null configuration.
const edm::EDGetTokenT< edm::ValueMap< reco::PFCandidatePtr > > pfCandidateMapToken_
const bool usePfCandidateMultiMap_
pat::helper::MultiIsolator isolator_
std::vector< edm::Handle< edm::Association< reco::GenParticleCollection > > > GenAssociations
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_photons_
void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup)
const bool addPuppiIsolation_
const bool embedHighLevelSelection_
embed high level selection variables?
void newEvent(const edm::Event &event, const edm::EventSetup &setup)
To be called for each new event, reads in the EventSetup object.
std::vector< edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > > genMatchTokens_
def unique(seq, keepstr=True)
std::vector< edm::Handle< edm::ValueMap< IsoDeposit > > > IsoDepositMaps
std::vector< edm::EDGetTokenT< edm::ValueMap< IsoDeposit > > > isoDepositTokens_
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_neutral_hadrons_
const edm::EDGetTokenT< EcalRecHitCollection > reducedEndcapRecHitCollectionToken_
const bool addPFClusterIso_
math::XYZPoint Point
point in the space
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_photons_
reducedEERecHitCollection
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
const_iterator end() const
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
const edm::EDGetTokenT< reco::BeamSpot > beamLineToken_
void fillElectron2(Electron &anElectron, const reco::CandidatePtr &candPtrForIsolation, const reco::CandidatePtr &candPtrForGenMatch, const reco::CandidatePtr &candPtrForLoader, const GenAssociations &genMatches, const IsoDepositMaps &deposits, const IsolationValueMaps &isolationValues) const
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueNoPFIdTokens_
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
T const * product() const
pat::helper::EfficiencyLoader efficiencyLoader_
const edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollectionToken_
const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > pfCandidateMultiMapToken_
pat::PATUserDataHelper< pat::Electron > userDataHelper_
const CaloTopology * ecalTopology_
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
void setElectronMiniIso(pat::Electron &anElectron, const pat::PackedCandidateCollection *pc)
iterator find(key_type k)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
reducedEBRecHitCollection
pat::helper::KinResolutionsLoader resolutionLoader_
const Point & position() const
position
const bool embedPflowBasicClusters_
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueTokens_
pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_
primaryVertex
hltOfflineBeamSpot for HLTMON
edm::EDGetTokenT< pat::PackedCandidateCollection > pcToken_
std::vector< NameTag > elecIDSrcs_
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const