453 if (
iEvent.isRealData()) {
517 std::vector<edm::Handle<edm::ValueMap<float>>> idhandles;
518 std::vector<pat::Electron::IdPair> ids;
533 bool beamSpotIsValid =
false;
534 bool primaryVertexIsValid =
false;
548 if (pvHandle.
isValid() && !pvHandle->empty()) {
550 primaryVertexIsValid =
true;
553 <<
"No primary vertex available from EventSetup, not adding high level selection \n";
575 std::vector<Electron>*
patElectrons =
new std::vector<Electron>();
590 bool MatchedToAmbiguousGsfTrack =
false;
595 if (
Matched || MatchedToAmbiguousGsfTrack)
600 if (itElectron->gsfTrack() ==
i->gsfTrackRef()) {
603 for (
auto const& it : itElectron->ambiguousGsfTracks()) {
604 MatchedToAmbiguousGsfTrack |= (
bool)(
i->gsfTrackRef() == it);
608 if (
Matched || MatchedToAmbiguousGsfTrack) {
615 anElectron.setPFCandidateRef(pfRef);
617 anElectron.setIsolationPUPPI((*PUPPIIsolation_charged_hadrons)[elePtr],
618 (*PUPPIIsolation_neutral_hadrons)[elePtr],
619 (*PUPPIIsolation_photons)[elePtr]);
620 anElectron.setIsolationPUPPINoLeptons((*PUPPINoLeptonsIsolation_charged_hadrons)[elePtr],
621 (*PUPPINoLeptonsIsolation_neutral_hadrons)[elePtr],
622 (*PUPPINoLeptonsIsolation_photons)[elePtr]);
624 anElectron.setIsolationPUPPI(-999., -999., -999.);
625 anElectron.setIsolationPUPPINoLeptons(-999., -999., -999.);
629 anElectron.setIsPF(
true);
632 anElectron.embedPFCandidate();
646 if (
track.isNonnull() &&
track.isAvailable()) {
651 ip3d = ip3dpv.second.value();
660 ids[
i].second = (*idhandles[
i])[elecsRef];
663 ids.push_back(std::make_pair(
"pf_evspi", pfRef->mva_e_pi()));
664 ids.push_back(std::make_pair(
"pf_evsmu", pfRef->mva_e_mu()));
665 anElectron.setElectronIDs(ids);
670 const auto& vCov = lazyTools.localCovariances(*(itElectron->superCluster()->seed()));
671 anElectron.setMvaVariables(vCov[1],
ip3d);
683 anElectron.setPfIsolationVariables(newPFIsol);
686 std::vector<DetId> selectedCells;
687 bool barrel = itElectron->isEB();
691 clusIt != itElectron->superCluster()->clustersEnd();
694 DetId seed = lazyTools.getMaximum(**clusIt).first;
696 std::vector<DetId> dets5x5 =
699 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
702 for (
const std::pair<DetId, float>&
hit : (*clusIt)->hitsAndFractions()) {
703 selectedCells.push_back(
hit.first);
710 clusIt != itElectron->parentSuperCluster()->clustersEnd();
713 DetId seed = lazyTools.getMaximum(**clusIt).first;
715 std::vector<DetId> dets5x5 =
718 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
721 for (
const std::pair<DetId, float>&
hit : (*clusIt)->hitsAndFractions()) {
722 selectedCells.push_back(
hit.first);
728 std::sort(selectedCells.begin(), selectedCells.end());
729 std::unique(selectedCells.begin(), selectedCells.end());
742 unsigned nSelectedCells = selectedCells.size();
743 for (
unsigned icell = 0; icell < nSelectedCells; ++icell) {
749 selectedRecHits.
sort();
751 anElectron.embedRecHits(&selectedRecHits);
754 bool passconversionveto =
false;
755 if (hConversions.isValid()) {
765 anElectron.setPassConversionVeto(passconversionveto);
797 bool pfCandsPresent =
false, valMapPresent =
false;
822 anElectron.setPFCandidateRef(
pf);
826 }
else if (pfCandsPresent) {
834 if (trkRef == pfTrkRef) {
837 anElectron.setPFCandidateRef(pfRef);
841 }
else if (valMapPresent) {
846 pfId = pfElePtr.isNonnull();
849 anElectron.setIsPF(pfId);
862 anElectron.setIsolation(it->first, it->second);
866 for (
size_t j = 0, nd =
deposits.size();
j < nd; ++
j) {
873 ids[
i].second = (*idhandles[
i])[elecsRef];
875 anElectron.setElectronIDs(ids);
890 if (
track.isNonnull() &&
track.isAvailable()) {
895 ip3d = ip3dpv.second.value();
901 const auto& vCov = lazyTools.localCovariances(*(itElectron->superCluster()->seed()));
902 anElectron.setMvaVariables(vCov[1],
ip3d);
915 anElectron.setPfIsolationVariables(newPFIsol);
919 anElectron.setIsolationPUPPI((*PUPPIIsolation_charged_hadrons)[elePtr],
920 (*PUPPIIsolation_neutral_hadrons)[elePtr],
921 (*PUPPIIsolation_photons)[elePtr]);
922 anElectron.setIsolationPUPPINoLeptons((*PUPPINoLeptonsIsolation_charged_hadrons)[elePtr],
923 (*PUPPINoLeptonsIsolation_neutral_hadrons)[elePtr],
924 (*PUPPINoLeptonsIsolation_photons)[elePtr]);
926 anElectron.setIsolationPUPPI(-999., -999., -999.);
927 anElectron.setIsolationPUPPINoLeptons(-999., -999., -999.);
930 std::vector<DetId> selectedCells;
931 bool barrel = itElectron->isEB();
935 clusIt != itElectron->superCluster()->clustersEnd();
938 DetId seed = lazyTools.getMaximum(**clusIt).first;
940 std::vector<DetId> dets5x5 =
943 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
946 for (
const std::pair<DetId, float>&
hit : (*clusIt)->hitsAndFractions()) {
947 selectedCells.push_back(
hit.first);
954 clusIt != itElectron->parentSuperCluster()->clustersEnd();
957 DetId seed = lazyTools.getMaximum(**clusIt).first;
959 std::vector<DetId> dets5x5 =
962 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
965 for (
const std::pair<DetId, float>&
hit : (*clusIt)->hitsAndFractions()) {
966 selectedCells.push_back(
hit.first);
972 std::sort(selectedCells.begin(), selectedCells.end());
973 std::unique(selectedCells.begin(), selectedCells.end());
986 unsigned nSelectedCells = selectedCells.size();
987 for (
unsigned icell = 0; icell < nSelectedCells; ++icell) {
993 selectedRecHits.
sort();
995 anElectron.embedRecHits(&selectedRecHits);
998 bool passconversionveto =
false;
999 if (hConversions.isValid()) {
1001 passconversionveto =
1005 passconversionveto =
1008 anElectron.setPassConversionVeto(passconversionveto);
1025 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.
const edm::EDGetTokenT< reco::ConversionCollection > hConversionsToken_
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_charged_hadrons_
const GreaterByPt< Electron > pTComparator_
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_charged_hadrons_
bool enabled() const
True if it has a non null configuration.
const bool useParticleFlow_
pflow specific
const edm::EDGetTokenT< reco::PFCandidateCollection > pfElecToken_
const Point & position() const
position
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_neutral_hadrons_
const edm::EDGetTokenT< edm::ValueMap< float > > ecalPFClusterIsoT_
IsolationLabels isoDepositLabels_
const bool embedPFCandidate_
T const * product() const
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
void push_back(T const &t)
const edm::EDGetTokenT< edm::ValueMap< float > > hcalPFClusterIsoT_
Log< level::Error, false > LogError
const bool embedBasicClusters_
PFCandidateCollection::const_iterator PFCandidateConstIterator
iterator
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > elecIDTokens_
const edm::ESGetToken< CaloTopology, CaloTopologyRecord > ecalTopologyToken_
const edm::EDGetTokenT< edm::View< reco::GsfElectron > > electronToken_
const bool addMVAVariables_
mva input variables
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const
reco::TransientTrack build(const reco::Track *p) const
const edm::EDGetTokenT< std::vector< reco::Vertex > > pvToken_
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)
bool enabled() const
'true' if this there is at least one efficiency configured
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 EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
const edm::EDGetTokenT< EcalRecHitCollection > reducedEndcapRecHitCollectionToken_
bool getData(T &iHolder) const
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
const bool addPFClusterIso_
math::XYZPoint Point
point in the space
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_photons_
reducedEERecHitCollection
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
void add(ObjectType &patObject, edm::Event const &iEvent, edm::EventSetup const &iSetup)
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
const edm::EDGetTokenT< reco::BeamSpot > beamLineToken_
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueNoPFIdTokens_
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
pat::helper::EfficiencyLoader efficiencyLoader_
const edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollectionToken_
const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > trackBuilderToken_
const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > pfCandidateMultiMapToken_
pat::PATUserDataHelper< pat::Electron > userDataHelper_
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
const CaloTopology * ecalTopology_
void setElectronMiniIso(pat::Electron &anElectron, const pat::PackedCandidateCollection *pc)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
reducedEBRecHitCollection
pat::helper::KinResolutionsLoader resolutionLoader_
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_
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
std::vector< NameTag > elecIDSrcs_