JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
VQwBCM.cc
Go to the documentation of this file.
1/*!
2 * \file VQwBCM.cc
3 * \brief Virtual base class implementation for beam current monitors
4 *
5 * Factory helpers to create concrete BCMs and combined BCMs by module type.
6 * Documentation-only edits; runtime behavior unchanged.
7 */
8
9#include "VQwBCM.h"
10
11#include "QwBCM.h"
12#include "QwCombinedBCM.h"
13
14// System headers
15#include <stdexcept>
16
17// Qweak database headers
18#ifdef __USE_DATABASE__
19#include "QwDBInterface.h"
20#endif // __USE_DATABASE__
21
22// Qweak types that we want to use in this template
23#include "QwVQWK_Channel.h"
24#include "QwADC18_Channel.h"
25#include "QwScaler_Channel.h"
26#include "QwMollerADC_Channel.h"
27
28/*!
29 * \brief Factory method to create a concrete BCM instance for the requested module type.
30 * \param subsystemname Name of the parent subsystem.
31 * \param name BCM channel name.
32 * \param type Module type string (VQWK, ADC18, SIS3801, SIS3801D24/SCALER, MOLLERADC).
33 * \param clock Clock reference name for timing-based modules.
34 * \return Pointer to newly created BCM instance.
35 *
36 * Creates appropriate concrete BCM template instantiation based on module type.
37 * Supported types include integrating ADCs (VQWK, ADC18, MOLLERADC) and
38 * scalers (SIS3801, SIS3801D24). Each type uses the corresponding channel class
39 * for data handling and calibration.
40 */
41VQwBCM* VQwBCM::Create(TString subsystemname, TString name, TString type, TString clock)
42{
43 Bool_t localDebug = kFALSE;
44 type.ToUpper();
45 if( localDebug ) QwMessage<<"Creating BCM of type: "<<type<<" with name: "<<
46 name<<". Subsystem Name: " <<subsystemname<<" and clock name="<<clock<<"\n";
47 // (jc2) As a first try, let's do this the ugly way (but rather very
48 // simple), just list out the types of BCM's supported by this code!!!
49 if( type == "VQWK") {
50 return new QwBCM<QwVQWK_Channel>(subsystemname,name,type);
51 } else if ( type == "ADC18" ) {
52 return new QwBCM<QwADC18_Channel>(subsystemname,name,type,clock);
53 } else if ( type == "SIS3801" ) {
54 return new QwBCM<QwSIS3801_Channel>(subsystemname,name,type,clock);
55 } else if ( type == "SCALER" || type == "SIS3801D24" ) {
56 return new QwBCM<QwSIS3801D24_Channel>(subsystemname,name,type,clock);
57 } else if ( type == "MOLLERADC" ) {
58 return new QwBCM<QwMollerADC_Channel>(subsystemname,name,type,clock);
59 } else { // Unsupported one!
60 QwWarning << "BCM of type="<<type<<" is UNSUPPORTED!!\n";
61 exit(-1);
62 }
63}
64
65/*!
66 * \brief Copy constructor factory method to clone a BCM from an existing instance.
67 * \param source Reference BCM to copy from.
68 * \return Pointer to newly created BCM copy.
69 *
70 * Creates a deep copy of the source BCM by determining its concrete type
71 * and calling the appropriate template constructor. Preserves all calibration
72 * parameters and configuration from the source.
73 */
75{
76 Bool_t localDebug = kFALSE;
77 TString type = source.GetModuleType();
78 type.ToUpper();
79 if( localDebug ) QwMessage<<"Creating BCM of type: "<<type<<QwLog::endl;
80 // (jc2) As a first try, let's do this the ugly way (but rather very
81 // simple), just list out the types of BCM's supported by this code!!!
82 if( type == "VQWK") {
83 return new QwBCM<QwVQWK_Channel>(dynamic_cast<const QwBCM<QwVQWK_Channel>&>(source));
84 } else if ( type == "ADC18" ) {
85 return new QwBCM<QwADC18_Channel>(dynamic_cast<const QwBCM<QwADC18_Channel>&>(source));
86 } else if ( type == "SIS3801" ) {
87 return new QwBCM<QwSIS3801_Channel>(dynamic_cast<const QwBCM<QwSIS3801_Channel>&>(source));
88 } else if ( type == "SCALER" || type == "SIS3801D24" ) {
89 return new QwBCM<QwSIS3801D24_Channel>(dynamic_cast<const QwBCM<QwSIS3801D24_Channel>&>(source));
90 } else if ( type == "MOLLERADC" ) {
91 return new QwBCM<QwMollerADC_Channel>(dynamic_cast<const QwBCM<QwMollerADC_Channel>&>(source));
92 } else { // Unsupported one!
93 QwWarning << "BCM of type="<<type<<" is UNSUPPORTED!!\n";
94 exit(-1);
95 }
96}
97
98/*!
99 * \brief Factory method to create a concrete Combined BCM for the requested module type.
100 */
101VQwBCM* VQwBCM::CreateCombo(TString subsystemname, TString name, TString type)
102{
103 Bool_t localDebug = kFALSE;
104 type.ToUpper();
105 if( localDebug ) QwMessage<<"Creating CombinedBCM of type: "<<type<<" with name: "<<
106 name<<". Subsystem Name: " <<subsystemname<<"\n";
107 // (jc2) As a first try, let's do this the ugly way (but rather very
108 // simple), just list out the types of BCM's supported by this code!!!
109 if( type == "VQWK") {
110 return new QwCombinedBCM<QwVQWK_Channel>(subsystemname,name,type);
111 } else if ( type == "ADC18" ) {
112 return new QwCombinedBCM<QwADC18_Channel>(subsystemname,name,type);
113 } else if ( type == "SIS3801" ) {
114 return new QwCombinedBCM<QwSIS3801_Channel>(subsystemname,name,type);
115 } else if ( type == "SCALER" || type == "SIS3801D24" ) {
116 return new QwCombinedBCM<QwSIS3801D24_Channel>(subsystemname,name,type);
117 } else if ( type == "MOLLERADC" ) {
118 return new QwCombinedBCM<QwMollerADC_Channel>(subsystemname,name,type);
119 } else { // Unsupported one!
120 QwWarning << "BCM of type="<<type<<" is UNSUPPORTED!!\n";
121 exit(-1);
122 }
123}
124
126{
127 Bool_t localDebug = kFALSE;
128 TString type = source.GetModuleType();
129 type.ToUpper();
130 if( localDebug ) QwMessage<<"Creating CombinedBCM of type: "<<type<< QwLog::endl;
131 // (jc2) As a first try, let's do this the ugly way (but rather very
132 // simple), just list out the types of BCM's supported by this code!!!
133 if( type == "VQWK") {
134 return new QwCombinedBCM<QwVQWK_Channel>(dynamic_cast<const QwCombinedBCM<QwVQWK_Channel>&>(source));
135 } else if ( type == "ADC18" ) {
136 return new QwCombinedBCM<QwADC18_Channel>(dynamic_cast<const QwCombinedBCM<QwADC18_Channel>&>(source));
137 } else if ( type == "SIS3801" ) {
138 return new QwCombinedBCM<QwSIS3801_Channel>(dynamic_cast<const QwCombinedBCM<QwSIS3801_Channel>&>(source));
139 } else if ( type == "SCALER" || type == "SIS3801D24" ) {
140 return new QwCombinedBCM<QwSIS3801D24_Channel>(dynamic_cast<const QwCombinedBCM<QwSIS3801D24_Channel>&>(source));
141 } else if ( type == "MOLLERADC" ) {
142 return new QwCombinedBCM<QwMollerADC_Channel>(dynamic_cast<const QwCombinedBCM<QwMollerADC_Channel>&>(source));
143 } else { // Unsupported one!
144 QwWarning << "BCM of type="<<type<<" is UNSUPPORTED!!\n";
145 exit(-1);
146 }
147}
Base and derived classes for scaler channel data handling.
#define QwWarning
Predefined log drain for warnings.
Definition QwLog.h:44
#define QwMessage
Predefined log drain for regular messages.
Definition QwLog.h:49
Decoding and management for Moller ADC channels (6x32-bit datawords)
Decoding and management for VQWK ADC channels (6x32-bit datawords)
Database interface for QwIntegrationPMT and subsystems.
Virtual base class for beam current monitors.
Combined beam current monitor using weighted average of multiple BCMs.
Beam current monitor template class.
static std::ostream & endl(std::ostream &)
End of the line.
Definition QwLog.cc:297
TString GetModuleType() const
Return the type of the beam instrument.
friend class QwCombinedBCM
Definition VQwBCM.h:61
friend class QwBCM
Definition VQwBCM.h:60
static VQwBCM * CreateCombo(TString subsystemname, TString type, TString name)
Factory method to create a concrete Combined BCM for the requested module type.
Definition VQwBCM.cc:101
VQwBCM(VQwDataElement &beamcurrent)
Definition VQwBCM.h:64
static VQwBCM * Create(TString subsystemname, TString type, TString name, TString clock="")
Factory method to create a concrete BCM instance for the requested module type.
Definition VQwBCM.cc:41