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";
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) {
182 if (getFilenameExtension(
outputFile) == ROOT_FILE_FORMAT) {
184 FATAL(
"Invalid total weight: " << W <<
endl);
193 if (inputFile ==
"") {
208 NOTICE(
"Extracting run information from database... " << flush);
212 for (
JRuns parameters; rs >> parameters; ) {
213 if (TString(parameters.RUNSETUPNAME.c_str()).Contains(
regexp)) {
233 selector.add(&JRunSummaryNumbers::SOURCE_NAME, *git);
237 NOTICE(
"Extracting run summmary information with source " << *git <<
" from database... " << flush);
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) {
263 for (data_type::const_iterator i = run->second.begin(); i != run->second.end(); ++i) {
264 quality.put(i->first, i->second);
273 catch(
const exception& error) {
279 if (detid !=
"" && !is_integer(detid)) {
280 WARNING(
"Detector identifier \"" << detid <<
"\" discarded." <<
endl);
303 if (buffer.empty()) {
307 if (
debug >= debug_t) {
317 if (getFilenameExtension(
outputFile) == ROOT_FILE_FORMAT) {
319 runs = JRange_t(buffer.begin()->run, buffer.rbegin()->run);
321 TH1D h0(
"h0",
NULL, 1000, 0.0, 1.01);
324 for (
size_t i = 0; i !=
condition.size(); ++i) {
325 h1.GetXaxis()->SetBinLabel(i+1,
condition[i].formula.c_str());
329 h0.SetMaximum(1.1 * (
runs.getUpperLimit() -
runs.getLowerLimit() + 1));
332 h1.SetMaximum(1.1 * (
runs.getUpperLimit() -
runs.getLowerLimit() + 1));
337 JManager<TString, TH1D>
H1(
new TH1D(
"%",
NULL,
runs.getLength() + 1, xmin, xmax));
342 H1[i->formula]->GetListOfFunctions()->Add(
new TF1(
MAKE_CSTRING(
"C " << i->formula <<
":upper"),
MAKE_CSTRING(i->range.getUpperLimit()), xmin, xmax));
343 H1[i->formula]->GetListOfFunctions()->Add(
new TF1(
MAKE_CSTRING(
"C " << i->formula <<
":lower"),
MAKE_CSTRING(i->range.getLowerLimit()), xmin, xmax));
346 for (JCondition_t::const_iterator i =
veto.begin(); i !=
veto.end();++i) {
347 H1[i->formula]->GetListOfFunctions()->Add(
new TF1(
MAKE_CSTRING(
"V " << i->formula <<
":upper"),
MAKE_CSTRING(i->range.getUpperLimit()), xmin, xmax));
348 H1[i->formula]->GetListOfFunctions()->Add(
new TF1(
MAKE_CSTRING(
"V " << i->formula <<
":lower"),
MAKE_CSTRING(i->range.getLowerLimit()), xmin, xmax));
355 for (
size_t i = 0; i !=
condition.size(); ++i) {
356 os <<
":" << (
char) (
'a' + i);
361 TNtuple n1(
"n1",
"quality", os.str().c_str());
372 for (
size_t i = 0; i !=
condition.size(); ++i) {
375 const double y = getResult(ps.formula, *
quality);
383 p->SetBinContent(p->FindBin((
double)
quality->run), y);
390 h1.AddBinContent(i + 1, ps.range(y) ? 1.0 : 0.0);
393 const double Q = w/W;
399 for (
size_t i = 0; i !=
veto.size(); ++i) {
401 const JCondition& ps =
veto[i];
402 const double y = getResult(ps.formula, *
quality);
410 p->SetBinContent(p->FindBin((
double)
quality->run), y);
415 p->SetBinContent(p->FindBin((
double)
quality->run), ps.range(y) ? 0.0 : 1.0);
435 h0.SetBinContent(i, (w += h0.GetBinContent(i)));
442 out << h0 << h1 <<
n1 <<
H1;
449 if (getFilenameExtension(
outputFile) == ASCII_FILE_FORMAT) {
455 out.setf(ios::fixed);