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