30{
   33 
   38 
   39  try {
   40 
   41    JParser<> zap(
"Auxiliary program to project 3D histograms.");
 
   42 
   43    zap[
'f'] = 
make_field(inputFile,  
"<input file>:<object name>");
 
   44    zap[
'P'] = 
make_field(project,    
"projection")                  = 
' ', 
'x', 
'X', 
'y', 
'Y', 
'z', 
'Z';
 
   47 
   48    zap(argc, argv);
   49  }
   50  catch(const exception &error) {
   51    FATAL(error.what() << endl);
 
   52  }
   53 
   57 
   58  if ((px ? 1 : 0) +
   59      (py ? 1 : 0) +
   60      (pz ? 1 : 0) != 1) {
   61    FATAL(
"Invalid operation: " 
   62          << (px ? "" : "no") << " X projection " << " and " 
   63          << (py ? "" : "no") << " Y projection " << " and " 
   64          << (pz ? "" : "no") << " Z projection " << endl);
   65  }
   66  
   68 
   69  for (vector<JRootObjectID>::const_iterator input = inputFile.begin(); input != inputFile.end(); ++input) {
   70    
   71    DEBUG(
"Input: " << *input << endl);
 
   72    
   74 
   75    if (dir == NULL) {
   76      ERROR(
"File: " << input->getFullFilename() << 
" not opened." << endl);
 
   77      continue;
   78    }
   79 
   80    const TRegexp regexp(input->getObjectName());
   81 
   82    TIter iter(dir->GetListOfKeys());
   83 
   84    for (TKey* key; (
key = (TKey*) iter.Next()) != NULL; ) {
 
   85 
   86      const TString tag(
key->GetName());
 
   87      
   88      DEBUG(
"Key: " << tag << 
" match = " << tag.Contains(regexp) << endl);
 
   89 
   90      
   91 
   92      if (tag.Contains(regexp) && 
isTObject(key)) {
 
   93        
   94        TH3* h3 = 
dynamic_cast<TH3*
>(
key->ReadObj());
 
   95 
   96        if (h3 != NULL) {
   97          
   98          if      (px) 
   99            listOfObjects.push_back(h3->ProjectionX(
MAKE_CSTRING(h3->GetName() << 
"_px")));
 
  100          else if (py)
  101            listOfObjects.push_back(h3->ProjectionY(
MAKE_CSTRING(h3->GetName() << 
"_py")));
 
  102          else if (pz)
  103            listOfObjects.push_back(h3->ProjectionZ(
MAKE_CSTRING(h3->GetName() << 
"_pz")));
 
  104        }
  105      }
  106    }
  107  }
  108 
  109  if (!listOfObjects.empty()) {
  110 
  112    
  113    for (vector<TObject*>::const_iterator i = listOfObjects.begin(); i != listOfObjects.end(); ++i) {
  114      (*i)->Write();
  115    }
  116      
  117    out.Write();
  118    out.Close();
  119  }
  120}
#define DEBUG(A)
Message macros.
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
 
#define MAKE_CSTRING(A)
Make C-string.
 
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).