4#include <TApplication.h>
19int main(
int argc,
char * argv[]){
21 TApplication app(
"app", &argc, argv);
34 constexpr double bfield = 2.;
39 constexpr double yMesh = 0.01;
40 constexpr double vMesh = -500.;
45 constexpr double yDrift = yMesh + 0.3;
46 constexpr double vDrift = -3000.;
53 constexpr double pitch = 0.07;
55 constexpr double interstrip = 0.01;
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;
69 sensor.
SetArea(0., 0., -1., 5 * pitch, yDrift, 1.);
77 const double tMin = 0.;
78 const double tMax = 100.;
79 const double tStep = 0.05;
80 const int nTimeBins = int((tMax - tMin) / tStep);
89 constexpr double momentum = 300.e6;
107 track.
NewTrack(xt, yt, zt, 0, 0, -1, 0);
110 for (
const auto& electron : cluster.electrons) {
113 electron.t, 0.1, 0., 0., 0.);
115 const auto& p1 = aval.
GetElectrons().front().path.back();
117 if (fabs(p1.y - yMesh) > 1.e-6)
continue;
120 p1.energy, 0, -1., 0.);
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);
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";
142 gStyle->SetPadRightMargin(0.15);
143 TCanvas* c1 =
new TCanvas(
"c1",
"", 1400, 600);
147 driftView.
SetArea(0.0, 0.0, 0.2, yDrift);
151 driftView.
Plot(
true);
156 fieldView.
Plot(
"v",
"cont1z");
158 c1->SaveAs(
"plot.pdf");
Calculate electron drift lines and avalanches using microscopic tracking.
const std::vector< Electron > & GetElectrons() const
void EnableIonisationMarkers(const bool on=true)
Draw a marker at every ionising collision or not.
void EnableExcitationMarkers(const bool on=true)
Draw a marker at every excitation or not.
bool AvalancheElectron(const double x, const double y, const double z, const double t, const double e, const double dx=0., const double dy=0., const double dz=0.)
Calculate an avalanche initiated by a given electron.
void EnablePlotting(ViewDrift *view, const size_t nColl=100)
Switch on drift line plotting.
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 EnableMagneticField()
Take the magnetic field into account in the stepping algorithm.
bool NewTrack(const double x0, const double y0, const double z0, const double t0, const double dx0, const double dy0, const double dz0) override
const std::vector< Cluster > & GetClusters() const
void EnablePlotting(ViewDrift *viewer)
Switch on plotting.
void SetMomentum(const double p)
Set the particle momentum.
virtual void SetParticle(const std::string &part)
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.
int main(int argc, char *argv[])
PlottingEngine plottingEngine