Belle II Software  release-06-02-00
ECLLeakagePosition Class Reference

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

#include <ECLLeakagePosition.h>

Collaboration diagram for ECLLeakagePosition:

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. More...
 

Private Attributes

DBObjPtr< ECLCrystalCalibm_ECLCrystalThetaEdge
 Required geometry payloads. More...
 
std::vector< float > thetaEdge
 lower theta edges from DB object
 
DBObjPtr< ECLCrystalCalibm_ECLCrystalPhiEdge
 lower edges of crystals, phi
 
std::vector< float > phiEdge
 lower phi edges from DB object
 
DBObjPtr< ECLCrystalCalibm_ECLCrystalThetaWidth
 width in theta
 
std::vector< float > thetaWidth
 crystal theta widths from DB object
 
DBObjPtr< ECLCrystalCalibm_ECLCrystalPhiWidth
 width in phi
 
std::vector< float > phiWidth
 crystal phi widths from DB object
 
ECL::ECLNeighboursneighbours {nullptr}
 8 nearest neighbours to crystal
 
std::vector< int > thetaIDofCrysID
 thetaID of each crystal ID
 
std::vector< int > phiIDofCrysID
 phiID of each crystal ID
 
std::vector< int > crysBetweenMech
 crystals between phi mechanical structure per thetaID
 
const int firstBarrelThetaID = 13
 first barrel thetaID
 
const int 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.

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 72 of file ECLLeakagePosition.cc.

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

Member Data Documentation

◆ m_ECLCrystalThetaEdge

DBObjPtr<ECLCrystalCalib> m_ECLCrystalThetaEdge
private

Required geometry payloads.

lower edges of crystals, theta

Definition at line 45 of file ECLLeakagePosition.h.


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