14 #include <trg/cdc/modules/trgcdctsfUnpacker/trgcdctsfUnpackerModule.h>
19 using namespace TRGCDCTSF;
24 string TRGCDCTSFUnpackerModule::version()
const
26 return string(
"1.00");
29 TRGCDCTSFUnpackerModule::TRGCDCTSFUnpackerModule()
33 string desc =
"TRGCDCTSFUnpackerModule(" +
version() +
")";
42 B2DEBUG(20,
"trgcdctsfunpacker: Constructor done.");
58 sprintf(c_name,
"TRGCDCTSFUnpackerStore%d",
m_TSFMOD);
59 storeAry.registerInDataStore(c_name);
62 _exp = bevt->getExperiment();
63 _run = bevt->getRun();
98 B2ERROR(
"trgcdctsfunpacker:cooper address is not set");
108 for (
int i = 0; i < nLeafs; i++) {
109 for (
int j = 0; j < 2; j++) {
116 for (
int i = 0; i < nLeafs; i++) {
117 for (
int j = 0; j < 2; j++) {
122 B2ERROR(
"trgcdctsfunpacker:cooper address is not set");
125 for (
int i = 0; i < nLeafs; i++) {
126 for (
int j = 0; j < 2; j++) {
145 for (
int i = 0; i < raw_trgarray.
getEntries(); i++) {
146 for (
int j = 0; j < raw_trgarray[i]->GetNumEntries(); j++) {
150 int firm_vers = (raw_trgarray[i]->GetDetectorBuffer(j,
m_copper_ab))[1];
155 if (
m_TSFMOD == 1 && (firm_vers == 0x19041805 || firm_vers > 0x19052105)) {
157 }
else if (
m_TSFMOD == 3 && (firm_vers == 0x19041805 || firm_vers > 0x19052105)) {
159 }
else if (
m_TSFMOD == 5 && (firm_vers == 0x19041901 || firm_vers > 0x19061105)) {
173 const unsigned nword_header = 3;
175 for (
int clk = 0; clk < nClks; clk++) {
178 int ntups =
storeAry.getEntries() - 1;
179 int* bitArray[nLeafs + nLeafsExtra];
180 setLeafPointersArray(
storeAry[ntups], bitArray);
181 for (
int l = 0; l < nLeafs + nLeafsExtra; l++) *bitArray[l] = 0;
186 storeAry[ntups]->m_firmver = buf[1];
190 for (
int _wd = 0; _wd <
m_nBits / 32; _wd++) {
191 int wd = buf[clk * (
m_nBits / 32) + _wd + nword_header];
193 for (
int bb = 0; bb < 32; bb++) {
194 if ((wd >> (31 - bb)) & 1) {
195 int bitPosition = (
m_nBits - 1) - _wd * 32 - bb;
197 leaf < nLeafs; leaf++) {
200 int bitMaxOfTheLeaf = 0 ;
201 if (
m_nword == nword_2k) { bitMaxOfTheLeaf = BitMap_2k[leaf][0]; }
202 else {bitMaxOfTheLeaf = BitMap_4k[leaf][0];}
204 int bitWidOfTheLeaf = 0 ;
205 if (
m_nword == nword_2k) { bitWidOfTheLeaf = BitMap_2k[leaf][1]; }
206 else {bitWidOfTheLeaf = BitMap_4k[leaf][1];}
208 int bitMinOfTheLeaf = bitMaxOfTheLeaf - bitWidOfTheLeaf;
209 if (bitMinOfTheLeaf <= bitPosition && bitPosition <= bitMaxOfTheLeaf) {
210 *bitArray[leaf] |= (1 << (bitPosition - bitMinOfTheLeaf));
222 const unsigned nword_header = 3;
224 for (
int clk = 0; clk < nClks; clk++) {
227 int ntups =
storeAry.getEntries() - 1;
228 int* bitArray[nLeafs_4k15ts + nLeafsExtra];
229 setLeafPointersArray_4k15ts(
storeAry[ntups], bitArray);
230 for (
int l = 0; l < nLeafs_4k15ts + nLeafsExtra; l++) *bitArray[l] = 0;
235 storeAry[ntups]->m_firmver = buf[1];
239 for (
int _wd = 0; _wd <
m_nBits / 32; _wd++) {
240 int wd = buf[clk * (
m_nBits / 32) + _wd + nword_header];
242 for (
int bb = 0; bb < 32; bb++) {
243 if ((wd >> (31 - bb)) & 1) {
244 int bitPosition = (
m_nBits - 1) - _wd * 32 - bb;
246 leaf < nLeafs_4k15ts; leaf++) {
247 int bitMaxOfTheLeaf = BitMap_4k15ts[leaf][0];
248 int bitWidOfTheLeaf = BitMap_4k15ts[leaf][1];
249 int bitMinOfTheLeaf = bitMaxOfTheLeaf - bitWidOfTheLeaf;
250 if (bitMinOfTheLeaf <= bitPosition && bitPosition <= bitMaxOfTheLeaf) {
251 *bitArray[leaf] |= (1 << (bitPosition - bitMinOfTheLeaf));