8 #include <TGraphErrors.h>
12 #include <boost/format.hpp>
20 using namespace boost;
21 using namespace SdCalibPlotterOG;
25 BaselineView::DividePage(TCanvas&
c)
27 const double xmargin = 0.003;
28 const double ymargin = 0.003;
29 const double vertDivision = 0.2;
31 TPad*
const savePad = (TPad*)gPad;
33 const string name = c.GetName();
36 os.str(
""); os << name <<
"_1";
37 const double x1 = xmargin;
38 const double x2 = vertDivision - 0.5*xmargin;
39 const double x3 = vertDivision + 0.5*xmargin;
40 const double x4 = 1 - xmargin;
41 const double y11 = ymargin;
42 const double y12 = 1 - ymargin;
43 TPad*
const pad1 =
new TPad(os.str().c_str(), os.str().c_str(), x1, y11, x2, y12, 0);
47 for (
int row = 0; row < nRows; ++row) {
48 const double y1 = 1 - (row+1)*(1 - ymargin)/nRows;
49 const double y2 = 1 - ymargin - row*(1 - ymargin)/nRows;
50 os.str(
""); os << name <<
'_' << n;
51 TPad*
const pad =
new TPad(os.str().c_str(), os.str().c_str(), x3, y1, x4, y2, 0);
53 pad->SetLeftMargin(0.5*pad->GetLeftMargin());
54 pad->SetRightMargin(0);
62 BaselineView::Draw(
const PMT& pmt)
65 Missing(
"No FADC Trace");
70 const int traceLength = trace.
GetSize();
72 os <<
"PMT" << pmt.
GetId() <<
'_'
76 Add(
new TH1D(os.str().c_str(), os.str().c_str(), traceLength, 0, traceLength));
77 for (
int i = 0; i < traceLength; ++i)
78 th.SetBinContent(i+1, trace[i]);
81 th.SetLineColor(kRed);
82 th.GetYaxis()->SetTitle(
"[FADC]");
83 th.GetYaxis()->SetTitleOffset(0.23);
84 th.GetYaxis()->SetTickLength(0.01);
87 Missing(
"No Rec Data");
98 TArrow& ba = Add(
new TArrow(0.2*traceLength, baseline, 0, baseline, 0.01));
103 Missing(
"No Baseline");
110 Add(
new TH1D((os.str() +
"2").c_str(),
"", traceLength, 0, traceLength));
111 for (
int i = 0; i < traceLength; ++i)
112 bh.SetBinContent(i+1, baseline[i]);
114 bh.SetLineColor(kBlue);
119 const double baseWidth =
max(baseError, 3.);
120 double baseMin = bh.GetMinimum();
121 double baseMax = bh.GetMaximum();
122 double baseMean = 0.5*(baseMin + baseMax);
123 double baseDiff = baseMax - baseMin;
124 baseMin -= 0.3*baseDiff;
125 baseMax += 0.3*baseDiff;
126 baseDiff = baseMax - baseMin;
127 if (baseDiff < 3*baseWidth) {
128 baseMin = baseMean - 1.5*baseWidth;
129 baseMax = baseMean + 1.5*baseWidth;
135 if (onlineBase < baseMean)
136 baseMin = 2*onlineBase - baseMax;
138 baseMax = 2*onlineBase - baseMin;
144 const int nFlat = flat.size();
146 for (
int i = 0; i < nFlat; ++i) {
147 const int start = flat[i].first;
148 const int y = trace[start];
149 const int min = y - sigma - 1;
152 const int max = y + sigma + 1;
157 baseMin = floor(baseMin);
158 baseMax = ceil(baseMax);
163 if (baseMax > (1<<10))
166 th.SetMinimum(baseMin);
167 th.SetMaximum(baseMax);
177 TGraphErrors& bg = Add(
new TGraphErrors(1, &x, &y, 0, &baseError));
178 bg.SetMarkerStyle(kCircle);
181 bg.SetLineColor(kGreen);
186 for (
int i = 0; i < nFlat; ++i) {
187 const int start = flat[i].first;
188 const int stop = flat[i].second;
189 const int y = trace[start];
190 TBox& bb = Add(
new TBox(start, y-sigma, stop, y+sigma));
198 TPaveText& pt = Add(
new TPaveText(0.95,0.77,0.99,0.87,
"ndc"));
201 pt.SetFillColor(kWhite);
208 TPaveText& pt = Add(
new TPaveText(0.94,0.62,0.99,0.74,
"ndc"));
211 pt.SetFillColor(kCyan);
222 TPaveText& pt = Add(
new TPaveText(0.69,0.73,0.8,0.87,
"ndc"));
225 pt.SetFillColor(kRed);
226 pt.AddText(
"Tube not OK");
232 TPaveText& pt = Add(
new TPaveText(0.92,0.90,0.99,1,
"ndc"));
235 pt.SetFillColor(kWhite);
245 BaselineView::Missing(
const string& what)
247 TPaveText& pt = Add(
new TPaveText(0.3,0.4,0.7,0.6,
"ndc"));
249 pt.SetFillColor(kRed);
251 pt.AddText(what.c_str());
bool HasRecData() const
Check for existenc of PMT reconstructed data object.
class to hold data at PMT level
bool HasFADCBaseline(const sdet::PMTConstants::PMTGain gain=sdet::PMTConstants::eHighGain) const
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.
double GetFADCBaselineError(const sdet::PMTConstants::PMTGain gain=sdet::PMTConstants::eHighGain) const
int GetFADCSaturatedBins(const sdet::PMTConstants::PMTGain gain=sdet::PMTConstants::eHighGain) const
unsigned int GetId() const
Return Id of the PMT.
FlatPieceCollection & GetBaselineFlatPieces(const sdet::PMTConstants::PMTGain gain=sdet::PMTConstants::eHighGain)
bool HasFADCTrace(const StationConstants::SignalComponent source=StationConstants::eTotal) const
Check if a FADC trace exists. Trace source may be specified.
class to hold reconstructed data at PMT level
int GetFADCBaselineWindow(const sdet::PMTConstants::PMTGain gain=sdet::PMTConstants::eHighGain) const
utl::TraceI & GetFADCTrace(const sdet::PMTConstants::PMTGain gain=sdet::PMTConstants::eHighGain, const StationConstants::SignalComponent source=StationConstants::eTotal)
double GetBaseline(const sdet::PMTConstants::PMTGain gain=sdet::PMTConstants::eHighGain) const
std::vector< Piece > FlatPieceCollection
sdet::PMTConstants::PMTGain GetGainUsed() const
utl::TraceD & GetFADCBaseline(const sdet::PMTConstants::PMTGain gain=sdet::PMTConstants::eHighGain)
double GetGainRatio() const
double GetGainRatio() const