Belle II Software  release-08-01-10
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 header.
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 namespace Belle2 {
36  //-----------------------------------------------------------------
37  // Register module
38  //-----------------------------------------------------------------
39 
40  REG_MODULE(ARICHRateCal);
41 
42  //-----------------------------------------------------------------
43  // Implementation
44  //-----------------------------------------------------------------
45 
47  {
48  // set module description (e.g. insert text)
49  setDescription("Fills ARICHHits collection from ARICHDigits");
51  addParam("nrun", m_nrun, "# of scan runs", 100);
52  addParam("nevents", m_nevents, "# of events per run", 1000);
53  double v = 0;
54  addParam("dth", m_dth, "dth", v);
55  addParam("th0", m_th0, "th0", v);
56  addParam("debug", m_debugmode, "debug mode", false);
57  addParam("internal", m_internalmode, "Internal thscan mode", false);
58  addParam("daqdb", m_daqdb, "daqdb config name", std::string(""));
59  }
60 
62  {
63  }
64 
66  {
67  /*
68  if (m_daqdb.size() > 0) {
69  ConfigFile config("slowcontrol");
70  PostgreSQLInterface db(config.get("database.host"),
71  config.get("database.dbname"),
72  config.get("database.user"),
73  config.get("database.password"),
74  config.getInt("database.port"));
75  DBObject obj = DBObjectLoader::load(db, "arich_th",
76  StringUtil::replace(m_daqdb, ".", ":"));
77  obj.print();
78  m_dth = obj.getFloat("dth");
79  m_th0 = obj.getFloat("th0");
80  m_nrun = obj.getInt("nth");
81  db.close();
82  }
83  */
84 
85  if (m_dth == 0) {
86  B2WARNING("dth is set to 0");
87  }
88  for (int i = 0; i < 100; i++) {
89  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,
90  m_nrun, (m_th0 - 0.5 * m_dth) * 1000, (m_th0 + (m_nrun - 0.5)*m_dth) * 1000);
91  }
92  }
93 
95  {
96 
97  REG_HISTOGRAM
99  rawdata.isRequired();
100  //StoreArray<RawARICH> rawdata;
101  //rawdata.isRequired();
102  }
103 
105  {
106  StoreObjPtr<EventMetaData> evtmetadata;
107  //int expno = evtmetadata->getExperiment();
108  int runno = evtmetadata->getRun();
109  if (runno == 100 && !m_internalmode) {
110  terminate();
111  }
112  }
113 
115  {
116  StoreObjPtr<EventMetaData> evtmetadata;
117  StoreObjPtr<ARICHInfo> arichinfo;
118  if (!arichinfo->getthscan_mode()) return;
119  double vth_thscan = arichinfo->getvth_thscan();
120 
121  //int runno = m_internalmode ? m_run_count : evtmetadata->getRun();
122  //int raw_evtno = m_internalmode ? m_evt_count : evtmetadata->getEvent();
123  int runno = evtmetadata->getRun();
124  //int raw_evtno = evtmetadata->getEvent();
125 
126  ARICHThParam param(runno, m_dth, m_th0, m_nrun);
127  StoreArray<ARICHRawDigit> rawdigits;
128  for (auto& rawdigit : rawdigits) {
129  const int mrgid = rawdigit.getBoardId();
130  //const int nfebs = rawdigit.getNFEBs();
131  //B2INFO("MB="<<mrgid<<" nfeb="<<nfebs);
132  std::vector<ARICHRawDigit::FEBDigit>& febs(rawdigit.getFEBs());
133  for (auto& feb : febs) {
134  const int febno = feb.febno;
135  std::vector<ARICHRawDigit::FEBDigit::ChannelDigit>& channels(feb());
136  for (auto& channel : channels) {
137  if (channel.val > 0) {
138  //B2INFO("MB="<<mrgid<<" ch="<< channel.chno);
139  double vth = m_internalmode ? vth_thscan * 1000 : param.getVth() * 1000 ;
140  h_rate2D[mrgid]->Fill(channel.chno + febno * 144, vth);
141  }
142  }
143  }
144  }
145 
146  // evt,run counter for internal thscan mode
147  m_evt_count++;
148  if (m_evt_count == m_nevents) {
149  m_evt_count = 0;
150  m_run_count++;
151  }
152 
153  }
154 
156 } // 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
virtual void terminate() override
Function to terminate module.
Definition: HistoModule.h:46
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:96
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
virtual void beginRun() override
Called when entering a new run.
REG_MODULE(arichBtest)
Register the Module.
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
Abstract base class for different kinds of events.