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 <vector>
10
11// Boost math library for random number generation
12#include "boost/random.hpp"
13
14// ROOT headers
15#include <TTree.h>
16
17// Qweak headers
18#include "VQwDataElement.h"
19#include "VQwHardwareChannel.h"
20#include "QwBCM.h"
21
22// Forward declarations
23#ifdef __USE_DATABASE__
24class QwDBInterface;
25#endif // __USE_DATABASE__
26
27/**
28 * \class QwCombinedBCM
29 * \ingroup QwAnalysis_BL
30 * \brief Template for a combined beam current monitor using weighted inputs
31 *
32 * Aggregates multiple BCMs into a single effective current channel by
33 * applying user-provided weights. Provides event processing hooks and
34 * error propagation consistent with VQwBCM.
35 */
36
37template<typename T>
38class QwCombinedBCM : public QwBCM<T> {
39/////
40 public:
42 QwCombinedBCM(TString name){
43 InitializeChannel(name, "derived");
44 };
45 QwCombinedBCM(TString subsystem, TString name){
46 InitializeChannel(subsystem, name, "derived");
47 };
48 QwCombinedBCM(TString subsystemname, TString name, TString type){
49 this->SetSubsystemName(subsystemname);
50 InitializeChannel(subsystemname, name,type,"raw");
51 };
53 : QwBCM<T>(source)
54 { }
55 ~QwCombinedBCM() override { };
56
57 // This is to setup one of the used BCM's in this combo
58 void SetBCMForCombo(VQwBCM* bcm, Double_t weight, Double_t sumqw ) override;
59
60 // No processing of event buffer
61 Int_t ProcessEvBuffer(UInt_t* buffer, UInt_t word_position_in_buffer, UInt_t subelement = 0) override { return 0; };
62
63 void InitializeChannel(TString name, TString datatosave) override;
64 // new routine added to update necessary information for tree trimming
65 void InitializeChannel(TString subsystem, TString name, TString datatosave) override;
66 void InitializeChannel(TString subsystem, TString name, TString type,
67 TString datatosave);
68
69 void ProcessEvent() override;
70
71//---------------------------------------------------------------------------------------------
72 void GetProjectedCharge(VQwBCM *device) override;
73 void RandomizeEventData(int helicity = 0, double time = 0.0) override;
74 size_t GetNumberOfElements() override {return fElement.size();};
75 TString GetSubElementName(Int_t index) override {return fElement.at(index)->GetElementName();};
76 void LoadMockDataParameters(QwParameterFile &paramfile) override;
77//---------------------------------------------------------------------------------------------
78
79 Bool_t ApplyHWChecks(){
80 return kTRUE;
81 };
82
83 Bool_t ApplySingleEventCuts() override;//Check for good events by setting limits on the devices readings
84
85 UInt_t UpdateErrorFlag() override;
86
87
88 // Implementation of Parent class's virtual operators
89 VQwBCM& operator= (const VQwBCM &value) override;
91
92 /*
93 void AccumulateRunningSum(const VQwBCM &value);
94 void DeaccumulateRunningSum(VQwBCM &value);
95 void CalculateRunningAverage();
96 */
97 void SetPedestal(Double_t ped) override {
99 }
100 void SetCalibrationFactor(Double_t calib) override {
102 }
103
105 return &(this->fBeamCurrent);
106 };
107
108 const VQwHardwareChannel* GetCharge() const override {
109 return const_cast<QwCombinedBCM*>(this)->GetCharge();
110 };
111
112/////
113 private:
114
115 std::vector <QwBCM<T>*> fElement;
116 std::vector <Double_t> fWeights;
117 Double_t fSumQweights;
118
120 Double_t fTripPeriod;
121 Double_t fTripLength;
122 Double_t fTripRamp;
124
125 protected:
126 /// \name Parity mock data generation
127 // @{
128 /// Internal randomness generator
129 static boost::mt19937 fRandomnessGenerator;
130 /// Internal normal probability distribution
131 static boost::random::uniform_real_distribution<double> fDistribution;
132 /// Internal normal random variable
133 static boost::variate_generator
134 < boost::mt19937, boost::random::uniform_real_distribution<double> > fRandomVariable;
135public:
136 static void SetTripSeed(uint seedval);
137 // @}
138};
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 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()
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
static boost::random::uniform_real_distribution< double > fDistribution
Internal normal probability distribution.
static boost::variate_generator< boost::mt19937, boost::random::uniform_real_distribution< double > > fRandomVariable
Internal normal random variable.
Double_t fSumQweights
void SetBCMForCombo(VQwBCM *bcm, Double_t weight, Double_t sumqw) override
static boost::mt19937 fRandomnessGenerator
Internal randomness generator.
void RandomizeEventData(int helicity=0, double time=0.0) override
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:187
QwBCM()
Definition QwBCM.h:40
Abstract base for beam current monitors (BCMs)
Definition VQwBCM.h:52