34 std::unique_ptr<TFile>
file(TFile::Open(fullPath.c_str(),
"READ"));
37 return StatusCode::FAILURE;
41 std::string key =
"etaBinning";
42 TH1* histo =
dynamic_cast<TH1*
>(
file->Get(key.c_str()));
44 histo->SetDirectory(
nullptr);
49 return StatusCode::FAILURE;
55 TString tmpSlopKey[
s_nProngBins] = {
"slopeNPV1P",
"slopeNPV3P"};
56 TString tmpFuncBase[
s_nProngBins] = {
"OneP_Eta_",
"MultiP_Eta_"};
68 histo =
dynamic_cast<TH1*
>(
file->Get(tmpSlopKey[i]));
70 histo->SetDirectory(
nullptr);
74 ATH_MSG_FATAL(
"Failed to get an object with key " << tmpSlopKey[i]);
75 return StatusCode::FAILURE;
79 TString key = tmpFuncBase[i];
81 TF1* fcn =
dynamic_cast<TF1*
>(
file->Get(key));
87 return StatusCode::FAILURE;
96 return StatusCode::SUCCESS;
106 if ( tau_p4.Pt() <= 0.) {
107 ATH_MSG_DEBUG(
"tau energy at LC scale is " << tau_p4.Pt()/
GeV <<
"--> set energy=0.001");
108 tau.
setP4(0.001, tau_p4.Eta(), tau_p4.Phi(), tau.
m());
110 return StatusCode::SUCCESS;
115 if (tau.
nTracks() <= 1) prongBin = 0;
117 double absEta = std::abs( tau_p4.Eta() );
118 int etaBin = std::as_const(*m_etaBinHist).GetXaxis()->FindBin(absEta) - 1;
126 if (!vertexInHandle.
isValid()) {
127 ATH_MSG_ERROR (
"Could not retrieve HiveDataObj with key " << vertexInHandle.
key());
128 return StatusCode::FAILURE;
131 for (
const auto *
const vertex : *vxContainer) {
138 double calibConst = 1.;
140 double slopeNPV =
m_slopeNPVHist[prongBin]->GetBinContent(etaBin + 1);
144 double energyLC = tau_p4.Pt()/
GeV;
146 if (energyLC - offset <= 0.) {
147 ATH_MSG_DEBUG(
"after pile-up correction energy would be = " << energyLC - offset <<
" --> setting offset=0 now!");
152 double energyPileupCorr = energyLC - offset;
154 if (energyPileupCorr > 0. and energyPileupCorr < 10000.)
156 calibConst =
m_calibFunc[prongBin][etaBin]->Eval(energyPileupCorr);
158 if (calibConst <= 0.) {
168 double energyFinal = energyPileupCorr / calibConst;
172 tau.
setP4( energyFinal *
GeV, tau_p4.Eta(), tau_p4.Phi(), tau.
m());
174 ATH_MSG_DEBUG(
"Energy at LC scale = " << energyLC <<
" pile-up offset " << offset <<
" calib. const. = " << calibConst <<
" final energy = " << energyFinal);
176 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexInputContainer
Gaudi::Property< std::string > m_calibrationFile
virtual StatusCode execute(xAOD::TauJet &tau) const override
Execute - called for each tau candidate.
TauCalibrateLC(const std::string &name="TauCalibrateLC")
std::unique_ptr< TH1 > m_etaBinHist
static const int s_nProngBins
virtual StatusCode initialize() override
Tool initializer.
std::vector< std::vector< std::unique_ptr< TF1 > > > m_calibFunc
std::vector< std::unique_ptr< TH1 > > m_slopeNPVHist
Gaudi::Property< bool > m_doVertexCorrection
virtual double phi() const
The azimuthal angle ( ) of the particle.
virtual FourMom_t p4() const
The full 4-momentum of the particle.
virtual double pt() const
The transverse momentum ( ) of the particle.
void setP4(double pt, double eta, double phi, double m)
Set methods for IParticle values.
virtual double m() const
The invariant mass of the particle.
virtual double eta() const
The pseudorapidity ( ) of the particle.
size_t nTracks(TauJetParameters::TauTrackFlag flag=TauJetParameters::TauTrackFlag::classifiedCharged) const
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
TauJet_v3 TauJet
Definition of the current "tau version".