14 #include <ecl/geometry/ECLNeighbours.h>
15 #include <ecl/geometry/ECLGeometryPar.h>
18 #include <framework/logging/Logger.h>
19 #include <framework/gearbox/Unit.h>
32 std::vector<short int> fakeneighbours;
33 fakeneighbours.push_back(0);
36 int parToInt = int(par);
39 if (neighbourDef ==
"N") {
40 B2DEBUG(150,
"ECLNeighbours::ECLNeighbours: initialize " << neighbourDef <<
", n x n: " << parToInt * 2 + 1 <<
" x " << parToInt * 2
42 if ((parToInt >= 0) and (parToInt < 6))
initializeN(parToInt);
43 else B2FATAL(
"ECLNeighbours::ECLNeighbours: " << parToInt <<
" is an invalid parameter (must be between 0 and 5)!");
44 }
else if (neighbourDef ==
"NC") {
45 B2DEBUG(150,
"ECLNeighbours::ECLNeighbours: initialize " << neighbourDef <<
", n x n (minus corners): " << parToInt * 2 + 1 <<
" x "
48 if ((parToInt >= 0) and (parToInt < 6))
initializeNC(parToInt, 1);
49 else B2FATAL(
"ECLNeighbours::ECLNeighbours: " << parToInt <<
" is an invalid parameter (must be between 0 and 5)!");
50 }
else if (neighbourDef ==
"N2C") {
51 B2DEBUG(150,
"ECLNeighbours::ECLNeighbours: initialize " << neighbourDef <<
", n x n (minus 2 corners): " << parToInt * 2 + 1 <<
54 if ((parToInt >= 0) and (parToInt < 6))
initializeNC(parToInt, 2);
55 else B2FATAL(
"ECLNeighbours::ECLNeighbours: " << parToInt <<
" is an invalid parameter (must be between 0 and 5)!");
58 else if (neighbourDef ==
"R") {
59 B2DEBUG(150,
"ECLNeighbours::ECLNeighbours: initialize " << neighbourDef <<
", radius: " << par <<
" cm");
61 else B2FATAL(
"ECLNeighbours::ECLNeighbours: " << par <<
" is an invalid parameter (must be between 0 cm and 30 cm)!");
64 else if (neighbourDef ==
"F") {
65 double parChecked = par;
66 if (parChecked > 1.0) parChecked = 1.0;
67 else if (parChecked < 0.1) parChecked = 0.1;
68 B2DEBUG(150,
"ECLNeighbours::ECLNeighbours: initialize " << neighbourDef <<
", fraction: " << parChecked);
73 B2FATAL(
"ECLNeighbours::ECLNeighbours (constructor via std::string): Invalid option: " << neighbourDef <<
74 " (valid: N, NC, NC2, R ( with R<30 cm), F (with 0.1<f<1)");
87 std::vector<short int> fakeneighbours;
88 fakeneighbours.push_back(0);
97 for (
int i = 0; i < 8736; i++) {
99 TVector3 direction = geom->GetCrystalVec(i);
100 TVector3 position = geom->GetCrystalPos(i);
104 std::vector<short int> neighboursTemp;
107 for (
auto const&
id : neighbours) {
108 const TVector3& directionNeighbour = geom->GetCrystalVec(
id - 1);
109 const double alpha = direction.Angle(directionNeighbour);
110 const double R = position.Mag();
113 if (distance <= radius) neighboursTemp.push_back(
id);
129 for (
int i = 0; i < 8736; i++) {
131 std::vector<short int> neighbours;
135 const short tid = geom->GetThetaID();
136 const short pid = geom->GetPhiID();
141 neighbours.push_back(geom->GetCellID(tid , pid) + 1);
142 neighbours.push_back(geom->GetCellID(tid , phiInc) + 1);
143 neighbours.push_back(geom->GetCellID(tid , phiDec) + 1);
148 short int tidinner = tid - 1;
159 const double dist = fabs(fracPos - f);
164 n1 = geom->GetCellID(tidinner, inner);
166 }
else if (dist < dist2) {
168 n2 = geom->GetCellID(tidinner, inner);
178 neighbours.push_back(n1 + 1);
179 if (cov < frac - 1e-4) neighbours.push_back(n2 + 1);
183 short int tidouter = tid + 1;
184 if (tidouter <= 68) {
186 double disto1 = 999.;
187 short int pido1 = -1;
189 double disto2 = 999.;
193 const double dist = fabs(fracPos - f);
198 no1 = geom->GetCellID(tidouter, outer);
200 }
else if (dist < disto2) {
202 no2 = geom->GetCellID(tidouter, outer);
211 neighbours.push_back(no1 + 1);
212 if (cov < frac - 1e-4) {
213 neighbours.push_back(no2 + 1);
230 for (
int i = 0; i < 8736; i++) {
233 std::vector<short int> neighbours;
237 const short tid = geom->GetThetaID();
238 const short pid = geom->GetPhiID();
243 const double fractionalPhiInc =
static_cast < double >(phiInc) /
m_crystalsPerRing [ tid ];
244 const double fractionalPhiDec =
static_cast < double >(phiDec) /
m_crystalsPerRing [ tid ];
247 for (
int theta = tid - n; theta <= tid + n; theta++) {
248 if ((theta > 68) || (theta < 0))
continue;
250 short int thisPhiInc = std::lround(fractionalPhiInc *
m_crystalsPerRing [ theta ]);
252 short int thisPhiDec = std::lround(fractionalPhiDec *
m_crystalsPerRing [ theta ]);
255 const std::vector<short int> phiList =
getPhiIdsInBetween(thisPhiInc, thisPhiDec, theta);
257 for (
unsigned int k = 0; k < phiList.size(); ++k) {
258 neighbours.push_back(geom->GetCellID(theta , phiList.at(k)) + 1);
276 for (
int i = 0; i < 8736; i++) {
279 std::vector<short int> neighbours;
283 const short tid = geom->GetThetaID();
284 const short pid = geom->GetPhiID();
289 const double fractionalPhiInc =
static_cast < double >(phiInc) /
m_crystalsPerRing [ tid ];
290 const double fractionalPhiDec =
static_cast < double >(phiDec) /
m_crystalsPerRing [ tid ];
293 for (
int theta = tid - n; theta <= tid + n; theta++) {
294 if ((theta > 68) || (theta < 0))
continue;
296 short int thisPhiInc = std::lround(fractionalPhiInc *
m_crystalsPerRing [ theta ]);
298 short int thisPhiDec = std::lround(fractionalPhiDec *
m_crystalsPerRing [ theta ]);
301 std::vector<short int> phiList;
302 if ((theta == tid - n) or (theta == tid + n)) phiList =
getPhiIdsInBetweenC(thisPhiInc, thisPhiDec, theta, corners);
303 else if (corners == 2 and ((theta == tid - n + 1)
304 or (theta == tid + n - 1))) phiList =
getPhiIdsInBetweenC(thisPhiInc, thisPhiDec, theta, 1);
307 for (
unsigned int k = 0; k < phiList.size(); ++k) {
308 neighbours.push_back(geom->GetCellID(theta , phiList.at(k)) + 1);
326 short int previousPhiId = ((phiid - n < 0) ?
m_crystalsPerRing[thetaid] + phiid - n : phiid - n);
327 return previousPhiId;
340 std::vector<short int> phiList;
341 short int loop = phi0;
344 phiList.push_back(loop);
345 if (loop == phi1)
break;
355 std::vector<short int> phiList;
356 if (phi0 == phi1)
return phiList;
359 if (loop == phi1)
return phiList;
364 phiList.push_back(loop);
365 if (loop == stop)
break;
374 return 2.0 * R * TMath::Sin(alpha / 2.0);