diff --git a/srcC/examples/chargeSum.cpp b/srcC/examples/chargeSum.cpp index b30bdd6..e99caea 100644 --- a/srcC/examples/chargeSum.cpp +++ b/srcC/examples/chargeSum.cpp @@ -27,9 +27,9 @@ int main(int argc, char** argv) { // instantiate QADB - QADB * qa = new QADB(); + QADB * qa = new QADB("latest"); // alternatively, specify run range to restrict QADB (may be more efficient) - //QADB * qa = new QADB(5000,5500); + //QADB * qa = new QADB("latest",5000,5500); // define variables diff --git a/srcC/examples/cutAsymmetry.cpp b/srcC/examples/cutAsymmetry.cpp index 96497e8..494ff84 100644 --- a/srcC/examples/cutAsymmetry.cpp +++ b/srcC/examples/cutAsymmetry.cpp @@ -26,9 +26,9 @@ int main(int argc, char** argv) { // instantiate QADB - QADB * qa = new QADB(); + QADB * qa = new QADB("latest"); // alternatively, specify run range to restrict QADB (may be more efficient) - //QADB * qa = new QADB(5000,5500); + //QADB * qa = new QADB("latest",5000,5500); // define variables diff --git a/srcC/examples/cutCustom.cpp b/srcC/examples/cutCustom.cpp index 76dff83..e75932d 100644 --- a/srcC/examples/cutCustom.cpp +++ b/srcC/examples/cutCustom.cpp @@ -28,9 +28,9 @@ int main(int argc, char** argv) { // instantiate QADB - QADB * qa = new QADB(); + QADB * qa = new QADB("latest"); // alternatively, specify run range to restrict QADB (may be more efficient) - //QADB * qa = new QADB(5000,5500); + //QADB * qa = new QADB("latest",5000,5500); // custom QA cut definition // - decide which defects you want to check for; an event will not pass diff --git a/srcC/examples/cutGolden.cpp b/srcC/examples/cutGolden.cpp index f81b281..fb7946c 100644 --- a/srcC/examples/cutGolden.cpp +++ b/srcC/examples/cutGolden.cpp @@ -27,9 +27,9 @@ int main(int argc, char** argv) { // instantiate QADB - QADB * qa = new QADB(); + QADB * qa = new QADB("latest"); // alternatively, specify run range to restrict QADB (may be more efficient) - //QADB * qa = new QADB(5000,5500); + //QADB * qa = new QADB("latest",5000,5500); // define variables diff --git a/srcC/examples/dumpQADB.cpp b/srcC/examples/dumpQADB.cpp index 6f6682c..f5317a6 100644 --- a/srcC/examples/dumpQADB.cpp +++ b/srcC/examples/dumpQADB.cpp @@ -26,9 +26,9 @@ int main(int argc, char ** argv) { // instantiate QADB - QADB * qa = new QADB(); + QADB * qa = new QADB("latest"); // alternatively, specify run range to restrict QADB (may be more efficient) - //QADB * qa = new QADB(5000,5500); + //QADB * qa = new QADB("latest",5000,5500); // loop through QA bins diff --git a/srcC/include/QADB.h b/srcC/include/QADB.h index 9d48701..33ccd53 100644 --- a/srcC/include/QADB.h +++ b/srcC/include/QADB.h @@ -42,12 +42,27 @@ namespace QA { // constructor //````````````````` //arguments: + // - cook: which cook (pass) to use: + // - 'latest': just use the latest available one + // - 'pass1': use pass 1 + // - 'pass2': use pass 2 // - runnumMin and runnumMax: if both are negative (default), then the // entire QADB will be read; you can restrict to a specific range of // runs to limit QADB, which may be more effecient // - verbose: if true, print (a lot) more information - inline QADB(int runnumMin_=-1, int runnumMax=-1, bool verbose_=false); - + inline QADB(std::string const& cook, int runnumMin_=-1, int runnumMax=-1, bool verbose_=false); + + inline QADB(int runnumMin_=-1, int runnumMax=-1, bool verbose_=false) { + std::cerr << R"(| ERROR: QADB constructor now requires you to specify the cook as the first argument +| - use "latest" to use the latest available cook's QADB +| - see the QADB documentation for the list of available QADBs +| - the latest cook may not yet have a QADB +| - use "pass1" to restrict to Pass 1 cooks +| - older data may have less QA defect bits, or other issues +| - use "pass2" to restrict to Pass 2 data, etc. +)"; + throw std::runtime_error("please specify the cook"); + } //............................... // golden QA cut @@ -228,7 +243,7 @@ namespace QA { //............... // constructor //``````````````` - QADB::QADB(int runnumMin_, int runnumMax_, bool verbose_) { + QADB::QADB(std::string const& cook, int runnumMin_, int runnumMax_, bool verbose_) { runnumMin = runnumMin_; runnumMax = runnumMax_; @@ -241,7 +256,12 @@ namespace QA { std::cerr << "ERROR: QADB environment variable not set" << std::endl; return; }; - dbDirN += "/qadb/latest"; + dbDirN += "/qadb"; + std::set cooks_avail{"latest", "pass1", "pass2"}; + if(cooks_avail.find(cook) != cooks_avail.end()) + dbDirN += std::string("/") + cook; + else + throw std::runtime_error("cook '" + cook + "' is not available"); if(verbose) std::cout << "QADB at " << dbDirN << std::endl; // get list of json files diff --git a/srcC/tests/testCharge.cpp b/srcC/tests/testCharge.cpp index dd1099d..32694d0 100644 --- a/srcC/tests/testCharge.cpp +++ b/srcC/tests/testCharge.cpp @@ -14,9 +14,9 @@ using namespace std; int main(int argc, char ** argv) { // instantiate QADB - QADB * qa = new QADB(); + QADB * qa = new QADB("latest"); // alternatively, specify run range to restrict QADB (may be more efficient) - //QADB * qa = new QADB(5000,5500); + //QADB * qa = new QADB("latest",5000,5500); int evnum; string defname; int chargeInt; diff --git a/srcC/tests/testDumpQADB.cpp b/srcC/tests/testDumpQADB.cpp index 1b6fd97..89f51bb 100644 --- a/srcC/tests/testDumpQADB.cpp +++ b/srcC/tests/testDumpQADB.cpp @@ -32,9 +32,9 @@ int main(int argc, char ** argv) { // instantiate QADB - QADB * qa = new QADB(); + QADB * qa = new QADB("latest"); // alternatively, specify run range to restrict QADB (may be more efficient) - //QADB * qa = new QADB(5000,5500); + //QADB * qa = new QADB("latest",5000,5500); diff --git a/srcC/tests/testOkForAsymmetry.cpp b/srcC/tests/testOkForAsymmetry.cpp index b6d46bf..7f0e4ad 100644 --- a/srcC/tests/testOkForAsymmetry.cpp +++ b/srcC/tests/testOkForAsymmetry.cpp @@ -14,7 +14,7 @@ int main(int argc, char ** argv) { // to avoid in their analysis, and a list of runs for which the `Misc` defect bit // should be ignored std::cout << "Loading QADBs..." << std::endl; - auto qa = new QA::QADB(); + auto qa = new QA::QADB("latest"); qa->CheckForDefect("TotalOutlier"); // these choices match the criteria of `OkForAsymmetry` qa->CheckForDefect("TerminalOutlier"); qa->CheckForDefect("MarginalOutlier"); @@ -36,8 +36,8 @@ int main(int argc, char ** argv) { // instantiate more QADBs, for comparison (`qa` will use the general method) - auto qa_deprecated = new QA::QADB(); // will use `OkForAsymmetry`, which is deprecated - auto qa_third_party = new QA::QADB(); // a third party, only used for DB traversal + auto qa_deprecated = new QA::QADB("latest"); // will use `OkForAsymmetry`, which is deprecated + auto qa_third_party = new QA::QADB("latest"); // a third party, only used for DB traversal std::cout << "...done" << std::endl; // compare the QADBs' results: prove the above general method is equivalent to `OkForAsymmetry`