13 #include "GaudiKernel/SystemOfUnits.h"
17 #include <unordered_map>
34 return StatusCode::SUCCESS;
41 return StatusCode::SUCCESS;
47 float distEtaTrk = 0.;
48 float energy_3phi[101] = {0.0};
49 float eta[101] = {0.0};
56 float etamaxcut = 0.158;
57 float phimaxcut = 0.1;
58 float signum_eta = 0.;
60 float sumETCellsLAr = 0.;
61 float eta0cut = 0.075;
62 float eta1cut = 0.0475;
63 float eta2cut = 0.075;
67 float phi2cut = 0.075;
68 float phi3cut = 0.075;
71 float etagran1 = 0.00315;
72 float etagran2 = 0.00415;
73 float sumETCellsHad1 = 0.;
74 float etahadcut = 0.2;
75 float phihadcut = 0.2;
83 constexpr
size_t numberOfEM_Layers{4};
84 constexpr
double invalidCoordinate{-11111.};
85 constexpr
double invalidCoordinateThreshold{-11110.};
86 std::array<double, numberOfEM_Layers> extrapolatedEta{};
87 std::array<double, numberOfEM_Layers> extrapolatedPhi{};
88 extrapolatedEta.fill(invalidCoordinate);
89 extrapolatedPhi.fill(invalidCoordinate);
93 std::unique_ptr<Trk::CaloExtension> uniqueExtension ;
95 trackIndex = orgTrack->
index();
100 Gaudi::Hive::currentContext(), *orgTrack);
101 caloExtension = uniqueExtension.get();
106 caloExtension = (*particleCache)[trackIndex];
107 ATH_MSG_VERBOSE(
"Getting element " << trackIndex <<
" from the particleCache");
108 if( not caloExtension ){
109 ATH_MSG_VERBOSE(
"Cache does not contain a calo extension -> Calculating with the a CaloExtensionTool" );
111 Gaudi::Hive::currentContext(), *orgTrack);
112 caloExtension = uniqueExtension.get();
115 if( not caloExtension){
116 ATH_MSG_DEBUG(
"extrapolation of leading track to calo surfaces failed : caloExtension is nullptr" );
117 return StatusCode::RECOVERABLE;
119 const std::vector<Trk::CurvilinearParameters>& clParametersVector = caloExtension->caloLayerIntersections();
120 if(clParametersVector.empty() ){
121 ATH_MSG_DEBUG(
"extrapolation of leading track to calo surfaces failed : caloLayerIntersection is empty" );
122 return StatusCode::RECOVERABLE;
134 if(
index < 0 )
continue;
135 extrapolatedEta[
index] =
cur.position().eta();
136 extrapolatedPhi[
index] =
cur.position().phi();
138 for (
size_t i = 0;
i < numberOfEM_Layers; ++
i) {
139 if ( extrapolatedEta[
i] < invalidCoordinateThreshold || extrapolatedPhi[
i] < invalidCoordinateThreshold ){
140 ATH_MSG_DEBUG(
"extrapolation of leading track to calo surfaces failed for sampling : " <<
i );
141 return StatusCode::SUCCESS;
146 std::bitset<200000> cellSeen{};
147 const std::unordered_map<int, int> samplingLookup{
148 {4,0}, {5,1}, {6,2}, {7,3}, {8,12},
149 {15, 12}, {16,13}, {17,14}, {18,12}, {19, 13}, {20,14}
151 const auto notFound{samplingLookup.end()};
153 std::vector<xAOD::CaloVertexedTopoCluster> vertexedClusterList = pTau.
vertexedClusters();
158 if (cell_links ==
nullptr) {
159 ATH_MSG_DEBUG(
"NO Cell links found for cluster with pT " << cluster.
pt());
164 for (; pCellIter != pCellIterE; ++pCellIter) {
165 double cellEta{}, cellPhi{}, cellET{};
171 cellPhi = vxCell.
phi();
172 cellEta = vxCell.
eta();
173 cellET = vxCell.
et();
175 cellPhi = pCell->
phi();
176 cellEta = pCell->
eta();
177 cellET = pCell->
et();
180 if (
const auto & pElement {samplingLookup.find(sampling)};pElement != notFound){
181 sampling = pElement->second;
184 if (sampling < 4)
i = sampling;
185 if (sampling == 12 || sampling == 13 || sampling == 14)
i = 3;
187 detEtaTrk = std::abs( cellEta - extrapolatedEta[
i] );
188 clEtaTrk = extrapolatedEta[
i];
189 distEtaTrk = cellEta - extrapolatedEta[
i];
190 if ((sampling == 0 && detEtaTrk < eta0cut && detPhiTrk < phi0cut) ||
191 (sampling == 1 && detEtaTrk < eta1cut && detPhiTrk < phi1cut) ||
192 (sampling == 2 && detEtaTrk < eta2cut && detPhiTrk < phi2cut) ||
193 (sampling == 3 && detEtaTrk < eta3cut && detPhiTrk < phi3cut)) {
194 sumETCellsLAr += cellET;
196 if (sampling == 12 && detEtaTrk < etahadcut && detPhiTrk < phihadcut) sumETCellsHad1 += cellET;
197 if (std::abs(cellEta) > 0.8 && std::abs(cellEta) <= 1.2 && (sampling == 13 || sampling == 14) && detEtaTrk < etahadcut && detPhiTrk < phihadcut) {
198 sumETCellsHad1 += cellET;
200 if (std::abs(pTau.
track(0)->
eta()) <= 1.7) {
201 if (sampling == 1 && detEtaTrk < etamaxcut && detPhiTrk <= phimaxcut) {
202 if ((std::abs(cellEta) < 1.37 || std::abs(cellEta) > 1.52) && std::abs(cellEta) < 1.85) {
203 if (std::abs(clEtaTrk) <= etacase1 && std::abs(cellEta) <= etacase1) {
204 n = 50 +
int(distEtaTrk / etagran1);
206 if (std::abs(clEtaTrk) <= etacase1 && std::abs(cellEta) > etacase1) {
207 n = 50 +
int(signum_eta * ((etacase1 - std::abs(clEtaTrk)) / etagran1 + (-etacase1 + std::abs(cellEta)) / etagran2));
209 energy_3phi[
n] = energy_3phi[
n] + cellET /
GeV;
210 eta[
n] = signum_eta * (clEtaTrk - cellEta);
220 if (std::abs(cellEta) <= etacase1) {
227 for (
int m1 = 0;
m1 < 101;
m1++) {
228 if ((energy_3phi[
m1] > Emax1)) {
229 Emax1 = energy_3phi[
m1];
233 for (
int m2 = 1;
m2 < 100;
m2++) {
235 if ((energy_3phi[
m2] > Emax2) && (energy_3phi[
m2] > energy_3phi[
m2 - 1]) && (energy_3phi[
m2] > energy_3phi[
m2 + 1])) {
236 Emax2 = energy_3phi[
m2];
240 if (std::abs(
eta[
max1]) >= etareg) {
250 ATH_MSG_DEBUG(
"retrieval of track summary value failed. Not filling electron veto variables for this one prong candidate");
251 return StatusCode::SUCCESS;
256 ATH_MSG_DEBUG(
"retrieval of track summary value failed. Not filling electron veto variables for this one prong candidate");
257 return StatusCode::SUCCESS;
262 ATH_MSG_DEBUG(
"retrieval of track summary value failed. Not filling electron veto variables for this one prong candidate");
263 return StatusCode::SUCCESS;
268 ATH_MSG_DEBUG(
"retrieval of track summary value failed. Not filling electron veto variables for this one prong candidate");
269 return StatusCode::SUCCESS;
272 float TRTratio = -9999.0;
273 if (TRTHits + TRTOutliers != 0) {
274 TRTratio =
float( TRTHTHits + TRTHTOutliers) /
float( TRTHits + TRTOutliers );
283 return StatusCode::SUCCESS;