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);
452 anElectron.setPfIsolationVariables(newPFIsol);
455 std::vector<DetId> selectedCells;
456 bool barrel = itElectron->isEB();
459 for (
reco::CaloCluster_iterator clusIt = itElectron->superCluster()->clustersBegin(); clusIt!=itElectron->superCluster()->clustersEnd(); ++clusIt) {
461 DetId seed = lazyTools.getMaximum(**clusIt).first;
465 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
468 for (
const std::pair<DetId, float> &
hit : (*clusIt)->hitsAndFractions()) {
469 selectedCells.push_back(
hit.first);
475 for (
reco::CaloCluster_iterator clusIt = itElectron->parentSuperCluster()->clustersBegin(); clusIt!=itElectron->parentSuperCluster()->clustersEnd(); ++clusIt) {
477 DetId seed = lazyTools.getMaximum(**clusIt).first;
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);
491 std::sort(selectedCells.begin(),selectedCells.end());
492 std::unique(selectedCells.begin(),selectedCells.end());
506 unsigned nSelectedCells = selectedCells.
size();
507 for (
unsigned icell = 0 ; icell < nSelectedCells ; ++icell) {
509 if ( it != recHits->
end() ) {
513 selectedRecHits.
sort();
514 if (
embedRecHits_) anElectron.embedRecHits(& selectedRecHits);
517 bool passconversionveto =
false;
526 anElectron.setPassConversionVeto( passconversionveto );
551 patElectrons->push_back(anElectron);
562 bool pfCandsPresent =
false, valMapPresent =
false;
573 unsigned int idx = itElectron - electrons->begin();
577 auto elePtr = electrons -> ptrAt(idx);
586 anElectron.setPFCandidateRef(
pf );
590 }
else if ( pfCandsPresent ) {
595 ie != pfElectrons->end(); ++ie, ++
index) {
598 if( trkRef == pfTrkRef ) {
601 anElectron.setPFCandidateRef( pfRef );
606 else if( valMapPresent ) {
611 pfId= pfElePtr.isNonnull();
614 anElectron.setIsPF( pfId );
624 anElectron.setIsolation(it->first, it->second);
628 for (
size_t j = 0, nd =
deposits.size(); j < nd; ++j) {
635 ids[
i].second = (*idhandles[
i])[elecsRef];
637 anElectron.setElectronIDs(ids);
661 primaryVertexIsValid,
666 ip3d = ip3dpv.second.value();
673 std::vector<float> vCov = lazyTools.localCovariances(*( itElectron->superCluster()->seed()));
674 anElectron.setMvaVariables(vCov[1], ip3d);
687 anElectron.setPfIsolationVariables(newPFIsol);
691 anElectron.setIsolationPUPPI((*PUPPIIsolation_charged_hadrons)[elePtr], (*PUPPIIsolation_neutral_hadrons)[elePtr], (*PUPPIIsolation_photons)[elePtr]);
692 anElectron.setIsolationPUPPINoLeptons((*PUPPINoLeptonsIsolation_charged_hadrons)[elePtr], (*PUPPINoLeptonsIsolation_neutral_hadrons)[elePtr], (*PUPPINoLeptonsIsolation_photons)[elePtr]);
695 anElectron.setIsolationPUPPI(-999., -999.,-999.);
696 anElectron.setIsolationPUPPINoLeptons(-999., -999.,-999.);
699 std::vector<DetId> selectedCells;
700 bool barrel = itElectron->isEB();
703 for (
reco::CaloCluster_iterator clusIt = itElectron->superCluster()->clustersBegin(); clusIt!=itElectron->superCluster()->clustersEnd(); ++clusIt) {
705 DetId seed = lazyTools.getMaximum(**clusIt).first;
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 for (
reco::CaloCluster_iterator clusIt = itElectron->parentSuperCluster()->clustersBegin(); clusIt!=itElectron->parentSuperCluster()->clustersEnd(); ++clusIt) {
721 DetId seed = lazyTools.getMaximum(**clusIt).first;
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);
735 std::sort(selectedCells.begin(),selectedCells.end());
736 std::unique(selectedCells.begin(),selectedCells.end());
749 unsigned nSelectedCells = selectedCells.
size();
750 for (
unsigned icell = 0 ; icell < nSelectedCells ; ++icell) {
752 if ( it != recHits->
end() ) {
756 selectedRecHits.
sort();
757 if (
embedRecHits_) anElectron.embedRecHits(& selectedRecHits);
760 bool passconversionveto =
false;
768 anElectron.setPassConversionVeto( passconversionveto );
777 patElectrons->push_back(anElectron);
782 std::sort(patElectrons->begin(), patElectrons->end(),
pTComparator_);
785 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