10 #include "../TPadManipulator.h" 17 #include "TTimeStamp.h" 30 const string myname =
"test_TPadManipulator: ";
31 cout << myname <<
"Starting test" <<
endl;
33 cout << myname <<
"NDEBUG must be off." <<
endl;
36 string line =
"-----------------------------";
39 cout << myname << line <<
endl;
40 cout << myname <<
"Test data" <<
endl;
42 cout << myname << line <<
endl;
43 cout << myname <<
"Create histogram." <<
endl;
45 TH1* ph =
new TH1F(
"h1",
"My histo; X values; Y value [units]", 100, 0, xmax);
48 for (
unsigned int ibin=1; ibin<=100; ++ ibin ) {
49 ph->SetBinContent(ibin, ibin-1);
52 cout << myname << line <<
endl;
53 cout << myname <<
"Create manipulator" <<
endl;
58 assert( man.
pad() == nullptr );
59 assert( man.
hist() == nullptr );
61 cout << myname << line <<
endl;
62 cout << myname <<
"Add histogram." <<
endl;
65 TLatex lin(0.15, 0.85,
"Test of TPadManipulator");
70 TLatex lin(0.15, 0.80,
"Histogram");
74 assert( man.
hist() != nullptr );
76 cout << myname << line <<
endl;
77 cout << myname <<
"Add axis." <<
endl;
80 cout << myname << line <<
endl;
81 cout << myname <<
"Add vertical mod lines." <<
endl;
84 cout << myname << line <<
endl;
85 cout << myname <<
"Add sloped lines." <<
endl;
89 cout << myname << line <<
endl;
90 cout << myname <<
"Add label." <<
endl;
92 man.
setLabel(
"This is my #beta data for E_{tot} = m#timesC^{2}.");
95 cout << myname << line <<
endl;
96 cout << myname <<
"Copy the pad and draw copy with time format." <<
endl;
97 *pmantop->
man(1) = *pmantop->
man(0);
104 TLatex lin(0.15, 0.75,
"Zoomed");
106 pmantop->
man(1)->
add(&lin);
109 TLatex lin(0.15, 0.70,
"Time format");
111 pmantop->
man(1)->
add(&lin);
114 cout << myname << line <<
endl;
115 cout << myname <<
"Draw." <<
endl;
116 assert( man.
pad() == nullptr );
118 assert( man.
pad() != nullptr );
120 cout << myname << line <<
endl;
121 cout << myname <<
"Draw." <<
endl;
122 pmantop->
print(
"test_TPadManipulator.png");
124 cout << myname << line <<
endl;
125 cout << myname <<
"Copy the full plot." <<
endl;
127 cout << myname <<
"Old subpad: " << pmantop->
man(0) <<
endl;
128 cout << myname <<
"Old canvas: " << pmantop <<
endl;
129 cout << myname <<
"Old subpad parent: " << pmantop->
man(0)->
parent() <<
endl;
130 cout << myname <<
"New subpad: " << man2.
man(0) <<
endl;
131 cout << myname <<
"New canvas: " << &man2 <<
endl;
132 cout << myname <<
"New subpad parent: " << man2.
man(0)->
parent() <<
endl;
134 cout << myname << line <<
endl;
135 cout << myname <<
"Change title and y-label size on copy." <<
endl;
144 cout << myname << line <<
endl;
145 cout << myname <<
"Draw copy." <<
endl;
146 man2.
print(
"test_TPadManipulator-copy.{png,pdf,tpad}");
150 cout << myname << line <<
endl;
151 cout << myname <<
"Create time graph." <<
endl;
152 TGraph* pg =
new TGraph;
153 pg->SetTitle(
"Clock");
154 pg->GetXaxis()->SetTitle(
"March 6 daytime minutes");
155 pg->GetYaxis()->SetTitle(
"Minute");
156 pg->SetMarkerStyle(2);
158 TTimeStamp ts0(2019, 3, 6, 6, 0, 0);
159 for (
int i=0; i<12*60; ++i ) {
160 double tsec = ts0 + 60*i;
161 double min = fmod(i, 60);
162 pg->SetPoint(i, tsec, min);
167 double t0 = ts0.AsDouble();
171 mant.
print(
"test_TPadManipulator-time.png");
173 cout << myname << line <<
endl;
174 string rfnam =
"test_TPadManipulator.root";
175 cout << myname <<
"Write pad to " << rfnam <<
endl;
177 assert( pmantop->
print(rfnam) == 0 );
179 cout << myname << line <<
endl;
180 cout << myname <<
"Read pad from " << rfnam <<
endl;
182 assert( pmani !=
nullptr );
185 TLatex lin(0.01, 0.97,
"Read from file");
189 pmani->
print(
"test_TPadManipulator-read.png");
191 cout << myname << line <<
endl;
192 cout << myname <<
"Root canvas count: " << gROOT->GetListOfCanvases()->GetEntries() <<
endl;
193 cout << myname <<
"Deleting manipulator." <<
endl;
195 cout << myname <<
"Root canvas count: " << gROOT->GetListOfCanvases()->GetEntries() <<
endl;
197 cout << myname << line <<
endl;
198 cout << myname <<
"Done." <<
endl;
code to link reconstructed objects back to the MC truth information
TPadManipulator * parent()
int test_TPadManipulator()
int setTitleSize(double siz)
int add(unsigned int ipad, TObject *pobj, std::string sopt="", bool replace=false)
std::string getLabel() const
int addSlopedLine(double slop, double yoff=0.0, int isty=1)
int setLabelSizeY(double siz)
int setLabel(std::string slab)
int setTitle(std::string sttl, float height=-1.0)
static TPadManipulator * read(Name fnam, Name onam="tpad")
int addAxis(bool flag=true)
TPadManipulator * man(unsigned int ipad=0)
int addVerticalModLines(double xmod, double xoff=0.0, double lenfrac=1.0, int isty=3)
Q_EXPORT QTSManip setw(int w)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
void line(double t, double *p, double &x, double &y, double &z)
int setRangeX(double x1, double x2)
int setTimeFormatX(std::string sfmt)
TVirtualPad * pad() const
int setRangeY(double y1, double y2)
int print(std::string fname, std::string spat="{,}")
double getLabelSizeY() const
QTextStream & endl(QTextStream &s)