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