HerdSoftware  0.1.1
DistributionFiberTool.h
Go to the documentation of this file.
1 /*
2  * DistributionFiberTool.h
3  *
4  * This tool calculates the fraction of the total path length
5  * of a track in the core of each fibre that was hit along with
6  * the position of the fibre.
7  *
8  * Created on 03 Mar 2020
9  * Author: Valerio Formato (based on code by Junjing Wang)
10  */
11 
12 #ifndef HERD_DISTRIBUTIONFIBERTOOL_H_
13 #define HERD_DISTRIBUTIONFIBERTOOL_H_
14 
15 // HerdSoftware headers
16 #include "common/Benchmark.h"
18 #include "dataobjects/Point.h"
19 
20 // C++ headers
21 #include <cmath>
22 #include <vector>
23 
24 // this in c++17 will become
25 // namespace Herd::FitDigitizationTools {
26 namespace Herd {
27 namespace FitDigitizationTools {
28 
29 namespace MCFT {
30 
31 class Vec2 : public Vec3D {
32 public:
33  Vec2() : Vec3D(std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), 0) {}
34  Vec2(float u, float v) : Vec3D(u, v, 0) {}
35 
36  Vec2(const Vec3D &vec) : Vec2(vec[RefFrame::Coo::X], vec[RefFrame::Coo::Y]) {}
37 
38  // float u() { return (*this)[RefFrame::Coo::X]; }
39  // float v() { return (*this)[RefFrame::Coo::Y]; }
40 };
41 
42 double distanceToSquared(const Vec2 &v, const Vec2 &p);
43 double distanceTo(const Vec2 &v, const Vec2 &p);
44 double minDistanceFromLineSegmentToPoint(const Vec2 &v, const Vec2 &w, const Vec2 &p);
45 double minDistanceFromLineToPoint(const Vec2 &v, const Vec2 &w, const Vec2 &p);
46 
47 inline double getXOnPath(const Vec2 &entry, const Vec2 &exit, double z) {
48  return entry[RefFrame::Coo::X] + (exit[RefFrame::Coo::X] - entry[RefFrame::Coo::X]) /
49  (exit[RefFrame::Coo::Y] - entry[RefFrame::Coo::Y]) *
50  (z - entry[RefFrame::Coo::Y]);
51 }
52 
53 inline double getZOnPath(const Vec2 &entry, const Vec2 &exit, double x) {
54  return entry[RefFrame::Coo::Y] + (exit[RefFrame::Coo::Y] - entry[RefFrame::Coo::Y]) /
55  (exit[RefFrame::Coo::X] - entry[RefFrame::Coo::X]) *
56  (x - entry[RefFrame::Coo::X]);
57 }
58 
59 } // namespace MCFT
60 
62 public:
64  ~DistributionFiberTool() = default;
65 
66  std::vector<std::pair<Point, double>> effectivePathFracInCores(const Point &enPoint, const Point &exPoint,
67  const FitGeoParams &geoParams) const;
68 
69  void setMatWidth(float matWidth);
70 
71 private:
82  inline double getFiberX(unsigned int iLayer, int iFiber) const {
83  return m_fibrePitch * (iFiber + 0.5 * (iLayer % 2));
84  }
85  inline double getFiberZ(unsigned int iLayer) const { return (iLayer - 0.5 * (m_nlayers - 1)) * m_deltaZ; }
86 
87  inline double firstFiber(unsigned int iLayer) const { return ((iLayer % 2) == 0) ? m_firstFiber0 : m_firstFiber1; }
88 
89  inline double lastFiber(unsigned int iLayer) const { return ((iLayer % 2) == 0) ? -m_firstFiber0 : m_lastFiber1; }
90 
91  void initNFibers(unsigned int nFibers);
92 
97  std::pair<int, int> getAdjacentFiberIds(double x, double dx_over_dz, unsigned int iLayer) const;
98 
99  // const double m_fibreDiameter = 0.025; // Diameter of the fiber in the fiber mats
100  const double m_fibreCoreRadius = 0.011; // Radius of the fiber core
101  const double m_fibrePitch = 0.0275; // Distance between two neighbour fibre centers in x-direction
102  const double m_deltaZ = 0.021; // Pitch in z-direction
103  // junjing 0809
104  int m_nlayers = 6; // Number of layers
105 
106  // ()()()
107  // ()()()()
108  // ()()()
109  // ()()()()
110  // ()()()
111  // ()()()()
112 
113  const double m_crossTalkProb = 0.193; // Probability of cross talk between fibers
114  const double m_CTmodelTouching = 0.163; // Fraction of cross talk going to the each of the 4 neighbors touching fibers
115  const double m_CTmodelSide = 0.147; // Fraction of cross talk going to each of the 2 neighbors on the sides
116  const double m_CTmodel2layers = 0.028; // Fraction of cross talk going to each of the 2 neighbors on the same column
117  //*/
118 
119  double m_minZ;
120  unsigned int m_nFibers = 355;
124 };
125 } // namespace FitDigitizationTools
126 } // namespace Herd
127 
128 #endif
Coo
Aliases for the three space coordinates. RefFrame.h common/RefFrame.h.
Definition: RefFrame.h:24
CssGeoParams.h CssGeoParams class declaration.
Definition: CaloPDCalibrationAlgo.h:24
int m_firstFiber1
Definition: DistributionFiberTool.h:122
double getFiberZ(unsigned int iLayer) const
Definition: DistributionFiberTool.h:85
Vec2()
Definition: DistributionFiberTool.h:33
Data structure for single silicon layer geometry parameters.
Definition: FitGeoParams.h:64
double getZOnPath(const Vec2 &entry, const Vec2 &exit, double x)
Definition: DistributionFiberTool.h:53
Vec2(const Vec3D &vec)
Definition: DistributionFiberTool.h:36
int m_firstFiber0
Definition: DistributionFiberTool.h:121
Definition: DistributionFiberTool.h:61
A class describing a vector in 3D space.
Definition: Vec3D.h:33
Definition: DistributionFiberTool.h:31
double m_minZ
Definition: DistributionFiberTool.h:119
double firstFiber(unsigned int iLayer) const
Definition: DistributionFiberTool.h:87
double minDistanceFromLineToPoint(const Vec2 &v, const Vec2 &w, const Vec2 &p)
Definition: DistributionFiberTool.cpp:280
double getXOnPath(const Vec2 &entry, const Vec2 &exit, double z)
Definition: DistributionFiberTool.h:47
double minDistanceFromLineSegmentToPoint(const Vec2 &v, const Vec2 &w, const Vec2 &p)
Definition: DistributionFiberTool.cpp:262
double distanceToSquared(const Vec2 &v, const Vec2 &p)
Definition: DistributionFiberTool.cpp:255
int m_lastFiber1
Definition: DistributionFiberTool.h:123
double distanceTo(const Vec2 &v, const Vec2 &p)
Definition: DistributionFiberTool.cpp:260
double lastFiber(unsigned int iLayer) const
Definition: DistributionFiberTool.h:89
Vec2(float u, float v)
Definition: DistributionFiberTool.h:34
double getFiberX(unsigned int iLayer, int iFiber) const
Definition: DistributionFiberTool.h:82