test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes
PFEGammaAlgo Class Reference

#include <PFEGammaAlgo.h>

Classes

struct  PFEGConfigInfo
 
struct  ProtoEGObject
 

Public Types

typedef std::unordered_map
< unsigned int, std::vector
< unsigned int > > 
AsscMap
 
typedef std::unordered_map
< const PFClusterElement
*, std::vector
< PFClusterFlaggedElement > > 
ClusterMap
 
typedef
reco::PFCluster::EEtoPSAssociation 
EEtoPSAssociation
 
typedef std::vector< std::pair
< const reco::PFBlockElement
*, const reco::PFBlockElement * > > 
ElementMap
 
typedef std::unordered_map
< const PFGSFElement
*, std::vector
< PFKFFlaggedElement > > 
GSFToTrackMap
 
typedef std::unordered_map
< const PFKFElement *, float > 
KFValMap
 
typedef reco::PFBlockElementBrem PFBremElement
 
typedef std::pair< const
PFBremElement *, bool > 
PFBremFlaggedElement
 
typedef reco::PFBlockElementCluster PFClusterElement
 
typedef std::pair< const
PFClusterElement *, bool > 
PFClusterFlaggedElement
 
typedef std::pair< const
reco::PFBlockElement *, bool > 
PFFlaggedElement
 
typedef
reco::PFBlockElementGsfTrack 
PFGSFElement
 
typedef std::pair< const
PFGSFElement *, bool > 
PFGSFFlaggedElement
 
typedef reco::PFBlockElementTrack PFKFElement
 
typedef std::pair< const
PFKFElement *, bool > 
PFKFFlaggedElement
 
typedef
reco::PFBlockElementSuperCluster 
PFSCElement
 
typedef std::pair< const
PFSCElement *, bool > 
PFSCFlaggedElement
 

Public Member Functions

reco::PFCandidateCollectiongetCandidates ()
 
reco::PFCandidateEGammaExtraCollectiongetEGExtra ()
 
reco::SuperClusterCollectiongetRefinedSCs ()
 
bool isEGValidCandidate (const pfEGHelpers::HeavyObjectCache *hoc, const reco::PFBlockRef &blockRef, std::vector< bool > &active)
 
 PFEGammaAlgo (const PFEGConfigInfo &)
 
void RunPFEG (const pfEGHelpers::HeavyObjectCache *hoc, const reco::PFBlockRef &blockRef, std::vector< bool > &active)
 
void setEEtoPSAssociation (const edm::Handle< EEtoPSAssociation > &eetops)
 
void setnPU (int nVtx)
 
void setPhotonPrimaryVtx (const reco::Vertex &primary)
 
 ~PFEGammaAlgo ()
 

Private Types

enum  verbosityLevel { Silent, Summary, Chatty }
 

Private Member Functions

int attachPSClusters (const PFClusterElement *, ClusterMap::mapped_type &)
 
void buildAndRefineEGObjects (const pfEGHelpers::HeavyObjectCache *hoc, const reco::PFBlockRef &block)
 
reco::SuperCluster buildRefinedSuperCluster (const ProtoEGObject &)
 
float calculate_ele_mva (const pfEGHelpers::HeavyObjectCache *hoc, const ProtoEGObject &, reco::PFCandidateEGammaExtra &)
 
void dumpCurrentRefinableObjects () const
 
float EvaluateSingleLegMVA (const pfEGHelpers::HeavyObjectCache *hoc, const reco::PFBlockRef &blockref, const reco::Vertex &primaryvtx, unsigned int track_index)
 
void fill_extra_info (const ProtoEGObject &, reco::PFCandidateEGammaExtra &)
 
void fillPFCandidates (const pfEGHelpers::HeavyObjectCache *hoc, const std::list< ProtoEGObject > &, reco::PFCandidateCollection &, reco::PFCandidateEGammaExtraCollection &)
 
void initializeProtoCands (std::list< ProtoEGObject > &)
 
bool isAMuon (const reco::PFBlockElement &)
 
bool isPrimaryTrack (const reco::PFBlockElementTrack &KfEl, const reco::PFBlockElementGsfTrack &GsfEl)
 
void linkKFTrackToECAL (const PFKFFlaggedElement &, ProtoEGObject &)
 
void linkRefinableObjectBremTangentsToECAL (ProtoEGObject &)
 
void linkRefinableObjectConvSecondaryKFsToSecondaryKFs (ProtoEGObject &)
 
void linkRefinableObjectECALToSingleLegConv (const pfEGHelpers::HeavyObjectCache *hoc, 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< PFClusterFlaggedElement > &, ClusterMap &)
 
unsigned int whichTrackAlgo (const reco::TrackRef &trackRef)
 

Private Attributes

reco::PFBlockRef _currentblock
 
reco::PFBlock::LinkData _currentlinks
 
reco::PFCandidateCollection _finalCandidates
 
ElementMap _recoveredlinks
 
std::list< ProtoEGObject_refinableObjects
 
std::vector< std::vector
< PFFlaggedElement > > 
_splayedblock
 
std::vector< unsigned int > AddFromElectron_
 
PFEGConfigInfo cfg_
 
float chi2
 
float chi2_gsf
 
float chi2_kf
 
float Clus5x5ratio_
 
float ClusEta_
 
float ClusPhi_
 
float ClusR9_
 
std::vector< std::pair
< unsigned int, unsigned int > > 
convGsfTrack_
 
float CrysEta_
 
int CrysIEta_
 
int CrysIPhi_
 
float CrysPhi_
 
float CrysX_
 
float CrysY_
 
float del_phi
 
float dEta_
 
float DEtaGsfEcalClust
 
float dPhi_
 
float dPtOverPt_gsf
 
float DPtOverPt_gsf
 
float DPtOverPt_kf
 
float e1x3_
 
float e1x5_
 
float e2x5Bottom_
 
float e2x5Left_
 
float e2x5Max_
 
float e2x5Right_
 
float e2x5Top_
 
float e3x1_
 
float e3x3_
 
float E3x3_
 
float e5x5Map [5][5]
 
float earlyBrem
 
float EB
 
float ebottom_
 
edm::Handle
< reco::PFCluster::EEtoPSAssociation
eetops_
 
reco::PFCandidateCollection egCandidate_
 
reco::PFCandidateEGammaExtraCollection egExtra_
 
float EGsfPoutMode
 
float eleft_
 
float EoverPt
 
float eright_
 
float eSeed_
 
float Eta_gsf
 
float etop_
 
float EtotBremPinPoutMode
 
float EtotPinMode
 
float excluded_
 
std::vector< std::pair
< unsigned int, unsigned int > > 
fifthStepKfTrack_
 
float firstBrem
 
std::vector< bool > GsfTrackSingleEcal_
 
float HOverHE
 
float HOverPin
 
float HoverPt
 
bool isvalid_
 
float lateBrem
 
float lnPt_gsf
 
std::vector< bool > lockExtraKf_
 
float logPFClusE_
 
float LowClusE_
 
std::vector< int > match_ind
 
float Mustache_Et_out_
 
float Mustache_EtRatio_
 
float MustE_
 
double mvaValue
 
const char * mvaWeightFile_
 
float nhit_gsf
 
float nhit_kf
 
float nlayers
 
float nlost
 
float nPFClus_
 
float nVtx_
 
reco::PFCandidateCollection outcands_
 
reco::PFCandidateEGammaExtraCollection outcandsextra_
 
std::vector< reco::PFCandidatepermElectronCandidates_
 
float PFCrysEtaCrack_
 
float PFPhoE_
 
float PFPhoECorr_
 
float PFPhoEt_
 
float PFPhoEta_
 
float PFPhoEtCorr_
 
float PFPhoPhi_
 
float PFPhoR9_
 
float PFPhoR9Corr_
 
const reco::VertexprimaryVertex_
 
float RConv_
 
const GBRForestReaderGC_
 
const GBRForestReaderGCEB_
 
const GBRForestReaderGCEEhR9_
 
const GBRForestReaderGCEElR9_
 
const GBRForestReaderLC_
 
const GBRForestReaderLCEB_
 
const GBRForestReaderLCEE_
 
const GBRForestReaderRes_
 
reco::SuperClusterCollection refinedscs_
 
float RMSAll_
 
float RMSMust_
 
float SCEtaWidth_
 
float SCPhiWidth_
 
float SigmaEtaEta
 
float STIP
 
double sumPtTrackIsoForPhoton_
 
double sumPtTrackIsoSlopeForPhoton_
 
float TotPS1_
 
float TotPS2_
 
float track_pt
 
verbosityLevel verbosityLevel_
 
float VtxZ_
 
TH2D * X0_inner
 
TH2D * X0_middle
 
TH2D * X0_outer
 
TH2D * X0_sum
 
float x0inner_
 
float x0middle_
 
float x0outer_
 

Detailed Description

Definition at line 53 of file PFEGammaAlgo.h.

Member Typedef Documentation

typedef std::unordered_map<unsigned int, std::vector<unsigned int> > PFEGammaAlgo::AsscMap

Definition at line 67 of file PFEGammaAlgo.h.

typedef std::unordered_map<const PFClusterElement*, std::vector<PFClusterFlaggedElement> > PFEGammaAlgo::ClusterMap

Definition at line 73 of file PFEGammaAlgo.h.

Definition at line 55 of file PFEGammaAlgo.h.

typedef std::vector<std::pair<const reco::PFBlockElement*, const reco::PFBlockElement*> > PFEGammaAlgo::ElementMap

Definition at line 69 of file PFEGammaAlgo.h.

typedef std::unordered_map<const PFGSFElement*, std::vector<PFKFFlaggedElement> > PFEGammaAlgo::GSFToTrackMap

Definition at line 71 of file PFEGammaAlgo.h.

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

Definition at line 75 of file PFEGammaAlgo.h.

Definition at line 57 of file PFEGammaAlgo.h.

typedef std::pair<const PFBremElement*,bool> PFEGammaAlgo::PFBremFlaggedElement

Definition at line 63 of file PFEGammaAlgo.h.

Definition at line 60 of file PFEGammaAlgo.h.

Definition at line 66 of file PFEGammaAlgo.h.

typedef std::pair<const reco::PFBlockElement*,bool> PFEGammaAlgo::PFFlaggedElement

Definition at line 61 of file PFEGammaAlgo.h.

Definition at line 58 of file PFEGammaAlgo.h.

typedef std::pair<const PFGSFElement*,bool> PFEGammaAlgo::PFGSFFlaggedElement

Definition at line 64 of file PFEGammaAlgo.h.

Definition at line 59 of file PFEGammaAlgo.h.

typedef std::pair<const PFKFElement*,bool> PFEGammaAlgo::PFKFFlaggedElement

Definition at line 65 of file PFEGammaAlgo.h.

Definition at line 56 of file PFEGammaAlgo.h.

typedef std::pair<const PFSCElement*,bool> PFEGammaAlgo::PFSCFlaggedElement

Definition at line 62 of file PFEGammaAlgo.h.

Member Enumeration Documentation

Enumerator
Silent 
Summary 
Chatty 

Definition at line 172 of file PFEGammaAlgo.h.

Constructor & Destructor Documentation

PFEGammaAlgo::PFEGammaAlgo ( const PFEGConfigInfo cfg)

Definition at line 688 of file PFEGammaAlgo.cc.

References cfg_, X0_inner, PFEGammaAlgo::PFEGConfigInfo::X0_Map, X0_middle, X0_outer, and X0_sum.

688  :
689  cfg_(cfg),
690  isvalid_(false),
692  nlost(0.0), nlayers(0.0),
693  chi2(0.0), STIP(0.0), del_phi(0.0),HoverPt(0.0), EoverPt(0.0), track_pt(0.0),
694  mvaValue(0.0),
695  CrysPhi_(0.0), CrysEta_(0.0), VtxZ_(0.0), ClusPhi_(0.0), ClusEta_(0.0),
696  ClusR9_(0.0), Clus5x5ratio_(0.0), PFCrysEtaCrack_(0.0), logPFClusE_(0.0), e3x3_(0.0),
697  CrysIPhi_(0), CrysIEta_(0),
698  CrysX_(0.0), CrysY_(0.0),
699  EB(0.0),
700  eSeed_(0.0), e1x3_(0.0),e3x1_(0.0), e1x5_(0.0), e2x5Top_(0.0), e2x5Bottom_(0.0), e2x5Left_(0.0), e2x5Right_(0.0),
701  etop_(0.0), ebottom_(0.0), eleft_(0.0), eright_(0.0),
702  e2x5Max_(0.0),
703  PFPhoEta_(0.0), PFPhoPhi_(0.0), PFPhoR9_(0.0), PFPhoR9Corr_(0.0), SCPhiWidth_(0.0), SCEtaWidth_(0.0),
704  PFPhoEt_(0.0), RConv_(0.0), PFPhoEtCorr_(0.0), PFPhoE_(0.0), PFPhoECorr_(0.0), MustE_(0.0), E3x3_(0.0),
705  dEta_(0.0), dPhi_(0.0), LowClusE_(0.0), RMSAll_(0.0), RMSMust_(0.0), nPFClus_(0.0),
706  TotPS1_(0.0), TotPS2_(0.0),
707  nVtx_(0.0),
708  x0inner_(0.0), x0middle_(0.0), x0outer_(0.0),
710 {
711  //Material Map
712  TFile *XO_File = new TFile(cfg_.X0_Map.c_str(),"READ");
713  X0_sum = (TH2D*)XO_File->Get("TrackerSum");
714  X0_inner = (TH2D*)XO_File->Get("Inner");
715  X0_middle = (TH2D*)XO_File->Get("Middle");
716  X0_outer = (TH2D*)XO_File->Get("Outer");
717 
718 }
float SCEtaWidth_
Definition: PFEGammaAlgo.h:371
double mvaValue
Definition: PFEGammaAlgo.h:356
tuple cfg
Definition: looper.py:293
float e2x5Bottom_
Definition: PFEGammaAlgo.h:367
float Mustache_Et_out_
Definition: PFEGammaAlgo.h:382
TH2D * X0_outer
Definition: PFEGammaAlgo.h:379
float Clus5x5ratio_
Definition: PFEGammaAlgo.h:361
float PFPhoEtCorr_
Definition: PFEGammaAlgo.h:371
float e2x5Right_
Definition: PFEGammaAlgo.h:367
PFEGConfigInfo cfg_
Definition: PFEGammaAlgo.h:300
float SCPhiWidth_
Definition: PFEGammaAlgo.h:371
float Mustache_EtRatio_
Definition: PFEGammaAlgo.h:382
float logPFClusE_
Definition: PFEGammaAlgo.h:361
float PFPhoECorr_
Definition: PFEGammaAlgo.h:371
TH2D * X0_inner
Definition: PFEGammaAlgo.h:377
float PFPhoR9Corr_
Definition: PFEGammaAlgo.h:371
TH2D * X0_middle
Definition: PFEGammaAlgo.h:378
verbosityLevel verbosityLevel_
Definition: PFEGammaAlgo.h:329
float PFCrysEtaCrack_
Definition: PFEGammaAlgo.h:361
PFEGammaAlgo::~PFEGammaAlgo ( )
inline

Definition at line 134 of file PFEGammaAlgo.h.

134 { };

Member Function Documentation

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

Definition at line 1226 of file PFEGammaAlgo.cc.

References _splayedblock, 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().

1227  {
1228  if( ecalclus->clusterRef()->layer() == PFLayer::ECAL_BARREL ) return 0;
1229  edm::Ptr<reco::PFCluster> clusptr = refToPtr(ecalclus->clusterRef());
1230  EEtoPSElement ecalkey = std::make_pair(clusptr.key(),clusptr);
1231  auto assc_ps = std::equal_range(eetops_->cbegin(),
1232  eetops_->cend(),
1233  ecalkey,
1234  comparePSMapByKey);
1235  for( const auto& ps1 : _splayedblock[reco::PFBlockElement::PS1] ) {
1236  edm::Ptr<reco::PFCluster> temp = refToPtr(ps1.first->clusterRef());
1237  for( auto pscl = assc_ps.first; pscl != assc_ps.second; ++pscl ) {
1238  if( pscl->second == temp ) {
1239  const ClusterElement* pstemp =
1240  docast(const ClusterElement*,ps1.first);
1241  eslist.push_back( PFClusterFlaggedElement(pstemp,true) );
1242  }
1243  }
1244  }
1245  for( const auto& ps2 : _splayedblock[reco::PFBlockElement::PS2] ) {
1246  edm::Ptr<reco::PFCluster> temp = refToPtr(ps2.first->clusterRef());
1247  for( auto pscl = assc_ps.first; pscl != assc_ps.second; ++pscl ) {
1248  if( pscl->second == temp ) {
1249  const ClusterElement* pstemp =
1250  docast(const ClusterElement*,ps2.first);
1251  eslist.push_back( PFClusterFlaggedElement(pstemp,true) );
1252  }
1253  }
1254  }
1255  return eslist.size();
1256  }
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
key_type key() const
Definition: Ptr.h:186
std::pair< const PFClusterElement *, bool > PFClusterFlaggedElement
Definition: PFEGammaAlgo.h:66
std::vector< std::vector< PFFlaggedElement > > _splayedblock
Definition: PFEGammaAlgo.h:191
edm::Handle< reco::PFCluster::EEtoPSAssociation > eetops_
Definition: PFEGammaAlgo.h:186
#define docast(x, y)
Definition: PFEGammaAlgo.cc:43
void PFEGammaAlgo::buildAndRefineEGObjects ( const pfEGHelpers::HeavyObjectCache hoc,
const reco::PFBlockRef block 
)
private

Definition at line 821 of file PFEGammaAlgo.cc.

References _currentblock, _currentlinks, _finalCandidates, _recoveredlinks, _refinableObjects, _splayedblock, a, b, createPayload::block, dumpCurrentRefinableObjects(), fillPFCandidates(), initializeProtoCands(), isAMuon(), linkRefinableObjectBremTangentsToECAL(), linkRefinableObjectConvSecondaryKFsToSecondaryKFs(), linkRefinableObjectECALToSingleLegConv(), linkRefinableObjectGSFTracksToKFs(), linkRefinableObjectKFTracksToECAL(), linkRefinableObjectPrimaryGSFTrackToECAL(), linkRefinableObjectPrimaryGSFTrackToHCAL(), linkRefinableObjectPrimaryKFsToSecondaryKFs(), linkRefinableObjectSecondaryKFsToECAL(), LOGDRESSED, LOGVERB, mergeROsByAnyLink(), outcands_, outcandsextra_, removeOrLinkECALClustersToKFTracks(), python.multivaluedict::sort(), unlinkRefinableObjectKFandECALMatchedToHCAL(), and unlinkRefinableObjectKFandECALWithBadEoverP().

Referenced by RunPFEG().

822  {
823  LOGVERB("PFEGammaAlgo")
824  << "Resetting PFEGammaAlgo for new block and running!" << std::endl;
825  _splayedblock.clear();
826  _recoveredlinks.clear();
827  _refinableObjects.clear();
828  _finalCandidates.clear();
829  _splayedblock.resize(12); // make sure that we always have the SC entry
830 
832  _currentlinks = block->linkData();
833  //LOGDRESSED("PFEGammaAlgo") << *_currentblock << std::endl;
834  LOGVERB("PFEGammaAlgo") << "Splaying block" << std::endl;
835  //unwrap the PF block into a fast access map
836  for( const auto& pfelement : _currentblock->elements() ) {
837  if( isAMuon(pfelement) ) continue; // don't allow muons in our element list
838  const size_t itype = (size_t)pfelement.type();
839  if( itype >= _splayedblock.size() ) _splayedblock.resize(itype+1);
840  _splayedblock[itype].push_back(std::make_pair(&pfelement,true));
841  }
842 
843  // show the result of splaying the tree if it's really *really* needed
844 #ifdef PFLOW_DEBUG
845  std::stringstream splayout;
846  for( size_t itype = 0; itype < _splayedblock.size(); ++itype ) {
847  splayout << "\tType: " << itype << " indices: ";
848  for( const auto& flaggedelement : _splayedblock[itype] ) {
849  splayout << flaggedelement.first->index() << ' ';
850  }
851  if( itype != _splayedblock.size() - 1 ) splayout << std::endl;
852  }
853  LOGVERB("PFEGammaAlgo") << splayout.str();
854 #endif
855 
856  // precleaning of the ECAL clusters with respect to primary KF tracks
857  // we don't allow clusters in super clusters to be locked out this way
859 
861  LOGDRESSED("PFEGammaAlgo")
862  << "Initialized " << _refinableObjects.size() << " proto-EGamma objects"
863  << std::endl;
865 
866  //
867  // now we start the refining steps
868  //
869  //
870 
871  // --- Primary Linking Step ---
872  // since this is particle flow and we try to work from the pixels out
873  // we start by linking the tracks together and finding the ECAL clusters
874  for( auto& RO : _refinableObjects ) {
875  // find the KF tracks associated to GSF primary tracks
877  // do the same for HCAL clusters associated to the GSF
879  // link secondary KF tracks associated to primary KF tracks
881  // pick up clusters that are linked to the GSF primary
883  // link associated KF to ECAL (ECAL part grabs PS clusters too if able)
885  // now finally look for clusters associated to brem tangents
887  }
888 
889  LOGDRESSED("PFEGammaAlgo")
890  << "Dumping after GSF and KF Track (Primary) Linking : " << std::endl;
892 
893  // merge objects after primary linking
894  mergeROsByAnyLink(_refinableObjects);
895 
896  LOGDRESSED("PFEGammaAlgo")
897  << "Dumping after first merging operation : " << std::endl;
899 
900  // --- Secondary Linking Step ---
901  // after this we go through the ECAL clusters on the remaining tracks
902  // and try to link those in...
903  for( auto& RO : _refinableObjects ) {
904  // look for conversion legs
907  // look for tracks that complement conversion legs
909  // look again for ECAL clusters (this time with an e/p cut)
911  }
912 
913  LOGDRESSED("PFEGammaAlgo")
914  << "Dumping after ECAL to Track (Secondary) Linking : " << std::endl;
916 
917  // merge objects after primary linking
918  mergeROsByAnyLink(_refinableObjects);
919 
920  LOGDRESSED("PFEGammaAlgo")
921  << "There are " << _refinableObjects.size()
922  << " after the 2nd merging step." << std::endl;
924 
925  // -- unlinking and proto-object vetos, final sorting
926  for( auto& RO : _refinableObjects ) {
927  // remove secondary KFs (and possibly ECALs) matched to HCAL clusters
929  // remove secondary KFs and ECALs linked to them that have bad E/p_in
930  // and spoil the resolution
932  // put things back in order after partitioning
933  std::sort(RO.ecalclusters.begin(), RO.ecalclusters.end(),
934  [](const PFClusterFlaggedElement& a,
935  const PFClusterFlaggedElement& b)
936  { return ( a.first->clusterRef()->correctedEnergy() >
937  b.first->clusterRef()->correctedEnergy() ) ; });
938  setROElectronCluster(RO);
939  }
940 
941  LOGDRESSED("PFEGammaAlgo")
942  << "There are " << _refinableObjects.size()
943  << " after the unlinking and vetos step." << std::endl;
945 
946  // fill the PF candidates and then build the refined SC
947  fillPFCandidates(hoc,_refinableObjects,outcands_,outcandsextra_);
948 
949 }
void unlinkRefinableObjectKFandECALWithBadEoverP(ProtoEGObject &)
std::pair< const PFClusterElement *, bool > PFClusterFlaggedElement
Definition: PFEGammaAlgo.h:66
void linkRefinableObjectPrimaryGSFTrackToECAL(ProtoEGObject &)
void linkRefinableObjectECALToSingleLegConv(const pfEGHelpers::HeavyObjectCache *hoc, ProtoEGObject &)
std::vector< std::vector< PFFlaggedElement > > _splayedblock
Definition: PFEGammaAlgo.h:191
void linkRefinableObjectBremTangentsToECAL(ProtoEGObject &)
reco::PFBlockRef _currentblock
Definition: PFEGammaAlgo.h:187
#define LOGVERB(x)
Definition: PFEGammaAlgo.cc:44
#define LOGDRESSED(x)
Definition: PFEGammaAlgo.cc:47
void dumpCurrentRefinableObjects() const
void initializeProtoCands(std::list< ProtoEGObject > &)
void linkRefinableObjectPrimaryKFsToSecondaryKFs(ProtoEGObject &)
std::list< ProtoEGObject > _refinableObjects
Definition: PFEGammaAlgo.h:205
reco::PFCandidateEGammaExtraCollection outcandsextra_
Definition: PFEGammaAlgo.h:181
reco::PFBlock::LinkData _currentlinks
Definition: PFEGammaAlgo.h:188
bool isAMuon(const reco::PFBlockElement &)
double b
Definition: hdecay.h:120
void linkRefinableObjectGSFTracksToKFs(ProtoEGObject &)
ElementMap _recoveredlinks
Definition: PFEGammaAlgo.h:192
void fillPFCandidates(const pfEGHelpers::HeavyObjectCache *hoc, const std::list< ProtoEGObject > &, reco::PFCandidateCollection &, reco::PFCandidateEGammaExtraCollection &)
void removeOrLinkECALClustersToKFTracks()
void unlinkRefinableObjectKFandECALMatchedToHCAL(ProtoEGObject &, bool removeFreeECAL=false, bool removeSCECAL=false)
double a
Definition: hdecay.h:121
void mergeROsByAnyLink(std::list< ProtoEGObject > &)
void linkRefinableObjectKFTracksToECAL(ProtoEGObject &)
void linkRefinableObjectSecondaryKFsToECAL(ProtoEGObject &)
reco::PFCandidateCollection _finalCandidates
Definition: PFEGammaAlgo.h:207
void linkRefinableObjectConvSecondaryKFsToSecondaryKFs(ProtoEGObject &)
reco::PFCandidateCollection outcands_
Definition: PFEGammaAlgo.h:180
void linkRefinableObjectPrimaryGSFTrackToHCAL(ProtoEGObject &)
reco::SuperCluster PFEGammaAlgo::buildRefinedSuperCluster ( const ProtoEGObject RO)
private

Definition at line 2227 of file PFEGammaAlgo.cc.

References reco::SuperCluster::addCluster(), reco::CaloCluster::addHitAndFraction(), reco::SuperCluster::addPreshowerCluster(), PFEGammaAlgo::PFEGConfigInfo::applyCrackCorrections, cfg_, TauDecayModes::dec, PFEGammaAlgo::ProtoEGObject::ecal2ps, PFLayer::ECAL_ENDCAP, PFEGammaAlgo::ProtoEGObject::ecalclusters, Exception, spr::find(), plotBeamSpotDB::first, edm::Ptr< T >::get(), PFClusterWidthAlgo::pflowEtaWidth(), PFClusterWidthAlgo::pflowPhiWidth(), reco::SuperCluster::preshowerClustersBegin(), reco::SuperCluster::preshowerClustersEnd(), reco::PFBlockElement::PS1, reco::PFBlockElement::PS2, 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 PFEGammaAlgo::PFEGConfigInfo::thePFEnergyCalibration.

Referenced by fillPFCandidates().

2227  {
2228  if( !RO.ecalclusters.size() ) {
2229  return reco::SuperCluster(0.0,math::XYZPoint(0,0,0));
2230  }
2231 
2232  SumPSEnergy sumps1(reco::PFBlockElement::PS1),
2233  sumps2(reco::PFBlockElement::PS2);
2234 
2235  bool isEE = false;
2236  edm::Ptr<reco::PFCluster> clusptr;
2237  // need the vector of raw pointers for a PF width class
2238  std::vector<const reco::PFCluster*> bare_ptrs;
2239  // calculate necessary parameters and build the SC
2240  double posX(0), posY(0), posZ(0),
2241  rawSCEnergy(0), corrSCEnergy(0), corrPSEnergy(0),
2242  PS1_clus_sum(0), PS2_clus_sum(0),
2243  ePS1(0), ePS2(0), ps1_energy(0.0), ps2_energy(0.0);
2244  for( auto& clus : RO.ecalclusters ) {
2245  ePS1 = 0;
2246  ePS2 = 0;
2247  isEE = PFLayer::ECAL_ENDCAP == clus.first->clusterRef()->layer();
2248  clusptr =
2249  edm::refToPtr<reco::PFClusterCollection>(clus.first->clusterRef());
2250  bare_ptrs.push_back(clusptr.get());
2251 
2252  const double cluseraw = clusptr->energy();
2253  double cluscalibe = clusptr->correctedEnergy();
2254  const math::XYZPoint& cluspos = clusptr->position();
2255  posX += cluseraw * cluspos.X();
2256  posY += cluseraw * cluspos.Y();
2257  posZ += cluseraw * cluspos.Z();
2258  // update EE calibrated super cluster energies
2259  if( isEE ) {
2260  const auto& psclusters = RO.ecal2ps.at(clus.first);
2261  PS1_clus_sum = std::accumulate(psclusters.begin(),psclusters.end(),
2262  0.0,sumps1);
2263  PS2_clus_sum = std::accumulate(psclusters.begin(),psclusters.end(),
2264  0.0,sumps2);
2265  cluscalibe =
2266  cfg_.thePFEnergyCalibration->energyEm(*clusptr,
2267  PS1_clus_sum,PS2_clus_sum,
2268  ePS1, ePS2,
2270  }
2271 
2272  rawSCEnergy += cluseraw;
2273  corrSCEnergy += cluscalibe;
2274  ps1_energy += ePS1;
2275  ps2_energy += ePS2;
2276  corrPSEnergy += ePS1 + ePS2;
2277  }
2278  posX /= rawSCEnergy;
2279  posY /= rawSCEnergy;
2280  posZ /= rawSCEnergy;
2281 
2282  // now build the supercluster
2283  reco::SuperCluster new_sc(corrSCEnergy,math::XYZPoint(posX,posY,posZ));
2284 
2285  clusptr =
2286  edm::refToPtr<reco::PFClusterCollection>(RO.ecalclusters.front().
2287  first->clusterRef());
2288  new_sc.setCorrectedEnergy(corrSCEnergy);
2289  new_sc.setSeed(clusptr);
2290  new_sc.setPreshowerEnergyPlane1(ps1_energy);
2291  new_sc.setPreshowerEnergyPlane2(ps2_energy);
2292  new_sc.setPreshowerEnergy(corrPSEnergy);
2293  for( const auto& clus : RO.ecalclusters ) {
2294  clusptr =
2295  edm::refToPtr<reco::PFClusterCollection>(clus.first->clusterRef());
2296  new_sc.addCluster(clusptr);
2297  auto& hits_and_fractions = clusptr->hitsAndFractions();
2298  for( auto& hit_and_fraction : hits_and_fractions ) {
2299  new_sc.addHitAndFraction(hit_and_fraction.first,hit_and_fraction.second);
2300  }
2301  // put the preshower stuff back in later
2302  const auto& cluspsassociation = RO.ecal2ps.at(clus.first);
2303  // EE rechits should be uniquely matched to sets of pre-shower
2304  // clusters at this point, so we throw an exception if otherwise
2305  // now wrapped in EDM debug flags
2306  for( const auto& pscluselem : cluspsassociation ) {
2307  edm::Ptr<reco::PFCluster> psclus =
2308  edm::refToPtr<reco::PFClusterCollection>(pscluselem.first->
2309  clusterRef());
2310 #ifdef PFFLOW_DEBUG
2311  auto found_pscluster = std::find(new_sc.preshowerClustersBegin(),
2312  new_sc.preshowerClustersEnd(),
2313  reco::CaloClusterPtr(psclus));
2314  if( found_pscluster == new_sc.preshowerClustersEnd() ) {
2315 #endif
2316  new_sc.addPreshowerCluster(psclus);
2317 #ifdef PFFLOW_DEBUG
2318  } else {
2319  throw cms::Exception("PFECALSuperClusterAlgo::buildSuperCluster")
2320  << "Found a PS cluster matched to more than one EE cluster!"
2321  << std::endl << std::hex << psclus.get() << " == "
2322  << found_pscluster->get() << std::dec << std::endl;
2323  }
2324 #endif
2325  }
2326  }
2327 
2328  // calculate linearly weighted cluster widths
2329  PFClusterWidthAlgo pfwidth(bare_ptrs);
2330  new_sc.setEtaWidth(pfwidth.pflowEtaWidth());
2331  new_sc.setPhiWidth(pfwidth.pflowPhiWidth());
2332 
2333  // cache the value of the raw energy
2334  new_sc.rawEnergy();
2335 
2336  return new_sc;
2337 }
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:160
std::shared_ptr< PFEnergyCalibration > thePFEnergyCalibration
Definition: PFEGammaAlgo.h:109
edm::Ptr< CaloCluster > CaloClusterPtr
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
PFEGConfigInfo cfg_
Definition: PFEGammaAlgo.h:300
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
float PFEGammaAlgo::calculate_ele_mva ( const pfEGHelpers::HeavyObjectCache hoc,
const ProtoEGObject RO,
reco::PFCandidateEGammaExtra xtra 
)
private

Definition at line 2031 of file PFEGammaAlgo.cc.

References _currentblock, a, funct::abs(), b, PFEGammaAlgo::ProtoEGObject::brems, chi2_gsf, chi2_kf, constexpr, DEtaGsfEcalClust, dPtOverPt_gsf, DPtOverPt_gsf, DPtOverPt_kf, alignCSCRings::e, earlyBrem, patCandidatesForDimuonsSequences_cff::ecal, PFEGammaAlgo::ProtoEGObject::ecalclusters, EGsfPoutMode, PFEGammaAlgo::ProtoEGObject::electronClusters, Eta_gsf, EtotBremPinPoutMode, EtotPinMode, f, spr::find(), PFEGammaAlgo::ProtoEGObject::firstBrem, firstBrem, pfEGHelpers::HeavyObjectCache::gbrEle_, reco::PFBlockElementGsfTrack::GsftrackRef(), PFEGammaAlgo::ProtoEGObject::hcalClusters, HOverHE, HOverPin, edm::Ref< C, T, F >::isNonnull(), PFEGammaAlgo::ProtoEGObject::lateBrem, lateBrem, lnPt_gsf, PFEGammaAlgo::ProtoEGObject::localMap, cmsBatch::log, bookConverter::max, min(), PFEGammaAlgo::ProtoEGObject::nBremsWithClusters, nhit_gsf, nhit_kf, NULL, 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 SigmaEtaEta.

Referenced by fillPFCandidates().

2033  {
2034  if( !RO.primaryGSFs.size() ) return -2.0f;
2035  const PFGSFElement* gsfElement = RO.primaryGSFs.front().first;
2036  const PFKFElement* kfElement = NULL;
2037  if( RO.primaryKFs.size() ) kfElement = RO.primaryKFs.front().first;
2038  reco::GsfTrackRef RefGSF= gsfElement->GsftrackRef();
2039  reco::TrackRef RefKF;
2040  constexpr float m_el = 0.000511;
2041  const double Ein_gsf = std::hypot(RefGSF->pMode(),m_el);
2042  double deta_gsfecal = 1e6;
2043  double sigmaEtaEta = 1e-14;
2044  const double Ene_hcalgsf = std::accumulate(RO.hcalClusters.begin(),
2045  RO.hcalClusters.end(),
2046  0.0,
2047  [](const double a,
2048  const PFClusterFlaggedElement& b)
2049  { return a + b.first->clusterRef()->energy(); }
2050  );
2051  if( RO.primaryKFs.size() ) {
2052  RefKF = RO.primaryKFs.front().first->trackRef();
2053  }
2054  const double Eout_gsf = gsfElement->Pout().t();
2055  const double Etaout_gsf = gsfElement->positionAtECALEntrance().eta();
2056  double FirstEcalGsfEnergy(0.0), OtherEcalGsfEnergy(0.0), EcalBremEnergy(0.0);
2057  //shower shape of cluster closest to gsf track
2058  std::vector<const reco::PFCluster*> gsfcluster;
2059  for( const auto& ecal : RO.ecalclusters ) {
2060  const double cenergy = ecal.first->clusterRef()->correctedEnergy();
2061  ElementMap::value_type gsfToEcal(gsfElement,ecal.first);
2062  ElementMap::value_type kfToEcal(kfElement,ecal.first);
2063  bool hasgsf =
2064  ( std::find(RO.localMap.begin(), RO.localMap.end(), gsfToEcal) ==
2065  RO.localMap.end() );
2066  bool haskf =
2067  ( std::find(RO.localMap.begin(), RO.localMap.end(), kfToEcal) ==
2068  RO.localMap.end() );
2069  bool hasbrem = false;
2070  for( const auto& brem : RO.brems ) {
2071  ElementMap::value_type bremToEcal(brem.first,ecal.first);
2072  if( std::find(RO.localMap.begin(), RO.localMap.end(), bremToEcal) !=
2073  RO.localMap.end() ) {
2074  hasbrem = true;
2075  }
2076  }
2077  if( hasbrem && ecal.first != RO.electronClusters[0] ) {
2078  EcalBremEnergy += cenergy;
2079  }
2080  if( !hasbrem && ecal.first != RO.electronClusters[0] ) {
2081  if( hasgsf ) OtherEcalGsfEnergy += cenergy;
2082  if( haskf ) EcalBremEnergy += cenergy; // from conv. brem!
2083  if( !(hasgsf || haskf) ) OtherEcalGsfEnergy += cenergy; // stuff from SC
2084  }
2085  }
2086 
2087  if( RO.electronClusters[0] ) {
2088  reco::PFClusterRef cref = RO.electronClusters[0]->clusterRef();
2089  xtra.setGsfElectronClusterRef(_currentblock,*(RO.electronClusters[0]));
2090  FirstEcalGsfEnergy = cref->correctedEnergy();
2091  deta_gsfecal = cref->positionREP().eta() - Etaout_gsf;
2092  gsfcluster.push_back(&*cref);
2093  PFClusterWidthAlgo pfwidth(gsfcluster);
2094  sigmaEtaEta = pfwidth.pflowSigmaEtaEta();
2095  }
2096 
2097  // brem sequence information
2098  lateBrem = firstBrem = earlyBrem = -1.0f;
2099  if(RO.nBremsWithClusters > 0) {
2100  if (RO.lateBrem == 1) lateBrem = 1.0f;
2101  else lateBrem = 0.0f;
2102  firstBrem = RO.firstBrem;
2103  if(RO.firstBrem < 4) earlyBrem = 1.0f;
2104  else earlyBrem = 0.0f;
2105  }
2106  xtra.setEarlyBrem(earlyBrem);
2107  xtra.setLateBrem(lateBrem);
2108  if( FirstEcalGsfEnergy > 0.0 ) {
2109  if( RefGSF.isNonnull() ) {
2110  xtra.setGsfTrackPout(gsfElement->Pout());
2111  // normalization observables
2112  const float Pt_gsf = RefGSF->ptMode();
2113  lnPt_gsf = std::log(Pt_gsf);
2114  Eta_gsf = RefGSF->etaMode();
2115  // tracking observables
2116  const double ptModeErrorGsf = RefGSF->ptModeError();
2117  dPtOverPt_gsf = (ptModeErrorGsf > 0. ? ptModeErrorGsf/Pt_gsf : 1.0);
2118  nhit_gsf = RefGSF->hitPattern().trackerLayersWithMeasurement();
2119  chi2_gsf = RefGSF->normalizedChi2();
2120  DPtOverPt_gsf = (Pt_gsf - gsfElement->Pout().pt())/Pt_gsf;
2121  // kalman filter vars
2122  nhit_kf = 0;
2123  chi2_kf = -0.01;
2124  DPtOverPt_kf = -0.01;
2125  if( RefKF.isNonnull() ) {
2126  nhit_kf = RefKF->hitPattern().trackerLayersWithMeasurement();
2127  chi2_kf = RefKF->normalizedChi2();
2128  // not used for moment, weird behavior of variable
2129  // DPtOverPt_kf = (RefKF->pt() - RefKF->outerPt())/RefKF->pt();
2130  }
2131  //tracker + calorimetry observables
2132  const double EcalETot =
2133  (FirstEcalGsfEnergy+OtherEcalGsfEnergy+EcalBremEnergy);
2134  EtotPinMode = EcalETot / Ein_gsf;
2135  EGsfPoutMode = FirstEcalGsfEnergy / Eout_gsf;
2136  EtotBremPinPoutMode = ( (EcalBremEnergy + OtherEcalGsfEnergy) /
2137  (Ein_gsf - Eout_gsf) );
2138  DEtaGsfEcalClust = std::abs(deta_gsfecal);
2139  SigmaEtaEta = std::log(sigmaEtaEta);
2141  xtra.setSigmaEtaEta(sigmaEtaEta);
2142 
2143  HOverHE = Ene_hcalgsf/(Ene_hcalgsf + FirstEcalGsfEnergy);
2144  HOverPin = Ene_hcalgsf / Ein_gsf;
2145  xtra.setHadEnergy(Ene_hcalgsf);
2146 
2147  // Apply bounds to variables and calculate MVA
2151  chi2_gsf = std::min(chi2_gsf,10.0f);
2154  chi2_kf = std::min(chi2_kf,10.0f);
2162  SigmaEtaEta = std::max(SigmaEtaEta,-14.0f);
2163  HOverPin = std::max(HOverPin,0.0f);
2164  HOverPin = std::min(HOverPin,5.0f);
2165  /*
2166  std::cout << " **** PFEG BDT observables ****" << endl;
2167  std::cout << " < Normalization > " << endl;
2168  std::cout << " Pt_gsf " << Pt_gsf << " Pin " << Ein_gsf
2169  << " Pout " << Eout_gsf << " Eta_gsf " << Eta_gsf << endl;
2170  std::cout << " < PureTracking > " << endl;
2171  std::cout << " dPtOverPt_gsf " << dPtOverPt_gsf
2172  << " DPtOverPt_gsf " << DPtOverPt_gsf
2173  << " chi2_gsf " << chi2_gsf
2174  << " nhit_gsf " << nhit_gsf
2175  << " DPtOverPt_kf " << DPtOverPt_kf
2176  << " chi2_kf " << chi2_kf
2177  << " nhit_kf " << nhit_kf << endl;
2178  std::cout << " < track-ecal-hcal-ps " << endl;
2179  std::cout << " EtotPinMode " << EtotPinMode
2180  << " EGsfPoutMode " << EGsfPoutMode
2181  << " EtotBremPinPoutMode " << EtotBremPinPoutMode
2182  << " DEtaGsfEcalClust " << DEtaGsfEcalClust
2183  << " SigmaEtaEta " << SigmaEtaEta
2184  << " HOverHE " << HOverHE << " Hcal energy " << Ene_hcalgsf
2185  << " HOverPin " << HOverPin
2186  << " lateBrem " << lateBrem
2187  << " firstBrem " << firstBrem << endl;
2188  */
2189 
2190  float vars[] = { lnPt_gsf, Eta_gsf, dPtOverPt_gsf, DPtOverPt_gsf, chi2_gsf,
2193 
2194  return hoc->gbrEle_->GetAdaBoostClassifier(vars);
2195  }
2196  }
2197  return -2.0f;
2198 }
float EtotBremPinPoutMode
Definition: PFEGammaAlgo.h:315
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
void setGsfElectronClusterRef(const reco::PFBlockRef &blk, const reco::PFBlockElementCluster &ref)
set gsf electron cluster ref
float EGsfPoutMode
Definition: PFEGammaAlgo.h:315
std::pair< const PFClusterElement *, bool > PFClusterFlaggedElement
Definition: PFEGammaAlgo.h:66
void setHadEnergy(float val)
set the had energy. The cluster energies should be entered before
reco::PFBlockElementGsfTrack PFGSFElement
Definition: PFEGammaAlgo.h:58
float DEtaGsfEcalClust
Definition: PFEGammaAlgo.h:316
#define NULL
Definition: scimark2.h:8
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
reco::PFBlockRef _currentblock
Definition: PFEGammaAlgo.h:187
#define constexpr
float DPtOverPt_gsf
Definition: PFEGammaAlgo.h:309
std::unique_ptr< const GBRForest > gbrEle_
void setSigmaEtaEta(float val)
set the sigmaetaeta
void setEarlyBrem(float val)
set EarlyBrem
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float DPtOverPt_kf
Definition: PFEGammaAlgo.h:309
void setGsfTrackPout(const math::XYZTLorentzVector &pout)
set the pout (not trivial to get from the GSF track)
float dPtOverPt_gsf
Definition: PFEGammaAlgo.h:309
double f[11][100]
T min(T a, T b)
Definition: MathUtil.h:58
Container::value_type value_type
void setDeltaEta(float val)
set the delta eta
reco::PFBlockElementTrack PFKFElement
Definition: PFEGammaAlgo.h:59
float SigmaEtaEta
Definition: PFEGammaAlgo.h:317
double b
Definition: hdecay.h:120
float EtotPinMode
Definition: PFEGammaAlgo.h:315
double a
Definition: hdecay.h:121
void setLateBrem(float val)
set LateBrem
tuple log
Definition: cmsBatch.py:341
void PFEGammaAlgo::dumpCurrentRefinableObjects ( ) const
private

Definition at line 1258 of file PFEGammaAlgo.cc.

References _refinableObjects, and info().

Referenced by buildAndRefineEGObjects().

1258  {
1259  #ifdef PFLOW_DEBUG
1260  edm::LogVerbatim("PFEGammaAlgo")
1261  //<< "Dumping current block: " << std::endl << *_currentblock << std::endl
1262  << "Dumping " << _refinableObjects.size()
1263  << " refinable objects for this block: " << std::endl;
1264  for( const auto& ro : _refinableObjects ) {
1265  std::stringstream info;
1266  info << "Refinable Object:" << std::endl;
1267  if( ro.parentSC ) {
1268  info << "\tSuperCluster element attached to object:" << std::endl
1269  << '\t';
1270  ro.parentSC->Dump(info,"\t");
1271  info << std::endl;
1272  }
1273  if( ro.electronSeed.isNonnull() ) {
1274  info << "\tGSF element attached to object:" << std::endl;
1275  ro.primaryGSFs.front().first->Dump(info,"\t");
1276  info << std::endl;
1277  info << "firstBrem : " << ro.firstBrem
1278  << " lateBrem : " << ro.lateBrem
1279  << " nBrems with cluster : " << ro.nBremsWithClusters
1280  << std::endl;;
1281  if( ro.electronClusters.size() && ro.electronClusters[0] ) {
1282  info << "electron cluster : ";
1283  ro.electronClusters[0]->Dump(info,"\t");
1284  info << std::endl;
1285  } else {
1286  info << " no electron cluster." << std::endl;
1287  }
1288  }
1289  if( ro.primaryKFs.size() ) {
1290  info << "\tPrimary KF tracks attached to object: " << std::endl;
1291  for( const auto& kf : ro.primaryKFs ) {
1292  kf.first->Dump(info,"\t");
1293  info << std::endl;
1294  }
1295  }
1296  if( ro.secondaryKFs.size() ) {
1297  info << "\tSecondary KF tracks attached to object: " << std::endl;
1298  for( const auto& kf : ro.secondaryKFs ) {
1299  kf.first->Dump(info,"\t");
1300  info << std::endl;
1301  }
1302  }
1303  if( ro.brems.size() ) {
1304  info << "\tBrem tangents attached to object: " << std::endl;
1305  for( const auto& brem : ro.brems ) {
1306  brem.first->Dump(info,"\t");
1307  info << std::endl;
1308  }
1309  }
1310  if( ro.ecalclusters.size() ) {
1311  info << "\tECAL clusters attached to object: " << std::endl;
1312  for( const auto& clus : ro.ecalclusters ) {
1313  clus.first->Dump(info,"\t");
1314  info << std::endl;
1315  if( ro.ecal2ps.find(clus.first) != ro.ecal2ps.end() ) {
1316  for( const auto& psclus : ro.ecal2ps.at(clus.first) ) {
1317  info << "\t\t Attached PS Cluster: ";
1318  psclus.first->Dump(info,"");
1319  info << std::endl;
1320  }
1321  }
1322  }
1323  }
1324  edm::LogVerbatim("PFEGammaAlgo") << info.str();
1325  }
1326  #endif
1327  }
static const TGPicture * info(bool iBackgroundIsBlack)
std::list< ProtoEGObject > _refinableObjects
Definition: PFEGammaAlgo.h:205
float PFEGammaAlgo::EvaluateSingleLegMVA ( const pfEGHelpers::HeavyObjectCache hoc,
const reco::PFBlockRef blockref,
const reco::Vertex primaryvtx,
unsigned int  track_index 
)
private

Definition at line 738 of file PFEGammaAlgo.cc.

References reco::PFBlock::associatedElements(), createPayload::block, chi2, del_phi, SiPixelRawToDigiRegional_cfi::deltaPhi, reco::PFBlockElement::ECAL, reco::PFBlock::elements(), bookConverter::elements, EoverPt, pfEGHelpers::HeavyObjectCache::gbrSingleLeg_, reco::PFBlockElement::HCAL, HoverPt, reco::PFBlock::linkData(), reco::PFBlock::LINKTEST_ALL, mvaValue, nlayers, nlost, colinearityKinematic::Phi, PV3DBase< T, PVType, FrameType >::phi(), STIP, track_pt, X, reco::Vertex::x(), reco::Vertex::y(), and reco::Vertex::z().

Referenced by fillPFCandidates(), and linkRefinableObjectECALToSingleLegConv().

741  {
742  const reco::PFBlock& block = *blockref;
744  //use this to store linkdata in the associatedElements function below
745  PFBlock::LinkData linkData = block.linkData();
746  //calculate MVA Variables
747  chi2=elements[track_index].trackRef()->chi2()/elements[track_index].trackRef()->ndof();
748  nlost=elements[track_index].trackRef()->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS);
749  nlayers=elements[track_index].trackRef()->hitPattern().trackerLayersWithMeasurement();
750  track_pt=elements[track_index].trackRef()->pt();
751  STIP=elements[track_index].trackRefPF()->STIP();
752 
753  float linked_e=0;
754  float linked_h=0;
755  std::multimap<double, unsigned int> ecalAssoTrack;
756  block.associatedElements( track_index,linkData,
757  ecalAssoTrack,
760  std::multimap<double, unsigned int> hcalAssoTrack;
761  block.associatedElements( track_index,linkData,
762  hcalAssoTrack,
765  if(ecalAssoTrack.size() > 0) {
766  for(std::multimap<double, unsigned int>::iterator itecal = ecalAssoTrack.begin();
767  itecal != ecalAssoTrack.end(); ++itecal) {
768  linked_e=linked_e+elements[itecal->second].clusterRef()->energy();
769  }
770  }
771  if(hcalAssoTrack.size() > 0) {
772  for(std::multimap<double, unsigned int>::iterator ithcal = hcalAssoTrack.begin();
773  ithcal != hcalAssoTrack.end(); ++ithcal) {
774  linked_h=linked_h+elements[ithcal->second].clusterRef()->energy();
775  }
776  }
777  EoverPt=linked_e/elements[track_index].trackRef()->pt();
778  HoverPt=linked_h/elements[track_index].trackRef()->pt();
779  GlobalVector rvtx(elements[track_index].trackRef()->innerPosition().X()-primaryvtx.x(),
780  elements[track_index].trackRef()->innerPosition().Y()-primaryvtx.y(),
781  elements[track_index].trackRef()->innerPosition().Z()-primaryvtx.z());
782  double vtx_phi=rvtx.phi();
783  //delta Phi between conversion vertex and track
784  del_phi=fabs(deltaPhi(vtx_phi, elements[track_index].trackRef()->innerMomentum().Phi()));
785 
786  float vars[] = { del_phi, nlayers, chi2, EoverPt,
787  HoverPt, track_pt, STIP, nlost };
788 
789  mvaValue = hoc->gbrSingleLeg_->GetAdaBoostClassifier(vars);
790 
791  return mvaValue;
792 }
double mvaValue
Definition: PFEGammaAlgo.h:356
double y() const
y coordinate
Definition: Vertex.h:110
std::map< unsigned int, Link > LinkData
Definition: PFBlock.h:46
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
#define X(str)
Definition: MuonsGrabber.cc:48
const edm::OwnVector< reco::PFBlockElement > & elements() const
Definition: PFBlock.h:107
const LinkData & linkData() const
Definition: PFBlock.h:112
dictionary elements
std::unique_ptr< const GBRForest > gbrSingleLeg_
double z() const
y coordinate
Definition: Vertex.h:112
double x() const
x coordinate
Definition: Vertex.h:108
void associatedElements(unsigned i, const LinkData &linkData, std::multimap< double, unsigned > &sortedAssociates, reco::PFBlockElement::Type type=PFBlockElement::NONE, LinkTest test=LINKTEST_RECHIT) const
Definition: PFBlock.cc:75
Block of elements.
Definition: PFBlock.h:30
void PFEGammaAlgo::fill_extra_info ( const ProtoEGObject RO,
reco::PFCandidateEGammaExtra xtra 
)
private

Definition at line 2200 of file PFEGammaAlgo.cc.

References _currentblock, _currentlinks, _splayedblock, reco::PFCandidateEGammaExtra::addExtraNonConvTrack(), docast, reco::PFBlockElement::ECAL, patCandidatesForDimuonsSequences_cff::ecal, PFEGammaAlgo::ProtoEGObject::ecalclusters, and reco::PFBlockElement::TRACK.

Referenced by fillPFCandidates().

2201  {
2202  // add tracks associated to clusters that are not T_FROM_GAMMACONV
2203  // info about single-leg convs is already save, so just veto in loops
2204  IsConversionTrack<reco::PFBlockElementTrack> isConvKf;
2205  auto KFbegin = _splayedblock[reco::PFBlockElement::TRACK].begin();
2206  auto KFend = _splayedblock[reco::PFBlockElement::TRACK].end();
2207  for( auto& ecal : RO.ecalclusters ) {
2208  NotCloserToOther<reco::PFBlockElement::ECAL,
2210  true>
2211  ECALToTracks(_currentblock,_currentlinks,ecal.first);
2212  auto notmatchedkf = std::partition(KFbegin,KFend,ECALToTracks);
2213  auto notconvkf = std::partition(KFbegin,notmatchedkf,isConvKf);
2214  // go through non-conv-identified kfs and check MVA to add conversions
2215  for( auto kf = notconvkf; kf != notmatchedkf; ++kf ) {
2216  const reco::PFBlockElementTrack* elemaskf =
2217  docast(const reco::PFBlockElementTrack*,kf->first);
2218  xtra.addExtraNonConvTrack(_currentblock,*elemaskf);
2219  }
2220  }
2221 }
std::vector< std::vector< PFFlaggedElement > > _splayedblock
Definition: PFEGammaAlgo.h:191
reco::PFBlockRef _currentblock
Definition: PFEGammaAlgo.h:187
reco::PFBlock::LinkData _currentlinks
Definition: PFEGammaAlgo.h:188
#define docast(x, y)
Definition: PFEGammaAlgo.cc:43
void addExtraNonConvTrack(const reco::PFBlockRef &blk, const reco::PFBlockElementTrack &tkref)
track counting for electrons and photons
void PFEGammaAlgo::fillPFCandidates ( const pfEGHelpers::HeavyObjectCache hoc,
const std::list< ProtoEGObject > &  ,
reco::PFCandidateCollection ,
reco::PFCandidateEGammaExtraCollection  
)
private

Definition at line 1900 of file PFEGammaAlgo.cc.

References _currentblock, reco::PFCandidateEGammaExtra::addConversionRef(), reco::PFCandidate::addElementInBlock(), reco::PFCandidateEGammaExtra::addSingleLegConvTrackRefMva(), buildRefinedSuperCluster(), calculate_ele_mva(), cfg_, reco::PFBlockElementTrack::convRefs(), patCandidatesForDimuonsSequences_cff::ecal, reco::CaloCluster::energy(), EvaluateSingleLegMVA(), fill_extra_info(), reco::PFBlockElementGsfTrack::GsftrackRef(), reco::PFBlockElement::index(), edm::Ref< C, T, F >::index(), p4, reco::Vertex::position(), reco::CaloCluster::position(), reco::PFBlockElementTrack::positionAtECALEntrance(), reco::PFBlockElementGsfTrack::positionAtECALEntrance(), PFEGammaAlgo::PFEGConfigInfo::primaryVtx, PFEGammaAlgo::PFEGConfigInfo::produceEGCandsWithNoSuperCluster, reco::SuperCluster::rawEnergy(), refinedscs_, reco::SuperCluster::seed(), reco::PFCandidate::set_mva_e_pi(), reco::LeafCandidate::setCharge(), reco::PFCandidate::setEcalEnergy(), reco::PFCandidateEGammaExtra::setGsfTrackRef(), reco::PFCandidate::setGsfTrackRef(), reco::PFCandidateEGammaExtra::setKfTrackRef(), reco::PFCandidateEGammaExtra::setMVA(), reco::LeafCandidate::setP4(), reco::LeafCandidate::setPdgId(), reco::PFCandidate::setPositionAtECALEntrance(), reco::PFCandidateEGammaExtra::setSuperClusterPFECALRef(), reco::PFCandidateEGammaExtra::setSuperClusterRef(), reco::PFCandidate::setSuperClusterRef(), reco::PFCandidate::setTrackRef(), and reco::PFBlockElementTrack::trackRef().

Referenced by buildAndRefineEGObjects().

1903  {
1904  // reset output collections
1905  egcands.clear();
1906  egxs.clear();
1907  refinedscs_.clear();
1908  egcands.reserve(ROs.size());
1909  egxs.reserve(ROs.size());
1910  refinedscs_.reserve(ROs.size());
1911  for( auto& RO : ROs ) {
1912  if( RO.ecalclusters.size() == 0 &&
1914 
1915  reco::PFCandidate cand;
1917  if( RO.primaryGSFs.size() || RO.primaryKFs.size() ) {
1918  cand.setPdgId(-11); // anything with a primary track is an electron
1919  } else {
1920  cand.setPdgId(22); // anything with no primary track is a photon
1921  }
1922  if( RO.primaryKFs.size() ) {
1923  cand.setCharge(RO.primaryKFs[0].first->trackRef()->charge());
1924  xtra.setKfTrackRef(RO.primaryKFs[0].first->trackRef());
1925  cand.setTrackRef(RO.primaryKFs[0].first->trackRef());
1926  cand.addElementInBlock(_currentblock,RO.primaryKFs[0].first->index());
1927  }
1928  if( RO.primaryGSFs.size() ) {
1929  cand.setCharge(RO.primaryGSFs[0].first->GsftrackRef()->chargeMode());
1930  xtra.setGsfTrackRef(RO.primaryGSFs[0].first->GsftrackRef());
1931  cand.setGsfTrackRef(RO.primaryGSFs[0].first->GsftrackRef());
1932  cand.addElementInBlock(_currentblock,RO.primaryGSFs[0].first->index());
1933  }
1934  if( RO.parentSC ) {
1935  xtra.setSuperClusterPFECALRef(RO.parentSC->superClusterRef());
1936  // we'll set to the refined supercluster back up in the producer
1937  cand.setSuperClusterRef(RO.parentSC->superClusterRef());
1938  xtra.setSuperClusterRef(RO.parentSC->superClusterRef());
1939  cand.addElementInBlock(_currentblock,RO.parentSC->index());
1940  }
1941  // add brems
1942  for( const auto& bremflagged : RO.brems ) {
1943  const PFBremElement* brem = bremflagged.first;
1944  cand.addElementInBlock(_currentblock,brem->index());
1945  }
1946  // add clusters and ps clusters
1947  for( const auto& ecal : RO.ecalclusters ) {
1948  const PFClusterElement* clus = ecal.first;
1949  cand.addElementInBlock(_currentblock,clus->index());
1950  for( auto& ps : RO.ecal2ps.at(clus) ) {
1951  const PFClusterElement* psclus = ps.first;
1952  cand.addElementInBlock(_currentblock,psclus->index());
1953  }
1954  }
1955  // add secondary tracks
1956  for( const auto& secdkf : RO.secondaryKFs ) {
1957  const PFKFElement* kf = secdkf.first;
1959  const reco::ConversionRefVector& convrefs = kf->convRefs();
1960  bool no_conv_ref = true;
1961  for( const auto& convref : convrefs ) {
1962  if( convref.isNonnull() && convref.isAvailable() ) {
1963  xtra.addConversionRef(convref);
1964  no_conv_ref = false;
1965  }
1966  }
1967  if( no_conv_ref ) {
1968  //single leg conversions
1969 
1970  //look for stored mva value in map or else recompute
1971  const auto &mvavalmapped = RO.singleLegConversionMvaMap.find(kf);
1972  //FIXME: Abuse single mva value to store both provenance and single leg mva score
1973  //by storing 3.0 + mvaval
1974  float mvaval = ( mvavalmapped != RO.singleLegConversionMvaMap.end() ?
1975  mvavalmapped->second :
1977  *cfg_.primaryVtx,
1978  kf->index()) );
1979 
1980  xtra.addSingleLegConvTrackRefMva(std::make_pair(kf->trackRef(),mvaval));
1981  }
1982  }
1983 
1984  // build the refined supercluster from those clusters left in the cand
1985  refinedscs_.push_back(buildRefinedSuperCluster(RO));
1986 
1987  const reco::SuperCluster& the_sc = refinedscs_.back();
1988  // with the refined SC in hand we build a naive candidate p4
1989  // and set the candidate ECAL position to either the barycenter of the
1990  // supercluster (if super-cluster present) or the seed of the
1991  // new SC generated by the EGAlgo
1992  const double scE = the_sc.energy();
1993  if( scE != 0.0 ) {
1994  const math::XYZPoint& seedPos = the_sc.seed()->position();
1995  math::XYZVector egDir = the_sc.position()-cfg_.primaryVtx->position();
1996  egDir = egDir.Unit();
1997  cand.setP4(math::XYZTLorentzVector(scE*egDir.x(),
1998  scE*egDir.y(),
1999  scE*egDir.z(),
2000  scE ));
2001  math::XYZPointF ecalPOS_f(seedPos.x(),seedPos.y(),seedPos.z());
2002  cand.setPositionAtECALEntrance(ecalPOS_f);
2003  cand.setEcalEnergy(the_sc.rawEnergy(),the_sc.energy());
2004  } else if ( cfg_.produceEGCandsWithNoSuperCluster &&
2005  RO.primaryGSFs.size() ) {
2006  const PFGSFElement* gsf = RO.primaryGSFs[0].first;
2007  reco::GsfTrackRef gref = gsf->GsftrackRef();
2008  math::XYZTLorentzVector p4(gref->pxMode(),gref->pyMode(),
2009  gref->pzMode(),gref->pMode());
2010  cand.setP4(p4);
2011  cand.setPositionAtECALEntrance(gsf->positionAtECALEntrance());
2012  } else if ( cfg_.produceEGCandsWithNoSuperCluster &&
2013  RO.primaryKFs.size() ) {
2014  const PFKFElement* kf = RO.primaryKFs[0].first;
2015  reco::TrackRef kref = RO.primaryKFs[0].first->trackRef();
2016  math::XYZTLorentzVector p4(kref->px(),kref->py(),kref->pz(),kref->p());
2017  cand.setP4(p4);
2018  cand.setPositionAtECALEntrance(kf->positionAtECALEntrance());
2019  }
2020  const float ele_mva_value = calculate_ele_mva(hoc,RO,xtra);
2021  fill_extra_info(RO,xtra);
2022  //std::cout << "PFEG ele_mva: " << ele_mva_value << std::endl;
2023  xtra.setMVA(ele_mva_value);
2024  cand.set_mva_e_pi(ele_mva_value);
2025  egcands.push_back(cand);
2026  egxs.push_back(xtra);
2027  }
2028 }
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:126
void setSuperClusterRef(reco::SuperClusterRef sc)
set reference to the corresponding supercluster
reco::SuperClusterCollection refinedscs_
Definition: PFEGammaAlgo.h:182
void setPositionAtECALEntrance(const math::XYZPointF &pos)
set position at ECAL entrance
Definition: PFCandidate.h:348
virtual void setCharge(Charge q)
set electric charge
Definition: LeafCandidate.h:93
float calculate_ele_mva(const pfEGHelpers::HeavyObjectCache *hoc, const ProtoEGObject &, reco::PFCandidateEGammaExtra &)
void addSingleLegConvTrackRefMva(const std::pair< reco::TrackRef, float > &trackrefmva)
add Single Leg Conversion TrackRef
reco::PFBlockElementGsfTrack PFGSFElement
Definition: PFEGammaAlgo.h:58
key_type index() const
Definition: Ref.h:267
virtual void setP4(const LorentzVector &p4)
set 4-momentum
unsigned int index
index type
Definition: Vertex.h:49
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
Definition: Point3D.h:10
const reco::Vertex * primaryVtx
Definition: PFEGammaAlgo.h:126
reco::PFBlockRef _currentblock
Definition: PFEGammaAlgo.h:187
void setGsfTrackRef(const reco::GsfTrackRef &ref)
set gsftrack reference
const Point & position() const
position
Definition: Vertex.h:106
PFEGConfigInfo cfg_
Definition: PFEGammaAlgo.h:300
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
void set_mva_e_pi(float mvaNI)
Definition: PFCandidate.h:311
void addElementInBlock(const reco::PFBlockRef &blockref, unsigned elementIndex)
add an element to the current PFCandidate
Definition: PFCandidate.cc:211
double p4[4]
Definition: TauolaWrapper.h:92
double energy() const
cluster energy
Definition: CaloCluster.h:121
reco::PFBlockElementCluster PFClusterElement
Definition: PFEGammaAlgo.h:60
reco::PFBlockElementBrem PFBremElement
Definition: PFEGammaAlgo.h:57
void setEcalEnergy(float eeRaw, float eeCorr)
set corrected Ecal energy
Definition: PFCandidate.h:217
double rawEnergy() const
raw uncorrected energy (sum of energies of component BasicClusters)
Definition: SuperCluster.h:47
float EvaluateSingleLegMVA(const pfEGHelpers::HeavyObjectCache *hoc, const reco::PFBlockRef &blockref, const reco::Vertex &primaryvtx, unsigned int track_index)
void fill_extra_info(const ProtoEGObject &, reco::PFCandidateEGammaExtra &)
void setGsfTrackRef(const reco::GsfTrackRef &ref)
set gsftrack reference
Definition: PFCandidate.cc:454
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
reco::PFBlockElementTrack PFKFElement
Definition: PFEGammaAlgo.h:59
void setSuperClusterPFECALRef(reco::SuperClusterRef sc)
set reference to the corresponding supercluster
void addConversionRef(const reco::ConversionRef &convref)
add Conversions from PF
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
reco::SuperCluster buildRefinedSuperCluster(const ProtoEGObject &)
virtual void setPdgId(int pdgId)
void setSuperClusterRef(const reco::SuperClusterRef &scRef)
Definition: PFCandidate.cc:620
void setKfTrackRef(const reco::TrackRef &ref)
set kf track reference
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:66
void setMVA(float val)
set the result (mostly for debugging)
void setTrackRef(const reco::TrackRef &ref)
set track reference
Definition: PFCandidate.cc:416
reco::PFCandidateCollection& PFEGammaAlgo::getCandidates ( )
inline

Definition at line 161 of file PFEGammaAlgo.h.

References outcands_.

161 {return outcands_;}
reco::PFCandidateCollection outcands_
Definition: PFEGammaAlgo.h:180
reco::PFCandidateEGammaExtraCollection& PFEGammaAlgo::getEGExtra ( )
inline

Definition at line 164 of file PFEGammaAlgo.h.

References outcandsextra_.

164 {return outcandsextra_;}
reco::PFCandidateEGammaExtraCollection outcandsextra_
Definition: PFEGammaAlgo.h:181
reco::SuperClusterCollection& PFEGammaAlgo::getRefinedSCs ( )
inline

Definition at line 167 of file PFEGammaAlgo.h.

References refinedscs_.

167 {return refinedscs_;}
reco::SuperClusterCollection refinedscs_
Definition: PFEGammaAlgo.h:182
void PFEGammaAlgo::initializeProtoCands ( std::list< ProtoEGObject > &  )
private

Definition at line 952 of file PFEGammaAlgo.cc.

References _currentblock, _currentlinks, _refinableObjects, _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(), 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 buildAndRefineEGObjects().

952  {
953  // step 1: build SC based proto-candidates
954  // in the future there will be an SC Et requirement made here to control
955  // block size
956  for( auto& element : _splayedblock[PFBlockElement::SC] ) {
957  LOGDRESSED("PFEGammaAlgo")
958  << "creating SC-based proto-object" << std::endl
959  << "\tSC at index: " << element.first->index()
960  << " has type: " << element.first->type() << std::endl;
961  element.second = false;
962  ProtoEGObject fromSC;
963  fromSC.nBremsWithClusters = -1;
964  fromSC.firstBrem = -1;
965  fromSC.lateBrem = -1;
966  fromSC.parentBlock = _currentblock;
967  fromSC.parentSC = docast(const PFSCElement*,element.first);
968  // splay the supercluster so we can knock out used elements
969  bool sc_success =
970  unwrapSuperCluster(fromSC.parentSC,fromSC.ecalclusters,fromSC.ecal2ps);
971  if( sc_success ) {
972  /*
973  auto ins_pos = std::lower_bound(_refinableObjects.begin(),
974  _refinableObjects.end(),
975  fromSC,
976  [&](const ProtoEGObject& a,
977  const ProtoEGObject& b){
978  const double a_en =
979  a.parentSC->superClusterRef()->energy();
980  const double b_en =
981  b.parentSC->superClusterRef()->energy();
982  return a_en < b_en;
983  });
984  */
985  _refinableObjects.insert(_refinableObjects.end(),fromSC);
986  }
987  }
988  // step 2: build GSF-seed-based proto-candidates
989  reco::GsfTrackRef gsfref_forextra;
990  reco::TrackExtraRef gsftrk_extra;
991  reco::ElectronSeedRef theseedref;
992  std::list<ProtoEGObject>::iterator objsbegin, objsend;
993  for( auto& element : _splayedblock[PFBlockElement::GSF] ) {
994  LOGDRESSED("PFEGammaAlgo")
995  << "creating GSF-based proto-object" << std::endl
996  << "\tGSF at index: " << element.first->index()
997  << " has type: " << element.first->type() << std::endl;
998  const PFGSFElement* elementAsGSF =
999  docast(const PFGSFElement*,element.first);
1000  if( elementAsGSF->trackType(reco::PFBlockElement::T_FROM_GAMMACONV) ) {
1001  continue; // for now, do not allow dedicated brems to make proto-objects
1002  }
1003  element.second = false;
1004 
1005  ProtoEGObject fromGSF;
1006  fromGSF.nBremsWithClusters = -1;
1007  fromGSF.firstBrem = -1;
1008  fromGSF.lateBrem = 0;
1009  gsfref_forextra = elementAsGSF->GsftrackRef();
1010  gsftrk_extra = ( gsfref_forextra.isAvailable() ?
1011  gsfref_forextra->extra() : reco::TrackExtraRef() );
1012  theseedref = ( gsftrk_extra.isAvailable() ?
1013  gsftrk_extra->seedRef().castTo<reco::ElectronSeedRef>() :
1014  reco::ElectronSeedRef() );
1015  fromGSF.electronSeed = theseedref;
1016  // exception if there's no seed
1017  if(fromGSF.electronSeed.isNull() || !fromGSF.electronSeed.isAvailable()) {
1018  std::stringstream gsf_err;
1019  elementAsGSF->Dump(gsf_err,"\t");
1020  throw cms::Exception("PFEGammaAlgo::initializeProtoCands()")
1021  << "Found a GSF track with no seed! This should not happen!"
1022  << std::endl << gsf_err.str() << std::endl;
1023  }
1024  // flag this GSF element as globally used and push back the track ref
1025  // into the protocand
1026  element.second = false;
1027  fromGSF.parentBlock = _currentblock;
1028  fromGSF.primaryGSFs.push_back(std::make_pair(elementAsGSF,true));
1029  // add the directly matched brem tangents
1030  for( auto& brem : _splayedblock[PFBlockElement::BREM] ) {
1031  float dist = _currentblock->dist(elementAsGSF->index(),
1032  brem.first->index(),
1033  _currentlinks,
1035  if( dist == 0.001f ) {
1036  const PFBremElement* eAsBrem =
1037  docast(const PFBremElement*,brem.first);
1038  fromGSF.brems.push_back(std::make_pair(eAsBrem,true));
1039  fromGSF.localMap.push_back( ElementMap::value_type(eAsBrem,elementAsGSF) );
1040  fromGSF.localMap.push_back( ElementMap::value_type(elementAsGSF,eAsBrem) );
1041  brem.second = false;
1042  }
1043  }
1044  // if this track is ECAL seeded reset links or import cluster
1045  // tracker (this is pixel only, right?) driven seeds just get the GSF
1046  // track associated since this only branches for ECAL Driven seeds
1047  if( fromGSF.electronSeed->isEcalDriven() ) {
1048  // step 2a: either merge with existing ProtoEG object with SC or add
1049  // SC directly to this proto EG object if not present
1050  LOGDRESSED("PFEGammaAlgo")
1051  << "GSF-based proto-object is ECAL driven, merging SC-cand"
1052  << std::endl;
1053  LOGVERB("PFEGammaAlgo")
1054  << "ECAL Seed Ptr: " << fromGSF.electronSeed.get()
1055  << " isAvailable: " << fromGSF.electronSeed.isAvailable()
1056  << " isNonnull: " << fromGSF.electronSeed.isNonnull()
1057  << std::endl;
1058  SeedMatchesToProtoObject sctoseedmatch(fromGSF.electronSeed);
1059  objsbegin = _refinableObjects.begin();
1060  objsend = _refinableObjects.end();
1061  // this auto is a std::list<ProtoEGObject>::iterator
1062  auto clusmatch = std::find_if(objsbegin,objsend,sctoseedmatch);
1063  if( clusmatch != objsend ) {
1064  fromGSF.parentSC = clusmatch->parentSC;
1065  fromGSF.ecalclusters = std::move(clusmatch->ecalclusters);
1066  fromGSF.ecal2ps = std::move(clusmatch->ecal2ps);
1067  _refinableObjects.erase(clusmatch);
1068  } else if (fromGSF.electronSeed.isAvailable() &&
1069  fromGSF.electronSeed.isNonnull()) {
1070  // link tests in the gap region can current split a gap electron
1071  // HEY THIS IS A WORK AROUND FOR A KNOWN BUG IN PFBLOCKALGO
1072  // MAYBE WE SHOULD FIX IT??????????????????????????????????
1073  LOGDRESSED("PFEGammaAlgo")
1074  << "Encountered the known GSF-SC splitting bug "
1075  << " in PFBlockAlgo! We should really fix this!" << std::endl;
1076  } else { // SC was not in a earlier proto-object
1077  std::stringstream gsf_err;
1078  elementAsGSF->Dump(gsf_err,"\t");
1079  throw cms::Exception("PFEGammaAlgo::initializeProtoCands()")
1080  << "Expected SuperCluster from ECAL driven GSF seed "
1081  << "was not found in the block!" << std::endl
1082  << gsf_err.str() << std::endl;
1083  } // supercluster in block
1084  } // is ECAL driven seed?
1085  /*
1086  auto ins_pos = std::lower_bound(_refinableObjects.begin(),
1087  _refinableObjects.end(),
1088  fromGSF,
1089  [&](const ProtoEGObject& a,
1090  const ProtoEGObject& b){
1091  const double a_en = ( a.parentSC ?
1092  a.parentSC->superClusterRef()->energy() :
1093  a.primaryGSFs[0].first->GsftrackRef()->pt() );
1094  const double b_en = ( b.parentSC ?
1095  b.parentSC->superClusterRef()->energy() :
1096  b.primaryGSFs[0].first->GsftrackRef()->pt() );
1097  return a_en < b_en;
1098  });
1099  */
1100  _refinableObjects.insert(_refinableObjects.end(),fromGSF);
1101  } // end loop on GSF elements of block
1102 }
bool isAvailable() const
Definition: Ref.h:576
reco::PFBlockElementSuperCluster PFSCElement
Definition: PFEGammaAlgo.h:56
reco::PFBlockElementGsfTrack PFGSFElement
Definition: PFEGammaAlgo.h:58
edm::Ref< TrackExtraCollection > TrackExtraRef
persistent reference to a TrackExtra
Definition: TrackExtraFwd.h:17
std::vector< std::vector< PFFlaggedElement > > _splayedblock
Definition: PFEGammaAlgo.h:191
reco::PFBlockRef _currentblock
Definition: PFEGammaAlgo.h:187
#define LOGVERB(x)
Definition: PFEGammaAlgo.cc:44
#define LOGDRESSED(x)
Definition: PFEGammaAlgo.cc:47
bool unwrapSuperCluster(const reco::PFBlockElementSuperCluster *, std::vector< PFClusterFlaggedElement > &, ClusterMap &)
def move
Definition: eostools.py:510
double f[11][100]
std::list< ProtoEGObject > _refinableObjects
Definition: PFEGammaAlgo.h:205
reco::PFBlockElementBrem PFBremElement
Definition: PFEGammaAlgo.h:57
Container::value_type value_type
reco::PFBlock::LinkData _currentlinks
Definition: PFEGammaAlgo.h:188
#define docast(x, y)
Definition: PFEGammaAlgo.cc:43
bool PFEGammaAlgo::isAMuon ( const reco::PFBlockElement pfbe)
private

Definition at line 794 of file PFEGammaAlgo.cc.

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 buildAndRefineEGObjects().

794  {
795  switch( pfbe.type() ) {
797  {
798  auto& elements = _currentblock->elements();
799  std::multimap<double,unsigned> tks;
800  _currentblock->associatedElements(pfbe.index(),
802  tks,
805  for( const auto& tk : tks ) {
806  if( PFMuonAlgo::isMuon(elements[tk.second]) ) {
807  return true;
808  }
809  }
810  }
811  break;
812  case reco::PFBlockElement::TRACK:
813  return PFMuonAlgo::isMuon(pfbe);
814  break;
815  default:
816  break;
817  }
818  return false;
819 }
static bool isMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:155
Type type() const
reco::PFBlockRef _currentblock
Definition: PFEGammaAlgo.h:187
dictionary elements
unsigned index() const
reco::PFBlock::LinkData _currentlinks
Definition: PFEGammaAlgo.h:188
bool PFEGammaAlgo::isEGValidCandidate ( const pfEGHelpers::HeavyObjectCache hoc,
const reco::PFBlockRef blockRef,
std::vector< bool > &  active 
)
inline

Definition at line 153 of file PFEGammaAlgo.h.

References egCandidate_, and RunPFEG().

155  {
156  RunPFEG(hoc,blockRef,active);
157  return (egCandidate_.size()>0);
158  };
reco::PFCandidateCollection egCandidate_
Definition: PFEGammaAlgo.h:386
void RunPFEG(const pfEGHelpers::HeavyObjectCache *hoc, const reco::PFBlockRef &blockRef, std::vector< bool > &active)
bool PFEGammaAlgo::isPrimaryTrack ( const reco::PFBlockElementTrack KfEl,
const reco::PFBlockElementGsfTrack GsfEl 
)
private

Definition at line 2550 of file PFEGammaAlgo.cc.

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

Referenced by linkRefinableObjectGSFTracksToKFs().

2551  {
2552  bool isPrimary = false;
2553 
2554  GsfPFRecTrackRef gsfPfRef = GsfEl.GsftrackRefPF();
2555 
2556  if(gsfPfRef.isNonnull()) {
2557  PFRecTrackRef kfPfRef = KfEl.trackRefPF();
2558  PFRecTrackRef kfPfRef_fromGsf = (*gsfPfRef).kfPFRecTrackRef();
2559  if(kfPfRef.isNonnull() && kfPfRef_fromGsf.isNonnull()) {
2560  reco::TrackRef kfref= (*kfPfRef).trackRef();
2561  reco::TrackRef kfref_fromGsf = (*kfPfRef_fromGsf).trackRef();
2562  if(kfref.isNonnull() && kfref_fromGsf.isNonnull()) {
2563  if(kfref == kfref_fromGsf)
2564  isPrimary = true;
2565  }
2566  }
2567  }
2568 
2569  return isPrimary;
2570 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
const GsfPFRecTrackRef & GsftrackRefPF() const
const PFRecTrackRef & trackRefPF() const
void PFEGammaAlgo::linkKFTrackToECAL ( const PFKFFlaggedElement ,
ProtoEGObject  
)
private

Definition at line 1677 of file PFEGammaAlgo.cc.

References _currentblock, _currentlinks, _splayedblock, attachPSClusters(), docast, reco::PFBlockElement::ECAL, PFEGammaAlgo::ProtoEGObject::ecal2ps, PFEGammaAlgo::ProtoEGObject::ecalclusters, PFEGammaAlgo::ProtoEGObject::localMap, and LOGDRESSED.

Referenced by linkRefinableObjectKFTracksToECAL().

1678  {
1679  std::vector<PFClusterFlaggedElement>& currentECAL = RO.ecalclusters;
1680  auto ECALbegin = _splayedblock[reco::PFBlockElement::ECAL].begin();
1681  auto ECALend = _splayedblock[reco::PFBlockElement::ECAL].end();
1682  NotCloserToOther<reco::PFBlockElement::TRACK,reco::PFBlockElement::ECAL>
1683  kfTrackToECALs(_currentblock,_currentlinks,kfflagged.first);
1684  NotCloserToOther<reco::PFBlockElement::GSF,reco::PFBlockElement::ECAL>
1685  kfTrackGSFToECALs(_currentblock,_currentlinks,kfflagged.first);
1686  //get the ECAL elements not used and not closer to another KF
1687  auto notmatched_sc = std::partition(currentECAL.begin(),
1688  currentECAL.end(),
1689  kfTrackToECALs);
1690  //get subset ECAL elements not used or closer to another GSF of any type
1691  notmatched_sc = std::partition(currentECAL.begin(),
1692  notmatched_sc,
1693  kfTrackGSFToECALs);
1694  for( auto ecalitr = currentECAL.begin(); ecalitr != notmatched_sc;
1695  ++ecalitr ) {
1696  const PFClusterElement* elemascluster =
1697  docast(const PFClusterElement*,ecalitr->first);
1698  PFClusterFlaggedElement flaggedclus(elemascluster,true);
1699 
1700  LOGDRESSED("PFEGammaAlgo::linkKFTracktoECAL()")
1701  << "Found a cluster already in RO by KF extrapolation"
1702  << " at ECAL surface!" << std::endl
1703  << *elemascluster << std::endl;
1704  RO.localMap.push_back(ElementMap::value_type(elemascluster,
1705  kfflagged.first));
1706  RO.localMap.push_back(ElementMap::value_type(kfflagged.first,
1707  elemascluster));
1708  }
1709  //get the ECAL elements not used and not closer to another KF
1710  auto notmatched_blk = std::partition(ECALbegin,ECALend,kfTrackToECALs);
1711  //get subset ECAL elements not used or closer to another GSF of any type
1712  notmatched_blk = std::partition(ECALbegin,notmatched_blk,kfTrackGSFToECALs);
1713  for( auto ecalitr = ECALbegin; ecalitr != notmatched_blk; ++ecalitr ) {
1714  const PFClusterElement* elemascluster =
1715  docast(const PFClusterElement*,ecalitr->first);
1716  if( addPFClusterToROSafe(elemascluster,RO) ) {
1717  attachPSClusters(elemascluster,RO.ecal2ps[elemascluster]);
1718  ecalitr->second = false;
1719 
1720  LOGDRESSED("PFEGammaAlgo::linkKFTracktoECAL()")
1721  << "Found a cluster not in RO by KF extrapolation"
1722  << " at ECAL surface!" << std::endl
1723  << *elemascluster << std::endl;
1724  RO.localMap.push_back(ElementMap::value_type(elemascluster,
1725  kfflagged.first));
1726  RO.localMap.push_back( ElementMap::value_type(kfflagged.first,
1727  elemascluster));
1728  }
1729  }
1730 }
std::pair< const PFClusterElement *, bool > PFClusterFlaggedElement
Definition: PFEGammaAlgo.h:66
std::vector< std::vector< PFFlaggedElement > > _splayedblock
Definition: PFEGammaAlgo.h:191
reco::PFBlockRef _currentblock
Definition: PFEGammaAlgo.h:187
#define LOGDRESSED(x)
Definition: PFEGammaAlgo.cc:47
reco::PFBlockElementCluster PFClusterElement
Definition: PFEGammaAlgo.h:60
Container::value_type value_type
reco::PFBlock::LinkData _currentlinks
Definition: PFEGammaAlgo.h:188
#define docast(x, y)
Definition: PFEGammaAlgo.cc:43
int attachPSClusters(const PFClusterElement *, ClusterMap::mapped_type &)
void PFEGammaAlgo::linkRefinableObjectBremTangentsToECAL ( ProtoEGObject RO)
private

Definition at line 1733 of file PFEGammaAlgo.cc.

References _currentblock, _currentlinks, _splayedblock, funct::abs(), attachPSClusters(), PFEGammaAlgo::ProtoEGObject::brems, docast, reco::PFBlockElement::ECAL, patCandidatesForDimuonsSequences_cff::ecal, PFEGammaAlgo::ProtoEGObject::ecal2ps, PFEGammaAlgo::ProtoEGObject::ecalclusters, PFEGammaAlgo::ProtoEGObject::firstBrem, PFEGammaAlgo::ProtoEGObject::localMap, LOGDRESSED, and PFEGammaAlgo::ProtoEGObject::nBremsWithClusters.

Referenced by buildAndRefineEGObjects().

1733  {
1734  if( !RO.brems.size() ) return;
1735  int FirstBrem = -1;
1736  int TrajPos = -1;
1737  int lastBremTrajPos = -1;
1738  for( auto& bremflagged : RO.brems ) {
1739  bool has_clusters = false;
1740  TrajPos = (bremflagged.first->indTrajPoint())-2;
1741  auto ECALbegin = _splayedblock[reco::PFBlockElement::ECAL].begin();
1742  auto ECALend = _splayedblock[reco::PFBlockElement::ECAL].end();
1743  NotCloserToOther<reco::PFBlockElement::BREM,reco::PFBlockElement::ECAL>
1744  BremToECALs(_currentblock,_currentlinks,bremflagged.first);
1745  // check for late brem using clusters already in the SC
1746  auto RSCBegin = RO.ecalclusters.begin();
1747  auto RSCEnd = RO.ecalclusters.end();
1748  auto notmatched_rsc = std::partition(RSCBegin,RSCEnd,BremToECALs);
1749  for( auto ecal = RSCBegin; ecal != notmatched_rsc; ++ecal ) {
1750  float deta =
1751  std::abs( ecal->first->clusterRef()->positionREP().eta() -
1752  bremflagged.first->positionAtECALEntrance().eta() );
1753  if( deta < 0.015 ) {
1754  has_clusters = true;
1755  if( lastBremTrajPos == -1 || lastBremTrajPos < TrajPos ) {
1756  lastBremTrajPos = TrajPos;
1757  }
1758  if( FirstBrem == -1 || TrajPos < FirstBrem ) { // set brem information
1759  FirstBrem = TrajPos;
1760  RO.firstBrem = TrajPos;
1761  }
1762  LOGDRESSED("PFEGammaAlgo::linkBremToECAL()")
1763  << "Found a cluster already in SC linked to brem extrapolation"
1764  << " at ECAL surface!" << std::endl;
1765  RO.localMap.push_back( ElementMap::value_type(ecal->first,bremflagged.first) );
1766  RO.localMap.push_back( ElementMap::value_type(bremflagged.first,ecal->first) );
1767  }
1768  }
1769  // grab new clusters from the block (ensured to not be late brem)
1770  auto notmatched_block = std::partition(ECALbegin,ECALend,BremToECALs);
1771  for( auto ecal = ECALbegin; ecal != notmatched_block; ++ecal ) {
1772  float deta =
1773  std::abs( ecal->first->clusterRef()->positionREP().eta() -
1774  bremflagged.first->positionAtECALEntrance().eta() );
1775  if( deta < 0.015 ) {
1776  has_clusters = true;
1777  if( lastBremTrajPos == -1 || lastBremTrajPos < TrajPos ) {
1778  lastBremTrajPos = TrajPos;
1779  }
1780  if( FirstBrem == -1 || TrajPos < FirstBrem ) { // set brem information
1781 
1782  FirstBrem = TrajPos;
1783  RO.firstBrem = TrajPos;
1784  }
1785  const PFClusterElement* elemasclus =
1786  docast(const PFClusterElement*,ecal->first);
1787  if( addPFClusterToROSafe(elemasclus,RO) ) {
1788  attachPSClusters(elemasclus,RO.ecal2ps[elemasclus]);
1789 
1790  RO.localMap.push_back( ElementMap::value_type(ecal->first,bremflagged.first) );
1791  RO.localMap.push_back( ElementMap::value_type(bremflagged.first,ecal->first) );
1792  ecal->second = false;
1793  LOGDRESSED("PFEGammaAlgo::linkBremToECAL()")
1794  << "Found a cluster not already associated by brem extrapolation"
1795  << " at ECAL surface!" << std::endl;
1796  }
1797 
1798  }
1799  }
1800  if(has_clusters) {
1801  if( RO.nBremsWithClusters == -1 ) RO.nBremsWithClusters = 0;
1802  ++RO.nBremsWithClusters;
1803  }
1804  }
1805 }
std::vector< std::vector< PFFlaggedElement > > _splayedblock
Definition: PFEGammaAlgo.h:191
reco::PFBlockRef _currentblock
Definition: PFEGammaAlgo.h:187
#define LOGDRESSED(x)
Definition: PFEGammaAlgo.cc:47
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
reco::PFBlockElementCluster PFClusterElement
Definition: PFEGammaAlgo.h:60
Container::value_type value_type
reco::PFBlock::LinkData _currentlinks
Definition: PFEGammaAlgo.h:188
#define docast(x, y)
Definition: PFEGammaAlgo.cc:43
int attachPSClusters(const PFClusterElement *, ClusterMap::mapped_type &)
void PFEGammaAlgo::linkRefinableObjectConvSecondaryKFsToSecondaryKFs ( ProtoEGObject RO)
private

Definition at line 1808 of file PFEGammaAlgo.cc.

References _currentblock, _currentlinks, _splayedblock, HLT_25ns14e33_v1_cff::distance, docast, plotBeamSpotDB::first, customizeTrackingMonitorSeedNumber::idx, PFEGammaAlgo::ProtoEGObject::localMap, PFEGammaAlgo::ProtoEGObject::secondaryKFs, and reco::PFBlockElement::TRACK.

Referenced by buildAndRefineEGObjects().

1808  {
1809  IsConversionTrack<reco::PFBlockElementTrack> isConvKf;
1810  auto KFbegin = _splayedblock[reco::PFBlockElement::TRACK].begin();
1811  auto KFend = _splayedblock[reco::PFBlockElement::TRACK].end();
1812  auto BeginROskfs = RO.secondaryKFs.begin();
1813  auto EndROskfs = RO.secondaryKFs.end();
1814  auto ronotconv = std::partition(BeginROskfs,EndROskfs,isConvKf);
1815  size_t convkfs_end = std::distance(BeginROskfs,ronotconv);
1816  for( size_t idx = 0; idx < convkfs_end; ++idx ) {
1817  const std::vector<PFKFFlaggedElement>& secKFs = 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
1818  NotCloserToOther<reco::PFBlockElement::TRACK,
1820  true>
1821  TracksToTracks(_currentblock,_currentlinks, secKFs[idx].first);
1822  auto notmatched = std::partition(KFbegin,KFend,TracksToTracks);
1823  notmatched = std::partition(KFbegin,notmatched,isConvKf);
1824  for( auto kf = KFbegin; kf != notmatched; ++kf ) {
1825  const reco::PFBlockElementTrack* elemaskf =
1826  docast(const reco::PFBlockElementTrack*,kf->first);
1827  RO.secondaryKFs.push_back( std::make_pair(elemaskf,true) );
1828  RO.localMap.push_back( ElementMap::value_type(secKFs[idx].first,kf->first) );
1829  RO.localMap.push_back( ElementMap::value_type(kf->first,secKFs[idx].first) );
1830  kf->second = false;
1831  }
1832  }
1833 }
std::vector< std::vector< PFFlaggedElement > > _splayedblock
Definition: PFEGammaAlgo.h:191
reco::PFBlockRef _currentblock
Definition: PFEGammaAlgo.h:187
Container::value_type value_type
reco::PFBlock::LinkData _currentlinks
Definition: PFEGammaAlgo.h:188
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
#define docast(x, y)
Definition: PFEGammaAlgo.cc:43
void PFEGammaAlgo::linkRefinableObjectECALToSingleLegConv ( const pfEGHelpers::HeavyObjectCache hoc,
ProtoEGObject RO 
)
private

Definition at line 1836 of file PFEGammaAlgo.cc.

References _currentblock, _currentlinks, _splayedblock, cfg_, docast, reco::PFBlockElement::ECAL, patCandidatesForDimuonsSequences_cff::ecal, PFEGammaAlgo::ProtoEGObject::ecalclusters, EvaluateSingleLegMVA(), PFEGammaAlgo::ProtoEGObject::localMap, PFEGammaAlgo::PFEGConfigInfo::mvaConvCut, PFEGammaAlgo::PFEGConfigInfo::primaryVtx, PFEGammaAlgo::ProtoEGObject::secondaryKFs, PFEGammaAlgo::ProtoEGObject::singleLegConversionMvaMap, and reco::PFBlockElement::TRACK.

Referenced by buildAndRefineEGObjects().

1837  {
1838  IsConversionTrack<reco::PFBlockElementTrack> isConvKf;
1839  auto KFbegin = _splayedblock[reco::PFBlockElement::TRACK].begin();
1840  auto KFend = _splayedblock[reco::PFBlockElement::TRACK].end();
1841  for( auto& ecal : RO.ecalclusters ) {
1842  NotCloserToOther<reco::PFBlockElement::ECAL,
1844  true>
1845  ECALToTracks(_currentblock,_currentlinks,ecal.first);
1846  auto notmatchedkf = std::partition(KFbegin,KFend,ECALToTracks);
1847  auto notconvkf = std::partition(KFbegin,notmatchedkf,isConvKf);
1848  // add identified KF conversion tracks
1849  for( auto kf = KFbegin; kf != notconvkf; ++kf ) {
1850  const reco::PFBlockElementTrack* elemaskf =
1851  docast(const reco::PFBlockElementTrack*,kf->first);
1852  RO.secondaryKFs.push_back( std::make_pair(elemaskf,true) );
1853  RO.localMap.push_back( ElementMap::value_type(ecal.first,elemaskf) );
1854  RO.localMap.push_back( ElementMap::value_type(elemaskf,ecal.first) );
1855  kf->second = false;
1856  }
1857  // go through non-conv-identified kfs and check MVA to add conversions
1858  for( auto kf = notconvkf; kf != notmatchedkf; ++kf ) {
1859  float mvaval = EvaluateSingleLegMVA(hoc,_currentblock,
1860  *cfg_.primaryVtx,
1861  kf->first->index());
1862  if(mvaval > cfg_.mvaConvCut) {
1863  const reco::PFBlockElementTrack* elemaskf =
1864  docast(const reco::PFBlockElementTrack*,kf->first);
1865  RO.secondaryKFs.push_back( std::make_pair(elemaskf,true) );
1866  RO.localMap.push_back( ElementMap::value_type(ecal.first,elemaskf) );
1867  RO.localMap.push_back( ElementMap::value_type(elemaskf,ecal.first) );
1868  kf->second = false;
1869 
1870  RO.singleLegConversionMvaMap.insert(std::make_pair(elemaskf, mvaval));
1871  }
1872  }
1873  }
1874 }
unsigned int index
index type
Definition: Vertex.h:49
std::vector< std::vector< PFFlaggedElement > > _splayedblock
Definition: PFEGammaAlgo.h:191
const reco::Vertex * primaryVtx
Definition: PFEGammaAlgo.h:126
reco::PFBlockRef _currentblock
Definition: PFEGammaAlgo.h:187
PFEGConfigInfo cfg_
Definition: PFEGammaAlgo.h:300
Container::value_type value_type
reco::PFBlock::LinkData _currentlinks
Definition: PFEGammaAlgo.h:188
float EvaluateSingleLegMVA(const pfEGHelpers::HeavyObjectCache *hoc, const reco::PFBlockRef &blockref, const reco::Vertex &primaryvtx, unsigned int track_index)
#define docast(x, y)
Definition: PFEGammaAlgo.cc:43
void PFEGammaAlgo::linkRefinableObjectGSFTracksToKFs ( ProtoEGObject RO)
private

Definition at line 1517 of file PFEGammaAlgo.cc.

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

Referenced by buildAndRefineEGObjects().

1517  {
1521  auto KFbegin = _splayedblock[reco::PFBlockElement::TRACK].begin();
1522  auto KFend = _splayedblock[reco::PFBlockElement::TRACK].end();
1523  for( auto& gsfflagged : RO.primaryGSFs ) {
1524  const PFGSFElement* seedtk = gsfflagged.first;
1525  // don't process SC-only ROs or secondary seeded ROs
1526  if( RO.electronSeed.isNull() || seedtk->trackType(convType) ) continue;
1527  NotCloserToOther<reco::PFBlockElement::GSF,reco::PFBlockElement::TRACK>
1528  gsfTrackToKFs(_currentblock,_currentlinks,seedtk);
1529  // get KF tracks not closer to another and not already used
1530  auto notlinked = std::partition(KFbegin,KFend,gsfTrackToKFs);
1531  // attach tracks and set as used
1532  for( auto kft = KFbegin; kft != notlinked; ++kft ) {
1533  const PFKFElement* elemaskf =
1534  docast(const PFKFElement*,kft->first);
1535  // don't care about things that aren't primaries or directly
1536  // associated secondary tracks
1537  if( isPrimaryTrack(*elemaskf,*seedtk) &&
1538  !elemaskf->trackType(convType) ) {
1539  kft->second = false;
1540  RO.primaryKFs.push_back(std::make_pair(elemaskf,true));
1541  RO.localMap.push_back( ElementMap::value_type(seedtk,elemaskf) );
1542  RO.localMap.push_back( ElementMap::value_type(elemaskf,seedtk) );
1543  } else if ( elemaskf->trackType(convType) ) {
1544  kft->second = false;
1545  RO.secondaryKFs.push_back(std::make_pair(elemaskf,true));
1546  RO.localMap.push_back( ElementMap::value_type(seedtk,elemaskf) );
1547  RO.localMap.push_back( ElementMap::value_type(elemaskf,seedtk) );
1548  }
1549  }// loop on closest KFs not closer to other GSFs
1550  } // loop on GSF primaries on RO
1551 }
reco::PFBlockElementGsfTrack PFGSFElement
Definition: PFEGammaAlgo.h:58
bool isPrimaryTrack(const reco::PFBlockElementTrack &KfEl, const reco::PFBlockElementGsfTrack &GsfEl)
std::vector< std::vector< PFFlaggedElement > > _splayedblock
Definition: PFEGammaAlgo.h:191
reco::PFBlockRef _currentblock
Definition: PFEGammaAlgo.h:187
#define constexpr
Container::value_type value_type
reco::PFBlock::LinkData _currentlinks
Definition: PFEGammaAlgo.h:188
reco::PFBlockElementTrack PFKFElement
Definition: PFEGammaAlgo.h:59
#define docast(x, y)
Definition: PFEGammaAlgo.cc:43
tuple size
Write out results.
void PFEGammaAlgo::linkRefinableObjectKFTracksToECAL ( ProtoEGObject RO)
private

Definition at line 1670 of file PFEGammaAlgo.cc.

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

Referenced by buildAndRefineEGObjects().

1670  {
1671  if( !_splayedblock[reco::PFBlockElement::ECAL].size() ) return;
1672  for( auto& primkf : RO.primaryKFs ) linkKFTrackToECAL(primkf,RO);
1673  for( auto& secdkf : RO.secondaryKFs ) linkKFTrackToECAL(secdkf,RO);
1674 }
std::vector< std::vector< PFFlaggedElement > > _splayedblock
Definition: PFEGammaAlgo.h:191
void linkKFTrackToECAL(const PFKFFlaggedElement &, ProtoEGObject &)
tuple size
Write out results.
void PFEGammaAlgo::linkRefinableObjectPrimaryGSFTrackToECAL ( ProtoEGObject RO)
private

Definition at line 1590 of file PFEGammaAlgo.cc.

References _currentblock, _currentlinks, _splayedblock, attachPSClusters(), docast, reco::PFBlockElement::ECAL, patCandidatesForDimuonsSequences_cff::ecal, PFEGammaAlgo::ProtoEGObject::ecal2ps, PFEGammaAlgo::ProtoEGObject::ecalclusters, PFEGammaAlgo::ProtoEGObject::electronClusters, PFEGammaAlgo::ProtoEGObject::localMap, LOGDRESSED, NULL, PFEGammaAlgo::ProtoEGObject::primaryGSFs, findQualityFiles::size, and groupFilesInBlocks::temp.

Referenced by buildAndRefineEGObjects().

1590  {
1592  RO.electronClusters.push_back(NULL);
1593  return;
1594  }
1595  auto ECALbegin = _splayedblock[reco::PFBlockElement::ECAL].begin();
1596  auto ECALend = _splayedblock[reco::PFBlockElement::ECAL].end();
1597  for( auto& primgsf : RO.primaryGSFs ) {
1598  NotCloserToOther<reco::PFBlockElement::GSF,reco::PFBlockElement::ECAL>
1599  gsfTracksToECALs(_currentblock,_currentlinks,primgsf.first);
1600  CompatibleEoPOut eoverp_test(primgsf.first);
1601  // get set of matching ecals not already in SC
1602  auto notmatched_blk = std::partition(ECALbegin,ECALend,gsfTracksToECALs);
1603  notmatched_blk = std::partition(ECALbegin,notmatched_blk,eoverp_test);
1604  // get set of matching ecals already in the RO
1605  auto notmatched_sc = std::partition(RO.ecalclusters.begin(),
1606  RO.ecalclusters.end(),
1607  gsfTracksToECALs);
1608  notmatched_sc = std::partition(RO.ecalclusters.begin(),
1609  notmatched_sc,
1610  eoverp_test);
1611  // look inside the SC for the ECAL cluster
1612  for( auto ecal = RO.ecalclusters.begin(); ecal != notmatched_sc; ++ecal ) {
1613  const PFClusterElement* elemascluster =
1614  docast(const PFClusterElement*,ecal->first);
1615  PFClusterFlaggedElement temp(elemascluster,true);
1616  LOGDRESSED("PFEGammaAlgo::linkGSFTracktoECAL()")
1617  << "Found a cluster already in RO by GSF extrapolation"
1618  << " at ECAL surface!" << std::endl
1619  << *elemascluster << std::endl;
1620 
1621  RO.localMap.push_back(ElementMap::value_type(primgsf.first,temp.first));
1622  RO.localMap.push_back(ElementMap::value_type(temp.first,primgsf.first));
1623  }
1624  // look outside the SC for the ecal cluster
1625  for( auto ecal = ECALbegin; ecal != notmatched_blk; ++ecal ) {
1626  const PFClusterElement* elemascluster =
1627  docast(const PFClusterElement*,ecal->first);
1628  LOGDRESSED("PFEGammaAlgo::linkGSFTracktoECAL()")
1629  << "Found a cluster not already in RO by GSF extrapolation"
1630  << " at ECAL surface!" << std::endl
1631  << *elemascluster << std::endl;
1632  if( addPFClusterToROSafe(elemascluster,RO) ) {
1633  attachPSClusters(elemascluster,RO.ecal2ps[elemascluster]);
1634  RO.localMap.push_back(ElementMap::value_type(primgsf.first,elemascluster));
1635  RO.localMap.push_back(ElementMap::value_type(elemascluster,primgsf.first));
1636  ecal->second = false;
1637  }
1638  }
1639  }
1640 }
std::pair< const PFClusterElement *, bool > PFClusterFlaggedElement
Definition: PFEGammaAlgo.h:66
#define NULL
Definition: scimark2.h:8
std::vector< std::vector< PFFlaggedElement > > _splayedblock
Definition: PFEGammaAlgo.h:191
reco::PFBlockRef _currentblock
Definition: PFEGammaAlgo.h:187
#define LOGDRESSED(x)
Definition: PFEGammaAlgo.cc:47
reco::PFBlockElementCluster PFClusterElement
Definition: PFEGammaAlgo.h:60
Container::value_type value_type
reco::PFBlock::LinkData _currentlinks
Definition: PFEGammaAlgo.h:188
#define docast(x, y)
Definition: PFEGammaAlgo.cc:43
int attachPSClusters(const PFClusterElement *, ClusterMap::mapped_type &)
tuple size
Write out results.
void PFEGammaAlgo::linkRefinableObjectPrimaryGSFTrackToHCAL ( ProtoEGObject RO)
private

Definition at line 1644 of file PFEGammaAlgo.cc.

References _currentblock, _currentlinks, _splayedblock, docast, reco::PFBlockElement::HCAL, patCandidatesForDimuonsSequences_cff::hcal, PFEGammaAlgo::ProtoEGObject::hcalClusters, PFEGammaAlgo::ProtoEGObject::localMap, LOGDRESSED, PFEGammaAlgo::ProtoEGObject::primaryGSFs, findQualityFiles::size, and groupFilesInBlocks::temp.

Referenced by buildAndRefineEGObjects().

1644  {
1645  if( !_splayedblock[reco::PFBlockElement::HCAL].size() ) return;
1646  auto HCALbegin = _splayedblock[reco::PFBlockElement::HCAL].begin();
1647  auto HCALend = _splayedblock[reco::PFBlockElement::HCAL].end();
1648  for( auto& primgsf : RO.primaryGSFs ) {
1649  NotCloserToOther<reco::PFBlockElement::GSF,reco::PFBlockElement::HCAL>
1650  gsfTracksToHCALs(_currentblock,_currentlinks,primgsf.first);
1651  CompatibleEoPOut eoverp_test(primgsf.first);
1652  auto notmatched = std::partition(HCALbegin,HCALend,gsfTracksToHCALs);
1653  for( auto hcal = HCALbegin; hcal != notmatched; ++hcal ) {
1654  const PFClusterElement* elemascluster =
1655  docast(const PFClusterElement*,hcal->first);
1656  PFClusterFlaggedElement temp(elemascluster,true);
1657  LOGDRESSED("PFEGammaAlgo::linkGSFTracktoECAL()")
1658  << "Found an HCAL cluster associated to GSF extrapolation"
1659  << std::endl;
1660  RO.hcalClusters.push_back(temp);
1661  RO.localMap.push_back( ElementMap::value_type(primgsf.first,temp.first) );
1662  RO.localMap.push_back( ElementMap::value_type(temp.first,primgsf.first) );
1663  hcal->second = false;
1664  }
1665  }
1666 }
std::pair< const PFClusterElement *, bool > PFClusterFlaggedElement
Definition: PFEGammaAlgo.h:66
std::vector< std::vector< PFFlaggedElement > > _splayedblock
Definition: PFEGammaAlgo.h:191
reco::PFBlockRef _currentblock
Definition: PFEGammaAlgo.h:187
#define LOGDRESSED(x)
Definition: PFEGammaAlgo.cc:47
reco::PFBlockElementCluster PFClusterElement
Definition: PFEGammaAlgo.h:60
Container::value_type value_type
reco::PFBlock::LinkData _currentlinks
Definition: PFEGammaAlgo.h:188
#define docast(x, y)
Definition: PFEGammaAlgo.cc:43
tuple size
Write out results.
void PFEGammaAlgo::linkRefinableObjectPrimaryKFsToSecondaryKFs ( ProtoEGObject RO)
private

Definition at line 1554 of file PFEGammaAlgo.cc.

References _currentblock, _currentlinks, _splayedblock, constexpr, docast, Exception, PFEGammaAlgo::ProtoEGObject::localMap, PFEGammaAlgo::ProtoEGObject::primaryKFs, PFEGammaAlgo::ProtoEGObject::secondaryKFs, findQualityFiles::size, reco::PFBlockElement::T_FROM_GAMMACONV, reco::PFBlockElement::TRACK, and reco::PFBlockElementTrack::trackType().

Referenced by buildAndRefineEGObjects().

1554  {
1558  auto KFbegin = _splayedblock[reco::PFBlockElement::TRACK].begin();
1559  auto KFend = _splayedblock[reco::PFBlockElement::TRACK].end();
1560  for( auto& kfflagged : RO.primaryKFs ) {
1561  const PFKFElement* primkf = kfflagged.first;
1562  // don't process SC-only ROs or secondary seeded ROs
1563  if( primkf->trackType(convType) ) {
1564  throw cms::Exception("PFEGammaAlgo::linkRefinableObjectPrimaryKFsToSecondaryKFs()")
1565  << "A KF track from conversion has been assigned as a primary!!"
1566  << std::endl;
1567  }
1568  NotCloserToOther<reco::PFBlockElement::TRACK,reco::PFBlockElement::TRACK,true>
1569  kfTrackToKFs(_currentblock,_currentlinks,primkf);
1570  // get KF tracks not closer to another and not already used
1571  auto notlinked = std::partition(KFbegin,KFend,kfTrackToKFs);
1572  // attach tracks and set as used
1573  for( auto kft = KFbegin; kft != notlinked; ++kft ) {
1574  const PFKFElement* elemaskf =
1575  docast(const PFKFElement*,kft->first);
1576  // don't care about things that aren't primaries or directly
1577  // associated secondary tracks
1578  if( elemaskf->trackType(convType) ) {
1579  kft->second = false;
1580  RO.secondaryKFs.push_back(std::make_pair(elemaskf,true));
1581  RO.localMap.push_back( ElementMap::value_type(primkf,elemaskf) );
1582  RO.localMap.push_back( ElementMap::value_type(elemaskf,primkf) );
1583  }
1584  }// loop on closest KFs not closer to other KFs
1585  } // loop on KF primaries on RO
1586 }
std::vector< std::vector< PFFlaggedElement > > _splayedblock
Definition: PFEGammaAlgo.h:191
reco::PFBlockRef _currentblock
Definition: PFEGammaAlgo.h:187
#define constexpr
Container::value_type value_type
reco::PFBlock::LinkData _currentlinks
Definition: PFEGammaAlgo.h:188
reco::PFBlockElementTrack PFKFElement
Definition: PFEGammaAlgo.h:59
#define docast(x, y)
Definition: PFEGammaAlgo.cc:43
tuple size
Write out results.
void PFEGammaAlgo::linkRefinableObjectSecondaryKFsToECAL ( ProtoEGObject RO)
private

Definition at line 1877 of file PFEGammaAlgo.cc.

References _currentblock, _currentlinks, _splayedblock, attachPSClusters(), docast, reco::PFBlockElement::ECAL, patCandidatesForDimuonsSequences_cff::ecal, PFEGammaAlgo::ProtoEGObject::ecal2ps, PFEGammaAlgo::ProtoEGObject::localMap, PFEGammaAlgo::ProtoEGObject::secondaryKFs, and reco::PFBlockElement::TRACK.

Referenced by buildAndRefineEGObjects().

1877  {
1878  auto ECALbegin = _splayedblock[reco::PFBlockElement::ECAL].begin();
1879  auto ECALend = _splayedblock[reco::PFBlockElement::ECAL].end();
1880  for( auto& skf : RO.secondaryKFs ) {
1881  NotCloserToOther<reco::PFBlockElement::TRACK,
1883  false>
1884  TracksToECALwithCut(_currentblock,_currentlinks,skf.first,1.5f);
1885  auto notmatched = std::partition(ECALbegin,ECALend,TracksToECALwithCut);
1886  for( auto ecal = ECALbegin; ecal != notmatched; ++ecal ) {
1887  const reco::PFBlockElementCluster* elemascluster =
1888  docast(const reco::PFBlockElementCluster*,ecal->first);
1889  if( addPFClusterToROSafe(elemascluster,RO) ) {
1890  attachPSClusters(elemascluster,RO.ecal2ps[elemascluster]);
1891  RO.localMap.push_back(ElementMap::value_type(skf.first,elemascluster));
1892  RO.localMap.push_back(ElementMap::value_type(elemascluster,skf.first));
1893  ecal->second = false;
1894  }
1895  }
1896  }
1897 }
std::vector< std::vector< PFFlaggedElement > > _splayedblock
Definition: PFEGammaAlgo.h:191
reco::PFBlockRef _currentblock
Definition: PFEGammaAlgo.h:187
Container::value_type value_type
reco::PFBlock::LinkData _currentlinks
Definition: PFEGammaAlgo.h:188
#define docast(x, y)
Definition: PFEGammaAlgo.cc:43
int attachPSClusters(const PFClusterElement *, ClusterMap::mapped_type &)
void PFEGammaAlgo::mergeROsByAnyLink ( std::list< ProtoEGObject > &  )
private

Definition at line 1422 of file PFEGammaAlgo.cc.

References PFEGammaAlgo::ProtoEGObject::brems, HLT_25ns14e33_v1_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 buildAndRefineEGObjects().

1422  {
1423  if( ROs.size() < 2 ) return; // nothing to do with one or zero ROs
1424  bool check_for_merge = true;
1425  while( check_for_merge ) {
1426  // bugfix for early termination merging loop (15 April 2014)
1427  // check all pairwise combinations in the list
1428  // if one has a merge shuffle it to the front of the list
1429  // if there are no merges left to do we can terminate
1430  for( auto it1 = ROs.begin(); it1 != ROs.end(); ++it1 ) {
1431  TestIfROMergableByLink mergeTest(*it1);
1432  auto find_start = it1; ++find_start;
1433  auto has_merge = std::find_if(find_start,ROs.end(),mergeTest);
1434  if( has_merge != ROs.end() && it1 != ROs.begin() ) {
1435  std::swap(*(ROs.begin()),*it1);
1436  break;
1437  }
1438  }// ensure mergables are shuffled to the front
1439  ProtoEGObject& thefront = ROs.front();
1440  TestIfROMergableByLink mergeTest(thefront);
1441  auto mergestart = ROs.begin(); ++mergestart;
1442  auto nomerge = std::partition(mergestart,ROs.end(),mergeTest);
1443  if( nomerge != mergestart ) {
1444  LOGDRESSED("PFEGammaAlgo::mergeROsByAnyLink()")
1445  << "Found objects " << std::distance(mergestart,nomerge)
1446  << " to merge by links to the front!" << std::endl;
1447  for( auto roToMerge = mergestart; roToMerge != nomerge; ++roToMerge) {
1448  //bugfix! L.Gray 14 Jan 2016
1449  // -- check that the front is still mergeable!
1450  if( thefront.ecalclusters.size() && roToMerge->ecalclusters.size() ) {
1451  if( thefront.ecalclusters.front().first->clusterRef()->layer() !=
1452  roToMerge->ecalclusters.front().first->clusterRef()->layer() ) {
1453  LOGWARN("PFEGammaAlgo::mergeROsByAnyLink")
1454  << "Tried to merge EB and EE clusters! Skipping!";
1455  ROs.push_back(*roToMerge);
1456  continue;
1457  }
1458  }
1459  //end bugfix
1460  thefront.ecalclusters.insert(thefront.ecalclusters.end(),
1461  roToMerge->ecalclusters.begin(),
1462  roToMerge->ecalclusters.end());
1463  thefront.ecal2ps.insert(roToMerge->ecal2ps.begin(),
1464  roToMerge->ecal2ps.end());
1465  thefront.secondaryKFs.insert(thefront.secondaryKFs.end(),
1466  roToMerge->secondaryKFs.begin(),
1467  roToMerge->secondaryKFs.end());
1468 
1469  thefront.localMap.insert(thefront.localMap.end(),
1470  roToMerge->localMap.begin(),
1471  roToMerge->localMap.end());
1472  // TO FIX -> use best (E_gsf - E_clustersum)/E_GSF
1473  if( !thefront.parentSC && roToMerge->parentSC ) {
1474  thefront.parentSC = roToMerge->parentSC;
1475  }
1476  if( thefront.electronSeed.isNull() &&
1477  roToMerge->electronSeed.isNonnull() ) {
1478  thefront.electronSeed = roToMerge->electronSeed;
1479  thefront.primaryGSFs.insert(thefront.primaryGSFs.end(),
1480  roToMerge->primaryGSFs.begin(),
1481  roToMerge->primaryGSFs.end());
1482  thefront.primaryKFs.insert(thefront.primaryKFs.end(),
1483  roToMerge->primaryKFs.begin(),
1484  roToMerge->primaryKFs.end());
1485  thefront.brems.insert(thefront.brems.end(),
1486  roToMerge->brems.begin(),
1487  roToMerge->brems.end());
1488  thefront.electronClusters = roToMerge->electronClusters;
1489  thefront.nBremsWithClusters = roToMerge->nBremsWithClusters;
1490  thefront.firstBrem = roToMerge->firstBrem;
1491  thefront.lateBrem = roToMerge->lateBrem;
1492  } else if ( thefront.electronSeed.isNonnull() &&
1493  roToMerge->electronSeed.isNonnull()) {
1494  LOGWARN("PFEGammaAlgo::mergeROsByAnyLink")
1495  << "Need to implement proper merging of two gsf candidates!"
1496  << std::endl;
1497  }
1498  }
1499  ROs.erase(mergestart,nomerge);
1500  // put the merged element in the back of the cleaned list
1501  ROs.push_back(ROs.front());
1502  ROs.pop_front();
1503  } else {
1504  check_for_merge = false;
1505  }
1506  }
1507  LOGDRESSED("PFEGammaAlgo::mergeROsByAnyLink()")
1508  << "After merging by links there are: " << ROs.size()
1509  << " refinable EGamma objects!" << std::endl;
1510  }
#define LOGDRESSED(x)
Definition: PFEGammaAlgo.cc:47
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
#define LOGWARN(x)
Definition: PFEGammaAlgo.cc:45
void PFEGammaAlgo::removeOrLinkECALClustersToKFTracks ( )
private

Definition at line 1331 of file PFEGammaAlgo.cc.

References _currentblock, _currentlinks, _recoveredlinks, _splayedblock, cfg_, docast, reco::PFBlockElement::ECAL, f, reco::PFBlockElement::GSF, reco::PFBlockElement::index(), reco::PFBlock::LINKTEST_ALL, reco::TrackBase::pixelLessStep, PFEGammaAlgo::PFEGConfigInfo::primaryVtx, reco::PFBlockElement::SC, findQualityFiles::size, 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 buildAndRefineEGObjects().

1331  {
1332  typedef std::multimap<double, unsigned> MatchedMap;
1333  typedef const reco::PFBlockElementGsfTrack* GsfTrackElementPtr;
1336  MatchedMap matchedGSFs, matchedECALs;
1337  std::unordered_map<GsfTrackElementPtr,MatchedMap> gsf_ecal_cache;
1338  for( auto& kftrack : _splayedblock[reco::PFBlockElement::TRACK] ) {
1339  matchedGSFs.clear();
1340  _currentblock->associatedElements(kftrack.first->index(), _currentlinks,
1341  matchedGSFs,
1344  if( !matchedGSFs.size() ) { // only run this if we aren't associated to GSF
1345  LesserByDistance closestTrackToECAL(_currentblock,_currentlinks,
1346  &kftrack);
1347  auto ecalbegin = _splayedblock[reco::PFBlockElement::ECAL].begin();
1348  auto ecalend = _splayedblock[reco::PFBlockElement::ECAL].end();
1349  std::partial_sort(ecalbegin,ecalbegin+1,ecalend,closestTrackToECAL);
1350  PFFlaggedElement& closestECAL =
1352  const float dist = _currentblock->dist(kftrack.first->index(),
1353  closestECAL.first->index(),
1354  _currentlinks,
1356  bool inSC = false;
1357  for( auto& sc : _splayedblock[reco::PFBlockElement::SC] ) {
1358  float dist_sc = _currentblock->dist(sc.first->index(),
1359  closestECAL.first->index(),
1360  _currentlinks,
1362  if( dist_sc != -1.0f) { inSC = true; break; }
1363  }
1364 
1365  if( dist != -1.0f && closestECAL.second ) {
1366  bool gsflinked = false;
1367  // check that this cluster is not associated to a GSF track
1368  for(const auto& gsfflag : _splayedblock[reco::PFBlockElement::GSF]) {
1369  const reco::PFBlockElementGsfTrack* elemasgsf =
1370  docast(const reco::PFBlockElementGsfTrack*,gsfflag.first);
1372  continue; // keep clusters that have a found conversion GSF near
1373  }
1374  // make sure cache exists
1375  if( !gsf_ecal_cache.count(elemasgsf) ) {
1376  matchedECALs.clear();
1377  _currentblock->associatedElements(elemasgsf->index(), _currentlinks,
1378  matchedECALs,
1381  gsf_ecal_cache.emplace(elemasgsf,matchedECALs);
1382  MatchedMap().swap(matchedECALs);
1383  }
1384  const MatchedMap& ecal_matches = gsf_ecal_cache[elemasgsf];
1385  if( ecal_matches.size() ) {
1386  if( ecal_matches.begin()->second == closestECAL.first->index() ) {
1387  gsflinked = true;
1388  break;
1389  }
1390  }
1391  } // loop over primary GSF tracks
1392  if( !gsflinked && !inSC) {
1393  // determine if we should remove the matched cluster
1394  const reco::PFBlockElementTrack * kfEle =
1395  docast(const reco::PFBlockElementTrack*,kftrack.first);
1396  const reco::TrackRef trackref = kfEle->trackRef();
1397  const reco::TrackBase::TrackAlgorithm Algo = trackref->algo();
1398  const int nexhits =
1399  trackref->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS);
1400  bool fromprimaryvertex = false;
1401  for( auto vtxtks = cfg_.primaryVtx->tracks_begin();
1402  vtxtks != cfg_.primaryVtx->tracks_end(); ++ vtxtks ) {
1403  if( trackref == vtxtks->castTo<reco::TrackRef>() ) {
1404  fromprimaryvertex = true;
1405  break;
1406  }
1407  }// loop over tracks in primary vertex
1408  // if associated to good non-GSF matched track remove this cluster
1409  if( Algo < reco::TrackBase::pixelLessStep && nexhits == 0 && fromprimaryvertex ) {
1410  closestECAL.second = false;
1411  } else { // otherwise associate the cluster and KF track
1412  _recoveredlinks.push_back( ElementMap::value_type(closestECAL.first,kftrack.first) );
1413  _recoveredlinks.push_back( ElementMap::value_type(kftrack.first,closestECAL.first) );
1414  }
1415  }
1416  } // found a good closest ECAL match
1417  } // no GSF track matched to KF
1418  } // loop over KF elements
1419  }
const reco::TrackRef & trackRef() const
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:44
std::vector< std::vector< PFFlaggedElement > > _splayedblock
Definition: PFEGammaAlgo.h:191
const reco::Vertex * primaryVtx
Definition: PFEGammaAlgo.h:126
reco::PFBlockRef _currentblock
Definition: PFEGammaAlgo.h:187
std::pair< const reco::PFBlockElement *, bool > PFFlaggedElement
Definition: PFEGammaAlgo.h:61
TrackAlgorithm
track algorithm
Definition: TrackBase.h:99
PFEGConfigInfo cfg_
Definition: PFEGammaAlgo.h:300
unsigned index() const
double f[11][100]
virtual bool trackType(TrackType trType) const
Container::value_type value_type
reco::PFBlock::LinkData _currentlinks
Definition: PFEGammaAlgo.h:188
#define docast(x, y)
Definition: PFEGammaAlgo.cc:43
ElementMap _recoveredlinks
Definition: PFEGammaAlgo.h:192
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:39
tuple size
Write out results.
Definition: fakeMenu.h:6
void PFEGammaAlgo::RunPFEG ( const pfEGHelpers::HeavyObjectCache hoc,
const reco::PFBlockRef blockRef,
std::vector< bool > &  active 
)

Definition at line 720 of file PFEGammaAlgo.cc.

References buildAndRefineEGObjects(), Chatty, convGsfTrack_, egCandidate_, egExtra_, fifthStepKfTrack_, and verbosityLevel_.

Referenced by isEGValidCandidate().

722  {
723 
724  fifthStepKfTrack_.clear();
725  convGsfTrack_.clear();
726 
727  egCandidate_.clear();
728  egExtra_.clear();
729 
730  // define how much is printed out for debugging.
731  // ... will be setable via CFG file parameter
732  verbosityLevel_ = Chatty; // Chatty mode.
733 
734  buildAndRefineEGObjects(hoc, blockRef);
735 }
reco::PFCandidateEGammaExtraCollection egExtra_
Definition: PFEGammaAlgo.h:390
std::vector< std::pair< unsigned int, unsigned int > > fifthStepKfTrack_
Definition: PFEGammaAlgo.h:297
void buildAndRefineEGObjects(const pfEGHelpers::HeavyObjectCache *hoc, const reco::PFBlockRef &block)
reco::PFCandidateCollection egCandidate_
Definition: PFEGammaAlgo.h:386
std::vector< std::pair< unsigned int, unsigned int > > convGsfTrack_
Definition: PFEGammaAlgo.h:298
verbosityLevel verbosityLevel_
Definition: PFEGammaAlgo.h:329
void PFEGammaAlgo::setEEtoPSAssociation ( const edm::Handle< EEtoPSAssociation > &  eetops)
inline

Definition at line 136 of file PFEGammaAlgo.h.

References eetops_.

136  {
137  eetops_ = eetops;
138  }
edm::Handle< reco::PFCluster::EEtoPSAssociation > eetops_
Definition: PFEGammaAlgo.h:186
void PFEGammaAlgo::setnPU ( int  nVtx)
inline

Definition at line 140 of file PFEGammaAlgo.h.

References nVtx_.

140  {
141  nVtx_=nVtx;
142  }
void PFEGammaAlgo::setPhotonPrimaryVtx ( const reco::Vertex primary)
inline

Definition at line 143 of file PFEGammaAlgo.h.

References cfg_, and PFEGammaAlgo::PFEGConfigInfo::primaryVtx.

143  {
144  cfg_.primaryVtx = & primary;
145  }
const reco::Vertex * primaryVtx
Definition: PFEGammaAlgo.h:126
PFEGConfigInfo cfg_
Definition: PFEGammaAlgo.h:300
void PFEGammaAlgo::unlinkRefinableObjectKFandECALMatchedToHCAL ( ProtoEGObject RO,
bool  removeFreeECAL = false,
bool  removeSCECAL = false 
)
private

Definition at line 2430 of file PFEGammaAlgo.cc.

References _currentblock, _currentlinks, _splayedblock, reco::PFBlockElementCluster::clusterRef(), HLT_25ns14e33_v1_cff::distance, patCandidatesForDimuonsSequences_cff::ecal, PFEGammaAlgo::ProtoEGObject::ecalclusters, f, spr::find(), reco::PFBlockElement::HCAL, reco::PFBlock::LINKTEST_ALL, PFEGammaAlgo::ProtoEGObject::localMap, LOGDRESSED, PFEGammaAlgo::ProtoEGObject::parentSC, PFEGammaAlgo::ProtoEGObject::secondaryKFs, and whichTrackAlgo().

Referenced by buildAndRefineEGObjects().

2432  {
2433  std::vector<bool> cluster_in_sc;
2434  auto ecal_begin = RO.ecalclusters.begin();
2435  auto ecal_end = RO.ecalclusters.end();
2436  auto hcal_begin = _splayedblock[reco::PFBlockElement::HCAL].begin();
2437  auto hcal_end = _splayedblock[reco::PFBlockElement::HCAL].end();
2438  for( auto secd_kf = RO.secondaryKFs.begin();
2439  secd_kf != RO.secondaryKFs.end(); ++secd_kf ) {
2440  bool remove_this_kf = false;
2441  NotCloserToOther<reco::PFBlockElement::TRACK,reco::PFBlockElement::HCAL>
2442  tracksToHCALs(_currentblock,_currentlinks,secd_kf->first);
2443  reco::TrackRef trkRef = secd_kf->first->trackRef();
2444  const unsigned int Algo = whichTrackAlgo(trkRef);
2445  const float secpin = trkRef->p();
2446 
2447  for( auto ecal = ecal_begin; ecal != ecal_end; ++ecal ) {
2448  const double ecalenergy = ecal->first->clusterRef()->correctedEnergy();
2449  // first check if the cluster is in the SC (use dist calc for fastness)
2450  const size_t clus_idx = std::distance(ecal_begin,ecal);
2451  if( cluster_in_sc.size() < clus_idx + 1) {
2452  float dist = -1.0f;
2453  if( RO.parentSC ) {
2454  dist = _currentblock->dist(secd_kf->first->index(),
2455  ecal->first->index(),
2456  _currentlinks,
2458  }
2459  cluster_in_sc.push_back(dist != -1.0f);
2460  }
2461 
2462  ElementMap::value_type check_match(ecal->first,secd_kf->first);
2463  auto kf_matched = std::find(RO.localMap.begin(),
2464  RO.localMap.end(),
2465  check_match);
2466  // if we've found a secondary KF that matches this ecal cluster
2467  // now we see if it is matched to HCAL
2468  // if it is matched to an HCAL cluster we take different
2469  // actions if the cluster was in an SC or not
2470  if( kf_matched != RO.localMap.end() ) {
2471  auto hcal_matched = std::partition(hcal_begin,hcal_end,tracksToHCALs);
2472  for( auto hcalclus = hcal_begin;
2473  hcalclus != hcal_matched;
2474  ++hcalclus ) {
2475  const reco::PFBlockElementCluster * clusthcal =
2476  dynamic_cast<const reco::PFBlockElementCluster*>(hcalclus->first);
2477  const double hcalenergy = clusthcal->clusterRef()->energy();
2478  const double hpluse = ecalenergy+hcalenergy;
2479  const bool isHoHE = ( (hcalenergy / hpluse ) > 0.1 && Algo < 3 );
2480  const bool isHoE = ( hcalenergy > ecalenergy );
2481  const bool isPoHE = ( secpin > hpluse );
2482  if( cluster_in_sc[clus_idx] ) {
2483  if(isHoE || isPoHE) {
2484  LOGDRESSED("PFEGammaAlgo")
2485  << "REJECTED TRACK FOR H/E or P/(H+E), CLUSTER IN SC"
2486  << " H/H+E " << (hcalenergy / hpluse)
2487  << " H/E " << (hcalenergy > ecalenergy)
2488  << " P/(H+E) " << (secpin/hpluse)
2489  << " HCAL ENE " << hcalenergy
2490  << " ECAL ENE " << ecalenergy
2491  << " secPIN " << secpin
2492  << " Algo Track " << Algo << std::endl;
2493  remove_this_kf = true;
2494  }
2495  } else {
2496  if(isHoHE){
2497  LOGDRESSED("PFEGammaAlgo")
2498  << "REJECTED TRACK FOR H/H+E, CLUSTER NOT IN SC"
2499  << " H/H+E " << (hcalenergy / hpluse)
2500  << " H/E " << (hcalenergy > ecalenergy)
2501  << " P/(H+E) " << (secpin/hpluse)
2502  << " HCAL ENE " << hcalenergy
2503  << " ECAL ENE " << ecalenergy
2504  << " secPIN " << secpin
2505  << " Algo Track " << Algo << std::endl;
2506  remove_this_kf = true;
2507  }
2508  }
2509  }
2510  }
2511  }
2512  if( remove_this_kf ) {
2513  secd_kf = RO.secondaryKFs.erase(secd_kf);
2514  if( secd_kf == RO.secondaryKFs.end() ) break;
2515  }
2516  }
2517 }
unsigned int whichTrackAlgo(const reco::TrackRef &trackRef)
const PFClusterRef & clusterRef() const
std::vector< std::vector< PFFlaggedElement > > _splayedblock
Definition: PFEGammaAlgo.h:191
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
reco::PFBlockRef _currentblock
Definition: PFEGammaAlgo.h:187
#define LOGDRESSED(x)
Definition: PFEGammaAlgo.cc:47
double f[11][100]
Container::value_type value_type
reco::PFBlock::LinkData _currentlinks
Definition: PFEGammaAlgo.h:188
Definition: fakeMenu.h:6
void PFEGammaAlgo::unlinkRefinableObjectKFandECALWithBadEoverP ( ProtoEGObject RO)
private

Definition at line 2340 of file PFEGammaAlgo.cc.

References _currentblock, _currentlinks, funct::abs(), PFEGammaAlgo::ProtoEGObject::brems, HLT_25ns14e33_v1_cff::distance, patCandidatesForDimuonsSequences_cff::ecal, PFEGammaAlgo::ProtoEGObject::ecalclusters, eta, f, spr::find(), reco::PFBlock::LINKTEST_ALL, PFEGammaAlgo::ProtoEGObject::localMap, LOGDRESSED, PFEGammaAlgo::ProtoEGObject::primaryGSFs, and PFEGammaAlgo::ProtoEGObject::secondaryKFs.

Referenced by buildAndRefineEGObjects().

2340  {
2341  // this only means something for ROs with a primary GSF track
2342  if( !RO.primaryGSFs.size() ) return;
2343  // need energy sums to tell if we've added crap or not
2344  const double Pin_gsf = RO.primaryGSFs.front().first->GsftrackRef()->pMode();
2345  const double gsfOuterEta =
2346  RO.primaryGSFs.front().first->positionAtECALEntrance().Eta();
2347  double tot_ecal= 0.0;
2348  std::vector<double> min_brem_dists;
2349  std::vector<double> closest_brem_eta;
2350  // first get the total ecal energy (we should replace this with a cache)
2351  for( const auto& ecal : RO.ecalclusters ) {
2352  tot_ecal += ecal.first->clusterRef()->correctedEnergy();
2353  // we also need to look at the minimum distance to brems
2354  // since energetic brems will be closer to the brem than the track
2355  double min_brem_dist = 5000.0;
2356  double eta = -999.0;
2357  for( const auto& brem : RO.brems ) {
2358  const float dist = _currentblock->dist(brem.first->index(),
2359  ecal.first->index(),
2360  _currentlinks,
2362  if( dist < min_brem_dist && dist != -1.0f ) {
2363  min_brem_dist = dist;
2364  eta = brem.first->positionAtECALEntrance().Eta();
2365  }
2366  }
2367  min_brem_dists.push_back(min_brem_dist);
2368  closest_brem_eta.push_back(eta);
2369  }
2370 
2371  // loop through the ECAL clusters and remove ECAL clusters matched to
2372  // secondary track either in *or* out of the SC if the E/pin is bad
2373  for( auto secd_kf = RO.secondaryKFs.begin();
2374  secd_kf != RO.secondaryKFs.end(); ++secd_kf ) {
2375  reco::TrackRef trkRef = secd_kf->first->trackRef();
2376  const float secpin = secd_kf->first->trackRef()->p();
2377  bool remove_this_kf = false;
2378  for( auto ecal = RO.ecalclusters.begin();
2379  ecal != RO.ecalclusters.end(); ++ecal ) {
2380  size_t bremidx = std::distance(RO.ecalclusters.begin(),ecal);
2381  const float minbremdist = min_brem_dists[bremidx];
2382  const double ecalenergy = ecal->first->clusterRef()->correctedEnergy();
2383  const double Epin = ecalenergy/secpin;
2384  const double detaGsf =
2385  std::abs(gsfOuterEta - ecal->first->clusterRef()->positionREP().Eta());
2386  const double detaBrem =
2387  std::abs(closest_brem_eta[bremidx] -
2388  ecal->first->clusterRef()->positionREP().Eta());
2389 
2390  ElementMap::value_type check_match(ecal->first,secd_kf->first);
2391  auto kf_matched = std::find(RO.localMap.begin(),
2392  RO.localMap.end(),
2393  check_match);
2394 
2395  const float tkdist = _currentblock->dist(secd_kf->first->index(),
2396  ecal->first->index(),
2397  _currentlinks,
2399 
2400  // do not reject this track if it is closer to a brem than the
2401  // secondary track, or if it lies in the delta-eta plane with the
2402  // gsf track or if it is in the dEta plane with the brems
2403  if( Epin > 3 && kf_matched != RO.localMap.end() &&
2404  tkdist != -1.0f && tkdist < minbremdist &&
2405  detaGsf > 0.05 && detaBrem > 0.015) {
2406  double res_with = std::abs((tot_ecal-Pin_gsf)/Pin_gsf);
2407  double res_without = std::abs((tot_ecal-ecalenergy-Pin_gsf)/Pin_gsf);
2408  if(res_without < res_with) {
2409  LOGDRESSED("PFEGammaAlgo")
2410  << " REJECTED_RES totenergy " << tot_ecal
2411  << " Pin_gsf " << Pin_gsf
2412  << " cluster to secondary " << ecalenergy
2413  << " res_with " << res_with
2414  << " res_without " << res_without << std::endl;
2415  tot_ecal -= ecalenergy;
2416  remove_this_kf = true;
2417  ecal = RO.ecalclusters.erase(ecal);
2418  if( ecal == RO.ecalclusters.end() ) break;
2419  }
2420  }
2421  }
2422  if( remove_this_kf ) {
2423  secd_kf = RO.secondaryKFs.erase(secd_kf);
2424  if( secd_kf == RO.secondaryKFs.end() ) break;
2425  }
2426  }
2427 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
reco::PFBlockRef _currentblock
Definition: PFEGammaAlgo.h:187
#define LOGDRESSED(x)
Definition: PFEGammaAlgo.cc:47
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
Container::value_type value_type
reco::PFBlock::LinkData _currentlinks
Definition: PFEGammaAlgo.h:188
bool PFEGammaAlgo::unwrapSuperCluster ( const reco::PFBlockElementSuperCluster thesc,
std::vector< PFClusterFlaggedElement > &  ecalclusters,
ClusterMap ecal2ps 
)
private

Definition at line 1105 of file PFEGammaAlgo.cc.

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

Referenced by initializeProtoCands().

1107  {
1108  ecalclusters.clear();
1109  ecal2ps.clear();
1110  LOGVERB("PFEGammaAlgo")
1111  << "Pointer to SC element: 0x"
1112  << std::hex << thesc << std::dec << std::endl
1113  << "cleared ecalclusters and ecal2ps!" << std::endl;
1114  auto ecalbegin = _splayedblock[reco::PFBlockElement::ECAL].begin();
1115  auto ecalend = _splayedblock[reco::PFBlockElement::ECAL].end();
1116  if( ecalbegin == ecalend ) {
1117  LOGERR("PFEGammaAlgo::unwrapSuperCluster()")
1118  << "There are no ECAL elements in a block with imported SC!"
1119  << " This is a bug we should fix this!"
1120  << std::endl;
1121  return false;
1122  }
1123  reco::SuperClusterRef scref = thesc->superClusterRef();
1124  const bool is_pf_sc = thesc->fromPFSuperCluster();
1125  if( !(scref.isAvailable() && scref.isNonnull()) ) {
1126  throw cms::Exception("PFEGammaAlgo::unwrapSuperCluster()")
1127  << "SuperCluster pointed to by block element is null!"
1128  << std::endl;
1129  }
1130  LOGDRESSED("PFEGammaAlgo")
1131  << "Got a valid super cluster ref! 0x"
1132  << std::hex << scref.get() << std::dec << std::endl;
1133  const size_t nscclusters = scref->clustersSize();
1134  const size_t nscpsclusters = scref->preshowerClustersSize();
1135  size_t npfpsclusters = 0;
1136  size_t npfclusters = 0;
1137  LOGDRESSED("PFEGammaAlgo")
1138  << "Precalculated cluster multiplicities: "
1139  << nscclusters << ' ' << nscpsclusters << std::endl;
1140  NotCloserToOther<reco::PFBlockElement::SC,reco::PFBlockElement::ECAL>
1141  ecalClustersInSC(_currentblock,_currentlinks,thesc);
1142  auto firstnotinsc = std::partition(ecalbegin,ecalend,ecalClustersInSC);
1143  //reset the begin and end iterators
1144  ecalbegin = _splayedblock[reco::PFBlockElement::ECAL].begin();
1145  ecalend = _splayedblock[reco::PFBlockElement::ECAL].end();
1146 
1147  //get list of associated clusters by det id and energy matching
1148  //(only needed when using non-pf supercluster)
1149  std::vector<const ClusterElement*> safePFClusters = is_pf_sc ? std::vector<const ClusterElement*>() : getSCAssociatedECALsSafe(scref,_splayedblock[reco::PFBlockElement::ECAL]);
1150 
1151  if( firstnotinsc == ecalbegin ) {
1152  LOGERR("PFEGammaAlgo::unwrapSuperCluster()")
1153  << "No associated block elements to SuperCluster!"
1154  << " This is a bug we should fix!"
1155  << std::endl;
1156  return false;
1157  }
1158  npfclusters = std::distance(ecalbegin,firstnotinsc);
1159  // ensure we have found the correct number of PF ecal clusters in the case
1160  // that this is a PF supercluster, otherwise all bets are off
1161  if( is_pf_sc && nscclusters != npfclusters ) {
1162  std::stringstream sc_err;
1163  thesc->Dump(sc_err,"\t");
1164  throw cms::Exception("PFEGammaAlgo::unwrapSuperCluster()")
1165  << "The number of found ecal elements ("
1166  << nscclusters << ") in block is not the same as"
1167  << " the number of ecal PF clusters reported by the PFSuperCluster"
1168  << " itself (" << npfclusters
1169  << ")! This should not happen!" << std::endl
1170  << sc_err.str() << std::endl;
1171  }
1172  for( auto ecalitr = ecalbegin; ecalitr != firstnotinsc; ++ecalitr ) {
1173  const PFClusterElement* elemascluster =
1174  docast(const PFClusterElement*,ecalitr->first);
1175 
1176  // reject clusters that really shouldn't be associated to the SC
1177  // (only needed when using non-pf-supercluster)
1178  if(!is_pf_sc && std::find(safePFClusters.begin(),safePFClusters.end(),elemascluster) ==
1179  safePFClusters.end() ) continue;
1180 
1181  //add cluster
1182  ecalclusters.push_back(std::make_pair(elemascluster,true));
1183  //mark cluster as used
1184  ecalitr->second = false;
1185 
1186  // process the ES elements
1187  // auto is a pair<Iterator,bool> here, bool is false when placing fails
1188  auto emplaceresult = ecal2ps.emplace(elemascluster,
1189  ClusterMap::mapped_type());
1190  if( !emplaceresult.second ) {
1191  std::stringstream clus_err;
1192  elemascluster->Dump(clus_err,"\t");
1193  throw cms::Exception("PFEGammaAlgo::unwrapSuperCluster()")
1194  << "List of pointers to ECAL block elements contains non-unique items!"
1195  << " This is very bad!" << std::endl
1196  << "cluster ptr = 0x" << std::hex << elemascluster << std::dec
1197  << std::endl << clus_err.str() << std::endl;
1198  }
1199  ClusterMap::mapped_type& eslist = emplaceresult.first->second;
1200  npfpsclusters += attachPSClusters(elemascluster,eslist);
1201  } // loop over ecal elements
1202 
1203  /*
1204  if( is_pf_sc && nscpsclusters != npfpsclusters) {
1205  std::stringstream sc_err;
1206  thesc->Dump(sc_err,"\t");
1207  throw cms::Exception("PFEGammaAlgo::unwrapSuperCluster()")
1208  << "The number of found PF preshower elements ("
1209  << npfpsclusters << ") in block is not the same as"
1210  << " the number of preshower clusters reported by the PFSuperCluster"
1211  << " itself (" << nscpsclusters << ")! This should not happen!"
1212  << std::endl
1213  << sc_err.str() << std::endl;
1214  }
1215  */
1216 
1217  LOGDRESSED("PFEGammaAlgo")
1218  << " Unwrapped SC has " << npfclusters << " ECAL sub-clusters"
1219  << " and " << npfpsclusters << " PreShower layers 1 & 2 clusters!"
1220  << std::endl;
1221  return true;
1222  }
bool isAvailable() const
Definition: Ref.h:576
const SuperClusterRef & superClusterRef() const
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
std::vector< std::vector< PFFlaggedElement > > _splayedblock
Definition: PFEGammaAlgo.h:191
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
reco::PFBlockRef _currentblock
Definition: PFEGammaAlgo.h:187
#define LOGERR(x)
Definition: PFEGammaAlgo.cc:46
#define LOGVERB(x)
Definition: PFEGammaAlgo.cc:44
#define LOGDRESSED(x)
Definition: PFEGammaAlgo.cc:47
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:244
reco::PFBlockElementCluster PFClusterElement
Definition: PFEGammaAlgo.h:60
reco::PFBlock::LinkData _currentlinks
Definition: PFEGammaAlgo.h:188
#define docast(x, y)
Definition: PFEGammaAlgo.cc:43
void Dump(std::ostream &out=std::cout, const char *tab=" ") const
print the object inside the element
int attachPSClusters(const PFClusterElement *, ClusterMap::mapped_type &)
unsigned int PFEGammaAlgo::whichTrackAlgo ( const reco::TrackRef trackRef)
private

Definition at line 2520 of file PFEGammaAlgo.cc.

References DetachedTripletStep_cff::detachedTripletStep, InitialStep_cff::initialStep, JetCoreRegionalStep_cff::jetCoreRegionalStep, LowPtTripletStep_cff::lowPtTripletStep, MixedTripletStep_cff::mixedTripletStep, PixelLessStep_cff::pixelLessStep, PixelPairStep_cff::pixelPairStep, and TobTecStep_cff::tobTecStep.

Referenced by unlinkRefinableObjectKFandECALMatchedToHCAL().

2520  {
2521  unsigned int Algo = 0;
2522  switch (trackRef->algo()) {
2523  case TrackBase::ctf:
2528  case TrackBase::muonSeededStepInOut:
2529  case TrackBase::muonSeededStepOutIn:
2530  Algo = 0;
2531  break;
2533  Algo = 1;
2534  break;
2536  Algo = 2;
2537  break;
2539  Algo = 3;
2540  break;
2541  case TrackBase::tobTecStep:
2542  Algo = 4;
2543  break;
2544  default:
2545  Algo = 5;
2546  break;
2547  }
2548  return Algo;
2549 }
Definition: fakeMenu.h:6

Member Data Documentation

reco::PFBlockRef PFEGammaAlgo::_currentblock
private
reco::PFBlock::LinkData PFEGammaAlgo::_currentlinks
private
reco::PFCandidateCollection PFEGammaAlgo::_finalCandidates
private

Definition at line 207 of file PFEGammaAlgo.h.

Referenced by buildAndRefineEGObjects().

ElementMap PFEGammaAlgo::_recoveredlinks
private

Definition at line 192 of file PFEGammaAlgo.h.

Referenced by buildAndRefineEGObjects(), and removeOrLinkECALClustersToKFTracks().

std::list<ProtoEGObject> PFEGammaAlgo::_refinableObjects
private
std::vector<std::vector<PFFlaggedElement> > PFEGammaAlgo::_splayedblock
private
std::vector<unsigned int> PFEGammaAlgo::AddFromElectron_
private

Definition at line 384 of file PFEGammaAlgo.h.

PFEGConfigInfo PFEGammaAlgo::cfg_
private
float PFEGammaAlgo::chi2
private

Definition at line 355 of file PFEGammaAlgo.h.

Referenced by EvaluateSingleLegMVA().

float PFEGammaAlgo::chi2_gsf
private

Definition at line 309 of file PFEGammaAlgo.h.

Referenced by calculate_ele_mva().

float PFEGammaAlgo::chi2_kf
private

Definition at line 309 of file PFEGammaAlgo.h.

Referenced by calculate_ele_mva().

float PFEGammaAlgo::Clus5x5ratio_
private

Definition at line 361 of file PFEGammaAlgo.h.

float PFEGammaAlgo::ClusEta_
private

Definition at line 361 of file PFEGammaAlgo.h.

float PFEGammaAlgo::ClusPhi_
private

Definition at line 361 of file PFEGammaAlgo.h.

float PFEGammaAlgo::ClusR9_
private

Definition at line 361 of file PFEGammaAlgo.h.

std::vector< std::pair <unsigned int, unsigned int> > PFEGammaAlgo::convGsfTrack_
private

Definition at line 298 of file PFEGammaAlgo.h.

Referenced by RunPFEG().

float PFEGammaAlgo::CrysEta_
private

Definition at line 361 of file PFEGammaAlgo.h.

int PFEGammaAlgo::CrysIEta_
private

Definition at line 363 of file PFEGammaAlgo.h.

int PFEGammaAlgo::CrysIPhi_
private

Definition at line 363 of file PFEGammaAlgo.h.

float PFEGammaAlgo::CrysPhi_
private

Definition at line 361 of file PFEGammaAlgo.h.

float PFEGammaAlgo::CrysX_
private

Definition at line 364 of file PFEGammaAlgo.h.

float PFEGammaAlgo::CrysY_
private

Definition at line 364 of file PFEGammaAlgo.h.

float PFEGammaAlgo::del_phi
private

Definition at line 355 of file PFEGammaAlgo.h.

Referenced by EvaluateSingleLegMVA().

float PFEGammaAlgo::dEta_
private

Definition at line 372 of file PFEGammaAlgo.h.

float PFEGammaAlgo::DEtaGsfEcalClust
private

Definition at line 316 of file PFEGammaAlgo.h.

Referenced by calculate_ele_mva().

float PFEGammaAlgo::dPhi_
private

Definition at line 372 of file PFEGammaAlgo.h.

float PFEGammaAlgo::dPtOverPt_gsf
private

Definition at line 309 of file PFEGammaAlgo.h.

Referenced by calculate_ele_mva().

float PFEGammaAlgo::DPtOverPt_gsf
private

Definition at line 309 of file PFEGammaAlgo.h.

Referenced by calculate_ele_mva().

float PFEGammaAlgo::DPtOverPt_kf
private

Definition at line 309 of file PFEGammaAlgo.h.

Referenced by calculate_ele_mva().

float PFEGammaAlgo::e1x3_
private

Definition at line 367 of file PFEGammaAlgo.h.

float PFEGammaAlgo::e1x5_
private

Definition at line 367 of file PFEGammaAlgo.h.

float PFEGammaAlgo::e2x5Bottom_
private

Definition at line 367 of file PFEGammaAlgo.h.

float PFEGammaAlgo::e2x5Left_
private

Definition at line 367 of file PFEGammaAlgo.h.

float PFEGammaAlgo::e2x5Max_
private

Definition at line 369 of file PFEGammaAlgo.h.

float PFEGammaAlgo::e2x5Right_
private

Definition at line 367 of file PFEGammaAlgo.h.

float PFEGammaAlgo::e2x5Top_
private

Definition at line 367 of file PFEGammaAlgo.h.

float PFEGammaAlgo::e3x1_
private

Definition at line 367 of file PFEGammaAlgo.h.

float PFEGammaAlgo::e3x3_
private

Definition at line 361 of file PFEGammaAlgo.h.

float PFEGammaAlgo::E3x3_
private

Definition at line 371 of file PFEGammaAlgo.h.

float PFEGammaAlgo::e5x5Map[5][5]
private

Definition at line 358 of file PFEGammaAlgo.h.

float PFEGammaAlgo::earlyBrem
private

Definition at line 319 of file PFEGammaAlgo.h.

Referenced by calculate_ele_mva().

float PFEGammaAlgo::EB
private

Definition at line 365 of file PFEGammaAlgo.h.

float PFEGammaAlgo::ebottom_
private

Definition at line 368 of file PFEGammaAlgo.h.

edm::Handle<reco::PFCluster::EEtoPSAssociation> PFEGammaAlgo::eetops_
private

Definition at line 186 of file PFEGammaAlgo.h.

Referenced by attachPSClusters(), and setEEtoPSAssociation().

reco::PFCandidateCollection PFEGammaAlgo::egCandidate_
private

Definition at line 386 of file PFEGammaAlgo.h.

Referenced by isEGValidCandidate(), and RunPFEG().

reco::PFCandidateEGammaExtraCollection PFEGammaAlgo::egExtra_
private

Definition at line 390 of file PFEGammaAlgo.h.

Referenced by RunPFEG().

float PFEGammaAlgo::EGsfPoutMode
private

Definition at line 315 of file PFEGammaAlgo.h.

Referenced by calculate_ele_mva().

float PFEGammaAlgo::eleft_
private

Definition at line 368 of file PFEGammaAlgo.h.

float PFEGammaAlgo::EoverPt
private

Definition at line 355 of file PFEGammaAlgo.h.

Referenced by EvaluateSingleLegMVA().

float PFEGammaAlgo::eright_
private

Definition at line 368 of file PFEGammaAlgo.h.

float PFEGammaAlgo::eSeed_
private

Definition at line 367 of file PFEGammaAlgo.h.

float PFEGammaAlgo::Eta_gsf
private

Definition at line 306 of file PFEGammaAlgo.h.

Referenced by calculate_ele_mva().

float PFEGammaAlgo::etop_
private

Definition at line 368 of file PFEGammaAlgo.h.

float PFEGammaAlgo::EtotBremPinPoutMode
private

Definition at line 315 of file PFEGammaAlgo.h.

Referenced by calculate_ele_mva().

float PFEGammaAlgo::EtotPinMode
private

Definition at line 315 of file PFEGammaAlgo.h.

Referenced by calculate_ele_mva().

float PFEGammaAlgo::excluded_
private

Definition at line 382 of file PFEGammaAlgo.h.

std::vector< std::pair <unsigned int, unsigned int> > PFEGammaAlgo::fifthStepKfTrack_
private

Definition at line 297 of file PFEGammaAlgo.h.

Referenced by RunPFEG().

float PFEGammaAlgo::firstBrem
private

Definition at line 319 of file PFEGammaAlgo.h.

Referenced by calculate_ele_mva().

std::vector<bool> PFEGammaAlgo::GsfTrackSingleEcal_
private

Definition at line 296 of file PFEGammaAlgo.h.

float PFEGammaAlgo::HOverHE
private

Definition at line 320 of file PFEGammaAlgo.h.

Referenced by calculate_ele_mva().

float PFEGammaAlgo::HOverPin
private

Definition at line 320 of file PFEGammaAlgo.h.

Referenced by calculate_ele_mva().

float PFEGammaAlgo::HoverPt
private

Definition at line 355 of file PFEGammaAlgo.h.

Referenced by EvaluateSingleLegMVA().

bool PFEGammaAlgo::isvalid_
private

Definition at line 322 of file PFEGammaAlgo.h.

float PFEGammaAlgo::lateBrem
private

Definition at line 319 of file PFEGammaAlgo.h.

Referenced by calculate_ele_mva().

float PFEGammaAlgo::lnPt_gsf
private

Definition at line 306 of file PFEGammaAlgo.h.

Referenced by calculate_ele_mva().

std::vector<bool> PFEGammaAlgo::lockExtraKf_
private

Definition at line 295 of file PFEGammaAlgo.h.

float PFEGammaAlgo::logPFClusE_
private

Definition at line 361 of file PFEGammaAlgo.h.

float PFEGammaAlgo::LowClusE_
private

Definition at line 372 of file PFEGammaAlgo.h.

std::vector<int> PFEGammaAlgo::match_ind
private

Definition at line 350 of file PFEGammaAlgo.h.

float PFEGammaAlgo::Mustache_Et_out_
private

Definition at line 382 of file PFEGammaAlgo.h.

float PFEGammaAlgo::Mustache_EtRatio_
private

Definition at line 382 of file PFEGammaAlgo.h.

float PFEGammaAlgo::MustE_
private

Definition at line 371 of file PFEGammaAlgo.h.

double PFEGammaAlgo::mvaValue
private

Definition at line 356 of file PFEGammaAlgo.h.

Referenced by EvaluateSingleLegMVA().

const char* PFEGammaAlgo::mvaWeightFile_
private

Definition at line 302 of file PFEGammaAlgo.h.

float PFEGammaAlgo::nhit_gsf
private

Definition at line 312 of file PFEGammaAlgo.h.

Referenced by calculate_ele_mva().

float PFEGammaAlgo::nhit_kf
private

Definition at line 312 of file PFEGammaAlgo.h.

Referenced by calculate_ele_mva().

float PFEGammaAlgo::nlayers
private

Definition at line 354 of file PFEGammaAlgo.h.

Referenced by EvaluateSingleLegMVA().

float PFEGammaAlgo::nlost
private

Definition at line 354 of file PFEGammaAlgo.h.

Referenced by EvaluateSingleLegMVA().

float PFEGammaAlgo::nPFClus_
private

Definition at line 372 of file PFEGammaAlgo.h.

float PFEGammaAlgo::nVtx_
private

Definition at line 374 of file PFEGammaAlgo.h.

Referenced by setnPU().

reco::PFCandidateCollection PFEGammaAlgo::outcands_
private

Definition at line 180 of file PFEGammaAlgo.h.

Referenced by buildAndRefineEGObjects(), and getCandidates().

reco::PFCandidateEGammaExtraCollection PFEGammaAlgo::outcandsextra_
private

Definition at line 181 of file PFEGammaAlgo.h.

Referenced by buildAndRefineEGObjects(), and getEGExtra().

std::vector< reco::PFCandidate > PFEGammaAlgo::permElectronCandidates_
private

Definition at line 353 of file PFEGammaAlgo.h.

float PFEGammaAlgo::PFCrysEtaCrack_
private

Definition at line 361 of file PFEGammaAlgo.h.

float PFEGammaAlgo::PFPhoE_
private

Definition at line 371 of file PFEGammaAlgo.h.

float PFEGammaAlgo::PFPhoECorr_
private

Definition at line 371 of file PFEGammaAlgo.h.

float PFEGammaAlgo::PFPhoEt_
private

Definition at line 371 of file PFEGammaAlgo.h.

float PFEGammaAlgo::PFPhoEta_
private

Definition at line 371 of file PFEGammaAlgo.h.

float PFEGammaAlgo::PFPhoEtCorr_
private

Definition at line 371 of file PFEGammaAlgo.h.

float PFEGammaAlgo::PFPhoPhi_
private

Definition at line 371 of file PFEGammaAlgo.h.

float PFEGammaAlgo::PFPhoR9_
private

Definition at line 371 of file PFEGammaAlgo.h.

float PFEGammaAlgo::PFPhoR9Corr_
private

Definition at line 371 of file PFEGammaAlgo.h.

const reco::Vertex* PFEGammaAlgo::primaryVertex_
private

Definition at line 335 of file PFEGammaAlgo.h.

float PFEGammaAlgo::RConv_
private

Definition at line 371 of file PFEGammaAlgo.h.

const GBRForest* PFEGammaAlgo::ReaderGC_
private

Definition at line 338 of file PFEGammaAlgo.h.

const GBRForest* PFEGammaAlgo::ReaderGCEB_
private

Definition at line 343 of file PFEGammaAlgo.h.

const GBRForest* PFEGammaAlgo::ReaderGCEEhR9_
private

Definition at line 344 of file PFEGammaAlgo.h.

const GBRForest* PFEGammaAlgo::ReaderGCEElR9_
private

Definition at line 345 of file PFEGammaAlgo.h.

const GBRForest* PFEGammaAlgo::ReaderLC_
private

Definition at line 337 of file PFEGammaAlgo.h.

const GBRForest* PFEGammaAlgo::ReaderLCEB_
private

Definition at line 341 of file PFEGammaAlgo.h.

const GBRForest* PFEGammaAlgo::ReaderLCEE_
private

Definition at line 342 of file PFEGammaAlgo.h.

const GBRForest* PFEGammaAlgo::ReaderRes_
private

Definition at line 339 of file PFEGammaAlgo.h.

reco::SuperClusterCollection PFEGammaAlgo::refinedscs_
private

Definition at line 182 of file PFEGammaAlgo.h.

Referenced by fillPFCandidates(), and getRefinedSCs().

float PFEGammaAlgo::RMSAll_
private

Definition at line 372 of file PFEGammaAlgo.h.

float PFEGammaAlgo::RMSMust_
private

Definition at line 372 of file PFEGammaAlgo.h.

float PFEGammaAlgo::SCEtaWidth_
private

Definition at line 371 of file PFEGammaAlgo.h.

float PFEGammaAlgo::SCPhiWidth_
private

Definition at line 371 of file PFEGammaAlgo.h.

float PFEGammaAlgo::SigmaEtaEta
private

Definition at line 317 of file PFEGammaAlgo.h.

Referenced by calculate_ele_mva().

float PFEGammaAlgo::STIP
private

Definition at line 355 of file PFEGammaAlgo.h.

Referenced by EvaluateSingleLegMVA().

double PFEGammaAlgo::sumPtTrackIsoForPhoton_
private

Definition at line 348 of file PFEGammaAlgo.h.

double PFEGammaAlgo::sumPtTrackIsoSlopeForPhoton_
private

Definition at line 349 of file PFEGammaAlgo.h.

float PFEGammaAlgo::TotPS1_
private

Definition at line 373 of file PFEGammaAlgo.h.

float PFEGammaAlgo::TotPS2_
private

Definition at line 373 of file PFEGammaAlgo.h.

float PFEGammaAlgo::track_pt
private

Definition at line 355 of file PFEGammaAlgo.h.

Referenced by EvaluateSingleLegMVA().

verbosityLevel PFEGammaAlgo::verbosityLevel_
private

Definition at line 329 of file PFEGammaAlgo.h.

Referenced by RunPFEG().

float PFEGammaAlgo::VtxZ_
private

Definition at line 361 of file PFEGammaAlgo.h.

TH2D* PFEGammaAlgo::X0_inner
private

Definition at line 377 of file PFEGammaAlgo.h.

Referenced by PFEGammaAlgo().

TH2D* PFEGammaAlgo::X0_middle
private

Definition at line 378 of file PFEGammaAlgo.h.

Referenced by PFEGammaAlgo().

TH2D* PFEGammaAlgo::X0_outer
private

Definition at line 379 of file PFEGammaAlgo.h.

Referenced by PFEGammaAlgo().

TH2D* PFEGammaAlgo::X0_sum
private

Definition at line 376 of file PFEGammaAlgo.h.

Referenced by PFEGammaAlgo().

float PFEGammaAlgo::x0inner_
private

Definition at line 380 of file PFEGammaAlgo.h.

float PFEGammaAlgo::x0middle_
private

Definition at line 380 of file PFEGammaAlgo.h.

float PFEGammaAlgo::x0outer_
private

Definition at line 380 of file PFEGammaAlgo.h.