9#include <trg/cdc/modules/trgcdctsfUnpacker/trgcdctsfUnpackerModule.h>
14using namespace TRGCDCTSF;
21 return string(
"1.00");
28 string desc =
"TRGCDCTSFUnpackerModule(" +
version() +
")";
37 B2DEBUG(20,
"trgcdctsfunpacker: Constructor done.");
53 sprintf(c_name,
"TRGCDCTSFUnpackerStore%d",
m_TSFMOD);
54 storeAry.registerInDataStore(c_name);
57 _exp = bevt->getExperiment();
58 _run = bevt->getRun();
111 B2ERROR(
"trgcdctsfunpacker:cooper address is not set");
123 for (
int i = 0; i < nLeafs; i++) {
124 for (
int j = 0; j < 2; j++) {
131 for (
int i = 0; i < nLeafs; i++) {
132 for (
int j = 0; j < 2; j++) {
137 B2ERROR(
"trgcdctsfunpacker:cooper address is not set");
140 for (
int i = 0; i < nLeafs; i++) {
141 for (
int j = 0; j < 2; j++) {
160 for (
int i = 0; i < raw_trgarray.
getEntries(); i++) {
163 if (raw_trgarray[i]->GetMaxNumOfCh(0) == 48) {
m_pciedata =
true; }
164 else if (raw_trgarray[i]->GetMaxNumOfCh(0) == 4) {
m_pciedata =
false; }
165 else { B2FATAL(
"TRGCDCTSFUnpackerModule: Invalid value of GetMaxNumOfCh from raw data: " <<
LogVar(
"Number of ch: ", raw_trgarray[i]->GetMaxNumOfCh(0))); }
167 unsigned int node_id = 0;
168 unsigned int ch_id = 0;
177 for (
int j = 0; j < raw_trgarray[i]->GetNumEntries(); j++) {
178 if (raw_trgarray[i]->GetNodeID(j) == node_id) {
179 if (raw_trgarray[i]->GetDetectorNwords(j, ch_id) ==
m_nword) {
181 int firm_vers = (raw_trgarray[i]->GetDetectorBuffer(j, ch_id))[1];
186 if (
m_TSFMOD == 1 && (firm_vers == 0x19041805 || firm_vers > 0x19052105)) {
188 }
else if (
m_TSFMOD == 3 && (firm_vers == 0x19041805 || firm_vers > 0x19052105)) {
190 }
else if (
m_TSFMOD == 5 && (firm_vers == 0x19041901 || firm_vers > 0x19061105)) {
193 fillTreeCDCTSF(raw_trgarray[i]->GetDetectorBuffer(j, ch_id), raw_trgarray[j]->GetEveNo(j));
204 const unsigned nword_header = 3;
206 for (
int clk = 0; clk < nClks; clk++) {
209 int ntups =
storeAry.getEntries() - 1;
210 int* bitArray[nLeafs + nLeafsExtra];
211 setLeafPointersArray(
storeAry[ntups], bitArray);
212 for (
int l = 0; l < nLeafs + nLeafsExtra; l++) *bitArray[l] = 0;
217 storeAry[ntups]->m_firmver = buf[1];
221 for (
int _wd = 0; _wd <
m_nBits / 32; _wd++) {
222 unsigned wd = buf[clk * (
m_nBits / 32) + _wd + nword_header];
224 for (
int bb = 0; bb < 32; bb++) {
225 if ((wd >> (31 - bb)) & 1) {
226 int bitPosition = (
m_nBits - 1) - _wd * 32 - bb;
228 leaf < nLeafs; leaf++) {
231 int bitMaxOfTheLeaf = 0 ;
232 if (
m_nword == nword_2k) { bitMaxOfTheLeaf = BitMap_2k[leaf][0]; }
233 else {bitMaxOfTheLeaf = BitMap_4k[leaf][0];}
235 int bitWidOfTheLeaf = 0 ;
236 if (
m_nword == nword_2k) { bitWidOfTheLeaf = BitMap_2k[leaf][1]; }
237 else {bitWidOfTheLeaf = BitMap_4k[leaf][1];}
239 int bitMinOfTheLeaf = bitMaxOfTheLeaf - bitWidOfTheLeaf;
240 if (bitMinOfTheLeaf <= bitPosition && bitPosition <= bitMaxOfTheLeaf) {
241 *bitArray[leaf] |= (1 << (bitPosition - bitMinOfTheLeaf));
253 const unsigned nword_header = 3;
255 for (
int clk = 0; clk < nClks; clk++) {
258 int ntups =
storeAry.getEntries() - 1;
259 int* bitArray[nLeafs_4k15ts + nLeafsExtra];
260 setLeafPointersArray_4k15ts(
storeAry[ntups], bitArray);
261 for (
int l = 0; l < nLeafs_4k15ts + nLeafsExtra; l++) *bitArray[l] = 0;
266 storeAry[ntups]->m_firmver = buf[1];
270 for (
int _wd = 0; _wd <
m_nBits / 32; _wd++) {
271 unsigned wd = buf[clk * (
m_nBits / 32) + _wd + nword_header];
273 for (
int bb = 0; bb < 32; bb++) {
274 if ((wd >> (31 - bb)) & 1) {
275 int bitPosition = (
m_nBits - 1) - _wd * 32 - bb;
277 leaf < nLeafs_4k15ts; leaf++) {
278 int bitMaxOfTheLeaf = BitMap_4k15ts[leaf][0];
279 int bitWidOfTheLeaf = BitMap_4k15ts[leaf][1];
280 int bitMinOfTheLeaf = bitMaxOfTheLeaf - bitWidOfTheLeaf;
281 if (bitMinOfTheLeaf <= bitPosition && bitPosition <= bitMaxOfTheLeaf) {
282 *bitArray[leaf] |= (1 << (bitPosition - bitMinOfTheLeaf));
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Accessor to arrays stored in the data store.
int getEntries() const
Get the number of objects in the array.
Type-safe access to single objects in the data store.
bool m_pciedata
PCIe40 data or copper data.
StoreArray< TRGCDCTSFUnpackerStore > storeAry
StoreArray of TRGCDCTSFUnpackerStore.
virtual void fillTreeCDCTSF(int *buf, int evt)
Unpacker main function.
virtual void initialize() override
Initilizes TRGCDCTSFUnpackerModuel.
virtual void event() override
Called event by event.
virtual void endRun() override
Called when run ended.
virtual ~TRGCDCTSFUnpackerModule()
Destructor.
unsigned int m_pcie40_ch
channel ID of PCIe40 module
virtual void terminate() override
Called when processing ended.
TRGCDCTSFUnpackerModule()
Constructor.
int m_TSFMOD
TSF module number.
virtual void beginRun() override
Called when new run started.
unsigned int m_pcie40_address
address of PCIe40 module
int m_nword
number of word
unsigned int m_copper_address
address of copper module
std::string version() const
returns version of TRGCDCTSFUnpackerModule.
virtual void fillTreeCDCTSF_4k15ts(int *buf, int evt)
Unpacker main function for 4k, 15 TS version.
unsigned int m_copper_ab
address of copper module
Class to store variables with their name which were sent to the logging service.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.