Skip to content

Commit

Permalink
feat!: handle cook version (pass1 vs. pass2)
Browse files Browse the repository at this point in the history
  • Loading branch information
c-dilks committed Sep 28, 2024
1 parent 6668925 commit 216ec3d
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 21 deletions.
4 changes: 2 additions & 2 deletions srcC/examples/chargeSum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions srcC/examples/cutAsymmetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions srcC/examples/cutCustom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions srcC/examples/cutGolden.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions srcC/examples/dumpQADB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 24 additions & 4 deletions srcC/include/QADB.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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_;
Expand All @@ -241,7 +256,12 @@ namespace QA {
std::cerr << "ERROR: QADB environment variable not set" << std::endl;
return;
};
dbDirN += "/qadb/latest";
dbDirN += "/qadb";
std::set<std::string> 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
Expand Down
4 changes: 2 additions & 2 deletions srcC/tests/testCharge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions srcC/tests/testDumpQADB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);



Expand Down
6 changes: 3 additions & 3 deletions srcC/tests/testOkForAsymmetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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`
Expand Down

0 comments on commit 216ec3d

Please sign in to comment.