444 if (
iEvent.isRealData()) {
508 std::vector<edm::Handle<edm::ValueMap<float>>> idhandles;
509 std::vector<pat::Electron::IdPair> ids;
524 bool beamSpotIsValid =
false;
525 bool primaryVertexIsValid =
false;
539 if (beamSpotHandle.
isValid()) {
541 beamSpotIsValid =
true;
543 edm::LogError(
"DataNotAvailable") <<
"No beam spot available from EventSetup, not adding high level selection \n";
546 if (pvHandle.
isValid() && !pvHandle->empty()) {
548 primaryVertexIsValid =
true;
551 <<
"No primary vertex available from EventSetup, not adding high level selection \n";
573 std::vector<Electron>*
patElectrons =
new std::vector<Electron>();
588 bool MatchedToAmbiguousGsfTrack =
false;
593 if (
Matched || MatchedToAmbiguousGsfTrack)
598 if (itElectron->gsfTrack() ==
i->gsfTrackRef()) {
601 for (
auto const&
it : itElectron->ambiguousGsfTracks()) {
602 MatchedToAmbiguousGsfTrack |= (
bool)(
i->gsfTrackRef() ==
it);
606 if (
Matched || MatchedToAmbiguousGsfTrack) {
613 anElectron.setPFCandidateRef(pfRef);
615 anElectron.setIsolationPUPPI((*PUPPIIsolation_charged_hadrons)[elePtr],
616 (*PUPPIIsolation_neutral_hadrons)[elePtr],
617 (*PUPPIIsolation_photons)[elePtr]);
618 anElectron.setIsolationPUPPINoLeptons((*PUPPINoLeptonsIsolation_charged_hadrons)[elePtr],
619 (*PUPPINoLeptonsIsolation_neutral_hadrons)[elePtr],
620 (*PUPPINoLeptonsIsolation_photons)[elePtr]);
622 anElectron.setIsolationPUPPI(-999., -999., -999.);
623 anElectron.setIsolationPUPPINoLeptons(-999., -999., -999.);
627 anElectron.setIsPF(
true);
630 anElectron.embedPFCandidate();
644 if (
track.isNonnull() &&
track.isAvailable()) {
649 ip3d = ip3dpv.second.value();
658 ids[
i].second = (*idhandles[
i])[elecsRef];
661 ids.push_back(std::make_pair(
"pf_evspi", pfRef->mva_e_pi()));
662 ids.push_back(std::make_pair(
"pf_evsmu", pfRef->mva_e_mu()));
663 anElectron.setElectronIDs(ids);
668 const auto& vCov = lazyTools.localCovariances(*(itElectron->superCluster()->seed()));
669 anElectron.setMvaVariables(vCov[1],
ip3d);
681 anElectron.setPfIsolationVariables(newPFIsol);
684 std::vector<DetId> selectedCells;
685 bool barrel = itElectron->isEB();
689 clusIt != itElectron->superCluster()->clustersEnd();
692 DetId seed = lazyTools.getMaximum(**clusIt).first;
694 std::vector<DetId> dets5x5 =
697 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
700 for (
const std::pair<DetId, float>&
hit : (*clusIt)->hitsAndFractions()) {
701 selectedCells.push_back(
hit.first);
708 clusIt != itElectron->parentSuperCluster()->clustersEnd();
711 DetId seed = lazyTools.getMaximum(**clusIt).first;
713 std::vector<DetId> dets5x5 =
716 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
719 for (
const std::pair<DetId, float>&
hit : (*clusIt)->hitsAndFractions()) {
720 selectedCells.push_back(
hit.first);
726 std::sort(selectedCells.begin(), selectedCells.end());
727 std::unique(selectedCells.begin(), selectedCells.end());
740 unsigned nSelectedCells = selectedCells.size();
741 for (
unsigned icell = 0; icell < nSelectedCells; ++icell) {
747 selectedRecHits.
sort();
749 anElectron.embedRecHits(&selectedRecHits);
752 bool passconversionveto =
false;
753 if (hConversions.isValid()) {
763 anElectron.setPassConversionVeto(passconversionveto);
795 bool pfCandsPresent =
false, valMapPresent =
false;
820 anElectron.setPFCandidateRef(
pf);
824 }
else if (pfCandsPresent) {
832 if (trkRef == pfTrkRef) {
835 anElectron.setPFCandidateRef(pfRef);
839 }
else if (valMapPresent) {
844 pfId = pfElePtr.isNonnull();
847 anElectron.setIsPF(pfId);
860 anElectron.setIsolation(
it->first,
it->second);
864 for (
size_t j = 0, nd =
deposits.size();
j < nd; ++
j) {
871 ids[
i].second = (*idhandles[
i])[elecsRef];
873 anElectron.setElectronIDs(ids);
888 if (
track.isNonnull() &&
track.isAvailable()) {
893 ip3d = ip3dpv.second.value();
899 const auto& vCov = lazyTools.localCovariances(*(itElectron->superCluster()->seed()));
900 anElectron.setMvaVariables(vCov[1],
ip3d);
913 anElectron.setPfIsolationVariables(newPFIsol);
917 anElectron.setIsolationPUPPI((*PUPPIIsolation_charged_hadrons)[elePtr],
918 (*PUPPIIsolation_neutral_hadrons)[elePtr],
919 (*PUPPIIsolation_photons)[elePtr]);
920 anElectron.setIsolationPUPPINoLeptons((*PUPPINoLeptonsIsolation_charged_hadrons)[elePtr],
921 (*PUPPINoLeptonsIsolation_neutral_hadrons)[elePtr],
922 (*PUPPINoLeptonsIsolation_photons)[elePtr]);
924 anElectron.setIsolationPUPPI(-999., -999., -999.);
925 anElectron.setIsolationPUPPINoLeptons(-999., -999., -999.);
928 std::vector<DetId> selectedCells;
929 bool barrel = itElectron->isEB();
933 clusIt != itElectron->superCluster()->clustersEnd();
936 DetId seed = lazyTools.getMaximum(**clusIt).first;
938 std::vector<DetId> dets5x5 =
941 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
944 for (
const std::pair<DetId, float>&
hit : (*clusIt)->hitsAndFractions()) {
945 selectedCells.push_back(
hit.first);
952 clusIt != itElectron->parentSuperCluster()->clustersEnd();
955 DetId seed = lazyTools.getMaximum(**clusIt).first;
957 std::vector<DetId> dets5x5 =
960 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
963 for (
const std::pair<DetId, float>&
hit : (*clusIt)->hitsAndFractions()) {
964 selectedCells.push_back(
hit.first);
970 std::sort(selectedCells.begin(), selectedCells.end());
971 std::unique(selectedCells.begin(), selectedCells.end());
984 unsigned nSelectedCells = selectedCells.size();
985 for (
unsigned icell = 0; icell < nSelectedCells; ++icell) {
991 selectedRecHits.
sort();
993 anElectron.embedRecHits(&selectedRecHits);
996 bool passconversionveto =
false;
997 if (hConversions.isValid()) {
1003 passconversionveto =
1006 anElectron.setPassConversionVeto(passconversionveto);
1023 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_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
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_
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_