Skip to content

Commit

Permalink
Update KElectron
Browse files Browse the repository at this point in the history
- Isolation and cutbased ID variables moved to KLepton
- Reduced amount of isolation variables
- Full implementation of fiducial flags
  • Loading branch information
JoramBerger committed Nov 30, 2014
1 parent 5ca6b9f commit b33bbd2
Show file tree
Hide file tree
Showing 2 changed files with 186 additions and 167 deletions.
123 changes: 58 additions & 65 deletions DataFormats/interface/KElectron.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,92 +12,85 @@

struct KElectronMetadata
{
std::vector<std::string> idNames;
std::vector<std::string> idNames; //< names of configurable electron IDs
};

struct KElectron : public KLepton
namespace KElectronType { enum Type
{
/// Isolation variables
float trackIso03; // dr03TkSumPt: track iso deposit with electron footprint removed (Delta R = 0.3)
float ecalIso03; // dr03EcalRecHitSumEt: ecal iso deposit with electron footprint removed.
float hcal1Iso03; // dr03HcalDepth1TowerSumEt: hcal depht 1 iso deposit with electron footprint removed.
float hcal2Iso03; // dr03HcalDepth2TowerSumEt: hcal depht 2 iso deposit with electron footprint removed.
inline float hcalIso03() const { return hcal1Iso03 + hcal2Iso03; }; // dr03HcalTowerSumEt
ecalEnergyCorrected = 0, //< true if ecal energy has been corrected = isEcalScaleCorrected
momentumCorrected = 1, //< true if E-p combination has been applied.
ecalDriven = 2, //<
trackerDriven = 3, //<
cutPreselected = 4, //<
mvaPreselected = 5, //<
ecalDrivenSeed = 6, //< can be replaced if space is needed = preselection + ecalDriven
hasConversionMatch = 7 //<
};
}

float trackIso04; // same isolations with Delta R = 0.4
float ecalIso04;
float hcal1Iso04;
float hcal2Iso04;
inline float hcalIso04() const { return hcal1Iso04 + hcal2Iso04; };

float pfIsoCh; // PF isolation from PAT electrons isoVals
float pfIsoEm;
float pfIsoNh;
struct KElectron : public KLepton
{
/// identification results
std::vector<float> electronIds; //< configurable electron IDs (mainly for MVA IDs)

/// Identification
/// identification variables
/// Variables for cutbased electron identification (cf. reco::GsfElectron)
// https://twiki.cern.ch/twiki/bin/viewauth/CMS/EgammaCutBasedIdentification
float deltaEtaSuperClusterTrackAtVtx; // dEtaIn
float deltaPhiSuperClusterTrackAtVtx; // dPhiIn
/// https://twiki.cern.ch/twiki/bin/viewauth/CMS/EgammaCutBasedIdentification?rev=32
unsigned char fiducialFlags; //< ECAL region: bits are set according to reco::GsfElectron::FiducialFlags
unsigned char electronType; //< cf. enum KElectronType::Type
float dEtaIn; //< deltaEtaSuperClusterTrackAtVtx
float dPhiIn; //< deltaPhiSuperClusterTrackAtVtx
float sigmaIetaIeta;
float hadronicOverEm;
float fbrem;
//d0 dz vertexfitprob + missing hits
float eSuperClusterOverP;
float superclusterEnergy; //supercluster
RMPoint superclusterPosition;
bool ecalDrivenSeed;
bool ecalDriven;
bool isEcalEnergyCorrected; //true if ecal energy has been corrected. = isEcalScaleCorrected
float ecalEnergy; //the new corrected value, or the supercluster energy.
float ecalEnergyError;
bool isMomentumCorrected; //true if E-p combination has been applied.
float trackMomentumError; //track momentum error from gsf fit.
float electronMomentumError; //the final electron momentum error.
bool hasConversionMatch;
int status;
/// calculable quantities: p_in and 1/E - 1/p_in:
inline float trackMomentumAtVtxP() const { return ecalEnergy / eSuperClusterOverP; };
inline float invEMinusInvP() const { return (1.0f - eSuperClusterOverP) / ecalEnergy; };

/// cutbased isolation results
unsigned char cutbasedIDs;
inline bool cutbasedIdLoose() const { return (cutbasedIDs & (1 << 0)); };
inline bool cutbasedIdMedium() const { return (cutbasedIDs & (1 << 1)); };
inline bool cutbasedIdTight() const { return (cutbasedIDs & (1 << 2)); };
inline bool cutbasedIdVeto() const { return (cutbasedIDs & (1 << 3)); };

float superclusterEnergy;
float ecalEnergy; //< the new corrected value, or the supercluster energy.
float ecalEnergyErr;
float trackMomentumErr; //< track momentum error from gsf fit.
float electronMomentumErr; //< the final electron momentum error.
RMPoint superclusterPosition; //< position of the supercluster

// ECAL region: bits are set according to reco::GsfElectron::FiducialFlags
unsigned char fiducialFlags; // container for all 7 bits
// accessor functions: must be in sync with KElectronProducer
inline bool isEB() const { return (fiducialFlags & (1 << 0)); }; // is e in ECAL Barrel (EB)
inline bool isEE() const { return (fiducialFlags & (1 << 1)); }; // is e in ECAL Endcaps (EE)
inline bool isEBEEGap() const { return (fiducialFlags & (1 << 2)); }; // is e in the crack between EB and EE
inline bool isEBEtaGap() const { return (fiducialFlags & (1 << 3)); }; // is e in EB and in the eta gaps between modules
inline bool isEBPhiGap() const { return (fiducialFlags & (1 << 4)); }; // is e in EB and in the phi gaps between modules
inline bool isEEDeeGap() const { return (fiducialFlags & (1 << 5)); }; // is e in EE and in the gaps between dees
inline bool isEERingGap() const { return (fiducialFlags & (1 << 6)); }; // is e in EE and in the gaps between rings
inline bool isEBGap() const { return isEBEtaGap() || isEBPhiGap(); }; // is e in in any EB gap
inline bool isEEGap() const { return isEEDeeGap() || isEERingGap(); }; // is e in any EE gap
inline bool isGap() const { return isEBEEGap() || isEBGap() || isEEGap(); }; // is e in any gap
/// Isolation results
float trackIso; //< dr03TkSumPt: track iso deposit with electron footprint removed (Delta R = 0.3)
float ecalIso; //< dr03EcalRecHitSumEt: ecal iso deposit with electron footprint removed.
float hcal1Iso; //< dr03HcalDepth1TowerSumEt: hcal depht 1 iso deposit with electron footprint removed.
float hcal2Iso; //< dr03HcalDepth2TowerSumEt: hcal depht 2 iso deposit with electron footprint removed.

/// Configurable MVA IDs
/** Run2: https://twiki.cern.ch/twiki/bin/viewauth/CMS/MultivariateElectronIdentificationRun2
* Full instructions in Producer/interface/KElectrons_cff
*/
std::vector<float> electronIds;
/// calculable quantities:
inline float pIn() const { return ecalEnergy / eSuperClusterOverP; }; //< trackMomentumAtVtxP
inline float invEMinusInvP() const { return (1.0f - eSuperClusterOverP) / ecalEnergy; }; //< 1/E - 1/p_in
inline float hcalIso() const { return hcal1Iso + hcal2Iso; }; //< dr03HcalTowerSumEt

float getId(const std::string &name, const KElectronMetadata *idMetadata) const
/// get configurable (MVA) ID
float getId(const std::string &name, const KElectronMetadata* meta) const
{
for (unsigned int i = 0; i < idMetadata->idNames.size(); ++i)
for (unsigned int i = 0; i < meta->idNames.size(); ++i)
{
if (idMetadata->idNames[i] == name)
if (meta->idNames[i] == name)
return electronIds[i];
}
std::cout << "ElectronId " << name << " not available!" << std::endl;
std::cout << "Electron ID " << name << " not available!" << std::endl;
exit(1);
}

/** Accessor functions to gap values
* must be in sync with KElectronProducer
*/
inline bool isEB() const { return (fiducialFlags & (1 << 0)); }; //< is e in ECAL Barrel (EB)
inline bool isEE() const { return (fiducialFlags & (1 << 1)); }; //< is e in ECAL Endcaps (EE)
inline bool isEBEEGap() const { return (fiducialFlags & (1 << 2)); }; //< is e in the crack between EB and EE
inline bool isEBEtaGap() const { return (fiducialFlags & (1 << 3)); }; //< is e in EB and in the eta gaps between modules
inline bool isEBPhiGap() const { return (fiducialFlags & (1 << 4)); }; //< is e in EB and in the phi gaps between modules
inline bool isEEDeeGap() const { return (fiducialFlags & (1 << 5)); }; //< is e in EE and in the gaps between dees
inline bool isEERingGap() const { return (fiducialFlags & (1 << 6)); }; //< is e in EE and in the gaps between rings
inline bool isEBGap() const { return isEBEtaGap() || isEBPhiGap(); }; //< is e in in any EB gap
inline bool isEEGap() const { return isEEDeeGap() || isEERingGap(); }; //< is e in any EE gap
inline bool isGap() const { return isEBEEGap() || isEBGap() || isEEGap(); }; // is e in any gap


};
typedef std::vector<KElectron> KElectrons;

Expand Down
Loading

0 comments on commit b33bbd2

Please sign in to comment.