SDetector/Scintillator.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <sstream>
3 #include <vector>
4 #include <boost/lexical_cast.hpp>
5 
6 #include <sdet/Station.h>
7 #include <sdet/Scintillator.h>
8 #include <det/Detector.h>
9 #include <sdet/SDetector.h>
10 #include <utl/ErrorLogger.h>
11 #include <utl/Math.h>
12 #include <utl/Point.h>
13 #include <utl/Line.h>
14 #include <utl/GeometryUtilities.h>
15 #include <utl/UTMPoint.h>
16 #include <utl/Reader.h>
17 #include <utl/CoordinateSystem.h>
18 #include <utl/AugerCoordinateSystem.h>
19 #include <fwk/LocalCoordinateSystem.h>
20 
21 using namespace sdet;
22 using namespace std;
23 using namespace utl;
24 
25 
26 double
28  const
29 {
30  if (!fBarLength.IsValid()) {
31  GetScintillatorData(fBarLength.Get(), "barLength", "scintillator", "scintillator bar length");
32  fBarLength.SetValid();
33  }
34  return fBarLength.Get();
35 }
36 
37 
38 double
40  const
41 {
42  if (!fBarWidth.IsValid()) {
43  GetScintillatorData(fBarWidth.Get(), "barWidth", "scintillator", "scintillator bar width");
44  fBarWidth.SetValid();
45  }
46  return fBarWidth.Get();
47 }
48 
49 
50 double
52  const
53 {
54  if (!fBarThickness.IsValid()) {
55  GetScintillatorData(fBarThickness.Get(), "barThickness", "scintillator", "scintillator bar thickness");
56  fBarThickness.SetValid();
57  }
58  return fBarThickness.Get();
59 }
60 
61 
62 unsigned int
64  const
65 {
66  if (!fNBars.IsValid()) {
67  const det::ManagerRegister& m = det::Detector::GetInstance().GetSManagerRegister();
68  m.GetDataOrThrow(fNBars.Get(), "scintillator", "barCount", indexMap);
69  fNBars.SetValid();
70  }
71  return fNBars.Get();
72 }
73 
74 
75 double
77  const
78 {
79  if (!fGap.IsValid()) {
80  GetScintillatorData(fGap.Get(), "gap", "scintillator", "gap between sides of scintillator");
81  fGap.SetValid();
82  }
83  return fGap.Get();
84 }
85 
86 
87 double
89  const
90 {
91  if (!fFiberLength.IsValid()) {
92  GetScintillatorData(fFiberLength.Get(), "fiberLength", "scintillator",
93  "length of on fiber routed through two scintillator bars");
94  fFiberLength.SetValid();
95  }
96  return fFiberLength.Get();
97 }
98 
99 
100 double
102  const
103 {
104  if (!fFiberUTurnDiameter.IsValid()) {
105  GetScintillatorData(fFiberUTurnDiameter.Get(), "fiberUTurnDiameter", "scintillator",
106  "diameter of the u-turn fibers make in their connections from one bar to the next");
107  fFiberUTurnDiameter.SetValid();
108  }
109  return fFiberUTurnDiameter.Get();
110 }
111 
112 
113 double
115  const
116 {
117  if (!fHousingLength.IsValid()) {
118  GetScintillatorData(fHousingLength.Get(), "housingLength", "scintillator", "length of scintillator polystyrene housing");
119  fHousingLength.SetValid();
120  }
121  return fHousingLength.Get();
122 }
123 
124 
125 double
127  const
128 {
129  if (!fHousingWidth.IsValid()) {
130  GetScintillatorData(fHousingWidth.Get(), "housingWidth", "scintillator", "width of scintillator polystyrene housing");
131  fHousingWidth.SetValid();
132  }
133  return fHousingWidth.Get();
134 }
135 
136 
137 double
139  const
140 {
141  if (!fHousingThickness.IsValid()) {
142  GetScintillatorData(fHousingThickness.Get(), "housingThickness", "scintillator", "thickness of scintillator polystyrene housing");
143  fHousingThickness.SetValid();
144  }
145  return fHousingThickness.Get();
146 }
147 
148 
149 double
151  const
152 {
153  if (!fCasingThickness.IsValid()) {
154  GetScintillatorData(fCasingThickness.Get(), "casingThickness", "scintillator", "thickness of scintillator aluminum casing");
155  fCasingThickness.SetValid();
156  }
157  return fCasingThickness.Get();
158 }
159 
160 
161 double
163  const
164 {
165  if (!fSandwichPanelThickness.IsValid()) {
166  GetScintillatorData(fSandwichPanelThickness.Get(), "sandwichPanelThickness", "scintillator", "thickness of the foam portion of the sandwich board of the scintillator");
167  fSandwichPanelThickness.SetValid();
168  }
169  return fSandwichPanelThickness.Get();
170 }
171 
172 
173 double
175  const
176 {
177  if (!fRoofOffset.IsValid()) {
178  GetScintillatorData(fRoofOffset.Get(), "roofOffset", "scintillator", "offset of the bottom of the roof from the top of the top aluminum sheet of the scintillator");
179  fRoofOffset.SetValid();
180  }
181  return fRoofOffset.Get();
182 }
183 
184 
185 double
187  const
188 {
189  if (!fRoofThickness.IsValid()) {
190  GetScintillatorData(fRoofThickness.Get(), "roofThickness", "scintillator", "thickness of the scintillator roof");
191  fRoofThickness.SetValid();
192  }
193  return fRoofThickness.Get();
194 }
195 
196 
199  const
200 {
201  if (!fPosition.IsValid()) {
202 
203  vector<double> coords;
204  GetScintillatorData(coords, "position", "scintillator", "scintillator position");
205 
206  // Return the scintillator position in a coordinate system whose origin is
207  // at the intersection of the ground and the central axis of the tank
208 
209  CoordinateSystemPtr tCS =
210  det::Detector::GetInstance().GetSDetector().GetStation(fStationId).GetLocalCoordinateSystem();
211 
212  fPosition = utl::Point(coords[0], coords[1], coords[2], tCS);
213 
214  }
215  return fPosition.Get();
216 }
217 
218 
219 double
221  const
222 {
223  if (!fFiberExpDecayConstant.IsValid()) {
224  GetScintillatorData(fFiberExpDecayConstant.Get(), "fiberExpDecayConst", "scintillator", "fiber exponential decay constant");
225  fFiberExpDecayConstant.SetValid();
226  }
227  return fFiberExpDecayConstant.Get();
228 }
229 
230 
231 double
233  const
234 {
235  if (!fBarExpDecayConstant.IsValid()) {
236  GetScintillatorData(fBarExpDecayConstant.Get(), "barExpDecayConst", "scintillator", "scintillator bar exponential decay constant");
237  fBarExpDecayConstant.SetValid();
238  }
239  return fBarExpDecayConstant.Get();
240 }
241 
242 
243 double
245  const
246 {
247  if (!fAttenuationLength.IsValid()) {
248  GetScintillatorData(fAttenuationLength.Get(), "attenuationLength", "scintillator", "attenuation length");
249  fAttenuationLength.SetValid();
250  }
251  return fAttenuationLength.Get();
252 }
253 
254 
255 double
257  const
258 {
259  if (!fBarLeakageExpCoefficient.IsValid()) {
260  GetScintillatorData(fBarLeakageExpCoefficient.Get(), "barLeakageExpCoefficient",
261  "scintillator", "exponential coefficient describing photon leakage at ends of bar");
262  fBarLeakageExpCoefficient.SetValid();
263  }
264  return fBarLeakageExpCoefficient.Get();
265 }
266 
267 
268 double
270  const
271 {
272  if (!fBarLeakageMaxRatio.IsValid()) {
273  GetScintillatorData(fBarLeakageMaxRatio.Get(), "barLeakageMaxRatio", "scintillator",
274  "maximum ratio of photon leakage at ends of bar");
275  fBarLeakageMaxRatio.SetValid();
276  }
277  return fBarLeakageMaxRatio.Get();
278 }
279 
280 
281 double
283  const
284 {
285  if (!fEffectiveRefractiveIndex.IsValid()) {
286  GetScintillatorData(fEffectiveRefractiveIndex.Get(), "effectiveRefractiveIndex", "scintillator", "effective refractive index");
287  fEffectiveRefractiveIndex.SetValid();
288  }
289  return fEffectiveRefractiveIndex.Get();
290 }
291 
292 
293 double
295  const
296 {
297  if (!fReferencePENumber.IsValid()) {
298  GetScintillatorData(fReferencePENumber.Get(), "referencePENumber", "scintillator", "non attenuated average number of PEs per VMIP");
299  fReferencePENumber.SetValid();
300  }
301  return fReferencePENumber.Get();
302 }
303 
304 
305 double
307  const
308 {
309  if (!fSigmaBarToBar.IsValid()) {
310  GetScintillatorData(fSigmaBarToBar.Get(), "sigmaBarToBar", "scintillator", "standard deviation of bar-to-bar response");
311  fSigmaBarToBar.SetValid();
312  }
313  return fSigmaBarToBar.Get();
314 }
315 
316 
317 double
319  const
320 {
321  if (!fReferenceEnergy.IsValid()) {
322  GetScintillatorData(fReferenceEnergy.Get(), "referenceEnergy", "scintillator", "average energy deposit per VMIP");
323  fReferenceEnergy.SetValid();
324  }
325  return fReferenceEnergy.Get();
326 }
327 
328 
329 void
331  const
332 {
333  ostringstream err;
334  err << "Did not find requested component: '" << msg
335  << "' for station = " << indexMap["stationId"];
336  throw NonExistentComponentException(err.str());
337 }
338 
339 
340 Scintillator::Scintillator(const int stationId, const unsigned int isUUB) :
341  fStationId(stationId)
342 {
343  /*
344  * Adding stationId and isUUB to index map, which is passed
345  * to the managers with each GetScintillatorData request (or when
346  * Handle is used).
347  */
348  indexMap["stationId"] = boost::lexical_cast<string>(stationId);
349  indexMap["isUUB"] = boost::lexical_cast<string>(isUUB);
350 }
351 
352 
353 std::vector<double>
355  const
356 {
358  det::Detector::GetInstance().GetSDetector().GetStation(fStationId).GetLocalCoordinateSystem();
359  /*
360  * Check to ensure point is inside one of the scintillator wings. If the point is within the a
361  * "halo" distance (set to the width of one bar), this check will still pass (as the intention
362  * of the check is just to ensure requests are not being made with absurd coordinates and has
363  * no effect on the distance calculation). A more elegant management of the halo could be
364  * implemented in the future.
365  */
366  if (!IsInsideBar(p, GetBarWidth())) {
367  ostringstream err;
368  err << "Point is not within the active area (bars) of the scintillator.";
369  throw OutOfBoundException(err.str());
370  }
371  const double longLeg =
372  GetBarLength() + 0.5*GetGap() -
373  abs(p.GetX(cs) - GetPosition().GetX(cs)) + 0.25*kPi*GetFiberUTurnDiameter() + 0.5*GetFiberLength();
374  std::vector<double> v { GetFiberLength() - longLeg, longLeg };
375  return v;
376 }
377 
378 
379 pair<double, double>
381  const
382 {
384  det::Detector::GetInstance().GetSDetector().GetStation(fStationId).GetLocalCoordinateSystem();
385  /*
386  * Check to ensure point is inside one of the scintillator wings. If the point is within the a
387  * "halo" distance (set to the width of one bar), this check will still pass (as the intention
388  * of the check is just to ensure requests are not being made with absurd coordinates and has
389  * no effect on the distance calculation). A more elegant management of the halo could be
390  * implemented in the future.
391  */
392  if (!IsInsideBar(p, GetBarWidth())) {
393  ostringstream err;
394  err << "Point is not within the active area (bars) of the scintillator.";
395  throw OutOfBoundException(err.str());
396  }
397  // distance to end of bar closer to PMT
398  const double di = abs(p.GetX(cs) - GetPosition().GetX(cs)) - 0.5*GetGap();
399  return make_pair(di, GetBarLength()-di);
400 }
401 
402 
403 bool
404 Scintillator::IsHit(const Point& particlePoint, const Vector& particleDirection, const double halo)
405  const
406 {
407  const Line particleLine(particlePoint, particleDirection);
409  det::Detector::GetInstance().GetSDetector().GetStation(fStationId).GetLocalCoordinateSystem();
410  const utl::Point& position = GetPosition();
411  const Plane scintillatorPlane(Point(0, 0, position.GetZ(cs), cs),
412  Vector(0, 0, 1, cs));
413  const Point where = Intersection(scintillatorPlane, particleLine);
414 
415  // variables needed to define the area where particle might hit the detector
416  const double gapLength = GetGap();
417  const double barLength = GetBarLength();
418  const int barCount = GetNBars();
419  const double barWidth = GetBarWidth();
420  const double width = 0.5*barCount * barWidth;
421 
422  const double scintillatorPosition_X = position.GetX(cs);
423  const double scintillatorPosition_Y = position.GetY(cs);
424 
425  // Limits for the interaction area
426  const double limitX1_r = scintillatorPosition_X + 0.5*gapLength - halo;
427  const double limitX2_r = scintillatorPosition_X + 0.5*gapLength + barLength + halo;
428  const double limitX1_l = scintillatorPosition_X - 0.5*gapLength + halo;
429  const double limitX2_l = scintillatorPosition_X - 0.5*gapLength - barLength - halo;
430 
431  const double limitY1 = scintillatorPosition_Y - 0.5*width - halo;
432  const double limitY2 = scintillatorPosition_Y + 0.5*width + halo;
433 
434  const double x = where.GetX(cs);
435  const double y = where.GetY(cs);
436  if (limitX1_r < x && x < limitX2_r && limitY1 < y && y < limitY2) // Try right panel
437  return true;
438  if (limitX2_l < x && x < limitX1_l && limitY1 < y && y < limitY2) // Try left panel
439  return true;
440 
441  return false;
442 }
443 
444 
445 bool
446 Scintillator::IsInsideBar(const Point& p, const double halo)
447  const
448 {
450  det::Detector::GetInstance().GetSDetector().GetStation(fStationId).GetLocalCoordinateSystem();
451  // check if in xy plane of either wing
452  if (!IsHit(p, Vector(0, 0, 1, cs), halo))
453  return false;
454  // check if z-coordinate is within bar height bounds
455  if (abs(p.GetZ(cs) - GetPosition().GetZ(cs)) > 0.5*GetBarThickness() + halo)
456  return false;
457 
458  return true;
459 }
460 
461 
462 double
464  const
465 {
466  const utl::Point& position = GetPosition();
467  const double x0 = position.GetX(position.GetCoordinateSystem());
468  const double y0 = position.GetY(position.GetCoordinateSystem());
469 
470  const double maxX = abs(x0) + 0.5*GetHousingLength() + GetCasingThickness();
471  const double maxY = abs(y0) + 0.5*GetHousingWidth() + GetCasingThickness();
472 
473  return hypot(maxX, maxY);
474 }
475 
476 
477 double
479  const
480 {
481  const utl::Point& position = GetPosition();
482  const double z = position.GetZ(position.GetCoordinateSystem());
484 }
485 
486 
487 void
489  const
490 {
491  // In this method we clean all the variables that might change with time.
492  fPosition.SetValid(false);
493 }
double GetBarLeakageExpCoefficient() const
utl::Validated< utl::Point > fPosition
Point object.
Definition: Point.h:32
bool IsHit(const utl::Point &from, const utl::Vector &direction, const double halo=0) const
CoordinateSystemPtr GetCoordinateSystem() const
Get the coordinate system of the current internal representation.
Definition: BasicVector.h:234
Status GetDataOrThrow(T &returnData, const std::string &component, const std::string &property, const IndexMap &index=IndexMap()) const
double GetBarExpDecayConstant() const
double GetReferenceEnergy() const
double GetHousingWidth() const
double GetAttenuationLength() const
Base class for exceptions trying to access non-existing components.
double GetFiberLength() const
double GetSandwichPanelThickness() const
Line Intersection(const Plane &p1, const Plane &p2)
Exception for reporting variable out of valid range.
std::vector< double > GetDistancesToPMT(const utl::Point &p) const
unsigned int GetNBars() const
double GetFiberUTurnDiameter() const
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Class describing a Plane object.
Definition: Plane.h:17
double GetHousingThickness() const
std::pair< double, double > GetDistancesToBarEnds(const utl::Point &p) const
double GetX(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:206
constexpr double kPi
Definition: MathConstants.h:24
double abs(const SVector< n, T > &v)
double GetBarLength() const
double GetBarLeakageMaxRatio() const
void NotFoundAndThrow(const std::string &msg) const
double GetFiberExpDecayConstant() const
det::VManager::IndexMap indexMap
double GetY(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:209
double GetCasingThickness() const
double GetReferencePENumber() const
utl::Point GetPosition() const
Register for detector description managers.
double GetBarThickness() const
Vector object.
Definition: Vector.h:30
double GetHousingLength() const
double GetRoofThickness() const
void SetValid(const bool valid=true)
Definition: Validated.h:66
Scintillator(const int stationId, const unsigned int isUUB)
double GetSigmaBarToBar() const
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:212
double GetEffectiveRefractiveIndex() const
constexpr double m
Definition: AugerUnits.h:121
bool IsInsideBar(const utl::Point &p, const double halo=0) const
Definition: Line.h:17

, generated on Tue Sep 26 2023.