22 #include "lwtnn/parse_json.hh"
32 m_config(nullptr), m_jetAlgo(
""), m_calibAreaTag(
""), m_dev(false), m_doSplineCorr(true)
40 m_config(nullptr), m_jetAlgo(
""), m_calibAreaTag(
""), m_dev(false), m_doSplineCorr(true)
46 m_config(
config), m_jetAlgo(std::move(jetAlgo)), m_calibAreaTag(calibAreaTag), m_dev(dev), m_doSplineCorr(true)
65 if (
m_jetAlgo.EqualTo(
"") ) {
ATH_MSG_FATAL(
"No jet algorithm specified. Aborting.");
return StatusCode::FAILURE; }
68 TString MLGSCFile =
m_config->GetValue(
"GNNC.MLFactorsFile",
"empty");
69 if ( MLGSCFile.EqualTo(
"empty") ) {
71 return StatusCode::FAILURE;
74 MLGSCFile.Remove(0,33);
75 MLGSCFile.Insert(0,
"JetCalibTools/");
85 m_lwnns.push_back(std::move(lwnn));
92 TString ptCalibHists =
m_config->GetValue(
"GNNC.JPtS_CalibHists",
"");
94 ptCalibHists.Remove(0,33);
95 ptCalibHists.Insert(0,
"JetCalibTools/");
104 ATH_MSG_FATAL(
"Pt cutoff vector has wrong length. There should be one value per eta bin.");
return StatusCode::FAILURE;
105 return StatusCode::FAILURE;
121 return StatusCode::SUCCESS;
128 jetStartP4 =
jet.jetP4();
135 std::map<std::string,std::map<std::string,double>>
inputs;
136 inputs[
"node_0"] = NN_inputValues;
139 double nnCalibFactor =
outputs[
"out_0"];
154 jet.setJetP4( calibP4 );
156 return StatusCode::SUCCESS;
165 std::unique_ptr<TFile> tmpF(TFile::Open(
fileName ));
166 TList *ptCorr_l =
dynamic_cast<TList*
>( tmpF->Get(ptCorr_name.c_str()));
168 ATH_MSG_ERROR(
"TList pointer is null in GlobalNNCalibration::loadSplineHists");
173 int nBinsCorr = ptCorr_l->GetSize();
176 ATH_MSG_WARNING(
"Do not have the correct number of eta bins for " <<
fileName <<
"\t" << ptCorr_name <<
"\t" << ptCorr_l->GetSize() );
180 auto *pTH1 =
dynamic_cast<TH1*
>(ptCorr_l->At(
i));
181 if (not pTH1)
continue;
198 double R = slope*(
pT-ptCutoff)+Rcutoff;
215 double slope = (rSecond - rFirst) /
binWidth;
224 std::vector<float> samplingFrac = jet_reco.
getAttribute<std::vector<float> >(
"EnergyPerSampling");
228 jetStartP4 = jet_reco.
jetP4();
230 float jetE_constitscale = jetconstitP4.e();
233 int PVindex = jetEventInfo.
PVIndex();
238 float EM0 = (samplingFrac[0]+samplingFrac[4])/jetE_constitscale;
239 float EM1 = (samplingFrac[1]+samplingFrac[5])/jetE_constitscale;
240 float EM2 = (samplingFrac[2]+samplingFrac[6])/jetE_constitscale;
241 float EM3 = (samplingFrac[3]+samplingFrac[7])/jetE_constitscale;
242 float Tile0 = (samplingFrac[12]+samplingFrac[18])/jetE_constitscale;
243 float Tile1 = (samplingFrac[13]+samplingFrac[19])/jetE_constitscale;
244 float Tile2 = (samplingFrac[14]+samplingFrac[20])/jetE_constitscale;
245 float HEC0 = (samplingFrac[8])/jetE_constitscale;
246 float HEC1 = (samplingFrac[9])/jetE_constitscale;
247 float HEC2 = (samplingFrac[10])/jetE_constitscale;
248 float HEC3 = (samplingFrac[11])/jetE_constitscale;
250 float FCAL0 = (samplingFrac[21])/jetE_constitscale;
251 float FCAL1 = (samplingFrac[22])/jetE_constitscale;
252 float FCAL2 = (samplingFrac[23])/jetE_constitscale;
257 std::map<std::string,double> inputValues;
263 inputValues[
"jet_pt"] = log10(
getJESPt(jet_reco));
266 inputValues[
"jet_pt"] =
getJESPt(jet_reco);
268 inputValues[
"EM0"] = EM0;
269 inputValues[
"EM1"] =
EM1;
270 inputValues[
"EM2"] =
EM2;
271 inputValues[
"EM3"] =
EM3;
272 inputValues[
"TILE0"] = Tile0;
273 inputValues[
"TILE1"] = Tile1;
274 inputValues[
"TILE2"] = Tile2;
275 inputValues[
"HEC0"] =
HEC0;
276 inputValues[
"HEC1"] =
HEC1;
277 inputValues[
"HEC2"] =
HEC2;
278 inputValues[
"HEC3"] =
HEC3;
279 inputValues[
"FCAL0"] =
FCAL0;
280 inputValues[
"FCAL1"] =
FCAL1;
281 inputValues[
"FCAL2"] =
FCAL2;
286 inputValues[
"jet_n90Constituents"] = jet_reco.
getAttribute<
float>(
"N90Constituents");
287 inputValues[
"jet_nMuSeg"] = jet_reco.
getAttribute<
int>(
"GhostMuonSegmentCount");
288 inputValues[
"NPV"] = jetEventInfo.
NPV();
289 inputValues[
"averageInteractionsPerCrossing"] = jetEventInfo.
mu();
292 std::map<std::string,double> NNInputValues;
294 NNInputValues[
input.Data()] = inputValues[
input.Data()];
297 return NNInputValues;
304 double detEta = jet_reco.
getAttribute<
float>(
"DetectorEta");
305 for(
unsigned int i=1;
i<
etaBins.size()-1;
i++){
306 if(std::abs(detEta) <
etaBins[
i])
return i-1;
315 if( SumPtChargedPFOPt500Acc.
isAvailable(jet_reco) ) {
316 float thisChargedFraction = SumPtChargedPFOPt500Acc(jet_reco).at(PVindex);
318 return double(thisChargedFraction);
326 return DetectorEtaAcc.
withDefault (jet_reco, -999);
332 return NumTrkPt1000Acc(jet_reco).at(PVindex);
339 return double(TrackWidthPt1000Acc(jet_reco).at(PVindex));
345 return jet_reco.
jetP4(
"JetEtaJESScaleMomentum").pt() / 1.e3;