52 return StatusCode::FAILURE;
58 return StatusCode::FAILURE;
61 return StatusCode::SUCCESS;
71 double corrIDpT = mu.ID.calib_pt;
74 double corrMEpT = mu.ME.calib_pt;
77 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 else mu.CB.calib_pt = corrStatCombCBpT;
136 for(
const auto& corr: correction)
138 double originalPt =
pt;
141 ATH_MSG_DEBUG(
"CorrectForCharge - in pT: " << originalPt <<
" corrPt: " <<
pt <<
" applied saggita: " << corr);
170 std::vector<double> corrections;
179 corrections.push_back(corr);
191 ATH_MSG_ERROR(
"Sagitta correction is not applied to data, yet Eta dependant systematics are requested. This configuration is not supported");
206 corrections.push_back(corr);
218 corrections.push_back(corr);
228 if(
m_release.value().find(
"Recs2023") != std::string::npos) deltas = 1.2 * deltas;
229 else if(std::abs(
eta)>1.05) deltas = 1.5 * deltas;
231 double corr = deltas * scale;
234 corrections.push_back(corr);
248 double deltas = 0.00002;
253 corr += std::abs(450.0 - 45) * deltas;
255 corr += std::abs(pT - 45) * deltas;
258 if (
eta > 2 || (
eta > -2 &&
eta < -1.05)) {
260 corr += std::abs(450.0 - 45) / 100 * deltas;
262 corr += std::abs(pT - 45) / 100 * deltas;
266 corr += std::abs(450.0 - 45) / 200 * deltas;
268 corr += std::abs(pT - 45) / 200 * deltas;
271 if (
m_release.value().find(
"Recs2023") != std::string::npos) {
274 else if (
eta < -1.05) corr += 1.1*deltas;
275 else if (
eta > 0.5 ) corr += 0.8*deltas;
279 if (
eta > -2 &&
eta < -1.05) corr = corr*2.5;
280 if (
eta < -2) corr = corr*6;
281 if (
eta > 1.5 &&
eta < 2) {
283 corr += std::abs(450.0 - 45) / 80 * deltas;
285 corr += std::abs(pT - 45) / 80 * deltas;
287 if (
eta > 1.05 &&
eta < 1.5) {
289 corr += std::abs(450.0 - 45) / 40 * deltas;
291 corr += std::abs(pT - 45) / 40 * deltas;
298 corrections.push_back(corr*scale);
299 ATH_MSG_VERBOSE(
"High pT variation for pT "<<pT<<
" deltas "<<deltas<<
" final corr: "<<corr);
309 corr *= (0.5 * scale);
311 corrections.push_back(corr);
334 if(mu.ID.calib_pt == 0)
return CBpT;
335 if(mu.ME.calib_pt == 0)
return CBpT;
336 if(corrIDpT == 0)
return CBpT;
337 if(corrMEpT == 0)
return CBpT;
339 double chi2Nom = -999;
352 using TLV = ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double>>;
353 TLV tlv{mu.ID.calib_pt, mu.ID.eta, mu.ID.phi, mu.ID.mass};
355 if(tlv.P() == 0) parsID[4] = 1e12;
356 else parsID[4] = 1.0 / (tlv.P() * 1e3);
358 tlv.SetCoordinates(mu.ME.calib_pt, mu.ME.eta, mu.ME.phi, mu.ME.mass);
360 if(tlv.P() == 0) parsMS[4] = 1e12;
361 else parsMS[4] = 1.0 / (tlv.P() * 1e3);
369 tlv.SetCoordinates(corrIDpT, mu.ID.eta, mu.ID.phi, mu.ID.mass);
371 if(tlv.P() == 0) parsID[4] = 1e12;
372 else parsID[4] = 1.0 / (tlv.P() * 1e3);
374 tlv.SetCoordinates(corrMEpT, mu.ME.eta, mu.ME.phi, mu.ME.mass);
376 if(tlv.P() == 0) parsMS[4] = 1e12;
377 else parsMS[4] = 1.0 / (tlv.P() * 1e3);
379 SysCorrCode =
applyStatCombination(parsID, covID, parsMS, covMS, mu.CB.calib_charge, parsCBCorr, covCBCorr, chi2Nom);
383 double statCombPtNom = std::sin(parsCBNom[3]) / std::abs(parsCBNom[4]);
384 double statCombPtCorr = std::sin(parsCBCorr[3]) / std::abs(parsCBCorr[4]);
385 double corrCBpT = CBpT * (statCombPtCorr / statCombPtNom);
394 parsID[4] = std::abs(parsID[4]);
395 parsMS[4] = std::abs(parsMS[4]);
399 if (!matID.isInvertible()) {
407 if (!matMS.isInvertible()) {
414 Eigen::FullPivLU<
AmgSymMatrix(5)> matCB(weightID + weightMS);
415 if (!matCB.isInvertible()) {
419 covCB = matCB.inverse();
422 Eigen::FullPivLU<
AmgSymMatrix(5)> matSum(covID + covMS);
423 if (!matSum.isInvertible()) {
431 chi2 = diffPars.transpose() * invCovSum * diffPars;
434 parsCB = covCB * (weightID * parsID + weightMS * parsMS);
437 if (parsCB[2] >
M_PI)
438 parsCB[2] -= 2. *
M_PI;
439 else if (parsCB[2] < -
M_PI)
440 parsCB[2] += 2. *
M_PI;
449 return sys.find(systematic) != sys.end();
506 else if (!syst.
empty())
return StatusCode::FAILURE;
513 else if (!syst.
empty())
return StatusCode::FAILURE;
520 else if (!syst.
empty())
return StatusCode::FAILURE;
527 else if (!syst.
empty())
return StatusCode::FAILURE;
542 else if (!syst.
empty())
return StatusCode::FAILURE;
557 else if (!syst.
empty())
return StatusCode::FAILURE;
564 else if (!syst.
empty())
return StatusCode::FAILURE;
574 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.