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;
142 SG::AuxElement::Accessor<int> puCorrectedAcc(
"PileupCorrected");
148 const double E_det = jetStartP4.e();
149 const double pT_det = jetStartP4.pt();
150 const double eta_det = jetStartP4.eta();
151 const double mass_det = jetStartP4.mass();
153 if ( E_det < mass_det ) {
154 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." );
155 return StatusCode::FAILURE;
162 double pT_offset = pT_det;
163 double pileup_SF = 1;
171 pT_offset =
m_doJetArea ? pT_det - rho*jetareaP4.pt() - offsetET : pT_det - offsetET;
174 pileup_SF = pT_offset >= 0 ? pT_offset / pT_det : 10./pT_det;
176 calibP4 = jetStartP4*pileup_SF;
181 pT_offset =
m_doJetArea ? pT_det - rho*jetareaP4.pt() - offsetET : pT_det - offsetET;
182 double muSF = pT_offset >= 0 ? pT_offset / pT_det : 10./pT_det;
184 calibP4 = jetStartP4*muSF;
188 double pT_afterMuCalib = calibP4.pt();
189 pT_offset = pT_afterMuCalib - offsetET;
190 double SF = pT_offset >= 0 ? pT_offset / pT_afterMuCalib : 10./pT_afterMuCalib;
191 calibP4 = calibP4*SF;
196 puCorrectedAcc(*
jet) = 1 ;
199 jet->setJetP4( calibP4 );
204 return StatusCode::SUCCESS;
209 int nJet,
bool MuOnly,
bool NOnly )
const {
215 int nJet,
bool MuOnly,
bool NOnly,
216 const std::vector<double>& OffsetMu,
217 const std::vector<double>& OffsetNPV,
218 const std::vector<double>& OffsetNjet,
219 const TAxis *OffsetBins )
const {
221 static const double toMeV= 1000.;
228 double alpha, beta, etaEdge;
229 if(!MuOnly){ beta = OffsetNjet[0];
231 if(!NOnly){ alpha = OffsetMu[0];
232 }
else { alpha = 0; }
235 for (;
bin<=OffsetBins->GetNbins();++
bin) {
236 etaEdge = OffsetBins->GetBinLowEdge(
bin);
237 const double width=OffsetBins->GetBinWidth(
bin);
238 if (abseta<etaEdge+
width)
break;
239 if(!NOnly) alpha +=
width*OffsetMu[
bin];
240 if(!MuOnly) beta +=
width*OffsetNjet[
bin];
242 if(!NOnly) alpha += OffsetMu[
bin]*(abseta-etaEdge);
243 if(!MuOnly) beta += OffsetNjet[
bin]*(abseta-etaEdge);
249 double alpha, beta, etaEdge;
250 if(!MuOnly){ beta = OffsetNPV[0];
252 if(!NOnly){ alpha = OffsetMu[0];
253 }
else { alpha = 0; }
256 for (;
bin<=OffsetBins->GetNbins();++
bin) {
257 etaEdge = OffsetBins->GetBinLowEdge(
bin);
258 const double width=OffsetBins->GetBinWidth(
bin);
259 if (abseta<etaEdge+
width)
break;
260 if(!NOnly) alpha +=
width*OffsetMu[
bin];
261 if(!MuOnly) beta +=
width*OffsetNPV[
bin];
263 if(!NOnly) alpha += OffsetMu[
bin]*(abseta-etaEdge);
264 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.