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