Belle II Software development
trggdlDSTModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8//---------------------------------------------------------------
9// $Id$
10//---------------------------------------------------------------
11// Filename : trggdlDSTModule.cc
12// Section : TRG GDL DST
13// Owner :
14// Email :
15//---------------------------------------------------------------
16// Description : A trigger module for TRG GDL DST
17//---------------------------------------------------------------
18// 1.00 : 2017/05/08 : First version
19//---------------------------------------------------------------
20#include <framework/datastore/StoreObjPtr.h>
21#include <framework/datastore/StoreArray.h>
22
23#include <mdst/dataobjects/TRGSummary.h>
24#include <trg/gdl/dataobjects/TRGGDLDST.h>
25#include <trg/gdl/modules/trggdlDST/trggdlDSTModule.h>
26#include <trg/gdl/modules/trggdlUnpacker/trggdlUnpackerModule.h>
27
28#include <string.h>
29
30
31using namespace Belle2;
32using namespace GDL;
33
35
37 : Module::Module()
38{
39
40 setDescription("Fill experiment data to TRGGDLDST");
42
43}
44
46{
47
48 GDLResult.registerInDataStore();
49
50 for (int i = 0; i < 320; i++) {
51 LeafBitMap[i] = m_unpacker->getLeafMap(i);
52 }
53 for (int i = 0; i < 320; i++) {
54 strcpy(LeafNames[i], m_unpacker->getLeafnames(i));
55 }
56 _e_timtype = 0;
57 _e_gdll1rvc = 0;
58 _e_coml1rvc = 0;
59 _e_toprvc = 0;
60 _e_eclrvc = 0;
61 _e_cdcrvc = 0;
62 _e_toptiming = 0;
63 _e_ecltiming = 0;
64 _e_cdctiming = 0;
65 for (int i = 0; i < 320; i++) {
66 if (strcmp(LeafNames[i], "timtype") == 0) _e_timtype = LeafBitMap[i];
67 if (strcmp(LeafNames[i], "gdll1rvc") == 0) _e_gdll1rvc = LeafBitMap[i];
68 if (strcmp(LeafNames[i], "coml1rvc") == 0) _e_coml1rvc = LeafBitMap[i];
69 if (strcmp(LeafNames[i], "toprvc") == 0) _e_toprvc = LeafBitMap[i];
70 if (strcmp(LeafNames[i], "eclrvc") == 0) _e_eclrvc = LeafBitMap[i];
71 if (strcmp(LeafNames[i], "cdcrvc") == 0) _e_cdcrvc = LeafBitMap[i];
72 if (strcmp(LeafNames[i], "toptiming") == 0) _e_toptiming = LeafBitMap[i];
73 if (strcmp(LeafNames[i], "ecltiming") == 0) _e_ecltiming = LeafBitMap[i];
74 if (strcmp(LeafNames[i], "cdctiming") == 0) _e_cdctiming = LeafBitMap[i];
75 }
76}
77
79{
80
81 int n_leafs = 0;
82 n_leafs = m_unpacker->getnLeafs();
83 int n_leafsExtra = 0;
84 n_leafsExtra = m_unpacker->getnLeafsExtra();
85 int n_clocks = m_unpacker->getnClks();
86 //int nconf = m_unpacker->getconf(); // unused
87
88
90 if (!entAry || !entAry.getEntries()) return;
91
92 //prepare entAry adress
93 int clk_map = 0;
94 for (int i = 0; i < 320; i++) {
95 if (strcmp(entAry[0]->m_unpackername[i], "clk") == 0) clk_map = i;
96 }
97
98 std::vector<std::vector<int> > _data(n_leafs + n_leafsExtra);
99 for (int leaf = 0; leaf < n_leafs + n_leafsExtra; leaf++) {
100 std::vector<int> _v(n_clocks);
101 _data[leaf] = _v;
102 }
103
104 // fill "bit vs clk" for the event
105 for (int ii = 0; ii < entAry.getEntries(); ii++) {
106 std::vector<int*> Bits(n_leafs + n_leafsExtra);
107 //set pointer
108 for (int i = 0; i < 320; i++) {
109 if (LeafBitMap[i] != -1) {
110 Bits[LeafBitMap[i]] = &(entAry[ii]->m_unpacker[i]);
111 }
112 }
113 for (int leaf = 0; leaf < n_leafs + n_leafsExtra; leaf++) {
114 _data[leaf][entAry[ii]->m_unpacker[clk_map]] = *Bits[leaf];
115 }
116 }
117
118 GDLResult.create();
119
120 GDLResult->setGdlL1Time(_data[_e_gdll1rvc][n_clocks - 1]);
121 GDLResult->setComL1Time(_data[_e_coml1rvc][n_clocks - 1]);
122 GDLResult->setTimsrcGdlTime(_data[_e_toprvc][n_clocks - 1],
123 _data[_e_eclrvc][n_clocks - 1],
124 _data[_e_cdcrvc][n_clocks - 1]);
125 GDLResult->setT0(_data[_e_toptiming][n_clocks - 1],
126 _data[_e_ecltiming][n_clocks - 1],
127 _data[_e_cdctiming][n_clocks - 1]);
128
129
130 GDL::EGDLTimingType gtt = (GDL::EGDLTimingType)_data[_e_timtype][0];
132 if (gtt == GDL::e_tt_cdc) {
134 } else if (gtt == GDL::e_tt_ecl) {
136 } else if (gtt == GDL::e_tt_top) {
138 } else if (gtt == GDL::e_tt_dphy) {
140 } else if (gtt == GDL::e_tt_rand) {
142 } else if (gtt == GDL::e_tt_psnm) {
144 } else {
146 }
147
148 GDLResult->setTimType(tt);
149
150}
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
virtual void initialize() override
initialize
virtual void event() override
Event.
StoreObjPtr< TRGGDLDST > GDLResult
output for TRGDST
ETimingType
types of trigger timing source defined in b2tt firmware
Definition: TRGSummary.h:43
@ TTYP_DPHY
delayed physics events for background
Definition: TRGSummary.h:65
@ TTYP_SELF
events triggered by self trigger
Definition: TRGSummary.h:53
@ TTYP_NONE
reserved (not defined yet)
Definition: TRGSummary.h:75
@ TTYP_TOP
events triggered by TOP timing
Definition: TRGSummary.h:61
@ TTYP_CDC
events triggered by CDC timing
Definition: TRGSummary.h:63
@ TTYP_ECL
events triggered by ECL timing
Definition: TRGSummary.h:45
@ TTYP_RAND
random trigger events
Definition: TRGSummary.h:67
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.