10 #include <TGraphErrors.h>
14 #include <boost/format.hpp>
22 using namespace boost;
23 using namespace SdCalibPlotterOG;
27 FADCTraceView::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 FADCTraceView::Draw(
const PMT& pmt)
68 Missing(
"No FADC Trace");
73 const auto traceLength = trace.
GetSize();
75 os <<
"PMT" << pmt.
GetId() <<
'_'
78 auto& th = Add(
new TH1D(os.str().c_str(),
"", traceLength, 0, traceLength));
79 for (
unsigned int i = 0; i < traceLength; ++i)
80 th.SetBinContent(i+1, trace[i]);
82 th.SetLineColor(kRed);
85 Missing(
"No PMT Rec Data");
93 if (!pmtRec.HasFADCBaseline(fGain))
94 Missing(
"No FADC Baseline");
97 bh = &Add(
new TH1D((os.str() +
"2").c_str(), os.str().c_str(), traceLength, 0, traceLength));
98 for (
unsigned int i = 0; i < traceLength; ++i)
99 bh->SetBinContent(i+1, baseline[i]);
101 bh->SetLineColor(kBlue);
102 bh->GetYaxis()->SetTitle(
"[FADC]");
103 bh->GetYaxis()->SetTitleOffset(0.23);
104 bh->GetYaxis()->SetTickLength(0.01);
109 const auto& signals = pmtRec.GetSignals();
110 const bool plotSignals =
113 for (
unsigned int s = 0,
ns = signals.size();
s <
ns; ++
s) {
114 Accumulator::MinMax<int>
mm(trace[signals[
s].fStart]);
115 for (
int i = signals[
s].fStart+1, n = signals[
s].fStop; i < n; ++i)
117 const double diff = 0.075*(mm.GetMax() - mm.GetMin());
118 const double newMin = mm.GetMin() - diff;
119 const double newMax = mm.GetMax() + diff;
120 if (th.GetMinimum() > newMin)
121 th.SetMinimum(newMin);
122 if (th.GetMaximum() < newMax)
123 th.SetMaximum(newMax);
128 bh->SetMinimum(th.GetMinimum());
129 bh->SetMaximum(th.GetMaximum());
135 const auto& rawSignals = pmtRec.GetRawSignals();
136 for (
unsigned int s = 0,
ns = rawSignals.size();
s <
ns; ++
s) {
137 Accumulator::MinMax<int>
mm(trace[rawSignals[
s].fStart]);
138 for (
int i = rawSignals[
s].fStart+1, n = rawSignals[
s].fStop; i < n; ++i)
140 const double diff = 0.025*(mm.GetMax() - mm.GetMin());
141 auto& sb = Add(
new TBox(rawSignals[
s].fStart, mm.GetMin() - diff,
142 rawSignals[
s].fStop, mm.GetMax() + diff));
144 sb.SetLineColor(kGreen);
149 for (
unsigned int s = 0, ns = signals.size();
s <
ns; ++
s) {
150 Accumulator::MinMax<int>
mm(trace[signals[
s].fStart]);
151 for (
int i = signals[
s].fStart+1, n = signals[
s].fStop; i < n; ++i)
153 const int diff = mm.GetMax() - mm.GetMin();
154 const double eps = 0.05*diff;
155 auto& sb = Add(
new TBox(signals[
s].fStart, mm.GetMin() -
eps,
156 signals[
s].fStop, mm.GetMax() +
eps));
160 const double plotSpan = th.GetMaximum() - th.GetMinimum();
161 if (diff < 0.3*plotSpan) {
162 const double x = 0.5*(signals[
s].fStop + signals[
s].fStart);
163 auto&
a = Add(
new TArrow(x, mm.GetMax() + 0.4*plotSpan,
164 x, mm.GetMax() + 0.1*plotSpan, 0.01));
176 if (fGain == pmtRec.GetGainUsed()) {
177 auto& pt = Add(
new TPaveText(0.95,0.77,0.99,0.87,
"ndc"));
180 pt.SetFillColor(kWhite);
186 if (pmtRec.GetFADCSaturatedBins(fGain)) {
187 auto& pt = Add(
new TPaveText(0.94,0.62,0.99,0.74,
"ndc"));
190 pt.SetFillColor(kCyan);
191 pt.AddText((format(
"N_{sat} = %d ") % pmtRec.GetFADCSaturatedBins(fGain)).str().c_str());
200 if (!pmtCalib.IsTubeOk()) {
201 auto& pt = Add(
new TPaveText(0.69,0.73,0.8,0.87,
"ndc"));
204 pt.SetFillColor(kRed);
205 pt.AddText(
"Tube not OK");
211 auto& pt = Add(
new TPaveText(0.92,0.90,0.99,1,
"ndc"));
214 pt.SetFillColor(kWhite);
215 pt.AddText((format(
"D/A = %.2f (%.2f)") % pmtRec.GetGainRatio() % pmtCalib.GetGainRatio()).str().c_str());
224 FADCTraceView::Missing(
const string& what)
226 auto& pt = Add(
new TPaveText(0.3,0.4,0.7,0.6,
"ndc"));
228 pt.SetFillColor(kRed);
230 pt.AddText(what.c_str());
bool HasRecData() const
Check for existenc of PMT reconstructed data object.
class to hold data at PMT level
PMTCalibData & GetCalibData()
Get object containing PMT calibration data.
PMTRecData & GetRecData()
Get object containing PMT reconstructed data.
bool HasCalibData() const
Check for existence of PMT calibration data object.
unsigned int GetId() const
Return Id of the PMT.
bool HasFADCTrace(const StationConstants::SignalComponent source=StationConstants::eTotal) const
Check if a FADC trace exists. Trace source may be specified.
utl::TraceI & GetFADCTrace(const sdet::PMTConstants::PMTGain gain=sdet::PMTConstants::eHighGain, const StationConstants::SignalComponent source=StationConstants::eTotal)
utl::TraceD & GetFADCBaseline(const sdet::PMTConstants::PMTGain gain=sdet::PMTConstants::eHighGain)