302 TString buffer(
text);
304 if (
object != NULL) {
306 TClass* p = TClass::GetClass(object->ClassName());
312 TMethod* method = NULL;
314 for (std::unique_ptr<TIterator> iter(p->GetListOfAllPublicMethods()->MakeIterator()); TMethod* p = (TMethod*) iter->Next(); ) {
315 if (buffer.Index(p->GetName()) != -1) {
316 if (method == NULL || strlen(p->GetName()) > strlen(method->GetName())) {
322 if (method == NULL) {
326 for (Ssiz_t index; (index = buffer.Index(method->GetName())) != -1; ) {
328 const TRegexp fp(
" *([^)]*)");
331 Ssiz_t pos = buffer.Index(fp, &len, index);
335 if (pos == -1 || pos != index + (Ssiz_t) strlen(method->GetName())) {
337 TMethodCall(p, method->GetName(), NULL).Execute(
object, value);
339 len = strlen(method->GetName());
343 TMethodCall(p, method->GetName(), NULL).Execute(
object, TString(buffer(pos + 1, len - 2)), value);
345 len += strlen(method->GetName());
348 buffer.Replace(index, len, TString::Format(
"%20.10e", value));
354 return TFormula(
"/tmp", buffer.Data()).Eval(0.0);
1119 inline void convertToPDF(TH2& h2,
const std::string& option =
"NXYW",
const double factor = 1.0)
1121 using namespace std;
1123 const bool normalise = (option.find(
'N') != string::npos || option.find(
'n') != string::npos);
1124 const bool X = (option.find(
'X') != string::npos || option.find(
'x') != string::npos);
1125 const bool Y = (option.find(
'Y') != string::npos || option.find(
'y') != string::npos);
1126 const bool bin_width = (option.find(
'W') != string::npos || option.find(
'w') != string::npos);
1127 const bool use_error = (option.find(
'E') != string::npos || option.find(
'e') != string::npos);
1137 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1138 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1139 W += h2.GetBinContent(ix,iy);
1146 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1147 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1149 const Double_t w = W * (bin_width ? h2.GetXaxis()->GetBinWidth(ix) * h2.GetYaxis()->GetBinWidth(iy) : 1.0);
1151 h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) * factor / w);
1154 h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) * factor / w);
1162 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1168 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1169 W += h2.GetBinContent(ix,iy);
1175 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1177 const Double_t w = W * (bin_width ? h2.GetXaxis()->GetBinWidth(ix) : 1.0);
1179 h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) * factor / w);
1182 h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) * factor / w);
1190 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1196 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1197 W += h2.GetBinContent(ix,iy);
1203 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1205 const Double_t w = W * (bin_width ? h2.GetYaxis()->GetBinWidth(iy) : 1.0);
1207 h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) / w);
1210 h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) / w);
1234 inline void convertToPDF(TH3& h3,
const std::string& option =
"NXYW",
const double factor = 1.0)
1236 using namespace std;
1238 const bool normalise = (option.find(
'N') != string::npos || option.find(
'n') != string::npos);
1239 const bool X = (option.find(
'X') != string::npos || option.find(
'x') != string::npos);
1240 const bool Y = (option.find(
'Y') != string::npos || option.find(
'y') != string::npos);
1241 const bool Z = (option.find(
'Z') != string::npos || option.find(
'z') != string::npos);
1242 const bool bin_width = (option.find(
'W') != string::npos || option.find(
'w') != string::npos);
1243 const bool use_error = (option.find(
'E') != string::npos || option.find(
'e') != string::npos);
1253 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1254 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1255 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1256 W += h3.GetBinContent(ix,iy,iz);
1264 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1265 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1266 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1268 const Double_t w = W * (bin_width ? h3.GetXaxis()->GetBinWidth(ix) * h3.GetYaxis()->GetBinWidth(iy) * h3.GetZaxis()->GetBinWidth(iz) : 1.0);
1270 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1273 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1280 }
else if (X && Z) {
1282 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1288 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1289 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1290 W += h3.GetBinContent(ix,iy,iz);
1297 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1298 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1300 const Double_t w = W * (bin_width ? h3.GetXaxis()->GetBinWidth(ix) * h3.GetZaxis()->GetBinWidth(iz) : 1.0);
1302 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1305 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1312 }
else if (Y && Z) {
1314 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1320 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1321 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1322 W += h3.GetBinContent(ix,iy,iz);
1329 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1330 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1332 const Double_t w = W * (bin_width ? h3.GetYaxis()->GetBinWidth(iy) * h3.GetZaxis()->GetBinWidth(iz) : 1.0);
1334 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1337 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1344 }
else if (X && Y) {
1346 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1352 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1353 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1354 W += h3.GetBinContent(ix,iy,iz);
1361 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1362 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1364 const Double_t w = W * (bin_width ? h3.GetXaxis()->GetBinWidth(ix) * h3.GetYaxis()->GetBinWidth(iy) : 1.0);
1366 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1369 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1378 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1379 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1385 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1386 W += h3.GetBinContent(ix,iy,iz);
1392 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1394 const Double_t w = W * (bin_width ? h3.GetXaxis()->GetBinWidth(ix) : 1.0);
1396 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1399 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1408 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1409 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1415 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1416 W += h3.GetBinContent(ix,iy,iz);
1422 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1424 const Double_t w = W * (bin_width ? h3.GetYaxis()->GetBinWidth(iy) : 1.0);
1426 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) / w);
1429 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) / w);
1438 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1439 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1445 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1446 W += h3.GetBinContent(ix,iy,iz);
1452 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1454 const Double_t w = W * (bin_width ? h3.GetZaxis()->GetBinWidth(iz) : 1.0);
1456 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) / w);
1459 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) / w);