22 m_insituCorr(nullptr),
23 m_insituCorr_JMS(nullptr),
24 m_insituCorr_ResidualMCbased(nullptr),
32 m_jetAlgo(std::move(jetAlgo)),
33 m_calibAreaTag(std::move(calibAreaTag)),
35 m_insituCorr(nullptr),
36 m_insituCorr_JMS(nullptr),
37 m_insituCorr_ResidualMCbased(nullptr),
49 ATH_MSG_ERROR(
"In Situ data correction tool received a null config pointer.");
50 return StatusCode::FAILURE;
56 TString insitu_filename =
m_config->GetValue(
"InsituCalibrationFile",
"None");
66 TString rel_histoname =
m_config->GetValue(
"RelativeInsituCalibrationHistogram",
"");
68 TString abs_histoname =
m_config->GetValue(
"AbsoluteInsituCalibrationHistogram",
"");
70 TString residualmcbased_histoname =
m_config->GetValue(
"ResidualMCbasedInsituCalibrationHistogram",
"");
72 TString insitu_desc =
m_config->GetValue(
"InsituCalibrationDescription",
"");
74 double insitu_etarestriction_residualmcbased =
m_config->GetValue(
"InsituEtaRestrictionResidualMCbased",0.8);
76 double insitu_etarestriction_relativeandabsolute =
m_config->GetValue(
"InsituEtaRestrictionRelativeandAbsolute",0.8);
83 if ( !insitu_filename.EqualTo(
"None") ){
85 insitu_filename.Remove(0,32);
86 insitu_filename.Insert(0,
"JetCalibTools/");
92 std::unique_ptr<TFile> insitu_file(TFile::Open(insitu_filename));
93 if ( !insitu_file ) {
ATH_MSG_FATAL(
"Cannot open InsituCalibrationFile: " << insitu_filename );
return StatusCode::FAILURE; }
95 ATH_MSG_INFO(
"Reading In-situ correction factors from: " << insitu_filename);
97 rel_histoname.ReplaceAll(
"JETALGO",
m_jetAlgo); abs_histoname.ReplaceAll(
"JETALGO",
m_jetAlgo);
101 if ( !rel_histo || !abs_histo ) {
102 ATH_MSG_FATAL(
"\n Tool configured for data, but no residual in-situ histograms could be retrieved. Aborting..." );
103 return StatusCode::FAILURE;
107 m_relhistoPtMax = rel_histo->GetXaxis()->GetBinLowEdge(rel_histo->GetNbinsX()+1);
119 ATH_MSG_FATAL(
"\n Tool configured for the Residual MC based correction, but no residualmcbased in-situ histograms could be retrieved. Aborting..." );
120 return StatusCode::FAILURE;
131 ATH_MSG_FATAL(
"\n Tool configured for Insitu correction, but no in-situ histograms could be retrieved. Aborting..." );
132 return StatusCode::FAILURE;
138 TString insituJMS_filename =
m_config->GetValue(
"InsituCalibrationFile_JMS",
"None");
140 TString abs_histoname_JMS =
m_config->GetValue(
"AbsoluteInsituCalibrationHistogram_JMS",
"");
141 TString abs_histoname_JMS_TA =
m_config->GetValue(
"AbsoluteInsituCalibrationHistogram_JMS_TA",
"");
143 double insitu_etarestriction_JMS =
m_config->GetValue(
"InsituEtaRestriction_JMS",2.0);
146 if ( !insituJMS_filename.EqualTo(
"None")){
148 insituJMS_filename.Remove(0,32);
149 insituJMS_filename.Insert(0,
"JetCalibTools/");
157 std::unique_ptr<TFile> insituJMS_file(TFile::Open(insituJMS_filename));
158 if ( !insituJMS_file ) {
ATH_MSG_FATAL(
"Cannot open InsituJMSCalibrationFile: " << insituJMS_filename );
return StatusCode::FAILURE; }
160 ATH_MSG_INFO(
"Reading In-situ JMS correction factors from: " << insituJMS_filename);
162 abs_histoname_JMS.ReplaceAll(
"JETALGO",
m_jetAlgo);
164 abs_histoname_JMS_TA.ReplaceAll(
"JETALGO",
m_jetAlgo);
169 if ( !abs_histo_JMS ) {
170 ATH_MSG_FATAL(
"\n Tool configured for data, but no in-situ JMS histogram could be retrieved. Aborting..." );
171 return StatusCode::FAILURE;
187 if ( !abs_histo_JMS_TA ){
188 ATH_MSG_FATAL(
"\n Tool configured for data, but no in-situ JMS histogram for TA mass could be retrieved. Aborting..." );
189 return StatusCode::FAILURE;
198 ATH_MSG_FATAL(
"\n Tool configured for Insitu correction, but no in-situ histograms could be retrieved. Aborting..." );
199 return StatusCode::FAILURE;
204 ATH_MSG_INFO(
"In-situ correction to be applied: " << insitu_desc);
205 return StatusCode::SUCCESS;
214 return StatusCode::SUCCESS;
216 float detectorEta =
jet.getAttribute<
float>(
"DetectorEta");
222 jetStartP4 =
jet.jetP4();
229 float insituFactor =
getInsituCorr( jetStartP4.pt(), detectorEta,
"RelativeAbs" );
230 jet.setAttribute<
float>(
"JetRelativeAbsInsituCalibFactor",insituFactor);
238 calibP4_JMS = calibP4;
240 calibP4_JMS=calibP4*
getInsituCorr_JMS( calibP4.pt(), calibP4.M(), detectorEta,
"RelativeAbs",
false );
243 TLorentzVector TLVjet;
244 TLVjet.SetPtEtaPhiM( calibP4.pt(), calibP4.eta(), calibP4.phi(), calibP4_JMS.M() );
245 calibP4.SetPxPyPzE( TLVjet.Px(), TLVjet.Py(), TLVjet.Pz(), TLVjet.E() );
250 jet.setJetP4( calibP4 );
260 calibP4_calo=jetStartP4_calo;
262 ATH_MSG_FATAL(
"Cannot retrieve JetJMSScaleMomentumCalo jets" );
263 return StatusCode::FAILURE;
269 float insituFactor_calo =
getInsituCorr( jetStartP4_calo.pt(), detectorEta,
"RelativeAbs" );
270 jet.setAttribute<
float>(
"JetRelativeAbsInsituCalibFactor_calo",insituFactor_calo);
277 calibP4_calo_JMS = calibP4_calo;
279 calibP4_calo_JMS=calibP4_calo*
getInsituCorr_JMS( calibP4_calo.pt(), calibP4_calo.M(), detectorEta,
"RelativeAbs",
false );
282 TLorentzVector TLVjet_calo;
283 TLVjet_calo.SetPtEtaPhiM( calibP4_calo.pt(), calibP4_calo.eta(), calibP4_calo.phi(), calibP4_calo_JMS.M() );
284 calibP4_calo.SetPxPyPzE( TLVjet_calo.Px(), TLVjet_calo.Py(), TLVjet_calo.Pz(), TLVjet_calo.E() );
289 jet.setJetP4( calibP4_calo );
295 calibP4_ta=jetStartP4_ta;
297 ATH_MSG_FATAL(
"Cannot retrieve JetJMSScaleMomentumTA jets" );
298 return StatusCode::FAILURE;
304 float insituFactor_ta =
getInsituCorr( jetStartP4_ta.pt(), detectorEta,
"RelativeAbs" );
305 jet.setAttribute<
float>(
"JetRelativeAbsInsituCalibFactor_ta",insituFactor_ta);
312 calibP4_ta_JMS = calibP4_ta;
314 calibP4_ta_JMS=calibP4_ta*
getInsituCorr_JMS( calibP4_ta.pt(), calibP4_ta.M(), detectorEta,
"RelativeAbs",
true );
317 TLorentzVector TLVjet_ta;
318 TLVjet_ta.SetPtEtaPhiM( calibP4_ta.pt(), calibP4_ta.eta(), calibP4_ta.phi(), calibP4_ta_JMS.M() );
319 calibP4_ta.SetPxPyPzE( TLVjet_ta.Px(), TLVjet_ta.Py(), TLVjet_ta.Pz(), TLVjet_ta.E() );
324 jet.setJetP4( calibP4_ta );
328 return StatusCode::SUCCESS;
339 if (calibstep ==
"ResidualMCbased"){
346 if ( myPt <= ptMin ) myPt = ptMin + 1
e-6;
347 else if ( myPt >= ptMax ) myPt = ptMax - 1
e-6;
349 if(myEta>=
etaMax)
return 1.0;
353 if(myEta>=
etaMax)
return 1.0;
354 else if(myEta<=-
etaMax)
return 1.0;
383 if ( myPt <= ptMin ) myPt = ptMin + 1
e-6;
384 else if ( myPt >= ptMax ) myPt = ptMax - 1
e-6;
386 if(myEta>=
etaMax)
return 1.0;
387 else if(myEta<=-
etaMax)
return 1.0;
391 if (myMass <= massMin ) myMass = massMin + 1
e-6;
392 else if (myMass >= massMax ) myMass = massMax - 1
e-6;
394 double calibFactor = 1.0;
408 std::unique_ptr<TH2> prod(
static_cast<TH2*
>(h2d->Clone()));
409 for (
int xi=1;xi<=prod->GetNbinsX();xi++) {
410 double pt=prod->GetXaxis()->GetBinCenter(xi);
411 const double R_abs=
h->Interpolate(
pt);
412 const double inv_R_abs = 1. / R_abs;
414 for (
int yi=1;yi<=prod->GetNbinsY();yi++) {
415 double c_rel = h2d->GetBinContent(xi,yi);
416 prod->SetBinContent(xi,yi,c_rel*inv_R_abs);
423 std::unique_ptr<TH2> inv(
static_cast<TH2*
>(h2d->Clone()));
424 for (
int xi=1;xi<=inv->GetNbinsX();xi++) {
425 for (
int yi=1;yi<=inv->GetNbinsY();yi++) {
426 inv->SetBinContent(xi,yi,1./h2d->GetBinContent(xi,yi));