28 if ( low < 0. || low > 1.
29 || p_low < 0. || p_low > 1.
30 || p_up < 0. || p_up > 1.
31 || up < 0. || up > 1. ) {
32 cout <<
" Fatal error: input coordinates for tuPadDim for pads must all "
33 " be in range [0,1] " << endl;
37 cout <<
" Fatal error: input coordinates must monotonically increase " << endl;
42 noiPadDim(
double _low,
double _p_low,
double _p_up,
double _up ) :
46 noiPadDim(
double _low,
double _p_low,
double _up ) :
52 cout << Form(
" Four points are: (%.2f, %.2f %.2f, %.2f)",
low,
p_low,
p_up,
up) << endl;
56 if (margin < 0) margin = 0;
62 if (margin < 0) margin = 0;
81 double left_margin,
double pad_width,
86 left+left_margin+pad_width,
87 left+left_margin+pad_width+right_margin };
92 bool flip_direction =
false;
97 vector<noiPadDim> pads (npads) ;
99 double first_left = (
lefts.size() > 0) ?
lefts[0] : 0.2;
100 double inner_left = (
lefts.size() > 1) ?
lefts[1] : 0.0001;
101 double page_left = (
lefts.size() > 2) ?
lefts[2] : 0.01;
103 double last_right = (
rights.size() > 0) ?
rights[0] : 0.0001;
104 double inner_right = (
rights.size() > 1) ?
rights[1] : 0.0;
105 double page_right = (
rights.size() > 2) ?
rights[2] : 0.01;
107 if (npads == 0)
throw std::runtime_error(
108 "fatal in noiPadDimSet must request at least one pad");
110 double pad_width = 1.-first_left-page_left-last_right-page_right;
111 if (pad_width<=0)
throw std::runtime_error(
112 "fatal in noiPadDimSet margins have consumed more than 100\% of TCanvas");
113 pads[0] =
make_pad( page_left, first_left, pad_width, last_right );
117 double pad_width { (1.-(first_left+page_left+last_right+page_right+
118 (inner_left+inner_right)*(npads-1)))/npads };
119 if (pad_width<=0)
throw std::runtime_error(
120 "fatal in noiPadDimSet margins have consumed more than 100\% of TCanvas");
122 int index = flip_direction ? npads-1 : 0;
123 pads[
index] =
make_pad(page_left, first_left, pad_width, inner_right);
126 for (
int i=1;
i<npads-1;++
i) {
127 int index = flip_direction ? npads-
i-1 :
i;
128 pads[
index] =
make_pad(left, inner_left, pad_width, inner_right);
129 left = pads[
index].up;
131 pads[flip_direction ? 0 : npads-1] =
make_pad(left, inner_left, pad_width, last_right);
139 if (_lefts.size() == 0)
nPads = 1;
140 else if (_lefts[0] >= 1.) {
141 nPads = (int) _lefts[0];
142 for (
int i{0};
i<(int)_lefts.size()-1; ++
i)
lefts.push_back(_lefts[
i+1]);
164 noiPads (
int nYpads=1, vector<double> dimensions={},
int nXpads=1 ) {
166 noiPadDimSet xPads{ {0.2, 0.0001, 0.01}, {0.0001,0.0,0.01 }};
167 noiPadDimSet yPads{ {0.2, 0.0001, 0.01}, {0.0001,0.0,0.01 }};
173 for (
auto val : dimensions) {
178 }
else if (val > 1) {
182 }
else if (which == 0) {
187 yPads.rights[cnt] = val;
190 yPads.lefts[cnt] = val;
193 xPads.lefts[cnt] = val;
196 xPads.rights[cnt] = val;
199 throw std::runtime_error(Form(
"fatal error: noiPads::noiPads: Error in selection of pad dimensions: was %i but must be (2,3,5,6:kLeft,Right,Bottom,Top)",
204 yPads.nPads = -nYpads;
205 xPads.nPads = nXpads;
208 nCol = TMath::Abs(nXpads);
209 nRow = TMath::Abs(nYpads);
210 for (
auto x_pad : xPads.calc_pads())
211 for (
auto y_pad : yPads.calc_pads())
216 noiPads ( vector<pair<noiPadDim, noiPadDim>> _pad_dimensions={{{},{}}},
int _canvas_width=0,
int _canvas_height=0) :
217 pad_dimensions{ _pad_dimensions }
219 if (_canvas_width) canvas_width = _canvas_width;
220 if (_canvas_height) canvas_height = _canvas_height;
223 void add_pad(pair<noiPadDim,noiPadDim>& coord){
226 if (pads.size()==0) {
228 canvas_pad ->SetFillStyle(4000);
229 canvas_pad ->SetFrameFillStyle(4000);
242 p->SetLeftMargin(
x.low_margin());
243 p->SetRightMargin(
x.up_margin());
244 p->SetBottomMargin(
y.low_margin());
245 p->SetTopMargin(
y.up_margin());
247 p->SetFillStyle(4000);
248 p->SetFrameFillStyle(4000);
254 for (
auto& inp :
input) add_pad(inp);
260 canvas =
new TCanvas(
noiUniqueName(i_prefix,Form(
"canv_%s",
prefix.c_str())),
"",canvas_width, canvas_height);
261 canvas->SetFillStyle(4000);
262 canvas->SetFrameFillStyle(4000);
267 add_pad(pad_dimensions);
273 if (pads.size() == 0)
init();
279 int i_pad = row+
col*nRow;
280 if (i_pad >= (
int)pads.size()) {
281 i_pad = i_pad % (int) pads.size();
288 "TextColor", (kGray+2),
294 if (msg.size() > 120) {
295 cout <<
"pads stamp msg size: " << msg.size() << endl;
296 noiDict dsize {{
"TextSize", 10 }};
301 noiDrawTLatex(msg.c_str(),dict(
"x-loc"), dict(
"y-loc"), dict);
305 void pdf(
string string_with_dollar0, vector<string> other={}) {
306 string name = gSystem->pwd();
309 iss.str(string_with_dollar0);
311 while (iss >> word) {
314 for (
auto& words : other) {
317 while (iss >> word) {
322 canvas->Print(name.c_str());