37 const char FILTER =
'!';
47 int main(
int argc,
char **argv)
59 JRange_t runs = JRange_t::DEFAULT_RANGE;
60 long long int numberOfRows;
68 locate.insert(
"pmt_id");
69 locate.insert(
"pmt_threshold");
70 locate.insert(
"pmt_threshold@");
71 locate.insert(
"pmt_highvolt");
72 locate.insert(
"pmt_highvolt@");
76 JParser<> zap(
"Auxiliary program to convert slow control data from the database to ROOT TTree.");
82 zap[
'D'] =
make_field(detid,
"Detector identifier");
84 zap[
'n'] =
make_field(numberOfRows,
"Maximal number of rows") = numeric_limits<long long int>::max();
87 zap[
'P'] =
make_field(prescale,
"Prescale sampling of data") = 1;
88 zap[
'G'] =
make_field(graph,
"Write TGraph instead of TTree");
94 catch(
const exception &error) {
95 FATAL(error.what() << endl);
98 filter.push_back(
MAKE_STRING(FILTER <<
"CLBControlTimeoutMS"));
100 if (runs.getUpperLimit() < runs.getLowerLimit()) {
101 runs.setUpperLimit(runs.getLowerLimit());
105 WARNING(
"Setting prescale to one." << endl);
115 void put(
const Double_t x,
const Double_t y)
155 DEBUG(
"Reading database table " << getTable<JDetectorIntegration>() << endl);
157 ResultSet& rs =
getResultSet(getTable<JDetectorIntegration>());
164 DEBUG(
"Number of integrated products (before) " << right <<
detector.size() << endl);
168 DEBUG(
"Number of integrated products (after) " << right <<
detector.size() << endl);
173 DEBUG(
"Reading database table " << getTable<JAllParams>() << endl);
177 for (
JAllParams parameters; rs >> parameters; ) {
179 unit[
to_upper(parameters.NAME)] = parameters.UNIT_EASY_SCALE;
181 catch(
const exception &error) {
182 FATAL(error.what() << endl);
191 runs.getLowerLimit(),
192 runs.getUpperLimit());
194 ResultSet& rs =
getResultSet(getTable<JDatalogNumbers>(), selection);
196 long long int counter = 0;
198 for (
JDatalogNumbers parameters; rs >> parameters && counter != numberOfRows; ++counter) {
202 const JUPI upi = parameters.SOURCE_NAME;
203 const JLocation_t& location = router.getLocation(upi);
207 strings.insert(location.
string);
208 floors .insert(location.
floor);
216 bool nos = (*i)[0] == FILTER;
217 TRegexp regexp = (nos ? i->substr(1).c_str() : i->c_str());
219 if (TString(parameters.PARAMETER_NAME).Contains(regexp)) {
227 if (location.
string >= (
int) data.size()) {
228 data.resize(location.
string + 1);
231 if (location.
floor >= (
int) data[location.
string].size()) {
235 string buffer = parameters.PARAMETER_NAME;
237 if (locate.count(buffer) != 0) {
241 JGraph_t&
g1 = data[location.
string][location.
floor][buffer];
250 errors[parameters.PARAMETER_NAME] += 1;
253 if ((
g1.counter++)%prescale == 0) {
261 parameters.PARAMETER_NAME,
263 parameters.DATA_VALUE * factor));
267 g1.put(parameters.getTime(), parameters.DATA_VALUE * factor);
274 warnings[parameters.PARAMETER_NAME] += 1;
280 catch(
const exception& error) {
281 FATAL(error.what() << endl);
286 cout << endl <<
"Parameters without location in detector." << endl;
289 cout << left << setw(48) << i->first <<
' ' << setw(6) << i->second << endl;
293 if (!errors.empty()) {
295 cout << endl <<
"Parameters without scale." << endl;
298 cout << left << setw(48) << i->first <<
' ' << setw(6) << i->second << endl;
304 for (
size_t string = 0;
string != data.size(); ++string) {
305 for (
size_t floor = 0; floor != data[string].size(); ++floor) {
306 for (map_type::iterator i = data[
string][floor].begin(); i != data[string][floor].end(); ++i) {
308 TGraph
g1(i->second.X.size(), i->second.X.data(), i->second.Y.data());
310 g1.SetName(
MAKE_CSTRING(
FILL(3,
'0') <<
string <<
'.' <<
FILL(2,
'0') << floor <<
'.' << setfill(
' ') << i->first));
312 const JRange<double> range(i->second.Y.begin(), i->second.Y.end());
314 g1.SetMinimum(range.getLowerLimit());
315 g1.SetMaximum(range.getUpperLimit());
324 os <<
"set_variable NUMBER_OF_STRINGS " << setw(4) << strings.size() <<
";" << endl;
325 os <<
"set_variable NUMBER_OF_FLOORS " << setw(4) << floors. size() <<
";" << endl;
326 if (!strings.empty()) {
327 os <<
"set_variable FIRST_STRING " << setw(4) << *strings. begin() <<
";" << endl;
328 os <<
"set_variable LAST_STRING " << setw(4) << *strings.rbegin() <<
";" << endl;
330 if (!floors.empty()) {
331 os <<
"set_variable FIRST_FLOOR " << setw(4) << *floors. begin() <<
";" << endl;
332 os <<
"set_variable LAST_FLOOR " << setw(4) << *floors. rbegin() <<
";" << endl;
334 os <<
"set_array STRINGS ";
335 copy(strings.begin(), strings.end(), ostream_iterator<int>(os,
" "));
338 outputFile.put(TNamed(
"TUNA", os.str().c_str()));