Jpp  pmt_effective_area_update_2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JMantisShrimp.cc File Reference

Program to compare root histograms. More...

#include <iostream>
#include <fstream>
#include "TString.h"
#include "TRegexp.h"
#include "TFile.h"
#include "Jeep/JParser.hh"
#include "JTest_t.hh"
#include "JTestDictionary.hh"
#include "JGizmo/JRootObjectID.hh"
#include "JGizmo/JGizmoToolkit.hh"
#include "JSupport/JMeta.hh"

Go to the source code of this file.

Functions

vector< TObject * > getListOfObjects (vector< JRootObjectID > listOfPatterns)
 
int main (int argc, char **argv)
 

Detailed Description

Program to compare root histograms.


The input histograms and the test to be applied for each histogram are specified
through the command line.

The histogram names are treated as regular expressions. Therefore, multiple histograms could be tested on one shot.
The command line argument specifies the test to be performed, and the corresponding parameters. See JTestDictionary()

Author
rgruiz

Definition in file JMantisShrimp.cc.

Function Documentation

vector<TObject*> getListOfObjects ( vector< JRootObjectID listOfPatterns)
inline

Definition at line 24 of file JMantisShrimp.cc.

24  {
25 
26  vector<TObject*> listOfObjects;
27 
28  for (vector<JRootObjectID>::const_iterator pattern = listOfPatterns.begin(); pattern != listOfPatterns.end(); ++pattern) {
29 
30  TDirectory* dir = getDirectory(*pattern);
31 
32  if (dir == NULL) {
33  ERROR("File: " << pattern->getFullFilename() << " not opened." << endl);
34  continue;
35  }
36 
37  const TRegexp regexp(pattern->getObjectName());
38 
39  TIter iter(dir->GetListOfKeys());
40 
41  for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
42 
43  const TString tag(key->GetName());
44 
45  if (tag.Contains(regexp)) {
46 
47  TObject* p = key->ReadObj();
48  p->SetUniqueID(dir->GetUUID().GetUUIDNumber());
49  listOfObjects.push_back(p);
50  }
51  }
52  }
53  return listOfObjects;
54 }
Definition: JRoot.hh:19
#define ERROR(A)
Definition: JMessage.hh:66
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
int main ( int  argc,
char **  argv 
)

Definition at line 69 of file JMantisShrimp.cc.

69  {
70 
71  string steeringFile;
72 
73  vector<JRootObjectID> input_a;
74  vector<JRootObjectID> input_b;
75  string test;
76  string output;
77  string ascii;
78  bool onlyFailures;
79 
80  try {
81  JParser<> zap("\nProgram to compare root histograms. See the link below this usage for further details.\n");
82  zap['a'] = make_field(input_a, "Histogram a");
83  zap['b'] = make_field(input_b, "Histogram b");
84  zap['t'] = make_field(test, "Test parameters");
85  zap['o'] = make_field(output, "output file") = "out.root";
86  zap['t'] = make_field(ascii , "output file txt" ) = " ";
87  zap['w'] = make_field(onlyFailures , "write only failed tests" );
88 
89  zap(argc,argv);
90  }
91  catch(const exception &error) {
92  ERROR(error.what() << endl);
93  }
94 
96 
97  int testID;
98 
99  istringstream iss(test);
100  iss >> testID;
101  d[testID]->read(iss);
102 
103  vector<TObject*> listOfObjects_a = getListOfObjects(input_a);
104  vector<TObject*> listOfObjects_b = getListOfObjects(input_b);
105 
106  for(vector<TObject*>::const_iterator object_a = listOfObjects_a.begin() ; object_a != listOfObjects_a.end() ; ++object_a){
107  for(vector<TObject*>::const_iterator object_b = listOfObjects_b.begin() ; object_b != listOfObjects_b.end() ; ++object_b){
108 
109  d[testID]->test(*object_a,*object_b);
110  }
111  }
112 
113  TFile out(output.c_str(),"recreate");
114  out.cd();
115 
116  d[testID]->write(cout);
117  d[testID]->save(&out, "", onlyFailures);
118 
119  if(ascii != " "){
120  ofstream results;
121  results.open (ascii);
122  d[testID]->write(results, ";", onlyFailures);
123  results.close();
124  }
125 
126  putObject(&out, JMeta(argc, argv));
127 
128  out.Close();
129 
130  return 0;
131 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:70
Utility class to parse command line options.
Definition: JParser.hh:1500
vector< TObject * > getListOfObjects(vector< JRootObjectID > listOfPatterns)
bool putObject(TDirectory *dir, const TObject &object)
Write object to ROOT directory.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
#define ERROR(A)
Definition: JMessage.hh:66
then JMuonMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
Definition: JMuonPath.sh:47