13 : m_className(
"ViewSignal"),
17 m_hasExternalCanvas(false),
18 m_hSignal(NULL), m_hSignalElectrons(NULL), m_hSignalIons(NULL),
26 if (!m_hasExternalCanvas && m_canvas)
delete m_canvas;
27 if (m_hSignal)
delete m_hSignal;
28 if (m_hSignalElectrons)
delete m_hSignalElectrons;
29 if (m_hSignalIons)
delete m_hSignalIons;
30 if (m_gCrossings)
delete m_gCrossings;
36 std::cerr << m_className <<
"::SetSensor: Null pointer.\n";
45 if (!m_hasExternalCanvas && m_canvas) {
50 m_hasExternalCanvas =
true;
54 const bool electron,
const bool ion) {
57 std::cerr << m_className <<
"::PlotSignal: Sensor is not defined.\n";
63 m_canvas =
new TCanvas();
64 m_canvas->SetTitle(
"Signal");
65 if (m_hasExternalCanvas) m_hasExternalCanvas =
false;
69 unsigned int nBins = 100;
70 double t0 = 0., dt = 1.;
78 const std::string hname = FindHistogramName(
"hSignal_");
79 m_hSignal =
new TH1D(hname.c_str(), label.c_str(), nBins, t0, t0 + nBins * dt);
81 m_hSignal->GetXaxis()->SetTitle(
"time [ns]");
82 m_hSignal->GetYaxis()->SetTitle(
"signal [fC / ns]");
84 for (
unsigned int i = 0; i < nBins; ++i) {
85 const double sig = m_sensor->
GetSignal(label, i);
86 m_hSignal->SetBinContent(i + 1, sig);
97 m_gCrossings =
new TGraph(nCrossings);
98 m_gCrossings->SetMarkerStyle(20);
100 double time = 0., level = 0.;
102 for (
int i = nCrossings; i--;) {
104 m_gCrossings->SetPoint(i, time, level);
110 if (nCrossings > 0) m_gCrossings->Draw(
"psame");
116 if (m_hSignalElectrons) {
117 delete m_hSignalElectrons;
118 m_hSignalElectrons = NULL;
120 const std::string hname = FindHistogramName(
"hSignalElectrons_");
121 m_hSignalElectrons =
new TH1D(hname.c_str(),
122 label.c_str(), nBins, t0, t0 + nBins * dt);
124 m_hSignalElectrons->GetXaxis()->SetTitle(
"time [ns]");
125 m_hSignalElectrons->GetYaxis()->SetTitle(
"signal [fC / ns]");
126 for (
unsigned int i = 0; i < nBins; ++i) {
128 m_hSignalElectrons->SetBinContent(i + 1, sig);
130 m_hSignalElectrons->Draw(
"same");
135 delete m_hSignalIons;
136 m_hSignalIons = NULL;
138 const std::string hname = FindHistogramName(
"hSignalIons_");
139 m_hSignalIons =
new TH1D(hname.c_str(),
140 label.c_str(), nBins, t0, t0 + nBins * dt);
142 m_hSignalIons->GetXaxis()->SetTitle(
"time [ns]");
143 m_hSignalIons->GetYaxis()->SetTitle(
"signal [fC / ns]");
144 for (
unsigned int i = 0; i < nBins; ++i) {
146 m_hSignalIons->SetBinContent(i + 1, sig);
148 m_hSignalIons->Draw(
"same");
153std::string ViewSignal::FindHistogramName(
const std::string& base)
const {
155 std::string hname = base +
"_0";
157 while (gDirectory->GetList()->FindObject(hname.c_str())) {
159 std::stringstream ss;
int GetRootColorElectron()
double GetElectronSignal(const std::string &label, const unsigned int bin)
double GetSignal(const std::string &label, const unsigned int bin)
bool GetThresholdCrossing(const unsigned int i, double &time, double &level, bool &rise) const
unsigned int GetNumberOfThresholdCrossings() const
void GetTimeWindow(double &tstart, double &tstep, unsigned int &nsteps)
double GetIonSignal(const std::string &label, const unsigned int bin)
void PlotSignal(const std::string &label, const bool total=true, const bool electron=false, const bool ion=false)
void SetSensor(Sensor *s)
Set the sensor from which to retrieve the signal.
void SetCanvas(TCanvas *c)
Set the pad on which to draw the histogram.
PlottingEngineRoot plottingEngine