31 {
32
33 TApplication app("app", &argc, argv);
34
35
36
37 const double lem_th = 0.04;
38
39 const double lem_cpth = 0.0035;
40
41 const double lem_pitch = 0.07;
42
43 const double axis_x = 0.1;
44
45 const double axis_y = 0.1;
46 const double axis_z = 0.25 + lem_th / 2 + lem_cpth;
47
48
49
51
52 gas.SetTemperature(293.15);
53
54 gas.SetPressure(740.);
55
56
58 "gemcell/mesh.header", "gemcell/mesh.elements", "gemcell/mesh.nodes",
59 "gemcell/dielectrics.dat", "gemcell/gemcell.result", "cm");
60 elm.EnablePeriodicityX();
61 elm.EnableMirrorPeriodicityY();
62 elm.SetGas(&gas);
63
64
65
66
69 sensor.
SetArea(-axis_x, -axis_y, -axis_z, axis_x, axis_y, axis_z);
70
71
72 const double tEnd = 500.0;
73 const int nsBins = 500;
74
75
76
78
79
81 viewDrift.
SetArea(-axis_x, -axis_y, -axis_z, axis_x, axis_y, axis_z);
82 aval.EnablePlotting(&viewDrift, 100);
83
84
85
86 const double zi = 0.5 * lem_th + lem_cpth + 0.1;
89 double xi = ri *
cos(thetai);
90 double yi = ri *
sin(thetai);
91
92 aval.AvalancheElectron(xi, yi, zi, 0., 0., 0., 0., 0.);
93 std::cout << "... avalanche complete with "
94 << aval.GetNumberOfElectronEndpoints() << " electron tracks.\n";
95
96
97 double bscale = tEnd / nsBins;
98 double sum = 0.;
99
100
101 TFile* f = new TFile("avalanche_signals.root", "RECREATE");
102 TH1F* hS = new TH1F("hh", "hh", nsBins, 0, tEnd);
103 TH1F* hInt = new TH1F("hInt", "hInt", nsBins, 0, tEnd);
104
105
106
107
108
109
110 for (int i = 0; i < nsBins; i++) {
111 double wt = sensor.
GetSignal(
"wtlel", i) / ElementaryCharge;
112 sum += wt;
113 hS->Fill(i * bscale, wt);
114 hInt->Fill(i * bscale, sum);
115 }
116
117
118 hS->Write();
119 hInt->Write();
120 f->Close();
121
122
123 const bool plotSignal = false;
124 if (plotSignal) {
125 TCanvas* cSignal = new TCanvas("signal", "Signal");
130 }
131
132
133 TCanvas* cGeom = new TCanvas("geom", "Geometry/Avalanche/Fields");
134 cGeom->SetLeftMargin(0.14);
135 const bool plotContours = false;
136 if (plotContours) {
140 vf->
SetArea(-axis_x, -axis_y, axis_x, axis_y);
145 }
146
147
149 vFE.
SetArea(-axis_x, -axis_z, -axis_y, axis_x, axis_z, axis_y);
157 if (!plotContours) {
163 }
164
165 app.Run();
166 return 0;
167}
Calculate electron drift lines and avalanches using microscopic tracking.
Component for importing field maps computed by Elmer.
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 SetArea(const bool verbose=false)
Set the user area to the default.
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)
virtual void SetPlane(const double fx, const double fy, const double fz, const double x0, const double y0, const double z0)
Visualize drift lines and tracks.
Draw the mesh of a field-map component.
bool Plot(const bool twod=true)
Plot method to be called by user.
void SetYaxisTitle(const std::string &ytitle)
void SetViewDrift(ViewDrift *vd)
Set the optional associated ViewDrift.
void SetXaxisTitle(const std::string &xtitle)
void SetPlane(const double fx, const double fy, const double fz, const double x0, const double y0, const double z0) override
void SetComponent(ComponentFieldMap *cmp)
Set the component from which to retrieve the mesh and field.
void SetColor(int matID, int colorID)
void SetFillMesh(const bool f)
Element fill switch; 2D only, set false for wireframe mesh.
Visualize the potential or electric field of a component or sensor.
void SetNumberOfSamples2d(const unsigned int nx, const unsigned int ny)
Set the number of points used for drawing 2D functions.
void PlotContour(const std::string &option="v")
void SetNumberOfContours(const unsigned int n)
Set the number of contour levels.
void SetSensor(Sensor *s)
Set the sensor for which to plot the field.
Plot the signal computed by a sensor as a ROOT histogram.
void SetSensor(Sensor *s)
Set the sensor from which to retrieve the signal.
void PlotSignal(const std::string &label, const std::string &optTotal="t", const std::string &optPrompt="", const std::string &optDelayed="", const bool same=false)
double RndmUniform()
Draw a random number uniformly distributed in the range [0, 1).
DoubleAc cos(const DoubleAc &f)
DoubleAc sin(const DoubleAc &f)