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);
1060 inline void convertToPDF(TH2& h2,
const std::string& option =
"NXYW",
const double factor = 1.0)
1062 using namespace std;
1064 const bool normalise = (option.find(
'N') != string::npos || option.find(
'n') != string::npos);
1065 const bool X = (option.find(
'X') != string::npos || option.find(
'x') != string::npos);
1066 const bool Y = (option.find(
'Y') != string::npos || option.find(
'y') != string::npos);
1067 const bool bin_width = (option.find(
'W') != string::npos || option.find(
'w') != string::npos);
1068 const bool use_error = (option.find(
'E') != string::npos || option.find(
'e') != string::npos);
1078 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1079 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1080 W += h2.GetBinContent(ix,iy);
1087 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1088 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1090 const Double_t w = W * (bin_width ? h2.GetXaxis()->GetBinWidth(ix) * h2.GetYaxis()->GetBinWidth(iy) : 1.0);
1092 h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) * factor / w);
1095 h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) * factor / w);
1103 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1109 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1110 W += h2.GetBinContent(ix,iy);
1116 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1118 const Double_t w = W * (bin_width ? h2.GetXaxis()->GetBinWidth(ix) : 1.0);
1120 h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) * factor / w);
1123 h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) * factor / w);
1131 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
1137 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1138 W += h2.GetBinContent(ix,iy);
1144 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
1146 const Double_t w = W * (bin_width ? h2.GetYaxis()->GetBinWidth(iy) : 1.0);
1148 h2.SetBinContent(ix, iy, h2.GetBinContent(ix,iy) / w);
1151 h2.SetBinError(ix, iy, h2.GetBinError(ix,iy) / w);
1175 inline void convertToPDF(TH3& h3,
const std::string& option =
"NXYW",
const double factor = 1.0)
1177 using namespace std;
1179 const bool normalise = (option.find(
'N') != string::npos || option.find(
'n') != string::npos);
1180 const bool X = (option.find(
'X') != string::npos || option.find(
'x') != string::npos);
1181 const bool Y = (option.find(
'Y') != string::npos || option.find(
'y') != string::npos);
1182 const bool Z = (option.find(
'Z') != string::npos || option.find(
'z') != string::npos);
1183 const bool bin_width = (option.find(
'W') != string::npos || option.find(
'w') != string::npos);
1184 const bool use_error = (option.find(
'E') != string::npos || option.find(
'e') != string::npos);
1194 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1195 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1196 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1197 W += h3.GetBinContent(ix,iy,iz);
1205 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1206 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1207 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1209 const Double_t w = W * (bin_width ? h3.GetXaxis()->GetBinWidth(ix) * h3.GetYaxis()->GetBinWidth(iy) * h3.GetZaxis()->GetBinWidth(iz) : 1.0);
1211 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1214 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1221 }
else if (X && Z) {
1223 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1229 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1230 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1231 W += h3.GetBinContent(ix,iy,iz);
1238 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1239 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1241 const Double_t w = W * (bin_width ? h3.GetXaxis()->GetBinWidth(ix) * h3.GetZaxis()->GetBinWidth(iz) : 1.0);
1243 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1246 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1253 }
else if (Y && Z) {
1255 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1261 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1262 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1263 W += h3.GetBinContent(ix,iy,iz);
1270 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1271 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1273 const Double_t w = W * (bin_width ? h3.GetYaxis()->GetBinWidth(iy) * h3.GetZaxis()->GetBinWidth(iz) : 1.0);
1275 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1278 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1285 }
else if (X && Y) {
1287 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1293 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1294 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1295 W += h3.GetBinContent(ix,iy,iz);
1302 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1303 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1305 const Double_t w = W * (bin_width ? h3.GetXaxis()->GetBinWidth(ix) * h3.GetYaxis()->GetBinWidth(iy) : 1.0);
1307 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1310 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1319 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1320 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1326 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1327 W += h3.GetBinContent(ix,iy,iz);
1333 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1335 const Double_t w = W * (bin_width ? h3.GetXaxis()->GetBinWidth(ix) : 1.0);
1337 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) * factor / w);
1340 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) * factor / w);
1349 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1350 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1356 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1357 W += h3.GetBinContent(ix,iy,iz);
1363 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1365 const Double_t w = W * (bin_width ? h3.GetYaxis()->GetBinWidth(iy) : 1.0);
1367 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) / w);
1370 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) / w);
1379 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
1380 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
1386 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1387 W += h3.GetBinContent(ix,iy,iz);
1393 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
1395 const Double_t w = W * (bin_width ? h3.GetZaxis()->GetBinWidth(iz) : 1.0);
1397 h3.SetBinContent(ix, iy, iz, h3.GetBinContent(ix,iy,iz) / w);
1400 h3.SetBinError(ix, iy, iz, h3.GetBinError(ix,iy,iz) / w);