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 (pvHandle.
isValid() && !pvHandle->empty()) {
541 primaryVertexIsValid =
true;
544 <<
"No primary vertex available from EventSetup, not adding high level selection \n";
566 std::vector<Electron>*
patElectrons =
new std::vector<Electron>();
581 bool MatchedToAmbiguousGsfTrack =
false;
586 if (
Matched || MatchedToAmbiguousGsfTrack)
591 if (itElectron->gsfTrack() ==
i->gsfTrackRef()) {
594 for (
auto const& it : itElectron->ambiguousGsfTracks()) {
595 MatchedToAmbiguousGsfTrack |= (
bool)(
i->gsfTrackRef() == it);
599 if (
Matched || MatchedToAmbiguousGsfTrack) {
606 anElectron.setPFCandidateRef(pfRef);
608 anElectron.setIsolationPUPPI((*PUPPIIsolation_charged_hadrons)[elePtr],
609 (*PUPPIIsolation_neutral_hadrons)[elePtr],
610 (*PUPPIIsolation_photons)[elePtr]);
611 anElectron.setIsolationPUPPINoLeptons((*PUPPINoLeptonsIsolation_charged_hadrons)[elePtr],
612 (*PUPPINoLeptonsIsolation_neutral_hadrons)[elePtr],
613 (*PUPPINoLeptonsIsolation_photons)[elePtr]);
615 anElectron.setIsolationPUPPI(-999., -999., -999.);
616 anElectron.setIsolationPUPPINoLeptons(-999., -999., -999.);
620 anElectron.setIsPF(
true);
623 anElectron.embedPFCandidate();
637 if (
track.isNonnull() &&
track.isAvailable()) {
642 ip3d = ip3dpv.second.value();
651 ids[
i].second = (*idhandles[
i])[elecsRef];
654 ids.push_back(std::make_pair(
"pf_evspi", pfRef->mva_e_pi()));
655 ids.push_back(std::make_pair(
"pf_evsmu", pfRef->mva_e_mu()));
656 anElectron.setElectronIDs(ids);
661 const auto& vCov = lazyTools.localCovariances(*(itElectron->superCluster()->seed()));
662 anElectron.setMvaVariables(vCov[1],
ip3d);
674 anElectron.setPfIsolationVariables(newPFIsol);
677 std::vector<DetId> selectedCells;
678 bool barrel = itElectron->isEB();
682 clusIt != itElectron->superCluster()->clustersEnd();
685 DetId seed = lazyTools.getMaximum(**clusIt).first;
687 std::vector<DetId> dets5x5 =
690 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
693 for (
const std::pair<DetId, float>&
hit : (*clusIt)->hitsAndFractions()) {
694 selectedCells.push_back(
hit.first);
701 clusIt != itElectron->parentSuperCluster()->clustersEnd();
704 DetId seed = lazyTools.getMaximum(**clusIt).first;
706 std::vector<DetId> dets5x5 =
709 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
712 for (
const std::pair<DetId, float>&
hit : (*clusIt)->hitsAndFractions()) {
713 selectedCells.push_back(
hit.first);
719 std::sort(selectedCells.begin(), selectedCells.end());
720 std::unique(selectedCells.begin(), selectedCells.end());
733 unsigned nSelectedCells = selectedCells.size();
734 for (
unsigned icell = 0; icell < nSelectedCells; ++icell) {
740 selectedRecHits.
sort();
742 anElectron.embedRecHits(&selectedRecHits);
745 bool passconversionveto =
false;
746 if (hConversions.isValid()) {
756 anElectron.setPassConversionVeto(passconversionveto);
788 bool pfCandsPresent =
false, valMapPresent =
false;
813 anElectron.setPFCandidateRef(
pf);
817 }
else if (pfCandsPresent) {
825 if (trkRef == pfTrkRef) {
828 anElectron.setPFCandidateRef(pfRef);
832 }
else if (valMapPresent) {
837 pfId = pfElePtr.isNonnull();
840 anElectron.setIsPF(pfId);
853 anElectron.setIsolation(it->first, it->second);
857 for (
size_t j = 0, nd =
deposits.size();
j < nd; ++
j) {
864 ids[
i].second = (*idhandles[
i])[elecsRef];
866 anElectron.setElectronIDs(ids);
881 if (
track.isNonnull() &&
track.isAvailable()) {
886 ip3d = ip3dpv.second.value();
892 const auto& vCov = lazyTools.localCovariances(*(itElectron->superCluster()->seed()));
893 anElectron.setMvaVariables(vCov[1],
ip3d);
906 anElectron.setPfIsolationVariables(newPFIsol);
910 anElectron.setIsolationPUPPI((*PUPPIIsolation_charged_hadrons)[elePtr],
911 (*PUPPIIsolation_neutral_hadrons)[elePtr],
912 (*PUPPIIsolation_photons)[elePtr]);
913 anElectron.setIsolationPUPPINoLeptons((*PUPPINoLeptonsIsolation_charged_hadrons)[elePtr],
914 (*PUPPINoLeptonsIsolation_neutral_hadrons)[elePtr],
915 (*PUPPINoLeptonsIsolation_photons)[elePtr]);
917 anElectron.setIsolationPUPPI(-999., -999., -999.);
918 anElectron.setIsolationPUPPINoLeptons(-999., -999., -999.);
921 std::vector<DetId> selectedCells;
922 bool barrel = itElectron->isEB();
926 clusIt != itElectron->superCluster()->clustersEnd();
929 DetId seed = lazyTools.getMaximum(**clusIt).first;
931 std::vector<DetId> dets5x5 =
934 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
937 for (
const std::pair<DetId, float>&
hit : (*clusIt)->hitsAndFractions()) {
938 selectedCells.push_back(
hit.first);
945 clusIt != itElectron->parentSuperCluster()->clustersEnd();
948 DetId seed = lazyTools.getMaximum(**clusIt).first;
950 std::vector<DetId> dets5x5 =
953 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
956 for (
const std::pair<DetId, float>&
hit : (*clusIt)->hitsAndFractions()) {
957 selectedCells.push_back(
hit.first);
963 std::sort(selectedCells.begin(), selectedCells.end());
964 std::unique(selectedCells.begin(), selectedCells.end());
977 unsigned nSelectedCells = selectedCells.size();
978 for (
unsigned icell = 0; icell < nSelectedCells; ++icell) {
984 selectedRecHits.
sort();
986 anElectron.embedRecHits(&selectedRecHits);
989 bool passconversionveto =
false;
990 if (hConversions.isValid()) {
999 anElectron.setPassConversionVeto(passconversionveto);
1016 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_