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