Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
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

◆ main()

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;
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
146 set<int> strings;
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}
string outputFile
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define STATUS(A)
Definition JMessage.hh:63
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Double_t g1(const Double_t x)
Function.
Definition JQuantiles.cc:25
Utility class to parse command line options.
Definition JParser.hh:1698
General purpose class for object reading from a list of file names.
virtual void rewind() override
Rewind.
virtual bool hasNext() override
Check availability of next element.
virtual const pointer_type & next() override
Get next element.
Range of values.
Definition JRange.hh:42
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition JHead.cc:163
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
bool filter(const JDAQEvent &tev, const JEvt &evt, const Evt *const pE)
Event selection.
double getTime() const
Get time.
Definition JDatalog.hh:65
std::string parameter
Definition JDatalog.hh:74
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition JParser.hh:68
Auxiliary data structure to build TGraph.
Definition JGraph.hh:44
Auxiliary class for defining the range of iterations of objects.
Definition JLimit.hh:45
static counter_type max()
Get maximum counter value.
Definition JLimit.hh:128