13#include <trg/cdc/modules/trgcdct3dUnpacker/TRGCDCT3DUnpackerModule.h>
17using namespace TRGCDCT3DUNPACKERSPACE;
24 return string(
"1.10");
31 string desc =
"TRGCDCT3DUnpackerModule(" +
version() +
")";
37 B2DEBUG(20,
"TRGCDCT3DUnpacker: Constructor done.");
51 sprintf(c_name,
"TRGCDCT3DUnpackerStore%d",
m_T3DMOD);
52 m_store.registerInDataStore(c_name);
81 B2ERROR(
"trgcdct3dunpacker:cooper address is not set");
102 for (
int i = 0; i < raw_trgarray.
getEntries(); i++) {
105 if (raw_trgarray[i]->GetMaxNumOfCh(0) == 48) {
m_pciedata =
true; }
106 else if (raw_trgarray[i]->GetMaxNumOfCh(0) == 4) {
m_pciedata =
false; }
107 else { B2FATAL(
"TRGCDCT3DUnpackerModule: Invalid value of GetMaxNumOfCh from raw data: " <<
LogVar(
"Number of ch: ", raw_trgarray[i]->GetMaxNumOfCh(0))); }
109 unsigned int node_id = 0;
110 unsigned int ch_id = 0;
119 for (
int j = 0; j < raw_trgarray[i]->GetNumEntries(); j++) {
121 if (raw_trgarray[i]->GetNodeID(j) == node_id) {
123 if (raw_trgarray[i]->GetDetectorNwords(j, ch_id) ==
m_nword_2k) {
124 int firm_id = (raw_trgarray[i]->GetDetectorBuffer(j, ch_id))[0];
125 if (firm_id == 0x32444620) {
132 else if (raw_trgarray[i]->GetDetectorNwords(j, ch_id) ==
m_nword_2624) {
143 const unsigned nword_header = 3;
145 long dataHeader = buf[nword_header] & 0xffff0000;
146 if (dataHeader != 0xdddd0000) {
152 for (
int clk = 0; clk < nClks; clk++) {
155 int ntups =
m_store.getEntries() - 1;
156 int* bitArray[nLeafs + nLeafsExtra];
157 setLeafPointersArray(
m_store[ntups], bitArray);
158 for (
int l = 0; l < nLeafs + nLeafsExtra; l++) *bitArray[l] = 0;
162 m_store[ntups]->m_firmid = buf[0];
163 m_store[ntups]->m_firmver = buf[1];
186 for (
unsigned _wd = 0; _wd < nBits_2k / 32; _wd++) {
187 unsigned wd = buf[clk * (nBits_2k / 32) + _wd + nword_header];
188 for (
int bb = 0; bb < 32; bb++) {
189 if ((wd >> (31 - bb)) & 1) {
190 int bitPosition = (nBits_2k - 1) - _wd * 32 - bb;
192 leaf < nLeafs; leaf++) {
193 int bitMaxOfTheLeaf = BitMap[leaf][0];
194 int bitWidOfTheLeaf = BitMap[leaf][1];
195 int bitMinOfTheLeaf = bitMaxOfTheLeaf - bitWidOfTheLeaf;
196 if (bitMinOfTheLeaf <= bitPosition && bitPosition <= bitMaxOfTheLeaf) {
197 *bitArray[leaf] |= (1 << (bitPosition - bitMinOfTheLeaf));
209 const unsigned nword_header = 3;
211 long dataHeader = buf[nword_header] & 0xffff0000;
212 if (dataHeader != 0xdddd0000) {
218 for (
int clk = 0; clk < nClks; clk++) {
221 int ntups =
m_store.getEntries() - 1;
222 int* bitArray[nLeafs_2dfitter + nLeafsExtra];
223 setLeafPointersArray_2dfitter(
m_store[ntups], bitArray);
224 for (
int l = 0; l < nLeafs_2dfitter + nLeafsExtra; l++) *bitArray[l] = 0;
228 m_store[ntups]->m_firmid = buf[0];
229 m_store[ntups]->m_firmver = buf[1];
252 for (
unsigned _wd = 0; _wd < nBits_2k / 32; _wd++) {
253 unsigned wd = buf[clk * (nBits_2k / 32) + _wd + nword_header];
254 for (
int bb = 0; bb < 32; bb++) {
255 if ((wd >> (31 - bb)) & 1) {
256 int bitPosition = (nBits_2k - 1) - _wd * 32 - bb;
258 leaf < nLeafs_2dfitter; leaf++) {
259 int bitMaxOfTheLeaf = BitMap_2dfitter[leaf][0];
260 int bitWidOfTheLeaf = BitMap_2dfitter[leaf][1];
261 int bitMinOfTheLeaf = bitMaxOfTheLeaf - bitWidOfTheLeaf;
262 if (bitMinOfTheLeaf <= bitPosition && bitPosition <= bitMaxOfTheLeaf) {
263 *bitArray[leaf] |= (1 << (bitPosition - bitMinOfTheLeaf));
276 const unsigned nword_header = 3;
278 long dataHeader = buf[nword_header] & 0xffff0000;
279 if (dataHeader != 0xdddd0000) {
285 for (
int clk = 0; clk < nClks; clk++) {
288 int ntups =
m_store.getEntries() - 1;
289 int* bitArray[nLeafs_2624 + nLeafsExtra];
290 setLeafPointersArray_2624(
m_store[ntups], bitArray);
291 for (
int l = 0; l < nLeafs_2624 + nLeafsExtra; l++) *bitArray[l] = 0;
295 m_store[ntups]->m_firmid = buf[0];
296 m_store[ntups]->m_firmver = buf[1];
319 for (
unsigned _wd = 0; _wd < nBits_2624 / 32; _wd++) {
320 unsigned wd = buf[clk * (nBits_2624 / 32) + _wd + nword_header];
321 for (
int bb = 0; bb < 32; bb++) {
322 if ((wd >> (31 - bb)) & 1) {
323 int bitPosition = (nBits_2624 - 1) - _wd * 32 - bb;
325 leaf < nLeafs_2624; leaf++) {
326 int bitMaxOfTheLeaf = BitMap_2624[leaf][0];
327 int bitWidOfTheLeaf = BitMap_2624[leaf][1];
328 int bitMinOfTheLeaf = bitMaxOfTheLeaf - bitWidOfTheLeaf;
329 if (bitMinOfTheLeaf <= bitPosition && bitPosition <= bitMaxOfTheLeaf) {
330 *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.
virtual void fillTreeTRGCDCT3DUnpacker_2624(int *buf, int evt)
Unpacker main function, 2.6k, 15 TS version.
virtual void fillTreeTRGCDCT3DUnpacker(int *buf, int evt)
Unpacker main function.
bool m_pciedata
PCIe40 data or copper data;.
virtual ~TRGCDCT3DUnpackerModule()
Destructor.
virtual void fillTreeTRGCDCT3DUnpacker_2dfitter(int *buf, int evt)
Unpacker main function.
int m_T3DMOD
T3D module number.
virtual void initialize() override
Initilizes TRGCDCT3DUnpackerUnpackerModule.
int m_nword_2k
Number of words im raw data, 2k.
virtual void event() override
Called event by event.
virtual void endRun() override
Called when run ended.
unsigned int m_pcie40_ch
channel ID of PCIe40 module
virtual void terminate() override
Called when processing ended.
int m_nword_2624
Number of words im raw data, 2.6k, 15 TS version.
virtual void beginRun() override
Called when new run started.
unsigned int m_pcie40_address
address of PCIe40 module
TRGCDCT3DUnpackerModule()
Constructor.
unsigned int m_copper_address
address of copper module
StoreArray< TRGCDCT3DUnpackerStore > m_store
Output datastore for unpacker.
std::string version() const
returns version of TRGCDCT3DUnpackerModule.
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.