131 typedef JRange<int> JRange_t;
143 JCondition_t condition;
151 JParser<> zap(
"Main program to evaluate quality data from data base."\
152 "\nThe condition and veto can be any TFormula compatible expression involving QA/QC parameters (see e.g. JQAQC.sh -h).");
158 zap[
'f'] =
make_field(inputFile,
"Optional input file instead of database.") =
"";
159 zap[
'o'] =
make_field(
outputFile,
"ROOT file with histograms and n-tuple or ASCII file with QA/QC data.") =
"quality.root";
161 zap[
'R'] =
make_field(runs,
"Run range") = JRange_t(1, JRange_t::getMaximum());
162 zap[
'S'] =
make_field(source,
"GIT versions") =
getGITTags(TRegexp(
"v[0-9]*\\.[0-9]*\\.[0-9]*$"), JGITTags_t::key_type(
"2019-04-12"));
171 catch(
const exception &error) {
172 FATAL(error.what() << endl);
178 for (JCondition_t::const_iterator i = condition.begin(); i != condition.end(); ++i) {
184 FATAL(
"Invalid total weight: " << W << endl);
193 if (inputFile ==
"") {
201 const int ID = getDetector<int> (detid);
202 detid = getDetector<string>(detid);
206 selection += getSelector<JRuns>(
ID);
208 NOTICE(
"Extracting run information from database... " << flush);
210 ResultSet& rs =
getResultSet(getTable<JRuns>(), selection);
213 if (TString(parameters.RUNSETUPNAME.c_str()).Contains(regexp)) {
214 setups.put(parameters);
231 JSelector selector = getSelector<JRunSummaryNumbers>(detid, runs.getLowerLimit(), runs.getUpperLimit());
233 selector.add(&JRunSummaryNumbers::SOURCE_NAME, *git);
237 NOTICE(
"Extracting run summmary information with source " << *git <<
" from database... " << flush);
239 ResultSet& rs =
getResultSet(getTable<JRunSummaryNumbers>(), selector);
241 for (JRunSummaryNumbers parameters; rs >>
parameters; ) {
242 if (setups.has(parameters.RUN)) {
243 zmap[parameters.RUN].insert(make_pair(parameters.PARAMETER_NAME, parameters.DATA_VALUE));
251 catch(
const exception& error) {
NOTICE(endl); }
253 for (map_type::const_iterator run = zmap.begin(); run != zmap.end(); ++run) {
258 quality.detector =
ID;
259 quality.run = run->first;
260 quality.value = setups[run->first].value;
262 for (data_type::const_iterator i = run->second.begin(); i != run->second.end(); ++i) {
263 quality.put(i->first, i->second);
266 buffer.insert(quality);
270 catch(
const exception& error) {
271 FATAL(error.what() << endl);
282 for (JRunQuality quality;
in >> quality; ) {
283 buffer.insert(quality);
290 if (buffer.empty()) {
291 FATAL(
"No data." << endl);
297 runs = JRange_t(buffer.begin()->run, buffer.rbegin()->run);
299 TH1D h0(
"h0", NULL, 1000, 0.0, 1.01);
300 TH1D
h1(
"h1", NULL, condition.size(), -0.5, condition.size() - 0.5);
302 for (
size_t i = 0; i != condition.size(); ++i) {
303 h1.GetXaxis()->SetBinLabel(i+1, condition[i].formula.c_str());
307 h0.SetMaximum(1.1 * (runs.getUpperLimit() - runs.getLowerLimit()));
310 h1.SetMaximum(1.1 * (runs.getUpperLimit() - runs.getLowerLimit()));
312 const Double_t xmin = runs.getLowerLimit() - 0.5;
313 const Double_t xmax = runs.getUpperLimit() + 0.5;
315 JManager<TString, TH1D> H1(
new TH1D(
"%", NULL, runs.getLength() + 1, xmin, xmax));
319 for (JCondition_t::const_iterator i = condition.begin(); i != condition.end();++i) {
320 H1[i->formula]->GetListOfFunctions()->Add(
new TF1(
MAKE_CSTRING(
"C " << i->formula <<
":upper"),
MAKE_CSTRING(i->range.getUpperLimit()), xmin, xmax));
321 H1[i->formula]->GetListOfFunctions()->Add(
new TF1(
MAKE_CSTRING(
"C " << i->formula <<
":lower"),
MAKE_CSTRING(i->range.getLowerLimit()), xmin, xmax));
324 for (JCondition_t::const_iterator i = veto.begin(); i != veto.end();++i) {
325 H1[i->formula]->GetListOfFunctions()->Add(
new TF1(
MAKE_CSTRING(
"V " << i->formula <<
":upper"),
MAKE_CSTRING(i->range.getUpperLimit()), xmin, xmax));
326 H1[i->formula]->GetListOfFunctions()->Add(
new TF1(
MAKE_CSTRING(
"V " << i->formula <<
":lower"),
MAKE_CSTRING(i->range.getLowerLimit()), xmin, xmax));
333 for (
size_t i = 0; i != condition.size(); ++i) {
334 os <<
":" << (char) (
'a' + i);
339 TNtuple n1(
"n1",
"quality", os.str().c_str());
350 for (
size_t i = 0; i != condition.size(); ++i) {
352 const JCondition& ps = condition[i];
353 const double y =
getResult(ps.formula, *quality);
355 DEBUG(ps.formula <<
' ' << y << endl);
357 tuple.push_back((Float_t) y);
359 TH1D* p = H1[ps.formula];
361 p->SetBinContent(p->FindBin((
double) quality->run), y);
362 p->SetBinError (p->FindBin((
double) quality->run), numeric_limits<double>::epsilon());
368 h1.AddBinContent(i + 1, ps.range(y) ? 1.0 : 0.0);
371 const double Q = w/W;
373 tuple.push_back((Float_t) Q);
377 for (
size_t i = 0; i != veto.size(); ++i) {
379 const JCondition& ps = veto[i];
380 const double y =
getResult(ps.formula, *quality);
382 DEBUG(ps.formula <<
' ' << y << endl);
388 p->SetBinContent(p->FindBin((
double) quality->run), y);
389 p->SetBinError (p->FindBin((
double) quality->run), numeric_limits<double>::epsilon());
393 p->SetBinContent(p->FindBin((
double) quality->run), ps.range(y) ? 0.0 : 1.0);
394 p->SetBinError (p->FindBin((
double) quality->run), numeric_limits<double>::epsilon());
401 tuple.push_back((Float_t) V);
402 tuple.push_back((Float_t) setups.get(quality->run));
405 n1.Fill(tuple.data());
407 cout << setw(8) << quality->run <<
' ' <<
FIXED(5,3) << Q <<
' ' << setw(2) << V << endl;
412 for (Int_t i = 0; i <= h0.GetXaxis()->GetNbins(); ++i) {
413 h0.SetBinContent(i, (w += h0.GetBinContent(i)));
420 out << h0 <<
h1 << n1 << H1;
433 out.setf(ios::fixed);
437 comment.add(JMeta(argc, argv));
Utility class to parse command line options.
Q(UTCMax_s-UTCMin_s)-livetime_s
*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.
then for HISTOGRAM in h0 h1
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Auxiliary data structure for floating point format specification.
static const char *const ASCII_FILE_FORMAT
file name extension ASCII format
V(JDAQEvent-JTriggerReprocessor)*1.0/(JDAQEvent+1.0e-10)
#define MAKE_STRING(A)
Make string.
std::vector< std::string > getGITTags(const TRegexp ®exp, const JGITTags_t::key_type &date)
Get selection of GIT tags.
#define ASSERT(A,...)
Assert macro.
T & getInstance(const T &object)
Get static instance from temporary object.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Double_t getResult(const TString &text, TObject *object=NULL)
Get result of given textual formula.
std::string getFilenameExtension(const std::string &file_name)
Get file name extension, i.e. part after last JEEP::FILENAME_SEPARATOR if any.
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.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
static const char *const ROOT_FILE_FORMAT
file name extension ROOT format