QwAnalysis
VQwScaler_Channel Class Referenceabstract

#include <QwScaler_Channel.h>

+ Inheritance diagram for VQwScaler_Channel:
+ Collaboration diagram for VQwScaler_Channel:

Public Member Functions

 VQwScaler_Channel ()
 
 VQwScaler_Channel (TString name, TString datatosave="raw")
 
 VQwScaler_Channel (const VQwScaler_Channel &source)
 
virtual ~VQwScaler_Channel ()
 
void InitializeChannel (TString name, TString datatosave="raw")
 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 SetDefaultSampleSize (size_t NumberOfSamples_map)
 
void LoadChannelParameters (QwParameterFile &paramfile)
 
void ClearEventData ()
 Clear the event data in this element. More...
 
void RandomizeEventData (int helicity=0, double time=0.0)
 Internally generate random event data. More...
 
void SetEventData (Double_t value)
 
virtual void EncodeEventData (std::vector< UInt_t > &buffer)=0
 Encode the event data into a CODA buffer. More...
 
virtual Int_t ProcessEvBuffer (UInt_t *buffer, UInt_t num_words_left, UInt_t index=0)=0
 Process the CODA event buffer for this element. More...
 
void ProcessEvent ()
 
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
 
VQwScaler_Channeloperator= (const VQwScaler_Channel &value)
 
void AssignScaledValue (const VQwScaler_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)
 
VQwScaler_Channeloperator+= (const VQwScaler_Channel &value)
 
VQwScaler_Channeloperator-= (const VQwScaler_Channel &value)
 
VQwScaler_Channeloperator*= (const VQwScaler_Channel &value)
 
VQwHardwareChanneloperator+= (const VQwHardwareChannel *input)
 
VQwHardwareChanneloperator-= (const VQwHardwareChannel *input)
 
VQwHardwareChanneloperator*= (const VQwHardwareChannel *input)
 
VQwHardwareChanneloperator/= (const VQwHardwareChannel *input)
 
void Sum (VQwScaler_Channel &value1, VQwScaler_Channel &value2)
 
void Difference (VQwScaler_Channel &value1, VQwScaler_Channel &value2)
 
void Ratio (const VQwScaler_Channel &numer, const VQwScaler_Channel &denom)
 
void Product (VQwScaler_Channel &numer, VQwScaler_Channel &denom)
 
void AddChannelOffset (Double_t Offset)
 
void Scale (Double_t Offset)
 
void DivideBy (const VQwScaler_Channel &denom)
 
Int_t ApplyHWChecks ()
 
Bool_t ApplySingleEventCuts ()
 
void IncrementErrorCounters ()
 
void PrintErrorCounters () const
 report number of events failed due to HW and event cut failure More...
 
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
 
void AccumulateRunningSum (const VQwScaler_Channel &value)
 
void AccumulateRunningSum (const VQwScaler_Channel &value, Int_t count)
 
void AccumulateRunningSum (const VQwHardwareChannel *value, Int_t count)
 
void DeaccumulateRunningSum (const VQwScaler_Channel &value)
 
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 CalculateRunningAverage ()
 
virtual Bool_t NeedsExternalClock ()
 
virtual void SetNeedsExternalClock (Bool_t needed)
 
virtual std::string GetExternalClockName ()
 
virtual void SetExternalClockPtr (const VQwHardwareChannel *clock)
 
virtual void SetExternalClockName (const std::string name)
 
virtual Bool_t IsDifferentialScaler ()
 
virtual void SetDifferentialScaler (Bool_t diff)
 
void ScaledAdd (Double_t scale, const VQwHardwareChannel *value)
 
- 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 AddErrEntriesToList (std::vector< QwErrDBInterface > &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 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 scalerindex, Int_t wordindex, UInt_t header=1)
 
static void PrintErrorCounterHead ()
 
static void PrintErrorCounterTail ()
 

Protected Member Functions

VQwScaler_Channeloperator/= (const VQwScaler_Channel &)
 
- 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...
 

Protected Attributes

UInt_t fValue_Raw_Old
 
UInt_t fValue_Raw
 
Double_t fValue
 
Double_t fValueM2
 
Double_t fValueError
 
const VQwHardwareChannelfNormChannelPtr
 
Double_t fClockNormalization
 
std::string fNormChannelName
 
Bool_t fNeedsExternalClock
 
Bool_t fIsDifferentialScaler
 
Int_t fNumEvtsWithHWErrors
 
Int_t fNumEvtsWithEventCutsRejected
 
- 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

static const Bool_t kDEBUG = kFALSE
 
- 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...
 

Additional Inherited Members

- Public Types inherited from VQwDataElement
enum  EDataToSave { kRaw = 0, kDerived }
 

Detailed Description

Definition at line 28 of file QwScaler_Channel.h.

Constructor & Destructor Documentation

VQwScaler_Channel::VQwScaler_Channel ( )
inline

Definition at line 45 of file QwScaler_Channel.h.

References InitializeChannel().

45  : MQwMockable() {
46  InitializeChannel("","");
47  }
void InitializeChannel(TString name, TString datatosave="raw")
Initialize the fields in this object.

+ Here is the call graph for this function:

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

Definition at line 49 of file QwScaler_Channel.h.

References InitializeChannel().

49  : MQwMockable() {
50  InitializeChannel(name,datatosave);
51  };
void InitializeChannel(TString name, TString datatosave="raw")
Initialize the fields in this object.

+ Here is the call graph for this function:

VQwScaler_Channel::VQwScaler_Channel ( const VQwScaler_Channel source)
inline

Definition at line 52 of file QwScaler_Channel.h.

53  : VQwHardwareChannel(source),MQwMockable(source),
55  fValue_Raw(source.fValue_Raw),
56  fValue(source.fValue),
57  fValueM2(source.fValueM2),
58  fValueError(source.fValueError),
59  // TODO: Don't copy the pointer; we need to regenerate it somehow.
60  //fNormChannelPtr(source.fNormChannelPtr);
65  { }
std::string fNormChannelName
Double_t fClockNormalization
virtual VQwScaler_Channel::~VQwScaler_Channel ( )
inlinevirtual

Definition at line 66 of file QwScaler_Channel.h.

66 { };

Member Function Documentation

void VQwScaler_Channel::AccumulateRunningSum ( const VQwScaler_Channel value)
inline

Definition at line 144 of file QwScaler_Channel.h.

References VQwDataElement::fGoodEventCount.

Referenced by AccumulateRunningSum(), and DeaccumulateRunningSum().

144  {
146  }
void AccumulateRunningSum(const VQwScaler_Channel &value)
Int_t fGoodEventCount
Number of good events accumulated in this element.

+ Here is the caller graph for this function:

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

Definition at line 658 of file QwScaler_Channel.cc.

References QwLog::endl(), VQwDataElement::fErrorFlag, VQwDataElement::fGoodEventCount, fValue, fValueM2, VQwDataElement::GetElementName(), and QwWarning.

659 {
660  // Moment calculations
661  Int_t n1 = fGoodEventCount;
662  Int_t n2 = count;
663 
664  // If there are no good events, check whether device HW is good
665  if (n2 == 0 && value.fErrorFlag == 0) {
666  n2 = 1;
667  }
668  Int_t n = n1 + n2;
669 
670  // Set up variables
671  Double_t M11 = fValue;
672  Double_t M12 = value.fValue;
673  Double_t M22 = value.fValueM2;
674  if (n2 == 0) {
675  // no good events for addition
676  return;
677  } else if (n2 == 1) {
678  // simple version for addition of single event
679  fGoodEventCount++;
680  fValue += (M12 - M11) / n;
681  fValueM2 += (M12 - M11) * (M12 - fValue); // note: using updated mean
682  } else if (n2 > 1) {
683  // general version for addition of multi-event sets
684  fGoodEventCount += n2;
685  fValue += n2 * (M12 - M11) / n;
686  fValueM2 += M22 + n1 * n2 * (M12 - M11) * (M12 - M11) / n;
687  }
688 
689  // Nanny
690  if (fValue != fValue)
691  QwWarning << "Angry Nanny: NaN detected in " << GetElementName() << QwLog::endl;
692 }
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
Int_t fGoodEventCount
Number of good events accumulated in this element.
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:

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

Implements VQwHardwareChannel.

Definition at line 148 of file QwScaler_Channel.h.

References AccumulateRunningSum().

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

+ Here is the call graph for this function:

void VQwScaler_Channel::AddChannelOffset ( Double_t  Offset)

Definition at line 571 of file QwScaler_Channel.cc.

References fValue, and VQwDataElement::IsNameEmpty().

572 {
573  if (!IsNameEmpty())
574  {
575  fValue += offset;
576  }
577 }
Bool_t IsNameEmpty() const
Is the name of this element empty?

+ Here is the call graph for this function:

void VQwScaler_Channel::AddValueFrom ( const VQwHardwareChannel valueptr)
virtual

Implements VQwHardwareChannel.

Definition at line 327 of file QwScaler_Channel.cc.

References VQwDataElement::GetElementName().

328 {
329  const VQwScaler_Channel* tmpptr;
330  tmpptr = dynamic_cast<const VQwScaler_Channel*>(valueptr);
331  if (tmpptr!=NULL){
332  *this += *tmpptr;
333  } else {
334  TString loc="Standard exception from VQwScaler_Channel::AddValueFrom = "
335  +valueptr->GetElementName()+" is an incompatable type.";
336  throw std::invalid_argument(loc.Data());
337  }
338 }
virtual const TString & GetElementName() const
Get the name of this element.

+ Here is the call graph for this function:

Int_t VQwScaler_Channel::ApplyHWChecks ( )
virtual

Implements VQwHardwareChannel.

Definition at line 595 of file QwScaler_Channel.cc.

References VQwHardwareChannel::bEVENTCUTMODE, VQwDataElement::fErrorFlag, VQwHardwareChannel::GetRawValue(), and kErrorFlag_ZeroHW.

595  {
596  // fErrorFlag=0;
597  if (bEVENTCUTMODE>0){//Global switch to ON/OFF event cuts set at the event cut file
598  //check for the hw_sum is zero
599  if (GetRawValue()==0){
601  }
602  }
603  return fErrorFlag;
604 }
static const UInt_t kErrorFlag_ZeroHW
Definition: QwTypes.h:163
Int_t GetRawValue() const
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...

+ Here is the call graph for this function:

Bool_t VQwScaler_Channel::ApplySingleEventCuts ( )
virtual

Implements VQwHardwareChannel.

Definition at line 608 of file QwScaler_Channel.cc.

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

609 {
610  Bool_t status;
611  //QwError<<" Single Event Check ! "<<QwLog::endl;
612  if (bEVENTCUTMODE>=2){//Global switch to ON/OFF event cuts set at the event cut file
613 
614  if (fULimit==0 && fLLimit==0){
615  status=kTRUE;
616  } else if (GetValue()<=fULimit && GetValue()>=fLLimit){
617  //QwError<<" Single Event Cut passed "<<GetElementName()<<" "<<GetValue()<<QwLog::endl;
618  if (fErrorFlag !=0)
619  status=kFALSE;
620  else
621  status=kTRUE;
622  }
623  else{
624  //QwError<<" Single Event Cut Failed "<<GetElementName()<<" "<<GetValue()<<QwLog::endl;
625  if (GetValue()> fULimit)
627  else
629  status=kFALSE;
630  }
631 
632  if (bEVENTCUTMODE==3){
633  status=kTRUE; //Update the event cut fail flag but pass the event.
634  }
635 
636  }
637  else{
638  status=kTRUE;
639  fErrorFlag=0;
640  }
641 
642 
643  return status;
644 }
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 GetValue() const
static const UInt_t kErrorFlag_EventCut_U
Definition: QwTypes.h:165

+ Here is the call graph for this function:

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

Definition at line 390 of file QwScaler_Channel.cc.

References VQwDataElement::fErrorFlag, VQwDataElement::fGoodEventCount, fValue, fValueError, fValueM2, and VQwDataElement::IsNameEmpty().

392 {
393  if (!IsNameEmpty()) {
394  this->fValue = value.fValue * scale;
395  this->fValueError = value.fValueError;
396  this->fValueM2 = value.fValueM2 * scale * scale;
397  this->fErrorFlag = value.fErrorFlag;//error code is updated.
398  this->fGoodEventCount = value.fGoodEventCount;
399  }
400  return;
401 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
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.

+ Here is the call graph for this function:

void VQwScaler_Channel::AssignValueFrom ( const VQwDataElement valueptr)
virtual

Implements VQwHardwareChannel.

Definition at line 316 of file QwScaler_Channel.cc.

References VQwDataElement::GetElementName().

316  {
317  const VQwScaler_Channel* tmpptr;
318  tmpptr = dynamic_cast<const VQwScaler_Channel*>(valueptr);
319  if (tmpptr!=NULL){
320  *this = *tmpptr;
321  } else {
322  TString loc="Standard exception from VQwScaler_Channel::AssignValueFrom = "
323  +valueptr->GetElementName()+" is an incompatable type.";
324  throw std::invalid_argument(loc.Data());
325  }
326 }
virtual const TString & GetElementName() const
Get the name of this element.

+ Here is the call graph for this function:

void VQwScaler_Channel::CalculateRunningAverage ( )
virtual

Implements VQwHardwareChannel.

Definition at line 694 of file QwScaler_Channel.cc.

References VQwDataElement::fGoodEventCount, fValueError, and fValueM2.

695 {
696  // See notes in QwVQWK_Channel; we are using:
697  // error = sqrt(M2)/n,
698  // or alternately we could use the unbiased estimator for both
699  // the sigma and error on the mean:
700  // error = sqrt(M2)/(n-1)
701  if(fGoodEventCount > 0) {
703  } else {
704  fValueError = 0.0;
705  }
706 
707 }
Int_t fGoodEventCount
Number of good events accumulated in this element.
void VQwScaler_Channel::ClearEventData ( )
virtual

Clear the event data in this element.

Reimplemented from VQwHardwareChannel.

Definition at line 65 of file QwScaler_Channel.cc.

References VQwDataElement::fErrorFlag, VQwDataElement::fGoodEventCount, fValue, fValue_Raw, fValueError, and fValueM2.

66 {
67  fValue_Raw = 0;
68  fValue = 0.0;
69  fValueM2 = 0.0;
70  fValueError = 0.0;
71 
72  fGoodEventCount = 0;
73  fErrorFlag = 0;
74 }
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.
void VQwScaler_Channel::ConstructBranch ( TTree *  tree,
TString &  prefix 
)
virtual

Implements VQwHardwareChannel.

Definition at line 272 of file QwScaler_Channel.cc.

References fValue, VQwDataElement::GetElementName(), and VQwDataElement::IsNameEmpty().

273 {
274  if (IsNameEmpty()){
275  // This channel is not used, so skip setting up the tree.
276  } else {
277  TString basename = prefix + GetElementName();
278 
279  tree->Branch(basename, &fValue, basename+"/D");
280  }
281 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
virtual const TString & GetElementName() const
Get the name of this element.

+ Here is the call graph for this function:

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

Implements VQwHardwareChannel.

Definition at line 248 of file QwScaler_Channel.cc.

References VQwHardwareChannel::fDataToSave, VQwHardwareChannel::fTreeArrayIndex, VQwHardwareChannel::fTreeArrayNumEntries, VQwDataElement::GetElementName(), gQwHists, VQwDataElement::IsNameEmpty(), VQwDataElement::kRaw, and QwHistogramHelper::MatchDeviceParamsFromList().

249 {
250  if (IsNameEmpty()){
251  // This channel is not used, so skip setting up the tree.
252  } else {
253  TString basename = prefix + GetElementName();
254  fTreeArrayIndex = values.size();
255 
256  TString list;
257  values.push_back(0.0);
258  list = "value/D";
259  values.push_back(0.0);
260  list += ":Device_Error_Code/D";
261  if(fDataToSave==kRaw){
262  values.push_back(0.0);
263  list += ":raw/D";
264  }
265 
266  fTreeArrayNumEntries = values.size() - fTreeArrayIndex;
267  if (gQwHists.MatchDeviceParamsFromList(basename.Data()))
268  tree->Branch(basename, &(values[fTreeArrayIndex]), list);
269  }
270 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
Bool_t MatchDeviceParamsFromList(const std::string &devicename)
QwHistogramHelper gQwHists
Globally defined instance of the QwHistogramHelper class.
virtual const TString & GetElementName() const
Get the name of this element.

+ Here is the call graph for this function:

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

Construct the histograms for this data element.

Implements VQwDataElement.

Definition at line 218 of file QwScaler_Channel.cc.

References QwHistogramHelper::Construct1DHist(), MQwHistograms::fHistograms, VQwDataElement::GetElementName(), and gQwHists.

218  {
219  // If we have defined a subdirectory in the ROOT file, then change into it.
220  if (folder != NULL) folder->cd();
221 
222  if (GetElementName()==""){
223  // This channel is not used, so skip filling the histograms.
224  } else {
225  // Now create the histograms.
226  TString basename, fullname;
227  basename = prefix + GetElementName();
228 
229  fHistograms.resize(1, NULL);
230  size_t index=0;
231  fHistograms[index] = gQwHists.Construct1DHist(basename);
232  index += 1;
233  }
234 }
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:

void VQwScaler_Channel::DeaccumulateRunningSum ( const VQwScaler_Channel value)
inline

Definition at line 152 of file QwScaler_Channel.h.

References AccumulateRunningSum().

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

+ Here is the call graph for this function:

void VQwScaler_Channel::Difference ( VQwScaler_Channel value1,
VQwScaler_Channel value2 
)

Definition at line 498 of file QwScaler_Channel.cc.

498  {
499  *this = value1;
500  *this -= value2;
501 }
void VQwScaler_Channel::DivideBy ( const VQwHardwareChannel valueptr)
virtual

Implements VQwHardwareChannel.

Definition at line 364 of file QwScaler_Channel.cc.

References VQwDataElement::GetElementName().

365 {
366  const VQwScaler_Channel* tmpptr;
367  tmpptr = dynamic_cast<const VQwScaler_Channel*>(valueptr);
368  if (tmpptr!=NULL){
369  *this /= *tmpptr;
370  } else {
371  TString loc="Standard exception from VQwScaler_Channel::DivideBy = "
372  +valueptr->GetElementName()+" is an incompatable type.";
373  throw std::invalid_argument(loc.Data());
374  }
375 }
virtual const TString & GetElementName() const
Get the name of this element.

+ Here is the call graph for this function:

void VQwScaler_Channel::DivideBy ( const VQwScaler_Channel denom)

Definition at line 589 of file QwScaler_Channel.cc.

590 {
591  *this /= denom;
592 }
virtual void VQwScaler_Channel::EncodeEventData ( std::vector< UInt_t > &  buffer)
pure virtual

Encode the event data into a CODA buffer.

Implements MQwMockable.

Implemented in QwScaler_Channel< data_mask, data_shift >, and QwScaler_Channel< 0x00ffffff, 0 >.

void VQwScaler_Channel::FillHistograms ( )
virtual

Fill the histograms for this data element.

Implements VQwDataElement.

Definition at line 236 of file QwScaler_Channel.cc.

References VQwDataElement::fErrorFlag, MQwHistograms::fHistograms, fValue, and VQwDataElement::IsNameEmpty().

237 {
238  size_t index = 0;
239  if (IsNameEmpty()) {
240  // This channel is not used, so skip creating the histograms.
241  } else {
242  if (index < fHistograms.size() && fHistograms[index] != NULL && fErrorFlag==0)
243  fHistograms[index]->Fill(this->fValue);
244  index += 1;
245  }
246 }
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
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...

+ Here is the call graph for this function:

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

Implements VQwHardwareChannel.

Definition at line 283 of file QwScaler_Channel.cc.

References QwLog::endl(), VQwHardwareChannel::fDataToSave, VQwDataElement::fElementName, VQwDataElement::fErrorFlag, VQwHardwareChannel::fTreeArrayIndex, VQwHardwareChannel::fTreeArrayNumEntries, fValue, fValue_Raw, VQwDataElement::GetElementName(), VQwDataElement::IsNameEmpty(), VQwDataElement::kRaw, and QwError.

284 {
285  if (IsNameEmpty()) {
286  // This channel is not used, so skip setting up the tree.
287  } else if (fTreeArrayNumEntries < 0) {
288  QwError << "VQwScaler_Channel::FillTreeVector: fTreeArrayNumEntries=="
290  } else if (fTreeArrayNumEntries == 0) {
291  static bool warned = false;
292  if (!warned) {
293  QwError << "VQwScaler_Channel::FillTreeVector: fTreeArrayNumEntries=="
294  << fTreeArrayNumEntries << " (no branch constructed?)" << QwLog::endl;
295  QwError << "Offending element is " << GetElementName() << QwLog::endl;
296  warned = true;
297  }
298  } else if (values.size() < fTreeArrayIndex+fTreeArrayNumEntries) {
299  QwError << "VQwScaler_Channel::FillTreeVector: values.size()=="
300  << values.size() << " name: " << fElementName
301  << "; fTreeArrayIndex+fTreeArrayNumEntries=="
302  << fTreeArrayIndex << '+' << fTreeArrayNumEntries << '='
304  << QwLog::endl;
305  } else {
306  size_t index = fTreeArrayIndex;
307  values[index++] = this->fValue;
308  values[index++] = this->fErrorFlag;
309  if(fDataToSave==kRaw){
310  values[index++] = this->fValue_Raw;
311  }
312  }
313 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
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
TString fElementName
Name of this data element.
virtual const TString & GetElementName() const
Get the name of this element.
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

Int_t VQwScaler_Channel::GetBufferOffset ( Int_t  scalerindex,
Int_t  wordindex,
UInt_t  header = 1 
)
static

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

Parameters
scalerindexScaler index within this buffer; counts from 1
wordindexWord index within this scaler; counts from 1
headerNumber of header words; normally is 1
Returns
The number of words offset to the beginning of this scaler word from the beginning of the buffer.

Definition at line 103 of file QwScaler_Channel.cc.

References QwLog::endl(), and QwError.

Referenced by QwBeamDetectorID::QwBeamDetectorID().

104 {
105  Int_t offset = -1;
106  Int_t kMaxWords = 32; // usually the scalers have 32 data words starting from 0
107 
108  if (scalerindex<0 ){
109  QwError << "QwScaler_Channel::GetBufferOffset: Invalid scaler index,"
110  << scalerindex
111  << ". Must be zero or greater."
112  << QwLog::endl;
113  } else if (scalerindex<0 || wordindex>kMaxWords){
114  QwError << "QwScaler_Channel::GetBufferOffset: Invalid word index,"
115  << wordindex
116  << ". Must be in range [0," << kMaxWords << "]."
117  << QwLog::endl;
118  } else {
119  offset = (header + kMaxWords)*scalerindex + header + wordindex ;
120  }
121  return offset;
122 }
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
#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:

virtual std::string VQwScaler_Channel::GetExternalClockName ( )
inlinevirtual

Reimplemented from VQwDataElement.

Definition at line 164 of file QwScaler_Channel.h.

References fNormChannelName.

164 { return fNormChannelName; };
std::string fNormChannelName
Int_t VQwScaler_Channel::GetRawValue ( size_t  element) const
inlinevirtual

Implements VQwHardwareChannel.

Definition at line 91 of file QwScaler_Channel.h.

References fValue_Raw.

91 { return fValue_Raw; };
Double_t VQwScaler_Channel::GetValue ( size_t  element) const
inlinevirtual

Implements VQwHardwareChannel.

Definition at line 92 of file QwScaler_Channel.h.

References fValue.

92 { return fValue; };
Double_t VQwScaler_Channel::GetValueError ( size_t  element) const
inlinevirtual

Implements VQwHardwareChannel.

Definition at line 94 of file QwScaler_Channel.h.

References fValueError.

94 { return fValueError; };
Double_t VQwScaler_Channel::GetValueM2 ( size_t  element) const
inlinevirtual

Implements VQwHardwareChannel.

Definition at line 93 of file QwScaler_Channel.h.

References fValueM2.

93 { return fValueM2; };
void VQwScaler_Channel::IncrementErrorCounters ( )

Definition at line 646 of file QwScaler_Channel.cc.

References VQwDataElement::fErrorFlag, fNumEvtsWithEventCutsRejected, fNumEvtsWithHWErrors, kErrorFlag_EventCut_L, kErrorFlag_EventCut_U, and kErrorFlag_ZeroHW.

647 {
649  fNumEvtsWithHWErrors++; //increment the hw error counter
650  }
651  if ( ((kErrorFlag_EventCut_L & fErrorFlag)==kErrorFlag_EventCut_L)
652  || ((kErrorFlag_EventCut_U & fErrorFlag)==kErrorFlag_EventCut_U)){
653  fNumEvtsWithEventCutsRejected++; //increment the event cut error counter
654  }
655 }
static const UInt_t kErrorFlag_ZeroHW
Definition: QwTypes.h:163
Int_t fNumEvtsWithEventCutsRejected
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
static const UInt_t kErrorFlag_EventCut_U
Definition: QwTypes.h:165
void VQwScaler_Channel::InitializeChannel ( TString  name,
TString  datatosave = "raw" 
)
virtual

Initialize the fields in this object.

Implements VQwHardwareChannel.

Definition at line 21 of file QwScaler_Channel.cc.

References VQwHardwareChannel::fCalibrationFactor, fClockNormalization, VQwDataElement::fErrorConfigFlag, VQwDataElement::fErrorFlag, VQwDataElement::fGoodEventCount, fIsDifferentialScaler, fNeedsExternalClock, fNormChannelPtr, fNumEvtsWithEventCutsRejected, fNumEvtsWithHWErrors, VQwHardwareChannel::fPedestal, VQwHardwareChannel::fTreeArrayIndex, VQwHardwareChannel::fTreeArrayNumEntries, fValue, fValue_Raw, fValue_Raw_Old, fValueError, fValueM2, VQwHardwareChannel::SetDataToSave(), VQwDataElement::SetElementName(), VQwHardwareChannel::SetNumberOfDataWords(), VQwHardwareChannel::SetNumberOfSubElements(), and MQwMockable::SetRandomEventParameters().

Referenced by InitializeChannel(), and VQwScaler_Channel().

22 {
23  fNormChannelPtr = NULL;
24  fNeedsExternalClock = kFALSE;
25  fIsDifferentialScaler = false;
26 
27  SetElementName(name);
28  SetDataToSave(datatosave);
29  SetNumberOfDataWords(1); //Scaler - single word, 32 bits
31 
32  // Default mockdata parameters
33  SetRandomEventParameters(300.0, 50.0);
34 
35  fValue_Raw_Old = 0;
36  fValue_Raw = 0;
37  fValue = 0.0;
38  fValueM2 = 0.0;
39  fValueError = 0.0;
40  fPedestal = 0.0;
41  fCalibrationFactor = 1.0;
42 
43  fClockNormalization = 1.0;
44 
45  fTreeArrayIndex = 0;
47 
48  fNumEvtsWithHWErrors=0;//init error counters
49  fNumEvtsWithEventCutsRejected=0;//init error counters
50 
51  fErrorFlag = 0;
53  fGoodEventCount = 0;
54  return;
55 };
const VQwHardwareChannel * fNormChannelPtr
void SetRandomEventParameters(Double_t mean, Double_t sigma)
Set the normal random event parameters.
Definition: MQwMockable.cc:41
void SetDataToSave(TString datatosave)
Set the flag indicating if raw or derived values are in this data element.
void SetNumberOfDataWords(const UInt_t &numwords)
Set the number of data words in this data element.
void SetNumberOfSubElements(const size_t elements)
Set the number of data words in this data element.
Int_t fNumEvtsWithEventCutsRejected
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...
UInt_t fErrorConfigFlag
contains the global/local/stability flags
Int_t fGoodEventCount
Number of good events accumulated in this element.
Double_t fClockNormalization

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Initialize the fields in this object.

Implements VQwHardwareChannel.

Definition at line 59 of file QwScaler_Channel.cc.

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

59  {
60  InitializeChannel(name,datatosave);
61  SetSubsystemName(subsystem);
62  SetModuleType(instrumenttype);
63 }
void InitializeChannel(TString name, TString datatosave="raw")
Initialize the fields in this object.
void SetSubsystemName(TString sysname)
Set the name of the inheriting subsystem name.
void SetModuleType(TString ModuleType)
set the type of the beam instrument

+ Here is the call graph for this function:

virtual Bool_t VQwScaler_Channel::IsDifferentialScaler ( )
inlinevirtual

Definition at line 169 of file QwScaler_Channel.h.

References fIsDifferentialScaler.

169 { return fIsDifferentialScaler; };
void VQwScaler_Channel::LoadChannelParameters ( QwParameterFile paramfile)
virtual

Reimplemented from VQwDataElement.

Definition at line 133 of file QwScaler_Channel.cc.

References fNeedsExternalClock, QwParameterFile::ReturnValue(), and SetExternalClockName().

133  {
134  std::string varvalue;
135  if (paramfile.ReturnValue("normclock",varvalue)){
136  boost::to_lower(varvalue);
137  SetExternalClockName(varvalue);
138  fNeedsExternalClock = kTRUE;
139  }
140 };
virtual void SetExternalClockName(const std::string name)
Bool_t ReturnValue(const std::string keyname, T &retvalue)

+ Here is the call graph for this function:

void VQwScaler_Channel::MultiplyBy ( const VQwHardwareChannel valueptr)
virtual

Implements VQwHardwareChannel.

Definition at line 351 of file QwScaler_Channel.cc.

References VQwDataElement::GetElementName().

352 {
353  const VQwScaler_Channel* tmpptr;
354  tmpptr = dynamic_cast<const VQwScaler_Channel*>(valueptr);
355  if (tmpptr!=NULL){
356  *this *= *tmpptr;
357  } else {
358  TString loc="Standard exception from VQwScaler_Channel::MultiplyBy = "
359  +valueptr->GetElementName()+" is an incompatable type.";
360  throw std::invalid_argument(loc.Data());
361  }
362 }
virtual const TString & GetElementName() const
Get the name of this element.

+ Here is the call graph for this function:

virtual Bool_t VQwScaler_Channel::NeedsExternalClock ( )
inlinevirtual

Reimplemented from VQwDataElement.

Definition at line 162 of file QwScaler_Channel.h.

References fNeedsExternalClock.

Referenced by ProcessEvent().

162 { return fNeedsExternalClock; };

+ Here is the caller graph for this function:

VQwScaler_Channel & VQwScaler_Channel::operator*= ( const VQwScaler_Channel value)

Definition at line 424 of file QwScaler_Channel.cc.

References VQwDataElement::fErrorFlag, fValue, fValue_Raw, fValueM2, and VQwDataElement::IsNameEmpty().

425 {
426  if (!IsNameEmpty()){
427  this->fValue *= value.fValue;
428  fValue_Raw = 0;
429  this->fValueM2 = 0.0;
430  this->fErrorFlag |= (value.fErrorFlag);//error code is ORed.
431  }
432  return *this;
433 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...

+ Here is the call graph for this function:

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

Implements VQwHardwareChannel.

Definition at line 463 of file QwScaler_Channel.cc.

References VQwDataElement::GetElementName().

464 {
465  const VQwScaler_Channel* tmpptr;
466  tmpptr = dynamic_cast<const VQwScaler_Channel*>(source);
467  if (tmpptr!=NULL){
468  *this *= *tmpptr;
469  } else {
470  TString loc="Standard exception from VQwScaler_Channel::operator*= "
471  +source->GetElementName()+" "
472  +this->GetElementName()+" are not of the same type";
473  throw(std::invalid_argument(loc.Data()));
474  }
475  return *this;
476 }
virtual const TString & GetElementName() const
Get the name of this element.

+ Here is the call graph for this function:

VQwScaler_Channel & VQwScaler_Channel::operator+= ( const VQwScaler_Channel value)

Definition at line 404 of file QwScaler_Channel.cc.

References VQwDataElement::fErrorFlag, fValue, fValueM2, and VQwDataElement::IsNameEmpty().

405 {
406  if (!IsNameEmpty()){
407  this->fValue += value.fValue;
408  this->fValueM2 = 0.0;
409  this->fErrorFlag |= value.fErrorFlag;//error code is ORed.
410  }
411  return *this;
412 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...

+ Here is the call graph for this function:

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

Implements VQwHardwareChannel.

Definition at line 435 of file QwScaler_Channel.cc.

References VQwDataElement::GetElementName().

436 {
437  const VQwScaler_Channel* tmpptr;
438  tmpptr = dynamic_cast<const VQwScaler_Channel*>(source);
439  if (tmpptr!=NULL){
440  *this += *tmpptr;
441  } else {
442  TString loc="Standard exception from VQwScaler_Channel::operator+= "
443  +source->GetElementName()+" "
444  +this->GetElementName()+" are not of the same type";
445  throw(std::invalid_argument(loc.Data()));
446  }
447  return *this;
448 }
virtual const TString & GetElementName() const
Get the name of this element.

+ Here is the call graph for this function:

VQwScaler_Channel & VQwScaler_Channel::operator-= ( const VQwScaler_Channel value)

Definition at line 414 of file QwScaler_Channel.cc.

References VQwDataElement::fErrorFlag, fValue, fValueM2, and VQwDataElement::IsNameEmpty().

415 {
416  if (!IsNameEmpty()){
417  this->fValue -= value.fValue;
418  this->fValueM2 = 0.0;
419  this->fErrorFlag |= (value.fErrorFlag);//error code is ORed.
420  }
421  return *this;
422 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...

+ Here is the call graph for this function:

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

Implements VQwHardwareChannel.

Definition at line 449 of file QwScaler_Channel.cc.

References VQwDataElement::GetElementName().

450 {
451  const VQwScaler_Channel* tmpptr;
452  tmpptr = dynamic_cast<const VQwScaler_Channel*>(source);
453  if (tmpptr!=NULL){
454  *this -= *tmpptr;
455  } else {
456  TString loc="Standard exception from VQwScaler_Channel::operator-= "
457  +source->GetElementName()+" "
458  +this->GetElementName()+" are not of the same type";
459  throw(std::invalid_argument(loc.Data()));
460  }
461  return *this;
462 }
virtual const TString & GetElementName() const
Get the name of this element.

+ Here is the call graph for this function:

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

Implements VQwHardwareChannel.

Definition at line 477 of file QwScaler_Channel.cc.

References VQwDataElement::GetElementName().

478 {
479  const VQwScaler_Channel* tmpptr;
480  tmpptr = dynamic_cast<const VQwScaler_Channel*>(source);
481  if (tmpptr!=NULL){
482  *this /= *tmpptr;
483  } else {
484  TString loc="Standard exception from VQwScaler_Channel::operator/= "
485  +source->GetElementName()+" "
486  +this->GetElementName()+" are not of the same type";
487  throw(std::invalid_argument(loc.Data()));
488  }
489  return *this;
490 }
virtual const TString & GetElementName() const
Get the name of this element.

+ Here is the call graph for this function:

VQwScaler_Channel & VQwScaler_Channel::operator/= ( const VQwScaler_Channel denom)
protected

Definition at line 518 of file QwScaler_Channel.cc.

References QwLog::endl(), VQwDataElement::fErrorFlag, fValue, fValueM2, VQwDataElement::GetElementName(), VQwDataElement::IsNameEmpty(), QwVerbose, and QwWarning.

519 {
520  // In this function, leave the "raw" variables untouched.
521  Double_t ratio;
522  Double_t variance;
523  if (!IsNameEmpty()){
524  // The variances are calculated using the following formula:
525  // Var[ratio] = ratio^2 (Var[numer] / numer^2 + Var[denom] / denom^2)
526  //
527  // This requires that both the numerator and denominator are non-zero!
528  //
529  if (this->fValue != 0.0 && denom.fValue != 0.0){
530  ratio = (this->fValue) / (denom.fValue);
531  variance = ratio * ratio *
532  (this->fValueM2 / this->fValue / this->fValue
533  + denom.fValueM2 / denom.fValue / denom.fValue);
534  fValue = ratio;
535  fValueM2 = variance;
536  } else if (this->fValue == 0.0) {
537  fValue = 0.0;
538  fValueM2 = 0.0;
539  } else {
540  QwVerbose << "Attempting to divide by zero in "
541  << GetElementName() << QwLog::endl;
542  fValue = 0.0;
543  fValueM2 = 0.0;
544  }
545 
546  // Remaining variables
547  // Don't change fGoodEventCount.
548  // 'OR' the device error codes together.
549  fErrorFlag |= denom.fErrorFlag;
550  }
551 
552  // Nanny
553  if (fValue != fValue)
554  QwWarning << "Angry Nanny: NaN detected in " << GetElementName() << QwLog::endl;
555  return *this;
556 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
#define QwVerbose
Predefined log drain for verbose messages.
Definition: QwLog.h:55
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
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:

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

Definition at line 377 of file QwScaler_Channel.cc.

References fValue, fValue_Raw, fValueError, fValueM2, VQwDataElement::IsNameEmpty(), and VQwHardwareChannel::operator=().

378 {
379  if(this == &value) return *this;
380  if (!IsNameEmpty()) {
382  this->fValue_Raw = value.fValue_Raw;
383  this->fValue = value.fValue;
384  this->fValueError = value.fValueError;
385  this->fValueM2 = value.fValueM2;
386  }
387  return *this;
388 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
virtual VQwHardwareChannel & operator=(const VQwHardwareChannel &value)
Arithmetic assignment operator: Should only copy event-based data.

+ Here is the call graph for this function:

static void VQwScaler_Channel::PrintErrorCounterHead ( )
static
void VQwScaler_Channel::PrintErrorCounters ( ) const
virtual

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

Reimplemented from VQwDataElement.

Definition at line 709 of file QwScaler_Channel.cc.

References QwLog::endl(), fNumEvtsWithEventCutsRejected, fNumEvtsWithHWErrors, VQwDataElement::GetElementName(), and QwMessage.

709  {
710  if (fNumEvtsWithHWErrors>0)
711  QwMessage << "QwScaler_Channel " << GetElementName()
712  << " had " << fNumEvtsWithHWErrors
713  << " events with a hardware faliure."
714  << QwLog::endl;
715 
717  QwMessage << "QwScaler_Channel " << GetElementName()
718  << " had " << fNumEvtsWithEventCutsRejected
719  << " events rejected by Event Cuts."
720  << QwLog::endl;
721  }
#define QwMessage
Predefined log drain for regular messages.
Definition: QwLog.h:50
Int_t fNumEvtsWithEventCutsRejected
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:

static void VQwScaler_Channel::PrintErrorCounterTail ( )
static
void VQwScaler_Channel::PrintInfo ( ) const
virtual

Print multiple lines of information about this data element.

Reimplemented from VQwDataElement.

Definition at line 211 of file QwScaler_Channel.cc.

References QwLog::endl(), VQwDataElement::GetElementName(), and QwMessage.

212 {
213  QwMessage << "***************************************" << QwLog::endl;
214  QwMessage << "QwScaler channel: " << GetElementName()
215  << QwLog::endl;
216 }
#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
virtual const TString & GetElementName() const
Get the name of this element.

+ Here is the call graph for this function:

void VQwScaler_Channel::PrintValue ( ) const
virtual

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

Reimplemented from VQwDataElement.

Definition at line 202 of file QwScaler_Channel.cc.

References QwLog::endl(), VQwDataElement::GetElementName(), VQwHardwareChannel::GetValue(), VQwHardwareChannel::GetValueError(), VQwHardwareChannel::GetValueWidth(), and QwMessage.

203 {
204  // printf("Name %s %23.4f +/- %15.4f", GetElementName().Data(), fValue, fValueError);
205  QwMessage << std::setw(5) << std::left << GetElementName() << " , "
206  << std::setprecision(4)
207  << std::setw(5) << std::right << GetValue() << " +/- " << GetValueError() << " sigma "<<GetValueWidth()
208  << QwLog::endl;
209 }
#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
virtual const TString & GetElementName() const
Get the name of this element.
Double_t GetValueError() const
Double_t GetValue() const
Double_t GetValueWidth() const

+ Here is the call graph for this function:

virtual Int_t VQwScaler_Channel::ProcessEvBuffer ( UInt_t *  buffer,
UInt_t  num_words_left,
UInt_t  subelement = 0 
)
pure virtual

Process the CODA event buffer for this element.

Implements VQwDataElement.

Implemented in QwScaler_Channel< data_mask, data_shift >, and QwScaler_Channel< 0x00ffffff, 0 >.

void VQwScaler_Channel::ProcessEvent ( )

Definition at line 183 of file QwScaler_Channel.cc.

References QwLog::endl(), VQwHardwareChannel::fCalibrationFactor, fNormChannelName, fNormChannelPtr, VQwHardwareChannel::fPedestal, fValue, fValue_Raw, VQwDataElement::GetElementName(), VQwHardwareChannel::GetValue(), NeedsExternalClock(), and QwWarning.

184 {
185  if (NeedsExternalClock()){
186  if(fNormChannelPtr){
187  Double_t time = fNormChannelPtr->GetValue();
188  //QwError << "VQwScaler_Channel::ProcessEvent() "<<GetElementName()<<" "<< fValue_Raw<< " "<< fValue<<" "<<fCalibrationFactor<<" "<< fPedestal<<QwLog::endl;
189  fValue = fCalibrationFactor * (Double_t(fValue_Raw)/time - fPedestal);
190  } else {
191  QwWarning << "VQwScaler_Channel::ProcessEvent: "
192  << "Missing the reference clock, "
194  << ", for data element "
195  << GetElementName()
196  << QwLog::endl;
197  }
198  }
199 }
const VQwHardwareChannel * fNormChannelPtr
std::string fNormChannelName
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.
Double_t GetValue() const
#define QwWarning
Predefined log drain for warnings.
Definition: QwLog.h:45
virtual Bool_t NeedsExternalClock()

+ Here is the call graph for this function:

void VQwScaler_Channel::Product ( VQwScaler_Channel numer,
VQwScaler_Channel denom 
)

Definition at line 558 of file QwScaler_Channel.cc.

References VQwDataElement::fErrorFlag, VQwDataElement::fGoodEventCount, fValue, fValue_Raw, and VQwDataElement::IsNameEmpty().

559 {
560  if (!IsNameEmpty()){
561  fValue = numer.fValue * denom.fValue;
562  fValue_Raw = 0;
563 
564  // Remaining variables
566  fErrorFlag = (numer.fErrorFlag|denom.fErrorFlag);//error code is ORed.
567  }
568 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
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.

+ Here is the call graph for this function:

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

Internally generate random event data.

Implements MQwMockable.

Definition at line 76 of file QwScaler_Channel.cc.

References VQwHardwareChannel::fCalibrationFactor, MQwMockable::fMockAsymmetry, MQwMockable::fMockDriftAmplitude, MQwMockable::fMockDriftFrequency, MQwMockable::fMockDriftPhase, MQwMockable::fMockGaussianMean, MQwMockable::fMockGaussianSigma, VQwHardwareChannel::fPedestal, fValue, fValue_Raw, MQwMockable::GetRandomValue(), and Qw::pi.

77 {
78  // Calculate drift (if time is not specified, it stays constant at zero)
79  Double_t drift = 0.0;
80  for (UInt_t i = 0; i < fMockDriftFrequency.size(); i++) {
81  drift += fMockDriftAmplitude[i] * sin(2.0 * Qw::pi * fMockDriftFrequency[i] * time + fMockDriftPhase[i]);
82  }
83 
84  Double_t value = fMockGaussianMean * (1 + helicity * fMockAsymmetry)
86  + drift;
87 
88  fValue = value;
89  fValue_Raw = Int_t(value / fCalibrationFactor + fPedestal);
90 }
static const double pi
Angles: base unit is radian.
Definition: QwUnits.h:102
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
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:

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

Definition at line 503 of file QwScaler_Channel.cc.

References VQwDataElement::fErrorFlag, VQwDataElement::fGoodEventCount, fValue_Raw, and VQwDataElement::IsNameEmpty().

504 {
505  if (!IsNameEmpty()){
506  *this = numer;
507  *this /= denom;
508 
509  // Set the raw values to zero.
510  fValue_Raw = 0;
511 
512  // Remaining variables
514  fErrorFlag = (numer.fErrorFlag|denom.fErrorFlag);//error code is ORed.
515  }
516 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
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.

+ Here is the call graph for this function:

void VQwScaler_Channel::Scale ( Double_t  Offset)
virtual

Implements VQwHardwareChannel.

Definition at line 580 of file QwScaler_Channel.cc.

References fValue, fValueM2, and VQwDataElement::IsNameEmpty().

581 {
582  if (!IsNameEmpty())
583  {
584  fValue *= scale;
585  fValueM2 *= scale * scale;
586  }
587 }
Bool_t IsNameEmpty() const
Is the name of this element empty?

+ Here is the call graph for this function:

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

Implements VQwHardwareChannel.

Definition at line 723 of file QwScaler_Channel.cc.

References VQwDataElement::fErrorFlag, fValue, fValueM2, and VQwDataElement::IsNameEmpty().

723  {
724 
725  const VQwScaler_Channel* input = dynamic_cast<const VQwScaler_Channel*>(value);
726 
727  // follows same steps as += but w/ scaling factor
728  if (input!=NULL && !IsNameEmpty()){
729  this->fValue += scale * input->fValue;
730  this->fValueM2 = 0.0;
731  this->fErrorFlag |= (input->fErrorFlag);
732  }
733 }
Bool_t IsNameEmpty() const
Is the name of this element empty?
UInt_t fErrorFlag
This the standard error code generated for the channel that contains the global/local/stability flags...

+ Here is the call graph for this function:

void VQwScaler_Channel::SetDefaultSampleSize ( size_t  NumberOfSamples_map)
inline

Definition at line 74 of file QwScaler_Channel.h.

74  {
75  //std::cerr << "QwScaler_Channel SetDefaultSampleSize does nothing!"
76  // << std::endl;
77  }
virtual void VQwScaler_Channel::SetDifferentialScaler ( Bool_t  diff)
inlinevirtual

Definition at line 170 of file QwScaler_Channel.h.

References fIsDifferentialScaler.

Referenced by QwScaler::LoadChannelMap().

170 { fIsDifferentialScaler = diff; };

+ Here is the caller graph for this function:

void VQwScaler_Channel::SetEventData ( Double_t  value)

Definition at line 125 of file QwScaler_Channel.cc.

References fValue, and fValue_Raw.

125  {
126 
127  this->fValue = value;
128  this->fValue_Raw = (UInt_t)value;
129  //std::cout<<"fValue is set to: value = "<<value<<std::endl;
130 
131 }
virtual void VQwScaler_Channel::SetExternalClockName ( const std::string  name)
inlinevirtual

Reimplemented from VQwDataElement.

Definition at line 166 of file QwScaler_Channel.h.

References fNormChannelName.

Referenced by LoadChannelParameters().

166 { fNormChannelName = name; };
std::string fNormChannelName

+ Here is the caller graph for this function:

virtual void VQwScaler_Channel::SetExternalClockPtr ( const VQwHardwareChannel clock)
inlinevirtual

Reimplemented from VQwDataElement.

Definition at line 165 of file QwScaler_Channel.h.

References fNormChannelPtr.

165 { fNormChannelPtr = clock; };
const VQwHardwareChannel * fNormChannelPtr
virtual void VQwScaler_Channel::SetNeedsExternalClock ( Bool_t  needed)
inlinevirtual

Reimplemented from VQwDataElement.

Definition at line 163 of file QwScaler_Channel.h.

References fNeedsExternalClock.

163 { fNeedsExternalClock = needed; };
void VQwScaler_Channel::SubtractValueFrom ( const VQwHardwareChannel valueptr)
virtual

Implements VQwHardwareChannel.

Definition at line 339 of file QwScaler_Channel.cc.

References VQwDataElement::GetElementName().

340 {
341  const VQwScaler_Channel* tmpptr;
342  tmpptr = dynamic_cast<const VQwScaler_Channel*>(valueptr);
343  if (tmpptr!=NULL){
344  *this -= *tmpptr;
345  } else {
346  TString loc="Standard exception from VQwScaler_Channel::SubtractValueFrom = "
347  +valueptr->GetElementName()+" is an incompatable type.";
348  throw std::invalid_argument(loc.Data());
349  }
350 }
virtual const TString & GetElementName() const
Get the name of this element.

+ Here is the call graph for this function:

void VQwScaler_Channel::Sum ( VQwScaler_Channel value1,
VQwScaler_Channel value2 
)

Definition at line 492 of file QwScaler_Channel.cc.

493 {
494  *this = value1;
495  *this += value2;
496 }

Field Documentation

Double_t VQwScaler_Channel::fClockNormalization
protected

Definition at line 186 of file QwScaler_Channel.h.

Referenced by InitializeChannel().

Bool_t VQwScaler_Channel::fIsDifferentialScaler
protected
Bool_t VQwScaler_Channel::fNeedsExternalClock
protected
std::string VQwScaler_Channel::fNormChannelName
protected

Definition at line 187 of file QwScaler_Channel.h.

Referenced by GetExternalClockName(), ProcessEvent(), and SetExternalClockName().

const VQwHardwareChannel* VQwScaler_Channel::fNormChannelPtr
protected

Definition at line 185 of file QwScaler_Channel.h.

Referenced by InitializeChannel(), ProcessEvent(), and SetExternalClockPtr().

Int_t VQwScaler_Channel::fNumEvtsWithEventCutsRejected
protected
Int_t VQwScaler_Channel::fNumEvtsWithHWErrors
protected
UInt_t VQwScaler_Channel::fValue_Raw
protected
UInt_t VQwScaler_Channel::fValue_Raw_Old
protected

Definition at line 180 of file QwScaler_Channel.h.

Referenced by InitializeChannel().

Double_t VQwScaler_Channel::fValueError
protected
const Bool_t VQwScaler_Channel::kDEBUG = kFALSE
staticprotected

Definition at line 178 of file QwScaler_Channel.h.


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