16 std::cerr <<
m_className <<
"::SetSensor: Null pointer.\n";
24 if (fabs(xmax - xmin) < Small) {
25 std::cerr <<
m_className <<
"::SetRangeX: Invalid range.\n";
28 m_xmin = std::min(xmin, xmax);
29 m_xmax = std::max(xmin, xmax);
35 if (fabs(ymax - ymin) < Small) {
36 std::cerr <<
m_className <<
"::SetRangeY: Invalid range.\n";
39 m_ymin = std::min(ymin, ymax);
40 m_ymax = std::max(ymin, ymax);
45 const bool electron,
const bool ion,
48 std::cerr <<
m_className <<
"::PlotSignal: Sensor is not defined.\n";
60 unsigned int nBins = 100;
61 double t0 = 0., dt = 1.;
63 const double t1 = t0 + nBins * dt;
65 const auto title = label.c_str();
66 std::string xlabel =
"time [ns]";
67 std::string ylabel = m_labelY;
69 ylabel = m_sensor->
IsIntegrated() ?
"signal [fC]" :
"signal [fC / ns]";
73 m_hSignal.reset(
new TH1D(hname, title, nBins, t0, t1));
75 m_hSignal->GetXaxis()->SetTitle(xlabel.c_str()),
76 m_hSignal->GetYaxis()->SetTitle(ylabel.c_str());
77 m_hSignal->SetStats(0);
78 for (
unsigned int i = 0; i < nBins; ++i) {
79 const double sig = m_sensor->
GetSignal(label, i);
80 m_hSignal->SetBinContent(i + 1, sig);
83 if (m_userRangeX) m_hSignal->SetAxisRange(m_xmin, m_xmax,
"X");
84 if (m_userRangeY) m_hSignal->SetAxisRange(m_ymin, m_ymax,
"Y");
89 m_gCrossings.reset(
new TGraph(nCrossings));
90 m_gCrossings->SetMarkerStyle(20);
92 double time = 0., level = 0.;
94 for (
unsigned int i = 0; i < nCrossings; ++i) {
96 m_gCrossings->SetPoint(i, time, level);
99 m_gCrossings->Draw(
"psame");
104 m_hDelayedSignal.reset(
new TH1D(hname, title, nBins, t0, t1));
105 m_hDelayedSignal->SetLineColor(kCyan + 2);
106 m_hDelayedSignal->SetLineStyle(2);
107 m_hDelayedSignal->SetStats(0);
108 for (
unsigned int i = 0; i < nBins; ++i) {
111 m_hDelayedSignal->SetBinContent(i + 1, sig);
113 m_hDelayedSignal->Draw(
"same");
121 m_hSignalElectrons.reset(
new TH1D(hname, title, nBins, t0, t1));
123 m_hSignalElectrons->GetXaxis()->SetTitle(xlabel.c_str());
124 m_hSignalElectrons->GetYaxis()->SetTitle(ylabel.c_str());
125 m_hSignalElectrons->SetStats(0);
126 for (
unsigned int i = 0; i < nBins; ++i) {
128 m_hSignalElectrons->SetBinContent(i + 1, sig);
130 m_hSignalElectrons->Draw(
"same");
132 if (m_userRangeX) m_hSignalElectrons->SetAxisRange(m_xmin, m_xmax,
"X");
133 if (m_userRangeY) m_hSignalElectrons->SetAxisRange(m_ymin, m_ymax,
"Y");
137 m_hDelayedSignalElectrons.reset(
new TH1D(hname, title, nBins, t0, t1));
138 m_hDelayedSignalElectrons->SetLineColor(kYellow - 7);
139 m_hDelayedSignalElectrons->SetLineStyle(2);
140 m_hDelayedSignalElectrons->SetStats(0);
141 for (
unsigned int i = 0; i < nBins; ++i) {
143 m_hDelayedSignalElectrons->SetBinContent(i + 1, sig);
145 m_hDelayedSignalElectrons->Draw(
"same");
151 m_hSignalIons.reset(
new TH1D(hname, title, nBins, t0, t1));
153 m_hSignalIons->GetXaxis()->SetTitle(xlabel.c_str());
154 m_hSignalIons->GetYaxis()->SetTitle(ylabel.c_str());
155 m_hSignalIons->SetStats(0);
156 for (
unsigned int i = 0; i < nBins; ++i) {
158 m_hSignalIons->SetBinContent(i + 1, sig);
160 m_hSignalIons->Draw(
"same");
161 if (!(total || electron)) {
162 if (m_userRangeX) m_hSignalIons->SetAxisRange(m_xmin, m_xmax,
"X");
163 if (m_userRangeY) m_hSignalIons->SetAxisRange(m_ymin, m_ymax,
"Y");
167 m_hDelayedSignalIons.reset(
new TH1D(hname, title, nBins, t0, t1));
168 m_hDelayedSignalIons->SetLineColor(kRed - 9);
169 m_hDelayedSignalIons->SetLineStyle(2);
170 m_hDelayedSignalIons->SetStats(0);
171 for (
unsigned int i = 0; i < nBins; ++i) {
173 m_hDelayedSignalIons->SetBinContent(i + 1, sig);
175 m_hDelayedSignalIons->Draw(
"same");
int GetRootColorElectron()
bool IsIntegrated() const
Return whether the signal has been integrated/convoluted.
double GetElectronSignal(const std::string &label, const unsigned int bin)
Retrieve the electron signal for a given electrode and time bin.
double GetDelayedIonSignal(const std::string &label, const unsigned int bin)
Retrieve the delayed ion/hole signal for a given electrode and time bin.
void GetTimeWindow(double &tstart, double &tstep, unsigned int &nsteps) const
Retrieve the time window and binning.
double GetSignal(const std::string &label, const unsigned int bin)
Retrieve the total signal for a given electrode and time bin.
bool GetThresholdCrossing(const unsigned int i, double &time, double &level, bool &rise) const
unsigned int GetNumberOfThresholdCrossings() const
double GetDelayedElectronSignal(const std::string &label, const unsigned int bin)
Retrieve the delayed electron signal for a given electrode and time bin.
double GetIonSignal(const std::string &label, const unsigned int bin)
Retrieve the ion or hole signal for a given electrode and time bin.
Base class for visualization classes.
std::string FindUnusedHistogramName(const std::string &s) const
void SetSensor(Sensor *s)
Set the sensor from which to retrieve the signal.
void PlotSignal(const std::string &label, const bool total=true, const bool electron=false, const bool ion=false, const bool delayed=false)
void SetRangeY(const double ymin, const double ymax)
Set the y-axis limits explicitly.
void SetRangeX(const double xmin, const double xmax)
Set the x-axis limits explicitly.
PlottingEngineRoot plottingEngine