9#include <trg/grl/modules/TRGGRLUnpacker/TRGGRLUnpackerModule.h>
13using namespace TRGGRLUNPACKERSPACE;
20 return string(
"1.00");
27 string desc =
"TRGGRLUnpackerModule(" +
version() +
")";
30 B2DEBUG(20,
"TRGGRLUnpacker: Constructor done.");
59 for (
int i = 0; i < raw_trgarray.
getEntries(); i++) {
62 if (raw_trgarray[i]->GetMaxNumOfCh(0) == 48) {
m_pciedata =
true; }
63 else if (raw_trgarray[i]->GetMaxNumOfCh(0) == 4) {
m_pciedata =
false; }
64 else { B2FATAL(
"TRGGRLUnpackerModule: Invalid value of GetMaxNumOfCh from raw data: " <<
LogVar(
"Number of ch: ", raw_trgarray[i]->GetMaxNumOfCh(0))); }
77 if (raw_trgarray[i]->GetTRGType(0) == 7) {
continue;}
79 for (
int j = 0; j < raw_trgarray[i]->GetNumEntries(); j++) {
80 if ((
int)raw_trgarray[i]->GetNodeID(j) == node_id) {
83 if (raw_trgarray[i]->GetDetectorNwords(j, ch_id) > 0) {
94 const unsigned nword_header = 3;
106 for (
int l = 0; l < nLeafs + nLeafsExtra; l++) {
107 SetStoreLeaf(rawstore, l, 0);
115 rawstore->
set_coml1(buf[2] & ((1 << 12) - 1));
116 rawstore->
set_b2ldly((buf[2] >> 12) & ((1 << 9) - 1));
117 rawstore->
set_maxrvc((buf[2] >> 21) & ((1 << 11) - 1));
126 for (
int _wd = 0; _wd < nBits / 32; _wd++) {
127 unsigned wd = buf[0 * (nBits / 32) + _wd + nword_header];
128 for (
int bb = 0; bb < 32; bb++) {
129 if ((wd >> (31 - bb)) & 1) {
130 int bitPosition = (nBits - 1) - _wd * 32 - bb;
132 leaf < nLeafs; leaf++) {
133 int bitMaxOfTheLeaf = BitMap[leaf][0];
134 int bitWidOfTheLeaf = BitMap[leaf][1];
135 int bitMinOfTheLeaf = bitMaxOfTheLeaf - bitWidOfTheLeaf;
136 if (bitMinOfTheLeaf <= bitPosition && bitPosition <= bitMaxOfTheLeaf) {
137 SetStoreLeaf(rawstore, leaf, GetStoreLeaf(rawstore, leaf) | (1 << (bitPosition - bitMinOfTheLeaf)));
146 std::vector<int> index_ECL;
147 std::vector<int> clkindex_ECL;
149 clkindex_ECL.clear();
151 index_ECL.push_back(i); clkindex_ECL.push_back(0);
154 index_ECL.push_back(i + 6); clkindex_ECL.push_back(1);
159 evtinfo->ClearVectors();
161 int index = index_ECL[i];
162 int clkindex = clkindex_ECL[i];
164 evtinfo->Addto_clk_ECL(clkindex);
165 evtinfo->Addto_E_ECL(rawstore->
get_E_ECL(index));
166 evtinfo->Addto_t_ECL(rawstore->
get_t_ECL(index));
168 evtinfo->Addto_phi_ECL(rawstore->
get_phi_ECL(index));
169 evtinfo->Addto_E_ECL(rawstore->
get_E_ECL(index));
176 for (
int i = 0; i < 32; i++) {
177 evtinfo->set_phi_i(i, (rawstore->
get_phi_i_int(0) & (1u << i)) != 0);
178 evtinfo->set_phi_CDC(i, (rawstore->
get_phi_CDC_int(0) & (1u << i)) != 0);
180 for (
int i = 32; i < 36; i++) {
181 evtinfo->set_phi_i(i, (rawstore->
get_phi_i_int(1) & (1 << (i - 32))) != 0);
182 evtinfo->set_phi_CDC(i, (rawstore->
get_phi_CDC_int(1) & (1 << (i - 32))) != 0);
185 for (
int i = 0; i < 16; i++) {
190 for (
int i = 0; i < 8; i++) {
195 for (
int i = 0; i < 32; i++) {
196 evtinfo->set_map_ST(i, (rawstore->
get_map_ST_int(0) & (1u << i)) != 0);
197 evtinfo->set_map_ST2(i, (rawstore->
get_map_ST2_int(0) & (1u << i)) != 0);
205 for (
int i = 32; i < 64; i++) {
206 evtinfo->set_map_ST(i, (rawstore->
get_map_ST_int(1) & (1u << (i - 32))) != 0);
207 evtinfo->set_map_ST2(i, (rawstore->
get_map_ST2_int(1) & (1u << (i - 32))) != 0);
208 evtinfo->set_map_veto(i, (rawstore->
get_map_veto_int(1) & (1u << (i - 32))) != 0);
209 evtinfo->set_map_TSF0(i, (rawstore->
get_map_TSF0_int(1) & (1u << (i - 32))) != 0);
210 evtinfo->set_map_TSF2(i, (rawstore->
get_map_TSF2_int(1) & (1u << (i - 32))) != 0);
211 evtinfo->set_map_TSF4(i, (rawstore->
get_map_TSF4_int(1) & (1u << (i - 32))) != 0);
212 evtinfo->set_map_TSF1(i, (rawstore->
get_map_TSF1_int(1) & (1u << (i - 32))) != 0);
213 evtinfo->set_map_TSF3(i, (rawstore->
get_map_TSF3_int(1) & (1u << (i - 32))) != 0);
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...
bool assign(TObject *object, bool replace=false)
Assign 'object' to this accessor.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
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.
TRGGRLUnpackerModule()
Constructor.
bool m_pciedata
PCIe40 data or copper data.
virtual void initialize() override
Initilizes TRGGRLUnpackerUnpackerModule.
virtual void event() override
Called event by event.
virtual void endRun() override
Called when run ended.
virtual void terminate() override
Called when processing ended.
virtual void beginRun() override
Called when new run started.
virtual ~TRGGRLUnpackerModule()
Destructor.
std::string version() const
returns version of TRGGRLUnpackerModule.
virtual void fillTreeTRGGRLUnpacker(int *buf, int evt)
Unpacker main function.
void set_b2ldly(int b2ldly)
m_b2ldly leafs
int get_N_cluster_0() const
m_N_cluster_0 leaf
int get_phi_CDC_int(int i) const
m_phi_CDC integer leaf
int get_2GeV_ECL(int i) const
m_2GeV_flag_ECL leaf
int get_map_TSF2_int(int i) const
m_map_TSF2 integer leaf
int get_map_TSF0_int(int i) const
m_map_TSF0 integer leaf
int get_t_ECL(int i) const
m_t_ECL leaf
void set_firmid(int firmid)
m_firmid leafs
int get_sector_CDC_int() const
m_sector_CDC integer leaf
int get_phi_i_int(int i) const
m_phi_i integer leaf
void set_evt(int evt)
m_evt leafs
int get_map_TSF3_int(int i) const
m_map_TSF3 integer leaf
int get_slot_TOP_int() const
m_slot_TOP integer leaf
int get_map_ST_int(int i) const
m_map_ST integer leaf
int get_map_TSF1_int(int i) const
m_map_TSF1 integer leaf
int get_map_TSF4_int(int i) const
m_map_TSF4 integer leaf
int get_map_ST2_int(int i) const
m_map_ST2 integer leaf
void set_firmver(int firmver)
m_firmver leafs
int get_N_cluster_1() const
m_N_cluster_1 leaf
int get_phi_ECL(int i) const
m_phi_ECL leaf
int get_sector_KLM_int() const
m_sector_KLM integer leaf
int get_map_veto_int(int i) const
m_map_veto integer leaf
void set_N_cluster(int N_cluster)
m_N_cluster leaf
void set_coml1(int coml1)
m_coml1 leafs
int get_N_cluster() const
m_N_cluster leaf
void set_maxrvc(int maxrvc)
m_maxrvc leafs
int get_theta_ECL(int i) const
m_theta_ECL leaf
void set_clk(int clk)
m_clk leafs
int get_E_ECL(int i) const
m_E_ECL leaf
int get_1GeV_ECL(int i) const
m_1GeV_flag_ECL leaf
int get_slot_CDC_int() const
m_slot_CDC integer leaf
Class to store variables with their name which were sent to the logging service.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.