ATLAS Offline Software
Loading...
Searching...
No Matches
CaloCellSelectorMinPerp.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
6// CaloCellSelectorMinPerp.cxx, (c) ATLAS Detector software
8
10
11#include "CaloEvent/CaloCell.h"
14
15namespace Trk {
16
18
20 m_caloExtension = &caloExtension;
21
22 // find a circular cone (defined by cut in perpendicular distance form track i.e. perp2)
23 // with approx area as the dR cone
24 // the dR cone is roughly thought as an elipse
25 if (m_caloExtension->caloLayerIntersections().empty()) return false;
26
27 Amg::Vector3D pos = m_caloExtension->caloLayerIntersections()[0].position();
28
29 double a = fabs(pos.eta());
30 double b = exp(-a); // = tan(theta/2)
31 double c = 2. * b / (1. - b * b); // = tan(theta)
32 double r = c / sqrt(1. + c * c); // distance from beam axis
33 double t1 = 2. * atan(exp(-(a - m_coneSize)));
34 double t2 = 2. * atan(exp(-(a + m_coneSize)));
35 double dRad1 = fabs(t1 - t2) / 2.;
36 // double dRad1 = 2.*b/(1.+b*b) * m_coneSize; //semi-major axis of the dR cone elipse
37 double dRad2 = r * m_coneSize; // semi minor axis of the dR cone elipse
38 m_perp2cut = dRad1 * dRad2; // force area of circle = area of elipse, i.e. pi*r*r = pi*dRad1*dRad2
39 return true;
40 }
41
42 bool CaloCellSelectorMinPerp::select(const CaloCell& cell) const {
43 if (!m_caloExtension || m_caloExtension->caloLayerIntersections().empty()) return false;
44
45 const CaloDetDescrElement* dde = cell.caloDDE();
46 if (!dde) return false;
47
48 Amg::Vector3D cellPos(dde->x(), dde->y(), dde->z());
49
50 int nearestIdx;
51 Amg::Vector3D nearestPos, nearestMom;
52 Utils::findNearestPoint(cellPos, m_caloExtension, nearestIdx, nearestPos, nearestMom);
53
54 // get the perp2 from track
55 Amg::Vector3D dPos = cellPos - nearestPos;
56 float perp2 = dPos.perp2(nearestMom);
57
58 // get the total track length from IP to point of cloest approach to the cell
59 // scale the perp2 cut with this length
60 float totTrkLen = sqrt(dPos.mag2() - perp2);
61 if (dPos.dot(nearestMom) < 0) { totTrkLen = -totTrkLen; }
62
63 Amg::Vector3D pos;
64 Amg::Vector3D oldPos(0., 0., 0.);
65 const std::vector<Trk::CurvilinearParameters>& intersections = m_caloExtension->caloLayerIntersections();
66 for (int i = 0; i <= nearestIdx; ++i) {
67 pos = intersections[i].position();
68 totTrkLen += (pos - oldPos).mag();
69 std::swap(oldPos, pos);
70 }
71
72 // prevent cell at exact opposite of the track from being selected..
73 if (totTrkLen < 0) return false;
74
75 if (perp2 < (m_perp2cut * totTrkLen * totTrkLen)) { return true; } // IF
76
77 return false;
78 }
79
80} // namespace Trk
Scalar perp2() const
perp2 method - perpendicular length squared
Scalar mag() const
mag method
static Double_t a
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
This class groups all DetDescr information related to a CaloCell.
const Trk::CaloExtension * m_caloExtension
bool select(const CaloCell &cell) const
Method to determine if a cell is to be selected or not.
bool preSelectAction(const Trk::CaloExtension &caloExtension)
Initialize selector wtih CaloExtension, returns false if the selection cannot be performed for the gi...
Tracking class to hold the extrapolation through calorimeter Layers Both the caloEntryLayerIntersecti...
int r
Definition globals.cxx:22
Eigen::Matrix< double, 3, 1 > Vector3D
Ensure that the ATLAS eigen extensions are properly loaded.
void findNearestPoint(const Amg::Vector3D &inputPos, const Trk::CaloExtension *caloExtension, int &nearestIdx, Amg::Vector3D &nearestPos, Amg::Vector3D &nearestMom)
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)