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

Auxiliary program to convert ROOT TTree with slow control data to ROOT TGraph's. More...

#include <string>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <set>
#include <map>
#include "TROOT.h"
#include "TFile.h"
#include "TGraph.h"
#include "TTimeStamp.h"
#include "TNamed.h"
#include "JDB/JDatalog.hh"
#include "JDB/JSupport.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JROOT/JGraph.hh"
#include "JROOT/JRootToolkit.hh"
#include "JTools/JRange.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to convert ROOT TTree with slow control data to ROOT TGraph's.

Author
mdejong

Definition in file JTuna2Graph.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 116 of file JTuna2Graph.cc.

117 {
118  using namespace std;
119  using namespace JPP;
120 
122  JLimit_t& numberOfEvents = inputFile.getLimit();
123  string outputFile;
124  set<string> filter;
125  int debug;
126 
127  try {
128 
129  JParser<> zap("Auxiliary program to convert ROOT TTree with slow control data to ROOT TGraph's.");
130 
131  zap['f'] = make_field(inputFile, "ROOT input file (output file of JTuna).");
132  zap['n'] = make_field(numberOfEvents) = JLimit::max();
133  zap['o'] = make_field(outputFile, "ROOT output file");
134  zap['F'] = make_field(filter, "filter") = JPARSER::initialised();
135  zap['d'] = make_field(debug) = 2;
136 
137  zap(argc, argv);
138  }
139  catch(const exception &error) {
140  FATAL(error.what() << endl);
141  }
142 
143 
145 
147  set<int> floors;
148 
149  long long int counter = 0;
150 
151  for (inputFile.rewind(); inputFile.hasNext(); ++counter) {
152 
153  STATUS(setw(10) << counter << '\r'); DEBUG(endl);
154 
155  JDatalog* p = inputFile.next();
156 
157  if (filter.count(p->parameter) == 0) {
158 
159  JGraph_t& g1 = data[JKey_t(p->string, p->floor, p->parameter)];
160 
161  g1.put(p->getTime(), p->value);
162 
163  strings.insert(p->string);
164  floors .insert(p->floor);
165  }
166  }
167  STATUS(endl);
168 
169 
170  TFile out(outputFile.c_str(), "recreate");
171 
172  for (map<JKey_t, JGraph_t>::iterator i = data.begin(); i != data.end(); ++i) {
173 
174  JGraph g1(i->second, i->first.toString().c_str());
175 
176  const JRange<double> range(i->second.Y.begin(), i->second.Y.end());
177 
178  g1.SetMinimum(range.getLowerLimit());
179  g1.SetMaximum(range.getUpperLimit());
180 
181  out << g1;
182  }
183 
184  ostringstream os;
185 
186  os << "set_variable NUMBER_OF_STRINGS " << setw(4) << strings.size() << ";" << endl;
187  os << "set_variable NUMBER_OF_FLOORS " << setw(4) << floors. size() << ";" << endl;
188  if (!strings.empty()) {
189  os << "set_variable FIRST_STRING " << setw(4) << *strings. begin() << ";" << endl;
190  os << "set_variable LAST_STRING " << setw(4) << *strings.rbegin() << ";" << endl;
191  }
192  if (!floors.empty()) {
193  os << "set_variable FIRST_FLOOR " << setw(4) << *floors. begin() << ";" << endl;
194  os << "set_variable LAST_FLOOR " << setw(4) << *floors. rbegin() << ";" << endl;
195  }
196  os << "set_array STRINGS ";
197  copy(strings.begin(), strings.end(), ostream_iterator<int>(os, " "));
198  os << endl;
199 
200  TNamed meta("TUNA", os.str().c_str());
201 
202  out << meta;
203 
204  out.Write();
205  out.Close();
206 }
Utility class to parse command line options.
Definition: JParser.hh:1500
double getTime() const
Get time.
Definition: JDatalog.hh:65
void put(const Double_t x, const Double_t y)
Put data.
Definition: JGraph.hh:28
Data structure for graph data.
Definition: JGraph.hh:21
#define STATUS(A)
Definition: JMessage.hh:63
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:66
then usage $script< detector specific pre-calibration script >< option > nAuxiliary script to make scan of pre stretching of detector strings(see JEditDetector)." "\nPossible options
Auxiliary data structure to build TGraph.
Definition: JGraph.hh:42
string outputFile
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:67
#define FATAL(A)
Definition: JMessage.hh:67
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
std::string parameter
Definition: JDatalog.hh:74
General purpose class for object reading from a list of file names.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:139
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25