Belle II Software development
TrgEclDatabaseImporter Class Reference

Database importer of TRGECL. More...

#include <TrgEclDatabaseImporter.h>

Public Member Functions

 TrgEclDatabaseImporter ()
 TrgEclDatabaseImporter Constructor.
 
virtual ~TrgEclDatabaseImporter ()
 TrgEclDatabaseImporter Destructor.
 
void setRunNumber (int start, int end)
 Set Run Number.
 
void setExpNumber (int start, int end)
 Set Experiment Number.
 
void importFAMParameter (std::string, std::string, std::string)
 Import FAM Parameters.
 
void importFAMTCADCThreshold (std::string)
 Import FAM TC ADC Threshold.
 
void importTMMParameter (std::string)
 Import TMM Parameters.
 
void importETMParameter (std::string)
 Import ETM Parameters.
 
void importBadRunNumber (std::string)
 Import Bad Run Number.
 
void printTCThreshold ()
 Print TC energy Threshold.
 

Private Attributes

const int c_NTC = 576
 the number of total TC
 
int m_startExp
 Start Experiment Number.
 
int m_startRun
 Start Run Number.
 
int m_endExp
 End Experiment Number.
 
int m_endRun
 End Run Number.
 

Detailed Description

Database importer of TRGECL.

Definition at line 22 of file TrgEclDatabaseImporter.h.

Constructor & Destructor Documentation

◆ TrgEclDatabaseImporter()

TrgEclDatabaseImporter Constructor.

Definition at line 37 of file TrgEclDatabaseImporter.cc.

37 :
38 m_startExp(0), m_startRun(0), m_endExp(-1), m_endRun(-1)
39{}
int m_startExp
Start Experiment Number.
int m_endExp
End Experiment Number.

◆ ~TrgEclDatabaseImporter()

virtual ~TrgEclDatabaseImporter ( )
inlinevirtual

TrgEclDatabaseImporter Destructor.

Definition at line 29 of file TrgEclDatabaseImporter.h.

29{}

Member Function Documentation

◆ importBadRunNumber()

void importBadRunNumber ( std::string InputFileName)

Import Bad Run Number.

Definition at line 311 of file TrgEclDatabaseImporter.cc.

312{
313 std::ifstream stream;
314 stream.open(InputFileName.c_str());
315 if (!stream) {
316 B2ERROR("openFile: " << InputFileName << " *** failed to open");
317 return;
318 }
319
320 DBImportArray<TRGECLBadRun> badrun;
321
322 int BadRunNumber;
323 while (!stream.eof()) {
324
325 stream >> BadRunNumber ;
326 badrun.appendNew(BadRunNumber);
327 }
328 stream.close();
329
330 //Import to DB
331 IntervalOfValidity iov(m_startExp, m_startRun, m_endExp, m_endRun);
332
333 badrun.import(iov);
334
335 B2RESULT("BadRunList are imported to database.");
336
337}
T * appendNew()
Construct a new T object at the end of the array.
bool import(const IntervalOfValidity &iov)
Import the object to database.

◆ importETMParameter()

void importETMParameter ( std::string InputFileName)

Import ETM Parameters.

Definition at line 252 of file TrgEclDatabaseImporter.cc.

253{
254
255 std::ifstream stream;
256 stream.open(InputFileName.c_str());
257 if (!stream) {
258 B2ERROR("openFile: " << InputFileName << " *** failed to open");
259 return;
260 }
261
262 // get data from InputFileName
263 std::vector<string> v_par_name;
264 std::vector<double> v_par_value;
265 string str_line;
266 int cnt_par = 0;
267 while (getline(stream, str_line)) {
268 if (str_line.find("#")) {
269 std::stringstream sss;
270 sss << str_line;
271 int tmp_id;
272 char tmp_name[100];
273 double tmp_value;
274 if (sscanf(sss.str().data(),
275 "%i%99s%lf",
276 &tmp_id, tmp_name, &tmp_value) == 3) {
277 string str_tmp_name = string(tmp_name);
278 v_par_name.push_back(str_tmp_name);
279 v_par_value.push_back(tmp_value);
280 cnt_par++;
281 }
282 }
283 }
284 stream.close();
285
286 B2INFO("[TrgEclDatabaseImporter] The number of parameters in "
287 << InputFileName
288 << " = "
289 << cnt_par);
290
291 DBImportObjPtr<TRGECLETMParameters> etmpara;
292 etmpara.construct();
293
294 etmpara->setnpar(cnt_par);
295
296 for (int iii = 0; iii < cnt_par; iii++) {
297 etmpara->setparMap(v_par_name[iii], v_par_value[iii]);
298 }
299
300 //Import to DB
301 IntervalOfValidity iov(m_startExp, m_startRun, m_endExp, m_endRun);
302
303 etmpara.import(iov);
304
305 B2RESULT("ETM Parameters are imported to database.");
306
307}
void construct(Args &&... params)
Construct an object of type T in this DBImportObjPtr using the provided constructor arguments.

◆ importFAMParameter()

void importFAMParameter ( std::string InputFileName,
std::string InputFileSignalPDF,
std::string InputFileNoise )

Import FAM Parameters.

Definition at line 41 of file TrgEclDatabaseImporter.cc.

44{
45 std::ifstream stream;
46 stream.open(InputFileName.c_str());
47 if (!stream) {
48 B2ERROR("openFile: " << InputFileName << " *** failed to open");
49 return;
50 }
51 std::ifstream stream1;
52 stream1.open(InputFileSignalPDF.c_str());
53 if (!stream1) {
54 B2ERROR("openFile: " << InputFileSignalPDF << " *** failed to open");
55 return;
56 }
57
58 std::ifstream stream2;
59 stream2.open(InputFileNoise.c_str());
60 if (!stream2) {
61 B2ERROR("openFile: " << InputFileNoise << " *** failed to open");
62 return;
63 }
64
65 TrgEclMapping* m_map = new TrgEclMapping();
66
67 DBImportArray<TRGECLFAMPara> fampara;
68 // fampara.construct();
69
70 std::vector<int> FPGAversion;
71 std::vector<int> TCId;
72 std::vector<int> FAMId;
73 std::vector<int> ChannelId;
74 std::vector<int> TEreconstruction;
75 std::vector<int> Threshold;
76 std::vector<double> Conversionfactor;
77 std::vector<int> Toffset;
78 std::vector<int> Wavemean;
79 std::vector<int> Wavesigma;
80 FPGAversion.clear();
81 TCId.clear();
82 FAMId.clear();
83 ChannelId.clear();
84 TEreconstruction.clear();
85 Threshold.clear();
86 Conversionfactor.clear();
87 Toffset.clear();
88 Wavemean.clear();
89 Wavesigma.clear();
90
91 FPGAversion.resize(624, 0);
92 TCId.resize(624, 0);
93 FAMId.resize(624, 0);
94 ChannelId.resize(624, 0);
95 TEreconstruction.resize(624, 0);
96 Threshold.resize(624, 0);
97 Conversionfactor.resize(624, 0);
98 Toffset.resize(624, 0);
99
100 Wavemean.resize(624, 0);
101 Wavesigma.resize(624, 0);
102
103
104 std::vector<std::vector<double> > SignalPDF;
105 SignalPDF.clear();
106 std::vector<std::vector<double> > NoiseCovarianceMatrix;
107 NoiseCovarianceMatrix.clear();
108 SignalPDF.resize(624, std::vector<double>(8, 0));
109 NoiseCovarianceMatrix.resize(624, std::vector<double>(78, 0));
110
111 int Id = 0;
112 while (!stream.eof()) {
113 stream >> FAMId[Id]
114 >> ChannelId[Id]
115 >> FPGAversion [Id]
116 >> TEreconstruction[Id]
117 >> Threshold[Id]
118 >> Conversionfactor[Id]
119 >> Toffset[Id]
120 >> Wavemean[Id]
121 >> Wavesigma[Id];
122 TCId[Id] = m_map->getTCIdFromFAMChannel(FAMId[Id], ChannelId[Id]);
123 Id++;
124 if (Id == 624) {
125 break;
126 }
127 }
128 stream.close();
129 //-----------------------------------------------------------------
130
131 Id = 0;
132 int line = 0;
133
134 while (!stream1.eof()) {
135 stream1 >> SignalPDF[Id][line];
136 line++;
137 if (line == 8) {
138 line = 0;
139 Id++;
140 }
141
142 }
143 stream1.close();
144
145 Id = 0;
146 line = 0;
147 while (!stream2.eof()) {
148 stream2 >> NoiseCovarianceMatrix[Id][line];
149 line++;
150 if (line == 78) {
151 line = 0;
152 Id++;
153 }
154
155 }
156 stream2.close();
157
158
159 //Import to DB
160 for (int iTCId = 0; iTCId < 624; iTCId++) {
161 fampara.appendNew(FPGAversion[iTCId],
162 TCId[iTCId],
163 FAMId[iTCId],
164 ChannelId[iTCId],
165 TEreconstruction[iTCId],
166 Conversionfactor[iTCId],
167 Toffset[iTCId],
168 Threshold[iTCId],
169 Wavemean[iTCId],
170 Wavesigma[iTCId],
171 SignalPDF[iTCId],
172 NoiseCovarianceMatrix[iTCId]
173 );
174 }
175
176 IntervalOfValidity iov(m_startExp, m_startRun, m_endExp, m_endRun);
177
178 fampara.import(iov);
179
180 delete m_map ;
181 B2RESULT("FAM parameters are imported to database.");
182
183}
int getTCIdFromFAMChannel(int, int)
Get TC from FAM # and Channel #.

◆ importFAMTCADCThreshold()

void importFAMTCADCThreshold ( std::string InputFileName)

Import FAM TC ADC Threshold.

Definition at line 187 of file TrgEclDatabaseImporter.cc.

188{
189 std::ifstream stream;
190 stream.open(InputFileName.c_str());
191 if (!stream) {
192 B2ERROR("openFile: " << InputFileName << " *** failed to open");
193 return;
194 }
195
196 DBImportArray<TRGECLFAMTCADCThreshold> DbTCADCThreshold;
197
198 // parameters to be imported to conditionDB
199 std::vector<int> TCId(c_NTC, 0);
200 std::vector<int> TCADCThreshold(c_NTC, 0);
201
202 int id = 0;
203 while (!stream.eof()) {
204 stream >> TCId[id]
205 >> TCADCThreshold[id];
206 id++;
207 }
208 stream.close();
209
210 //Import to DB
211 for (int iTCId = 0; iTCId < c_NTC; iTCId++) {
212 DbTCADCThreshold.appendNew(TCId[iTCId],
213 TCADCThreshold[iTCId]);
214 }
215
216 IntervalOfValidity iov(m_startExp, m_startRun, m_endExp, m_endRun);
217
218 DbTCADCThreshold.import(iov);
219
220 B2RESULT("FAM TCADCThresholds are imported to database.");
221
222}
const int c_NTC
the number of total TC

◆ importTMMParameter()

void importTMMParameter ( std::string InputFileName)

Import TMM Parameters.

Definition at line 226 of file TrgEclDatabaseImporter.cc.

227{
228 std::ifstream stream;
229 stream.open(InputFileName.c_str());
230 if (!stream) {
231 B2ERROR("openFile: " << InputFileName << " *** failed to open");
232 return;
233 }
234
235 DBImportArray<TRGECLTMMPara> tmmpara;
236
237 int FPGAversion;
238 stream >> FPGAversion ;
239 tmmpara.appendNew(FPGAversion);
240 stream.close();
241 //Import to DB
242 IntervalOfValidity iov(m_startExp, m_startRun, m_endExp, m_endRun);
243
244 tmmpara.import(iov);
245
246 B2RESULT("TMM parameters are imported to database.");
247
248}

◆ printTCThreshold()

void printTCThreshold ( )

Print TC energy Threshold.

Definition at line 341 of file TrgEclDatabaseImporter.cc.

342{
343
344 DBObjPtr<TRGECLFAMPara> para ;
345
346 para->Dump();
347
348}

◆ setExpNumber()

void setExpNumber ( int start,
int end )
inline

Set Experiment Number.

Definition at line 37 of file TrgEclDatabaseImporter.h.

38 {
39 m_startExp = start;
40 m_endExp = end;
41 }

◆ setRunNumber()

void setRunNumber ( int start,
int end )
inline

Set Run Number.

Definition at line 31 of file TrgEclDatabaseImporter.h.

32 {
33 m_startRun = start;
34 m_endRun = end;
35 }

Member Data Documentation

◆ c_NTC

const int c_NTC = 576
private

the number of total TC

Definition at line 61 of file TrgEclDatabaseImporter.h.

◆ m_endExp

int m_endExp
private

End Experiment Number.

Definition at line 67 of file TrgEclDatabaseImporter.h.

◆ m_endRun

int m_endRun
private

End Run Number.

Definition at line 69 of file TrgEclDatabaseImporter.h.

◆ m_startExp

int m_startExp
private

Start Experiment Number.

Definition at line 63 of file TrgEclDatabaseImporter.h.

◆ m_startRun

int m_startRun
private

Start Run Number.

Definition at line 65 of file TrgEclDatabaseImporter.h.


The documentation for this class was generated from the following files: