1#ifndef G_AVALANCHE_GRID_H
2#define G_AVALANCHE_GRID_H
37 double vel = sqrt(vx * vx + vy * vy + vz * vz);
38 if (vel != std::abs(vx) && vel != std::abs(vy) && vel != std::abs(vz))
40 int nx = (int)vx / vel;
41 int ny = (int)vy / vel;
42 int nz = (int)vz / vel;
43 m_velNormal = {nx, ny, nz};
44 m_Velocity = -std::abs(vel);
56 m_DiffSigma = diffSigma;
66 const double t = 0,
const int n = 1);
71 void SetGrid(
const double xmin,
const double xmax,
const int xsteps,
72 const double ymin,
const double ymax,
const int ysteps,
73 const double zmin,
const double zmax,
const int zsteps);
90 double m_Townsend = -1;
92 double m_Attachment = -1;
94 double m_Velocity = 0.;
96 std::vector<int> m_velNormal = {0, 0, 0};
98 double m_MaxSize = 1.6e7;
100 bool m_Saturated =
false;
102 double m_SaturationTime =
105 bool m_diffusion =
false;
107 double m_DiffSigma = 0.;
111 bool m_driftAvalanche =
false;
112 bool m_importAvalanche =
false;
114 bool m_layerIndix =
false;
115 std::vector<double> m_NLayer;
117 std::string m_className =
"AvalancheGrid";
119 Sensor *m_sensor =
nullptr;
121 bool m_printPar =
false;
124 std::vector<double> zgrid;
129 std::vector<double> ygrid;
130 double yStepSize = 0.;
133 std::vector<double> xgrid;
134 double xStepSize = 0.;
137 bool gridset =
false;
145 struct AvalancheNode {
155 double attachment = 0;
159 std::vector<int> velNormal = {0, 0, 0};
169 std::vector<AvalancheNode> m_activeNodes = {};
173 void SetZGrid(Grid &av,
const double top,
const double bottom,
176 void SetYGrid(Grid &av,
const double top,
const double bottom,
179 void SetXGrid(Grid &av,
const double top,
const double bottom,
185 bool SnapToGrid(Grid &av,
const double x,
const double y,
const double z,
186 const double v,
const int n = 1);
188 void NextAvalancheGridPoint(Grid &av);
191 bool GetParameters(AvalancheNode &newNode);
193 void DeactivateNode(AvalancheNode &node);
void SetMaxAvalancheSize(const double size)
Set the maximum avalanche size (1e7 by default).
void AvalancheElectron(const double x, const double y, const double z, const double t=0, const int n=1)
void SetSensor(Sensor *sensor)
Set the sensor.
void SetElectronTownsend(const double town)
Set the electron Townsend coefficient (in 1 / cm).
void ImportElectronsFromAvalancheMicroscopic(AvalancheMicroscopic *avmc)
Import electron data from AvalancheMicroscopic class.
int GetAmountOfStartingElectrons()
Returns the initial number of electrons in the avalanche.
void StartGridAvalanche()
void SetElectronAttachment(const double att)
Set the electron attachment coefficient (in 1 / cm).
AvalancheGrid()
Constructor.
void SetElectronVelocity(const double vx, const double vy, const double vz)
Set the electron drift velocity (in cm / ns).
void AsignLayerIndex(ComponentParallelPlate *RPC)
Asigning layer index to all Avalanche nodes.
void EnableDiffusion(const double diffSigma)
void SetGrid(const double xmin, const double xmax, const int xsteps, const double ymin, const double ymax, const int ysteps, const double zmin, const double zmax, const int zsteps)
Import electron data from AvalancheMicroscopic class.
int GetAvalancheSize()
Returns the final number of electrons in the avalanche.
~AvalancheGrid()
Destructor.
Calculate electron drift lines and avalanches using microscopic tracking.
Component for parallel-plate geometries.