33 int main(
int argc,
char **argv)
50 JParser<> zap(
"Auxiliary program to scale ROOT histograms."\
51 "\nNote that the formula may contain method names of the specified object.");
53 zap[
'f'] =
make_field(inputFile,
"<input file>:<object name>");
55 zap[
'F'] =
make_field(formula,
"ROOT TFormula (may contain method names of object)");
63 catch(
const exception &error) {
64 FATAL(error.what() << endl);
72 DEBUG(
"Input: " << *input << endl);
77 ERROR(
"File: " << input->getFullFilename() <<
" not opened." << endl);
81 const TRegexp regexp(input->getObjectName());
83 TIter iter(dir->GetListOfKeys());
85 for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
87 const TString tag(key->GetName());
89 DEBUG(
"Key: " << tag <<
" match = " << tag.Contains(regexp) << endl);
93 if (tag.Contains(regexp)) {
95 TObject*
object = key->ReadObj();
99 TH1&
h1 =
dynamic_cast<TH1&
>(*object);
101 if (X !=
JRange_t()) { h1.GetXaxis()->SetRangeUser(X.getLowerLimit(), X.getUpperLimit()); }
102 if (Y !=
JRange_t()) { h1.GetYaxis()->SetRangeUser(Y.getLowerLimit(), Y.getUpperLimit()); }
104 double factor =
getResult(formula,
object);
106 DEBUG(h1.GetName() <<
' ' << formula <<
' ' << factor << endl);
108 h1.Scale(factor, option.c_str());
110 out.WriteTObject(&h1);
Utility class to parse command line options.
then for HISTOGRAM in h0 h1
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Double_t getResult(const TString &text, TObject *object=NULL)
Get result of given textual formula.
General purpose messaging.
JRange< Double_t > JRange_t
Auxiliary class to define a range between two values.
Utility class to parse command line options.
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
#define DEBUG(A)
Message macros.
int main(int argc, char *argv[])