Garfield++ v1r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
Garfield::ViewSignal Class Reference

#include <ViewSignal.hh>

Public Member Functions

 ViewSignal ()
 
 ~ViewSignal ()
 
void SetSensor (Sensor *s)
 
void SetCanvas (TCanvas *c)
 
void PlotSignal (const std::string label)
 
TH1D * GetHistogram ()
 
void EnableDebugging ()
 
void DisableDebugging ()
 

Detailed Description

Definition at line 14 of file ViewSignal.hh.

Constructor & Destructor Documentation

◆ ViewSignal()

Garfield::ViewSignal::ViewSignal ( )

Definition at line 11 of file ViewSignal.cc.

12 : m_className("ViewSignal"),
13 m_debug(false),
14 m_sensor(0),
15 m_canvas(0),
16 m_hasExternalCanvas(false),
17 m_hSignal(0),
18 m_gCrossings(0) {
19
21}
PlottingEngineRoot plottingEngine

◆ ~ViewSignal()

Garfield::ViewSignal::~ViewSignal ( )

Definition at line 23 of file ViewSignal.cc.

23 {
24
25 if (!m_hasExternalCanvas && m_canvas != 0) delete m_canvas;
26 if (m_hSignal != 0) delete m_hSignal;
27 if (m_gCrossings != 0) delete m_gCrossings;
28}

Member Function Documentation

◆ DisableDebugging()

void Garfield::ViewSignal::DisableDebugging ( )
inline

Definition at line 29 of file ViewSignal.hh.

29{ m_debug = false; }

◆ EnableDebugging()

void Garfield::ViewSignal::EnableDebugging ( )
inline

Definition at line 28 of file ViewSignal.hh.

28{ m_debug = true; }

◆ GetHistogram()

TH1D * Garfield::ViewSignal::GetHistogram ( )
inline

Definition at line 26 of file ViewSignal.hh.

26{ return m_hSignal; }

◆ PlotSignal()

void Garfield::ViewSignal::PlotSignal ( const std::string  label)

Definition at line 52 of file ViewSignal.cc.

52 {
53
54 if (m_sensor == 0) {
55 std::cerr << m_className << "::PlotSignal:\n";
56 std::cerr << " Sensor is not defined.\n";
57 return;
58 }
59
60 // Setup the canvas
61 if (m_canvas == 0) {
62 m_canvas = new TCanvas();
63 m_canvas->SetTitle("Signal");
64 if (m_hasExternalCanvas) m_hasExternalCanvas = false;
65 }
66 m_canvas->cd();
67
68 int nBins;
69 double t0, dt;
70 m_sensor->GetTimeWindow(t0, dt, nBins);
71
72 if (m_hSignal != 0) {
73 delete m_hSignal;
74 m_hSignal = 0;
75 }
76 m_hSignal = new TH1D("hSignal", label.c_str(), nBins, t0, t0 + nBins * dt);
77 m_hSignal->SetLineColor(plottingEngine.GetRootColorLine1());
78 m_hSignal->GetXaxis()->SetTitle("time [ns]");
79 m_hSignal->GetYaxis()->SetTitle("signal [fC / ns]");
80
81 double sig = 0.;
82 for (int i = nBins; i--;) {
83 sig = m_sensor->GetSignal(label, i);
84 m_hSignal->SetBinContent(i + 1, sig);
85 }
86
87 if (m_gCrossings != 0) {
88 delete m_gCrossings;
89 m_gCrossings = 0;
90 }
91
92 // Get threshold crossings.
93 const int nCrossings = m_sensor->GetNumberOfThresholdCrossings();
94 if (nCrossings > 0) {
95 m_gCrossings = new TGraph(nCrossings);
96 m_gCrossings->SetMarkerStyle(20);
97 m_gCrossings->SetMarkerColor(plottingEngine.GetRootColorLine1());
98 double time = 0., level = 0.;
99 bool rise = true;
100 for (int i = nCrossings; i--;) {
101 if (m_sensor->GetThresholdCrossing(i, time, level, rise)) {
102 m_gCrossings->SetPoint(i, time, level);
103 }
104 }
105 }
106
107 m_hSignal->Draw("");
108 if (nCrossings > 0) m_gCrossings->Draw("psame");
109 m_canvas->Update();
110}
bool GetThresholdCrossing(const int i, double &time, double &level, bool &rise)
Definition: Sensor.cc:961
int GetNumberOfThresholdCrossings()
Definition: Sensor.hh:103
void GetTimeWindow(double &tstart, double &tstep, int &nsteps)
Definition: Sensor.hh:84
double GetSignal(const std::string label, const int bin)
Definition: Sensor.cc:591

◆ SetCanvas()

void Garfield::ViewSignal::SetCanvas ( TCanvas *  c)

Definition at line 41 of file ViewSignal.cc.

41 {
42
43 if (c == 0) return;
44 if (!m_hasExternalCanvas && m_canvas != 0) {
45 delete m_canvas;
46 m_canvas = 0;
47 }
48 m_canvas = c;
49 m_hasExternalCanvas = true;
50}

◆ SetSensor()

void Garfield::ViewSignal::SetSensor ( Sensor s)

Definition at line 30 of file ViewSignal.cc.

30 {
31
32 if (s == 0) {
33 std::cerr << m_className << "::SetSensor:\n";
34 std::cerr << " Sensor pointer is null.\n";
35 return;
36 }
37
38 m_sensor = s;
39}

The documentation for this class was generated from the following files: