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"));
104 if (runs.getUpperLimit() < runs.getLowerLimit()) {
105 runs.setUpperLimit(runs.getLowerLimit());
109 WARNING(
"Setting prescale to one." << endl);
146 DEBUG(
"Reading database table " << getTable<JDetectorIntegration_t>() << endl);
148 ResultSet& rs =
getResultSet(getTable<JDetectorIntegration_t>());
150 if (! (rs >> detector)) {
155 DEBUG(
"Number of integrated products (before) " << right << detector.size() << endl);
159 DEBUG(
"Number of integrated products (after) " << right << detector.size() << endl);
164 DEBUG(
"Reading database table " << getTable<JAllParams>() << endl);
175 if (
to_upper(parameters.TYPE) ==
"INTEGER" && parameters.INTEGER_UNIT_SCALE > 0.0) {
176 unit[
to_upper(parameters.NAME)] = parameters.INTEGER_UNIT_SCALE;
184 DEBUG(
"Reading database table " << getTable<JDatalogNumbers>() << endl);
187 runs.getLowerLimit(),
188 runs.getUpperLimit());
190 ResultSet& rs =
getResultSet(getTable<JDatalogNumbers>(), selection);
192 long long int counter = 0;
194 for (
JDatalogNumbers parameters; rs >> parameters && counter != numberOfRows; ++counter) {
198 const JUPI_t upi = parameters.SOURCE_NAME;
199 const JLocation_t& location = router.getLocation(upi);
203 strings.insert(location.
string);
204 floors .insert(location.
floor);
212 bool nos = (*i)[0] == FILTER;
213 TRegexp regexp = (nos ? i->substr(1).c_str() : i->c_str());
215 if (TString(parameters.PARAMETER_NAME).Contains(regexp)) {
223 if (location.
string >= (
int) data.size()) {
224 data.resize(location.
string + 1);
227 if (location.
floor >= (
int) data[location.
string].size()) {
231 string buffer = parameters.PARAMETER_NAME;
233 if (locate.count(buffer) != 0) {
246 errors[parameters.PARAMETER_NAME] += 1;
249 if ((counts[location.
string][location.
floor][buffer]++)%prescale == 0) {
257 parameters.PARAMETER_NAME,
259 parameters.DATA_VALUE * factor));
263 g1.
put(parameters.getTime(), parameters.DATA_VALUE * factor);
270 warnings[parameters.PARAMETER_NAME] += 1;
276 catch(
const exception& error) {
277 ERROR(error.what() << endl);
282 cout << endl <<
"Parameters without location in detector." << endl;
285 cout << left << setw(48) << i->first <<
' ' << setw(6) << i->second << endl;
289 if (!errors.empty()) {
291 cout << endl <<
"Parameters without scale." << endl;
294 cout << left << setw(48) << i->first <<
' ' << setw(6) << i->second << endl;
300 for (
size_t string = 0;
string != data.size(); ++string) {
301 for (
size_t floor = 0; floor != data[string].size(); ++floor) {
302 for (map_type::iterator i = data[
string][floor].begin(); i != data[string][floor].end(); ++i) {
308 g1.SetMinimum(
range.getLowerLimit());
309 g1.SetMaximum(
range.getUpperLimit());
318 os <<
"set_variable NUMBER_OF_STRINGS " << setw(4) << strings.size() <<
";" << endl;
319 os <<
"set_variable NUMBER_OF_FLOORS " << setw(4) << floors. size() <<
";" << endl;
320 if (!strings.empty()) {
321 os <<
"set_variable FIRST_STRING " << setw(4) << *strings. begin() <<
";" << endl;
322 os <<
"set_variable LAST_STRING " << setw(4) << *strings.rbegin() <<
";" << endl;
324 if (!floors.empty()) {
325 os <<
"set_variable FIRST_FLOOR " << setw(4) << *floors. begin() <<
";" << endl;
326 os <<
"set_variable LAST_FLOOR " << setw(4) << *floors. rbegin() <<
";" << endl;
328 os <<
"set_array STRINGS ";
329 copy(strings.begin(), strings.end(), ostream_iterator<int>(os,
" "));
332 outputFile.put(TNamed(
"TUNA", os.str().c_str()));
Utility class to parse command line options.
void put(const Double_t x, const Double_t y)
Put data.
Data structure for graph data.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
#define MAKE_CSTRING(A)
Make C-string.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Universal product identifier (UPI).
Auxiliary class for specifying selection of database data.
Auxiliary data structure to build TGraph.
#define MAKE_STRING(A)
Make string.
JDetectorsHelper getDetector
Function object for mapping serial number to object identifier of detector and vice versa...
int floor
position in string
Auxiliary data structure for location of product in detector.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
bool is_integer(const std::string &buffer)
Check if string is an integer.
std::string to_upper(const std::string &value)
Convert all character to upper case.
Auxiliary data structure for streaming of STL containers.
static const JPBSSequences CLB_SEQUENCES
PBS sequences for central-logic board.
Auxiliary class to map UPI to location in detector.
Auxiliary data structure for sequence of same character.
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
int position
position in floor
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
ResultSet & getResultSet(const std::string &query)
Get result set.
std::vector< JServer > getServernames()
Get list of names of available database servers.
Wrapper class for server name.
void copy(const Head &from, JHead &to)
Copy header from from to to.
do set_variable DETECTOR_TXT $WORKDIR detector
int string
position in detector
void configure(const std::string &detid)
Configure detector integration for given detector identifier.
Template definition for getting table specific selector.
do if[[!-f $ACOUSTICS_WORKDIR/${KEY}.txt]]
Double_t g1(const Double_t x)
Function.