Belle II Software development
ECLLeakagePosition Class Reference

Class to get position information for a cluster for leakage corrections. More...

#include <ECLLeakagePosition.h>

Public Member Functions

 ECLLeakagePosition ()
 Constructor.
 
 ~ECLLeakagePosition ()
 Destructor.
 
std::vector< int > getLeakagePosition (const int cellIDFromEnergy, const float theta, const float phi, const int nPositions)
 Return postion.
 

Private Attributes

DBObjPtr< ECLCrystalCalibm_ECLCrystalThetaEdge
 Required geometry payloads.
 
std::vector< float > m_thetaEdge
 lower theta edges from DB object
 
DBObjPtr< ECLCrystalCalibm_ECLCrystalPhiEdge
 lower edges of crystals, phi
 
std::vector< float > m_phiEdge
 lower phi edges from DB object
 
DBObjPtr< ECLCrystalCalibm_ECLCrystalThetaWidth
 width in theta
 
std::vector< float > m_thetaWidth
 crystal theta widths from DB object
 
DBObjPtr< ECLCrystalCalibm_ECLCrystalPhiWidth
 width in phi
 
std::vector< float > m_phiWidth
 crystal phi widths from DB object
 
ECL::ECLNeighboursm_neighbours {nullptr}
 8 nearest neighbours to crystal
 
std::vector< int > m_thetaIDofCrysID
 thetaID of each crystal ID
 
std::vector< int > m_phiIDofCrysID
 phiID of each crystal ID
 
std::vector< int > m_crysBetweenMech
 crystals between phi mechanical structure per thetaID
 
const int m_firstBarrelThetaID = 13
 first barrel thetaID
 
const int m_lastBarrelThetaID = 58
 last barrel thetaID
 

Detailed Description

Class to get position information for a cluster for leakage corrections.

Definition at line 24 of file ECLLeakagePosition.h.

Constructor & Destructor Documentation

◆ ECLLeakagePosition()

Constructor.

Definition at line 22 of file ECLLeakagePosition.cc.

22 :
23 m_ECLCrystalThetaEdge("ECLCrystalThetaEdge"),
24 m_ECLCrystalPhiEdge("ECLCrystalPhiEdge"),
25 m_ECLCrystalThetaWidth("ECLCrystalThetaWidth"),
26 m_ECLCrystalPhiWidth("ECLCrystalPhiWidth")
27{
28
29 //..Obtain the vectors of crystal edges and widths from the database
30 if (m_ECLCrystalThetaEdge.hasChanged()) {
31 m_thetaEdge = m_ECLCrystalThetaEdge->getCalibVector();
32 }
33 if (m_ECLCrystalPhiEdge.hasChanged()) {
34 m_phiEdge = m_ECLCrystalPhiEdge->getCalibVector();
35 }
36 if (m_ECLCrystalThetaWidth.hasChanged()) {
37 m_thetaWidth = m_ECLCrystalThetaWidth->getCalibVector();
38 }
39 if (m_ECLCrystalPhiWidth.hasChanged()) {
40 m_phiWidth = m_ECLCrystalPhiWidth->getCalibVector();
41 }
42
43 //..Eight nearest neighbours, plus crystal itself. Uses cellID, 1--8736
44 m_neighbours = new ECLNeighbours("N", 1);
45
46 //..Record the thetaID and phiID of each cellID
47 for (int thID = 0; thID < 69; thID++) {
48 for (int phID = 0; phID < m_neighbours->getCrystalsPerRing(thID); phID++) {
49 m_thetaIDofCrysID.push_back(thID);
50 m_phiIDofCrysID.push_back(phID);
51 }
52 }
53
54 //..Crystals between mechanical structure for each thetaID
55 for (int thID = 0; thID < m_firstBarrelThetaID; thID++) {
56 int nCrys = m_neighbours->getCrystalsPerRing(thID) / 16;
57 m_crysBetweenMech.push_back(nCrys);
58 }
59 for (int thID = m_firstBarrelThetaID; thID <= m_lastBarrelThetaID; thID++) {
60 m_crysBetweenMech.push_back(2);
61 }
62 for (int thID = m_lastBarrelThetaID + 1; thID < 69; thID++) {
63 int nCrys = m_neighbours->getCrystalsPerRing(thID) / 16;
64 m_crysBetweenMech.push_back(nCrys);
65 }
66}
DBObjPtr< ECLCrystalCalib > m_ECLCrystalPhiEdge
lower edges of crystals, phi
std::vector< int > m_crysBetweenMech
crystals between phi mechanical structure per thetaID
ECL::ECLNeighbours * m_neighbours
8 nearest neighbours to crystal
std::vector< int > m_thetaIDofCrysID
thetaID of each crystal ID
std::vector< float > m_thetaEdge
lower theta edges from DB object
std::vector< int > m_phiIDofCrysID
phiID of each crystal ID
std::vector< float > m_thetaWidth
crystal theta widths from DB object
DBObjPtr< ECLCrystalCalib > m_ECLCrystalThetaWidth
width in theta
std::vector< float > m_phiWidth
crystal phi widths from DB object
DBObjPtr< ECLCrystalCalib > m_ECLCrystalPhiWidth
width in phi
const int m_firstBarrelThetaID
first barrel thetaID
std::vector< float > m_phiEdge
lower phi edges from DB object
const int m_lastBarrelThetaID
last barrel thetaID
DBObjPtr< ECLCrystalCalib > m_ECLCrystalThetaEdge
Required geometry payloads.
Class to get the neighbours for a given cell id.
Definition: ECLNeighbours.h:25
short int getCrystalsPerRing(const short int thetaid) const
return number of crystals in a given theta ring
Definition: ECLNeighbours.h:39

◆ ~ECLLeakagePosition()

Destructor.

Definition at line 68 of file ECLLeakagePosition.cc.

69{
70 delete m_neighbours;
71}

Member Function Documentation

◆ getLeakagePosition()

std::vector< int > getLeakagePosition ( const int  cellIDFromEnergy,
const float  theta,
const float  phi,
const int  nPositions 
)

Return postion.

Elements of returned vector: cellID, thetaID, region, localThetaBin, localPhiBin, phiMech, status region: 0 = forward, 1 = barrel, 2 = backward localPhiBin is from edge with mechanical structure, or else lower edge phiMech: 0 = mechanical structure on phi edge; 1 = no mechanical structure status: 0 = cellID is max energy crystal; 1 = neighbour; 2 = more distant

Definition at line 73 of file ECLLeakagePosition.cc.

75{
76
77 //..Start by checking if the crystal with the most energy is the correct one
78 int crysID = cellIDFromEnergy - 1;
79 int iStatus = -1;
80
81 //..theta and phi need to be within the crystal
82 float dTheta = theta - m_thetaEdge[crysID];
83 float dPhi = phi - m_phiEdge[crysID];
84 if (dPhi > TMath::Pi()) {dPhi -= 2.*TMath::Pi();}
85 if (dPhi < -TMath::Pi()) {dPhi += 2.*TMath::Pi();}
86 if (dTheta >= 0 and dTheta <= m_thetaWidth[crysID] and dPhi >= 0 and dPhi <= m_phiWidth[crysID]) {
87 iStatus = 0;
88 }
89
90 //..Theta and phi are not located in the maximum energy crystal. Check the
91 // eight nearest neighbours.
92 if (iStatus == -1) {
93
94 //..Nearest neighbours (plus the central crystal)
95 for (const auto& tempCellID : m_neighbours->getNeighbours(cellIDFromEnergy)) {
96 int tempCrysID = tempCellID - 1;
97 dTheta = theta - m_thetaEdge[tempCrysID];
98 dPhi = phi - m_phiEdge[tempCrysID];
99 if (dPhi > TMath::Pi()) {dPhi -= 2.*TMath::Pi();}
100 if (dPhi < -TMath::Pi()) {dPhi += 2.*TMath::Pi();}
101
102 //..This one is correct
103 if (dTheta >= 0 and dTheta <= m_thetaWidth[tempCrysID] and dPhi >= 0 and dPhi <= m_phiWidth[tempCrysID]) {
104 iStatus = 1;
105 crysID = tempCrysID;
106 break;
107 }
108 }
109 }
110
111 //..Need to do this one by brute force
112 if (iStatus == -1) {
113
114 //..Start at the last crystal and work backwards
115 for (int crys = 8735; crys >= 0; crys--) {
116 dTheta = theta - m_thetaEdge[crys];
117 dPhi = phi - m_phiEdge[crys];
118 if (dPhi > TMath::Pi()) {dPhi -= 2.*TMath::Pi();}
119 if (dPhi < -TMath::Pi()) {dPhi += 2.*TMath::Pi();}
120 if (dPhi >= 0 and dPhi <= m_phiWidth[crys] and dTheta >= 0) {
121 iStatus = 2;
122 crysID = crys;
123 break;
124 }
125 }
126 }
127
128 //..Above should cover all cases, but set sensible values if we missed something
129 if (iStatus == -1) {
130 iStatus = 3;
131 crysID = cellIDFromEnergy - 1;
132 dTheta = 0.5;
133 dPhi = 0.5;
134 }
135
136 //..Return values
137 int cellID = crysID + 1;
138 int thetaID = m_thetaIDofCrysID[crysID];
139 int iRegion = 0;
140 if (thetaID >= m_firstBarrelThetaID and thetaID <= m_lastBarrelThetaID) {iRegion = 1;}
141 if (thetaID > m_lastBarrelThetaID) {iRegion = 2;}
142
143 //..Mechanical structure is on lower edge of phiID 0, and every 2 (barrel) or n (endcap)
144 // crystals thereafter
145 int iPhiMech = m_phiIDofCrysID[crysID] % m_crysBetweenMech[thetaID];
146 bool reversePhi;
147
148 //..Mechanical structure on lower edge
149 if ((iPhiMech == 0 and iRegion != 1) or (iPhiMech == m_crysBetweenMech[thetaID] - 1 and iRegion == 1)) {
150 iPhiMech = 0;
151 reversePhi = false;
152
153 //..Mechanical structure on upper edge
154 } else if ((iPhiMech == m_crysBetweenMech[thetaID] - 1 and iRegion != 1) or (iPhiMech == 0 and iRegion == 1)) {
155 iPhiMech = 0;
156 reversePhi = true;
157
158 //..No mechanical structure adjacent
159 } else {
160 iPhiMech = 1;
161 reversePhi = false;
162 }
163
164 //..Divide crystal into nPositions in width, starting from lower edge
165 int iLocalTheta = (int)(nPositions * dTheta / m_thetaWidth[crysID]);
166 if (iLocalTheta < 0) {iLocalTheta = 0;}
167 if (iLocalTheta >= nPositions) {iLocalTheta = nPositions - 1;}
168
169 int iLocalPhi = (int)(nPositions * dPhi / m_phiWidth[crysID]);
170 if (iLocalPhi < 0) {iLocalPhi = 0;}
171 if (iLocalPhi >= nPositions) {iLocalPhi = nPositions - 1;}
172
173 //..iLocalPhi is measured from edge with mechanical structure, if present,
174 // so reverse order of iLocalPhi if mech structure is on the upper edge
175 if (reversePhi) {iLocalPhi = nPositions - iLocalPhi - 1;}
176
177 //..Return as a std::vector
178 std::vector<int> position;
179 position.push_back(cellID);
180 position.push_back(thetaID);
181 position.push_back(iRegion);
182 position.push_back(iLocalTheta);
183 position.push_back(iLocalPhi);
184 position.push_back(iPhiMech);
185 position.push_back(iStatus);
186 return position;
187}
const std::vector< short int > & getNeighbours(short int cid) const
Return the neighbours for a given cell ID.

Member Data Documentation

◆ m_crysBetweenMech

std::vector<int> m_crysBetweenMech
private

crystals between phi mechanical structure per thetaID

Definition at line 61 of file ECLLeakagePosition.h.

◆ m_ECLCrystalPhiEdge

DBObjPtr<ECLCrystalCalib> m_ECLCrystalPhiEdge
private

lower edges of crystals, phi

Definition at line 48 of file ECLLeakagePosition.h.

◆ m_ECLCrystalPhiWidth

DBObjPtr<ECLCrystalCalib> m_ECLCrystalPhiWidth
private

width in phi

Definition at line 54 of file ECLLeakagePosition.h.

◆ m_ECLCrystalThetaEdge

DBObjPtr<ECLCrystalCalib> m_ECLCrystalThetaEdge
private

Required geometry payloads.

lower edges of crystals, theta

Definition at line 45 of file ECLLeakagePosition.h.

◆ m_ECLCrystalThetaWidth

DBObjPtr<ECLCrystalCalib> m_ECLCrystalThetaWidth
private

width in theta

Definition at line 51 of file ECLLeakagePosition.h.

◆ m_firstBarrelThetaID

const int m_firstBarrelThetaID = 13
private

first barrel thetaID

Definition at line 62 of file ECLLeakagePosition.h.

◆ m_lastBarrelThetaID

const int m_lastBarrelThetaID = 58
private

last barrel thetaID

Definition at line 63 of file ECLLeakagePosition.h.

◆ m_neighbours

ECL::ECLNeighbours* m_neighbours {nullptr}
private

8 nearest neighbours to crystal

Definition at line 57 of file ECLLeakagePosition.h.

◆ m_phiEdge

std::vector<float> m_phiEdge
private

lower phi edges from DB object

Definition at line 49 of file ECLLeakagePosition.h.

◆ m_phiIDofCrysID

std::vector<int> m_phiIDofCrysID
private

phiID of each crystal ID

Definition at line 60 of file ECLLeakagePosition.h.

◆ m_phiWidth

std::vector<float> m_phiWidth
private

crystal phi widths from DB object

Definition at line 55 of file ECLLeakagePosition.h.

◆ m_thetaEdge

std::vector<float> m_thetaEdge
private

lower theta edges from DB object

Definition at line 46 of file ECLLeakagePosition.h.

◆ m_thetaIDofCrysID

std::vector<int> m_thetaIDofCrysID
private

thetaID of each crystal ID

Definition at line 59 of file ECLLeakagePosition.h.

◆ m_thetaWidth

std::vector<float> m_thetaWidth
private

crystal theta widths from DB object

Definition at line 52 of file ECLLeakagePosition.h.


The documentation for this class was generated from the following files: