File indexing completed on 2024-04-06 12:10:19
0001 #ifndef SimpleElectron_STANDALONE
0002 #include "EgammaAnalysis/ElectronTools/interface/SimpleElectron.h"
0003 SimpleElectron::SimpleElectron(const reco::GsfElectron &in, unsigned int runNumber, bool isMC)
0004 : run_(runNumber),
0005 eClass_(int(in.classification())),
0006 r9_(in.full5x5_r9()),
0007 scEnergy_(in.superCluster()->rawEnergy() + (in.isEB() ? 0 : in.superCluster()->preshowerEnergy())),
0008 scEnergyError_(-999.),
0009 trackMomentum_(in.trackMomentumAtVtx().R()),
0010 trackMomentumError_(in.trackMomentumError()),
0011 regEnergy_(in.correctedEcalEnergy()),
0012 regEnergyError_(in.correctedEcalEnergyError()),
0013 eta_(in.superCluster()->eta()),
0014 isEB_(in.isEB()),
0015 isMC_(isMC),
0016 isEcalDriven_(in.ecalDriven()),
0017 isTrackerDriven_(in.trackerDrivenSeed()),
0018 newEnergy_(regEnergy_),
0019 newEnergyError_(regEnergyError_),
0020 combinedMomentum_(in.p4(reco::GsfElectron::P4_COMBINATION).P()),
0021 combinedMomentumError_(in.p4Error(reco::GsfElectron::P4_COMBINATION)),
0022 scale_(1.0),
0023 smearing_(0.0) {}
0024
0025 void SimpleElectron::writeTo(reco::GsfElectron &out) const {
0026 math::XYZTLorentzVector oldMomentum = out.p4();
0027 math::XYZTLorentzVector newMomentum =
0028 math::XYZTLorentzVector(oldMomentum.x() * getCombinedMomentum() / oldMomentum.t(),
0029 oldMomentum.y() * getCombinedMomentum() / oldMomentum.t(),
0030 oldMomentum.z() * getCombinedMomentum() / oldMomentum.t(),
0031 getCombinedMomentum());
0032 out.setCorrectedEcalEnergy(getNewEnergy());
0033 out.setCorrectedEcalEnergyError(getNewEnergyError());
0034 out.correctMomentum(newMomentum, getTrackerMomentumError(), getCombinedMomentumError());
0035 }
0036 #endif