Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JMantisShrimp.cc File Reference
#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)
 

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 63 of file JMantisShrimp.cc.

63  {
64 
65  string steeringFile;
66 
67  vector<JRootObjectID> input_a;
68  vector<JRootObjectID> input_b;
69  string test;
70  string output;
71 
72  try {
73  JParser<> zap;
74  zap['a'] = make_field(input_a, "Histogram a");
75  zap['b'] = make_field(input_b, "Histogram b");
76  zap['t'] = make_field(test, "Test parameters");
77  zap['o'] = make_field(output, "output file") = "out.root";
78  zap(argc,argv);
79  }
80  catch(const exception &error) {
81  ERROR(error.what() << endl);
82  }
83 
84  JTestDictionary d;
85 
86  int testID;
87 
88  istringstream iss(test);
89  iss >> testID;
90  d[testID]->read(iss);
91 
92  vector<TObject*> listOfObjects_a = getListOfObjects(input_a);
93  vector<TObject*> listOfObjects_b = getListOfObjects(input_b);
94 
95  for(vector<TObject*>::const_iterator object_a = listOfObjects_a.begin() ; object_a != listOfObjects_a.end() ; ++object_a){
96  for(vector<TObject*>::const_iterator object_b = listOfObjects_b.begin() ; object_b != listOfObjects_b.end() ; ++object_b){
97 
98  d[testID]->test(*object_a,*object_b);
99  }
100  }
101 
102  TFile out(output.c_str(),"recreate");
103  out.cd();
104 
105  d[testID]->write(cout);
106  d[testID]->save(&out, "");
107 
108  putObject(&out, JMeta(argc, argv));
109 
110  out.Close();
111 
112  return 0;
113 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:71
Utility class to parse command line options.
Definition: JParser.hh:1493
vector< TObject * > getListOfObjects(vector< JRootObjectID > listOfPatterns)
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
then print_variable DETECTOR INPUT_FILE INTERMEDIATE_FILE check_input_file $DETECTOR $INPUT_FILE check_output_file $INTERMEDIATE_FILE $OUTPUT_FILE JMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
Definition: JPath.sh:52
#define ERROR(A)
Definition: JMessage.hh:66
bool putObject(TDirectory *dir, const T &object)
Write object to ROOT directory.