27 #include "TObjString.h"
28 #include "TObjArray.h"
79 snprintf(col, 200,
" %d ", val);
88 snprintf(col, 200,
" $%d \\pm %d$ ", val, err);
99 if(scientificNotation >= 0) {
107 snprintf(format, 100,
" $%%%d.%df $", scientificNotation, scientificNotation);
108 snprintf(col, 200, format, mantissa);
111 snprintf(format, 100,
" $%%%d.%df \\cdot 10^{%%0.0f} $", scientificNotation, scientificNotation);
112 snprintf(col, 200,format, mantissa, exp);
122 snprintf(format, 100,
" $%%%d.%df $", -scientificNotation,-scientificNotation);
123 snprintf(col, 200, format , TMath::Nint(val*TMath::Power(10,-scientificNotation))/TMath::Power(10,-scientificNotation));
127 snprintf(col,200,
" %f ", val);
144 if(scientificNotation >=0 ) {
152 Int_t nSigDigits =TMath::Nint(exp - exp_err);
153 if(scientificNotation != 0) nSigDigits = nSigDigits + scientificNotation - 1;
158 snprintf(format, 100,
" $%%%d.%df \\pm %%%d.%df $", nSigDigits, nSigDigits, nSigDigits, nSigDigits);
159 snprintf(col, 200,format, mantissa, mantissa_err/TMath::Power(10,exp - exp_err));
162 snprintf(format, 100,
" $%%%d.%df \\pm %%%d.%df \\cdot 10^{%%0.0f}$", nSigDigits, nSigDigits, nSigDigits, nSigDigits);
163 snprintf(col, 200, format, mantissa, mantissa_err/TMath::Power(10,exp - exp_err), exp);
173 snprintf(format, 100,
" $%%%d.%df \\pm %%%d.%df $", -scientificNotation,-scientificNotation,-scientificNotation,-scientificNotation);
174 snprintf(col, 200, format , TMath::Nint(val*TMath::Power(10,-scientificNotation))/TMath::Power(10,-scientificNotation), TMath::Nint(err*TMath::Power(10,-scientificNotation))/TMath::Power(10,-scientificNotation));
179 snprintf(col, 200,
" $%f \\pm %f$ ", val, err);
198 if(scientificNotation >=0 ) {
206 Double_t mantissa_errsyst, exp_errsyst;
209 Int_t nSigDigits =TMath::Nint(exp - exp_err);
210 if(scientificNotation != 0) nSigDigits = nSigDigits + scientificNotation - 1;
215 snprintf(format, 100,
" $%%%d.%df \\pm %%%d.%df \\pm %%%d.%df $",
216 nSigDigits, nSigDigits, nSigDigits, nSigDigits, nSigDigits, nSigDigits);
217 snprintf(col, 200, format, mantissa,
218 mantissa_err/TMath::Power(10,exp - exp_err),
219 mantissa_errsyst/TMath::Power(10,exp - exp_errsyst));
222 snprintf(format, 100,
" $%%%d.%df \\pm %%%d.%df \\pm %%%d.%df \\cdot 10^{%%0.0f}$",
223 nSigDigits, nSigDigits, nSigDigits, nSigDigits, nSigDigits, nSigDigits);
224 snprintf(col, 200, format, mantissa,
225 mantissa_err/TMath::Power(10,exp - exp_err),
226 mantissa_errsyst/TMath::Power(10,exp - exp_errsyst),
237 snprintf(format, 100,
" $%%%d.%df \\pm %%%d.%df \\pm %%%d.%df $", -scientificNotation,-scientificNotation,-scientificNotation,-scientificNotation, -scientificNotation,-scientificNotation);
238 snprintf(col, 200, format ,TMath::Nint(val*TMath::Power(10,-scientificNotation))/TMath::Power(10,-scientificNotation), TMath::Nint(err*TMath::Power(10,-scientificNotation))/TMath::Power(10,-scientificNotation), TMath::Nint(errSyst*TMath::Power(10,-scientificNotation))/TMath::Power(10,-scientificNotation));
243 snprintf(col, 200,
" $%f \\pm %f \\pm %f$ ", val, err, errSyst);
276 fCols->Add(
new TObjString(val));
283 fRows->Add(
new TObjString(row));
293 Warning(
"InsertRow",
"Wrong number of cols: %d (!= %d)",
fNcolReady,
fNcol);
298 row = row + ((TObjString*)
fCols->At(icol))->String();
299 if(icol != (fNcol-1)) row = row +
" & ";
303 fRows->Add(
new TObjString(row));
313 fRows->Add(
new TObjString(
"\\hline"));
326 col_widths[icol] = 0;
330 for(
Int_t irow = 0; irow < nrow; irow++){
332 if(row.Contains(
"\\hline"))
continue;
337 if(cols->GetEntries() !=
fNcol) {
338 Error(
"GetColWidths",
"Wrong number of cols in row %s: %d - %d", row.Data(), cols->GetEntries(),
fNcol);
341 Int_t w = ((TObjString *) cols->At(icol))->String().Length();
342 if (w>col_widths[icol]) col_widths[icol] = w;
366 Int_t total_lenght = 0;
367 for(
Int_t icol = 0; icol <
fNcol; icol++) total_lenght = total_lenght + colWidths[icol] + 2 ;
370 for(
Int_t irow = 0; irow < nrow; irow++){
371 TString row = ((TObjString*)
fRows->At(irow))->String();
372 if (row.Contains(
"\\hline")){
374 for(
Int_t il = 0; il < total_lenght; il++) printf(
"-");
381 if (
TString(opt)==
"TWIKI") printf(
" | ");
383 TString strTmp = ((TObjString *) cols->At(icol))->String();
385 strTmp.ReplaceAll(
"AMPER",
"&");
387 const char * colstr = strTmp.Data();
390 snprintf(format, 200,
"%%%ds", colWidths[icol] + 2);
392 snprintf(format, 200,
"%%s");
394 printf(format, colstr);
395 if (
TString(opt)==
"CSV") printf(
", ");
396 if (
TString(opt)==
"TWIKI") printf(
" | ");
408 cout <<
"\\begin{tabular}{"<<
fFormat<<
"}"<<endl;
412 for(
Int_t irow = 0; irow < nrow; irow++){
413 cout << ((TObjString*)
fRows->At(irow))->String() << endl;
416 cout <<
"\\end{tabular}" << endl;
447 exp = TMath::Floor(TMath::Log10(TMath::Abs(num)));
448 man = num / TMath::Power(10, exp);
461 text.ReplaceAll(
"\\cdot",
"x");
462 text.ReplaceAll(
"$",
"");
463 if (format ==
"ASCII") {
464 text.ReplaceAll(
"\\right>",
">");
465 text.ReplaceAll(
"\\left<",
"<");
466 text.ReplaceAll(
"\\rangle",
">");
467 text.ReplaceAll(
"\\langle",
"<");
468 text.ReplaceAll(
"\\pm",
"+-");
469 }
else if (format ==
"HTML" || format ==
"TWIKI") {
471 text.ReplaceAll(
"\\right>",
"AMPERrang;");
472 text.ReplaceAll(
"\\left<",
"AMPERlang;");
473 text.ReplaceAll(
"\\rangle",
"AMPERrang;");
474 text.ReplaceAll(
"\\langle",
"AMPERlang;");
475 text.ReplaceAll(
"\\pm",
"AMPERplusmn;");
477 if(text.Contains(
"multicolumn")) {
481 TObjArray * array = TPRegexp(
"multicolumn\\{([^}]*)\\}\\{[^}]*\\}\\{([^]]*)\\}").MatchS(text);
482 const TString content = ((TObjString *)array->At(2))->GetString();
483 Int_t nspan = ((TObjString *)array->At(1))->GetString().Atoi();
488 for(
Int_t ispan = 1; ispan < nspan; ispan++){
496 text.ReplaceAll(
"\\mathrm",
"");
498 text.ReplaceAll(
"\\",
"");
499 text.Strip(TString::EStripType(1),
' ');
507 ifstream
file (filename);
508 if (!file.is_open()) {
509 AliError(Form(
"Cannot open file %s", filename));
512 while (line.ReadLine(file)) {
513 if (line.Contains(
"begin") && line.Contains(
"tabular")) {
516 TPRegexp re(
".*begin{tabular}{(.*)}");
518 if (arr->GetLast() > 0){
521 TString subStr = ((TObjString *)arr->At(1))->GetString();
522 subStr.ReplaceAll(
"|",
"");
523 subStr.ReplaceAll(
" ",
"");
524 subStr.ReplaceAll(
"\t",
"");
527 fNcol = subStr.Length();
533 if (line.Contains(
"begin"))
continue;
534 if (line.Contains(
"end"))
continue;
535 if (line.Contains(
"tabular"))
continue;
void LoadTeXFromFileAndPrintASCII(const char *filename)
void PrintTable(Option_t *opt="")
void SetNextCol(Int_t val)
void InsertCustomRow(TString row)
void GetMantissaAndExpBase10(Double_t num, Double_t &man, Double_t &exp)
ClassImp(AliLatexTable) AliLatexTable
void StripLatex(TString &row, TString format)