237 edm::InputTag reducedEBRecHitCollection(
string(
"reducedEcalRecHitsEB"));
238 edm::InputTag reducedEERecHitCollection(
string(
"reducedEcalRecHitsEE"));
279 std::vector<edm::Handle<edm::ValueMap<float> > > idhandles;
280 std::vector<pat::Electron::IdPair> ids;
296 bool beamSpotIsValid =
false;
297 bool primaryVertexIsValid =
false;
311 if ( pvHandle.
isValid() && !pvHandle->empty() ) {
312 primaryVertex = pvHandle->at(0);
313 primaryVertexIsValid =
true;
316 <<
"No primary vertex available from EventSetup, not adding high level selection \n";
339 std::vector<Electron> *
patElectrons =
new std::vector<Electron>();
347 i != pfElectrons->end(); ++
i, ++
index) {
356 bool MatchedToAmbiguousGsfTrack=
false;
358 unsigned int idx = itElectron - electrons->begin();
359 auto elePtr = electrons -> ptrAt(idx);
360 if (Matched || MatchedToAmbiguousGsfTrack)
continue;
364 if (itElectron->gsfTrack()==
i->gsfTrackRef()){
369 it!=itElectron->ambiguousGsfTracksEnd(); it++ ){
370 MatchedToAmbiguousGsfTrack |= (
bool)(
i->gsfTrackRef()==(*it));
374 if (Matched || MatchedToAmbiguousGsfTrack){
382 anElectron.setPFCandidateRef( pfRef );
384 anElectron.setIsolationPUPPI((*PUPPIIsolation_charged_hadrons)[elePtr], (*PUPPIIsolation_neutral_hadrons)[elePtr], (*PUPPIIsolation_photons)[elePtr]);
385 anElectron.setIsolationPUPPINoLeptons((*PUPPINoLeptonsIsolation_charged_hadrons)[elePtr], (*PUPPINoLeptonsIsolation_neutral_hadrons)[elePtr], (*PUPPINoLeptonsIsolation_photons)[elePtr]);
388 anElectron.setIsolationPUPPI(-999., -999.,-999.);
389 anElectron.setIsolationPUPPINoLeptons(-999., -999.,-999.);
393 anElectron.setIsPF(
true );
416 primaryVertexIsValid,
421 ip3d = ip3dpv.second.value();
430 ids[
i].second = (*idhandles[
i])[elecsRef];
433 ids.push_back(std::make_pair(
"pf_evspi",pfRef->mva_e_pi()));
434 ids.push_back(std::make_pair(
"pf_evsmu",pfRef->mva_e_mu()));
435 anElectron.setElectronIDs(ids);
440 std::vector<float> vCov = lazyTools.localCovariances(*( itElectron->superCluster()->seed()));
441 anElectron.setMvaVariables(vCov[1], ip3d);
453 anElectron.setPfIsolationVariables(newPFIsol);
456 std::vector<DetId> selectedCells;
457 bool barrel = itElectron->isEB();
460 for (
reco::CaloCluster_iterator clusIt = itElectron->superCluster()->clustersBegin(); clusIt!=itElectron->superCluster()->clustersEnd(); ++clusIt) {
462 DetId seed = lazyTools.getMaximum(**clusIt).first;
466 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
469 for (
const std::pair<DetId, float> &
hit : (*clusIt)->hitsAndFractions()) {
470 selectedCells.push_back(
hit.first);
476 for (
reco::CaloCluster_iterator clusIt = itElectron->parentSuperCluster()->clustersBegin(); clusIt!=itElectron->parentSuperCluster()->clustersEnd(); ++clusIt) {
478 DetId seed = lazyTools.getMaximum(**clusIt).first;
482 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
485 for (
const std::pair<DetId, float> &
hit : (*clusIt)->hitsAndFractions()) {
486 selectedCells.push_back(
hit.first);
492 std::sort(selectedCells.begin(),selectedCells.end());
493 std::unique(selectedCells.begin(),selectedCells.end());
507 unsigned nSelectedCells = selectedCells.
size();
508 for (
unsigned icell = 0 ; icell < nSelectedCells ; ++icell) {
510 if ( it != recHits->
end() ) {
514 selectedRecHits.
sort();
515 if (
embedRecHits_) anElectron.embedRecHits(& selectedRecHits);
518 bool passconversionveto =
false;
527 anElectron.setPassConversionVeto( passconversionveto );
552 patElectrons->push_back(anElectron);
563 bool pfCandsPresent =
false, valMapPresent =
false;
574 unsigned int idx = itElectron - electrons->begin();
578 auto elePtr = electrons -> ptrAt(idx);
587 anElectron.setPFCandidateRef(
pf );
591 }
else if ( pfCandsPresent ) {
596 ie != pfElectrons->end(); ++ie, ++
index) {
599 if( trkRef == pfTrkRef ) {
602 anElectron.setPFCandidateRef( pfRef );
607 else if( valMapPresent ) {
612 pfId= pfElePtr.isNonnull();
615 anElectron.setIsPF( pfId );
625 anElectron.setIsolation(it->first, it->second);
629 for (
size_t j = 0, nd =
deposits.size(); j < nd; ++j) {
636 ids[
i].second = (*idhandles[
i])[elecsRef];
638 anElectron.setElectronIDs(ids);
662 primaryVertexIsValid,
667 ip3d = ip3dpv.second.value();
674 std::vector<float> vCov = lazyTools.localCovariances(*( itElectron->superCluster()->seed()));
675 anElectron.setMvaVariables(vCov[1], ip3d);
688 anElectron.setPfIsolationVariables(newPFIsol);
692 anElectron.setIsolationPUPPI((*PUPPIIsolation_charged_hadrons)[elePtr], (*PUPPIIsolation_neutral_hadrons)[elePtr], (*PUPPIIsolation_photons)[elePtr]);
693 anElectron.setIsolationPUPPINoLeptons((*PUPPINoLeptonsIsolation_charged_hadrons)[elePtr], (*PUPPINoLeptonsIsolation_neutral_hadrons)[elePtr], (*PUPPINoLeptonsIsolation_photons)[elePtr]);
696 anElectron.setIsolationPUPPI(-999., -999.,-999.);
697 anElectron.setIsolationPUPPINoLeptons(-999., -999.,-999.);
700 std::vector<DetId> selectedCells;
701 bool barrel = itElectron->isEB();
704 for (
reco::CaloCluster_iterator clusIt = itElectron->superCluster()->clustersBegin(); clusIt!=itElectron->superCluster()->clustersEnd(); ++clusIt) {
706 DetId seed = lazyTools.getMaximum(**clusIt).first;
710 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
713 for (
const std::pair<DetId, float> &
hit : (*clusIt)->hitsAndFractions()) {
714 selectedCells.push_back(
hit.first);
720 for (
reco::CaloCluster_iterator clusIt = itElectron->parentSuperCluster()->clustersBegin(); clusIt!=itElectron->parentSuperCluster()->clustersEnd(); ++clusIt) {
722 DetId seed = lazyTools.getMaximum(**clusIt).first;
726 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
729 for (
const std::pair<DetId, float> &
hit : (*clusIt)->hitsAndFractions()) {
730 selectedCells.push_back(
hit.first);
736 std::sort(selectedCells.begin(),selectedCells.end());
737 std::unique(selectedCells.begin(),selectedCells.end());
750 unsigned nSelectedCells = selectedCells.
size();
751 for (
unsigned icell = 0 ; icell < nSelectedCells ; ++icell) {
753 if ( it != recHits->
end() ) {
757 selectedRecHits.
sort();
758 if (
embedRecHits_) anElectron.embedRecHits(& selectedRecHits);
761 bool passconversionveto =
false;
769 anElectron.setPassConversionVeto( passconversionveto );
778 patElectrons->push_back(anElectron);
783 std::sort(patElectrons->begin(), patElectrons->end(),
pTComparator_);
786 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