 |
Belle II Software
release-05-02-19
|
11 #include <svd/modules/svdPacker/SVDPackerModule.h>
12 #include <svd/online/SVDOnlineToOfflineMap.h>
14 #include <framework/datastore/DataStore.h>
15 #include <framework/datastore/StoreObjPtr.h>
16 #include <framework/datastore/RelationArray.h>
17 #include <framework/datastore/RelationIndex.h>
18 #include <framework/logging/Logger.h>
19 #include <framework/utilities/FileSystem.h>
21 #include <arpa/inet.h>
22 #include <boost/crc.hpp>
45 SVDPackerModule::SVDPackerModule() :
Module(),
46 m_mapping(m_xmlFileName),
47 m_FADCTriggerNumberOffset(0)
59 "number to be added to the FADC trigger number to match the main trigger number", 0);
100 #pragma GCC diagnostic push
101 #pragma GCC diagnostic ignored "-Wstack-usage="
107 B2ERROR(
"Missing valid EventMetaData.");
112 B2ERROR(
"Missing valid SVDEventInfo.");
123 if (daqMode == 3) daqType = 1;
132 B2ERROR(
"xml map not loaded, going to the next module");
142 rawcprpacker_info.
tt_ctime = 0x7123456;
143 rawcprpacker_info.
tt_utime = 0xF1234567;
150 vector<DataInfo> (*fadc_apv_matrix)[48] =
new
153 for (
unsigned int i = 0; i < nEntries_SVDShaperDigits; i++) {
157 short int cellID = hit->getCellID();
158 VxdID sensID = hit->getSensorID();
159 bool isU = hit->isUStrip();
167 unsigned short fadc = CHIP_info.
fadc;
168 unsigned short apv = CHIP_info.
apv;
169 unsigned short apvChannel = CHIP_info.
apvChannel;
172 if (fadc == 0)
continue;
181 for (
unsigned short j = 0; j < 6; j++) {
182 dataInfo.
data[j] = samples[j];
187 fadc_apv_matrix[fadcIter->second][apv].push_back(dataInfo);
192 for (
unsigned int iFADC = 0; iFADC <
nFADCboards; iFADC++) {
230 auto apv_range =
APVmap->equal_range(FADCorg);
232 for (
auto& it = apv_range.first; it != apv_range.second; ++it) {
233 unsigned short iAPV = it->second;
251 vector<DataInfo>& apv_data_vec = fadc_apv_matrix[iFADC][iAPV];
253 if (apv_data_vec.size() > 0) {
254 for (std::vector<DataInfo>::iterator apv_data = apv_data_vec.begin(); apv_data != apv_data_vec.end(); ++apv_data) {
298 uint32_t tmpBuffer[nCRC];
300 for (
unsigned short i = 0; i < nCRC; i++)
304 boost::crc_basic<16> bcrc(0x8005, 0xffff, 0,
false,
false);
305 bcrc.process_block(tmpBuffer, tmpBuffer + nCRC);
306 unsigned int crc = bcrc.checksum();
319 unsigned int nwords_2nd = 0;
320 unsigned int nwords_3rd = 0;
321 unsigned int nwords_4th = 0;
323 int* buf1 =
new int[nwords_1st];
329 for (
unsigned int j = 0; j < nwords_1st; j++) {
348 delete [] fadc_apv_matrix;
354 #pragma GCC diagnostic pop
373 B2INFO(
"\nbinary printout:");
374 for (
unsigned int j = 0; j < nwords; j++) {
376 uint32_t ulFlag = 1 << (
sizeof(
data_words[j]) * 8 - 1);
377 for (; ulFlag > 0; ulFlag >>= 1)
378 printf(
"%d", (
data_words[j] & ulFlag) ? 1 : 0);
unsigned int tt_utime
27bit clock ticks at trigger timing distributed by FTSW. For details, see Nakao-san's belle2link user...
struct to contain header information used by RawCOPPERFormat::Packer()
bool hasChanged()
Check whether the object has changed since the last call to hasChanged of the accessor).
std::unique_ptr< SVDOnlineToOfflineMap > m_map
Pointer to online-to-offline map.
bool m_binPrintout
if true, print data created by the Packer
unsigned int exp_num
Experiment number (10bit)
Class to uniquely identify a any structure of the PXD and SVD.
unsigned int node_id
Event Number (32bit)
unsigned int frameErrOR
Frame Error OR.
unsigned int sample4
4th data sample
baseType getTriggerBin() const
Get the triggerBin id.
unsigned int DAQType
(from 2020c) Event type(0): "0"…3 or …6 acquisition mode, "1"…3-mixed-6 acquisition mode
unsigned int b2l_ctime
32bit unitx time at trigger timing distributed by FTSW. For details, see Nakao-san's belle2link user ...
std::string m_svdEventInfoName
SVDEventInfo name.
unsigned int sample2
2nd data sample
FADCTrailer m_FADCTrailer
Implementation of FADC Trailer.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
virtual void event() override
event
virtual void beginRun() override
begin run
std::unordered_multimap< unsigned char, unsigned char > * APVmap
pointer to APVforFADCmap filled by mapping procedure
The Raw SVD class Class for RawCOPPER class data taken by SVD Currently, this class is almost same as...
int m_FADCTriggerNumberOffset
FADC trigger numnber offset.
baseType getLadderNumber() const
Get the ladder id.
Struct to hold data about an APV25 chip.
std::string m_svdShaperDigitListName
SVDShaperDigit StoreArray name.
unsigned int runType
Run Type.
FADCmap FADCnumberMap
maps containing assignment (0,1,2,3,4,..,nFADCboards-1) <-> FADC numbers
APVHeader m_APVHeader
Implementation of APV Header.
void addData32(uint32_t adata32)
adds packed 32-bit data word to the raw data vector
FTBTrailer m_FTBTrailer
Implementation of FTB Trailer.
Class to store SVD mode information.
unsigned int eve_num
Run # and subrun # ( 22bit )
const std::string & getType() const
Returns the type of the module (i.e.
baseType getDAQMode() const
Get the daqMode id.
StoreObjPtr< EventMetaData > m_eventMetaDataPtr
Required input for EventMetaData.
unsigned int sample6
6th data sample
data_A m_data_A
Implementation of 1st data word.
unsigned int sample3
3rd data sample
unsigned int apvErrOR
APV chip number OR.
virtual ~SVDPackerModule()
default destructor
unsigned int tt_ctime
Node ID (32bit)
unsigned int check
MSB "1" - for Data word identification.
unsigned int DAQMode
Event type(2:1): "00"…1-sample, "01"…3-sample, "10"…6-sample.
The SVD ShaperDigit class.
unsigned int stripNum
Strip number.
unsigned int check
MSB "1" - for Data word identification.
std::array< APVFloatSampleType, c_nAPVSamples > APVFloatSamples
array of APVFloatSampleType objects
int n_basf2evt
event number
unsigned int nullDigits
"0000000"
unsigned int trgType
Trigger Type.
unsigned int check
MSB "1110" - for FADC Trailer identification.
unsigned int trgNumber
Trigger Number.
virtual void initialize() override
initialize
std::vector< uint32_t > data_words
vector of raw data words
unsigned int dataSizeCut
APV data-size cut flag
unsigned int crc16
FTB CRC16 Checksum
unsigned short channel
APV channel number.
unsigned int fifoErrOR
FIFO full Error OR.
Abstract base class for different kinds of events.
unsigned int run_subrun_num
Experiment number (10bit)
void binPrintout(unsigned int nwords)
tool: print out N words
unsigned int trgTiming
Trigger Timing.
unsigned int FADCnum
FADC number.
unsigned int FTBFlags
FTB Flags Field.
Namespace to encapsulate code needed for simulation and reconstrucion of the SVD.
unsigned int xTalk
cross talk tag
unsigned int sample5
5th data sample
unsigned short fadc
fadc number
unsigned int sample1
1st data sample
virtual void terminate() override
terminate
baseType getSensorNumber() const
Get the sensor id.
baseType getRunType() const
Get the runMode id.
unsigned int detectErrOR
Detection Error OR.
unsigned short nFADCboards
how many FADCs we have
unsigned char apvChannel
apv channel
unsigned int controlWord
MSB "ff55" - FADC Trailer ID.
virtual void endRun() override
end run
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
MainHeader m_MainHeader
Implementation of FADC Header.
data_B m_data_B
Implementation of 2nd data word.
DBObjPtr< PayloadFile > m_mapping
channel map payload
unsigned char apv
apv number
void PackDetectorBuf(int *detector_buf_1st, int nwords_1st, int *detector_buf_2nd, int nwords_2nd, int *detector_buf_3rd, int nwords_3rd, int *detector_buf_4th, int nwords_4th, RawCOPPERPackerInfo rawcprpacker_info)
Packer for RawCOPPER class Pack data (format ver.
StoreArray< SVDShaperDigit > m_svdShaperDigit
Required input for SVDShaperDigit.
FADCmap FADCnumberMapRev
maps containing assignment (0,1,2,3,4,..,nFADCboards-1) <-> FADC numbers
baseType getLayerNumber() const
Get the layer id.
unsigned int stripNum
Strip number.
FTBHeader m_FTBHeader
Implementation of FTB Header.
static std::string m_xmlFileName
< xml filename
StoreArray< RawSVD > m_rawSVD
output for RawSVD
uint32_t data32
Output 32-bit data word.
std::string m_rawSVDListName
RawSVD StoreArray name.
unsigned int check
MSB "110" - for FADC Header identification.
StoreObjPtr< SVDEventInfo > m_svdEventInfoPtr
SVDEventInfo from simulation.