14 #include "GaudiKernel/SystemOfUnits.h"
18 #include <unordered_map>
39 return StatusCode::SUCCESS;
46 return StatusCode::SUCCESS;
52 float distEtaTrk = 0.;
53 float energy_3phi[101] = {0.0};
54 float eta[101] = {0.0};
61 float etamaxcut = 0.158;
62 float phimaxcut = 0.1;
63 float signum_eta = 0.;
65 float sumETCellsLAr = 0.;
66 float eta0cut = 0.075;
67 float eta1cut = 0.0475;
68 float eta2cut = 0.075;
72 float phi2cut = 0.075;
73 float phi3cut = 0.075;
76 float etagran1 = 0.00315;
77 float etagran2 = 0.00415;
78 float sumETCellsHad1 = 0.;
79 float etahadcut = 0.2;
80 float phihadcut = 0.2;
88 constexpr
size_t numberOfEM_Layers{4};
89 constexpr
double invalidCoordinate{-11111.};
90 constexpr
double invalidCoordinateThreshold{-11110.};
91 std::array<double, numberOfEM_Layers> extrapolatedEta{};
92 std::array<double, numberOfEM_Layers> extrapolatedPhi{};
93 extrapolatedEta.fill(invalidCoordinate);
94 extrapolatedPhi.fill(invalidCoordinate);
98 std::unique_ptr<Trk::CaloExtension> uniqueExtension ;
100 trackIndex = orgTrack->
index();
105 Gaudi::Hive::currentContext(), *orgTrack);
106 caloExtension = uniqueExtension.get();
111 caloExtension = (*particleCache)[trackIndex];
112 ATH_MSG_VERBOSE(
"Getting element " << trackIndex <<
" from the particleCache");
113 if( not caloExtension ){
114 ATH_MSG_VERBOSE(
"Cache does not contain a calo extension -> Calculating with the a CaloExtensionTool" );
116 Gaudi::Hive::currentContext(), *orgTrack);
117 caloExtension = uniqueExtension.get();
120 if( not caloExtension){
121 ATH_MSG_DEBUG(
"extrapolation of leading track to calo surfaces failed : caloExtension is nullptr" );
122 return StatusCode::RECOVERABLE;
124 const std::vector<Trk::CurvilinearParameters>& clParametersVector = caloExtension->caloLayerIntersections();
125 if(clParametersVector.empty() ){
126 ATH_MSG_DEBUG(
"extrapolation of leading track to calo surfaces failed : caloLayerIntersection is empty" );
127 return StatusCode::RECOVERABLE;
139 if(
index < 0 )
continue;
140 extrapolatedEta[
index] =
cur.position().eta();
141 extrapolatedPhi[
index] =
cur.position().phi();
143 for (
size_t i = 0;
i < numberOfEM_Layers; ++
i) {
144 if ( extrapolatedEta[
i] < invalidCoordinateThreshold || extrapolatedPhi[
i] < invalidCoordinateThreshold ){
145 ATH_MSG_DEBUG(
"extrapolation of leading track to calo surfaces failed for sampling : " <<
i );
146 return StatusCode::SUCCESS;
151 std::bitset<200000> cellSeen{};
152 const std::unordered_map<int, int> samplingLookup{
153 {4,0}, {5,1}, {6,2}, {7,3}, {8,12},
154 {15, 12}, {16,13}, {17,14}, {18,12}, {19, 13}, {20,14}
156 const auto notFound{samplingLookup.end()};
158 std::vector<xAOD::CaloVertexedTopoCluster> vertexedClusterList = pTau.
vertexedClusters();
163 if (cell_links ==
nullptr) {
164 ATH_MSG_DEBUG(
"NO Cell links found for cluster with pT " << cluster.
pt());
169 for (; pCellIter != pCellIterE; ++pCellIter) {
170 double cellEta{}, cellPhi{}, cellET{};
176 cellPhi = vxCell.
phi();
177 cellEta = vxCell.
eta();
178 cellET = vxCell.
et();
180 cellPhi = pCell->
phi();
181 cellEta = pCell->
eta();
182 cellET = pCell->
et();
185 if (
const auto & pElement {samplingLookup.find(sampling)};pElement != notFound){
186 sampling = pElement->second;
189 if (sampling < 4)
i = sampling;
190 if (sampling == 12 || sampling == 13 || sampling == 14)
i = 3;
192 detEtaTrk = std::abs( cellEta - extrapolatedEta[
i] );
193 clEtaTrk = extrapolatedEta[
i];
194 distEtaTrk = cellEta - extrapolatedEta[
i];
195 if ((sampling == 0 && detEtaTrk < eta0cut && detPhiTrk < phi0cut) ||
196 (sampling == 1 && detEtaTrk < eta1cut && detPhiTrk < phi1cut) ||
197 (sampling == 2 && detEtaTrk < eta2cut && detPhiTrk < phi2cut) ||
198 (sampling == 3 && detEtaTrk < eta3cut && detPhiTrk < phi3cut)) {
199 sumETCellsLAr += cellET;
201 if (sampling == 12 && detEtaTrk < etahadcut && detPhiTrk < phihadcut) sumETCellsHad1 += cellET;
202 if (std::abs(cellEta) > 0.8 && std::abs(cellEta) <= 1.2 && (sampling == 13 || sampling == 14) && detEtaTrk < etahadcut && detPhiTrk < phihadcut) {
203 sumETCellsHad1 += cellET;
205 if (std::abs(pTau.
track(0)->
eta()) <= 1.7) {
206 if (sampling == 1 && detEtaTrk < etamaxcut && detPhiTrk <= phimaxcut) {
207 if ((std::abs(cellEta) < 1.37 || std::abs(cellEta) > 1.52) && std::abs(cellEta) < 1.85) {
208 if (std::abs(clEtaTrk) <= etacase1 && std::abs(cellEta) <= etacase1) {
209 n = 50 +
int(distEtaTrk / etagran1);
211 if (std::abs(clEtaTrk) <= etacase1 && std::abs(cellEta) > etacase1) {
212 n = 50 +
int(signum_eta * ((etacase1 - std::abs(clEtaTrk)) / etagran1 + (-etacase1 + std::abs(cellEta)) / etagran2));
214 energy_3phi[
n] = energy_3phi[
n] + cellET /
GeV;
215 eta[
n] = signum_eta * (clEtaTrk - cellEta);
225 if (std::abs(cellEta) <= etacase1) {
232 for (
int m1 = 0;
m1 < 101;
m1++) {
233 if ((energy_3phi[
m1] > Emax1)) {
234 Emax1 = energy_3phi[
m1];
238 for (
int m2 = 1;
m2 < 100;
m2++) {
240 if ((energy_3phi[
m2] > Emax2) && (energy_3phi[
m2] > energy_3phi[
m2 - 1]) && (energy_3phi[
m2] > energy_3phi[
m2 + 1])) {
241 Emax2 = energy_3phi[
m2];
245 if (std::abs(
eta[
max1]) >= etareg) {
255 ATH_MSG_DEBUG(
"retrieval of track summary value failed. Not filling electron veto variables for this one prong candidate");
256 return StatusCode::SUCCESS;
261 ATH_MSG_DEBUG(
"retrieval of track summary value failed. Not filling electron veto variables for this one prong candidate");
262 return StatusCode::SUCCESS;
267 ATH_MSG_DEBUG(
"retrieval of track summary value failed. Not filling electron veto variables for this one prong candidate");
268 return StatusCode::SUCCESS;
273 ATH_MSG_DEBUG(
"retrieval of track summary value failed. Not filling electron veto variables for this one prong candidate");
274 return StatusCode::SUCCESS;
277 float TRTratio = -9999.0;
278 if (TRTHits + TRTOutliers != 0) {
279 TRTratio =
float( TRTHTHits + TRTHTOutliers) /
float( TRTHits + TRTOutliers );
288 return StatusCode::SUCCESS;