From e539db5e66032212b45b6e72ef1993d37b9ef01a Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Fri, 13 Sep 2024 10:41:16 -0400 Subject: [PATCH 01/26] feat: defect bit definitions file this file is meant to be used by: - the local C++ and Groovy classes - documentation generation - an iguana algorithm --- qadb/defect_definitions.json | 122 +++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 qadb/defect_definitions.json diff --git a/qadb/defect_definitions.json b/qadb/defect_definitions.json new file mode 100644 index 0000000..32b833b --- /dev/null +++ b/qadb/defect_definitions.json @@ -0,0 +1,122 @@ +[ + { + "bit_number": 0, + "bit_name": "TotalOutlier", + "description": "Outlier N/F, but not terminal, marginal, or sector loss, for FD electron", + "documentation": "" + }, + { + "bit_number": 1, + "bit_name": "TerminalOutlier", + "description": "Outlier N/F of first or last QA bin of run, not marginal, for FD electron", + "documentation": "" + }, + { + "bit_number": 2, + "bit_name": "MarginalOutlier", + "description": "Marginal outlier N/F, within one standard deviation of cut line, for FD electron", + "documentation": "" + }, + { + "bit_number": 3, + "bit_name": "SectorLoss", + "description": "N/F diminished within a FD sector for several consecutive QA bin", + "documentation": "For older datasets (RG-A,B,K,M pass 1), this bit replaced the assignment of TotalOutlier, TerminalOutlier, and MarginalOutlier; newer datasets only add the SectorLoss bit and do not remove the outlier bits." + }, + { + "bit_number": 4, + "bit_name": "LowLiveTime", + "description": "Live time < 0.9", + "documentation": "This assignment of this bit may be correlated with a low fraction of events with a defined (nonzero) helicity." + }, + { + "bit_number": 5, + "bit_name": "Misc", + "description": "Miscellaneous defect, documented as comment", + "documentation": "This bit is often assigned to all QA bins within a run, but in some cases, may only be assigned to the relevant QA bins. The analyzer must decide whether data assigned with the Misc bit should be excluded from their analysis; the comment is provided for this purpose. Analyzers are also encouraged to check the Hall B log book for further details." + }, + { + "bit_number": 6, + "bit_name": "TotalOutlierFT", + "description": "Outlier N/F, but not terminal, marginal, or `LossFT`, FT electron", + "documentation": "cf. TotalOutlier." + }, + { + "bit_number": 7, + "bit_name": "TerminalOutlierFT", + "description": "Outlier N/F of first or last QA bin of run, not marginal, FT electron", + "documentation": "cf. TerminalOutlier." + }, + { + "bit_number": 8, + "bit_name": "MarginalOutlierFT", + "description": "Marginal outlier N/F, within one standard deviation of cut line, FT electron", + "documentation": "cf. MarginalOutlier." + }, + { + "bit_number": 9, + "bit_name": "LossFT", + "description": "N/F diminished within FT for several consecutive QA bins", + "documentation": "cf. SectorLoss." + }, + { + "bit_number": 10, + "bit_name": "BSAWrong", + "description": "Beam Spin Asymmetry is the wrong sign", + "documentation": "This bit is assigned per run. The asymmetry is significant, but the opposite sign than expected; analyzers must therefore flip the helicity sign." + }, + { + "bit_number": 11, + "bit_name": "BSAUnknown", + "description": "Beam Spin Asymmetry is unknown, likely because of low statistics", + "documentation": "This bit is assigned per run. We do not have enough statistics to determine if the helicity sign is correct." + }, + { + "bit_number": 12, + "bit_name": "TSAWrong", + "description": "Target Spin Asymmetry is the wrong sign", + "documentation": "Not yet used." + }, + { + "bit_number": 13, + "bit_name": "TSAUnknown", + "description": "Target Spin Asymmetry is unknown, likely because of low statistics", + "documentation": "Not yet used." + }, + { + "bit_number": 14, + "bit_name": "DSAWrong", + "description": "Double Spin Asymmetry is the wrong sign", + "documentation": "Not yet used." + }, + { + "bit_number": 15, + "bit_name": "DSAUnknown", + "description": "Double Spin Asymmetry is unknown, likely because of low statistics", + "documentation": "Not yet used." + }, + { + "bit_number": 16, + "bit_name": "ChargeHigh", + "description": "FC Charge is abnormally high", + "documentation": "NOTE: the assignment criteria of this bit is still under study." + }, + { + "bit_number": 17, + "bit_name": "ChargeNegative", + "description": "FC Charge is negative", + "documentation": "The FC charge is calculated from the charge readout at QA bin boundaries. Normally the later charge readout is higher than the earlier; this bit is assigned when the opposite happens." + }, + { + "bit_number": 18, + "bit_name": "ChargeUnknown", + "description": "FC Charge is unknown; the first and last time bins always have this defect", + "documentation": "QA bin boundaries are at scaler charge readouts. The first QA bin, before any readout, has no initial charge; the last QA bin, after all scaler readouts, has no final charge. Therefore, the first and last QA bins have an unknown, but likely very small charge accumulation." + }, + { + "bit_number": 19, + "bit_name": "PossiblyNoBeam", + "description": "Both N and F are low, indicating the beam was possibly off", + "documentation": "NOTE: the assignment criteria of this bit is still under study." + } +] From 6a9ebd1ba00e2c630c69b54382ac3d855a4d0a77 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Fri, 13 Sep 2024 21:01:58 -0400 Subject: [PATCH 02/26] feat: example of `OkForAsymmetry` replacement --- srcC/examples/Makefile | 19 +++++- srcC/examples/chargeSum.cpp | 2 +- srcC/examples/cutAsymmetry.cpp | 2 +- srcC/examples/cutCustom.cpp | 14 ++-- srcC/examples/cutGolden.cpp | 2 +- srcC/examples/dumpQADB.cpp | 4 +- srcC/include/QADB.h | 102 +++++++++++++++++++++++++++--- srcC/tests/Makefile | 4 ++ srcC/tests/testCharge.cpp | 8 +-- srcC/tests/testDumpQADB.cpp | 14 ++-- srcC/tests/testOkForAsymmetry.cpp | 93 +++++++++++++++++++++++++++ 11 files changed, 231 insertions(+), 33 deletions(-) create mode 100644 srcC/tests/testOkForAsymmetry.cpp diff --git a/srcC/examples/Makefile b/srcC/examples/Makefile index a3e16e0..1130033 100644 --- a/srcC/examples/Makefile +++ b/srcC/examples/Makefile @@ -1,12 +1,27 @@ CXX = g++ -std=c++11 FLAGS = -g -Wno-deprecated -fPIC -m64 -fno-inline -Wno-write-strings + +ifndef QADB +$(error "ERROR: you need environment variable 'QADB'; run 'source environ.sh'") +endif +ifndef CLAS12ROOT +$(error "ERROR: you need environment variable 'CLAS12ROOT'") +endif +ifndef HIPO +$(error "ERROR: you need environment variable 'HIPO'") +endif + # QADB and rapidjson DEPS += -I$(QADB)/srcC/rapidjson/include -I$(QADB)/srcC/include # clas12root -DEPS += -I$(CLAS12ROOT)/hipo4 -I$(CLAS12ROOT)/Clas12Banks -I$(CLAS12ROOT)/Clas12Root -LIBS += -L$(CLAS12ROOT)/lib -lClas12Banks -lClas12Root -lHipo4 -llz4 +DEPS += -I$(CLAS12ROOT)/Clas12Banks -I$(CLAS12ROOT)/Clas12Root +LIBS += -L$(CLAS12ROOT)/lib -lClas12Banks -lClas12Root -llz4 + +# HIPO +DEPS += -I$(HIPO)/include +LIBS += -L$(HIPO)/lib -lHipo4 # ROOT DEPS += $(shell root-config --cflags) diff --git a/srcC/examples/chargeSum.cpp b/srcC/examples/chargeSum.cpp index d3b988a..fbf499b 100644 --- a/srcC/examples/chargeSum.cpp +++ b/srcC/examples/chargeSum.cpp @@ -5,7 +5,7 @@ #include // clas12root headers -#include "reader.h" +#include "hipo4/reader.h" #include "clas12reader.h" // QADB header and namespace diff --git a/srcC/examples/cutAsymmetry.cpp b/srcC/examples/cutAsymmetry.cpp index 5a50de1..96497e8 100644 --- a/srcC/examples/cutAsymmetry.cpp +++ b/srcC/examples/cutAsymmetry.cpp @@ -4,7 +4,7 @@ #include // clas12root headers -#include "reader.h" +#include "hipo4/reader.h" #include "clas12reader.h" // QADB header and namespace diff --git a/srcC/examples/cutCustom.cpp b/srcC/examples/cutCustom.cpp index 3844c21..1aa6af1 100644 --- a/srcC/examples/cutCustom.cpp +++ b/srcC/examples/cutCustom.cpp @@ -6,7 +6,7 @@ #include // clas12root headers -#include "reader.h" +#include "hipo4/reader.h" #include "clas12reader.h" // QADB header and namespace @@ -37,12 +37,12 @@ int main(int argc, char** argv) { // the QA cut if the associated file has any of the specified defects // - set to true to check the bit // - set to false to ignore the bit (by default, all bits are ignored) - qa->SetMaskBit("TotalOutlier",false); - qa->SetMaskBit("TerminalOutlier",false); - qa->SetMaskBit("MarginalOutlier",false); - qa->SetMaskBit("SectorLoss",true); // this is the only bit we check here - qa->SetMaskBit("LowLiveTime",false); - qa->SetMaskBit("Misc",false); + qa->CheckForDefect("TotalOutlier",false); + qa->CheckForDefect("TerminalOutlier",false); + qa->CheckForDefect("MarginalOutlier",false); + qa->CheckForDefect("SectorLoss",true); // this is the only bit we check here + qa->CheckForDefect("LowLiveTime",false); + qa->CheckForDefect("Misc",false); // print the defect bit mask cout << "\ndefect mask = 0b" << bitset<16>(qa->GetMask()) << endl; diff --git a/srcC/examples/cutGolden.cpp b/srcC/examples/cutGolden.cpp index 65e5436..c273537 100644 --- a/srcC/examples/cutGolden.cpp +++ b/srcC/examples/cutGolden.cpp @@ -5,7 +5,7 @@ #include // clas12root headers -#include "reader.h" +#include "hipo4/reader.h" #include "clas12reader.h" // QADB header and namespace diff --git a/srcC/examples/dumpQADB.cpp b/srcC/examples/dumpQADB.cpp index 9012077..0fc3a03 100644 --- a/srcC/examples/dumpQADB.cpp +++ b/srcC/examples/dumpQADB.cpp @@ -33,12 +33,12 @@ int main(int argc, char ** argv) { // loop through files int evnum; - for(int filenum=0; filenum<=qa->GetMaxFilenum(runnum); filenum+=5) { + for(int filenum=0; filenum<=qa->GetMaxBinnum(runnum); filenum+=5) { sep("=",50); cout << "FILE NUMBER " << filenum << endl; // perform the lookup, by filenum - if(qa->QueryByFilenum(runnum,filenum)) { + if(qa->QueryByBinnum(runnum,filenum)) { // we need an event number within this file, to pass to QA criteria // checking methods, such as Golden; no additional Query will be called diff --git a/srcC/include/QADB.h b/srcC/include/QADB.h index a9dba47..bd2ca42 100644 --- a/srcC/include/QADB.h +++ b/srcC/include/QADB.h @@ -14,6 +14,28 @@ namespace QA { class QADB { + private: + + void DeprecationGuidance() { + std::cerr << R"(| INSTEAD: +| - please use `QADB::CheckForDefect` to choose which defects you want +| to filter out, then use `QADB::Pass` on each event +| - for runs with the `Misc` defect bit (bit 5) assigned: +| - use `QADB::GetComment` to check the QADB comment, which explains +| why this bit was assigned for the run +| - use `QADB::AllowMiscBit` to ignore the `Misc` bit for certain +| runs that you want to allow in your analysis (`OkForAsymmetry` +| internally does this for a specific list of RG-A runs) +)"; + } + + void WarningBanner(bool first) { + if(first) + std::cerr << "\nWARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING\n|\n"; + else + std::cerr << "|\nWARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING\n\n"; + } + public: //................. @@ -31,7 +53,19 @@ namespace QA { // golden QA cut //``````````````````````````````` // returns false if the event is in a file with *any* defect - inline bool Golden(int runnum_, int evnum_) { + inline bool Golden(int runnum_, int evnum_) { + if(!dep_warned_Golden) { + dep_warned_Golden = true; + WarningBanner(true); + std::cerr << R"(| WARNING: `QADB::Golden` is DEPRECATED +| - you may still use this method, but since many more defect bits have been +| defined, and "Golden" means "no defect bits set", you may find that +| requiring your data to be "Golden" is too strict for your analysis +| - in some cases, none of the data are "Golden" +)"; + DeprecationGuidance(); + WarningBanner(false); + } bool foundHere = this->Query(runnum_,evnum_); return foundHere && defect==0; }; @@ -51,12 +85,18 @@ namespace QA { // none are set; the variable `mask` will be applied as a mask // on the defect bits inline void SetMaskBit(const char * defectName, bool state=true); + inline void CheckForDefect(const char * defectName, bool state=true); // alias // access the custom mask, if you want to double-check it inline int GetMask() { return mask; }; // then call this method to check your custom QA cut for a given // run number and event number inline bool Pass(int runnum_, int evnum_); + // ignore certain runs for the `Misc` bit assignment + inline void AllowMiscBit(int runnum_) { + allowMiscBitList.insert(runnum_); + } + //................. // accessors @@ -64,6 +104,7 @@ namespace QA { // --- access this file's info inline int GetRunnum() { return found ? runnum : -1; }; inline int GetFilenum() { return found ? filenum : -1; }; + inline int GetBinnum() { return found ? filenum : -1; }; // alias for `GetFilenum` inline std::string GetComment() { return found ? comment : ""; }; inline int GetEvnumMin() { return found ? evnumMin : -1; }; inline int GetEvnumMax() { return found ? evnumMax : -1; }; @@ -108,7 +149,19 @@ namespace QA { inline bool QueryByFilenum(int runnum_, int filenum_); // get maximum file number for a given run (useful for QADB validation) inline int GetMaxFilenum(int runnum_); - + // aliases + inline bool QueryByBinnum(int runnum_, int filenum_); + inline int GetMaxBinnum(int runnum_); + + // check if this bin number exists + inline bool HasBinnum(int runnum_, int binnum_) { + sprintf(runnumStr,"%d",runnum_); + if(qaTree.HasMember(runnumStr)) { + sprintf(filenumStr,"%d",binnum_); + return qaTree[runnumStr].GetObject().HasMember(filenumStr); + } + return false; + } //................................. // Faraday Cup charge @@ -154,6 +207,7 @@ namespace QA { bool chargeCounted; std::vector> chargeCountedFiles; + std::map defectNameMap; int nbits; @@ -162,6 +216,10 @@ namespace QA { int mask; std::set allowForOkForAsymmetry; + std::set allowMiscBitList; + + bool dep_warned_Golden; + bool dep_warned_OkForAsymmetry; }; @@ -291,6 +349,8 @@ namespace QA { charge = 0; chargeTotal = 0; chargeCounted = false; + dep_warned_Golden = false; + dep_warned_OkForAsymmetry = false; }; @@ -343,6 +403,18 @@ namespace QA { //``````````````````````````````````` bool QADB::OkForAsymmetry(int runnum_, int evnum_) { + // deprecation notice + if(!dep_warned_OkForAsymmetry) { + dep_warned_OkForAsymmetry = true; + WarningBanner(true); + std::cerr << R"(| WARNING: `QADB::OkForAsymmetry` is DEPRECATED +| - you may still use this method, but `OkForAsymmetry` does +| not include NEW defect bits 6 and above in its criteria +)"; + DeprecationGuidance(); + WarningBanner(false); + } + // perform lookup bool foundHere = this->Query(runnum_,evnum_); if(!foundHere) return false; @@ -385,9 +457,19 @@ namespace QA { if(state) mask |= (0x1 << defectBit); }; }; + void QADB::CheckForDefect(const char * defectName, bool state) { + SetMaskBit(defectName, state); + } bool QADB::Pass(int runnum_, int evnum_) { bool foundHere = this->Query(runnum_,evnum_); - return foundHere && !(defect & mask); + if(!foundHere) + return false; + auto use_mask = mask; + if(this->HasDefectBit(5)) { + if(allowMiscBitList.find(runnum_) != allowMiscBitList.end()) + use_mask &= ~(0x1 << 5); // set `use_mask`'s Misc bit to 0 + } + return !(defect & use_mask); } @@ -519,18 +601,22 @@ namespace QA { // result of query return found; }; + bool QADB::QueryByBinnum(int runnum_, int filenum_) { + return QueryByFilenum(runnum_, filenum_); + } // ----- return maximum filenum for a given runnum int QADB::GetMaxFilenum(int runnum_) { - int maxFilenum=0; + int maxFilenum = 0; sprintf(runnumStr,"%d",runnum_); auto runTree = qaTree[runnumStr].GetObject(); - for(auto it=runTree.MemberBegin(); it!=runTree.MemberEnd(); ++it) { - maxFilenum = atoi((it->name).GetString()) > maxFilenum ? - atoi((it->name).GetString()) : maxFilenum; - }; + for(auto it=runTree.MemberBegin(); it!=runTree.MemberEnd(); ++it) + maxFilenum = std::max(atoi((it->name).GetString()), maxFilenum); return maxFilenum; }; + int QADB::GetMaxBinnum(int runnum_) { + return GetMaxFilenum(runnum_); + } diff --git a/srcC/tests/Makefile b/srcC/tests/Makefile index 2a452c4..fb54113 100644 --- a/srcC/tests/Makefile +++ b/srcC/tests/Makefile @@ -1,6 +1,10 @@ CXX = g++ -std=c++11 FLAGS = -g -Wno-deprecated -fPIC -m64 -fno-inline -Wno-write-strings +ifndef QADB +$(error "ERROR: you need environment variable 'QADB'; run 'source environ.sh'") +endif + # QADB and rapidjson DEPS += -I$(QADB)/srcC/rapidjson/include -I$(QADB)/srcC/include diff --git a/srcC/tests/testCharge.cpp b/srcC/tests/testCharge.cpp index 2ced965..9cc2556 100644 --- a/srcC/tests/testCharge.cpp +++ b/srcC/tests/testCharge.cpp @@ -33,18 +33,18 @@ int main(int argc, char ** argv) { // specify QA criteria - qa->SetMaskBit("SectorLoss"); - qa->SetMaskBit("MarginalOutlier"); + qa->CheckForDefect("SectorLoss"); + qa->CheckForDefect("MarginalOutlier"); // loop over runs for(int runnum : runnumList) { // loop over files - for(int filenum=0; filenum<=qa->GetMaxFilenum(runnum); filenum+=5) { + for(int filenum=0; filenum<=qa->GetMaxBinnum(runnum); filenum+=5) { // query by file number - qa->QueryByFilenum(runnum,filenum); + qa->QueryByBinnum(runnum,filenum); evnum = qa->GetEvnumMin(); // evnum needed for QA cut methods // accumulate charge, if QA criteria are satisfied diff --git a/srcC/tests/testDumpQADB.cpp b/srcC/tests/testDumpQADB.cpp index ec7d1af..1ccb6b8 100644 --- a/srcC/tests/testDumpQADB.cpp +++ b/srcC/tests/testDumpQADB.cpp @@ -42,13 +42,13 @@ int main(int argc, char ** argv) { int evnum; string defname; int chargeInt; - for(int filenum=0; filenum<=qa->GetMaxFilenum(runnum); filenum+=5) { + for(int filenum=0; filenum<=qa->GetMaxBinnum(runnum); filenum+=5) { sep("=",50); //err("test error print"); // query by file number - qa->QueryByFilenum(runnum,filenum); + qa->QueryByBinnum(runnum,filenum); evnum = qa->GetEvnumMin(); // evnum needed for QA cut methods // check run and file number accessors: make sure that they @@ -56,8 +56,8 @@ int main(int argc, char ** argv) { cout << "- run,file,evnum" << endl; cout << qa->GetRunnum() << " " << runnum << endl; if(qa->GetRunnum() != runnum) err("QADB::GetRunnum != runnum"); - cout << qa->GetFilenum() << " " << filenum << endl; - if(qa->GetFilenum() != filenum) err("QADB::GetFilenum != filenum"); + cout << qa->GetBinnum() << " " << filenum << endl; + if(qa->GetBinnum() != filenum) err("QADB::GetBinnum != filenum"); // check event number: report an error if evnum min>=max cout << qa->GetEvnumMin() << " " << qa->GetEvnumMax() << endl; @@ -98,9 +98,9 @@ int main(int argc, char ** argv) { for(int sec=1; sec<=6; sec++) cout << " " << qa->HasDefect(defname.c_str(),sec); cout << endl; // print bit masking - qa->SetMaskBit(defname.c_str()); + qa->CheckForDefect(defname.c_str()); cout << qa->GetMask() << " " << qa->Pass(runnum,evnum) << endl; - qa->SetMaskBit(defname.c_str(),false); + qa->CheckForDefect(defname.c_str(),false); }; // print QA cuts (see above for custom cut check with mask) @@ -116,7 +116,7 @@ int main(int argc, char ** argv) { cout << ((int)(1000*qa->GetAccumulatedCharge())) << endl; // print max file number - cout << qa->GetMaxFilenum(runnum) << endl; + cout << qa->GetMaxBinnum(runnum) << endl; sep("=",50); diff --git a/srcC/tests/testOkForAsymmetry.cpp b/srcC/tests/testOkForAsymmetry.cpp new file mode 100644 index 0000000..5430cdb --- /dev/null +++ b/srcC/tests/testOkForAsymmetry.cpp @@ -0,0 +1,93 @@ +// test equivelance of `OkForAsymmetry` and the preferred user method + +#include +#include +#include "../include/QADB.h" + +bool const debug = false; + +// MAIN +int main(int argc, char ** argv) { + + // specify run numbers to test + std::set test_runnums = { + // RGA Fa18 inbending + 5032, 5036, 5038, 5039, 5040, 5041, 5043, 5045, + 5046, 5047, 5051, 5052, 5053, 5116, 5117, 5119, + 5120, 5124, 5125, 5126, 5127, 5128, 5129, 5130, + 5137, 5138, 5139, 5153, 5158, 5159, 5160, 5162, + 5163, 5164, 5165, 5166, 5167, 5168, 5169, 5180, + 5181, 5182, 5183, 5189, 5190, 5191, 5193, 5194, + 5195, 5196, 5197, 5198, 5199, 5200, 5201, 5202, + 5203, 5204, 5205, 5206, 5208, 5211, 5212, 5215, + 5216, 5219, 5220, 5221, 5222, 5223, 5225, 5229, + 5230, 5231, 5232, 5233, 5234, 5235, 5237, 5238, + 5239, 5247, 5248, 5249, 5250, 5252, 5253, 5257, + 5258, 5259, 5261, 5262, 5300, 5301, 5302, 5303, + 5304, 5305, 5306, 5307, 5310, 5311, 5315, 5316, + 5317, 5318, 5319, 5320, 5323, 5324, 5325, 5333, + 5334, 5335, 5336, 5339, 5340, 5341, 5342, 5343, + 5344, 5345, 5346, 5347, 5349, 5351, 5354, 5355, + 5356, 5357, 5358, 5359, 5360, 5361, 5362, 5366, + 5367, 5368, 5369, 5370, 5371, 5372, 5373, 5374, + 5375, 5376, 5377, 5378, 5379, 5380, 5381, 5382, + 5383, 5386, 5390, 5391, 5392, 5393, 5394, 5398, + 5399, 5400, 5401, 5402, 5403, 5404, 5406, 5407, + 5414, 5415, 5416, 5417, 5418, 5419 + }; + + // instantiate two QADBs + std::cout << "Loading QADBs..." << std::endl; + QA::QADB * qa = new QA::QADB(); // will use the preferred method + QA::QADB * qa_deprecated = new QA::QADB(); // will use `OkForAsymmetry`, which is deprecated + std::cout << "...done" << std::endl; + + ////////////////////////////////////////////////////////////////////////////////// + // the preferred method requires the user to choose the bits, an runs for which + // the `Misc` defect bit should be ignored + // - these choices match the criteria of `OkForAsymmetry` + // - in the event loop, call `qa->Pass(runnum,evnum)` + qa->CheckForDefect("TotalOutlier"); + qa->CheckForDefect("TerminalOutlier"); + qa->CheckForDefect("MarginalOutlier"); + qa->CheckForDefect("SectorLoss"); + qa->CheckForDefect("Misc"); + for(int run : { // list of runs with `Misc` defect that are allowed + 5046, 5047, 5051, 5128, 5129, 5130, 5158, 5159, + 5160, 5163, 5165, 5166, 5167, 5168, 5169, 5180, + 5181, 5182, 5183, 5400, 5448, 5495, 5496, 5505, + 5567, 5610, 5617, 5621, 5623}) + qa->AllowMiscBit(run); + ////////////////////////////////////////////////////////////////////////////////// + + // loop over test runs + for(auto const& runnum : test_runnums) { + std::cout << "test run " << runnum << std::endl; + + // loop over QA bins for this run + auto max_bin_num = qa->GetMaxBinnum(runnum); + if(debug) std::cout << "debug: this run has max bin number = " << max_bin_num << std::endl; + for(int binnum = 0; binnum <= max_bin_num; binnum++) { + + // skip non-existent bin numbers (required since old QADBs' bin numbers are multiples of 5) + if(!qa->HasBinnum(runnum, binnum)) continue; + if(debug) std::cout << "debug: test binnum " << binnum << std::endl; + + // we need an event number to query the QADBs + qa->QueryByBinnum(runnum, binnum); + auto evnum = (qa->GetEvnumMin() + qa->GetEvnumMax()) / 2; + + // test equivelance of `OkForAsymmetry` and the preferred user method (`Pass`) + auto pass_qa_preferred = qa->Pass(runnum, evnum); + auto pass_qa_deprecated = qa_deprecated->OkForAsymmetry(runnum, evnum); + if(debug) std::cout << "debug: " << pass_qa_preferred << " =?= " << pass_qa_deprecated << std::endl; + assert(( pass_qa_preferred == pass_qa_deprecated )); + } + + std::cout << "=> test passed." << std::endl; + } + + std::cout << "all test passed." << std::endl; + return 0; +} + From c36f07cdb5519fb455e24d3d0cb4c7bc81b6ea9f Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Fri, 13 Sep 2024 21:30:30 -0400 Subject: [PATCH 03/26] doc: clarify example and messages --- srcC/include/QADB.h | 13 +++-- srcC/tests/testOkForAsymmetry.cpp | 94 ++++++++++++++++--------------- 2 files changed, 57 insertions(+), 50 deletions(-) diff --git a/srcC/include/QADB.h b/srcC/include/QADB.h index bd2ca42..dc79092 100644 --- a/srcC/include/QADB.h +++ b/srcC/include/QADB.h @@ -17,12 +17,12 @@ namespace QA { private: void DeprecationGuidance() { - std::cerr << R"(| INSTEAD: -| - please use `QADB::CheckForDefect` to choose which defects you want + std::cerr << R"(| INSTEAD: use the general methods +| - use `QADB::CheckForDefect` to choose which defects you want | to filter out, then use `QADB::Pass` on each event | - for runs with the `Misc` defect bit (bit 5) assigned: -| - use `QADB::GetComment` to check the QADB comment, which explains -| why this bit was assigned for the run +| - use `QADB::GetComment` to check the QADB comment, which +| explains why this bit was assigned for the run | - use `QADB::AllowMiscBit` to ignore the `Misc` bit for certain | runs that you want to allow in your analysis (`OkForAsymmetry` | internally does this for a specific list of RG-A runs) @@ -412,6 +412,11 @@ namespace QA { | not include NEW defect bits 6 and above in its criteria )"; DeprecationGuidance(); + std::cerr << R"(| EXAMPLE: +| - see '$QADB/srcC/tests/testOkForAsymmetry.cpp' for a +| preferred, equivalent implementation; from there, you may +| customize your QA criteria and use the new defect bits +)"; WarningBanner(false); } diff --git a/srcC/tests/testOkForAsymmetry.cpp b/srcC/tests/testOkForAsymmetry.cpp index 5430cdb..48e04dd 100644 --- a/srcC/tests/testOkForAsymmetry.cpp +++ b/srcC/tests/testOkForAsymmetry.cpp @@ -1,73 +1,46 @@ -// test equivelance of `OkForAsymmetry` and the preferred user method +// test equivelance of `OkForAsymmetry` and the preferred general method #include #include #include "../include/QADB.h" bool const debug = false; +std::set test_runnums(); -// MAIN int main(int argc, char ** argv) { - // specify run numbers to test - std::set test_runnums = { - // RGA Fa18 inbending - 5032, 5036, 5038, 5039, 5040, 5041, 5043, 5045, - 5046, 5047, 5051, 5052, 5053, 5116, 5117, 5119, - 5120, 5124, 5125, 5126, 5127, 5128, 5129, 5130, - 5137, 5138, 5139, 5153, 5158, 5159, 5160, 5162, - 5163, 5164, 5165, 5166, 5167, 5168, 5169, 5180, - 5181, 5182, 5183, 5189, 5190, 5191, 5193, 5194, - 5195, 5196, 5197, 5198, 5199, 5200, 5201, 5202, - 5203, 5204, 5205, 5206, 5208, 5211, 5212, 5215, - 5216, 5219, 5220, 5221, 5222, 5223, 5225, 5229, - 5230, 5231, 5232, 5233, 5234, 5235, 5237, 5238, - 5239, 5247, 5248, 5249, 5250, 5252, 5253, 5257, - 5258, 5259, 5261, 5262, 5300, 5301, 5302, 5303, - 5304, 5305, 5306, 5307, 5310, 5311, 5315, 5316, - 5317, 5318, 5319, 5320, 5323, 5324, 5325, 5333, - 5334, 5335, 5336, 5339, 5340, 5341, 5342, 5343, - 5344, 5345, 5346, 5347, 5349, 5351, 5354, 5355, - 5356, 5357, 5358, 5359, 5360, 5361, 5362, 5366, - 5367, 5368, 5369, 5370, 5371, 5372, 5373, 5374, - 5375, 5376, 5377, 5378, 5379, 5380, 5381, 5382, - 5383, 5386, 5390, 5391, 5392, 5393, 5394, 5398, - 5399, 5400, 5401, 5402, 5403, 5404, 5406, 5407, - 5414, 5415, 5416, 5417, 5418, 5419 - }; - - // instantiate two QADBs + // instantiate two QADBs (this program compares their results, for testing) std::cout << "Loading QADBs..." << std::endl; - QA::QADB * qa = new QA::QADB(); // will use the preferred method + QA::QADB * qa = new QA::QADB(); // will use the general method QA::QADB * qa_deprecated = new QA::QADB(); // will use `OkForAsymmetry`, which is deprecated std::cout << "...done" << std::endl; ////////////////////////////////////////////////////////////////////////////////// - // the preferred method requires the user to choose the bits, an runs for which - // the `Misc` defect bit should be ignored - // - these choices match the criteria of `OkForAsymmetry` - // - in the event loop, call `qa->Pass(runnum,evnum)` - qa->CheckForDefect("TotalOutlier"); + // the general method requires the user to choose the defects they want + // to avoid in their analysis, and a list of runs for which the `Misc` defect bit + // should be ignored + qa->CheckForDefect("TotalOutlier"); // these choices match the criteria of `OkForAsymmetry` qa->CheckForDefect("TerminalOutlier"); qa->CheckForDefect("MarginalOutlier"); qa->CheckForDefect("SectorLoss"); qa->CheckForDefect("Misc"); - for(int run : { // list of runs with `Misc` defect that are allowed + for(int run : { // list of runs with `Misc` defect that are allowed by `OkForAsymmetry` 5046, 5047, 5051, 5128, 5129, 5130, 5158, 5159, 5160, 5163, 5165, 5166, 5167, 5168, 5169, 5180, 5181, 5182, 5183, 5400, 5448, 5495, 5496, 5505, 5567, 5610, 5617, 5621, 5623}) qa->AllowMiscBit(run); + // after this, just use `qa->Pass(runnum, evnum)` for each event (instead of + // `qa->OkForAsymmetry(runnum, evnum)`) ////////////////////////////////////////////////////////////////////////////////// - // loop over test runs - for(auto const& runnum : test_runnums) { + + // compare the QADBs' results: prove the above general method is equivalent to `OkForAsymmetry` + for(auto const& runnum : test_runnums()) { std::cout << "test run " << runnum << std::endl; // loop over QA bins for this run - auto max_bin_num = qa->GetMaxBinnum(runnum); - if(debug) std::cout << "debug: this run has max bin number = " << max_bin_num << std::endl; - for(int binnum = 0; binnum <= max_bin_num; binnum++) { + for(int binnum = 0; binnum <= qa->GetMaxBinnum(runnum); binnum++) { // skip non-existent bin numbers (required since old QADBs' bin numbers are multiples of 5) if(!qa->HasBinnum(runnum, binnum)) continue; @@ -77,11 +50,11 @@ int main(int argc, char ** argv) { qa->QueryByBinnum(runnum, binnum); auto evnum = (qa->GetEvnumMin() + qa->GetEvnumMax()) / 2; - // test equivelance of `OkForAsymmetry` and the preferred user method (`Pass`) - auto pass_qa_preferred = qa->Pass(runnum, evnum); + // test equivelance of `OkForAsymmetry` and the general user method (`Pass`) + auto pass_qa_general = qa->Pass(runnum, evnum); auto pass_qa_deprecated = qa_deprecated->OkForAsymmetry(runnum, evnum); - if(debug) std::cout << "debug: " << pass_qa_preferred << " =?= " << pass_qa_deprecated << std::endl; - assert(( pass_qa_preferred == pass_qa_deprecated )); + if(debug) std::cout << "debug: " << pass_qa_general << " =?= " << pass_qa_deprecated << std::endl; + assert(( pass_qa_general == pass_qa_deprecated )); } std::cout << "=> test passed." << std::endl; @@ -91,3 +64,32 @@ int main(int argc, char ** argv) { return 0; } +// specify run numbers to test +std::set test_runnums() +{ + // RG-A Fa18 inbending + return { + 5032, 5036, 5038, 5039, 5040, 5041, 5043, 5045, + 5046, 5047, 5051, 5052, 5053, 5116, 5117, 5119, + 5120, 5124, 5125, 5126, 5127, 5128, 5129, 5130, + 5137, 5138, 5139, 5153, 5158, 5159, 5160, 5162, + 5163, 5164, 5165, 5166, 5167, 5168, 5169, 5180, + 5181, 5182, 5183, 5189, 5190, 5191, 5193, 5194, + 5195, 5196, 5197, 5198, 5199, 5200, 5201, 5202, + 5203, 5204, 5205, 5206, 5208, 5211, 5212, 5215, + 5216, 5219, 5220, 5221, 5222, 5223, 5225, 5229, + 5230, 5231, 5232, 5233, 5234, 5235, 5237, 5238, + 5239, 5247, 5248, 5249, 5250, 5252, 5253, 5257, + 5258, 5259, 5261, 5262, 5300, 5301, 5302, 5303, + 5304, 5305, 5306, 5307, 5310, 5311, 5315, 5316, + 5317, 5318, 5319, 5320, 5323, 5324, 5325, 5333, + 5334, 5335, 5336, 5339, 5340, 5341, 5342, 5343, + 5344, 5345, 5346, 5347, 5349, 5351, 5354, 5355, + 5356, 5357, 5358, 5359, 5360, 5361, 5362, 5366, + 5367, 5368, 5369, 5370, 5371, 5372, 5373, 5374, + 5375, 5376, 5377, 5378, 5379, 5380, 5381, 5382, + 5383, 5386, 5390, 5391, 5392, 5393, 5394, 5398, + 5399, 5400, 5401, 5402, 5403, 5404, 5406, 5407, + 5414, 5415, 5416, 5417, 5418, 5419 + }; +} From 5225e79860e3823fd37669dc27531a6bc7a62798 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Fri, 13 Sep 2024 22:13:51 -0400 Subject: [PATCH 04/26] fix: test (and fix) all of the runs --- srcC/include/QADB.h | 2 +- srcC/tests/testOkForAsymmetry.cpp | 250 ++++++++++++++++++++++++++---- 2 files changed, 217 insertions(+), 35 deletions(-) diff --git a/srcC/include/QADB.h b/srcC/include/QADB.h index dc79092..896feac 100644 --- a/srcC/include/QADB.h +++ b/srcC/include/QADB.h @@ -409,7 +409,7 @@ namespace QA { WarningBanner(true); std::cerr << R"(| WARNING: `QADB::OkForAsymmetry` is DEPRECATED | - you may still use this method, but `OkForAsymmetry` does -| not include NEW defect bits 6 and above in its criteria +| not include NEW defect bits that have been recently defined )"; DeprecationGuidance(); std::cerr << R"(| EXAMPLE: diff --git a/srcC/tests/testOkForAsymmetry.cpp b/srcC/tests/testOkForAsymmetry.cpp index 48e04dd..b6d46bf 100644 --- a/srcC/tests/testOkForAsymmetry.cpp +++ b/srcC/tests/testOkForAsymmetry.cpp @@ -9,16 +9,12 @@ std::set test_runnums(); int main(int argc, char ** argv) { - // instantiate two QADBs (this program compares their results, for testing) - std::cout << "Loading QADBs..." << std::endl; - QA::QADB * qa = new QA::QADB(); // will use the general method - QA::QADB * qa_deprecated = new QA::QADB(); // will use `OkForAsymmetry`, which is deprecated - std::cout << "...done" << std::endl; - ////////////////////////////////////////////////////////////////////////////////// // the general method requires the user to choose the defects they want // 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(); qa->CheckForDefect("TotalOutlier"); // these choices match the criteria of `OkForAsymmetry` qa->CheckForDefect("TerminalOutlier"); qa->CheckForDefect("MarginalOutlier"); @@ -28,27 +24,36 @@ int main(int argc, char ** argv) { 5046, 5047, 5051, 5128, 5129, 5130, 5158, 5159, 5160, 5163, 5165, 5166, 5167, 5168, 5169, 5180, 5181, 5182, 5183, 5400, 5448, 5495, 5496, 5505, - 5567, 5610, 5617, 5621, 5623}) + 5567, 5610, 5617, 5621, 5623, 6736, 6737, 6738, + 6739, 6740, 6741, 6742, 6743, 6744, 6746, 6747, + 6748, 6749, 6750, 6751, 6753, 6754, 6755, 6756, + 6757}) qa->AllowMiscBit(run); // after this, just use `qa->Pass(runnum, evnum)` for each event (instead of // `qa->OkForAsymmetry(runnum, evnum)`) ////////////////////////////////////////////////////////////////////////////////// + + // 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 + std::cout << "...done" << std::endl; + // compare the QADBs' results: prove the above general method is equivalent to `OkForAsymmetry` for(auto const& runnum : test_runnums()) { std::cout << "test run " << runnum << std::endl; // loop over QA bins for this run - for(int binnum = 0; binnum <= qa->GetMaxBinnum(runnum); binnum++) { + for(int binnum = 0; binnum <= qa_third_party->GetMaxBinnum(runnum); binnum++) { // skip non-existent bin numbers (required since old QADBs' bin numbers are multiples of 5) - if(!qa->HasBinnum(runnum, binnum)) continue; + if(!qa_third_party->HasBinnum(runnum, binnum)) continue; if(debug) std::cout << "debug: test binnum " << binnum << std::endl; // we need an event number to query the QADBs - qa->QueryByBinnum(runnum, binnum); - auto evnum = (qa->GetEvnumMin() + qa->GetEvnumMax()) / 2; + qa_third_party->QueryByBinnum(runnum, binnum); + auto evnum = (qa_third_party->GetEvnumMin() + qa_third_party->GetEvnumMax()) / 2; // test equivelance of `OkForAsymmetry` and the general user method (`Pass`) auto pass_qa_general = qa->Pass(runnum, evnum); @@ -67,29 +72,206 @@ int main(int argc, char ** argv) { // specify run numbers to test std::set test_runnums() { - // RG-A Fa18 inbending return { - 5032, 5036, 5038, 5039, 5040, 5041, 5043, 5045, - 5046, 5047, 5051, 5052, 5053, 5116, 5117, 5119, - 5120, 5124, 5125, 5126, 5127, 5128, 5129, 5130, - 5137, 5138, 5139, 5153, 5158, 5159, 5160, 5162, - 5163, 5164, 5165, 5166, 5167, 5168, 5169, 5180, - 5181, 5182, 5183, 5189, 5190, 5191, 5193, 5194, - 5195, 5196, 5197, 5198, 5199, 5200, 5201, 5202, - 5203, 5204, 5205, 5206, 5208, 5211, 5212, 5215, - 5216, 5219, 5220, 5221, 5222, 5223, 5225, 5229, - 5230, 5231, 5232, 5233, 5234, 5235, 5237, 5238, - 5239, 5247, 5248, 5249, 5250, 5252, 5253, 5257, - 5258, 5259, 5261, 5262, 5300, 5301, 5302, 5303, - 5304, 5305, 5306, 5307, 5310, 5311, 5315, 5316, - 5317, 5318, 5319, 5320, 5323, 5324, 5325, 5333, - 5334, 5335, 5336, 5339, 5340, 5341, 5342, 5343, - 5344, 5345, 5346, 5347, 5349, 5351, 5354, 5355, - 5356, 5357, 5358, 5359, 5360, 5361, 5362, 5366, - 5367, 5368, 5369, 5370, 5371, 5372, 5373, 5374, - 5375, 5376, 5377, 5378, 5379, 5380, 5381, 5382, - 5383, 5386, 5390, 5391, 5392, 5393, 5394, 5398, - 5399, 5400, 5401, 5402, 5403, 5404, 5406, 5407, - 5414, 5415, 5416, 5417, 5418, 5419 + 5032, 5036, 5038, 5039, 5040, 5041, 5043, 5045, 5046, 5047, 5051, + 5052, 5053, 5116, 5117, 5119, 5120, 5124, 5125, 5126, 5127, 5128, + 5129, 5130, 5137, 5138, 5139, 5153, 5158, 5159, 5160, 5162, 5163, + 5164, 5165, 5166, 5167, 5168, 5169, 5180, 5181, 5182, 5183, 5189, + 5190, 5191, 5193, 5194, 5195, 5196, 5197, 5198, 5199, 5200, 5201, + 5202, 5203, 5204, 5205, 5206, 5208, 5211, 5212, 5215, 5216, 5219, + 5220, 5221, 5222, 5223, 5225, 5229, 5230, 5231, 5232, 5233, 5234, + 5235, 5237, 5238, 5239, 5247, 5248, 5249, 5250, 5252, 5253, 5257, + 5258, 5259, 5261, 5262, 5300, 5301, 5302, 5303, 5304, 5305, 5306, + 5307, 5310, 5311, 5315, 5316, 5317, 5318, 5319, 5320, 5323, 5324, + 5325, 5333, 5334, 5335, 5336, 5339, 5340, 5341, 5342, 5343, 5344, + 5345, 5346, 5347, 5349, 5351, 5354, 5355, 5356, 5357, 5358, 5359, + 5360, 5361, 5362, 5366, 5367, 5368, 5369, 5370, 5371, 5372, 5373, + 5374, 5375, 5376, 5377, 5378, 5379, 5380, 5381, 5382, 5383, 5386, + 5390, 5391, 5392, 5393, 5394, 5398, 5399, 5400, 5401, 5402, 5403, + 5404, 5406, 5407, 5414, 5415, 5416, 5417, 5418, 5419, 5422, 5423, + 5424, 5425, 5426, 5428, 5429, 5430, 5431, 5432, 5434, 5435, 5436, + 5437, 5438, 5439, 5440, 5441, 5442, 5443, 5444, 5445, 5447, 5448, + 5449, 5450, 5451, 5452, 5453, 5454, 5455, 5456, 5457, 5460, 5462, + 5464, 5465, 5466, 5467, 5468, 5469, 5470, 5471, 5472, 5473, 5474, + 5475, 5476, 5478, 5479, 5480, 5481, 5482, 5483, 5485, 5486, 5487, + 5495, 5496, 5497, 5498, 5499, 5500, 5504, 5505, 5507, 5516, 5517, + 5518, 5519, 5520, 5521, 5522, 5523, 5524, 5525, 5526, 5527, 5528, + 5530, 5532, 5533, 5534, 5535, 5536, 5537, 5538, 5540, 5541, 5542, + 5543, 5544, 5545, 5546, 5547, 5548, 5549, 5550, 5551, 5552, 5554, + 5555, 5556, 5557, 5558, 5559, 5561, 5562, 5564, 5565, 5566, 5567, + 5569, 5570, 5571, 5572, 5573, 5574, 5577, 5578, 5581, 5584, 5586, + 5589, 5590, 5591, 5592, 5594, 5595, 5597, 5598, 5600, 5601, 5602, + 5603, 5604, 5606, 5607, 5609, 5610, 5611, 5612, 5613, 5614, 5615, + 5616, 5617, 5618, 5619, 5620, 5621, 5623, 5624, 5625, 5626, 5627, + 5628, 5629, 5630, 5631, 5632, 5633, 5634, 5635, 5637, 5638, 5639, + 5641, 5643, 5644, 5645, 5646, 5647, 5648, 5649, 5650, 5651, 5652, + 5654, 5655, 5656, 5662, 5663, 5664, 5665, 5666, 5674, 5675, 5676, + 5677, 5678, 5679, 5680, 5681, 5682, 5683, 5684, 5685, 5686, 5688, + 5689, 5690, 5691, 5692, 5693, 5694, 5695, 5696, 5698, 5699, 5700, + 5701, 5702, 5703, 5704, 5705, 5706, 5707, 5708, 5715, 5716, 5717, + 5718, 5720, 5722, 5723, 5724, 5725, 5726, 5727, 5728, 5729, 5732, + 5733, 5734, 5735, 5736, 5739, 5741, 5742, 5743, 5745, 5746, 5749, + 5750, 5751, 5753, 5758, 5759, 5760, 5761, 5762, 5763, 5765, 5766, + 5767, 5768, 5769, 5772, 5774, 5777, 5787, 5788, 5789, 5790, 5791, + 5792, 5793, 5794, 5795, 5796, 5797, 5798, 5799, 5800, 5801, 5802, + 5803, 5804, 5806, 5807, 5808, 5809, 5810, 5811, 5812, 5813, 5814, + 5815, 5816, 5817, 5821, 5822, 5823, 5824, 5825, 5826, 5827, 5828, + 5829, 5830, 5832, 5835, 5836, 5838, 5839, 5841, 5843, 5844, 5845, + 5846, 5847, 5848, 5849, 5850, 5851, 5852, 5853, 5854, 5855, 5856, + 5857, 5858, 5859, 5860, 5861, 5862, 5863, 5864, 5865, 5866, 5867, + 5868, 5869, 5870, 5875, 5877, 5878, 5879, 5880, 5881, 5883, 5884, + 5885, 5886, 5887, 5889, 5890, 5891, 5892, 5893, 5894, 5895, 5896, + 5897, 5898, 5899, 5900, 5901, 5904, 5905, 5906, 5907, 5909, 5910, + 5911, 5912, 5913, 5914, 5915, 5916, 5917, 5918, 5919, 5920, 5922, + 5923, 5924, 5925, 5926, 5928, 5929, 5931, 5932, 5933, 5934, 5935, + 5936, 5937, 5938, 5939, 5940, 5941, 5942, 5943, 5944, 5949, 5950, + 5951, 5952, 5953, 5954, 5955, 5956, 5957, 5958, 5962, 5963, 5964, + 5965, 5966, 5967, 5968, 5969, 5970, 5971, 5972, 5973, 5974, 5975, + 5976, 5977, 5978, 5979, 5980, 5981, 5982, 5983, 5984, 5985, 5986, + 5987, 5988, 5990, 5991, 5992, 5993, 5994, 5995, 5996, 5997, 5998, + 5999, 6000, 6156, 6157, 6164, 6167, 6168, 6169, 6170, 6189, 6190, + 6191, 6193, 6194, 6197, 6198, 6199, 6200, 6201, 6202, 6204, 6206, + 6208, 6209, 6210, 6214, 6215, 6216, 6218, 6219, 6220, 6221, 6222, + 6223, 6224, 6225, 6226, 6227, 6233, 6235, 6236, 6237, 6239, 6240, + 6241, 6242, 6243, 6244, 6245, 6247, 6248, 6249, 6250, 6251, 6252, + 6253, 6254, 6255, 6256, 6257, 6258, 6259, 6260, 6262, 6263, 6265, + 6266, 6285, 6286, 6287, 6288, 6289, 6296, 6298, 6299, 6302, 6303, + 6305, 6307, 6308, 6310, 6311, 6313, 6321, 6322, 6323, 6326, 6327, + 6328, 6329, 6330, 6331, 6333, 6334, 6335, 6336, 6337, 6338, 6339, + 6340, 6341, 6342, 6346, 6347, 6348, 6349, 6350, 6351, 6352, 6353, + 6354, 6356, 6357, 6359, 6361, 6362, 6363, 6366, 6367, 6368, 6369, + 6370, 6371, 6373, 6374, 6377, 6378, 6379, 6380, 6381, 6382, 6383, + 6384, 6385, 6386, 6389, 6396, 6399, 6420, 6421, 6422, 6426, 6428, + 6429, 6430, 6431, 6432, 6433, 6437, 6442, 6443, 6444, 6445, 6446, + 6447, 6448, 6449, 6450, 6451, 6452, 6453, 6454, 6455, 6456, 6457, + 6458, 6459, 6460, 6461, 6462, 6463, 6464, 6465, 6466, 6467, 6468, + 6470, 6471, 6472, 6473, 6474, 6475, 6476, 6479, 6481, 6482, 6483, + 6484, 6485, 6486, 6488, 6489, 6491, 6492, 6498, 6499, 6501, 6502, + 6510, 6511, 6512, 6513, 6514, 6515, 6516, 6522, 6523, 6524, 6525, + 6546, 6547, 6548, 6549, 6550, 6551, 6557, 6558, 6559, 6560, 6561, + 6562, 6563, 6565, 6566, 6567, 6568, 6569, 6570, 6571, 6572, 6573, + 6576, 6577, 6578, 6581, 6582, 6585, 6586, 6587, 6589, 6590, 6591, + 6592, 6593, 6595, 6596, 6597, 6598, 6599, 6601, 6603, 6616, 6618, + 6619, 6620, 6631, 6632, 6636, 6637, 6638, 6639, 6640, 6642, 6645, + 6647, 6648, 6650, 6651, 6652, 6654, 6655, 6656, 6657, 6658, 6660, + 6661, 6662, 6663, 6664, 6665, 6666, 6667, 6668, 6669, 6670, 6672, + 6673, 6675, 6676, 6677, 6678, 6680, 6682, 6683, 6684, 6685, 6687, + 6688, 6689, 6691, 6692, 6693, 6694, 6695, 6696, 6697, 6698, 6699, + 6704, 6705, 6706, 6707, 6708, 6709, 6710, 6711, 6712, 6713, 6714, + 6715, 6716, 6717, 6718, 6719, 6722, 6723, 6724, 6725, 6728, 6729, + 6730, 6731, 6732, 6733, 6734, 6736, 6737, 6738, 6739, 6740, 6741, + 6742, 6743, 6744, 6746, 6747, 6748, 6749, 6750, 6751, 6753, 6754, + 6755, 6756, 6757, 6759, 6760, 6762, 6763, 6764, 6765, 6767, 6768, + 6769, 6775, 6776, 6777, 6778, 6779, 6780, 6781, 6783, 11093, 11094, + 11095, 11096, 11097, 11098, 11099, 11100, 11101, 11102, 11103, 11107, 11108, + 11109, 11110, 11111, 11113, 11114, 11117, 11119, 11120, 11121, 11122, 11124, + 11125, 11126, 11127, 11128, 11129, 11132, 11143, 11156, 11158, 11159, 11160, + 11162, 11165, 11171, 11174, 11175, 11176, 11178, 11179, 11180, 11182, 11183, + 11189, 11190, 11193, 11194, 11195, 11197, 11198, 11199, 11200, 11201, 11202, + 11203, 11206, 11207, 11210, 11211, 11212, 11213, 11214, 11215, 11218, 11220, + 11221, 11222, 11223, 11225, 11226, 11230, 11231, 11232, 11233, 11234, 11235, + 11238, 11239, 11241, 11243, 11244, 11247, 11248, 11250, 11251, 11252, 11253, + 11254, 11256, 11257, 11258, 11265, 11266, 11268, 11269, 11270, 11272, 11273, + 11274, 11276, 11277, 11279, 11282, 11283, 11286, 11287, 11288, 11289, 11290, + 11291, 11292, 11293, 11294, 11295, 11296, 11297, 11298, 11299, 11300, 11323, + 11324, 11325, 11326, 11327, 11328, 11329, 11330, 11331, 11336, 11338, 11339, + 11340, 11341, 11342, 11345, 11347, 11348, 11352, 11354, 11356, 11357, 11358, + 11361, 11362, 11363, 11364, 11365, 11366, 11367, 11368, 11370, 11372, 11373, + 11374, 11375, 11376, 11378, 11379, 11381, 11383, 11386, 11387, 11389, 11390, + 11394, 11395, 11396, 11397, 11398, 11399, 11400, 11401, 11402, 11403, 11404, + 11412, 11413, 11414, 11415, 11416, 11417, 11418, 11419, 11420, 11421, 11422, + 11423, 11429, 11430, 11432, 11433, 11434, 11435, 11436, 11437, 11438, 11439, + 11440, 11441, 11442, 11443, 11444, 11445, 11446, 11447, 11449, 11450, 11451, + 11458, 11460, 11462, 11463, 11465, 11466, 11467, 11468, 11469, 11470, 11471, + 11472, 11473, 11474, 11475, 11476, 11477, 11479, 11480, 11481, 11483, 11484, + 11485, 11486, 11487, 11490, 11491, 11492, 11493, 11494, 11495, 11496, 11497, + 11498, 11499, 11501, 11502, 11504, 11505, 11506, 11507, 11508, 11509, 11510, + 11511, 11512, 11513, 11514, 11515, 11516, 11517, 11518, 11519, 11521, 11522, + 11524, 11525, 11528, 11529, 11530, 11531, 11532, 11533, 11534, 11535, 11536, + 11537, 11538, 11539, 11540, 11541, 11544, 11545, 11546, 11548, 11550, 11553, + 11554, 11556, 11557, 11560, 11561, 11562, 11563, 11564, 11565, 11566, 11567, + 11568, 11569, 11570, 11571, 15019, 15020, 15022, 15023, 15024, 15025, 15026, + 15027, 15028, 15029, 15030, 15031, 15032, 15033, 15034, 15035, 15036, 15045, + 15046, 15047, 15049, 15050, 15051, 15052, 15053, 15054, 15055, 15056, 15057, + 15058, 15059, 15060, 15061, 15062, 15065, 15066, 15067, 15072, 15073, 15074, + 15075, 15077, 15078, 15079, 15081, 15082, 15093, 15094, 15095, 15096, 15097, + 15098, 15099, 15100, 15101, 15102, 15103, 15104, 15105, 15106, 15109, 15110, + 15111, 15113, 15114, 15116, 15117, 15128, 15132, 15133, 15134, 15136, 15137, + 15139, 15141, 15142, 15143, 15145, 15147, 15148, 15149, 15150, 15151, 15153, + 15154, 15155, 15156, 15157, 15158, 15159, 15160, 15164, 15186, 15187, 15188, + 15189, 15190, 15191, 15192, 15193, 15194, 15196, 15199, 15200, 15202, 15203, + 15204, 15205, 15206, 15207, 15210, 15212, 15213, 15214, 15215, 15217, 15219, + 15220, 15221, 15223, 15224, 15225, 15226, 15228, 15234, 15235, 15236, 15238, + 15239, 15240, 15241, 15242, 15243, 15245, 15246, 15247, 15248, 15249, 15250, + 15252, 15253, 15254, 15255, 15257, 15258, 15259, 15260, 15261, 15262, 15263, + 15264, 15265, 15266, 15269, 15270, 15271, 15272, 15273, 15274, 15275, 15278, + 15279, 15280, 15282, 15283, 15284, 15286, 15287, 15288, 15289, 15290, 15291, + 15292, 15293, 15294, 15295, 15296, 15298, 15300, 15301, 15302, 15303, 15304, + 15305, 15306, 15307, 15308, 15309, 15310, 15311, 15312, 15313, 15314, 15316, + 15317, 15320, 15322, 15323, 15324, 15325, 15326, 15327, 15357, 15358, 15359, + 15362, 15363, 15364, 15365, 15366, 15367, 15368, 15369, 15370, 15371, 15374, + 15375, 15376, 15378, 15380, 15381, 15383, 15384, 15385, 15387, 15389, 15391, + 15392, 15395, 15396, 15397, 15399, 15400, 15401, 15402, 15405, 15408, 15409, + 15410, 15414, 15415, 15416, 15417, 15418, 15419, 15421, 15422, 15427, 15428, + 15429, 15430, 15431, 15432, 15435, 15436, 15437, 15439, 15441, 15442, 15443, + 15444, 15445, 15447, 15448, 15449, 15450, 15451, 15452, 15454, 15455, 15456, + 15458, 15459, 15461, 15462, 15463, 15465, 15466, 15468, 15469, 15471, 15472, + 15475, 15476, 15477, 15478, 15480, 15481, 15482, 15483, 15485, 15486, 15487, + 15488, 15489, 15490, 15550, 15551, 15552, 15554, 15555, 15556, 15560, 15561, + 15562, 15563, 15567, 15568, 15569, 15570, 15572, 15573, 15574, 15575, 15576, + 15577, 15578, 15579, 15580, 15581, 15582, 15583, 15586, 15587, 15588, 15589, + 15590, 15591, 15592, 15593, 15594, 15595, 15598, 15599, 15600, 15601, 15602, + 15603, 15604, 15606, 15607, 15608, 15609, 15610, 15611, 15612, 15613, 15614, + 15615, 15616, 15617, 15618, 15619, 15620, 15622, 15623, 15624, 15625, 15626, + 15627, 15628, 15629, 15631, 15632, 15633, 15634, 15635, 15636, 15644, 15645, + 15646, 15647, 15650, 15651, 15652, 15653, 15654, 15655, 15656, 15657, 15658, + 15659, 15660, 15661, 15662, 15663, 15664, 15665, 15666, 15667, 15668, 15669, + 15670, 15672, 15673, 15674, 15675, 15676, 15677, 15678, 15679, 15680, 15681, + 15682, 15683, 15684, 15685, 15686, 15691, 15692, 15693, 15694, 15695, 15696, + 15698, 15700, 15701, 15702, 15703, 15704, 15706, 15707, 15708, 15709, 15710, + 15711, 15712, 15713, 15714, 15715, 15716, 15717, 15718, 15719, 15720, 15721, + 15722, 15723, 15724, 15733, 15743, 15744, 15745, 15749, 15750, 15751, 15752, + 15753, 15754, 15755, 15756, 15759, 15764, 15766, 15768, 15769, 15770, 15771, + 15772, 15773, 15775, 15778, 15779, 15780, 15781, 15782, 15783, 15784, 15792, + 15793, 15794, 15795, 15796, 15797, 15798, 15800, 15801, 15802, 15807, 15809, + 15810, 15811, 15812, 15814, 15815, 15816, 15818, 15819, 15820, 15821, 15822, + 15823, 15824, 15825, 15826, 15827, 15830, 15832, 15833, 15834, 15835, 15836, + 15843, 15845, 15846, 15847, 15848, 15849, 15851, 15852, 15854, 15856, 15858, + 15859, 15860, 15861, 15863, 15864, 15866, 15867, 15868, 15869, 15872, 15873, + 15874, 15875, 15880, 15883, 15884, 16042, 16043, 16044, 16047, 16048, 16049, + 16050, 16051, 16052, 16054, 16066, 16067, 16069, 16074, 16075, 16076, 16077, + 16078, 16089, 16096, 16098, 16100, 16101, 16102, 16103, 16105, 16106, 16107, + 16108, 16109, 16110, 16111, 16112, 16113, 16114, 16115, 16116, 16117, 16119, + 16122, 16128, 16134, 16137, 16138, 16144, 16145, 16146, 16148, 16156, 16157, + 16158, 16164, 16166, 16167, 16168, 16169, 16170, 16178, 16184, 16185, 16186, + 16194, 16211, 16213, 16214, 16221, 16222, 16223, 16224, 16225, 16226, 16228, + 16231, 16232, 16233, 16234, 16235, 16236, 16238, 16243, 16244, 16245, 16246, + 16248, 16249, 16250, 16251, 16252, 16253, 16256, 16257, 16259, 16260, 16262, + 16263, 16270, 16271, 16273, 16276, 16277, 16279, 16280, 16281, 16283, 16284, + 16285, 16286, 16287, 16288, 16289, 16290, 16291, 16292, 16293, 16296, 16297, + 16298, 16299, 16300, 16301, 16302, 16303, 16306, 16307, 16308, 16309, 16317, + 16318, 16320, 16321, 16322, 16323, 16325, 16326, 16327, 16328, 16329, 16330, + 16331, 16332, 16333, 16335, 16336, 16337, 16338, 16339, 16341, 16343, 16345, + 16346, 16348, 16350, 16352, 16353, 16354, 16355, 16356, 16357, 16358, 16359, + 16360, 16361, 16362, 16396, 16397, 16398, 16400, 16401, 16403, 16404, 16405, + 16406, 16407, 16408, 16409, 16410, 16411, 16412, 16414, 16415, 16416, 16419, + 16420, 16421, 16422, 16423, 16424, 16425, 16426, 16432, 16433, 16434, 16435, + 16436, 16438, 16440, 16441, 16442, 16443, 16444, 16445, 16447, 16448, 16449, + 16454, 16455, 16456, 16457, 16458, 16460, 16461, 16463, 16465, 16466, 16467, + 16468, 16469, 16470, 16471, 16472, 16473, 16474, 16475, 16476, 16477, 16478, + 16480, 16482, 16483, 16484, 16489, 16490, 16491, 16493, 16494, 16495, 16498, + 16500, 16501, 16502, 16503, 16504, 16505, 16506, 16507, 16508, 16509, 16510, + 16511, 16512, 16513, 16514, 16515, 16517, 16518, 16519, 16520, 16580, 16581, + 16583, 16586, 16587, 16588, 16594, 16597, 16598, 16599, 16600, 16601, 16602, + 16604, 16609, 16610, 16611, 16615, 16616, 16617, 16618, 16619, 16620, 16625, + 16626, 16627, 16628, 16629, 16630, 16631, 16632, 16633, 16634, 16636, 16658, + 16659, 16660, 16664, 16665, 16666, 16671, 16672, 16673, 16674, 16675, 16676, + 16678, 16679, 16681, 16682, 16683, 16685, 16686, 16687, 16688, 16689, 16690, + 16692, 16693, 16695, 16697, 16698, 16699, 16700, 16701, 16702, 16704, 16709, + 16710, 16711, 16712, 16713, 16715, 16716, 16717, 16718, 16719, 16720, 16721, + 16722, 16723, 16726, 16727, 16728, 16729, 16730, 16731, 16732, 16733, 16734, + 16736, 16738, 16742, 16743, 16744, 16746, 16747, 16748, 16749, 16750, 16751, + 16752, 16753, 16754, 16755, 16756, 16757, 16758, 16759, 16761, 16762, 16763, + 16765, 16766, 16767, 16768, 16769, 16770, 16771, 16772 }; } From 54b09a9b1eccac797fb674ca2d014da5151e9fa8 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Fri, 13 Sep 2024 22:14:54 -0400 Subject: [PATCH 05/26] fix: soon, binnums won't be multiples of 5 --- srcC/examples/dumpQADB.cpp | 4 +++- srcC/tests/testCharge.cpp | 5 ++++- srcC/tests/testDumpQADB.cpp | 5 +++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/srcC/examples/dumpQADB.cpp b/srcC/examples/dumpQADB.cpp index 0fc3a03..35635c5 100644 --- a/srcC/examples/dumpQADB.cpp +++ b/srcC/examples/dumpQADB.cpp @@ -33,8 +33,10 @@ int main(int argc, char ** argv) { // loop through files int evnum; - for(int filenum=0; filenum<=qa->GetMaxBinnum(runnum); filenum+=5) { + for(int filenum=0; filenum<=qa->GetMaxBinnum(runnum); filenum++) { sep("=",50); + // skip non-existent bin numbers (required since old QADBs' bin numbers are multiples of 5) + if(!qa->HasBinnum(runnum, filenum)) continue; cout << "FILE NUMBER " << filenum << endl; // perform the lookup, by filenum diff --git a/srcC/tests/testCharge.cpp b/srcC/tests/testCharge.cpp index 9cc2556..dd1099d 100644 --- a/srcC/tests/testCharge.cpp +++ b/srcC/tests/testCharge.cpp @@ -41,7 +41,10 @@ int main(int argc, char ** argv) { for(int runnum : runnumList) { // loop over files - for(int filenum=0; filenum<=qa->GetMaxBinnum(runnum); filenum+=5) { + for(int filenum=0; filenum<=qa->GetMaxBinnum(runnum); filenum++) { + + // skip non-existent bin numbers (required since old QADBs' bin numbers are multiples of 5) + if(!qa->HasBinnum(runnum, filenum)) continue; // query by file number qa->QueryByBinnum(runnum,filenum); diff --git a/srcC/tests/testDumpQADB.cpp b/srcC/tests/testDumpQADB.cpp index 1ccb6b8..cfa005c 100644 --- a/srcC/tests/testDumpQADB.cpp +++ b/srcC/tests/testDumpQADB.cpp @@ -42,10 +42,11 @@ int main(int argc, char ** argv) { int evnum; string defname; int chargeInt; - for(int filenum=0; filenum<=qa->GetMaxBinnum(runnum); filenum+=5) { + for(int filenum=0; filenum<=qa->GetMaxBinnum(runnum); filenum++) { sep("=",50); - //err("test error print"); + // skip non-existent bin numbers (required since old QADBs' bin numbers are multiples of 5) + if(!qa->HasBinnum(runnum, filenum)) continue; // query by file number qa->QueryByBinnum(runnum,filenum); From 46cd2d8c875546a9a786bef8544f8f653b338120 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Sun, 15 Sep 2024 17:34:01 -0400 Subject: [PATCH 06/26] doc: note which datasets use the old bit set --- srcC/include/QADB.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/srcC/include/QADB.h b/srcC/include/QADB.h index 896feac..0f96248 100644 --- a/srcC/include/QADB.h +++ b/srcC/include/QADB.h @@ -61,6 +61,8 @@ namespace QA { | - you may still use this method, but since many more defect bits have been | defined, and "Golden" means "no defect bits set", you may find that | requiring your data to be "Golden" is too strict for your analysis +| - NOTE: QADBs for Run Groups A, B, K, and M for Pass1 data only use +| defect bits 0 to 9, whereas newer QADBs define many more bits | - in some cases, none of the data are "Golden" )"; DeprecationGuidance(); From a1b71ad95664062d01f5b07e2b8ead39469a0eaf Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Sun, 15 Sep 2024 18:36:23 -0400 Subject: [PATCH 07/26] feat: port most changes to Groovy --- src/clasqa/QADB.groovy | 96 ++++++++++++++++++++++++++++++++++- src/examples/cutCustom.groovy | 12 ++--- src/examples/dumpQADB.groovy | 6 ++- src/tests/testCharge.groovy | 11 ++-- src/tests/testDumpQADB.groovy | 16 +++--- srcC/examples/dumpQADB.cpp | 2 +- srcC/include/QADB.h | 3 +- srcC/tests/testDumpQADB.cpp | 3 +- 8 files changed, 124 insertions(+), 25 deletions(-) diff --git a/src/clasqa/QADB.groovy b/src/clasqa/QADB.groovy index 17ef153..57418a9 100644 --- a/src/clasqa/QADB.groovy +++ b/src/clasqa/QADB.groovy @@ -106,6 +106,32 @@ class QADB { chargeTotal = 0 chargeCounted = false chargeCountedFiles = [] + dep_warned_Golden = false + dep_warned_OkForAsymmetry = false + } + + //............................... + // deprecation warnings + //``````````````````````````````` + private void deprecationGuidance() { + System.err.print("""| INSTEAD: use the general methods +| - use `QADB::checkForDefect` to choose which defects you want +| to filter out, then use `QADB::pass` on each event +| - for runs with the `Misc` defect bit (bit 5) assigned: +| - use `QADB::getComment` to check the QADB comment, which +| explains why this bit was assigned for the run +| - use `QADB::allowMiscBit` to ignore the `Misc` bit for certain +| runs that you want to allow in your analysis (`OkForAsymmetry` +| internally does this for a specific list of RG-A runs) +""") + } + + private void warningBanner(boolean first) { + if(first) { + System.err.print("\nWARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING\n|\n") + } else { + System.err.print("|\nWARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING\n\n") + } } @@ -114,6 +140,20 @@ class QADB { //``````````````````````````````` // returns false if the event is in a file with *any* defect public boolean golden(int runnum_, int evnum_) { + if(!dep_warned_Golden) { + dep_warned_Golden = true + warningBanner(true) + System.err.print("""| WARNING: `QADB::golden` is DEPRECATED +| - you may still use this method, but since many more defect bits have been +| defined, and "Golden" means "no defect bits set", you may find that +| requiring your data to be "Golden" is too strict for your analysis +| - NOTE: QADBs for Run Groups A, B, K, and M for Pass1 data only use +| defect bits 0 to 9, whereas newer QADBs define many more bits +| - in some cases, none of the data are "Golden" +""") + deprecationGuidance() + warningBanner(false) + } def foundHere = query(runnum_,evnum_) return foundHere && defect==0 } @@ -125,6 +165,23 @@ class QADB { // if true, this event is good for a spin asymmetry analysis public boolean OkForAsymmetry(int runnum_, int evnum_) { + if(!dep_warned_OkForAsymmetry) { + dep_warned_OkForAsymmetry = true + warningBanner(true) + System.err.print("""| WARNING: `QADB::OkForAsymmetry` is DEPRECATED +| - you may still use this method, but `OkForAsymmetry` does +| not include NEW defect bits that have been recently defined +""") + deprecationGuidance() + System.err.print("""| EXAMPLE: +| - see '$QADB/src/tests/testOkForAsymmetry.groovy' for a +| preferred, equivalent implementation; from there, you may +| customize your QA criteria and use the new defect bits +""") + warningBanner(false) + } + + // perform lookup def foundHere = query(runnum_,evnum_) if(!foundHere) return false; @@ -170,13 +227,30 @@ class QADB { if(state) mask |= (0x1 << defectBit) } } + public void checkForDefect(String bitStr, boolean state=true) { // alias + setMaskBit(bitStr, state) + } // access the custom mask, if you want to double-check it public int getMask() { return mask } // then call this method to check your custom QA cut for a given // run number and event number public boolean pass(int runnum_, int evnum_) { def foundHere = query(runnum_,evnum_) - return foundHere && !(defect & mask) + if(!foundHere) { + return false + } + def use_mask = mask + if(hasDefectBit(5)) { + if(runnum_ in allowMiscBitList) { + use_mask &= ~(0x1 << 5) // set `use_mask`'s Misc bit to 0 + } + } + return foundHere && !(defect & use_mask) + } + + // ignore certain runs for the `Misc` bit assignment + public void allowMiscBit(int runnum_) { + allowMiscBitList.add(runnum_) } @@ -186,6 +260,7 @@ class QADB { // --- access this file's info public int getRunnum() { return found ? runnum.toInteger() : -1 } public int getFilenum() { return found ? filenum.toInteger() : -1 } + public int getBinnum() { return getFilenum() } public String getComment() { return found ? comment : "" } public int getEvnumMin() { return found ? evnumMin : -1 } public int getEvnumMax() { return found ? evnumMax : -1 } @@ -319,6 +394,18 @@ class QADB { // result of query return found } + // aliases + public boolean queryByBinnum(int runnum_, int binnum_) { + return queryByFilenum(runnum_, binnum_) + } + + // check if this bin number exists + public boolean hasBinnum(int runnum_, int binnum_) { + if(qaTree.containsKey("$runnum_")) { + return qaTree["$runnum_"].containsKey("$binnum_") + } + return false + } // get maximum file number for a given run (useful for QADB validation) @@ -330,6 +417,9 @@ class QADB { } return maxFilenum } + public int getMaxBinnum(int runnum_) { // alias + return getMaxFilenum(runnum_) + } @@ -387,4 +477,8 @@ class QADB { private def mask private def asymMask private def allowForOkForAsymmetry + private def allowMiscBitList + + private boolean dep_warned_Golden + private boolean dep_warned_OkForAsymmetry } diff --git a/src/examples/cutCustom.groovy b/src/examples/cutCustom.groovy index c949845..ad870dc 100644 --- a/src/examples/cutCustom.groovy +++ b/src/examples/cutCustom.groovy @@ -26,12 +26,12 @@ QADB qa = new QADB() // the QA cut if the associated file has any of the specified defects // - set to true to check the bit // - set to false to ignore the bit (by default, all bits are ignored) -qa.setMaskBit('TotalOutlier',false) -qa.setMaskBit('TerminalOutlier',false) -qa.setMaskBit('MarginalOutlier',false) -qa.setMaskBit('SectorLoss',true) // this is the only bit we check here -qa.setMaskBit('LowLiveTime',false) -qa.setMaskBit('Misc',false) +qa.checkForDefect('TotalOutlier',false) +qa.checkForDefect('TerminalOutlier',false) +qa.checkForDefect('MarginalOutlier',false) +qa.checkForDefect('SectorLoss',true) // this is the only bit we check here +qa.checkForDefect('LowLiveTime',false) +qa.checkForDefect('Misc',false) // print the defect bit mask println "\ndefect mask = " + qa.util.printBinary(qa.getMask(),16) + "\n" diff --git a/src/examples/dumpQADB.groovy b/src/examples/dumpQADB.groovy index 17a1c49..7b09b3a 100644 --- a/src/examples/dumpQADB.groovy +++ b/src/examples/dumpQADB.groovy @@ -25,12 +25,14 @@ QADB qa = new QADB() // loop through files int evnum -for(int filenum=0; filenum<=qa.getMaxFilenum(runnum); filenum+=5) { +for(int filenum=0; filenum<=qa.getMaxBinnum(runnum); filenum++) { + // skip non-existent bin numbers (required since old QADBs' bin numbers are multiples of 5) + if(qa.hasBinnum(runnum, filenum)) { continue } sep("=",50) println "FILE NUMBER $filenum" // perform the lookup, by filenum - if(qa.queryByFilenum(runnum,filenum)) { + if(qa.queryByBinnum(runnum,filenum)) { // we need an event number within this file, to pass to QA criteria // checking methods, such as Golden; no additional Query will be called diff --git a/src/tests/testCharge.groovy b/src/tests/testCharge.groovy index ca39d2a..7c07488 100644 --- a/src/tests/testCharge.groovy +++ b/src/tests/testCharge.groovy @@ -25,18 +25,21 @@ def runnumList = [ // specify QA criteria -qa.setMaskBit("SectorLoss") -qa.setMaskBit("MarginalOutlier") +qa.checkForDefect("SectorLoss") +qa.checkForDefect("MarginalOutlier") // loop over runs runnumList.each{ runnum -> // loop over files - for(int filenum=0; filenum<=qa.getMaxFilenum(runnum); filenum+=5) { + for(int filenum=0; filenum<=qa.getMaxBinnum(runnum); filenum++) { + + // skip non-existent bin numbers (required since old QADBs' bin numbers are multiples of 5) + if(qa.hasBinnum(runnum, filenum)) { continue } // query by file number - qa.queryByFilenum(runnum,filenum) + qa.queryByBinnum(runnum,filenum) evnum = qa.getEvnumMin() // evnum needed for QA cut methods // accumulate charge, if QA criteria are satisfied diff --git a/src/tests/testDumpQADB.groovy b/src/tests/testDumpQADB.groovy index 623dc37..811a855 100644 --- a/src/tests/testDumpQADB.groovy +++ b/src/tests/testDumpQADB.groovy @@ -33,13 +33,15 @@ QADB qa = new QADB() int evnum def defname int chargeInt -for(int filenum=0; filenum<=qa.getMaxFilenum(runnum); filenum+=5) { +for(int filenum=0; filenum<=qa.getMaxBinnum(runnum); filenum++) { + // skip non-existent bin numbers (required since old QADBs' bin numbers are multiples of 5) + if(qa.hasBinnum(runnum, filenum)) { continue } sep("=",50) //err("test error print") // query by file number - qa.queryByFilenum(runnum,filenum) + qa.queryByBinnum(runnum,filenum) evnum = qa.getEvnumMin() // evnum needed for QA cut methods // check run and file number accessors: make sure that they @@ -47,8 +49,8 @@ for(int filenum=0; filenum<=qa.getMaxFilenum(runnum); filenum+=5) { println "- run,file,evnum" println qa.getRunnum() + " " + runnum if(qa.getRunnum() != runnum) err("QADB::getRunnum != runnum"); - println qa.getFilenum() + " " + filenum - if(qa.getFilenum() != filenum) err("QADB::GetFilenum != filenum"); + println qa.getBinnum() + " " + filenum + if(qa.getBinnum() != filenum) err("QADB::GetBinnum != filenum"); // check event number: report an error if evnum min>=max println qa.getEvnumMin() + " " + qa.getEvnumMax() @@ -88,9 +90,9 @@ for(int filenum=0; filenum<=qa.getMaxFilenum(runnum); filenum+=5) { for(int sec=1; sec<=6; sec++) print " " + (qa.hasDefect(defname,sec)?1:0); println "" // print bit masking - qa.setMaskBit(defname); + qa.checkForDefect(defname); println qa.getMask() + " " + (qa.pass(runnum,evnum)?1:0) - qa.setMaskBit(defname,false); + qa.checkForDefect(defname,false); }; // print QA cuts (see above for custom cut check with mask) @@ -105,6 +107,6 @@ println "- charge, max filenum" println ((int)(1000*qa.getAccumulatedCharge())) // print max file number -println qa.getMaxFilenum(runnum) +println qa.getMaxBinnum(runnum) sep("=",50); diff --git a/srcC/examples/dumpQADB.cpp b/srcC/examples/dumpQADB.cpp index 35635c5..3cd62ae 100644 --- a/srcC/examples/dumpQADB.cpp +++ b/srcC/examples/dumpQADB.cpp @@ -34,9 +34,9 @@ int main(int argc, char ** argv) { // loop through files int evnum; for(int filenum=0; filenum<=qa->GetMaxBinnum(runnum); filenum++) { - sep("=",50); // skip non-existent bin numbers (required since old QADBs' bin numbers are multiples of 5) if(!qa->HasBinnum(runnum, filenum)) continue; + sep("=",50); cout << "FILE NUMBER " << filenum << endl; // perform the lookup, by filenum diff --git a/srcC/include/QADB.h b/srcC/include/QADB.h index 0f96248..bae3e3a 100644 --- a/srcC/include/QADB.h +++ b/srcC/include/QADB.h @@ -106,7 +106,7 @@ namespace QA { // --- access this file's info inline int GetRunnum() { return found ? runnum : -1; }; inline int GetFilenum() { return found ? filenum : -1; }; - inline int GetBinnum() { return found ? filenum : -1; }; // alias for `GetFilenum` + inline int GetBinnum() { return GetFilenum(); }; // alias for `GetFilenum` inline std::string GetComment() { return found ? comment : ""; }; inline int GetEvnumMin() { return found ? evnumMin : -1; }; inline int GetEvnumMax() { return found ? evnumMax : -1; }; @@ -209,7 +209,6 @@ namespace QA { bool chargeCounted; std::vector> chargeCountedFiles; - std::map defectNameMap; int nbits; diff --git a/srcC/tests/testDumpQADB.cpp b/srcC/tests/testDumpQADB.cpp index cfa005c..1b6fd97 100644 --- a/srcC/tests/testDumpQADB.cpp +++ b/srcC/tests/testDumpQADB.cpp @@ -43,10 +43,9 @@ int main(int argc, char ** argv) { string defname; int chargeInt; for(int filenum=0; filenum<=qa->GetMaxBinnum(runnum); filenum++) { - sep("=",50); - // skip non-existent bin numbers (required since old QADBs' bin numbers are multiples of 5) if(!qa->HasBinnum(runnum, filenum)) continue; + sep("=",50); // query by file number qa->QueryByBinnum(runnum,filenum); From 14550509f8431e817562fb28d706b525691840ec Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Sun, 15 Sep 2024 18:55:37 -0400 Subject: [PATCH 08/26] feat: port `testOkForAsymmetry` to Groovy --- src/tests/testOkForAsymmetry.groovy | 113 ++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 src/tests/testOkForAsymmetry.groovy diff --git a/src/tests/testOkForAsymmetry.groovy b/src/tests/testOkForAsymmetry.groovy new file mode 100644 index 0000000..553814e --- /dev/null +++ b/src/tests/testOkForAsymmetry.groovy @@ -0,0 +1,113 @@ +import clasqa.QADB + +boolean debug = true + + +////////////////////////////////////////////////////////////////////////////////// +// the general method requires the user to choose the defects they want +// to avoid in their analysis, and a list of runs for which the `Misc` defect bit +// should be ignored +System.out.println('Loading QADBs...') +QADB qa = new QADB() +qa.checkForDefect('TotalOutlier') // these choices match the criteria of `OkForAsymmetry` +qa.checkForDefect('TerminalOutlier') +qa.checkForDefect('MarginalOutlier') +qa.checkForDefect('SectorLoss') +qa.checkForDefect('Misc') +[ // list of runs with `Misc` defect that are allowed by `OkForAsymmetry` + 5046, 5047, 5051, 5128, 5129, 5130, 5158, 5159, + 5160, 5163, 5165, 5166, 5167, 5168, 5169, 5180, + 5181, 5182, 5183, 5400, 5448, 5495, 5496, 5505, + 5567, 5610, 5617, 5621, 5623, 6736, 6737, 6738, + 6739, 6740, 6741, 6742, 6743, 6744, 6746, 6747, + 6748, 6749, 6750, 6751, 6753, 6754, 6755, 6756, + 6757 +].each{ run -> qa.allowMiscBit(run) } +// after this, just use `qa.pass(runnum, evnum)` for each event (instead of +// `qa.OkForAsymmetry(runnum, evnum)`) +////////////////////////////////////////////////////////////////////////////////// + + + +// instantiate more QADBs, for comparison (`qa` will use the general method) +QADB qa_deprecated = new QADB() // will use `OkForAsymmetry`, which is deprecated +QADB qa_third_party = new QADB() // 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` +// for each of the following runs: +[ + 5032, 5036, 5038, 5039, 5040, 5041, 5043, 5045, 5046, 5047, 5051, 5052, 5053, 5116, 5117, 5119, 5120, 5124, 5125, 5126, 5127, 5128, 5129, 5130, 5137, 5138, 5139, 5153, 5158, 5159, 5160, 5162, 5163, 5164, 5165, 5166, 5167, 5168, 5169, 5180, 5181, 5182, 5183, 5189, + 5190, 5191, 5193, 5194, 5195, 5196, 5197, 5198, 5199, 5200, 5201, 5202, 5203, 5204, 5205, 5206, 5208, 5211, 5212, 5215, 5216, 5219, 5220, 5221, 5222, 5223, 5225, 5229, 5230, 5231, 5232, 5233, 5234, 5235, 5237, 5238, 5239, 5247, 5248, 5249, 5250, 5252, 5253, 5257, + 5258, 5259, 5261, 5262, 5300, 5301, 5302, 5303, 5304, 5305, 5306, 5307, 5310, 5311, 5315, 5316, 5317, 5318, 5319, 5320, 5323, 5324, 5325, 5333, 5334, 5335, 5336, 5339, 5340, 5341, 5342, 5343, 5344, 5345, 5346, 5347, 5349, 5351, 5354, 5355, 5356, 5357, 5358, 5359, + 5360, 5361, 5362, 5366, 5367, 5368, 5369, 5370, 5371, 5372, 5373, 5374, 5375, 5376, 5377, 5378, 5379, 5380, 5381, 5382, 5383, 5386, 5390, 5391, 5392, 5393, 5394, 5398, 5399, 5400, 5401, 5402, 5403, 5404, 5406, 5407, 5414, 5415, 5416, 5417, 5418, 5419, 5422, 5423, + 5424, 5425, 5426, 5428, 5429, 5430, 5431, 5432, 5434, 5435, 5436, 5437, 5438, 5439, 5440, 5441, 5442, 5443, 5444, 5445, 5447, 5448, 5449, 5450, 5451, 5452, 5453, 5454, 5455, 5456, 5457, 5460, 5462, 5464, 5465, 5466, 5467, 5468, 5469, 5470, 5471, 5472, 5473, 5474, + 5475, 5476, 5478, 5479, 5480, 5481, 5482, 5483, 5485, 5486, 5487, 5495, 5496, 5497, 5498, 5499, 5500, 5504, 5505, 5507, 5516, 5517, 5518, 5519, 5520, 5521, 5522, 5523, 5524, 5525, 5526, 5527, 5528, 5530, 5532, 5533, 5534, 5535, 5536, 5537, 5538, 5540, 5541, 5542, + 5543, 5544, 5545, 5546, 5547, 5548, 5549, 5550, 5551, 5552, 5554, 5555, 5556, 5557, 5558, 5559, 5561, 5562, 5564, 5565, 5566, 5567, 5569, 5570, 5571, 5572, 5573, 5574, 5577, 5578, 5581, 5584, 5586, 5589, 5590, 5591, 5592, 5594, 5595, 5597, 5598, 5600, 5601, 5602, + 5603, 5604, 5606, 5607, 5609, 5610, 5611, 5612, 5613, 5614, 5615, 5616, 5617, 5618, 5619, 5620, 5621, 5623, 5624, 5625, 5626, 5627, 5628, 5629, 5630, 5631, 5632, 5633, 5634, 5635, 5637, 5638, 5639, 5641, 5643, 5644, 5645, 5646, 5647, 5648, 5649, 5650, 5651, 5652, + 5654, 5655, 5656, 5662, 5663, 5664, 5665, 5666, 5674, 5675, 5676, 5677, 5678, 5679, 5680, 5681, 5682, 5683, 5684, 5685, 5686, 5688, 5689, 5690, 5691, 5692, 5693, 5694, 5695, 5696, 5698, 5699, 5700, 5701, 5702, 5703, 5704, 5705, 5706, 5707, 5708, 5715, 5716, 5717, + 5718, 5720, 5722, 5723, 5724, 5725, 5726, 5727, 5728, 5729, 5732, 5733, 5734, 5735, 5736, 5739, 5741, 5742, 5743, 5745, 5746, 5749, 5750, 5751, 5753, 5758, 5759, 5760, 5761, 5762, 5763, 5765, 5766, 5767, 5768, 5769, 5772, 5774, 5777, 5787, 5788, 5789, 5790, 5791, + 5792, 5793, 5794, 5795, 5796, 5797, 5798, 5799, 5800, 5801, 5802, 5803, 5804, 5806, 5807, 5808, 5809, 5810, 5811, 5812, 5813, 5814, 5815, 5816, 5817, 5821, 5822, 5823, 5824, 5825, 5826, 5827, 5828, 5829, 5830, 5832, 5835, 5836, 5838, 5839, 5841, 5843, 5844, 5845, + 5846, 5847, 5848, 5849, 5850, 5851, 5852, 5853, 5854, 5855, 5856, 5857, 5858, 5859, 5860, 5861, 5862, 5863, 5864, 5865, 5866, 5867, 5868, 5869, 5870, 5875, 5877, 5878, 5879, 5880, 5881, 5883, 5884, 5885, 5886, 5887, 5889, 5890, 5891, 5892, 5893, 5894, 5895, 5896, + 5897, 5898, 5899, 5900, 5901, 5904, 5905, 5906, 5907, 5909, 5910, 5911, 5912, 5913, 5914, 5915, 5916, 5917, 5918, 5919, 5920, 5922, 5923, 5924, 5925, 5926, 5928, 5929, 5931, 5932, 5933, 5934, 5935, 5936, 5937, 5938, 5939, 5940, 5941, 5942, 5943, 5944, 5949, 5950, + 5951, 5952, 5953, 5954, 5955, 5956, 5957, 5958, 5962, 5963, 5964, 5965, 5966, 5967, 5968, 5969, 5970, 5971, 5972, 5973, 5974, 5975, 5976, 5977, 5978, 5979, 5980, 5981, 5982, 5983, 5984, 5985, 5986, 5987, 5988, 5990, 5991, 5992, 5993, 5994, 5995, 5996, 5997, 5998, + 5999, 6000, 6156, 6157, 6164, 6167, 6168, 6169, 6170, 6189, 6190, 6191, 6193, 6194, 6197, 6198, 6199, 6200, 6201, 6202, 6204, 6206, 6208, 6209, 6210, 6214, 6215, 6216, 6218, 6219, 6220, 6221, 6222, 6223, 6224, 6225, 6226, 6227, 6233, 6235, 6236, 6237, 6239, 6240, + 6241, 6242, 6243, 6244, 6245, 6247, 6248, 6249, 6250, 6251, 6252, 6253, 6254, 6255, 6256, 6257, 6258, 6259, 6260, 6262, 6263, 6265, 6266, 6285, 6286, 6287, 6288, 6289, 6296, 6298, 6299, 6302, 6303, 6305, 6307, 6308, 6310, 6311, 6313, 6321, 6322, 6323, 6326, 6327, + 6328, 6329, 6330, 6331, 6333, 6334, 6335, 6336, 6337, 6338, 6339, 6340, 6341, 6342, 6346, 6347, 6348, 6349, 6350, 6351, 6352, 6353, 6354, 6356, 6357, 6359, 6361, 6362, 6363, 6366, 6367, 6368, 6369, 6370, 6371, 6373, 6374, 6377, 6378, 6379, 6380, 6381, 6382, 6383, + 6384, 6385, 6386, 6389, 6396, 6399, 6420, 6421, 6422, 6426, 6428, 6429, 6430, 6431, 6432, 6433, 6437, 6442, 6443, 6444, 6445, 6446, 6447, 6448, 6449, 6450, 6451, 6452, 6453, 6454, 6455, 6456, 6457, 6458, 6459, 6460, 6461, 6462, 6463, 6464, 6465, 6466, 6467, 6468, + 6470, 6471, 6472, 6473, 6474, 6475, 6476, 6479, 6481, 6482, 6483, 6484, 6485, 6486, 6488, 6489, 6491, 6492, 6498, 6499, 6501, 6502, 6510, 6511, 6512, 6513, 6514, 6515, 6516, 6522, 6523, 6524, 6525, 6546, 6547, 6548, 6549, 6550, 6551, 6557, 6558, 6559, 6560, 6561, + 6562, 6563, 6565, 6566, 6567, 6568, 6569, 6570, 6571, 6572, 6573, 6576, 6577, 6578, 6581, 6582, 6585, 6586, 6587, 6589, 6590, 6591, 6592, 6593, 6595, 6596, 6597, 6598, 6599, 6601, 6603, 6616, 6618, 6619, 6620, 6631, 6632, 6636, 6637, 6638, 6639, 6640, 6642, 6645, + 6647, 6648, 6650, 6651, 6652, 6654, 6655, 6656, 6657, 6658, 6660, 6661, 6662, 6663, 6664, 6665, 6666, 6667, 6668, 6669, 6670, 6672, 6673, 6675, 6676, 6677, 6678, 6680, 6682, 6683, 6684, 6685, 6687, 6688, 6689, 6691, 6692, 6693, 6694, 6695, 6696, 6697, 6698, 6699, + 6704, 6705, 6706, 6707, 6708, 6709, 6710, 6711, 6712, 6713, 6714, 6715, 6716, 6717, 6718, 6719, 6722, 6723, 6724, 6725, 6728, 6729, 6730, 6731, 6732, 6733, 6734, 6736, 6737, 6738, 6739, 6740, 6741, 6742, 6743, 6744, 6746, 6747, 6748, 6749, 6750, 6751, 6753, 6754, + 6755, 6756, 6757, 6759, 6760, 6762, 6763, 6764, 6765, 6767, 6768, 6769, 6775, 6776, 6777, 6778, 6779, 6780, 6781, 6783, 11093, 11094, 11095, 11096, 11097, 11098, 11099, 11100, 11101, 11102, 11103, 11107, 11108, 11109, 11110, 11111, 11113, 11114, 11117, 11119, 11120, 11121, 11122, 11124, + 11125, 11126, 11127, 11128, 11129, 11132, 11143, 11156, 11158, 11159, 11160, 11162, 11165, 11171, 11174, 11175, 11176, 11178, 11179, 11180, 11182, 11183, 11189, 11190, 11193, 11194, 11195, 11197, 11198, 11199, 11200, 11201, 11202, 11203, 11206, 11207, 11210, 11211, 11212, 11213, 11214, 11215, 11218, 11220, + 11221, 11222, 11223, 11225, 11226, 11230, 11231, 11232, 11233, 11234, 11235, 11238, 11239, 11241, 11243, 11244, 11247, 11248, 11250, 11251, 11252, 11253, 11254, 11256, 11257, 11258, 11265, 11266, 11268, 11269, 11270, 11272, 11273, 11274, 11276, 11277, 11279, 11282, 11283, 11286, 11287, 11288, 11289, 11290, + 11291, 11292, 11293, 11294, 11295, 11296, 11297, 11298, 11299, 11300, 11323, 11324, 11325, 11326, 11327, 11328, 11329, 11330, 11331, 11336, 11338, 11339, 11340, 11341, 11342, 11345, 11347, 11348, 11352, 11354, 11356, 11357, 11358, 11361, 11362, 11363, 11364, 11365, 11366, 11367, 11368, 11370, 11372, 11373, + 11374, 11375, 11376, 11378, 11379, 11381, 11383, 11386, 11387, 11389, 11390, 11394, 11395, 11396, 11397, 11398, 11399, 11400, 11401, 11402, 11403, 11404, 11412, 11413, 11414, 11415, 11416, 11417, 11418, 11419, 11420, 11421, 11422, 11423, 11429, 11430, 11432, 11433, 11434, 11435, 11436, 11437, 11438, 11439, + 11440, 11441, 11442, 11443, 11444, 11445, 11446, 11447, 11449, 11450, 11451, 11458, 11460, 11462, 11463, 11465, 11466, 11467, 11468, 11469, 11470, 11471, 11472, 11473, 11474, 11475, 11476, 11477, 11479, 11480, 11481, 11483, 11484, 11485, 11486, 11487, 11490, 11491, 11492, 11493, 11494, 11495, 11496, 11497, + 11498, 11499, 11501, 11502, 11504, 11505, 11506, 11507, 11508, 11509, 11510, 11511, 11512, 11513, 11514, 11515, 11516, 11517, 11518, 11519, 11521, 11522, 11524, 11525, 11528, 11529, 11530, 11531, 11532, 11533, 11534, 11535, 11536, 11537, 11538, 11539, 11540, 11541, 11544, 11545, 11546, 11548, 11550, 11553, + 11554, 11556, 11557, 11560, 11561, 11562, 11563, 11564, 11565, 11566, 11567, 11568, 11569, 11570, 11571, 15019, 15020, 15022, 15023, 15024, 15025, 15026, 15027, 15028, 15029, 15030, 15031, 15032, 15033, 15034, 15035, 15036, 15045, 15046, 15047, 15049, 15050, 15051, 15052, 15053, 15054, 15055, 15056, 15057, + 15058, 15059, 15060, 15061, 15062, 15065, 15066, 15067, 15072, 15073, 15074, 15075, 15077, 15078, 15079, 15081, 15082, 15093, 15094, 15095, 15096, 15097, 15098, 15099, 15100, 15101, 15102, 15103, 15104, 15105, 15106, 15109, 15110, 15111, 15113, 15114, 15116, 15117, 15128, 15132, 15133, 15134, 15136, 15137, + 15139, 15141, 15142, 15143, 15145, 15147, 15148, 15149, 15150, 15151, 15153, 15154, 15155, 15156, 15157, 15158, 15159, 15160, 15164, 15186, 15187, 15188, 15189, 15190, 15191, 15192, 15193, 15194, 15196, 15199, 15200, 15202, 15203, 15204, 15205, 15206, 15207, 15210, 15212, 15213, 15214, 15215, 15217, 15219, + 15220, 15221, 15223, 15224, 15225, 15226, 15228, 15234, 15235, 15236, 15238, 15239, 15240, 15241, 15242, 15243, 15245, 15246, 15247, 15248, 15249, 15250, 15252, 15253, 15254, 15255, 15257, 15258, 15259, 15260, 15261, 15262, 15263, 15264, 15265, 15266, 15269, 15270, 15271, 15272, 15273, 15274, 15275, 15278, + 15279, 15280, 15282, 15283, 15284, 15286, 15287, 15288, 15289, 15290, 15291, 15292, 15293, 15294, 15295, 15296, 15298, 15300, 15301, 15302, 15303, 15304, 15305, 15306, 15307, 15308, 15309, 15310, 15311, 15312, 15313, 15314, 15316, 15317, 15320, 15322, 15323, 15324, 15325, 15326, 15327, 15357, 15358, 15359, + 15362, 15363, 15364, 15365, 15366, 15367, 15368, 15369, 15370, 15371, 15374, 15375, 15376, 15378, 15380, 15381, 15383, 15384, 15385, 15387, 15389, 15391, 15392, 15395, 15396, 15397, 15399, 15400, 15401, 15402, 15405, 15408, 15409, 15410, 15414, 15415, 15416, 15417, 15418, 15419, 15421, 15422, 15427, 15428, + 15429, 15430, 15431, 15432, 15435, 15436, 15437, 15439, 15441, 15442, 15443, 15444, 15445, 15447, 15448, 15449, 15450, 15451, 15452, 15454, 15455, 15456, 15458, 15459, 15461, 15462, 15463, 15465, 15466, 15468, 15469, 15471, 15472, 15475, 15476, 15477, 15478, 15480, 15481, 15482, 15483, 15485, 15486, 15487, + 15488, 15489, 15490, 15550, 15551, 15552, 15554, 15555, 15556, 15560, 15561, 15562, 15563, 15567, 15568, 15569, 15570, 15572, 15573, 15574, 15575, 15576, 15577, 15578, 15579, 15580, 15581, 15582, 15583, 15586, 15587, 15588, 15589, 15590, 15591, 15592, 15593, 15594, 15595, 15598, 15599, 15600, 15601, 15602, + 15603, 15604, 15606, 15607, 15608, 15609, 15610, 15611, 15612, 15613, 15614, 15615, 15616, 15617, 15618, 15619, 15620, 15622, 15623, 15624, 15625, 15626, 15627, 15628, 15629, 15631, 15632, 15633, 15634, 15635, 15636, 15644, 15645, 15646, 15647, 15650, 15651, 15652, 15653, 15654, 15655, 15656, 15657, 15658, + 15659, 15660, 15661, 15662, 15663, 15664, 15665, 15666, 15667, 15668, 15669, 15670, 15672, 15673, 15674, 15675, 15676, 15677, 15678, 15679, 15680, 15681, 15682, 15683, 15684, 15685, 15686, 15691, 15692, 15693, 15694, 15695, 15696, 15698, 15700, 15701, 15702, 15703, 15704, 15706, 15707, 15708, 15709, 15710, + 15711, 15712, 15713, 15714, 15715, 15716, 15717, 15718, 15719, 15720, 15721, 15722, 15723, 15724, 15733, 15743, 15744, 15745, 15749, 15750, 15751, 15752, 15753, 15754, 15755, 15756, 15759, 15764, 15766, 15768, 15769, 15770, 15771, 15772, 15773, 15775, 15778, 15779, 15780, 15781, 15782, 15783, 15784, 15792, + 15793, 15794, 15795, 15796, 15797, 15798, 15800, 15801, 15802, 15807, 15809, 15810, 15811, 15812, 15814, 15815, 15816, 15818, 15819, 15820, 15821, 15822, 15823, 15824, 15825, 15826, 15827, 15830, 15832, 15833, 15834, 15835, 15836, 15843, 15845, 15846, 15847, 15848, 15849, 15851, 15852, 15854, 15856, 15858, + 15859, 15860, 15861, 15863, 15864, 15866, 15867, 15868, 15869, 15872, 15873, 15874, 15875, 15880, 15883, 15884, 16042, 16043, 16044, 16047, 16048, 16049, 16050, 16051, 16052, 16054, 16066, 16067, 16069, 16074, 16075, 16076, 16077, 16078, 16089, 16096, 16098, 16100, 16101, 16102, 16103, 16105, 16106, 16107, + 16108, 16109, 16110, 16111, 16112, 16113, 16114, 16115, 16116, 16117, 16119, 16122, 16128, 16134, 16137, 16138, 16144, 16145, 16146, 16148, 16156, 16157, 16158, 16164, 16166, 16167, 16168, 16169, 16170, 16178, 16184, 16185, 16186, 16194, 16211, 16213, 16214, 16221, 16222, 16223, 16224, 16225, 16226, 16228, + 16231, 16232, 16233, 16234, 16235, 16236, 16238, 16243, 16244, 16245, 16246, 16248, 16249, 16250, 16251, 16252, 16253, 16256, 16257, 16259, 16260, 16262, 16263, 16270, 16271, 16273, 16276, 16277, 16279, 16280, 16281, 16283, 16284, 16285, 16286, 16287, 16288, 16289, 16290, 16291, 16292, 16293, 16296, 16297, + 16298, 16299, 16300, 16301, 16302, 16303, 16306, 16307, 16308, 16309, 16317, 16318, 16320, 16321, 16322, 16323, 16325, 16326, 16327, 16328, 16329, 16330, 16331, 16332, 16333, 16335, 16336, 16337, 16338, 16339, 16341, 16343, 16345, 16346, 16348, 16350, 16352, 16353, 16354, 16355, 16356, 16357, 16358, 16359, + 16360, 16361, 16362, 16396, 16397, 16398, 16400, 16401, 16403, 16404, 16405, 16406, 16407, 16408, 16409, 16410, 16411, 16412, 16414, 16415, 16416, 16419, 16420, 16421, 16422, 16423, 16424, 16425, 16426, 16432, 16433, 16434, 16435, 16436, 16438, 16440, 16441, 16442, 16443, 16444, 16445, 16447, 16448, 16449, + 16454, 16455, 16456, 16457, 16458, 16460, 16461, 16463, 16465, 16466, 16467, 16468, 16469, 16470, 16471, 16472, 16473, 16474, 16475, 16476, 16477, 16478, 16480, 16482, 16483, 16484, 16489, 16490, 16491, 16493, 16494, 16495, 16498, 16500, 16501, 16502, 16503, 16504, 16505, 16506, 16507, 16508, 16509, 16510, + 16511, 16512, 16513, 16514, 16515, 16517, 16518, 16519, 16520, 16580, 16581, 16583, 16586, 16587, 16588, 16594, 16597, 16598, 16599, 16600, 16601, 16602, 16604, 16609, 16610, 16611, 16615, 16616, 16617, 16618, 16619, 16620, 16625, 16626, 16627, 16628, 16629, 16630, 16631, 16632, 16633, 16634, 16636, 16658, + 16659, 16660, 16664, 16665, 16666, 16671, 16672, 16673, 16674, 16675, 16676, 16678, 16679, 16681, 16682, 16683, 16685, 16686, 16687, 16688, 16689, 16690, 16692, 16693, 16695, 16697, 16698, 16699, 16700, 16701, 16702, 16704, 16709, 16710, 16711, 16712, 16713, 16715, 16716, 16717, 16718, 16719, 16720, 16721, + 16722, 16723, 16726, 16727, 16728, 16729, 16730, 16731, 16732, 16733, 16734, 16736, 16738, 16742, 16743, 16744, 16746, 16747, 16748, 16749, 16750, 16751, 16752, 16753, 16754, 16755, 16756, 16757, 16758, 16759, 16761, 16762, 16763, 16765, 16766, 16767, 16768, 16769, 16770, 16771, 16772 +].each{ runnum -> + + System.out.println("test run $run") + + // loop over QA bins for this run + for(int binnum = 0; binnum <= qa_third_party->GetMaxBinnum(runnum); binnum++) { + + // skip non-existent bin numbers (required since old QADBs' bin numbers are multiples of 5) + if(!qa_third_party.hasBinnum(runnum, binnum)) { continue } + if(debug) { System.out.println("debug: test binnum $binnum") } + + // we need an event number to query the QADBs + qa_third_party.queryByBinnum(runnum, binnum) + def evnum = (qa_third_party.getEvnumMin() + qa_third_party.getEvnumMax()) / 2 + + // test equivelance of `OkForAsymmetry` and the general user method (`Pass`) + def pass_qa_general = qa.pass(runnum, evnum) + def pass_qa_deprecated = qa_deprecated.OkForAsymmetry(runnum, evnum) + if(debug) { System.out.println("debug: $pass_qa_general =?= $pass_qa_deprecated") } + assert pass_qa_general == pass_qa_deprecated + } + + System.out.println('=> test passed.') +} From f7296294c1ad23b0b476e7a257fd88f49ab43a2c Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Sun, 15 Sep 2024 21:51:32 -0400 Subject: [PATCH 09/26] fix: make `testOkForAsymmetry` work... ... but it still consumes way too much memory... wontfix, since will be deprecated soon --- src/clasqa/QADB.groovy | 24 +++++++++++++----------- src/examples/dumpQADB.groovy | 2 +- src/tests/testCharge.groovy | 2 +- src/tests/testDumpQADB.groovy | 2 +- src/tests/testOkForAsymmetry.groovy | 11 +++++++---- 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/clasqa/QADB.groovy b/src/clasqa/QADB.groovy index 57418a9..f806996 100644 --- a/src/clasqa/QADB.groovy +++ b/src/clasqa/QADB.groovy @@ -2,6 +2,7 @@ package clasqa import groovy.json.JsonSlurper import groovy.json.JsonOutput +import groovy.json.JsonParserType import clasqa.Tools class QADB { @@ -30,7 +31,7 @@ class QADB { // concatenate trees qaTree = [:] chargeTree = [:] - slurper = new JsonSlurper() + slurper = new JsonSlurper().setType(JsonParserType.INDEX_OVERLAY) def dbDir = new File(dbDirN) def dbFilter = ~/.*Tree.json$/ def slurpAction = { tree,branch -> @@ -108,13 +109,14 @@ class QADB { chargeCountedFiles = [] dep_warned_Golden = false dep_warned_OkForAsymmetry = false + allowMiscBitList = [] } //............................... // deprecation warnings //``````````````````````````````` private void deprecationGuidance() { - System.err.print("""| INSTEAD: use the general methods + System.err.print('''| INSTEAD: use the general methods | - use `QADB::checkForDefect` to choose which defects you want | to filter out, then use `QADB::pass` on each event | - for runs with the `Misc` defect bit (bit 5) assigned: @@ -123,7 +125,7 @@ class QADB { | - use `QADB::allowMiscBit` to ignore the `Misc` bit for certain | runs that you want to allow in your analysis (`OkForAsymmetry` | internally does this for a specific list of RG-A runs) -""") +''') } private void warningBanner(boolean first) { @@ -143,14 +145,14 @@ class QADB { if(!dep_warned_Golden) { dep_warned_Golden = true warningBanner(true) - System.err.print("""| WARNING: `QADB::golden` is DEPRECATED + System.err.print('''| WARNING: `QADB::golden` is DEPRECATED | - you may still use this method, but since many more defect bits have been | defined, and "Golden" means "no defect bits set", you may find that | requiring your data to be "Golden" is too strict for your analysis | - NOTE: QADBs for Run Groups A, B, K, and M for Pass1 data only use | defect bits 0 to 9, whereas newer QADBs define many more bits | - in some cases, none of the data are "Golden" -""") +''') deprecationGuidance() warningBanner(false) } @@ -168,16 +170,16 @@ class QADB { if(!dep_warned_OkForAsymmetry) { dep_warned_OkForAsymmetry = true warningBanner(true) - System.err.print("""| WARNING: `QADB::OkForAsymmetry` is DEPRECATED + System.err.print('''| WARNING: `QADB::OkForAsymmetry` is DEPRECATED | - you may still use this method, but `OkForAsymmetry` does | not include NEW defect bits that have been recently defined -""") +''') deprecationGuidance() - System.err.print("""| EXAMPLE: + System.err.print('''| EXAMPLE: | - see '$QADB/src/tests/testOkForAsymmetry.groovy' for a | preferred, equivalent implementation; from there, you may | customize your QA criteria and use the new defect bits -""") +''') warningBanner(false) } @@ -401,8 +403,8 @@ class QADB { // check if this bin number exists public boolean hasBinnum(int runnum_, int binnum_) { - if(qaTree.containsKey("$runnum_")) { - return qaTree["$runnum_"].containsKey("$binnum_") + if(qaTree["$runnum_"] != null) { + return qaTree["$runnum_"]["$binnum_"] != null } return false } diff --git a/src/examples/dumpQADB.groovy b/src/examples/dumpQADB.groovy index 7b09b3a..7dedcc4 100644 --- a/src/examples/dumpQADB.groovy +++ b/src/examples/dumpQADB.groovy @@ -27,7 +27,7 @@ QADB qa = new QADB() int evnum for(int filenum=0; filenum<=qa.getMaxBinnum(runnum); filenum++) { // skip non-existent bin numbers (required since old QADBs' bin numbers are multiples of 5) - if(qa.hasBinnum(runnum, filenum)) { continue } + if(!qa.hasBinnum(runnum, filenum)) { continue } sep("=",50) println "FILE NUMBER $filenum" diff --git a/src/tests/testCharge.groovy b/src/tests/testCharge.groovy index 7c07488..3edd667 100644 --- a/src/tests/testCharge.groovy +++ b/src/tests/testCharge.groovy @@ -36,7 +36,7 @@ runnumList.each{ runnum -> for(int filenum=0; filenum<=qa.getMaxBinnum(runnum); filenum++) { // skip non-existent bin numbers (required since old QADBs' bin numbers are multiples of 5) - if(qa.hasBinnum(runnum, filenum)) { continue } + if(!qa.hasBinnum(runnum, filenum)) { continue } // query by file number qa.queryByBinnum(runnum,filenum) diff --git a/src/tests/testDumpQADB.groovy b/src/tests/testDumpQADB.groovy index 811a855..0f278cb 100644 --- a/src/tests/testDumpQADB.groovy +++ b/src/tests/testDumpQADB.groovy @@ -35,7 +35,7 @@ def defname int chargeInt for(int filenum=0; filenum<=qa.getMaxBinnum(runnum); filenum++) { // skip non-existent bin numbers (required since old QADBs' bin numbers are multiples of 5) - if(qa.hasBinnum(runnum, filenum)) { continue } + if(!qa.hasBinnum(runnum, filenum)) { continue } sep("=",50) //err("test error print") diff --git a/src/tests/testOkForAsymmetry.groovy b/src/tests/testOkForAsymmetry.groovy index 553814e..dd44747 100644 --- a/src/tests/testOkForAsymmetry.groovy +++ b/src/tests/testOkForAsymmetry.groovy @@ -2,12 +2,13 @@ import clasqa.QADB boolean debug = true +System.out.println("WARNING: run with `-Xmx4096m`") ////////////////////////////////////////////////////////////////////////////////// // the general method requires the user to choose the defects they want // to avoid in their analysis, and a list of runs for which the `Misc` defect bit // should be ignored -System.out.println('Loading QADBs...') +System.out.println('Loading QADBs...\n...1/3...') QADB qa = new QADB() qa.checkForDefect('TotalOutlier') // these choices match the criteria of `OkForAsymmetry` qa.checkForDefect('TerminalOutlier') @@ -30,7 +31,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 +System.out.println('...3/3...') QADB qa_third_party = new QADB() // a third party, only used for DB traversal System.out.println('...done') @@ -89,10 +92,10 @@ System.out.println('...done') 16722, 16723, 16726, 16727, 16728, 16729, 16730, 16731, 16732, 16733, 16734, 16736, 16738, 16742, 16743, 16744, 16746, 16747, 16748, 16749, 16750, 16751, 16752, 16753, 16754, 16755, 16756, 16757, 16758, 16759, 16761, 16762, 16763, 16765, 16766, 16767, 16768, 16769, 16770, 16771, 16772 ].each{ runnum -> - System.out.println("test run $run") + System.out.println("test run $runnum") // loop over QA bins for this run - for(int binnum = 0; binnum <= qa_third_party->GetMaxBinnum(runnum); binnum++) { + for(int binnum = 0; binnum <= qa_third_party.getMaxBinnum(runnum); binnum++) { // skip non-existent bin numbers (required since old QADBs' bin numbers are multiples of 5) if(!qa_third_party.hasBinnum(runnum, binnum)) { continue } @@ -100,7 +103,7 @@ System.out.println('...done') // we need an event number to query the QADBs qa_third_party.queryByBinnum(runnum, binnum) - def evnum = (qa_third_party.getEvnumMin() + qa_third_party.getEvnumMax()) / 2 + def evnum = ((qa_third_party.getEvnumMin() + qa_third_party.getEvnumMax()) / 2).toInteger() // test equivelance of `OkForAsymmetry` and the general user method (`Pass`) def pass_qa_general = qa.pass(runnum, evnum) From 28ca14c79c00762121f2b63f77747855e826154d Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Sun, 15 Sep 2024 21:59:30 -0400 Subject: [PATCH 10/26] fix: test groovy-cpp diff --- srcC/include/QADB.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srcC/include/QADB.h b/srcC/include/QADB.h index bae3e3a..ee6d014 100644 --- a/srcC/include/QADB.h +++ b/srcC/include/QADB.h @@ -189,7 +189,7 @@ namespace QA { private: int runnumMin, runnumMax; - bool verbose = true; + bool verbose = false; std::vector qaJsonList; std::vector chargeJsonList; From c5f371d09db665d40460e523b5654cdaa0277994 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Mon, 16 Sep 2024 20:16:24 -0400 Subject: [PATCH 11/26] doc: strikethrough --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 62edad6..03dd94f 100644 --- a/README.md +++ b/README.md @@ -285,7 +285,7 @@ Documentation for QADB maintenance and revision * run `source environ.sh` * run `bin/makeTables.sh` * run `bin/makeTextFiles.sh` - * update customized QA criteria sets, such as `OkForAsymmetry` + * ~~update customized QA criteria sets, such as `OkForAsymmetry`~~ * update the above table of data sets * use `git status` and `git diff` to review changes, then add and commit to git, and push to the remote branch From 924a678a06040345e964762d4d34696f60092339 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Mon, 16 Sep 2024 20:19:32 -0400 Subject: [PATCH 12/26] doc: one more note --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 03dd94f..8a85da5 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,8 @@ The following tables describe the available datasets in the QADB. The columns ar * `defect`: not `gold` or `silver` * `text/listOfGoldenFiles.txt`: list of files with no defects * `text/summary.txt`: summary table, where for each file the QA criteria result - (`Golden`, `OkForAsymmetry`, etc.) is provided + (`Golden`, `OkForAsymmetry`, etc.) is provided, but note that these QA criteria + are deprecated, in favor users choosing their own criteria * it is also possible to produce `latex` tables; see `util/makeLatexTables.sh` and `util/makeLatexTables2.sh` From cff6f51dffbdbb71f266621d11e6713c22899528 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Tue, 17 Sep 2024 11:16:38 -0400 Subject: [PATCH 13/26] fix: more `file` -> `bin` renames --- README.md | 107 ++++++++++++++++++---------------- src/examples/chargeSum.groovy | 4 +- src/examples/cutCustom.groovy | 2 +- src/examples/dumpQADB.groovy | 22 +++---- srcC/examples/chargeSum.cpp | 4 +- srcC/examples/cutCustom.cpp | 2 +- srcC/examples/cutGolden.cpp | 4 +- srcC/examples/dumpQADB.cpp | 22 +++---- 8 files changed, 87 insertions(+), 80 deletions(-) diff --git a/README.md b/README.md index 8a85da5..5ceb9fa 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ The following tables describe the available datasets in the QADB. The columns ar - _Up-to-Date_: this is the most recent Pass of these data, and the QADB has been updated for it - _Deprecated_: a newer Pass exists for these data, but the QADB for this version is still preserved - _TO DO_: the Pass for these data exist, but the QADB has not yet been updated for it -- **Data files**: the DST files used for the QA +- **Data files**: the input data files used for the QA ### Run Group A @@ -80,30 +80,34 @@ The following tables describe the available datasets in the QADB. The columns ar ## Defect Bit Definitions -* QA information is stored for each DST file, in the form of "defect bits" +* QA information is stored for "QA bin", in the form of "defect bits" * the user needs only the run number and event number to query the QADB - * queries will find the DST file associated with the event, and are only + * queries will find the QA bin associated with the event, and are only performed "as needed" * full dumps of the QADB are also possible, for browsing +* A QA bin is: + * the set of events between a fixed number of scaler readouts (roughly a time bin, although + there are fluctuations in a bin's duration) + * for older QADBs, Run Groups A, B, K, and M of Pass 1 data, the QA bins were DST 5-files * N/F is defined as the electron yield N, normalized by the Faraday Cup charge F; the electron yield is for Forward Detector electrons with `status<0`, unless specified otherwise * The QA checks for outliers of N/F, along with several other miscellaneous criteria - * The term "golden" means that a file has ***no*** defects -* The table below lists the defect bits + * The term "golden" means that a QA bin has ***no*** defects +* The table below lists the defect bits (Example: `defect=0b11000` has defects `SectorLoss` and `LowLiveTime`) | Bit | Name | Description | | --- | --- | --- | | 0 | `TotalOutlier` | outlier N/F, but not terminal, marginal, or sector loss, for FD electron | -| 1 | `TerminalOutlier` | outlier N/F of first or last file of run, not marginal, for FD electron | +| 1 | `TerminalOutlier` | outlier N/F of first or last QA bin of run, not marginal, for FD electron | | 2 | `MarginalOutlier` | marginal outlier N/F, within one standard deviation of cut line, for FD electron | -| 3 | `SectorLoss` | N/F diminished within a FD sector for several consecutive files | +| 3 | `SectorLoss` | N/F diminished within a FD sector for several consecutive QA bins | | 4 | `LowLiveTime` | live time < 0.9 | | 5 | `Misc` | miscellaneous defect, documented as comment | | 6 | `TotalOutlierFT` | outlier N/F, but not terminal, marginal, or `LossFT`, FT electron | -| 7 | `TerminalOutlierFT` | outlier N/F of first or last file of run, not marginal, FT electron | +| 7 | `TerminalOutlierFT` | outlier N/F of first or last QA bin of run, not marginal, FT electron | | 8 | `MarginalOutlierFT` | marginal outlier N/F, within one standard deviation of cut line, FT electron | -| 9 | `LossFT` | N/F diminished within FT for several consecutive files | +| 9 | `LossFT` | N/F diminished within FT for several consecutive QA bins | | 10 | `BSAWrong` | Beam Spin Asymmetry is the wrong sign | | 11 | `BSAUnknown` | Beam Spin Asymmetry is unknown, likely because of low statistics | | 12 | `TSAWrong` | __[not yet used]__ Target Spin Asymmetry is the wrong sign | @@ -131,18 +135,20 @@ The following tables describe the available datasets in the QADB. The columns ar database format; future development plans include considering more efficient formats, such as `SQLlite` * there are also some text files stored in `text/`: + * **NOTE**: since both `OkForAsymmetry` and `Golden` criteria sets have been deprecated, + these text files will no longer be maintained; they are still provided, however * `text/listOfGoldenRuns.txt`: list of runs, each classified as one of the following: - * `gold`: all files have no defects. Note that this is **very strict**, - so not many runs are `gold`, since most runs have at least one file - with a defect; in practice it is better to apply QA cuts per file, + * `gold`: all QA bins have no defects. Note that this is **very strict**, + so not many runs are `gold`, since most runs have at least one QA bin + with a defect; in practice it is better to apply QA cuts per QA bin, using the QADB software - * `silver`: the only defects are terminal outliers (first or last file is + * `silver`: the only defects are terminal outliers (first or last QA bin is an outlier); note that `gold` runs are, by definition, also `silver`. This is also **very strict**: so far, only about half the runs are `silver` * `defect`: not `gold` or `silver` - * `text/listOfGoldenFiles.txt`: list of files with no defects - * `text/summary.txt`: summary table, where for each file the QA criteria result + * `text/listOfGoldenFiles.txt`: list of QA bins with no defects + * `text/summary.txt`: summary table, where for each QA bin the QA criteria result (`Golden`, `OkForAsymmetry`, etc.) is provided, but note that these QA criteria are deprecated, in favor users choosing their own criteria * it is also possible to produce `latex` tables; see @@ -178,9 +184,9 @@ Classes in both C++ and Groovy are provided, for access to the QADB within analy ## Table files Human-readable format of QA result, stored in `qadb/*/*/qaTree.json.table` -* each run begins with the keyword `RUN:`; lines below are for each of that - run's file and its QA result, with the following syntax: - * `run number` `file number` `defect bits` `comment` +* each run begins with the keyword `RUN:`; lines below are for each of that + run's QA bins and its QA result, with the following syntax: + * `run number` `bin number` `defect bits` `comment` * the `defect bits` are listed by name, and the numbers in the `[brackets]` indicate which sectors have that defect * if a comment is included, it will be printed after the defect bits, following the @@ -194,21 +200,21 @@ Human-readable format of QA result, stored in `qadb/*/*/qaTree.json.table` * the format is a tree (nested maps): ``` qaTree.json ─┬─ run number 1 - ├─ run number 2 ─┬─ file number 1 - │ ├─ file number 2 - │ ├─ file number 3 ─┬─ evnumMin - │ │ ├─ evnumMax - │ │ ├─ sectorDefects - │ │ ├─ defect - │ │ └─ comment - │ ├─ file number 4 - │ └─ file number 5 + ├─ run number 2 ─┬─ bin number 1 + │ ├─ bin number 2 + │ ├─ bin number 3 ─┬─ evnumMin + │ │ ├─ evnumMax + │ │ ├─ sectorDefects + │ │ ├─ defect + │ │ └─ comment + │ ├─ bin number 4 + │ └─ bin number 5 ├─ run number 3 └─ run number 4 ``` -* for each file, the following variables are defined: +* for each bin, the following variables are defined: * `evnumMin` and `evnumMax` represent the range of event numbers associated - to this file; use this to map a particular event number to a file number + to this bin; use this to map a particular event number to a bin number * `sectorDefects` is a map with sector number keys paired with lists of associated defect bits * `defect` is a decimal representation of the `OR` of each sector's defect bits, for @@ -220,47 +226,48 @@ qaTree.json ─┬─ run number 1 a similar format: ``` chargeTree.json ─┬─ run number 1 - ├─ run number 2 ─┬─ file number 1 - │ ├─ file number 2 - │ ├─ file number 3 ─┬─ fcChargeMin - │ │ ├─ fcChargeMax - │ │ ├─ ufcChargeMin - │ │ ├─ ufcChargeMax - │ │ └─ nElec ─┬─ sector 1 - │ │ ├─ sector 2 - │ │ ├─ sector 3 - │ │ ├─ sector 4 - │ │ ├─ sector 5 - │ │ └─ sector 6 - │ ├─ file number 4 - │ └─ file number 5 + ├─ run number 2 ─┬─ bin number 1 + │ ├─ bin number 2 + │ ├─ bin number 3 ─┬─ fcChargeMin + │ │ ├─ fcChargeMax + │ │ ├─ ufcChargeMin + │ │ ├─ ufcChargeMax + │ │ └─ nElec ─┬─ sector 1 + │ │ ├─ sector 2 + │ │ ├─ sector 3 + │ │ ├─ sector 4 + │ │ ├─ sector 5 + │ │ └─ sector 6 + │ ├─ bin number 4 + │ └─ bin number 5 ├─ run number 3 └─ run number 4 ``` -* for each file, the following variables are defined: +* for each bin, the following variables are defined: * `fcChargeMin` and `fcChargeMax` represent the minimum and maximum DAQ-gated Faraday cup charge, in nC * `ufcChargeMin` and `ufcChargeMax` represent the minimum and maximum FC charge, but not gated by the DAQ * the difference between the maximum and minimum charge is the accumulated charge - in that file + in that bin * `nElec` lists the number of electrons from each sector # Faraday Cup Charge Access -* the charge is stored in the QADB for each DST file, so that it is possible to +* the charge is stored in the QADB for each QA bin, so that it is possible to determine the amount of accumulated charge for data that satisfy your specified QA criteria. * see `src/examples/chargeSum.groovy` or `srcC/examples/chargeSum.cpp` for usage example in an analysis event loop * call `QADB::AccumulateCharge()` within your event loop, after your QA cuts are satisfied; the QADB instance will keep track of the accumulated charge - you analyzed (accumulation performed per DST file) + you analyzed (accumulation performed per QA bin) * at the end of your event loop, the total accumulated charge you analyzed is given by `QADB::getAccumulatedCharge()` -* note: for Pass 1 QA results, we find some evidence that the charge from file to file may slightly overlap, - or there may be gaps in the accumulated charge between each file; the former leads to +* note: for Pass 1 QA results for Run Groups A, B, K, and M, we find some + evidence that the charge from bin to bin may slightly overlap, + or there may be gaps in the accumulated charge between each bin; the former leads to a slight over-counting and the latter leads to a slight under-counting * for RGK, we find the correction to this issue would be very small (no more than the order of 0.1%) @@ -286,7 +293,7 @@ Documentation for QADB maintenance and revision * run `source environ.sh` * run `bin/makeTables.sh` * run `bin/makeTextFiles.sh` - * ~~update customized QA criteria sets, such as `OkForAsymmetry`~~ + * ~~update customized QA criteria sets, such as `OkForAsymmetry`~~ this function is no longer maintained * update the above table of data sets * use `git status` and `git diff` to review changes, then add and commit to git, and push to the remote branch diff --git a/src/examples/chargeSum.groovy b/src/examples/chargeSum.groovy index e127734..ad9607c 100644 --- a/src/examples/chargeSum.groovy +++ b/src/examples/chargeSum.groovy @@ -46,8 +46,8 @@ while(reader.hasEvent()) { // accumulate charge; note that although the call to // QADB::accumulateCharge() charge happens for each - // event within a DST file that passed the QA cuts, that - // file's charge will only be accumulated once, so + // event within a QA bin that passed the QA cuts, that + // bin's charge will only be accumulated once, so // overcounting is not possible qa.accumulateCharge() diff --git a/src/examples/cutCustom.groovy b/src/examples/cutCustom.groovy index ad870dc..ec1457c 100644 --- a/src/examples/cutCustom.groovy +++ b/src/examples/cutCustom.groovy @@ -23,7 +23,7 @@ QADB qa = new QADB() // custom QA cut definition // - decide which defects you want to check for; an event will not pass -// the QA cut if the associated file has any of the specified defects +// the QA cut if the associated bin has any of the specified defects // - set to true to check the bit // - set to false to ignore the bit (by default, all bits are ignored) qa.checkForDefect('TotalOutlier',false) diff --git a/src/examples/dumpQADB.groovy b/src/examples/dumpQADB.groovy index 7dedcc4..93b5f39 100644 --- a/src/examples/dumpQADB.groovy +++ b/src/examples/dumpQADB.groovy @@ -1,7 +1,7 @@ // dump QADB data for a specified run; this demonstrates access to the various // data stored in QADB // - this program does not require a HIPO file or clas12root; it only loops -// through the QADB itself, performing lookup by file number +// through the QADB itself, performing lookup by bin number // - you can specify a run number as an argument // imports @@ -23,26 +23,26 @@ QADB qa = new QADB() //QADB qa = new QADB(5000,5500); -// loop through files +// loop through QA bins int evnum -for(int filenum=0; filenum<=qa.getMaxBinnum(runnum); filenum++) { +for(int binnum=0; binnum<=qa.getMaxBinnum(runnum); binnum++) { // skip non-existent bin numbers (required since old QADBs' bin numbers are multiples of 5) - if(!qa.hasBinnum(runnum, filenum)) { continue } + if(!qa.hasBinnum(runnum, binnum)) { continue } sep("=",50) - println "FILE NUMBER $filenum" + println "BIN NUMBER $binnum" - // perform the lookup, by filenum - if(qa.queryByBinnum(runnum,filenum)) { + // perform the lookup, by binnum + if(qa.queryByBinnum(runnum,binnum)) { - // we need an event number within this file, to pass to QA criteria + // we need an event number within this QA bin, to pass to QA criteria // checking methods, such as Golden; no additional Query will be called evnum = qa.getEvnumMin(); - // print whether this file passes some QA cuts + // print whether this bin passes some QA cuts if(qa.golden(runnum,evnum)) { - println "- GOLDEN FILE!" + println "- GOLDEN BIN!" } else { - println "- not golden: file has defects" + println "- not golden: bin has defects" print (qa.OkForAsymmetry(runnum,evnum) ? "- OK" : "- NOT OK") println " for asymmetry analysis" } diff --git a/srcC/examples/chargeSum.cpp b/srcC/examples/chargeSum.cpp index fbf499b..b30bdd6 100644 --- a/srcC/examples/chargeSum.cpp +++ b/srcC/examples/chargeSum.cpp @@ -54,8 +54,8 @@ int main(int argc, char** argv) { // accumulate charge; note that although the call to // QADB::accumulateCharge() charge happens for each - // event within a DST file that passed the QA cuts, that - // file's charge will only be accumulated once, so + // event within a QA bin that passed the QA cuts, that + // bin's charge will only be accumulated once, so // overcounting is not possible qa->AccumulateCharge(); diff --git a/srcC/examples/cutCustom.cpp b/srcC/examples/cutCustom.cpp index 1aa6af1..76dff83 100644 --- a/srcC/examples/cutCustom.cpp +++ b/srcC/examples/cutCustom.cpp @@ -34,7 +34,7 @@ int main(int argc, char** argv) { // custom QA cut definition // - decide which defects you want to check for; an event will not pass - // the QA cut if the associated file has any of the specified defects + // the QA cut if the associated QA bin has any of the specified defects // - set to true to check the bit // - set to false to ignore the bit (by default, all bits are ignored) qa->CheckForDefect("TotalOutlier",false); diff --git a/srcC/examples/cutGolden.cpp b/srcC/examples/cutGolden.cpp index c273537..f81b281 100644 --- a/srcC/examples/cutGolden.cpp +++ b/srcC/examples/cutGolden.cpp @@ -1,5 +1,5 @@ -// demonstrates how to select events from golden files only, which -// are files that have no defect +// demonstrates how to select events from golden bins only, which +// are bins that have no defect // - you must specify a hipo file as an argument #include diff --git a/srcC/examples/dumpQADB.cpp b/srcC/examples/dumpQADB.cpp index 3cd62ae..6f6682c 100644 --- a/srcC/examples/dumpQADB.cpp +++ b/srcC/examples/dumpQADB.cpp @@ -1,7 +1,7 @@ // dump QADB data for a specified run; this demonstrates access to the various // data stored in QADB // - this program does not require a HIPO file or clas12root; it only loops -// through the QADB itself, performing lookup by file number +// through the QADB itself, performing lookup by bin number // - you can specify a run number as an argument #include @@ -31,26 +31,26 @@ int main(int argc, char ** argv) { //QADB * qa = new QADB(5000,5500); - // loop through files + // loop through QA bins int evnum; - for(int filenum=0; filenum<=qa->GetMaxBinnum(runnum); filenum++) { + for(int binnum=0; binnum<=qa->GetMaxBinnum(runnum); binnum++) { // skip non-existent bin numbers (required since old QADBs' bin numbers are multiples of 5) - if(!qa->HasBinnum(runnum, filenum)) continue; + if(!qa->HasBinnum(runnum, binnum)) continue; sep("=",50); - cout << "FILE NUMBER " << filenum << endl; + cout << "BIN NUMBER " << binnum << endl; - // perform the lookup, by filenum - if(qa->QueryByBinnum(runnum,filenum)) { + // perform the lookup, by binnum + if(qa->QueryByBinnum(runnum,binnum)) { - // we need an event number within this file, to pass to QA criteria + // we need an event number within this bin, to pass to QA criteria // checking methods, such as Golden; no additional Query will be called evnum = qa->GetEvnumMin(); - // print whether this file passes some QA cuts + // print whether this bin passes some QA cuts if(qa->Golden(runnum,evnum)) { - cout << "- GOLDEN FILE!" << endl; + cout << "- GOLDEN BIN!" << endl; } else { - cout << "- not golden: file has defects" << endl; + cout << "- not golden: bin has defects" << endl; cout << (qa->OkForAsymmetry(runnum,evnum) ? "- OK" : "- NOT OK"); cout << " for asymmetry analysis" << endl; }; From 2125005d9a6382d8c10ad4d9385b945c0640c141 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Tue, 17 Sep 2024 11:23:51 -0400 Subject: [PATCH 14/26] doc: some grammar fixes --- qadb/defect_definitions.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/qadb/defect_definitions.json b/qadb/defect_definitions.json index 32b833b..ba15a79 100644 --- a/qadb/defect_definitions.json +++ b/qadb/defect_definitions.json @@ -2,25 +2,25 @@ { "bit_number": 0, "bit_name": "TotalOutlier", - "description": "Outlier N/F, but not terminal, marginal, or sector loss, for FD electron", + "description": "Outlier FD electron N/F, but not terminal, marginal, or sector loss", "documentation": "" }, { "bit_number": 1, "bit_name": "TerminalOutlier", - "description": "Outlier N/F of first or last QA bin of run, not marginal, for FD electron", + "description": "Outlier FD electron N/F of first or last QA bin of run, not marginal", "documentation": "" }, { "bit_number": 2, "bit_name": "MarginalOutlier", - "description": "Marginal outlier N/F, within one standard deviation of cut line, for FD electron", + "description": "Marginal FD electron outlier N/F, within one standard deviation of cut line", "documentation": "" }, { "bit_number": 3, "bit_name": "SectorLoss", - "description": "N/F diminished within a FD sector for several consecutive QA bin", + "description": "FD electron N/F diminished for several consecutive QA bins", "documentation": "For older datasets (RG-A,B,K,M pass 1), this bit replaced the assignment of TotalOutlier, TerminalOutlier, and MarginalOutlier; newer datasets only add the SectorLoss bit and do not remove the outlier bits." }, { @@ -38,25 +38,25 @@ { "bit_number": 6, "bit_name": "TotalOutlierFT", - "description": "Outlier N/F, but not terminal, marginal, or `LossFT`, FT electron", + "description": "Outlier FT electron N/F, but not terminal, marginal, or `LossFT`", "documentation": "cf. TotalOutlier." }, { "bit_number": 7, "bit_name": "TerminalOutlierFT", - "description": "Outlier N/F of first or last QA bin of run, not marginal, FT electron", + "description": "Outlier FT electron N/F of first or last QA bin of run, not marginal", "documentation": "cf. TerminalOutlier." }, { "bit_number": 8, "bit_name": "MarginalOutlierFT", - "description": "Marginal outlier N/F, within one standard deviation of cut line, FT electron", + "description": "Marginal FT electron outlier N/F, within one standard deviation of cut line", "documentation": "cf. MarginalOutlier." }, { "bit_number": 9, "bit_name": "LossFT", - "description": "N/F diminished within FT for several consecutive QA bins", + "description": "FT electron N/F diminished within FT for several consecutive QA bins", "documentation": "cf. SectorLoss." }, { From 046063b96be2f39b891f0daadbce674ea1ba2c67 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Tue, 17 Sep 2024 13:55:27 -0400 Subject: [PATCH 15/26] doc: improve the main README --- README.md | 164 ++++++++++++++++++++++-------------------------------- 1 file changed, 66 insertions(+), 98 deletions(-) diff --git a/README.md b/README.md index 5ceb9fa..6c7519e 100644 --- a/README.md +++ b/README.md @@ -80,21 +80,18 @@ The following tables describe the available datasets in the QADB. The columns ar ## Defect Bit Definitions -* QA information is stored for "QA bin", in the form of "defect bits" +* QA information is stored for each **QA bin**, in the form of **defect bits** * the user needs only the run number and event number to query the QADB - * queries will find the QA bin associated with the event, and are only - performed "as needed" - * full dumps of the QADB are also possible, for browsing -* A QA bin is: +* A **QA bin** is: * the set of events between a fixed number of scaler readouts (roughly a time bin, although there are fluctuations in a bin's duration) * for older QADBs, Run Groups A, B, K, and M of Pass 1 data, the QA bins were DST 5-files -* N/F is defined as the electron yield N, normalized by the Faraday Cup charge F; the - electron yield is for Forward Detector electrons with `status<0`, unless specified otherwise - * The QA checks for outliers of N/F, along with several other miscellaneous criteria - * The term "golden" means that a QA bin has ***no*** defects -* The table below lists the defect bits - (Example: `defect=0b11000` has defects `SectorLoss` and `LowLiveTime`) +* A **defect bit** is: + * a bit (of a binary number) that is `1` if the QA bin exhibits the corresponding defect or `0` if not + * each defect bit corresponds to a different defect, as shown in the table below + * many defects check the value of N/F, defined as the trigger electron yield N, normalized by the DAQ-gated Faraday Cup charge F + +### Table of Defect Bits | Bit | Name | Description | | --- | --- | --- | @@ -122,62 +119,35 @@ The following tables describe the available datasets in the QADB. The columns ar # Database Access +You may access the QADB in many ways: + ## Text Access - * this only provides human-readable access; see below for access with - common programming languages and software used at CLAS - * using the Groovy or C++ access is the preferred method to apply QA cuts - * the human-readable tables are stored in `qadb/*/qaTree.json.table`; see - the section *QA data storage, Table files* below for details for how - to read these files - * QADB JSON files are stored in `qadb/*/qaTree.json` - * the JSON files are the QADB files - * for now we use JSON out of convenience, although it's not a proper - database format; future development plans include considering more - efficient formats, such as `SQLlite` - * there are also some text files stored in `text/`: - * **NOTE**: since both `OkForAsymmetry` and `Golden` criteria sets have been deprecated, - these text files will no longer be maintained; they are still provided, however - * `text/listOfGoldenRuns.txt`: list of runs, each classified as one of the following: - * `gold`: all QA bins have no defects. Note that this is **very strict**, - so not many runs are `gold`, since most runs have at least one QA bin - with a defect; in practice it is better to apply QA cuts per QA bin, - using the QADB software - * `silver`: the only defects are terminal outliers (first or last QA bin is - an outlier); note that `gold` runs are, by definition, also `silver`. - This is also **very strict**: so far, only about half the runs are - `silver` - * `defect`: not `gold` or `silver` - * `text/listOfGoldenFiles.txt`: list of QA bins with no defects - * `text/summary.txt`: summary table, where for each QA bin the QA criteria result - (`Golden`, `OkForAsymmetry`, etc.) is provided, but note that these QA criteria - are deprecated, in favor users choosing their own criteria - * it is also possible to produce `latex` tables; see - `util/makeLatexTables.sh` and `util/makeLatexTables2.sh` +* human-readable tables are stored in `qadb/*/qaTree.json.table`; see + the section *QA data storage, Table files* below for details for how + to read these files +* QADB JSON files are stored in `qadb/*/qaTree.json` +* there are also some text files stored in `text/`, but they are no longer maintained ## Software Access -Classes in both C++ and Groovy are provided, for access to the QADB within analysis code - -### Groovy Access -* first set environment variables by running `source environ.sh` - * `bash` is recommended, though if you choose to use `tcsh`, run - instead `source environ.csh` -* then proceed following `src/README.md` - -### C++ Access -* __NOTE:__ [`clas12root`](https://github.com/JeffersonLab/clas12root) now provides - access to the QADB -* needs [`rapidjson`](https://github.com/Tencent/rapidjson/) library; - it is a submodule of this repository and can be obtained by - ``` - git clone --recurse-submodules https://github.com/JeffersonLab/clas12-qadb.git - ``` -* first set environment variables by running `source environ.sh` - * alternatively, set environment variable `$QADB` to the path to this - `clas12-qadb` repository - * `bash` is recommended, though if you choose to use `tcsh`, run - instead `source environ.csh` -* then proceed following `srcC/README.md` +Classes in both C++ and Groovy are provided, for access to the QADB within analysis code. +In either case, you need environment variables; if you are using an `ifarm` build, they +have already been set for you, otherwise: +```bash +source environ.sh # for bash, zsh +source environ.csh # for csh, tcsh +``` +Then: +- for Groovy, follow [`src/README.md`](/src/README.md) +- for C++, follow [`srcC/README.md`](/srcC/README.md) + +> [IMPORTANT] C++ access needs [`rapidjson`](https://github.com/Tencent/rapidjson/), provided as a +> submodule of this repository in [`srcC/rapidjson`](/srcC/rapidjson). If this directory +> is empty, you can clone the submodule by running +> ```bash +> git submodule update --init --recursive +> ``` + # Data Storage @@ -185,19 +155,17 @@ Classes in both C++ and Groovy are provided, for access to the QADB within analy ## Table files Human-readable format of QA result, stored in `qadb/*/*/qaTree.json.table` * each run begins with the keyword `RUN:`; lines below are for each of that - run's QA bins and its QA result, with the following syntax: - * `run number` `bin number` `defect bits` `comment` - * the `defect bits` are listed by name, and the numbers in the `[brackets]` - indicate which sectors have that defect - * if a comment is included, it will be printed after the defect bits, following the - `::` delimiter -* these table files can be generated from the JSON files using `bin/makeTables.sh` + run's QA bins and their QA results, with the following syntax: + * `run_number bin_number defect_bits :: comment` + * defect bits have the following form: `bit_number-defect_name[list_of_sectors]`, + and `[all]` means that all 6 sectors have this defect + * comments are usually associated with `Misc` defects, but not always ## JSON files ### `qaTree.json` * The QADB itself is stored as JSON files in `qadb/*/*/qaTree.json` -* the format is a tree (nested maps): +* the format is a tree: ``` qaTree.json ─┬─ run number 1 ├─ run number 2 ─┬─ bin number 1 @@ -214,11 +182,11 @@ qaTree.json ─┬─ run number 1 ``` * for each bin, the following variables are defined: * `evnumMin` and `evnumMax` represent the range of event numbers associated - to this bin; use this to map a particular event number to a bin number + with this bin; use this to map a particular event number to a bin number * `sectorDefects` is a map with sector number keys paired with lists of associated defect bits * `defect` is a decimal representation of the `OR` of each sector's defect bits, for - example, `11=0b1011` means the `OR` of the defect bit lists is `[0,1,3]` + example, `11=0b1011` means that the `OR` of the defect bit lists is `[0,1,3]` * `comment` stores an optional comment regarding the QA result ### `chargeTree.json` @@ -258,24 +226,22 @@ chargeTree.json ─┬─ run number 1 * the charge is stored in the QADB for each QA bin, so that it is possible to determine the amount of accumulated charge for data that satisfy your specified QA criteria. -* see `src/examples/chargeSum.groovy` or `srcC/examples/chargeSum.cpp` for - usage example in an analysis event loop +* see [`chargeSum.groovy`](/src/examples/chargeSum.groovy) or [`chargeSum.cpp`](/srcC/examples/chargeSum.cpp) + for usage example in an analysis event loop; basically: * call `QADB::AccumulateCharge()` within your event loop, after your QA cuts are satisfied; the QADB instance will keep track of the accumulated charge you analyzed (accumulation performed per QA bin) * at the end of your event loop, the total accumulated charge you analyzed is - given by `QADB::getAccumulatedCharge()` -* note: for Pass 1 QA results for Run Groups A, B, K, and M, we find some - evidence that the charge from bin to bin may slightly overlap, - or there may be gaps in the accumulated charge between each bin; the former leads to - a slight over-counting and the latter leads to a slight under-counting - * for RGK, we find the correction to this issue would be very small - (no more than the order of 0.1%) - * corrections of this issue are therefore not applied - * if you require higher precision of the accumulated charge than what is - provided, contact the developers to discuss an implementation of the - corrections + given by `QADB::GetAccumulatedCharge()` +> [!CAUTION] +> For Pass 1 QA results for Run Groups A, B, K, and M, we find some +> evidence that the charge from bin to bin may slightly overlap, +> or there may be gaps in the accumulated charge between each bin; the former leads to +> a slight over-counting and the latter leads to a slight under-counting +> * this issue is why we transitioned from using DST files as QA bins to using +> nth scaler readouts as bin boundaries +> * corrections of this issue to these older QADBs will not be applied # QADB Management @@ -283,20 +249,19 @@ chargeTree.json ─┬─ run number 1 Documentation for QADB maintenance and revision ## Adding to or revising the QADB -* the QADB files are produced by [`clasqa` timeline-production code](https://github.com/c-dilks/clasqa); - if you have produced QA results for a new data set, and would like to add +* the QADB files are produced by [`clas12-timeline`](https://github.com/JeffersonLab/clas12-timeline) +* if you have produced QA results for a new data set, and would like to add them to the QADB, or if you would like to update results for an existing dataset, follow the following procedure: - * `mkdir qadb/pass${pass}/${dataset}/`, then copy the final `qaTree.json` and + * [ ] `mkdir qadb/pass${pass}/${dataset}/`, then copy the final `qaTree.json` and `chargeTree.json` to that directory - * add/update a symlink to this dataset in `qadb/latest`, if this is a new Pass - * run `source environ.sh` - * run `bin/makeTables.sh` - * run `bin/makeTextFiles.sh` - * ~~update customized QA criteria sets, such as `OkForAsymmetry`~~ this function is no longer maintained - * update the above table of data sets - * use `git status` and `git diff` to review changes, then add and commit to - git, and push to the remote branch + * [ ] add/update a symlink to this dataset in `qadb/latest`, if this is a new Pass + * [ ] run `source environ.sh` and: + * [ ] run `bin/makeTables.sh` + * [ ] run `bin/makeTextFiles.sh` + * [x] ~~update customized QA criteria sets, such as `OkForAsymmetry`~~ this function is no longer maintained + * [ ] update the above table of data sets + * [ ] submit a pull request ## Adding new defect bits * defect bits must be added in the following places: @@ -309,9 +274,12 @@ Documentation for QADB maintenance and revision * `srcC/examples/dumpQADB.cpp` (optional) * Documentation: * bits table in `README.md` + * `qadb/defect_definitions.json` # Contributions -All contributions are welcome, whether to the code, examples, documentation, or the QADB itself. You are welcome to open an issue and/or a pull request. If the maintainer(s) do not respond in a reasonable time, send them an email. +All contributions are welcome, whether to the code, examples, documentation, or +the QADB itself. You are welcome to open an issue and/or a pull request. If the +maintainer(s) do not respond in a reasonable time, send them an email. From 8577eb8e2241386b461bc8b26ebcdccc88829fdf Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Tue, 17 Sep 2024 14:34:26 -0400 Subject: [PATCH 16/26] doc: automate bit table generation --- README.md | 50 +++++++++++++++++++----------------- bin/makeDefectMarkdown.rb | 31 ++++++++++++++++++++++ qadb/defect_definitions.json | 34 ++++++++++++------------ 3 files changed, 74 insertions(+), 41 deletions(-) create mode 100755 bin/makeDefectMarkdown.rb diff --git a/README.md b/README.md index 6c7519e..0a677af 100644 --- a/README.md +++ b/README.md @@ -93,28 +93,30 @@ The following tables describe the available datasets in the QADB. The columns ar ### Table of Defect Bits -| Bit | Name | Description | -| --- | --- | --- | -| 0 | `TotalOutlier` | outlier N/F, but not terminal, marginal, or sector loss, for FD electron | -| 1 | `TerminalOutlier` | outlier N/F of first or last QA bin of run, not marginal, for FD electron | -| 2 | `MarginalOutlier` | marginal outlier N/F, within one standard deviation of cut line, for FD electron | -| 3 | `SectorLoss` | N/F diminished within a FD sector for several consecutive QA bins | -| 4 | `LowLiveTime` | live time < 0.9 | -| 5 | `Misc` | miscellaneous defect, documented as comment | -| 6 | `TotalOutlierFT` | outlier N/F, but not terminal, marginal, or `LossFT`, FT electron | -| 7 | `TerminalOutlierFT` | outlier N/F of first or last QA bin of run, not marginal, FT electron | -| 8 | `MarginalOutlierFT` | marginal outlier N/F, within one standard deviation of cut line, FT electron | -| 9 | `LossFT` | N/F diminished within FT for several consecutive QA bins | -| 10 | `BSAWrong` | Beam Spin Asymmetry is the wrong sign | -| 11 | `BSAUnknown` | Beam Spin Asymmetry is unknown, likely because of low statistics | -| 12 | `TSAWrong` | __[not yet used]__ Target Spin Asymmetry is the wrong sign | -| 13 | `TSAUnknown` | __[not yet used]__ Target Spin Asymmetry is unknown, likely because of low statistics | -| 14 | `DSAWrong` | __[not yet used]__ Double Spin Asymmetry is the wrong sign | -| 15 | `DSAUnknown` | __[not yet used]__ Double Spin Asymmetry is unknown, likely because of low statistics | -| 16 | `ChargeHigh` | FC Charge is abnormally high | -| 17 | `ChargeNegative` | FC Charge is negative | -| 18 | `ChargeUnknown` | FC Charge is unknown; the first and last time bins always have this defect | -| 19 | `PossiblyNoBeam` | Both N and F are low, indicating the beam was possibly off | + +| Bit | Name | Description | Additional Notes | +| --- | --- | --- | --- | +| 0 | `TotalOutlier` | Outlier FD electron N/F, but not `TerminalOutlier` or `MarginalOutlier` | | +| 1 | `TerminalOutlier` | Outlier FD electron N/F of first or last QA bin of run | | +| 2 | `MarginalOutlier` | Marginal FD electron outlier N/F, within one standard deviation of cut line | | +| 3 | `SectorLoss` | FD electron N/F diminished for several consecutive QA bins | For older datasets (RG-A,B,K,M pass 1), this bit _replaced_ the assignment of `TotalOutlier`, `TerminalOutlier`, and `MarginalOutlier`; newer datasets only add the `SectorLoss` bit and do not remove the outlier bits. | +| 4 | `LowLiveTime` | Live time < 0.9 | This assignment of this bit may be correlated with a low fraction of events with a defined (nonzero) helicity. | +| 5 | `Misc` | Miscellaneous defect, documented as comment | This bit is often assigned to all QA bins within a run, but in some cases, may only be assigned to the relevant QA bins. The analyzer must decide whether data assigned with the Misc bit should be excluded from their analysis; the comment is provided for this purpose. Analyzers are also encouraged to check the Hall B log book for further details. | +| 6 | `TotalOutlierFT` | Outlier FT electron N/F, but not `TerminalOutlierFT` or `MarginalOutlierFT` | _cf_. `TotalOutlier`. | +| 7 | `TerminalOutlierFT` | Outlier FT electron N/F of first or last QA bin of run | _cf_. `TerminalOutlier`. | +| 8 | `MarginalOutlierFT` | Marginal FT electron outlier N/F, within one standard deviation of cut line | _cf_. `MarginalOutlier`. | +| 9 | `LossFT` | FT electron N/F diminished within FT for several consecutive QA bins | _cf_. `SectorLoss`. | +| 10 | `BSAWrong` | Beam Spin Asymmetry is the wrong sign | This bit is assigned per run. The asymmetry is significant, but the opposite sign than expected; analyzers must therefore _flip_ the helicity sign. | +| 11 | `BSAUnknown` | Beam Spin Asymmetry is unknown, likely because of low statistics | This bit is assigned per run. There are not enough data to determine if the helicity sign is correct for this run. | +| 12 | `TSAWrong` | Target Spin Asymmetry is the wrong sign | __Not yet used.__ | +| 13 | `TSAUnknown` | Target Spin Asymmetry is unknown, likely because of low statistics | __Not yet used.__ | +| 14 | `DSAWrong` | Double Spin Asymmetry is the wrong sign | __Not yet used.__ | +| 15 | `DSAUnknown` | Double Spin Asymmetry is unknown, likely because of low statistics | __Not yet used.__ | +| 16 | `ChargeHigh` | FC Charge is abnormally high | NOTE: the assignment criteria of this bit is still under study. | +| 17 | `ChargeNegative` | FC Charge is negative | The FC charge is calculated from the charge readout at QA bin boundaries. Normally the later charge readout is higher than the earlier; this bit is assigned when the opposite happens. | +| 18 | `ChargeUnknown` | FC Charge is unknown; the first and last time bins _always_ have this defect | QA bin boundaries are at scaler charge readouts. The first QA bin, before any readout, has no initial charge; the last QA bin, after all scaler readouts, has no final charge. Therefore, the first and last QA bins have an unknown, but likely _very small_ charge accumulation. | +| 19 | `PossiblyNoBeam` | Both N and F are low, indicating the beam was possibly off | NOTE: the assignment criteria of this bit is still under study. | + # Database Access @@ -273,8 +275,8 @@ Documentation for QADB maintenance and revision * `srcC/include/QADB.h` * `srcC/examples/dumpQADB.cpp` (optional) * Documentation: - * bits table in `README.md` - * `qadb/defect_definitions.json` + * `qadb/defect_definitions.json`, then use `bin/makeDefectMarkdown.rb` to generate + Markdown table for `README.md` diff --git a/bin/makeDefectMarkdown.rb b/bin/makeDefectMarkdown.rb new file mode 100755 index 0000000..54af3b2 --- /dev/null +++ b/bin/makeDefectMarkdown.rb @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby + +# generates a Markdown table of the defect bits and their descriptions + +require 'json' + +unless ENV.has_key? 'QADB' + $stderr.puts 'you need to source environment variables' + exit 1 +end + +def puts_row(columns) + puts "| #{columns.join ' | '} |" +end + +puts_row ['Bit', 'Name', 'Description', 'Additional Notes'] +puts_row 4.times.map{|i|'---'} + +File.open("#{ENV['QADB']}/qadb/defect_definitions.json") do |defect_file| + defect_defs = JSON.load defect_file + defect_defs.each do |defect_def| + defect_cols = ['bit_number', 'bit_name', 'description', 'documentation'].map do |k| + if k == 'bit_name' + "`#{defect_def[k]}`" + else + defect_def[k].to_s + end + end + puts_row defect_cols + end +end diff --git a/qadb/defect_definitions.json b/qadb/defect_definitions.json index ba15a79..ee35ee8 100644 --- a/qadb/defect_definitions.json +++ b/qadb/defect_definitions.json @@ -2,13 +2,13 @@ { "bit_number": 0, "bit_name": "TotalOutlier", - "description": "Outlier FD electron N/F, but not terminal, marginal, or sector loss", + "description": "Outlier FD electron N/F, but not `TerminalOutlier` or `MarginalOutlier`", "documentation": "" }, { "bit_number": 1, "bit_name": "TerminalOutlier", - "description": "Outlier FD electron N/F of first or last QA bin of run, not marginal", + "description": "Outlier FD electron N/F of first or last QA bin of run", "documentation": "" }, { @@ -21,7 +21,7 @@ "bit_number": 3, "bit_name": "SectorLoss", "description": "FD electron N/F diminished for several consecutive QA bins", - "documentation": "For older datasets (RG-A,B,K,M pass 1), this bit replaced the assignment of TotalOutlier, TerminalOutlier, and MarginalOutlier; newer datasets only add the SectorLoss bit and do not remove the outlier bits." + "documentation": "For older datasets (RG-A,B,K,M pass 1), this bit _replaced_ the assignment of `TotalOutlier`, `TerminalOutlier`, and `MarginalOutlier`; newer datasets only add the `SectorLoss` bit and do not remove the outlier bits." }, { "bit_number": 4, @@ -38,62 +38,62 @@ { "bit_number": 6, "bit_name": "TotalOutlierFT", - "description": "Outlier FT electron N/F, but not terminal, marginal, or `LossFT`", - "documentation": "cf. TotalOutlier." + "description": "Outlier FT electron N/F, but not `TerminalOutlierFT` or `MarginalOutlierFT`", + "documentation": "_cf_. `TotalOutlier`." }, { "bit_number": 7, "bit_name": "TerminalOutlierFT", - "description": "Outlier FT electron N/F of first or last QA bin of run, not marginal", - "documentation": "cf. TerminalOutlier." + "description": "Outlier FT electron N/F of first or last QA bin of run", + "documentation": "_cf_. `TerminalOutlier`." }, { "bit_number": 8, "bit_name": "MarginalOutlierFT", "description": "Marginal FT electron outlier N/F, within one standard deviation of cut line", - "documentation": "cf. MarginalOutlier." + "documentation": "_cf_. `MarginalOutlier`." }, { "bit_number": 9, "bit_name": "LossFT", "description": "FT electron N/F diminished within FT for several consecutive QA bins", - "documentation": "cf. SectorLoss." + "documentation": "_cf_. `SectorLoss`." }, { "bit_number": 10, "bit_name": "BSAWrong", "description": "Beam Spin Asymmetry is the wrong sign", - "documentation": "This bit is assigned per run. The asymmetry is significant, but the opposite sign than expected; analyzers must therefore flip the helicity sign." + "documentation": "This bit is assigned per run. The asymmetry is significant, but the opposite sign than expected; analyzers must therefore _flip_ the helicity sign." }, { "bit_number": 11, "bit_name": "BSAUnknown", "description": "Beam Spin Asymmetry is unknown, likely because of low statistics", - "documentation": "This bit is assigned per run. We do not have enough statistics to determine if the helicity sign is correct." + "documentation": "This bit is assigned per run. There are not enough data to determine if the helicity sign is correct for this run." }, { "bit_number": 12, "bit_name": "TSAWrong", "description": "Target Spin Asymmetry is the wrong sign", - "documentation": "Not yet used." + "documentation": "__Not yet used.__" }, { "bit_number": 13, "bit_name": "TSAUnknown", "description": "Target Spin Asymmetry is unknown, likely because of low statistics", - "documentation": "Not yet used." + "documentation": "__Not yet used.__" }, { "bit_number": 14, "bit_name": "DSAWrong", "description": "Double Spin Asymmetry is the wrong sign", - "documentation": "Not yet used." + "documentation": "__Not yet used.__" }, { "bit_number": 15, "bit_name": "DSAUnknown", "description": "Double Spin Asymmetry is unknown, likely because of low statistics", - "documentation": "Not yet used." + "documentation": "__Not yet used.__" }, { "bit_number": 16, @@ -110,8 +110,8 @@ { "bit_number": 18, "bit_name": "ChargeUnknown", - "description": "FC Charge is unknown; the first and last time bins always have this defect", - "documentation": "QA bin boundaries are at scaler charge readouts. The first QA bin, before any readout, has no initial charge; the last QA bin, after all scaler readouts, has no final charge. Therefore, the first and last QA bins have an unknown, but likely very small charge accumulation." + "description": "FC Charge is unknown; the first and last time bins _always_ have this defect", + "documentation": "QA bin boundaries are at scaler charge readouts. The first QA bin, before any readout, has no initial charge; the last QA bin, after all scaler readouts, has no final charge. Therefore, the first and last QA bins have an unknown, but likely _very small_ charge accumulation." }, { "bit_number": 19, From 97578af48611a7e48e2e41e19ac6f2d5ebe75a56 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Tue, 17 Sep 2024 15:24:16 -0400 Subject: [PATCH 17/26] fix: syntax --- README.md | 2 +- qadb/defect_definitions.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0a677af..247ff60 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ The following tables describe the available datasets in the QADB. The columns ar | 2 | `MarginalOutlier` | Marginal FD electron outlier N/F, within one standard deviation of cut line | | | 3 | `SectorLoss` | FD electron N/F diminished for several consecutive QA bins | For older datasets (RG-A,B,K,M pass 1), this bit _replaced_ the assignment of `TotalOutlier`, `TerminalOutlier`, and `MarginalOutlier`; newer datasets only add the `SectorLoss` bit and do not remove the outlier bits. | | 4 | `LowLiveTime` | Live time < 0.9 | This assignment of this bit may be correlated with a low fraction of events with a defined (nonzero) helicity. | -| 5 | `Misc` | Miscellaneous defect, documented as comment | This bit is often assigned to all QA bins within a run, but in some cases, may only be assigned to the relevant QA bins. The analyzer must decide whether data assigned with the Misc bit should be excluded from their analysis; the comment is provided for this purpose. Analyzers are also encouraged to check the Hall B log book for further details. | +| 5 | `Misc` | Miscellaneous defect, documented as comment | This bit is often assigned to all QA bins within a run, but in some cases, may only be assigned to the relevant QA bins. The analyzer must decide whether data assigned with the `Misc` bit should be excluded from their analysis; the comment is provided for this purpose. Analyzers are also encouraged to check the Hall B log book for further details. | | 6 | `TotalOutlierFT` | Outlier FT electron N/F, but not `TerminalOutlierFT` or `MarginalOutlierFT` | _cf_. `TotalOutlier`. | | 7 | `TerminalOutlierFT` | Outlier FT electron N/F of first or last QA bin of run | _cf_. `TerminalOutlier`. | | 8 | `MarginalOutlierFT` | Marginal FT electron outlier N/F, within one standard deviation of cut line | _cf_. `MarginalOutlier`. | diff --git a/qadb/defect_definitions.json b/qadb/defect_definitions.json index ee35ee8..6e0cb4b 100644 --- a/qadb/defect_definitions.json +++ b/qadb/defect_definitions.json @@ -33,7 +33,7 @@ "bit_number": 5, "bit_name": "Misc", "description": "Miscellaneous defect, documented as comment", - "documentation": "This bit is often assigned to all QA bins within a run, but in some cases, may only be assigned to the relevant QA bins. The analyzer must decide whether data assigned with the Misc bit should be excluded from their analysis; the comment is provided for this purpose. Analyzers are also encouraged to check the Hall B log book for further details." + "documentation": "This bit is often assigned to all QA bins within a run, but in some cases, may only be assigned to the relevant QA bins. The analyzer must decide whether data assigned with the `Misc` bit should be excluded from their analysis; the comment is provided for this purpose. Analyzers are also encouraged to check the Hall B log book for further details." }, { "bit_number": 6, From 57dc185d8d389d8beea9d059947b1e7e82942ce5 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Tue, 17 Sep 2024 15:25:28 -0400 Subject: [PATCH 18/26] fix: grammar --- README.md | 2 +- qadb/defect_definitions.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 247ff60..bca17b7 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ The following tables describe the available datasets in the QADB. The columns ar | 6 | `TotalOutlierFT` | Outlier FT electron N/F, but not `TerminalOutlierFT` or `MarginalOutlierFT` | _cf_. `TotalOutlier`. | | 7 | `TerminalOutlierFT` | Outlier FT electron N/F of first or last QA bin of run | _cf_. `TerminalOutlier`. | | 8 | `MarginalOutlierFT` | Marginal FT electron outlier N/F, within one standard deviation of cut line | _cf_. `MarginalOutlier`. | -| 9 | `LossFT` | FT electron N/F diminished within FT for several consecutive QA bins | _cf_. `SectorLoss`. | +| 9 | `LossFT` | FT electron N/F diminished for several consecutive QA bins | _cf_. `SectorLoss`. | | 10 | `BSAWrong` | Beam Spin Asymmetry is the wrong sign | This bit is assigned per run. The asymmetry is significant, but the opposite sign than expected; analyzers must therefore _flip_ the helicity sign. | | 11 | `BSAUnknown` | Beam Spin Asymmetry is unknown, likely because of low statistics | This bit is assigned per run. There are not enough data to determine if the helicity sign is correct for this run. | | 12 | `TSAWrong` | Target Spin Asymmetry is the wrong sign | __Not yet used.__ | diff --git a/qadb/defect_definitions.json b/qadb/defect_definitions.json index 6e0cb4b..72c858f 100644 --- a/qadb/defect_definitions.json +++ b/qadb/defect_definitions.json @@ -56,7 +56,7 @@ { "bit_number": 9, "bit_name": "LossFT", - "description": "FT electron N/F diminished within FT for several consecutive QA bins", + "description": "FT electron N/F diminished for several consecutive QA bins", "documentation": "_cf_. `SectorLoss`." }, { From 010fe869f6facef8b84396f4045db6a999dc3c96 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Tue, 17 Sep 2024 15:26:23 -0400 Subject: [PATCH 19/26] fix: grammar --- README.md | 2 +- qadb/defect_definitions.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bca17b7..39171a7 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ The following tables describe the available datasets in the QADB. The columns ar | 7 | `TerminalOutlierFT` | Outlier FT electron N/F of first or last QA bin of run | _cf_. `TerminalOutlier`. | | 8 | `MarginalOutlierFT` | Marginal FT electron outlier N/F, within one standard deviation of cut line | _cf_. `MarginalOutlier`. | | 9 | `LossFT` | FT electron N/F diminished for several consecutive QA bins | _cf_. `SectorLoss`. | -| 10 | `BSAWrong` | Beam Spin Asymmetry is the wrong sign | This bit is assigned per run. The asymmetry is significant, but the opposite sign than expected; analyzers must therefore _flip_ the helicity sign. | +| 10 | `BSAWrong` | Beam Spin Asymmetry is the wrong sign | This bit is assigned per run. The asymmetry is significant, but the sign is opposite than expected; analyzers must therefore _flip_ the helicity sign. | | 11 | `BSAUnknown` | Beam Spin Asymmetry is unknown, likely because of low statistics | This bit is assigned per run. There are not enough data to determine if the helicity sign is correct for this run. | | 12 | `TSAWrong` | Target Spin Asymmetry is the wrong sign | __Not yet used.__ | | 13 | `TSAUnknown` | Target Spin Asymmetry is unknown, likely because of low statistics | __Not yet used.__ | diff --git a/qadb/defect_definitions.json b/qadb/defect_definitions.json index 72c858f..325929f 100644 --- a/qadb/defect_definitions.json +++ b/qadb/defect_definitions.json @@ -63,7 +63,7 @@ "bit_number": 10, "bit_name": "BSAWrong", "description": "Beam Spin Asymmetry is the wrong sign", - "documentation": "This bit is assigned per run. The asymmetry is significant, but the opposite sign than expected; analyzers must therefore _flip_ the helicity sign." + "documentation": "This bit is assigned per run. The asymmetry is significant, but the sign is opposite than expected; analyzers must therefore _flip_ the helicity sign." }, { "bit_number": 11, From 844a36d28b6a4b71db14f61fda7ae100738384c6 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Tue, 17 Sep 2024 15:27:20 -0400 Subject: [PATCH 20/26] fix: more grammar --- README.md | 4 ++-- qadb/defect_definitions.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 39171a7..f099b9e 100644 --- a/README.md +++ b/README.md @@ -112,10 +112,10 @@ The following tables describe the available datasets in the QADB. The columns ar | 13 | `TSAUnknown` | Target Spin Asymmetry is unknown, likely because of low statistics | __Not yet used.__ | | 14 | `DSAWrong` | Double Spin Asymmetry is the wrong sign | __Not yet used.__ | | 15 | `DSAUnknown` | Double Spin Asymmetry is unknown, likely because of low statistics | __Not yet used.__ | -| 16 | `ChargeHigh` | FC Charge is abnormally high | NOTE: the assignment criteria of this bit is still under study. | +| 16 | `ChargeHigh` | FC Charge is abnormally high | NOTE: the assignment criteria of this bit are still under study. | | 17 | `ChargeNegative` | FC Charge is negative | The FC charge is calculated from the charge readout at QA bin boundaries. Normally the later charge readout is higher than the earlier; this bit is assigned when the opposite happens. | | 18 | `ChargeUnknown` | FC Charge is unknown; the first and last time bins _always_ have this defect | QA bin boundaries are at scaler charge readouts. The first QA bin, before any readout, has no initial charge; the last QA bin, after all scaler readouts, has no final charge. Therefore, the first and last QA bins have an unknown, but likely _very small_ charge accumulation. | -| 19 | `PossiblyNoBeam` | Both N and F are low, indicating the beam was possibly off | NOTE: the assignment criteria of this bit is still under study. | +| 19 | `PossiblyNoBeam` | Both N and F are low, indicating the beam was possibly off | NOTE: the assignment criteria of this bit are still under study. | diff --git a/qadb/defect_definitions.json b/qadb/defect_definitions.json index 325929f..c4ce0fa 100644 --- a/qadb/defect_definitions.json +++ b/qadb/defect_definitions.json @@ -99,7 +99,7 @@ "bit_number": 16, "bit_name": "ChargeHigh", "description": "FC Charge is abnormally high", - "documentation": "NOTE: the assignment criteria of this bit is still under study." + "documentation": "NOTE: the assignment criteria of this bit are still under study." }, { "bit_number": 17, @@ -117,6 +117,6 @@ "bit_number": 19, "bit_name": "PossiblyNoBeam", "description": "Both N and F are low, indicating the beam was possibly off", - "documentation": "NOTE: the assignment criteria of this bit is still under study." + "documentation": "NOTE: the assignment criteria of this bit are still under study." } ] From 01375bd823cee618d889491f03be51a92a5c3869 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Tue, 17 Sep 2024 15:28:26 -0400 Subject: [PATCH 21/26] fix: block --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f099b9e..64fcd7d 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,7 @@ Then: - for Groovy, follow [`src/README.md`](/src/README.md) - for C++, follow [`srcC/README.md`](/srcC/README.md) -> [IMPORTANT] C++ access needs [`rapidjson`](https://github.com/Tencent/rapidjson/), provided as a +> [!IMPORTANT] C++ access needs [`rapidjson`](https://github.com/Tencent/rapidjson/), provided as a > submodule of this repository in [`srcC/rapidjson`](/srcC/rapidjson). If this directory > is empty, you can clone the submodule by running > ```bash From e725c8a8d0a26144244fa0ab92d019c64e42303e Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Tue, 17 Sep 2024 15:29:12 -0400 Subject: [PATCH 22/26] fix: block 2 --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 64fcd7d..4e0f006 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,8 @@ Then: - for Groovy, follow [`src/README.md`](/src/README.md) - for C++, follow [`srcC/README.md`](/srcC/README.md) -> [!IMPORTANT] C++ access needs [`rapidjson`](https://github.com/Tencent/rapidjson/), provided as a +> [!IMPORTANT] +> C++ access needs [`rapidjson`](https://github.com/Tencent/rapidjson/), provided as a > submodule of this repository in [`srcC/rapidjson`](/srcC/rapidjson). If this directory > is empty, you can clone the submodule by running > ```bash From d77bdb552104841652379e80f47c5d745e677e88 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Tue, 17 Sep 2024 15:30:30 -0400 Subject: [PATCH 23/26] fix: links --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4e0f006..f8bebdd 100644 --- a/README.md +++ b/README.md @@ -140,8 +140,8 @@ source environ.sh # for bash, zsh source environ.csh # for csh, tcsh ``` Then: -- for Groovy, follow [`src/README.md`](/src/README.md) -- for C++, follow [`srcC/README.md`](/srcC/README.md) +- for Groovy, follow [`src/README.md`](/src/) +- for C++, follow [`srcC/README.md`](/srcC/) > [!IMPORTANT] > C++ access needs [`rapidjson`](https://github.com/Tencent/rapidjson/), provided as a From 257515934b7e0e27addb8ff7474f7860a5452b56 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Tue, 17 Sep 2024 15:34:01 -0400 Subject: [PATCH 24/26] fix: don't encourage `cutAsymmetry` as an example --- src/README.md | 3 +-- srcC/README.md | 11 +++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/README.md b/src/README.md index f38cf9e..7ac42c7 100644 --- a/src/README.md +++ b/src/README.md @@ -7,8 +7,7 @@ This directory contains the Groovy source code to access the QA database provided by `coatjava` (at `$COATJAVA/bin/run-groovy`) - see example scripts in `examples/` directory - a standard usage of QA cuts is demonstrated in - `examples/cutAsymmetry.groovy`, where the QA criteria for a spin asymmetry - analysis are applied + [`examples/cutCustom.groovy`](examples/cutCustom.groovy) - usage notes: - include the `QADB` class with `import clasqa.QADB`, then instantiate - the `QADB` class provides several methods for accessing the QA info; diff --git a/srcC/README.md b/srcC/README.md index ac3530f..e0cf995 100644 --- a/srcC/README.md +++ b/srcC/README.md @@ -3,7 +3,7 @@ This directory contains the C++ source code to access the QA database - first, make sure you have the - [`rapidjson`](https://github.com/Tencent/rapidjson/) library; + [`rapidjson`](https://github.com/Tencent/rapidjson/) library; it is a submodule of this repository and can be obtained by ``` git clone --recurse-submodules https://github.com/JeffersonLab/clas12-qadb.git @@ -11,22 +11,21 @@ This directory contains the C++ source code to access the QA database - be sure the `$QADB` environment variable points to the `clas12-qadb` repository - this can be done with `source ../environ.sh` - in your analysis code, add the following directories to your project's include path: - - `srcC/include` + - `srcC/include` - `srcC/rapidjson/include` - you may need to specify these as "absolute paths" (i.e., not relative paths); see `examples/Makefile` macro `DEPS` for an example - see the `examples/` directory for example QADB usage in analysis loops - a standard usage of QA cuts is demonstrated in - `examples/cutAsymmetry.cpp`, where the QA criteria for a spin asymmetry - analysis are applied + [`examples/cutCustom.cpp`](examples/cutCustom.cpp) - usage notes: - include the `QADB.h` header, then instantiate - - `QADB` is in the `QA` namespace, so you will either need to add + - `QADB` is in the `QA` namespace, so you will either need to add `using namespace QA` or use specifiers, such as `QA::QADB *q` - the `QADB` class provides several methods for accessing the QA info; you only need to provide it a run number and event number - database lookups are only performed as needed, so it is safe to use any accessor method in a standard analysis event loop - **NOTE** `QADB` has been tested with compiled analysis code, but some users - encounter problems when interpreting analysis code with ROOT Cling; it is + encounter problems when interpreting analysis code with ROOT Cling; it is recommended to compile your analysis code From 0e7ac6838a424ebec130a8e3b5616ea3c7f48e24 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Tue, 17 Sep 2024 15:36:03 -0400 Subject: [PATCH 25/26] fix: broken link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f8bebdd..c87029c 100644 --- a/README.md +++ b/README.md @@ -145,7 +145,7 @@ Then: > [!IMPORTANT] > C++ access needs [`rapidjson`](https://github.com/Tencent/rapidjson/), provided as a -> submodule of this repository in [`srcC/rapidjson`](/srcC/rapidjson). If this directory +> submodule of this repository in `srcC/rapidjson`. If this directory > is empty, you can clone the submodule by running > ```bash > git submodule update --init --recursive From 566088133e69161d6ab7e50dd84f2a23af25f48b Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Tue, 17 Sep 2024 16:00:27 -0400 Subject: [PATCH 26/26] fix: var name --- srcC/include/QADB.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/srcC/include/QADB.h b/srcC/include/QADB.h index ee6d014..9d48701 100644 --- a/srcC/include/QADB.h +++ b/srcC/include/QADB.h @@ -152,7 +152,7 @@ namespace QA { // get maximum file number for a given run (useful for QADB validation) inline int GetMaxFilenum(int runnum_); // aliases - inline bool QueryByBinnum(int runnum_, int filenum_); + inline bool QueryByBinnum(int runnum_, int binnum_); inline int GetMaxBinnum(int runnum_); // check if this bin number exists @@ -607,8 +607,8 @@ namespace QA { // result of query return found; }; - bool QADB::QueryByBinnum(int runnum_, int filenum_) { - return QueryByFilenum(runnum_, filenum_); + bool QADB::QueryByBinnum(int runnum_, int binnum_) { + return QueryByFilenum(runnum_, binnum_); } // ----- return maximum filenum for a given runnum