31 int main(
int argc,
char **argv)
43 JParser<> zap(
"Auxiliary program to rebin ROOT histograms.");
45 zap[
'f'] =
make_field(inputFile,
"<input file>:<object name>");
52 catch(
const exception &error) {
53 FATAL(error.what() << endl);
58 FATAL(
"No abscissa values." << endl);
65 DEBUG(
"Input: " << *input << endl);
70 ERROR(
"File: " << input->getFullFilename() <<
" not opened." << endl);
74 const TRegexp regexp(input->getObjectName());
76 TIter iter(dir->GetListOfKeys());
78 for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
80 const TString tag(key->GetName());
82 DEBUG(
"Key: " << tag <<
" match = " << tag.Contains(regexp) << endl);
86 if (tag.Contains(regexp)) {
88 TObject*
object = key->ReadObj();
92 TH1D& h0 =
dynamic_cast<TH1D&
>(*object);
94 TH1D
h1(h0.GetName(), NULL, X.size() - 1, X.data());
96 for (
int ix = 1; ix <=
h1.GetXaxis()->GetNbins(); ++ix) {
98 const Double_t xmin = h0.GetXaxis()->FindBin(
h1.GetXaxis()->GetBinLowEdge(ix));
99 const Double_t xmax = h0.GetXaxis()->FindBin(
h1.GetXaxis()->GetBinUpEdge (ix));
101 const Int_t imin = xmin;
102 const Int_t imax = xmax;
110 for (Int_t i = imin; i != imax; ++i) {
112 const Double_t y = h0.GetBinContent(i);
113 const Double_t z = h0.GetBinWidth (i);
114 const Double_t
w = h0.GetBinError (i);
124 h1.SetBinContent(ix, Y);
125 h1.SetBinError (ix, W);
129 ERROR(
"Invalid bin " << ix <<
" [" <<
FIXED(9,3) << xmin <<
"," <<
FIXED(9,3) << xmax <<
"]" <<
" -> " << imin <<
' ' << imax << endl);
133 out.WriteTObject(&
h1);
Utility class to parse command line options.
then for HISTOGRAM in h0 h1
Auxiliary data structure for floating point format specification.
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
General purpose messaging.
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[])