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);
1079 inline void convertToPDF(TH2& h2,
const std::string& option =
"NXYW",
const double factor = 1.0)
1081 using namespace std;
1083 const bool normalise = (option.find(
'N') != string::npos || option.find(
'n') != string::npos);
1084 const bool X = (option.find(
'X') != string::npos || option.find(
'x') != string::npos);
1085 const bool Y = (option.find(
'Y') != string::npos || option.find(
'y') != string::npos);
1086 const bool bin_width = (option.find(
'W') != string::npos || option.find(
'w') != string::npos);
1087 const bool use_error = (option.find(
'E') != string::npos || option.find(
'e') != string::npos);
1097 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1098 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1099 W += h2.GetBinContent(ix,iy);
1106 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1107 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1109 const Double_t w = W * (bin_width ? h2.GetXaxis()->GetBinWidth(ix) * h2.GetYaxis()->GetBinWidth(iy) : 1.0);
1111 h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) * factor / w);
1114 h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) * factor / w);
1122 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1128 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1129 W += h2.GetBinContent(ix,iy);
1135 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1137 const Double_t w = W * (bin_width ? h2.GetXaxis()->GetBinWidth(ix) : 1.0);
1139 h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) * factor / w);
1142 h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) * factor / w);
1150 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1156 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1157 W += h2.GetBinContent(ix,iy);
1163 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1165 const Double_t w = W * (bin_width ? h2.GetYaxis()->GetBinWidth(iy) : 1.0);
1167 h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) / w);
1170 h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) / w);
1194 inline void convertToPDF(TH3& h3,
const std::string& option =
"NXYW",
const double factor = 1.0)
1196 using namespace std;
1198 const bool normalise = (option.find(
'N') != string::npos || option.find(
'n') != string::npos);
1199 const bool X = (option.find(
'X') != string::npos || option.find(
'x') != string::npos);
1200 const bool Y = (option.find(
'Y') != string::npos || option.find(
'y') != string::npos);
1201 const bool Z = (option.find(
'Z') != string::npos || option.find(
'z') != string::npos);
1202 const bool bin_width = (option.find(
'W') != string::npos || option.find(
'w') != string::npos);
1203 const bool use_error = (option.find(
'E') != string::npos || option.find(
'e') != string::npos);
1213 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1214 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1215 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1216 W += h3.GetBinContent(ix,iy,iz);
1224 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1225 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1226 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1228 const Double_t w = W * (bin_width ? h3.GetXaxis()->GetBinWidth(ix) * h3.GetYaxis()->GetBinWidth(iy) * h3.GetZaxis()->GetBinWidth(iz) : 1.0);
1230 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1233 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1240 }
else if (X && Z) {
1242 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1248 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1249 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1250 W += h3.GetBinContent(ix,iy,iz);
1257 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1258 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1260 const Double_t w = W * (bin_width ? h3.GetXaxis()->GetBinWidth(ix) * h3.GetZaxis()->GetBinWidth(iz) : 1.0);
1262 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1265 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1272 }
else if (Y && Z) {
1274 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1280 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1281 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1282 W += h3.GetBinContent(ix,iy,iz);
1289 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1290 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1292 const Double_t w = W * (bin_width ? h3.GetYaxis()->GetBinWidth(iy) * h3.GetZaxis()->GetBinWidth(iz) : 1.0);
1294 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1297 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1304 }
else if (X && Y) {
1306 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1312 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1313 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1314 W += h3.GetBinContent(ix,iy,iz);
1321 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1322 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1324 const Double_t w = W * (bin_width ? h3.GetXaxis()->GetBinWidth(ix) * h3.GetYaxis()->GetBinWidth(iy) : 1.0);
1326 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1329 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1338 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1339 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1345 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1346 W += h3.GetBinContent(ix,iy,iz);
1352 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1354 const Double_t w = W * (bin_width ? h3.GetXaxis()->GetBinWidth(ix) : 1.0);
1356 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1359 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1368 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1369 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1375 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1376 W += h3.GetBinContent(ix,iy,iz);
1382 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1384 const Double_t w = W * (bin_width ? h3.GetYaxis()->GetBinWidth(iy) : 1.0);
1386 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) / w);
1389 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) / w);
1398 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1399 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1405 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1406 W += h3.GetBinContent(ix,iy,iz);
1412 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1414 const Double_t w = W * (bin_width ? h3.GetZaxis()->GetBinWidth(iz) : 1.0);
1416 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) / w);
1419 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) / w);