9 #include <trg/cdc/modules/trgcdctsfUnpacker/trgcdctsfUnpackerModule.h>
14 using namespace TRGCDCTSF;
19 string TRGCDCTSFUnpackerModule::version()
const
21 return string(
"1.00");
24 TRGCDCTSFUnpackerModule::TRGCDCTSFUnpackerModule()
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();
93 B2ERROR(
"trgcdctsfunpacker:cooper address is not set");
103 for (
int i = 0; i < nLeafs; i++) {
104 for (
int j = 0; j < 2; j++) {
111 for (
int i = 0; i < nLeafs; i++) {
112 for (
int j = 0; j < 2; j++) {
117 B2ERROR(
"trgcdctsfunpacker:cooper address is not set");
120 for (
int i = 0; i < nLeafs; i++) {
121 for (
int j = 0; j < 2; j++) {
140 for (
int i = 0; i < raw_trgarray.
getEntries(); i++) {
141 for (
int j = 0; j < raw_trgarray[i]->GetNumEntries(); j++) {
145 int firm_vers = (raw_trgarray[i]->GetDetectorBuffer(j,
m_copper_ab))[1];
150 if (
m_TSFMOD == 1 && (firm_vers == 0x19041805 || firm_vers > 0x19052105)) {
152 }
else if (
m_TSFMOD == 3 && (firm_vers == 0x19041805 || firm_vers > 0x19052105)) {
154 }
else if (
m_TSFMOD == 5 && (firm_vers == 0x19041901 || firm_vers > 0x19061105)) {
168 const unsigned nword_header = 3;
170 for (
int clk = 0; clk < nClks; clk++) {
173 int ntups =
storeAry.getEntries() - 1;
174 int* bitArray[nLeafs + nLeafsExtra];
175 setLeafPointersArray(
storeAry[ntups], bitArray);
176 for (
int l = 0; l < nLeafs + nLeafsExtra; l++) *bitArray[l] = 0;
181 storeAry[ntups]->m_firmver = buf[1];
185 for (
int _wd = 0; _wd <
m_nBits / 32; _wd++) {
186 unsigned wd = buf[clk * (
m_nBits / 32) + _wd + nword_header];
188 for (
int bb = 0; bb < 32; bb++) {
189 if ((wd >> (31 - bb)) & 1) {
190 int bitPosition = (
m_nBits - 1) - _wd * 32 - bb;
192 leaf < nLeafs; leaf++) {
195 int bitMaxOfTheLeaf = 0 ;
196 if (
m_nword == nword_2k) { bitMaxOfTheLeaf = BitMap_2k[leaf][0]; }
197 else {bitMaxOfTheLeaf = BitMap_4k[leaf][0];}
199 int bitWidOfTheLeaf = 0 ;
200 if (
m_nword == nword_2k) { bitWidOfTheLeaf = BitMap_2k[leaf][1]; }
201 else {bitWidOfTheLeaf = BitMap_4k[leaf][1];}
203 int bitMinOfTheLeaf = bitMaxOfTheLeaf - bitWidOfTheLeaf;
204 if (bitMinOfTheLeaf <= bitPosition && bitPosition <= bitMaxOfTheLeaf) {
205 *bitArray[leaf] |= (1 << (bitPosition - bitMinOfTheLeaf));
217 const unsigned nword_header = 3;
219 for (
int clk = 0; clk < nClks; clk++) {
222 int ntups =
storeAry.getEntries() - 1;
223 int* bitArray[nLeafs_4k15ts + nLeafsExtra];
224 setLeafPointersArray_4k15ts(
storeAry[ntups], bitArray);
225 for (
int l = 0; l < nLeafs_4k15ts + nLeafsExtra; l++) *bitArray[l] = 0;
230 storeAry[ntups]->m_firmver = buf[1];
234 for (
int _wd = 0; _wd <
m_nBits / 32; _wd++) {
235 unsigned wd = buf[clk * (
m_nBits / 32) + _wd + nword_header];
237 for (
int bb = 0; bb < 32; bb++) {
238 if ((wd >> (31 - bb)) & 1) {
239 int bitPosition = (
m_nBits - 1) - _wd * 32 - bb;
241 leaf < nLeafs_4k15ts; leaf++) {
242 int bitMaxOfTheLeaf = BitMap_4k15ts[leaf][0];
243 int bitWidOfTheLeaf = BitMap_4k15ts[leaf][1];
244 int bitMinOfTheLeaf = bitMaxOfTheLeaf - bitWidOfTheLeaf;
245 if (bitMinOfTheLeaf <= bitPosition && bitPosition <= bitMaxOfTheLeaf) {
246 *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.
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.
virtual void terminate() override
Called when processing ended.
int m_TSFMOD
TSF module number.
virtual void beginRun() override
Called when new run started.
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
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.