144 const std::vector<const CaloCell*>& cells,
149 constexpr bool use3D =
true;
155 ATH_MSG_DEBUG(
"EntryExitLayerMap " << entryExitLayerMap.size());
161 ATH_MSG_DEBUG(
"Getting cells intersections using cells " << cells.size());
162 for (
const auto* cell : cells) {
166 auto pos = entryExitLayerMap.find(sample);
167 if (pos == entryExitLayerMap.end())
175 if (sample == CaloSampling::PreSamplerB) {
176 pos2 = entryExitLayerMap.find(CaloSampling::EMB1);
177 if (pos2 == entryExitLayerMap.end()) {
184 double drFix = cell->caloDDE()->dr();
185 double dzFix = cell->caloDDE()->dz();
188 int isample = cell->caloDDE()->getSampling();
192 if (sample == CaloSampling::PreSamplerB || sample == CaloSampling::EMB1 ||
193 sample == CaloSampling::EMB2 || sample == CaloSampling::EMB3)
196 double drTG = fabs((pos->second.first - pos2->second.second).perp());
197 double dzTG = fabs((pos->second.first - pos2->second.second).z());
201 << cell->caloDDE()->getSampling() <<
" dr "
202 << cell->caloDDE()->dr() <<
" drTG " << drTG);
205 << cell->caloDDE()->getSampling() <<
" dz "
206 << cell->caloDDE()->dz() <<
" dzTG " << dzTG);
213 if (cell->caloDDE()->deta() > 0) {
214 double theta = atan2(cell->caloDDE()->r(), cell->z());
216 2 * cell->caloDDE()->deta() * sin(
theta / 2.) * cos(
theta / 2);
219 fabs(cell->z() * tan(
theta + dtheta) - cell->z() * tan(
theta));
222 -log(tan((
theta + dtheta) / 2.)) + log(tan((
theta) / 2.));
224 << cell->caloDDE()->getSampling() <<
" deta "
225 << cell->caloDDE()->deta() <<
" detaCheck "
226 << detaCheck <<
" drFix " << drFix);
229 <<
theta <<
" dtheta " << dtheta <<
" sum/pi "
230 << (
theta + dtheta) * M_1_PI <<
" deta "
231 << cell->caloDDE()->deta());
237 double drMin = 100000.;
241 const CaloCell* cellFound =
nullptr;
242 for (
const auto* celln : cells) {
245 if (cell->caloDDE()->getSubCalo() == celln->caloDDE()->getSubCalo()) {
246 int dsample = isample - celln->caloDDE()->getSampling();
247 if (abs(dsample) == dscut) {
248 double drNew = fabs(cell->caloDDE()->r() - celln->caloDDE()->r());
260 << cell->caloDDE()->getSampling() <<
" x "
261 << cell->caloDDE()->x() <<
" y " << cell->caloDDE()->y()
262 <<
" z " << cell->caloDDE()->z() <<
" dr "
263 << cell->caloDDE()->dr() <<
" drFix " << drFix
264 <<
" drTG " << drTG);
268 << cellFound->
caloDDE()->
x() <<
" y "
269 << cellFound->
caloDDE()->
y() <<
" z "
270 << cellFound->
caloDDE()->
z() <<
" dr "
271 << cellFound->
caloDDE()->
dr() <<
" dscut " << dscut
272 <<
" drFix " << drFix);
280 if (cell->caloDDE()->deta() > 0) {
281 double theta = atan2(cell->caloDDE()->r(), cell->z());
283 2 * cell->caloDDE()->deta() * sin(
theta / 2.) * cos(
theta / 2);
285 double dz = fabs(cell->caloDDE()->r() / tan(
theta + dtheta) -
286 cell->caloDDE()->r() / tan(
theta));
290 <<
theta <<
" dtheta " << dtheta <<
" sum/pi "
291 << (
theta + dtheta) * M_1_PI <<
" deta "
292 << cell->caloDDE()->deta());
295 -log(tan((
theta + dtheta) / 2.)) + log(tan((
theta) / 2.));
297 << cell->caloDDE()->getSampling() <<
" deta "
298 << cell->caloDDE()->deta() <<
" detaCheck "
299 << detaCheck <<
" dtheta " << dtheta <<
" dzFix "
302 double dzMin = 100000.;
306 const CaloCell* cellFound =
nullptr;
307 for (
const auto* celln : cells) {
310 if (cell->caloDDE()->getSubCalo() == celln->caloDDE()->getSubCalo()) {
311 int isample2 = celln->caloDDE()->getSampling();
312 if (abs(isample - isample2) == dscut) {
313 double dzNew = fabs(cell->caloDDE()->z() - celln->caloDDE()->z());
325 << cell->caloDDE()->getSampling() <<
" x "
326 << cell->caloDDE()->x() <<
" y " << cell->caloDDE()->y()
327 <<
" z " << cell->caloDDE()->z() <<
" dz "
328 << cell->caloDDE()->dz() <<
" dzFix " << dzFix
329 <<
" dzTG " << dzTG);
333 << cellFound->
caloDDE()->
x() <<
" y "
334 << cellFound->
caloDDE()->
y() <<
" z "
335 << cellFound->
caloDDE()->
z() <<
" dz "
336 << cellFound->
caloDDE()->
dz() <<
" dscut " << dscut
337 <<
" dzFix " << dzFix);
345 if (cell->energy() > 50.)
347 << cell->caloDDE()->getSampling() <<
" cell energy "
348 << cell->energy() <<
" dzFix " << dzFix <<
" dzTG " << dzTG
349 <<
" drFix " << drFix <<
" drTG " << drTG <<
" barrel "
360 *cell, pos->second.first, pos2->second.second, drFix, dzFix);
361 double totpath = (pos->second.first - pos2->second.second).
mag();
362 path = totpath != 0 ? pathInMM / totpath : 0.;
363 if (path > 0 || cell->energy() > 50.) {
365 << cell->caloDDE()->getSampling() <<
" cell energy "
366 << cell->energy() <<
" drFix " << drFix <<
" dzFix "
367 << dzFix <<
" path " << path <<
" length TG " << totpath);
368 ATH_MSG_DEBUG(
" cell dr " << cell->caloDDE()->dr() <<
" cell dz "
369 << cell->caloDDE()->dz() <<
" deta "
370 << cell->caloDDE()->deta());
378 path2 =
pathInsideCell(*cell, pos->second.first, pos2->second.second);
380 if (path2 <= 0. && path <= 0.)
384 auto eLossPair = eLossLayerMap.find(sample);
389 if (eLossPair != eLossLayerMap.end()) {
390 eLoss = eLossPair->second;
391 if (sample == CaloSampling::PreSamplerB) {
392 auto eLossPair2 = eLossLayerMap.find(CaloSampling::EMB1);
393 if (eLossPair2 != eLossLayerMap.end()) {
394 eLoss = 0.5 * (eLossPair->second) + 0.5 * (eLossPair2->second);
396 }
else if (sample == CaloSampling::EMB1) {
397 auto eLossPair2 = eLossLayerMap.find(CaloSampling::PreSamplerB);
398 if (eLossPair2 != eLossLayerMap.end()) {
399 eLoss = 0.5 * (eLossPair->second) + 0.5 * (eLossPair2->second);
405 << path <<
" PATH2D = " << path2 <<
" eLoss " << eLoss
406 <<
" cell energy " << (cell)->energy() <<
" radius "
407 << cell->caloDDE()->r() <<
" phi " << cell->caloDDE()->phi()
408 <<
" dr " << cell->caloDDE()->dr() <<
" dphi "
409 << cell->caloDDE()->dphi() <<
" x " << cell->caloDDE()->x()
410 <<
" y " << cell->caloDDE()->y() <<
" z "
411 << cell->caloDDE()->z() <<
" dx " << cell->caloDDE()->dx()
412 <<
" dy " << cell->caloDDE()->dy() <<
" dz "
413 << cell->caloDDE()->dz() <<
" volume "
414 << cell->caloDDE()->volume());
416 cellIntersections.emplace_back(
419 ATH_MSG_DEBUG(
" added cell intersections " << cellIntersections.size());
std::vector< std::pair< const CaloCell *, ParticleCellIntersection * > > CellIntersections
typedef for vector of cell intersections