CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
EGEtScaleSysModifier Class Reference
Inheritance diagram for EGEtScaleSysModifier:
ModifyObjectValueBase

Classes

class  UncertFuncBase
 
class  UncertFuncV1
 

Public Member Functions

 EGEtScaleSysModifier (const edm::ParameterSet &conf, edm::ConsumesCollector &)
 
void modifyObject (pat::Electron &ele) const final
 
void modifyObject (pat::Photon &pho) const final
 
void setEvent (const edm::Event &) final
 
void setEventContent (const edm::EventSetup &) final
 
 ~EGEtScaleSysModifier () override
 
- Public Member Functions inherited from ModifyObjectValueBase
virtual void modifyObject (reco::GsfElectron &) const
 
virtual void modifyObject (reco::Photon &) const
 
virtual void modifyObject (reco::Muon &) const
 
virtual void modifyObject (reco::BaseTau &) const
 
virtual void modifyObject (reco::Jet &) const
 
virtual void modifyObject (pat::Muon &) const
 
virtual void modifyObject (pat::Tau &) const
 
virtual void modifyObject (pat::Jet &) const
 
 ModifyObjectValueBase (const edm::ParameterSet &conf)
 
const std::string & name () const
 
virtual ~ModifyObjectValueBase ()
 

Private Member Functions

std::pair< float, float > calCombinedMom (reco::GsfElectron &ele, const float scale, const float smear) const
 
void setEcalEnergy (reco::GsfElectron &ele, const float scale, const float smear) const
 

Private Attributes

EpCombinationTool epCombTool_
 
std::unique_ptr< UncertFuncBaseuncertFunc_
 

Detailed Description

Definition at line 28 of file EGEtScaleSysModifier.cc.

Constructor & Destructor Documentation

◆ EGEtScaleSysModifier()

EGEtScaleSysModifier::EGEtScaleSysModifier ( const edm::ParameterSet conf,
edm::ConsumesCollector cc 
)

Definition at line 89 of file EGEtScaleSysModifier.cc.

References gpuPixelDoublets::cc, edm::ParameterSet::getParameterSet(), and eostools::move().

90  : ModifyObjectValueBase(conf), epCombTool_{conf.getParameterSet("epCombConfig"), std::move(cc)} {
91  const edm::ParameterSet& funcPSet = conf.getParameterSet("uncertFunc");
92  const std::string& funcName = funcPSet.getParameter<std::string>("name");
93  if (funcName == "UncertFuncV1") {
94  uncertFunc_ = std::make_unique<UncertFuncV1>(funcPSet);
95  } else {
96  throw cms::Exception("ConfigError") << "Error constructing EGEtScaleSysModifier, function name " << funcName
97  << " not valid";
98  }
99 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::unique_ptr< UncertFuncBase > uncertFunc_
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
EpCombinationTool epCombTool_
ParameterSet const & getParameterSet(std::string const &) const
ModifyObjectValueBase(const edm::ParameterSet &conf)
def move(src, dest)
Definition: eostools.py:511

◆ ~EGEtScaleSysModifier()

EGEtScaleSysModifier::~EGEtScaleSysModifier ( )
inlineoverride

Definition at line 31 of file EGEtScaleSysModifier.cc.

31 {}

Member Function Documentation

◆ calCombinedMom()

std::pair< float, float > EGEtScaleSysModifier::calCombinedMom ( reco::GsfElectron ele,
const float  scale,
const float  smear 
) const
private

Definition at line 165 of file EGEtScaleSysModifier.cc.

References EpCombinationTool::combine(), reco::GsfElectron::correctMomentum(), reco::GsfElectron::ecalEnergy(), reco::GsfElectron::ecalEnergyError(), epCombTool_, reco::GsfElectron::p4(), reco::GsfElectron::P4_COMBINATION, reco::GsfElectron::p4Error(), pfClustersFromCombinedCaloHF_cfi::scale, reco::GsfElectron::setCorrectedEcalEnergy(), reco::GsfElectron::setCorrectedEcalEnergyError(), setEcalEnergy(), and reco::GsfElectron::trackMomentumError().

Referenced by modifyObject().

167  {
168  const float oldEcalEnergy = ele.ecalEnergy();
169  const float oldEcalEnergyErr = ele.ecalEnergyError();
170  const auto oldP4 = ele.p4();
171  const float oldP4Err = ele.p4Error(reco::GsfElectron::P4_COMBINATION);
172  const float oldTrkMomErr = ele.trackMomentumError();
173 
174  setEcalEnergy(ele, scale, smear);
175  const auto& combinedMomentum = epCombTool_.combine(ele);
176  ele.setCorrectedEcalEnergy(oldEcalEnergy);
177  ele.setCorrectedEcalEnergyError(oldEcalEnergyErr);
178  ele.correctMomentum(oldP4, oldTrkMomErr, oldP4Err);
179 
180  return combinedMomentum;
181 }
float trackMomentumError() const
Definition: GsfElectron.h:884
void correctMomentum(const LorentzVector &p4, float trackMomentumError, float p4Error)
Definition: GsfElectron.h:905
EpCombinationTool epCombTool_
void combine(SimpleElectron &mySimpleElectron) const
void setCorrectedEcalEnergyError(float newEnergyError)
Definition: GsfElectron.cc:170
const LorentzVector & p4(P4Kind kind) const
Definition: GsfElectron.cc:217
void setEcalEnergy(reco::GsfElectron &ele, const float scale, const float smear) const
float p4Error(P4Kind kind) const
Definition: GsfElectron.cc:230
float ecalEnergy() const
Definition: GsfElectron.h:896
float ecalEnergyError() const
Definition: GsfElectron.h:897
void setCorrectedEcalEnergy(float newEnergy)
Definition: GsfElectron.cc:174

◆ modifyObject() [1/2]

void EGEtScaleSysModifier::modifyObject ( pat::Electron ele) const
finalvirtual

Reimplemented from ModifyObjectValueBase.

Definition at line 105 of file EGEtScaleSysModifier.cc.

References pat::PATObject< ObjectType >::addUserFloat(), calCombinedMom(), alignCSCRings::corr, reco::GsfElectron::correctMomentum(), reco::GsfElectron::ecalEnergy(), reco::GsfElectron::ecalEnergyError(), reco::LeafCandidate::energy(), reco::LeafCandidate::et(), EGEnergySysIndex::kEcalErrPreCorr, EGEnergySysIndex::kEcalPostCorr, EGEnergySysIndex::kEcalPreCorr, EGEnergySysIndex::kScaleValue, EGEnergySysIndex::kSmearValue, EGEnergySysIndex::name(), reco::GsfElectron::p4(), reco::GsfElectron::P4_COMBINATION, reco::GsfElectron::p4Error(), reco::GsfElectron::setCorrectedEcalEnergy(), reco::GsfElectron::setCorrectedEcalEnergyError(), reco::GsfElectron::trackMomentumError(), uncertFunc_, and pat::PATObject< ObjectType >::userFloat().

105  {
106  auto getVal = [](const pat::Electron& ele, EGEnergySysIndex::Index valIndex) {
107  return ele.userFloat(EGEnergySysIndex::name(valIndex));
108  };
109  //so ele.energy() may be either pre or post corrections, we have no idea
110  //so we explicity access the pre and post correction ecal energies
111  //we need the pre corrected to properly do the e/p combination
112  //we need the post corrected to get et uncertainty
113  const float ecalEnergyPostCorr = getVal(ele, EGEnergySysIndex::kEcalPostCorr);
114  const float ecalEnergyPreCorr = getVal(ele, EGEnergySysIndex::kEcalPreCorr);
115  const float ecalEnergyErrPreCorr = getVal(ele, EGEnergySysIndex::kEcalErrPreCorr);
116 
117  //the et cut is in terms of ecal et using the track angle and post corr ecal energy
118  const float etUncert = uncertFunc_->val(ele.et() / ele.energy() * ecalEnergyPostCorr);
119  const float smear = getVal(ele, EGEnergySysIndex::kSmearValue);
120  const float corr = getVal(ele, EGEnergySysIndex::kScaleValue);
121 
122  //get the values we have to reset back to
123  const float oldEcalEnergy = ele.ecalEnergy();
124  const float oldEcalEnergyErr = ele.ecalEnergyError();
125  const auto oldP4 = ele.p4();
126  const float oldP4Err = ele.p4Error(reco::GsfElectron::P4_COMBINATION);
127  const float oldTrkMomErr = ele.trackMomentumError();
128 
129  ele.setCorrectedEcalEnergy(ecalEnergyPreCorr);
130  ele.setCorrectedEcalEnergyError(ecalEnergyErrPreCorr);
131 
132  const float energyEtUncertUp = calCombinedMom(ele, corr + etUncert, smear).first;
133  const float energyEtUncertDn = calCombinedMom(ele, corr - etUncert, smear).first;
134 
135  //reset it back to how it was
136  ele.setCorrectedEcalEnergy(oldEcalEnergy);
137  ele.setCorrectedEcalEnergyError(oldEcalEnergyErr);
138  ele.correctMomentum(oldP4, oldTrkMomErr, oldP4Err);
139 
140  ele.addUserFloat("energyScaleEtUp", energyEtUncertUp);
141  ele.addUserFloat("energyScaleEtDown", energyEtUncertDn);
142 }
std::unique_ptr< UncertFuncBase > uncertFunc_
static const std::string & name(size_t index)
float trackMomentumError() const
Definition: GsfElectron.h:884
void correctMomentum(const LorentzVector &p4, float trackMomentumError, float p4Error)
Definition: GsfElectron.h:905
void addUserFloat(const std::string &label, float data, const bool overwrite=false)
Set user-defined float.
Definition: PATObject.h:892
void setCorrectedEcalEnergyError(float newEnergyError)
Definition: GsfElectron.cc:170
std::pair< float, float > calCombinedMom(reco::GsfElectron &ele, const float scale, const float smear) const
dictionary corr
const LorentzVector & p4(P4Kind kind) const
Definition: GsfElectron.cc:217
float p4Error(P4Kind kind) const
Definition: GsfElectron.cc:230
float ecalEnergy() const
Definition: GsfElectron.h:896
Analysis-level electron class.
Definition: Electron.h:51
float ecalEnergyError() const
Definition: GsfElectron.h:897
void setCorrectedEcalEnergy(float newEnergy)
Definition: GsfElectron.cc:174
double et() const final
transverse energy
float userFloat(const std::string &key) const
Definition: PATObject.h:871
double energy() const final
energy

◆ modifyObject() [2/2]

void EGEtScaleSysModifier::modifyObject ( pat::Photon pho) const
finalvirtual

Reimplemented from ModifyObjectValueBase.

Definition at line 144 of file EGEtScaleSysModifier.cc.

References pat::PATObject< ObjectType >::addUserFloat(), alignCSCRings::corr, reco::LeafCandidate::energy(), reco::LeafCandidate::et(), EGEnergySysIndex::kEcalPostCorr, EGEnergySysIndex::kEcalPreCorr, EGEnergySysIndex::kScaleValue, EGEnergySysIndex::name(), uncertFunc_, and pat::PATObject< ObjectType >::userFloat().

144  {
145  auto getVal = [](const pat::Photon& pho, EGEnergySysIndex::Index valIndex) {
146  return pho.userFloat(EGEnergySysIndex::name(valIndex));
147  };
148  //so pho.energy() may be either pre or post corrections, we have no idea
149  //so we explicity access the pre and post correction ecal energies
150  //post corr for the et value for the systematic, pre corr to apply them
151  const float ecalEnergyPostCorr = getVal(pho, EGEnergySysIndex::kEcalPostCorr);
152  const float ecalEnergyPreCorr = getVal(pho, EGEnergySysIndex::kEcalPreCorr);
153 
154  //the et cut is in terms of post corr ecal energy
155  const float etUncert = uncertFunc_->val(pho.et() / pho.energy() * ecalEnergyPostCorr);
156  const float corr = getVal(pho, EGEnergySysIndex::kScaleValue);
157 
158  const float energyEtUncertUp = ecalEnergyPreCorr * (corr + etUncert);
159  const float energyEtUncertDn = ecalEnergyPreCorr * (corr - etUncert);
160 
161  pho.addUserFloat("energyScaleEtUp", energyEtUncertUp);
162  pho.addUserFloat("energyScaleEtDown", energyEtUncertDn);
163 }
Analysis-level Photon class.
Definition: Photon.h:46
std::unique_ptr< UncertFuncBase > uncertFunc_
static const std::string & name(size_t index)
void addUserFloat(const std::string &label, float data, const bool overwrite=false)
Set user-defined float.
Definition: PATObject.h:892
dictionary corr
double et() const final
transverse energy
float userFloat(const std::string &key) const
Definition: PATObject.h:871
double energy() const final
energy

◆ setEcalEnergy()

void EGEtScaleSysModifier::setEcalEnergy ( reco::GsfElectron ele,
const float  scale,
const float  smear 
) const
private

Definition at line 183 of file EGEtScaleSysModifier.cc.

References reco::GsfElectron::ecalEnergy(), reco::GsfElectron::ecalEnergyError(), Matriplex::hypot(), pfClustersFromCombinedCaloHF_cfi::scale, reco::GsfElectron::setCorrectedEcalEnergy(), and reco::GsfElectron::setCorrectedEcalEnergyError().

Referenced by calCombinedMom().

183  {
184  const float oldEcalEnergy = ele.ecalEnergy();
185  const float oldEcalEnergyErr = ele.ecalEnergyError();
186  ele.setCorrectedEcalEnergy(oldEcalEnergy * scale);
187  ele.setCorrectedEcalEnergyError(std::hypot(oldEcalEnergyErr * scale, oldEcalEnergy * smear * scale));
188 }
MPlex< T, D1, D2, N > hypot(const MPlex< T, D1, D2, N > &a, const MPlex< T, D1, D2, N > &b)
Definition: Matriplex.h:417
void setCorrectedEcalEnergyError(float newEnergyError)
Definition: GsfElectron.cc:170
float ecalEnergy() const
Definition: GsfElectron.h:896
float ecalEnergyError() const
Definition: GsfElectron.h:897
void setCorrectedEcalEnergy(float newEnergy)
Definition: GsfElectron.cc:174

◆ setEvent()

void EGEtScaleSysModifier::setEvent ( const edm::Event iEvent)
finalvirtual

Reimplemented from ModifyObjectValueBase.

Definition at line 101 of file EGEtScaleSysModifier.cc.

101 {}

◆ setEventContent()

void EGEtScaleSysModifier::setEventContent ( const edm::EventSetup iSetup)
finalvirtual

Reimplemented from ModifyObjectValueBase.

Definition at line 103 of file EGEtScaleSysModifier.cc.

References epCombTool_, and EpCombinationTool::setEventContent().

103 { epCombTool_.setEventContent(iSetup); }
EpCombinationTool epCombTool_
void setEventContent(const edm::EventSetup &iSetup)

Member Data Documentation

◆ epCombTool_

EpCombinationTool EGEtScaleSysModifier::epCombTool_
private

Definition at line 85 of file EGEtScaleSysModifier.cc.

Referenced by calCombinedMom(), and setEventContent().

◆ uncertFunc_

std::unique_ptr<UncertFuncBase> EGEtScaleSysModifier::uncertFunc_
private

Definition at line 86 of file EGEtScaleSysModifier.cc.

Referenced by modifyObject().