CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
PFEGammaAlgo Class Reference

#include <PFEGammaAlgo.h>

Classes

struct  EgammaObjects
 
class  GBRForests
 
struct  PFEGConfigInfo
 
struct  ProtoEGObject
 

Public Types

using ClusterMap = std::unordered_map< PFClusterElement const *, std::vector< PFClusterElement const * > >
 
typedef reco::PFCluster::EEtoPSAssociation EEtoPSAssociation
 
typedef std::unordered_map< const PFKFElement *, float > KFValMap
 
typedef reco::PFBlockElementBrem PFBremElement
 
typedef reco::PFBlockElementCluster PFClusterElement
 
typedef reco::PFBlockElementGsfTrack PFGSFElement
 
typedef reco::PFBlockElementTrack PFKFElement
 
typedef reco::PFBlockElementSuperCluster PFSCElement
 

Public Member Functions

EgammaObjects operator() (const reco::PFBlockRef &block)
 
 PFEGammaAlgo (const PFEGConfigInfo &, GBRForests const &gbrForests, EEtoPSAssociation const &eetops, ESEEIntercalibConstants const &esEEInterCalib, ESChannelStatus const &channelStatus, reco::Vertex const &primaryVertex)
 

Private Member Functions

int attachPSClusters (const PFClusterElement *, ClusterMap::mapped_type &)
 
reco::SuperCluster buildRefinedSuperCluster (const ProtoEGObject &)
 
float calculateEleMVA (const ProtoEGObject &, reco::PFCandidateEGammaExtra &) const
 
void dumpCurrentRefinableObjects () const
 
float evaluateSingleLegMVA (const reco::PFBlockRef &blockref, const reco::Vertex &primaryVtx, unsigned int trackIndex)
 
void fillExtraInfo (const ProtoEGObject &, reco::PFCandidateEGammaExtra &)
 
EgammaObjects fillPFCandidates (const std::list< ProtoEGObject > &)
 
void initializeProtoCands (std::list< ProtoEGObject > &)
 
bool isMuon (const reco::PFBlockElement &)
 
bool isPrimaryTrack (const reco::PFBlockElementTrack &KfEl, const reco::PFBlockElementGsfTrack &GsfEl)
 
void linkKFTrackToECAL (PFKFElement const *, ProtoEGObject &)
 
void linkRefinableObjectBremTangentsToECAL (ProtoEGObject &)
 
void linkRefinableObjectConvSecondaryKFsToSecondaryKFs (ProtoEGObject &)
 
void linkRefinableObjectECALToSingleLegConv (ProtoEGObject &)
 
void linkRefinableObjectGSFTracksToKFs (ProtoEGObject &)
 
void linkRefinableObjectKFTracksToECAL (ProtoEGObject &)
 
void linkRefinableObjectPrimaryGSFTrackToECAL (ProtoEGObject &)
 
void linkRefinableObjectPrimaryGSFTrackToHCAL (ProtoEGObject &)
 
void linkRefinableObjectPrimaryKFsToSecondaryKFs (ProtoEGObject &)
 
void linkRefinableObjectSecondaryKFsToECAL (ProtoEGObject &)
 
void mergeROsByAnyLink (std::list< ProtoEGObject > &)
 
void removeOrLinkECALClustersToKFTracks ()
 
void unlinkRefinableObjectKFandECALMatchedToHCAL (ProtoEGObject &, bool removeFreeECAL=false, bool removeSCECAL=false)
 
void unlinkRefinableObjectKFandECALWithBadEoverP (ProtoEGObject &)
 
bool unwrapSuperCluster (const reco::PFBlockElementSuperCluster *, std::vector< FlaggedPtr< const PFClusterElement >> &, ClusterMap &)
 

Private Attributes

reco::PFBlockRef _currentblock
 
reco::PFBlock::LinkData _currentlinks
 
std::vector< std::vector< FlaggedPtr< const reco::PFBlockElement > > > _splayedblock
 
PFEGConfigInfo const & cfg_
 
ESChannelStatus const & channelStatus_
 
reco::PFCluster::EEtoPSAssociation const & eetops_
 
GBRForests const & gbrForests_
 
reco::Vertex const & primaryVertex_
 
PFEnergyCalibration thePFEnergyCalibration_
 

Detailed Description

Definition at line 62 of file PFEGammaAlgo.h.

Member Typedef Documentation

◆ ClusterMap

using PFEGammaAlgo::ClusterMap = std::unordered_map<PFClusterElement const*, std::vector<PFClusterElement const*> >

Definition at line 72 of file PFEGammaAlgo.h.

◆ EEtoPSAssociation

Definition at line 64 of file PFEGammaAlgo.h.

◆ KFValMap

typedef std::unordered_map<const PFKFElement*, float> PFEGammaAlgo::KFValMap

Definition at line 70 of file PFEGammaAlgo.h.

◆ PFBremElement

Definition at line 66 of file PFEGammaAlgo.h.

◆ PFClusterElement

Definition at line 69 of file PFEGammaAlgo.h.

◆ PFGSFElement

Definition at line 67 of file PFEGammaAlgo.h.

◆ PFKFElement

Definition at line 68 of file PFEGammaAlgo.h.

◆ PFSCElement

Definition at line 65 of file PFEGammaAlgo.h.

Constructor & Destructor Documentation

◆ PFEGammaAlgo()

PFEGammaAlgo::PFEGammaAlgo ( const PFEGConfigInfo cfg,
GBRForests const &  gbrForests,
EEtoPSAssociation const &  eetops,
ESEEIntercalibConstants const &  esEEInterCalib,
ESChannelStatus const &  channelStatus,
reco::Vertex const &  primaryVertex 
)

Definition at line 445 of file PFEGammaAlgo.cc.

451  : gbrForests_(gbrForests),
452  eetops_(eetops),
453  cfg_(cfg),
455  channelStatus_(channelStatus) {
457 }

References PFEnergyCalibration::initAlphaGamma_ESplanes_fromDB(), and thePFEnergyCalibration_.

Member Function Documentation

◆ attachPSClusters()

int PFEGammaAlgo::attachPSClusters ( const PFClusterElement ,
ClusterMap::mapped_type &   
)
private

Definition at line 901 of file PFEGammaAlgo.cc.

901  {
902  if (ecalclus->clusterRef()->layer() == PFLayer::ECAL_BARREL)
903  return 0;
904  edm::Ptr<reco::PFCluster> clusptr = refToPtr(ecalclus->clusterRef());
905  EEtoPSElement ecalkey(clusptr.key(), clusptr);
906  auto assc_ps =
907  std::equal_range(eetops_.cbegin(), eetops_.cend(), ecalkey, [](const EEtoPSElement& a, const EEtoPSElement& b) {
908  return a.first < b.first;
909  });
910  for (const auto& ps1 : _splayedblock[reco::PFBlockElement::PS1]) {
911  edm::Ptr<reco::PFCluster> temp = refToPtr(ps1->clusterRef());
912  for (auto pscl = assc_ps.first; pscl != assc_ps.second; ++pscl) {
913  if (pscl->second == temp) {
914  const ClusterElement* pstemp = docast(const ClusterElement*, ps1.get());
915  eslist.emplace_back(pstemp);
916  }
917  }
918  }
919  for (const auto& ps2 : _splayedblock[reco::PFBlockElement::PS2]) {
920  edm::Ptr<reco::PFCluster> temp = refToPtr(ps2->clusterRef());
921  for (auto pscl = assc_ps.first; pscl != assc_ps.second; ++pscl) {
922  if (pscl->second == temp) {
923  const ClusterElement* pstemp = docast(const ClusterElement*, ps2.get());
924  eslist.emplace_back(pstemp);
925  }
926  }
927  }
928  return eslist.size();
929 }

References _splayedblock, a, b, docast, PFLayer::ECAL_BARREL, eetops_, edm::Ptr< T >::key(), reco::PFBlockElement::PS1, reco::PFBlockElement::PS2, edm::refToPtr(), and groupFilesInBlocks::temp.

Referenced by linkKFTrackToECAL(), linkRefinableObjectBremTangentsToECAL(), linkRefinableObjectPrimaryGSFTrackToECAL(), linkRefinableObjectSecondaryKFsToECAL(), and unwrapSuperCluster().

◆ buildRefinedSuperCluster()

reco::SuperCluster PFEGammaAlgo::buildRefinedSuperCluster ( const ProtoEGObject RO)
private

Definition at line 1786 of file PFEGammaAlgo.cc.

1786  {
1787  if (RO.ecalclusters.empty()) {
1788  return reco::SuperCluster(0.0, math::XYZPoint(0, 0, 0));
1789  }
1790 
1791  bool isEE = false;
1792  // need the vector of raw pointers for a PF width class
1793  std::vector<const reco::PFCluster*> bare_ptrs;
1794  // calculate necessary parameters and build the SC
1795  double posX(0), posY(0), posZ(0), rawSCEnergy(0), corrSCEnergy(0), corrPSEnergy(0), ps1_energy(0.0), ps2_energy(0.0);
1796  for (auto& clus : RO.ecalclusters) {
1797  double ePS1 = 0;
1798  double ePS2 = 0;
1799  isEE = PFLayer::ECAL_ENDCAP == clus->clusterRef()->layer();
1800  auto clusptr = edm::refToPtr<reco::PFClusterCollection>(clus->clusterRef());
1801  bare_ptrs.push_back(clusptr.get());
1802 
1803  const double cluseraw = clusptr->energy();
1804  double cluscalibe = clusptr->correctedEnergy();
1805  const math::XYZPoint& cluspos = clusptr->position();
1806  posX += cluseraw * cluspos.X();
1807  posY += cluseraw * cluspos.Y();
1808  posZ += cluseraw * cluspos.Z();
1809  // update EE calibrated super cluster energies
1810  if (isEE && RO.ecal2ps.count(clus.get())) {
1811  const auto& psclusters = RO.ecal2ps.at(clus.get());
1812 
1813  std::vector<reco::PFCluster const*> psClusterPointers;
1814  for (auto const& psc : psclusters) {
1815  psClusterPointers.push_back(psc->clusterRef().get());
1816  }
1817  auto calibratedEnergies = thePFEnergyCalibration_.calibrateEndcapClusterEnergies(
1818  *clusptr, psClusterPointers, channelStatus_, cfg_.applyCrackCorrections);
1819  cluscalibe = calibratedEnergies.clusterEnergy;
1820  ePS1 = calibratedEnergies.ps1Energy;
1821  ePS2 = calibratedEnergies.ps2Energy;
1822  }
1823  if (ePS1 == -1.)
1824  ePS1 = 0;
1825  if (ePS2 == -1.)
1826  ePS2 = 0;
1827 
1828  rawSCEnergy += cluseraw;
1829  corrSCEnergy += cluscalibe;
1830  ps1_energy += ePS1;
1831  ps2_energy += ePS2;
1832  corrPSEnergy += ePS1 + ePS2;
1833  }
1834  posX /= rawSCEnergy;
1835  posY /= rawSCEnergy;
1836  posZ /= rawSCEnergy;
1837 
1838  // now build the supercluster
1839  reco::SuperCluster new_sc(corrSCEnergy, math::XYZPoint(posX, posY, posZ));
1840 
1841  auto clusptr = edm::refToPtr<reco::PFClusterCollection>(RO.ecalclusters.front()->clusterRef());
1842  new_sc.setCorrectedEnergy(corrSCEnergy);
1843  new_sc.setSeed(clusptr);
1844  new_sc.setPreshowerEnergyPlane1(ps1_energy);
1845  new_sc.setPreshowerEnergyPlane2(ps2_energy);
1846  new_sc.setPreshowerEnergy(corrPSEnergy);
1847  for (const auto& clus : RO.ecalclusters) {
1848  clusptr = edm::refToPtr<reco::PFClusterCollection>(clus->clusterRef());
1849  new_sc.addCluster(clusptr);
1850  auto& hits_and_fractions = clusptr->hitsAndFractions();
1851  for (auto& hit_and_fraction : hits_and_fractions) {
1852  new_sc.addHitAndFraction(hit_and_fraction.first, hit_and_fraction.second);
1853  }
1854  // put the preshower stuff back in later
1855  if (RO.ecal2ps.count(clus.get())) {
1856  const auto& cluspsassociation = RO.ecal2ps.at(clus.get());
1857  // EE rechits should be uniquely matched to sets of pre-shower
1858  // clusters at this point, so we throw an exception if otherwise
1859  // now wrapped in EDM debug flags
1860  for (const auto& pscluselem : cluspsassociation) {
1861  edm::Ptr<reco::PFCluster> psclus = edm::refToPtr<reco::PFClusterCollection>(pscluselem->clusterRef());
1862 #ifdef PFFLOW_DEBUG
1863  auto found_pscluster =
1864  std::find(new_sc.preshowerClustersBegin(), new_sc.preshowerClustersEnd(), reco::CaloClusterPtr(psclus));
1865  if (found_pscluster == new_sc.preshowerClustersEnd()) {
1866 #endif
1867  new_sc.addPreshowerCluster(psclus);
1868 #ifdef PFFLOW_DEBUG
1869  } else {
1870  throw cms::Exception("PFECALSuperClusterAlgo::buildSuperCluster")
1871  << "Found a PS cluster matched to more than one EE cluster!" << std::endl
1872  << std::hex << psclus.get() << " == " << found_pscluster->get() << std::dec << std::endl;
1873  }
1874 #endif
1875  }
1876  }
1877  }
1878 
1879  // calculate linearly weighted cluster widths
1880  PFClusterWidthAlgo pfwidth(bare_ptrs);
1881  new_sc.setEtaWidth(pfwidth.pflowEtaWidth());
1882  new_sc.setPhiWidth(pfwidth.pflowPhiWidth());
1883 
1884  // cache the value of the raw energy
1885  new_sc.rawEnergy();
1886 
1887  return new_sc;
1888 }

References reco::SuperCluster::addCluster(), reco::CaloCluster::addHitAndFraction(), reco::SuperCluster::addPreshowerCluster(), PFEGammaAlgo::PFEGConfigInfo::applyCrackCorrections, PFEnergyCalibration::calibrateEndcapClusterEnergies(), cfg_, channelStatus_, PFEnergyCalibration::CalibratedEndcapPFClusterEnergies::clusterEnergy, TauDecayModes::dec, PFEGammaAlgo::ProtoEGObject::ecal2ps, PFLayer::ECAL_ENDCAP, PFEGammaAlgo::ProtoEGObject::ecalclusters, Exception, spr::find(), edm::Ptr< T >::get(), PFClusterWidthAlgo::pflowEtaWidth(), PFClusterWidthAlgo::pflowPhiWidth(), RecoTauValidation_cfi::posX, RecoTauValidation_cfi::posY, reco::SuperCluster::preshowerClustersBegin(), reco::SuperCluster::preshowerClustersEnd(), reco::SuperCluster::rawEnergy(), reco::CaloCluster::setCorrectedEnergy(), reco::SuperCluster::setEtaWidth(), reco::SuperCluster::setPhiWidth(), reco::SuperCluster::setPreshowerEnergy(), reco::SuperCluster::setPreshowerEnergyPlane1(), reco::SuperCluster::setPreshowerEnergyPlane2(), reco::SuperCluster::setSeed(), and thePFEnergyCalibration_.

Referenced by fillPFCandidates().

◆ calculateEleMVA()

float PFEGammaAlgo::calculateEleMVA ( const ProtoEGObject ro,
reco::PFCandidateEGammaExtra xtra 
) const
private

Definition at line 1601 of file PFEGammaAlgo.cc.

1601  {
1602  if (ro.primaryGSFs.empty()) {
1603  return -2.0f;
1604  }
1605  const PFGSFElement* gsfElement = ro.primaryGSFs.front();
1606  const PFKFElement* kfElement = nullptr;
1607  if (!ro.primaryKFs.empty()) {
1608  kfElement = ro.primaryKFs.front();
1609  }
1610  auto const& refGsf = gsfElement->GsftrackRef();
1611  reco::TrackRef refKf;
1612  constexpr float mEl = 0.000511;
1613  const double eInGsf = std::hypot(refGsf->pMode(), mEl);
1614  double dEtGsfEcal = 1e6;
1615  double sigmaEtaEta = 1e-14;
1616  const double eneHcalGsf =
1617  std::accumulate(ro.hcalClusters.begin(), ro.hcalClusters.end(), 0.0, [](const double a, auto const& b) {
1618  return a + b->clusterRef()->energy();
1619  });
1620  if (!ro.primaryKFs.empty()) {
1621  refKf = ro.primaryKFs.front()->trackRef();
1622  }
1623  const double eOutGsf = gsfElement->Pout().t();
1624  const double etaOutGsf = gsfElement->positionAtECALEntrance().eta();
1625  double firstEcalGsfEnergy{0.0};
1626  double otherEcalGsfEnergy{0.0};
1627  double ecalBremEnergy{0.0};
1628  //shower shape of cluster closest to gsf track
1629  std::vector<const reco::PFCluster*> gsfCluster;
1630  for (const auto& ecal : ro.ecalclusters) {
1631  const double cenergy = ecal->clusterRef()->correctedEnergy();
1632  bool hasgsf = ro.localMap.contains(gsfElement, ecal.get());
1633  bool haskf = ro.localMap.contains(kfElement, ecal.get());
1634  bool hasbrem = false;
1635  for (const auto& brem : ro.brems) {
1636  if (ro.localMap.contains(brem, ecal.get())) {
1637  hasbrem = true;
1638  }
1639  }
1640  if (hasbrem && ecal.get() != ro.electronClusters[0]) {
1641  ecalBremEnergy += cenergy;
1642  }
1643  if (!hasbrem && ecal.get() != ro.electronClusters[0]) {
1644  if (hasgsf)
1645  otherEcalGsfEnergy += cenergy;
1646  if (haskf)
1647  ecalBremEnergy += cenergy; // from conv. brem!
1648  if (!(hasgsf || haskf))
1649  otherEcalGsfEnergy += cenergy; // stuff from SC
1650  }
1651  }
1652 
1653  if (ro.electronClusters[0]) {
1654  reco::PFClusterRef cref = ro.electronClusters[0]->clusterRef();
1655  xtra.setGsfElectronClusterRef(_currentblock, *(ro.electronClusters[0]));
1656  firstEcalGsfEnergy = cref->correctedEnergy();
1657  dEtGsfEcal = cref->positionREP().eta() - etaOutGsf;
1658  gsfCluster.push_back(cref.get());
1659  PFClusterWidthAlgo pfwidth(gsfCluster);
1660  sigmaEtaEta = pfwidth.pflowSigmaEtaEta();
1661  }
1662 
1663  // brem sequence information
1664  float firstBrem{-1.0f};
1665  float earlyBrem{-1.0f};
1666  float lateBrem{-1.0f};
1667  if (ro.nBremsWithClusters > 0) {
1668  firstBrem = ro.firstBrem;
1669  earlyBrem = ro.firstBrem < 4 ? 1.0f : 0.0f;
1670  lateBrem = ro.lateBrem == 1 ? 1.0f : 0.0f;
1671  }
1672  xtra.setEarlyBrem(earlyBrem);
1673  xtra.setLateBrem(lateBrem);
1674  if (firstEcalGsfEnergy > 0.0) {
1675  if (refGsf.isNonnull()) {
1676  xtra.setGsfTrackPout(gsfElement->Pout());
1677  // normalization observables
1678  const float ptGsf = refGsf->ptMode();
1679  const float etaGsf = refGsf->etaMode();
1680  // tracking observables
1681  const double ptModeErrorGsf = refGsf->ptModeError();
1682  float ptModeErrOverPtGsf = (ptModeErrorGsf > 0. ? ptModeErrorGsf / ptGsf : 1.0);
1683  float chi2Gsf = refGsf->normalizedChi2();
1684  float dPtOverPtGsf = (ptGsf - gsfElement->Pout().pt()) / ptGsf;
1685  // kalman filter vars
1686  float nHitKf = refKf.isNonnull() ? refKf->hitPattern().trackerLayersWithMeasurement() : 0;
1687  float chi2Kf = refKf.isNonnull() ? refKf->normalizedChi2() : -0.01;
1688 
1689  //tracker + calorimetry observables
1690  float eTotPinMode = (firstEcalGsfEnergy + otherEcalGsfEnergy + ecalBremEnergy) / eInGsf;
1691  float eGsfPoutMode = firstEcalGsfEnergy / eOutGsf;
1692  float eTotBremPinPoutMode = (ecalBremEnergy + otherEcalGsfEnergy) / (eInGsf - eOutGsf);
1693  float dEtaGsfEcalClust = std::abs(dEtGsfEcal);
1694  float logSigmaEtaEta = std::log(sigmaEtaEta);
1695  float hOverHe = eneHcalGsf / (eneHcalGsf + firstEcalGsfEnergy);
1696 
1697  xtra.setDeltaEta(dEtaGsfEcalClust);
1699  xtra.setHadEnergy(eneHcalGsf);
1700 
1701  // Apply bounds to variables and calculate MVA
1702  dPtOverPtGsf = std::clamp(dPtOverPtGsf, -0.2f, 1.0f);
1703  ptModeErrOverPtGsf = std::min(ptModeErrOverPtGsf, 0.3f);
1704  chi2Gsf = std::min(chi2Gsf, 10.0f);
1705  chi2Kf = std::min(chi2Kf, 10.0f);
1706  eTotPinMode = std::clamp(eTotPinMode, 0.0f, 5.0f);
1707  eGsfPoutMode = std::clamp(eGsfPoutMode, 0.0f, 5.0f);
1708  eTotBremPinPoutMode = std::clamp(eTotBremPinPoutMode, 0.0f, 5.0f);
1709  dEtaGsfEcalClust = std::min(dEtaGsfEcalClust, 0.1f);
1710  logSigmaEtaEta = std::max(logSigmaEtaEta, -14.0f);
1711 
1712  // not used for moment, weird behavior of variable
1713  //float dPtOverPtKf = refKf.isNonnull() ? (refKf->pt() - refKf->outerPt())/refKf->pt() : -0.01;
1714  //dPtOverPtKf = std::clamp(dPtOverPtKf,-0.2f, 1.0f);
1715 
1716  /*
1717  * To be used for debugging:
1718  * pretty-print the PFEgamma electron MVA input variables
1719  *
1720  * std::cout << " **** PFEG BDT observables ****" << endl;
1721  * std::cout << " < Normalization > " << endl;
1722  * std::cout << " ptGsf " << ptGsf << " Pin " << eInGsf
1723  * << " Pout " << eOutGsf << " etaGsf " << etaGsf << endl;
1724  * std::cout << " < PureTracking > " << endl;
1725  * std::cout << " ptModeErrOverPtGsf " << ptModeErrOverPtGsf
1726  * << " dPtOverPtGsf " << dPtOverPtGsf
1727  * << " chi2Gsf " << chi2Gsf
1728  * << " nhit_gsf " << nhit_gsf
1729  * << " dPtOverPtKf " << dPtOverPtKf
1730  * << " chi2Kf " << chi2Kf
1731  * << " nHitKf " << nHitKf << endl;
1732  * std::cout << " < track-ecal-hcal-ps " << endl;
1733  * std::cout << " eTotPinMode " << eTotPinMode
1734  * << " eGsfPoutMode " << eGsfPoutMode
1735  * << " eTotBremPinPoutMode " << eTotBremPinPoutMode
1736  * << " dEtaGsfEcalClust " << dEtaGsfEcalClust
1737  * << " logSigmaEtaEta " << logSigmaEtaEta
1738  * << " hOverHe " << hOverHe << " Hcal energy " << eneHcalGsf
1739  * << " lateBrem " << lateBrem
1740  * << " firstBrem " << firstBrem << endl;
1741  */
1742 
1743  float vars[] = {std::log(ptGsf),
1744  etaGsf,
1745  ptModeErrOverPtGsf,
1746  dPtOverPtGsf,
1747  chi2Gsf,
1748  nHitKf,
1749  chi2Kf,
1750  eTotPinMode,
1751  eGsfPoutMode,
1752  eTotBremPinPoutMode,
1753  dEtaGsfEcalClust,
1754  logSigmaEtaEta,
1755  hOverHe,
1756  lateBrem,
1757  firstBrem};
1758 
1759  return gbrForests_.ele_->GetAdaBoostClassifier(vars);
1760  }
1761  }
1762  return -2.0f;
1763 }

References _currentblock, a, funct::abs(), b, PFEGammaAlgo::ProtoEGObject::brems, CommutativePairs< T >::contains(), MillePedeFileConverter_cfg::e, bsc_activity_cfg::ecal, PFEGammaAlgo::ProtoEGObject::ecalclusters, PFEGammaAlgo::GBRForests::ele_, PFEGammaAlgo::ProtoEGObject::electronClusters, f, PFEGammaAlgo::ProtoEGObject::firstBrem, gbrForests_, edm::Ref< C, T, F >::get(), reco::PFBlockElementGsfTrack::GsftrackRef(), PFEGammaAlgo::ProtoEGObject::hcalClusters, edm::Ref< C, T, F >::isNonnull(), PFEGammaAlgo::ProtoEGObject::lateBrem, PFEGammaAlgo::ProtoEGObject::localMap, dqm-mbProfile::log, SiStripPI::max, min(), PFEGammaAlgo::ProtoEGObject::nBremsWithClusters, PFClusterWidthAlgo::pflowSigmaEtaEta(), reco::PFBlockElementGsfTrack::positionAtECALEntrance(), reco::PFBlockElementGsfTrack::Pout(), PFEGammaAlgo::ProtoEGObject::primaryGSFs, PFEGammaAlgo::ProtoEGObject::primaryKFs, reco::PFCandidateEGammaExtra::setDeltaEta(), reco::PFCandidateEGammaExtra::setEarlyBrem(), reco::PFCandidateEGammaExtra::setGsfElectronClusterRef(), reco::PFCandidateEGammaExtra::setGsfTrackPout(), reco::PFCandidateEGammaExtra::setHadEnergy(), reco::PFCandidateEGammaExtra::setLateBrem(), reco::PFCandidateEGammaExtra::setSigmaEtaEta(), and electronIdCutBasedExt_cfi::sigmaEtaEta.

Referenced by fillPFCandidates().

◆ dumpCurrentRefinableObjects()

void PFEGammaAlgo::dumpCurrentRefinableObjects ( ) const
private

Definition at line 931 of file PFEGammaAlgo.cc.

931  {
932 #ifdef PFLOW_DEBUG
933  edm::LogVerbatim("PFEGammaAlgo")
934  //<< "Dumping current block: " << std::endl << *_currentblock << std::endl
935  << "Dumping " << refinableObjects.size() << " refinable objects for this block: " << std::endl;
936  for (const auto& ro : refinableObjects) {
937  std::stringstream info;
938  info << "Refinable Object:" << std::endl;
939  if (ro.parentSC) {
940  info << "\tSuperCluster element attached to object:" << std::endl << '\t';
941  ro.parentSC->Dump(info, "\t");
942  info << std::endl;
943  }
944  if (ro.electronSeed.isNonnull()) {
945  info << "\tGSF element attached to object:" << std::endl;
946  ro.primaryGSFs.front()->Dump(info, "\t");
947  info << std::endl;
948  info << "firstBrem : " << ro.firstBrem << " lateBrem : " << ro.lateBrem
949  << " nBrems with cluster : " << ro.nBremsWithClusters << std::endl;
950  ;
951  if (ro.electronClusters.size() && ro.electronClusters[0]) {
952  info << "electron cluster : ";
953  ro.electronClusters[0]->Dump(info, "\t");
954  info << std::endl;
955  } else {
956  info << " no electron cluster." << std::endl;
957  }
958  }
959  if (ro.primaryKFs.size()) {
960  info << "\tPrimary KF tracks attached to object: " << std::endl;
961  for (const auto& kf : ro.primaryKFs) {
962  kf->Dump(info, "\t");
963  info << std::endl;
964  }
965  }
966  if (ro.secondaryKFs.size()) {
967  info << "\tSecondary KF tracks attached to object: " << std::endl;
968  for (const auto& kf : ro.secondaryKFs) {
969  kf->Dump(info, "\t");
970  info << std::endl;
971  }
972  }
973  if (ro.brems.size()) {
974  info << "\tBrem tangents attached to object: " << std::endl;
975  for (const auto& brem : ro.brems) {
976  brem->Dump(info, "\t");
977  info << std::endl;
978  }
979  }
980  if (ro.ecalclusters.size()) {
981  info << "\tECAL clusters attached to object: " << std::endl;
982  for (const auto& clus : ro.ecalclusters) {
983  clus->Dump(info, "\t");
984  info << std::endl;
985  if (ro.ecal2ps.find(clus) != ro.ecal2ps.end()) {
986  for (const auto& psclus : ro.ecal2ps.at(clus)) {
987  info << "\t\t Attached PS Cluster: ";
988  psclus->Dump(info, "");
989  info << std::endl;
990  }
991  }
992  }
993  }
994  edm::LogVerbatim("PFEGammaAlgo") << info.str();
995  }
996 #endif
997 }

References info().

Referenced by operator()().

◆ evaluateSingleLegMVA()

float PFEGammaAlgo::evaluateSingleLegMVA ( const reco::PFBlockRef blockref,
const reco::Vertex primaryVtx,
unsigned int  trackIndex 
)
private

Definition at line 459 of file PFEGammaAlgo.cc.

461  {
462  const reco::PFBlock& block = *blockRef;
464  //use this to store linkdata in the associatedElements function below
465  const PFBlock::LinkData& linkData = block.linkData();
466  //calculate MVA Variables
467  const float chi2 = elements[trackIndex].trackRef()->chi2() / elements[trackIndex].trackRef()->ndof();
468  const float nlost = elements[trackIndex].trackRef()->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS);
469  const float nLayers = elements[trackIndex].trackRef()->hitPattern().trackerLayersWithMeasurement();
470  const float trackPt = elements[trackIndex].trackRef()->pt();
471  const float stip = elements[trackIndex].trackRefPF()->STIP();
472 
473  float linkedE = 0;
474  float linkedH = 0;
475  std::multimap<double, unsigned int> ecalAssoTrack;
476  block.associatedElements(
477  trackIndex, linkData, ecalAssoTrack, reco::PFBlockElement::ECAL, reco::PFBlock::LINKTEST_ALL);
478  std::multimap<double, unsigned int> hcalAssoTrack;
479  block.associatedElements(
480  trackIndex, linkData, hcalAssoTrack, reco::PFBlockElement::HCAL, reco::PFBlock::LINKTEST_ALL);
481  if (!ecalAssoTrack.empty()) {
482  for (auto& itecal : ecalAssoTrack) {
483  linkedE = linkedE + elements[itecal.second].clusterRef()->energy();
484  }
485  }
486  if (!hcalAssoTrack.empty()) {
487  for (auto& ithcal : hcalAssoTrack) {
488  linkedH = linkedH + elements[ithcal.second].clusterRef()->energy();
489  }
490  }
491  const float eOverPt = linkedE / elements[trackIndex].trackRef()->pt();
492  const float hOverPt = linkedH / elements[trackIndex].trackRef()->pt();
493  GlobalVector rvtx(elements[trackIndex].trackRef()->innerPosition().X() - primaryVtx.x(),
494  elements[trackIndex].trackRef()->innerPosition().Y() - primaryVtx.y(),
495  elements[trackIndex].trackRef()->innerPosition().Z() - primaryVtx.z());
496  double vtxPhi = rvtx.phi();
497  //delta Phi between conversion vertex and track
498  float delPhi = fabs(deltaPhi(vtxPhi, elements[trackIndex].trackRef()->innerMomentum().Phi()));
499 
500  float vars[] = {delPhi, nLayers, chi2, eOverPt, hOverPt, trackPt, stip, nlost};
501 
502  return gbrForests_.singleLeg_->GetAdaBoostClassifier(vars);
503 }

References groupFilesInBlocks::block, hltPixelTracks_cff::chi2, delPhi(), SiPixelRawToDigiRegional_cfi::deltaPhi, reco::PFBlockElement::ECAL, bookConverter::elements, gbrForests_, reco::PFBlockElement::HCAL, reco::PFBlock::LINKTEST_ALL, MuonTCMETValueMapProducer_cff::nLayers, PV3DBase< T, PVType, FrameType >::phi(), VtxSmearedParameters_cfi::Phi, PFEGammaAlgo::GBRForests::singleLeg_, listHistos::trackPt, X, reco::Vertex::x(), reco::Vertex::y(), and reco::Vertex::z().

Referenced by fillPFCandidates(), and linkRefinableObjectECALToSingleLegConv().

◆ fillExtraInfo()

void PFEGammaAlgo::fillExtraInfo ( const ProtoEGObject RO,
reco::PFCandidateEGammaExtra xtra 
)
private

Definition at line 1765 of file PFEGammaAlgo.cc.

1765  {
1766  // add tracks associated to clusters that are not T_FROM_GAMMACONV
1767  // info about single-leg convs is already save, so just veto in loops
1768  auto KFbegin = _splayedblock[reco::PFBlockElement::TRACK].begin();
1769  auto KFend = _splayedblock[reco::PFBlockElement::TRACK].end();
1770  for (auto& ecal : RO.ecalclusters) {
1771  NotCloserToOther<reco::PFBlockElement::ECAL, reco::PFBlockElement::TRACK, true> ECALToTracks(_currentblock,
1772  ecal.get());
1773  auto notmatchedkf = std::partition(KFbegin, KFend, ECALToTracks);
1774  auto notconvkf = std::partition(KFbegin, notmatchedkf, [](auto const& x) { return x->trackType(ConvType); });
1775  // go through non-conv-identified kfs and check MVA to add conversions
1776  for (auto kf = notconvkf; kf != notmatchedkf; ++kf) {
1777  const reco::PFBlockElementTrack* elemaskf = docast(const reco::PFBlockElementTrack*, kf->get());
1778  xtra.addExtraNonConvTrack(_currentblock, *elemaskf);
1779  }
1780  }
1781 }

References _currentblock, _splayedblock, reco::PFCandidateEGammaExtra::addExtraNonConvTrack(), docast, bsc_activity_cfg::ecal, PFEGammaAlgo::ProtoEGObject::ecalclusters, reco::PFBlockElement::TRACK, and x.

Referenced by fillPFCandidates().

◆ fillPFCandidates()

PFEGammaAlgo::EgammaObjects PFEGammaAlgo::fillPFCandidates ( const std::list< ProtoEGObject > &  )
private

Definition at line 1468 of file PFEGammaAlgo.cc.

1468  {
1470 
1471  // reserve output collections
1472  output.candidates.reserve(ROs.size());
1473  output.candidateExtras.reserve(ROs.size());
1474  output.refinedSuperClusters.reserve(ROs.size());
1475 
1476  for (auto& RO : ROs) {
1477  if (RO.ecalclusters.empty() && !cfg_.produceEGCandsWithNoSuperCluster)
1478  continue;
1479 
1482  if (!RO.primaryGSFs.empty() || !RO.primaryKFs.empty()) {
1483  cand.setPdgId(-11); // anything with a primary track is an electron
1484  } else {
1485  cand.setPdgId(22); // anything with no primary track is a photon
1486  }
1487  if (!RO.primaryKFs.empty()) {
1488  cand.setCharge(RO.primaryKFs[0]->trackRef()->charge());
1489  xtra.setKfTrackRef(RO.primaryKFs[0]->trackRef());
1490  cand.setTrackRef(RO.primaryKFs[0]->trackRef());
1491  cand.addElementInBlock(_currentblock, RO.primaryKFs[0]->index());
1492  }
1493  if (!RO.primaryGSFs.empty()) {
1494  cand.setCharge(RO.primaryGSFs[0]->GsftrackRef()->chargeMode());
1495  xtra.setGsfTrackRef(RO.primaryGSFs[0]->GsftrackRef());
1496  cand.setGsfTrackRef(RO.primaryGSFs[0]->GsftrackRef());
1497  cand.addElementInBlock(_currentblock, RO.primaryGSFs[0]->index());
1498  }
1499  if (RO.parentSC) {
1500  xtra.setSuperClusterPFECALRef(RO.parentSC->superClusterRef());
1501  // we'll set to the refined supercluster back up in the producer
1502  cand.setSuperClusterRef(RO.parentSC->superClusterRef());
1503  xtra.setSuperClusterRef(RO.parentSC->superClusterRef());
1504  cand.addElementInBlock(_currentblock, RO.parentSC->index());
1505  }
1506  // add brems
1507  for (const auto& brem : RO.brems) {
1508  cand.addElementInBlock(_currentblock, brem->index());
1509  }
1510  // add clusters and ps clusters
1511  for (const auto& ecal : RO.ecalclusters) {
1512  const PFClusterElement* clus = ecal.get();
1513  cand.addElementInBlock(_currentblock, clus->index());
1514  if (RO.ecal2ps.count(clus)) {
1515  for (auto& psclus : RO.ecal2ps.at(clus)) {
1516  cand.addElementInBlock(_currentblock, psclus->index());
1517  }
1518  }
1519  }
1520  // add secondary tracks
1521  for (const auto& kf : RO.secondaryKFs) {
1522  cand.addElementInBlock(_currentblock, kf->index());
1523  const reco::ConversionRefVector& convrefs = kf->convRefs();
1524  bool no_conv_ref = true;
1525  for (const auto& convref : convrefs) {
1526  if (convref.isNonnull() && convref.isAvailable()) {
1527  xtra.addConversionRef(convref);
1528  no_conv_ref = false;
1529  }
1530  }
1531  if (no_conv_ref) {
1532  //single leg conversions
1533 
1534  //look for stored mva value in map or else recompute
1535  const auto& mvavalmapped = RO.singleLegConversionMvaMap.find(kf);
1536  //FIXME: Abuse single mva value to store both provenance and single leg mva score
1537  //by storing 3.0 + mvaval
1538  float mvaval = (mvavalmapped != RO.singleLegConversionMvaMap.end()
1539  ? mvavalmapped->second
1541 
1542  xtra.addSingleLegConvTrackRefMva(std::make_pair(kf->trackRef(), mvaval));
1543  }
1544  }
1545 
1546  // build the refined supercluster from those clusters left in the cand
1547  output.refinedSuperClusters.push_back(buildRefinedSuperCluster(RO));
1548 
1549  //*TODO* cluster time is not reliable at the moment, so only use track timing
1550  float trkTime = 0, trkTimeErr = -1;
1551  if (!RO.primaryGSFs.empty() && RO.primaryGSFs[0]->isTimeValid()) {
1552  trkTime = RO.primaryGSFs[0]->time();
1553  trkTimeErr = RO.primaryGSFs[0]->timeError();
1554  } else if (!RO.primaryKFs.empty() && RO.primaryKFs[0]->isTimeValid()) {
1555  trkTime = RO.primaryKFs[0]->time();
1556  trkTimeErr = RO.primaryKFs[0]->timeError();
1557  }
1558  if (trkTimeErr >= 0) {
1559  cand.setTime(trkTime, trkTimeErr);
1560  }
1561 
1562  const reco::SuperCluster& the_sc = output.refinedSuperClusters.back();
1563  // with the refined SC in hand we build a naive candidate p4
1564  // and set the candidate ECAL position to either the barycenter of the
1565  // supercluster (if super-cluster present) or the seed of the
1566  // new SC generated by the EGAlgo
1567  const double scE = the_sc.energy();
1568  if (scE != 0.0) {
1569  const math::XYZPoint& seedPos = the_sc.seed()->position();
1570  math::XYZVector egDir = the_sc.position() - primaryVertex_.position();
1571  egDir = egDir.Unit();
1572  cand.setP4(math::XYZTLorentzVector(scE * egDir.x(), scE * egDir.y(), scE * egDir.z(), scE));
1573  math::XYZPointF ecalPOS_f(seedPos.x(), seedPos.y(), seedPos.z());
1574  cand.setPositionAtECALEntrance(ecalPOS_f);
1575  cand.setEcalEnergy(the_sc.rawEnergy(), the_sc.energy());
1576  } else if (cfg_.produceEGCandsWithNoSuperCluster && !RO.primaryGSFs.empty()) {
1577  const PFGSFElement* gsf = RO.primaryGSFs[0];
1578  const reco::GsfTrackRef& gref = gsf->GsftrackRef();
1579  math::XYZTLorentzVector p4(gref->pxMode(), gref->pyMode(), gref->pzMode(), gref->pMode());
1580  cand.setP4(p4);
1581  cand.setPositionAtECALEntrance(gsf->positionAtECALEntrance());
1582  } else if (cfg_.produceEGCandsWithNoSuperCluster && !RO.primaryKFs.empty()) {
1583  const PFKFElement* kf = RO.primaryKFs[0];
1584  reco::TrackRef kref = RO.primaryKFs[0]->trackRef();
1585  math::XYZTLorentzVector p4(kref->px(), kref->py(), kref->pz(), kref->p());
1586  cand.setP4(p4);
1587  cand.setPositionAtECALEntrance(kf->positionAtECALEntrance());
1588  }
1589  const float eleMVAValue = calculateEleMVA(RO, xtra);
1590  fillExtraInfo(RO, xtra);
1591  //std::cout << "PFEG eleMVA: " << eleMVAValue << std::endl;
1592  xtra.setMVA(eleMVAValue);
1593  cand.set_mva_e_pi(eleMVAValue);
1594  output.candidates.push_back(cand);
1595  output.candidateExtras.push_back(xtra);
1596  }
1597 
1598  return output;
1599 }

References _currentblock, reco::PFCandidateEGammaExtra::addConversionRef(), reco::PFCandidateEGammaExtra::addSingleLegConvTrackRefMva(), buildRefinedSuperCluster(), calculateEleMVA(), cfg_, bsc_activity_cfg::ecal, reco::CaloCluster::energy(), evaluateSingleLegMVA(), fillExtraInfo(), ntupleEnum::gsf, reco::PFBlockElement::index(), edm::Ref< C, T, F >::index(), convertSQLitetoXML_cfg::output, p4, reco::Vertex::position(), reco::CaloCluster::position(), reco::PFBlockElementTrack::positionAtECALEntrance(), primaryVertex_, PFEGammaAlgo::PFEGConfigInfo::produceEGCandsWithNoSuperCluster, reco::SuperCluster::rawEnergy(), reco::SuperCluster::seed(), reco::PFCandidateEGammaExtra::setGsfTrackRef(), reco::PFCandidateEGammaExtra::setKfTrackRef(), reco::PFCandidateEGammaExtra::setMVA(), reco::PFCandidateEGammaExtra::setSuperClusterPFECALRef(), and reco::PFCandidateEGammaExtra::setSuperClusterRef().

Referenced by operator()().

◆ initializeProtoCands()

void PFEGammaAlgo::initializeProtoCands ( std::list< ProtoEGObject > &  )
private

Definition at line 655 of file PFEGammaAlgo.cc.

655  {
656  // step 1: build SC based proto-candidates
657  // in the future there will be an SC Et requirement made here to control
658  // block size
659  for (auto& element : _splayedblock[PFBlockElement::SC]) {
660  LOGDRESSED("PFEGammaAlgo") << "creating SC-based proto-object" << std::endl
661  << "\tSC at index: " << element->index() << " has type: " << element->type()
662  << std::endl;
663  element.setFlag(false);
664  ProtoEGObject fromSC;
665  fromSC.nBremsWithClusters = -1;
666  fromSC.firstBrem = -1;
667  fromSC.lateBrem = -1;
668  fromSC.parentBlock = _currentblock;
669  fromSC.parentSC = docast(const PFSCElement*, element.get());
670  // splay the supercluster so we can knock out used elements
671  bool sc_success = unwrapSuperCluster(fromSC.parentSC, fromSC.ecalclusters, fromSC.ecal2ps);
672  if (sc_success) {
673  /*
674  auto ins_pos = std::lower_bound(refinableObjects.begin(),
675  refinableObjects.end(),
676  fromSC,
677  [&](const ProtoEGObject& a,
678  const ProtoEGObject& b){
679  const double a_en =
680  a.parentSC->superClusterRef()->energy();
681  const double b_en =
682  b.parentSC->superClusterRef()->energy();
683  return a_en < b_en;
684  });
685  */
686  egobjs.insert(egobjs.end(), fromSC);
687  }
688  }
689  // step 2: build GSF-seed-based proto-candidates
690  reco::GsfTrackRef gsfref_forextra;
691  reco::TrackExtraRef gsftrk_extra;
692  reco::ElectronSeedRef theseedref;
693  for (auto& element : _splayedblock[PFBlockElement::GSF]) {
694  LOGDRESSED("PFEGammaAlgo") << "creating GSF-based proto-object" << std::endl
695  << "\tGSF at index: " << element->index() << " has type: " << element->type()
696  << std::endl;
697  const PFGSFElement* elementAsGSF = docast(const PFGSFElement*, element.get());
698  if (elementAsGSF->trackType(reco::PFBlockElement::T_FROM_GAMMACONV)) {
699  continue; // for now, do not allow dedicated brems to make proto-objects
700  }
701  element.setFlag(false);
702 
703  ProtoEGObject fromGSF;
704  fromGSF.nBremsWithClusters = -1;
705  fromGSF.firstBrem = -1;
706  fromGSF.lateBrem = 0;
707  gsfref_forextra = elementAsGSF->GsftrackRef();
708  gsftrk_extra = (gsfref_forextra.isAvailable() ? gsfref_forextra->extra() : reco::TrackExtraRef());
709  theseedref = (gsftrk_extra.isAvailable() ? gsftrk_extra->seedRef().castTo<reco::ElectronSeedRef>()
711  fromGSF.electronSeed = theseedref;
712  // exception if there's no seed
713  if (fromGSF.electronSeed.isNull() || !fromGSF.electronSeed.isAvailable()) {
714  std::stringstream gsf_err;
715  elementAsGSF->Dump(gsf_err, "\t");
716  throw cms::Exception("PFEGammaAlgo::initializeProtoCands()")
717  << "Found a GSF track with no seed! This should not happen!" << std::endl
718  << gsf_err.str() << std::endl;
719  }
720  // flag this GSF element as globally used and push back the track ref
721  // into the protocand
722  element.setFlag(false);
723  fromGSF.parentBlock = _currentblock;
724  fromGSF.primaryGSFs.push_back(elementAsGSF);
725  // add the directly matched brem tangents
726  for (auto& brem : _splayedblock[PFBlockElement::BREM]) {
727  float dist =
728  _currentblock->dist(elementAsGSF->index(), brem->index(), _currentlinks, reco::PFBlock::LINKTEST_ALL);
729  if (dist == 0.001f) {
730  const PFBremElement* eAsBrem = docast(const PFBremElement*, brem.get());
731  fromGSF.brems.push_back(eAsBrem);
732  fromGSF.localMap.insert(eAsBrem, elementAsGSF);
733  brem.setFlag(false);
734  }
735  }
736  // if this track is ECAL seeded reset links or import cluster
737  // tracker (this is pixel only, right?) driven seeds just get the GSF
738  // track associated since this only branches for ECAL Driven seeds
739  if (fromGSF.electronSeed->isEcalDriven()) {
740  // step 2a: either merge with existing ProtoEG object with SC or add
741  // SC directly to this proto EG object if not present
742  LOGDRESSED("PFEGammaAlgo") << "GSF-based proto-object is ECAL driven, merging SC-cand" << std::endl;
743  LOGVERB("PFEGammaAlgo") << "ECAL Seed Ptr: " << fromGSF.electronSeed.get()
744  << " isAvailable: " << fromGSF.electronSeed.isAvailable()
745  << " isNonnull: " << fromGSF.electronSeed.isNonnull() << std::endl;
746  SeedMatchesToProtoObject sctoseedmatch(fromGSF.electronSeed);
747  auto objsbegin = egobjs.begin();
748  auto objsend = egobjs.end();
749  // this auto is a std::list<ProtoEGObject>::iterator
750  auto clusmatch = std::find_if(objsbegin, objsend, sctoseedmatch);
751  if (clusmatch != objsend) {
752  fromGSF.parentSC = clusmatch->parentSC;
753  fromGSF.ecalclusters = std::move(clusmatch->ecalclusters);
754  fromGSF.ecal2ps = std::move(clusmatch->ecal2ps);
755  egobjs.erase(clusmatch);
756  } else if (fromGSF.electronSeed.isAvailable() && fromGSF.electronSeed.isNonnull()) {
757  // link tests in the gap region can current split a gap electron
758  // HEY THIS IS A WORK AROUND FOR A KNOWN BUG IN PFBLOCKALGO
759  // MAYBE WE SHOULD FIX IT??????????????????????????????????
760  LOGDRESSED("PFEGammaAlgo") << "Encountered the known GSF-SC splitting bug "
761  << " in PFBlockAlgo! We should really fix this!" << std::endl;
762  } else { // SC was not in a earlier proto-object
763  std::stringstream gsf_err;
764  elementAsGSF->Dump(gsf_err, "\t");
765  throw cms::Exception("PFEGammaAlgo::initializeProtoCands()")
766  << "Expected SuperCluster from ECAL driven GSF seed "
767  << "was not found in the block!" << std::endl
768  << gsf_err.str() << std::endl;
769  } // supercluster in block
770  } // is ECAL driven seed?
771 
772  egobjs.insert(egobjs.end(), fromGSF);
773  } // end loop on GSF elements of block
774 }

References _currentblock, _currentlinks, _splayedblock, PFEGammaAlgo::ProtoEGObject::brems, docast, reco::PFBlockElementGsfTrack::Dump(), PFEGammaAlgo::ProtoEGObject::ecal2ps, PFEGammaAlgo::ProtoEGObject::ecalclusters, PFEGammaAlgo::ProtoEGObject::electronSeed, Exception, f, PFEGammaAlgo::ProtoEGObject::firstBrem, edm::Ref< C, T, F >::get(), reco::PFBlockElementGsfTrack::GsftrackRef(), reco::PFBlockElement::index(), CommutativePairs< T >::insert(), edm::Ref< C, T, F >::isAvailable(), edm::Ref< C, T, F >::isNonnull(), edm::Ref< C, T, F >::isNull(), PFEGammaAlgo::ProtoEGObject::lateBrem, reco::PFBlock::LINKTEST_ALL, PFEGammaAlgo::ProtoEGObject::localMap, LOGDRESSED, LOGVERB, eostools::move(), PFEGammaAlgo::ProtoEGObject::nBremsWithClusters, PFEGammaAlgo::ProtoEGObject::parentBlock, PFEGammaAlgo::ProtoEGObject::parentSC, PFEGammaAlgo::ProtoEGObject::primaryGSFs, reco::PFBlockElement::T_FROM_GAMMACONV, reco::PFBlockElementGsfTrack::trackType(), and unwrapSuperCluster().

Referenced by operator()().

◆ isMuon()

bool PFEGammaAlgo::isMuon ( const reco::PFBlockElement pfbe)
private

Definition at line 505 of file PFEGammaAlgo.cc.

505  {
506  switch (pfbe.type()) {
508  auto& elements = _currentblock->elements();
509  std::multimap<double, unsigned> tks;
510  _currentblock->associatedElements(
512  for (const auto& tk : tks) {
513  if (PFMuonAlgo::isMuon(elements[tk.second])) {
514  return true;
515  }
516  }
517  } break;
519  return PFMuonAlgo::isMuon(pfbe);
520  break;
521  default:
522  break;
523  }
524  return false;
525 }

References _currentblock, _currentlinks, bookConverter::elements, reco::PFBlockElement::GSF, reco::PFBlockElement::index(), PFMuonAlgo::isMuon(), reco::PFBlock::LINKTEST_ALL, reco::PFBlockElement::TRACK, and reco::PFBlockElement::type().

Referenced by operator()().

◆ isPrimaryTrack()

bool PFEGammaAlgo::isPrimaryTrack ( const reco::PFBlockElementTrack KfEl,
const reco::PFBlockElementGsfTrack GsfEl 
)
private

Definition at line 2035 of file PFEGammaAlgo.cc.

2035  {
2036  bool isPrimary = false;
2037 
2038  const GsfPFRecTrackRef& gsfPfRef = GsfEl.GsftrackRefPF();
2039 
2040  if (gsfPfRef.isNonnull()) {
2041  const PFRecTrackRef& kfPfRef = KfEl.trackRefPF();
2042  PFRecTrackRef kfPfRef_fromGsf = (*gsfPfRef).kfPFRecTrackRef();
2043  if (kfPfRef.isNonnull() && kfPfRef_fromGsf.isNonnull()) {
2044  reco::TrackRef kfref = (*kfPfRef).trackRef();
2045  reco::TrackRef kfref_fromGsf = (*kfPfRef_fromGsf).trackRef();
2046  if (kfref.isNonnull() && kfref_fromGsf.isNonnull()) {
2047  if (kfref == kfref_fromGsf)
2048  isPrimary = true;
2049  }
2050  }
2051  }
2052 
2053  return isPrimary;
2054 }

References reco::PFBlockElementGsfTrack::GsftrackRefPF(), edm::Ref< C, T, F >::isNonnull(), and reco::PFBlockElementTrack::trackRefPF().

Referenced by linkRefinableObjectGSFTracksToKFs().

◆ linkKFTrackToECAL()

void PFEGammaAlgo::linkKFTrackToECAL ( PFKFElement const *  kfflagged,
ProtoEGObject RO 
)
private

Definition at line 1295 of file PFEGammaAlgo.cc.

1295  {
1296  std::vector<FlaggedPtr<const PFClusterElement>>& currentECAL = RO.ecalclusters;
1297  auto ECALbegin = _splayedblock[reco::PFBlockElement::ECAL].begin();
1298  auto ECALend = _splayedblock[reco::PFBlockElement::ECAL].end();
1299  NotCloserToOther<reco::PFBlockElement::TRACK, reco::PFBlockElement::ECAL> kfTrackToECALs(_currentblock, kfflagged);
1300  NotCloserToOther<reco::PFBlockElement::GSF, reco::PFBlockElement::ECAL> kfTrackGSFToECALs(_currentblock, kfflagged);
1301  //get the ECAL elements not used and not closer to another KF
1302  auto notmatched_sc = std::partition(currentECAL.begin(), currentECAL.end(), kfTrackToECALs);
1303  //get subset ECAL elements not used or closer to another GSF of any type
1304  notmatched_sc = std::partition(currentECAL.begin(), notmatched_sc, kfTrackGSFToECALs);
1305  for (auto ecalitr = currentECAL.begin(); ecalitr != notmatched_sc; ++ecalitr) {
1306  const PFClusterElement* elemascluster = docast(const PFClusterElement*, ecalitr->get());
1307  FlaggedPtr<const PFClusterElement> flaggedclus(elemascluster, true);
1308 
1309  LOGDRESSED("PFEGammaAlgo::linkKFTracktoECAL()") << "Found a cluster already in RO by KF extrapolation"
1310  << " at ECAL surface!" << std::endl
1311  << *elemascluster << std::endl;
1312  RO.localMap.insert(elemascluster, kfflagged);
1313  }
1314  //get the ECAL elements not used and not closer to another KF
1315  auto notmatched_blk = std::partition(ECALbegin, ECALend, kfTrackToECALs);
1316  //get subset ECAL elements not used or closer to another GSF of any type
1317  notmatched_blk = std::partition(ECALbegin, notmatched_blk, kfTrackGSFToECALs);
1318  for (auto ecalitr = ECALbegin; ecalitr != notmatched_blk; ++ecalitr) {
1319  const PFClusterElement* elemascluster = docast(const PFClusterElement*, ecalitr->get());
1320  if (addPFClusterToROSafe(elemascluster, RO)) {
1321  attachPSClusters(elemascluster, RO.ecal2ps[elemascluster]);
1322  ecalitr->setFlag(false);
1323 
1324  LOGDRESSED("PFEGammaAlgo::linkKFTracktoECAL()") << "Found a cluster not in RO by KF extrapolation"
1325  << " at ECAL surface!" << std::endl
1326  << *elemascluster << std::endl;
1327  RO.localMap.insert(elemascluster, kfflagged);
1328  }
1329  }
1330 }

References _currentblock, _splayedblock, attachPSClusters(), docast, reco::PFBlockElement::ECAL, PFEGammaAlgo::ProtoEGObject::ecal2ps, PFEGammaAlgo::ProtoEGObject::ecalclusters, CommutativePairs< T >::insert(), PFEGammaAlgo::ProtoEGObject::localMap, and LOGDRESSED.

Referenced by linkRefinableObjectKFTracksToECAL().

◆ linkRefinableObjectBremTangentsToECAL()

void PFEGammaAlgo::linkRefinableObjectBremTangentsToECAL ( ProtoEGObject RO)
private

Definition at line 1332 of file PFEGammaAlgo.cc.

1332  {
1333  if (RO.brems.empty())
1334  return;
1335  int FirstBrem = -1;
1336  int TrajPos = -1;
1337  int lastBremTrajPos = -1;
1338  for (auto& brem : RO.brems) {
1339  bool has_clusters = false;
1340  TrajPos = (brem->indTrajPoint()) - 2;
1341  auto ECALbegin = _splayedblock[reco::PFBlockElement::ECAL].begin();
1342  auto ECALend = _splayedblock[reco::PFBlockElement::ECAL].end();
1343  NotCloserToOther<reco::PFBlockElement::BREM, reco::PFBlockElement::ECAL> BremToECALs(_currentblock, brem);
1344  // check for late brem using clusters already in the SC
1345  auto RSCBegin = RO.ecalclusters.begin();
1346  auto RSCEnd = RO.ecalclusters.end();
1347  auto notmatched_rsc = std::partition(RSCBegin, RSCEnd, BremToECALs);
1348  for (auto ecal = RSCBegin; ecal != notmatched_rsc; ++ecal) {
1349  float deta = std::abs((*ecal)->clusterRef()->positionREP().eta() - brem->positionAtECALEntrance().eta());
1350  if (deta < 0.015) {
1351  has_clusters = true;
1352  if (lastBremTrajPos == -1 || lastBremTrajPos < TrajPos) {
1353  lastBremTrajPos = TrajPos;
1354  }
1355  if (FirstBrem == -1 || TrajPos < FirstBrem) { // set brem information
1356  FirstBrem = TrajPos;
1357  RO.firstBrem = TrajPos;
1358  }
1359  LOGDRESSED("PFEGammaAlgo::linkBremToECAL()") << "Found a cluster already in SC linked to brem extrapolation"
1360  << " at ECAL surface!" << std::endl;
1361  RO.localMap.insert(ecal->get(), brem);
1362  }
1363  }
1364  // grab new clusters from the block (ensured to not be late brem)
1365  auto notmatched_block = std::partition(ECALbegin, ECALend, BremToECALs);
1366  for (auto ecal = ECALbegin; ecal != notmatched_block; ++ecal) {
1367  float deta = std::abs((*ecal)->clusterRef()->positionREP().eta() - brem->positionAtECALEntrance().eta());
1368  if (deta < 0.015) {
1369  has_clusters = true;
1370  if (lastBremTrajPos == -1 || lastBremTrajPos < TrajPos) {
1371  lastBremTrajPos = TrajPos;
1372  }
1373  if (FirstBrem == -1 || TrajPos < FirstBrem) { // set brem information
1374 
1375  FirstBrem = TrajPos;
1376  RO.firstBrem = TrajPos;
1377  }
1378  const PFClusterElement* elemasclus = docast(const PFClusterElement*, ecal->get());
1379  if (addPFClusterToROSafe(elemasclus, RO)) {
1380  attachPSClusters(elemasclus, RO.ecal2ps[elemasclus]);
1381 
1382  RO.localMap.insert(ecal->get(), brem);
1383  ecal->setFlag(false);
1384  LOGDRESSED("PFEGammaAlgo::linkBremToECAL()") << "Found a cluster not already associated by brem extrapolation"
1385  << " at ECAL surface!" << std::endl;
1386  }
1387  }
1388  }
1389  if (has_clusters) {
1390  if (RO.nBremsWithClusters == -1)
1391  RO.nBremsWithClusters = 0;
1392  ++RO.nBremsWithClusters;
1393  }
1394  }
1395 }

References _currentblock, _splayedblock, funct::abs(), attachPSClusters(), PFEGammaAlgo::ProtoEGObject::brems, docast, bsc_activity_cfg::ecal, reco::PFBlockElement::ECAL, PFEGammaAlgo::ProtoEGObject::ecal2ps, PFEGammaAlgo::ProtoEGObject::ecalclusters, PFEGammaAlgo::ProtoEGObject::firstBrem, CommutativePairs< T >::insert(), PFEGammaAlgo::ProtoEGObject::localMap, LOGDRESSED, and PFEGammaAlgo::ProtoEGObject::nBremsWithClusters.

Referenced by operator()().

◆ linkRefinableObjectConvSecondaryKFsToSecondaryKFs()

void PFEGammaAlgo::linkRefinableObjectConvSecondaryKFsToSecondaryKFs ( ProtoEGObject RO)
private

Definition at line 1397 of file PFEGammaAlgo.cc.

1397  {
1398  auto KFbegin = _splayedblock[reco::PFBlockElement::TRACK].begin();
1399  auto KFend = _splayedblock[reco::PFBlockElement::TRACK].end();
1400  auto BeginROskfs = RO.secondaryKFs.begin();
1401  auto EndROskfs = RO.secondaryKFs.end();
1402  auto ronotconv = std::partition(BeginROskfs, EndROskfs, [](auto const& x) { return x->trackType(ConvType); });
1403  size_t convkfs_end = std::distance(BeginROskfs, ronotconv);
1404  for (size_t idx = 0; idx < convkfs_end; ++idx) {
1405  auto const& secKFs =
1406  RO.secondaryKFs; //we want the entry at the index but we allocate to secondaryKFs in loop which invalidates all iterators, references and pointers, hence we need to get the entry fresh each time
1407  NotCloserToOther<reco::PFBlockElement::TRACK, reco::PFBlockElement::TRACK, true> TracksToTracks(_currentblock,
1408  secKFs[idx]);
1409  auto notmatched = std::partition(KFbegin, KFend, TracksToTracks);
1410  notmatched = std::partition(KFbegin, notmatched, [](auto const& x) { return x->trackType(ConvType); });
1411  for (auto kf = KFbegin; kf != notmatched; ++kf) {
1412  const reco::PFBlockElementTrack* elemaskf = docast(const reco::PFBlockElementTrack*, kf->get());
1413  RO.secondaryKFs.push_back(elemaskf);
1414  RO.localMap.insert(secKFs[idx], kf->get());
1415  kf->setFlag(false);
1416  }
1417  }
1418 }

References _currentblock, _splayedblock, HLT_2018_cff::distance, docast, training_settings::idx, CommutativePairs< T >::insert(), PFEGammaAlgo::ProtoEGObject::localMap, PFEGammaAlgo::ProtoEGObject::secondaryKFs, reco::PFBlockElement::TRACK, and x.

Referenced by operator()().

◆ linkRefinableObjectECALToSingleLegConv()

void PFEGammaAlgo::linkRefinableObjectECALToSingleLegConv ( ProtoEGObject RO)
private

Definition at line 1420 of file PFEGammaAlgo.cc.

1420  {
1421  auto KFbegin = _splayedblock[reco::PFBlockElement::TRACK].begin();
1422  auto KFend = _splayedblock[reco::PFBlockElement::TRACK].end();
1423  for (auto& ecal : RO.ecalclusters) {
1424  NotCloserToOther<reco::PFBlockElement::ECAL, reco::PFBlockElement::TRACK, true> ECALToTracks(_currentblock,
1425  ecal.get());
1426  auto notmatchedkf = std::partition(KFbegin, KFend, ECALToTracks);
1427  auto notconvkf = std::partition(KFbegin, notmatchedkf, [](auto const& x) { return x->trackType(ConvType); });
1428  // add identified KF conversion tracks
1429  for (auto kf = KFbegin; kf != notconvkf; ++kf) {
1430  const reco::PFBlockElementTrack* elemaskf = docast(const reco::PFBlockElementTrack*, kf->get());
1431  RO.secondaryKFs.push_back(elemaskf);
1432  RO.localMap.insert(ecal.get(), elemaskf);
1433  kf->setFlag(false);
1434  }
1435  // go through non-conv-identified kfs and check MVA to add conversions
1436  for (auto kf = notconvkf; kf != notmatchedkf; ++kf) {
1437  float mvaval = evaluateSingleLegMVA(_currentblock, primaryVertex_, (*kf)->index());
1438  if (mvaval > cfg_.mvaConvCut) {
1439  const reco::PFBlockElementTrack* elemaskf = docast(const reco::PFBlockElementTrack*, kf->get());
1440  RO.secondaryKFs.push_back(elemaskf);
1441  RO.localMap.insert(ecal.get(), elemaskf);
1442  kf->setFlag(false);
1443 
1444  RO.singleLegConversionMvaMap.emplace(elemaskf, mvaval);
1445  }
1446  }
1447  }
1448 }

References _currentblock, _splayedblock, cfg_, docast, bsc_activity_cfg::ecal, PFEGammaAlgo::ProtoEGObject::ecalclusters, evaluateSingleLegMVA(), CommutativePairs< T >::insert(), PFEGammaAlgo::ProtoEGObject::localMap, PFEGammaAlgo::PFEGConfigInfo::mvaConvCut, primaryVertex_, PFEGammaAlgo::ProtoEGObject::secondaryKFs, PFEGammaAlgo::ProtoEGObject::singleLegConversionMvaMap, reco::PFBlockElement::TRACK, and x.

Referenced by operator()().

◆ linkRefinableObjectGSFTracksToKFs()

void PFEGammaAlgo::linkRefinableObjectGSFTracksToKFs ( ProtoEGObject RO)
private

Definition at line 1159 of file PFEGammaAlgo.cc.

1159  {
1162  return;
1163  auto KFbegin = _splayedblock[reco::PFBlockElement::TRACK].begin();
1164  auto KFend = _splayedblock[reco::PFBlockElement::TRACK].end();
1165  for (auto& gsfflagged : RO.primaryGSFs) {
1166  const PFGSFElement* seedtk = gsfflagged;
1167  // don't process SC-only ROs or secondary seeded ROs
1168  if (RO.electronSeed.isNull() || seedtk->trackType(convType))
1169  continue;
1170  NotCloserToOther<reco::PFBlockElement::GSF, reco::PFBlockElement::TRACK> gsfTrackToKFs(_currentblock, seedtk);
1171  // get KF tracks not closer to another and not already used
1172  auto notlinked = std::partition(KFbegin, KFend, gsfTrackToKFs);
1173  // attach tracks and set as used
1174  for (auto kft = KFbegin; kft != notlinked; ++kft) {
1175  const PFKFElement* elemaskf = docast(const PFKFElement*, kft->get());
1176  // don't care about things that aren't primaries or directly
1177  // associated secondary tracks
1178  if (isPrimaryTrack(*elemaskf, *seedtk) && !elemaskf->trackType(convType)) {
1179  kft->setFlag(false);
1180  RO.primaryKFs.push_back(elemaskf);
1181  RO.localMap.insert(seedtk, elemaskf);
1182  } else if (elemaskf->trackType(convType)) {
1183  kft->setFlag(false);
1184  RO.secondaryKFs.push_back(elemaskf);
1185  RO.localMap.insert(seedtk, elemaskf);
1186  }
1187  } // loop on closest KFs not closer to other GSFs
1188  } // loop on GSF primaries on RO
1189 }

References _currentblock, _splayedblock, docast, PFEGammaAlgo::ProtoEGObject::electronSeed, relativeConstraints::empty, CommutativePairs< T >::insert(), edm::Ref< C, T, F >::isNull(), isPrimaryTrack(), PFEGammaAlgo::ProtoEGObject::localMap, PFEGammaAlgo::ProtoEGObject::primaryGSFs, PFEGammaAlgo::ProtoEGObject::primaryKFs, PFEGammaAlgo::ProtoEGObject::secondaryKFs, reco::PFBlockElement::T_FROM_GAMMACONV, reco::PFBlockElement::TRACK, reco::PFBlockElementTrack::trackType(), and reco::PFBlockElementGsfTrack::trackType().

Referenced by operator()().

◆ linkRefinableObjectKFTracksToECAL()

void PFEGammaAlgo::linkRefinableObjectKFTracksToECAL ( ProtoEGObject RO)
private

Definition at line 1286 of file PFEGammaAlgo.cc.

1286  {
1288  return;
1289  for (auto& primkf : RO.primaryKFs)
1290  linkKFTrackToECAL(primkf, RO);
1291  for (auto& secdkf : RO.secondaryKFs)
1292  linkKFTrackToECAL(secdkf, RO);
1293 }

References _splayedblock, reco::PFBlockElement::ECAL, relativeConstraints::empty, linkKFTrackToECAL(), PFEGammaAlgo::ProtoEGObject::primaryKFs, and PFEGammaAlgo::ProtoEGObject::secondaryKFs.

Referenced by operator()().

◆ linkRefinableObjectPrimaryGSFTrackToECAL()

void PFEGammaAlgo::linkRefinableObjectPrimaryGSFTrackToECAL ( ProtoEGObject RO)
private

Definition at line 1222 of file PFEGammaAlgo.cc.

1222  {
1224  RO.electronClusters.push_back(nullptr);
1225  return;
1226  }
1227  auto ECALbegin = _splayedblock[reco::PFBlockElement::ECAL].begin();
1228  auto ECALend = _splayedblock[reco::PFBlockElement::ECAL].end();
1229  for (auto& primgsf : RO.primaryGSFs) {
1230  NotCloserToOther<reco::PFBlockElement::GSF, reco::PFBlockElement::ECAL> gsfTracksToECALs(_currentblock, primgsf);
1231  // get set of matching ecals not already in SC
1232  auto notmatched_blk = std::partition(ECALbegin, ECALend, gsfTracksToECALs);
1233  notmatched_blk =
1234  std::partition(ECALbegin, notmatched_blk, [&primgsf](auto const& x) { return compatibleEoPOut(*x, *primgsf); });
1235  // get set of matching ecals already in the RO
1236  auto notmatched_sc = std::partition(RO.ecalclusters.begin(), RO.ecalclusters.end(), gsfTracksToECALs);
1237  notmatched_sc = std::partition(
1238  RO.ecalclusters.begin(), notmatched_sc, [&primgsf](auto const& x) { return compatibleEoPOut(*x, *primgsf); });
1239  // look inside the SC for the ECAL cluster
1240  for (auto ecal = RO.ecalclusters.begin(); ecal != notmatched_sc; ++ecal) {
1241  const PFClusterElement* elemascluster = docast(const PFClusterElement*, ecal->get());
1242  FlaggedPtr<const PFClusterElement> temp(elemascluster, true);
1243  LOGDRESSED("PFEGammaAlgo::linkGSFTracktoECAL()") << "Found a cluster already in RO by GSF extrapolation"
1244  << " at ECAL surface!" << std::endl
1245  << *elemascluster << std::endl;
1246 
1247  RO.localMap.insert(primgsf, temp.get());
1248  }
1249  // look outside the SC for the ecal cluster
1250  for (auto ecal = ECALbegin; ecal != notmatched_blk; ++ecal) {
1251  const PFClusterElement* elemascluster = docast(const PFClusterElement*, ecal->get());
1252  LOGDRESSED("PFEGammaAlgo::linkGSFTracktoECAL()") << "Found a cluster not already in RO by GSF extrapolation"
1253  << " at ECAL surface!" << std::endl
1254  << *elemascluster << std::endl;
1255  if (addPFClusterToROSafe(elemascluster, RO)) {
1256  attachPSClusters(elemascluster, RO.ecal2ps[elemascluster]);
1257  RO.localMap.insert(primgsf, elemascluster);
1258  ecal->setFlag(false);
1259  }
1260  }
1261  }
1262 }

References _currentblock, _splayedblock, attachPSClusters(), docast, bsc_activity_cfg::ecal, reco::PFBlockElement::ECAL, PFEGammaAlgo::ProtoEGObject::ecal2ps, PFEGammaAlgo::ProtoEGObject::ecalclusters, PFEGammaAlgo::ProtoEGObject::electronClusters, relativeConstraints::empty, CommutativePairs< T >::insert(), PFEGammaAlgo::ProtoEGObject::localMap, LOGDRESSED, PFEGammaAlgo::ProtoEGObject::primaryGSFs, groupFilesInBlocks::temp, and x.

Referenced by operator()().

◆ linkRefinableObjectPrimaryGSFTrackToHCAL()

void PFEGammaAlgo::linkRefinableObjectPrimaryGSFTrackToHCAL ( ProtoEGObject RO)
private

Definition at line 1265 of file PFEGammaAlgo.cc.

1265  {
1267  return;
1268  auto HCALbegin = _splayedblock[reco::PFBlockElement::HCAL].begin();
1269  auto HCALend = _splayedblock[reco::PFBlockElement::HCAL].end();
1270  for (auto& primgsf : RO.primaryGSFs) {
1271  NotCloserToOther<reco::PFBlockElement::GSF, reco::PFBlockElement::HCAL> gsfTracksToHCALs(_currentblock, primgsf);
1272  auto notmatched = std::partition(HCALbegin, HCALend, gsfTracksToHCALs);
1273  for (auto hcal = HCALbegin; hcal != notmatched; ++hcal) {
1274  const PFClusterElement* elemascluster = docast(const PFClusterElement*, hcal->get());
1275  FlaggedPtr<const PFClusterElement> temp(elemascluster, true);
1276  LOGDRESSED("PFEGammaAlgo::linkGSFTracktoECAL()")
1277  << "Found an HCAL cluster associated to GSF extrapolation" << std::endl;
1278  RO.hcalClusters.push_back(temp.get());
1279  RO.localMap.insert(primgsf, temp.get());
1280  hcal->setFlag(false);
1281  }
1282  }
1283 }

References _currentblock, _splayedblock, docast, relativeConstraints::empty, reco::PFBlockElement::HCAL, patCandidatesForDimuonsSequences_cff::hcal, PFEGammaAlgo::ProtoEGObject::hcalClusters, CommutativePairs< T >::insert(), PFEGammaAlgo::ProtoEGObject::localMap, LOGDRESSED, PFEGammaAlgo::ProtoEGObject::primaryGSFs, and groupFilesInBlocks::temp.

Referenced by operator()().

◆ linkRefinableObjectPrimaryKFsToSecondaryKFs()

void PFEGammaAlgo::linkRefinableObjectPrimaryKFsToSecondaryKFs ( ProtoEGObject RO)
private

Definition at line 1191 of file PFEGammaAlgo.cc.

1191  {
1194  return;
1195  auto KFbegin = _splayedblock[reco::PFBlockElement::TRACK].begin();
1196  auto KFend = _splayedblock[reco::PFBlockElement::TRACK].end();
1197  for (auto& primkf : RO.primaryKFs) {
1198  // don't process SC-only ROs or secondary seeded ROs
1199  if (primkf->trackType(convType)) {
1200  throw cms::Exception("PFEGammaAlgo::linkRefinableObjectPrimaryKFsToSecondaryKFs()")
1201  << "A KF track from conversion has been assigned as a primary!!" << std::endl;
1202  }
1203  NotCloserToOther<reco::PFBlockElement::TRACK, reco::PFBlockElement::TRACK, true> kfTrackToKFs(_currentblock,
1204  primkf);
1205  // get KF tracks not closer to another and not already used
1206  auto notlinked = std::partition(KFbegin, KFend, kfTrackToKFs);
1207  // attach tracks and set as used
1208  for (auto kft = KFbegin; kft != notlinked; ++kft) {
1209  const PFKFElement* elemaskf = docast(const PFKFElement*, kft->get());
1210  // don't care about things that aren't primaries or directly
1211  // associated secondary tracks
1212  if (elemaskf->trackType(convType)) {
1213  kft->setFlag(false);
1214  RO.secondaryKFs.push_back(elemaskf);
1215  RO.localMap.insert(primkf, elemaskf);
1216  }
1217  } // loop on closest KFs not closer to other KFs
1218  } // loop on KF primaries on RO
1219 }

References _currentblock, _splayedblock, docast, relativeConstraints::empty, Exception, CommutativePairs< T >::insert(), PFEGammaAlgo::ProtoEGObject::localMap, PFEGammaAlgo::ProtoEGObject::primaryKFs, PFEGammaAlgo::ProtoEGObject::secondaryKFs, reco::PFBlockElement::T_FROM_GAMMACONV, reco::PFBlockElement::TRACK, and reco::PFBlockElementTrack::trackType().

Referenced by operator()().

◆ linkRefinableObjectSecondaryKFsToECAL()

void PFEGammaAlgo::linkRefinableObjectSecondaryKFsToECAL ( ProtoEGObject RO)
private

Definition at line 1450 of file PFEGammaAlgo.cc.

1450  {
1451  auto ECALbegin = _splayedblock[reco::PFBlockElement::ECAL].begin();
1452  auto ECALend = _splayedblock[reco::PFBlockElement::ECAL].end();
1453  for (auto& skf : RO.secondaryKFs) {
1454  NotCloserToOther<reco::PFBlockElement::TRACK, reco::PFBlockElement::ECAL, false> TracksToECALwithCut(
1455  _currentblock, skf, 1.5f);
1456  auto notmatched = std::partition(ECALbegin, ECALend, TracksToECALwithCut);
1457  for (auto ecal = ECALbegin; ecal != notmatched; ++ecal) {
1458  const reco::PFBlockElementCluster* elemascluster = docast(const reco::PFBlockElementCluster*, ecal->get());
1459  if (addPFClusterToROSafe(elemascluster, RO)) {
1460  attachPSClusters(elemascluster, RO.ecal2ps[elemascluster]);
1461  RO.localMap.insert(skf, elemascluster);
1462  ecal->setFlag(false);
1463  }
1464  }
1465  }
1466 }

References _currentblock, _splayedblock, attachPSClusters(), docast, bsc_activity_cfg::ecal, reco::PFBlockElement::ECAL, PFEGammaAlgo::ProtoEGObject::ecal2ps, f, CommutativePairs< T >::insert(), PFEGammaAlgo::ProtoEGObject::localMap, and PFEGammaAlgo::ProtoEGObject::secondaryKFs.

Referenced by operator()().

◆ mergeROsByAnyLink()

void PFEGammaAlgo::mergeROsByAnyLink ( std::list< ProtoEGObject > &  )
private

Definition at line 1079 of file PFEGammaAlgo.cc.

1079  {
1080  if (ROs.size() < 2)
1081  return; // nothing to do with one or zero ROs
1082  bool check_for_merge = true;
1083  while (check_for_merge) {
1084  // bugfix for early termination merging loop (15 April 2014)
1085  // check all pairwise combinations in the list
1086  // if one has a merge shuffle it to the front of the list
1087  // if there are no merges left to do we can terminate
1088  for (auto it1 = ROs.begin(); it1 != ROs.end(); ++it1) {
1089  auto find_start = it1;
1090  ++find_start;
1091  auto has_merge = std::find_if(find_start, ROs.end(), std::bind(testIfROMergableByLink, _1, *it1));
1092  if (has_merge != ROs.end() && it1 != ROs.begin()) {
1093  std::swap(*(ROs.begin()), *it1);
1094  break;
1095  }
1096  } // ensure mergables are shuffled to the front
1097  ProtoEGObject& thefront = ROs.front();
1098  auto mergestart = ROs.begin();
1099  ++mergestart;
1100  auto nomerge = std::partition(mergestart, ROs.end(), std::bind(testIfROMergableByLink, _1, thefront));
1101  if (nomerge != mergestart) {
1102  LOGDRESSED("PFEGammaAlgo::mergeROsByAnyLink()")
1103  << "Found objects " << std::distance(mergestart, nomerge) << " to merge by links to the front!" << std::endl;
1104  for (auto roToMerge = mergestart; roToMerge != nomerge; ++roToMerge) {
1105  //bugfix! L.Gray 14 Jan 2016
1106  // -- check that the front is still mergeable!
1107  if (!thefront.ecalclusters.empty() && !roToMerge->ecalclusters.empty()) {
1108  if (thefront.ecalclusters.front()->clusterRef()->layer() !=
1109  roToMerge->ecalclusters.front()->clusterRef()->layer()) {
1110  LOGWARN("PFEGammaAlgo::mergeROsByAnyLink") << "Tried to merge EB and EE clusters! Skipping!";
1111  ROs.push_back(*roToMerge);
1112  continue;
1113  }
1114  }
1115  //end bugfix
1116  thefront.ecalclusters.insert(
1117  thefront.ecalclusters.end(), roToMerge->ecalclusters.begin(), roToMerge->ecalclusters.end());
1118  thefront.ecal2ps.insert(roToMerge->ecal2ps.begin(), roToMerge->ecal2ps.end());
1119  thefront.secondaryKFs.insert(
1120  thefront.secondaryKFs.end(), roToMerge->secondaryKFs.begin(), roToMerge->secondaryKFs.end());
1121 
1122  thefront.localMap.concatenate(roToMerge->localMap);
1123  // TO FIX -> use best (E_gsf - E_clustersum)/E_GSF
1124  if (!thefront.parentSC && roToMerge->parentSC) {
1125  thefront.parentSC = roToMerge->parentSC;
1126  }
1127  if (thefront.electronSeed.isNull() && roToMerge->electronSeed.isNonnull()) {
1128  thefront.electronSeed = roToMerge->electronSeed;
1129  thefront.primaryGSFs.insert(
1130  thefront.primaryGSFs.end(), roToMerge->primaryGSFs.begin(), roToMerge->primaryGSFs.end());
1131  thefront.primaryKFs.insert(
1132  thefront.primaryKFs.end(), roToMerge->primaryKFs.begin(), roToMerge->primaryKFs.end());
1133  thefront.brems.insert(thefront.brems.end(), roToMerge->brems.begin(), roToMerge->brems.end());
1134  thefront.electronClusters = roToMerge->electronClusters;
1135  thefront.nBremsWithClusters = roToMerge->nBremsWithClusters;
1136  thefront.firstBrem = roToMerge->firstBrem;
1137  thefront.lateBrem = roToMerge->lateBrem;
1138  } else if (thefront.electronSeed.isNonnull() && roToMerge->electronSeed.isNonnull()) {
1139  LOGDRESSED("PFEGammaAlgo::mergeROsByAnyLink")
1140  << "Need to implement proper merging of two gsf candidates!" << std::endl;
1141  }
1142  }
1143  ROs.erase(mergestart, nomerge);
1144  // put the merged element in the back of the cleaned list
1145  ROs.push_back(ROs.front());
1146  ROs.pop_front();
1147  } else {
1148  check_for_merge = false;
1149  }
1150  }
1151  LOGDRESSED("PFEGammaAlgo::mergeROsByAnyLink()")
1152  << "After merging by links there are: " << ROs.size() << " refinable EGamma objects!" << std::endl;
1153 }

References PFEGammaAlgo::ProtoEGObject::brems, CommutativePairs< T >::concatenate(), HLT_2018_cff::distance, PFEGammaAlgo::ProtoEGObject::ecal2ps, PFEGammaAlgo::ProtoEGObject::ecalclusters, PFEGammaAlgo::ProtoEGObject::electronClusters, PFEGammaAlgo::ProtoEGObject::electronSeed, PFEGammaAlgo::ProtoEGObject::firstBrem, edm::Ref< C, T, F >::isNonnull(), edm::Ref< C, T, F >::isNull(), PFEGammaAlgo::ProtoEGObject::lateBrem, PFEGammaAlgo::ProtoEGObject::localMap, LOGDRESSED, LOGWARN, PFEGammaAlgo::ProtoEGObject::nBremsWithClusters, PFEGammaAlgo::ProtoEGObject::parentSC, PFEGammaAlgo::ProtoEGObject::primaryGSFs, PFEGammaAlgo::ProtoEGObject::primaryKFs, PFEGammaAlgo::ProtoEGObject::secondaryKFs, and std::swap().

Referenced by operator()().

◆ operator()()

PFEGammaAlgo::EgammaObjects PFEGammaAlgo::operator() ( const reco::PFBlockRef block)

Definition at line 527 of file PFEGammaAlgo.cc.

527  {
528  LOGVERB("PFEGammaAlgo") << "Resetting PFEGammaAlgo for new block and running!" << std::endl;
529 
530  // candidate collections:
531  // this starts off as an inclusive list of prototype objects built from
532  // supercluster/ecal-driven seeds and tracker driven seeds in a block
533  // it is then refined through by various cleanings, determining the energy
534  // flow.
535  // use list for constant-time removals
536  std::list<ProtoEGObject> refinableObjects;
537 
538  _splayedblock.clear();
539  _splayedblock.resize(13); // make sure that we always have the HGCAL entry
540 
542  _currentlinks = block->linkData();
543  //LOGDRESSED("PFEGammaAlgo") << *_currentblock << std::endl;
544  LOGVERB("PFEGammaAlgo") << "Splaying block" << std::endl;
545  //unwrap the PF block into a fast access map
546  for (const auto& pfelement : _currentblock->elements()) {
547  if (isMuon(pfelement))
548  continue; // don't allow muons in our element list
549  if (pfelement.type() == PFBlockElement::HCAL && pfelement.clusterRef()->flags() & reco::CaloCluster::badHcalMarker)
550  continue; // skip also dead area markers for now
551  const size_t itype = (size_t)pfelement.type();
552  if (itype >= _splayedblock.size())
553  _splayedblock.resize(itype + 1);
554  _splayedblock[itype].emplace_back(&pfelement, true);
555  }
556 
557  // show the result of splaying the tree if it's really *really* needed
558 #ifdef PFLOW_DEBUG
559  std::stringstream splayout;
560  for (size_t itype = 0; itype < _splayedblock.size(); ++itype) {
561  splayout << "\tType: " << itype << " indices: ";
562  for (const auto& flaggedelement : _splayedblock[itype]) {
563  splayout << flaggedelement->index() << ' ';
564  }
565  if (itype != _splayedblock.size() - 1)
566  splayout << std::endl;
567  }
568  LOGVERB("PFEGammaAlgo") << splayout.str();
569 #endif
570 
571  // precleaning of the ECAL clusters with respect to primary KF tracks
572  // we don't allow clusters in super clusters to be locked out this way
574 
575  initializeProtoCands(refinableObjects);
576  LOGDRESSED("PFEGammaAlgo") << "Initialized " << refinableObjects.size() << " proto-EGamma objects" << std::endl;
578 
579  //
580  // now we start the refining steps
581  //
582  //
583 
584  // --- Primary Linking Step ---
585  // since this is particle flow and we try to work from the pixels out
586  // we start by linking the tracks together and finding the ECAL clusters
587  for (auto& RO : refinableObjects) {
588  // find the KF tracks associated to GSF primary tracks
590  // do the same for HCAL clusters associated to the GSF
592  // link secondary KF tracks associated to primary KF tracks
594  // pick up clusters that are linked to the GSF primary
596  // link associated KF to ECAL (ECAL part grabs PS clusters too if able)
598  // now finally look for clusters associated to brem tangents
600  }
601 
602  LOGDRESSED("PFEGammaAlgo") << "Dumping after GSF and KF Track (Primary) Linking : " << std::endl;
604 
605  // merge objects after primary linking
606  mergeROsByAnyLink(refinableObjects);
607 
608  LOGDRESSED("PFEGammaAlgo") << "Dumping after first merging operation : " << std::endl;
610 
611  // --- Secondary Linking Step ---
612  // after this we go through the ECAL clusters on the remaining tracks
613  // and try to link those in...
614  for (auto& RO : refinableObjects) {
615  // look for conversion legs
618  // look for tracks that complement conversion legs
620  // look again for ECAL clusters (this time with an e/p cut)
622  }
623 
624  LOGDRESSED("PFEGammaAlgo") << "Dumping after ECAL to Track (Secondary) Linking : " << std::endl;
626 
627  // merge objects after primary linking
628  mergeROsByAnyLink(refinableObjects);
629 
630  LOGDRESSED("PFEGammaAlgo") << "There are " << refinableObjects.size() << " after the 2nd merging step." << std::endl;
632 
633  // -- unlinking and proto-object vetos, final sorting
634  for (auto& RO : refinableObjects) {
635  // remove secondary KFs (and possibly ECALs) matched to HCAL clusters
637  // remove secondary KFs and ECALs linked to them that have bad E/p_in
638  // and spoil the resolution
640  // put things back in order after partitioning
641  std::sort(RO.ecalclusters.begin(), RO.ecalclusters.end(), [](auto const& a, auto const& b) {
642  return (a->clusterRef()->correctedEnergy() > b->clusterRef()->correctedEnergy());
643  });
644  setROElectronCluster(RO);
645  }
646 
647  LOGDRESSED("PFEGammaAlgo") << "There are " << refinableObjects.size() << " after the unlinking and vetos step."
648  << std::endl;
650 
651  // fill the PF candidates and then build the refined SC
652  return fillPFCandidates(refinableObjects);
653 }

References _currentblock, _currentlinks, _splayedblock, a, b, reco::CaloCluster::badHcalMarker, groupFilesInBlocks::block, dumpCurrentRefinableObjects(), fillPFCandidates(), HCAL, initializeProtoCands(), isMuon(), linkRefinableObjectBremTangentsToECAL(), linkRefinableObjectConvSecondaryKFsToSecondaryKFs(), linkRefinableObjectECALToSingleLegConv(), linkRefinableObjectGSFTracksToKFs(), linkRefinableObjectKFTracksToECAL(), linkRefinableObjectPrimaryGSFTrackToECAL(), linkRefinableObjectPrimaryGSFTrackToHCAL(), linkRefinableObjectPrimaryKFsToSecondaryKFs(), linkRefinableObjectSecondaryKFsToECAL(), LOGDRESSED, LOGVERB, mergeROsByAnyLink(), removeOrLinkECALClustersToKFTracks(), unlinkRefinableObjectKFandECALMatchedToHCAL(), and unlinkRefinableObjectKFandECALWithBadEoverP().

◆ removeOrLinkECALClustersToKFTracks()

void PFEGammaAlgo::removeOrLinkECALClustersToKFTracks ( )
private

Definition at line 1000 of file PFEGammaAlgo.cc.

1000  {
1001  typedef std::multimap<double, unsigned> MatchedMap;
1002  typedef const reco::PFBlockElementGsfTrack* GsfTrackElementPtr;
1004  return;
1005  MatchedMap matchedGSFs, matchedECALs;
1006  std::unordered_map<GsfTrackElementPtr, MatchedMap> gsf_ecal_cache;
1007  for (auto& kftrack : _splayedblock[reco::PFBlockElement::TRACK]) {
1008  matchedGSFs.clear();
1009  _currentblock->associatedElements(
1010  kftrack->index(), _currentlinks, matchedGSFs, reco::PFBlockElement::GSF, reco::PFBlock::LINKTEST_ALL);
1011  if (matchedGSFs.empty()) { // only run this if we aren't associated to GSF
1012  LesserByDistance closestTrackToECAL(_currentblock, _currentlinks, kftrack.get());
1013  auto ecalbegin = _splayedblock[reco::PFBlockElement::ECAL].begin();
1014  auto ecalend = _splayedblock[reco::PFBlockElement::ECAL].end();
1015  std::partial_sort(ecalbegin, ecalbegin + 1, ecalend, closestTrackToECAL);
1016  auto& closestECAL = _splayedblock[reco::PFBlockElement::ECAL].front();
1017  const float dist =
1018  _currentblock->dist(kftrack->index(), closestECAL->index(), _currentlinks, reco::PFBlock::LINKTEST_ALL);
1019  bool inSC = false;
1020  for (auto& sc : _splayedblock[reco::PFBlockElement::SC]) {
1021  float dist_sc =
1022  _currentblock->dist(sc->index(), closestECAL->index(), _currentlinks, reco::PFBlock::LINKTEST_ALL);
1023  if (dist_sc != -1.0f) {
1024  inSC = true;
1025  break;
1026  }
1027  }
1028 
1029  if (dist != -1.0f && closestECAL.flag()) {
1030  bool gsflinked = false;
1031  // check that this cluster is not associated to a GSF track
1032  for (const auto& gsfflag : _splayedblock[reco::PFBlockElement::GSF]) {
1033  const reco::PFBlockElementGsfTrack* elemasgsf = docast(const reco::PFBlockElementGsfTrack*, gsfflag.get());
1035  continue; // keep clusters that have a found conversion GSF near
1036  }
1037  // make sure cache exists
1038  if (!gsf_ecal_cache.count(elemasgsf)) {
1039  matchedECALs.clear();
1040  _currentblock->associatedElements(elemasgsf->index(),
1041  _currentlinks,
1042  matchedECALs,
1045  gsf_ecal_cache.emplace(elemasgsf, matchedECALs);
1046  MatchedMap().swap(matchedECALs);
1047  }
1048  const MatchedMap& ecal_matches = gsf_ecal_cache[elemasgsf];
1049  if (!ecal_matches.empty()) {
1050  if (ecal_matches.begin()->second == closestECAL->index()) {
1051  gsflinked = true;
1052  break;
1053  }
1054  }
1055  } // loop over primary GSF tracks
1056  if (!gsflinked && !inSC) {
1057  // determine if we should remove the matched cluster
1058  const reco::PFBlockElementTrack* kfEle = docast(const reco::PFBlockElementTrack*, kftrack.get());
1059  const reco::TrackRef& trackref = kfEle->trackRef();
1060 
1061  const int nexhits = trackref->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS);
1062  bool fromprimaryvertex = false;
1063  for (auto vtxtks = primaryVertex_.tracks_begin(); vtxtks != primaryVertex_.tracks_end(); ++vtxtks) {
1064  if (trackref == vtxtks->castTo<reco::TrackRef>()) {
1065  fromprimaryvertex = true;
1066  break;
1067  }
1068  } // loop over tracks in primary vertex
1069  // if associated to good non-GSF matched track remove this cluster
1070  if (PFTrackAlgoTools::isGoodForEGMPrimary(trackref->algo()) && nexhits == 0 && fromprimaryvertex) {
1071  closestECAL.setFlag(false);
1072  }
1073  }
1074  } // found a good closest ECAL match
1075  } // no GSF track matched to KF
1076  } // loop over KF elements
1077 }

References _currentblock, _currentlinks, _splayedblock, docast, reco::PFBlockElement::ECAL, relativeConstraints::empty, f, reco::PFBlockElement::GSF, reco::PFBlockElement::index(), PFTrackAlgoTools::isGoodForEGMPrimary(), reco::PFBlock::LINKTEST_ALL, primaryVertex_, reco::PFBlockElement::SC, reco::PFBlockElement::T_FROM_GAMMACONV, reco::PFBlockElement::TRACK, reco::PFBlockElementTrack::trackRef(), reco::Vertex::tracks_begin(), reco::Vertex::tracks_end(), and reco::PFBlockElementGsfTrack::trackType().

Referenced by operator()().

◆ unlinkRefinableObjectKFandECALMatchedToHCAL()

void PFEGammaAlgo::unlinkRefinableObjectKFandECALMatchedToHCAL ( ProtoEGObject RO,
bool  removeFreeECAL = false,
bool  removeSCECAL = false 
)
private

Definition at line 1963 of file PFEGammaAlgo.cc.

1965  {
1966  std::vector<bool> cluster_in_sc;
1967  auto ecal_begin = RO.ecalclusters.begin();
1968  auto ecal_end = RO.ecalclusters.end();
1969  auto hcal_begin = _splayedblock[reco::PFBlockElement::HCAL].begin();
1970  auto hcal_end = _splayedblock[reco::PFBlockElement::HCAL].end();
1971  for (auto secd_kf = RO.secondaryKFs.begin(); secd_kf != RO.secondaryKFs.end(); ++secd_kf) {
1972  bool remove_this_kf = false;
1973  NotCloserToOther<reco::PFBlockElement::TRACK, reco::PFBlockElement::HCAL> tracksToHCALs(_currentblock, *secd_kf);
1974  reco::TrackRef trkRef = (*secd_kf)->trackRef();
1975 
1976  bool goodTrack = PFTrackAlgoTools::isGoodForEGM(trkRef->algo());
1977  const float secpin = trkRef->p();
1978 
1979  for (auto ecal = ecal_begin; ecal != ecal_end; ++ecal) {
1980  const double ecalenergy = (*ecal)->clusterRef()->correctedEnergy();
1981  // first check if the cluster is in the SC (use dist calc for fastness)
1982  const size_t clus_idx = std::distance(ecal_begin, ecal);
1983  if (cluster_in_sc.size() < clus_idx + 1) {
1984  float dist = -1.0f;
1985  if (RO.parentSC) {
1986  dist = _currentblock->dist((*secd_kf)->index(), (*ecal)->index(), _currentlinks, reco::PFBlock::LINKTEST_ALL);
1987  }
1988  cluster_in_sc.push_back(dist != -1.0f);
1989  }
1990 
1991  // if we've found a secondary KF that matches this ecal cluster
1992  // now we see if it is matched to HCAL
1993  // if it is matched to an HCAL cluster we take different
1994  // actions if the cluster was in an SC or not
1995  if (RO.localMap.contains(ecal->get(), *secd_kf)) {
1996  auto hcal_matched = std::partition(hcal_begin, hcal_end, tracksToHCALs);
1997  for (auto hcalclus = hcal_begin; hcalclus != hcal_matched; ++hcalclus) {
1998  const reco::PFBlockElementCluster* clusthcal =
1999  dynamic_cast<const reco::PFBlockElementCluster*>(hcalclus->get());
2000  const double hcalenergy = clusthcal->clusterRef()->energy();
2001  const double hpluse = ecalenergy + hcalenergy;
2002  const bool isHoHE = ((hcalenergy / hpluse) > 0.1 && goodTrack);
2003  const bool isHoE = (hcalenergy > ecalenergy);
2004  const bool isPoHE = (secpin > hpluse);
2005  if (cluster_in_sc[clus_idx]) {
2006  if (isHoE || isPoHE) {
2007  LOGDRESSED("PFEGammaAlgo") << "REJECTED TRACK FOR H/E or P/(H+E), CLUSTER IN SC"
2008  << " H/H+E " << (hcalenergy / hpluse) << " H/E " << (hcalenergy > ecalenergy)
2009  << " P/(H+E) " << (secpin / hpluse) << " HCAL ENE " << hcalenergy
2010  << " ECAL ENE " << ecalenergy << " secPIN " << secpin << " Algo Track "
2011  << trkRef->algo() << std::endl;
2012  remove_this_kf = true;
2013  }
2014  } else {
2015  if (isHoHE) {
2016  LOGDRESSED("PFEGammaAlgo") << "REJECTED TRACK FOR H/H+E, CLUSTER NOT IN SC"
2017  << " H/H+E " << (hcalenergy / hpluse) << " H/E " << (hcalenergy > ecalenergy)
2018  << " P/(H+E) " << (secpin / hpluse) << " HCAL ENE " << hcalenergy
2019  << " ECAL ENE " << ecalenergy << " secPIN " << secpin << " Algo Track "
2020  << trkRef->algo() << std::endl;
2021  remove_this_kf = true;
2022  }
2023  }
2024  }
2025  }
2026  }
2027  if (remove_this_kf) {
2028  secd_kf = RO.secondaryKFs.erase(secd_kf);
2029  if (secd_kf == RO.secondaryKFs.end())
2030  break;
2031  }
2032  }
2033 }

References _currentblock, _currentlinks, _splayedblock, reco::PFBlockElementCluster::clusterRef(), CommutativePairs< T >::contains(), HLT_2018_cff::distance, bsc_activity_cfg::ecal, PFEGammaAlgo::ProtoEGObject::ecalclusters, f, spr::goodTrack(), reco::PFBlockElement::HCAL, PFTrackAlgoTools::isGoodForEGM(), reco::PFBlock::LINKTEST_ALL, PFEGammaAlgo::ProtoEGObject::localMap, LOGDRESSED, PFEGammaAlgo::ProtoEGObject::parentSC, and PFEGammaAlgo::ProtoEGObject::secondaryKFs.

Referenced by operator()().

◆ unlinkRefinableObjectKFandECALWithBadEoverP()

void PFEGammaAlgo::unlinkRefinableObjectKFandECALWithBadEoverP ( ProtoEGObject RO)
private

Definition at line 1890 of file PFEGammaAlgo.cc.

1890  {
1891  // this only means something for ROs with a primary GSF track
1892  if (RO.primaryGSFs.empty())
1893  return;
1894  // need energy sums to tell if we've added crap or not
1895  const double Pin_gsf = RO.primaryGSFs.front()->GsftrackRef()->pMode();
1896  const double gsfOuterEta = RO.primaryGSFs.front()->positionAtECALEntrance().Eta();
1897  double tot_ecal = 0.0;
1898  std::vector<double> min_brem_dists;
1899  std::vector<double> closest_brem_eta;
1900  // first get the total ecal energy (we should replace this with a cache)
1901  for (const auto& ecal : RO.ecalclusters) {
1902  tot_ecal += ecal->clusterRef()->correctedEnergy();
1903  // we also need to look at the minimum distance to brems
1904  // since energetic brems will be closer to the brem than the track
1905  double min_brem_dist = 5000.0;
1906  double eta = -999.0;
1907  for (const auto& brem : RO.brems) {
1908  const float dist = _currentblock->dist(brem->index(), ecal->index(), _currentlinks, reco::PFBlock::LINKTEST_ALL);
1909  if (dist < min_brem_dist && dist != -1.0f) {
1910  min_brem_dist = dist;
1911  eta = brem->positionAtECALEntrance().Eta();
1912  }
1913  }
1914  min_brem_dists.push_back(min_brem_dist);
1915  closest_brem_eta.push_back(eta);
1916  }
1917 
1918  // loop through the ECAL clusters and remove ECAL clusters matched to
1919  // secondary track either in *or* out of the SC if the E/pin is bad
1920  for (auto secd_kf = RO.secondaryKFs.begin(); secd_kf != RO.secondaryKFs.end(); ++secd_kf) {
1921  reco::TrackRef trkRef = (*secd_kf)->trackRef();
1922  const float secpin = (*secd_kf)->trackRef()->p();
1923  bool remove_this_kf = false;
1924  for (auto ecal = RO.ecalclusters.begin(); ecal != RO.ecalclusters.end(); ++ecal) {
1925  size_t bremidx = std::distance(RO.ecalclusters.begin(), ecal);
1926  const float minbremdist = min_brem_dists[bremidx];
1927  const double ecalenergy = (*ecal)->clusterRef()->correctedEnergy();
1928  const double Epin = ecalenergy / secpin;
1929  const double detaGsf = std::abs(gsfOuterEta - (*ecal)->clusterRef()->positionREP().Eta());
1930  const double detaBrem = std::abs(closest_brem_eta[bremidx] - (*ecal)->clusterRef()->positionREP().Eta());
1931 
1932  bool kf_matched = RO.localMap.contains(ecal->get(), *secd_kf);
1933 
1934  const float tkdist =
1935  _currentblock->dist((*secd_kf)->index(), (*ecal)->index(), _currentlinks, reco::PFBlock::LINKTEST_ALL);
1936 
1937  // do not reject this track if it is closer to a brem than the
1938  // secondary track, or if it lies in the delta-eta plane with the
1939  // gsf track or if it is in the dEta plane with the brems
1940  if (Epin > 3 && kf_matched && tkdist != -1.0f && tkdist < minbremdist && detaGsf > 0.05 && detaBrem > 0.015) {
1941  double res_with = std::abs((tot_ecal - Pin_gsf) / Pin_gsf);
1942  double res_without = std::abs((tot_ecal - ecalenergy - Pin_gsf) / Pin_gsf);
1943  if (res_without < res_with) {
1944  LOGDRESSED("PFEGammaAlgo") << " REJECTED_RES totenergy " << tot_ecal << " Pin_gsf " << Pin_gsf
1945  << " cluster to secondary " << ecalenergy << " res_with " << res_with
1946  << " res_without " << res_without << std::endl;
1947  tot_ecal -= ecalenergy;
1948  remove_this_kf = true;
1949  ecal = RO.ecalclusters.erase(ecal);
1950  if (ecal == RO.ecalclusters.end())
1951  break;
1952  }
1953  }
1954  }
1955  if (remove_this_kf) {
1956  secd_kf = RO.secondaryKFs.erase(secd_kf);
1957  if (secd_kf == RO.secondaryKFs.end())
1958  break;
1959  }
1960  }
1961 }

References _currentblock, _currentlinks, funct::abs(), PFEGammaAlgo::ProtoEGObject::brems, CommutativePairs< T >::contains(), HLT_2018_cff::distance, bsc_activity_cfg::ecal, PFEGammaAlgo::ProtoEGObject::ecalclusters, PVValHelper::eta, f, reco::PFBlock::LINKTEST_ALL, PFEGammaAlgo::ProtoEGObject::localMap, LOGDRESSED, PFEGammaAlgo::ProtoEGObject::primaryGSFs, and PFEGammaAlgo::ProtoEGObject::secondaryKFs.

Referenced by operator()().

◆ unwrapSuperCluster()

bool PFEGammaAlgo::unwrapSuperCluster ( const reco::PFBlockElementSuperCluster thesc,
std::vector< FlaggedPtr< const PFClusterElement >> &  ecalclusters,
ClusterMap ecal2ps 
)
private

Definition at line 776 of file PFEGammaAlgo.cc.

778  {
779  ecalclusters.clear();
780  ecal2ps.clear();
781  LOGVERB("PFEGammaAlgo") << "Pointer to SC element: 0x" << std::hex << thesc << std::dec << std::endl
782  << "cleared ecalclusters and ecal2ps!" << std::endl;
783  auto ecalbegin = _splayedblock[reco::PFBlockElement::ECAL].begin();
784  auto ecalend = _splayedblock[reco::PFBlockElement::ECAL].end();
785  auto hgcalbegin = _splayedblock[reco::PFBlockElement::HGCAL].begin();
786  auto hgcalend = _splayedblock[reco::PFBlockElement::HGCAL].end();
787  if (ecalbegin == ecalend && hgcalbegin == hgcalend) {
788  LOGERR("PFEGammaAlgo::unwrapSuperCluster()") << "There are no ECAL elements in a block with imported SC!"
789  << " This is a bug we should fix this!" << std::endl;
790  return false;
791  }
792  reco::SuperClusterRef scref = thesc->superClusterRef();
793  const bool is_pf_sc = thesc->fromPFSuperCluster();
794  if (!(scref.isAvailable() && scref.isNonnull())) {
795  throw cms::Exception("PFEGammaAlgo::unwrapSuperCluster()")
796  << "SuperCluster pointed to by block element is null!" << std::endl;
797  }
798  LOGDRESSED("PFEGammaAlgo") << "Got a valid super cluster ref! 0x" << std::hex << scref.get() << std::dec << std::endl;
799  const size_t nscclusters = scref->clustersSize();
800  const size_t nscpsclusters = scref->preshowerClustersSize();
801  size_t npfpsclusters = 0;
802  size_t npfclusters = 0;
803  LOGDRESSED("PFEGammaAlgo") << "Precalculated cluster multiplicities: " << nscclusters << ' ' << nscpsclusters
804  << std::endl;
805  NotCloserToOther<reco::PFBlockElement::SC, reco::PFBlockElement::ECAL> ecalClustersInSC(_currentblock, thesc);
806  NotCloserToOther<reco::PFBlockElement::SC, reco::PFBlockElement::HGCAL> hgcalClustersInSC(_currentblock, thesc);
807  auto ecalfirstnotinsc = std::partition(ecalbegin, ecalend, ecalClustersInSC);
808  auto hgcalfirstnotinsc = std::partition(hgcalbegin, hgcalend, hgcalClustersInSC);
809  //reset the begin and end iterators
810  ecalbegin = _splayedblock[reco::PFBlockElement::ECAL].begin();
811  ecalend = _splayedblock[reco::PFBlockElement::ECAL].end();
812 
813  hgcalbegin = _splayedblock[reco::PFBlockElement::HGCAL].begin();
814  hgcalend = _splayedblock[reco::PFBlockElement::HGCAL].end();
815 
816  //get list of associated clusters by det id and energy matching
817  //(only needed when using non-pf supercluster)
818  std::vector<const ClusterElement*> safePFClusters =
819  is_pf_sc ? std::vector<const ClusterElement*>()
820  : getSCAssociatedECALsSafe(scref, _splayedblock[reco::PFBlockElement::ECAL]);
821 
822  if (ecalfirstnotinsc == ecalbegin && hgcalfirstnotinsc == hgcalbegin) {
823  LOGERR("PFEGammaAlgo::unwrapSuperCluster()") << "No associated block elements to SuperCluster!"
824  << " This is a bug we should fix!" << std::endl;
825  return false;
826  }
827  npfclusters = std::distance(ecalbegin, ecalfirstnotinsc) + std::distance(hgcalbegin, hgcalfirstnotinsc);
828  // ensure we have found the correct number of PF ecal clusters in the case
829  // that this is a PF supercluster, otherwise all bets are off
830  if (is_pf_sc && nscclusters != npfclusters) {
831  std::stringstream sc_err;
832  thesc->Dump(sc_err, "\t");
833  throw cms::Exception("PFEGammaAlgo::unwrapSuperCluster()")
834  << "The number of found ecal elements (" << nscclusters << ") in block is not the same as"
835  << " the number of ecal PF clusters reported by the PFSuperCluster"
836  << " itself (" << npfclusters << ")! This should not happen!" << std::endl
837  << sc_err.str() << std::endl;
838  }
839  for (auto ecalitr = ecalbegin; ecalitr != ecalfirstnotinsc; ++ecalitr) {
840  const PFClusterElement* elemascluster = docast(const PFClusterElement*, ecalitr->get());
841 
842  // reject clusters that really shouldn't be associated to the SC
843  // (only needed when using non-pf-supercluster)
844  if (!is_pf_sc && std::find(safePFClusters.begin(), safePFClusters.end(), elemascluster) == safePFClusters.end())
845  continue;
846 
847  //add cluster
848  ecalclusters.emplace_back(elemascluster, true);
849  //mark cluster as used
850  ecalitr->setFlag(false);
851 
852  // process the ES elements
853  // auto is a pair<Iterator,bool> here, bool is false when placing fails
854  auto emplaceresult = ecal2ps.emplace(elemascluster, ClusterMap::mapped_type());
855  if (!emplaceresult.second) {
856  std::stringstream clus_err;
857  elemascluster->Dump(clus_err, "\t");
858  throw cms::Exception("PFEGammaAlgo::unwrapSuperCluster()")
859  << "List of pointers to ECAL block elements contains non-unique items!"
860  << " This is very bad!" << std::endl
861  << "cluster ptr = 0x" << std::hex << elemascluster << std::dec << std::endl
862  << clus_err.str() << std::endl;
863  }
864  ClusterMap::mapped_type& eslist = emplaceresult.first->second;
865  npfpsclusters += attachPSClusters(elemascluster, eslist);
866  } // loop over ecal elements
867 
868  for (auto hgcalitr = hgcalbegin; hgcalitr != hgcalfirstnotinsc; ++hgcalitr) {
869  const PFClusterElement* elemascluster = docast(const PFClusterElement*, hgcalitr->get());
870 
871  // reject clusters that really shouldn't be associated to the SC
872  // (only needed when using non-pf-supercluster)
873  if (!is_pf_sc && std::find(safePFClusters.begin(), safePFClusters.end(), elemascluster) == safePFClusters.end())
874  continue;
875 
876  //add cluster
877  ecalclusters.emplace_back(elemascluster, true);
878  //mark cluster as used
879  hgcalitr->setFlag(false);
880  } // loop over ecal elements
881 
882  /*
883  if( is_pf_sc && nscpsclusters != npfpsclusters) {
884  std::stringstream sc_err;
885  thesc->Dump(sc_err,"\t");
886  throw cms::Exception("PFEGammaAlgo::unwrapSuperCluster()")
887  << "The number of found PF preshower elements ("
888  << npfpsclusters << ") in block is not the same as"
889  << " the number of preshower clusters reported by the PFSuperCluster"
890  << " itself (" << nscpsclusters << ")! This should not happen!"
891  << std::endl
892  << sc_err.str() << std::endl;
893  }
894  */
895 
896  LOGDRESSED("PFEGammaAlgo") << " Unwrapped SC has " << npfclusters << " ECAL sub-clusters"
897  << " and " << npfpsclusters << " PreShower layers 1 & 2 clusters!" << std::endl;
898  return true;
899 }

References _currentblock, _splayedblock, attachPSClusters(), TauDecayModes::dec, HLT_2018_cff::distance, docast, reco::PFBlockElementCluster::Dump(), reco::PFBlockElementSuperCluster::Dump(), reco::PFBlockElement::ECAL, Exception, spr::find(), reco::PFBlockElementSuperCluster::fromPFSuperCluster(), edm::Ref< C, T, F >::get(), reco::PFBlockElement::HGCAL, edm::Ref< C, T, F >::isAvailable(), edm::Ref< C, T, F >::isNonnull(), LOGDRESSED, LOGERR, LOGVERB, and reco::PFBlockElementSuperCluster::superClusterRef().

Referenced by initializeProtoCands().

Member Data Documentation

◆ _currentblock

reco::PFBlockRef PFEGammaAlgo::_currentblock
private

◆ _currentlinks

reco::PFBlock::LinkData PFEGammaAlgo::_currentlinks
private

◆ _splayedblock

std::vector<std::vector<FlaggedPtr<const reco::PFBlockElement> > > PFEGammaAlgo::_splayedblock
private

◆ cfg_

PFEGConfigInfo const& PFEGammaAlgo::cfg_
private

◆ channelStatus_

ESChannelStatus const& PFEGammaAlgo::channelStatus_
private

Definition at line 224 of file PFEGammaAlgo.h.

Referenced by buildRefinedSuperCluster().

◆ eetops_

reco::PFCluster::EEtoPSAssociation const& PFEGammaAlgo::eetops_
private

Definition at line 143 of file PFEGammaAlgo.h.

Referenced by attachPSClusters().

◆ gbrForests_

GBRForests const& PFEGammaAlgo::gbrForests_
private

Definition at line 135 of file PFEGammaAlgo.h.

Referenced by calculateEleMVA(), and evaluateSingleLegMVA().

◆ primaryVertex_

reco::Vertex const& PFEGammaAlgo::primaryVertex_
private

◆ thePFEnergyCalibration_

PFEnergyCalibration PFEGammaAlgo::thePFEnergyCalibration_
private

Definition at line 137 of file PFEGammaAlgo.h.

Referenced by buildRefinedSuperCluster(), and PFEGammaAlgo().

Vector3DBase
Definition: Vector3DBase.h:8
reco::PFCandidateEGammaExtra::setHadEnergy
void setHadEnergy(float val)
set the had energy. The cluster energies should be entered before
Definition: PFCandidateEGammaExtra.cc:74
PFEGammaAlgo::linkRefinableObjectPrimaryGSFTrackToECAL
void linkRefinableObjectPrimaryGSFTrackToECAL(ProtoEGObject &)
Definition: PFEGammaAlgo.cc:1222
reco::PFBlockElementGsfTrack::trackType
bool trackType(TrackType trType) const override
Definition: PFBlockElementGsfTrack.h:31
PFEGammaAlgo::mergeROsByAnyLink
void mergeROsByAnyLink(std::list< ProtoEGObject > &)
Definition: PFEGammaAlgo.cc:1079
PFEGammaAlgo::_splayedblock
std::vector< std::vector< FlaggedPtr< const reco::PFBlockElement > > > _splayedblock
Definition: PFEGammaAlgo.h:148
LOGERR
#define LOGERR(x)
Definition: PFEGammaAlgo.cc:45
PFEGammaAlgo::PFGSFElement
reco::PFBlockElementGsfTrack PFGSFElement
Definition: PFEGammaAlgo.h:67
PFEGammaAlgo::linkRefinableObjectConvSecondaryKFsToSecondaryKFs
void linkRefinableObjectConvSecondaryKFsToSecondaryKFs(ProtoEGObject &)
Definition: PFEGammaAlgo.cc:1397
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
reco::PFCandidateEGammaExtra::setDeltaEta
void setDeltaEta(float val)
set the delta eta
Definition: PFCandidateEGammaExtra.cc:85
PFEGammaAlgo::cfg_
PFEGConfigInfo const & cfg_
Definition: PFEGammaAlgo.h:221
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:32
reco::SuperCluster
Definition: SuperCluster.h:18
X
#define X(str)
Definition: MuonsGrabber.cc:38
edm::Ref::isAvailable
bool isAvailable() const
Definition: Ref.h:537
min
T min(T a, T b)
Definition: MathUtil.h:58
reco::Vertex::z
double z() const
z coordinate
Definition: Vertex.h:120
reco::PFCandidateEGammaExtra::addExtraNonConvTrack
void addExtraNonConvTrack(const reco::PFBlockRef &blk, const reco::PFBlockElementTrack &tkref)
track counting for electrons and photons
Definition: PFCandidateEGammaExtra.h:177
PFEGammaAlgo::channelStatus_
ESChannelStatus const & channelStatus_
Definition: PFEGammaAlgo.h:224
hcal
Definition: ConfigurationDatabase.cc:13
PFEGammaAlgo::linkRefinableObjectECALToSingleLegConv
void linkRefinableObjectECALToSingleLegConv(ProtoEGObject &)
Definition: PFEGammaAlgo.cc:1420
reco::PFBlock
Block of elements.
Definition: PFBlock.h:26
reco::PFBlockElement::SC
Definition: PFBlockElement.h:41
reco::PFCandidateEGammaExtra::addConversionRef
void addConversionRef(const reco::ConversionRef &convref)
add Conversions from PF
Definition: PFCandidateEGammaExtra.cc:143
PFEGammaAlgo::PFEGConfigInfo::applyCrackCorrections
bool applyCrackCorrections
Definition: PFEGammaAlgo.h:112
reco::PFBlockElementTrack::trackRef
const reco::TrackRef & trackRef() const override
Definition: PFBlockElementTrack.h:49
edm::Ref::get
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
HLT_2018_cff.distance
distance
Definition: HLT_2018_cff.py:6417
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:152
PFEGammaAlgo::gbrForests_
GBRForests const & gbrForests_
Definition: PFEGammaAlgo.h:135
reco::Vertex::position
const Point & position() const
position
Definition: Vertex.h:114
spr::goodTrack
bool goodTrack(const reco::Track *pTrack, math::XYZPoint leadPV, trackSelectionParameters parameters, bool debug=false)
Definition: TrackSelection.cc:10
reco::PFBlockElement::HCAL
Definition: PFBlockElement.h:36
edm::Ptr::get
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:139
DDAxes::x
edm::RefVector< ConversionCollection >
reco::PFBlockElement::HGCAL
Definition: PFBlockElement.h:43
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
PFEGammaAlgo::evaluateSingleLegMVA
float evaluateSingleLegMVA(const reco::PFBlockRef &blockref, const reco::Vertex &primaryVtx, unsigned int trackIndex)
Definition: PFEGammaAlgo.cc:459
hltPixelTracks_cff.chi2
chi2
Definition: hltPixelTracks_cff.py:25
edm::Ptr::key
key_type key() const
Definition: Ptr.h:163
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
edm::Ref::index
key_type index() const
Definition: Ref.h:253
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
training_settings.idx
idx
Definition: training_settings.py:16
reco::PFCandidateEGammaExtra
Definition: PFCandidateEGammaExtra.h:25
reco::PFCandidateEGammaExtra::setSuperClusterRef
void setSuperClusterRef(reco::SuperClusterRef sc)
set reference to the corresponding supercluster
Definition: PFCandidateEGammaExtra.h:108
reco::CaloClusterPtr
edm::Ptr< CaloCluster > CaloClusterPtr
Definition: CaloClusterFwd.h:21
reco::PFCandidateEGammaExtra::setMVA
void setMVA(float val)
set the result (mostly for debugging)
Definition: PFCandidateEGammaExtra.cc:116
reco::PFBlockElementSuperCluster::Dump
void Dump(std::ostream &out=std::cout, const char *tab=" ") const override
print the object inside the element
Definition: PFBlockElementSuperCluster.cc:11
edm::Ref< TrackCollection >
PFLayer::ECAL_BARREL
Definition: PFLayer.h:33
reco::PFCandidateEGammaExtra::setEarlyBrem
void setEarlyBrem(float val)
set EarlyBrem
Definition: PFCandidateEGammaExtra.cc:69
PFEGammaAlgo::unlinkRefinableObjectKFandECALWithBadEoverP
void unlinkRefinableObjectKFandECALWithBadEoverP(ProtoEGObject &)
Definition: PFEGammaAlgo.cc:1890
edm::refToPtr
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
Definition: RefToPtr.h:18
patCandidatesForDimuonsSequences_cff.hcal
hcal
Definition: patCandidatesForDimuonsSequences_cff.py:37
BeamMonitor_cff.primaryVertex
primaryVertex
hltOfflineBeamSpot for HLTMON
Definition: BeamMonitor_cff.py:7
reco::PFCandidateEGammaExtra::setGsfElectronClusterRef
void setGsfElectronClusterRef(const reco::PFBlockRef &blk, const reco::PFBlockElementCluster &ref)
set gsf electron cluster ref
Definition: PFCandidateEGammaExtra.h:88
reco::PFCandidateEGammaExtra::setKfTrackRef
void setKfTrackRef(const reco::TrackRef &ref)
set kf track reference
Definition: PFCandidateEGammaExtra.cc:51
ECAL
Definition: HCALResponse.h:21
PFEGammaAlgo::PFBremElement
reco::PFBlockElementBrem PFBremElement
Definition: PFEGammaAlgo.h:66
PFEGammaAlgo::primaryVertex_
reco::Vertex const & primaryVertex_
Definition: PFEGammaAlgo.h:222
PFEGammaAlgo::isPrimaryTrack
bool isPrimaryTrack(const reco::PFBlockElementTrack &KfEl, const reco::PFBlockElementGsfTrack &GsfEl)
Definition: PFEGammaAlgo.cc:2035
reco::PFCandidateEGammaExtra::setGsfTrackPout
void setGsfTrackPout(const math::XYZTLorentzVector &pout)
set the pout (not trivial to get from the GSF track)
Definition: PFCandidateEGammaExtra.cc:49
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
reco::PFBlockElementTrack::trackRefPF
const PFRecTrackRef & trackRefPF() const override
Definition: PFBlockElementTrack.h:46
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
LOGDRESSED
#define LOGDRESSED(x)
Definition: PFEGammaAlgo.cc:46
vars
vars
Definition: DeepTauId.cc:163
PFEGammaAlgo::calculateEleMVA
float calculateEleMVA(const ProtoEGObject &, reco::PFCandidateEGammaExtra &) const
Definition: PFEGammaAlgo.cc:1601
reco::PFBlockElement::TRACK
Definition: PFBlockElement.h:32
PVValHelper::eta
Definition: PVValidationHelpers.h:69
PFEGammaAlgo::PFClusterElement
reco::PFBlockElementCluster PFClusterElement
Definition: PFEGammaAlgo.h:69
PFEGammaAlgo::GBRForests::ele_
const std::unique_ptr< const GBRForest > ele_
Definition: PFEGammaAlgo.h:80
reco::Vertex::tracks_end
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:73
reco::CaloCluster::badHcalMarker
Definition: CaloCluster.h:50
PFEGammaAlgo::_currentblock
reco::PFBlockRef _currentblock
Definition: PFEGammaAlgo.h:144
RecoTauValidation_cfi.posX
posX
Definition: RecoTauValidation_cfi.py:288
reco::PFCandidateEGammaExtra::setLateBrem
void setLateBrem(float val)
set LateBrem
Definition: PFCandidateEGammaExtra.cc:64
PFEGammaAlgo::fillExtraInfo
void fillExtraInfo(const ProtoEGObject &, reco::PFCandidateEGammaExtra &)
Definition: PFEGammaAlgo.cc:1765
VtxSmearedParameters_cfi.Phi
Phi
Definition: VtxSmearedParameters_cfi.py:112
HCAL
Definition: HCALResponse.h:21
b
double b
Definition: hdecay.h:118
PFEGammaAlgo::linkRefinableObjectBremTangentsToECAL
void linkRefinableObjectBremTangentsToECAL(ProtoEGObject &)
Definition: PFEGammaAlgo.cc:1332
PFEnergyCalibration::initAlphaGamma_ESplanes_fromDB
void initAlphaGamma_ESplanes_fromDB(const ESEEIntercalibConstants *esEEInterCalib)
Definition: PFEnergyCalibration.h:67
reco::PFCandidateEGammaExtra::setGsfTrackRef
void setGsfTrackRef(const reco::GsfTrackRef &ref)
set gsftrack reference
Definition: PFCandidateEGammaExtra.cc:47
MuonTCMETValueMapProducer_cff.nLayers
nLayers
Definition: MuonTCMETValueMapProducer_cff.py:38
reco::PFBlockElement::TrackType
TrackType
Definition: PFBlockElement.h:47
LOGWARN
#define LOGWARN(x)
Definition: PFEGammaAlgo.cc:44
PFEGammaAlgo::linkRefinableObjectGSFTracksToKFs
void linkRefinableObjectGSFTracksToKFs(ProtoEGObject &)
Definition: PFEGammaAlgo.cc:1159
reco::PFCandidateEGammaExtra::setSuperClusterPFECALRef
void setSuperClusterPFECALRef(reco::SuperClusterRef sc)
set reference to the corresponding supercluster
Definition: PFCandidateEGammaExtra.h:111
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
delPhi
static double delPhi(const double phi1, const double phi2)
Definition: FFTGenericScaleCalculator.cc:20
a
double a
Definition: hdecay.h:119
reco::SuperCluster::seed
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:77
reco::PFCandidateEGammaExtra::setSigmaEtaEta
void setSigmaEtaEta(float val)
set the sigmaetaeta
Definition: PFCandidateEGammaExtra.cc:80
reco::PFBlockElement::GSF
Definition: PFBlockElement.h:37
PFEGammaAlgo::PFKFElement
reco::PFBlockElementTrack PFKFElement
Definition: PFEGammaAlgo.h:68
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
reco::Vertex::tracks_begin
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:71
PFEGammaAlgo::initializeProtoCands
void initializeProtoCands(std::list< ProtoEGObject > &)
Definition: PFEGammaAlgo.cc:655
reco::Vertex::x
double x() const
x coordinate
Definition: Vertex.h:116
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
PFTrackAlgoTools::isGoodForEGMPrimary
bool isGoodForEGMPrimary(const reco::TrackBase::TrackAlgorithm &)
Definition: PFTrackAlgoTools.cc:144
PFEGammaAlgo::linkRefinableObjectPrimaryKFsToSecondaryKFs
void linkRefinableObjectPrimaryKFsToSecondaryKFs(ProtoEGObject &)
Definition: PFEGammaAlgo.cc:1191
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
FlaggedPtr
Definition: FlaggedPtr.h:5
reco::TrackExtraRef
edm::Ref< TrackExtraCollection > TrackExtraRef
persistent reference to a TrackExtra
Definition: TrackExtraFwd.h:16
reco::PFBlockElement::ECAL
Definition: PFBlockElement.h:35
cand
Definition: decayParser.h:34
PFEGammaAlgo::GBRForests::singleLeg_
const std::unique_ptr< const GBRForest > singleLeg_
Definition: PFEGammaAlgo.h:81
p4
double p4[4]
Definition: TauolaWrapper.h:92
PFEGammaAlgo::removeOrLinkECALClustersToKFTracks
void removeOrLinkECALClustersToKFTracks()
Definition: PFEGammaAlgo.cc:1000
reco::PFBlockElement::T_FROM_GAMMACONV
Definition: PFBlockElement.h:47
edm::LogVerbatim
Definition: MessageLogger.h:297
reco::PFCandidateEGammaExtra::addSingleLegConvTrackRefMva
void addSingleLegConvTrackRefMva(const std::pair< reco::TrackRef, float > &trackrefmva)
add Single Leg Conversion TrackRef
Definition: PFCandidateEGammaExtra.cc:139
PFEGammaAlgo::attachPSClusters
int attachPSClusters(const PFClusterElement *, ClusterMap::mapped_type &)
Definition: PFEGammaAlgo.cc:901
ntupleEnum.gsf
gsf
Definition: ntupleEnum.py:48
groupFilesInBlocks.block
block
Definition: groupFilesInBlocks.py:150
PFEGammaAlgo::linkRefinableObjectKFTracksToECAL
void linkRefinableObjectKFTracksToECAL(ProtoEGObject &)
Definition: PFEGammaAlgo.cc:1286
PFEGammaAlgo::linkRefinableObjectSecondaryKFsToECAL
void linkRefinableObjectSecondaryKFsToECAL(ProtoEGObject &)
Definition: PFEGammaAlgo.cc:1450
reco::PFBlock::LinkData
std::map< unsigned int, Link > LinkData
Definition: PFBlock.h:39
reco::PFBlock::LINKTEST_ALL
Definition: PFBlock.h:41
reco::PFBlockElement
Abstract base class for a PFBlock element (track, cluster...)
Definition: PFBlockElement.h:26
reco::PFBlockElementSuperCluster::superClusterRef
const SuperClusterRef & superClusterRef() const
Definition: PFBlockElementSuperCluster.h:36
reco::CaloCluster::position
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:154
edm::Ptr< reco::PFCluster >
looper.cfg
cfg
Definition: looper.py:297
reco::PFBlockElementGsfTrack
Track Element.
Definition: PFBlockElementGsfTrack.h:18
bookConverter.elements
elements
Definition: bookConverter.py:147
eostools.move
def move(src, dest)
Definition: eostools.py:511
reco::Vertex::y
double y() const
y coordinate
Definition: Vertex.h:118
PFMuonAlgo::isMuon
static bool isMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:56
PFEGammaAlgo::linkKFTrackToECAL
void linkKFTrackToECAL(PFKFElement const *, ProtoEGObject &)
Definition: PFEGammaAlgo.cc:1295
math::XYZTLorentzVector
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
PFEGammaAlgo::linkRefinableObjectPrimaryGSFTrackToHCAL
void linkRefinableObjectPrimaryGSFTrackToHCAL(ProtoEGObject &)
Definition: PFEGammaAlgo.cc:1265
PFTrackAlgoTools::isGoodForEGM
bool isGoodForEGM(const reco::TrackBase::TrackAlgorithm &)
Definition: PFTrackAlgoTools.cc:117
reco::SuperCluster::rawEnergy
double rawEnergy() const
raw uncorrected energy (sum of energies of component BasicClusters)
Definition: SuperCluster.h:58
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
reco::PFBlockElementCluster
Cluster Element.
Definition: PFBlockElementCluster.h:16
Exception
Definition: hltDiff.cc:246
PFEGammaAlgo::_currentlinks
reco::PFBlock::LinkData _currentlinks
Definition: PFEGammaAlgo.h:145
PFClusterWidthAlgo
Definition: PFClusterWidthAlgo.h:6
EgammaObjects
Definition: EgammaObjects.h:25
reco::PFBlockElementTrack
Track Element.
Definition: PFBlockElementTrack.h:17
PFEGammaAlgo::isMuon
bool isMuon(const reco::PFBlockElement &)
Definition: PFEGammaAlgo.cc:505
PFEGammaAlgo::PFEGConfigInfo::mvaConvCut
double mvaConvCut
Definition: PFEGammaAlgo.h:114
reco::PFBlockElementGsfTrack::GsftrackRefPF
const GsfPFRecTrackRef & GsftrackRefPF() const
Definition: PFBlockElementGsfTrack.h:44
reco::PFBlockElementCluster::clusterRef
const PFClusterRef & clusterRef() const override
Definition: PFBlockElementCluster.h:29
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
PFEnergyCalibration::CalibratedEndcapPFClusterEnergies::clusterEnergy
double clusterEnergy
Definition: PFEnergyCalibration.h:50
reco::PFBlockElement::type
Type type() const
Definition: PFBlockElement.h:69
bsc_activity_cfg.ecal
ecal
Definition: bsc_activity_cfg.py:25
LOGVERB
#define LOGVERB(x)
Definition: PFEGammaAlgo.cc:43
electronIdCutBasedExt_cfi.sigmaEtaEta
sigmaEtaEta
Definition: electronIdCutBasedExt_cfi.py:123
PFEGammaAlgo::eetops_
reco::PFCluster::EEtoPSAssociation const & eetops_
Definition: PFEGammaAlgo.h:143
PFEGammaAlgo::PFSCElement
reco::PFBlockElementSuperCluster PFSCElement
Definition: PFEGammaAlgo.h:65
reco::PFCandidate
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
PFEGammaAlgo::unwrapSuperCluster
bool unwrapSuperCluster(const reco::PFBlockElementSuperCluster *, std::vector< FlaggedPtr< const PFClusterElement >> &, ClusterMap &)
Definition: PFEGammaAlgo.cc:776
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
reco::PFBlockElement::PS1
Definition: PFBlockElement.h:33
reco::Vertex::index
unsigned int index
index type
Definition: Vertex.h:54
PFEnergyCalibration::calibrateEndcapClusterEnergies
CalibratedEndcapPFClusterEnergies calibrateEndcapClusterEnergies(reco::PFCluster const &eeCluster, std::vector< reco::PFCluster const * > const &psClusterPointers, ESChannelStatus const &channelStatus, bool applyCrackCorrections) const
Definition: PFEnergyCalibration.cc:154
reco::PFBlockElement::index
unsigned index() const
Definition: PFBlockElement.h:86
math::XYZPointF
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
Definition: Point3D.h:10
PFLayer::ECAL_ENDCAP
Definition: PFLayer.h:32
docast
#define docast(x, y)
Definition: PFEGammaAlgo.cc:42
PFEGammaAlgo::dumpCurrentRefinableObjects
void dumpCurrentRefinableObjects() const
Definition: PFEGammaAlgo.cc:931
listHistos.trackPt
trackPt
Definition: listHistos.py:120
reco::CaloCluster::energy
double energy() const
cluster energy
Definition: CaloCluster.h:149
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
PFEGammaAlgo::buildRefinedSuperCluster
reco::SuperCluster buildRefinedSuperCluster(const ProtoEGObject &)
Definition: PFEGammaAlgo.cc:1786
reco::PFBlockElementSuperCluster::fromPFSuperCluster
bool fromPFSuperCluster() const
Definition: PFBlockElementSuperCluster.h:86
PFEGammaAlgo::fillPFCandidates
EgammaObjects fillPFCandidates(const std::list< ProtoEGObject > &)
Definition: PFEGammaAlgo.cc:1468
PFEGammaAlgo::unlinkRefinableObjectKFandECALMatchedToHCAL
void unlinkRefinableObjectKFandECALMatchedToHCAL(ProtoEGObject &, bool removeFreeECAL=false, bool removeSCECAL=false)
Definition: PFEGammaAlgo.cc:1963
RecoTauValidation_cfi.posY
posY
Definition: RecoTauValidation_cfi.py:289
PFEGammaAlgo::PFEGConfigInfo::produceEGCandsWithNoSuperCluster
bool produceEGCandsWithNoSuperCluster
Definition: PFEGammaAlgo.h:113
reco::PFBlockElement::PS2
Definition: PFBlockElement.h:34
edm::OwnVector< reco::PFBlockElement >
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
PFEGammaAlgo::thePFEnergyCalibration_
PFEnergyCalibration thePFEnergyCalibration_
Definition: PFEGammaAlgo.h:137