49int main(
int argc,
char **argv)
62 JRange_t runs = JRange_t::DEFAULT_RANGE();
63 long long int numberOfRows;
71 locate.insert(
"pmt_id");
72 locate.insert(
"pmt_threshold");
73 locate.insert(
"pmt_threshold@");
74 locate.insert(
"pmt_highvolt");
75 locate.insert(
"pmt_highvolt@");
79 JParser<> zap(
"Auxiliary program to convert slow control data from the database to ROOT TTree.");
86 zap[
'D'] =
make_field(detid,
"Detector identifier");
88 zap[
'n'] =
make_field(numberOfRows,
"Maximal number of rows") = numeric_limits<long long int>::max();
91 zap[
'P'] =
make_field(prescale,
"Prescale sampling of data") = 1;
92 zap[
'G'] =
make_field(graph,
"Write TGraph instead of TTree");
98 catch(
const exception &error) {
99 FATAL(error.what() << endl);
102 filter.push_back(
MAKE_STRING(FILTER <<
"CLBControlTimeoutMS"));
109 WARNING(
"Setting prescale to one." << endl);
137 JDB::reset(usr, pwd, cookie);
153 DEBUG(
"Number of integrated products (before) " << right <<
detector.size() << endl);
157 DEBUG(
"Number of integrated products (after) " << right <<
detector.size() << endl);
166 for (
JAllParams parameters; rs >> parameters; ) {
173 if (
to_upper(parameters.TYPE) ==
"INTEGER" && parameters.INTEGER_UNIT_SCALE > 0.0) {
174 unit[
to_upper(parameters.NAME)] = parameters.INTEGER_UNIT_SCALE;
190 long long int counter = 0;
192 for (
JDatalogNumbers parameters; rs >> parameters && counter != numberOfRows; ++counter) {
196 const JUPI_t upi = parameters.SOURCE_NAME;
201 strings.insert(location.
string);
202 floors .insert(location.
floor);
206 for (vector<string>::const_iterator i = filter.begin(); i != filter.end(); ++i) {
210 bool nos = (*i)[0] == FILTER;
211 TRegexp regexp = (nos ? i->substr(1).c_str() : i->c_str());
213 if (TString(parameters.PARAMETER_NAME).Contains(regexp)) {
221 if (location.
string >= (
int) data.size()) {
222 data.resize(location.
string + 1);
225 if (location.
floor >= (
int) data[location.
string].size()) {
229 string buffer = parameters.PARAMETER_NAME;
231 if (locate.count(buffer) != 0) {
235 JGraph_t&
g1 = data[location.
string][location.
floor][buffer];
244 errors[parameters.PARAMETER_NAME] += 1;
247 if ((counts[location.
string][location.
floor][buffer]++)%prescale == 0) {
255 parameters.PARAMETER_NAME,
257 parameters.DATA_VALUE * factor));
261 g1.put(parameters.getTime(), parameters.DATA_VALUE * factor);
268 warnings[parameters.PARAMETER_NAME] += 1;
274 catch(
const exception& error) {
275 ERROR(error.what() << endl);
280 cout << endl <<
"Parameters without location in detector." << endl;
283 cout << left << setw(48) << i->first <<
' ' << setw(6) << i->second << endl;
287 if (!errors.empty()) {
289 cout << endl <<
"Parameters without scale." << endl;
292 cout << left << setw(48) << i->first <<
' ' << setw(6) << i->second << endl;
298 for (
size_t string = 0;
string != data.size(); ++string) {
299 for (
size_t floor = 0; floor != data[string].size(); ++floor) {
300 for (map_type::iterator i = data[
string][floor].begin(); i != data[string][floor].end(); ++i) {
304 const JRange<double> range(i->second.Y.begin(), i->second.Y.end());
316 os <<
"set_variable NUMBER_OF_STRINGS " << setw(4) << strings.size() <<
";" << endl;
317 os <<
"set_variable NUMBER_OF_FLOORS " << setw(4) << floors. size() <<
";" << endl;
318 if (!strings.empty()) {
319 os <<
"set_variable FIRST_STRING " << setw(4) << *strings. begin() <<
";" << endl;
320 os <<
"set_variable LAST_STRING " << setw(4) << *strings.rbegin() <<
";" << endl;
322 if (!floors.empty()) {
323 os <<
"set_variable FIRST_FLOOR " << setw(4) << *floors. begin() <<
";" << endl;
324 os <<
"set_variable LAST_FLOOR " << setw(4) << *floors. rbegin() <<
";" << endl;
326 os <<
"set_array STRINGS ";
327 copy(strings.begin(), strings.end(), ostream_iterator<int>(os,
" "));
330 outputFile.put(TNamed(
"TUNA", os.str().c_str()));