Belle II Software  release-05-02-19
SVDPackerModule.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2014 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Jarek Wiechczynski *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #ifndef SVDPackerModule_H
12 #define SVDPackerModule_H
13 
14 #include <framework/core/Module.h>
15 #include <framework/datastore/StoreArray.h>
16 #include <framework/datastore/StoreObjPtr.h>
17 #include <framework/dataobjects/EventMetaData.h>
18 #include <svd/dataobjects/SVDEventInfo.h>
19 
20 #include <rawdata/dataobjects/RawSVD.h>
21 #include <svd/dataobjects/SVDShaperDigit.h>
22 
23 #include <svd/online/SVDOnlineToOfflineMap.h>
24 
25 #include <framework/database/PayloadFile.h>
26 
27 
28 namespace Belle2 {
33  namespace SVD {
34 
42  class SVDPackerModule : public Module {
43 
44  public:
45 
46  //Constructor
47 
50 
52  virtual ~SVDPackerModule();
53 
54  virtual void initialize() override;
55  virtual void beginRun() override;
56  virtual void event() override;
57  virtual void endRun() override;
58  virtual void terminate() override;
61  std::string m_rawSVDListName;
62  std::string m_svdShaperDigitListName;
63  std::string m_svdEventInfoName;
65  bool m_binPrintout;
67  private:
68 
70  typedef std::unordered_map<unsigned short, unsigned short> FADCmap;
71 
73  unsigned short nFADCboards;
74 
76  std::unordered_multimap<unsigned char, unsigned char>* APVmap;
77 
78  int n_basf2evt;
79  int m_nodeid;
81  static std::string m_xmlFileName ;
84  std::unique_ptr<SVDOnlineToOfflineMap> m_map;
90 
91  std::vector<uint32_t> data_words;
94  void inline addData32(uint32_t adata32)
95  {
96  data_words.push_back(adata32);
97  }
99  void binPrintout(unsigned int nwords);
100 
102  struct DataInfo {
103  short data[6];
104  unsigned short channel;
105  } dataInfo;
106 
107  // The following assumes i386 byte order: MSB comes last!
108 
110  struct FTBHeader {
111  unsigned int errorsField : 8;
112  unsigned int eventNumber : 24;
113  };
114 
116  struct MainHeader {
117  unsigned int trgNumber : 8;
118  unsigned int trgType : 4;
119  unsigned int trgTiming : 2;
120  unsigned int xTalk : 2;
121  unsigned int FADCnum : 8;
122  unsigned int DAQType : 1;
123  unsigned int DAQMode : 2;
124  unsigned int runType : 2;
125  unsigned int check : 3;
126  };
127 
129  struct APVHeader {
130  unsigned int CMC1 : 8;
131  unsigned int CMC2 : 4;
132  unsigned int fifoErr: 1;
133  unsigned int frameErr: 1;
134  unsigned int detectErr: 1;
135  unsigned int apvErr : 1;
136  unsigned int pipelineAddr : 8;
137  unsigned int APVnum : 6;
138  unsigned int check : 2;
139  };
140 
142  struct data_A {
143  unsigned int sample1 : 8;
144  unsigned int sample2 : 8;
145  unsigned int sample3 : 8;
146  unsigned int stripNum : 7;
147  unsigned int check : 1;
148  };
149 
151  struct data_B {
152  unsigned int sample4 : 8;
153  unsigned int sample5 : 8;
154  unsigned int sample6 : 8;
155  unsigned int stripNum : 7;
156  unsigned int check : 1;
157  };
158 
160  struct FADCTrailer {
161  unsigned int FTBFlags: 16;
162  unsigned int dataSizeCut: 1;
163  unsigned int nullDigits: 7;
164  unsigned int fifoErrOR: 1;
165  unsigned int frameErrOR: 1;
166  unsigned int detectErrOR: 1;
167  unsigned int apvErrOR: 1;
168  unsigned int check : 4;
169  };
170 
172  struct FTBTrailer {
173  unsigned int crc16 : 16;
174  unsigned int controlWord : 16;
175  };
176 
177 
178  union {
179  uint32_t data32;
183  data_A m_data_A;
184  data_B m_data_B;
187  };
188 
195  };
196  } //SVD
198 } // Belle2
199 
200 #endif /* SVDPackerModule_H */
Belle2::SVD::SVDPackerModule::APVHeader::fifoErr
unsigned int fifoErr
FIFO full Error.
Definition: SVDPackerModule.h:140
Belle2::SVD::SVDPackerModule::m_map
std::unique_ptr< SVDOnlineToOfflineMap > m_map
Pointer to online-to-offline map.
Definition: SVDPackerModule.h:92
Belle2::SVD::SVDPackerModule::m_binPrintout
bool m_binPrintout
if true, print data created by the Packer
Definition: SVDPackerModule.h:73
Belle2::SVD::SVDPackerModule::APVHeader
implementation of APV Header
Definition: SVDPackerModule.h:137
Belle2::DBObjPtr< PayloadFile >
Specialization of DBObjPtr in case of PayloadFiles.
Definition: PayloadFile.h:64
Belle2::SVD::SVDPackerModule::APVHeader::CMC2
unsigned int CMC2
Common Mode Noise after masking out particle signals.
Definition: SVDPackerModule.h:139
Belle2::SVD::SVDPackerModule::FADCTrailer::frameErrOR
unsigned int frameErrOR
Frame Error OR.
Definition: SVDPackerModule.h:173
Belle2::SVD::SVDPackerModule::data_B::sample4
unsigned int sample4
4th data sample
Definition: SVDPackerModule.h:160
Belle2::SVD::SVDPackerModule::APVHeader::check
unsigned int check
MSB "10" - for APV Header identification.
Definition: SVDPackerModule.h:146
Belle2::SVD::SVDPackerModule::MainHeader::DAQType
unsigned int DAQType
(from 2020c) Event type(0): "0"…3 or …6 acquisition mode, "1"…3-mixed-6 acquisition mode
Definition: SVDPackerModule.h:130
Belle2::SVD::SVDPackerModule::APVHeader::apvErr
unsigned int apvErr
APV Error.
Definition: SVDPackerModule.h:143
Belle2::SVD::SVDPackerModule::m_nodeid
int m_nodeid
Node ID.
Definition: SVDPackerModule.h:87
Belle2::SVD::SVDPackerModule::m_svdEventInfoName
std::string m_svdEventInfoName
SVDEventInfo name.
Definition: SVDPackerModule.h:71
Belle2::SVD::SVDPackerModule::data_A::sample2
unsigned int sample2
2nd data sample
Definition: SVDPackerModule.h:152
Belle2::SVD::SVDPackerModule::m_FADCTrailer
FADCTrailer m_FADCTrailer
Implementation of FADC Trailer.
Definition: SVDPackerModule.h:193
Belle2::SVD::SVDPackerModule::event
virtual void event() override
event
Definition: SVDPackerModule.cc:103
Belle2::SVD::SVDPackerModule::FADCTrailer
implementation of FADC Trailer
Definition: SVDPackerModule.h:168
Belle2::SVD::SVDPackerModule::data_B
implementation of the second data word
Definition: SVDPackerModule.h:159
Belle2::SVD::SVDPackerModule::beginRun
virtual void beginRun() override
begin run
Definition: SVDPackerModule.cc:83
Belle2::SVD::SVDPackerModule::APVmap
std::unordered_multimap< unsigned char, unsigned char > * APVmap
pointer to APVforFADCmap filled by mapping procedure
Definition: SVDPackerModule.h:84
Belle2::SVD::SVDPackerModule::FTBHeader
implementation of FTB Header
Definition: SVDPackerModule.h:118
Belle2::SVD::SVDPackerModule::m_FADCTriggerNumberOffset
int m_FADCTriggerNumberOffset
FADC trigger numnber offset.
Definition: SVDPackerModule.h:201
Belle2::SVD::SVDPackerModule::m_svdShaperDigitListName
std::string m_svdShaperDigitListName
SVDShaperDigit StoreArray name.
Definition: SVDPackerModule.h:70
Belle2::SVD::SVDPackerModule::MainHeader::runType
unsigned int runType
Run Type.
Definition: SVDPackerModule.h:132
Belle2::SVD::SVDPackerModule::APVHeader::APVnum
unsigned int APVnum
APV chip number.
Definition: SVDPackerModule.h:145
Belle2::SVD::SVDPackerModule::FADCnumberMap
FADCmap FADCnumberMap
maps containing assignment (0,1,2,3,4,..,nFADCboards-1) <-> FADC numbers
Definition: SVDPackerModule.h:95
Belle2::SVD::SVDPackerModule::m_APVHeader
APVHeader m_APVHeader
Implementation of APV Header.
Definition: SVDPackerModule.h:190
Belle2::SVD::SVDPackerModule::addData32
void addData32(uint32_t adata32)
adds packed 32-bit data word to the raw data vector
Definition: SVDPackerModule.h:102
Belle2::SVD::SVDPackerModule::m_FTBTrailer
FTBTrailer m_FTBTrailer
Implementation of FTB Trailer.
Definition: SVDPackerModule.h:194
Belle2::SVD::SVDPackerModule::APVHeader::CMC1
unsigned int CMC1
Common Mode Noise w/o masking out particle signals.
Definition: SVDPackerModule.h:138
Belle2::SVD::SVDPackerModule::FTBHeader::eventNumber
unsigned int eventNumber
FTB event number.
Definition: SVDPackerModule.h:120
Belle2::SVD::SVDPackerModule::m_eventMetaDataPtr
StoreObjPtr< EventMetaData > m_eventMetaDataPtr
Required input for EventMetaData.
Definition: SVDPackerModule.h:197
Belle2::SVD::SVDPackerModule::data_B::sample6
unsigned int sample6
6th data sample
Definition: SVDPackerModule.h:162
Belle2::SVD::SVDPackerModule::m_data_A
data_A m_data_A
Implementation of 1st data word.
Definition: SVDPackerModule.h:191
Belle2::SVD::SVDPackerModule::data_A::sample3
unsigned int sample3
3rd data sample
Definition: SVDPackerModule.h:153
Belle2::SVD::SVDPackerModule::FADCTrailer::apvErrOR
unsigned int apvErrOR
APV chip number OR.
Definition: SVDPackerModule.h:175
Belle2::SVD::SVDPackerModule::~SVDPackerModule
virtual ~SVDPackerModule()
default destructor
Definition: SVDPackerModule.cc:67
Belle2::SVD::SVDPackerModule::data_A::check
unsigned int check
MSB "1" - for Data word identification.
Definition: SVDPackerModule.h:155
Belle2::SVD::SVDPackerModule::MainHeader::DAQMode
unsigned int DAQMode
Event type(2:1): "00"…1-sample, "01"…3-sample, "10"…6-sample.
Definition: SVDPackerModule.h:131
Belle2::SVD::SVDPackerModule::data_A
implementation of the first data word
Definition: SVDPackerModule.h:150
Belle2::SVD::SVDPackerModule::MainHeader
implementation of FADC Header
Definition: SVDPackerModule.h:124
Belle2::SVD::SVDPackerModule::m_simulate3sampleData
bool m_simulate3sampleData
if true, simulate 3-sample data taking
Definition: SVDPackerModule.h:72
Belle2::SVD::SVDPackerModule::data_A::stripNum
unsigned int stripNum
Strip number.
Definition: SVDPackerModule.h:154
Belle2::SVD::SVDPackerModule::data_B::check
unsigned int check
MSB "1" - for Data word identification.
Definition: SVDPackerModule.h:164
Belle2::SVD::SVDPackerModule::n_basf2evt
int n_basf2evt
event number
Definition: SVDPackerModule.h:86
Belle2::SVD::SVDPackerModule::FADCTrailer::nullDigits
unsigned int nullDigits
"0000000"
Definition: SVDPackerModule.h:171
Belle2::SVD::SVDPackerModule::MainHeader::trgType
unsigned int trgType
Trigger Type.
Definition: SVDPackerModule.h:126
Belle2::SVD::SVDPackerModule::FADCTrailer::check
unsigned int check
MSB "1110" - for FADC Trailer identification.
Definition: SVDPackerModule.h:176
Belle2::SVD::SVDPackerModule::MainHeader::trgNumber
unsigned int trgNumber
Trigger Number.
Definition: SVDPackerModule.h:125
Belle2::SVD::SVDPackerModule::initialize
virtual void initialize() override
initialize
Definition: SVDPackerModule.cc:73
Belle2::SVD::SVDPackerModule::data_words
std::vector< uint32_t > data_words
vector of raw data words
Definition: SVDPackerModule.h:99
Belle2::SVD::SVDPackerModule::FADCTrailer::dataSizeCut
unsigned int dataSizeCut
APV data-size cut flag
Definition: SVDPackerModule.h:170
Belle2::SVD::SVDPackerModule::FTBTrailer::crc16
unsigned int crc16
FTB CRC16 Checksum
Definition: SVDPackerModule.h:181
Belle2::SVD::SVDPackerModule::APVHeader::detectErr
unsigned int detectErr
Detection Error.
Definition: SVDPackerModule.h:142
Belle2::SVD::SVDPackerModule::DataInfo::channel
unsigned short channel
APV channel number.
Definition: SVDPackerModule.h:112
Belle2::SVD::SVDPackerModule::APVHeader::frameErr
unsigned int frameErr
Frame Error.
Definition: SVDPackerModule.h:141
Belle2::SVD::SVDPackerModule::FADCTrailer::fifoErrOR
unsigned int fifoErrOR
FIFO full Error OR.
Definition: SVDPackerModule.h:172
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::StoreObjPtr
Type-safe access to single objects in the data store.
Definition: ParticleList.h:33
Belle2::SVD::SVDPackerModule::binPrintout
void binPrintout(unsigned int nwords)
tool: print out N words
Definition: SVDPackerModule.cc:370
Belle2::SVD::SVDPackerModule::MainHeader::trgTiming
unsigned int trgTiming
Trigger Timing.
Definition: SVDPackerModule.h:127
Belle2::SVD::SVDPackerModule::MainHeader::FADCnum
unsigned int FADCnum
FADC number.
Definition: SVDPackerModule.h:129
Belle2::SVD::SVDPackerModule::FADCTrailer::FTBFlags
unsigned int FTBFlags
FTB Flags Field.
Definition: SVDPackerModule.h:169
Belle2::SVD::SVDPackerModule::MainHeader::xTalk
unsigned int xTalk
cross talk tag
Definition: SVDPackerModule.h:128
Belle2::SVD::SVDPackerModule::FADCmap
std::unordered_map< unsigned short, unsigned short > FADCmap
type def for the FADC map
Definition: SVDPackerModule.h:78
Belle2::SVD::SVDPackerModule::data_B::sample5
unsigned int sample5
5th data sample
Definition: SVDPackerModule.h:161
Belle2::SVD::SVDPackerModule::FTBTrailer
implementation of FTB Trailer
Definition: SVDPackerModule.h:180
Belle2::SVD::SVDPackerModule::data_A::sample1
unsigned int sample1
1st data sample
Definition: SVDPackerModule.h:151
Belle2::SVD::SVDPackerModule::terminate
virtual void terminate() override
terminate
Definition: SVDPackerModule.cc:358
Belle2::SVD::SVDPackerModule::FADCTrailer::detectErrOR
unsigned int detectErrOR
Detection Error OR.
Definition: SVDPackerModule.h:174
Belle2::SVD::SVDPackerModule::nFADCboards
unsigned short nFADCboards
how many FADCs we have
Definition: SVDPackerModule.h:81
Belle2::SVD::SVDPackerModule::FTBTrailer::controlWord
unsigned int controlWord
MSB "ff55" - FADC Trailer ID.
Definition: SVDPackerModule.h:182
Belle2::SVD::SVDPackerModule::endRun
virtual void endRun() override
end run
Definition: SVDPackerModule.cc:363
Belle2::SVD::SVDPackerModule::m_MainHeader
MainHeader m_MainHeader
Implementation of FADC Header.
Definition: SVDPackerModule.h:189
Belle2::SVD::SVDPackerModule::DataInfo
6 samples and APV channel struct
Definition: SVDPackerModule.h:110
Belle2::SVD::SVDPackerModule::FTBHeader::errorsField
unsigned int errorsField
FTB error fields.
Definition: SVDPackerModule.h:119
Belle2::SVD::SVDPackerModule::m_data_B
data_B m_data_B
Implementation of 2nd data word.
Definition: SVDPackerModule.h:192
Belle2::SVD::SVDPackerModule::m_mapping
DBObjPtr< PayloadFile > m_mapping
channel map payload
Definition: SVDPackerModule.h:90
Belle2::SVD::SVDPackerModule::APVHeader::pipelineAddr
unsigned int pipelineAddr
Pipeline Address.
Definition: SVDPackerModule.h:144
Belle2::SVD::SVDPackerModule::m_svdShaperDigit
StoreArray< SVDShaperDigit > m_svdShaperDigit
Required input for SVDShaperDigit.
Definition: SVDPackerModule.h:200
Belle2::SVD::SVDPackerModule::FADCnumberMapRev
FADCmap FADCnumberMapRev
maps containing assignment (0,1,2,3,4,..,nFADCboards-1) <-> FADC numbers
Definition: SVDPackerModule.h:97
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
Belle2::SVD::SVDPackerModule::DataInfo::data
short data[6]
6 samples
Definition: SVDPackerModule.h:111
Belle2::SVD::SVDPackerModule::data_B::stripNum
unsigned int stripNum
Strip number.
Definition: SVDPackerModule.h:163
Belle2::SVD::SVDPackerModule::m_FTBHeader
FTBHeader m_FTBHeader
Implementation of FTB Header.
Definition: SVDPackerModule.h:188
Belle2::SVD::SVDPackerModule::m_xmlFileName
static std::string m_xmlFileName
< xml filename
Definition: SVDPackerModule.h:89
Belle2::SVD::SVDPackerModule::m_rawSVD
StoreArray< RawSVD > m_rawSVD
output for RawSVD
Definition: SVDPackerModule.h:199
Belle2::SVD::SVDPackerModule::data32
uint32_t data32
Output 32-bit data word.
Definition: SVDPackerModule.h:187
Belle2::SVD::SVDPackerModule::m_rawSVDListName
std::string m_rawSVDListName
RawSVD StoreArray name.
Definition: SVDPackerModule.h:69
Belle2::SVD::SVDPackerModule::SVDPackerModule
SVDPackerModule()
default constructor
Definition: SVDPackerModule.cc:45
Belle2::SVD::SVDPackerModule::MainHeader::check
unsigned int check
MSB "110" - for FADC Header identification.
Definition: SVDPackerModule.h:133
Belle2::SVD::SVDPackerModule::m_svdEventInfoPtr
StoreObjPtr< SVDEventInfo > m_svdEventInfoPtr
SVDEventInfo from simulation.
Definition: SVDPackerModule.h:198