JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
QwBCM.cc
Go to the documentation of this file.
1/*!
2 * \file QwBCM.cc
3 * \brief Beam current monitor template class implementation
4 */
5
6#include "QwBCM.h"
7
8// System headers
9#include <stdexcept>
10
11// ROOT headers for RNTuple support
12#ifdef HAS_RNTUPLE_SUPPORT
13#include <ROOT/RNTupleModel.hxx>
14#include <ROOT/RNTupleWriter.hxx>
15#endif // HAS_RNTUPLE_SUPPORT
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 Set the pedestal value for the beam current monitor.
30 * \param pedestal Pedestal offset to apply to the raw signal.
31 */
32template<typename T>
33void QwBCM<T>::SetPedestal(Double_t pedestal)
34{
35 fBeamCurrent.SetPedestal(pedestal);
36}
37
38/**
39 * \brief Set the calibration factor for the beam current monitor.
40 * \param calibration Multiplicative calibration factor.
41 */
42template<typename T>
43void QwBCM<T>::SetCalibrationFactor(Double_t calibration)
44{
45 fBeamCurrent.SetCalibrationFactor(calibration);
46}
47/********************************************************/
48/**
49 * \brief Initialize the BCM with a name and data-saving mode.
50 * \param name Detector name used for branches and histograms.
51 * \param datatosave Storage mode (e.g., "raw" or "derived").
52 */
53template<typename T>
54void QwBCM<T>::InitializeChannel(TString name, TString datatosave)
55{
56 SetPedestal(0.);
58 SetResolution(0.0);
59 fBeamCurrent.InitializeChannel(name,datatosave);
60 this->SetElementName(name);
61}
62/********************************************************/
63/**
64 * \brief Initialize the BCM with subsystem and name.
65 * \param subsystem Subsystem identifier.
66 * \param name Detector name used for branches and histograms.
67 * \param datatosave Storage mode (e.g., "raw" or "derived").
68 */
69template<typename T>
70void QwBCM<T>::InitializeChannel(TString subsystem, TString name, TString datatosave){
71 SetPedestal(0.);
73 SetResolution(0.0);
74 fBeamCurrent.InitializeChannel(subsystem, "QwBCM", name, datatosave);
75 SetElementName(name);
76}
77/********************************************************/
78/**
79 * \brief Initialize the BCM with subsystem, module type, and name.
80 * \param subsystem Subsystem identifier.
81 * \param name Detector name used for branches and histograms.
82 * \param type Module type tag used in ROOT foldering.
83 * \param datatosave Storage mode (e.g., "raw" or "derived").
84 */
85template<typename T>
86void QwBCM<T>::InitializeChannel(TString subsystem, TString name, TString type, TString datatosave){
87 SetPedestal(0.);
89 SetResolution(0.0);
90 SetModuleType(type);
91 fBeamCurrent.InitializeChannel(subsystem, "QwBCM", name, datatosave);
92 SetElementName(name);
93}
94/********************************************************/
95/**
96 * \brief Load mock-data configuration for the underlying channel.
97 * \param paramfile Parameter file reader positioned at channel section.
98 */
99template<typename T>
101/*
102 Bool_t ldebug=kFALSE;
103 Double_t asym=0.0, mean=0.0, sigma=0.0;
104*/
105 Double_t res=0.0;
106
107 if (paramfile.GetLine().find("resolution")!=std::string::npos){
108 paramfile.GetNextToken();
109 res = paramfile.GetTypedNextToken<Double_t>();
110 this->SetResolution(res);
111 } else {
112/*
113 asym = paramfile.GetTypedNextToken<Double_t>();
114 mean = paramfile.GetTypedNextToken<Double_t>();
115 sigma = paramfile.GetTypedNextToken<Double_t>();
116
117 if (ldebug==1) {
118 std::cout << "#################### \n";
119 std::cout << "asym, mean, sigma \n" << std::endl;
120 std::cout << asym << " / "
121 << mean << " / "
122 << sigma << " / "
123 << std::endl;
124 }
125 this->SetRandomEventParameters(mean, sigma);
126 this->SetRandomEventAsymmetry(asym);
127*/
128 //std::cout << "In QwBCM: ChannelName = " << GetElementName() << std::endl;
129 fBeamCurrent.SetMockDataAsDiff();
130 fBeamCurrent.LoadMockDataParameters(paramfile);
131 }
132}
133/********************************************************/
134/** \brief Clear event-scoped data in the underlying channel. */
135template<typename T>
137{
138 fBeamCurrent.ClearEventData();
139}
140
141/********************************************************/
142/** \brief Use an external random variable source for mock data. */
143template<typename T>
145{
146 fBeamCurrent.UseExternalRandomVariable();
147}
148/********************************************************/
149/**
150 * \brief Set the external random variable to drive mock data.
151 * \param random_variable External random value.
152 */
153template<typename T>
154void QwBCM<T>::SetExternalRandomVariable(double random_variable)
155{
156 fBeamCurrent.SetExternalRandomVariable(random_variable);
157}
158/********************************************************/
159/**
160 * \brief Configure deterministic drift parameters applied per event.
161 */
162template<typename T>
163void QwBCM<T>::SetRandomEventDriftParameters(Double_t amplitude, Double_t phase, Double_t frequency)
164{
165 fBeamCurrent.SetRandomEventDriftParameters(amplitude, phase, frequency);
166}
167/********************************************************/
168/** \brief Add additional drift parameters to the drift model. */
169template<typename T>
170void QwBCM<T>::AddRandomEventDriftParameters(Double_t amplitude, Double_t phase, Double_t frequency)
171{
172 fBeamCurrent.AddRandomEventDriftParameters(amplitude, phase, frequency);
173}
174/********************************************************/
175/** \brief Configure Gaussian mock data parameters. */
176template<typename T>
177void QwBCM<T>::SetRandomEventParameters(Double_t mean, Double_t sigma)
178{
179 fBeamCurrent.SetRandomEventParameters(mean, sigma);
180}
181/********************************************************/
182/** \brief Set an asymmetry parameter applied to helicity states. */
183template<typename T>
184void QwBCM<T>::SetRandomEventAsymmetry(Double_t asymmetry)
185{
186 fBeamCurrent.SetRandomEventAsymmetry(asymmetry);
187}
188/********************************************************/
189/** \brief Smear the channel by the configured resolution. */
190template<typename T>
192 fBeamCurrent.SmearByResolution(fResolution);
193}
194/** \brief Materialize the current event state as raw event data. */
195template<typename T>
197{
198 fBeamCurrent.SetRawEventData();
199}
200
201/**
202 * \brief Generate mock event data for this BCM.
203 * \param helicity Helicity state indicator.
204 * \param time Event time or timestamp proxy.
205 */
206template<typename T>
207void QwBCM<T>::RandomizeEventData(int helicity, double time)
208{
209 fBeamCurrent.RandomizeEventData(helicity, time);
210 fBeamCurrent.SetRawEventData();
211
212}
213/********************************************************/
214/** \brief Encode current event data into an output buffer. */
215template<typename T>
216void QwBCM<T>::EncodeEventData(std::vector<UInt_t> &buffer)
217{
218 fBeamCurrent.EncodeEventData(buffer);
219}
220
221/********************************************************/
222/** \brief Apply hardware checks and process the event for this BCM. */
223template<typename T>
225{
226 this->ApplyHWChecks();//first apply HW checks and update HW error flags. Calling this routine either in ApplySingleEventCuts or here do not make any difference for a BCM but do for a BPMs because they have derived devices.
227 fBeamCurrent.ProcessEvent();
228}
229/********************************************************/
230/**
231 * \brief Apply hardware checks and return whether the event is valid.
232 * \return kTRUE if no hardware error was detected; otherwise kFALSE.
233 */
234template<typename T>
236{
237 Bool_t eventokay=kTRUE;
238
239 UInt_t deviceerror=fBeamCurrent.ApplyHWChecks();//will check for HW consistency and return the error code (=0 is HW good)
240 eventokay=(deviceerror & 0x0);//if no HW error return true
241
242 return eventokay;
243}
244/********************************************************/
245
246/** \brief Set basic single-event cut limits. */
247template<typename T>
248Int_t QwBCM<T>::SetSingleEventCuts(Double_t LL, Double_t UL){//std::vector<Double_t> & dEventCuts){//two limits and sample size
249 fBeamCurrent.SetSingleEventCuts(LL,UL);
250 return 1;
251}
252
253/**
254 * \brief Configure detailed single-event cuts for this BCM.
255 */
256template<typename T>
257void QwBCM<T>::SetSingleEventCuts(UInt_t errorflag, Double_t LL, Double_t UL, Double_t stability, Double_t burplevel){
258 //set the unique tag to identify device type (bcm,bpm & etc)
259 errorflag|=kBCMErrorFlag;
260 QwMessage<<"QwBCM Error Code passing to QwVQWK_Ch "<<errorflag<<" "<<stability<<QwLog::endl;
261 //QwError<<"***************************"<<typeid(fBeamCurrent).name()<<QwLog::endl;
262 fBeamCurrent.SetSingleEventCuts(errorflag,LL,UL,stability,burplevel);
263
264}
265
266/** \brief Set the default sample size used by the channel. */
267template<typename T>
268void QwBCM<T>::SetDefaultSampleSize(Int_t sample_size){
269 fBeamCurrent.SetDefaultSampleSize((size_t)sample_size);
270}
271
272
273/********************************************************/
274/**
275 * \brief Apply single-event cuts for this BCM and return pass/fail.
276 * \return kTRUE if event passes, otherwise kFALSE.
277 */
278template<typename T>
280{
281 //std::cout<<" QwBCM::SingleEventCuts() "<<std::endl;
282 Bool_t status = kTRUE;
283
284 if (fBeamCurrent.ApplySingleEventCuts()) {
285 status = kTRUE;
286 } else {
287 status &= kFALSE;
288 }
289 return status;
290}
291
292/********************************************************/
293
294/** \brief Increment error counters (number of failed events). */
295template<typename T>
297{// report number of events failed due to HW and event cut failure
298 fBeamCurrent.IncrementErrorCounters();
299}
300
301/** \brief Print error counters (const overload). */
302template<typename T>
304{// report number of events failed due to HW and event cut failure
305 fBeamCurrent.PrintErrorCounters();
306}
307
308/********************************************************/
309/** \brief Merge error flags from a reference BCM into this instance. */
310template<typename T>
311void QwBCM<T>::UpdateErrorFlag(const VQwBCM *ev_error){
312 try {
313 if(typeid(*ev_error)==typeid(*this)) {
314 // std::cout<<" Here in QwBCM::UpdateErrorFlag \n";
315 if (this->GetElementName()!="") {
316 const QwBCM<T>* value_bcm = dynamic_cast<const QwBCM<T>* >(ev_error);
317 fBeamCurrent.UpdateErrorFlag(value_bcm->fBeamCurrent);
318 }
319 } else {
320 TString loc="Standard exception from QwBCM::UpdateErrorFlag :"+
321 ev_error->GetElementName()+" "+this->GetElementName()+" are not of the "
322 +"same type";
323 throw std::invalid_argument(loc.Data());
324 }
325 } catch (std::exception& e) {
326 std::cerr<< e.what()<<std::endl;
327 }
328};
329
330
331/********************************************************/
332/**
333 * \brief Process the raw event buffer and decode into the channel.
334 * \return The updated buffer word position.
335 */
336template<typename T>
337Int_t QwBCM<T>::ProcessEvBuffer(UInt_t* buffer, UInt_t word_position_in_buffer, UInt_t subelement)
338{
339 fBeamCurrent.ProcessEvBuffer(buffer,word_position_in_buffer);
340
341 return word_position_in_buffer;
342}
343/********************************************************/
344/** \brief Copy-assign from another BCM (event-scoped data). */
345template<typename T>
347{
348// std::cout<<" Here in QwBCM::operator= \n";
349 if (this->GetElementName()!="")
350 {
351 this->fBeamCurrent=value.fBeamCurrent;
352 }
353// std::cout<<" to be copied \n";
354// value.Print();
355// std::cout<<" copied \n";
356// this->Print();
357
358 return *this;
359}
360
361/** \brief Polymorphic copy-assign from VQwBCM if types match. */
362template<typename T>
364{
365 try {
366 if(typeid(value)==typeid(*this)) {
367 // std::cout<<" Here in QwBCM::operator= \n";
368 if (this->GetElementName()!="") {
369 const QwBCM<T>* value_bcm = dynamic_cast<const QwBCM<T>* >(&value);
370 QwBCM<T>* this_cast = dynamic_cast<QwBCM<T>* >(this);
371 this_cast->fBeamCurrent= value_bcm->fBeamCurrent;
372 }
373 } else {
374 TString loc="Standard exception from QwBCM::operator= :"+
375 value.GetElementName()+" "+this->GetElementName()+" are not of the "
376 +"same type";
377 throw std::invalid_argument(loc.Data());
378 }
379 } catch (std::exception& e) {
380 std::cerr<< e.what()<<std::endl;
381 }
382// std::cout<<" to be copied \n";
383// value.Print();
384// std::cout<<" copied \n";
385// this->Print();
386
387 return *this;
388}
389
390/** \brief Add-assign from another BCM (sum raw channels). */
391template<typename T>
393{
394 if (this->GetElementName()!="")
395 {
396 this->fBeamCurrent+=value.fBeamCurrent;
397 }
398 return *this;
399}
400
401/** \brief Polymorphic add-assign from VQwBCM if types match. */
402template<typename T>
404{
405 try {
406 if(typeid(value)==typeid(*this)) {
407 // std::cout<<" Here in QwBCM::operator+= \n";
408 if (this->GetElementName()!="") {
409 const QwBCM<T>* value_bcm = dynamic_cast<const QwBCM<T>* >(&value);
410 QwBCM<T>* this_cast = dynamic_cast<QwBCM<T>* >(this);
411 this_cast->fBeamCurrent+=value_bcm->fBeamCurrent;
412 }
413 } else {
414 TString loc="Standard exception from QwBCM::operator+= :"+
415 value.GetElementName()+" "+this->GetElementName()+" are not of the "
416 +"same type";
417 throw std::invalid_argument(loc.Data());
418 }
419 } catch (std::exception& e) {
420 std::cerr<< e.what()<<std::endl;
421 }
422
423 return *this;
424}
425
426/** \brief Polymorphic subtract-assign from VQwBCM. */
427template<typename T>
429{
430 if (this->GetElementName()!="")
431 {
432 const QwBCM<T>* value_bcm = dynamic_cast<const QwBCM<T>* >(&value);
433 QwBCM<T>* this_cast = dynamic_cast<QwBCM<T>* >(this);
434 this_cast->fBeamCurrent-=value_bcm->fBeamCurrent;
435 }
436 return *this;
437}
438
439/** \brief Subtract-assign from another BCM (difference raw channels). */
440template<typename T>
442{
443 try {
444 if(typeid(value)==typeid(*this)) {
445 // std::cout<<" Here in QwBCM::operator-= \n";
446 if (this->GetElementName()!="") {
447 const QwBCM<T>* value_bcm = dynamic_cast<const QwBCM<T>* >(&value);
448 QwBCM<T>* this_cast = dynamic_cast<QwBCM<T>* >(this);
449 this_cast->fBeamCurrent-=value_bcm->fBeamCurrent;
450 }
451 } else {
452 TString loc="Standard exception from QwBCM::operator-= :"+
453 value.GetElementName()+" "+this->GetElementName()+" are not of the "
454 +"same type";
455 throw std::invalid_argument(loc.Data());
456 }
457 } catch (std::exception& e) {
458 std::cerr<< e.what()<<std::endl;
459 }
460 return *this;
461}
462
463/** \brief Polymorphic ratio formation for BCM. */
464template<typename T>
465void QwBCM<T>::Ratio(const VQwBCM &numer, const VQwBCM &denom)
466{
467 Ratio(*dynamic_cast<const QwBCM<T>* >(&numer),
468 *dynamic_cast<const QwBCM<T>* >(&denom));
469}
470
471/** \brief Type-specific ratio formation for BCM. */
472template<typename T>
473void QwBCM<T>::Ratio(const QwBCM<T> &numer, const QwBCM<T> &denom)
474{
475 // std::cout<<"QwBCM::Ratio element name ="<<GetElementName()<<" \n";
476 if (this->GetElementName()!="")
477 {
478 // std::cout<<"here in \n";
479 this->fBeamCurrent.Ratio(numer.fBeamCurrent,denom.fBeamCurrent);
480 }
481}
482
483/** \brief Scale the underlying channel by a constant factor. */
484template<typename T>
485void QwBCM<T>::Scale(Double_t factor)
486{
487 fBeamCurrent.Scale(factor);
488}
489
490/** \brief Update running averages for the underlying channel. */
491template<typename T>
493{
494 fBeamCurrent.CalculateRunningAverage();
495}
496
497/**
498 * \brief Check for burp failures by delegating to the underlying channel.
499 * \param ev_error Reference BCM to compare against.
500 * \return kTRUE if a burp failure was detected; otherwise kFALSE.
501 */
502template<typename T>
504 Bool_t burpstatus = kFALSE;
505 //QwError << "************* " << this->GetElementName() << " <<<this, event>>> " << ev_error->GetElementName() << " *****************" << QwLog::endl;
506 try {
507 if(typeid(*ev_error)==typeid(*this)) {
508 //std::cout<<" Here in VQwBCM::CheckForBurpFail \n";
509 if (this->GetElementName()!="") {
510 const QwBCM<T>* value_bcm = dynamic_cast<const QwBCM<T>* >(ev_error);
511 burpstatus |= fBeamCurrent.CheckForBurpFail(&(value_bcm->fBeamCurrent));
512 }
513 } else {
514 TString loc="Standard exception from QwBCM::CheckForBurpFail :"+
515 ev_error->GetElementName()+" "+this->GetElementName()+" are not of the "
516 +"same type";
517 throw std::invalid_argument(loc.Data());
518 }
519 } catch (std::exception& e) {
520 std::cerr<< e.what()<<std::endl;
521 }
522 return burpstatus;
523}
524
525/** \brief Accumulate running sums from another BCM into this one. */
526template<typename T>
527void QwBCM<T>::AccumulateRunningSum(const VQwBCM& value, Int_t count, Int_t ErrorMask) {
528 fBeamCurrent.AccumulateRunningSum(
529 dynamic_cast<const QwBCM<T>* >(&value)->fBeamCurrent, count, ErrorMask);
530}
531
532/** \brief Remove a single entry from the running sums using a source value. */
533template<typename T>
534void QwBCM<T>::DeaccumulateRunningSum(VQwBCM& value, Int_t ErrorMask) {
535 fBeamCurrent.DeaccumulateRunningSum(dynamic_cast<QwBCM<T>* >(&value)->fBeamCurrent, ErrorMask);
536}
537/** \brief Print a compact value summary for this BCM. */
538template<typename T>
540{
541 fBeamCurrent.PrintValue();
542}
543
544/** \brief Print detailed information for this BCM. */
545template<typename T>
547{
548 std::cout << "QwVQWK_Channel Info " << std::endl;
549 fBeamCurrent.PrintInfo();
550}
551
552/********************************************************/
553/**
554 * \brief Define histograms for this BCM (delegated to underlying channel).
555 * \param folder ROOT folder to contain histograms.
556 * \param prefix Histogram name prefix.
557 */
558template<typename T>
559void QwBCM<T>::ConstructHistograms(TDirectory *folder, TString &prefix)
560{
561 if (this->GetElementName()=="")
562 {
563 // This channel is not used, so skip filling the histograms.
564 }
565 else
566 {
567 fBeamCurrent.ConstructHistograms(folder, prefix);
568 }
569}
570
571/** \brief Fill histograms for this BCM if enabled. */
572template<typename T>
574{
575 if (this->GetElementName()=="")
576 {
577 // This channel is not used, so skip filling the histograms.
578 }
579 else
580 {
581 fBeamCurrent.FillHistograms();
582 }
583}
584
585/**
586 * \brief Construct ROOT branches and value vector entries.
587 * \param tree Output tree.
588 * \param prefix Branch name prefix.
589 * \param values Output value vector to be appended.
590 */
591template<typename T>
592void QwBCM<T>::ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values)
593{
594 if (this->GetElementName()==""){
595 // This channel is not used, so skip
596 } else
597 {
598 fBeamCurrent.ConstructBranchAndVector(tree, prefix,values);
599 }
600}
601
602/** \brief Construct ROOT branches for this BCM (if enabled). */
603template<typename T>
604void QwBCM<T>::ConstructBranch(TTree *tree, TString &prefix)
605{
606 if (GetElementName()==""){
607 // This channel is not used, so skip filling the histograms.
608 } else
609 {
610 fBeamCurrent.ConstructBranch(tree, prefix);
611 // this functions doesn't do anything yet
612 }
613}
614
615/** \brief Construct ROOT branches for this BCM using a trim file filter. */
616template<typename T>
617void QwBCM<T>::ConstructBranch(TTree *tree, TString &prefix, QwParameterFile& modulelist)
618{
619 TString devicename;
620
621 devicename=GetElementName();
622 devicename.ToLower();
623 if (GetElementName()==""){
624 // This channel is not used, so skip filling the histograms.
625 } else
626 {
627
628 //QwMessage <<" QwBCM "<<devicename<<QwLog::endl;
629 if (modulelist.HasValue(devicename)){
630 fBeamCurrent.ConstructBranch(tree, prefix);
631 QwMessage <<" Tree leave added to "<<devicename<<QwLog::endl;
632 }
633 // this functions doesn't do anything yet
634 }
635}
636
637/** \brief Fill tree vector entries for this BCM. */
638template<typename T>
640{
641 if (this->GetElementName()==""){
642 // This channel is not used, so skip filling the histograms.
643 } else
644 {
645 fBeamCurrent.FillTreeVector(values);
646 // this functions doesn't do anything yet
647 }
648}
649
650#ifdef HAS_RNTUPLE_SUPPORT
651/** \brief Construct RNTuple fields and append values vector entries. */
652template<typename T>
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)
654{
655 if (this->GetElementName()==""){
656 // This channel is not used, so skip
657 } else
658 {
659 fBeamCurrent.ConstructNTupleAndVector(model, prefix, values, fieldPtrs);
660 }
661}
662
663/** \brief Fill RNTuple values for this BCM. */
664template<typename T>
665void QwBCM<T>::FillNTupleVector(std::vector<Double_t>& values) const
666{
667 if (this->GetElementName()==""){
668 // This channel is not used, so skip filling.
669 } else
670 {
671 fBeamCurrent.FillNTupleVector(values);
672 }
673}
674#endif
675
676#ifdef __USE_DATABASE__
677/** \brief Collect database entries for this BCM. */
678template<typename T>
679std::vector<QwDBInterface> QwBCM<T>::GetDBEntry()
680{
681 std::vector <QwDBInterface> row_list;
682 fBeamCurrent.AddEntriesToList(row_list);
683 return row_list;
684}
685
686/** \brief Collect error database entries for this BCM. */
687template<typename T>
688std::vector<QwErrDBInterface> QwBCM<T>::GetErrDBEntry()
689{
690 std::vector <QwErrDBInterface> row_list;
691 fBeamCurrent.AddErrEntriesToList(row_list);
692 return row_list;
693}
694#endif // __USE_DATABASE__
695
696/** \brief Get the current value of the beam current. */
697template<typename T>
699{
700 return fBeamCurrent.GetValue();
701}
702
703
704/** \brief Get the statistical error on the beam current. */
705template<typename T>
707{
708 return fBeamCurrent.GetValueError();
709}
710
711/** \brief Get the width of the beam current distribution. */
712template<typename T>
714{
715 return fBeamCurrent.GetValueWidth();
716}
717
718template class QwBCM<QwVQWK_Channel>;
719template class QwBCM<QwADC18_Channel>;
720template class QwBCM<QwSIS3801_Channel>;
721template class QwBCM<QwSIS3801D24_Channel>;
722template class QwBCM<QwMollerADC_Channel>;
Base and derived classes for scaler channel data handling.
#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)
static const UInt_t kBCMErrorFlag
Definition QwTypes.h:168
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.
Definition QwLog.cc:297
Configuration file parser with flexible tokenization and search capabilities.
T GetTypedNextToken()
Get next token into specific type.
Bool_t HasValue(TString &vname)
std::string GetLine()
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.
Definition QwRootFile.h:53
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.
Definition QwBCM.h:36
void SetExternalRandomVariable(Double_t random_variable)
Set the external random variable to drive mock data.
Definition QwBCM.cc:154
void ConstructBranch(TTree *tree, TString &prefix) override
Construct ROOT branches for this BCM (if enabled).
Definition QwBCM.cc:604
void IncrementErrorCounters() override
Increment error counters (number of failed events).
Definition QwBCM.cc:296
void ConstructHistograms(TDirectory *folder, TString &prefix) override
Define histograms for this BCM (delegated to underlying channel).
Definition QwBCM.cc:559
void SetPedestal(Double_t ped) override
Set the pedestal value for the beam current monitor.
Definition QwBCM.cc:33
void DeaccumulateRunningSum(VQwBCM &value, Int_t ErrorMask=0xFFFFFFF) override
Remove a single entry from the running sums using a source value.
Definition QwBCM.cc:534
void SetRandomEventDriftParameters(Double_t amplitude, Double_t phase, Double_t frequency)
Configure deterministic drift parameters applied per event.
Definition QwBCM.cc:163
void Scale(Double_t factor) override
Scale the underlying channel by a constant factor.
Definition QwBCM.cc:485
void Ratio(const VQwBCM &numer, const VQwBCM &denom) override
Polymorphic ratio formation for BCM.
Definition QwBCM.cc:465
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
void SetCalibrationFactor(Double_t calib) override
Set the calibration factor for the beam current monitor.
Definition QwBCM.cc:43
void RandomizeEventData(int helicity=0, double time=0) override
Generate mock event data for this BCM.
Definition QwBCM.cc:207
Double_t GetValue() override
Get the current value of the beam current.
Definition QwBCM.cc:698
VQwBCM & operator=(const VQwBCM &value) override
Polymorphic copy-assign from VQwBCM if types match.
Definition QwBCM.cc:363
void AddRandomEventDriftParameters(Double_t amplitude, Double_t phase, Double_t frequency) override
Add additional drift parameters to the drift model.
Definition QwBCM.cc:170
void PrintValue() const override
Print a compact value summary for this BCM.
Definition QwBCM.cc:539
Bool_t CheckForBurpFail(const VQwDataElement *ev_error) override
Check for burp failures by delegating to the underlying channel.
Definition QwBCM.cc:503
void SetRandomEventAsymmetry(Double_t asymmetry) override
Set an asymmetry parameter applied to helicity states.
Definition QwBCM.cc:184
void CalculateRunningAverage() override
Update running averages for the underlying channel.
Definition QwBCM.cc:492
Double_t fResolution
Definition QwBCM.h:191
void AccumulateRunningSum(const VQwBCM &, Int_t count=0, Int_t ErrorMask=0xFFFFFFF) override
Accumulate running sums from another BCM into this one.
Definition QwBCM.cc:527
void EncodeEventData(std::vector< UInt_t > &buffer) override
Encode current event data into an output buffer.
Definition QwBCM.cc:216
Double_t GetValueWidth() override
Get the width of the beam current distribution.
Definition QwBCM.cc:713
VQwBCM & operator+=(const VQwBCM &value) override
Polymorphic add-assign from VQwBCM if types match.
Definition QwBCM.cc:403
std::vector< QwErrDBInterface > GetErrDBEntry()
void SetDefaultSampleSize(Int_t sample_size) override
Set the default sample size used by the channel.
Definition QwBCM.cc:268
void SetResolution(Double_t resolution)
Definition QwBCM.h:79
Bool_t ApplyHWChecks()
Apply hardware checks and return whether the event is valid.
Definition QwBCM.cc:235
T fBeamCurrent
Definition QwBCM.h:187
Double_t GetValueError() override
Get the statistical error on the beam current.
Definition QwBCM.cc:706
void ProcessEvent() override
Apply hardware checks and process the event for this BCM.
Definition QwBCM.cc:224
void FillHistograms() override
Fill histograms for this BCM if enabled.
Definition QwBCM.cc:573
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.
Definition QwBCM.cc:337
void UseExternalRandomVariable()
Use an external random variable source for mock data.
Definition QwBCM.cc:144
std::vector< QwDBInterface > GetDBEntry()
Bool_t ApplySingleEventCuts() override
Apply single-event cuts for this BCM and return pass/fail.
Definition QwBCM.cc:279
void SetRandomEventParameters(Double_t mean, Double_t sigma) override
Configure Gaussian mock data parameters.
Definition QwBCM.cc:177
void ClearEventData() override
Clear event-scoped data in the underlying channel.
Definition QwBCM.cc:136
QwBCM()
Definition QwBCM.h:40
void PrintErrorCounters() const override
Print error counters (const overload).
Definition QwBCM.cc:303
void InitializeChannel(TString name, TString datatosave) override
Initialize the BCM with a name and data-saving mode.
Definition QwBCM.cc:54
void PrintInfo() const override
Print detailed information for this BCM.
Definition QwBCM.cc:546
Int_t SetSingleEventCuts(Double_t mean=0, Double_t sigma=0)
Set basic single-event cut limits.
Definition QwBCM.cc:248
void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values) override
Construct ROOT branches and value vector entries.
Definition QwBCM.cc:592
VQwBCM & operator-=(const VQwBCM &value) override
Polymorphic subtract-assign from VQwBCM.
Definition QwBCM.cc:428
void FillTreeVector(QwRootTreeBranchVector &values) const override
Fill tree vector entries for this BCM.
Definition QwBCM.cc:639
void LoadMockDataParameters(QwParameterFile &paramfile) override
Load mock-data configuration for the underlying channel.
Definition QwBCM.cc:100
VQwBCM(VQwDataElement &beamcurrent)
Definition VQwBCM.h:64