16 :
asg::AsgMessaging(
"ResidualOffsetCorrection"),
17 m_config(nullptr), m_jetAlgo(
""), m_calibAreaTag(
""), m_dev(false), m_isData(false),
18 m_npvBeamspotCorr(nullptr), m_resOffsetBins(nullptr)
23 m_config(
config), m_jetAlgo(std::move(jetAlgo)), m_calibAreaTag(std::move(calibAreaTag)), m_dev(dev), m_isData(isData),
24 m_npvBeamspotCorr(nullptr), m_resOffsetBins(nullptr)
42 bool doMuOnly =
m_config->GetValue(
"ApplyOnlyMuResidual",
false);
43 bool doNPVOnly =
m_config->GetValue(
"ApplyOnlyNPVResidual",
false);
44 bool doNJetOnly =
m_config->GetValue(
"ApplyOnlyNJetResidual",
false);
48 if (
m_mu_ref==-99 && !doNPVOnly && !doNJetOnly) {
49 ATH_MSG_FATAL(
"OffsetCorrection.DefaultMuRef not specified.");
50 return StatusCode::FAILURE;
54 ATH_MSG_FATAL(
"OffsetCorrection.DefaultNPVRef not specified.");
55 return StatusCode::FAILURE;
59 ATH_MSG_FATAL(
"OffsetCorrection.DefaultNPVRef not specified.");
60 return StatusCode::FAILURE;
64 ATH_MSG_FATAL(
"OffsetCorrection.DefaultNjetRef not specified.");
65 return StatusCode::FAILURE;
69 TString ResidualOffsetCalibFile =
m_config->GetValue(
"ResidualOffset.CalibFile",
"");
71 ResidualOffsetCalibFile.Remove(0,33);
72 ResidualOffsetCalibFile.Insert(0,
"JetCalibTools/");
76 m_config->ReadFile(calibFile, kEnvLocal);
78 TString offsetName =
m_config->GetValue(
"ResidualOffsetCorrection.Name",
"");
80 ATH_MSG_INFO(
"Reading residual jet-area pile-up correction factors from: " << calibFile);
87 if (offsetEtaBins.size()<3) {
ATH_MSG_FATAL(offsetName <<
".AbsEtaBins not specified");
return StatusCode::FAILURE; }
90 if(!doNPVOnly && !doNJetOnly){
94 return StatusCode::FAILURE;
101 return StatusCode::FAILURE;
103 }
else if(!doMuOnly){
107 return StatusCode::FAILURE;
111 ATH_MSG_INFO(
"\n NPV beamspot correction will be applied.");
115 return StatusCode::SUCCESS;
119 int nJet,
bool MuOnly,
bool NOnly )
const {
125 int nJet,
bool MuOnly,
bool NOnly,
126 const std::vector<double>&
OffsetMu,
128 const std::vector<double>& OffsetNjet,
129 const TAxis *OffsetBins )
const {
137 double alpha,
beta, etaEdge;
138 if(!MuOnly){
beta = OffsetNjet[0];
141 }
else { alpha = 0; }
144 for (;
bin<=OffsetBins->GetNbins();++
bin) {
145 etaEdge = OffsetBins->GetBinLowEdge(
bin);
146 const double width=OffsetBins->GetBinWidth(
bin);
147 if (abseta<etaEdge+
width)
break;
151 if(!NOnly) alpha +=
OffsetMu[
bin]*(abseta-etaEdge);
152 if(!MuOnly)
beta += OffsetNjet[
bin]*(abseta-etaEdge);
158 double alpha,
beta, etaEdge;
162 }
else { alpha = 0; }
165 for (;
bin<=OffsetBins->GetNbins();++
bin) {
166 etaEdge = OffsetBins->GetBinLowEdge(
bin);
167 const double width=OffsetBins->GetBinWidth(
bin);
168 if (abseta<etaEdge+
width)
break;
172 if(!NOnly) alpha +=
OffsetMu[
bin]*(abseta-etaEdge);