QwAnalysis
QwVQWK_Channel Class Reference

#include <QwVQWK_Channel.h>

+ Inheritance diagram for QwVQWK_Channel:
+ Collaboration diagram for QwVQWK_Channel:

Public Member Functions

 QwVQWK_Channel ()
 
 QwVQWK_Channel (TString name, TString datatosave="raw")
 
 QwVQWK_Channel (const QwVQWK_Channel &value)
 
 QwVQWK_Channel (const QwVQWK_Channel &value, VQwDataElement::EDataToSave datatosave)
 
virtual ~QwVQWK_Channel ()
 
void InitializeChannel (TString name, TString datatosave)
 Initialize the fields in this object. More...
 
void InitializeChannel (TString subsystem, TString instrumenttype, TString name, TString datatosave)
 Initialize the fields in this object. More...
 
void LoadChannelParameters (QwParameterFile &paramfile)
 
void SetDefaultSampleSize (size_t num_samples_map)
 
void ClearEventData ()
 Clear the event data in this element. More...
 
void RandomizeEventData (int helicity=0.0, double time=0.0)
 Internally generate random event data. More...
 
void SetHardwareSum (Double_t hwsum, UInt_t sequencenumber=0)
 
void SetEventData (Double_t *block, UInt_t sequencenumber=0)
 
void EncodeEventData (std::vector< UInt_t > &buffer)
 Encode the event data into a CODA buffer. More...
 
Int_t ProcessEvBuffer (UInt_t *buffer, UInt_t num_words_left, UInt_t index=0)
 Decode the event data from a CODA buffer. More...
 
void ProcessEvent ()
 Process the event data according to pedestal and calibration factor. More...
 
QwVQWK_Channeloperator= (const QwVQWK_Channel &value)
 
void AssignScaledValue (const QwVQWK_Channel &value, Double_t scale)
 
void AssignValueFrom (const VQwDataElement *valueptr)
 
void AddValueFrom (const VQwHardwareChannel *valueptr)
 
void SubtractValueFrom (const VQwHardwareChannel *valueptr)
 
void MultiplyBy (const VQwHardwareChannel *valueptr)
 
void DivideBy (const VQwHardwareChannel *valueptr)
 
QwVQWK_Channeloperator+= (const QwVQWK_Channel &value)
 
QwVQWK_Channeloperator-= (const QwVQWK_Channel &value)
 
QwVQWK_Channeloperator*= (const QwVQWK_Channel &value)
 
VQwHardwareChanneloperator+= (const VQwHardwareChannel *input)
 
VQwHardwareChanneloperator-= (const VQwHardwareChannel *input)
 
VQwHardwareChanneloperator*= (const VQwHardwareChannel *input)
 
VQwHardwareChanneloperator/= (const VQwHardwareChannel *input)
 
const QwVQWK_Channel operator+ (const QwVQWK_Channel &value) const
 
const QwVQWK_Channel operator- (const QwVQWK_Channel &value) const
 
const QwVQWK_Channel operator* (const QwVQWK_Channel &value) const
 
void Sum (const QwVQWK_Channel &value1, const QwVQWK_Channel &value2)
 
void Difference (const QwVQWK_Channel &value1, const QwVQWK_Channel &value2)
 
void Ratio (const QwVQWK_Channel &numer, const QwVQWK_Channel &denom)
 
void Product (const QwVQWK_Channel &value1, const QwVQWK_Channel &value2)
 
void DivideBy (const QwVQWK_Channel &denom)
 
void AddChannelOffset (Double_t Offset)
 
void Scale (Double_t Offset)
 
void AccumulateRunningSum (const QwVQWK_Channel &value)
 
void AccumulateRunningSum (const QwVQWK_Channel &value, Int_t count)
 
void AccumulateRunningSum (const VQwHardwareChannel *value, Int_t count)
 
void DeaccumulateRunningSum (const QwVQWK_Channel &value)
 
void CalculateRunningAverage ()
 
Bool_t MatchSequenceNumber (size_t seqnum)
 
Bool_t MatchNumberOfSamples (size_t numsamp)
 
Bool_t ApplySingleEventCuts (Double_t LL, Double_t UL)
 
Bool_t ApplySingleEventCuts ()
 
void PrintErrorCounters () const
 report number of events failed due to HW and event cut failure More...
 
void SetVQWKSaturationLimt (Double_t sat_volts=8.5)
 
Double_t GetVQWKSaturationLimt ()
 
Int_t ApplyHWChecks ()
 
void IncrementErrorCounters ()
 
void ConstructHistograms (TDirectory *folder, TString &prefix)
 Construct the histograms for this data element. More...
 
void FillHistograms ()
 Fill the histograms for this data element. More...
 
void ConstructBranchAndVector (TTree *tree, TString &prefix, std::vector< Double_t > &values)
 
void ConstructBranch (TTree *tree, TString &prefix)
 
void FillTreeVector (std::vector< Double_t > &values) const
 
Int_t GetRawValue (size_t element) const
 
Double_t GetValue (size_t element) const
 
Double_t GetValueM2 (size_t element) const
 
Double_t GetValueError (size_t element) const
 
Double_t GetAverageVolts () const
 
size_t GetSequenceNumber () const
 
size_t GetNumberOfSamples () const
 
void SetCalibrationToVolts ()
 
void PrintValue () const
 Print single line of value and error of this data element. More...
 
void PrintInfo () const
 Print multiple lines of information about this data element. More...
 
void Blind (const QwBlinder *blinder)
 Blind this channel as an asymmetry. More...
 
void Blind (const QwBlinder *blinder, const QwVQWK_Channel &yield)
 Blind this channel as a difference. More...
 
void ScaledAdd (Double_t scale, const VQwHardwareChannel *value)
 
void AddErrEntriesToList (std::vector< QwErrDBInterface > &row_list)
 
- Public Member Functions inherited from VQwHardwareChannel
 VQwHardwareChannel ()
 
 VQwHardwareChannel (const VQwHardwareChannel &value)
 
 VQwHardwareChannel (const VQwHardwareChannel &value, VQwDataElement::EDataToSave datatosave)
 
virtual ~VQwHardwareChannel ()
 
size_t GetNumberOfDataWords ()
 Get the number of data words in this data element. More...
 
size_t GetNumberOfSubelements ()
 Get the number of subelements in this data element. More...
 
Int_t GetRawValue () const
 
Double_t GetValue () const
 
Double_t GetValueM2 () const
 
Double_t GetValueError () const
 
Double_t GetValueWidth () const
 
Double_t GetValueWidth (size_t element) const
 
void InitializeChannel (TString name)
 Initialize the fields in this object. More...
 
void SetEventCutMode (Int_t bcuts)
 
void SetSingleEventCuts (Double_t min, Double_t max)
 Set the upper and lower limits (fULimit and fLLimit) for this channel. More...
 
void SetSingleEventCuts (UInt_t errorflag, Double_t min, Double_t max, Double_t stability)
 Inherited from VQwDataElement to set the upper and lower limits (fULimit and fLLimit), stability % and the error flag on this channel. More...
 
Double_t GetEventCutUpperLimit () const
 
Double_t GetEventCutLowerLimit () const
 
Double_t GetStabilityLimit () const
 
UInt_t UpdateErrorFlag ()
 Update the error flag based on the error flags of internally contained objects Return paramter is the "Eventcut Error Flag". More...
 
void UpdateErrorFlag (const VQwHardwareChannel &elem)
 
virtual UInt_t GetErrorCode () const
 
virtual VQwHardwareChanneloperator= (const VQwHardwareChannel &value)
 Arithmetic assignment operator: Should only copy event-based data. More...
 
void SetPedestal (Double_t ped)
 
Double_t GetPedestal () const
 
void SetCalibrationFactor (Double_t factor)
 
Double_t GetCalibrationFactor () const
 
void AddEntriesToList (std::vector< QwDBInterface > &row_list)
 
virtual void AccumulateRunningSum (const VQwHardwareChannel *value)
 
virtual void DeaccumulateRunningSum (const VQwHardwareChannel *value)
 
void ConstructBranch (TTree *tree, TString &prefix, QwParameterFile &modulelist)
 
- Public Member Functions inherited from VQwDataElement
 VQwDataElement ()
 Default constructor. More...
 
 VQwDataElement (const VQwDataElement &value)
 Copy constructor. More...
 
virtual ~VQwDataElement ()
 Virtual destructor. More...
 
Bool_t IsNameEmpty () const
 Is the name of this element empty? More...
 
void SetElementName (const TString &name)
 Set the name of this element. More...
 
virtual const TString & GetElementName () const
 Get the name of this element. More...
 
size_t GetNumberOfDataWords ()
 Get the number of data words in this data element. More...
 
UInt_t GetGoodEventCount () const
 
virtual VQwDataElementoperator+= (const VQwDataElement &value)
 Addition-assignment operator. More...
 
virtual VQwDataElementoperator-= (const VQwDataElement &value)
 Subtraction-assignment operator. More...
 
virtual void Sum (const VQwDataElement &value1, const VQwDataElement &value2)
 Sum operator. More...
 
virtual void Difference (const VQwDataElement &value1, const VQwDataElement &value2)
 Difference operator. More...
 
virtual void Ratio (const VQwDataElement &numer, const VQwDataElement &denom)
 Ratio operator. More...
 
virtual UInt_t GetEventcutErrorFlag ()
 return the error flag on this channel/device More...
 
virtual void SetNeedsExternalClock (Bool_t needed)
 
virtual Bool_t NeedsExternalClock ()
 
virtual std::string GetExternalClockName ()
 
virtual void SetExternalClockPtr (const VQwHardwareChannel *clock)
 
virtual void SetExternalClockName (const std::string name)
 
virtual Double_t GetNormClockValue ()
 
TString GetSubsystemName () const
 Return the name of the inheriting subsystem name. More...
 
void SetSubsystemName (TString sysname)
 Set the name of the inheriting subsystem name. More...
 
TString GetModuleType () const
 Return the type of the beam instrument. More...
 
void SetModuleType (TString ModuleType)
 set the type of the beam instrument More...
 
- Public Member Functions inherited from MQwHistograms
void ShareHistograms (const MQwHistograms *source)
 Share histogram pointers between objects. More...
 
- Public Member Functions inherited from MQwMockable
 MQwMockable ()
 
virtual ~MQwMockable ()
 
void SetRandomEventDriftParameters (Double_t amplitude, Double_t phase, Double_t frequency)
 Set a single set of harmonic drift parameters. More...
 
void AddRandomEventDriftParameters (Double_t amplitude, Double_t phase, Double_t frequency)
 Add drift parameters to the internal set. More...
 
void SetRandomEventParameters (Double_t mean, Double_t sigma)
 Set the normal random event parameters. More...
 
void SetRandomEventAsymmetry (Double_t asymmetry)
 Set the helicity asymmetry. More...
 
Double_t GetRandomValue ()
 
void UseExternalRandomVariable ()
 Set the flag to use an externally provided random variable. More...
 
void SetExternalRandomVariable (Double_t random_variable)
 Set the externally provided random variable. More...
 

Static Public Member Functions

static Int_t GetBufferOffset (Int_t moduleindex, Int_t channelindex)
 
static void PrintErrorCounterHead ()
 
static void PrintErrorCounterTail ()
 

Protected Member Functions

QwVQWK_Channeloperator/= (const QwVQWK_Channel &value)
 
- Protected Member Functions inherited from VQwHardwareChannel
void SetNumberOfDataWords (const UInt_t &numwords)
 Set the number of data words in this data element. More...
 
void SetNumberOfSubElements (const size_t elements)
 Set the number of data words in this data element. More...
 
void SetDataToSave (TString datatosave)
 Set the flag indicating if raw or derived values are in this data element. More...
 
void SetDataToSave (VQwDataElement::EDataToSave datatosave)
 Set the flag indicating if raw or derived values are in this data element. More...
 
void RangeCheck (size_t element) const
 Checks that the requested element is in range, to be used in accesses to subelements similar to std::vector::at(). More...
 
- Protected Member Functions inherited from VQwDataElement
void SetNumberOfDataWords (const UInt_t &numwords)
 Set the number of data words in this data element. More...
 
virtual VQwDataElementoperator= (const VQwDataElement &value)
 Arithmetic assignment operator: Should only copy event-based data. More...
 
virtual void UpdateErrorFlag (const UInt_t &error)
 
- Protected Member Functions inherited from MQwHistograms
 MQwHistograms ()
 Default constructor. More...
 
 MQwHistograms (const MQwHistograms &source)
 Copy constructor. More...
 
virtual ~MQwHistograms ()
 Virtual destructor. More...
 
virtual MQwHistogramsoperator= (const MQwHistograms &value)
 
void Fill_Pointer (TH1_ptr hist_ptr, Double_t value)
 
void AddHistogram (TH1 *h)
 Register a histogram. More...
 

Private Member Functions

Double_t GetBlockValue (size_t blocknum) const
 
Double_t GetBlockErrorValue (size_t blocknum) const
 
Double_t GetHardwareSum () const
 
Double_t GetHardwareSumM2 () const
 
Double_t GetHardwareSumWidth () const
 
Double_t GetHardwareSumError () const
 
Int_t GetRawBlockValue (size_t blocknum) const
 
Int_t GetRawHardwareSum () const
 
Int_t GetRawSoftwareSum () const
 

Private Attributes

QwVQWK_ChannelfRunningSum
 Pointer to the running sum for this channel. More...
 
size_t fSequenceNumber
 Event sequence number for this channel. More...
 
size_t fPreviousSequenceNumber
 Previous event sequence number for this channel. More...
 
size_t fNumberOfSamples
 Number of samples read through the module. More...
 
size_t fNumberOfSamples_map
 Number of samples in the expected to read through the module. This value is set in the QwBeamline map file. More...
 
Int_t fErrorCount_HWSat
 check to see ADC channel is saturated More...
 
Int_t fErrorCount_sample
 for sample size check More...
 
Int_t fErrorCount_SW_HW
 HW_sum==SW_sum check. More...
 
Int_t fErrorCount_Sequence
 sequence number check More...
 
Int_t fErrorCount_SameHW
 check to see ADC returning same HW value More...
 
Int_t fErrorCount_ZeroHW
 check to see ADC returning zero More...
 
Int_t fNumEvtsWithEventCutsRejected
 Counts the Event cut rejected events. More...
 
Int_t fADC_Same_NumEvt
 Keep track of how many events with same ADC value returned. More...
 
Int_t fSequenceNo_Prev
 Keep the sequence number of the last event. More...
 
Int_t fSequenceNo_Counter
 Internal counter to keep track of the sequence number. More...
 
Double_t fPrev_HardwareBlockSum
 Previous Module-based sum of the four sub-blocks. More...
 
Double_t fSaturationABSLimit
 absolute value of the VQWK saturation volt More...
 
Bool_t bHw_sum
 
Bool_t bHw_sum_raw
 
Bool_t bBlock
 
Bool_t bBlock_raw
 
Bool_t bNum_samples
 
Bool_t bDevice_Error_Code
 
Bool_t bSequence_number
 
Channel configuration data members
Short_t fBlocksPerEvent
 
Event data members---Raw values
Int_t fBlock_raw [4]
 Array of the sub-block data as read from the module. More...
 
Int_t fHardwareBlockSum_raw
 Module-based sum of the four sub-blocks as read from the module. More...
 
Int_t fSoftwareBlockSum_raw
 Sum of the data in the four sub-blocks raw. More...
 
Event data members---Potentially calibrated values
Double_t fBlock [4]
 Array of the sub-block data. More...
 
Double_t fHardwareBlockSum
 Module-based sum of the four sub-blocks. More...
 
Calculation of the statistical moments
Double_t fBlockM2 [4]
 Second moment of the sub-block. More...
 
Double_t fBlockError [4]
 Uncertainty on the sub-block. More...
 
Double_t fHardwareBlockSumM2
 Second moment of the hardware sum. More...
 
Double_t fHardwareBlockSumError
 Uncertainty on the hardware sum. More...
 

Static Private Attributes

static const Bool_t kDEBUG = kFALSE
 
static const Int_t kWordsPerChannel = 6
 
static const Int_t kMaxChannels = 8
 
static const Bool_t bDEBUG =kFALSE
 debugging display purposes More...
 
ADC Calibration
static const Double_t kVQWK_VoltsPerBit = (20./(1<<18))
 

Friends

std::ostream & operator<< (std::ostream &stream, const QwVQWK_Channel &channel)
 

Additional Inherited Members

- Public Types inherited from VQwDataElement
enum  EDataToSave { kRaw = 0, kDerived }
 
- Protected Attributes inherited from VQwHardwareChannel
UInt_t fNumberOfDataWords
 Number of raw data words in this data element. More...
 
UInt_t fNumberOfSubElements
 Number of subelements in this data element. More...
 
EDataToSave fDataToSave
 
size_t fTreeArrayIndex
 
size_t fTreeArrayNumEntries
 
Double_t fPedestal
 
Double_t fCalibrationFactor
 
Bool_t kFoundPedestal
 
Bool_t kFoundGain
 
Int_t bEVENTCUTMODE
 
Double_t fULimit
 
Double_t fLLimit
 
Double_t fStability
 
- Protected Attributes inherited from VQwDataElement
TString fElementName
 Name of this data element. More...
 
UInt_t fNumberOfDataWords
 Number of raw data words in this data element. More...
 
Int_t fGoodEventCount
 Number of good events accumulated in this element. More...
 
TString fSubsystemName
 
TString fModuleType
 
UInt_t fErrorFlag
 This the standard error code generated for the channel that contains the global/local/stability flags and the Device error code (Unique error code for HW failures) More...
 
UInt_t fErrorConfigFlag
 contains the global/local/stability flags More...
 
- Protected Attributes inherited from MQwHistograms
std::vector< TH1_ptrfHistograms
 Histograms associated with this data element. More...
 
- Protected Attributes inherited from MQwMockable
bool fUseExternalRandomVariable
 Flag to use an externally provided normal random variable. More...
 
double fExternalRandomVariable
 Externally provided normal random variable. More...
 
Double_t fMockAsymmetry
 Helicity asymmetry. More...
 
Double_t fMockGaussianMean
 Mean of normal distribution. More...
 
Double_t fMockGaussianSigma
 Sigma of normal distribution. More...
 
std::vector< Double_t > fMockDriftAmplitude
 Harmonic drift amplitude. More...
 
std::vector< Double_t > fMockDriftFrequency
 Harmonic drift frequency. More...
 
std::vector< Double_t > fMockDriftPhase
 Harmonic drift phase. More...
 
- Static Protected Attributes inherited from MQwMockable
static boost::mt19937 fRandomnessGenerator
 Internal randomness generator. More...
 
static
boost::normal_distribution
< double > 
fNormalDistribution
 Internal normal probability distribution. More...
 
static
boost::variate_generator
< boost::mt19937,
boost::normal_distribution
< double > > 
fNormalRandomVariable
 Internal normal random variable. More...
 

Detailed Description

Definition at line 30 of file QwVQWK_Channel.h.

Constructor & Destructor Documentation

QwVQWK_Channel::QwVQWK_Channel ( )
inline

Definition at line 54 of file QwVQWK_Channel.h.

References InitializeChannel(), and SetVQWKSaturationLimt().

54  : MQwMockable() {
55  InitializeChannel("","");
56  SetVQWKSaturationLimt(8.5);//set the default saturation limit
57  };
void SetVQWKSaturationLimt(Double_t sat_volts=8.5)
void InitializeChannel(TString name, TString datatosave)
Initialize the fields in this object.

+ Here is the call graph for this function:

QwVQWK_Channel::QwVQWK_Channel ( TString  name,
TString  datatosave = "raw" 
)
inline

Definition at line 58 of file QwVQWK_Channel.h.

References InitializeChannel(), and SetVQWKSaturationLimt().

58  : MQwMockable() {
59  InitializeChannel(name, datatosave);
60  SetVQWKSaturationLimt(8.5);//set the default saturation limit
61  };
void SetVQWKSaturationLimt(Double_t sat_volts=8.5)
void InitializeChannel(TString name, TString datatosave)
Initialize the fields in this object.

+ Here is the call graph for this function:

QwVQWK_Channel::QwVQWK_Channel ( const QwVQWK_Channel value)
inline

Definition at line 62 of file QwVQWK_Channel.h.

62  :
63  VQwHardwareChannel(value), MQwMockable(value),
67  {
68  *this = value;
69  };
Short_t fBlocksPerEvent
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 fSaturationABSLimit
absolute value of the VQWK saturation volt
QwVQWK_Channel::QwVQWK_Channel ( const QwVQWK_Channel value,
VQwDataElement::EDataToSave  datatosave 
)
inline

Definition at line 70 of file QwVQWK_Channel.h.

70  :
71  VQwHardwareChannel(value,datatosave), MQwMockable(value),
75  {
76  *this = value;
77  };
Short_t fBlocksPerEvent
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 fSaturationABSLimit
absolute value of the VQWK saturation volt
virtual QwVQWK_Channel::~QwVQWK_Channel ( )
inlinevirtual

Definition at line 78 of file QwVQWK_Channel.h.

78 { };

Member Function Documentation

void QwVQWK_Channel::AccumulateRunningSum ( const QwVQWK_Channel value)
inline

Definition at line 143 of file QwVQWK_Channel.h.

References VQwDataElement::fGoodEventCount.

Referenced by QwEnergyCalculator::AccumulateRunningSum(), QwQPD::AccumulateRunningSum(), QwBPMCavity::AccumulateRunningSum(), QwLinearDiodeArray::AccumulateRunningSum(), QwIntegrationPMT::AccumulateRunningSum(), AccumulateRunningSum(), and DeaccumulateRunningSum().

143  {
145  }
Int_t fGoodEventCount
Number of good events accumulated in this element.
void AccumulateRunningSum(const QwVQWK_Channel &value)

+ Here is the caller graph for this function:

void QwVQWK_Channel::AccumulateRunningSum ( const QwVQWK_Channel value,
Int_t  count 
)

Moments and uncertainty calculation on the running sums and averages The calculation of the first and second moments of the running sum is not completely straightforward due to numerical instabilities associated with small variances and large average values. The naive computation taking the difference of the square of the average and the average of the squares leads to the subtraction of two very large numbers to get a small number.

Alternative algorithms (including for higher order moments) are supplied in Pebay, Philippe (2008), "Formulas for Robust, One-Pass Parallel Computation of Covariances and Arbitrary-Order Statistical Moments", Technical Report SAND2008-6212, Sandia National Laboratories. http://infoserve.sandia.gov/sand_doc/2008/086212.pdf

In the following formulas the moments $ M^1 $ and $ M^2 $ are defined

\begin{eqnarray} M^1 & = & \frac{1}{n} \sum^n y \\ M^2 & = & \sum^n (y - \mu) \end{eqnarray}

Recurrence relations for the addition of a single event:

\begin{eqnarray} M^1_n & = & M^1_{n-1} + \frac{y - M^1_{n-1}}{n} \\ M^2_n & = & M^2_{n-1} + (y - M^1_{n-1})(y - M^1_n) \end{eqnarray}

For the addition of an already accumulated sum:

\begin{eqnarray} M^1 & = & M^1_1 + n_2 \frac{M^1_2 - M^1_1}{n} \\ M^2 & = & M^2_1 + M^2_2 + n_1 n_2 \frac{(M^1_2 - M^1_1)^2}{n} \end{eqnarray}

In these recursive formulas we start from $ M^1 = y $ and $ M^2 = 0 $.

To calculate the mean and standard deviation we use

\begin{eqnarray} \mu & = & M^1 \\ \sigma^2 & = & \frac{1}{n} M^2 \end{eqnarray}

The standard deviation is a biased estimator, but this is what ROOT uses. Better would be to divide by $ (n-1) $.

We use the formulas provided there for the calculation of the first and second moments (i.e. average and variance). Accumulate the running moments M1 and M2

Parameters
valueObject (single event or accumulated) to add to running moments
countNumber of good events in value

Definition at line 1232 of file QwVQWK_Channel.cc.

References QwLog::endl(), fBlock, fBlockM2, VQwDataElement::fErrorFlag, VQwDataElement::fGoodEventCount, fHardwareBlockSum, fHardwareBlockSumM2, fRunningSum, VQwDataElement::GetElementName(), PrintValue(), and QwWarning.

1233 {
1234  // Store pointer to running sum
1235  if (value.fRunningSum == 0) {
1236  QwVQWK_Channel* vqwk = const_cast<QwVQWK_Channel*>(&value);
1237  vqwk->fRunningSum = this;
1238  }
1239 
1240  // Moment calculations
1241  Bool_t berror=kTRUE;//only needed for deaccumulation (stability check purposes)
1242 
1243  /*
1244  note:
1245  The AccumulateRunningSum is called on a dedicated subsystem array object and for the standard running avg computations
1246  we only need value.fErrorFlag==0 events to be included in the running avg. So the "berror" conditions is only used for the stability check purposes.
1247 
1248  The need for this check below came due to fact that when routine DeaccumulateRunningSum is called the errorflag is updated with
1249  the kBeamStabilityError flag (+ configuration flags for global errors) and need to make sure we remove this flag and any configuration flags before
1250  checking the (fErrorFlag != 0) condition
1251 
1252  See how the stability check is implemented in the QwEventRing class
1253 
1254  Rakitha
1255  */
1256 
1257  if (count==-1 && value.fErrorFlag>0){
1258  berror=(((value.fErrorFlag) & 0xFFFFFFF) == 0); //The operation value.fErrorFlag & 0xFFFFFFF set the stability failed error bit to zero //-value.fErrorConfigFlag
1259  if (GetElementName()=="qwk_enegy"){//qwk_target_EffectiveCharge
1260  PrintValue();
1261  }
1262  }
1263 
1264 
1265 
1266  Int_t n1 = fGoodEventCount;
1267  Int_t n2 = count;
1268  // If there are no good events, check the error flag
1269  if (n2 == 0 && (value.fErrorFlag) == 0) {
1270  n2 = 1;
1271  //one event is removed from the sum (Deaccumulation)
1272  }else if (n2 == -1 && berror) { //check only single event cut errors except stability fail flag since by the time the value is deaccumulated this could be flagged as stability failed error.
1273  n2 = -1;
1274  }else
1275  n2 = -100;//ignore it
1276  Int_t n = n1 + n2;
1277  // Set up variables
1278  Double_t M11 = fHardwareBlockSum;
1279  Double_t M12 = value.fHardwareBlockSum;
1280  Double_t M22 = value.fHardwareBlockSumM2;
1281  if (n2 == 0) {
1282  // no good events for addition
1283 
1284  return;
1285  } else if (n2 == -1) {
1286  // simple version for removal of single event from the sum
1287  fGoodEventCount--;
1288  //QwMessage<<"Deaccumulate before "<<QwLog::endl;
1289  if (n>0){
1290  fHardwareBlockSum -= (M12 - M11) / n;
1291  fHardwareBlockSumM2 -= (M12 - M11)
1292  * (M12 - fHardwareBlockSum); // note: using updated mean
1293  // and for individual blocks
1294  for (Int_t i = 0; i < 4; i++) {
1295  M11 = fBlock[i];
1296  M12 = value.fBlock[i];
1297  M22 = value.fBlockM2[i];
1298  fBlock[i] -= (M12 - M11) / n;
1299  fBlockM2[i] -= (M12 - M11) * (M12 - fBlock[i]); // note: using updated mean
1300  }
1301  }else if (n==0){
1302  //QwMessage<<"Deaccumulate at zero "<<QwLog::endl;
1303  /*
1304  //Need any fail safe check for Deaccumulation????
1305  */
1306  }
1307 
1308  } else if (n2 == 1) {
1309  // simple version for addition of single event
1310  fGoodEventCount++;
1311  fHardwareBlockSum += (M12 - M11) / n;
1312  fHardwareBlockSumM2 += (M12 - M11)
1313  * (M12 - fHardwareBlockSum); // note: using updated mean
1314  // and for individual blocks
1315  for (Int_t i = 0; i < 4; i++) {
1316  M11 = fBlock[i];
1317  M12 = value.fBlock[i];
1318  M22 = value.fBlockM2[i];
1319  fBlock[i] += (M12 - M11) / n;
1320  fBlockM2[i] += (M12 - M11) * (M12 - fBlock[i]); // note: using updated mean
1321  }
1322  } else if (n2 > 1) {
1323  // general version for addition of multi-event sets
1324  fGoodEventCount += n2;
1325  fHardwareBlockSum += n2 * (M12 - M11) / n;
1326  fHardwareBlockSumM2 += M22 + n1 * n2 * (M12 - M11) * (M12 - M11) / n;
1327  // and for individual blocks
1328  for (Int_t i = 0; i < 4; i++) {
1329  M11 = fBlock[i];
1330  M12 = value.fBlock[i];
1331  M22 = value.fBlockM2[i];
1332  fBlock[i] += n2 * (M12 - M11) / n;
1333  fBlockM2[i] += M22 + n1 * n2 * (M12 - M11) * (M12 - M11) / n;
1334  }
1335  }
1336 
1337  // Nanny
1339  QwWarning << "Angry Nanny: NaN detected in " << GetElementName() << QwLog::endl;
1340 
1341 
1342 
1343 
1344 }
Double_t fHardwareBlockSumM2
Second moment of the hardware sum.
Double_t fHardwareBlockSum
Module-based sum of the four sub-blocks.
void PrintValue() const
Print single line of value and error of this data element.
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...
QwVQWK_Channel * fRunningSum
Pointer to the running sum for this channel.
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
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.
#define QwWarning
Predefined log drain for warnings.
Definition: QwLog.h:45
Double_t fBlock[4]
Array of the sub-block data.

+ Here is the call graph for this function:

void QwVQWK_Channel::AccumulateRunningSum ( const VQwHardwareChannel value,
Int_t  count 
)
inlinevirtual

Implements VQwHardwareChannel.

Definition at line 147 of file QwVQWK_Channel.h.

References AccumulateRunningSum().

147  {
148  const QwVQWK_Channel *tmp_ptr = dynamic_cast<const QwVQWK_Channel*>(value);
149  if (tmp_ptr != NULL) AccumulateRunningSum(*tmp_ptr, count);
150  };
void AccumulateRunningSum(const QwVQWK_Channel &value)

+ Here is the call graph for this function:

void QwVQWK_Channel::AddChannelOffset ( Double_t  offset)

This function will add a offset to the hw_sum and add the same offset for blocks.

Definition at line 1150 of file QwVQWK_Channel.cc.

References fBlock, fBlocksPerEvent, fHardwareBlockSum, and VQwDataElement::IsNameEmpty().

Referenced by QwBPMCavity::GetAbsolutePosition(), QwLinearDiodeArray::GetAbsolutePosition(), QwEnergyCalculator::ProcessEvent(), and QwBPMCavity::ProcessEvent().

1151 {
1152  if (!IsNameEmpty()){
1153  fHardwareBlockSum += offset;
1154  for (Int_t i=0; i<fBlocksPerEvent; i++) fBlock[i] += offset;
1155  }
1156  return;
1157 }
Short_t fBlocksPerEvent
Bool_t IsNameEmpty() const
Is the name of this element empty?
Double_t fHardwareBlockSum
Module-based sum of the four sub-blocks.
Double_t fBlock[4]
Array of the sub-block data.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwVQWK_Channel::AddErrEntriesToList ( std::vector< QwErrDBInterface > &  row_list)
virtual

Reimplemented from VQwHardwareChannel.

Definition at line 1618 of file QwVQWK_Channel.cc.

References fErrorCount_HWSat, fErrorCount_SameHW, fErrorCount_sample, fErrorCount_Sequence, fErrorCount_SW_HW, fErrorCount_ZeroHW, fNumEvtsWithEventCutsRejected, VQwDataElement::GetElementName(), QwErrDBInterface::Reset(), QwErrDBInterface::SetDeviceName(), QwErrDBInterface::SetErrorCodeId(), and QwErrDBInterface::SetN().

Referenced by QwEnergyCalculator::GetErrDBEntry(), QwQPD::GetErrDBEntry(), QwBPMCavity::GetErrDBEntry(), QwLinearDiodeArray::GetErrDBEntry(), and QwIntegrationPMT::GetErrDBEntry().

1619 {
1620 
1621  // TString message;
1622  // message = Form("%30s",GetElementName().Data());
1623  // message += Form("%9d", fErrorCount_HWSat);
1624  // message += Form("%9d", fErrorCount_sample);
1625  // message += Form("%9d", fErrorCount_SW_HW);
1626  // message += Form("%9d", fErrorCount_Sequence);
1627  // message += Form("%9d", fErrorCount_SameHW);
1628  // message += Form("%9d", fErrorCount_ZeroHW);
1629  // message += Form("%9d", fNumEvtsWithEventCutsRejected);
1630  // QwMessage << message << QwLog::endl;
1631 
1632  // kErrorFlag_VQWK_Sat =0x1; //VQWK Saturation Cut. Currently saturation limit is set to +/-8.5V
1633  // kErrorFlag_sample =0x2; //If sample size mis-matches with the default value in the map file.
1634  // kErrorFlag_SW_HW =0x4; //If software sum and hardware sum are not equal.
1635  // kErrorFlag_Sequence =0x8; //If the ADC sequence number is not incrementing properly
1636  // kErrorFlag_SameHW =0x10; //If ADC value keep returning the same value
1637  // kErrorFlag_ZeroHW =0x20; //Check to see ADC is returning zero
1638 
1639 
1640 
1641  // kErrorFlag_EventCut_L =0x40; //Flagged if lower limit of the event cut has failed
1642  // kErrorFlag_EventCut_U =0x80; //Flagged if upper limit of the event cut has failed
1643  // >>>>>> fNumEvtsWithEventCutsRejected
1644 
1645 
1646  // outside QwVQWK_Channel
1647  // kErrorFlag_BlinderFail = 0x0200;// in Decimal 512 to identify the blinder fail flag
1648  // kStabilityCutError = 0x10000000;// in Decimal 2^28 to identify the stability cut failure
1649 
1650  // This is my modified mysql DB, Thursday, December 8 16:40:36 EST 2011, jhlee
1651  // Error code must be matched to MySQL DB
1652  //
1653  // mysql> select * from error_code;
1654  // +---------------+------------------------------+
1655  // | error_code_id | quantity |
1656  // +---------------+------------------------------+
1657  // | 1 | kErrorFlag_VQWK_Sat |
1658  // | 2 | kErrorFlag_sample |
1659  // | 3 | kErrorFlag_SW_HW |
1660  // | 4 | kErrorFlag_Sequence |
1661  // | 5 | kErrorFlag_SameHW |
1662  // | 6 | kErrorFlag_ZeroHW |
1663  // | 7 | kErrorFlag_EventCut_Rejected |
1664  // | 8 | kErrorFlag_EventCut_L |
1665  // | 9 | kErrorFlag_EventCut_U |
1666  // | 10 | kErrorFlag_BlinderFail |
1667  // | 11 | kStabilityCutError |
1668  // +---------------+------------------------------+
1669  // 11 rows in set (0.00 sec)
1670 
1671 
1672  QwErrDBInterface row;
1673  TString name = GetElementName();
1674 
1675  row.Reset();
1676  row.SetDeviceName(name);
1677  row.SetErrorCodeId(1);
1678  row.SetN(fErrorCount_HWSat);
1679  row_list.push_back(row);
1680 
1681  row.Reset();
1682  row.SetDeviceName(name);
1683  row.SetErrorCodeId(2);
1684  row.SetN(fErrorCount_sample);
1685  row_list.push_back(row);
1686 
1687  row.Reset();
1688  row.SetDeviceName(name);
1689  row.SetErrorCodeId(3);
1690  row.SetN(fErrorCount_SW_HW);
1691  row_list.push_back(row);
1692 
1693 
1694  row.Reset();
1695  row.SetDeviceName(name);
1696  row.SetErrorCodeId(4);
1698  row_list.push_back(row);
1699 
1700 
1701  row.Reset();
1702  row.SetDeviceName(name);
1703  row.SetErrorCodeId(5);
1704  row.SetN(fErrorCount_SameHW);
1705  row_list.push_back(row);
1706 
1707  row.Reset();
1708  row.SetDeviceName(name);
1709  row.SetErrorCodeId(6);
1710  row.SetN(fErrorCount_ZeroHW);
1711  row_list.push_back(row);
1712 
1713 
1714  row.Reset();
1715  row.SetDeviceName(name);
1716  row.SetErrorCodeId(7);
1718  row_list.push_back(row);
1719  return;
1720 
1721 }
Int_t fErrorCount_Sequence
sequence number check
Int_t fErrorCount_sample
for sample size check
Int_t fErrorCount_ZeroHW
check to see ADC returning zero
Int_t fErrorCount_SW_HW
HW_sum==SW_sum check.
Int_t fErrorCount_HWSat
check to see ADC channel is saturated
Int_t fErrorCount_SameHW
check to see ADC returning same HW value
void SetN(UInt_t in)
void SetErrorCodeId(UInt_t in)
Int_t fNumEvtsWithEventCutsRejected
Counts the Event cut rejected events.
virtual const TString & GetElementName() const
Get the name of this element.
void SetDeviceName(TString &in)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwVQWK_Channel::AddValueFrom ( const VQwHardwareChannel valueptr)
virtual

Implements VQwHardwareChannel.

Definition at line 846 of file QwVQWK_Channel.cc.

References VQwDataElement::GetElementName().

847 {
848  const QwVQWK_Channel* tmpptr;
849  tmpptr = dynamic_cast<const QwVQWK_Channel*>(valueptr);
850  if (tmpptr!=NULL){
851  *this += *tmpptr;
852  } else {
853  TString loc="Standard exception from QwVQWK_Channel::AddValueFrom = "
854  +valueptr->GetElementName()+" is an incompatable type.";
855  throw std::invalid_argument(loc.Data());
856  }
857 }
virtual const TString & GetElementName() const
Get the name of this element.

+ Here is the call graph for this function:

Int_t QwVQWK_Channel::ApplyHWChecks ( )
virtual

Implements VQwHardwareChannel.

Definition at line 54 of file QwVQWK_Channel.cc.

References bDEBUG, VQwHardwareChannel::bEVENTCUTMODE, QwLog::endl(), fADC_Same_NumEvt, VQwDataElement::fErrorFlag, VQwDataElement::fGoodEventCount, fNumberOfSamples, fNumberOfSamples_map, fPrev_HardwareBlockSum, fSequenceNo_Counter, fSequenceNo_Prev, VQwDataElement::GetElementName(), GetNumberOfSamples(), GetRawHardwareSum(), GetRawSoftwareSum(), GetSequenceNumber(), GetVQWKSaturationLimt(), kErrorFlag_SameHW, kErrorFlag_sample, kErrorFlag_Sequence, kErrorFlag_SW_HW, kErrorFlag_VQWK_Sat, kErrorFlag_ZeroHW, kVQWK_VoltsPerBit, MatchNumberOfSamples(), MatchSequenceNumber(), and QwWarning.

Referenced by QwQPD::ApplyHWChecks(), QwBPMCavity::ApplyHWChecks(), QwLinearDiodeArray::ApplyHWChecks(), and QwIntegrationPMT::ApplyHWChecks().

55 {
56  Bool_t fEventIsGood=kTRUE;
57  Bool_t bStatus;
58  if (bEVENTCUTMODE>0){//Global switch to ON/OFF event cuts set at the event cut file
59 
60  if (bDEBUG)
61  QwWarning<<" QwQWVK_Channel "<<GetElementName()<<" "<<GetNumberOfSamples()<<QwLog::endl;
62 
63  // Sample size check
64  bStatus = MatchNumberOfSamples(fNumberOfSamples_map);//compare the default sample size with no.of samples read by the module
65  if (!bStatus) {
67  }
68 
69  // Check SW and HW return the same sum
70  bStatus = (GetRawHardwareSum() == GetRawSoftwareSum());
71  //fEventIsGood = bStatus;
72  if (!bStatus) {
74  }
75 
76 
77 
78  //check sequence number
80  if (fSequenceNo_Counter==0 || GetSequenceNumber()==0){//starting the data run
82  }
83 
84  if (!MatchSequenceNumber(fSequenceNo_Prev)){//we have a sequence number error
85  fEventIsGood=kFALSE;
87  if (bDEBUG) QwWarning<<" QwQWVK_Channel "<<GetElementName()<<" Sequence number previous value = "<<fSequenceNo_Prev<<" Current value= "<< GetSequenceNumber()<<QwLog::endl;
88  }
89 
91 
92  //Checking for HW_sum is returning same value.
94  //std::cout<<" BCM hardware sum is different "<<std::endl;
97  }else
98  fADC_Same_NumEvt++;//hw_sum is same increment the counter
99 
100  //check for the hw_sum is giving the same value
101  if (fADC_Same_NumEvt>0){//we have ADC stuck with same value
102  if (bDEBUG) QwWarning<<" BCM hardware sum is same for more than "<<fADC_Same_NumEvt<<" time consecutively "<<QwLog::endl;
104  }
105 
106  //check for the hw_sum is zero
107  if (GetRawHardwareSum()==0){
109  }
110  if (!fEventIsGood)
111  fSequenceNo_Counter=0;//resetting the counter after ApplyHWChecks() a failure
112 
114  if (bDEBUG)
115  QwWarning << this->GetElementName()<<" "<<GetRawHardwareSum() << "Saturating VQWK invoked! " <<TMath::Abs(GetRawHardwareSum())*kVQWK_VoltsPerBit/fNumberOfSamples<<" Limit "<<GetVQWKSaturationLimt() << QwLog::endl;
117  }
118 
119  }
120  else {
121  fGoodEventCount = 1;
122  fErrorFlag = 0;
123  }
124 
125  return fErrorFlag;
126 }
static const UInt_t kErrorFlag_SW_HW
Definition: QwTypes.h:160
static const UInt_t kErrorFlag_ZeroHW
Definition: QwTypes.h:163
Int_t GetRawSoftwareSum() const
size_t GetNumberOfSamples() const
static const UInt_t kErrorFlag_sample
Definition: QwTypes.h:159
Bool_t MatchNumberOfSamples(size_t numsamp)
static const UInt_t kErrorFlag_SameHW
Definition: QwTypes.h:162
size_t fNumberOfSamples_map
Number of samples in the expected to read through the module. This value is set in the QwBeamline map...
Int_t GetRawHardwareSum() const
Int_t fSequenceNo_Counter
Internal counter to keep track of the sequence number.
static const UInt_t kErrorFlag_Sequence
Definition: QwTypes.h:161
Double_t fPrev_HardwareBlockSum
Previous Module-based sum of the four sub-blocks.
Int_t fSequenceNo_Prev
Keep the sequence number of the last event.
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...
static const Double_t kVQWK_VoltsPerBit
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
Int_t fGoodEventCount
Number of good events accumulated in this element.
virtual const TString & GetElementName() const
Get the name of this element.
Int_t fADC_Same_NumEvt
Keep track of how many events with same ADC value returned.
size_t fNumberOfSamples
Number of samples read through the module.
size_t GetSequenceNumber() const
#define QwWarning
Predefined log drain for warnings.
Definition: QwLog.h:45
static const Bool_t bDEBUG
debugging display purposes
static const UInt_t kErrorFlag_VQWK_Sat
Definition: QwTypes.h:158
Double_t GetVQWKSaturationLimt()
Bool_t MatchSequenceNumber(size_t seqnum)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Bool_t QwVQWK_Channel::ApplySingleEventCuts ( Double_t  LL,
Double_t  UL 
)

Definition at line 1492 of file QwVQWK_Channel.cc.

References VQwDataElement::fErrorFlag, GetHardwareSum(), and kPreserveError.

Referenced by QwEnergyCalculator::ApplySingleEventCuts(), QwQPD::ApplySingleEventCuts(), QwBPMCavity::ApplySingleEventCuts(), QwLinearDiodeArray::ApplySingleEventCuts(), and QwIntegrationPMT::ApplySingleEventCuts().

1493 {
1494  Bool_t status = kFALSE;
1495 
1496  if (LL==0 && UL==0){
1497  status=kTRUE;
1498  } else if (GetHardwareSum()<=UL && GetHardwareSum()>=LL){
1499  if ((fErrorFlag & kPreserveError)!=0)
1500  status=kTRUE;
1501  else
1502  status=kFALSE;//If the device HW is failed
1503  }
1504  std::cout<<(this->fErrorFlag & kPreserveError)<<std::endl;
1505  return status;
1506 }
static const UInt_t kPreserveError
Definition: QwTypes.h:179
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...
Double_t GetHardwareSum() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Bool_t QwVQWK_Channel::ApplySingleEventCuts ( )
virtual

Implements VQwHardwareChannel.

Definition at line 1508 of file QwVQWK_Channel.cc.

References VQwHardwareChannel::bEVENTCUTMODE, VQwDataElement::fErrorFlag, VQwHardwareChannel::fLLimit, VQwHardwareChannel::fULimit, GetHardwareSum(), kErrorFlag_EventCut_L, and kErrorFlag_EventCut_U.

1509 {
1510  Bool_t status;
1511 
1512  if (bEVENTCUTMODE>=2){//Global switch to ON/OFF event cuts set at the event cut file
1513 
1514  if (fULimit==0 && fLLimit==0){
1515  status=kTRUE;
1516  } else if (GetHardwareSum()<=fULimit && GetHardwareSum()>=fLLimit){
1517  if ((fErrorFlag)==0)
1518  status=kTRUE;
1519  else
1520  status=kFALSE;//If the device HW is failed
1521  }
1522  else{
1523  if (GetHardwareSum()> fULimit)
1525  else
1527  status=kFALSE;
1528  }
1529 
1530  if (bEVENTCUTMODE==3){
1531  status=kTRUE; //Update the event cut fail flag but pass the event.
1532  }
1533 
1534 
1535  }
1536  else{
1537  status=kTRUE;
1538  //fErrorFlag=0;//we need to keep the device error codes
1539  }
1540 
1541  return status;
1542 }
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...
static const UInt_t kErrorFlag_EventCut_L
Definition: QwTypes.h:164
Double_t GetHardwareSum() const
static const UInt_t kErrorFlag_EventCut_U
Definition: QwTypes.h:165

+ Here is the call graph for this function:

void QwVQWK_Channel::AssignScaledValue ( const QwVQWK_Channel value,
Double_t  scale 
)

Definition at line 811 of file QwVQWK_Channel.cc.

References fBlock, fBlock_raw, fBlockM2, fBlocksPerEvent, VQwDataElement::fErrorFlag, VQwDataElement::fGoodEventCount, fHardwareBlockSum, fHardwareBlockSum_raw, fHardwareBlockSumError, fHardwareBlockSumM2, fNumberOfSamples, fSequenceNumber, fSoftwareBlockSum_raw, and VQwDataElement::IsNameEmpty().

813 {
814  if(this == &value) return;
815 
816  if (!IsNameEmpty()) {
817  for (Int_t i=0; i<fBlocksPerEvent; i++){
818  this->fBlock_raw[i] = value.fBlock_raw[i]; // Keep this?
819  this->fBlock[i] = value.fBlock[i] * scale;
820  this->fBlockM2[i] = value.fBlockM2[i] * scale * scale;
821  }
822  this->fHardwareBlockSum_raw = value.fHardwareBlockSum_raw; // Keep this?
823  this->fSoftwareBlockSum_raw = value.fSoftwareBlockSum_raw; // Keep this?
824  this->fHardwareBlockSum = value.fHardwareBlockSum * scale;
825  this->fHardwareBlockSumM2 = value.fHardwareBlockSumM2 * scale * scale;
826  this->fHardwareBlockSumError = value.fHardwareBlockSumError; // Keep this?
827  this->fGoodEventCount = value.fGoodEventCount;
828  this->fNumberOfSamples = value.fNumberOfSamples;
829  this->fSequenceNumber = value.fSequenceNumber;
830  this->fErrorFlag = value.fErrorFlag;
831  }
832 }
Short_t fBlocksPerEvent
Bool_t IsNameEmpty() const
Is the name of this element empty?
Double_t fHardwareBlockSumM2
Second moment of the hardware sum.
Double_t fHardwareBlockSumError
Uncertainty on the hardware sum.
Int_t fHardwareBlockSum_raw
Module-based sum of the four sub-blocks as read from the module.
size_t fSequenceNumber
Event sequence number for this channel.
Int_t fSoftwareBlockSum_raw
Sum of the data in the four sub-blocks raw.
Double_t fHardwareBlockSum
Module-based sum of the four sub-blocks.
Int_t fBlock_raw[4]
Array of the sub-block data as read from the module.
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...
Int_t fGoodEventCount
Number of good events accumulated in this element.
Double_t fBlockM2[4]
Second moment of the sub-block.
size_t fNumberOfSamples
Number of samples read through the module.
Double_t fBlock[4]
Array of the sub-block data.

+ Here is the call graph for this function:

void QwVQWK_Channel::AssignValueFrom ( const VQwDataElement valueptr)
virtual

Implements VQwHardwareChannel.

Definition at line 834 of file QwVQWK_Channel.cc.

References VQwDataElement::GetElementName().

Referenced by QwEnergyCalculator::ProcessEvent().

835 {
836  const QwVQWK_Channel* tmpptr;
837  tmpptr = dynamic_cast<const QwVQWK_Channel*>(valueptr);
838  if (tmpptr!=NULL){
839  *this = *tmpptr;
840  } else {
841  TString loc="Standard exception from QwVQWK_Channel::AssignValueFrom = "
842  +valueptr->GetElementName()+" is an incompatable type.";
843  throw std::invalid_argument(loc.Data());
844  }
845 }
virtual const TString & GetElementName() const
Get the name of this element.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwVQWK_Channel::Blind ( const QwBlinder blinder)

Blind this channel as an asymmetry.

Blind this channel as an asymmetry

Parameters
blinderBlinder

Definition at line 1427 of file QwVQWK_Channel.cc.

References QwBlinder::BlindValue(), fBlock, fBlocksPerEvent, VQwDataElement::fErrorFlag, fHardwareBlockSum, QwBlinder::IsBlinderOkay(), VQwDataElement::IsNameEmpty(), and QwBlinder::ModifyThisErrorCode().

Referenced by QwIntegrationPMT::Blind().

1428 {
1429  if (!IsNameEmpty()) {
1430  if (blinder->IsBlinderOkay() && ((fErrorFlag)==0) ){
1431  for (Int_t i = 0; i < fBlocksPerEvent; i++)
1432  blinder->BlindValue(fBlock[i]);
1433  blinder->BlindValue(fHardwareBlockSum);
1434  } else {
1435  blinder->ModifyThisErrorCode(fErrorFlag);
1436  for (Int_t i = 0; i < fBlocksPerEvent; i++) fBlock[i] = 0.0;
1437  fHardwareBlockSum = 0.0;
1438  }
1439  }
1440  return;
1441 }
Short_t fBlocksPerEvent
const Bool_t & IsBlinderOkay() const
Definition: QwBlinder.h:193
void BlindValue(Double_t &value) const
Asymmetry blinding.
Definition: QwBlinder.h:124
Bool_t IsNameEmpty() const
Is the name of this element empty?
void ModifyThisErrorCode(UInt_t &errorcode) const
Definition: QwBlinder.h:119
Double_t fHardwareBlockSum
Module-based sum of the four sub-blocks.
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...
Double_t fBlock[4]
Array of the sub-block data.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwVQWK_Channel::Blind ( const QwBlinder blinder,
const QwVQWK_Channel yield 
)

Blind this channel as a difference.

Blind this channel as a difference with specified yield

Parameters
blinderBlinder
yieldCorresponding yield

Definition at line 1448 of file QwVQWK_Channel.cc.

References QwBlinder::BlindValue(), fBlock, fBlocksPerEvent, VQwDataElement::fErrorFlag, fHardwareBlockSum, QwBlinder::IsBlinderOkay(), VQwDataElement::IsNameEmpty(), and QwBlinder::ModifyThisErrorCode().

1449 {
1450  if (!IsNameEmpty()) {
1451  if (blinder->IsBlinderOkay() && ((fErrorFlag) ==0) ){
1452  for (Int_t i = 0; i < fBlocksPerEvent; i++)
1453  blinder->BlindValue(fBlock[i], yield.fBlock[i]);
1455  } else {
1456  blinder->ModifyThisErrorCode(fErrorFlag);//update the HW error code
1457  for (Int_t i = 0; i < fBlocksPerEvent; i++) fBlock[i] = 0.0;
1458  fHardwareBlockSum = 0.0;
1459  }
1460  }
1461  return;
1462 }
Short_t fBlocksPerEvent
const Bool_t & IsBlinderOkay() const
Definition: QwBlinder.h:193
void BlindValue(Double_t &value) const
Asymmetry blinding.
Definition: QwBlinder.h:124
Bool_t IsNameEmpty() const
Is the name of this element empty?
void ModifyThisErrorCode(UInt_t &errorcode) const
Definition: QwBlinder.h:119
Double_t fHardwareBlockSum
Module-based sum of the four sub-blocks.
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...
Double_t fBlock[4]
Array of the sub-block data.

+ Here is the call graph for this function:

void QwVQWK_Channel::CalculateRunningAverage ( )
virtual

Implements VQwHardwareChannel.

Definition at line 1347 of file QwVQWK_Channel.cc.

References fBlockError, fBlockM2, fBlocksPerEvent, VQwDataElement::fErrorConfigFlag, VQwDataElement::fErrorFlag, VQwDataElement::fGoodEventCount, fHardwareBlockSumError, fHardwareBlockSumM2, VQwHardwareChannel::fStability, VQwHardwareChannel::GetValueWidth(), kBeamStabilityError, and kStabilityCut.

Referenced by QwEnergyCalculator::CalculateRunningAverage(), QwQPD::CalculateRunningAverage(), QwBPMCavity::CalculateRunningAverage(), QwLinearDiodeArray::CalculateRunningAverage(), and QwIntegrationPMT::CalculateRunningAverage().

1348 {
1349  /*
1350  if (GetElementName()=="qwk_engy"){//qwk_target_EffectiveCharge
1351  PrintValue();
1352  }
1353  */
1354 
1355  if (fGoodEventCount <= 0)
1356  {
1357  for (Int_t i = 0; i < fBlocksPerEvent; i++) {
1358  fBlockError[i] = 0.0;
1359  }
1360  fHardwareBlockSumError = 0.0;
1361  }
1362  else
1363  {
1364  // We use a biased estimator by dividing by n. Use (n - 1) to get the
1365  // unbiased estimator for the standard deviation.
1366  //
1367  // Note we want to calculate the error here, not sigma:
1368  // sigma = sqrt(M2 / n);
1369  // error = sigma / sqrt (n) = sqrt(M2) / n;
1370  for (Int_t i = 0; i < fBlocksPerEvent; i++)
1371  fBlockError[i] = sqrt(fBlockM2[i]) / fGoodEventCount;
1373  //Stability check 83951872
1374  if ((fStability>0) &&( (fErrorConfigFlag & kStabilityCut)==kStabilityCut)){//check to see the channel has stability cut activated in the event cut file
1375  /*
1376  //for Debugging
1377  PrintValue();
1378  */
1379  if (GetValueWidth()>fStability){//if the width is greater than the stability required flag the event
1381  }else
1382  fErrorFlag=0;
1383  }
1384 
1385  }
1386 }
Short_t fBlocksPerEvent
Double_t fHardwareBlockSumM2
Second moment of the hardware sum.
Double_t fHardwareBlockSumError
Uncertainty on the hardware sum.
Double_t fBlockError[4]
Uncertainty on the sub-block.
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...
static const UInt_t kBeamStabilityError
Definition: QwTypes.h:174
UInt_t fErrorConfigFlag
contains the global/local/stability flags
Int_t fGoodEventCount
Number of good events accumulated in this element.
Double_t fBlockM2[4]
Second moment of the sub-block.
Double_t GetValueWidth() const
static const UInt_t kStabilityCut
Definition: QwTypes.h:178

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwVQWK_Channel::ClearEventData ( )
virtual

Clear the event data in this element.

Reimplemented from VQwHardwareChannel.

Definition at line 241 of file QwVQWK_Channel.cc.

References fBlock, fBlock_raw, fBlockError, fBlockM2, fBlocksPerEvent, VQwDataElement::fErrorFlag, VQwDataElement::fGoodEventCount, fHardwareBlockSum, fHardwareBlockSum_raw, fHardwareBlockSumError, fHardwareBlockSumM2, fNumberOfSamples, fSequenceNumber, and fSoftwareBlockSum_raw.

Referenced by QwEnergyCalculator::ClearEventData(), QwBPMCavity::ClearEventData(), QwLinearDiodeArray::ClearEventData(), QwQPD::ClearEventData(), QwIntegrationPMT::ClearEventData(), InitializeChannel(), QwEnergyCalculator::ProcessEvent(), QwQPD::ProcessEvent(), and QwLinearDiodeArray::ProcessEvent().

242 {
243  for (Int_t i = 0; i < fBlocksPerEvent; i++) {
244  fBlock_raw[i] = 0;
245  fBlock[i] = 0.0;
246  fBlockM2[i] = 0.0;
247  fBlockError[i] = 0.0;
248  }
251  fHardwareBlockSum = 0.0;
252  fHardwareBlockSumM2 = 0.0;
254  fSequenceNumber = 0;
255  fNumberOfSamples = 0;
256  fGoodEventCount = 0;
257  fErrorFlag=0;
258  return;
259 }
Short_t fBlocksPerEvent
Double_t fHardwareBlockSumM2
Second moment of the hardware sum.
Double_t fHardwareBlockSumError
Uncertainty on the hardware sum.
Int_t fHardwareBlockSum_raw
Module-based sum of the four sub-blocks as read from the module.
size_t fSequenceNumber
Event sequence number for this channel.
Int_t fSoftwareBlockSum_raw
Sum of the data in the four sub-blocks raw.
Double_t fHardwareBlockSum
Module-based sum of the four sub-blocks.
Double_t fBlockError[4]
Uncertainty on the sub-block.
Int_t fBlock_raw[4]
Array of the sub-block data as read from the module.
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...
Int_t fGoodEventCount
Number of good events accumulated in this element.
Double_t fBlockM2[4]
Second moment of the sub-block.
size_t fNumberOfSamples
Number of samples read through the module.
Double_t fBlock[4]
Array of the sub-block data.

+ Here is the caller graph for this function:

void QwVQWK_Channel::ConstructBranch ( TTree *  tree,
TString &  prefix 
)
virtual

Implements VQwHardwareChannel.

Definition at line 687 of file QwVQWK_Channel.cc.

References fHardwareBlockSum, VQwHardwareChannel::fTreeArrayIndex, VQwHardwareChannel::fTreeArrayNumEntries, VQwDataElement::GetElementName(), VQwDataElement::IsNameEmpty(), and kDEBUG.

Referenced by QwEnergyCalculator::ConstructBranch(), QwQPD::ConstructBranch(), QwBPMCavity::ConstructBranch(), QwLinearDiodeArray::ConstructBranch(), and QwIntegrationPMT::ConstructBranch().

688 {
689  if (IsNameEmpty()){
690  // This channel is not used, so skip setting up the tree.
691  } else {
692  TString basename = prefix + GetElementName();
693  tree->Branch(basename,&fHardwareBlockSum,basename+"/D");
694  if (kDEBUG){
695  std::cerr << "QwVQWK_Channel::ConstructBranchAndVector: fTreeArrayIndex==" << fTreeArrayIndex
696  << "; fTreeArrayNumEntries==" << fTreeArrayNumEntries
697  << std::endl;
698  }
699  }
700  return;
701 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
static const Bool_t kDEBUG
Double_t fHardwareBlockSum
Module-based sum of the four sub-blocks.
virtual const TString & GetElementName() const
Get the name of this element.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwVQWK_Channel::ConstructBranchAndVector ( TTree *  tree,
TString &  prefix,
std::vector< Double_t > &  values 
)
virtual

Implements VQwHardwareChannel.

Definition at line 591 of file QwVQWK_Channel.cc.

References bBlock, bBlock_raw, bDevice_Error_Code, bHw_sum, bHw_sum_raw, bNum_samples, bSequence_number, QwLog::endl(), VQwHardwareChannel::fDataToSave, VQwHardwareChannel::fTreeArrayIndex, VQwHardwareChannel::fTreeArrayNumEntries, VQwDataElement::GetElementName(), VQwDataElement::GetModuleType(), VQwDataElement::GetSubsystemName(), gQwHists, VQwDataElement::IsNameEmpty(), kDEBUG, VQwDataElement::kRaw, QwHistogramHelper::MatchDeviceParamsFromList(), QwHistogramHelper::MatchVQWKElementFromList(), and QwMessage.

Referenced by QwEnergyCalculator::ConstructBranchAndVector(), QwQPD::ConstructBranchAndVector(), QwBPMCavity::ConstructBranchAndVector(), QwLinearDiodeArray::ConstructBranchAndVector(), and QwIntegrationPMT::ConstructBranchAndVector().

592 {
593 
594  if (IsNameEmpty()){
595  // This channel is not used, so skip setting up the tree.
596  } else {
597  TString basename = prefix + GetElementName();
598  fTreeArrayIndex = values.size();
599 
600  TString list="";
601 
607  bDevice_Error_Code=gQwHists.MatchVQWKElementFromList(GetSubsystemName().Data(), GetModuleType().Data(), "Device_Error_Code");
609 
610  if (bHw_sum){
611  values.push_back(0.0);
612  list += "hw_sum/D";
613  }
614  if (bBlock){
615  values.push_back(0.0);
616  list += ":block0/D";
617 
618  values.push_back(0.0);
619  list += ":block1/D";
620 
621  values.push_back(0.0);
622  list += ":block2/D";
623 
624  values.push_back(0.0);
625  list += ":block3/D";
626  }
627 
628  if (bNum_samples){
629  values.push_back(0.0);
630  list += ":num_samples/D";
631  }
632 
633  if (bDevice_Error_Code){
634  values.push_back(0.0);
635  list += ":Device_Error_Code/D";
636  }
637 
638  if(fDataToSave==kRaw)
639  {
640  if (bHw_sum_raw){
641  values.push_back(0.0);
642  list += ":hw_sum_raw/D";
643  }
644  if (bBlock_raw){
645  values.push_back(0.0);
646  list += ":block0_raw/D";
647 
648  values.push_back(0.0);
649  list += ":block1_raw/D";
650 
651  values.push_back(0.0);
652  list += ":block2_raw/D";
653 
654  values.push_back(0.0);
655  list += ":block3_raw/D";
656  }
657  if (bSequence_number){
658  values.push_back(0.0);
659  list += ":sequence_number/D";
660  }
661  }
662 
663  fTreeArrayNumEntries = values.size() - fTreeArrayIndex;
664 
666 
667  if (list=="hw_sum/D")//this is for the RT mode
668  list=basename+"/D";
669 
670  if (kDEBUG)
671  QwMessage <<"base name "<<basename<<" List "<<list<< QwLog::endl;
672  tree->Branch(basename, &(values[fTreeArrayIndex]), list);
673  }
674 
675  if (kDEBUG){
676  std::cerr << "QwVQWK_Channel::ConstructBranchAndVector: fTreeArrayIndex==" << fTreeArrayIndex
677  << "; fTreeArrayNumEntries==" << fTreeArrayNumEntries
678  << "; values.size()==" << values.size()
679  << "; list==" << list
680  << std::endl;
681  }
682  }
683  //exit(1);
684  return;
685 }
#define QwMessage
Predefined log drain for regular messages.
Definition: QwLog.h:50
Bool_t IsNameEmpty() const
Is the name of this element empty?
Bool_t bDevice_Error_Code
TString GetModuleType() const
Return the type of the beam instrument.
Bool_t MatchDeviceParamsFromList(const std::string &devicename)
static const Bool_t kDEBUG
Bool_t MatchVQWKElementFromList(const std::string &subsystemname, const std::string &moduletype, const std::string &devicename)
Bool_t bSequence_number
TString GetSubsystemName() const
Return the name of the inheriting subsystem name.
QwHistogramHelper gQwHists
Globally defined instance of the QwHistogramHelper class.
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
virtual const TString & GetElementName() const
Get the name of this element.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwVQWK_Channel::ConstructHistograms ( TDirectory *  folder,
TString &  prefix 
)
virtual

Construct the histograms for this data element.

Implements VQwDataElement.

Definition at line 481 of file QwVQWK_Channel.cc.

References QwHistogramHelper::Construct1DHist(), fBlocksPerEvent, VQwHardwareChannel::fDataToSave, MQwHistograms::fHistograms, VQwDataElement::GetElementName(), gQwHists, VQwDataElement::IsNameEmpty(), VQwDataElement::kDerived, and VQwDataElement::kRaw.

Referenced by QwEnergyCalculator::ConstructHistograms(), QwQPD::ConstructHistograms(), QwBPMCavity::ConstructHistograms(), QwLinearDiodeArray::ConstructHistograms(), and QwIntegrationPMT::ConstructHistograms().

482 {
483  // If we have defined a subdirectory in the ROOT file, then change into it.
484  if (folder != NULL) folder->cd();
485 
486  if (IsNameEmpty()){
487  // This channel is not used, so skip filling the histograms.
488  } else {
489  // Now create the histograms.
490  if (prefix == TString("asym_")
491  || prefix == TString("diff_")
492  || prefix == TString("yield_"))
494 
495  TString basename, fullname;
496  basename = prefix + GetElementName();
497 
498  if(fDataToSave==kRaw)
499  {
500  fHistograms.resize(8+2+1, NULL);
501  size_t index=0;
502  for (Int_t i=0; i<fBlocksPerEvent; i++){
503  fHistograms[index] = gQwHists.Construct1DHist(basename+Form("_block%d_raw",i));
504  fHistograms[index+1] = gQwHists.Construct1DHist(basename+Form("_block%d",i));
505  index += 2;
506  }
507  fHistograms[index] = gQwHists.Construct1DHist(basename+Form("_hw_raw"));
508  fHistograms[index+1] = gQwHists.Construct1DHist(basename+Form("_hw"));
509  index += 2;
510  fHistograms[index] = gQwHists.Construct1DHist(basename+Form("_sw-hw_raw"));
511  }
512  else if(fDataToSave==kDerived)
513  {
514  fHistograms.resize(4+1+1, NULL);
515  Int_t index=0;
516  for (Int_t i=0; i<fBlocksPerEvent; i++){
517  fHistograms[index] = gQwHists.Construct1DHist(basename+Form("_block%d",i));
518  index += 1;
519  }
520  fHistograms[index] = gQwHists.Construct1DHist(basename+Form("_hw"));
521  index += 1;
522  fHistograms[index] = gQwHists.Construct1DHist(basename+Form("_dev_err"));
523  index += 1;
524  }
525  else
526  {
527  // this is not recognized
528  }
529 
530  }
531 }
Short_t fBlocksPerEvent
Bool_t IsNameEmpty() const
Is the name of this element empty?
std::vector< TH1_ptr > fHistograms
Histograms associated with this data element.
Definition: MQwHistograms.h:46
QwHistogramHelper gQwHists
Globally defined instance of the QwHistogramHelper class.
virtual const TString & GetElementName() const
Get the name of this element.
TH1F * Construct1DHist(const TString &inputfile, const TString &name_title)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwVQWK_Channel::DeaccumulateRunningSum ( const QwVQWK_Channel value)
inline

Definition at line 152 of file QwVQWK_Channel.h.

References AccumulateRunningSum().

Referenced by QwEnergyCalculator::DeaccumulateRunningSum(), QwQPD::DeaccumulateRunningSum(), QwBPMCavity::DeaccumulateRunningSum(), QwLinearDiodeArray::DeaccumulateRunningSum(), and QwIntegrationPMT::DeaccumulateRunningSum().

152  {
153  AccumulateRunningSum(value, -1);
154  };
void AccumulateRunningSum(const QwVQWK_Channel &value)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwVQWK_Channel::Difference ( const QwVQWK_Channel value1,
const QwVQWK_Channel value2 
)

Definition at line 1042 of file QwVQWK_Channel.cc.

Referenced by QwLinearDiodeArray::ProcessEvent(), and QwQPD::ProcessEvent().

1043 {
1044  *this = value1;
1045  *this -= value2;
1046 }

+ Here is the caller graph for this function:

void QwVQWK_Channel::DivideBy ( const VQwHardwareChannel valueptr)
virtual

Implements VQwHardwareChannel.

Definition at line 882 of file QwVQWK_Channel.cc.

References VQwDataElement::GetElementName().

Referenced by QwIntegrationPMT::Normalize().

883 {
884  const QwVQWK_Channel* tmpptr;
885  tmpptr = dynamic_cast<const QwVQWK_Channel*>(valueptr);
886  if (tmpptr!=NULL){
887  *this /= *tmpptr;
888  } else {
889  TString loc="Standard exception from QwVQWK_Channel::DivideBy = "
890  +valueptr->GetElementName()+" is an incompatable type.";
891  throw std::invalid_argument(loc.Data());
892  }
893 }
virtual const TString & GetElementName() const
Get the name of this element.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwVQWK_Channel::DivideBy ( const QwVQWK_Channel denom)

Definition at line 1173 of file QwVQWK_Channel.cc.

1174 {
1175  *this /= denom;
1176 }
void QwVQWK_Channel::EncodeEventData ( std::vector< UInt_t > &  buffer)
virtual

Encode the event data into a CODA buffer.

Implements MQwMockable.

Definition at line 331 of file QwVQWK_Channel.cc.

References fBlock_raw, fHardwareBlockSum_raw, fNumberOfSamples, fSequenceNumber, and VQwDataElement::IsNameEmpty().

Referenced by QwIntegrationPMT::EncodeEventData().

332 {
333  Long_t localbuf[6] = {0};
334 
335  if (IsNameEmpty()) {
336  // This channel is not used, but is present in the data stream.
337  // Skip over this data.
338  } else {
339  // localbuf[4] = 0;
340  for (Int_t i = 0; i < 4; i++) {
341  localbuf[i] = fBlock_raw[i];
342  // localbuf[4] += localbuf[i]; // fHardwareBlockSum_raw
343  }
344  // The following causes many rounding errors and skips due to the check
345  // that fHardwareBlockSum_raw == fSoftwareBlockSum_raw in IsGoodEvent().
346  localbuf[4] = fHardwareBlockSum_raw;
347  localbuf[5] = (fNumberOfSamples << 16 & 0xFFFF0000)
348  | (fSequenceNumber << 8 & 0x0000FF00);
349 
350  for (Int_t i = 0; i < 6; i++){
351  buffer.push_back(localbuf[i]);
352  }
353  }
354 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
Int_t fHardwareBlockSum_raw
Module-based sum of the four sub-blocks as read from the module.
size_t fSequenceNumber
Event sequence number for this channel.
Int_t fBlock_raw[4]
Array of the sub-block data as read from the module.
size_t fNumberOfSamples
Number of samples read through the module.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwVQWK_Channel::FillHistograms ( )
virtual

Fill the histograms for this data element.

Implements VQwDataElement.

Definition at line 533 of file QwVQWK_Channel.cc.

References fBlocksPerEvent, VQwHardwareChannel::fDataToSave, VQwDataElement::fErrorFlag, MQwHistograms::fHistograms, GetBlockValue(), GetHardwareSum(), GetRawBlockValue(), GetRawHardwareSum(), GetRawSoftwareSum(), VQwDataElement::IsNameEmpty(), VQwDataElement::kDerived, kErrorFlag_SameHW, kErrorFlag_sample, kErrorFlag_Sequence, kErrorFlag_SW_HW, kErrorFlag_VQWK_Sat, kErrorFlag_ZeroHW, and VQwDataElement::kRaw.

Referenced by QwEnergyCalculator::FillHistograms(), QwQPD::FillHistograms(), QwBPMCavity::FillHistograms(), QwLinearDiodeArray::FillHistograms(), and QwIntegrationPMT::FillHistograms().

534 {
535  Int_t index=0;
536 
537  if (IsNameEmpty())
538  {
539  // This channel is not used, so skip creating the histograms.
540  } else
541  {
542  if(fDataToSave==kRaw)
543  {
544  for (Int_t i=0; i<fBlocksPerEvent; i++)
545  {
546  if (fHistograms[index] != NULL && (fErrorFlag)==0)
547  fHistograms[index]->Fill(this->GetRawBlockValue(i));
548  if (fHistograms[index+1] != NULL && (fErrorFlag)==0)
549  fHistograms[index+1]->Fill(this->GetBlockValue(i));
550  index+=2;
551  }
552  if (fHistograms[index] != NULL && (fErrorFlag)==0)
553  fHistograms[index]->Fill(this->GetRawHardwareSum());
554  if (fHistograms[index+1] != NULL && (fErrorFlag)==0)
555  fHistograms[index+1]->Fill(this->GetHardwareSum());
556  index+=2;
557  if (fHistograms[index] != NULL && (fErrorFlag)==0)
558  fHistograms[index]->Fill(this->GetRawSoftwareSum()-this->GetRawHardwareSum());
559  }
560  else if(fDataToSave==kDerived)
561  {
562  for (Int_t i=0; i<fBlocksPerEvent; i++)
563  {
564  if (fHistograms[index] != NULL && (fErrorFlag)==0)
565  fHistograms[index]->Fill(this->GetBlockValue(i));
566  index+=1;
567  }
568  if (fHistograms[index] != NULL && (fErrorFlag)==0)
569  fHistograms[index]->Fill(this->GetHardwareSum());
570  index+=1;
571  if (fHistograms[index] != NULL){
573  fHistograms[index]->Fill(kErrorFlag_sample);
574  if ( (kErrorFlag_SW_HW & fErrorFlag)==kErrorFlag_SW_HW)
575  fHistograms[index]->Fill(kErrorFlag_SW_HW);
576  if ( (kErrorFlag_Sequence & fErrorFlag)==kErrorFlag_Sequence)
577  fHistograms[index]->Fill(kErrorFlag_Sequence);
578  if ( (kErrorFlag_ZeroHW & fErrorFlag)==kErrorFlag_ZeroHW)
579  fHistograms[index]->Fill(kErrorFlag_ZeroHW);
580  if ( (kErrorFlag_VQWK_Sat & fErrorFlag)==kErrorFlag_VQWK_Sat)
581  fHistograms[index]->Fill(kErrorFlag_VQWK_Sat);
582  if ( (kErrorFlag_SameHW & fErrorFlag)==kErrorFlag_SameHW)
583  fHistograms[index]->Fill(kErrorFlag_SameHW);
584  }
585 
586  }
587 
588  }
589 }
static const UInt_t kErrorFlag_SW_HW
Definition: QwTypes.h:160
static const UInt_t kErrorFlag_ZeroHW
Definition: QwTypes.h:163
Int_t GetRawSoftwareSum() const
Short_t fBlocksPerEvent
static const UInt_t kErrorFlag_sample
Definition: QwTypes.h:159
Bool_t IsNameEmpty() const
Is the name of this element empty?
static const UInt_t kErrorFlag_SameHW
Definition: QwTypes.h:162
std::vector< TH1_ptr > fHistograms
Histograms associated with this data element.
Definition: MQwHistograms.h:46
Int_t GetRawHardwareSum() const
static const UInt_t kErrorFlag_Sequence
Definition: QwTypes.h:161
Int_t GetRawBlockValue(size_t blocknum) const
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...
Double_t GetBlockValue(size_t blocknum) const
Double_t GetHardwareSum() const
static const UInt_t kErrorFlag_VQWK_Sat
Definition: QwTypes.h:158

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwVQWK_Channel::FillTreeVector ( std::vector< Double_t > &  values) const
virtual

Implements VQwHardwareChannel.

Definition at line 704 of file QwVQWK_Channel.cc.

References bBlock, bBlock_raw, bDEBUG, bDevice_Error_Code, bHw_sum, bHw_sum_raw, bNum_samples, bSequence_number, fBlocksPerEvent, VQwHardwareChannel::fDataToSave, VQwDataElement::fErrorFlag, fNumberOfSamples, fSequenceNumber, VQwHardwareChannel::fTreeArrayIndex, VQwHardwareChannel::fTreeArrayNumEntries, GetBlockValue(), GetHardwareSum(), GetRawBlockValue(), GetRawHardwareSum(), VQwDataElement::IsNameEmpty(), and VQwDataElement::kRaw.

Referenced by QwEnergyCalculator::FillTreeVector(), QwBPMCavity::FillTreeVector(), QwQPD::FillTreeVector(), QwLinearDiodeArray::FillTreeVector(), and QwIntegrationPMT::FillTreeVector().

705 {
706  if (IsNameEmpty()) {
707  // This channel is not used, so skip filling the tree vector.
708  } else if (fTreeArrayNumEntries <= 0) {
709  if (bDEBUG) std::cerr << "QwVQWK_Channel::FillTreeVector: fTreeArrayNumEntries=="
710  << fTreeArrayNumEntries << std::endl;
711  } else if (values.size() < fTreeArrayIndex+fTreeArrayNumEntries){
712  if (bDEBUG) std::cerr << "QwVQWK_Channel::FillTreeVector: values.size()=="
713  << values.size()
714  << "; fTreeArrayIndex+fTreeArrayNumEntries=="
716  << std::endl;
717  } else {
718  UInt_t index = fTreeArrayIndex;
719  //hw_sum
720  if (bHw_sum)
721  values[index++] = this->GetHardwareSum();
722 
723  if (bBlock){
724  for (Int_t i=0; i<fBlocksPerEvent; i++){
725  //blocki
726  values[index++] = this->GetBlockValue(i);
727  }
728  }
729 
730  //num_samples
731  if (bNum_samples)
732  values[index++] = this->fNumberOfSamples;
733 
734  //Device_Error_Code
735  if (bDevice_Error_Code)
736  values[index++] = (this->fErrorFlag);
737 
738  if(fDataToSave==kRaw)
739  {
740  //hw_sum_raw
741  if (bHw_sum_raw)
742  values[index++] = this->GetRawHardwareSum();
743 
744  if (bBlock_raw){
745  for (Int_t i=0; i<fBlocksPerEvent; i++){
746  //blocki_raw
747  values[index++] = this->GetRawBlockValue(i);
748  }
749  }
750 
751  //sequence_number
752  if (bSequence_number)
753  values[index++]=this->fSequenceNumber;
754  }
755  }
756 }
Short_t fBlocksPerEvent
Bool_t IsNameEmpty() const
Is the name of this element empty?
Int_t GetRawHardwareSum() const
Bool_t bDevice_Error_Code
size_t fSequenceNumber
Event sequence number for this channel.
Bool_t bSequence_number
Int_t GetRawBlockValue(size_t blocknum) const
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...
Double_t GetBlockValue(size_t blocknum) const
size_t fNumberOfSamples
Number of samples read through the module.
static const Bool_t bDEBUG
debugging display purposes
Double_t GetHardwareSum() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Double_t QwVQWK_Channel::GetAverageVolts ( ) const

Definition at line 442 of file QwVQWK_Channel.cc.

References fHardwareBlockSum, fNumberOfSamples, and kVQWK_VoltsPerBit.

443 {
444  //Double_t avgVolts = (fBlock[0]+fBlock[1]+fBlock[2]+fBlock[3])*kVQWK_VoltsPerBit/fNumberOfSamples;
445  Double_t avgVolts = fHardwareBlockSum * kVQWK_VoltsPerBit / fNumberOfSamples;
446  //std::cout<<"QwVQWK_Channel::GetAverageVolts() = "<<avgVolts<<std::endl;
447  return avgVolts;
448 
449 }
Double_t fHardwareBlockSum
Module-based sum of the four sub-blocks.
static const Double_t kVQWK_VoltsPerBit
size_t fNumberOfSamples
Number of samples read through the module.
Double_t QwVQWK_Channel::GetBlockErrorValue ( size_t  blocknum) const
inlineprivate

Definition at line 245 of file QwVQWK_Channel.h.

References VQwHardwareChannel::GetValueError().

Referenced by PrintValue().

245 { return GetValueError(blocknum+1);};
Double_t GetValueError() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Double_t QwVQWK_Channel::GetBlockValue ( size_t  blocknum) const
inlineprivate

Definition at line 244 of file QwVQWK_Channel.h.

References VQwHardwareChannel::GetValue().

Referenced by FillHistograms(), FillTreeVector(), and PrintValue().

244 { return GetValue(blocknum+1);};
Double_t GetValue() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Int_t QwVQWK_Channel::GetBufferOffset ( Int_t  moduleindex,
Int_t  channelindex 
)
static

Class: QwVQWK_Channel Base class containing decoding functions for the VQWK_Channel 6 32-bit datawords. The functions in this class will decode a single channel worth of VQWK_Channel data and provide the components through member functions.

Static member function to return the word offset within a data buffer given the module number index and the channel number index.

Parameters
moduleindexModule index within this buffer; counts from zero
channelindexChannel index within this module; counts from zero
Returns
The number of words offset to the beginning of this channel's data from the beginning of the VQWK buffer.

Definition at line 33 of file QwVQWK_Channel.cc.

References QwLog::endl(), kMaxChannels, kWordsPerChannel, and QwError.

Referenced by QwMainCerenkovDetector::LoadChannelMap(), QwIntegratedRaster::LoadChannelMap(), QwLumi::LoadChannelMap(), QwScanner::LoadChannelMap(), and QwBeamDetectorID::QwBeamDetectorID().

33  {
34  Int_t offset = -1;
35  if (moduleindex<0 ){
36  QwError << "QwVQWK_Channel::GetBufferOffset: Invalid module index,"
37  << moduleindex
38  << ". Must be zero or greater."
39  << QwLog::endl;
40  } else if (channelindex<0 || channelindex>kMaxChannels){
41  QwError << "QwVQWK_Channel::GetBufferOffset: Invalid channel index,"
42  << channelindex
43  << ". Must be in range [0," << kMaxChannels << "]."
44  << QwLog::endl;
45  } else {
46  offset = ( (moduleindex * kMaxChannels) + channelindex )
48  }
49  return offset;
50  }
static const Int_t kWordsPerChannel
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
static const Int_t kMaxChannels
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Double_t QwVQWK_Channel::GetHardwareSum ( ) const
inlineprivate

Definition at line 247 of file QwVQWK_Channel.h.

References VQwHardwareChannel::GetValue().

Referenced by ApplySingleEventCuts(), FillHistograms(), FillTreeVector(), operator<<(), and PrintValue().

247 { return GetValue(0);};
Double_t GetValue() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Double_t QwVQWK_Channel::GetHardwareSumError ( ) const
inlineprivate

Definition at line 250 of file QwVQWK_Channel.h.

References VQwHardwareChannel::GetValueError().

Referenced by PrintValue().

250 { return GetValueError(0); };
Double_t GetValueError() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Double_t QwVQWK_Channel::GetHardwareSumM2 ( ) const
inlineprivate

Definition at line 248 of file QwVQWK_Channel.h.

References VQwHardwareChannel::GetValueM2().

248 { return GetValueM2(0); };
Double_t GetValueM2() const

+ Here is the call graph for this function:

Double_t QwVQWK_Channel::GetHardwareSumWidth ( ) const
inlineprivate

Definition at line 249 of file QwVQWK_Channel.h.

References VQwHardwareChannel::GetValueWidth().

Referenced by PrintValue().

249 { return GetValueWidth(0); };
Double_t GetValueWidth() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t QwVQWK_Channel::GetNumberOfSamples ( ) const
inline

Definition at line 219 of file QwVQWK_Channel.h.

References fNumberOfSamples.

Referenced by QwQPD::ApplyHWChecks(), QwBPMCavity::ApplyHWChecks(), QwLinearDiodeArray::ApplyHWChecks(), and ApplyHWChecks().

219 {return (fNumberOfSamples);};
size_t fNumberOfSamples
Number of samples read through the module.

+ Here is the caller graph for this function:

Int_t QwVQWK_Channel::GetRawBlockValue ( size_t  blocknum) const
inlineprivate

Definition at line 253 of file QwVQWK_Channel.h.

References VQwHardwareChannel::GetRawValue().

Referenced by FillHistograms(), and FillTreeVector().

253 {return GetRawValue(blocknum+1);};
Int_t GetRawValue() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Int_t QwVQWK_Channel::GetRawHardwareSum ( ) const
inlineprivate

Definition at line 254 of file QwVQWK_Channel.h.

References VQwHardwareChannel::GetRawValue().

Referenced by ApplyHWChecks(), FillHistograms(), and FillTreeVector().

254 { return GetRawValue(0);};
Int_t GetRawValue() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Int_t QwVQWK_Channel::GetRawSoftwareSum ( ) const
inlineprivate

Definition at line 255 of file QwVQWK_Channel.h.

Referenced by ApplyHWChecks(), and FillHistograms().

255 {return fSoftwareBlockSum_raw;};
Int_t fSoftwareBlockSum_raw
Sum of the data in the four sub-blocks raw.

+ Here is the caller graph for this function:

Int_t QwVQWK_Channel::GetRawValue ( size_t  element) const
inlinevirtual

Implements VQwHardwareChannel.

Definition at line 194 of file QwVQWK_Channel.h.

References fBlock_raw, fHardwareBlockSum_raw, and VQwHardwareChannel::RangeCheck().

194  {
195  RangeCheck(element);
196  if (element==0) return fHardwareBlockSum_raw;
197  return fBlock_raw[element-1];
198  }
void RangeCheck(size_t element) const
Checks that the requested element is in range, to be used in accesses to subelements similar to std::...
Int_t fHardwareBlockSum_raw
Module-based sum of the four sub-blocks as read from the module.
Int_t fBlock_raw[4]
Array of the sub-block data as read from the module.

+ Here is the call graph for this function:

size_t QwVQWK_Channel::GetSequenceNumber ( ) const
inline

Definition at line 218 of file QwVQWK_Channel.h.

References fSequenceNumber.

Referenced by QwQPD::ApplyHWChecks(), QwBPMCavity::ApplyHWChecks(), QwLinearDiodeArray::ApplyHWChecks(), ApplyHWChecks(), QwLinearDiodeArray::ProcessEvent(), and QwQPD::ProcessEvent().

218 {return (fSequenceNumber);};
size_t fSequenceNumber
Event sequence number for this channel.

+ Here is the caller graph for this function:

Double_t QwVQWK_Channel::GetValue ( size_t  element) const
inlinevirtual

Implements VQwHardwareChannel.

Definition at line 199 of file QwVQWK_Channel.h.

References fBlock, fHardwareBlockSum, and VQwHardwareChannel::RangeCheck().

Referenced by QwIntegrationPMT::GetValue(), QwEnergyCalculator::ProcessEvent(), QwLinearDiodeArray::ProcessEvent(), QwQPD::ProcessEvent(), and QwBlinder::Update().

199  {
200  RangeCheck(element);
201  if (element==0) return fHardwareBlockSum;
202  return fBlock[element-1];
203  }
void RangeCheck(size_t element) const
Checks that the requested element is in range, to be used in accesses to subelements similar to std::...
Double_t fHardwareBlockSum
Module-based sum of the four sub-blocks.
Double_t fBlock[4]
Array of the sub-block data.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Double_t QwVQWK_Channel::GetValueError ( size_t  element) const
inlinevirtual

Implements VQwHardwareChannel.

Definition at line 209 of file QwVQWK_Channel.h.

References fBlockError, fHardwareBlockSumError, and VQwHardwareChannel::RangeCheck().

209  {
210  RangeCheck(element);
211  if (element==0) return fHardwareBlockSumError;
212  return fBlockError[element-1];
213  }
void RangeCheck(size_t element) const
Checks that the requested element is in range, to be used in accesses to subelements similar to std::...
Double_t fHardwareBlockSumError
Uncertainty on the hardware sum.
Double_t fBlockError[4]
Uncertainty on the sub-block.

+ Here is the call graph for this function:

Double_t QwVQWK_Channel::GetValueM2 ( size_t  element) const
inlinevirtual

Implements VQwHardwareChannel.

Definition at line 204 of file QwVQWK_Channel.h.

References fBlockM2, fHardwareBlockSumM2, and VQwHardwareChannel::RangeCheck().

204  {
205  RangeCheck(element);
206  if (element==0) return fHardwareBlockSumM2;
207  return fBlockM2[element-1];
208  }
void RangeCheck(size_t element) const
Checks that the requested element is in range, to be used in accesses to subelements similar to std::...
Double_t fHardwareBlockSumM2
Second moment of the hardware sum.
Double_t fBlockM2[4]
Second moment of the sub-block.

+ Here is the call graph for this function:

Double_t QwVQWK_Channel::GetVQWKSaturationLimt ( )
inline

Definition at line 176 of file QwVQWK_Channel.h.

References fSaturationABSLimit.

Referenced by ApplyHWChecks().

176  {//Get the absolute staturation limit in volts.
177  return fSaturationABSLimit;
178  }
Double_t fSaturationABSLimit
absolute value of the VQWK saturation volt

+ Here is the caller graph for this function:

void QwVQWK_Channel::IncrementErrorCounters ( )

Definition at line 130 of file QwVQWK_Channel.cc.

References fErrorCount_HWSat, fErrorCount_SameHW, fErrorCount_sample, fErrorCount_Sequence, fErrorCount_SW_HW, fErrorCount_ZeroHW, VQwDataElement::fErrorFlag, fNumEvtsWithEventCutsRejected, kErrorFlag_EventCut_L, kErrorFlag_EventCut_U, kErrorFlag_SameHW, kErrorFlag_sample, kErrorFlag_Sequence, kErrorFlag_SW_HW, kErrorFlag_VQWK_Sat, and kErrorFlag_ZeroHW.

Referenced by QwEnergyCalculator::IncrementErrorCounters(), QwQPD::IncrementErrorCounters(), QwBPMCavity::IncrementErrorCounters(), QwIntegrationPMT::IncrementErrorCounters(), and QwLinearDiodeArray::IncrementErrorCounters().

130  {
132  fErrorCount_sample++; //increment the hw error counter
133  if ( (kErrorFlag_SW_HW & fErrorFlag)==kErrorFlag_SW_HW)
134  fErrorCount_SW_HW++; //increment the hw error counter
135  if ( (kErrorFlag_Sequence & fErrorFlag)==kErrorFlag_Sequence)
136  fErrorCount_Sequence++; //increment the hw error counter
137  if ( (kErrorFlag_SameHW & fErrorFlag)==kErrorFlag_SameHW)
138  fErrorCount_SameHW++; //increment the hw error counter
139  if ( (kErrorFlag_ZeroHW & fErrorFlag)==kErrorFlag_ZeroHW)
140  fErrorCount_ZeroHW++; //increment the hw error counter
141  if ( (kErrorFlag_VQWK_Sat & fErrorFlag)==kErrorFlag_VQWK_Sat)
142  fErrorCount_HWSat++; //increment the hw saturation error counter
143  if ( ((kErrorFlag_EventCut_L & fErrorFlag)==kErrorFlag_EventCut_L)
144  || ((kErrorFlag_EventCut_U & fErrorFlag)==kErrorFlag_EventCut_U)){
145  fNumEvtsWithEventCutsRejected++; //increment the event cut error counter
146  }
147 }
static const UInt_t kErrorFlag_SW_HW
Definition: QwTypes.h:160
static const UInt_t kErrorFlag_ZeroHW
Definition: QwTypes.h:163
Int_t fErrorCount_Sequence
sequence number check
Int_t fErrorCount_sample
for sample size check
static const UInt_t kErrorFlag_sample
Definition: QwTypes.h:159
static const UInt_t kErrorFlag_SameHW
Definition: QwTypes.h:162
Int_t fErrorCount_ZeroHW
check to see ADC returning zero
Int_t fErrorCount_SW_HW
HW_sum==SW_sum check.
Int_t fErrorCount_HWSat
check to see ADC channel is saturated
static const UInt_t kErrorFlag_Sequence
Definition: QwTypes.h:161
Int_t fErrorCount_SameHW
check to see ADC returning same HW value
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...
Int_t fNumEvtsWithEventCutsRejected
Counts the Event cut rejected events.
static const UInt_t kErrorFlag_EventCut_L
Definition: QwTypes.h:164
static const UInt_t kErrorFlag_VQWK_Sat
Definition: QwTypes.h:158
static const UInt_t kErrorFlag_EventCut_U
Definition: QwTypes.h:165

+ Here is the caller graph for this function:

void QwVQWK_Channel::InitializeChannel ( TString  name,
TString  datatosave 
)
virtual

Initialize the fields in this object.

Implements VQwHardwareChannel.

Definition at line 151 of file QwVQWK_Channel.cc.

References VQwHardwareChannel::bEVENTCUTMODE, ClearEventData(), fADC_Same_NumEvt, fBlocksPerEvent, VQwHardwareChannel::fCalibrationFactor, VQwDataElement::fErrorConfigFlag, fErrorCount_HWSat, fErrorCount_SameHW, fErrorCount_sample, fErrorCount_Sequence, fErrorCount_SW_HW, fErrorCount_ZeroHW, VQwDataElement::fErrorFlag, VQwDataElement::fGoodEventCount, VQwHardwareChannel::fLLimit, MQwMockable::fMockAsymmetry, MQwMockable::fMockDriftAmplitude, MQwMockable::fMockDriftFrequency, MQwMockable::fMockDriftPhase, MQwMockable::fMockGaussianMean, MQwMockable::fMockGaussianSigma, fNumberOfSamples, fNumberOfSamples_map, fNumEvtsWithEventCutsRejected, VQwHardwareChannel::fPedestal, fPrev_HardwareBlockSum, fPreviousSequenceNumber, fRunningSum, fSequenceNo_Counter, fSequenceNo_Prev, VQwHardwareChannel::fTreeArrayIndex, VQwHardwareChannel::fTreeArrayNumEntries, VQwHardwareChannel::fULimit, MQwMockable::fUseExternalRandomVariable, VQwHardwareChannel::kFoundGain, VQwHardwareChannel::kFoundPedestal, VQwHardwareChannel::SetDataToSave(), VQwDataElement::SetElementName(), VQwHardwareChannel::SetNumberOfDataWords(), and VQwHardwareChannel::SetNumberOfSubElements().

Referenced by QwEnergyCalculator::InitializeChannel(), QwQPD::InitializeChannel(), QwIntegrationPMT::InitializeChannel(), QwBPMCavity::InitializeChannel(), QwLinearDiodeArray::InitializeChannel(), InitializeChannel(), QwBeamMod::LoadChannelMap(), QwEnergyCalculator::ProcessEvent(), QwLinearDiodeArray::ProcessEvent(), QwQPD::ProcessEvent(), and QwVQWK_Channel().

152 {
153  SetElementName(name);
154  SetDataToSave(datatosave);
157 
158  kFoundPedestal = 0;
159  kFoundGain = 0;
160 
161  fPedestal = 0.0;
162  fCalibrationFactor = 1.0;
163 
164  fBlocksPerEvent = 4;
165 
166  fTreeArrayIndex = 0;
168 
169  ClearEventData();
170 
173  fNumberOfSamples = 0;
174 
175  // Use internal random variable by default
177 
178  // Mock drifts
179  fMockDriftAmplitude.clear();
180  fMockDriftFrequency.clear();
181  fMockDriftPhase.clear();
182 
183  // Mock asymmetries
184  fMockAsymmetry = 0.0;
185  fMockGaussianMean = 0.0;
186  fMockGaussianSigma = 0.0;
187 
188  // Event cuts
189  fULimit=0;
190  fLLimit=0;
192 
193  fErrorFlag=0;//Initialize the error flag
194  fErrorConfigFlag=0;//Initialize the error config. flag
195 
196  //init error counters//
197  fErrorCount_sample = 0;
198  fErrorCount_SW_HW = 0;
200  fErrorCount_SameHW = 0;
201  fErrorCount_ZeroHW = 0;
202  fErrorCount_HWSat = 0;
203 
204  fRunningSum = 0;
205 
206  fADC_Same_NumEvt = 0;
207  fSequenceNo_Prev = 0;
210 
211  fGoodEventCount = 0;
212 
213  bEVENTCUTMODE = 0;
214 
215  //std::cout<< "name = "<<name<<" error count same _HW = "<<fErrorCount_SameHW <<std::endl;
216  return;
217 }
Int_t fErrorCount_Sequence
sequence number check
Int_t fErrorCount_sample
for sample size check
Short_t fBlocksPerEvent
std::vector< Double_t > fMockDriftPhase
Harmonic drift phase.
Definition: MQwMockable.h:96
std::vector< Double_t > fMockDriftFrequency
Harmonic drift frequency.
Definition: MQwMockable.h:95
Double_t fMockGaussianSigma
Sigma of normal distribution.
Definition: MQwMockable.h:93
Int_t fErrorCount_ZeroHW
check to see ADC returning zero
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.
size_t fNumberOfSamples_map
Number of samples in the expected to read through the module. This value is set in the QwBeamline map...
void SetNumberOfDataWords(const UInt_t &numwords)
Set the number of data words in this data element.
Int_t fErrorCount_HWSat
check to see ADC channel is saturated
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.
Definition: MQwMockable.h:86
Int_t fSequenceNo_Counter
Internal counter to keep track of the sequence number.
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.
Definition: MQwMockable.h:92
Int_t fErrorCount_SameHW
check to see ADC returning same HW value
Int_t fSequenceNo_Prev
Keep the sequence number of the last event.
std::vector< Double_t > fMockDriftAmplitude
Harmonic drift amplitude.
Definition: MQwMockable.h:94
void SetElementName(const TString &name)
Set the name of this element.
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...
Double_t fMockAsymmetry
Helicity asymmetry.
Definition: MQwMockable.h:91
QwVQWK_Channel * fRunningSum
Pointer to the running sum for this channel.
UInt_t fErrorConfigFlag
contains the global/local/stability flags
Int_t fNumEvtsWithEventCutsRejected
Counts the Event cut rejected events.
Int_t fGoodEventCount
Number of good events accumulated in this element.
size_t fPreviousSequenceNumber
Previous event sequence number for this channel.
Int_t fADC_Same_NumEvt
Keep track of how many events with same ADC value returned.
size_t fNumberOfSamples
Number of samples read through the module.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwVQWK_Channel::InitializeChannel ( TString  subsystem,
TString  instrumenttype,
TString  name,
TString  datatosave 
)
virtual

Initialize the fields in this object.

Implements VQwHardwareChannel.

Definition at line 221 of file QwVQWK_Channel.cc.

References InitializeChannel(), VQwDataElement::SetModuleType(), and VQwDataElement::SetSubsystemName().

221  {
222  InitializeChannel(name,datatosave);
223  SetSubsystemName(subsystem);
224  SetModuleType(instrumenttype);
225  //PrintInfo();
226 }
void SetSubsystemName(TString sysname)
Set the name of the inheriting subsystem name.
void SetModuleType(TString ModuleType)
set the type of the beam instrument
void InitializeChannel(TString name, TString datatosave)
Initialize the fields in this object.

+ Here is the call graph for this function:

void QwVQWK_Channel::LoadChannelParameters ( QwParameterFile paramfile)
virtual

Reimplemented from VQwDataElement.

Definition at line 228 of file QwVQWK_Channel.cc.

References QwLog::endl(), VQwDataElement::GetElementName(), QwWarning, QwParameterFile::ReturnValue(), and SetDefaultSampleSize().

228  {
229  UInt_t value = 0;
230  if (paramfile.ReturnValue("sample_size",value)){
231  SetDefaultSampleSize(value);
232  } else {
233  QwWarning << "VQWK Channel "
234  << GetElementName()
235  << " cannot set the default sample size."
236  << QwLog::endl;
237  }
238 };
void SetDefaultSampleSize(size_t num_samples_map)
Bool_t ReturnValue(const std::string keyname, T &retvalue)
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
virtual const TString & GetElementName() const
Get the name of this element.
#define QwWarning
Predefined log drain for warnings.
Definition: QwLog.h:45

+ Here is the call graph for this function:

Bool_t QwVQWK_Channel::MatchNumberOfSamples ( size_t  numsamp)

Definition at line 1474 of file QwVQWK_Channel.cc.

References bDEBUG, fNumberOfSamples, VQwDataElement::GetElementName(), and VQwDataElement::IsNameEmpty().

Referenced by ApplyHWChecks().

1475 {
1476  Bool_t status = kTRUE;
1477  if (!IsNameEmpty()){
1478  status = (fNumberOfSamples==numsamp);
1479  if (! status){
1480  if (bDEBUG)
1481  std::cerr << "QwVQWK_Channel::MatchNumberOfSamples: Channel "
1482  << GetElementName()
1483  << " had fNumberOfSamples==" << fNumberOfSamples
1484  << " and was supposed to have " << numsamp
1485  << std::endl;
1486  // PrintChannel();
1487  }
1488  }
1489  return status;
1490 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
virtual const TString & GetElementName() const
Get the name of this element.
size_t fNumberOfSamples
Number of samples read through the module.
static const Bool_t bDEBUG
debugging display purposes

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Bool_t QwVQWK_Channel::MatchSequenceNumber ( size_t  seqnum)

Definition at line 1464 of file QwVQWK_Channel.cc.

References fSequenceNumber, and VQwDataElement::IsNameEmpty().

Referenced by ApplyHWChecks().

1465 {
1466 
1467  Bool_t status = kTRUE;
1468  if (!IsNameEmpty()){
1469  status = (fSequenceNumber==seqnum);
1470  }
1471  return status;
1472 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
size_t fSequenceNumber
Event sequence number for this channel.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwVQWK_Channel::MultiplyBy ( const VQwHardwareChannel valueptr)
virtual

Implements VQwHardwareChannel.

Definition at line 870 of file QwVQWK_Channel.cc.

References VQwDataElement::GetElementName().

871 {
872  const QwVQWK_Channel* tmpptr;
873  tmpptr = dynamic_cast<const QwVQWK_Channel*>(valueptr);
874  if (tmpptr!=NULL){
875  *this *= *tmpptr;
876  } else {
877  TString loc="Standard exception from QwVQWK_Channel::MultiplyBy = "
878  +valueptr->GetElementName()+" is an incompatable type.";
879  throw std::invalid_argument(loc.Data());
880  }
881 }
virtual const TString & GetElementName() const
Get the name of this element.

+ Here is the call graph for this function:

const QwVQWK_Channel QwVQWK_Channel::operator* ( const QwVQWK_Channel value) const

Definition at line 951 of file QwVQWK_Channel.cc.

952 {
953  QwVQWK_Channel result = *this;
954  result *= value;
955  return result;
956 }
QwVQWK_Channel & QwVQWK_Channel::operator*= ( const QwVQWK_Channel value)

Definition at line 958 of file QwVQWK_Channel.cc.

References fBlock, fBlock_raw, fBlockM2, fBlocksPerEvent, VQwDataElement::fErrorFlag, fHardwareBlockSum, fHardwareBlockSum_raw, fHardwareBlockSumM2, fNumberOfSamples, fSequenceNumber, fSoftwareBlockSum_raw, and VQwDataElement::IsNameEmpty().

959 {
960  if (!IsNameEmpty()){
961  for (Int_t i=0; i<fBlocksPerEvent; i++){
962  this->fBlock[i] *= value.fBlock[i];
963  this->fBlock_raw[i] *= value.fBlock_raw[i];
964  this->fBlockM2[i] = 0.0;
965  }
968  this->fHardwareBlockSum *= value.fHardwareBlockSum;
969  this->fHardwareBlockSumM2 = 0.0;
970  this->fNumberOfSamples *= value.fNumberOfSamples;
971  this->fSequenceNumber = 0;
972  this->fErrorFlag |= (value.fErrorFlag);
973  }
974 
975  return *this;
976 }
Short_t fBlocksPerEvent
Bool_t IsNameEmpty() const
Is the name of this element empty?
Double_t fHardwareBlockSumM2
Second moment of the hardware sum.
Int_t fHardwareBlockSum_raw
Module-based sum of the four sub-blocks as read from the module.
size_t fSequenceNumber
Event sequence number for this channel.
Int_t fSoftwareBlockSum_raw
Sum of the data in the four sub-blocks raw.
Double_t fHardwareBlockSum
Module-based sum of the four sub-blocks.
Int_t fBlock_raw[4]
Array of the sub-block data as read from the module.
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...
Double_t fBlockM2[4]
Second moment of the sub-block.
size_t fNumberOfSamples
Number of samples read through the module.
Double_t fBlock[4]
Array of the sub-block data.

+ Here is the call graph for this function:

VQwHardwareChannel & QwVQWK_Channel::operator*= ( const VQwHardwareChannel input)
virtual

Implements VQwHardwareChannel.

Definition at line 1006 of file QwVQWK_Channel.cc.

References VQwDataElement::GetElementName().

1007 {
1008  const QwVQWK_Channel* tmpptr;
1009  tmpptr = dynamic_cast<const QwVQWK_Channel*>(source);
1010  if (tmpptr!=NULL){
1011  *this *= *tmpptr;
1012  } else {
1013  TString loc="Standard exception from QwVQWK_Channel::operator*= "
1014  +source->GetElementName()+" "
1015  +this->GetElementName()+" are not of the same type";
1016  throw(std::invalid_argument(loc.Data()));
1017  }
1018  return *this;
1019 }
virtual const TString & GetElementName() const
Get the name of this element.

+ Here is the call graph for this function:

const QwVQWK_Channel QwVQWK_Channel::operator+ ( const QwVQWK_Channel value) const

Definition at line 896 of file QwVQWK_Channel.cc.

897 {
898  QwVQWK_Channel result = *this;
899  result += value;
900  return result;
901 }
QwVQWK_Channel & QwVQWK_Channel::operator+= ( const QwVQWK_Channel value)

Definition at line 903 of file QwVQWK_Channel.cc.

References fBlock, fBlock_raw, fBlockM2, fBlocksPerEvent, VQwDataElement::fErrorFlag, fHardwareBlockSum, fHardwareBlockSum_raw, fHardwareBlockSumM2, fNumberOfSamples, fSequenceNumber, fSoftwareBlockSum_raw, and VQwDataElement::IsNameEmpty().

904 {
905  if (!IsNameEmpty()) {
906  for (Int_t i = 0; i < fBlocksPerEvent; i++) {
907  this->fBlock[i] += value.fBlock[i];
908  this->fBlock_raw[i] += value.fBlock_raw[i];
909  this->fBlockM2[i] = 0.0;
910  }
913  this->fHardwareBlockSum += value.fHardwareBlockSum;
914  this->fHardwareBlockSumM2 = 0.0;
915  this->fNumberOfSamples += value.fNumberOfSamples;
916  this->fSequenceNumber = 0;
917  this->fErrorFlag |= (value.fErrorFlag);
918 
919  }
920 
921  return *this;
922 }
Short_t fBlocksPerEvent
Bool_t IsNameEmpty() const
Is the name of this element empty?
Double_t fHardwareBlockSumM2
Second moment of the hardware sum.
Int_t fHardwareBlockSum_raw
Module-based sum of the four sub-blocks as read from the module.
size_t fSequenceNumber
Event sequence number for this channel.
Int_t fSoftwareBlockSum_raw
Sum of the data in the four sub-blocks raw.
Double_t fHardwareBlockSum
Module-based sum of the four sub-blocks.
Int_t fBlock_raw[4]
Array of the sub-block data as read from the module.
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...
Double_t fBlockM2[4]
Second moment of the sub-block.
size_t fNumberOfSamples
Number of samples read through the module.
Double_t fBlock[4]
Array of the sub-block data.

+ Here is the call graph for this function:

VQwHardwareChannel & QwVQWK_Channel::operator+= ( const VQwHardwareChannel input)
virtual

Implements VQwHardwareChannel.

Definition at line 978 of file QwVQWK_Channel.cc.

References VQwDataElement::GetElementName().

979 {
980  const QwVQWK_Channel* tmpptr;
981  tmpptr = dynamic_cast<const QwVQWK_Channel*>(source);
982  if (tmpptr!=NULL){
983  *this += *tmpptr;
984  } else {
985  TString loc="Standard exception from QwVQWK_Channel::operator+= "
986  +source->GetElementName()+" "
987  +this->GetElementName()+" are not of the same type";
988  throw(std::invalid_argument(loc.Data()));
989  }
990  return *this;
991 }
virtual const TString & GetElementName() const
Get the name of this element.

+ Here is the call graph for this function:

const QwVQWK_Channel QwVQWK_Channel::operator- ( const QwVQWK_Channel value) const

Definition at line 924 of file QwVQWK_Channel.cc.

925 {
926  QwVQWK_Channel result = *this;
927  result -= value;
928  return result;
929 }
QwVQWK_Channel & QwVQWK_Channel::operator-= ( const QwVQWK_Channel value)

Definition at line 931 of file QwVQWK_Channel.cc.

References fBlock, fBlock_raw, fBlockM2, fBlocksPerEvent, VQwDataElement::fErrorFlag, fHardwareBlockSum, fHardwareBlockSum_raw, fHardwareBlockSumM2, fNumberOfSamples, fSequenceNumber, fSoftwareBlockSum_raw, and VQwDataElement::IsNameEmpty().

932 {
933  if (!IsNameEmpty()){
934  for (Int_t i=0; i<fBlocksPerEvent; i++){
935  this->fBlock[i] -= value.fBlock[i];
936  this->fBlock_raw[i] = 0;
937  this->fBlockM2[i] = 0.0;
938  }
939  this->fHardwareBlockSum_raw = 0;
940  this->fSoftwareBlockSum_raw = 0;
941  this->fHardwareBlockSum -= value.fHardwareBlockSum;
942  this->fHardwareBlockSumM2 = 0.0;
943  this->fNumberOfSamples += value.fNumberOfSamples;
944  this->fSequenceNumber = 0;
945  this->fErrorFlag |= (value.fErrorFlag);
946  }
947 
948  return *this;
949 }
Short_t fBlocksPerEvent
Bool_t IsNameEmpty() const
Is the name of this element empty?
Double_t fHardwareBlockSumM2
Second moment of the hardware sum.
Int_t fHardwareBlockSum_raw
Module-based sum of the four sub-blocks as read from the module.
size_t fSequenceNumber
Event sequence number for this channel.
Int_t fSoftwareBlockSum_raw
Sum of the data in the four sub-blocks raw.
Double_t fHardwareBlockSum
Module-based sum of the four sub-blocks.
Int_t fBlock_raw[4]
Array of the sub-block data as read from the module.
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...
Double_t fBlockM2[4]
Second moment of the sub-block.
size_t fNumberOfSamples
Number of samples read through the module.
Double_t fBlock[4]
Array of the sub-block data.

+ Here is the call graph for this function:

VQwHardwareChannel & QwVQWK_Channel::operator-= ( const VQwHardwareChannel input)
virtual

Implements VQwHardwareChannel.

Definition at line 992 of file QwVQWK_Channel.cc.

References VQwDataElement::GetElementName().

993 {
994  const QwVQWK_Channel* tmpptr;
995  tmpptr = dynamic_cast<const QwVQWK_Channel*>(source);
996  if (tmpptr!=NULL){
997  *this -= *tmpptr;
998  } else {
999  TString loc="Standard exception from QwVQWK_Channel::operator-= "
1000  +source->GetElementName()+" "
1001  +this->GetElementName()+" are not of the same type";
1002  throw(std::invalid_argument(loc.Data()));
1003  }
1004  return *this;
1005 }
virtual const TString & GetElementName() const
Get the name of this element.

+ Here is the call graph for this function:

VQwHardwareChannel & QwVQWK_Channel::operator/= ( const VQwHardwareChannel input)
virtual

Implements VQwHardwareChannel.

Definition at line 1020 of file QwVQWK_Channel.cc.

References VQwDataElement::GetElementName().

1021 {
1022  const QwVQWK_Channel* tmpptr;
1023  tmpptr = dynamic_cast<const QwVQWK_Channel*>(source);
1024  if (tmpptr!=NULL){
1025  *this /= *tmpptr;
1026  } else {
1027  TString loc="Standard exception from QwVQWK_Channel::operator/= "
1028  +source->GetElementName()+" "
1029  +this->GetElementName()+" are not of the same type";
1030  throw(std::invalid_argument(loc.Data()));
1031  }
1032  return *this;
1033 }
virtual const TString & GetElementName() const
Get the name of this element.

+ Here is the call graph for this function:

QwVQWK_Channel & QwVQWK_Channel::operator/= ( const QwVQWK_Channel value)
protected

Definition at line 1066 of file QwVQWK_Channel.cc.

References QwLog::endl(), fBlock, fBlockM2, VQwDataElement::fErrorFlag, fHardwareBlockSum, fHardwareBlockSumM2, VQwDataElement::GetElementName(), VQwDataElement::IsNameEmpty(), QwVerbose, and QwWarning.

1067 {
1068  // In this function, leave the "raw" variables untouched.
1069  //
1070  Double_t ratio;
1071  Double_t variance;
1072  if (!IsNameEmpty()) {
1073  // The variances are calculated using the following formula:
1074  // Var[ratio] = ratio^2 (Var[numer] / numer^2 + Var[denom] / denom^2)
1075  //
1076  // This requires that both the numerator and denominator are non-zero!
1077  //
1078  for (Int_t i = 0; i < 4; i++) {
1079  if (this->fBlock[i] != 0.0 && denom.fBlock[i] != 0.0){
1080  ratio = (this->fBlock[i]) / (denom.fBlock[i]);
1081  variance = ratio * ratio *
1082  (this->fBlockM2[i] / this->fBlock[i] / this->fBlock[i]
1083  + denom.fBlockM2[i] / denom.fBlock[i] / denom.fBlock[i]);
1084  fBlock[i] = ratio;
1085  fBlockM2[i] = variance;
1086  } else if (this->fBlock[i] == 0.0) {
1087  this->fBlock[i] = 0.0;
1088  this->fBlockM2[i] = 0.0;
1089  } else {
1090  QwVerbose << "Attempting to divide by zero block in "
1091  << GetElementName() << QwLog::endl;
1092  fBlock[i] = 0.0;
1093  fBlockM2[i] = 0.0;
1094  }
1095  }
1096  if (this->fHardwareBlockSum != 0.0 && denom.fHardwareBlockSum != 0.0){
1097  ratio = (this->fHardwareBlockSum) / (denom.fHardwareBlockSum);
1098  variance = ratio * ratio *
1100  + denom.fHardwareBlockSumM2 / denom.fHardwareBlockSum / denom.fHardwareBlockSum);
1101  fHardwareBlockSum = ratio;
1102  fHardwareBlockSumM2 = variance;
1103  } else if (this->fHardwareBlockSum == 0.0) {
1104  fHardwareBlockSum = 0.0;
1105  fHardwareBlockSumM2 = 0.0;
1106  } else {
1107  QwVerbose << "Attempting to divide by zero sum in "
1108  << GetElementName() << QwLog::endl;
1109  fHardwareBlockSumM2 = 0.0;
1110  }
1111  // Remaining variables
1112  // Don't change fNumberOfSamples, fSequenceNumber, fGoodEventCount,
1113  // 'OR' the HW error codes in the fErrorFlag values together.
1114  fErrorFlag |= (denom.fErrorFlag);//mix only the hardware error codes
1115  }
1116 
1117  // Nanny
1119  QwWarning << "Angry Nanny: NaN detected in " << GetElementName() << QwLog::endl;
1120 
1121  return *this;
1122 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
Double_t fHardwareBlockSumM2
Second moment of the hardware sum.
#define QwVerbose
Predefined log drain for verbose messages.
Definition: QwLog.h:55
Double_t fHardwareBlockSum
Module-based sum of the four sub-blocks.
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
Double_t fBlockM2[4]
Second moment of the sub-block.
virtual const TString & GetElementName() const
Get the name of this element.
#define QwWarning
Predefined log drain for warnings.
Definition: QwLog.h:45
Double_t fBlock[4]
Array of the sub-block data.

+ Here is the call graph for this function:

QwVQWK_Channel & QwVQWK_Channel::operator= ( const QwVQWK_Channel value)

Definition at line 787 of file QwVQWK_Channel.cc.

References fBlock, fBlock_raw, fBlockM2, fBlocksPerEvent, fHardwareBlockSum, fHardwareBlockSum_raw, fHardwareBlockSumError, fHardwareBlockSumM2, fNumberOfSamples, fSequenceNumber, fSoftwareBlockSum_raw, VQwDataElement::IsNameEmpty(), and VQwHardwareChannel::operator=().

788 {
789  if(this ==&value) return *this;
790 
791  if (!IsNameEmpty()) {
793  for (Int_t i=0; i<fBlocksPerEvent; i++){
794  this->fBlock_raw[i] = value.fBlock_raw[i];
795  this->fBlock[i] = value.fBlock[i];
796  this->fBlockM2[i] = value.fBlockM2[i];
797  }
800  this->fHardwareBlockSum = value.fHardwareBlockSum;
803  this->fNumberOfSamples = value.fNumberOfSamples;
804  this->fSequenceNumber = value.fSequenceNumber;
805 
806 
807  }
808  return *this;
809 }
Short_t fBlocksPerEvent
Bool_t IsNameEmpty() const
Is the name of this element empty?
Double_t fHardwareBlockSumM2
Second moment of the hardware sum.
Double_t fHardwareBlockSumError
Uncertainty on the hardware sum.
Int_t fHardwareBlockSum_raw
Module-based sum of the four sub-blocks as read from the module.
size_t fSequenceNumber
Event sequence number for this channel.
Int_t fSoftwareBlockSum_raw
Sum of the data in the four sub-blocks raw.
Double_t fHardwareBlockSum
Module-based sum of the four sub-blocks.
Int_t fBlock_raw[4]
Array of the sub-block data as read from the module.
virtual VQwHardwareChannel & operator=(const VQwHardwareChannel &value)
Arithmetic assignment operator: Should only copy event-based data.
Double_t fBlockM2[4]
Second moment of the sub-block.
size_t fNumberOfSamples
Number of samples read through the module.
Double_t fBlock[4]
Array of the sub-block data.

+ Here is the call graph for this function:

void QwVQWK_Channel::PrintErrorCounterHead ( )
static

Definition at line 1544 of file QwVQWK_Channel.cc.

References QwLog::endl(), and QwMessage.

Referenced by QwBeamLine::PrintErrorCounters(), QwMainCerenkovDetector::PrintErrorCounters(), QwIntegratedRaster::PrintErrorCounters(), QwBeamMod::PrintErrorCounters(), and QwLumi::PrintErrorCounters().

1545 {
1546  TString message;
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;
1556  QwMessage << message << QwLog::endl;
1557  QwMessage << "---------------------------------------------------------------------------------------------" << QwLog::endl;
1558  return;
1559 }
#define QwMessage
Predefined log drain for regular messages.
Definition: QwLog.h:50
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwVQWK_Channel::PrintErrorCounters ( ) const
virtual

report number of events failed due to HW and event cut failure

Reimplemented from VQwDataElement.

Definition at line 1567 of file QwVQWK_Channel.cc.

References QwLog::endl(), VQwHardwareChannel::fDataToSave, fErrorCount_HWSat, fErrorCount_SameHW, fErrorCount_sample, fErrorCount_Sequence, fErrorCount_SW_HW, fErrorCount_ZeroHW, fNumEvtsWithEventCutsRejected, VQwDataElement::GetElementName(), VQwHardwareChannel::kFoundGain, VQwHardwareChannel::kFoundPedestal, VQwDataElement::kRaw, and QwMessage.

Referenced by QwIntegrationPMT::PrintErrorCounters(), QwEnergyCalculator::PrintErrorCounters(), QwQPD::PrintErrorCounters(), QwBPMCavity::PrintErrorCounters(), and QwLinearDiodeArray::PrintErrorCounters().

1568 {
1569  TString message;
1571  message = Form("%30s", GetElementName().Data());
1572  message += Form("%9d", fErrorCount_HWSat);
1573  message += Form("%9d", fErrorCount_sample);
1574  message += Form("%9d", fErrorCount_SW_HW);
1575  message += Form("%9d", fErrorCount_Sequence);
1576  message += Form("%9d", fErrorCount_SameHW);
1577  message += Form("%9d", fErrorCount_ZeroHW);
1578  message += Form("%9d", fNumEvtsWithEventCutsRejected);
1579 
1580  if((fDataToSave == kRaw) && (!kFoundPedestal||!kFoundGain)){
1581  message += " >>>>> No Pedestal or Gain in map file";
1582  }
1583 
1584  QwMessage << message << QwLog::endl;
1585  }
1586  return;
1587 }
#define QwMessage
Predefined log drain for regular messages.
Definition: QwLog.h:50
Int_t fErrorCount_Sequence
sequence number check
Int_t fErrorCount_sample
for sample size check
Int_t fErrorCount_ZeroHW
check to see ADC returning zero
Int_t fErrorCount_SW_HW
HW_sum==SW_sum check.
Int_t fErrorCount_HWSat
check to see ADC channel is saturated
Int_t fErrorCount_SameHW
check to see ADC returning same HW value
Int_t fNumEvtsWithEventCutsRejected
Counts the Event cut rejected events.
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
virtual const TString & GetElementName() const
Get the name of this element.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwVQWK_Channel::PrintErrorCounterTail ( )
static

Definition at line 1561 of file QwVQWK_Channel.cc.

References QwLog::endl(), and QwMessage.

Referenced by QwBeamLine::PrintErrorCounters(), QwMainCerenkovDetector::PrintErrorCounters(), QwIntegratedRaster::PrintErrorCounters(), QwBeamMod::PrintErrorCounters(), and QwLumi::PrintErrorCounters().

1562 {
1563  QwMessage << "---------------------------------------------------------------------------------------------" << QwLog::endl;
1564  return;
1565 }
#define QwMessage
Predefined log drain for regular messages.
Definition: QwLog.h:50
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwVQWK_Channel::PrintInfo ( ) const
virtual

Print multiple lines of information about this data element.

Reimplemented from VQwDataElement.

Definition at line 451 of file QwVQWK_Channel.cc.

References fBlock, fBlock_raw, fBlocksPerEvent, VQwHardwareChannel::fCalibrationFactor, fHardwareBlockSum, fHardwareBlockSum_raw, fHardwareBlockSumError, fHardwareBlockSumM2, fNumberOfSamples, VQwHardwareChannel::fPedestal, fSequenceNumber, fSoftwareBlockSum_raw, VQwDataElement::GetElementName(), VQwDataElement::GetModuleType(), and VQwDataElement::GetSubsystemName().

Referenced by QwEnergyCalculator::PrintInfo(), QwBPMCavity::PrintInfo(), QwLinearDiodeArray::PrintInfo(), QwIntegrationPMT::PrintInfo(), QwBPMCavity::ProcessEvent(), and QwQPD::ProcessEvent().

452 {
453  std::cout<<"***************************************"<<"\n";
454  std::cout<<"Subsystem "<<GetSubsystemName()<<"\n"<<"\n";
455  std::cout<<"Beam Instrument Type: "<<GetModuleType()<<"\n"<<"\n";
456  std::cout<<"QwVQWK channel: "<<GetElementName()<<"\n"<<"\n";
457  std::cout<<"fPedestal= "<< fPedestal<<"\n";
458  std::cout<<"fCalibrationFactor= "<<fCalibrationFactor<<"\n";
459  std::cout<<"fBlocksPerEvent= "<<fBlocksPerEvent<<"\n"<<"\n";
460  std::cout<<"fSequenceNumber= "<<fSequenceNumber<<"\n";
461  std::cout<<"fNumberOfSamples= "<<fNumberOfSamples<<"\n";
462  std::cout<<"fBlock_raw ";
463 
464  for (Int_t i = 0; i < fBlocksPerEvent; i++)
465  std::cout << " : " << fBlock_raw[i];
466  std::cout<<"\n";
467  std::cout<<"fHardwareBlockSum_raw= "<<fHardwareBlockSum_raw<<"\n";
468  std::cout<<"fSoftwareBlockSum_raw= "<<fSoftwareBlockSum_raw<<"\n";
469  std::cout<<"fBlock ";
470  for (Int_t i = 0; i < fBlocksPerEvent; i++)
471  std::cout << " : " << fBlock[i];
472  std::cout << std::endl;
473 
474  std::cout << "fHardwareBlockSum = "<<fHardwareBlockSum << std::endl;
475  std::cout << "fHardwareBlockSumM2 = "<<fHardwareBlockSumM2 << std::endl;
476  std::cout << "fHardwareBlockSumError = "<<fHardwareBlockSumError << std::endl;
477 
478  return;
479 }
Short_t fBlocksPerEvent
Double_t fHardwareBlockSumM2
Second moment of the hardware sum.
Double_t fHardwareBlockSumError
Uncertainty on the hardware sum.
Int_t fHardwareBlockSum_raw
Module-based sum of the four sub-blocks as read from the module.
TString GetModuleType() const
Return the type of the beam instrument.
size_t fSequenceNumber
Event sequence number for this channel.
Int_t fSoftwareBlockSum_raw
Sum of the data in the four sub-blocks raw.
Double_t fHardwareBlockSum
Module-based sum of the four sub-blocks.
Int_t fBlock_raw[4]
Array of the sub-block data as read from the module.
TString GetSubsystemName() const
Return the name of the inheriting subsystem name.
virtual const TString & GetElementName() const
Get the name of this element.
size_t fNumberOfSamples
Number of samples read through the module.
Double_t fBlock[4]
Array of the sub-block data.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwVQWK_Channel::PrintValue ( ) const
virtual

Print single line of value and error of this data element.

Reimplemented from VQwDataElement.

Definition at line 1389 of file QwVQWK_Channel.cc.

References QwLog::endl(), VQwDataElement::fGoodEventCount, GetBlockErrorValue(), GetBlockValue(), VQwDataElement::GetElementName(), VQwDataElement::GetGoodEventCount(), GetHardwareSum(), GetHardwareSumError(), GetHardwareSumWidth(), VQwDataElement::GetModuleType(), VQwDataElement::GetSubsystemName(), and QwMessage.

Referenced by AccumulateRunningSum(), QwEnergyCalculator::PrintValue(), QwBPMCavity::PrintValue(), QwLinearDiodeArray::PrintValue(), and QwIntegrationPMT::PrintValue().

1390 {
1391  QwMessage << std::setprecision(4)
1392  << std::setw(18) << std::left << GetSubsystemName() << " "
1393  << std::setw(18) << std::left << GetModuleType() << " "
1394  << std::setw(18) << std::left << GetElementName() << " "
1395  << std::setw(12) << std::left << GetHardwareSum() << "+/- "
1396  << std::setw(12) << std::left << GetHardwareSumError() << " sig "
1397  << std::setw(12) << std::left << GetHardwareSumWidth() << " "
1398  << std::setw(10) << std::left << GetGoodEventCount() << " "
1399  << std::setw(12) << std::left << GetBlockValue(0) << "+/- "
1400  << std::setw(12) << std::left << GetBlockErrorValue(0) << " "
1401  << std::setw(12) << std::left << GetBlockValue(1) << "+/- "
1402  << std::setw(12) << std::left << GetBlockErrorValue(1) << " "
1403  << std::setw(12) << std::left << GetBlockValue(2) << "+/- "
1404  << std::setw(12) << std::left << GetBlockErrorValue(2) << " "
1405  << std::setw(12) << std::left << GetBlockValue(3) << "+/- "
1406  << std::setw(12) << std::left << GetBlockErrorValue(3) << " "
1407  << std::setw(12) << std::left << fGoodEventCount << " "
1408  << QwLog::endl;
1409  /*
1410  //for Debudding
1411  << std::setw(12) << std::left << fErrorFlag << " err "
1412  << std::setw(12) << std::left << fErrorConfigFlag << " c-err "
1413 
1414  */
1415 }
#define QwMessage
Predefined log drain for regular messages.
Definition: QwLog.h:50
UInt_t GetGoodEventCount() const
Double_t GetHardwareSumWidth() const
Double_t GetHardwareSumError() const
TString GetModuleType() const
Return the type of the beam instrument.
TString GetSubsystemName() const
Return the name of the inheriting subsystem name.
Double_t GetBlockValue(size_t blocknum) const
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
Int_t fGoodEventCount
Number of good events accumulated in this element.
virtual const TString & GetElementName() const
Get the name of this element.
Double_t GetBlockErrorValue(size_t blocknum) const
Double_t GetHardwareSum() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Int_t QwVQWK_Channel::ProcessEvBuffer ( UInt_t *  buffer,
UInt_t  num_words_left,
UInt_t  index = 0 
)
virtual

Decode the event data from a CODA buffer.

Implements VQwDataElement.

Definition at line 358 of file QwVQWK_Channel.cc.

References fBlock_raw, fBlocksPerEvent, fHardwareBlockSum_raw, VQwHardwareChannel::fNumberOfDataWords, fNumberOfSamples, fSequenceNumber, fSoftwareBlockSum_raw, VQwDataElement::IsNameEmpty(), and kWordsPerChannel.

Referenced by QwIntegrationPMT::ProcessEvBuffer(), QwBPMCavity::ProcessEvBuffer(), QwLinearDiodeArray::ProcessEvBuffer(), and QwQPD::ProcessEvBuffer().

359 {
360  UInt_t words_read = 0;
361  UInt_t localbuf[kWordsPerChannel] = {0};
362  // The conversion from UInt_t to Double_t discards the sign, so we need an intermediate
363  // static_cast from UInt_t to Int_t.
364  Int_t localbuf_signed[kWordsPerChannel] = {0};
365 
366  if (IsNameEmpty()){
367  // This channel is not used, but is present in the data stream.
368  // Skip over this data.
369  words_read = fNumberOfDataWords;
370  } else if (num_words_left >= fNumberOfDataWords)
371  {
372  for (Int_t i=0; i<kWordsPerChannel; i++){
373  localbuf[i] = buffer[i];
374  localbuf_signed[i] = static_cast<Int_t>(localbuf[i]);
375  }
376 
378  for (Int_t i=0; i<fBlocksPerEvent; i++){
379  fBlock_raw[i] = localbuf_signed[i];
381  }
382  fHardwareBlockSum_raw = localbuf_signed[4];
383 
384  /* Permanent change in the structure of the 6th word of the ADC readout.
385  * The upper 16 bits are the number of samples, and the upper 8 of the
386  * lower 16 are the sequence number. This matches the structure of
387  * the ADC readout in block read mode, and now also in register read mode.
388  * P.King, 2007sep04.
389  */
390  fSequenceNumber = (localbuf[5]>>8) & 0xFF;
391  fNumberOfSamples = (localbuf[5]>>16) & 0xFFFF;
392 
393  words_read = fNumberOfDataWords;
394 
395  } else
396  {
397  std::cerr << "QwVQWK_Channel::ProcessEvBuffer: Not enough words!"
398  << std::endl;
399  }
400  return words_read;
401 }
static const Int_t kWordsPerChannel
Short_t fBlocksPerEvent
Bool_t IsNameEmpty() const
Is the name of this element empty?
UInt_t fNumberOfDataWords
Number of raw data words in this data element.
Int_t fHardwareBlockSum_raw
Module-based sum of the four sub-blocks as read from the module.
size_t fSequenceNumber
Event sequence number for this channel.
Int_t fSoftwareBlockSum_raw
Sum of the data in the four sub-blocks raw.
Int_t fBlock_raw[4]
Array of the sub-block data as read from the module.
size_t fNumberOfSamples
Number of samples read through the module.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwVQWK_Channel::ProcessEvent ( )

Process the event data according to pedestal and calibration factor.

Definition at line 405 of file QwVQWK_Channel.cc.

References QwLog::endl(), fBlock, fBlock_raw, fBlockM2, fBlocksPerEvent, VQwHardwareChannel::fCalibrationFactor, VQwDataElement::fErrorFlag, fHardwareBlockSum, fHardwareBlockSum_raw, fHardwareBlockSumM2, fNumberOfSamples, VQwHardwareChannel::fPedestal, VQwDataElement::GetElementName(), kErrorFlag_sample, and QwWarning.

Referenced by QwBPMCavity::ProcessEvent(), QwQPD::ProcessEvent(), QwLinearDiodeArray::ProcessEvent(), and QwIntegrationPMT::ProcessEvent().

406 {
407  if (fNumberOfSamples == 0 && fHardwareBlockSum_raw == 0) {
408  // There isn't valid data for this channel. Just flag it and
409  // move on.
410  for (Int_t i = 0; i < fBlocksPerEvent; i++) {
411  fBlock[i] = 0.0;
412  fBlockM2[i] = 0.0;
413  }
414  fHardwareBlockSum = 0.0;
415  fHardwareBlockSumM2 = 0.0;
417  } else if (fNumberOfSamples == 0) {
418  // This is probably a more serious problem.
419  QwWarning << "QwVQWK_Channel::ProcessEvent: Channel "
420  << this->GetElementName().Data()
421  << " has fNumberOfSamples==0 but has valid data in the hardware sum. "
422  << "Flag this as an error."
423  << QwLog::endl;
424  for (Int_t i = 0; i < fBlocksPerEvent; i++) {
425  fBlock[i] = 0.0;
426  fBlockM2[i] = 0.0;
427  }
428  fHardwareBlockSum = 0.0;
429  fHardwareBlockSumM2 = 0.0;
431  } else {
432  for (Int_t i = 0; i < fBlocksPerEvent; i++) {
433  fBlock[i] = fCalibrationFactor * ( (1.0 * fBlock_raw[i] * fBlocksPerEvent / fNumberOfSamples) - fPedestal );
434  fBlockM2[i] = 0.0; // second moment is zero for single events
435  }
437  fHardwareBlockSumM2 = 0.0; // second moment is zero for single events
438  }
439  return;
440 }
Short_t fBlocksPerEvent
static const UInt_t kErrorFlag_sample
Definition: QwTypes.h:159
Double_t fHardwareBlockSumM2
Second moment of the hardware sum.
Int_t fHardwareBlockSum_raw
Module-based sum of the four sub-blocks as read from the module.
Double_t fHardwareBlockSum
Module-based sum of the four sub-blocks.
Int_t fBlock_raw[4]
Array of the sub-block data as read from the module.
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
Double_t fBlockM2[4]
Second moment of the sub-block.
virtual const TString & GetElementName() const
Get the name of this element.
size_t fNumberOfSamples
Number of samples read through the module.
#define QwWarning
Predefined log drain for warnings.
Definition: QwLog.h:45
Double_t fBlock[4]
Array of the sub-block data.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwVQWK_Channel::Product ( const QwVQWK_Channel value1,
const QwVQWK_Channel value2 
)

Definition at line 1124 of file QwVQWK_Channel.cc.

References fBlock, fBlock_raw, fBlockM2, fBlocksPerEvent, VQwDataElement::fErrorFlag, fHardwareBlockSum, fHardwareBlockSum_raw, fHardwareBlockSumM2, fNumberOfSamples, fSequenceNumber, fSoftwareBlockSum_raw, and VQwDataElement::IsNameEmpty().

Referenced by QwLinearDiodeArray::ProcessEvent().

1125 {
1126  if (!IsNameEmpty()){
1127  for (Int_t i = 0; i < fBlocksPerEvent; i++) {
1128  this->fBlock[i] = (value1.fBlock[i]) * (value2.fBlock[i]);
1129  this->fBlock_raw[i] = 0;
1130  // For a single event the second moment is still zero
1131  this->fBlockM2[i] = 0.0;
1132  }
1133 
1134  // For a single event the second moment is still zero
1135  this->fHardwareBlockSumM2 = 0.0;
1136 
1137  this->fSoftwareBlockSum_raw = 0;
1139  this->fHardwareBlockSum = value1.fHardwareBlockSum * value2.fHardwareBlockSum;
1140  this->fNumberOfSamples = value1.fNumberOfSamples;
1141  this->fSequenceNumber = 0;
1142  this->fErrorFlag = (value1.fErrorFlag|value2.fErrorFlag);
1143  }
1144  return;
1145 }
Short_t fBlocksPerEvent
Bool_t IsNameEmpty() const
Is the name of this element empty?
Double_t fHardwareBlockSumM2
Second moment of the hardware sum.
Int_t fHardwareBlockSum_raw
Module-based sum of the four sub-blocks as read from the module.
size_t fSequenceNumber
Event sequence number for this channel.
Int_t fSoftwareBlockSum_raw
Sum of the data in the four sub-blocks raw.
Double_t fHardwareBlockSum
Module-based sum of the four sub-blocks.
Int_t fBlock_raw[4]
Array of the sub-block data as read from the module.
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...
Double_t fBlockM2[4]
Second moment of the sub-block.
size_t fNumberOfSamples
Number of samples read through the module.
Double_t fBlock[4]
Array of the sub-block data.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwVQWK_Channel::RandomizeEventData ( int  helicity = 0.0,
double  time = 0.0 
)
virtual

Internally generate random event data.

Implements MQwMockable.

Definition at line 261 of file QwVQWK_Channel.cc.

References fBlocksPerEvent, MQwMockable::fMockAsymmetry, MQwMockable::fMockDriftAmplitude, MQwMockable::fMockDriftFrequency, MQwMockable::fMockDriftPhase, MQwMockable::fMockGaussianMean, MQwMockable::fMockGaussianSigma, MQwMockable::GetRandomValue(), Qw::pi, and SetEventData().

Referenced by QwIntegrationPMT::RandomizeEventData().

262 {
263  // The blocks are assumed to be independent measurements
264  Double_t* block = new Double_t[fBlocksPerEvent];
265  Double_t sqrt_fBlocksPerEvent = 0.0;
266  sqrt_fBlocksPerEvent = sqrt(fBlocksPerEvent);
267 
268  // Calculate drift (if time is not specified, it stays constant at zero)
269  Double_t drift = 0.0;
270  for (UInt_t i = 0; i < fMockDriftFrequency.size(); i++) {
271  drift += fMockDriftAmplitude[i] * sin(2.0 * Qw::pi * fMockDriftFrequency[i] * time + fMockDriftPhase[i]);
272  }
273 
274  // Calculate signal
275  for (Int_t i = 0; i < fBlocksPerEvent; i++) {
276  block[i] =
277  fMockGaussianMean * (1 + helicity * fMockAsymmetry) / fBlocksPerEvent
278  + fMockGaussianSigma / sqrt_fBlocksPerEvent * GetRandomValue()
279  + drift / fBlocksPerEvent;
280  }
281 
282  SetEventData(block);
283 
284  delete block;
285  return;
286 }
static const double pi
Angles: base unit is radian.
Definition: QwUnits.h:102
Short_t fBlocksPerEvent
std::vector< Double_t > fMockDriftPhase
Harmonic drift phase.
Definition: MQwMockable.h:96
std::vector< Double_t > fMockDriftFrequency
Harmonic drift frequency.
Definition: MQwMockable.h:95
void SetEventData(Double_t *block, UInt_t sequencenumber=0)
Double_t fMockGaussianSigma
Sigma of normal distribution.
Definition: MQwMockable.h:93
Double_t GetRandomValue()
Definition: MQwMockable.cc:54
Double_t fMockGaussianMean
Mean of normal distribution.
Definition: MQwMockable.h:92
std::vector< Double_t > fMockDriftAmplitude
Harmonic drift amplitude.
Definition: MQwMockable.h:94
Double_t fMockAsymmetry
Helicity asymmetry.
Definition: MQwMockable.h:91

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwVQWK_Channel::Ratio ( const QwVQWK_Channel numer,
const QwVQWK_Channel denom 
)

Definition at line 1048 of file QwVQWK_Channel.cc.

References fBlock_raw, fBlocksPerEvent, VQwDataElement::fErrorFlag, VQwDataElement::fGoodEventCount, fHardwareBlockSum_raw, fNumberOfSamples, fSequenceNumber, fSoftwareBlockSum_raw, and VQwDataElement::IsNameEmpty().

Referenced by QwLinearDiodeArray::ProcessEvent(), QwQPD::ProcessEvent(), QwQPD::Ratio(), QwBPMCavity::Ratio(), QwLinearDiodeArray::Ratio(), and QwIntegrationPMT::Ratio().

1049 {
1050  if (!IsNameEmpty()) {
1051  *this = numer;
1052  *this /= denom;
1053 
1054  // Set the raw values to zero.
1055  for (Int_t i = 0; i < fBlocksPerEvent; i++) fBlock_raw[i] = 0;
1058  // Remaining variables
1060  fSequenceNumber = 0;
1062  fErrorFlag = (numer.fErrorFlag|denom.fErrorFlag);
1063  }
1064 }
Short_t fBlocksPerEvent
Bool_t IsNameEmpty() const
Is the name of this element empty?
Int_t fHardwareBlockSum_raw
Module-based sum of the four sub-blocks as read from the module.
size_t fSequenceNumber
Event sequence number for this channel.
Int_t fSoftwareBlockSum_raw
Sum of the data in the four sub-blocks raw.
Int_t fBlock_raw[4]
Array of the sub-block data as read from the module.
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...
Int_t fGoodEventCount
Number of good events accumulated in this element.
size_t fNumberOfSamples
Number of samples read through the module.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwVQWK_Channel::Scale ( Double_t  Offset)
virtual

Implements VQwHardwareChannel.

Definition at line 1159 of file QwVQWK_Channel.cc.

References fBlock, fBlockM2, fBlocksPerEvent, fHardwareBlockSum, fHardwareBlockSumM2, and VQwDataElement::IsNameEmpty().

Referenced by QwEnergyCalculator::ProcessEvent(), QwBPMCavity::ProcessEvent(), QwQPD::ProcessEvent(), QwLinearDiodeArray::ProcessEvent(), QwEnergyCalculator::Scale(), QwQPD::Scale(), QwBPMCavity::Scale(), QwLinearDiodeArray::Scale(), and QwIntegrationPMT::Scale().

1160 {
1161  if (!IsNameEmpty())
1162  {
1163  for (Int_t i = 0; i < fBlocksPerEvent; i++) {
1164  fBlock[i] *= scale;
1165  fBlockM2[i] *= scale * scale;
1166  }
1167  fHardwareBlockSum *= scale;
1168  fHardwareBlockSumM2 *= scale * scale;
1169  }
1170 }
Short_t fBlocksPerEvent
Bool_t IsNameEmpty() const
Is the name of this element empty?
Double_t fHardwareBlockSumM2
Second moment of the hardware sum.
Double_t fHardwareBlockSum
Module-based sum of the four sub-blocks.
Double_t fBlockM2[4]
Second moment of the sub-block.
Double_t fBlock[4]
Array of the sub-block data.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwVQWK_Channel::ScaledAdd ( Double_t  scale,
const VQwHardwareChannel value 
)
virtual

Implements VQwHardwareChannel.

Definition at line 1589 of file QwVQWK_Channel.cc.

References fBlock, fBlock_raw, fBlockM2, fBlocksPerEvent, VQwDataElement::fErrorFlag, fHardwareBlockSum, fHardwareBlockSum_raw, fHardwareBlockSumM2, fNumberOfSamples, fSequenceNumber, fSoftwareBlockSum_raw, and VQwDataElement::IsNameEmpty().

1590 {
1591  const QwVQWK_Channel* input = dynamic_cast<const QwVQWK_Channel*>(value);
1592 
1593  // follows same steps as += but w/ scaling factor
1594  if(input!=NULL && !IsNameEmpty()){
1595  // QwWarning << "Adding " << input->GetElementName()
1596  // << " to " << GetElementName()
1597  // << " with scale factor " << scale
1598  // << QwLog::endl;
1599  // PrintValue();
1600  // input->PrintValue();
1601  for(Int_t i = 0; i < fBlocksPerEvent; i++){
1602  this -> fBlock[i] += scale * input->fBlock[i];
1603  this->fBlock_raw[i] = 0;
1604  this -> fBlockM2[i] = 0.0;
1605  }
1606  this->fHardwareBlockSum_raw = 0;
1607  this->fSoftwareBlockSum_raw = 0;
1608  this -> fHardwareBlockSum += scale * input->fHardwareBlockSum;
1609  this -> fHardwareBlockSumM2 = 0.0;
1610  this -> fNumberOfSamples += input->fNumberOfSamples;
1611  this -> fSequenceNumber = 0;
1612  this -> fErrorFlag |= (input->fErrorFlag);
1613  }
1614  // QwWarning << "Finsihed with addition" << QwLog::endl;
1615  // PrintValue();
1616 }
Short_t fBlocksPerEvent
Bool_t IsNameEmpty() const
Is the name of this element empty?
Double_t fHardwareBlockSumM2
Second moment of the hardware sum.
Int_t fHardwareBlockSum_raw
Module-based sum of the four sub-blocks as read from the module.
size_t fSequenceNumber
Event sequence number for this channel.
Int_t fSoftwareBlockSum_raw
Sum of the data in the four sub-blocks raw.
Double_t fHardwareBlockSum
Module-based sum of the four sub-blocks.
Int_t fBlock_raw[4]
Array of the sub-block data as read from the module.
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...
Double_t fBlockM2[4]
Second moment of the sub-block.
size_t fNumberOfSamples
Number of samples read through the module.
Double_t fBlock[4]
Array of the sub-block data.

+ Here is the call graph for this function:

void QwVQWK_Channel::SetCalibrationToVolts ( )
inline

Definition at line 221 of file QwVQWK_Channel.h.

References kVQWK_VoltsPerBit, and VQwHardwareChannel::SetCalibrationFactor().

void SetCalibrationFactor(Double_t factor)
static const Double_t kVQWK_VoltsPerBit

+ Here is the call graph for this function:

void QwVQWK_Channel::SetDefaultSampleSize ( size_t  num_samples_map)
inline

Definition at line 89 of file QwVQWK_Channel.h.

References fNumberOfSamples_map.

Referenced by LoadChannelParameters(), and QwIntegrationPMT::SetDefaultSampleSize().

89  {
90  // This will be checked against the no.of samples read by the module
91  fNumberOfSamples_map = num_samples_map;
92  };
size_t fNumberOfSamples_map
Number of samples in the expected to read through the module. This value is set in the QwBeamline map...

+ Here is the caller graph for this function:

void QwVQWK_Channel::SetEventData ( Double_t *  block,
UInt_t  sequencenumber = 0 
)

Definition at line 303 of file QwVQWK_Channel.cc.

References fBlock, fBlock_raw, fBlockM2, fBlocksPerEvent, VQwHardwareChannel::fCalibrationFactor, fHardwareBlockSum, fHardwareBlockSum_raw, fHardwareBlockSumM2, fNumberOfSamples, VQwHardwareChannel::fPedestal, fSequenceNumber, and fSoftwareBlockSum_raw.

Referenced by RandomizeEventData(), QwIntegrationPMT::SetEventData(), and SetHardwareSum().

304 {
305  fHardwareBlockSum = 0.0;
306  fHardwareBlockSumM2 = 0.0; // second moment is zero for single events
307  for (Int_t i = 0; i < fBlocksPerEvent; i++) {
308  fBlock[i] = block[i];
309  fBlockM2[i] = 0.0; // second moment is zero for single events
310  fHardwareBlockSum += block[i];
311  }
312 
313  fSequenceNumber = sequencenumber;
314  fNumberOfSamples = 16680;
315 
316  Double_t thispedestal = 0.0;
317  thispedestal = fPedestal * fNumberOfSamples;
318 
320  for (Int_t i = 0; i < fBlocksPerEvent; i++)
321  {
322  fBlock_raw[i] = Int_t(fBlock[i] / fCalibrationFactor + thispedestal / (fBlocksPerEvent * 1.));
324  }
325  // fHardwareBlockSum_raw = fHardwareBlockSum / fCalibrationFactor + thispedestal;
327 
328  return;
329 }
Short_t fBlocksPerEvent
Double_t fHardwareBlockSumM2
Second moment of the hardware sum.
Int_t fHardwareBlockSum_raw
Module-based sum of the four sub-blocks as read from the module.
size_t fSequenceNumber
Event sequence number for this channel.
Int_t fSoftwareBlockSum_raw
Sum of the data in the four sub-blocks raw.
Double_t fHardwareBlockSum
Module-based sum of the four sub-blocks.
Int_t fBlock_raw[4]
Array of the sub-block data as read from the module.
Double_t fBlockM2[4]
Second moment of the sub-block.
size_t fNumberOfSamples
Number of samples read through the module.
Double_t fBlock[4]
Array of the sub-block data.

+ Here is the caller graph for this function:

void QwVQWK_Channel::SetHardwareSum ( Double_t  hwsum,
UInt_t  sequencenumber = 0 
)

TODO: SetHardwareSum should be removed, and SetEventData should be made protected.

Definition at line 288 of file QwVQWK_Channel.cc.

References fBlocksPerEvent, and SetEventData().

Referenced by QwQPD::SetEventData(), QwBPMCavity::SetEventData(), QwLinearDiodeArray::SetEventData(), and QwIntegrationPMT::SetHardwareSum().

289 {
290  Double_t* block = new Double_t[fBlocksPerEvent];
291  for (Int_t i = 0; i < fBlocksPerEvent; i++)
292  block[i] = hwsum / fBlocksPerEvent;
293  SetEventData(block);
294 
295  delete block;
296  return;
297 }
Short_t fBlocksPerEvent
void SetEventData(Double_t *block, UInt_t sequencenumber=0)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwVQWK_Channel::SetVQWKSaturationLimt ( Double_t  sat_volts = 8.5)
inline

Definition at line 172 of file QwVQWK_Channel.h.

References fSaturationABSLimit.

Referenced by QwVQWK_Channel().

172  {//Set the absolute staturation limit in volts.
173  fSaturationABSLimit=sat_volts;
174  }
Double_t fSaturationABSLimit
absolute value of the VQWK saturation volt

+ Here is the caller graph for this function:

void QwVQWK_Channel::SubtractValueFrom ( const VQwHardwareChannel valueptr)
virtual

Implements VQwHardwareChannel.

Definition at line 858 of file QwVQWK_Channel.cc.

References VQwDataElement::GetElementName().

859 {
860  const QwVQWK_Channel* tmpptr;
861  tmpptr = dynamic_cast<const QwVQWK_Channel*>(valueptr);
862  if (tmpptr!=NULL){
863  *this -= *tmpptr;
864  } else {
865  TString loc="Standard exception from QwVQWK_Channel::SubtractValueFrom = "
866  +valueptr->GetElementName()+" is an incompatable type.";
867  throw std::invalid_argument(loc.Data());
868  }
869 }
virtual const TString & GetElementName() const
Get the name of this element.

+ Here is the call graph for this function:

void QwVQWK_Channel::Sum ( const QwVQWK_Channel value1,
const QwVQWK_Channel value2 
)

Definition at line 1036 of file QwVQWK_Channel.cc.

Referenced by QwQPD::ProcessEvent().

1037 {
1038  *this = value1;
1039  *this += value2;
1040 }

+ Here is the caller graph for this function:

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  stream,
const QwVQWK_Channel channel 
)
friend

Definition at line 1417 of file QwVQWK_Channel.cc.

1418 {
1419  stream << channel.GetHardwareSum();
1420  return stream;
1421 }
Double_t GetHardwareSum() const

Field Documentation

Bool_t QwVQWK_Channel::bBlock
private

Definition at line 342 of file QwVQWK_Channel.h.

Referenced by ConstructBranchAndVector(), and FillTreeVector().

Bool_t QwVQWK_Channel::bBlock_raw
private

Definition at line 343 of file QwVQWK_Channel.h.

Referenced by ConstructBranchAndVector(), and FillTreeVector().

const Bool_t QwVQWK_Channel::bDEBUG =kFALSE
staticprivate

debugging display purposes

For VQWK data element trimming uses

Definition at line 337 of file QwVQWK_Channel.h.

Referenced by ApplyHWChecks(), FillTreeVector(), and MatchNumberOfSamples().

Bool_t QwVQWK_Channel::bDevice_Error_Code
private

Definition at line 345 of file QwVQWK_Channel.h.

Referenced by ConstructBranchAndVector(), and FillTreeVector().

Bool_t QwVQWK_Channel::bHw_sum
private

Definition at line 340 of file QwVQWK_Channel.h.

Referenced by ConstructBranchAndVector(), and FillTreeVector().

Bool_t QwVQWK_Channel::bHw_sum_raw
private

Definition at line 341 of file QwVQWK_Channel.h.

Referenced by ConstructBranchAndVector(), and FillTreeVector().

Bool_t QwVQWK_Channel::bNum_samples
private

Definition at line 344 of file QwVQWK_Channel.h.

Referenced by ConstructBranchAndVector(), and FillTreeVector().

Bool_t QwVQWK_Channel::bSequence_number
private

Definition at line 346 of file QwVQWK_Channel.h.

Referenced by ConstructBranchAndVector(), and FillTreeVector().

Int_t QwVQWK_Channel::fADC_Same_NumEvt
private

Keep track of how many events with same ADC value returned.

Definition at line 327 of file QwVQWK_Channel.h.

Referenced by ApplyHWChecks(), and InitializeChannel().

Int_t QwVQWK_Channel::fBlock_raw[4]
private
Double_t QwVQWK_Channel::fBlockError[4]
private

Uncertainty on the sub-block.

Definition at line 298 of file QwVQWK_Channel.h.

Referenced by CalculateRunningAverage(), ClearEventData(), and GetValueError().

Double_t QwVQWK_Channel::fBlockM2[4]
private
Int_t QwVQWK_Channel::fErrorCount_HWSat
private

check to see ADC channel is saturated

Definition at line 313 of file QwVQWK_Channel.h.

Referenced by AddErrEntriesToList(), IncrementErrorCounters(), InitializeChannel(), and PrintErrorCounters().

Int_t QwVQWK_Channel::fErrorCount_SameHW
private

check to see ADC returning same HW value

Definition at line 317 of file QwVQWK_Channel.h.

Referenced by AddErrEntriesToList(), IncrementErrorCounters(), InitializeChannel(), and PrintErrorCounters().

Int_t QwVQWK_Channel::fErrorCount_sample
private

for sample size check

Definition at line 314 of file QwVQWK_Channel.h.

Referenced by AddErrEntriesToList(), IncrementErrorCounters(), InitializeChannel(), and PrintErrorCounters().

Int_t QwVQWK_Channel::fErrorCount_Sequence
private

sequence number check

Definition at line 316 of file QwVQWK_Channel.h.

Referenced by AddErrEntriesToList(), IncrementErrorCounters(), InitializeChannel(), and PrintErrorCounters().

Int_t QwVQWK_Channel::fErrorCount_SW_HW
private

HW_sum==SW_sum check.

Definition at line 315 of file QwVQWK_Channel.h.

Referenced by AddErrEntriesToList(), IncrementErrorCounters(), InitializeChannel(), and PrintErrorCounters().

Int_t QwVQWK_Channel::fErrorCount_ZeroHW
private

check to see ADC returning zero

Definition at line 318 of file QwVQWK_Channel.h.

Referenced by AddErrEntriesToList(), IncrementErrorCounters(), InitializeChannel(), and PrintErrorCounters().

Int_t QwVQWK_Channel::fHardwareBlockSum_raw
private

Module-based sum of the four sub-blocks as read from the module.

Definition at line 284 of file QwVQWK_Channel.h.

Referenced by AssignScaledValue(), ClearEventData(), EncodeEventData(), GetRawValue(), operator*=(), operator+=(), operator-=(), operator=(), PrintInfo(), ProcessEvBuffer(), ProcessEvent(), Product(), Ratio(), ScaledAdd(), and SetEventData().

Double_t QwVQWK_Channel::fHardwareBlockSumError
private

Uncertainty on the hardware sum.

Definition at line 301 of file QwVQWK_Channel.h.

Referenced by AssignScaledValue(), CalculateRunningAverage(), ClearEventData(), GetValueError(), operator=(), and PrintInfo().

Double_t QwVQWK_Channel::fHardwareBlockSumM2
private
size_t QwVQWK_Channel::fNumberOfSamples_map
private

Number of samples in the expected to read through the module. This value is set in the QwBeamline map file.

Definition at line 308 of file QwVQWK_Channel.h.

Referenced by ApplyHWChecks(), InitializeChannel(), and SetDefaultSampleSize().

Int_t QwVQWK_Channel::fNumEvtsWithEventCutsRejected
private

Counts the Event cut rejected events.

Definition at line 320 of file QwVQWK_Channel.h.

Referenced by AddErrEntriesToList(), IncrementErrorCounters(), InitializeChannel(), and PrintErrorCounters().

Double_t QwVQWK_Channel::fPrev_HardwareBlockSum
private

Previous Module-based sum of the four sub-blocks.

Definition at line 330 of file QwVQWK_Channel.h.

Referenced by ApplyHWChecks(), and InitializeChannel().

size_t QwVQWK_Channel::fPreviousSequenceNumber
private

Previous event sequence number for this channel.

Definition at line 306 of file QwVQWK_Channel.h.

Referenced by InitializeChannel().

QwVQWK_Channel* QwVQWK_Channel::fRunningSum
private

Pointer to the running sum for this channel.

Definition at line 263 of file QwVQWK_Channel.h.

Referenced by AccumulateRunningSum(), and InitializeChannel().

Double_t QwVQWK_Channel::fSaturationABSLimit
private

absolute value of the VQWK saturation volt

Definition at line 334 of file QwVQWK_Channel.h.

Referenced by GetVQWKSaturationLimt(), and SetVQWKSaturationLimt().

Int_t QwVQWK_Channel::fSequenceNo_Counter
private

Internal counter to keep track of the sequence number.

Definition at line 329 of file QwVQWK_Channel.h.

Referenced by ApplyHWChecks(), and InitializeChannel().

Int_t QwVQWK_Channel::fSequenceNo_Prev
private

Keep the sequence number of the last event.

Definition at line 328 of file QwVQWK_Channel.h.

Referenced by ApplyHWChecks(), and InitializeChannel().

size_t QwVQWK_Channel::fSequenceNumber
private
Int_t QwVQWK_Channel::fSoftwareBlockSum_raw
private

Sum of the data in the four sub-blocks raw.

Definition at line 285 of file QwVQWK_Channel.h.

Referenced by AssignScaledValue(), ClearEventData(), operator*=(), operator+=(), operator-=(), operator=(), PrintInfo(), ProcessEvBuffer(), Product(), Ratio(), ScaledAdd(), and SetEventData().

const Bool_t QwVQWK_Channel::kDEBUG = kFALSE
staticprivate

Definition at line 255 of file QwVQWK_Channel.h.

Referenced by ConstructBranch(), and ConstructBranchAndVector().

const Int_t QwVQWK_Channel::kMaxChannels = 8
staticprivate

Definition at line 260 of file QwVQWK_Channel.h.

Referenced by GetBufferOffset().

const Double_t QwVQWK_Channel::kVQWK_VoltsPerBit = (20./(1<<18))
staticprivate

Conversion factor to translate the average bit count in an ADC channel into average voltage. The base factor is roughly 76 uV per count, and zero counts corresponds to zero voltage. Store as the exact value for 20 V range, 18 bit ADC.

Definition at line 267 of file QwVQWK_Channel.h.

Referenced by ApplyHWChecks(), GetAverageVolts(), and SetCalibrationToVolts().

const Int_t QwVQWK_Channel::kWordsPerChannel = 6
staticprivate

Definition at line 259 of file QwVQWK_Channel.h.

Referenced by GetBufferOffset(), and ProcessEvBuffer().


The documentation for this class was generated from the following files: