303 TString buffer(
text);
305 if (
object != NULL) {
307 TClass* p = TClass::GetClass(object->ClassName());
313 TMethod* method = NULL;
315 for (std::unique_ptr<TIterator> iter(p->GetListOfAllPublicMethods()->MakeIterator()); TMethod* p = (TMethod*) iter->Next(); ) {
316 if (buffer.Index(p->GetName()) != -1) {
317 if (method == NULL || strlen(p->GetName()) > strlen(method->GetName())) {
323 if (method == NULL) {
327 for (Ssiz_t index; (index = buffer.Index(method->GetName())) != -1; ) {
329 const TRegexp fp(
" *([^)]*)");
332 Ssiz_t pos = buffer.Index(fp, &len, index);
336 if (pos == -1 || pos != index + (Ssiz_t) strlen(method->GetName())) {
338 TMethodCall(p, method->GetName(), NULL).Execute(
object, value);
340 len = strlen(method->GetName());
344 TMethodCall(p, method->GetName(), NULL).Execute(
object, TString(buffer(pos + 1, len - 2)), value);
346 len += strlen(method->GetName());
349 buffer.Replace(index, len, TString::Format(
"%20.10e", value));
355 return TFormula(
"/tmp", buffer.Data()).Eval(0.0);
1136 inline void convertToPDF(TH2& h2,
const std::string& option =
"NXYW",
const double factor = 1.0)
1138 using namespace std;
1140 const bool normalise = (option.find(
'N') != string::npos || option.find(
'n') != string::npos);
1141 const bool X = (option.find(
'X') != string::npos || option.find(
'x') != string::npos);
1142 const bool Y = (option.find(
'Y') != string::npos || option.find(
'y') != string::npos);
1143 const bool bin_width = (option.find(
'W') != string::npos || option.find(
'w') != string::npos);
1144 const bool use_error = (option.find(
'E') != string::npos || option.find(
'e') != string::npos);
1154 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1155 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1156 W += h2.GetBinContent(ix,iy);
1163 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1164 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1166 const Double_t w = W * (bin_width ? h2.GetXaxis()->GetBinWidth(ix) * h2.GetYaxis()->GetBinWidth(iy) : 1.0);
1168 h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) * factor / w);
1171 h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) * factor / w);
1179 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1185 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1186 W += h2.GetBinContent(ix,iy);
1192 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1194 const Double_t w = W * (bin_width ? h2.GetXaxis()->GetBinWidth(ix) : 1.0);
1196 h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) * factor / w);
1199 h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) * factor / w);
1207 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1213 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1214 W += h2.GetBinContent(ix,iy);
1220 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1222 const Double_t w = W * (bin_width ? h2.GetYaxis()->GetBinWidth(iy) : 1.0);
1224 h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) / w);
1227 h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) / w);
1251 inline void convertToPDF(TH3& h3,
const std::string& option =
"NXYW",
const double factor = 1.0)
1253 using namespace std;
1255 const bool normalise = (option.find(
'N') != string::npos || option.find(
'n') != string::npos);
1256 const bool X = (option.find(
'X') != string::npos || option.find(
'x') != string::npos);
1257 const bool Y = (option.find(
'Y') != string::npos || option.find(
'y') != string::npos);
1258 const bool Z = (option.find(
'Z') != string::npos || option.find(
'z') != string::npos);
1259 const bool bin_width = (option.find(
'W') != string::npos || option.find(
'w') != string::npos);
1260 const bool use_error = (option.find(
'E') != string::npos || option.find(
'e') != string::npos);
1270 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1271 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1272 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1273 W += h3.GetBinContent(ix,iy,iz);
1281 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1282 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1283 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1285 const Double_t w = W * (bin_width ? h3.GetXaxis()->GetBinWidth(ix) * h3.GetYaxis()->GetBinWidth(iy) * h3.GetZaxis()->GetBinWidth(iz) : 1.0);
1287 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1290 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1297 }
else if (X && Z) {
1299 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1305 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1306 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1307 W += h3.GetBinContent(ix,iy,iz);
1314 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1315 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1317 const Double_t w = W * (bin_width ? h3.GetXaxis()->GetBinWidth(ix) * h3.GetZaxis()->GetBinWidth(iz) : 1.0);
1319 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1322 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1329 }
else if (Y && Z) {
1331 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1337 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1338 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1339 W += h3.GetBinContent(ix,iy,iz);
1346 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1347 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1349 const Double_t w = W * (bin_width ? h3.GetYaxis()->GetBinWidth(iy) * h3.GetZaxis()->GetBinWidth(iz) : 1.0);
1351 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1354 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1361 }
else if (X && Y) {
1363 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1369 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1370 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1371 W += h3.GetBinContent(ix,iy,iz);
1378 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1379 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1381 const Double_t w = W * (bin_width ? h3.GetXaxis()->GetBinWidth(ix) * h3.GetYaxis()->GetBinWidth(iy) : 1.0);
1383 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1386 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1395 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1396 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1402 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1403 W += h3.GetBinContent(ix,iy,iz);
1409 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1411 const Double_t w = W * (bin_width ? h3.GetXaxis()->GetBinWidth(ix) : 1.0);
1413 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1416 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1425 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1426 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1432 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1433 W += h3.GetBinContent(ix,iy,iz);
1439 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1441 const Double_t w = W * (bin_width ? h3.GetYaxis()->GetBinWidth(iy) : 1.0);
1443 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) / w);
1446 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) / w);
1455 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1456 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1462 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1463 W += h3.GetBinContent(ix,iy,iz);
1469 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1471 const Double_t w = W * (bin_width ? h3.GetZaxis()->GetBinWidth(iz) : 1.0);
1473 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) / w);
1476 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) / w);