QwAnalysis
|
Class for blinding data, adapted from G0 blinder class. More...
#include <QwBlinder.h>
Public Types | |
enum | EQwBlindingStrategy { kDisabled, kAdditive, kMultiplicative, kAdditiveMultiplicative } |
Available blinding strategies. More... | |
enum | EQwBlinderStatus { kIndeterminate = 0, kNotBlindable, kBlindable, kBlindableFail } |
Status of the blinding process or intermediate steps of the process. More... | |
Public Member Functions | |
QwBlinder (const EQwBlindingStrategy blinding_strategy=kAdditive) | |
Default constructor with optional database. More... | |
virtual | ~QwBlinder () |
Default destructor. More... | |
void | ProcessOptions (QwOptions &options) |
Update the status with new external information. More... | |
void | Update (QwParityDB *db) |
Update the status with new external information. More... | |
void | Update (const QwSubsystemArrayParity &detectors) |
Update the status with new external information. More... | |
void | Update (const QwEPICSEvent &epics) |
Update the status with new external information. More... | |
void | ClearEventData () |
void | WriteFinalValuesToDB (QwParityDB *db) |
void | PrintFinalValues () |
void | FillDB (QwParityDB *db, TString datatype) |
Write to the database. More... | |
void | FillErrDB (QwParityDB *db, TString datatype) |
void | ModifyThisErrorCode (UInt_t &errorcode) const |
void | BlindValue (Double_t &value) const |
Asymmetry blinding. More... | |
void | UnBlindValue (Double_t &value) const |
Asymmetry unblinding. More... | |
void | BlindValue (Double_t &value, const Double_t &yield) const |
Difference blinding. More... | |
void | UnBlindValue (Double_t &value, const Double_t &yield) const |
Difference unblinding. More... | |
void | Blind (QwSubsystemArrayParity &diff) |
Blind the asymmetry of an array of subsystems. More... | |
void | UnBlind (QwSubsystemArrayParity &diff) |
Unblind the asymmetry of an array of subsystems. More... | |
void | Blind (QwSubsystemArrayParity &diff, const QwSubsystemArrayParity &yield) |
Blind the difference of an array of subsystems. More... | |
void | UnBlind (QwSubsystemArrayParity &diff, const QwSubsystemArrayParity &yield) |
Unblind the difference of an array of subsystems. More... | |
const Bool_t & | IsBlinderOkay () const |
Static Public Member Functions | |
static void | DefineOptions (QwOptions &options) |
Static Public Attributes | |
static const TString | fStatusName [4] |
static const UInt_t | kErrorFlag_BlinderFail = 0x200 |
Error flag value. More... | |
Private Member Functions | |
void | SetTargetBlindability (EQwBlinderStatus status) |
void | SetWienState (EQwWienMode wienmode) |
void | SetIHWPPolarity (Int_t ihwppolarity) |
EQwBlinderStatus | CheckBlindability () |
QwBlinder (const QwBlinder &__attribute__((unused)) blinder) | |
Private copy constructor. More... | |
const QwBlinder & | operator= (const QwBlinder &__attribute__((unused)) blinder) |
Private assignment operator. More... | |
void | InitBlinders (const UInt_t seed_id) |
Vector of test values, after unblinding. More... | |
void | InitTestValues (const int n) |
Initializes fBlindingFactor from fSeed. More... | |
Bool_t | CheckTestValues () |
Int_t | UseMD5 (const TString &barestring) |
Recomputes fBlindTestValue to check for memory errors. More... | |
Int_t | UseStringManip (const TString &barestring) |
Returns an integer from a string using MD5. More... | |
Int_t | UsePseudorandom (const TString &barestring) |
Int_t | ReadSeed (QwParityDB *db, const UInt_t seed_id) |
Reads the seed with specified id from the database object. More... | |
Int_t | ReadSeed (QwParityDB *db) |
Reads the seed from the database object. More... | |
void | WriteChecksum (QwParityDB *db) |
void | WriteTestValues (QwParityDB *db) |
Writes fSeedID and fBFChecksum to DB for this analysis ID. More... | |
std::vector< UChar_t > | GenerateDigest (const TString &input) const |
Writes fTestNumber and fBlindTestValue to DB for this analysis ID. More... | |
Private Attributes | |
EQwBlinderStatus | fTargetBlindability_firstread |
Indicates the first value recieved of the blindability of the target. More... | |
EQwBlinderStatus | fTargetBlindability |
Bool_t | fTargetPositionForced |
EQwWienMode | fWienMode_firstread |
EQwWienMode | fWienMode |
Int_t | fIHWPPolarity_firstread |
Int_t | fIHWPPolarity |
Double_t | fBeamCurrentThreshold |
Bool_t | fBeamIsPresent |
Bool_t | fBlinderIsOkay |
const EQwBlindingStrategy | fBlindingStrategy |
Double_t | fBlindingOffset |
Blinding strategy. More... | |
Double_t | fBlindingOffset_Base |
The term to be added to detector asymmetries. More... | |
Double_t | fBlindingFactor |
The term to be added to detector asymmetries, before polarity correction. More... | |
UInt_t | fSeedID |
Maximum blinding factor (in % from identity) More... | |
TString | fSeed |
ID of seed used (seeds.seed_id) More... | |
std::vector< UChar_t > | fDigest |
Default seed. More... | |
std::string | fChecksum |
Checksum in raw hex. More... | |
std::vector< double > | fTestValues |
Checksum in ASCII hex. More... | |
std::vector< double > | fBlindTestValues |
Vector of test values, original. More... | |
std::vector< double > | fUnBlindTestValues |
Vector of test values, after blinding. More... | |
std::vector< Int_t > | fPatternCounters |
Counts the number of events in each failure mode. More... | |
Static Private Attributes | |
static const Double_t | kMaximumBlindingAsymmetry = 0.06 |
The factor to be mutliplied to detector asymmetries. More... | |
static const Double_t | kMaximumBlindingFactor = 0.1 |
Maximum blinding asymmetry (in ppm) More... | |
static const TString | kDefaultSeed = "Default seed, should not be used!" |
Seed string (seeds.seed) More... | |
Class for blinding data, adapted from G0 blinder class.
Definition at line 64 of file QwBlinder.h.
Status of the blinding process or intermediate steps of the process.
Enumerator | |
---|---|
kIndeterminate | |
kNotBlindable | |
kBlindable | |
kBlindableFail |
Definition at line 76 of file QwBlinder.h.
Available blinding strategies.
Enumerator | |
---|---|
kDisabled | |
kAdditive | |
kMultiplicative | |
kAdditiveMultiplicative |
Definition at line 69 of file QwBlinder.h.
QwBlinder::QwBlinder | ( | const EQwBlindingStrategy | blinding_strategy = kAdditive | ) |
Default constructor with optional database.
Default constructor using optional database connection and blinding strategy
blinding_strategy | Blinding strategy |
Definition at line 68 of file QwBlinder.cc.
References fPatternCounters, fSeed, fSeedID, InitBlinders(), InitTestValues(), kBlinderCount_NumCounters, and kDefaultSeed.
|
virtual |
Default destructor.
Destructor checks the validity of the blinding and unblinding
Definition at line 100 of file QwBlinder.cc.
References PrintFinalValues().
|
inlineprivate |
|
inline |
Blind the asymmetry of an array of subsystems.
Definition at line 174 of file QwBlinder.h.
References QwSubsystemArrayParity::Blind(), CheckBlindability(), and kNotBlindable.
Referenced by QwHelicityPattern::CalculateAsymmetry().
|
inline |
Blind the difference of an array of subsystems.
Definition at line 184 of file QwBlinder.h.
References QwSubsystemArrayParity::Blind(), CheckBlindability(), and kNotBlindable.
|
inline |
Asymmetry blinding.
Definition at line 124 of file QwBlinder.h.
References fBlindingFactor, fBlindingOffset, fBlindingStrategy, kAdditive, kAdditiveMultiplicative, and kMultiplicative.
Referenced by QwVQWK_Channel::Blind(), and InitTestValues().
|
inline |
Difference blinding.
Definition at line 149 of file QwBlinder.h.
References fBlindingFactor, fBlindingOffset, fBlindingStrategy, kAdditive, kAdditiveMultiplicative, and kMultiplicative.
|
private |
Definition at line 1079 of file QwBlinder.cc.
References QwLog::endl(), fBeamIsPresent, fBlinderIsOkay, fBlindingStrategy, fIHWPPolarity, fIHWPPolarity_firstread, fPatternCounters, fTargetBlindability, fTargetBlindability_firstread, fTargetPositionForced, fWienMode, fWienMode_firstread, kBlindable, kBlindableFail, kBlinderCount_Blindable, kBlinderCount_ChangedIHWP, kBlinderCount_ChangedTarget, kBlinderCount_ChangedWien, kBlinderCount_Disabled, kBlinderCount_NoBeam, kBlinderCount_NonBlindable, kBlinderCount_OtherFailure, kBlinderCount_Transverse, kBlinderCount_UndefinedIHWP, kBlinderCount_UndefinedWien, kBlinderCount_UnknownTarget, kDisabled, kIndeterminate, kNotBlindable, kWienHorizTrans, kWienIndeterminate, kWienVertTrans, QwDebug, and QwError.
Referenced by Blind().
|
private |
Initializes the test values: fTestNumber, fTestValue, fBlindTestValue, if fBlindingFactor is set.
This routines checks to see if the stored fBlindTestValues[i] match a recomputed blinded test value. The values are cast into floats, and their difference must be less than a change
First test: compare a blinded value with a second computation
Second test: compare the unblinded value with the original value
Definition at line 807 of file QwBlinder.cc.
References QwLog::endl(), fBlindingOffset, fBlindingOffset_Base, fBlindTestValues, fTestValues, fUnBlindTestValues, QwError, and UnBlindValue().
Referenced by FillDB(), PrintFinalValues(), and WriteFinalValuesToDB().
|
inline |
Definition at line 105 of file QwBlinder.h.
References fBeamIsPresent.
Referenced by QwHelicityPattern::ClearEventData().
|
static |
Definition at line 54 of file QwBlinder.cc.
References QwOptions::AddOptions(), and default_bool_value.
Referenced by QwHelicityPattern::DefineOptions().
void QwBlinder::FillDB | ( | QwParityDB * | db, |
TString | datatype | ||
) |
Write to the database.
Write the blinding parameters to the database
db | Database connection |
datatype | Datatype |
For each analyzed run the database contains a digest of the blinding parameters and a number of blinded test entries.
Definition at line 937 of file QwBlinder.cc.
References CheckTestValues(), QwDatabase::Connect(), QwDatabase::Disconnect(), QwLog::endl(), fBlindTestValues, fChecksum, fSeedID, fTestValues, QwParityDB::GetAnalysisID(), QwDatabase::Query(), QwDebug, QwError, and QwMessage.
Referenced by QwHelicityPattern::FillDB().
void QwBlinder::FillErrDB | ( | QwParityDB * | db, |
TString | datatype | ||
) |
Definition at line 1014 of file QwBlinder.cc.
References QwErrDBInterface::AddThisEntryToList(), QwDatabase::Connect(), QwDatabase::Disconnect(), QwLog::endl(), fPatternCounters, QwParityDB::GetAnalysisID(), kBlinderCount_NumCounters, QwDatabase::Query(), QwDebug, QwErrDBInterface::SetAnalysisID(), QwErrDBInterface::SetDeviceID(), QwErrDBInterface::SetErrorCodeId(), and QwErrDBInterface::SetN().
Referenced by QwHelicityPattern::FillErrDB().
|
private |
Writes fTestNumber and fBlindTestValue to DB for this analysis ID.
Generate an MD5 digest of the blinding parameters
input | Input string |
Definition at line 855 of file QwBlinder.cc.
Referenced by InitBlinders(), and UseMD5().
|
private |
Vector of test values, after unblinding.
Initialize the blinder parameters
The blinding constants are determined in two steps.
First, the blinding asymmetry (offset) is determined. It is generated from a signed number between +/- 0.244948974 that is squared to get a number between +/- 0.06 ppm.
Secondly, the multiplicative blinding factor is determined. This number is generated from the blinding asymmetry between, say, 0.9 and 1.1 by an oscillating but uniformly distributed sawtooth function.
TODO: This section of InitBlinders doesn't calculate a reasonable fBlindingFactor but we don't use it for anything.
Definition at line 441 of file QwBlinder.cc.
References QwLog::endl(), fBlindingFactor, fBlindingOffset, fBlindingOffset_Base, fBlindingStrategy, fChecksum, fDigest, fSeed, fSeedID, GenerateDigest(), kDefaultSeed, kDisabled, kMaximumBlindingAsymmetry, QwMessage, QwWarning, and UseMD5().
Referenced by QwBlinder(), and Update().
|
private |
Initializes fBlindingFactor from fSeed.
Generate a set of test values of similar size as measured asymmetries
n | Number of test values |
Definition at line 525 of file QwBlinder.cc.
References BlindValue(), QwLog::endl(), fBlindingOffset, fBlindingOffset_Base, fBlindTestValues, fSeed, fTestValues, fUnBlindTestValues, QwMessage, UnBlindValue(), and UsePseudorandom().
Referenced by QwBlinder(), and Update().
|
inline |
Definition at line 193 of file QwBlinder.h.
References fBlinderIsOkay.
Referenced by QwVQWK_Channel::Blind().
|
inline |
Modifies the device error code variable passed to it, if the blinder is not okay.
Definition at line 119 of file QwBlinder.h.
References kErrorFlag_BlinderFail.
Referenced by QwVQWK_Channel::Blind().
void QwBlinder::PrintFinalValues | ( | ) |
Print a summary of the blinding/unblinding test
Definition at line 880 of file QwBlinder.cc.
References CheckTestValues(), QwLog::endl(), fBlindTestValues, fChecksum, fPatternCounters, fSeedID, fTestValues, fUnBlindTestValues, kBlinderCount_Blindable, kBlinderCount_ChangedIHWP, kBlinderCount_ChangedTarget, kBlinderCount_ChangedWien, kBlinderCount_Disabled, kBlinderCount_NoBeam, kBlinderCount_NonBlindable, kBlinderCount_OtherFailure, kBlinderCount_Transverse, kBlinderCount_UndefinedIHWP, kBlinderCount_UndefinedWien, kBlinderCount_UnknownTarget, and QwMessage.
Referenced by ~QwBlinder().
void QwBlinder::ProcessOptions | ( | QwOptions & | options | ) |
Update the status with new external information.
Update the blinder status with new external information
options | Qweak option handler |
Definition at line 112 of file QwBlinder.cc.
References QwLog::endl(), fBeamCurrentThreshold, fTargetPositionForced, QwOptions::GetValue(), QwOptions::HasValue(), kBlindable, kNotBlindable, QwError, and SetTargetBlindability().
Referenced by QwHelicityPattern::ProcessOptions().
|
private |
Reads the seed with specified id from the database object.
Returns an integer from a string using a version of the helicity bit pseudorandom algorithm.
Function to read the seed in from the database.
Parameters: seed_id = ID number of seed to use (0 = most recent seed)
Return: Int_t
Definition at line 360 of file QwBlinder.cc.
References QwDatabase::Connect(), QwDatabase::Disconnect(), QwLog::endl(), fSeed, fSeedID, kDefaultSeed, QwDatabase::Query(), QwError, and QwWarning.
Referenced by Update().
|
private |
Reads the seed from the database object.
Function to read the seed in from the database.
Parameters:
Return: Int_t
Definition at line 273 of file QwBlinder.cc.
References QwDatabase::Connect(), QwDatabase::Disconnect(), QwLog::endl(), fSeed, fSeedID, QwParityDB::GetRunNumber(), kDefaultSeed, QwDatabase::Query(), QwError, and QwWarning.
|
private |
Definition at line 1068 of file QwBlinder.cc.
References QwLog::endl(), fIHWPPolarity, fIHWPPolarity_firstread, and QwMessage.
Referenced by Update().
|
private |
Definition at line 1046 of file QwBlinder.cc.
References QwLog::endl(), fStatusName, fTargetBlindability, fTargetBlindability_firstread, kIndeterminate, and QwMessage.
Referenced by ProcessOptions(), and Update().
|
private |
Definition at line 1057 of file QwBlinder.cc.
References QwLog::endl(), fWienMode, fWienMode_firstread, kWienIndeterminate, QwMessage, and WienModeName().
Referenced by Update().
|
inline |
Unblind the asymmetry of an array of subsystems.
Definition at line 179 of file QwBlinder.h.
References QwSubsystemArrayParity::UnBlind().
|
inline |
Unblind the difference of an array of subsystems.
Definition at line 189 of file QwBlinder.h.
References QwSubsystemArrayParity::UnBlind().
|
inline |
Asymmetry unblinding.
Definition at line 136 of file QwBlinder.h.
References fBlindingFactor, fBlindingOffset, fBlindingStrategy, kAdditive, kAdditiveMultiplicative, and kMultiplicative.
Referenced by CheckTestValues(), and InitTestValues().
|
inline |
Difference unblinding.
Definition at line 161 of file QwBlinder.h.
References fBlindingFactor, fBlindingOffset, fBlindingStrategy, kAdditive, kAdditiveMultiplicative, and kMultiplicative.
void QwBlinder::Update | ( | QwParityDB * | db | ) |
Update the status with new external information.
Update the blinder status with new external information
db | Database connection |
Definition at line 138 of file QwBlinder.cc.
References QwLog::endl(), fSeed, fSeedID, InitBlinders(), InitTestValues(), kDefaultSeed, QwWarning, and ReadSeed().
Referenced by QwHelicityPattern::UpdateBlinder().
void QwBlinder::Update | ( | const QwSubsystemArrayParity & | detectors | ) |
Update the status with new external information.
Update the blinder status with new external information
detectors | Current subsystem array |
Definition at line 158 of file QwBlinder.cc.
References fBeamCurrentThreshold, fBeamIsPresent, fBlindingStrategy, fTargetBlindability, QwVQWK_Channel::GetValue(), kBlindable, kDisabled, and QwSubsystemArray::ReturnInternalValue().
void QwBlinder::Update | ( | const QwEPICSEvent & | epics | ) |
Update the status with new external information.
Update the blinder status with new external information
epics | Current EPICS event |
Definition at line 184 of file QwBlinder.cc.
References QwEPICSEvent::DetermineIHWPPolarity(), QwEPICSEvent::DetermineWienMode(), QwLog::endl(), fBlindingOffset, fBlindingOffset_Base, fBlindingStrategy, fIHWPPolarity, fTargetBlindability, fTargetPositionForced, fWienMode, QwEPICSEvent::GetDataString(), QwEPICSEvent::GetDataValue(), kBlindable, kDisabled, kIndeterminate, kNotBlindable, kWienBackward, kWienForward, QwDebug, QwWarning, SetIHWPPolarity(), SetTargetBlindability(), and SetWienState().
|
private |
Recomputes fBlindTestValue to check for memory errors.
Use an MD5 checksum to get a number from the seed string
barestring | Seed string |
Definition at line 682 of file QwBlinder.cc.
References GenerateDigest().
Referenced by InitBlinders().
|
private |
Returns an integer from a string using a character manipulation algorithm
Use pseudo-random number generator to get a number from the seed string
barestring | Seed string |
Definition at line 617 of file QwBlinder.cc.
Referenced by InitTestValues().
|
private |
Returns an integer from a string using MD5.
Use string manipulation to get a number from the seed string
barestring | Seed string |
Definition at line 572 of file QwBlinder.cc.
|
private |
Function to write the checksum into the analysis table
Parameters: void
Return: void
Note: This function assumes that the analysis table has already
Definition at line 725 of file QwBlinder.cc.
References QwDatabase::Connect(), QwDatabase::Disconnect(), fChecksum, fSeedID, QwParityDB::GetAnalysisID(), and QwDatabase::Query().
Referenced by WriteFinalValuesToDB().
void QwBlinder::WriteFinalValuesToDB | ( | QwParityDB * | db | ) |
Definition at line 508 of file QwBlinder.cc.
References CheckTestValues(), QwLog::endl(), QwError, WriteChecksum(), and WriteTestValues().
|
private |
Writes fSeedID and fBFChecksum to DB for this analysis ID.
Function to write the test values into the database
Parameters: void
Definition at line 759 of file QwBlinder.cc.
References QwDatabase::Connect(), QwDatabase::Disconnect(), fBlindTestValues, fTestValues, QwParityDB::GetAnalysisID(), and QwDatabase::Query().
Referenced by WriteFinalValuesToDB().
|
private |
Definition at line 209 of file QwBlinder.h.
Referenced by ProcessOptions(), and Update().
|
private |
Definition at line 210 of file QwBlinder.h.
Referenced by CheckBlindability(), ClearEventData(), and Update().
|
private |
Definition at line 213 of file QwBlinder.h.
Referenced by CheckBlindability(), and IsBlinderOkay().
|
private |
The term to be added to detector asymmetries, before polarity correction.
Definition at line 229 of file QwBlinder.h.
Referenced by BlindValue(), InitBlinders(), and UnBlindValue().
|
private |
Blinding strategy.
Definition at line 227 of file QwBlinder.h.
Referenced by BlindValue(), CheckTestValues(), InitBlinders(), InitTestValues(), UnBlindValue(), and Update().
|
private |
The term to be added to detector asymmetries.
Definition at line 228 of file QwBlinder.h.
Referenced by CheckTestValues(), InitBlinders(), InitTestValues(), and Update().
|
private |
Definition at line 223 of file QwBlinder.h.
Referenced by BlindValue(), CheckBlindability(), InitBlinders(), UnBlindValue(), and Update().
|
private |
Vector of test values, original.
Definition at line 243 of file QwBlinder.h.
Referenced by CheckTestValues(), FillDB(), InitTestValues(), PrintFinalValues(), and WriteTestValues().
|
private |
Checksum in raw hex.
Definition at line 240 of file QwBlinder.h.
Referenced by FillDB(), InitBlinders(), PrintFinalValues(), and WriteChecksum().
|
private |
|
private |
Definition at line 203 of file QwBlinder.h.
Referenced by CheckBlindability(), SetIHWPPolarity(), and Update().
|
private |
Definition at line 202 of file QwBlinder.h.
Referenced by CheckBlindability(), and SetIHWPPolarity().
|
private |
Counts the number of events in each failure mode.
Definition at line 273 of file QwBlinder.h.
Referenced by CheckBlindability(), FillErrDB(), PrintFinalValues(), and QwBlinder().
|
private |
ID of seed used (seeds.seed_id)
Definition at line 236 of file QwBlinder.h.
Referenced by InitBlinders(), InitTestValues(), QwBlinder(), ReadSeed(), and Update().
|
private |
Maximum blinding factor (in % from identity)
Definition at line 235 of file QwBlinder.h.
Referenced by FillDB(), InitBlinders(), PrintFinalValues(), QwBlinder(), ReadSeed(), Update(), and WriteChecksum().
|
static |
Definition at line 82 of file QwBlinder.h.
Referenced by SetTargetBlindability().
|
private |
Definition at line 198 of file QwBlinder.h.
Referenced by CheckBlindability(), SetTargetBlindability(), and Update().
|
private |
Indicates the first value recieved of the blindability of the target.
Definition at line 193 of file QwBlinder.h.
Referenced by CheckBlindability(), and SetTargetBlindability().
|
private |
Definition at line 199 of file QwBlinder.h.
Referenced by CheckBlindability(), ProcessOptions(), and Update().
|
private |
Checksum in ASCII hex.
Definition at line 242 of file QwBlinder.h.
Referenced by CheckTestValues(), FillDB(), InitTestValues(), PrintFinalValues(), and WriteTestValues().
|
private |
Vector of test values, after blinding.
Definition at line 244 of file QwBlinder.h.
Referenced by CheckTestValues(), InitTestValues(), and PrintFinalValues().
|
private |
Definition at line 201 of file QwBlinder.h.
Referenced by CheckBlindability(), SetWienState(), and Update().
|
private |
Definition at line 200 of file QwBlinder.h.
Referenced by CheckBlindability(), and SetWienState().
|
staticprivate |
Seed string (seeds.seed)
Definition at line 237 of file QwBlinder.h.
Referenced by InitBlinders(), QwBlinder(), ReadSeed(), and Update().
|
static |
|
staticprivate |
The factor to be mutliplied to detector asymmetries.
Definition at line 232 of file QwBlinder.h.
Referenced by InitBlinders().
|
staticprivate |
Maximum blinding asymmetry (in ppm)
Definition at line 233 of file QwBlinder.h.