69 const EventContext& ctx)
const {
71 return StatusCode::SUCCESS;
76 float sumETCellsLAr = 0.;
77 float eta0cut = 0.075;
78 float eta1cut = 0.0475;
79 float eta2cut = 0.075;
83 float phi2cut = 0.075;
84 float phi3cut = 0.075;
92 constexpr size_t numberOfEM_Layers{4};
93 constexpr double invalidCoordinate{-11111.};
94 constexpr double invalidCoordinateThreshold{-11110.};
95 std::array<double, numberOfEM_Layers> extrapolatedEta{};
96 std::array<double, numberOfEM_Layers> extrapolatedPhi{};
97 extrapolatedEta.fill(invalidCoordinate);
98 extrapolatedPhi.fill(invalidCoordinate);
101 trackIndex = orgTrack->index();
106 std::unique_ptr<Trk::CaloExtension> uniqueExtension ;
111 caloExtension = uniqueExtension.get();
116 caloExtension = (*particleCache)[trackIndex];
117 ATH_MSG_VERBOSE(
"Getting element " << trackIndex <<
" from the particleCache");
118 if( not caloExtension ){
119 ATH_MSG_VERBOSE(
"Cache does not contain a calo extension -> Calculating with the a CaloExtensionTool" );
121 caloExtension = uniqueExtension.get();
124 if( not caloExtension){
125 ATH_MSG_DEBUG(
"extrapolation of leading track to calo surfaces failed : caloExtension is nullptr" );
126 return StatusCode::RECOVERABLE;
128 const std::vector<Trk::CurvilinearParameters>& clParametersVector = caloExtension->
caloLayerIntersections();
129 if(clParametersVector.empty() ){
130 ATH_MSG_DEBUG(
"extrapolation of leading track to calo surfaces failed : caloLayerIntersection is empty" );
131 return StatusCode::RECOVERABLE;
139 if( sample == CaloSampling::PreSamplerE || sample == CaloSampling::PreSamplerB )
index = 0;
140 else if( sample == CaloSampling::EME1 || sample == CaloSampling::EMB1 )
index = 1;
141 else if( sample == CaloSampling::EME2 || sample == CaloSampling::EMB2 )
index = 2;
142 else if( sample == CaloSampling::EME3 || sample == CaloSampling::EMB3 )
index = 3;
143 if(
index < 0 )
continue;
144 extrapolatedEta[
index] = cur.position().eta();
145 extrapolatedPhi[
index] = cur.position().phi();
150 unsigned int lastMeasIdx = 0;
152 ATH_MSG_ERROR(
"TrackParticle has no last measurement parameters");
153 return StatusCode::FAILURE;
156 Acts::Vector3 lastPos{orgTrack->
parameterX(lastMeasIdx),
163 Acts::BoundVector lastBoundParams = Acts::BoundVector::Zero();
164 lastBoundParams[Acts::eBoundPhi] = lastMom.phi();
165 lastBoundParams[Acts::eBoundTheta] = lastMom.theta();
166 lastBoundParams[Acts::eBoundQOverP] = orgTrack->
charge() / lastMom.norm();
168 std::shared_ptr<const Acts::Surface> lastSurface = Acts::CurvilinearSurface(lastPos, lastMom.normalized()).planeSurface()->getSharedPtr();
170 Acts::BoundTrackParameters boundPars{
171 std::move(lastSurface),
174 Acts::ParticleHypothesis::pion()
177 Acts::Result<std::pair<std::vector<Acts::detail::Step>, Acts::RecordedMaterial>> result =
m_extrapolationTool.get()->propagationSteps(ctx, boundPars);
180 ATH_MSG_WARNING(
"Error during extrapolation: " << result.error().message());
181 return StatusCode::RECOVERABLE;
184 const auto &[steps, _] = result.value();
186 for(
const auto &step : steps) {
188 if( step.surface ==
nullptr || step.surface->geometryId().sensitive() == 0 ) {
192 Acts::GeometryIdentifier thisGeoID = step.geoID;
197 const auto &p = step.position;
203 if( layer.find(
"PreSampler") != std::string::npos)
index = 0;
204 else if( (layer.find(
"EME1") != std::string::npos) || (layer.find(
"EMB1") != std::string::npos) )
index = 1;
205 else if( (layer.find(
"EME2") != std::string::npos) || (layer.find(
"EMB2") != std::string::npos) )
index = 2;
206 else if( (layer.find(
"EME3") != std::string::npos) || (layer.find(
"EMB3") != std::string::npos) )
index = 3;
208 if(
index < 0 )
continue;
210 extrapolatedEta[
index] = Acts::VectorHelpers::eta(p);
211 extrapolatedPhi[
index] = Acts::VectorHelpers::phi(p);
218 for (
size_t i = 0; i < numberOfEM_Layers; ++i) {
219 if ( extrapolatedEta[i] < invalidCoordinateThreshold || extrapolatedPhi[i] < invalidCoordinateThreshold ){
220 ATH_MSG_DEBUG(
"extrapolation of leading track to calo surfaces failed for sampling : " << i );
221 return StatusCode::SUCCESS;
228 std::bitset<200000> cellSeen{};
229 const std::unordered_map<int, int> samplingLookup{
230 {4,0}, {5,1}, {6,2}, {7,3}, {8,12},
231 {15, 12}, {16,13}, {17,14}, {18,12}, {19, 13}, {20,14}
233 const auto notFound{samplingLookup.end()};
235 std::vector<xAOD::CaloVertexedTopoCluster> vertexedClusterList = pTau.
vertexedClusters();
240 if (cell_links ==
nullptr) {
241 ATH_MSG_DEBUG(
"NO Cell links found for cluster with pT " << cluster.
pt());
246 for (; pCellIter != pCellIterE; ++pCellIter) {
247 double cellEta{}, cellPhi{}, cellET{};
253 cellPhi = vxCell.
phi();
254 cellEta = vxCell.
eta();
255 cellET = vxCell.
et();
257 cellPhi = pCell->
phi();
258 cellEta = pCell->
eta();
259 cellET = pCell->
et();
262 if (
const auto & pElement {samplingLookup.find(sampling)};pElement != notFound){
263 sampling = pElement->second;
266 if (sampling < 4) i = sampling;
267 if (sampling == 12 || sampling == 13 || sampling == 14) i = 3;
268 detPhiTrk = TVector2::Phi_mpi_pi(cellPhi-extrapolatedPhi[i]);
269 detEtaTrk = std::abs( cellEta - extrapolatedEta[i] );
270 if ((sampling == 0 && detEtaTrk < eta0cut && detPhiTrk < phi0cut) ||
271 (sampling == 1 && detEtaTrk < eta1cut && detPhiTrk < phi1cut) ||
272 (sampling == 2 && detEtaTrk < eta2cut && detPhiTrk < phi2cut) ||
273 (sampling == 3 && detEtaTrk < eta3cut && detPhiTrk < phi3cut)) {
274 sumETCellsLAr += cellET;
280 return StatusCode::SUCCESS;
bool indexOfParameterAtPosition(unsigned int &index, ParameterPosition position) const
Function to determine if this TrackParticle contains track parameters at a certain position,...
float parameterPX(unsigned int index) const
Returns the parameter x momentum component, for 'index'.
float parameterX(unsigned int index) const
Returns the parameter x position, for 'index'.
float parameterPY(unsigned int index) const
Returns the parameter y momentum component, for 'index'.
float parameterZ(unsigned int index) const
Returns the parameter z position, for 'index'.
float parameterY(unsigned int index) const
Returns the parameter y position, for 'index'.
float parameterPZ(unsigned int index) const
Returns the parameter z momentum component, for 'index'.