30 ATH_MSG_FATAL(
"If you're trying to apply only the Residual pile up correction, it needs to be specify in the Calibration Sequence. ApplyOnlyResidual should be true in the configuration file and the PileupStartScale should be specified.");
31 return StatusCode::FAILURE;
44 else ATH_MSG_DEBUG(
"The pileup residual calibrations will be applied simultaneously (default).");
52 "Sequential residual calibration can not be applied in doMuOnly or doNPVOnly or doNJetOnly cases.");
55 "Conflicting configuation, UseNjet true but doMuOnly or doNPVOnly also true.");
58 "It was requested to apply only the mu-based AND the NPV-based calibrations.");
61 "It was requested to apply only the mu-based AND the NJet-based calibrations.");
64 "It was requested to apply only the NJet-based calibration but not to use Njet instead of NPV.");
67 "It was requested to apply NJet-based and NPV calibrations.");
73 "OffsetCorrection.DefaultMuRef not specified.");
76 "OffsetCorrection.DefaultNPVRef not specified.");
79 "OffsetCorrection.DefaultNjetRef not specified.");
86 "Incorrect specification of MuTerm binning" );
91 "Incorrect specification of nJetTerm binning." );
94 "Incorrect specification of NPVTerm binning." );
98 ATH_MSG_INFO(
"\n NPV beamspot correction will be applied.");
102 return StatusCode::SUCCESS;
109 ATH_MSG_DEBUG(
"Calibrating jet collection with 1D pile-up correction");
113 double mu = eventInfoDecor(0) ;
124 "Could not retrieve xAOD::EventShape::Density from xAOD::EventShape "<<
m_rhoKey.key() );
138 static const double toGeV = 0.001;
147 const double E_det = jetStartP4.e();
148 const double pT_det = jetStartP4.pt();
149 const double eta_det = jetStartP4.eta();
150 const double mass_det = jetStartP4.mass();
152 if ( E_det < mass_det ) {
153 ATH_MSG_ERROR(
"JetPileupCorrection::calibrateImpl : Current jet has mass=" << mass_det*
toGeV <<
" GeV, which is greater than it's energy=" << E_det*
toGeV <<
" GeV?? Aborting." );
154 return StatusCode::FAILURE;
161 double pT_offset = pT_det;
162 double pileup_SF = 1;
170 pT_offset =
m_doJetArea ? pT_det - rho*jetareaP4.pt() - offsetET : pT_det - offsetET;
173 pileup_SF = pT_offset >= 0 ? pT_offset / pT_det : 10./pT_det;
175 calibP4 = jetStartP4*pileup_SF;
180 pT_offset =
m_doJetArea ? pT_det - rho*jetareaP4.pt() - offsetET : pT_det - offsetET;
181 double muSF = pT_offset >= 0 ? pT_offset / pT_det : 10./pT_det;
183 calibP4 = jetStartP4*muSF;
187 double pT_afterMuCalib = calibP4.pt();
188 pT_offset = pT_afterMuCalib - offsetET;
189 double SF = pT_offset >= 0 ? pT_offset / pT_afterMuCalib : 10./pT_afterMuCalib;
190 calibP4 = calibP4*SF;
196 jet->setJetP4( calibP4 );
201 return StatusCode::SUCCESS;
206 int nJet,
bool MuOnly,
bool NOnly )
const {
212 int nJet,
bool MuOnly,
bool NOnly,
213 const std::vector<double>& OffsetMu,
214 const std::vector<double>& OffsetNPV,
215 const std::vector<double>& OffsetNjet,
216 const TAxis *OffsetBins )
const {
218 static const double toMeV= 1000.;
225 double alpha, beta, etaEdge;
226 if(!MuOnly){ beta = OffsetNjet[0];
228 if(!NOnly){ alpha = OffsetMu[0];
229 }
else { alpha = 0; }
232 for (;
bin<=OffsetBins->GetNbins();++
bin) {
233 etaEdge = OffsetBins->GetBinLowEdge(
bin);
234 const double width=OffsetBins->GetBinWidth(
bin);
235 if (abseta<etaEdge+
width)
break;
236 if(!NOnly) alpha +=
width*OffsetMu[
bin];
237 if(!MuOnly) beta +=
width*OffsetNjet[
bin];
239 if(!NOnly) alpha += OffsetMu[
bin]*(abseta-etaEdge);
240 if(!MuOnly) beta += OffsetNjet[
bin]*(abseta-etaEdge);
246 double alpha, beta, etaEdge;
247 if(!MuOnly){ beta = OffsetNPV[0];
249 if(!NOnly){ alpha = OffsetMu[0];
250 }
else { alpha = 0; }
253 for (;
bin<=OffsetBins->GetNbins();++
bin) {
254 etaEdge = OffsetBins->GetBinLowEdge(
bin);
255 const double width=OffsetBins->GetBinWidth(
bin);
256 if (abseta<etaEdge+
width)
break;
257 if(!NOnly) alpha +=
width*OffsetMu[
bin];
258 if(!MuOnly) beta +=
width*OffsetNPV[
bin];
260 if(!NOnly) alpha += OffsetMu[
bin]*(abseta-etaEdge);
261 if(!MuOnly) beta += OffsetNPV[
bin]*(abseta-etaEdge);
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
This header defines wrapper classes around SG::AuxElement::Accessor used internally in the Jet EDM.
#define CHECK_THEN_ERROR(checkcode, message)
Gaudi::Property< std::vector< double > > m_resOffsetNjet
Gaudi::Property< int > m_njetThreshold
Gaudi::Property< std::string > m_jetOutScale
Gaudi::Property< bool > m_doMuOnly
NPVBeamspotCorrection * m_npvBeamspotCorr
virtual StatusCode calibrate(xAOD::JetContainer &jetCont) const override
Apply calibration to a jet container.
Gaudi::Property< float > m_mu_ref
Gaudi::Property< bool > m_doJetArea
Gaudi::Property< bool > m_doSequentialResidual
Gaudi::Property< bool > m_applyNPVBeamspotCorrection
Gaudi::Property< std::string > m_jetInScale
double getNPVBeamspotCorrection(double NPV) const
Gaudi::Property< std::vector< double > > m_resOffsetNPV
SG::ReadHandleKey< xAOD::VertexContainer > m_pvKey
double getResidualOffset(double abseta, double mu, double NPV, int nJet, bool MuOnly, bool NOnly) const
Gaudi::Property< float > m_NPV_ref
Gaudi::Property< std::vector< double > > m_resOffsetMu
Gaudi::Property< std::vector< double > > m_offsetEtaBins
Gaudi::Property< bool > m_isData
Pileup1DResidualCalibStep(const std::string &name="Pileup1DResidualCalibStep")
SG::ReadHandleKey< xAOD::JetContainer > m_nJetContainerKey
Gaudi::Property< float > m_muSF
double getResidualOffsetET(double abseta, double mu, double NPV, int nJet, bool MuOnly, bool NOnly, const std::vector< double > &OffsetMu, const std::vector< double > &OffsetNPV, const std::vector< double > &OffsetNjet, const TAxis *OffsetBins) const
Gaudi::Property< bool > m_doOnlyResidual
Gaudi::Property< bool > m_doNJetOnly
SG::ReadDecorHandleKey< xAOD::EventInfo > m_muKey
Gaudi::Property< float > m_nJet_ref
Gaudi::Property< bool > m_doNPVOnly
Gaudi::Property< bool > m_useNjet
SG::ReadHandleKey< xAOD::EventShape > m_rhoKey
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Handle class for reading a decoration on an object.
bool isPresent() const
Is the referenced container present in SG?
virtual bool isValid() override final
Can the handle be successfully dereferenced?
void getAttribute(const SG::AuxElement &p, TYPE &v) const
void setAttribute(SG::AuxElement &p, const TYPE &v) const
int countNPV(const VXCONT &vxCont)
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.