Belle II Software  release-06-00-14
ARICHRateCalModule.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 // Own include
10 #include <arich/modules/arichRateCal/ARICHRateCalModule.h>
11 #include <arich/dataobjects/ARICHThParam.h>
12 #include <arich/dataobjects/ARICHRawDigit.h>
13 #include <arich/dataobjects/ARICHInfo.h>
14 
15 // framework - DataStore
16 #include <framework/dataobjects/EventMetaData.h>
17 #include <framework/datastore/StoreArray.h>
18 #include <framework/datastore/StoreObjPtr.h>
19 
20 /*
21 #include <daq/slc/database/DBObjectLoader.h>
22 #include <daq/slc/psql/PostgreSQLInterface.h>
23 #include <daq/slc/base/ConfigFile.h>
24 #include <daq/slc/base/StringUtil.h>
25 */
26 
27 #include <sstream>
28 #include <TH2F.h>
29 
30 using namespace std;
31 
32 namespace Belle2 {
38  //-----------------------------------------------------------------
39  // Register module
40  //-----------------------------------------------------------------
41 
42  REG_MODULE(ARICHRateCal);
43 
44  //-----------------------------------------------------------------
45  // Implementation
46  //-----------------------------------------------------------------
47 
48  ARICHRateCalModule::ARICHRateCalModule() : HistoModule()
49  {
50  // set module description (e.g. insert text)
51  setDescription("Fills ARICHHits collection from ARICHDigits");
53  addParam("nrun", m_nrun, "# of scan runs", 100);
54  addParam("nevents", m_nevents, "# of events per run", 1000);
55  double v = 0;
56  addParam("dth", m_dth, "dth", v);
57  addParam("th0", m_th0, "th0", v);
58  addParam("debug", m_debugmode, "debug mode", false);
59  addParam("internal", m_internalmode, "Internal thscan mode", false);
60  addParam("daqdb", m_daqdb, "daqdb config name", std::string(""));
61  }
62 
64  {
65  }
66 
68  {
69  /*
70  if (m_daqdb.size() > 0) {
71  ConfigFile config("slowcontrol");
72  PostgreSQLInterface db(config.get("database.host"),
73  config.get("database.dbname"),
74  config.get("database.user"),
75  config.get("database.password"),
76  config.getInt("database.port"));
77  DBObject obj = DBObjectLoader::load(db, "arich_th",
78  StringUtil::replace(m_daqdb, ".", ":"));
79  obj.print();
80  m_dth = obj.getFloat("dth");
81  m_th0 = obj.getFloat("th0");
82  m_nrun = obj.getInt("nth");
83  db.close();
84  }
85  */
86 
87  if (m_dth == 0) {
88  B2WARNING("dth is set to 0");
89  }
90  for (int i = 0; i < 100; i++) {
91  h_rate2D[i] = new TH2F(Form("h_rate2D_%d", i), Form("MRG#%d;Channel ID; Vth [mV]", i), 144 * 6, -0.5, -0.5 + 144 * 6,
92  m_nrun, (m_th0 - 0.5 * m_dth) * 1000, (m_th0 + (m_nrun - 0.5)*m_dth) * 1000);
93  }
94  }
95 
97  {
98 
99  REG_HISTOGRAM
101  rawdata.isRequired();
102  //StoreArray<RawARICH> rawdata;
103  //rawdata.isRequired();
104  }
105 
107  {
108  StoreObjPtr<EventMetaData> evtmetadata;
109  //int expno = evtmetadata->getExperiment();
110  int runno = evtmetadata->getRun();
111  if (runno == 100 && !m_internalmode) {
112  terminate();
113  }
114  }
115 
117  {
118  StoreObjPtr<EventMetaData> evtmetadata;
119  StoreObjPtr<ARICHInfo> arichinfo;
120  if (!arichinfo->getthscan_mode()) return;
121  double vth_thscan = arichinfo->getvth_thscan();
122 
123  //int runno = m_internalmode ? m_run_count : evtmetadata->getRun();
124  //int raw_evtno = m_internalmode ? m_evt_count : evtmetadata->getEvent();
125  int runno = evtmetadata->getRun();
126  //int raw_evtno = evtmetadata->getEvent();
127 
128  ARICHThParam param(runno, m_dth, m_th0, m_nrun);
129  StoreArray<ARICHRawDigit> rawdigits;
130  for (auto& rawdigit : rawdigits) {
131  const int mrgid = rawdigit.getBoardId();
132  //const int nfebs = rawdigit.getNFEBs();
133  //B2INFO("MB="<<mrgid<<" nfeb="<<nfebs);
134  std::vector<ARICHRawDigit::FEBDigit>& febs(rawdigit.getFEBs());
135  for (auto& feb : febs) {
136  const int febno = feb.febno;
137  std::vector<ARICHRawDigit::FEBDigit::ChannelDigit>& channels(feb());
138  for (auto& channel : channels) {
139  if (channel.val > 0) {
140  //B2INFO("MB="<<mrgid<<" ch="<< channel.chno);
141  double vth = m_internalmode ? vth_thscan * 1000 : param.getVth() * 1000 ;
142  h_rate2D[mrgid]->Fill(channel.chno + febno * 144, vth);
143  }
144  }
145  }
146  }
147 
148  // evt,run counter for internal thscan mode
149  m_evt_count++;
150  if (m_evt_count == m_nevents) {
151  m_evt_count = 0;
152  m_run_count++;
153  }
154 
155  }
156 
157 
159  {
160  }
161 
163  {
164  }
165 
166 
168 } // end Belle2 namespace
ARICHThParam class for storing photon hit information.
Definition: ARICHThParam.h:26
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
Definition: HistoModule.h:29
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
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:95
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
virtual void endRun() override
End-of-run action.
virtual void terminate() override
Termination action.
virtual void beginRun() override
Called when entering a new run.
virtual ~ARICHRateCalModule()
Destructor.
virtual void defineHisto() override
Function to define histograms.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#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.