236 edm::InputTag reducedEBRecHitCollection(
string(
"reducedEcalRecHitsEB"));
237 edm::InputTag reducedEERecHitCollection(
string(
"reducedEcalRecHitsEE"));
278 std::vector<edm::Handle<edm::ValueMap<float> > > idhandles;
279 std::vector<pat::Electron::IdPair> ids;
295 bool beamSpotIsValid =
false;
296 bool primaryVertexIsValid =
false;
310 if ( pvHandle.
isValid() && !pvHandle->empty() ) {
311 primaryVertex = pvHandle->at(0);
312 primaryVertexIsValid =
true;
315 <<
"No primary vertex available from EventSetup, not adding high level selection \n";
338 std::vector<Electron> *
patElectrons =
new std::vector<Electron>();
346 i != pfElectrons->end(); ++
i, ++
index) {
355 bool MatchedToAmbiguousGsfTrack=
false;
357 unsigned int idx = itElectron - electrons->begin();
358 auto elePtr = electrons -> ptrAt(idx);
359 if (Matched || MatchedToAmbiguousGsfTrack)
continue;
363 if (itElectron->gsfTrack()==
i->gsfTrackRef()){
368 it!=itElectron->ambiguousGsfTracksEnd(); it++ ){
369 MatchedToAmbiguousGsfTrack |= (bool)(
i->gsfTrackRef()==(*it));
373 if (Matched || MatchedToAmbiguousGsfTrack){
381 anElectron.setPFCandidateRef( pfRef );
383 anElectron.setIsolationPUPPI((*PUPPIIsolation_charged_hadrons)[elePtr], (*PUPPIIsolation_neutral_hadrons)[elePtr], (*PUPPIIsolation_photons)[elePtr]);
384 anElectron.setIsolationPUPPINoLeptons((*PUPPINoLeptonsIsolation_charged_hadrons)[elePtr], (*PUPPINoLeptonsIsolation_neutral_hadrons)[elePtr], (*PUPPINoLeptonsIsolation_photons)[elePtr]);
387 anElectron.setIsolationPUPPI(-999., -999.,-999.);
388 anElectron.setIsolationPUPPINoLeptons(-999., -999.,-999.);
392 anElectron.setIsPF(
true );
415 primaryVertexIsValid,
420 ip3d = ip3dpv.second.value();
429 ids[
i].second = (*idhandles[
i])[elecsRef];
432 ids.push_back(std::make_pair(
"pf_evspi",pfRef->mva_e_pi()));
433 ids.push_back(std::make_pair(
"pf_evsmu",pfRef->mva_e_mu()));
434 anElectron.setElectronIDs(ids);
439 std::vector<float> vCov = lazyTools.localCovariances(*( itElectron->superCluster()->seed()));
440 anElectron.setMvaVariables(vCov[1], ip3d);
450 anElectron.setEcalPFClusterIso((*ecalPFClusterIsoMapH)[elecsRef]);
451 anElectron.setHcalPFClusterIso((*hcalPFClusterIsoMapH)[elecsRef]);
453 anElectron.setEcalPFClusterIso(-999.);
454 anElectron.setHcalPFClusterIso(-999.);
457 std::vector<DetId> selectedCells;
458 bool barrel = itElectron->isEB();
461 for (
reco::CaloCluster_iterator clusIt = itElectron->superCluster()->clustersBegin(); clusIt!=itElectron->superCluster()->clustersEnd(); ++clusIt) {
463 DetId seed = lazyTools.getMaximum(**clusIt).first;
467 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
470 for (
const std::pair<DetId, float> &
hit : (*clusIt)->hitsAndFractions()) {
471 selectedCells.push_back(
hit.first);
477 for (
reco::CaloCluster_iterator clusIt = itElectron->parentSuperCluster()->clustersBegin(); clusIt!=itElectron->parentSuperCluster()->clustersEnd(); ++clusIt) {
479 DetId seed = lazyTools.getMaximum(**clusIt).first;
483 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
486 for (
const std::pair<DetId, float> &
hit : (*clusIt)->hitsAndFractions()) {
487 selectedCells.push_back(
hit.first);
493 std::sort(selectedCells.begin(),selectedCells.end());
494 std::unique(selectedCells.begin(),selectedCells.end());
508 unsigned nSelectedCells = selectedCells.
size();
509 for (
unsigned icell = 0 ; icell < nSelectedCells ; ++icell) {
511 if ( it != recHits->
end() ) {
515 selectedRecHits.
sort();
516 if (
embedRecHits_) anElectron.embedRecHits(& selectedRecHits);
519 bool passconversionveto =
false;
528 anElectron.setPassConversionVeto( passconversionveto );
553 patElectrons->push_back(anElectron);
564 bool pfCandsPresent =
false, valMapPresent =
false;
575 unsigned int idx = itElectron - electrons->begin();
579 auto elePtr = electrons -> ptrAt(idx);
588 anElectron.setPFCandidateRef(
pf );
592 }
else if ( pfCandsPresent ) {
597 ie != pfElectrons->end(); ++ie, ++
index) {
600 if( trkRef == pfTrkRef ) {
603 anElectron.setPFCandidateRef( pfRef );
608 else if( valMapPresent ) {
613 pfId= pfElePtr.isNonnull();
616 anElectron.setIsPF( pfId );
626 anElectron.setIsolation(it->first, it->second);
630 for (
size_t j = 0, nd =
deposits.size(); j < nd; ++j) {
637 ids[
i].second = (*idhandles[
i])[elecsRef];
639 anElectron.setElectronIDs(ids);
663 primaryVertexIsValid,
668 ip3d = ip3dpv.second.value();
675 std::vector<float> vCov = lazyTools.localCovariances(*( itElectron->superCluster()->seed()));
676 anElectron.setMvaVariables(vCov[1], ip3d);
686 anElectron.setEcalPFClusterIso((*ecalPFClusterIsoMapH)[elecsRef]);
687 anElectron.setHcalPFClusterIso((*hcalPFClusterIsoMapH)[elecsRef]);
689 anElectron.setEcalPFClusterIso(-999.);
690 anElectron.setHcalPFClusterIso(-999.);
693 anElectron.setIsolationPUPPI((*PUPPIIsolation_charged_hadrons)[elePtr], (*PUPPIIsolation_neutral_hadrons)[elePtr], (*PUPPIIsolation_photons)[elePtr]);
694 anElectron.setIsolationPUPPINoLeptons((*PUPPINoLeptonsIsolation_charged_hadrons)[elePtr], (*PUPPINoLeptonsIsolation_neutral_hadrons)[elePtr], (*PUPPINoLeptonsIsolation_photons)[elePtr]);
697 anElectron.setIsolationPUPPI(-999., -999.,-999.);
698 anElectron.setIsolationPUPPINoLeptons(-999., -999.,-999.);
701 std::vector<DetId> selectedCells;
702 bool barrel = itElectron->isEB();
705 for (
reco::CaloCluster_iterator clusIt = itElectron->superCluster()->clustersBegin(); clusIt!=itElectron->superCluster()->clustersEnd(); ++clusIt) {
707 DetId seed = lazyTools.getMaximum(**clusIt).first;
711 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
714 for (
const std::pair<DetId, float> &
hit : (*clusIt)->hitsAndFractions()) {
715 selectedCells.push_back(
hit.first);
721 for (
reco::CaloCluster_iterator clusIt = itElectron->parentSuperCluster()->clustersBegin(); clusIt!=itElectron->parentSuperCluster()->clustersEnd(); ++clusIt) {
723 DetId seed = lazyTools.getMaximum(**clusIt).first;
727 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
730 for (
const std::pair<DetId, float> &
hit : (*clusIt)->hitsAndFractions()) {
731 selectedCells.push_back(
hit.first);
737 std::sort(selectedCells.begin(),selectedCells.end());
738 std::unique(selectedCells.begin(),selectedCells.end());
751 unsigned nSelectedCells = selectedCells.
size();
752 for (
unsigned icell = 0 ; icell < nSelectedCells ; ++icell) {
754 if ( it != recHits->
end() ) {
758 selectedRecHits.
sort();
759 if (
embedRecHits_) anElectron.embedRecHits(& selectedRecHits);
762 bool passconversionveto =
false;
770 anElectron.setPassConversionVeto( passconversionveto );
779 patElectrons->push_back(anElectron);
784 std::sort(patElectrons->begin(), patElectrons->end(),
pTComparator_);
787 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::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
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_photons_
const_iterator end() const
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)
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
iterator find(key_type k)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
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_
edm::EDGetTokenT< pat::PackedCandidateCollection > pcToken_
std::vector< NameTag > elecIDSrcs_
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const
std::vector< edm::Handle< edm::ValueMap< IsoDeposit > > > IsoDepositMaps