36 QwError <<
"QwVQWK_Channel::GetBufferOffset: Invalid module index,"
38 <<
". Must be zero or greater."
41 QwError <<
"QwVQWK_Channel::GetBufferOffset: Invalid channel index,"
43 <<
". Must be in range [0," << kMaxChannels <<
"]."
56 Bool_t fEventIsGood=kTRUE;
235 <<
" cannot set the default sample size."
265 Double_t sqrt_fBlocksPerEvent = 0.0;
269 Double_t drift = 0.0;
292 block[i] = hwsum / fBlocksPerEvent;
316 Double_t thispedestal = 0.0;
333 Long_t localbuf[6] = {0};
340 for (Int_t i = 0; i < 4; i++) {
350 for (Int_t i = 0; i < 6; i++){
351 buffer.push_back(localbuf[i]);
360 UInt_t words_read = 0;
373 localbuf[i] = buffer[i];
374 localbuf_signed[i] =
static_cast<Int_t
>(localbuf[i]);
397 std::cerr <<
"QwVQWK_Channel::ProcessEvBuffer: Not enough words!"
419 QwWarning <<
"QwVQWK_Channel::ProcessEvent: Channel "
421 <<
" has fNumberOfSamples==0 but has valid data in the hardware sum. "
422 <<
"Flag this as an error."
453 std::cout<<
"***************************************"<<
"\n";
455 std::cout<<
"Beam Instrument Type: "<<
GetModuleType()<<
"\n"<<
"\n";
457 std::cout<<
"fPedestal= "<<
fPedestal<<
"\n";
462 std::cout<<
"fBlock_raw ";
469 std::cout<<
"fBlock ";
471 std::cout <<
" : " <<
fBlock[i];
472 std::cout << std::endl;
484 if (folder != NULL) folder->cd();
490 if (prefix == TString(
"asym_")
491 || prefix == TString(
"diff_")
492 || prefix == TString(
"yield_"))
495 TString basename, fullname;
611 values.push_back(0.0);
615 values.push_back(0.0);
618 values.push_back(0.0);
621 values.push_back(0.0);
624 values.push_back(0.0);
629 values.push_back(0.0);
630 list +=
":num_samples/D";
634 values.push_back(0.0);
635 list +=
":Device_Error_Code/D";
641 values.push_back(0.0);
642 list +=
":hw_sum_raw/D";
645 values.push_back(0.0);
646 list +=
":block0_raw/D";
648 values.push_back(0.0);
649 list +=
":block1_raw/D";
651 values.push_back(0.0);
652 list +=
":block2_raw/D";
654 values.push_back(0.0);
655 list +=
":block3_raw/D";
658 values.push_back(0.0);
659 list +=
":sequence_number/D";
667 if (list==
"hw_sum/D")
676 std::cerr <<
"QwVQWK_Channel::ConstructBranchAndVector: fTreeArrayIndex==" <<
fTreeArrayIndex
678 <<
"; values.size()==" << values.size()
679 <<
"; list==" << list
695 std::cerr <<
"QwVQWK_Channel::ConstructBranchAndVector: fTreeArrayIndex==" <<
fTreeArrayIndex
709 if (
bDEBUG) std::cerr <<
"QwVQWK_Channel::FillTreeVector: fTreeArrayNumEntries=="
712 if (
bDEBUG) std::cerr <<
"QwVQWK_Channel::FillTreeVector: values.size()=="
714 <<
"; fTreeArrayIndex+fTreeArrayNumEntries=="
789 if(
this ==&value)
return *
this;
814 if(
this == &value)
return;
841 TString loc=
"Standard exception from QwVQWK_Channel::AssignValueFrom = "
843 throw std::invalid_argument(loc.Data());
853 TString loc=
"Standard exception from QwVQWK_Channel::AddValueFrom = "
855 throw std::invalid_argument(loc.Data());
865 TString loc=
"Standard exception from QwVQWK_Channel::SubtractValueFrom = "
867 throw std::invalid_argument(loc.Data());
877 TString loc=
"Standard exception from QwVQWK_Channel::MultiplyBy = "
879 throw std::invalid_argument(loc.Data());
889 TString loc=
"Standard exception from QwVQWK_Channel::DivideBy = "
891 throw std::invalid_argument(loc.Data());
985 TString loc=
"Standard exception from QwVQWK_Channel::operator+= "
988 throw(std::invalid_argument(loc.Data()));
999 TString loc=
"Standard exception from QwVQWK_Channel::operator-= "
1002 throw(std::invalid_argument(loc.Data()));
1013 TString loc=
"Standard exception from QwVQWK_Channel::operator*= "
1016 throw(std::invalid_argument(loc.Data()));
1027 TString loc=
"Standard exception from QwVQWK_Channel::operator/= "
1030 throw(std::invalid_argument(loc.Data()));
1078 for (Int_t i = 0; i < 4; i++) {
1081 variance = ratio * ratio *
1086 }
else if (this->
fBlock[i] == 0.0) {
1090 QwVerbose <<
"Attempting to divide by zero block in "
1098 variance = ratio * ratio *
1107 QwVerbose <<
"Attempting to divide by zero sum in "
1241 Bool_t berror=kTRUE;
1258 berror=(((value.
fErrorFlag) & 0xFFFFFFF) == 0);
1272 }
else if (n2 == -1 && berror) {
1285 }
else if (n2 == -1) {
1294 for (Int_t i = 0; i < 4; i++) {
1298 fBlock[i] -= (M12 - M11) / n;
1308 }
else if (n2 == 1) {
1315 for (Int_t i = 0; i < 4; i++) {
1319 fBlock[i] += (M12 - M11) / n;
1322 }
else if (n2 > 1) {
1328 for (Int_t i = 0; i < 4; i++) {
1332 fBlock[i] += n2 * (M12 - M11) / n;
1333 fBlockM2[i] += M22 + n1 * n2 * (M12 - M11) * (M12 - M11) / n;
1467 Bool_t status = kTRUE;
1476 Bool_t status = kTRUE;
1481 std::cerr <<
"QwVQWK_Channel::MatchNumberOfSamples: Channel "
1484 <<
" and was supposed to have " << numsamp
1494 Bool_t status = kFALSE;
1496 if (LL==0 && UL==0){
1547 message = Form(
"%30s",
"Device name");
1548 message += Form(
"%9s",
"HW Sat");
1549 message += Form(
"%9s",
"Sample");
1550 message += Form(
"%9s",
"SW_HW");
1551 message += Form(
"%9s",
"Sequence");
1552 message += Form(
"%9s",
"SameHW");
1553 message += Form(
"%9s",
"ZeroHW");
1554 message += Form(
"%9s",
"EventCut");
1555 QwMessage <<
"---------------------------------------------------------------------------------------------" <<
QwLog::endl;
1557 QwMessage <<
"---------------------------------------------------------------------------------------------" <<
QwLog::endl;
1563 QwMessage <<
"---------------------------------------------------------------------------------------------" <<
QwLog::endl;
1581 message +=
" >>>>> No Pedestal or Gain in map file";
1679 row_list.push_back(row);
1685 row_list.push_back(row);
1691 row_list.push_back(row);
1698 row_list.push_back(row);
1705 row_list.push_back(row);
1711 row_list.push_back(row);
1718 row_list.push_back(row);
static const double pi
Angles: base unit is radian.
static const Int_t kWordsPerChannel
#define QwMessage
Predefined log drain for regular messages.
static const UInt_t kErrorFlag_SW_HW
Int_t ProcessEvBuffer(UInt_t *buffer, UInt_t num_words_left, UInt_t index=0)
Decode the event data from a CODA buffer.
static const UInt_t kErrorFlag_ZeroHW
void ProcessEvent()
Process the event data according to pedestal and calibration factor.
Int_t GetRawSoftwareSum() const
Bool_t ApplySingleEventCuts()
Int_t fErrorCount_Sequence
sequence number check
size_t GetNumberOfSamples() const
UInt_t GetGoodEventCount() const
void RandomizeEventData(int helicity=0.0, double time=0.0)
Internally generate random event data.
Int_t fErrorCount_sample
for sample size check
void AssignValueFrom(const VQwDataElement *valueptr)
std::ostream & operator<<(std::ostream &out, const QwColor &color)
Output stream operator which uses the enum-to-escape-code mapping.
static const UInt_t kErrorFlag_sample
Double_t GetHardwareSumWidth() const
const Bool_t & IsBlinderOkay() const
QwVQWK_Channel & operator=(const QwVQWK_Channel &value)
void BlindValue(Double_t &value) const
Asymmetry blinding.
Double_t GetHardwareSumError() const
void Ratio(const QwVQWK_Channel &numer, const QwVQWK_Channel &denom)
void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)
void AssignScaledValue(const QwVQWK_Channel &value, Double_t scale)
Bool_t IsNameEmpty() const
Is the name of this element empty?
UInt_t fNumberOfDataWords
Number of raw data words in this data element.
Class for blinding data, adapted from G0 blinder class.
Bool_t MatchNumberOfSamples(size_t numsamp)
std::vector< Double_t > fMockDriftPhase
Harmonic drift phase.
void PrintInfo() const
Print multiple lines of information about this data element.
std::vector< Double_t > fMockDriftFrequency
Harmonic drift frequency.
static const UInt_t kErrorFlag_SameHW
Double_t fHardwareBlockSumM2
Second moment of the hardware sum.
std::vector< TH1_ptr > fHistograms
Histograms associated with this data element.
void SetEventData(Double_t *block, UInt_t sequencenumber=0)
void DivideBy(const VQwHardwareChannel *valueptr)
#define QwVerbose
Predefined log drain for verbose messages.
void SetDefaultSampleSize(size_t num_samples_map)
Double_t fMockGaussianSigma
Sigma of normal distribution.
void Scale(Double_t Offset)
Int_t fErrorCount_ZeroHW
check to see ADC returning zero
Double_t fHardwareBlockSumError
Uncertainty on the hardware sum.
void SetDataToSave(TString datatosave)
Set the flag indicating if raw or derived values are in this data element.
Int_t fErrorCount_SW_HW
HW_sum==SW_sum check.
void ConstructBranch(TTree *tree, TString &prefix)
size_t fNumberOfSamples_map
Number of samples in the expected to read through the module. This value is set in the QwBeamline map...
Double_t fCalibrationFactor
Int_t fHardwareBlockSum_raw
Module-based sum of the four sub-blocks as read from the module.
Int_t GetRawHardwareSum() const
VQwHardwareChannel & operator/=(const VQwHardwareChannel *input)
void SetNumberOfDataWords(const UInt_t &numwords)
Set the number of data words in this data element.
Bool_t bDevice_Error_Code
Bool_t ReturnValue(const std::string keyname, T &retvalue)
size_t fTreeArrayNumEntries
TString GetModuleType() const
Return the type of the beam instrument.
size_t fSequenceNumber
Event sequence number for this channel.
static void PrintErrorCounterHead()
Int_t fErrorCount_HWSat
check to see ADC channel is saturated
void SetHardwareSum(Double_t hwsum, UInt_t sequencenumber=0)
const QwVQWK_Channel operator*(const QwVQWK_Channel &value) const
const QwVQWK_Channel operator-(const QwVQWK_Channel &value) const
Int_t fSoftwareBlockSum_raw
Sum of the data in the four sub-blocks raw.
void ConstructHistograms(TDirectory *folder, TString &prefix)
Construct the histograms for this data element.
Bool_t MatchDeviceParamsFromList(const std::string &devicename)
void SetNumberOfSubElements(const size_t elements)
Set the number of data words in this data element.
bool fUseExternalRandomVariable
Flag to use an externally provided normal random variable.
static const Bool_t kDEBUG
Int_t fSequenceNo_Counter
Internal counter to keep track of the sequence number.
The pure virtual base class of all data elements.
QwVQWK_Channel & operator*=(const QwVQWK_Channel &value)
void ModifyThisErrorCode(UInt_t &errorcode) const
Double_t fHardwareBlockSum
Module-based sum of the four sub-blocks.
Double_t fBlockError[4]
Uncertainty on the sub-block.
void PrintValue() const
Print single line of value and error of this data element.
A logfile class, based on an identical class in the Hermes analyzer.
Double_t GetRandomValue()
void SetSubsystemName(TString sysname)
Set the name of the inheriting subsystem name.
Bool_t MatchVQWKElementFromList(const std::string &subsystemname, const std::string &moduletype, const std::string &devicename)
static const UInt_t kErrorFlag_Sequence
void ScaledAdd(Double_t scale, const VQwHardwareChannel *value)
void ClearEventData()
Clear the event data in this element.
Double_t fPrev_HardwareBlockSum
Previous Module-based sum of the four sub-blocks.
Double_t fMockGaussianMean
Mean of normal distribution.
QwVQWK_Channel & operator-=(const QwVQWK_Channel &value)
Int_t fBlock_raw[4]
Array of the sub-block data as read from the module.
Int_t fErrorCount_SameHW
check to see ADC returning same HW value
Int_t GetRawBlockValue(size_t blocknum) const
Int_t fSequenceNo_Prev
Keep the sequence number of the last event.
void FillTreeVector(std::vector< Double_t > &values) const
Double_t GetAverageVolts() const
TString GetSubsystemName() const
Return the name of the inheriting subsystem name.
std::vector< Double_t > fMockDriftAmplitude
Harmonic drift amplitude.
void SetElementName(const TString &name)
Set the name of this element.
static const UInt_t kPreserveError
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...
Double_t fMockAsymmetry
Helicity asymmetry.
QwVQWK_Channel * fRunningSum
Pointer to the running sum for this channel.
QwHistogramHelper gQwHists
Globally defined instance of the QwHistogramHelper class.
void PrintErrorCounters() const
report number of events failed due to HW and event cut failure
static const UInt_t kBeamStabilityError
A class for blinding data, adapted from G0 blinder class.
void FillHistograms()
Fill the histograms for this data element.
UInt_t fErrorConfigFlag
contains the global/local/stability flags
void Product(const QwVQWK_Channel &value1, const QwVQWK_Channel &value2)
Double_t GetBlockValue(size_t blocknum) const
void Sum(const QwVQWK_Channel &value1, const QwVQWK_Channel &value2)
void SetErrorCodeId(UInt_t in)
Int_t fNumEvtsWithEventCutsRejected
Counts the Event cut rejected events.
virtual VQwHardwareChannel & operator=(const VQwHardwareChannel &value)
Arithmetic assignment operator: Should only copy event-based data.
static const Double_t kVQWK_VoltsPerBit
static std::ostream & endl(std::ostream &)
End of the line.
void SetModuleType(TString ModuleType)
set the type of the beam instrument
static const UInt_t kErrorFlag_EventCut_L
Int_t fGoodEventCount
Number of good events accumulated in this element.
Double_t fBlockM2[4]
Second moment of the sub-block.
virtual const TString & GetElementName() const
Get the name of this element.
void AddValueFrom(const VQwHardwareChannel *valueptr)
void Difference(const QwVQWK_Channel &value1, const QwVQWK_Channel &value2)
Double_t GetBlockErrorValue(size_t blocknum) const
size_t fPreviousSequenceNumber
Previous event sequence number for this channel.
void SetDeviceName(TString &in)
void MultiplyBy(const VQwHardwareChannel *valueptr)
Int_t fADC_Same_NumEvt
Keep track of how many events with same ADC value returned.
QwVQWK_Channel & operator+=(const QwVQWK_Channel &value)
void EncodeEventData(std::vector< UInt_t > &buffer)
Encode the event data into a CODA buffer.
static void PrintErrorCounterTail()
size_t fNumberOfSamples
Number of samples read through the module.
static Int_t GetBufferOffset(Int_t moduleindex, Int_t channelindex)
size_t GetSequenceNumber() const
#define QwWarning
Predefined log drain for warnings.
static const Bool_t bDEBUG
debugging display purposes
Double_t GetValueWidth() const
Double_t GetHardwareSum() const
void InitializeChannel(TString name, TString datatosave)
Initialize the fields in this object.
Double_t fBlock[4]
Array of the sub-block data.
void AddChannelOffset(Double_t Offset)
void AddErrEntriesToList(std::vector< QwErrDBInterface > &row_list)
static const UInt_t kStabilityCut
void IncrementErrorCounters()
const QwVQWK_Channel operator+(const QwVQWK_Channel &value) const
static const UInt_t kErrorFlag_VQWK_Sat
Double_t GetVQWKSaturationLimt()
TH1F * Construct1DHist(const TString &inputfile, const TString &name_title)
Bool_t MatchSequenceNumber(size_t seqnum)
static const Int_t kMaxChannels
static const UInt_t kErrorFlag_EventCut_U
void CalculateRunningAverage()
void SubtractValueFrom(const VQwHardwareChannel *valueptr)
void Blind(const QwBlinder *blinder)
Blind this channel as an asymmetry.
void LoadChannelParameters(QwParameterFile ¶mfile)
#define QwError
Predefined log drain for errors.
void AccumulateRunningSum(const QwVQWK_Channel &value)