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);
296 Warning(
"InsertRow",
"Not enough columns provided, filling with empty cols");
305 row = row + ((TObjString*)
fCols->At(icol))->String();
306 if(icol != (fNcol-1)) row = row +
" & ";
310 fRows->Add(
new TObjString(row));
320 fRows->Add(
new TObjString(
"\\hline"));
333 col_widths[icol] = 0;
337 for(
Int_t irow = 0; irow < nrow; irow++){
339 if(row.Contains(
"\\hline"))
continue;
344 if(cols->GetEntries() !=
fNcol) {
345 Error(
"GetColWidths",
"Wrong number of cols in row %s: %d - %d", row.Data(), cols->GetEntries(),
fNcol);
348 Int_t w = ((TObjString *) cols->At(icol))->String().Length();
349 if (w>col_widths[icol]) col_widths[icol] = w;
374 Int_t total_lenght = 0;
375 for(
Int_t icol = 0; icol <
fNcol; icol++) total_lenght = total_lenght + colWidths[icol] + 2 ;
379 for(
Int_t irow = 0; irow < nrow; irow++){
380 TString row = ((TObjString*)
fRows->At(irow))->String();
381 if (row.Contains(
"\\hline")){
385 for(
Int_t ilen = 0; ilen < (colWidths[icol]+2); ilen++){
393 for(
Int_t il = 0; il < total_lenght; il++) printf(
"-");
403 TString strTmp = ((TObjString *) cols->At(icol))->String();
405 strTmp.ReplaceAll(
"AMPER",
"&");
407 const char * colstr = strTmp.Data();
410 snprintf(format, 200,
"%%%ds", colWidths[icol] + 2);
412 snprintf(format, 200,
"%%s");
414 printf(format, colstr);
415 if (
TString(opt)==
"CSV") printf(
", ");
416 if (
TString(opt)==
"TWIKI") printf(
" | ");
429 cout <<
"\\begin{tabular}{"<<
fFormat<<
"}"<<endl;
433 for(
Int_t irow = 0; irow < nrow; irow++){
434 cout << ((TObjString*)
fRows->At(irow))->String() << endl;
437 cout <<
"\\end{tabular}" << endl;
468 exp = TMath::Floor(TMath::Log10(TMath::Abs(num)));
469 man = num / TMath::Power(10, exp);
482 text.ReplaceAll(
"\\cdot",
"x");
483 text.ReplaceAll(
"$",
"");
484 if (format ==
"ASCII" || format ==
"MD") {
485 text.ReplaceAll(
"\\right>",
">");
486 text.ReplaceAll(
"\\left<",
"<");
487 text.ReplaceAll(
"\\rangle",
">");
488 text.ReplaceAll(
"\\langle",
"<");
489 text.ReplaceAll(
"\\pm",
"+-");
490 }
else if (format ==
"HTML" || format ==
"TWIKI") {
492 text.ReplaceAll(
"\\right>",
"AMPERrang;");
493 text.ReplaceAll(
"\\left<",
"AMPERlang;");
494 text.ReplaceAll(
"\\rangle",
"AMPERrang;");
495 text.ReplaceAll(
"\\langle",
"AMPERlang;");
496 text.ReplaceAll(
"\\pm",
"AMPERplusmn;");
498 if(text.Contains(
"multicolumn")) {
502 TObjArray * array = TPRegexp(
"multicolumn\\{([^}]*)\\}\\{[^}]*\\}\\{([^]]*)\\}").MatchS(text);
503 const TString content = ((TObjString *)array->At(2))->GetString();
504 Int_t nspan = ((TObjString *)array->At(1))->GetString().Atoi();
509 for(
Int_t ispan = 1; ispan < nspan; ispan++){
517 text.ReplaceAll(
"\\mathrm",
"");
519 text.ReplaceAll(
"\\",
"");
520 text.Strip(TString::EStripType(1),
' ');
528 ifstream
file (filename);
529 if (!file.is_open()) {
530 AliError(Form(
"Cannot open file %s", filename));
533 while (line.ReadLine(file)) {
534 if (line.Contains(
"begin") && line.Contains(
"tabular")) {
537 TPRegexp re(
".*begin{tabular}{(.*)}");
539 if (arr->GetLast() > 0){
542 TString subStr = ((TObjString *)arr->At(1))->GetString();
543 subStr.ReplaceAll(
"|",
"");
544 subStr.ReplaceAll(
" ",
"");
545 subStr.ReplaceAll(
"\t",
"");
548 fNcol = subStr.Length();
554 if (line.Contains(
"begin"))
continue;
555 if (line.Contains(
"end"))
continue;
556 if (line.Contains(
"tabular"))
continue;
TString format
file names tag, basically the trigger and calorimeter combination
void LoadTeXFromFileAndPrintASCII(const char *filename)
void PrintTable(Option_t *opt="")
TLatex * text[5]
option to what and if export to output file
void SetNextCol(Int_t val)
void InsertCustomRow(TString row)
void GetMantissaAndExpBase10(Double_t num, Double_t &man, Double_t &exp)
TFile * file
TList with histograms for a given trigger.
void StripLatex(TString &row, TString format)