19 {
20
21 TApplication app("app", &argc, argv);
23
24
26
27
28
33
34 constexpr double bfield = 2.;
37
38
39 constexpr double yMesh = 0.01;
40 constexpr double vMesh = -500.;
43
44
45 constexpr double yDrift = yMesh + 0.3;
46 constexpr double vDrift = -3000.;
49
50
51
52
53 constexpr double pitch = 0.07;
54
55 constexpr double interstrip = 0.01;
56
57 constexpr double hw = 0.5 * (pitch - interstrip);
58 const double xStrip1 = hw;
60 const double xStrip2 = xStrip1 + pitch;
62 const double xStrip3 = xStrip2 + pitch;
64
65
69 sensor.
SetArea(0., 0., -1., 5 * pitch, yDrift, 1.);
70
71
75
76
77 const double tMin = 0.;
78 const double tMax = 100.;
79 const double tStep = 0.05;
80 const int nTimeBins = int((tMax - tMin) / tStep);
82
83
85
86
88 track.SetParticle("pi-");
89 constexpr double momentum = 300.e6;
90 track.SetMomentum(momentum);
91 track.EnableMagneticField();
92
93
94
96 track.EnablePlotting(&driftView);
97 aval.EnablePlotting(&driftView);
98 aval.EnableExcitationMarkers(false);
99 aval.EnableIonisationMarkers(false);
100
101
102 double xt = 0.05;
103 double yt = yDrift;
104 double zt = 0.0;
105
106
107 track.NewTrack(xt, yt, zt, 0, 0, -1, 0);
108
109 for (const auto& cluster : track.GetClusters()) {
110 for (const auto& electron : cluster.electrons) {
111
112 aval.AvalancheElectron(electron.x, electron.y, electron.z,
113 electron.t, 0.1, 0., 0., 0.);
114
115 const auto& p1 = aval.GetElectrons().front().path.back();
116
117 if (
fabs(p1.y - yMesh) > 1.e-6)
continue;
118
119 aval.AvalancheElectron(p1.x, yMesh - 1.e-6, p1.z, p1.t,
120 p1.energy, 0, -1., 0.);
121 }
122 }
123
124
126 const double q1 = sensor.
GetSignal(
"strip1", nTimeBins - 1);
127 const double q2 = sensor.
GetSignal(
"strip2", nTimeBins - 1);
128 const double q3 = sensor.
GetSignal(
"strip3", nTimeBins - 1);
129
130
131
132 const double sum = q1 + q2 + q3;
133 double mean = (q1 * xStrip1 + q2 * xStrip2 + q3 * xStrip3) / sum;
134 const double res =
fabs(xt - mean) * 10000.0;
135 std::cout << "---------------------------\n";
136 std::cout << "XMean: " << mean << " cm, XTrue: " << xt << " cm\n";
137 std::cout << "XTrue - XMean: " << res << " um\n";
138 std::cout << "---------------------------\n";
139
140
141
142 gStyle->SetPadRightMargin(0.15);
143 TCanvas* c1 = new TCanvas("c1", "", 1400, 600);
144 c1->Divide(2, 1);
145
146
147 driftView.
SetArea(0.0, 0.0, 0.2, yDrift);
151 driftView.
Plot(
true);
152
156 fieldView.
Plot(
"v",
"cont1z");
157
158 c1->SaveAs("plot.pdf");
159 app.Run(true);
160 return 0;
161
162}
Calculate electron drift lines and avalanches using microscopic tracking.
void SetMedium(Medium *medium)
Set the medium inside the cell.
void AddPlaneY(const double y, const double voltage, const std::string &label="")
Add a plane at constant y.
void AddStripOnPlaneY(const char direction, const double y, const double smin, const double smax, const std::string &label, const double gap=-1.)
Add a strip in the x or z direction on an existing plane at constant y.
void SetMagneticField(const double bx, const double by, const double bz)
Set a constant magnetic field.
void SetTimeWindow(const double tstart, const double tstep, const unsigned int nsteps)
void AddElectrode(Component *comp, const std::string &label)
Add an electrode.
void AddComponent(Component *comp)
Add a component.
double GetSignal(const std::string &label, const unsigned int bin)
Retrieve the total signal for a given electrode and time bin.
bool IntegrateSignals()
Replace the signals on all electrodes curve by their integrals.
bool SetArea(const bool verbose=false)
Set the user area to the default.
Generate tracks using Heed++.
void SetCanvas(TPad *pad)
Set the canvas to be painted on.
void SetArea(const double xmin, const double ymin, const double xmax, const double ymax)
Visualize drift lines and tracks.
void Plot(const bool twod=false, const bool axis=true, const bool snapshot=false)
Draw the drift lines.
void SetClusterMarkerSize(const double size)
Set the size of the cluster markers (see TAttMarker).
void SetCollisionMarkerSize(const double size)
Set the size of the collision markers (see TAttMarker).
Visualize the potential or electric field of a component or sensor.
void Plot(const std::string &option="v", const std::string &drawopt="arr")
void SetSensor(Sensor *s)
Set the sensor for which to plot the field.
PlottingEngine plottingEngine
DoubleAc fabs(const DoubleAc &f)