53 return StatusCode::FAILURE;
59 return StatusCode::FAILURE;
62 return StatusCode::SUCCESS;
72 double corrIDpT = mu.ID.calib_pt;
75 double corrMEpT = mu.ME.calib_pt;
78 double corrDirectCBpT = mu.CB.calib_pt;
89 double central(45.2),
width(15.5);
95 double sigmaID = mu.expectedResID;
96 double sigmaME = mu.expectedResME;
97 double denominator = mu.CB.calib_pt * std::sqrt(sigmaID * sigmaID + sigmaME * sigmaME);
98 double res = denominator ? M_SQRT2 * sigmaID * sigmaME / denominator : 0.;
102 central += std::abs(0.5 *
res * central);
105 central -= std::abs(0.5 *
res * central);
112 double sigmas = std::max(1.,(std::abs(
mu.CB.calib_pt - central) /
width));
119 double corrCBpT =
rho * corrDirectCBpT + (1 -
rho) * corrStatCombCBpT;
121 ATH_MSG_DEBUG(
"Saggita correction - corrDirectCBpT: " << corrDirectCBpT <<
" corrStatCombCBpT: " << corrStatCombCBpT <<
" rho " << rho<<
" corrCBPt: "<<corrCBpT);
124 mu.ID.calib_pt = corrIDpT;
125 mu.ME.calib_pt = corrMEpT;
127 if(
m_calibMode == MuonCalibTool::correctData_CB)
mu.CB.calib_pt = corrCBpT;
128 else if(
m_calibMode == MuonCalibTool::correctData_IDMS)
mu.CB.calib_pt = corrStatCombCBpT;
129 else if(
m_calibMode == MuonCalibTool::correctData_IDonly)
mu.CB.calib_pt = corrIDpT;
130 else if(
m_calibMode == MuonCalibTool::correctData_MSonly)
mu.CB.calib_pt = corrMEpT;
139 for(
const auto& corr: correction)
141 double originalPt =
pt;
144 ATH_MSG_DEBUG(
"CorrectForCharge - in pT: " << originalPt <<
" corrPt: " <<
pt <<
" applied saggita: " << corr);
173 std::vector<double> corrections;
182 corrections.push_back(corr);
194 ATH_MSG_ERROR(
"Sagitta correction is not applied to data, yet Eta dependant systematics are requested. This configuration is not supported");
209 corrections.push_back(corr);
221 corrections.push_back(corr);
231 if(
m_release.value().find(
"Recs2023") != std::string::npos) deltas = 1.2 * deltas;
232 else if(std::abs(
eta)>1.05) deltas = 1.5 * deltas;
234 double corr = deltas * scale;
237 corrections.push_back(corr);
251 double deltas = 0.00002;
256 corr += std::abs(450.0 - 45) * deltas;
258 corr += std::abs(pT - 45) * deltas;
261 if (
eta > 2 || (
eta > -2 &&
eta < -1.05)) {
263 corr += std::abs(450.0 - 45) / 100 * deltas;
265 corr += std::abs(pT - 45) / 100 * deltas;
269 corr += std::abs(450.0 - 45) / 200 * deltas;
271 corr += std::abs(pT - 45) / 200 * deltas;
274 if (
m_release.value().find(
"Recs2023") != std::string::npos) {
277 else if (
eta < -1.05) corr += 1.1*deltas;
278 else if (
eta > 0.5 ) corr += 0.8*deltas;
282 if (
eta > -2 &&
eta < -1.05) corr = corr*2.5;
283 if (
eta < -2) corr = corr*6;
284 if (
eta > 1.5 &&
eta < 2) {
286 corr += std::abs(450.0 - 45) / 80 * deltas;
288 corr += std::abs(pT - 45) / 80 * deltas;
290 if (
eta > 1.05 &&
eta < 1.5) {
292 corr += std::abs(450.0 - 45) / 40 * deltas;
294 corr += std::abs(pT - 45) / 40 * deltas;
301 corrections.push_back(corr*scale);
302 ATH_MSG_VERBOSE(
"High pT variation for pT "<<pT<<
" deltas "<<deltas<<
" final corr: "<<corr);
312 corr *= (0.5 * scale);
314 corrections.push_back(corr);
337 if(mu.ID.calib_pt == 0)
return CBpT;
338 if(mu.ME.calib_pt == 0)
return CBpT;
339 if(corrIDpT == 0)
return CBpT;
340 if(corrMEpT == 0)
return CBpT;
342 double chi2Nom = -999;
355 using TLV = ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double>>;
356 TLV tlv{mu.ID.calib_pt, mu.ID.eta, mu.ID.phi, mu.ID.mass};
358 if(tlv.P() == 0) parsID[4] = 1e12;
359 else parsID[4] = 1.0 / (tlv.P() * 1e3);
361 tlv.SetCoordinates(mu.ME.calib_pt, mu.ME.eta, mu.ME.phi, mu.ME.mass);
363 if(tlv.P() == 0) parsMS[4] = 1e12;
364 else parsMS[4] = 1.0 / (tlv.P() * 1e3);
372 tlv.SetCoordinates(corrIDpT, mu.ID.eta, mu.ID.phi, mu.ID.mass);
374 if(tlv.P() == 0) parsID[4] = 1e12;
375 else parsID[4] = 1.0 / (tlv.P() * 1e3);
377 tlv.SetCoordinates(corrMEpT, mu.ME.eta, mu.ME.phi, mu.ME.mass);
379 if(tlv.P() == 0) parsMS[4] = 1e12;
380 else parsMS[4] = 1.0 / (tlv.P() * 1e3);
382 SysCorrCode =
applyStatCombination(parsID, covID, parsMS, covMS, mu.CB.calib_charge, parsCBCorr, covCBCorr, chi2Nom);
386 double statCombPtNom = std::sin(parsCBNom[3]) / std::abs(parsCBNom[4]);
387 double statCombPtCorr = std::sin(parsCBCorr[3]) / std::abs(parsCBCorr[4]);
388 double corrCBpT = CBpT * (statCombPtCorr / statCombPtNom);
397 parsID[4] = std::abs(parsID[4]);
398 parsMS[4] = std::abs(parsMS[4]);
402 if (!matID.isInvertible()) {
410 if (!matMS.isInvertible()) {
417 Eigen::FullPivLU<
AmgSymMatrix(5)> matCB(weightID + weightMS);
418 if (!matCB.isInvertible()) {
422 covCB = matCB.inverse();
425 Eigen::FullPivLU<
AmgSymMatrix(5)> matSum(covID + covMS);
426 if (!matSum.isInvertible()) {
434 chi2 = diffPars.transpose() * invCovSum * diffPars;
437 parsCB = covCB * (weightID * parsID + weightMS * parsMS);
440 if (parsCB[2] >
M_PI)
441 parsCB[2] -= 2. *
M_PI;
442 else if (parsCB[2] < -
M_PI)
443 parsCB[2] += 2. *
M_PI;
452 return sys.find(systematic) != sys.end();
509 else if (!syst.
empty())
return StatusCode::FAILURE;
516 else if (!syst.
empty())
return StatusCode::FAILURE;
523 else if (!syst.
empty())
return StatusCode::FAILURE;
530 else if (!syst.
empty())
return StatusCode::FAILURE;
545 else if (!syst.
empty())
return StatusCode::FAILURE;
560 else if (!syst.
empty())
return StatusCode::FAILURE;
567 else if (!syst.
empty())
return StatusCode::FAILURE;
577 return StatusCode::SUCCESS;
Scalar eta() const
pseudorapidity method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define AmgSymMatrix(dim)
std::pair< std::vector< unsigned int >, bool > res
Return value from object correction CP tools.
@ Error
Some error happened during the object correction.
@ Ok
The correction was done successfully.
This module implements the central registry for handling systematic uncertainties with CP tools.
static SystematicRegistry & getInstance()
Get the singleton instance of the registry for the curren thread.
StatusCode registerSystematics(const IReentrantSystematicsTool &tool)
effects: register all the systematics from the tool
Class to wrap a set of SystematicVariations.
SystematicVariation getSystematicByBaseName(const std::string &basename) const
description: get the first systematic matching basename
bool empty() const
returns: whether this is an empty systematic, i.e.
double chi2(TH1 *h0, TH1 *h1)
Select isolated Photons, Electrons and Muons.
std::map< SagittaCorrection, std::shared_ptr< CalibContainer > > createSagittaCorrMap(DataYear dataYear, TrackType type, const std::string &recommendationPath, const std::string &correctionType)
static constexpr std::array< MCP::DataYear, 7 > dataYearList
setRcore setEtHad setFside pt
Basic object to cache all relevant information from the track.
const double eta
Value of the track-eta.
double calib_pt
Smeared track pt.
const TrackType type
Flag telling the code whether this is CB/ME/ID.