Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: handle cook version (pass1 vs. pass2) #52

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions src/clasqa/QADB.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,32 @@ class QADB {
// 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
public QADB(int runnumMin=-1, runnumMax=-1, boolean verbose_=false) {
public QADB(String cook, int runnumMin=-1, runnumMax=-1, boolean verbose_=false) {

// setup
verbose = verbose_
util = new Tools()
nbits = util.bitDefinitions.size()
dbDirN = System.getenv('QADB') + '/qadb/latest'
dbDirN = System.getenv('QADB')
if(dbDirN==null) {
System.err << "ERROR: env var QADB not set; source environ.sh\n\n\n"
return
}
dbDirN += '/qadb'
if(cook in ["latest", "pass1", "pass2"]) {
dbDirN += "/${cook}"
} else {
System.err << "\nERROR: cook '${cook}' is not available in the QADB\n\n"
return
}
if(verbose) println("QADB dir = ${dbDirN}")

// concatenate trees
Expand Down Expand Up @@ -112,6 +123,18 @@ class QADB {
allowMiscBitList = []
}

public QADB(int runnumMin=-1, runnumMax=-1, boolean verbose_=false) {
System.err.print('''| ERROR: the 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.
''')
return
}

//...............................
// deprecation warnings
//```````````````````````````````
Expand Down
4 changes: 2 additions & 2 deletions src/examples/chargeSum.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ reader.open(inHipoFile)


// 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 src/examples/cutAsymmetry.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ reader.open(inHipoFile)


// 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 src/examples/cutCustom.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ reader.open(inHipoFile)


// 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
Expand Down
4 changes: 2 additions & 2 deletions src/examples/cutGolden.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ reader.open(inHipoFile)


// 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 src/examples/dumpQADB.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ println "dump QADB for RUN NUMBER $runnum"


// 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
4 changes: 2 additions & 2 deletions src/tests/testCharge.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import clasqa.QADB // access QADB


// 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
def defname
int chargeInt
Expand Down
4 changes: 2 additions & 2 deletions src/tests/testDumpQADB.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ println "test QADB for RUN NUMBER $runnum"


// 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 files
Expand Down
6 changes: 3 additions & 3 deletions src/tests/testOkForAsymmetry.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ System.out.println("WARNING: run with `-Xmx4096m`")
// to avoid in their analysis, and a list of runs for which the `Misc` defect bit
// should be ignored
System.out.println('Loading QADBs...\n...1/3...')
QADB qa = new QADB()
QADB qa = new QADB("latest")
qa.checkForDefect('TotalOutlier') // these choices match the criteria of `OkForAsymmetry`
qa.checkForDefect('TerminalOutlier')
qa.checkForDefect('MarginalOutlier')
Expand All @@ -32,9 +32,9 @@ qa.checkForDefect('Misc')

// instantiate more QADBs, for comparison (`qa` will use the general method)
System.out.println('...2/3...')
QADB qa_deprecated = new QADB() // will use `OkForAsymmetry`, which is deprecated
QADB qa_deprecated = new QADB("latest") // will use `OkForAsymmetry`, which is deprecated
System.out.println('...3/3...')
QADB qa_third_party = new QADB() // a third party, only used for DB traversal
QADB qa_third_party = new QADB("latest") // a third party, only used for DB traversal
System.out.println('...done')

// compare the QADBs' results: prove the above general method is equivalent to `OkForAsymmetry`
Expand Down
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: the 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 in the QADB");
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
2 changes: 1 addition & 1 deletion util/access.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import clasqa.QADB
import clasqa.Tools

Tools T = new Tools()
QADB qa = new QADB()
QADB qa = new QADB("latest")

/*
println "=========== raw"
Expand Down
2 changes: 1 addition & 1 deletion util/chargeSumRuns.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if(args.length==2) {
}
else { System.err << "ARGUMENTS: [runLB] [runUB]\n"; return; }
println "run range: $runLB to $runUB"
QADB qa = new QADB(runLB,runUB)
QADB qa = new QADB("latest",runLB,runUB)


// loop over runs and files
Expand Down
2 changes: 1 addition & 1 deletion util/gap_charge_systematic/calculateGapCharge.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if(args.length<1) {
System.exit(101)
}
def arg_runnum = args[0].toInteger()
QADB qa = new QADB()
QADB qa = new QADB("latest")

// define output file
def datfileName = "charge_gaps.dat"
Expand Down
2 changes: 1 addition & 1 deletion util/makeLatexTable2.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if(args.length==2) {
}
else { System.err << "ARGUMENTS: [runLB] [runUB]\n"; return; }
println "run range: $runLB to $runUB"
QADB qa = new QADB(runLB,runUB)
QADB qa = new QADB("latest",runLB,runUB)

def nPassQA, nTotal
def exList = []
Expand Down
2 changes: 1 addition & 1 deletion util/parseQaTree.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import clasqa.Tools
Tools T = new Tools()
/*
import clasqa.QADB
QADB qa = new QADB()
QADB qa = new QADB("latest")
*/

infile="qa/qaTree.json"
Expand Down
2 changes: 1 addition & 1 deletion util/printGoldenFiles.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// - "golden" means no defects

import clasqa.QADB
QADB qa = new QADB()
QADB qa = new QADB("latest")

// open output file writer
def outFileObj = new File(System.getenv('QADB')+"/text/listOfGoldenFiles.txt")
Expand Down
2 changes: 1 addition & 1 deletion util/printGoldenRuns.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import clasqa.QADB

QADB qa = new QADB()
QADB qa = new QADB("latest")
def gold,silver
def defect

Expand Down
2 changes: 1 addition & 1 deletion util/printSummary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using namespace std;

int main(int argc, char ** argv) {

QA::QADB * qa = new QA::QADB();
QA::QADB * qa = new QA::QADB("latest");

/// get sorted list of runs
auto qaTree = qa->GetQaTree();
Expand Down
2 changes: 1 addition & 1 deletion util/syncCheck.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

// open QADB
import clasqa.QADB
QADB qa = new QADB()
QADB qa = new QADB("latest")


def printSep
Expand Down
Loading