JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
QwHelicityDecoder.h
Go to the documentation of this file.
1/**********************************************************\
2* File: QwHelicityDecoder.h *
3* *
4* Contributor: Arindam Sen (asen@jlab.org) *
5* Time-stamp: November, 2025 *
6\**********************************************************/
7
8/*!
9 * \file QwHelicityDecoder.h
10 * \brief Helicity data decoder from the data file
11 */
12
13#pragma once
14
15// System headers
16#include <vector>
17
18// ROOT headers
19#include "TTree.h"
20
21// Qweak headers
22#include "QwWord.h"
23#include "QwHelicityBase.h"
24
25/**
26 * \class QwHelicityDecoder
27 * \ingroup QwAnalysis_BeamLine
28 * \brief Subsystem for helicity data decoding
29 *
30 * Manages helicity information from the polarized electron beam, including
31 * helicity state determination, pattern recognition, delayed helicity decoding,
32 * and helicity-correlated systematic checks. Supports multiple helicity
33 * encoding modes and provides helicity information to other subsystems.
34 */
35class QwHelicityDecoder: public QwHelicityBase, public MQwSubsystemCloneable<QwHelicityDecoder> {
36
37 private:
38 /// Private default constructor (not implemented, will throw linker error on use)
40
41 public:
42 /// Constructor with name
43 QwHelicityDecoder(const TString& name);
44 /// Copy constructor
46 /// Virtual destructor
47 virtual ~QwHelicityDecoder() override { }
48
49
50 /* derived from VQwSubsystem */
51 /// \brief Define options function
52
53 static void DefineOptions(QwOptions &options);
54 void ProcessOptions(QwOptions &options) override;
55 Int_t LoadChannelMap(TString mapfile) override;
56 Int_t LoadInputParameters(TString pedestalfile) override;
57 Int_t LoadEventCuts(TString filename) override;//Loads event cuts applicable to QwHelicityDecoder class, derived from VQwSubsystemParity
58 Bool_t ApplySingleEventCuts() override;//Apply event cuts in the QwHelicityDecoder class, derived from VQwSubsystemParity
59
60 Bool_t CheckForBurpFail(const VQwSubsystem *ev_error) override{
61 return kFALSE;
62 };
63
64 void UpdateErrorFlag(const VQwSubsystem *ev_error) override{
65 };
66
67 Int_t ProcessConfigurationBuffer(const ROCID_t roc_id, const BankID_t bank_id,
68 UInt_t* buffer, UInt_t num_words) override;
69 Int_t ProcessEvBuffer(const ROCID_t roc_id, const BankID_t bank_id, UInt_t* buffer, UInt_t num_words) {
70 return ProcessEvBuffer(0x1,roc_id,bank_id,buffer,num_words);
71 };
72 Int_t ProcessEvBuffer(UInt_t ev_type, const ROCID_t roc_id, const BankID_t bank_id, UInt_t* buffer, UInt_t num_words) override;
73
74 void EncodeEventData(std::vector<UInt_t> &buffer) override;
75
76
77 virtual void ClearEventData() override;
78 virtual void ProcessEvent() override;
79
80 UInt_t GetRandomSeedActual() { return iseed_Actual; };
81 UInt_t GetRandomSeedDelayed() { return iseed_Delayed; };
82
83 void PredictHelicity();
84 void RunPredictor();
85 void SetHelicityDelay(Int_t delay);
86 void SetHelicityBitPattern(TString hex);
87
88 void SetFirstBits(UInt_t nbits, UInt_t firstbits);
89
90 VQwSubsystem& operator= (VQwSubsystem *value) override;
91 VQwSubsystem& operator+= (VQwSubsystem *value) override;
92
93 VQwSubsystem& operator-= (VQwSubsystem *value) override {return *this;};
94 void Ratio(VQwSubsystem *numer, VQwSubsystem *denom) override;
95
96 void AccumulateRunningSum(VQwSubsystem* value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF) override;
97 //remove one entry from the running sums for devices
98 void DeaccumulateRunningSum(VQwSubsystem* value, Int_t ErrorMask=0xFFFFFFF) override{ };
99
101 void ConstructHistograms(TDirectory *folder, TString &prefix) override;
102 void FillHistograms() override;
103
105 void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values) override;
106 void ConstructBranch(TTree *tree, TString &prefix) override;
107 void ConstructBranch(TTree *tree, TString &prefix, QwParameterFile& trim_file) override;
108 void FillTreeVector(QwRootTreeBranchVector &values) const override;
109
110 void Print() const;
111
112// protected:
113 void CheckPatternNum(VQwSubsystem *value);
114 void MergeCounters(VQwSubsystem *value);
115
116 Bool_t CheckIORegisterMask(const UInt_t& ioregister, const UInt_t& mask) const {
117 return ((mask != 0)&&((ioregister & mask) == mask));
118 };
119
120 static const std::vector<UInt_t> kDefaultHelicityBitPattern;
121
122// std::vector<UInt_t> fHelicityBitPattern;
123
124// std::vector <QwWord> fWord;
125// std::vector < std::pair<Int_t, Int_t> > fWordsPerSubbank; // The indices of the first & last word in each subbank
126
127 void SetHistoTreeSave(const TString &prefix);
128
129
130
131 static const Bool_t kDEBUG=kFALSE;
132 // local helicity is a special mode for encoding helicity info
133 // it is not the fullblown helicity encoding we want to use for the main
134 // data taking. For example this was used during the injector data taking
135 // in winter 2008-09 injector tests
136 static const Int_t kUndefinedHelicity= -9999;
137
138
139 Bool_t Compare(VQwSubsystem *source);
140
141
142//----------------------------------
143
161
162//----------------------------------
163
164static const Int_t fNumDecoderWords;
165void FillHDVariables(uint32_t data, uint32_t index);
166
167};
168//
169// Register this subsystem with the factory
Word-level data manipulation and bit operations.
#define REGISTER_SUBSYSTEM_FACTORY(A)
Definition QwFactory.h:270
ULong64_t BankID_t
Definition QwTypes.h:21
UInt_t ROCID_t
Definition QwTypes.h:20
Helicity state management and pattern recognition.
Command-line and configuration file options processor.
Definition QwOptions.h:141
Configuration file parser with flexible tokenization and search capabilities.
A helper class to manage a vector of branch entries for ROOT trees.
Definition QwRootFile.h:55
Base class for subsystems implementing container-delegation pattern.
virtual void ConstructHistograms()
Construct the histograms for this subsystem.
static void DefineOptions()
Define options function (note: no virtual static functions in C++)
VQwSubsystem(const TString &name)
Constructor with name.
virtual void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values)=0
Construct the branch and tree vector.
QwHelicityBase()
Private default constructor (not implemented, will throw linker error on use)
Subsystem for helicity data decoding.
static const Int_t kUndefinedHelicity
virtual void ProcessEvent() override
void MergeCounters(VQwSubsystem *value)
VQwSubsystem & operator=(VQwSubsystem *value) override
Assignment Note: Must be called at the beginning of all subsystems routine call to operator=(VQwSubsy...
Int_t LoadChannelMap(TString mapfile) override
Mandatory map file definition.
void FillTreeVector(QwRootTreeBranchVector &values) const override
Fill the tree vector.
Int_t ProcessEvBuffer(const ROCID_t roc_id, const BankID_t bank_id, UInt_t *buffer, UInt_t num_words)
TODO: The non-event-type-aware ProcessEvBuffer routine should be replaced with the event-type-aware v...
virtual void ClearEventData() override
static const Bool_t kDEBUG
void AccumulateRunningSum(VQwSubsystem *value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF) override
Update the running sums for devices.
Bool_t Compare(VQwSubsystem *source)
virtual ~QwHelicityDecoder() override
Virtual destructor.
void SetFirstBits(UInt_t nbits, UInt_t firstbits)
QwHelicityDecoder()
Private default constructor (not implemented, will throw linker error on use)
virtual void ConstructHistograms()
Construct the histograms for this subsystem.
void Ratio(VQwSubsystem *numer, VQwSubsystem *denom) override
Bool_t ApplySingleEventCuts() override
Apply the single event cuts.
void ConstructBranch(TTree *tree, TString &prefix) override
Construct the branch and tree vector.
VQwSubsystem & operator+=(VQwSubsystem *value) override
void ProcessOptions(QwOptions &options) override
Process the command line options.
void EncodeEventData(std::vector< UInt_t > &buffer) override
static const Int_t fNumDecoderWords
Bool_t CheckForBurpFail(const VQwSubsystem *ev_error) override
Report the number of events failed due to HW and event cut failures.
static const std::vector< UInt_t > kDefaultHelicityBitPattern
void SetHelicityBitPattern(TString hex)
Int_t LoadInputParameters(TString pedestalfile) override
Mandatory parameter file definition.
Int_t LoadEventCuts(TString filename) override
Optional event cut file.
void CheckPatternNum(VQwSubsystem *value)
void DeaccumulateRunningSum(VQwSubsystem *value, Int_t ErrorMask=0xFFFFFFF) override
remove one entry from the running sums for devices
Int_t ProcessConfigurationBuffer(const ROCID_t roc_id, const BankID_t bank_id, UInt_t *buffer, UInt_t num_words) override
Bool_t CheckIORegisterMask(const UInt_t &ioregister, const UInt_t &mask) const
void SetHelicityDelay(Int_t delay)
void UpdateErrorFlag(const VQwSubsystem *ev_error) override
update the error flag in the subsystem level from the top level routines related to stability checks....
VQwSubsystem & operator-=(VQwSubsystem *value) override
void FillHDVariables(uint32_t data, uint32_t index)
void FillHistograms() override
Fill the histograms for this subsystem.
void SetHistoTreeSave(const TString &prefix)
void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values) override
Construct the branch and tree vector.