JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
QwCombinedBCM< T > Class Template Reference

Template for a combined beam current monitor using weighted inputs. More...

#include <QwCombinedBCM.h>

+ Inheritance diagram for QwCombinedBCM< T >:
+ Collaboration diagram for QwCombinedBCM< T >:

Public Member Functions

 QwCombinedBCM ()
 
 QwCombinedBCM (TString name)
 
 QwCombinedBCM (TString subsystem, TString name)
 
 QwCombinedBCM (TString subsystemname, TString name, TString type)
 
 QwCombinedBCM (const QwCombinedBCM &source)
 
 ~QwCombinedBCM () override
 
void SetBCMForCombo (VQwBCM *bcm, Double_t weight, Double_t sumqw) override
 
Int_t ProcessEvBuffer (UInt_t *buffer, UInt_t word_position_in_buffer, UInt_t subelement=0) override
 Process the raw event buffer and decode into the channel.
 
void InitializeChannel (TString name, TString datatosave) override
 
void InitializeChannel (TString subsystem, TString name, TString datatosave) override
 
void InitializeChannel (TString subsystem, TString name, TString type, TString datatosave)
 
void ProcessEvent () override
 
void GetProjectedCharge (VQwBCM *device) override
 
void RandomizeEventData (int helicity=0, double time=0.0) override
 
size_t GetNumberOfElements () override
 
TString GetSubElementName (Int_t index) override
 
void LoadMockDataParameters (QwParameterFile &paramfile) override
 
Bool_t ApplyHWChecks ()
 
Bool_t ApplySingleEventCuts () override
 
UInt_t UpdateErrorFlag () override
 
VQwBCMoperator= (const VQwBCM &value) override
 
QwCombinedBCMoperator= (const QwCombinedBCM &value)
 
void SetPedestal (Double_t ped) override
 Set the pedestal value for the beam current monitor.
 
void SetCalibrationFactor (Double_t calib) override
 Set the calibration factor for the beam current monitor.
 
VQwHardwareChannelGetCharge () override
 
const VQwHardwareChannelGetCharge () const override
 
- Public Member Functions inherited from QwBCM< T >
 QwBCM ()
 
 QwBCM (TString name)
 
 QwBCM (TString subsystemname, TString name)
 
 QwBCM (TString subsystemname, TString name, TString type, TString clock="")
 
 QwBCM (const QwBCM &source)
 
 ~QwBCM () override
 
void InitializeChannel (TString subsystem, TString name, TString type, TString datatosave)
 Initialize the BCM with subsystem, module type, and name.
 
void ClearEventData () override
 Clear event-scoped data in the underlying channel.
 
void LoadChannelParameters (QwParameterFile &paramfile) override
 
void SetRandomEventDriftParameters (Double_t amplitude, Double_t phase, Double_t frequency)
 Configure deterministic drift parameters applied per event.
 
void AddRandomEventDriftParameters (Double_t amplitude, Double_t phase, Double_t frequency) override
 Add additional drift parameters to the drift model.
 
void SetRandomEventParameters (Double_t mean, Double_t sigma) override
 Configure Gaussian mock data parameters.
 
void SetRandomEventAsymmetry (Double_t asymmetry) override
 Set an asymmetry parameter applied to helicity states.
 
void SetResolution (Double_t resolution)
 
void ApplyResolutionSmearing () override
 Smear the channel by the configured resolution.
 
void FillRawEventData () override
 Materialize the current event state as raw event data.
 
void EncodeEventData (std::vector< UInt_t > &buffer) override
 Encode current event data into an output buffer.
 
void UseExternalRandomVariable ()
 Use an external random variable source for mock data.
 
void SetExternalRandomVariable (Double_t random_variable)
 Set the external random variable to drive mock data.
 
Bool_t ApplyHWChecks ()
 Apply hardware checks and return whether the event is valid.
 
void IncrementErrorCounters () override
 Increment error counters (number of failed events).
 
void PrintErrorCounters () const override
 Print error counters (const overload).
 
UInt_t GetEventcutErrorFlag () override
 return the error flag on this channel/device
 
void UpdateErrorFlag (const VQwBCM *ev_error) override
 Merge error flags from a reference BCM into this instance.
 
UInt_t GetErrorCode () const
 
Int_t SetSingleEventCuts (Double_t mean=0, Double_t sigma=0)
 Set basic single-event cut limits.
 
void SetSingleEventCuts (UInt_t errorflag, Double_t min=0, Double_t max=0, Double_t stability=0, Double_t burplevel=0) override
 Inherited from VQwDataElement to set the upper and lower limits (fULimit and fLLimit), stability % and the error flag on this channel.
 
void SetDefaultSampleSize (Int_t sample_size) override
 Set the default sample size used by the channel.
 
void SetEventCutMode (Int_t bcuts) override
 
void PrintValue () const override
 Print a compact value summary for this BCM.
 
void PrintInfo () const override
 Print detailed information for this BCM.
 
std::string GetExternalClockName () override
 
Bool_t NeedsExternalClock () override
 
void SetExternalClockPtr (const VQwHardwareChannel *clock) override
 
void SetExternalClockName (const std::string name) override
 
Double_t GetNormClockValue () override
 
VQwBCMoperator+= (const VQwBCM &value) override
 Polymorphic add-assign from VQwBCM if types match.
 
VQwBCMoperator-= (const VQwBCM &value) override
 Polymorphic subtract-assign from VQwBCM.
 
QwBCMoperator= (const QwBCM &value)
 Copy-assign from another BCM (event-scoped data).
 
QwBCMoperator+= (const QwBCM &value)
 Add-assign from another BCM (sum raw channels).
 
QwBCMoperator-= (const QwBCM &value)
 Subtract-assign from another BCM (difference raw channels).
 
void Ratio (const VQwBCM &numer, const VQwBCM &denom) override
 Polymorphic ratio formation for BCM.
 
void Ratio (const QwBCM &numer, const QwBCM &denom)
 Type-specific ratio formation for BCM.
 
void Scale (Double_t factor) override
 Scale the underlying channel by a constant factor.
 
void AccumulateRunningSum (const VQwBCM &, Int_t count=0, Int_t ErrorMask=0xFFFFFFF) override
 Accumulate running sums from another BCM into this one.
 
void DeaccumulateRunningSum (VQwBCM &value, Int_t ErrorMask=0xFFFFFFF) override
 Remove a single entry from the running sums using a source value.
 
void CalculateRunningAverage () override
 Update running averages for the underlying channel.
 
Bool_t CheckForBurpFail (const VQwDataElement *ev_error) override
 Check for burp failures by delegating to the underlying channel.
 
void ConstructHistograms (TDirectory *folder, TString &prefix) override
 Define histograms for this BCM (delegated to underlying channel).
 
void FillHistograms () override
 Fill histograms for this BCM if enabled.
 
void ConstructBranchAndVector (TTree *tree, TString &prefix, QwRootTreeBranchVector &values) override
 Construct ROOT branches and value vector entries.
 
void ConstructBranch (TTree *tree, TString &prefix) override
 Construct ROOT branches for this BCM (if enabled).
 
void ConstructBranch (TTree *tree, TString &prefix, QwParameterFile &modulelist) override
 Construct ROOT branches for this BCM using a trim file filter.
 
void FillTreeVector (QwRootTreeBranchVector &values) const override
 Fill tree vector entries for this BCM.
 
Double_t GetValue () override
 Get the current value of the beam current.
 
Double_t GetValueError () override
 Get the statistical error on the beam current.
 
Double_t GetValueWidth () override
 Get the width of the beam current distribution.
 
- Public Member Functions inherited from VQwBCM
 ~VQwBCM () override
 
UInt_t UpdateErrorFlag () override
 Update the error flag based on the error flags of internally contained objects Return parameter is the "Eventcut Error Flag".
 
- Public Member Functions inherited from VQwDataElement
 VQwDataElement ()
 Default constructor.
 
 VQwDataElement (const VQwDataElement &value)
 Copy constructor.
 
 ~VQwDataElement () override
 Virtual destructor.
 
void CopyFrom (const VQwDataElement &value)
 
Bool_t IsNameEmpty () const
 Is the name of this element empty?
 
void SetElementName (const TString &name)
 Set the name of this element.
 
virtual const TString & GetElementName () const
 Get the name of this element.
 
size_t GetNumberOfDataWords ()
 Get the number of data words in this data element.
 
UInt_t GetGoodEventCount () const
 
virtual void AssignValueFrom (const VQwDataElement *)
 
VQwDataElementoperator+= (const VQwDataElement &)
 Addition-assignment operator.
 
VQwDataElementoperator-= (const VQwDataElement &)
 Subtraction-assignment operator.
 
void Sum (const VQwDataElement &, const VQwDataElement &)
 Sum operator (base class fallback throws runtime error)
 
void Difference (const VQwDataElement &, const VQwDataElement &)
 Difference operator (base class fallback throws runtime error)
 
void Ratio (const VQwDataElement &, const VQwDataElement &)
 Ratio operator (base class fallback throws runtime error)
 
void SetSingleEventCuts (UInt_t, Double_t, Double_t, Double_t)
 set the upper and lower limits (fULimit and fLLimit), stability % and the error flag on this channel
 
Bool_t CheckForBurpFail (const VQwDataElement *)
 
virtual void SetNeedsExternalClock (Bool_t)
 
TString GetSubsystemName () const
 Return the name of the inheriting subsystem name.
 
void SetSubsystemName (TString sysname)
 Set the name of the inheriting subsystem name.
 
TString GetModuleType () const
 Return the type of the beam instrument.
 
void SetModuleType (TString ModuleType)
 set the type of the beam instrument
 
- Public Member Functions inherited from MQwHistograms
void ShareHistograms (const MQwHistograms *source)
 Share histogram pointers between objects.
 

Private Attributes

std::vector< QwBCM< T > * > fElement
 
std::vector< Double_t > fWeights
 
Double_t fSumQweights
 
Double_t fLastTripTime
 
Double_t fTripPeriod
 
Double_t fTripLength
 
Double_t fTripRamp
 
Double_t fProbabilityOfTrip
 

Parity mock data generation

static std::mt19937 fRandomnessGenerator
 Internal randomness generator.
 
static std::uniform_real_distribution< double > fDistribution
 Internal uniform probability distribution.
 
static std::function< double()> fRandomVariable
 Internal normal random variable.
 
static void SetTripSeed (uint seedval)
 

Additional Inherited Members

- Public Types inherited from VQwDataElement
enum  EDataToSave { kRaw = 0 , kDerived , kMoments }
 
- Static Public Member Functions inherited from VQwBCM
static VQwBCMCreate (TString subsystemname, TString type, TString name, TString clock="")
 Factory method to create a concrete BCM instance for the requested module type.
 
static VQwBCMCreate (const VQwBCM &source)
 Copy constructor factory method to clone a BCM from an existing instance.
 
static VQwBCMCreateCombo (TString subsystemname, TString type, TString name)
 Factory method to create a concrete Combined BCM for the requested module type.
 
static VQwBCMCreateCombo (const VQwBCM &source)
 
- Protected Member Functions inherited from VQwBCM
 VQwBCM (VQwDataElement &beamcurrent)
 
 VQwBCM (VQwDataElement &beamcurrent, TString)
 
- Protected Member Functions inherited from VQwDataElement
void SetNumberOfDataWords (const UInt_t &numwords)
 Set the number of data words in this data element.
 
VQwDataElementoperator= (const VQwDataElement &value)
 Arithmetic assignment operator: Should only copy event-based data.
 
void UpdateErrorFlag (const UInt_t &error)
 
- Protected Member Functions inherited from MQwHistograms
 MQwHistograms ()
 Default constructor.
 
 MQwHistograms (const MQwHistograms &source)
 Copy constructor.
 
virtual ~MQwHistograms ()
 Virtual destructor.
 
MQwHistogramsoperator= (const MQwHistograms &value)
 
void Fill_Pointer (TH1_ptr hist_ptr, Double_t value)
 
void AddHistogram (TH1 *h)
 Register a histogram.
 
- Protected Attributes inherited from QwBCM< T >
fBeamCurrent
 
- Protected Attributes inherited from VQwBCM
VQwDataElementfBeamCurrent_ref
 
- Protected Attributes inherited from VQwDataElement
TString fElementName
 Name of this data element.
 
UInt_t fNumberOfDataWords
 Number of raw data words in this data element.
 
UInt_t fGoodEventCount
 Number of good events accumulated in this element.
 
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)
 
UInt_t fErrorConfigFlag
 contains the global/local/stability flags
 
- Protected Attributes inherited from MQwHistograms
std::vector< TH1_ptrfHistograms
 Histograms associated with this data element.
 

Detailed Description

template<typename T>
class QwCombinedBCM< T >

Template for a combined beam current monitor using weighted inputs.

Aggregates multiple BCMs into a single effective current channel by applying user-provided weights. Provides event processing hooks and error propagation consistent with VQwBCM.

Definition at line 37 of file QwCombinedBCM.h.

Constructor & Destructor Documentation

◆ QwCombinedBCM() [1/5]

template<typename T>
QwCombinedBCM< T >::QwCombinedBCM ( )
inline

Definition at line 40 of file QwCombinedBCM.h.

40{ };

Referenced by GetCharge(), operator=(), operator=(), and QwCombinedBCM().

+ Here is the caller graph for this function:

◆ QwCombinedBCM() [2/5]

template<typename T>
QwCombinedBCM< T >::QwCombinedBCM ( TString name)
inline

Definition at line 41 of file QwCombinedBCM.h.

41 {
42 InitializeChannel(name, "derived");
43 };
Template for a combined beam current monitor using weighted inputs.
void InitializeChannel(TString name, TString datatosave) override

References InitializeChannel().

+ Here is the call graph for this function:

◆ QwCombinedBCM() [3/5]

template<typename T>
QwCombinedBCM< T >::QwCombinedBCM ( TString subsystem,
TString name )
inline

Definition at line 44 of file QwCombinedBCM.h.

44 {
45 InitializeChannel(subsystem, name, "derived");
46 };

References InitializeChannel().

+ Here is the call graph for this function:

◆ QwCombinedBCM() [4/5]

template<typename T>
QwCombinedBCM< T >::QwCombinedBCM ( TString subsystemname,
TString name,
TString type )
inline

Definition at line 47 of file QwCombinedBCM.h.

47 {
50 };
void SetSubsystemName(TString sysname)
Set the name of the inheriting subsystem name.

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

+ Here is the call graph for this function:

◆ QwCombinedBCM() [5/5]

template<typename T>
QwCombinedBCM< T >::QwCombinedBCM ( const QwCombinedBCM< T > & source)
inline

Definition at line 51 of file QwCombinedBCM.h.

53 { }
friend class QwBCM
Definition VQwBCM.h:60

References QwBCM< T >::QwBCM(), and QwCombinedBCM().

+ Here is the call graph for this function:

◆ ~QwCombinedBCM()

template<typename T>
QwCombinedBCM< T >::~QwCombinedBCM ( )
inlineoverride

Definition at line 54 of file QwCombinedBCM.h.

54{ };

Member Function Documentation

◆ ApplyHWChecks()

template<typename T>
Bool_t QwCombinedBCM< T >::ApplyHWChecks ( )
inline

Definition at line 78 of file QwCombinedBCM.h.

78 {
79 return kTRUE;
80 };

◆ ApplySingleEventCuts()

template<typename T>
Bool_t QwCombinedBCM< T >::ApplySingleEventCuts ( )
overridevirtual

Apply single-event cuts: first propagate error codes from constituent BCMs, then apply cuts using the inherited BCM logic.

Reimplemented from QwBCM< T >.

Definition at line 236 of file QwCombinedBCM.cc.

237{
238
239 //This is required to update single event cut failures in individual channels
240 // First update the error code based on the codes
241 // of the elements. This requires that the BCMs
242 // have had ApplySingleEventCuts run on them already.
243
244 for (size_t i=0;i<fElement.size();i++){
245 this->fBeamCurrent.UpdateErrorFlag(fElement.at(i)->fBeamCurrent.GetErrorCode());
246 }
247
248
249 // Everything is identical as for a regular BCM
251}
std::vector< QwBCM< T > * > fElement
T fBeamCurrent
Definition QwBCM.h:189
Bool_t ApplySingleEventCuts() override
Apply single-event cuts for this BCM and return pass/fail.
Definition QwBCM.cc:279

References QwBCM< T >::ApplySingleEventCuts(), QwBCM< T >::fBeamCurrent, and fElement.

+ Here is the call graph for this function:

◆ GetCharge() [1/2]

template<typename T>
const VQwHardwareChannel * QwCombinedBCM< T >::GetCharge ( ) const
inlineoverridevirtual

Reimplemented from VQwBCM.

Definition at line 110 of file QwCombinedBCM.h.

110 {
111 return const_cast<QwCombinedBCM*>(this)->GetCharge();
112 };
VQwHardwareChannel * GetCharge() override

References GetCharge(), and QwCombinedBCM().

+ Here is the call graph for this function:

◆ GetCharge() [2/2]

template<typename T>
VQwHardwareChannel * QwCombinedBCM< T >::GetCharge ( )
inlineoverridevirtual

Reimplemented from QwBCM< T >.

Definition at line 106 of file QwCombinedBCM.h.

106 {
107 return &(this->fBeamCurrent);
108 };

References QwBCM< T >::fBeamCurrent.

Referenced by GetCharge().

+ Here is the caller graph for this function:

◆ GetNumberOfElements()

template<typename T>
size_t QwCombinedBCM< T >::GetNumberOfElements ( )
inlineoverridevirtual

Reimplemented from VQwBCM.

Definition at line 73 of file QwCombinedBCM.h.

73{return fElement.size();};

References fElement.

◆ GetProjectedCharge()

template<typename T>
void QwCombinedBCM< T >::GetProjectedCharge ( VQwBCM * device)
overridevirtual

Project the combined current to a device channel, applying resolution smearing and filling raw event data.

Reimplemented from VQwBCM.

Definition at line 145 of file QwCombinedBCM.cc.

146{
147 (device->GetCharge())->AssignScaledValue(this->fBeamCurrent,1.0);
148 //device->PrintInfo();
150 //device->PrintInfo();
152}
void ApplyResolutionSmearing() override
Smear the channel by the configured resolution.
Definition QwBCM.cc:191
void FillRawEventData() override
Materialize the current event state as raw event data.
Definition QwBCM.cc:196

References VQwBCM::ApplyResolutionSmearing(), QwBCM< T >::fBeamCurrent, VQwBCM::FillRawEventData(), VQwBCM::GetCharge(), and VQwBCM::VQwBCM().

+ Here is the call graph for this function:

◆ GetSubElementName()

template<typename T>
TString QwCombinedBCM< T >::GetSubElementName ( Int_t index)
inlineoverridevirtual

Reimplemented from VQwBCM.

Definition at line 74 of file QwCombinedBCM.h.

74{return fElement.at(index)->GetElementName();};

References fElement.

◆ InitializeChannel() [1/3]

template<typename T>
void QwCombinedBCM< T >::InitializeChannel ( TString name,
TString datatosave )
overridevirtual

Initialize combined BCM with simple name and default settings.

Reimplemented from QwBCM< T >.

Definition at line 70 of file QwCombinedBCM.cc.

71{
72 SetPedestal(0.);
74 fLastTripTime = -99999.9;
75 this->SetElementName(name);
76 this->fBeamCurrent.InitializeChannel(name,"derived");
77}
void SetElementName(const TString &name)
Set the name of this element.
void SetPedestal(Double_t ped) override
Set the pedestal value for the beam current monitor.
Double_t fLastTripTime
void SetCalibrationFactor(Double_t calib) override
Set the calibration factor for the beam current monitor.

References QwBCM< T >::fBeamCurrent, fLastTripTime, SetCalibrationFactor(), VQwDataElement::SetElementName(), and SetPedestal().

Referenced by QwCombinedBCM(), QwCombinedBCM(), and QwCombinedBCM().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InitializeChannel() [2/3]

template<typename T>
void QwCombinedBCM< T >::InitializeChannel ( TString subsystem,
TString name,
TString datatosave )
overridevirtual

Initialize combined BCM with subsystem scoping.

Reimplemented from QwBCM< T >.

Definition at line 81 of file QwCombinedBCM.cc.

82{
83 SetPedestal(0.);
85 fLastTripTime = -99999.9;
86 this->SetElementName(name);
87 this->fBeamCurrent.InitializeChannel(subsystem, "QwCombinedBCM", name,"derived");
88}

References QwBCM< T >::fBeamCurrent, fLastTripTime, SetCalibrationFactor(), VQwDataElement::SetElementName(), and SetPedestal().

+ Here is the call graph for this function:

◆ InitializeChannel() [3/3]

template<typename T>
void QwCombinedBCM< T >::InitializeChannel ( TString subsystem,
TString name,
TString type,
TString datatosave )

Definition at line 91 of file QwCombinedBCM.cc.

93{
94 SetPedestal(0.);
96 fLastTripTime = -99999.9;
97 this->SetElementName(name);
98 this->SetModuleType(type);
99 this->fBeamCurrent.InitializeChannel(subsystem, "QwCombinedBCM", name,"derived");
100}
void SetModuleType(TString ModuleType)
set the type of the beam instrument

References QwBCM< T >::fBeamCurrent, fLastTripTime, SetCalibrationFactor(), VQwDataElement::SetElementName(), VQwDataElement::SetModuleType(), and SetPedestal().

+ Here is the call graph for this function:

◆ LoadMockDataParameters()

template<typename T>
void QwCombinedBCM< T >::LoadMockDataParameters ( QwParameterFile & paramfile)
overridevirtual

Load mock data parameters including beam trip settings and resolution. Recognizes 'beamtrip' and 'resolution' keywords.

Reimplemented from QwBCM< T >.

Definition at line 202 of file QwCombinedBCM.cc.

202 {
203
204 Double_t res=0.0;
205
206 // Test for the word "beamtrip", and get the tripperiod and tripduration if it is found, otherwise, just pass
207 // the line to the fBeamCurrent object.
208 if (paramfile.GetLine().find("beamtrip")!=std::string::npos){
209 // "beamtrip" appears somewhere in the line. Assume it is the next token and move on...
210 paramfile.GetNextToken(); //Throw away this token. Now the next three should be the beamtrip parameters.
211
212 fTripPeriod = paramfile.GetTypedNextToken<Double_t>() * Qw::sec;
213 fTripLength = paramfile.GetTypedNextToken<Double_t>() * Qw::sec;
214 fTripRamp = paramfile.GetTypedNextToken<Double_t>() * Qw::sec;
215
217 } else if (paramfile.GetLine().find("resolution")!=std::string::npos){
218 paramfile.GetNextToken();
219 res = paramfile.GetTypedNextToken<Double_t>();
220 this->SetResolution(res);
221 } else {
222 //std::cout << "In QwCombinedBCM: ChannelName = " << this->GetElementName() << std::endl;
223 this->fBeamCurrent.LoadMockDataParameters(paramfile);
224 }
225}
Double_t fTripLength
Double_t fTripRamp
Double_t fProbabilityOfTrip
Double_t fTripPeriod
void SetResolution(Double_t resolution)
Definition QwBCM.h:79

References QwBCM< T >::fBeamCurrent, fProbabilityOfTrip, fTripLength, fTripPeriod, fTripRamp, QwParameterFile::GetLine(), QwParameterFile::GetNextToken(), QwParameterFile::GetTypedNextToken(), Qw::sec, and QwBCM< T >::SetResolution().

+ Here is the call graph for this function:

◆ operator=() [1/2]

template<typename T>
QwCombinedBCM< T > & QwCombinedBCM< T >::operator= ( const QwCombinedBCM< T > & value)

Assignment operator: copy the beam current value.

Definition at line 322 of file QwCombinedBCM.cc.

323{
324 if (this->GetElementName()!="")
326
327 return *this;
328}
virtual const TString & GetElementName() const
Get the name of this element.

References QwBCM< T >::fBeamCurrent, VQwDataElement::GetElementName(), and QwCombinedBCM().

+ Here is the call graph for this function:

◆ operator=() [2/2]

template<typename T>
VQwBCM & QwCombinedBCM< T >::operator= ( const VQwBCM & value)
overridevirtual

Polymorphic assignment operator.

Reimplemented from QwBCM< T >.

Definition at line 332 of file QwCombinedBCM.cc.

333{
334 if (this->GetElementName()!="")
335 dynamic_cast<QwCombinedBCM<T>* >(this)->fBeamCurrent=
336 dynamic_cast<const QwCombinedBCM<T>* >(&value)->fBeamCurrent;
337
338 return *this;
339}

References QwBCM< T >::fBeamCurrent, VQwDataElement::GetElementName(), QwCombinedBCM(), and VQwBCM::VQwBCM().

+ Here is the call graph for this function:

◆ ProcessEvBuffer()

template<typename T>
Int_t QwCombinedBCM< T >::ProcessEvBuffer ( UInt_t * buffer,
UInt_t word_position_in_buffer,
UInt_t subelement = 0 )
inlineoverridevirtual

Process the raw event buffer and decode into the channel.

Returns
The updated buffer word position.

Reimplemented from QwBCM< T >.

Definition at line 60 of file QwCombinedBCM.h.

60{ return 0; };

References QwBPMStripline< T >::subelement.

◆ ProcessEvent()

template<typename T>
void QwCombinedBCM< T >::ProcessEvent ( )
overridevirtual

Compute weighted average of constituent BCM currents and normalize by total weight sum.

Reimplemented from QwBCM< T >.

Definition at line 109 of file QwCombinedBCM.cc.

110{
111 static T tmpADC;
112 tmpADC.InitializeChannel("tmp","derived");
113
114 this->ClearEventData();
115
116 for (size_t i = 0; i < fElement.size(); i++) {
117 tmpADC = fElement[i]->fBeamCurrent;
119 this->fBeamCurrent += tmpADC;
120 }
121 this->fBeamCurrent.Scale(1.0/fSumQweights);
122
124 if (ldebug) {
125 QwMessage << "*****************" << QwLog::endl;
126 QwMessage << "QwCombinedBCM: " << this->GetElementName() << QwLog::endl
127 << "weighted average of hardware sums = " << this->fBeamCurrent.GetValue() << QwLog::endl;
128 if (this->fBeamCurrent.GetNumberOfSubelements() > 1) {
129 for (size_t i = 0; i < 4; i++) {
130 QwMessage << "weighted average of block[" << i << "] = " << this->fBeamCurrent.GetValue(i) << QwLog::endl;
131 }
132 }
133 QwMessage << "*****************" << QwLog::endl;
134 }
135}
virtual void ClearEventData()
Clear the event data in this element.
std::vector< Double_t > fWeights
Double_t fSumQweights
void Scale(Double_t factor) override
Scale the underlying channel by a constant factor.
Definition QwBCM.cc:485

References QwBCM< T >::ClearEventData(), QwLog::endl(), QwBCM< T >::fBeamCurrent, fElement, fSumQweights, fWeights, VQwDataElement::GetElementName(), and QwMessage.

+ Here is the call graph for this function:

◆ RandomizeEventData()

template<typename T>
void QwCombinedBCM< T >::RandomizeEventData ( int helicity = 0,
double time = 0.0 )
overridevirtual

Generate random event data and optionally simulate beam trips with configurable trip period, length, and ramp duration.

Reimplemented from QwBCM< T >.

Definition at line 160 of file QwCombinedBCM.cc.

161{
162 this->fBeamCurrent.RandomizeEventData(helicity, time);
163 // do the beam cut routine from MockDataGenerator, but just scale fBeamCurrent instead of re-randomizing
164 // Three time intervals: fmod(time,period) > (period-tripramp): Do the ramp scaling
165 // (period-tripramp) > fmod(time,period) > (period-triplength- tripramp): scale by 0.0
166 // (period-triplength- tripramp) > fmod(time,period) : leave the variable alone
167
168
169 // Determine the probability of having a beam trip
170 if (fLastTripTime<=-99999.9) {
172 }
173// if ( ((time-fLastTripTime) > (fTripPeriod)) ){ // Make some comparison to a probablilty instead of the time
174// Probability of a trip happening in one event: # of trips per hour/3600 * eventtime_in_seconds (which is 0.001s)
176// std::cout << "random value=="<<tmp << "; fProbabilityOfTrip=="<<fProbabilityOfTrip<<std::endl;
177 if (tmp < fProbabilityOfTrip) {
179 std::cout << "random value=="<<tmp << "; fProbabilityOfTrip=="<<fProbabilityOfTrip<<"; time=="<<time<<std::endl;
180 }
181
184 this->fBeamCurrent.Scale(0.0);
185 //std::cout << "fBeamCurrent.Scale(0.0)" << std::endl;
186 } else if (time_since_trip < (fTripLength + fTripRamp)) {
188 //std::cout << "(fTripPeriod - fmod(time, fTripPeriod))=="<<(fTripPeriod - fmod(time, fTripPeriod))<<"; fTripLength=="<<fTripLength
189 // << "; ((fTripPeriod - fmod(time, fTripPeriod)) / fTripLength)=="<<((fTripPeriod - fmod(time, fTripPeriod)) / fTripLength)
190 // << std::endl;
191 this->fBeamCurrent.Scale(factor);
192 //std::cout << "fBeamCurrent.Scale(factor) = " << factor << std::endl;
193 }
194}
std::function< double()> QwCombinedBCM< T >::fRandomVariable

References QwBCM< T >::fBeamCurrent, fLastTripTime, fProbabilityOfTrip, fTripLength, fTripRamp, and QwCombinedBCM< T >::fRandomVariable.

◆ SetBCMForCombo()

template<typename T>
void QwCombinedBCM< T >::SetBCMForCombo ( VQwBCM * bcm,
Double_t weight,
Double_t sumqw )
overridevirtual

Add a constituent BCM to the combination with specified weight.

Parameters
bcmPointer to the BCM to include.
weightCharge weight for this BCM.
sumqwTotal sum of absolute weights.

Reimplemented from QwBCM< T >.

Definition at line 58 of file QwCombinedBCM.cc.

59{
60 // Convert back to QWBCM<T>* from generic VQwBCM*
61 fElement.push_back(dynamic_cast<QwBCM<T>* >(bcm));
62 fWeights.push_back(weight);
64}

References fElement, fSumQweights, fWeights, QwBCM< T >::QwBCM(), and VQwBCM::VQwBCM().

+ Here is the call graph for this function:

◆ SetCalibrationFactor()

template<typename T>
void QwCombinedBCM< T >::SetCalibrationFactor ( Double_t calibration)
inlineoverridevirtual

Set the calibration factor for the beam current monitor.

Parameters
calibrationMultiplicative calibration factor.

Reimplemented from QwBCM< T >.

Definition at line 102 of file QwCombinedBCM.h.

102 {
104 }
void SetCalibrationFactor(Double_t calib) override
Set the calibration factor for the beam current monitor.
Definition QwBCM.cc:43

References QwBCM< T >::SetCalibrationFactor().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetPedestal()

template<typename T>
void QwCombinedBCM< T >::SetPedestal ( Double_t pedestal)
inlineoverridevirtual

Set the pedestal value for the beam current monitor.

Parameters
pedestalPedestal offset to apply to the raw signal.

Reimplemented from QwBCM< T >.

Definition at line 99 of file QwCombinedBCM.h.

99 {
101 }
void SetPedestal(Double_t ped) override
Set the pedestal value for the beam current monitor.
Definition QwBCM.cc:33

References QwBCM< T >::SetPedestal().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetTripSeed()

template<typename T>
void QwCombinedBCM< T >::SetTripSeed ( uint seedval)
static

Set random number generator seed for beam trip simulation.

Definition at line 40 of file QwCombinedBCM.cc.

41{
43}
static std::mt19937 fRandomnessGenerator
Internal randomness generator.

References fRandomnessGenerator.

Referenced by main().

+ Here is the caller graph for this function:

◆ UpdateErrorFlag()

template<typename T>
UInt_t QwCombinedBCM< T >::UpdateErrorFlag ( )
overridevirtual

Update error flags by propagating error codes from constituent BCMs.

Reimplemented from VQwDataElement.

Definition at line 257 of file QwCombinedBCM.cc.

257 {
258 for (size_t i=0;i<fElement.size();i++){
259 this->fBeamCurrent.UpdateErrorFlag(fElement.at(i)->fBeamCurrent.GetErrorCode());
260 }
261 return this->fBeamCurrent.GetEventcutErrorFlag();
262}

References QwBCM< T >::fBeamCurrent, and fElement.

Field Documentation

◆ fDistribution

template<typename T>
std::uniform_real_distribution<double> QwCombinedBCM< T >::fDistribution
staticprotected

Internal uniform probability distribution.

Definition at line 133 of file QwCombinedBCM.h.

◆ fElement

template<typename T>
std::vector<QwBCM<T>*> QwCombinedBCM< T >::fElement
private

◆ fLastTripTime

template<typename T>
Double_t QwCombinedBCM< T >::fLastTripTime
private

◆ fProbabilityOfTrip

template<typename T>
Double_t QwCombinedBCM< T >::fProbabilityOfTrip
private

Definition at line 125 of file QwCombinedBCM.h.

Referenced by LoadMockDataParameters(), and RandomizeEventData().

◆ fRandomnessGenerator

template<typename T>
std::mt19937 QwCombinedBCM< T >::fRandomnessGenerator
staticprotected

Internal randomness generator.

Definition at line 131 of file QwCombinedBCM.h.

Referenced by SetTripSeed().

◆ fRandomVariable

template<typename T>
std::function<double()> QwCombinedBCM< T >::fRandomVariable
staticprotected

Internal normal random variable.

Definition at line 135 of file QwCombinedBCM.h.

◆ fSumQweights

template<typename T>
Double_t QwCombinedBCM< T >::fSumQweights
private

Definition at line 119 of file QwCombinedBCM.h.

Referenced by ProcessEvent(), and SetBCMForCombo().

◆ fTripLength

template<typename T>
Double_t QwCombinedBCM< T >::fTripLength
private

Definition at line 123 of file QwCombinedBCM.h.

Referenced by LoadMockDataParameters(), and RandomizeEventData().

◆ fTripPeriod

template<typename T>
Double_t QwCombinedBCM< T >::fTripPeriod
private

Definition at line 122 of file QwCombinedBCM.h.

Referenced by LoadMockDataParameters().

◆ fTripRamp

template<typename T>
Double_t QwCombinedBCM< T >::fTripRamp
private

Definition at line 124 of file QwCombinedBCM.h.

Referenced by LoadMockDataParameters(), and RandomizeEventData().

◆ fWeights

template<typename T>
std::vector<Double_t> QwCombinedBCM< T >::fWeights
private

Definition at line 118 of file QwCombinedBCM.h.

Referenced by ProcessEvent(), and SetBCMForCombo().


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