48 JParser<> zap(
"Auxiliary program to project 2D histograms.");
50 zap[
'f'] =
make_field(inputFile,
"<input file>:<object name>");
51 zap[
'P'] =
make_field(project,
"projection") =
' ',
'x',
'X',
'y',
'Y';
56 zap[
'F'] =
make_field(format,
"format, e.g. \"%s %i\" or \"%s %f %f\"") =
"";
61 catch(
const exception &error) {
62 FATAL(error.what() << endl);
65 const bool px = (project ==
'x' || project ==
'X' || !Y.empty());
66 const bool py = (project ==
'y' || project ==
'Y' || !X.empty());
69 FATAL(
"Invalid operation: "
70 << (px ?
"" :
"no") <<
" X projection " <<
" and "
71 << (py ?
"" :
"no") <<
" X projection " << endl);
78 if (px) { format +=
"px"; }
79 if (py) { format +=
"py"; }
81 if (X.empty() && Y.empty())
91 DEBUG(
"Input: " << *input << endl);
96 ERROR(
"File: " << input->getFullFilename() <<
" not opened." << endl);
100 const TRegexp regexp(input->getObjectName());
102 TIter iter(dir->GetListOfKeys());
104 for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
106 const TString tag(key->GetName());
108 DEBUG(
"Key: " << tag <<
" match = " << tag.Contains(regexp) << endl);
112 if (tag.Contains(regexp)) {
114 TH2* h2 =
dynamic_cast<TH2*
>(key->ReadObj());
122 for (Int_t i = (overflow ? 0 : 1); i <= h2->GetYaxis()->GetNbins() + (overflow ? 1 : 0); ++i) {
123 listOfObjects.push_back(h2->ProjectionX(TString::Format(format.c_str(), h2->GetName(), i),
130 for (Int_t i = 0; i != (Int_t) Y.size(); ++i) {
131 listOfObjects.push_back(h2->ProjectionX(TString::Format(format.c_str(), h2->GetName(), Y[i].getLowerLimit(), Y[i].getUpperLimit()),
132 h2->GetYaxis()->FindBin(Y[i].getLowerLimit()),
133 h2->GetYaxis()->FindBin(Y[i].getUpperLimit()) - 1));
141 for (Int_t i = (overflow ? 0 : 1); i <= h2->GetXaxis()->GetNbins() + (overflow ? 1 : 0); ++i) {
142 listOfObjects.push_back(h2->ProjectionY(TString::Format(format.c_str(), h2->GetName(), i), i, i));
147 for (Int_t i = 0; i != (Int_t) X.size(); ++i) {
148 listOfObjects.push_back(h2->ProjectionY(TString::Format(format.c_str(), h2->GetName(), X[i].getLowerLimit(), X[i].getUpperLimit()),
149 h2->GetXaxis()->FindBin(X[i].getLowerLimit()),
150 h2->GetXaxis()->FindBin(X[i].getUpperLimit()) - 1));
159 if (!listOfObjects.empty()) {
Utility class to parse command line options.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
JRange< Double_t > JRange_t
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
#define DEBUG(A)
Message macros.