161 << middleParameters.
position().phi() <<
" Eta = " << middleParameters.
position().eta());
163 std::unique_ptr<CaloEnergy> caloEnergy;
166 const double eta = middleParameters.
position().eta();
167 const double phi = middleParameters.
position().phi();
168 const double etaEM = innerParameters ? innerParameters->
position().eta() :
eta;
169 const double phiEM = innerParameters ? innerParameters->
position().phi() :
phi;
170 const double etaHad = outerParameters ? outerParameters->
position().eta() :
eta;
171 const double phiHad = outerParameters ? outerParameters->
position().phi() :
phi;
172 std::unique_ptr<CaloMeas> caloMeas{
m_caloMeasTool->energyMeasurement(ctx, etaEM, phiEM, etaHad, phiHad)};
182 if (caloEnergy->deltaE() > 8. * Units::GeV && middleParameters.
momentum().mag() < 500. * Units::GeV)
183 ATH_MSG_WARNING(
" high parametrized energy loss: " << caloEnergy->deltaE() / Units::GeV <<
" GeV"
184 <<
" for p " << middleParameters.
momentum().mag() / Units::GeV
186 <<
" eta " << middleParameters.
position().eta());
189 std::bitset<Trk::MaterialEffectsBase::NumberOfMaterialEffectsTypes> typePattern(0);
195 std::unique_ptr<Trk::TrackParameters> middle_clone = middleParameters.
uniqueClone();
198 const double dE = caloEnergy->deltaE() / Units::GeV;
199 const double sigPlus_dE = caloEnergy->sigmaPlusDeltaE() / Units::GeV;
200 const double sigMinus_dE = caloEnergy->sigmaMinusDeltaE() / Units::GeV;
201 const double sig_dE = caloEnergy->sigmaDeltaE() / Units::GeV;
203 auto materialEffects =
204 std::make_unique<Trk::MaterialEffectsOnTrack>(
206 std::move(caloEnergy),
207 middle_clone->associatedSurface(),
211 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> pattern(0);
216 std::string eLossTypeStr =
" no Calo !!";
226 <<
" trackStateOnSurface with"
227 <<
" momentum =" << std::setw(6) << std::setprecision(1) << middleParameters.
momentum().mag() / Units::GeV
228 <<
" phi =" << std::setw(6) << std::setprecision(3) << middleParameters.
position().phi()
229 <<
" eta =" << std::setw(6) << std::setprecision(3) << middleParameters.
position().eta()
230 <<
". CaloEnergy: deltaE = " << std::setw(8) << std::setprecision(3) << dE
231 <<
" +" << std::setw(5) << std::setprecision(3) << sigPlus_dE <<
" -"
232 << std::setw(5) << std::setprecision(3) << sigMinus_dE <<
" (" << std::setw(5)
233 << std::setprecision(3) << sig_dE <<
") GeV, CaloEnergy::Type " << eLossTypeStr);
235 return std::make_unique<Trk::TrackStateOnSurface>(
236 nullptr, std::move(middle_clone), std::move(materialEffects), pattern);
244 std::unique_ptr<CaloEnergy> caloParamMean{
m_caloParamTool->meanParametrizedEnergy(trackMomentum,
eta,
phi)};
246 std::unique_ptr<CaloEnergy> caloParamMop{
m_caloParamTool->mopParametrizedEnergy(trackMomentum,
eta,
phi)};
248 std::unique_ptr<CaloEnergy> caloParamMip{
m_caloParamTool->meanParametrizedEnergy(10. * Units::GeV,
eta,
phi)};
257 double MopLoss = std::abs(caloParamMop->deltaE());
259 double MopError = mopPeak->sigmaDeltaE();
270 double MaterialCorrection =
InertMaterial * MopLossCorrected;
285 double ForwardHECCorrection = 0.;
287 ForwardHECCorrection = (1. - LArHECMeasurementMaterial) * HECMaterial * MopLossCorrected;
290 double TotalMeasuredEnergy = TileEnergy + EmEnergy + LArHECEnergy;
292 ATH_MSG_VERBOSE(
"Energy Deposition:Tile= " << TileEnergy / Units::GeV <<
",LArHEC= " << LArHECEnergy / Units::GeV
293 <<
",EM= " << EmEnergy / Units::GeV <<
" ForwardHECCorrection "
294 << ForwardHECCorrection / Units::GeV <<
" HECMaterial " << HECMaterial
295 <<
" MopLossCorrected " << MopLossCorrected / Units::GeV);
301 if (std::abs(
eta) < 1.4) {
302 if (LArHECEnergy + TileEnergy > 0.1 * MopLoss * HECMaterial) bHEC =
true;
303 }
else if (std::abs(
eta) > 1.8) {
304 if (LArHECEnergy + TileEnergy > 0.2 * MopLoss * HECMaterial) bHEC =
true;
306 if (LArHECEnergy + TileEnergy > 0.25 * MopLoss * HECMaterial) bHEC =
true;
308 if (EmEnergy > 0.5 * MopLoss * EmMaterial) bEM =
true;
319 double MeasCorrected = TotalMeasuredEnergy + MaterialCorrection;
324 const double IonizationLoss = (1. / 1.4) * std::abs(caloParamMip->deltaE());
326 double eOverMipCorrectionEm = 0.;
327 double eOverMipCorrectionHEC = 0.;
332 const double emipEM = 0.78;
333 eOverMipCorrectionEm = -(1. / emipEM - 1.) * IonizationLoss * EmMaterial * LArEmMeasurementMaterial;
334 if (EmEnergy + eOverMipCorrectionEm < 0.) eOverMipCorrectionEm = 0.;
337 const double emipTile = 0.86;
338 const double emipLAr = 0.94;
339 const double HECEnergy = TileEnergy + LArHECEnergy;
340 const double eOverMipCorrectionTile =
341 -(1. / emipTile - 1.) * TileEnergy / HECEnergy * IonizationLoss * HECMaterial * TileMeasurementMaterial;
342 const double eOverMipCorrectionLAr =
343 -(1. / emipLAr - 1.) * LArHECEnergy / HECEnergy * IonizationLoss * HECMaterial * LArHECMeasurementMaterial;
344 eOverMipCorrectionHEC = eOverMipCorrectionTile + eOverMipCorrectionLAr;
345 if (LArHECEnergy + TileEnergy + eOverMipCorrectionHEC < 0.) eOverMipCorrectionHEC = 0.;
347 const double eOverMipCorrection = eOverMipCorrectionEm + eOverMipCorrectionHEC;
351 constexpr double fix1FromPeter[26] = {0.424104, 0.479637, 0.483419, 0.490242, 0.52806, 0.573582, 0.822098,
352 0.767301, 0.809919, 0.658745, 0.157187, 0.413214, 0.771074, 0.61815,
353 0.350113, 0.322785, 0.479294, 0.806183, 0.822161, 0.757731, -0.0857186,
354 -0.0992693, -0.0492252, 0.0650174, 0.261538, 0.360413};
356 constexpr double fix2FromPeter[26] = {-0.647703, -0.303498, -0.268645, -0.261292, -0.260152, -0.269253, -0.266212,
357 -0.240837, -0.130172, -0.111638, -0.329423, -0.321011, -0.346050, -0.305592,
358 -0.313293, -0.317111, -0.428393, -0.524839, -0.599547, -0.464013, -0.159663,
359 -0.140879, -0.0975618, 0.0225352, 0.0701925, -0.24778};
360 int ieta =
static_cast<int>(std::abs(
eta) / 0.10);
361 if (ieta > 25) ieta = 25;
362 double FinalMeasuredEnergy = MeasCorrected + eOverMipCorrection + (fix1FromPeter[ieta] + fix2FromPeter[ieta]) * Units::GeV;
364 ATH_MSG_VERBOSE(
"Sum of cells " << (TileEnergy + EmEnergy + LArHECEnergy) / Units::GeV <<
" Total energy deposition "
365 << TotalMeasuredEnergy / Units::GeV <<
" corrected energy deposition " << MeasCorrected / Units::GeV
366 <<
" e/mip corre " << FinalMeasuredEnergy / Units::GeV << std::endl
367 <<
"\nFinal Energy Measurement = "
368 << FinalMeasuredEnergy / Units::GeV
371 <<
"\nMop Energy Deposition = " << MopLoss / Units::GeV <<
" +- "
372 << MopError / Units::GeV
378 <<
"Final Meas = " << FinalMeasuredEnergy / Units::GeV <<
" Mop Dep = " << MopLoss / Units::GeV
379 <<
" +- " << MopError / Units::GeV);
383 const double sinTheta = 1. / std::cosh(
eta);
384 const double pT = trackMomentum * sinTheta * Units::MeV;
386 constexpr double OneOver85 = 1. / 85;
387 constexpr double FifteenGeV = 15. * Units::GeV;
388 const double EmCut =
m_emMinEnergy + OneOver85 * (pT - FifteenGeV);
399 nTracks = inner.first;
401 if (pT < 100. * Units::GeV && nTracks >
m_maxNTracksIso) PassCut =
false;
404 ATH_MSG_VERBOSE(
"pT= " << pT / Units::GeV <<
",HECIso= " << HECIso / Units::GeV <<
",EmIso= " << EmIso / Units::GeV
405 <<
", nTracks= " << nTracks <<
",PassCut= " << PassCut);
408 std::unique_ptr<CaloEnergy> caloEnergy;
412 if (FinalMeasuredEnergy < MopLoss + 2. * MopError && FinalMeasuredEnergy >
m_minFinalEnergy) {
414 caloEnergy.swap(mopPeak);
415 }
else if (PassCut) {
420 ATH_MSG_VERBOSE(
" start Tail and FSR treatment: Et in e.m. " << EmEnergy * sinTheta / Units::GeV <<
" F1 ratio " << F1);
423 double FinalEnergyErrorPlus = 0.50 * std::sqrt(FinalMeasuredEnergy / Units::GeV) * Units::GeV;
424 double FinalEnergyErrorMinus = FinalEnergyErrorPlus;
427 if (LArHECEnergy > 1. * Units::GeV) {
428 FinalEnergyErrorMinus = FinalEnergyErrorPlus = 0.50 * std::sqrt(FinalMeasuredEnergy / Units::GeV) * Units::GeV;
430 double FinalEnergyError = 0.5 * (FinalEnergyErrorMinus + FinalEnergyErrorPlus);
432 caloEnergy = std::make_unique<CaloEnergy>(FinalMeasuredEnergy, FinalEnergyError, FinalEnergyErrorMinus,
433 FinalEnergyErrorPlus, lossType);
438 double FinalMeasuredEnergyNoEm = FinalMeasuredEnergy - EmEnergy + MopLossEm;
441 ATH_MSG_VERBOSE(
" CaloEnergy FSR : EmEnergy " << EmEnergy <<
" FinalMeasuredEnergy " << FinalMeasuredEnergy
442 <<
" MopLossEm " << MopLossEm <<
" MopErrorEm " << MopErrorEm
443 <<
" FinalMeasuredEnergyNoEm " << FinalMeasuredEnergyNoEm);
444 if (FinalMeasuredEnergyNoEm < MopLoss + 2. * MopError) {
450 std::make_unique<CaloEnergy>(caloParamMop->deltaE(), caloParamMop->sigmaDeltaE(),
451 caloParamMop->sigmaMinusDeltaE(), caloParamMop->sigmaPlusDeltaE(), lossType);
455 std::make_unique<CaloEnergy>(caloParamMean->deltaE(), caloParamMean->sigmaDeltaE(),
456 caloParamMean->sigmaMinusDeltaE(), caloParamMean->sigmaPlusDeltaE(), lossType);
458 ATH_MSG_VERBOSE(
" CaloEnergy FSR : Small deposit, FinalMeasuredEnergyNoEm " << FinalMeasuredEnergyNoEm
459 <<
" using Eloss " << caloEnergy->deltaE());
464 double FinalEnergyErrorNoEm = 0.50 * std::sqrt(FinalMeasuredEnergyNoEm / Units::GeV) * Units::GeV;
465 FinalEnergyErrorNoEm = std::hypot(FinalEnergyErrorNoEm, MopErrorEm);
466 caloEnergy = std::make_unique<CaloEnergy>(FinalMeasuredEnergyNoEm, FinalEnergyErrorNoEm, FinalEnergyErrorNoEm,
467 FinalEnergyErrorNoEm, lossType);
468 ATH_MSG_VERBOSE(
" CaloEnergy FSR : Large deposit, FinalMeasuredEnergyNoEm " << FinalMeasuredEnergyNoEm);
475 caloEnergy = std::make_unique<CaloEnergy>(caloParamMop->deltaE(), caloParamMop->sigmaDeltaE(),
476 caloParamMop->sigmaMinusDeltaE(), caloParamMop->sigmaPlusDeltaE(), lossType);
479 caloEnergy = std::make_unique<CaloEnergy>(caloParamMean->deltaE(), caloParamMean->sigmaDeltaE(),
480 caloParamMean->sigmaMinusDeltaE(), caloParamMean->sigmaPlusDeltaE(), lossType);
484 caloEnergy->set_fsrCandidateEnergy(MopLossEm);
532 constexpr double p1[5] = {0.4259894875, -0.1249762550, 0.03984243700, -0.006298287635, 0.001511162253};
533 constexpr double q1[5] = {1.0, -0.3388260629, 0.09594393323, -0.01608042283, 0.003778942063};
535 constexpr double p2[5] = {0.1788541609, 0.1173957403, 0.01488850518, -0.001394989411, 0.0001283617211};
536 constexpr double q2[5] = {1.0, 0.7428795082, 0.3153932961, 0.06694219548, 0.008790609714};
538 constexpr double p3[5] = {0.1788544503, 0.09359161662, 0.006325387654, 0.00006611667319, -0.000002031049101};
539 constexpr double q3[5] = {1.0, 0.6097809921, 0.2560616665, 0.04746722384, 0.006957301675};
541 constexpr double p4[5] = {0.9874054407, 118.6723273, 849.2794360, -743.7792444, 427.0262186};
542 constexpr double q4[5] = {1.0, 106.8615961, 337.6496214, 2016.712389, 1597.063511};
544 constexpr double p5[5] = {1.003675074, 167.5702434, 4789.711289, 21217.86767, -22324.94910};
545 constexpr double q5[5] = {1.0, 156.9424537, 3745.310488, 9834.698876, 66924.28357};
547 constexpr double p6[5] = {1.000827619, 664.9143136, 62972.92665, 475554.6998, -5743609.109};
548 constexpr double q6[5] = {1.0, 651.4101098, 56974.73333, 165917.4725, -2815759.939};
550 constexpr double a1[3] = {0.04166666667, -0.01996527778, 0.02709538966};
552 constexpr double a2[2] = {-1.845568670, -4.284640743};
554 if (sigma <= 0)
return 0.;
555 double v = (
x - mpv) / sigma;
556 double u, ue, us, den;
559 if (u < 1e-10)
return 0.0;
560 ue = std::exp(-1 / u);
562 den = 0.3989422803 * (ue / us) * (1 + (a1[0] + (a1[1] + a1[2] * u) * u) * u);
564 u = std::exp(-v - 1);
565 den = exp(-u) * std::sqrt(u) * (p1[0] + (p1[1] + (p1[2] + (p1[3] + p1[4] * v) * v) * v) * v) /
566 (q1[0] + (q1[1] + (q1[2] + (q1[3] + q1[4] * v) * v) * v) * v);
568 den = (p2[0] + (p2[1] + (p2[2] + (p2[3] + p2[4] * v) * v) * v) * v) /
569 (q2[0] + (q2[1] + (q2[2] + (q2[3] + q2[4] * v) * v) * v) * v);
571 den = (p3[0] + (p3[1] + (p3[2] + (p3[3] + p3[4] * v) * v) * v) * v) /
572 (q3[0] + (q3[1] + (q3[2] + (q3[3] + q3[4] * v) * v) * v) * v);
575 den = u * u * (p4[0] + (p4[1] + (p4[2] + (p4[3] + p4[4] * u) * u) * u) * u) /
576 (q4[0] + (q4[1] + (q4[2] + (q4[3] + q4[4] * u) * u) * u) * u);
579 den = u * u * (p5[0] + (p5[1] + (p5[2] + (p5[3] + p5[4] * u) * u) * u) * u) /
580 (q5[0] + (q5[1] + (q5[2] + (q5[3] + q5[4] * u) * u) * u) * u);
581 }
else if (v < 300) {
583 den = u * u * (p6[0] + (p6[1] + (p6[2] + (p6[3] + p6[4] * u) * u) * u) * u) /
584 (q6[0] + (q6[1] + (q6[2] + (q6[3] + q6[4] * u) * u) * u) * u);
586 u = 1 / (v - v * log(v) / (v + 1));
587 den = u * u * (1 + (a2[0] + a2[1] * u) * u);
589 if (!norm)
return den;