JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
VEventDecoder.h
Go to the documentation of this file.
1/*!
2 * \file VEventDecoder.h
3 * \brief Virtual base class for event decoders to encode and decode CODA data
4 */
5
6#pragma once
7
8#include <vector>
9
10
11#include "Rtypes.h"
12#include "QwTypes.h"
13#include "MQwCodaControlEvent.h"
14#include "QwOptions.h"
15
16
17/**
18 * \class VEventDecoder
19 * \ingroup QwAnalysis
20 * \brief Abstract base for CODA event encoding and decoding
21 *
22 * Provides the interface for encoding mock CODA events and decoding
23 * real CODA event streams. Concrete implementations handle version-specific
24 * differences (CODA 2 vs CODA 3) while exposing a common API for event
25 * type detection, bank decoding, and header processing.
26 */
28public:
30 fWordsSoFar(0),
31 fEvtLength(0),
32 fEvtNumber(0),
33 fFragLength(0),
34 fEvtType(0),
35 fEvtTag(0),
37 fSubbankTag(0),
38 fSubbankType(0),
39 fSubbankNum(0),
40 fROC(0),
41 fPhysicsEventFlag(kFALSE),
42 fControlEventFlag(kFALSE),
43 fAllowLowSubbankIDs(kFALSE) { }
44
45 virtual ~VEventDecoder() { }
46
47public:
48 // Encoding Functions
49 /**
50 * \brief Create a physics-event (PHYS) header bank for the given ROCs.
51 *
52 * Encodes a minimal CODA-compliant PHYS event header for one trigger,
53 * suitable for mock-data generation and unit tests.
54 *
55 * @param ROCList List of ROC IDs to include in the header/banks.
56 * @return A vector of 32-bit words containing the encoded header.
57 */
58 virtual std::vector<UInt_t> EncodePHYSEventHeader(std::vector<ROCID_t> &ROCList) = 0;
59 /**
60 * \brief Encode a PRESTART control-event header.
61 * @param buffer Output buffer (size >= 5 words) to receive the header.
62 * @param runnumber Run number to store in the header.
63 * @param runtype Run type identifier.
64 * @param localtime Wall-clock time (seconds) for the header timestamp.
65 */
66 virtual void EncodePrestartEventHeader(int* buffer, int runnumber, int runtype, int localtime) = 0;
67 /**
68 * \brief Encode a GO control-event header.
69 * @param buffer Output buffer (size >= 5 words) to receive the header.
70 * @param eventcount Current event count.
71 * @param localtime Wall-clock time (seconds) for the header timestamp.
72 */
73 virtual void EncodeGoEventHeader(int* buffer, int eventcount, int localtime) = 0;
74 /**
75 * \brief Encode a PAUSE control-event header.
76 * @param buffer Output buffer (size >= 5 words) to receive the header.
77 * @param eventcount Current event count.
78 * @param localtime Wall-clock time (seconds) for the header timestamp.
79 */
80 virtual void EncodePauseEventHeader(int* buffer, int eventcount, int localtime) = 0;
81 /**
82 * \brief Encode an END control-event header.
83 * @param buffer Output buffer (size >= 5 words) to receive the header.
84 * @param eventcount Final event count.
85 * @param localtime Wall-clock time (seconds) for the header timestamp.
86 */
87 virtual void EncodeEndEventHeader(int* buffer, int eventcount, int localtime) = 0;
88
89public:
90 // Decoding Functions
91 /**
92 * \brief Decode the event ID bank and classify the event type.
93 * @param buffer Pointer to the start of the event buffer.
94 * @return Non-negative on success (implementation-specific), negative on error.
95 */
96 virtual Int_t DecodeEventIDBank(UInt_t *buffer) = 0;
97 /**
98 * \brief Decode the subbank header for the current event/bank context.
99 *
100 * Updates internal fields (subbank tag/type/num, ROC, fragment length)
101 * and advances the internal word counter to the first subbank data word.
102 *
103 * @param buffer Pointer to the current position in the event buffer.
104 * @return kTRUE if a valid header was decoded; kFALSE at end-of-event or on error.
105 */
106 virtual Bool_t DecodeSubbankHeader(UInt_t *buffer);
107 /**
108 * \brief Print internal decoder state for diagnostics.
109 * @param out Logging stream to receive the formatted state (QwMessage/QwWarning/etc.).
110 */
111 virtual void PrintDecoderInfo(QwLog& out);
112
113public:
114 // Boolean Functions
115 virtual Bool_t IsPhysicsEvent(){
116 return fPhysicsEventFlag;
117 }
118
119 virtual Bool_t IsROCConfigurationEvent(){
120 return (fEvtType>=0x90 && fEvtType<=0x18f);
121 }
122
123 virtual Bool_t IsEPICSEvent(){
124 return (fEvtType==EPICS_EVTYPE); // Defined in CodaDecoder.h
125 }
126// Accessor Functions
127 // Generic Information
128 UInt_t GetWordsSoFar()const { return fWordsSoFar; }
129 UInt_t GetEvtNumber()const { return fEvtNumber; }
130 UInt_t GetEvtLength()const { return fEvtLength; }
131 UInt_t GetFragLength()const { return fFragLength; }
132 // Event Information
133 UInt_t GetEvtType()const { return fEvtType; }
134 UInt_t GetBankDataType()const{ return fBankDataType;}
135 UInt_t GetSubbankTag()const { return fSubbankTag; }
136 UInt_t GetSubbankType()const { return fSubbankType; }
137 ROCID_t GetROC()const { return fROC; }
138
139// Mutator Functions
140 void SetWordsSoFar(UInt_t val) { fWordsSoFar = val; }
142 void SetFragLength(UInt_t val) { fFragLength = val; }
143 void SetAllowLowSubbankIDs(Bool_t val = kFALSE) { fAllowLowSubbankIDs = val; }
144
145
146protected:
147 // Generic Information
149 UInt_t fEvtLength;
150 UInt_t fEvtNumber; ///< CODA event number; only defined for physics events
152
153 // Event Information
154 UInt_t fEvtType;
155 UInt_t fEvtTag;
161
162 // Booleans
166
167protected:
168 enum KEYWORDS {
170 };
171
172};
CODA control event data structure and management.
An options class which parses command line, config file and environment.
Basic data types and constants used throughout the Qweak analysis framework.
ULong64_t BankID_t
Definition QwTypes.h:21
UInt_t ROCID_t
Definition QwTypes.h:20
Logging and output management system with configurable verbosity levels.
Definition QwLog.h:73
UInt_t GetFragLength() const
Bool_t fPhysicsEventFlag
virtual void PrintDecoderInfo(QwLog &out)
Print internal decoder state for diagnostics.
BankID_t fSubbankTag
virtual Int_t DecodeEventIDBank(UInt_t *buffer)=0
Decode the event ID bank and classify the event type.
virtual Bool_t DecodeSubbankHeader(UInt_t *buffer)
Decode the subbank header for the current event/bank context.
UInt_t GetSubbankType() const
void SetWordsSoFar(UInt_t val)
virtual void EncodeEndEventHeader(int *buffer, int eventcount, int localtime)=0
Encode an END control-event header.
virtual Bool_t IsROCConfigurationEvent()
virtual ~VEventDecoder()
UInt_t GetWordsSoFar() const
UInt_t fEvtNumber
CODA event number; only defined for physics events.
virtual void EncodePrestartEventHeader(int *buffer, int runnumber, int runtype, int localtime)=0
Encode a PRESTART control-event header.
UInt_t GetSubbankTag() const
UInt_t GetEvtLength() const
void SetAllowLowSubbankIDs(Bool_t val=kFALSE)
UInt_t GetBankDataType() const
virtual void EncodeGoEventHeader(int *buffer, int eventcount, int localtime)=0
Encode a GO control-event header.
UInt_t GetEvtType() const
ROCID_t GetROC() const
Bool_t fControlEventFlag
UInt_t GetEvtNumber() const
virtual Bool_t IsEPICSEvent()
Bool_t fAllowLowSubbankIDs
virtual Bool_t IsPhysicsEvent()
void AddWordsSoFarAndFragLength()
virtual void EncodePauseEventHeader(int *buffer, int eventcount, int localtime)=0
Encode a PAUSE control-event header.
void SetFragLength(UInt_t val)
virtual std::vector< UInt_t > EncodePHYSEventHeader(std::vector< ROCID_t > &ROCList)=0
Create a physics-event (PHYS) header bank for the given ROCs.