4 #include <boost/format.hpp>
9 #include <TGraphErrors.h>
14 #include <sevt/Station.h>
22 using namespace boost;
23 using namespace SdCalibPlotterOG;
27 VEMTraceView::DividePage(TCanvas&
c)
29 const double xmargin = 0.003;
30 const double ymargin = 0.003;
31 const double vertDivision = 0.2;
33 TPad*
const savePad = (TPad*)gPad;
35 const string name = c.GetName();
38 os.str(
""); os << name <<
"_1";
39 const double x1 = xmargin;
40 const double x2 = vertDivision - 0.5*xmargin;
41 const double x3 = vertDivision + 0.5*xmargin;
42 const double x4 = 1 - xmargin;
43 const double y11 = ymargin;
44 const double y12 = 1 - ymargin;
45 TPad*
const pad1 =
new TPad(os.str().c_str(), os.str().c_str(), x1, y11, x2, y12, 0);
49 for (
int row = 0; row < nRows; ++row) {
50 const double y1 = 1 - (row+1)*(1 - ymargin)/nRows;
51 const double y2 = 1 - ymargin - row*(1 - ymargin)/nRows;
52 os.str(
""); os << name <<
'_' << n;
53 TPad*
const pad =
new TPad(os.str().c_str(), os.str().c_str(), x3, y1, x4, y2, 0);
55 pad->SetLeftMargin(0.5*pad->GetLeftMargin());
56 pad->SetRightMargin(0);
64 PMTVEMTraceView::Draw(
const PMT& pmt,
const int stationStart,
const int stationStop)
67 Missing(
"No Rec Data");
74 Missing(
"No VEM Trace");
80 const int traceLength = trace.
GetSize();
82 os <<
"PMT" << pmt.
GetId() <<
"_VEMTrace";
84 Add(
new TH1D(os.str().c_str(), os.str().c_str(), traceLength, 0, traceLength));
85 for (
int i = 0; i < traceLength; ++i)
86 th.SetBinContent(i+1, trace[i]);
88 th.SetLineColor(kRed);
92 const double xPeak[2] = { 0, double(traceLength) };
93 const double yPeak[2] = { peak, peak };
94 TGraph& pg = Add(
new TGraph(2, xPeak, yPeak));
95 pg.SetTitle(os.str().c_str());
96 pg.SetLineStyle(kDashed);
99 pg.GetXaxis()->SetLimits(0, traceLength);
100 pg.GetYaxis()->SetTitle(
"[VEM peak]");
101 pg.GetYaxis()->SetTitleOffset(0.3);
102 pg.GetYaxis()->SetTickLength(0.01);
103 TH1F& pgh = *pg.GetHistogram();
104 pgh.SetMinimum(th.GetMinimum());
105 pgh.SetMaximum(th.GetMaximum());
108 if (stationStart >= 0) {
109 const double x1[2] = { double(stationStart), double(stationStart) };
110 const double x2[2] = { double(stationStop), double(stationStop) };
111 const double y[2] = { -peak, 3*peak };
112 TGraph& ss1 = Add(
new TGraph(2, x1, y));
113 ss1.SetLineColor(kBlue);
114 ss1.SetLineStyle(kDashed);
116 TGraph& ss2 = Add(
new TGraph(2, x2, y));
117 ss2.SetLineColor(kBlue);
118 ss2.SetLineStyle(kDashed);
123 const double yZero[2] = { 0, 0 };
124 TGraph& zg = Add(
new TGraph(2, xPeak, yZero));
132 for (
unsigned int s = 0;
s < signals.size(); ++
s) {
133 double min = trace[signals[
s].fStart];
135 for (
int i = signals[
s].fStart+1; i < signals[
s].fStop; ++i) {
136 double val = trace[i];
142 const double eps = 0.1*(max - min);
143 const double y1 = min -
eps;
144 const double y2 = max +
eps;
145 if (y1 < pgh.GetMinimum())
147 if (y2 > pgh.GetMaximum())
150 const double plotSpan = pgh.GetMaximum() - pgh.GetMinimum();
151 for (
unsigned int s = 0;
s < signals.size(); ++
s) {
152 double min = trace[signals[
s].fStart];
154 for (
int i = signals[
s].fStart; i < signals[
s].fStop; ++i) {
155 double val = trace[i];
161 const double diff = max - min;
162 const double eps = 0.05*diff;
163 const double y1 = min -
eps;
164 const double y2 = max +
eps;
165 TBox& sb = Add(
new TBox(signals[
s].fStart, y1, signals[
s].fStop, y2));
169 const string& chargeStr = (format(
"%.2f") % signals[
s].fCharge).str();
170 if (diff < 0.35*plotSpan) {
171 const double x = 0.5*(signals[
s].fStart + signals[
s].fStop);
172 TArrow&
a = Add(
new TArrow(x, max + 0.3*plotSpan, x, max + 0.05*plotSpan, 0.01));
176 TText& t = Add(
new TText(signals[
s].fStart, max + 0.34*plotSpan, chargeStr.c_str()));
179 TText& t = Add(
new TText(signals[
s].fStop + 3, 0.3*min + 0.7*max, chargeStr.c_str()));
191 TPaveText& pt = Add(
new TPaveText(0.88,0.77,0.99,0.87,
"ndc"));
195 pt.SetFillColor(kWhite);
196 pt.AddText(
"From High Gain");
198 pt.SetFillColor(kCyan);
199 pt.AddText(
"From Low Gain");
208 TPaveText& pt = Add(
new TPaveText(0.92,0.64,0.99,0.74,
"ndc"));
211 pt.SetFillColor(kCyan);
212 pt.AddText((format(
"N_{sat} = %d ") % satBins).str().c_str());
219 TPaveText& pt = Add(
new TPaveText(0.9,0.90,0.99,1,
"ndc"));
222 pt.SetFillColor(kWhite);
223 pt.AddText((format(
"q = %.2f VEM") % pmtRec.
GetTotalCharge()).str().c_str());
230 StationVEMTraceView::Draw(
const Station& station)
233 Missing(
"No VEM Trace");
238 const int traceLength = trace.
GetSize();
239 const string titleStr = (format(
"Station_%04d_VEMTrace") % station.
GetId()).str();
242 const double xZero[2] = { 0., double(traceLength) };
243 const double yZero[2] = { 0, 0 };
244 TGraph& zg = Add(
new TGraph(2, xZero, yZero));
247 zg.SetTitle(titleStr.c_str());
249 zg.GetXaxis()->SetLimits(0, traceLength);
250 zg.GetYaxis()->SetTitle(
"[VEM peak]");
251 zg.GetYaxis()->SetTitleOffset(0.3);
252 zg.GetYaxis()->SetTickLength(0.01);
255 Add(
new TH1D(titleStr.c_str(),
"", traceLength, 0, traceLength));
256 for (
int i = 0; i < traceLength; ++i)
257 th.SetBinContent(i+1, trace[i]);
259 th.SetLineColor(kRed);
261 TH1F& zgh = *zg.GetHistogram();
262 zgh.SetMinimum(th.GetMinimum());
263 zgh.SetMaximum(th.GetMaximum());
268 for (
unsigned int s = 0;
s < signals.size(); ++
s) {
269 double min = trace[signals[
s].fStart];
271 for (
int i = signals[
s].fStart+1; i < signals[
s].fStop; ++i) {
272 double val = trace[i];
278 const double eps = 0.1*(max - min);
279 const double y1 = min -
eps;
280 const double y2 = max +
eps;
281 if (y1 < zgh.GetMinimum())
283 if (y2 > zgh.GetMaximum())
286 const double plotSpan = zgh.GetMaximum() - zgh.GetMinimum();
287 for (
unsigned int s = 0;
s < signals.size(); ++
s) {
288 double min = trace[signals[
s].fStart];
290 for (
int i = signals[
s].fStart; i < signals[
s].fStop; ++i) {
291 double val = trace[i];
297 const double diff = max - min;
298 const double eps = 0.05*diff;
299 const double y1 = min -
eps;
300 const double y2 = max +
eps;
301 TBox& sb = Add(
new TBox(signals[
s].fStart, y1, signals[
s].fStop, y2));
305 const string& chargeStr = (format(
"%.2f") % signals[
s].fCharge).str();
306 if (diff < 0.35*plotSpan) {
307 const double x = 0.5*(signals[
s].fStart + signals[
s].fStop);
308 TArrow&
a = Add(
new TArrow(x, max + 0.3*plotSpan, x, max + 0.05*plotSpan, 0.01));
312 TText& t = Add(
new TText(signals[
s].fStart, max + 0.34*plotSpan, chargeStr.c_str()));
315 TText& t = Add(
new TText(signals[
s].fStop + 3, 0.3*min + 0.7*max, chargeStr.c_str()));
322 Missing(
"No Rec Data");
331 double min = trace[start];
333 for (
int i = start; i < stop; ++i) {
334 double val = trace[i];
340 const double diff = max - min;
341 const double eps = 0.05*diff;
342 const double y1 = min -
eps;
343 const double y2 = max +
eps;
344 TBox& sb = Add(
new TBox(start, y1, stop, y2));
346 sb.SetLineColor(kBlue);
353 TPaveText& pt = Add(
new TPaveText(0.9,0.90,0.99,1,
"ndc"));
356 pt.SetFillColor(kWhite);
357 pt.AddText((format(
"q = %.2f VEM") % stRec.
GetTotalSignal()).str().c_str());
364 VEMTraceView::Missing(
const string& what)
366 TPaveText& pt = Add(
new TPaveText(0.3,0.4,0.7,0.6,
"ndc"));
368 pt.SetFillColor(kRed);
370 pt.AddText(what.c_str());
Class to access station level reconstructed data.
utl::TraceD & GetVEMTrace(const StationConstants::SignalComponent source=StationConstants::eTotal)
Traces calibrated in VEM Peak.
double GetTotalCharge() const
Total charge.
int GetId() const
Get the station Id.
bool HasRecData() const
Check for existenc of PMT reconstructed data object.
class to hold data at PMT level
PMTRecData & GetRecData()
Get object containing PMT reconstructed data.
sevt::StationRecData & GetRecData()
Get station level reconstructed data.
int GetFADCSaturatedBins(const sdet::PMTConstants::PMTGain gain=sdet::PMTConstants::eHighGain) const
unsigned int GetId() const
Return Id of the PMT.
utl::TraceD & GetVEMTrace(const StationConstants::SignalComponent source=StationConstants::eTotal)
signal trace calibrated in [VEM charge]
class to hold data at Station level
class to hold reconstructed data at PMT level
double GetTotalSignal() const
Total integrated signal in VEM unit, averaged over pmts.
unsigned int GetSignalStartSlot() const
Start time of the signal in time slots from beginning of trace.
bool HasVEMTrace(const StationConstants::SignalComponent source=StationConstants::eTotal) const
Check whether VEM trace exists.
unsigned int GetSignalEndSlot() const
End time of the signal in time slots from beginning of trace.
std::vector< SignalSegment > SignalSegmentCollection
sdet::PMTConstants::PMTGain GetGainUsed() const
bool HasRecData() const
Check whether station reconstructed data exists.
SignalSegmentCollection & GetSignals()
SignalSegmentCollection & GetSignals()
double GetPeakAmplitude() const
Peak Amplitude.
bool HasVEMTrace(const StationConstants::SignalComponent source=StationConstants::eTotal) const