Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
#ifndef SimpleElectron_STANDALONE
#include "EgammaAnalysis/ElectronTools/interface/SimpleElectron.h"
SimpleElectron::SimpleElectron(const reco::GsfElectron &in, unsigned int runNumber, bool isMC)
    : run_(runNumber),
      eClass_(int(in.classification())),
      r9_(in.full5x5_r9()),
      scEnergy_(in.superCluster()->rawEnergy() + (in.isEB() ? 0 : in.superCluster()->preshowerEnergy())),
      scEnergyError_(-999.),  // FIXME???
      trackMomentum_(in.trackMomentumAtVtx().R()),
      trackMomentumError_(in.trackMomentumError()),
      regEnergy_(in.correctedEcalEnergy()),
      regEnergyError_(in.correctedEcalEnergyError()),
      eta_(in.superCluster()->eta()),
      isEB_(in.isEB()),
      isMC_(isMC),
      isEcalDriven_(in.ecalDriven()),
      isTrackerDriven_(in.trackerDrivenSeed()),
      newEnergy_(regEnergy_),
      newEnergyError_(regEnergyError_),
      combinedMomentum_(in.p4(reco::GsfElectron::P4_COMBINATION).P()),
      combinedMomentumError_(in.p4Error(reco::GsfElectron::P4_COMBINATION)),
      scale_(1.0),
      smearing_(0.0) {}

void SimpleElectron::writeTo(reco::GsfElectron &out) const {
  math::XYZTLorentzVector oldMomentum = out.p4();
  math::XYZTLorentzVector newMomentum =
      math::XYZTLorentzVector(oldMomentum.x() * getCombinedMomentum() / oldMomentum.t(),
                              oldMomentum.y() * getCombinedMomentum() / oldMomentum.t(),
                              oldMomentum.z() * getCombinedMomentum() / oldMomentum.t(),
                              getCombinedMomentum());
  out.setCorrectedEcalEnergy(getNewEnergy());
  out.setCorrectedEcalEnergyError(getNewEnergyError());
  out.correctMomentum(newMomentum, getTrackerMomentumError(), getCombinedMomentumError());
}
#endif