Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e7c6303
Adding DNN variables for PFID for electrons in the dataformats
valsdav Sep 16, 2021
628d60c
Evaluation of the PFID DNN also for photons
valsdav Sep 17, 2021
7500538
Added switch to disable the DNN PFID loading in Photon and Electron p…
valsdav Sep 17, 2021
a636dbe
Added switch to disable the DNN PFID loading in Photon and Electron p…
valsdav Oct 1, 2021
36a4839
PF cluster isolations
jainshilpi Sep 20, 2021
c5e8ca5
Added minmax scaler to DNN estimator
valsdav Oct 1, 2021
a9f47b4
Moved PFcluster based isolation for electrons in GsfElectronAlgo
valsdav Sep 21, 2021
5eb0ae9
Added protection for HovEn and changed name of Photons variables
valsdav Sep 22, 2021
2ddc933
Added default models and configurations for Run3 PFid
valsdav Sep 23, 2021
2371f46
Added initial values for PFEgammaFilters DNN thresholds
valsdav Sep 23, 2021
4d0a44d
Added new scaler option for Photon PFID DNN
valsdav Oct 1, 2021
c43922e
edm::FileInPath for model and scalers files
valsdav Sep 25, 2021
493fe63
Disable PFiso computation if the DNN is disabled
valsdav Sep 29, 2021
fdf6fa3
Added new DNN info in the PFCandidate dataformat
valsdav Sep 30, 2021
0eece82
Improvements for TF sessions and fixes
valsdav Sep 30, 2021
fd49b69
Code improvements
valsdav Oct 4, 2021
920a5cc
Improved code for DNN estimator
valsdav Oct 4, 2021
7e35ef8
Removed logLevel from EgammaDNNHelper
valsdav Oct 5, 2021
105e752
Fixed bug in storing of DNN outputs in GsfElectronProducer
valsdav Oct 5, 2021
585ff66
Added getters in PFCandidate, fixed missing scaling mode in EgammaDNN…
valsdav Oct 5, 2021
0904547
Disabled by default DNN Egamma PFID for pre4
valsdav Oct 5, 2021
0f05158
Enabled back Egm PFid by default; endRun -> endStream for sessions cl…
valsdav Oct 8, 2021
80281d2
Fixed code-checks, added const to PFCandidate getters
valsdav Oct 8, 2021
f45b48a
From atomic to unique_ptr for Tensorflow GraphDef
valsdav Oct 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions DataFormats/EgammaCandidates/interface/GsfElectron.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ namespace reco {
* Renamed from PixelMatchGsfElectron.
* Originally adapted from the TRecElectron class in ORCA.
*
* \author Claude Charlot - Laboratoire Leprince-Ringuet - �cole polytechnique, CNRS/IN2P3
* \author David Chamont - Laboratoire Leprince-Ringuet - �cole polytechnique, CNRS/IN2P3
* \author Claude Charlot - Laboratoire Leprince-Ringuet - École polytechnique, CNRS/IN2P3
* \author David Chamont - Laboratoire Leprince-Ringuet - École polytechnique, CNRS/IN2P3
*
****************************************************************************/

Expand Down Expand Up @@ -701,12 +701,28 @@ namespace reco {
etOutsideMustache(-std::numeric_limits<float>::max()) {}
};

static constexpr float mvaPlaceholder = -999999999.;

struct MvaOutput {
int status; // see PFCandidateElectronExtra::StatusFlag
float mva_Isolated;
float mva_e_pi;
float mvaByPassForIsolated; // complementary MVA used in preselection
MvaOutput() : status(-1), mva_Isolated(-999999999.), mva_e_pi(-999999999.), mvaByPassForIsolated(-999999999.) {}
float dnn_e_sigIsolated;
float dnn_e_sigNonIsolated;
float dnn_e_bkgNonIsolated;
float dnn_e_bkgTau;
float dnn_e_bkgPhoton;
MvaOutput()
: status(-1),
mva_Isolated(mvaPlaceholder),
mva_e_pi(mvaPlaceholder),
mvaByPassForIsolated(mvaPlaceholder),
dnn_e_sigIsolated(mvaPlaceholder),
dnn_e_sigNonIsolated(mvaPlaceholder),
dnn_e_bkgNonIsolated(mvaPlaceholder),
dnn_e_bkgTau(mvaPlaceholder),
dnn_e_bkgPhoton(mvaPlaceholder) {}
};

// accessors
Expand All @@ -726,6 +742,11 @@ namespace reco {
// for backward compatibility
float mva_Isolated() const { return mvaOutput_.mva_Isolated; }
float mva_e_pi() const { return mvaOutput_.mva_e_pi; }
float dnn_signal_Isolated() const { return mvaOutput_.dnn_e_sigIsolated; }
float dnn_signal_nonIsolated() const { return mvaOutput_.dnn_e_sigNonIsolated; }
float dnn_bkg_nonIsolated() const { return mvaOutput_.dnn_e_bkgNonIsolated; }
float dnn_bkg_Tau() const { return mvaOutput_.dnn_e_bkgTau; }
float dnn_bkg_Photon() const { return mvaOutput_.dnn_e_bkgPhoton; }

private:
PflowIsolationVariables pfIso_;
Expand Down
12 changes: 5 additions & 7 deletions DataFormats/EgammaCandidates/interface/Photon.h
Original file line number Diff line number Diff line change
Expand Up @@ -556,25 +556,23 @@ namespace reco {
/// Set Particle Flow Isolation variables
void setPflowIsolationVariables(const PflowIsolationVariables& pfisol) { pfIsolation_ = pfisol; }

static constexpr float mvaPlaceholder = -999999999.;

struct PflowIDVariables {
int nClusterOutsideMustache;
float etOutsideMustache;
float mva;
float dnn;

PflowIDVariables()
:

nClusterOutsideMustache(-1),
etOutsideMustache(-999999999.),
mva(-999999999.)

{}
: nClusterOutsideMustache(-1), etOutsideMustache(mvaPlaceholder), mva(mvaPlaceholder), dnn(mvaPlaceholder) {}
};

// getters
int nClusterOutsideMustache() const { return pfID_.nClusterOutsideMustache; }
float etOutsideMustache() const { return pfID_.etOutsideMustache; }
float pfMVA() const { return pfID_.mva; }
float pfDNN() const { return pfID_.dnn; }
// setters
void setPflowIDVariables(const PflowIDVariables& pfid) { pfID_ = pfid; }

Expand Down
6 changes: 4 additions & 2 deletions DataFormats/EgammaCandidates/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
<![CDATA[chargedHadronPFPVIso = onfile.chargedHadronIso;]]>
</ioread>
</class>
<class name="reco::Photon::PflowIDVariables" ClassVersion="3">
<class name="reco::Photon::PflowIDVariables" ClassVersion="4">
<version ClassVersion="4" checksum="1852864461"/>
<version ClassVersion="3" checksum="2819734289"/>
</class>
<class name="reco::Photon::EnergyCorrections" ClassVersion="16">
Expand Down Expand Up @@ -221,7 +222,8 @@
<version ClassVersion="11" checksum="2106253688"/>
<version ClassVersion="10" checksum="2786166332"/>
</class>
<class name="reco::GsfElectron::MvaOutput" ClassVersion="13">
<class name="reco::GsfElectron::MvaOutput" ClassVersion="14">
<version ClassVersion="14" checksum="2762940185"/>
<version ClassVersion="13" checksum="632217271"/>
<version ClassVersion="12" checksum="3102257169"/>
<version ClassVersion="11" checksum="1838996036"/>
Expand Down
45 changes: 44 additions & 1 deletion DataFormats/ParticleFlowCandidate/interface/PFCandidate.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,31 @@ namespace reco {
/// set mva for neutral hadron - gamma discrimination
void set_mva_gamma_nh(float mva) { mva_gamma_nh_ = mva; }

// set DNN for electron PFID
// mva for ele PFID DNN sigIsolated class
float dnn_e_sigIsolated() const { return dnn_e_sigIsolated_; }
void set_dnn_e_sigIsolated(float mva) { dnn_e_sigIsolated_ = mva; }

// mva for ele PFID DNN sigNonIsolated class
float dnn_e_sigNonIsolated() const { return dnn_e_sigNonIsolated_; }
void set_dnn_e_sigNonIsolated(float mva) { dnn_e_sigNonIsolated_ = mva; }

// mva for ele PFID DNN bkgNonIsolated class
float dnn_e_bkgNonIsolated() const { return dnn_e_bkgNonIsolated_; }
void set_dnn_e_bkgNonIsolated(float mva) { dnn_e_bkgNonIsolated_ = mva; }

// mva for ele PFID DNN bkgTau class
float dnn_e_bkgTau() const { return dnn_e_bkgTau_; }
void set_dnn_e_bkgTau(float mva) { dnn_e_bkgTau_ = mva; }

// mva for ele PFID DNN bkgPhoton class
float dnn_e_bkgPhoton() const { return dnn_e_bkgPhoton_; }
void set_dnn_e_bkgPhoton(float mva) { dnn_e_bkgPhoton_ = mva; }

// set DNN for gamma PFID
float dnn_gamma() const { return dnn_gamma_; }
void set_dnn_gamma(float mva) { dnn_gamma_ = mva; }

/// mva for neutral hadron - gamma discrimination
float mva_gamma_nh() const { return mva_gamma_nh_; }

Expand Down Expand Up @@ -383,7 +408,7 @@ namespace reco {

const ElementsInBlocks& elementsInBlocks() const;

static const float bigMva_;
static constexpr float bigMva_ = -999.;

friend std::ostream& operator<<(std::ostream& out, const PFCandidate& c);

Expand Down Expand Up @@ -492,6 +517,24 @@ namespace reco {
/// mva for neutral hadron - gamma discrimination
float mva_gamma_nh_;

/// DNN for electron PFid: isolated signal
float dnn_e_sigIsolated_;

/// DNN for electron PFid: non-isolated signal
float dnn_e_sigNonIsolated_;

/// DNN for electron PFid: non-isolated bkg
float dnn_e_bkgNonIsolated_;

/// DNN for electron PFid: tau bkg
float dnn_e_bkgTau_;

/// DNN for electron PFid: photon bkg
float dnn_e_bkgPhoton_;

// DNN for gamma PFid
float dnn_gamma_;

/// position at ECAL entrance, from the PFRecTrack
math::XYZPointF positionAtECALEntrance_;

Expand Down
50 changes: 34 additions & 16 deletions DataFormats/ParticleFlowCandidate/src/PFCandidate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
using namespace reco;
using namespace std;

const float PFCandidate::bigMva_ = -999.;

#include "DataFormats/ParticleFlowCandidate/src/CountBits.h"

PFCandidate::PFCandidate()
Expand All @@ -35,13 +33,18 @@ PFCandidate::PFCandidate()
flags_(0),
deltaP_(0.),
vertexType_(kCandVertex),
mva_Isolated_(bigMva_),
mva_e_pi_(bigMva_),
mva_e_mu_(bigMva_),
mva_pi_mu_(bigMva_),
mva_nothing_gamma_(bigMva_),
mva_nothing_nh_(bigMva_),
mva_gamma_nh_(bigMva_),
mva_Isolated_(PFCandidate::bigMva_),
mva_e_pi_(PFCandidate::bigMva_),
mva_e_mu_(PFCandidate::bigMva_),
mva_pi_mu_(PFCandidate::bigMva_),
mva_nothing_gamma_(PFCandidate::bigMva_),
mva_nothing_nh_(PFCandidate::bigMva_),
mva_gamma_nh_(PFCandidate::bigMva_),
dnn_e_sigIsolated_(PFCandidate::bigMva_),
dnn_e_sigNonIsolated_(PFCandidate::bigMva_),
dnn_e_bkgNonIsolated_(PFCandidate::bigMva_),
dnn_e_bkgTau_(PFCandidate::bigMva_),
dnn_e_bkgPhoton_(PFCandidate::bigMva_),
getter_(nullptr),
storedRefsBitPattern_(0),
time_(0.f),
Expand Down Expand Up @@ -74,13 +77,18 @@ PFCandidate::PFCandidate(Charge charge, const LorentzVector& p4, ParticleType pa
flags_(0),
deltaP_(0.),
vertexType_(kCandVertex),
mva_Isolated_(bigMva_),
mva_e_pi_(bigMva_),
mva_e_mu_(bigMva_),
mva_pi_mu_(bigMva_),
mva_nothing_gamma_(bigMva_),
mva_nothing_nh_(bigMva_),
mva_gamma_nh_(bigMva_),
mva_Isolated_(PFCandidate::bigMva_),
mva_e_pi_(PFCandidate::bigMva_),
mva_e_mu_(PFCandidate::bigMva_),
mva_pi_mu_(PFCandidate::bigMva_),
mva_nothing_gamma_(PFCandidate::bigMva_),
mva_nothing_nh_(PFCandidate::bigMva_),
mva_gamma_nh_(PFCandidate::bigMva_),
dnn_e_sigIsolated_(PFCandidate::bigMva_),
dnn_e_sigNonIsolated_(PFCandidate::bigMva_),
dnn_e_bkgNonIsolated_(PFCandidate::bigMva_),
dnn_e_bkgTau_(PFCandidate::bigMva_),
dnn_e_bkgPhoton_(PFCandidate::bigMva_),
getter_(nullptr),
storedRefsBitPattern_(0),
time_(0.f),
Expand Down Expand Up @@ -137,6 +145,11 @@ PFCandidate::PFCandidate(PFCandidate const& iOther)
mva_nothing_gamma_(iOther.mva_nothing_gamma_),
mva_nothing_nh_(iOther.mva_nothing_nh_),
mva_gamma_nh_(iOther.mva_gamma_nh_),
dnn_e_sigIsolated_(iOther.dnn_e_sigIsolated_),
dnn_e_sigNonIsolated_(iOther.dnn_e_sigNonIsolated_),
dnn_e_bkgNonIsolated_(iOther.dnn_e_bkgNonIsolated_),
dnn_e_bkgTau_(iOther.dnn_e_bkgTau_),
dnn_e_bkgPhoton_(iOther.dnn_e_bkgPhoton_),
positionAtECALEntrance_(iOther.positionAtECALEntrance_),
getter_(iOther.getter_),
storedRefsBitPattern_(iOther.storedRefsBitPattern_),
Expand Down Expand Up @@ -181,6 +194,11 @@ PFCandidate& PFCandidate::operator=(PFCandidate const& iOther) {
mva_nothing_gamma_ = iOther.mva_nothing_gamma_;
mva_nothing_nh_ = iOther.mva_nothing_nh_;
mva_gamma_nh_ = iOther.mva_gamma_nh_;
dnn_e_sigIsolated_ = iOther.dnn_e_sigIsolated_;
dnn_e_sigNonIsolated_ = iOther.dnn_e_sigNonIsolated_;
dnn_e_bkgNonIsolated_ = iOther.dnn_e_bkgNonIsolated_;
dnn_e_bkgTau_ = iOther.dnn_e_bkgTau_;
dnn_e_bkgPhoton_ = iOther.dnn_e_bkgPhoton_;
positionAtECALEntrance_ = iOther.positionAtECALEntrance_;
getter_ = iOther.getter_;
storedRefsBitPattern_ = iOther.storedRefsBitPattern_;
Expand Down
9 changes: 6 additions & 3 deletions DataFormats/ParticleFlowCandidate/src/classes_def.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<lcgdict>

<class name="reco::PFCandidate" ClassVersion="19">
<class name="reco::PFCandidate" ClassVersion="20">
<version ClassVersion="20" checksum="2748489940"/>
<version ClassVersion="19" checksum="2990582232"/>
<version ClassVersion="18" checksum="910857761"/>
<version ClassVersion="17" checksum="3126170233"/>
Expand Down Expand Up @@ -52,7 +53,8 @@
<class name="edm::PtrVector<reco::PFCandidate> "/>
<class name="edm::Wrapper<edm::PtrVector<reco::PFCandidate> >"/>

<class name="reco::IsolatedPFCandidate" ClassVersion="15">
<class name="reco::IsolatedPFCandidate" ClassVersion="16">
<version ClassVersion="16" checksum="2274533749"/>
<version ClassVersion="15" checksum="3042264953"/>
<version ClassVersion="14" checksum="207328514"/>
<version ClassVersion="13" checksum="1855164250"/>
Expand All @@ -67,7 +69,8 @@
<class name="reco::IsolatedPFCandidateRefVector"/>
<class name="reco::IsolatedPFCandidatePtr"/>

<class name="reco::PileUpPFCandidate" ClassVersion="15">
<class name="reco::PileUpPFCandidate" ClassVersion="16">
<version ClassVersion="16" checksum="3331568330"/>
<version ClassVersion="15" checksum="953549166"/>
<version ClassVersion="14" checksum="4065938015"/>
<version ClassVersion="13" checksum="1734488695"/>
Expand Down
3 changes: 2 additions & 1 deletion DataFormats/PatCandidates/src/classes_def_objects.xml
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@
<version ClassVersion="11" checksum="3492108938"/>
<version ClassVersion="10" checksum="417284221"/>
</class>
<class name="pat::PFParticle" ClassVersion="15">
<class name="pat::PFParticle" ClassVersion="16">
<version ClassVersion="16" checksum="4057492004"/>
<version ClassVersion="15" checksum="1485536104"/>
<version ClassVersion="14" checksum="2795911745"/>
<version ClassVersion="13" checksum="223824921"/>
Expand Down
39 changes: 39 additions & 0 deletions RecoEgamma/EgammaElectronAlgos/interface/GsfElectronAlgo.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "RecoEgamma/EgammaIsolationAlgos/interface/EleTkIsolFromCands.h"
#include "RecoEgamma/ElectronIdentification/interface/ElectronMVAEstimator.h"
#include "RecoEgamma/ElectronIdentification/interface/SoftElectronMVAEstimator.h"
#include "RecoEgamma/ElectronIdentification/interface/ElectronDNNEstimator.h"
#include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h"
#include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgoRcd.h"
#include "TrackingTools/GsfTools/interface/MultiTrajectoryStateMode.h"
Expand All @@ -47,6 +48,8 @@
#include "RecoEgamma/EgammaElectronAlgos/interface/ConversionFinder.h"
#include "CondFormats/EcalObjects/interface/EcalPFRecHitThresholds.h"
#include "CondFormats/DataRecord/interface/EcalPFRecHitThresholdsRcd.h"
#include "RecoEgamma/EgammaIsolationAlgos/interface/EcalPFClusterIsolation.h"
#include "RecoEgamma/EgammaIsolationAlgos/interface/HcalPFClusterIsolation.h"

class GsfElectronAlgo {
public:
Expand All @@ -55,6 +58,7 @@ class GsfElectronAlgo {
HeavyObjectCache(const edm::ParameterSet&);
std::unique_ptr<const SoftElectronMVAEstimator> sElectronMVAEstimator;
std::unique_ptr<const ElectronMVAEstimator> iElectronMVAEstimator;
std::unique_ptr<const ElectronDNNEstimator> iElectronDNNEstimator;
};

struct Tokens {
Expand All @@ -69,6 +73,11 @@ class GsfElectronAlgo {
edm::EDGetTokenT<reco::BeamSpot> beamSpotTag;
edm::EDGetTokenT<reco::VertexCollection> vtxCollectionTag;
edm::EDGetTokenT<reco::ConversionCollection> conversions;

edm::EDGetTokenT<reco::PFClusterCollection> pfClusterProducer;
edm::EDGetTokenT<reco::PFClusterCollection> pfClusterProducerHCAL;
edm::EDGetTokenT<reco::PFClusterCollection> pfClusterProducerHFEM;
edm::EDGetTokenT<reco::PFClusterCollection> pfClusterProducerHFHAD;
};

struct StrategyConfiguration {
Expand All @@ -95,6 +104,8 @@ class GsfElectronAlgo {
//heavy ion in 2015 has no conversions and so cant fill conv vtx fit prob so this bool
//stops it from being filled
bool fillConvVtxFitProb;
// Compute PFcluster isolation for egamma PFID DNN
bool computePfClusterIso;
};

struct CutsConfiguration {
Expand Down Expand Up @@ -175,12 +186,33 @@ class GsfElectronAlgo {
bool useNumCrystals;
};

struct PFClusterIsolationConfiguration {
double ecaldrMax;
double ecaldrVetoBarrel;
double ecaldrVetoEndcap;
double ecaletaStripBarrel;
double ecaletaStripEndcap;
double ecalenergyBarrel;
double ecalenergyEndcap;

bool useHF;
double hcaldrMax;
double hcaldrVetoBarrel;
double hcaldrVetoEndcap;
double hcaletaStripBarrel;
double hcaletaStripEndcap;
double hcalenergyBarrel;
double hcalenergyEndcap;
bool hcaluseEt;
};

GsfElectronAlgo(const Tokens&,
const StrategyConfiguration&,
const CutsConfiguration& cutsCfg,
const ElectronHcalHelper::Configuration& hcalCone,
const ElectronHcalHelper::Configuration& hcalBc,
const IsolationConfiguration&,
const PFClusterIsolationConfiguration&,
const EcalRecHitsConfiguration&,
std::unique_ptr<EcalClusterFunctionBaseClass>&& crackCorrectionFunction,
const RegressionHelper::Configuration& regCfg,
Expand All @@ -204,6 +236,7 @@ class GsfElectronAlgo {
const StrategyConfiguration strategy;
const CutsConfiguration cuts;
const IsolationConfiguration iso;
const PFClusterIsolationConfiguration pfiso;
const EcalRecHitsConfiguration recHits;
};

Expand Down Expand Up @@ -263,6 +296,12 @@ class GsfElectronAlgo {
ElectronHcalHelper hcalHelperBc_;
std::unique_ptr<EcalClusterFunctionBaseClass> crackCorrectionFunction_;
RegressionHelper regHelper_;

// Algos for PfCluster Isolation
typedef EcalPFClusterIsolation<reco::GsfElectron> ElectronEcalPFClusterIsolation;
std::unique_ptr<ElectronEcalPFClusterIsolation> ecalisoAlgo_;
typedef HcalPFClusterIsolation<reco::GsfElectron> ElectronHcalPFClusterIsolation;
std::unique_ptr<ElectronHcalPFClusterIsolation> hcalisoAlgo_;
};

#endif // GsfElectronAlgo_H
Loading