12 #include "TProfile2D.h" 
   30 int main(
int argc, 
char **argv)
 
   49     JParser<> zap(
"Auxiliary program to project 2D histograms.");
 
   51     zap[
'f'] = 
make_field(inputFile,  
"<input file>:<object name>");
 
   57     zap[
'F'] = 
make_field(format,     
"format, e.g. \"%s %i\" or \"%s %f %f\"") = 
"";
 
   58     zap[
'O'] = 
make_field(option,     
"option, see TH2::Projection(X|Y)")       = 
"";
 
   63   catch(
const exception &error) {
 
   64     FATAL(error.what() << endl);
 
   71     FATAL(
"Invalid operation: " 
   72           << (px ? 
"" : 
"no") << 
" X projection " << 
" and "  
   73           << (py ? 
"" : 
"no") << 
" Y projection " << endl);
 
   80     if (px) { format += 
"px"; }
 
   81     if (py) { format += 
"py"; }
 
   83     if (X.empty() && Y.empty()) 
 
   93     DEBUG(
"Input: " << *input << endl);
 
   98       ERROR(
"File: " << input->getFullFilename() << 
" not opened." << endl);
 
  102     const TRegexp regexp(input->getObjectName());
 
  104     TIter iter(dir->GetListOfKeys());
 
  106     for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
 
  108       const TString tag(key->GetName());
 
  110       DEBUG(
"Key: " << tag << 
" match = " << tag.Contains(regexp) << endl);
 
  114       if (tag.Contains(regexp) && 
isTObject(key)) {
 
  116         TH2* h2 = 
dynamic_cast<TH2*
>(key->ReadObj());
 
  124               for (Int_t i = (overflow ? 0 : 1); i <= h2->GetYaxis()->GetNbins() + (overflow ? 1 : 0); ++i) {
 
  125                 listOfObjects.push_back(h2->ProjectionX(TString::Format(format.c_str(), h2->GetName(), i),
 
  132               for (Int_t i = 0; i != (Int_t) Y.size(); ++i) {
 
  133                 listOfObjects.push_back(h2->ProjectionX(TString::Format(format.c_str(), h2->GetName(), Y[i].getLowerLimit(), Y[i].getUpperLimit()),
 
  134                                                         h2->GetYaxis()->FindBin(Y[i].getLowerLimit()),
 
  135                                                         h2->GetYaxis()->FindBin(Y[i].getUpperLimit()) - 1, option.c_str()));
 
  143               for (Int_t i = (overflow ? 0 : 1); i <= h2->GetXaxis()->GetNbins() + (overflow ? 1 : 0); ++i) {
 
  144                 listOfObjects.push_back(h2->ProjectionY(TString::Format(format.c_str(), h2->GetName(), i), i, i, option.c_str()));
 
  149               for (Int_t i = 0; i != (Int_t) X.size(); ++i) {
 
  150                 listOfObjects.push_back(h2->ProjectionY(TString::Format(format.c_str(), h2->GetName(), X[i].getLowerLimit(), X[i].getUpperLimit()),
 
  151                                                         h2->GetXaxis()->FindBin(X[i].getLowerLimit()),
 
  152                                                         h2->GetXaxis()->FindBin(X[i].getUpperLimit()) - 1, option.c_str()));
 
  161   if (!listOfObjects.empty()) {
 
General purpose messaging.
 
#define DEBUG(A)
Message macros.
 
Utility class to parse command line options.
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
 
int main(int argc, char **argv)
 
Auxiliary class to define a range between two values.
 
Utility class to parse command line options.
 
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
 
bool isTObject(const TKey *key)
Check if given key corresponds to a TObject.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
Type definition of range.
 
Empty structure for specification of parser element that is initialised (i.e. does not require input)...