31 return StatusCode::FAILURE;
36 return StatusCode::FAILURE;
43 return StatusCode::SUCCESS;
55 jet->setJetP4(jetStartP4);
64 double jesCorrection =
getJES(varE, varEta, Emax);
71 const float etaCorr = calibP4.eta() +
getEtaCorr(jesCorrection*varE, varEta) ;
75 TLorentzVector TLVjet;
76 TLVjet.SetPtEtaPhiM( calibP4.P()/cosh(etaCorr), etaCorr, calibP4.phi(), calibP4.M() );
77 calibP4.SetPxPyPzE( TLVjet.Px(), TLVjet.Py(), TLVjet.Pz(), TLVjet.E() );
78 ATH_MSG_DEBUG(
"JES = "<<jesCorrection <<
" e="<<varE <<
" eta="<<jetStartP4.Eta()<<
" ieta="<< ieta <<
" post_pt= ="<< calibP4.Pt() <<
" etaCorr="<< etaCorr);
82 jet->setJetP4(calibP4);
85 return StatusCode::SUCCESS;
94 if(fileName==
"")
return false;
96 TEnv
config(fileName.c_str());
98 std::string jetAlgo=
static_cast<std::string
> (
m_jetAlgo);
100 std::vector<double> etaBins =
VectorizeD(
config.GetValue(
"JES.EtaBins",
""),
" ");
101 if (etaBins.size()==0){
102 for (
int i=0;i<=90; i++)
103 etaBins.push_back(0.1*i-4.5);
110 for (
uint ieta=0; ieta<etaBins.size()-1; ++ieta)
112 TString key=Form(
"JES.%s_Bin%d",jetAlgo.c_str(),ieta);
123 const double Rcutoff =
getLogPolN(factors,Ecutoff);
125 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] );
134 ATH_MSG_ERROR(
"LowPtJESExtrapolationMethod==2 not supported yet");
139 key=Form(
"EtaCorr.%s_Bin%d",jetAlgo.c_str(),ieta);
146 key=Form(
"EmaxJES.%s_Bin%d",jetAlgo.c_str(),ieta);
162 TEnv
config(fileName.c_str());
163 if(fileName==
"")
return false;
165 std::string jetAlgo=
static_cast<std::string
> (
m_jetAlgo);
167 std::vector<double> etaBins =
static_cast<std::vector<double>
> (
m_etaBins);
168 if (etaBins.size()==0){
169 for (
int i=0;i<=90; i++)
170 etaBins.push_back(0.1*i-4.5);
182 ATH_MSG_ERROR(
"Only linear extrapolations are supported for p-splines currently. Please change the config file to reflect this");
186 for (
uint ieta=0;ieta<etaBins.size()-1;++ieta) {
192 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] );
198 TString key=Form(
"EmaxJES.%s_Bin%d",jetAlgo.c_str(),ieta);
203 key=Form(
"EtaCorr.%s_Bin%d",jetAlgo.c_str(),ieta);
261 R = slope*(E_uncorr-Ecutoff)+Rcutoff;
263 else ATH_MSG_WARNING(
"Incorrect specification of low Pt JES extrapolation, please check the value of the LowPtJESExtrapolationMethod config flag.");
295 y += factors[i]*TMath::Power(log(
x),Int_t(i));
304 if (
bin<=0)
return 0;
311 const double inv_x = 1. /
x;
313 y += i*factors[i]*TMath::Power(log(
x),Int_t(i-1))*inv_x;
320 std::unique_ptr<TFile> tmpF(TFile::Open( fileName.c_str() ));
321 TList *etajes_l =
static_cast<TList*
>( tmpF->Get(etajes_name.c_str()));
325 ATH_MSG_WARNING(
"Do not have the correct number of eta bins for " << fileName <<
"\t" << etajes_name <<
"\t" << etajes_l->GetSize() );
329 auto *pTH1 =
dynamic_cast<TH1*
>(etajes_l->At(i));
330 if (not pTH1)
continue;
345 double slope = (rSecond - rFirst) /
binWidth;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
VecD VectorizeD(const TString &str, const TString &sep=" ")
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
bool readMCJESFromHists()
virtual StatusCode calibrate(xAOD::JetContainer &) const override
Apply calibration to a jet container.
double m_etaCorrFactors[s_nEtaBins][s_nParMax]
double getSplineCorr(const int etaBin, double E) const
double m_JES_MinPt_Slopes[s_nEtaBins]
Gaudi::Property< float > m_maxE_EtaCorr
Gaudi::Property< std::vector< double > > m_etaBins
Eta bins if other than 0.1 steps from -4.5 to 4.5.
double getLogPolN(const double *factors, double x) const
double getEmaxJES(const double Y) const
return Emax
double getLogPolNSlope(const double *factors, double x) const
Gaudi::Property< std::string > m_jetAlgo
jet collection to be calibrated
Gaudi::Property< std::string > m_histoFileName
ToolHandle< JetHelper::IVarTool > m_vartoolEta
interface for xAOD::jet variable to be defined by user, this must correspond to jet Eta in currect ve...
Gaudi::Property< std::string > m_jetInScale
double getEtaCorr(double X, double Y=0) const
return Eta correction
std::vector< std::unique_ptr< TH1 > > m_etajesFactors
double m_JES_MinPt_R[s_nEtaBins]
double getSplineSlope(const int ieta, const double minE) const
Gaudi::Property< float > m_minPt_JES
double m_JESFactors[s_nEtaBins][s_nParMax]
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Gaudi::Property< float > m_lowPtExtrap
Gaudi::Property< bool > m_freezeJESatHighE
EtaJESCalibStep(const std::string &name="EtaJESCalibStep")
Gaudi::Property< std::string > m_constantFileName
name of the text file
void loadSplineHists(const std::string &fileName, const std::string &etajes_name)
Gaudi::Property< std::string > m_jetOutScale
double getLowPtJES(double E_uncorr, double eta_det) const
deal with low pt jets
double m_JES_MinPt_E[s_nEtaBins]
double getJES(const double X, const double Y=0, const double Emax=-1) const
return MCJES calibration factor
Gaudi::Property< bool > m_useSpline
Gaudi::Property< float > m_minPt_EtaCorr
ToolHandle< JetHelper::IVarTool > m_vartoolE
double m_energyFreezeJES[s_nEtaBins]
int getEtaBin(double eta_det) const
Class JetContext Designed to read AOD information related to the event, N vertices,...
void setAttribute(SG::AuxElement &p, const TYPE &v) const
VecD VectorizeD(const TString &str, const TString &sep=" ")
Jet_v1 Jet
Definition of the current "jet version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.