14 #include "GaudiKernel/SystemOfUnits.h"
18 #include <unordered_map>
38 return StatusCode::SUCCESS;
45 return StatusCode::SUCCESS;
51 float distEtaTrk = 0.;
52 float energy_3phi[101] = {0.0};
53 float eta[101] = {0.0};
60 float etamaxcut = 0.158;
61 float phimaxcut = 0.1;
62 float signum_eta = 0.;
64 float sumETCellsLAr = 0.;
65 float eta0cut = 0.075;
66 float eta1cut = 0.0475;
67 float eta2cut = 0.075;
71 float phi2cut = 0.075;
72 float phi3cut = 0.075;
75 float etagran1 = 0.00315;
76 float etagran2 = 0.00415;
77 float sumETCellsHad1 = 0.;
78 float etahadcut = 0.2;
79 float phihadcut = 0.2;
87 constexpr
size_t numberOfEM_Layers{4};
88 constexpr
double invalidCoordinate{-11111.};
89 constexpr
double invalidCoordinateThreshold{-11110.};
90 std::array<double, numberOfEM_Layers> extrapolatedEta{};
91 std::array<double, numberOfEM_Layers> extrapolatedPhi{};
92 extrapolatedEta.fill(invalidCoordinate);
93 extrapolatedPhi.fill(invalidCoordinate);
97 std::unique_ptr<Trk::CaloExtension> uniqueExtension ;
99 trackIndex = orgTrack->
index();
104 Gaudi::Hive::currentContext(), *orgTrack);
105 caloExtension = uniqueExtension.get();
110 caloExtension = (*particleCache)[trackIndex];
111 ATH_MSG_VERBOSE(
"Getting element " << trackIndex <<
" from the particleCache");
112 if( not caloExtension ){
113 ATH_MSG_VERBOSE(
"Cache does not contain a calo extension -> Calculating with the a CaloExtensionTool" );
115 Gaudi::Hive::currentContext(), *orgTrack);
116 caloExtension = uniqueExtension.get();
119 if( not caloExtension){
120 ATH_MSG_DEBUG(
"extrapolation of leading track to calo surfaces failed : caloExtension is nullptr" );
121 return StatusCode::RECOVERABLE;
123 const std::vector<Trk::CurvilinearParameters>& clParametersVector = caloExtension->caloLayerIntersections();
124 if(clParametersVector.empty() ){
125 ATH_MSG_DEBUG(
"extrapolation of leading track to calo surfaces failed : caloLayerIntersection is empty" );
126 return StatusCode::RECOVERABLE;
138 if(
index < 0 )
continue;
139 extrapolatedEta[
index] =
cur.position().eta();
140 extrapolatedPhi[
index] =
cur.position().phi();
142 for (
size_t i = 0;
i < numberOfEM_Layers; ++
i) {
143 if ( extrapolatedEta[
i] < invalidCoordinateThreshold || extrapolatedPhi[
i] < invalidCoordinateThreshold ){
144 ATH_MSG_DEBUG(
"extrapolation of leading track to calo surfaces failed for sampling : " <<
i );
145 return StatusCode::SUCCESS;
150 std::bitset<200000> cellSeen{};
151 const std::unordered_map<int, int> samplingLookup{
152 {4,0}, {5,1}, {6,2}, {7,3}, {8,12},
153 {15, 12}, {16,13}, {17,14}, {18,12}, {19, 13}, {20,14}
155 const auto notFound{samplingLookup.end()};
157 std::vector<xAOD::CaloVertexedTopoCluster> vertexedClusterList = pTau.
vertexedClusters();
162 if (cell_links ==
nullptr) {
163 ATH_MSG_DEBUG(
"NO Cell links found for cluster with pT " << cluster.
pt());
168 for (; pCellIter != pCellIterE; ++pCellIter) {
169 double cellEta{}, cellPhi{}, cellET{};
175 cellPhi = vxCell.
phi();
176 cellEta = vxCell.
eta();
177 cellET = vxCell.
et();
179 cellPhi = pCell->
phi();
180 cellEta = pCell->
eta();
181 cellET = pCell->
et();
184 if (
const auto & pElement {samplingLookup.find(sampling)};pElement != notFound){
185 sampling = pElement->second;
188 if (sampling < 4)
i = sampling;
189 if (sampling == 12 || sampling == 13 || sampling == 14)
i = 3;
191 detEtaTrk = std::abs( cellEta - extrapolatedEta[
i] );
192 clEtaTrk = extrapolatedEta[
i];
193 distEtaTrk = cellEta - extrapolatedEta[
i];
194 if ((sampling == 0 && detEtaTrk < eta0cut && detPhiTrk < phi0cut) ||
195 (sampling == 1 && detEtaTrk < eta1cut && detPhiTrk < phi1cut) ||
196 (sampling == 2 && detEtaTrk < eta2cut && detPhiTrk < phi2cut) ||
197 (sampling == 3 && detEtaTrk < eta3cut && detPhiTrk < phi3cut)) {
198 sumETCellsLAr += cellET;
200 if (sampling == 12 && detEtaTrk < etahadcut && detPhiTrk < phihadcut) sumETCellsHad1 += cellET;
201 if (std::abs(cellEta) > 0.8 && std::abs(cellEta) <= 1.2 && (sampling == 13 || sampling == 14) && detEtaTrk < etahadcut && detPhiTrk < phihadcut) {
202 sumETCellsHad1 += cellET;
204 if (std::abs(pTau.
track(0)->
eta()) <= 1.7) {
205 if (sampling == 1 && detEtaTrk < etamaxcut && detPhiTrk <= phimaxcut) {
206 if ((std::abs(cellEta) < 1.37 || std::abs(cellEta) > 1.52) && std::abs(cellEta) < 1.85) {
207 if (std::abs(clEtaTrk) <= etacase1 && std::abs(cellEta) <= etacase1) {
208 n = 50 +
int(distEtaTrk / etagran1);
210 if (std::abs(clEtaTrk) <= etacase1 && std::abs(cellEta) > etacase1) {
211 n = 50 +
int(signum_eta * ((etacase1 - std::abs(clEtaTrk)) / etagran1 + (-etacase1 + std::abs(cellEta)) / etagran2));
213 energy_3phi[
n] = energy_3phi[
n] + cellET /
GeV;
214 eta[
n] = signum_eta * (clEtaTrk - cellEta);
224 if (std::abs(cellEta) <= etacase1) {
231 for (
int m1 = 0;
m1 < 101;
m1++) {
232 if ((energy_3phi[
m1] > Emax1)) {
233 Emax1 = energy_3phi[
m1];
237 for (
int m2 = 1;
m2 < 100;
m2++) {
239 if ((energy_3phi[
m2] > Emax2) && (energy_3phi[
m2] > energy_3phi[
m2 - 1]) && (energy_3phi[
m2] > energy_3phi[
m2 + 1])) {
240 Emax2 = energy_3phi[
m2];
244 if (std::abs(
eta[
max1]) >= etareg) {
254 ATH_MSG_DEBUG(
"retrieval of track summary value failed. Not filling electron veto variables for this one prong candidate");
255 return StatusCode::SUCCESS;
260 ATH_MSG_DEBUG(
"retrieval of track summary value failed. Not filling electron veto variables for this one prong candidate");
261 return StatusCode::SUCCESS;
266 ATH_MSG_DEBUG(
"retrieval of track summary value failed. Not filling electron veto variables for this one prong candidate");
267 return StatusCode::SUCCESS;
272 ATH_MSG_DEBUG(
"retrieval of track summary value failed. Not filling electron veto variables for this one prong candidate");
273 return StatusCode::SUCCESS;
276 float TRTratio = -9999.0;
277 if (TRTHits + TRTOutliers != 0) {
278 TRTratio =
float( TRTHTHits + TRTHTOutliers) /
float( TRTHits + TRTOutliers );
287 return StatusCode::SUCCESS;