JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
QwCombinedBCM.h
Go to the documentation of this file.
1/*!
2 * \file QwCombinedBCM.h
3 * \brief Combined beam current monitor using weighted average of multiple BCMs
4 */
5
6#pragma once
7
8// System headers
9#include <functional>
10#include <random>
11#include <vector>
12
13// ROOT headers
14#include <TTree.h>
15
16// Qweak headers
17#include "VQwDataElement.h"
18#include "VQwHardwareChannel.h"
19#include "QwBCM.h"
20
21// Forward declarations
22#ifdef __USE_DATABASE__
23class QwDBInterface;
24#endif // __USE_DATABASE__
25
26/**
27 * \class QwCombinedBCM
28 * \ingroup QwAnalysis_BL
29 * \brief Template for a combined beam current monitor using weighted inputs
30 *
31 * Aggregates multiple BCMs into a single effective current channel by
32 * applying user-provided weights. Provides event processing hooks and
33 * error propagation consistent with VQwBCM.
34 */
35
36template<typename T>
37class QwCombinedBCM : public QwBCM<T> {
38/////
39 public:
41 QwCombinedBCM(TString name){
42 InitializeChannel(name, "derived");
43 };
44 QwCombinedBCM(TString subsystem, TString name){
45 InitializeChannel(subsystem, name, "derived");
46 };
47 QwCombinedBCM(TString subsystemname, TString name, TString type){
48 this->SetSubsystemName(subsystemname);
49 InitializeChannel(subsystemname, name,type,"raw");
50 };
52 : QwBCM<T>(source)
53 { }
54 ~QwCombinedBCM() override { };
55
56 // This is to setup one of the used BCM's in this combo
57 void SetBCMForCombo(VQwBCM* bcm, Double_t weight, Double_t sumqw ) override;
58
59 // No processing of event buffer
60 Int_t ProcessEvBuffer(UInt_t* buffer, UInt_t word_position_in_buffer, UInt_t subelement = 0) override { return 0; };
61
62 void InitializeChannel(TString name, TString datatosave) override;
63 // new routine added to update necessary information for tree trimming
64 void InitializeChannel(TString subsystem, TString name, TString datatosave) override;
65 void InitializeChannel(TString subsystem, TString name, TString type,
66 TString datatosave);
67
68 void ProcessEvent() override;
69
70//---------------------------------------------------------------------------------------------
71 void GetProjectedCharge(VQwBCM *device) override;
72 void RandomizeEventData(int helicity = 0, double time = 0.0) override;
73 size_t GetNumberOfElements() override {return fElement.size();};
74 TString GetSubElementName(Int_t index) override {return fElement.at(index)->GetElementName();};
75 void LoadMockDataParameters(QwParameterFile &paramfile) override;
76//---------------------------------------------------------------------------------------------
77
78 Bool_t ApplyHWChecks(){
79 return kTRUE;
80 };
81
82 Bool_t ApplySingleEventCuts() override;//Check for good events by setting limits on the devices readings
83
84 using QwBCM<T>::UpdateErrorFlag; // avoid hiding UpdateErrorFlag(const VQwBCM*)
85 //void UpdateErrorFlag(const VQwBCM *ev_error) override;
86
87 UInt_t UpdateErrorFlag() override;
88
89
90 // Implementation of Parent class's virtual operators
91 VQwBCM& operator= (const VQwBCM &value) override;
93
94 /*
95 void AccumulateRunningSum(const VQwBCM &value);
96 void DeaccumulateRunningSum(VQwBCM &value);
97 void CalculateRunningAverage();
98 */
99 void SetPedestal(Double_t ped) override {
101 }
102 void SetCalibrationFactor(Double_t calib) override {
104 }
105
107 return &(this->fBeamCurrent);
108 };
109
110 const VQwHardwareChannel* GetCharge() const override {
111 return const_cast<QwCombinedBCM*>(this)->GetCharge();
112 };
113
114/////
115 private:
116
117 std::vector <QwBCM<T>*> fElement;
118 std::vector <Double_t> fWeights;
119 Double_t fSumQweights;
120
122 Double_t fTripPeriod;
123 Double_t fTripLength;
124 Double_t fTripRamp;
126
127 protected:
128 /// \name Parity mock data generation
129 // @{
130 /// Internal randomness generator
131 static std::mt19937 fRandomnessGenerator;
132 /// Internal uniform probability distribution
133 static std::uniform_real_distribution<double> fDistribution;
134 /// Internal normal random variable
135 static std::function<double()> fRandomVariable;
136public:
137 static void SetTripSeed(uint seedval);
138 // @}
139};
Definition of the pure virtual base class of all data elements.
Beam current monitor template class.
const TString QwBPMStripline< T >::subelement[4]
Configuration file parser with flexible tokenization and search capabilities.
void SetSubsystemName(TString sysname)
Set the name of the inheriting subsystem name.
Abstract base for concrete hardware channels implementing dual-operator pattern.
Template for a combined beam current monitor using weighted inputs.
const VQwHardwareChannel * GetCharge() const override
Double_t fTripLength
void SetPedestal(Double_t ped) override
Set the pedestal value for the beam current monitor.
Double_t fLastTripTime
void InitializeChannel(TString name, TString datatosave) override
QwCombinedBCM(TString subsystem, TString name)
void SetCalibrationFactor(Double_t calib) override
Set the calibration factor for the beam current monitor.
Double_t fTripRamp
QwCombinedBCM(TString subsystemname, TString name, TString type)
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.
static std::uniform_real_distribution< double > fDistribution
Internal uniform probability distribution.
static void SetTripSeed(uint seedval)
QwCombinedBCM(TString name)
TString GetSubElementName(Int_t index) override
Double_t fProbabilityOfTrip
void ProcessEvent() override
Double_t fTripPeriod
VQwHardwareChannel * GetCharge() override
std::vector< Double_t > fWeights
size_t GetNumberOfElements() override
std::vector< QwBCM< T > * > fElement
void GetProjectedCharge(VQwBCM *device) override
Bool_t ApplyHWChecks()
static std::function< double()> fRandomVariable
Internal normal random variable.
void LoadMockDataParameters(QwParameterFile &paramfile) override
UInt_t UpdateErrorFlag() override
Bool_t ApplySingleEventCuts() override
QwCombinedBCM(const QwCombinedBCM &source)
~QwCombinedBCM() override
VQwBCM & operator=(const VQwBCM &value) override
Double_t fSumQweights
void SetBCMForCombo(VQwBCM *bcm, Double_t weight, Double_t sumqw) override
void RandomizeEventData(int helicity=0, double time=0.0) override
static std::mt19937 fRandomnessGenerator
Internal randomness generator.
Templated concrete beam current monitor implementation.
Definition QwBCM.h:36
void SetPedestal(Double_t ped) override
Set the pedestal value for the beam current monitor.
Definition QwBCM.cc:33
void SetCalibrationFactor(Double_t calib) override
Set the calibration factor for the beam current monitor.
Definition QwBCM.cc:43
T fBeamCurrent
Definition QwBCM.h:189
QwBCM()
Definition QwBCM.h:40
Abstract base for beam current monitors (BCMs)
Definition VQwBCM.h:52