Belle II Software prerelease-10-00-00a
SVDPackerModule.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#ifndef SVDPackerModule_H
10#define SVDPackerModule_H
11
12#include <framework/core/Module.h>
13#include <framework/datastore/StoreArray.h>
14#include <framework/datastore/StoreObjPtr.h>
15#include <framework/dataobjects/EventMetaData.h>
16#include <svd/dataobjects/SVDEventInfo.h>
17
18#include <rawdata/dataobjects/RawSVD.h>
19#include <svd/dataobjects/SVDShaperDigit.h>
20
21#include <svd/online/SVDOnlineToOfflineMap.h>
22
23#include <framework/database/PayloadFile.h>
24
25
26namespace Belle2 {
31 namespace SVD {
32
40 class SVDPackerModule : public Module {
41
42 public:
43
44 //Constructor
45
48
50 virtual ~SVDPackerModule();
51
52 virtual void initialize() override;
53 virtual void beginRun() override;
54 virtual void event() override;
55 virtual void endRun() override;
56 virtual void terminate() override;
57
58
59 std::string m_rawSVDListName;
61 std::string m_svdEventInfoName;
64
65 private:
66
68 typedef std::unordered_map<unsigned short, unsigned short> FADCmap;
69
71 unsigned short nFADCboards;
72
74 std::unordered_multimap<unsigned char, unsigned char>* APVmap;
75
78
79 static std::string m_xmlFileName ;
81
82 std::unique_ptr<SVDOnlineToOfflineMap> m_map;
83
88
89 std::vector<uint32_t> data_words;
90
92 void inline addData32(uint32_t adata32)
93 {
94 data_words.push_back(adata32);
95 }
96
97 void binPrintout(unsigned int nwords);
98
100 struct DataInfo {
101 short data[6];
102 unsigned short channel;
104
105 // The following assumes i386 byte order: MSB comes last!
106
108 struct FTBHeader {
109 unsigned int errorsField : 8;
110 unsigned int eventNumber : 24;
111 };
112
114 struct MainHeader {
115 unsigned int trgNumber : 8;
116 unsigned int trgType : 4;
117 unsigned int trgTiming : 2;
118 unsigned int xTalk : 2;
119 unsigned int FADCnum : 8;
120 unsigned int DAQType : 1;
121 unsigned int DAQMode : 2;
122 unsigned int runType : 2;
123 unsigned int check : 3;
124 };
125
127 struct APVHeader {
128 unsigned int CMC1 : 8;
129 unsigned int CMC2 : 4;
130 unsigned int fifoErr: 1;
131 unsigned int frameErr: 1;
132 unsigned int detectErr: 1;
133 unsigned int apvErr : 1;
134 unsigned int pipelineAddr : 8;
135 unsigned int APVnum : 6;
136 unsigned int check : 2;
137 };
138
140 struct data_A {
141 unsigned int sample1 : 8;
142 unsigned int sample2 : 8;
143 unsigned int sample3 : 8;
144 unsigned int stripNum : 7;
145 unsigned int check : 1;
146 };
147
149 struct data_B {
150 unsigned int sample4 : 8;
151 unsigned int sample5 : 8;
152 unsigned int sample6 : 8;
153 unsigned int stripNum : 7;
154 unsigned int check : 1;
155 };
156
158 struct FADCTrailer {
159 unsigned int FTBFlags: 16;
160 unsigned int APVdataSizeCut: 1;
161 unsigned int FADCdataSizeCut: 1;
162 unsigned int DummyAPVHeader: 1;
163 unsigned int PiplAddrMismatch: 1;
164 unsigned int nullDigits: 4;
165 unsigned int fifoErrOR: 1;
166 unsigned int frameErrOR: 1;
167 unsigned int detectErrOR: 1;
168 unsigned int apvErrOR: 1;
169 unsigned int check : 4;
170 };
171
173 struct FTBTrailer {
174 unsigned int crc16 : 16;
175 unsigned int controlWord : 16;
176 };
177
178
179 union {
180 uint32_t data32;
188 };
189
195
196 };
197 } //SVD
199} // Belle2
200
201#endif /* SVDPackerModule_H */
Class for accessing objects in the database.
Definition DBObjPtr.h:21
Module()
Constructor.
Definition Module.cc:30
MainHeader m_MainHeader
Implementation of FADC Header.
bool m_simulate3sampleData
if true, simulate 3-sample data taking
StoreArray< RawSVD > m_rawSVD
output for RawSVD
FADCTrailer m_FADCTrailer
Implementation of FADC Trailer.
StoreObjPtr< SVDEventInfo > m_svdEventInfoPtr
SVDEventInfo from simulation.
virtual void initialize() override
initialize
std::unordered_map< unsigned short, unsigned short > FADCmap
type def for the FADC map
virtual void event() override
event
struct Belle2::SVD::SVDPackerModule::DataInfo dataInfo
data info
FTBHeader m_FTBHeader
Implementation of FTB Header.
virtual void endRun() override
end run
std::string m_rawSVDListName
RawSVD StoreArray name.
StoreArray< SVDShaperDigit > m_svdShaperDigit
Required input for SVDShaperDigit.
DBObjPtr< PayloadFile > m_mapping
channel map payload
virtual void terminate() override
terminate
data_B m_data_B
Implementation of 2nd data word.
int m_FADCTriggerNumberOffset
FADC trigger number offset.
static std::string m_xmlFileName
< xml filename
SVDPackerModule()
default constructor
void addData32(uint32_t adata32)
adds packed 32-bit data word to the raw data vector
FTBTrailer m_FTBTrailer
Implementation of FTB Trailer.
APVHeader m_APVHeader
Implementation of APV Header.
virtual void beginRun() override
begin run
std::string m_svdShaperDigitListName
SVDShaperDigit StoreArray name.
std::string m_svdEventInfoName
SVDEventInfo name.
virtual ~SVDPackerModule()
default destructor
data_A m_data_A
Implementation of 1st data word.
StoreObjPtr< EventMetaData > m_eventMetaDataPtr
Required input for EventMetaData.
std::unordered_multimap< unsigned char, unsigned char > * APVmap
pointer to APVforFADCmap filled by mapping procedure
std::unique_ptr< SVDOnlineToOfflineMap > m_map
Pointer to online-to-offline map.
uint32_t data32
Output 32-bit data word.
std::vector< uint32_t > data_words
vector of raw data words
void binPrintout(unsigned int nwords)
tool: print out N words
bool m_binPrintout
if true, print data created by the Packer
FADCmap FADCnumberMapRev
maps containing assignment (0,1,2,3,4,..,nFADCboards-1) <-> FADC numbers
FADCmap FADCnumberMap
maps containing assignment (0,1,2,3,4,..,nFADCboards-1) <-> FADC numbers
unsigned short nFADCboards
how many FADCs we have
Accessor to arrays stored in the data store.
Definition StoreArray.h:113
Type-safe access to single objects in the data store.
Definition StoreObjPtr.h:96
Namespace to encapsulate code needed for simulation and reconstrucion of the SVD.
Abstract base class for different kinds of events.
unsigned int detectErr
Detection Error.
unsigned int pipelineAddr
Pipeline Address.
unsigned int APVnum
APV chip number.
unsigned int CMC1
Common Mode Noise w/o masking out particle signals.
unsigned int check
MSB "10" - for APV Header identification.
unsigned int fifoErr
FIFO full Error.
unsigned int CMC2
Common Mode Noise after masking out particle signals.
6 samples and APV channel struct
unsigned short channel
APV channel number.
unsigned int PiplAddrMismatch
Pipeline address mismatch detection flag.
unsigned int apvErrOR
APV chip number OR.
unsigned int fifoErrOR
FIFO full Error OR.
unsigned int DummyAPVHeader
Dummy APV Header included flag.
unsigned int check
MSB "1110" - for FADC Trailer identification.
unsigned int FTBFlags
FTB Flags Field.
unsigned int APVdataSizeCut
APV data-size cut flag.
unsigned int FADCdataSizeCut
FADC data-size cut flag.
unsigned int detectErrOR
Detection Error OR.
unsigned int errorsField
FTB error fields.
unsigned int eventNumber
FTB event number.
unsigned int controlWord
MSB "ff55" - FADC Trailer ID.
unsigned int crc16
FTB CRC16 Checksum.
unsigned int DAQType
(from 2020c) Event type(0): "0"…3 or …6 acquisition mode, "1"…3-mixed-6 acquisition mode
unsigned int check
MSB "110" - for FADC Header identification.
unsigned int trgNumber
Trigger Number.
unsigned int trgTiming
Trigger Timing.
unsigned int DAQMode
Event type(2:1): "00"…1-sample, "01"…3-sample, "10"…6-sample.
implementation of the first data word
unsigned int sample3
3rd data sample
unsigned int stripNum
Strip number.
unsigned int sample2
2nd data sample
unsigned int check
MSB "1" - for Data word identification.
unsigned int sample1
1st data sample
implementation of the second data word
unsigned int sample6
6th data sample
unsigned int stripNum
Strip number.
unsigned int check
MSB "1" - for Data word identification.
unsigned int sample4
4th data sample
unsigned int sample5
5th data sample