4#include <TApplication.h>
19int main(
int argc,
char * argv[]){
21 TApplication app(
"app", &argc, argv);
35 constexpr double bfield = 2.;
40 constexpr double yMesh = 0.01;
41 constexpr double vMesh = -500.;
46 constexpr double yDrift = yMesh + 0.3;
47 constexpr double vDrift = -3000.;
54 constexpr double pitch = 0.07;
56 constexpr double interstrip = 0.01;
58 constexpr double hw = 0.5 * (pitch - interstrip);
59 const double xStrip1 = hw;
61 const double xStrip2 = xStrip1 + pitch;
63 const double xStrip3 = xStrip2 + pitch;
75 sensor.
SetArea(0., 0., -1., 5 * pitch, yDrift, 1.);
83 const double tMin = 0.;
84 const double tMax = 100.;
85 const double tStep = 0.05;
86 const int nTimeBins = int((tMax - tMin) / tStep);
99 constexpr double momentum = 300.e6;
118 track.
NewTrack(xt, yt, zt, 0, 0, -1, 0);
120 double xc, yc, zc, tc, ec, extra;
122 while (track.
GetCluster(xc, yc, zc, tc, nc, ec, extra)) {
123 for (
int j = 0; j < nc; ++j) {
124 double xe, ye, ze, te, ee, dxe, dye, dze;
125 track.
GetElectron(j, xe, ye, ze, te, ee, dxe, dye, dze);
133 const double q1 = sensor.
GetSignal(
"strip1", nTimeBins - 1);
134 const double q2 = sensor.
GetSignal(
"strip2", nTimeBins - 1);
135 const double q3 = sensor.
GetSignal(
"strip3", nTimeBins - 1);
139 const double sum = q1 + q2 + q3;
140 double mean = (q1 * xStrip1 + q2 * xStrip2 + q3 * xStrip3) / sum;
141 const double res = fabs(xt - mean) * 10000.0;
142 std::cout <<
"---------------------------\n";
143 std::cout <<
"XMean: " << mean <<
" cm, XTrue: " << xt <<
" cm\n";
144 std::cout <<
"XTrue - XMean: " << res <<
" um\n";
145 std::cout <<
"---------------------------\n";
149 gStyle->SetPadRightMargin(0.15);
150 TCanvas* c1 =
new TCanvas(
"c1",
"", 1400, 600);
154 driftView.
SetArea(0.0, 0.0, 0.2, yDrift);
158 driftView.
Plot(
true);
163 fieldView.
Plot(
"v",
"cont1z");
165 c1->SaveAs(
"plot.pdf");
Calculate electron drift lines and avalanches using microscopic tracking.
void EnablePlotting(ViewDrift *view)
Switch on drift line plotting.
void EnableIonisationMarkers(const bool on=true)
Draw a marker at every ionising collision or not.
void SetSensor(Sensor *sensor)
Set the sensor.
void EnableExcitationMarkers(const bool on=true)
Draw a marker at every excitation or not.
void EnableSignalCalculation(const bool on=true)
Switch on calculation of induced currents (default: off).
void EnableMagneticField(const bool on=true)
Enable magnetic field in stepping algorithm (default: off).
bool AvalancheElectron(const double x0, const double y0, const double z0, const double t0, const double e0, const double dx0=0., const double dy0=0., const double dz0=0.)
Calculate an avalanche initiated by a given electron.
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 AddReadout(const std::string &label)
Setup the weighting field for a given group of wires or planes.
void SetMagneticField(const double bx, const double by, const double bz)
Set a constant magnetic field.
bool SetComposition(const std::string &gas1, const double f1=1., const std::string &gas2="", const double f2=0., const std::string &gas3="", const double f3=0., const std::string &gas4="", const double f4=0., const std::string &gas5="", const double f5=0., const std::string &gas6="", const double f6=0.)
Set the gas mixture.
void SetDefaultStyle()
Apply the default Garfield ROOT style.
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.
bool SetArea()
Set the user area to the default.
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.
Generate tracks using Heed++.
void EnableMagneticField()
Take the magnetic field into account in the stepping algorithm.
bool GetCluster(double &xcls, double &ycls, double &zcls, double &tcls, int &n, double &e, double &extra) override
bool NewTrack(const double x0, const double y0, const double z0, const double t0, const double dx0, const double dy0, const double dz0) override
bool GetElectron(const unsigned int i, double &x, double &y, double &z, double &t, double &e, double &dx, double &dy, double &dz)
void EnablePlotting(ViewDrift *viewer)
Switch on plotting.
void SetSensor(Sensor *s)
Set the sensor through which to transport the particle.
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)
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