14 m_config(nullptr), m_jetAlgo(
""), m_calibAreaTag(
""), m_mass(false), m_dev(false),
15 m_minPt_JES(10), m_minPt_EtaCorr(8), m_maxE_EtaCorr(2500),
16 m_lowPtExtrap(0), m_lowPtMinR(0.25),
22 m_config(
config), m_jetAlgo(std::move(jetAlgo)), m_calibAreaTag(std::move(calibAreaTag)), m_mass(
mass), m_dev(dev),
23 m_minPt_JES(10), m_minPt_EtaCorr(8), m_maxE_EtaCorr(2500),
24 m_lowPtExtrap(0), m_lowPtMinR(0.25),
40 return StatusCode::FAILURE;
45 TString absoluteJESCalibFile =
m_config->GetValue(
"AbsoluteJES.CalibFile",
"");
47 absoluteJESCalibFile.Remove(0,33);
48 absoluteJESCalibFile.Insert(0,
"JetCalibTools/");
52 m_config->ReadFile(calibFile, kEnvLocal);
53 ATH_MSG_INFO(
"Reading absolute calibration factors from: " << calibFile);
76 for (
int i=0;
i<=90;
i++)
79 else if (
etaBins.empty()) {
ATH_MSG_FATAL(
"JES.EtaBins incorrectly specified");
return StatusCode::FAILURE; }
82 return StatusCode::FAILURE;
90 else {
ATH_MSG_FATAL(
"You can't apply the mass correction unless you specify ApplyMassCorrection: true in the configuration file!");
return StatusCode::FAILURE; }
99 if (m_nPar<s_nParMin || m_nPar>
s_nParMax) {
ATH_MSG_FATAL(
"Cannot read JES calib constants " <<
key );
return StatusCode::FAILURE; }
113 const double Rcutoff =
getLogPolN(factors,Ecutoff);
115 if(Slope > Rcutoff/Ecutoff)
ATH_MSG_FATAL(
"Slope of calibration curve at minimum ET is too steep for the JES factors of etabin " << ieta <<
", eta = " <<
etaBins[ieta] );
125 const double Param1 = (2/Ecutoff)*(Rcutoff-
h)-Slope;
126 const double Param2 = (0.5/Ecutoff)*(Slope-Param1);
128 if( Param1 < 0 || Param1 + 2*Param2*Ecutoff < 0)
ATH_MSG_FATAL(
"Polynomial extension to calibration curve below minimum ET is not monotonically increasing for etabin " << ieta <<
", eta = " <<
etaBins[ieta] );
136 TString
key=Form(
"EtaCorr.%s_Bin%d",
m_jetAlgo.Data(),ieta);
146 if (
params.size()!=1) {
ATH_MSG_FATAL(
"Cannot read starting energy for the freezing of JES correction " <<
key );
return StatusCode::FAILURE; }
160 TString absoluteJESCalibHists =
m_config->GetValue(
"AbsoluteJES.CalibHists",
"");
162 absoluteJESCalibHists.Remove(0,33);
163 absoluteJESCalibHists.Insert(0,
"JetCalibTools/");
173 ATH_MSG_ERROR(
"Only linear extrapolations are supported for p-splines currently. Please change the config file to reflect this");
174 return StatusCode::FAILURE;
189 if(Slope > Rcutoff/Ecutoff)
ATH_MSG_WARNING(
"Slope of calibration curve at minimum ET is too steep for the JES factors of etabin " << ieta <<
", eta = " <<
etaBins[ieta] );
199 return StatusCode::SUCCESS;
206 std::unique_ptr<TFile> tmpF(TFile::Open(
fileName ));
207 TList *etajes_l =
static_cast<TList*
>( tmpF->Get(etajes_name.c_str()));
211 ATH_MSG_WARNING(
"Do not have the correct number of eta bins for " <<
fileName <<
"\t" << etajes_name <<
"\t" << etajes_l->GetSize() );
215 auto *pTH1 =
dynamic_cast<TH1*
>(etajes_l->At(
i));
216 if (not pTH1)
continue;
228 jetStartP4 =
jet.jetP4();
232 float detectorEta =
jet.getAttribute<
float>(
"DetectorEta");
236 const double etaCorr = calibP4.eta() +
getEtaCorr( calibP4.e(), detectorEta );
239 else{ massCorr = jetStartP4.mass()*
getMassCorr(calibP4.e(), detectorEta); }
240 TLorentzVector TLVjet;
241 TLVjet.SetPtEtaPhiM( calibP4.P()/cosh(etaCorr),etaCorr,calibP4.phi(),massCorr );
242 calibP4.SetPxPyPzE( TLVjet.Px(), TLVjet.Py(), TLVjet.Pz(), TLVjet.E() );
245 float JESFactor = calibP4.e()/jetStartP4.e();
246 jet.setAttribute<
float>(
"JetJESCalibFactor",JESFactor);
251 jet.setJetP4( calibP4 );
253 return StatusCode::SUCCESS;
260 double E = E_uncorr/
m_GeV;
310 double R = slope*(E_uncorr-Ecutoff)+Rcutoff;
318 else ATH_MSG_WARNING(
"Incorrect specification of low Pt JES extrapolation, please check the value of the LowPtJESExtrapolationMethod config flag.");
329 double slope = (rSecond - rFirst) /
binWidth;
360 if (!
m_applyMassCorrection) {
ATH_MSG_FATAL(
"You can't apply the mass correction unless you specify ApplyMassCorrection: true in the configuration file!" );
return 0; }
364 double E = ( E_corr/cosh(eta_det)<5.0*
m_GeV ? 5.0*cosh(eta_det) : E_corr/
m_GeV );
373 y += factors[
i]*TMath::Power(
log(
x),Int_t(
i));
379 const double inv_x = 1. /
x;
381 y +=
i*factors[
i]*TMath::Power(
log(
x),Int_t(
i-1))*inv_x;
387 if (
bin<=0)
return 0;