12#ifdef HAS_RNTUPLE_SUPPORT
13#include <ROOT/RNTupleModel.hxx>
14#include <ROOT/RNTupleWriter.hxx>
18#ifdef __USE_DATABASE__
74 fBeamCurrent.InitializeChannel(subsystem,
"QwBCM", name, datatosave);
91 fBeamCurrent.InitializeChannel(subsystem,
"QwBCM", name, datatosave);
107 if (paramfile.
GetLine().find(
"resolution")!=std::string::npos){
156 fBeamCurrent.SetExternalRandomVariable(random_variable);
165 fBeamCurrent.SetRandomEventDriftParameters(amplitude, phase, frequency);
172 fBeamCurrent.AddRandomEventDriftParameters(amplitude, phase, frequency);
237 Bool_t eventokay=kTRUE;
240 eventokay=(deviceerror & 0x0);
262 fBeamCurrent.SetSingleEventCuts(errorflag,LL,UL,stability,burplevel);
282 Bool_t status = kTRUE;
313 if(
typeid(*ev_error)==
typeid(*
this)) {
320 TString loc=
"Standard exception from QwBCM::UpdateErrorFlag :"+
323 throw std::invalid_argument(loc.Data());
325 }
catch (std::exception& e) {
326 std::cerr<< e.what()<<std::endl;
339 fBeamCurrent.ProcessEvBuffer(buffer,word_position_in_buffer);
341 return word_position_in_buffer;
366 if(
typeid(value)==
typeid(*
this)) {
374 TString loc=
"Standard exception from QwBCM::operator= :"+
377 throw std::invalid_argument(loc.Data());
379 }
catch (std::exception& e) {
380 std::cerr<< e.what()<<std::endl;
406 if(
typeid(value)==
typeid(*
this)) {
414 TString loc=
"Standard exception from QwBCM::operator+= :"+
417 throw std::invalid_argument(loc.Data());
419 }
catch (std::exception& e) {
420 std::cerr<< e.what()<<std::endl;
444 if(
typeid(value)==
typeid(*
this)) {
452 TString loc=
"Standard exception from QwBCM::operator-= :"+
455 throw std::invalid_argument(loc.Data());
457 }
catch (std::exception& e) {
458 std::cerr<< e.what()<<std::endl;
468 *
dynamic_cast<const QwBCM<T>*
>(&denom));
504 Bool_t burpstatus = kFALSE;
507 if(
typeid(*ev_error)==
typeid(*
this)) {
514 TString loc=
"Standard exception from QwBCM::CheckForBurpFail :"+
517 throw std::invalid_argument(loc.Data());
519 }
catch (std::exception& e) {
520 std::cerr<< e.what()<<std::endl;
548 std::cout <<
"QwVQWK_Channel Info " << std::endl;
598 fBeamCurrent.ConstructBranchAndVector(tree, prefix,values);
622 devicename.ToLower();
629 if (modulelist.
HasValue(devicename)){
650#ifdef HAS_RNTUPLE_SUPPORT
653void QwBCM<T>::ConstructNTupleAndVector(std::unique_ptr<ROOT::RNTupleModel>& model, TString& prefix, std::vector<Double_t>& values, std::vector<std::shared_ptr<Double_t>>& fieldPtrs)
655 if (this->GetElementName()==
""){
659 fBeamCurrent.ConstructNTupleAndVector(model, prefix, values, fieldPtrs);
667 if (this->GetElementName()==
""){
671 fBeamCurrent.FillNTupleVector(values);
676#ifdef __USE_DATABASE__
681 std::vector <QwDBInterface> row_list;
682 fBeamCurrent.AddEntriesToList(row_list);
690 std::vector <QwErrDBInterface> row_list;
691 fBeamCurrent.AddErrEntriesToList(row_list);
Base and derived classes for scaler channel data handling.
#define QwMessage
Predefined log drain for regular messages.
Decoding and management for Moller ADC channels (6x32-bit datawords)
Decoding and management for VQWK ADC channels (6x32-bit datawords)
static const UInt_t kBCMErrorFlag
Database interface for QwIntegrationPMT and subsystems.
Beam current monitor template class.
const TString QwBPMStripline< T >::subelement[4]
static std::ostream & endl(std::ostream &)
End of the line.
Configuration file parser with flexible tokenization and search capabilities.
T GetTypedNextToken()
Get next token into specific type.
Bool_t HasValue(TString &vname)
std::string GetNextToken(const std::string &separatorchars)
Get next token as a string.
A helper class to manage a vector of branch entries for ROOT trees.
VQwDataElement()
Default constructor.
virtual UInt_t UpdateErrorFlag()
Update the error flag based on the error flags of internally contained objects Return parameter is th...
virtual const TString & GetElementName() const
Get the name of this element.
void SetElementName(const TString &name)
Set the name of this element.
void SetModuleType(TString ModuleType)
set the type of the beam instrument
Templated concrete beam current monitor implementation.
void SetExternalRandomVariable(Double_t random_variable)
Set the external random variable to drive mock data.
void ConstructBranch(TTree *tree, TString &prefix) override
Construct ROOT branches for this BCM (if enabled).
void IncrementErrorCounters() override
Increment error counters (number of failed events).
void ConstructHistograms(TDirectory *folder, TString &prefix) override
Define histograms for this BCM (delegated to underlying channel).
void SetPedestal(Double_t ped) override
Set the pedestal value for the beam current monitor.
void DeaccumulateRunningSum(VQwBCM &value, Int_t ErrorMask=0xFFFFFFF) override
Remove a single entry from the running sums using a source value.
void SetRandomEventDriftParameters(Double_t amplitude, Double_t phase, Double_t frequency)
Configure deterministic drift parameters applied per event.
void Scale(Double_t factor) override
Scale the underlying channel by a constant factor.
void Ratio(const VQwBCM &numer, const VQwBCM &denom) override
Polymorphic ratio formation for BCM.
void ApplyResolutionSmearing() override
Smear the channel by the configured resolution.
void FillRawEventData() override
Materialize the current event state as raw event data.
void SetCalibrationFactor(Double_t calib) override
Set the calibration factor for the beam current monitor.
void RandomizeEventData(int helicity=0, double time=0) override
Generate mock event data for this BCM.
Double_t GetValue() override
Get the current value of the beam current.
VQwBCM & operator=(const VQwBCM &value) override
Polymorphic copy-assign from VQwBCM if types match.
void AddRandomEventDriftParameters(Double_t amplitude, Double_t phase, Double_t frequency) override
Add additional drift parameters to the drift model.
void PrintValue() const override
Print a compact value summary for this BCM.
Bool_t CheckForBurpFail(const VQwDataElement *ev_error) override
Check for burp failures by delegating to the underlying channel.
void SetRandomEventAsymmetry(Double_t asymmetry) override
Set an asymmetry parameter applied to helicity states.
void CalculateRunningAverage() override
Update running averages for the underlying channel.
void AccumulateRunningSum(const VQwBCM &, Int_t count=0, Int_t ErrorMask=0xFFFFFFF) override
Accumulate running sums from another BCM into this one.
void EncodeEventData(std::vector< UInt_t > &buffer) override
Encode current event data into an output buffer.
Double_t GetValueWidth() override
Get the width of the beam current distribution.
VQwBCM & operator+=(const VQwBCM &value) override
Polymorphic add-assign from VQwBCM if types match.
std::vector< QwErrDBInterface > GetErrDBEntry()
void SetDefaultSampleSize(Int_t sample_size) override
Set the default sample size used by the channel.
void SetResolution(Double_t resolution)
Bool_t ApplyHWChecks()
Apply hardware checks and return whether the event is valid.
Double_t GetValueError() override
Get the statistical error on the beam current.
void ProcessEvent() override
Apply hardware checks and process the event for this BCM.
void FillHistograms() override
Fill histograms for this BCM if enabled.
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 UseExternalRandomVariable()
Use an external random variable source for mock data.
std::vector< QwDBInterface > GetDBEntry()
Bool_t ApplySingleEventCuts() override
Apply single-event cuts for this BCM and return pass/fail.
void SetRandomEventParameters(Double_t mean, Double_t sigma) override
Configure Gaussian mock data parameters.
void ClearEventData() override
Clear event-scoped data in the underlying channel.
void PrintErrorCounters() const override
Print error counters (const overload).
void InitializeChannel(TString name, TString datatosave) override
Initialize the BCM with a name and data-saving mode.
void PrintInfo() const override
Print detailed information for this BCM.
Int_t SetSingleEventCuts(Double_t mean=0, Double_t sigma=0)
Set basic single-event cut limits.
void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values) override
Construct ROOT branches and value vector entries.
VQwBCM & operator-=(const VQwBCM &value) override
Polymorphic subtract-assign from VQwBCM.
void FillTreeVector(QwRootTreeBranchVector &values) const override
Fill tree vector entries for this BCM.
void LoadMockDataParameters(QwParameterFile ¶mfile) override
Load mock-data configuration for the underlying channel.
VQwBCM(VQwDataElement &beamcurrent)