Belle II Software development
ARICHDatabaseImporter.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#include <arich/calibration/ARICHDatabaseImporter.h>
10#include <arich/calibration/ARICHDatabaseTools.h>
11#include <arich/dbobjects/ARICHAerogelMap.h>
12#include <arich/dbobjects/ARICHAerogelInfo.h>
13#include <arich/dbobjects/ARICHAerogelRayleighScatteringFit.h>
14#include <arich/dbobjects/ARICHAsicInfo.h>
15#include <arich/dbobjects/ARICHHapdQA.h>
16#include <arich/dbobjects/ARICHFebTest.h>
17#include <arich/dbobjects/ARICHHapdChipInfo.h>
18#include <arich/dbobjects/ARICHHapdInfo.h>
19#include <arich/dbobjects/ARICHHapdQE.h>
20#include <arich/dbobjects/ARICHMagnetTest.h>
21#include <arich/dbobjects/ARICHModuleTest.h>
22#include <arich/dbobjects/ARICHSensorModuleInfo.h>
23#include <arich/dbobjects/ARICHSensorModuleMap.h>
24#include <arich/dbobjects/ARICHBiasCablesMapping.h>
25#include <arich/dbobjects/ARICHBiasChannelsMapping.h>
26#include <arich/dbobjects/ARICHBiasVoltages.h>
27#include <arich/dbobjects/ARICHBiasCrateCableMapping.h>
28#include <arich/dbobjects/ARICHHvCablesMapping.h>
29#include <arich/dbobjects/ARICHHvChannelsMapping.h>
30#include <arich/dbobjects/ARICHHvCrateCableMapping.h>
31// database classes used by simulation/reconstruction software
32#include <arich/dbobjects/ARICHChannelMask.h>
33#include <arich/dbobjects/ARICHChannelMapping.h>
34#include <arich/dbobjects/ARICHModulesInfo.h>
35#include <arich/dbobjects/ARICHMergerMapping.h>
36#include <arich/dbobjects/ARICHCopperMapping.h>
37#include <arich/dbobjects/ARICHSimulationPar.h>
38#include <arich/dbobjects/ARICHReconstructionPar.h>
39#include <arich/dbobjects/ARICHGeometryConfig.h>
40#include <arich/dbobjects/ARICHAeroTilesInfo.h>
41#include <arich/dbobjects/ARICHGlobalAlignment.h>
42#include <arich/dbobjects/ARICHMirrorAlignment.h>
43#include <arich/dbobjects/ARICHPositionElement.h>
44#include <arich/dbobjects/ARICHAeroTilesAlignment.h>
45#include <arich/dbobjects/ARICHGeoMergerCooling.h>
46
47// channel histogram
48#include <arich/utility/ARICHChannelHist.h>
49#include <arich/utility/ARICHAerogelHist.h>
50
51#include <framework/gearbox/GearDir.h>
52#include <framework/gearbox/Unit.h>
53#include <framework/logging/Logger.h>
54#include <framework/database/EventDependency.h>
55
56#include <framework/database/IntervalOfValidity.h>
57#include <framework/database/Database.h>
58#include <framework/database/DBArray.h>
59#include <framework/database/DBObjPtr.h>
60#include <framework/database/DBImportObjPtr.h>
61
62#include <TH1.h>
63#include <TH2.h>
64#include <TH3.h>
65#include <TGraph.h>
66#include <TGraph2D.h>
67#include <TFile.h>
68#include <TKey.h>
69#include <TString.h>
70#include <string>
71#include <vector>
72#include <map>
73#include <fstream>
74#include <iostream>
75#include <TClonesArray.h>
76#include <TTree.h>
77#include <tuple>
78#include <iomanip>
79
80using namespace std;
81using namespace Belle2;
82
83ARICHDatabaseImporter::ARICHDatabaseImporter(const vector<string>& inputFilesHapdQA, const vector<string>& inputFilesAsicRoot,
84 const vector<string>& inputFilesAsicTxt, const vector<string>& inputFilesHapdQE, const vector<string>& inputFilesFebTest)
85{
86 m_inputFilesHapdQA.reserve(inputFilesHapdQA.size());
87 m_inputFilesAsicRoot.reserve(inputFilesAsicRoot.size());
88 m_inputFilesAsicTxt.reserve(inputFilesAsicTxt.size());
89 m_inputFilesHapdQE.reserve(inputFilesHapdQE.size());
90 m_inputFilesFebTest.reserve(inputFilesFebTest.size());
91 for (unsigned int i = 0; i < inputFilesHapdQA.size(); i++) { m_inputFilesHapdQA.push_back(inputFilesHapdQA[i]); }
92 for (unsigned int i = 0; i < inputFilesAsicRoot.size(); i++) { m_inputFilesAsicRoot.push_back(inputFilesAsicRoot[i]); }
93 for (unsigned int i = 0; i < inputFilesAsicTxt.size(); i++) { m_inputFilesAsicTxt.push_back(inputFilesAsicTxt[i]); }
94 for (unsigned int i = 0; i < inputFilesHapdQE.size(); i++) { m_inputFilesHapdQE.push_back(inputFilesHapdQE[i]); }
95 for (unsigned int i = 0; i < inputFilesFebTest.size(); i++) { m_inputFilesFebTest.push_back(inputFilesFebTest[i]); }
96 m_iov = IntervalOfValidity(0, 0, -1, -1);
97}
98
100{
102 meta->setRun(run); meta->setExperiment(experiment);
103 B2INFO("Experiment " << experiment << ", run " << run);
104 m_iov = IntervalOfValidity(0, 0, -1, -1);
105}
106
107void ARICHDatabaseImporter::SetIOV(int experimentLow, int runLow, int experimentHigh, int runHigh)
108{
109 m_iov = IntervalOfValidity(experimentLow, runLow, experimentHigh, runHigh);
110}
111
112
114{
116 meta->setRun(run); meta->setExperiment(experiment);
117 B2INFO("Experiment " << experiment << ", run " << run);
118}
119
120// classses for simulation/reconstruction software
122{
123
124 // geometry configuration
126
127 // QE 2D maps from DB
128 DBArray<ARICHHapdQE> QEMaps("ARICHHapdQE");
129
130 ARICHModulesInfo modInfo;
131
132 // channel mapping used in QA tests (QE measurements, etc.)
133 ARICHChannelMapping QAChMap;
134
135 // read mapping from xml file
136 GearDir content = GearDir("/Detector/DetectorComponent[@name='ARICH']/Content/ChannelMapping");
137 istringstream chstream;
138 int x, y, asic;
139 chstream.str(content.getString("QAChannelMapping"));
140 while (chstream >> x >> y >> asic) {
141 QAChMap.mapXY2Asic(x, y, asic);
142 }
143
144 // get list of installed modules from xml
145 GearDir installedModules = GearDir("/Detector/DetectorComponent[@name='ARICH']/Content/InstalledModules");
146 B2INFO("Installed modules\n");
147
148 std::vector<std::string> installed;
149
150 for (const GearDir& module : installedModules.getNodes("Module")) {
151 std::string hapdID = module.getString("@hapdID");
152
153 unsigned sector = module.getInt("Sector");
154 unsigned ring = module.getInt("Ring");
155 unsigned azimuth = module.getInt("Azimuth");
156 bool isActive = (bool)module.getInt("isActive");
157 B2INFO(" " << hapdID << ": S " << sector << " R " << ring << " Z " << azimuth << ", isActive: " << isActive << '\n');
158
159 if (std::find(installed.begin(), installed.end(), hapdID) != installed.end()) {
160 B2WARNING("ARICHDatabaseImporter::importModulesInfo: hapd " << hapdID << " installed multiple times!");
161 } else installed.push_back(hapdID);
162
163 unsigned moduleID = geoConfig->getDetectorPlane().getSlotIDFromSRF(sector, ring, azimuth);
164
165 // get and set QE map
166 std::vector<float> qs;
167 qs.assign(144, 0);
168 bool init = false;
169 for (const auto& QEMap : QEMaps) {
170 if (hapdID == QEMap.getHapdSerialNumber()) {
171 TH2F* qe2d = QEMap.getQuantumEfficiency2D();
172 for (int k = 1; k < 13; k++) {
173 for (int l = 1; l < 13; l++) {
174 int asicCh = QAChMap.getAsicFromXY(k - 1, l - 1);
175 qs[asicCh] = qe2d->GetBinContent(k, l);
176 }
177 }
178 init = true;
179 B2INFO(" Channels QE map found and set.\n");
180 }
181 }
182
183 if (!init) {
184 for (int k = 0; k < 144; k++) {
185 qs[k] = 27.0;
186 }
187 B2WARNING("ARICHDatabaseImporter::importModulesInfo: QE map for hapd " << hapdID << " not found! Setting 27% QE for all channels!");
188 }
189
190 modInfo.addModule(moduleID, qs, isActive);
191
192 }
193
195 importObj.construct(modInfo);
196 importObj.import(m_iov);
197
198}
199
201{
202
203 GearDir content = GearDir("/Detector/DetectorComponent[@name='ARICH']/Content");
204 GearDir alignPars(content, "GlobalAlignment");
205 ARICHGlobalAlignment arichAlign;
206 ARICHPositionElement alignel(alignPars.getLength("x"), alignPars.getLength("y"), alignPars.getLength("z"),
207 alignPars.getAngle("alpha"), alignPars.getAngle("beta"), alignPars.getAngle("gamma"));
208 arichAlign.setAlignmentElement(alignel);
209
211 importObj.construct(arichAlign);
212 importObj.import(m_iov);
213}
214
215
217{
218
219 GearDir content = GearDir("/Detector/DetectorComponent[@name='ARICH']/Content");
220 GearDir alignPars(content, "MirrorAlignment");
221
223
224 ARICHMirrorAlignment mirrAlign;
225
226 for (auto plate : alignPars.getNodes("Plate")) {
227 int id = plate.getInt("@id");
228 double r = plate.getLength("r");
229 double phi = plate.getAngle("phi");
230 double z = plate.getLength("z");
231 double alpha = plate.getLength("alpha");
232 double beta = plate.getLength("beta");
233 double gamma = plate.getLength("gamma");
234 double origPhi = geoConfig->getMirrors().getPoint(id).Phi();
235 ARICHPositionElement alignEl(r * cos(origPhi + phi), r * sin(origPhi + phi), z, alpha, beta, gamma);
236 mirrAlign.setAlignmentElement(id, alignEl);
237 alignEl.print();
238 }
239
241 importObj.construct(mirrAlign);
242 importObj.import(m_iov);
243
244}
245
247{
248
249 GearDir content = GearDir("/Detector/DetectorComponent[@name='ARICH']/Content");
250 GearDir alignPars(content, "AeroTilesAlignment");
251
252 ARICHAeroTilesAlignment tileAlign;
253
254 for (auto tile : alignPars.getNodes("Slot")) {
255 int id = tile.getInt("@id");
256 double r = tile.getLength("r");
257 double phi = tile.getAngle("phi");
258 double z = tile.getLength("z");
259 double alpha = tile.getLength("alpha");
260 double beta = tile.getLength("beta");
261 double gamma = tile.getLength("gamma");
262 ARICHPositionElement alignEl(r * cos(phi), r * sin(phi), z, alpha, beta, gamma);
263 tileAlign.setAlignmentElement(id, alignEl);
264 alignEl.print();
265 }
266
268 importObj.construct(tileAlign);
269 importObj.import(m_iov);
270
271}
272
273
275{
276
278
279 // module test results from DB (we take list of dead channels from here)
280 DBArray<ARICHModuleTest> moduleTest("ARICHModuleTestHV");
281
282 ARICHChannelMask chanMask;
283
284 // loop over installed modules (from xml file)
285 GearDir content = GearDir("/Detector/DetectorComponent[@name='ARICH']/Content/InstalledModules");
286 B2INFO("Installed modules\n");
287 for (const GearDir& module : content.getNodes("Module")) {
288 std::string hapdID = module.getString("@hapdID");
289 unsigned sector = module.getInt("Sector");
290 unsigned ring = module.getInt("Ring");
291 unsigned azimuth = module.getInt("Azimuth");
292 bool isActive = (bool)module.getInt("isActive");
293 B2INFO(" " << hapdID << ": S " << sector << " R " << ring << " Z " << azimuth << ", isActive: " << isActive << '\n');
294 unsigned moduleID = geoConfig->getDetectorPlane().getSlotIDFromSRF(sector, ring, azimuth);
295
296 // get and set channel mask (mask dead channels)
297 bool init = false;
298 for (const auto& test : moduleTest) {
299 if (hapdID == test.getHapdSN()) {
300
301 // loop over list of dead channels
302 for (int i = 0; i < test.getDeadChsSize(); i++) {
303 unsigned asicCh = test.getDeadCh(i);
304 if (asicCh > 143)B2ERROR("ARICHDatabaseImporter::importLWClasses: Asic channel for HAPD " << hapdID << " is out of range!");
305 chanMask.setActiveCh(moduleID, asicCh, false);
306 }
307 init = true;
308 B2INFO(" List of dead channels (from module test) found and set.\n");
309 }
310 }
311
312 if (!init) {
313 B2WARNING("ARICHDatabaseImporter::importLWClasses: List of dead channels for hapd " << hapdID <<
314 " not found! All channels set to active.");
315 continue;
316 }
317 }
318
320 importObj.construct(chanMask);
321 importObj.import(m_iov);
322
323}
324
326{
327
328 ARICHGeoMergerCooling cooling;
329 GearDir mergerCoolingParams = GearDir("/Detector/DetectorComponent[@name='ARICH']/Content/mergerCoolingBodiesv2");
330
331 cooling.setMergerCoolingBodiesMaterialName(mergerCoolingParams.getString("material"));
332 //std::cout<<"Merger cooling material -> "<<mergerCoolingParams.getString("material")<<std::endl;
333 for (auto mergerCoolingNode : mergerCoolingParams.getNodes("BodiesDatFileName/Body")) {
334 //std::cout<<"@positionID = "<<mergerCoolingNode.getInt("@positionID")<<std::endl;
335 tessellatedSolidStr mergerTessellation = readTessellatedSolidVerticesFromDATfile(mergerCoolingNode.getString());
336 cooling.addMergerCoolingBodiesInfo(mergerTessellation);
337 }
338 cooling.setMergerCoolingPositionID(mergerCoolingParams.getArray("mergerCoolingPositionID"));
340
342 importObj.construct(cooling);
343 importObj.import(m_iov);
344 B2INFO("--> Mergers cooling bodies geometry imported.");
345
346}
347
348
350{
351
352 tessellatedSolidStr solidStr;
353 std::string mot;
354 std::ifstream infile(inDATfile.c_str(), std::ifstream::in);
355
356 if (infile.is_open()) {
357 double val = 0.0;
358 while (infile >> mot) {
359 if (mot == "BodyPositionID")
360 infile >> solidStr.tessellatedSolidID;
361 else
362 assert(0);
363 infile >> mot;
364 if (mot == "nCells")
365 infile >> solidStr.nCells;
366 else
367 assert(0);
368 infile >> mot;
369 if (mot == "nApexPerCell")
370 infile >> solidStr.nApexPerCell;
371 else
372 assert(0);
373
374 TString apexNamesStr[3][3] = { { "Apex_1_x", "Apex_1_y", "Apex_1_z" },
375 { "Apex_2_x", "Apex_2_y", "Apex_2_z" },
376 { "Apex_3_x", "Apex_3_y", "Apex_3_z" }
377 };
378 for (unsigned int i = 0; i < 3; i++) {
379 infile >> mot;
380 if (mot != apexNamesStr[0][i])
381 assert(0);
382 std::vector<double> valv;
383 for (unsigned int j = 0; j < solidStr.nCells; j++) {
384 infile >> val;
385 valv.push_back(val);
386 }
387 solidStr.posV1.push_back(valv);
388 }
389 //Apex_2_x, Apex_2_y, Apex_2_z
390 for (unsigned int i = 0; i < 3; i++) {
391 infile >> mot;
392 if (mot != apexNamesStr[1][i])
393 assert(0);
394 std::vector<double> valv;
395 for (unsigned int j = 0; j < solidStr.nCells; j++) {
396 infile >> val;
397 valv.push_back(val);
398 }
399 solidStr.posV2.push_back(valv);
400 }
401 //Apex_3_x, Apex_3_y, Apex_3_z
402 for (unsigned int i = 0; i < 3; i++) {
403 infile >> mot;
404 if (mot != apexNamesStr[2][i])
405 assert(0);
406 std::vector<double> valv;
407 for (unsigned int j = 0; j < solidStr.nCells; j++) {
408 infile >> val;
409 valv.push_back(val);
410 }
411 solidStr.posV3.push_back(valv);
412 }
413 }
414 infile.close();
415 } else {
416 B2WARNING("Unable to open file : " << inDATfile << " with cooling bodies geometry.");
417 }
418 return solidStr;
419}
420
422{
423 if (h == NULL) {
424 B2ERROR("--> NULL Histogram");
425 return;
426 }
427
428 ARICHChannelMask mask;
429 int inactive = 0;
430 int numChannels = h->GetNbinsX();
431 const int NumberOfChannelsPerHapd = 144;
432 const int NumberOfHapds = 420;
433
434 if (numChannels != NumberOfHapds * NumberOfChannelsPerHapd) {
435 B2ERROR("There should be " << NumberOfHapds * NumberOfChannelsPerHapd << " in the histogram!");
436 return;
437 }
438
439 for (int bin = 1; bin <= numChannels; ++bin) {
440 int moduleID = (bin - 1) / NumberOfChannelsPerHapd + 1;
441 int channelID = (bin - 1) % NumberOfChannelsPerHapd;
442 bool value = (h->GetBinContent(bin) > 0);
443 if (!value) inactive++;
444 //B2INFO("--> moduleID " << moduleID << " channelID " << channelID << " ACTIVE:" << inactive);
445
446 mask.setActiveCh(moduleID, channelID, value);
447 }
448
450 importObj.construct(mask);
451 importObj.import(m_iov);
452 B2INFO("--> Channel Mask imported. Number of disabled channels=" << inactive << " Number of all channels=" << numChannels);
453}
454
455
456
458{
460 recPar.initializeDefault();
461
463 importObj.construct(recPar);
464 importObj.import(m_iov);
465
466}
467
469{
470
471 ARICHSimulationPar simPar;
472
473 GearDir content = GearDir("/Detector/DetectorComponent[@name='ARICH']/Content/SimulationParameters");
474
475 double qeScale = content.getDouble("qeScale");
476 double winAbs = content.getDouble("windowAbsorbtion");
477 double crossTalk = content.getDouble("chipNegativeCrosstalk");
478 double colEff = content.getDouble("colEff");
479
480 GearDir qeParams(content, "QE");
481 float lambdaFirst = qeParams.getLength("LambdaFirst") / Unit::nm;
482 float lambdaStep = qeParams.getLength("LambdaStep") / Unit::nm;
483 double peakQE = qeParams.getDouble("peakQE");
484
485 std::vector<float> qes;
486 for (const auto& qeff : qeParams.getNodes("Qeffi")) {
487 qes.push_back(qeff.getDouble("qe"));
488 }
489
490 simPar.setQECurve(lambdaFirst, lambdaStep, qes);
491 simPar.setCollectionEff(colEff);
492 simPar.setChipNegativeCrosstalk(crossTalk);
493 simPar.setWindowAbsorbtion(winAbs);
494 simPar.setQEScaling(qeScale);
495 simPar.setPeakQE(peakQE);
496
497 simPar.print();
498
500 importObj.construct(simPar);
501 importObj.import(m_iov);
502
503}
504
506{
507 GearDir content = GearDir("/Detector/DetectorComponent[@name='ARICH']/Content");
509
510 istringstream chstream;
511 int x, y, asic;
512 chstream.str(content.getString("ChannelMapping/SoftChannelMapping"));
513
514 B2INFO("Importing channel x,y to asic channel map\n");
515 B2INFO(" x y asic\n");
516 while (chstream >> x >> y >> asic) {
517 chMap.mapXY2Asic(x, y, asic);
518 B2INFO(" " << setw(2) << x << " " << setw(2) << y << " " << setw(3) << asic << '\n');
519 }
520
522 importObjMap.construct(chMap);
523 importObjMap.import(m_iov);
524
525}
526
528{
529
530 GearDir content = GearDir("/Detector/DetectorComponent[@name='ARICH']/Content");
531
533
534 ARICHMergerMapping mergerMap;
535 ARICHCopperMapping copperMap;
536 GearDir mapping(content, "FrontEndMapping");
537
538 for (const GearDir& merger : mapping.getNodes("Merger")) {
539 unsigned mergerID = (unsigned) merger.getInt("@id");
540 unsigned mergerSN = (unsigned) merger.getInt("@sn");
541 B2INFO('\n' << "Mapping of modules to merger no. " << mergerID << ", SN = " << mergerSN << '\n');
542 for (const GearDir& module : merger.getNodes("Modules/Module")) {
543 unsigned sector = module.getInt("Sector");
544 unsigned ring = module.getInt("Ring");
545 unsigned azimuth = module.getInt("Azimuth");
546 std::cout << "ring = " << ring << '\n';
547 unsigned moduleID = geoConfig->getDetectorPlane().getSlotIDFromSRF(sector, ring, azimuth);
548 std::cout << "moduleID = " << moduleID << '\n';
549 unsigned slot = (unsigned) module.getInt("@FEBSlot");
550 mergerMap.addMapping(moduleID, mergerID, slot, mergerSN);
551 std::cout << '\n' << " FEB slot: " << slot << ", module position: S" << sector << " R" << ring << " Z" << azimuth <<
552 ", module ID: " << moduleID << '\n';
553 std::cout << " crosscheck: mergerMap.getMergerID(" << moduleID << ") = " << mergerMap.getMergerID(
554 moduleID) << ", mergerMap.getFEBSlot(" << moduleID << ") = " << mergerMap.getFEBSlot(moduleID) << ", mergerMap.getModuleID(" <<
555 mergerID << "," << slot << ") = " << mergerMap.getModuleID(mergerID, slot) << '\n';
556
557 }
558 std::cout << '\n';
559
560 unsigned copperID = (unsigned) merger.getInt("COPPERid");
561 string finesseSlot = merger.getString("FinesseSlot");
562 int finesse = 0;
563 if (finesseSlot == "A") {finesse = 0;}
564 else if (finesseSlot == "B") {finesse = 1;}
565 else if (finesseSlot == "C") {finesse = 2;}
566 else if (finesseSlot == "D") {finesse = 3;}
567 else {
568 B2ERROR(merger.getPath() << "/FinesseSlot " << finesseSlot <<
569 " ***invalid slot (valid are A, B, C, D)");
570 continue;
571 }
572 copperMap.addMapping(mergerID, copperID, finesse);
573 std::cout << "Merger " << mergerID << " connected to copper " << copperID << ", finesse " << finesse << '\n';
574
575 }
576
578 importObjMerger.construct(mergerMap);
579 importObjMerger.import(m_iov);
580
582 importObjCopper.construct(copperMap);
583 importObjCopper.import(m_iov);
584
585}
586
588{
589
590 GearDir content = GearDir("/Detector/DetectorComponent[@name='ARICH']/Content");
591 ARICHGeometryConfig arichGeometryConfig(content);
592
594 importObj.construct(arichGeometryConfig);
595 importObj.import(m_iov);
596
597}
598
600{
601 GearDir content = GearDir("/Detector/DetectorComponent[@name='ARICH']/Content");
602 GearDir cosmic(content, "CosmicTest");
604
606 geoImport.construct(*geoConfig);
607
608 ARICHGeometryConfig& geo = (ARICHGeometryConfig&)geoImport;
609
610 GearDir masterDir(cosmic, "MasterVolume");
612 master.setPlacement(masterDir.getLength("Position/x"), masterDir.getLength("Position/y"), masterDir.getLength("Position/z"),
613 masterDir.getAngle("Rotation/x"), masterDir.getAngle("Rotation/y"), masterDir.getAngle("Rotation/z"));
614 master.setVolume(master.getInnerRadius(), master.getOuterRadius(), 100., master.getMaterial());
615 geo.setMasterVolume(master);
616
617
618 GearDir aerogel(cosmic, "Aerogel");
619 std::vector<double> par = {aerogel.getLength("xSize"), aerogel.getLength("ySize"), aerogel.getLength("xPosition"), aerogel.getLength("yPosition"), aerogel.getAngle("zRotation")};
621 plane.setSimple(par);
622 geo.setAerogelPlane(plane);
623
624 GearDir scints(cosmic, "Scintilators");
625 double size[3] = {scints.getLength("xSize"), scints.getLength("ySize"), scints.getLength("zSize")};
626 std::string scintMat = scints.getString("Material");
627
628 ARICHGeoSupport support = geo.getSupportStructure();
629 support.clearBoxes();
630 for (const GearDir& scint : scints.getNodes("Scintilator")) {
631 std::string name = scint.getString("@name");
632 double position[3] = {scint.getLength("Position/x"), scint.getLength("Position/y"), scint.getLength("Position/z")};
633 double rotation[3] = {scint.getAngle("Rotation/x"), scint.getAngle("Rotation/y"), scint.getAngle("Rotation/z")};
634 support.addBox(name, scintMat, size, position, rotation);
635 }
636
637 geo.setSupportStructure(support);
638
639 IntervalOfValidity iov(0, 0, -1, -1); // IOV (0,0,-1,-1) is valid for all runs and experiments
640 geoImport.import(iov);
641
642}
643
645{
646 ARICHAeroTilesInfo tilesInfo;
647
648 DBArray<ARICHAerogelMap> elements("ARICHAerogelMap");
649 elements.getEntries();
650 DBArray<ARICHAerogelInfo> elementsInfo("ARICHAerogelInfo");
651 elementsInfo.getEntries();
652
653 for (int slot = 1; slot < 125; slot++) {
656 std::string aeroID = "";
657 float refractiveIndex = 0.;
658 float transmissionLength = 0.;
659 float thickness = 0.;
660 for (int layer = 0; layer < 2; layer++) {
661 for (const auto& element : elements) {
662 if (element.getAerogelLayer(layer) == 1 && element.getAerogelRingID() == ring
663 && element.getAerogelColumnID() == column) aeroID = element.getAerogelSN();
664 }
665 for (const auto& elementInfo : elementsInfo) {
666 if (elementInfo.getAerogelSN() == aeroID) {
667 refractiveIndex = elementInfo.getAerogelRefractiveIndex();
668 transmissionLength = elementInfo.getAerogelTransmissionLength();
669 thickness = elementInfo.getAerogelThickness();
670 }
671 }
672
673 B2INFO("adding mapping... slot " << slot
674 << ", layer " << layer
675 << ", refIn " << refractiveIndex
676 << ", transLen " << transmissionLength
677 << ", thick " << thickness << '\n');
678 tilesInfo.addMapping(slot, layer, refractiveIndex, transmissionLength, thickness);
679
680 }
681 }
682
684 importObj.construct(tilesInfo);
685 importObj.import(m_iov);
686}
687
689{
690 int ring = 0;
691 if (slot < 23) ring = 1;
692 else if (slot < 51) ring = 2;
693 else if (slot < 85) ring = 3;
694 else ring = 4;
695
696 return ring;
697}
698
700{
701 int column = 0;
702 if (slot < 23) column = slot;
703 else if (slot < 51) column = slot - 22;
704 else if (slot < 85) column = slot - 50;
705 else column = slot - 84;
706
707 return column;
708}
709
710
712{
714 tilesInfo->print();
715
716 if (dump) {
718 importObj.construct(*tilesInfo);
719 importObj.import(tilesInfo.getIoV());
720 }
721}
722
724{
726 align->print();
727
728 if (dump) {
730 importObj.construct(*align);
731 importObj.import(align.getIoV());
732 }
733}
734
736{
738 align->print();
739
740 if (dump) {
742 importObj.construct(*align);
743 importObj.import(align.getIoV());
744 }
745}
746
748{
750 align->print();
751
752 if (dump) {
754 importObj.construct(*align);
755 importObj.import(align.getIoV());
756 }
757}
758
759// classes for DAQ
760
762{
763
764 GearDir content = GearDir("/DetectorCables[@name='ARICH']/Content");
765
767
769 GearDir mapping(content, "biasCableMapping");
770
771 for (const GearDir& module : mapping.getNodes("cableMap")) {
772 unsigned cableID = (unsigned) module.getInt("cableID");
773 unsigned innerID = module.getInt("innerID");
774 unsigned ring = module.getInt("ring");
775 unsigned azimuth = module.getInt("azimuth");
776 for (unsigned sector = 1; sector < 7; sector++) {
777 unsigned moduleID = geoConfig->getDetectorPlane().getSlotIDFromSRF(sector, ring, azimuth);
778 biasMap.addMapping(moduleID, sector, cableID, innerID);
779 }
780 }
781
782 ARICHBiasChannelsMapping channelsMap;
783 GearDir mappingCH(content, "biasChannelMapping");
784
785 for (const GearDir& module : mappingCH.getNodes("channelMap")) {
786 int crate = module.getInt("crate");
787 int slot = module.getInt("slot");
788 int channelID = module.getInt("channelID");
789 int pinID = module.getInt("pinID");
790 int connectionID = module.getInt("connectionID");
791 int innerID = module.getInt("innerID");
792 std::string type = module.getString("type");
793 channelsMap.addMapping(crate, slot, channelID, pinID, connectionID, innerID, type);
794 }
795
797 GearDir mappingCrate(content, "biasCrateToCable");
798
799 for (const GearDir& module : mappingCrate.getNodes("connection")) {
800 int connectionID = module.getInt("connectionID");
801 int sector = module.getInt("sector");
802 int cable = module.getInt("cable");
803 std::vector<int> sectorCable{sector, cable};
804
805 crateMap.addMapping(connectionID, sectorCable);
806 }
807
809 importObjBias.construct(biasMap);
810 importObjBias.import(m_iov);
811
813 importObjBiasCH.construct(channelsMap);
814 importObjBiasCH.import(m_iov);
815
817 importObjBiasCrate.construct(crateMap);
818 importObjBiasCrate.import(m_iov);
819}
820
822{
823
824 GearDir content = GearDir("/DetectorCables[@name='ARICH']/Content");
825
827
829 GearDir mapping(content, "hvCableToModuleMapping");
830
831 for (const GearDir& module : mapping.getNodes("cableMap")) {
832 unsigned cableID = (unsigned) module.getInt("cableID");
833 unsigned innerID = module.getInt("innerID");
834 unsigned ring = module.getInt("ring");
835 unsigned azimuth = module.getInt("azimuth");
836 for (unsigned sector = 1; sector < 7; sector++) {
837 unsigned moduleID = geoConfig->getDetectorPlane().getSlotIDFromSRF(sector, ring, azimuth);
838 hvMap.addMapping(moduleID, sector, cableID, innerID);
839 }
840 }
841
842 ARICHHvChannelsMapping channelsMap;
843 GearDir mappingCH(content, "hvChannelMapping");
844
845 for (const GearDir& module : mappingCH.getNodes("channelMap")) {
846 int crate = module.getInt("crate");
847 int slot = module.getInt("slot");
848 int channelID = module.getInt("channelID");
849 int connectionID = module.getInt("connectionID");
850 int pinID = module.getInt("pinID");
851 channelsMap.addMapping(crate, slot, channelID, connectionID, pinID);
852 }
853
855 GearDir mappingCrate(content, "hvCrateToCable");
856
857 for (const GearDir& module : mappingCrate.getNodes("connection")) {
858 int connectionID = module.getInt("connectionID");
859 int sector = module.getInt("sector");
860 int cable = module.getInt("cable");
861 std::vector<int> sectorCable{sector, cable};
862
863 crateMap.addMapping(connectionID, sectorCable);
864 }
865
867 importObjHv.construct(hvMap);
868 importObjHv.import(m_iov);
869
871 importObjHvCH.construct(channelsMap);
872 importObjHvCH.import(m_iov);
873
875 importObjHvCrate.construct(crateMap);
876 importObjHvCrate.import(m_iov);
877}
878
879
880
882{
883
884 GearDir content = GearDir("/DetectorCables[@name='ARICH']/Content");
885
887
888 ARICHBiasVoltages biasVolt;
889 GearDir biasVoltages(content, "biasVoltages");
890
891 for (const GearDir& module : biasVoltages.getNodes("hapd")) {
892 std::string hapdID = module.getString("@id");
893 int biasA = module.getInt("biasA");
894 int biasB = module.getInt("biasB");
895 int biasC = module.getInt("biasC");
896 int biasD = module.getInt("biasD");
897 int guard = module.getInt("guard");
898 std::vector<int> voltages{biasA, biasB, biasC, biasD, guard};
899 biasVolt.addVoltages(hapdID, voltages);
900 }
901
902 DBImportObjPtr<ARICHBiasVoltages> importObjBiasVolt;
903 importObjBiasVolt.construct(biasVolt);
904 importObjBiasVolt.import(m_iov);
905}
906
907
909{
911 biasMap->print();
913 channelsMap->print();
915 crateMap->print();
916
917 if (dump) {
919 importObjBias.construct(*biasMap);
920 importObjBias.import(biasMap.getIoV());
921
923 importObjBiasCH.construct(*channelsMap);
924 importObjBiasCH.import(channelsMap.getIoV());
925
927 importObjBiasCrate.construct(*crateMap);
928 importObjBiasCrate.import(crateMap.getIoV());
929 }
930}
931
933{
935 hvMap->print();
937 crateMap->print();
938
939 if (dump) {
941 importObjHv.construct(*hvMap);
942 importObjHv.import(hvMap.getIoV());
943
945 importObjHvCrate.construct(*crateMap);
946 importObjHvCrate.import(crateMap.getIoV());
947 }
948}
949
951{
953
954 ARICHChannelHist* hist = new ARICHChannelHist("hvMapping", "module - HV cable mapping", 1);
955 for (int hapdID = 1; hapdID < 421; hapdID++) {
956 int val = hvMap->getCableID(hapdID) * 100 + hvMap->getInnerID(hapdID);
957 hist->setBinContent(hapdID, val);
958 }
959 hist->SetOption("TEXT");
960 hist->SaveAs("HVMapping.root");
961}
962
964{
966 biasVolt->print();
967
968 if (dump) {
969 DBImportObjPtr<ARICHBiasVoltages> importObjBiasVolt;
970 importObjBiasVolt.construct(*biasVolt);
971 importObjBiasVolt.import(biasVolt.getIoV());
972 }
973}
974
976{
981 DBArray<ARICHSensorModuleInfo> elements("ARICHSensorModuleInfo");
982 elements.getEntries();
983
984 int connectionID = std::get<0>(channelsMap->getInnerConnection(channel));
985 int innerCable = std::get<1>(channelsMap->getInnerConnection(channel));
986 std::string biasType = std::get<2>(channelsMap->getInnerConnection(channel));
987
988 int sector = crateMap->getSector(connectionID);
989 int outerCable = crateMap->getCable(connectionID);
990
991 int moduleID = (int) biasMap->getModuleID(sector, outerCable, innerCable);
992 std::string hapdID = "";
993 for (const auto& element : elements) {
994 if (element.getSensorModuleID() == moduleID) hapdID = element.getHAPDserial();
995 }
996
997 std::vector<int> voltages = biasVolt->getBiasVoltages(hapdID);
998 int appliedVoltage = 0;
999// std::string appliedVoltage = "zero";
1000 if (biasType == "bias-a") appliedVoltage = voltages[0];
1001 if (biasType == "bias-b") appliedVoltage = voltages[1];
1002 if (biasType == "bias-c") appliedVoltage = voltages[2];
1003 if (biasType == "bias-d") appliedVoltage = voltages[3];
1004 if (biasType == "guard") appliedVoltage = voltages[4];
1005
1006
1007 B2INFO("Crate " << channel[0] << ", slot " << channel[1] << ", slot channel " << channel[2] << " belongs to hapd " << hapdID <<
1008 " (module ID = " << moduleID << ") in sector " << sector << ".\n Corresponding cable is " << sector << "-" << outerCable <<
1009 ".\n Cable type is " << biasType << " with applied voltage " << appliedVoltage << " V.");
1010// B2INFO(channel[0] << "," << channel[1] << "," << channel[2] << "," << moduleID << "," << sector << "," << outerCable << "," << biasType << "," << appliedVoltage);
1011}
1012
1013void ARICHDatabaseImporter::printHapdPositionFromCrateSlot(int crate, int slot, int channelID)
1014{
1019
1020 DBArray<ARICHSensorModuleMap> elements("ARICHSensorModuleMap");
1021 elements.getEntries();
1022
1023 std::vector<int> channel{crate, slot, channelID};
1024 int connectionID = std::get<0>(channelsMap->getInnerConnection(channel));
1025 int innerCableNum = std::get<1>(channelsMap->getInnerConnection(channel));
1026 std::string biasType = channelsMap->getType(channel);
1027
1028 int sector = crateMap->getSector(connectionID);
1029 int outerCable = crateMap->getCable(connectionID);
1030
1031 int moduleID = (int)biasMap->getModuleID(sector, outerCable, innerCableNum);
1032
1033 unsigned mergerID = mrgMap->getMergerID((unsigned)moduleID);
1034 unsigned mergerSN = mrgMap->getMergerSN((unsigned)mergerID);
1035 unsigned febSlot = mrgMap->getFEBSlot((unsigned)moduleID);
1036 int febSlotDaq = ARICHDatabaseImporter::getFebDaqSlot(febSlot);
1037
1038 for (const auto& element : elements) {
1039 if (element.getSensorGlobalID() == moduleID) B2INFO("HAPD for crate " << crate + 1 << ", slot " << slot << ", inner cable " <<
1040 innerCableNum << " has ID number " << moduleID << ". Bias cable number is " << sector << "-" << outerCable <<
1041 ".\n Position is: RING " << element.getSensorModuleRingID() << " COLUMN " << element.getSensorModuleColumnID() <<
1042 ". \n Bias type for channel " << channelID << " is " << biasType << ".\n It belongs to merger " << mergerID << " (SN " <<
1043 mergerSN << ") and has DAQ feb slot " << febSlotDaq);
1044 }
1045
1046}
1047
1049{
1050 std::map<unsigned, int> febSlots;
1051 febSlots.insert(std::pair<unsigned, int>(6, 0));
1052 febSlots.insert(std::pair<unsigned, int>(5, 1));
1053 febSlots.insert(std::pair<unsigned, int>(4, 2));
1054 febSlots.insert(std::pair<unsigned, int>(1, 3));
1055 febSlots.insert(std::pair<unsigned, int>(2, 4));
1056 febSlots.insert(std::pair<unsigned, int>(3, 5));
1057
1058 int febDaqSlot = febSlots.find(febSlot)->second;
1059
1060 return febDaqSlot;
1061}
1062
1064{
1066 simPar->print();
1067
1068 if (dump) {
1070 importObjSim.construct(*simPar);
1071 importObjSim.import(simPar.getIoV());
1072 }
1073}
1074
1076{
1078 geoConfig->print();
1079
1080 if (dump) {
1082 importObjGeo.construct(*geoConfig);
1083 importObjGeo.import(geoConfig.getIoV());
1084 }
1085}
1086
1088{
1090 chMap->print();
1091
1092 if (dump) {
1094 importObjMap.construct(*chMap);
1095 importObjMap.import(chMap.getIoV());
1096 }
1097}
1098
1100{
1102 mrgMap->print();
1103
1104 if (dump) {
1105 DBImportObjPtr<ARICHMergerMapping> importObjMerger;
1106 importObjMerger.construct(*mrgMap);
1107 importObjMerger.import(mrgMap.getIoV());
1108 }
1109}
1110
1112{
1114 copMap->print();
1115
1116 if (dump) {
1117 DBImportObjPtr<ARICHCopperMapping> importObjCopper;
1118 importObjCopper.construct(*copMap);
1119 importObjCopper.import(copMap.getIoV());
1120 }
1121}
1122
1124{
1126 modinfo->print();
1127
1128 if (dump) {
1130 importObjMod.construct(*modinfo);
1131 importObjMod.import(modinfo.getIoV());
1132 }
1133}
1134
1136{
1138 recPar->print();
1139
1140 if (dump) {
1142 importObjRec.construct(*recPar);
1143 importObjRec.import(recPar.getIoV());
1144 }
1145}
1146
1147
1148void ARICHDatabaseImporter::printChannelMask(bool makeHist, bool dump)
1149{
1150
1152 chMask->print();
1153
1154 if (makeHist) {
1155 ARICHChannelHist* hist = new ARICHChannelHist("channelMask", "Map of active channels");
1156 for (int hapdID = 1; hapdID < 421; hapdID++) {
1157 for (int ichn = 0; ichn < 144; ichn++) {
1158 if (chMask->isActive(hapdID, ichn)) hist->setBinContent(hapdID, ichn, 1.0);
1159 }
1160 }
1161 hist->SaveAs("channelMask.root");
1162 }
1163
1164 if (dump) {
1166 importObj.construct(*chMask);
1167 importObj.import(chMask.getIoV());
1168 }
1169}
1170
1172{
1174 ARICHChannelHist* hist = new ARICHChannelHist("mergerNum", "module - merger mapping", 1);
1175 for (int hapdID = 1; hapdID < 421; hapdID++) {
1176 int val = mgrMap->getMergerID(hapdID);
1177 if (sn) val = mgrMap->getMergerSN(val);
1178 hist->setBinContent(hapdID, val);
1179 }
1180 hist->SetOption("TEXT");
1181 hist->SaveAs("MergerMapping.root");
1182
1183}
1184
1186{
1187
1191
1192 GearDir content = GearDir("/Detector/DetectorComponent[@name='ARICH']/Content/InstalledModules");
1193
1194 cout << "{ \"hapdmap\": [" << endl;
1195 for (unsigned hapdID = 1; hapdID < 421; hapdID++) {
1196 std::string hapdsn;
1197 for (const GearDir& module : content.getNodes("Module")) {
1198 hapdsn = module.getString("@hapdID");
1199 unsigned sector = module.getInt("Sector");
1200 unsigned ring = module.getInt("Ring");
1201 unsigned azimuth = module.getInt("Azimuth");
1202 unsigned moduleID = geoConfig->getDetectorPlane().getSlotIDFromSRF(sector, ring, azimuth);
1203 if (moduleID == hapdID) break;
1204 }
1205
1206 int val = mgrMap->getMergerID(hapdID);
1207 cout << "{\n" << "\"ID\": \"" << hapdID << "\"," << endl;
1208 cout << "\"sn\": \"" << hapdsn << "\"," << endl;
1209 cout << "\"mrg\": \"" << val << "\"," << endl;
1210 cout << "\"mrgSN\": \"" << mgrMap->getMergerSN(val) << "\"," << endl;
1211 cout << "\"feb\": \"" << mgrMap->getFEBSlot(hapdID) - 1 << "\"," << endl;
1212 cout << "\"cpr\": \"" << cprMap->getCopperID(val) << "\"," << endl;
1213 cout << "\"hslb\": \"" << cprMap->getFinesse(val) << "\"" << endl;
1214 if (hapdID < 420) cout << "}," << endl;
1215 else cout << "}" << endl;
1216 }
1217 cout << "]}" << endl;
1218
1219
1220}
1221
1223{
1224
1225 ARICHChannelHist* hist = new ARICHChannelHist("moduleNum", "HAPD module slot numbering", 1);
1226 for (int hapdID = 1; hapdID < 421; hapdID++) {
1227 hist->setBinContent(hapdID, hapdID);
1228 }
1229 hist->SetOption("TEXT");
1230 hist->SaveAs("ModuleNumbering.root");
1231
1232}
1233
1235{
1239
1240 if (simple) {
1241 TGraph2D* gr = new TGraph2D();
1242 int point = 0;
1243 for (int i = 1; i < 421; i++) {
1244 if (modInfo->isInstalled(i)) {
1245 for (int j = 0; j < 144; j++) {
1246 int xCh, yCh;
1247 chMap->getXYFromAsic(j, xCh, yCh);
1248 ROOT::Math::XYVector chPos = geoConfig->getChannelPosition(i, xCh, yCh);
1249 gr->SetPoint(point, chPos.X(), chPos.Y(), modInfo->getChannelQE(i, j));
1250 point++;
1251 }
1252 }
1253 }
1254 gr->SaveAs("QEMap.root");
1255 } else {
1256 ARICHChannelHist* hist = new ARICHChannelHist("hapdQE", "hapd QE map");
1257 for (int hapdID = 1; hapdID < 421; hapdID++) {
1258 if (!modInfo->isInstalled(hapdID)) continue;
1259 for (int chID = 0; chID < 144; chID++) {
1260 hist->setBinContent(hapdID, chID, modInfo->getChannelQE(hapdID, chID));
1261 }
1262 }
1263 hist->SaveAs("QEMap.root");
1264 }
1265}
1266
1268{
1269
1270 ARICHAerogelHist* h2_aerogel_up_n = new ARICHAerogelHist("h2_aerogel_up_n", "aerogel up n");
1271 ARICHAerogelHist* h2_aerogel_up_transmL = new ARICHAerogelHist("h2_aerogel_up_transmL", "aerogel up transmL");
1272 ARICHAerogelHist* h2_aerogel_up_thick = new ARICHAerogelHist("h2_aerogel_up_thick", "aerogel up thick");
1273 ARICHAerogelHist* h2_aerogel_down_n = new ARICHAerogelHist("h2_aerogel_down_n", "aerogel down n");
1274 ARICHAerogelHist* h2_aerogel_down_transmL = new ARICHAerogelHist("h2_aerogel_down_transmL", "aerogel down transmL");
1275 ARICHAerogelHist* h2_aerogel_down_thick = new ARICHAerogelHist("h2_aerogel_down_thick", "aerogel down thick");
1276
1277 std::string condDBname = "ARICHdata";
1278 // cppcheck-suppress knownConditionTrueFalse
1279 if (condDBname == "ARICHdata") {
1280
1281 //
1282 DBArray<ARICHAerogelMap> elementsM("ARICHAerogelMap");
1283 elementsM.getEntries();
1284 DBArray<ARICHAerogelInfo> elementsI("ARICHAerogelInfo");
1285 elementsI.getEntries();
1286
1287 //
1288 for (const auto& elementM : elementsM) {
1289 if (elementM.getAerogelLayer(0) == 1) {
1290 for (const auto& elementI : elementsI) {
1291 if (elementI.getAerogelSN() == elementM.getAerogelSN()) {
1292 //down
1293 h2_aerogel_down_n->SetBinContent(h2_aerogel_down_n->GetBinIDFromRingColumn(elementM.getAerogelRingID(),
1294 elementM.getAerogelColumnID()), elementI.getAerogelRefractiveIndex());
1295 h2_aerogel_down_transmL->SetBinContent(h2_aerogel_down_transmL->GetBinIDFromRingColumn(elementM.getAerogelRingID(),
1296 elementM.getAerogelColumnID()), elementI.getAerogelTransmissionLength());
1297 h2_aerogel_down_thick->SetBinContent(h2_aerogel_down_thick->GetBinIDFromRingColumn(elementM.getAerogelRingID(),
1298 elementM.getAerogelColumnID()), elementI.getAerogelThickness());
1299 }// if (elementI.getAerogelSN() == elementM.getAerogelSN()){
1300 }// for (const auto& elementI : elementsI) {
1301 }
1302 if (elementM.getAerogelLayer(1) == 1) {
1303 for (const auto& elementI : elementsI) {
1304 if (elementI.getAerogelSN() == elementM.getAerogelSN()) {
1305 //up
1306 h2_aerogel_up_n->SetBinContent(h2_aerogel_up_n->GetBinIDFromRingColumn(elementM.getAerogelRingID(), elementM.getAerogelColumnID()),
1307 elementI.getAerogelRefractiveIndex());
1308 h2_aerogel_up_transmL->SetBinContent(h2_aerogel_up_transmL->GetBinIDFromRingColumn(elementM.getAerogelRingID(),
1309 elementM.getAerogelColumnID()), elementI.getAerogelTransmissionLength());
1310 h2_aerogel_up_thick->SetBinContent(h2_aerogel_up_thick->GetBinIDFromRingColumn(elementM.getAerogelRingID(),
1311 elementM.getAerogelColumnID()), elementI.getAerogelThickness());
1312 }// if (elementI.getAerogelSN() == elementM.getAerogelSN()){
1313 }// for (const auto& elementI : elementsI) {
1314 }
1315 }// for (const auto& elementM : elementsM) {
1316
1317 }// if (condDBname = "ARICHdata") {
1318 //else { // if (condDBname = "ARICHdata") {
1319 //To be added later when the information about aerogel optical properties
1320 //would be available not only in ARICHdata
1321 //}
1322
1323 TFile* rootFile = new TFile(outRootFileName.c_str(), "RECREATE", " Histograms", 1);
1324 rootFile->cd();
1325 if (rootFile->IsZombie()) {
1326 B2ERROR(" ERROR ---> file : " << outRootFileName.c_str() << " is zombi");
1327 }
1328 h2_aerogel_up_n->Write();
1329 h2_aerogel_up_transmL->Write();
1330 h2_aerogel_up_thick->Write();
1331 h2_aerogel_down_n->Write();
1332 h2_aerogel_down_transmL->Write();
1333 h2_aerogel_down_thick->Write();
1334 rootFile->Close();
1335}
1336
1337//class for ARICH aerogel Rayleigh scattering fit parameters
1339{
1340 GearDir content = GearDir("/aerogelFit");
1341
1342 //cout<<" ARICHDatabaseImporter::importAeroRayleighScatteringFit "<<endl;
1343
1344 // define data array
1345 TClonesArray agelFitConstants("Belle2::ARICHAerogelRayleighScatteringFit");
1346 int agel = 0;
1347 string serial;
1348 float version = (float) content.getDouble("version");
1349
1350 // loop over xml files and extract the data
1351 for (const auto& aerogel : content.getNodes("aerogeltile")) {
1352 //cout<<agel<<" serial : "<<<<endl;
1353 serial = aerogel.getString("serial");
1354 vector<float> vPar;
1355 vPar.push_back((float)aerogel.getDouble("p0"));
1356 vPar.push_back((float)aerogel.getDouble("p1"));
1357 vPar.push_back((float)aerogel.getDouble("p2"));
1358 vPar.push_back((float)aerogel.getDouble("p3"));
1359 vPar.push_back((float)aerogel.getDouble("p4"));
1360 vPar.push_back((float)aerogel.getDouble("p5"));
1361 vPar.push_back((float)aerogel.getDouble("p6"));
1362 ARICHAerogelRayleighScatteringFit* aeroRayScatFit = new ARICHAerogelRayleighScatteringFit(version, serial, commentSingleWord, vPar);
1363 //if(agel == 0)
1364 // aeroRayScatFit->printContent(true);
1365 //else
1366 // aeroRayScatFit->printContent();
1367 agelFitConstants[agel] = aeroRayScatFit;
1368 agel++;
1369 }
1370
1371 // store under default name:
1372 // Database::Instance().storeData(&agelConstants, iov);
1373 // store under user defined name:
1374 TString coreName = "ARICHAerogelRayleighScatteringFit";
1375 TString coreNameSuffix = commentSingleWord;
1376 if (coreNameSuffix != "")
1377 coreName += coreNameSuffix;
1378 Database::Instance().storeData(coreName.Data(), &agelFitConstants, m_iov);
1379
1380}
1381
1382// classes for quality assessment and test data
1384{
1385 GearDir content = GearDir("/ArichData/AllData/AerogelData/Content");
1386
1387 // define data array
1388 TClonesArray agelConstants("Belle2::ARICHAerogelInfo");
1389 int agel = 0;
1390
1391 // loop over xml files and extract the data
1392 for (const auto& aerogel : content.getNodes("aerogel")) {
1393 float version = (float) aerogel.getDouble("version");
1394 string serial = aerogel.getString("serial");
1395 string id = aerogel.getString("id");
1396 float index = (float) aerogel.getDouble("index");
1397 float trlen = ((float) aerogel.getDouble("translength")) * Unit::mm;
1398 float thickness = ((float) aerogel.getDouble("thick")) * Unit::mm;
1399 vector<int> lambdas;
1400 vector<float> transmittances;
1401 for (const auto& transmittance : aerogel.getNodes("transmittance/transpoint")) {
1402 int lambda = transmittance.getInt("@lambda");
1403 float val = (float) transmittance.getDouble(".");
1404 lambdas.push_back(lambda);
1405 transmittances.push_back(val);
1406 }
1407
1408 // save data as an element of the array
1409 new (agelConstants[agel]) ARICHAerogelInfo(version, serial, id, index, trlen, thickness, lambdas, transmittances);
1410 agel++;
1411 }
1412
1413 // define interval of validity
1414
1415 // store under default name:
1416 // Database::Instance().storeData(&agelConstants, iov);
1417 // store under user defined name:
1418 TString coreName = "ARICHAerogelInfo";
1419 if (coreNameSuffix != "")
1420 coreName += coreNameSuffix;
1421 Database::Instance().storeData(coreName.Data(), &agelConstants, m_iov);
1422}
1423
1425{
1426
1427 // Definition:
1428 // This function extracts data from the database for chosen event.
1429
1430 /*
1431 // Extract data from payload with bounded validity
1432
1433 // Define event, run and experiment numbers
1434 EventMetaData event = EventMetaData(1200,4,0); // (event, run, exp)
1435
1436 // Extract object and IOV from database
1437 std::pair<TObject*, IntervalOfValidity> podatki = Database::Instance().getData(event, "dbstore", "ARICHAerogelInfo");
1438
1439 // print interval of validity
1440 // IntervalOfValidity iov = std::get<1>(podatki);
1441 // B2INFO("iov = " << iov);
1442
1443 // Convert between different class types and extract TClonesArray
1444 // for chosen event
1445 TObject* data;
1446 data = std::get<0>(podatki);
1447 TClonesArray* elements = static_cast<TClonesArray*>(data);
1448
1449 // Get entries from TClonesArray and print aerogel info
1450 (*elements).GetEntries();
1451 for (int i = 0; i < elements->GetSize(); i++) {
1452 ARICHAerogelInfo* myelement = static_cast<ARICHAerogelInfo*>(elements->At(i));
1453 B2INFO("Version = " << myelement->getAerogelVersion() << ", SN = " << myelement->getAerogelSN() << ", n = " << myelement->getAerogelRefractiveIndex() << ", trl = " << myelement->getAerogelTransmissionLength() << ", thickness = " << myelement->getAerogelThickness());
1454 }
1455 */
1456
1457
1458
1459 // Extract data from payload with unbounded validity
1460 DBArray<ARICHAerogelInfo> elements("ARICHAerogelInfo");
1461 elements.getEntries();
1462
1463 // Print aerogel info
1464 for (const auto& element : elements) {
1465 B2INFO("Version = " << element.getAerogelVersion() << ", serial = " << element.getAerogelSN() <<
1466 ", id = " << element.getAerogelID() << ", n = " << element.getAerogelRefractiveIndex() << ", transmLength = " <<
1467 element.getAerogelTransmissionLength() << ", thickness = " << element.getAerogelThickness());
1468 if (verboseLevel > 0) {
1469 unsigned int ii = 0;
1470 int lllambda = 200;
1471 while (lllambda > 0) {
1472 lllambda = element.getAerogelTransmittanceLambda(ii);
1473 if (lllambda < 0)
1474 break;
1475 float llval = element.getAerogelTransmittance(ii);
1476 B2INFO(" Lambda = " << lllambda << " Transmittance = " << llval);
1477 ii++;
1478 }// while(lllambda > 0){
1479 }// if(verboseLevel>0){
1480 }// for (const auto& element : elements) {
1481
1482}
1483
1484
1486{
1487 GearDir content = GearDir("/ArichData/AllData/aerogelposition");
1488
1489 // define data array
1490 TClonesArray agelMap("Belle2::ARICHAerogelMap");
1491 int agel = 0;
1492
1493 for (int layer = 0; layer < 2; layer++) {
1494 // loop over xml files and extract the data
1495 for (const auto& aerogel : content.getNodes("position")) {
1496 string agelserial = "";
1497 int ring = aerogel.getInt("ring");
1498 int phi = aerogel.getInt("phi");
1499 if (layer == 1) agelserial = aerogel.getString("upaerogelserial");
1500 if (layer == 0) agelserial = aerogel.getString("downaerogelserial");
1501
1502 // save data as an element of the array
1503 new (agelMap[agel]) ARICHAerogelMap();
1504 auto* agelConst = static_cast<ARICHAerogelMap*>(agelMap[agel]);
1505 agelConst->setAerogelSN(agelserial);
1506 agelConst->setAerogelRingID(ring);
1507 agelConst->setAerogelColumnID(phi);
1508 agelConst->setAerogelLayer(layer, 1);
1509
1510 agel++;
1511 }
1512 }
1513
1514 // store under user defined name:
1515 Database::Instance().storeData("ARICHAerogelMap", &agelMap, m_iov);
1516}
1517
1518
1519
1521{
1522
1523 DBArray<ARICHAerogelMap> elements("ARICHAerogelMap");
1524 elements.getEntries();
1525
1526 // Print aerogel info
1527 for (const auto& element : elements) {
1528 string layer;
1529 if (element.getAerogelLayer(0) == 1) layer = "down";
1530 if (element.getAerogelLayer(1) == 1) layer = "up";
1531 B2INFO("ID = " << element.getAerogelSN() << ", ring = " << element.getAerogelRingID() <<
1532 ", column = " << element.getAerogelColumnID() << ", layer: " << layer);
1533 }
1534}
1535
1536
1538{
1539 GearDir content = GearDir("/ArichData/AllData/AerogelData/Content");
1540
1541 // define data arrays
1542 TClonesArray agelConstantsA("Belle2::ARICHAerogelInfo");
1543 TClonesArray agelConstantsB("Belle2::ARICHAerogelInfo");
1544 TClonesArray agelConstantsC("Belle2::ARICHAerogelInfo");
1545
1546
1547 for (int someint = 0; someint < 3; someint++) {
1548 int agel = 0;
1549 // loop over xml files and extract the data
1550 for (const auto& aerogel : content.getNodes("aerogel")) {
1551 // different version is made up - only used to check performance
1552 // of intrarun dependat function
1553 float version = 0;
1554 if (someint == 0) version = (float) aerogel.getDouble("version");
1555 if (someint == 1) version = 4.0;
1556 if (someint == 2) version = 5.0;
1557
1558 string serial = aerogel.getString("serial");
1559 string id = aerogel.getString("id");
1560 float index = (float) aerogel.getDouble("index");
1561 float trlen = ((float) aerogel.getDouble("translength")) * Unit::mm;
1562 float thickness = ((float) aerogel.getDouble("thick")) * Unit::mm;
1563 vector<int> lambdas;
1564 vector<float> transmittances;
1565 for (const auto& transmittance : aerogel.getNodes("transmittance/transpoint")) {
1566 int lambda = transmittance.getInt("@lambda");
1567 float val = (float) transmittance.getDouble(".");
1568 lambdas.push_back(lambda);
1569 transmittances.push_back(val);
1570 }
1571
1572 // save data as an element of the array
1573 if (someint == 0) new (agelConstantsA[agel]) ARICHAerogelInfo(version, serial, id, index, trlen, thickness, lambdas,
1574 transmittances);
1575 if (someint == 1) new (agelConstantsB[agel]) ARICHAerogelInfo(version, serial, id, index, trlen, thickness, lambdas,
1576 transmittances);
1577 if (someint == 2) new (agelConstantsC[agel]) ARICHAerogelInfo(version, serial, id, index, trlen, thickness, lambdas,
1578 transmittances);
1579 agel++;
1580 }
1581 }
1582
1583 // convert pointers to ARICHAerogelInfo into pointers to TObject
1584 TObject* agelObj[3];
1585 agelObj[0] = static_cast<TObject*>(&agelConstantsA);
1586 agelObj[1] = static_cast<TObject*>(&agelConstantsB);
1587 agelObj[2] = static_cast<TObject*>(&agelConstantsC);
1588
1589 // add objects with different validity
1590 EventDependency intraRun(agelObj[0]);
1591 intraRun.add(500, agelObj[1]); // valid from event number 500
1592 intraRun.add(1000, agelObj[2]); // valid from event number 1000
1593
1594 // store under user defined name
1595 Database::Instance().storeData("ARICHAerogelInfoEventDep", &intraRun, m_iov);
1596
1597}
1598
1600{
1601 // Definition:
1602 // This function extracts intrarun dependant data from the database.
1603 // It converts between different class types to get the saved
1604 // TClonesArray for chosen event, run and experiment.
1605
1606
1607 // Define event, run and experiment numbers
1608 EventMetaData event = EventMetaData(1200, 4, 0); // (event, run, exp)
1609
1610 // Extract object and IOV from database
1611 std::pair<TObject*, IntervalOfValidity> podatki = Database::Instance().getData(event, "ARICHAerogelInfoEventDep");
1612
1613 // print interval of validity
1614// IntervalOfValidity iov = std::get<1>(podatki);
1615// B2INFO("iov = " << iov);
1616
1617 // Convert between different class types and extract TClonesArray
1618 // for chosen event
1619 TObject* data = std::get<0>(podatki);
1620 EventDependency* data2 = static_cast<EventDependency*>(data);
1621 TObject* myobject = data2->getObject(event);
1622 TClonesArray* elements = static_cast<TClonesArray*>(myobject);
1623
1624 // Get entries from TClonesArray and print aerogel info
1625 (*elements).GetEntries();
1626 for (int i = 0; i < elements->GetSize(); i++) {
1627 ARICHAerogelInfo* myelement = (ARICHAerogelInfo*)elements->At(i);
1628 B2INFO("Version = " << myelement->getAerogelVersion() << ", SN = " << myelement->getAerogelSN() << ", n = " <<
1629 myelement->getAerogelRefractiveIndex() << ", trl = " << myelement->getAerogelTransmissionLength() << ", thickness = " <<
1630 myelement->getAerogelThickness());
1631 }
1632
1633 /*
1634
1635 // Extract data from the last added payload
1636 DBArray<ARICHAerogelInfo> elements("ARICHAerogelInfo");
1637 elements.getEntries();
1638
1639 // Print aerogel info
1640
1641 for (const auto& element : elements) {
1642 B2INFO("Version = " << element.getAerogelVersion() << ", serial = " << element.getAerogelSN() <<
1643 ", id = " << element.getAerogelID() << ", n = " << element.getAerogelRefractiveIndex() << ", transmLength = " <<
1644 element.getAerogelTransmissionLength() << ", thickness = " << element.getAerogelThickness())
1645 }
1646
1647 */
1648}
1649
1650
1652{
1653 // define data array
1654 TClonesArray hapdQAConstants("Belle2::ARICHHapdQA");
1655 int hapd = 0;
1656
1657 // loop over root riles
1658 for (const string& inputFile : m_inputFilesHapdQA) {
1659 TFile* f = TFile::Open(inputFile.c_str(), "READ");
1660
1661 int size = inputFile.length();
1662 string hapdSerial = inputFile.substr(size - 16, 6);
1663
1664 vector<TGraph*> leakCurrent;
1665 TH2F* hitData2D = 0;
1666 vector<TGraph*> noise;
1667 vector<TH1S*> hitCount;
1668 TTimeStamp arrivalDate;
1669 int arrival;
1670 TTree* tree = 0;
1671
1672 // extract data
1673 TIter next(f->GetListOfKeys());
1674 TKey* key;
1675 while ((key = (TKey*)next())) {
1676
1677 string strime = key->GetName();
1678
1679 if (strime.compare(0, 8, "gcurrent") == 0) {
1680 TGraph* graphcurrent = (TGraph*)f->Get(strime.c_str());
1681 leakCurrent.push_back(graphcurrent);
1682 }
1683
1684 else if (strime.compare(0, 7, "h2dscan") == 0) {
1685 hitData2D = (TH2F*)f->Get(strime.c_str());
1686 hitData2D->SetDirectory(0);
1687 }
1688
1689 else if (strime.compare(0, 9, "gnoise_ch") == 0) {
1690 TGraph* graphnoise = (TGraph*)f->Get(strime.c_str());
1691 noise.push_back(graphnoise);
1692 }
1693
1694 else if (strime.compare(0, 7, "hchscan") == 0) {
1695 TH1F* hhist3 = (TH1F*)f->Get(strime.c_str());
1696 hhist3->SetDirectory(0);
1697
1698 // conversion TH1F -> TH1S
1699
1700 const char* hhist3_ime = hhist3->GetName();
1701 const char* hhist3_naslov = hhist3->GetTitle();
1702 int hhist3_nbins = hhist3->GetSize();
1703 TH1S* hhist3short = new TH1S(hhist3_ime, hhist3_naslov, hhist3_nbins - 2, 0, 1);
1704 for (int bin = 0; bin < hhist3_nbins; bin++) {
1705 hhist3short->SetBinContent(bin, hhist3->GetBinContent(bin));
1706 }
1707 hhist3short->SetDirectory(0);
1708 hitCount.push_back(hhist3short);
1709 }
1710
1711 else if (strime.compare(0, 4, "tree") == 0) {
1712 tree = (TTree*)f->Get(strime.c_str());
1713 tree->SetBranchAddress("arrival", &arrival);
1714 tree->GetEntry(0);
1715 arrivalDate = TTimeStamp(arrival, 0);
1716 }
1717
1718 else { B2INFO("Key name does not match any of the following: gcurrent, 2dscan, gnoise, hchscan, tree_ts! - serial number: " << hapdSerial << "; key name = " << strime.c_str()); }
1719 }
1720
1721 // save data as an element of the array
1722 new (hapdQAConstants[hapd]) ARICHHapdQA(hapdSerial, arrivalDate, leakCurrent, hitData2D, noise, hitCount);
1723 hapd++;
1724 }
1725
1726 // define IOV and store data to the DB
1727 Database::Instance().storeData("ARICHHapdQA", &hapdQAConstants, m_iov);
1728}
1729
1730
1732{
1733 DBArray<ARICHHapdQA> elements("ARICHHapdQA");
1734 elements.getEntries();
1735
1736 // Print serial numbers of HAPDs
1737 for (const auto& element : elements) {
1738 B2INFO("Serial number = " << element.getHapdSerialNumber() << "; arrival date = " << element.getHapdArrivalDate());
1739 }
1740}
1741
1743{
1744 GearDir content = GearDir("/ArichData/AllData/asicList");
1745 // define data array
1746 TClonesArray asicConstants("Belle2::ARICHAsicInfo");
1747 int asic = 0;
1748
1749 for (const auto& asiclist : content.getNodes("asicinfo")) {
1750 string asicSerial = asiclist.getString("serial");
1751 string comment = asiclist.getString("comment");
1752 string numCH = asiclist.getString("num");
1753
1754 // get time of measurement
1755 TTimeStamp timeFinishGain = ARICHDatabaseImporter::getAsicDate(asicSerial, "gain");
1756 TTimeStamp timeFinishOffset = ARICHDatabaseImporter::getAsicDate(asicSerial, "offset");
1757
1758 // get lists of bad channels
1759 vector<int> nosignalCHs = ARICHDatabaseImporter::channelsList(asiclist.getString("nosignal"));
1760 vector<int> badconnCHs = ARICHDatabaseImporter::channelsList(asiclist.getString("badconn"));
1761 vector<int> badoffsetCHs = ARICHDatabaseImporter::channelsList(asiclist.getString("badoffset"));
1762 vector<int> badlinCHs = ARICHDatabaseImporter::channelsList(asiclist.getString("badlin"));
1763
1764 int num = 0;
1765 if (numCH.find("many") != string::npos) {num = 5000; }
1766 else if (numCH.find("all") != string::npos) {num = 10000; }
1767 else {num = atoi(numCH.c_str()); }
1768
1769
1770 // save data as an element of the array
1771 new (asicConstants[asic]) ARICHAsicInfo();
1772 auto* asicConst = static_cast<ARICHAsicInfo*>(asicConstants[asic]);
1773
1774 asicConst->setAsicID(asicSerial);
1775 asicConst->setTimeFinishGain(timeFinishGain);
1776 asicConst->setTimeFinishOffset(timeFinishOffset);
1777 asicConst->setDeadChannels(nosignalCHs);
1778 asicConst->setBadConnChannels(badconnCHs);
1779 asicConst->setBadOffsetChannels(badoffsetCHs);
1780 asicConst->setBadLinChannels(badlinCHs);
1781 asicConst->setNumOfProblematicChannels(num);
1782 asicConst->setComment(comment);
1783
1784 asic++;
1785 }
1786
1787 Database::Instance().storeData("ARICHAsicInfo", &asicConstants, m_iov);
1788}
1789
1791{
1792 TFile f1("asicInfoHistograms.root", "recreate");
1793 TH3F* gain0 = 0;
1794 TH3F* gain1 = 0;
1795 TH3F* gain2 = 0;
1796 TH3F* gain3 = 0;
1797 TH3F* offsetF = 0;
1798 TH3F* offsetR = 0;
1799 string asicSerial = "";
1800
1801 // define tree
1802 TTree* tree = new TTree("asicInfo", "asic info data");
1803
1804 tree->Branch("asicSerial", (void*)asicSerial.c_str(), "string/C", 1024);
1805 tree->Branch("gain0", "TH3F", &gain0);
1806 tree->Branch("gain1", "TH3F", &gain1);
1807 tree->Branch("gain2", "TH3F", &gain2);
1808 tree->Branch("gain3", "TH3F", &gain3);
1809 tree->Branch("offsetF", "TH3F", &offsetF);
1810 tree->Branch("offsetR", "TH3F", &offsetR);
1811
1812 // loop over root files
1813 for (const string& inputFile : m_inputFilesAsicRoot) {
1814
1815 string inputFileNew = (string) inputFile;
1816 string asicName = inputFileNew.substr(inputFileNew.find("/asicData") + 17);
1817 size_t findRoot = asicName.find(".root");
1818 if (findRoot != string::npos) {
1819 // extract the data from files
1820 TFile* f = TFile::Open(inputFile.c_str(), "READ", "", 0);
1821 TIter next(f->GetListOfKeys());
1822 TKey* key;
1823
1824 // fill vectors with histograms with different gain and offset settings
1825 while ((key = (TKey*)next())) {
1826 string strname = key->GetName();
1827 if (strname.find("_g0") != string::npos) gain0 = (TH3F*)f->Get(strname.c_str());
1828 else if (strname.find("_g1") != string::npos) gain1 = (TH3F*)f->Get(strname.c_str());
1829 else if (strname.find("_g2") != string::npos) gain2 = (TH3F*)f->Get(strname.c_str());
1830 else if (strname.find("_g3") != string::npos) gain3 = (TH3F*)f->Get(strname.c_str());
1831 else if (strname.find("_f") != string::npos) offsetF = (TH3F*)f->Get(strname.c_str());
1832 else if (strname.find("_c") != string::npos) offsetR = (TH3F*)f->Get(strname.c_str());
1833 else B2INFO("Key name does not match any of the following: gain, offset!");
1834 }
1835
1836 tree->Fill();
1837 f->Close();
1838 }
1839 }
1840
1841 f1.cd();
1842 tree->Write();
1843 f1.Close();
1844
1845// define IOV and store data to the DB
1846 Database::Instance().addPayload("ARICHAsicInfoRoot", "asicInfoHistograms.root", m_iov);
1847}
1848
1849TTimeStamp ARICHDatabaseImporter::getAsicDate(const std::string& asicSerial, const std::string& type)
1850{
1851 TTimeStamp timeFinish;
1852 string line;
1853 size_t findText = 100;
1854
1855 // extract measurement date for serial number
1856 for (const string& inputFile : m_inputFilesAsicTxt) {
1857 string inputFileNew = (string) inputFile;
1858 if (type == "gain") { findText = inputFileNew.find("dateGain.txt"); }
1859 else if (type == "offset") { findText = inputFileNew.find("dateOffset.txt"); }
1860 else {B2INFO("Check type of measurement!"); }
1861 if (findText != string::npos) {
1862 std::ifstream ifs(inputFile);
1863 if (ifs.is_open()) {
1864 while (ifs.good()) {
1865 std::getline(ifs, line);
1866 string asicSerial2 = asicSerial + ":";
1867 size_t findSerial = line.find(asicSerial2);
1868 if (findSerial != string::npos) {timeFinish = ARICHDatabaseImporter::timedate(line);}
1869 }
1870 }
1871 ifs.clear();
1872 ifs.close();
1873 }
1874 }
1875 return timeFinish;
1876}
1877
1878TTimeStamp ARICHDatabaseImporter::timedate(std::string enddate)
1879{
1880 // convert string into TTimeStamp
1881 string dateEnd = enddate.substr(enddate.find(":") + 2);
1882 string yearStr = dateEnd.substr(0, 4);
1883 string monthStr = dateEnd.substr(4, 2);
1884 string dayStr = dateEnd.substr(6, 2);
1885 string hourStr = dateEnd.substr(8, 2);
1886 string minStr = dateEnd.substr(10, 2);
1887 int year = atoi(yearStr.c_str());
1888 int month = atoi(monthStr.c_str());
1889 int day = atoi(dayStr.c_str());
1890 int hour = atoi(hourStr.c_str());
1891 int min = atoi(minStr.c_str());
1892 TTimeStamp datum = TTimeStamp(year, month, day, hour, min, 0, 0, kTRUE, -9 * 60 * 60);
1893 return datum;
1894}
1895
1896vector<int> ARICHDatabaseImporter::channelsList(std::string badCH)
1897{
1898
1899 vector<int> CHs;
1900
1901 if ((badCH.find("many") != string::npos) || (badCH.find("all") != string::npos)) CHs.emplace_back(-1);
1902 else ARICHTools::StringToVector::convert<int>(badCH, ',');
1903
1904 return CHs;
1905}
1906
1907
1909{
1910
1911 DBArray<ARICHAsicInfo> elements("ARICHAsicInfo");
1912 elements.getEntries();
1913
1914 // Print serial numbers of ASICs
1915 for (const auto& element : elements) {
1916 B2INFO("asic SN: " << element.getAsicID());
1917 }
1918}
1919
1920
1922{
1923
1924 // define data array
1925 TClonesArray febConstants("Belle2::ARICHFebTest");
1926
1927 int feb = 0;
1928
1929 GearDir content = GearDir("/ArichData/AllData/arich");
1930 GearDir content1 = GearDir("/ArichData/AllData/dnamap");
1931 GearDir content2 = GearDir("/ArichData/AllData/FEBData/Content");
1932
1933 for (const auto& runserial : content.getNodes("run")) {
1934 int serial = runserial.getInt("sn");
1935 // save data as an element of the array
1936 new (febConstants[feb]) ARICHFebTest();
1937 auto* febConst = static_cast<ARICHFebTest*>(febConstants[feb]);
1938 febConst->setFebSerial(serial);
1939
1940 string runLV = runserial.getString("lv");
1941 string runHV = runserial.getString("hv");
1942 string runSCAN = runserial.getString("scan");
1943 string comment = runserial.getString("comment");
1944
1945 febConst->setRunLV(runLV);
1946 febConst->setRunHV(runHV);
1947 febConst->setRunSlowC(runSCAN);
1948 febConst->setComment(comment);
1949
1950 int l = 0;
1951 string dna;
1952
1953 for (const auto& febmap : content1.getNodes("febps")) {
1954 string somedna = febmap.getString("@dna");
1955 int sn = febmap.getInt("sn");
1956 if ((l == 0) && (sn == serial)) {
1957 dna = somedna;
1958 febConst->setFebDna(dna);
1959 //febConst->setDeadChannels(ARICHDatabaseImporter::getDeadChFEB(dna));
1960 l++;
1961 }
1962 }
1963
1964 // slow control data
1965 if (!runSCAN.empty()) {
1966 int scanRun;
1967 if (stoi(runSCAN.c_str()) < 23) {scanRun = stoi(runSCAN.c_str());}
1968 else {scanRun = stoi(runSCAN.c_str()) - 77;}
1969 for (const auto& testFEB : content2.getNodes("febtest[" + std::to_string(scanRun) + "]")) {
1970 string timeSlowC = testFEB.getString("time");
1971 int i = 0;
1972 int positionOld = 0;
1973
1974 for (const auto& testFEBslowctest : testFEB.getNodes("slowc")) {
1975 int position = testFEBslowctest.getInt("id");
1976 if (position == positionOld) {i++; }
1977 else {i = 1; }
1978 if (i == 10) {
1979 string dnaNew = testFEBslowctest.getString("dna");
1980 if (dnaNew == dna) {
1981 float tmon0 = (float) testFEBslowctest.getDouble("TMON0");
1982 float tmon1 = (float) testFEBslowctest.getDouble("TMON1");
1983 float vdd = (float) testFEBslowctest.getDouble("VDD");
1984 float v2p = (float) testFEBslowctest.getDouble("V2P");
1985 float v2n = (float) testFEBslowctest.getDouble("V2N");
1986 float vss = (float) testFEBslowctest.getDouble("VSS");
1987 float vth1 = (float) testFEBslowctest.getDouble("VTH1");
1988 float vth2 = (float) testFEBslowctest.getDouble("VTH2");
1989 float vcc12 = (float) testFEBslowctest.getDouble("VCC12");
1990 float vcc15 = (float) testFEBslowctest.getDouble("VCC15");
1991 float vcc25 = (float) testFEBslowctest.getDouble("VCC25");
1992 float v38p = (float) testFEBslowctest.getDouble("V38P");
1993
1994 febConst->setTemperature0(tmon0);
1995 febConst->setTemperature1(tmon1);
1996 febConst->setVdd(vdd);
1997 febConst->setV2p(v2p);
1998 febConst->setV2n(v2n);
1999 febConst->setVss(vss);
2000 febConst->setVth1(vth1);
2001 febConst->setVth2(vth2);
2002 febConst->setVcc12(vcc12);
2003 febConst->setVcc15(vcc15);
2004 febConst->setVcc25(vcc25);
2005 febConst->setV38p(v38p);
2006 febConst->setTimeSlowC(ARICHDatabaseImporter::timedate2(timeSlowC));
2007
2008 }
2009 }
2010 positionOld = position;
2011 }
2012 }
2013
2014 // slopes (from offset settings measurements)
2015 pair<vector<float>, vector<float>> slopes = ARICHDatabaseImporter::getSlopes(serial, runSCAN);
2016
2017 febConst->setSlopesFine(slopes.first); // std::vector<float>
2018 febConst->setSlopesRough(slopes.second); // std::vector<float>
2019
2020 // set FWHM values&sigmas)
2021 vector<pair<float, float>> fwhm = ARICHDatabaseImporter::getFwhm(serial, runSCAN);
2022 febConst->setFWHM(fwhm);
2023 }
2024
2025
2026 // high voltage test data
2027 if (!runHV.empty()) {
2028 int hvRun;
2029 if (stoi(runHV.c_str()) < 43) {hvRun = stoi(runHV.c_str());}
2030 else {hvRun = stoi(runHV.c_str()) - 57;}
2031 tuple<string, float> HVtest = ARICHDatabaseImporter::getFebHVtestData(serial, hvRun);
2032 febConst->setTimeHV(ARICHDatabaseImporter::timedate2(get<0>(HVtest)));
2033 febConst->setCurrentV99p(get<1>(HVtest));
2034 }
2035
2036
2037 // low voltage test data
2038 if (!runLV.empty()) {
2039 int lvRun;
2040 if (stoi(runLV.c_str()) < 43) {lvRun = stoi(runLV.c_str());}
2041 else {lvRun = stoi(runLV.c_str()) - 57;}
2042 tuple<string, float, float, float> LVtest = ARICHDatabaseImporter::getFebLVtestData(serial, lvRun);
2043 febConst->setTimeLV(ARICHDatabaseImporter::timedate2(get<0>(LVtest)));
2044 febConst->setCurrentV20p(get<1>(LVtest));
2045 febConst->setCurrentV21n(get<2>(LVtest));
2046 febConst->setCurrentV38p(get<3>(LVtest));
2047 }
2048
2049 feb++;
2050
2051 }
2052
2053// define IOV and store data to the DB
2054 Database::Instance().storeData("ARICHFebTest", &febConstants, m_iov);
2055}
2056
2057
2058
2060{
2061 TFile f("febTestHistograms.root", "recreate");
2062 TH3F* offsetRough = 0;
2063 TH3F* offsetFine = 0;
2064 TH2F* testPulse = 0;
2065 int serial;
2066
2067 // define tree
2068 TTree* tree = new TTree("febTest", "feb test data");
2069
2070 tree->Branch("serial", &serial, "sn/I");
2071 tree->Branch("offsetRough", "TH3F", &offsetRough);
2072 tree->Branch("offsetFine", "TH3F", &offsetFine);
2073 tree->Branch("testPulse", "TH2F", &testPulse);
2074
2075 int febposition = -1;
2076
2077 GearDir content = GearDir("/ArichData/AllData/arich");
2078 GearDir content1 = GearDir("/ArichData/AllData/dnamap");
2079 GearDir content2 = GearDir("/ArichData/AllData/FEBData/Content");
2080
2081 for (const auto& runserial : content.getNodes("run")) {
2082 serial = runserial.getInt("sn");
2083 string runSCAN = runserial.getString("scan");
2084 int l = 0;
2085 string dna;
2086
2087 for (const auto& febmap : content1.getNodes("febps")) {
2088 string somedna = febmap.getString("@dna");
2089 int sn = febmap.getInt("sn");
2090 if ((l == 0) && (sn == serial)) {
2091 dna = somedna;
2092 l++;
2093 }
2094 }
2095 // slow control data
2096 if (!runSCAN.empty()) {
2097 int scanRun;
2098 if (stoi(runSCAN.c_str()) < 23) {scanRun = stoi(runSCAN.c_str());}
2099 else {scanRun = stoi(runSCAN.c_str()) - 77;}
2100 for (const auto& testFEB : content2.getNodes("febtest[" + std::to_string(scanRun) + "]")) {
2101 int i = 0;
2102 int positionOld = 0;
2103
2104 for (const auto& testFEBslowctest : testFEB.getNodes("slowc")) {
2105 int position = testFEBslowctest.getInt("id");
2106 if (position == positionOld) {i++; }
2107 else {i = 1; }
2108 if (i == 10) {
2109 string dnaNew = testFEBslowctest.getString("dna");
2110 if (dnaNew == dna) febposition = position;
2111 }
2112 positionOld = position;
2113 }
2114 }
2115 vector<TH3F*> histograms = getFebTestHistograms(dna, runSCAN, febposition);
2116 offsetRough = histograms[0];
2117 offsetFine = histograms[1];
2118
2119 testPulse = ARICHDatabaseImporter::getFebTestPulse(dna, runSCAN, febposition); // TH2F*
2120
2121 testPulse->SetDirectory(0);
2122 offsetRough->SetDirectory(0);
2123 offsetFine->SetDirectory(0);
2124
2125 tree->Fill();
2126
2127 delete testPulse;
2128 delete offsetRough;
2129 delete offsetFine;
2130 }
2131 }
2132
2133 f.cd();
2134 tree->Write();
2135 f.Close();
2136
2137
2138// define IOV and store data to the DB
2139 Database::Instance().addPayload("ARICHFebTestRoot", "febTestHistograms.root", m_iov);
2140
2141}
2142
2143std::tuple<std::string, float, float, float> ARICHDatabaseImporter::getFebLVtestData(int serial, int lvRun)
2144{
2145 GearDir content2LV = GearDir("/ArichData/AllData/FEBDataLV/Content");
2146 std::tuple<std::string, float, float, float> LVtest;
2147 float currentV20p = 0.0, currentV21n = 0.0, currentV38p = 0.0;
2148
2149 for (const auto& testFEBlv : content2LV.getNodes("febtest[" + std::to_string(lvRun) + "]")) {
2150 string timeLV = testFEBlv.getString("time");
2151 for (const auto& testFEBlv_sn : testFEBlv.getNodes("lvtest/feb[sn='" + to_string(serial) + "']/febps/n[@id='14']")) {
2152 for (const auto& testFEBlv_pw : testFEBlv_sn.getNodes("pw18")) {
2153 if (testFEBlv_pw.getInt("@id") == 0) { currentV20p = (float) testFEBlv_pw.getDouble("I"); }
2154 if (testFEBlv_pw.getInt("@id") == 1) { currentV21n = (float) testFEBlv_pw.getDouble("I"); }
2155 if (testFEBlv_pw.getInt("@id") == 2) { currentV38p = (float) testFEBlv_pw.getDouble("I"); }
2156 LVtest = make_tuple(timeLV, currentV20p, currentV21n, currentV38p);
2157 }
2158 }
2159 }
2160 return LVtest;
2161}
2162
2163
2164std::tuple<std::string, float> ARICHDatabaseImporter::getFebHVtestData(int serial, int hvRun)
2165{
2166 GearDir content2HV = GearDir("/ArichData/AllData/FEBDataHV/Content");
2167 std::tuple<std::string, float> HVtest;
2168 for (const auto& testFEBhv : content2HV.getNodes("febtest[" + std::to_string(hvRun) + "]")) {
2169 string timeHV = testFEBhv.getString("time");
2170 for (const auto& testFEBhv_sn : testFEBhv.getNodes("hvtest/feb[sn='" + to_string(serial) + "']/febhv/n[@id='9']")) {
2171 float currentV99p = (float) testFEBhv_sn.getDouble("n1470/I");
2172 HVtest = std::make_tuple(timeHV, currentV99p);
2173 }
2174 }
2175 return HVtest;
2176}
2177
2178std::vector<int> ARICHDatabaseImporter::getDeadChFEB(const std::string& dna)
2179{
2180 vector<int> listCHs;
2181 string line;
2182 ifstream fileFEB("febTest/FEBdeadChannels.txt");
2183 if (fileFEB.is_open()) {
2184 while (getline(fileFEB, line)) {
2185 string ch2 = line.substr(line.find(",") + 1);
2186 string dna2 = line.erase(line.find(",") - 1);
2187 if (dna2 == dna) { listCHs.push_back(atoi(ch2.c_str())); }
2188 }
2189 } else { B2INFO("No file FEBdeadChannels.txt"); }
2190 fileFEB.close();
2191
2192 return listCHs;
2193}
2194
2195TTimeStamp ARICHDatabaseImporter::timedate2(std::string time)
2196{
2197 // convert string into TTimeStamp
2198 string dateMeas = time.substr(4);
2199 string yearStr = dateMeas.substr(16, 4);
2200 string monthStr = dateMeas.substr(0, 3);
2201 string dayStr = dateMeas.substr(4, 2);
2202 string hourStr = dateMeas.substr(7, 2);
2203 string minStr = dateMeas.substr(10, 2);
2204 string secStr = dateMeas.substr(13, 2);
2205
2206 int year = atoi(yearStr.c_str());
2207 int day = atoi(dayStr.c_str());
2208 int hour = atoi(hourStr.c_str());
2209 int min = atoi(minStr.c_str());
2210 int sec = atoi(secStr.c_str());
2211 map<string, int> months {
2212 { "Jan", 1 }, { "Feb", 2 }, { "Mar", 3 }, { "Apr", 4 }, { "May", 5 }, { "Jun", 6 }, { "Jul", 7 }, { "Aug", 8 }, { "Sep", 9 }, { "Oct", 10 }, { "Nov", 11 }, { "Dec", 12 }
2213 };
2214 int month = months.find(monthStr)->second;
2215
2216 TTimeStamp datum = TTimeStamp(year, month, day, hour, min, sec, 0, kTRUE, 0);
2217 return datum;
2218}
2219
2220std::pair<std::vector<float>, std::vector<float>> ARICHDatabaseImporter::getSlopes(int serialNum, const std::string& run)
2221{
2222 GearDir contentData = GearDir("/ArichData/AllData/SlopesFebTest/Content");
2223 pair<vector<float>, vector<float>> slopesFebTest;
2224 vector<float> slopesCoarse, slopesFine;
2225
2226 for (const auto& contentSlopes : contentData.getNodes("febtest")) {
2227 if ((contentSlopes.getInt("@id") == serialNum) && (contentSlopes.getString("@run") == run)) {
2228 for (int i = 0; i < 144; i++) {
2229 for (const auto& contSlopes : contentSlopes.getNodes("slope/ch[@id='" + to_string(i) + "']")) {
2230 float slopeCoarse = ((float) contSlopes.getDouble("coarse")) * 2.5 / 1024; // slope in V/step
2231 float slopeFine = ((float) contSlopes.getDouble("fine")) * 2.5 / 1024; // slope in V/step
2232 slopesCoarse.push_back(slopeCoarse);
2233 slopesFine.push_back(slopeFine);
2234 }
2235 }
2236 }
2237 slopesFebTest = std::make_pair(slopesFine, slopesCoarse);
2238 }
2239 return slopesFebTest;
2240}
2241
2242std::vector<std::pair<float, float>> ARICHDatabaseImporter::getFwhm(int serialNum, const std::string& run)
2243{
2244 GearDir contentData = GearDir("/ArichData/AllData/SlopesFebTest/Content");
2245 vector<pair<float, float>> fwhm;
2246
2247 for (const auto& contentSlopes : contentData.getNodes("febtest")) {
2248 if ((contentSlopes.getInt("@id") == serialNum) && (contentSlopes.getString("@run") == run)) {
2249 for (const auto& contSlopes : contentSlopes.getNodes("data/ch")) {
2250 float fwhmVal = (float) contSlopes.getDouble("fwhm");
2251 float fwhmSig = (float) contSlopes.getDouble("sigma");
2252 pair<float, float> fwhmPair = std::make_pair(fwhmVal, fwhmSig);
2253 fwhm.push_back(fwhmPair);
2254 }
2255 }
2256 }
2257 return fwhm;
2258}
2259
2260std::vector<TH3F*> ARICHDatabaseImporter::getFebTestHistograms(const std::string& dna, const std::string& run, int febposition)
2261{
2262 vector<TH3F*> histogrami;
2263
2264 for (const string& inputFile : m_inputFilesFebTest) {
2265
2266 if (inputFile.find(run) != string::npos) {
2267 TFile* f = TFile::Open(inputFile.c_str(), "READ");
2268 int iMIN = 0, iMAX = 0, delta, stepsNum = 16, i = 0, point2 = 24;
2269 string option;
2270 float stepsMax = 15.5;
2271
2272 // check how many steps were measured
2273 TIter next(f->GetListOfKeys());
2274 TKey* key;
2275 while ((key = (TKey*)next())) {
2276 string strime = key->GetName();
2277 if (strime.compare(0, 5, "h2d_0") == 0) i++;
2278 }
2279
2280 // fill histogram for coarse/fine settings
2281 for (int k = 0; k < 2; k++) {
2282 if (i < 32) {
2283 stepsNum = 15;
2284 stepsMax = 14.5;
2285 point2 = 23;
2286 if (k == 0) { option = "coarse"; iMIN = 2; iMAX = 16; delta = 2;}
2287 if (k == 1) { option = "fine"; iMIN = 17; iMAX = 31; delta = 17; }
2288 } else {
2289 if (k == 0) { option = "coarse"; iMIN = 2; iMAX = 17; delta = 2; }
2290 if (k == 1) { option = "fine"; iMIN = 18; iMAX = 33; delta = 18; }
2291 }
2292
2293 TH3F* histogram = new TH3F((option + " " + dna).c_str(), (option + " " + dna).c_str(), 144, -0.5, 143.5, 250, 299, 799, stepsNum,
2294 -0.5, stepsMax);
2295
2296 for (int j = iMIN; j < iMAX + 1; j++) {
2297 TH2F* hist2d = (TH2F*)f->Get(("h2d_0;" + std::to_string(j)).c_str());
2298 hist2d->SetDirectory(0);
2299
2300 int binZ;
2301 if ((j - delta) < 8) {binZ = 8 - (j - delta);}
2302 if ((j - delta) > 7) {binZ = point2 - (j - delta);}
2303 // conversion TH2F -> TH3F
2304 for (int binX = 144 * febposition + 1; binX < 144 * (febposition + 1) + 1; binX++) {
2305 for (int binY = 1; binY < 251; binY++) {
2306 histogram->SetBinContent(binX - 144 * febposition, binY, binZ, hist2d->GetBinContent(binX, binY));
2307 }
2308 }
2309 }
2310 histogram->SetDirectory(0);
2311 histogrami.push_back(histogram);
2312 for (int kanal = 1; kanal < 145; kanal ++) {
2313 for (int offset = 1; offset < stepsNum + 1; offset++) {
2314 TH1D* h1 = histogram->ProjectionY("A", kanal, kanal, offset, offset);
2315 h1->SetName((dna + " kanal: " + to_string(kanal) + ", offset: " + to_string(offset)).c_str());
2316 }
2317 }
2318 }
2319 f->Close();
2320 }
2321 }
2322
2323 return histogrami;
2324}
2325
2326TH2F* ARICHDatabaseImporter::getFebTestPulse(const std::string& dna, const std::string& run, int febposition)
2327{
2328 TH2F* testPulse = new TH2F(("test pulse " + dna).c_str(), ("test pulse " + dna).c_str(), 144, -0.5, 143.5, 250, 299, 799);
2329
2330 for (const string& inputFile : m_inputFilesFebTest) {
2331 if (inputFile.find(run) != string::npos) {
2332 TFile* f = TFile::Open(inputFile.c_str(), "READ");
2333 TH2F* pulseTest = (TH2F*)f->Get("h2d_0;1");
2334 pulseTest->SetDirectory(0);
2335 for (int binX = 144 * febposition + 1; binX < 144 * (febposition + 1) + 1; binX++) {
2336 for (int binY = 1; binY < 251; binY++) {
2337 testPulse->SetBinContent(binX - 144 * febposition, binY, pulseTest->GetBinContent(binX, binY));
2338 }
2339 }
2340 f->Close();
2341 }
2342 }
2343 return testPulse;
2344}
2345
2346
2347
2349{
2350
2351 DBArray<ARICHFebTest> elements("ARICHFebTest");
2352 elements.getEntries();
2353
2354 // Print serial numbers of FEBs
2355 for (const auto& element : elements) {
2356 B2INFO("Serial = " << element.getFebSerial() << "; dna = " << element.getFebDna() << "; slope R (ch143) = " <<
2357 element.getSlopeRough(143) << "; slope F (ch143) = " << element.getSlopeFine(143) << "; comment = " << element.getComment());
2358 }
2359
2360}
2361
2363{
2364 int chip_i = 0;
2365 GearDir content = GearDir("/ArichData/AllData/hapdData/Content");
2366
2367 // define data array
2368 TClonesArray chipConstants("Belle2::ARICHHapdChipInfo");
2369
2370 // extract chip info, such as bias voltage, lists of dead and bad channels etc.
2371 for (const auto& hapdInfo : content.getNodes("hapd")) {
2372 // extract information about HAPD
2373 string sn = hapdInfo.getString("serial");
2374
2375 // define objects for chip info
2376 string chip[4];
2377 int channel_label_aval[4], bias[4], gain[4];
2378 TGraph** bombardmentGain, **avalancheGain;
2379 bombardmentGain = new TGraph *[4];
2380 avalancheGain = new TGraph *[4];
2381 TH2F** bias2DV, **bias2DI;
2382 bias2DV = new TH2F *[4];
2383 bias2DI = new TH2F *[4];
2384 vector<int> badlist[4], cutlist[4];
2385 vector<TGraph*> bombCurrents[4], avalCurrents[4];
2386 int chip_ABCD = 0;
2387
2388 // extract information for each chip
2389 for (const auto& chipInfo : hapdInfo.getNodes("chipinfo")) {
2390 chip[chip_ABCD] = chipInfo.getString("chip");
2391 bias[chip_ABCD] = chipInfo.getInt("bias");
2392 string badL = chipInfo.getString("deadlist");
2393 string cutL = chipInfo.getString("cutlist");
2394 if (badL.find("ch") != string::npos) { string badLsub = badL.substr(3); badlist[chip_ABCD] = ARICHDatabaseImporter::channelsListHapd(badLsub.c_str(), chip[chip_ABCD]); }
2395 if (cutL.find("ch") != string::npos) { string cutLsub = cutL.substr(3); cutlist[chip_ABCD] = ARICHDatabaseImporter::channelsListHapd(cutLsub.c_str(), chip[chip_ABCD]); }
2396 string gain_str = chipInfo.getString("gain");
2397 gain[chip_ABCD] = atoi(gain_str.c_str());
2398 chip_ABCD++;
2399 }
2400
2401 // prepare TGraphs for bombardment gain and current
2402 const int n3 = 30;
2403 int i3 = 0;
2404 //int channel_label_bomb;
2405 float hv_bomb[n3], gain_bomb[n3], current1_bomb[n3], current2_bomb[n3], current3_bomb[n3];
2406 chip_ABCD = 0;
2407 for (const auto& BG : hapdInfo.getNodes("bombardmentgain/ch")) {
2408 string value = BG.getString("value");
2409 string chip_label = value.erase(1);
2410 for (const auto& BG2 : BG.getNodes("point")) {
2411 hv_bomb[i3] = (float) BG2.getDouble("hv");
2412 gain_bomb[i3] = (float) BG2.getDouble("gain");
2413 current1_bomb[i3] = (float) BG2.getDouble("current1");
2414 current2_bomb[i3] = (float) BG2.getDouble("current2");
2415 current3_bomb[i3] = (float) BG2.getDouble("current3");
2416 i3++;
2417 }
2418
2419 bombardmentGain[chip_ABCD] = ARICHDatabaseImporter::getGraphGainCurrent("Bombardment", "gain", chip_label, i3, hv_bomb, gain_bomb);
2420 TGraph* bombardmentCurrent1 = ARICHDatabaseImporter::getGraphGainCurrent("Bombardment", "current1", chip_label, i3, hv_bomb,
2421 current1_bomb);
2422 TGraph* bombardmentCurrent2 = ARICHDatabaseImporter::getGraphGainCurrent("Bombardment", "current2", chip_label, i3, hv_bomb,
2423 current2_bomb);
2424 TGraph* bombardmentCurrent3 = ARICHDatabaseImporter::getGraphGainCurrent("Bombardment", "current3", chip_label, i3, hv_bomb,
2425 current3_bomb);
2426 bombCurrents[chip_ABCD].push_back(bombardmentCurrent1);
2427 bombCurrents[chip_ABCD].push_back(bombardmentCurrent2);
2428 bombCurrents[chip_ABCD].push_back(bombardmentCurrent3);
2429 chip_ABCD++;
2430 i3 = 0;
2431 }
2432
2433 // prepare TGraphs for avalanche gain and current
2434 const int n4 = 30;
2435 int i4 = 0;
2436 float hv_aval[n4], gain_aval[n4], current1_aval[n4], current2_aval[n4], current3_aval[n4];
2437 chip_ABCD = 0;
2438 for (const auto& BG : hapdInfo.getNodes("avalanchegain/ch")) {
2439 string value = BG.getString("value");
2440 string value_1 = value;
2441 string chip_label = value.erase(1);
2442 string value_2 = value_1.substr(2);
2443 channel_label_aval[chip_ABCD] = atoi(value_2.c_str());
2444 for (const auto& BG2 : BG.getNodes("point")) {
2445 hv_aval[i4] = (float) BG2.getDouble("biasv");
2446 gain_aval[i4] = (float) BG2.getDouble("gain");
2447 current1_aval[i4] = (float) BG2.getDouble("current1");
2448 current2_aval[i4] = (float) BG2.getDouble("current2");
2449 current3_aval[i4] = (float) BG2.getDouble("current3");
2450 i4++;
2451 }
2452
2453 avalancheGain[chip_ABCD] = ARICHDatabaseImporter::getGraphGainCurrent("Avalanche", "gain", chip_label, i4, hv_aval, gain_aval);
2454 TGraph* avalancheCurrent1 = ARICHDatabaseImporter::getGraphGainCurrent("Avalanche", "current1", chip_label, i4, hv_aval,
2455 current1_aval);
2456 TGraph* avalancheCurrent2 = ARICHDatabaseImporter::getGraphGainCurrent("Avalanche", "current2", chip_label, i4, hv_aval,
2457 current2_aval);
2458 TGraph* avalancheCurrent3 = ARICHDatabaseImporter::getGraphGainCurrent("Avalanche", "current3", chip_label, i4, hv_aval,
2459 current3_aval);
2460 avalCurrents[chip_ABCD].push_back(avalancheCurrent1);
2461 avalCurrents[chip_ABCD].push_back(avalancheCurrent2);
2462 avalCurrents[chip_ABCD].push_back(avalancheCurrent3);
2463
2464 chip_ABCD++;
2465 i4 = 0;
2466 }
2467
2468
2469 chip_ABCD = 0;
2470 // prepare 2D histograms for bias voltage and current
2471 const int n5 = 150;
2472 int i5 = 0, chipnum[n5];
2473 float biasv[n5], biasi[n5];
2474 for (const auto& HI : hapdInfo.getNodes("bias2d/biasvalue")) {
2475 string chip_2d = HI.getString("@chip");
2476 chipnum[i5] = HI.getInt("@ch");
2477 biasv[i5] = (float) HI.getDouble("biasv");
2478 biasi[i5] = (float) HI.getDouble("biasi");
2479 if (chipnum[i5] == 36) {
2480 bias2DV[chip_ABCD] = ARICHDatabaseImporter::getBiasGraph(chip_2d, "voltage", chipnum, biasv);
2481 bias2DI[chip_ABCD] = ARICHDatabaseImporter::getBiasGraph(chip_2d, "current", chipnum, biasi);
2482 i5 = -1;
2483 chip_ABCD++;
2484 }
2485 i5++;
2486 }
2487
2488 // prepare ARICHHapdChipInfo class for each chip
2489 for (unsigned int l = 0; l < 4; l++) {
2490 new (chipConstants[4 * chip_i + l]) ARICHHapdChipInfo();
2491 auto* chipConst = static_cast<ARICHHapdChipInfo*>(chipConstants[4 * chip_i + l]);
2492
2493 chipConst->setHapdSerial(sn);
2494 chipConst->setChipLabel(chip[l]);
2495 chipConst->setBiasVoltage(bias[l]);
2496 chipConst->setGain(gain[l]);
2497 chipConst->setBadChannel(badlist[l]);
2498 chipConst->setCutChannel(cutlist[l]);
2499 chipConst->setBombardmentGain(bombardmentGain[l]);
2500 chipConst->setBombardmentCurrent(bombCurrents[l]);
2501 chipConst->setAvalancheGain(avalancheGain[l]);
2502 chipConst->setAvalancheCurrent(avalCurrents[l]);
2503 chipConst->setChannelNumber(channel_label_aval[l]);
2504 chipConst->setBiasVoltage2D(bias2DV[l]);
2505 chipConst->setBiasCurrent2D(bias2DI[l]);
2506 }
2507
2508 chip_i++;
2509
2510 delete[] bombardmentGain;
2511 delete[] avalancheGain;
2512 delete[] bias2DV;
2513 delete[] bias2DI;
2514 }
2515
2516 // define IOV and store data to the DB
2517 Database::Instance().storeData("ARICHHapdChipInfo", &chipConstants, m_iov);
2518}
2519
2521{
2522 DBArray<ARICHHapdChipInfo> elements("ARICHHapdChipInfo");
2523 elements.getEntries();
2524
2525 for (const auto& element : elements) {
2526 B2INFO("Serial = " << element.getHapdSerial() << ", chip = " << element.getChipLabel() << ", bias= " << element.getBiasVoltage());
2527 }
2528}
2529
2530
2531
2533{
2534 int hapd_i = 0;
2535 GearDir content = GearDir("/ArichData/AllData/hapdData/Content");
2536
2537 // define data array
2538 TClonesArray hapdConstants("Belle2::ARICHHapdInfo");
2539
2540 // extract chip info, such as bias voltage, lists of dead and bad channels etc.
2541 for (const auto& hapdInfo : content.getNodes("hapd")) {
2542 // define element of TClonesArray
2543 new (hapdConstants[hapd_i]) ARICHHapdInfo();
2544 auto* hapdConst = static_cast<ARICHHapdInfo*>(hapdConstants[hapd_i]);
2545
2546 // extract information about HAPD
2547 string serial = hapdInfo.getString("serial");
2548 float qe400 = (float) hapdInfo.getDouble("qe400");
2549 float hv = 1000 * (float) hapdInfo.getDouble("hv");
2550 float current = (float) hapdInfo.getDouble("current");
2551 string gb = hapdInfo.getString("guardbias");
2552 int guardbias = atoi(gb.c_str());
2553
2554 // prepare TGraph of quantum efficiency as function of lambda
2555 const int n1 = 70;
2556 float lambda[n1], qepoint[n1];
2557 int i1 = 0;
2558 for (const auto& QE : hapdInfo.getNodes("qe/qepoint")) {
2559 lambda[i1] = (float) QE.getInt("@lambda");
2560 qepoint[i1] = (float) QE.getDouble(".");
2561 i1++;
2562 }
2563 TGraph* qe = new TGraph(i1, lambda, qepoint);
2564 qe->SetName("qe");
2565 qe->SetTitle("qe");
2566 qe->GetXaxis()->SetTitle("lambda");
2567 qe->GetYaxis()->SetTitle("qe");
2568
2569 // prepare TGraph of pulse height distribution
2570 const int n2 = 4100;
2571 int channel_adc[n2], pulse_adc[n2];
2572 int i2 = 0;
2573 for (const auto& ADC : hapdInfo.getNodes("adc/value")) {
2574 channel_adc[i2] = ADC.getInt("@ch");
2575 string str = ADC.getString(".");
2576 pulse_adc[i2] = atoi(str.c_str());
2577 i2++;
2578 }
2579 TGraph* adc = new TGraph(i2, channel_adc, pulse_adc);
2580 adc->SetName("adc");
2581 adc->SetTitle("Pulse Height Distribution");
2582 adc->GetXaxis()->SetTitle("channel");
2583 adc->GetYaxis()->SetTitle("pulse height");
2584
2585 // save HAPD data to the element of TClonesArray
2586 hapdConst->setSerialNumber(serial);
2587 hapdConst->setQuantumEfficiency400(qe400);
2588 hapdConst->setHighVoltage(hv);
2589 hapdConst->setGuardBias(guardbias);
2590 hapdConst->setCurrent(current);
2591 hapdConst->setQuantumEfficiency(qe);
2592 hapdConst->setPulseHeightDistribution(adc);
2593
2594 // export ARICHHapdChipInfo class for each chip from DB and
2595 // add it as an element of ARICHHapdInfo class
2596 DBArray<ARICHHapdChipInfo> elementsChip("ARICHHapdChipInfo");
2597 elementsChip.getEntries();
2598 for (const auto& element : elementsChip) {
2599 if (element.getHapdSerial() == serial) {
2600 ARICHHapdChipInfo& elementValue = const_cast<ARICHHapdChipInfo&>(element);
2601 if (element.getChipLabel() == "A") hapdConst->setHapdChipInfo(0, &elementValue);
2602 if (element.getChipLabel() == "B") hapdConst->setHapdChipInfo(1, &elementValue);
2603 if (element.getChipLabel() == "C") hapdConst->setHapdChipInfo(2, &elementValue);
2604 if (element.getChipLabel() == "D") hapdConst->setHapdChipInfo(3, &elementValue);
2605 }
2606 }
2607
2608 hapd_i++;
2609 }
2610
2611 // define IOV and store data to the DB
2612 Database::Instance().storeData("ARICHHapdInfo", &hapdConstants, m_iov);
2613}
2614
2615
2616// get list of bad channels on HAPD
2617std::vector<int> ARICHDatabaseImporter::channelsListHapd(std::string chlist, std::string chipDelay)
2618{
2619 B2INFO("channel list = " << chlist << ", chip = " << chipDelay);
2620 string chlistDig = ARICHTools::remove_chars_if_not(chlist, "0123456789,~");
2621
2622 vector<int> CHs = ARICHTools::getDeadCutList(*chipDelay.c_str(), ARICHTools::StringToVector::parse<int>(chlistDig, ','));
2623
2624 B2INFO("All channels: ");
2625 printContainer(CHs);
2626 return CHs;
2627}
2628
2629// prepare TGraph for bombardment/avalanche gain/current
2630TGraph* ARICHDatabaseImporter::getGraphGainCurrent(const std::string& bomb_aval, const std::string& g_i,
2631 const std::string& chip_label, int i, float* HV,
2632 float* gain_current)
2633{
2634 TGraph* hapd_graph = new TGraph(i, HV, gain_current);
2635 string title = bomb_aval + " " + g_i + ", chip " + chip_label;
2636 hapd_graph->SetTitle(title.c_str());
2637 hapd_graph->GetXaxis()->SetTitle("high voltage");
2638 hapd_graph->GetYaxis()->SetTitle(g_i.c_str());
2639 return hapd_graph;
2640}
2641
2642// use correct mapping of channels on HAPD
2643int ARICHDatabaseImporter::getChannelPosition(const std::string& XY, const std::string& chip_2d, int chipnum)
2644{
2645 int x = 100, y = 100;
2646 if (chip_2d == "A") {
2647 y = 12;
2648 x = 0 + chipnum;
2649 while (x > 6) {
2650 x = x - 6;
2651 y = y - 1;
2652 }
2653 } else if (chip_2d == "B") {
2654 x = 12;
2655 y = 13 - chipnum;
2656 while (y < 7) {
2657 y = y + 6;
2658 x = x - 1;
2659 }
2660 } else if (chip_2d == "C") {
2661 y = 1;
2662 x = 13 - chipnum;
2663 while (x < 7) {
2664 x = x + 6;
2665 y = y + 1;
2666 }
2667 } else if (chip_2d == "D") {
2668 x = 1;
2669 y = 0 + chipnum;
2670 while (y > 6) {
2671 y = y - 6;
2672 x = x + 1;
2673 }
2674 }
2675
2676 if (XY == "x") { return x;}
2677 else if (XY == "y") { return y;}
2678 else {return 100;}
2679}
2680
2681// prepare 2D histogram for bias voltage/current
2682TH2F* ARICHDatabaseImporter::getBiasGraph(const std::string& chip_2d, const std::string& voltage_current, int* chipnum,
2683 float* bias_v_i)
2684{
2685 string name = "bias " + voltage_current + ", chip " + chip_2d;
2686 TH2F* bias2d = new TH2F("bias2d", name.c_str(), 6, 0, 6, 6, 0, 6);
2687 for (int XYname = 0; XYname < 6; XYname++) {
2688 bias2d->GetXaxis()->SetBinLabel(XYname + 1, to_string(XYname).c_str());
2689 bias2d->GetYaxis()->SetBinLabel(XYname + 1, to_string(6 * XYname).c_str());
2690 }
2691 for (int XY = 0; XY < 36; XY++) {
2692 int x = 1;
2693 int y = 0 + chipnum[XY];
2694 while (y > 6) {
2695 y = y - 6;
2696 x = x + 1;
2697 }
2698 bias2d->SetBinContent(x, y, bias_v_i[XY]);
2699 }
2700 bias2d->SetDirectory(0);
2701 return bias2d;
2702}
2703
2705{
2706
2707 DBArray<ARICHHapdInfo> elements("ARICHHapdInfo");
2708 elements.getEntries();
2709
2710 for (const auto& element : elements) {
2711 B2INFO("Serial = " << element.getSerialNumber() << "; HV = " << element.getHighVoltage() << "; qe400 = " <<
2712 element.getQuantumEfficiency400());
2713 for (int n = 0; n < 4; n++) {
2714 ARICHHapdChipInfo* newelement = element.getHapdChipInfo(n);
2715 B2INFO("biasV(chip" << n << ") = " << newelement->getBiasVoltage());
2716 }
2717 /* TGraph* adc = element.getPulseHeightDistribution();
2718 TFile file("histogrami.root", "update");
2719 adc->Write();
2720 file.Close();
2721 */
2722 }
2723}
2724
2725
2727{
2728 // define data array
2729 TClonesArray hapdQEConstants("Belle2::ARICHHapdQE");
2730 int hapd = 0;
2731
2732 // loop over root riles
2733 for (const string& inputFile : m_inputFilesHapdQE) {
2734
2735 TFile* f = TFile::Open(inputFile.c_str(), "READ");
2736
2737 int size = inputFile.length();
2738 string hapdSerial = inputFile.substr(size - 11, 6);
2739 TH2F* qe2D = 0;
2740
2741 // extract data
2742 TIter next(f->GetListOfKeys());
2743 TKey* key;
2744 while ((key = (TKey*)next())) {
2745
2746 string strime = key->GetName();
2747
2748 if (strime.compare(0, 11, "hqe2d_pixel") == 0) {
2749 qe2D = (TH2F*)f->Get(strime.c_str());
2750 qe2D->SetTitle("quantum efficiency");
2751 qe2D->SetName("QE");
2752 qe2D->SetDirectory(0);
2753 }
2754
2755 else { B2INFO("Key name does not match 'hqe2d_pixel'!"); }
2756 }
2757
2758 // save data as an element of the array
2759 new (hapdQEConstants[hapd]) ARICHHapdQE(hapdSerial, qe2D);
2760 hapd++;
2761 f->Close();
2762 }
2763
2764 // define IOV and store data to the DB
2765 Database::Instance().storeData("ARICHHapdQE", &hapdQEConstants, m_iov);
2766}
2767
2768
2770{
2771 DBArray<ARICHHapdQE> elements("ARICHHapdQE");
2772 elements.getEntries();
2773 gROOT->SetBatch(kTRUE);
2774
2775 // Example that prints serial numbers of HAPDs and saves QE 2D histograms to root file
2776 for (const auto& element : elements) {
2777 B2INFO(" SN = " << element.getHapdSerialNumber());
2778 TH2F* qe2d = element.getQuantumEfficiency2D();
2779 TFile file("QEhists.root", "update");
2780 qe2d->Write();
2781 file.Close();
2782 }
2783
2784}
2785
2786void ARICHDatabaseImporter::printBiasVoltagesForHapdChip(const std::string& serialNumber)
2787{
2788 // example that shows how to extract and use data
2789 // it calculates bias voltage at gain = 40 for each chip
2790
2791 DBArray<ARICHHapdChipInfo> elements("ARICHHapdChipInfo");
2792 elements.getEntries();
2793
2794 for (const auto& element : elements) {
2795 if (element.getHapdSerial() == serialNumber) {
2796 TGraph* avalgain = element.getAvalancheGain();
2797
2798 // use linear interpolation to get bias voltage at gain = 40
2799 /*
2800 // 1) you can do it by hand
2801
2802 double A, B, C, D;
2803 for(int j = 0; j < 100; j++) {
2804 avalgain->GetPoint(j, A, B);
2805 if(B>40) {
2806 avalgain->GetPoint(j-1, A, B);
2807 avalgain->GetPoint(j, C, D);
2808 float k = (B-D)/(A-C);
2809 float n = B - k*A;
2810 float xgain = (40 - n)/k;
2811 B2INFO("serial#-chip = " << element.getHapdSerial() << "-" << element.getChipLabel() << "; " << "V(gain=40) = " << (int)(xgain+0.5));
2812 j = 100;
2813 }
2814 }
2815 */
2816
2817 // 2) use "Eval" function
2818 // - avalgain graph is gain(voltage)
2819 // - function "Eval" can be used to interpolate around chosen x
2820 // - convert graph gain(voltage) to voltage(gain) to interpolate around gain = 40
2821 TGraph* gainnew = new TGraph(avalgain->GetN());
2822 double xpoint, ypoint;
2823 for (int j = 0; j < avalgain->GetN(); j++) {
2824 avalgain->GetPoint(j, xpoint, ypoint);
2825 gainnew->SetPoint(j, ypoint, xpoint);
2826 }
2827 B2INFO("serial#-chip = " << element.getHapdSerial() << "-" << element.getChipLabel() << "; " << "V(gain=40) = " << (int)(
2828 gainnew->Eval(40) + 0.5));
2829 }
2830 }
2831}
2832
2833void ARICHDatabaseImporter::printMyParams(const std::string& aeroSerialNumber)
2834{
2835 map<string, float> aerogelParams = ARICHDatabaseImporter::getAerogelParams(aeroSerialNumber);
2836
2837 B2INFO("SN = " << aeroSerialNumber << "; n = " << aerogelParams.find("refractiveIndex")->second << "; transLen = " <<
2838 aerogelParams.find("transmissionLength")->second << "; thickness = " << aerogelParams.find("thickness")->second);
2839}
2840
2841
2842std::map<std::string, float> ARICHDatabaseImporter::getAerogelParams(const std::string& aeroSerialNumber)
2843{
2844 // Description:
2845 // This function loops over aerogel tiles and returns refractive index,
2846 // thickness and transmission length of aerogel for serial number
2847
2848 std::map<std::string, float> aerogelParams;
2849 DBArray<ARICHAerogelInfo> elements("ARICHAerogelInfo");
2850 elements.getEntries();
2851 for (const auto& element : elements) {
2852 if ((element.getAerogelSN()) == aeroSerialNumber) {
2853 aerogelParams = {
2854 { "refractiveIndex", element.getAerogelRefractiveIndex() },
2855 { "transmissionLength", element.getAerogelTransmissionLength() },
2856 { "thickness", element.getAerogelThickness() }
2857 };
2858 }
2859 }
2860 return aerogelParams;
2861}
2862
2864{
2865
2866 GearDir content = GearDir("/ArichData/AllData/febasicmapping");
2867
2868 // define data array
2869 TClonesArray febConstants("Belle2::ARICHFEBoardInfo");
2870 int feb = 0;
2871
2872 // loop over xml files and extract the data
2873 for (const auto& febinfo : content.getNodes("febasic")) {
2874 int febSN = (float) febinfo.getInt("sn");
2875 string asic1 = febinfo.getString("asic1");
2876 string asic2 = febinfo.getString("asic2");
2877 string asic3 = febinfo.getString("asic3");
2878 string asic4 = febinfo.getString("asic4");
2879 string delivery = febinfo.getString("delivered");
2880 string sentKEK = febinfo.getString("sentKEK");
2881
2882 if (delivery.size() != 10) cout << "feb sn " << febSN << " check delivery time!" << endl;
2883
2884 string year = delivery.substr(6, 4);
2885 delivery = febinfo.getString("delivered");
2886 string month = delivery.substr(3, 2);
2887 delivery = febinfo.getString("delivered");
2888 string day = delivery.substr(0, 2);
2889
2890 int deliveryINT = atoi((year + month + day + "u").c_str());
2891 TTimeStamp deliverytime(deliveryINT, 0u, 0u);
2892
2893 string location = "";
2894 if (!sentKEK.empty()) location = "KEK";
2895
2896 // save data as an element of the array
2897 new (febConstants[feb]) ARICHFEBoardInfo();
2898 auto* febConst = static_cast<ARICHFEBoardInfo*>(febConstants[feb]);
2899 febConst->setFEBoardSerial(febSN);
2900 febConst->setAsicPosition(0, asic1);
2901 febConst->setAsicPosition(1, asic2);
2902 febConst->setAsicPosition(2, asic3);
2903 febConst->setAsicPosition(3, asic4);
2904 febConst->setTimeStamp(deliverytime);
2905 febConst->setFEBoardLocation(location);
2906
2907 DBArray<ARICHAsicInfo> elementsAsic("ARICHAsicInfo");
2908 elementsAsic.getEntries();
2909 for (const auto& element : elementsAsic) {
2910 if (element.getAsicID() == asic1) {
2911 ARICHAsicInfo& elementValue = const_cast<ARICHAsicInfo&>(element);
2912 febConst->setAsicInfo(0, &elementValue);
2913 }
2914 if (element.getAsicID() == asic2) {
2915 ARICHAsicInfo& elementValue = const_cast<ARICHAsicInfo&>(element);
2916 febConst->setAsicInfo(1, &elementValue);
2917 }
2918 if (element.getAsicID() == asic3) {
2919 ARICHAsicInfo& elementValue = const_cast<ARICHAsicInfo&>(element);
2920 febConst->setAsicInfo(2, &elementValue);
2921 }
2922 if (element.getAsicID() == asic4) {
2923 ARICHAsicInfo& elementValue = const_cast<ARICHAsicInfo&>(element);
2924 febConst->setAsicInfo(3, &elementValue);
2925 }
2926 }
2927
2928 feb++;
2929 }
2930
2931 // store under user defined name:
2932 Database::Instance().storeData("ARICHFEBoardInfo", &febConstants, m_iov);
2933}
2934
2936{
2937 DBArray<ARICHFEBoardInfo> elements("ARICHFEBoardInfo");
2938 elements.getEntries();
2939
2940 for (const auto& element : elements) {
2941 B2INFO("Feb sn = " << element.getFEBoardSerial());
2942 for (int i = 0; i < 4; i++) {
2943 B2INFO("ASIC " << i << " = " << element.getAsicPosition(i));
2944 }
2945 }
2946}
2947
2948
2949void ARICHDatabaseImporter::importModuleTest(const std::string& mypath, const std::string& HVtest)
2950{
2951
2952
2953 std::string path;
2954 if (HVtest == "no") path = "/ArichData/AllData/moduletest";
2955 else if (HVtest == "yes") path = "/ArichData/AllData/moduletestHV";
2956 else B2INFO("Check HVB test parameter!");
2957
2958 GearDir content = GearDir(path);
2959
2960 // define data array
2961 TClonesArray moduleConstants("Belle2::ARICHModuleTest");
2962 int module = 0;
2963
2964 // loop over xml files and extract the data
2965 for (const auto& moduletest : content.getNodes("module")) {
2966 int febSN = (float) moduletest.getInt("febserial");
2967 string hapdSN = moduletest.getString("hapdserial");
2968 int hvbSN = -1;
2969 if (HVtest == "yes") hvbSN = (float) moduletest.getInt("hvbserial");
2970 int run = moduletest.getInt("run");
2971 int runposition = moduletest.getInt("runposition");
2972 int isok = moduletest.getInt("isok");
2973 bool isOK = false;
2974 if (isok == 1) isOK = true;
2975 string comment = moduletest.getString("comment");
2976
2977 vector<int> deadChannels;
2978
2979 if (HVtest == "no") {
2980 auto ids = ARICHTools::StringToVector::convert<ARICHTools::ModuleID_t>(moduletest.getString("dead"), ',');
2981 deadChannels.reserve(ids.size());
2982 for (const auto& rID : ids)
2983 deadChannels.emplace_back(rID.getNumbering());
2984 }
2985
2986
2987
2988 if (HVtest == "yes") {
2989 deadChannels = ARICHTools::StringToVector::convert<int>(moduletest.getString("dead"), ',');
2990 }
2991
2992 B2INFO("Dead channels: ");
2993 printContainer(deadChannels);
2994 // define histograms
2995 TGraph* guardBias_th = 0;
2996 TGraph* chipVdiff_th[4] = {0};
2997 TGraph* chipLeak_th[4] = {0};
2998 TGraph* HV_th = 0;
2999
3000 TGraph* guardBias_2Dx = 0;
3001 TGraph* chipVdiff_2Dx[4] = {0};
3002 TGraph* chipLeak_2Dx[4] = {0};
3003 TGraph* HV_2Dx = 0;
3004
3005 TGraph* guardBias_2Dy = 0;
3006 TGraph* chipVdiff_2Dy[4] = {0};
3007 TGraph* chipLeak_2Dy[4] = {0};
3008 TGraph* HV_2Dy = 0;
3009
3010 TH1F* gain = 0;
3011 TH2D* charge = 0;
3012 TH2D* th = 0;
3013 TH2D* scanX = 0;
3014 TH2D* scanY = 0;
3015
3016 string runStr = "";
3017 if (run < 10) runStr = "000" + to_string(run);
3018 if ((run > 9) && (run < 100)) runStr = "00" + to_string(run);
3019 if (run > 99) runStr = "0" + to_string(run);
3020 TFile* f = TFile::Open((mypath + runStr + "/" + runStr + "_" + hapdSN + "_out.root").c_str(), "READ");
3021
3022 // extract data
3023 TIter next(f->GetListOfKeys());
3024 TKey* key;
3025 while ((key = (TKey*)next())) {
3026
3027 string strime = key->GetName();
3028
3029 if (strime.find("Guard") != string::npos) {
3030 if (strime.find("_T_0") != string::npos) {
3031 guardBias_th = (TGraph*)f->Get(strime.c_str());
3032 }
3033 if (strime.find("_T_1") != string::npos) {
3034 guardBias_2Dx = (TGraph*)f->Get(strime.c_str());
3035 }
3036 if (strime.find("_T_2") != string::npos) {
3037 guardBias_2Dy = (TGraph*)f->Get(strime.c_str());
3038 }
3039 }
3040
3041 if (strime.find("BiasDifference") != string::npos) {
3042 for (int i = 0; i < 4; i++) {
3043 if (strime.find(("CHIP_" + to_string(i) + "_T_0").c_str()) != string::npos) {
3044 chipVdiff_th[i] = (TGraph*)f->Get(strime.c_str());
3045 }
3046 if (strime.find(("CHIP_" + to_string(i) + "_T_1").c_str()) != string::npos) {
3047 chipVdiff_2Dx[i] = (TGraph*)f->Get(strime.c_str());
3048 }
3049 if (strime.find(("CHIP_" + to_string(i) + "_T_2").c_str()) != string::npos) {
3050 chipVdiff_2Dy[i] = (TGraph*)f->Get(strime.c_str());
3051 }
3052 }
3053 }
3054
3055 if (strime.find("LeakageCurrent") != string::npos) {
3056 for (int i = 0; i < 4; i++) {
3057 if (strime.find(("CHIP_" + to_string(i) + "_T_0").c_str()) != string::npos) {
3058 chipLeak_th[i] = (TGraph*)f->Get(strime.c_str());
3059 }
3060 if (strime.find(("CHIP_" + to_string(i) + "_T_1").c_str()) != string::npos) {
3061 chipLeak_2Dx[i] = (TGraph*)f->Get(strime.c_str());
3062 }
3063 if (strime.find(("CHIP_" + to_string(i) + "_T_2").c_str()) != string::npos) {
3064 chipLeak_2Dy[i] = (TGraph*)f->Get(strime.c_str());
3065 }
3066 }
3067 }
3068
3069 if (strime.find("HV") != string::npos) {
3070 if (strime.find("_T_0") != string::npos) {
3071 HV_th = (TGraph*)f->Get(strime.c_str());
3072 }
3073 if (strime.find("_T_1") != string::npos) {
3074 HV_2Dx = (TGraph*)f->Get(strime.c_str());
3075 }
3076 if (strime.find("_T_2") != string::npos) {
3077 HV_2Dy = (TGraph*)f->Get(strime.c_str());
3078 }
3079 }
3080
3081 if (strime.find("Gain_1D") != string::npos) {
3082 gain = (TH1F*)f->Get(strime.c_str());
3083 gain->SetDirectory(0);
3084 }
3085
3086 if (strime.find("Charge_2D") != string::npos) {
3087 charge = (TH2D*)f->Get(strime.c_str());
3088 charge->SetDirectory(0);
3089 }
3090
3091 if (strime.find("Threshold_2D") != string::npos) {
3092 th = (TH2D*)f->Get(strime.c_str());
3093 th->SetDirectory(0);
3094 }
3095
3096 if (strime.find("Scan_2D_X") != string::npos) {
3097 scanX = (TH2D*)f->Get(strime.c_str());
3098 scanX->SetDirectory(0);
3099 }
3100
3101 if (strime.find("Scan_2D_Y") != string::npos) {
3102 scanY = (TH2D*)f->Get(strime.c_str());
3103 scanY->SetDirectory(0);
3104 }
3105 }
3106
3107 // save data as an element of the array
3108 new (moduleConstants[module]) ARICHModuleTest();
3109 auto* moduleConst = static_cast<ARICHModuleTest*>(moduleConstants[module]);
3110 moduleConst->setFebSN(febSN);
3111 moduleConst->setHapdSN(hapdSN);
3112 moduleConst->setRun(run);
3113 moduleConst->setRunPosition(runposition);
3114 moduleConst->setOK(isOK);
3115 moduleConst->setDeadChs(deadChannels);
3116 moduleConst->setComment(comment);
3117 moduleConst->setGuardBiasTH(guardBias_th);
3118 moduleConst->setHighVoltageTH(HV_th);
3119 moduleConst->setGuardBias2Dx(guardBias_2Dx);
3120 moduleConst->setHighVoltage2Dx(HV_2Dx);
3121 moduleConst->setGuardBias2Dy(guardBias_2Dy);
3122 moduleConst->setHighVoltage2Dy(HV_2Dy);
3123 moduleConst->setGain(gain);
3124 moduleConst->setChargeScan(charge);
3125 moduleConst->setTresholdScan(th);
3126 moduleConst->setLaserScanX(scanX);
3127 moduleConst->setLaserScanY(scanY);
3128
3129 for (int i = 0; i < 4; i++) {
3130 moduleConst->setChipVdiffTH(i, chipVdiff_th[i]);
3131 moduleConst->setChipLeakTH(i, chipLeak_th[i]);
3132 moduleConst->setChipVdiff2Dx(i, chipVdiff_2Dx[i]);
3133 moduleConst->setChipLeak2Dx(i, chipLeak_2Dx[i]);
3134 moduleConst->setChipVdiff2Dy(i, chipVdiff_2Dy[i]);
3135 moduleConst->setChipLeak2Dy(i, chipLeak_2Dy[i]);
3136 }
3137 if (HVtest == "yes") moduleConst->setHvbSN(hvbSN);
3138
3139 module++;
3140 B2INFO("module no " << module - 1 << " saved to DB. HAPD SN = " << hapdSN << ", FEB SN = " << febSN);
3141 f->Close();
3142 }
3143
3144 // store under user defined name:
3145 if (HVtest == "no") Database::Instance().storeData("ARICHModuleTest", &moduleConstants, m_iov);
3146 if (HVtest == "yes") Database::Instance().storeData("ARICHModuleTestHV", &moduleConstants, m_iov);
3147}
3148
3149void ARICHDatabaseImporter::exportModuleTest(const std::string& HVtest)
3150{
3151
3152 if (HVtest == "no") {
3153 DBArray<ARICHModuleTest> elements("ARICHModuleTest");
3154 elements.getEntries();
3155 for (const auto& element : elements) {
3156 B2INFO("Feb sn = " << element.getFebSN() << ", hapd sn = " << element.getHapdSN() << ", run = " << element.getRun() <<
3157 ", run position = " << element.getRunPosition() << ", module is ok = " << element.getOK() << ", comment = " <<
3158 element.getComment());
3159 for (int i = 0; i < element.getDeadChsSize(); i++) {
3160 B2INFO("dead channel = " << element.getDeadCh(i) << " (hapd mapping)");
3161 }
3162 }
3163 }
3164
3165 if (HVtest == "yes") {
3166 DBArray<ARICHModuleTest> elements("ARICHModuleTestHV");
3167 elements.getEntries();
3168 for (const auto& element : elements) {
3169 B2INFO("Feb sn = " << element.getFebSN() << ", hapd sn = " << element.getHapdSN() << ", hvb sn = " << element.getHvbSN() <<
3170 ", run = " << element.getRun() << ", run position = " << element.getRunPosition() << ", module is ok = " << element.getOK() <<
3171 ", comment = " << element.getComment());
3172 for (int i = 0; i < element.getDeadChsSize(); i++) {
3173 B2INFO("dead channel = " << element.getDeadCh(i) << " (asic mapping)");
3174 }
3175 }
3176 }
3177}
3178
3180{
3181 GearDir content = GearDir("/ArichData/AllData/moduleposition");
3182
3183 // define data array
3184 TClonesArray moduleInfoConstants("Belle2::ARICHSensorModuleInfo");
3185
3186 int module = 0;
3187
3188 // loop over xml files and extract the data
3189 for (const auto& sensor : content.getNodes("position")) {
3190 int febSerial = sensor.getInt("febserial");
3191 string hapdSerial = sensor.getString("hapdserial");
3192 int id = sensor.getInt("moduleID");
3193 int hvSerial = sensor.getInt("HVserial");
3194
3195 // save data as an element of the array
3196 new (moduleInfoConstants[module]) ARICHSensorModuleInfo();
3197 auto* moduleInfoConst = static_cast<ARICHSensorModuleInfo*>(moduleInfoConstants[module]);
3198 moduleInfoConst->setSensorModuleID(id);
3199 moduleInfoConst->setFEBserial(febSerial);
3200 moduleInfoConst->setHAPDserial(hapdSerial);
3201 moduleInfoConst->setHVboardID(hvSerial);
3202
3203 DBArray<ARICHHapdInfo> elementsHapd("ARICHHapdInfo");
3204 elementsHapd.getEntries();
3205 for (const auto& element : elementsHapd) {
3206 if (element.getSerialNumber() == hapdSerial) {
3207 ARICHHapdInfo& elementValue = const_cast<ARICHHapdInfo&>(element);
3208 moduleInfoConst->setHapdID(&elementValue);
3209 }
3210 }
3211
3212 DBArray<ARICHFEBoardInfo> elementsFeb("ARICHFEBoardInfo");
3213 elementsFeb.getEntries();
3214 for (const auto& element : elementsFeb) {
3215 if (element.getFEBoardSerial() == febSerial) {
3216 ARICHFEBoardInfo& elementValue = const_cast<ARICHFEBoardInfo&>(element);
3217 moduleInfoConst->setFEBoardID(&elementValue);
3218 }
3219 }
3220
3221 DBArray<ARICHModuleTest> elementsModule("ARICHModuleTestHV");
3222 elementsModule.getEntries();
3223 for (const auto& element : elementsModule) {
3224 if (element.getFebSN() == febSerial) {
3225 ARICHModuleTest& elementValue = const_cast<ARICHModuleTest&>(element);
3226 moduleInfoConst->setModuleTest(&elementValue);
3227 }
3228 }
3229
3230 module++;
3231 }
3232
3233 // store under default name:
3234 Database::Instance().storeData("ARICHSensorModuleInfo", &moduleInfoConstants, m_iov);
3235}
3236
3237
3239{
3240
3241 GearDir content = GearDir("/ArichData/AllData/moduleposition");
3242
3243 // define data array
3244 TClonesArray moduleMapConstants("Belle2::ARICHSensorModuleMap");
3245
3246 int module = 0;
3247
3248 // loop over xml files and extract the data
3249 for (const auto& sensor : content.getNodes("position")) {
3250 int sextant = sensor.getInt("sector");
3251 int ring = sensor.getInt("ring");
3252 int column = sensor.getInt("column");
3253 int id = sensor.getInt("moduleID");
3254
3255 // save data as an element of the array
3256 new (moduleMapConstants[module]) ARICHSensorModuleMap();
3257 auto* moduleMapConst = static_cast<ARICHSensorModuleMap*>(moduleMapConstants[module]);
3258 moduleMapConst->setSensorModuleSextantID(sextant);
3259 moduleMapConst->setSensorModuleRingID(ring);
3260 moduleMapConst->setSensorModuleColumnID(column);
3261 moduleMapConst->setSensorGlobalID(id);
3262
3263 DBArray<ARICHSensorModuleInfo> elementsModule("ARICHSensorModuleInfo");
3264 elementsModule.getEntries();
3265 for (const auto& element : elementsModule) {
3266 if (element.getSensorModuleID() == id) {
3267 ARICHSensorModuleInfo& elementValue = const_cast<ARICHSensorModuleInfo&>(element);
3268 moduleMapConst->setSensorModuleId(&elementValue);
3269 }
3270 }
3271
3272 module++;
3273 }
3274
3275 // store under default name:
3276 Database::Instance().storeData("ARICHSensorModuleMap", &moduleMapConstants, m_iov);
3277}
3278
3280{
3281 DBArray<ARICHSensorModuleMap> elements("ARICHSensorModuleMap");
3282 elements.getEntries();
3283
3284 for (const auto& element : elements) {
3285 B2INFO("Sextant = " << element.getSensorModuleSextantID() << ", ring = " << element.getSensorModuleRingID() << ", column = " <<
3286 element.getSensorModuleColumnID());
3287 ARICHSensorModuleInfo* newelement = element.getSensorModuleId();
3288 B2INFO("module ID = " << newelement->getSensorModuleID() << ", feb = " << newelement->getFEBserial() << ", hapd = " <<
3289 newelement->getHAPDserial());
3290 ARICHHapdInfo* newerelement = newelement->getHapdID();
3291 B2INFO("Hapd Serial = " << newerelement->getSerialNumber() << "; HV = " << newerelement->getHighVoltage() << "; qe400 = " <<
3292 newerelement->getQuantumEfficiency400());
3293 for (int i = 0; i < 4; i++) {
3294 ARICHHapdChipInfo* newestelement = newerelement->getHapdChipInfo(i);
3295 B2INFO("Hapd Serial = " << newestelement->getHapdSerial() << "; chip = " << newestelement->getChipLabel() << "; gain = " <<
3296 newestelement->getGain());
3297 }
3298 }
3299}
3300
3302{
3303 DBArray<ARICHSensorModuleMap> elements("ARICHSensorModuleMap");
3304 elements.getEntries();
3305
3306 for (const auto& element : elements) {
3307 ARICHSensorModuleInfo* newelement = element.getSensorModuleId();
3308 if (!(newelement->getSensorModuleID() == number)) continue;
3309 B2INFO("Sextant = " << element.getSensorModuleSextantID() << ", ring = " << element.getSensorModuleRingID() << ", column = " <<
3310 element.getSensorModuleColumnID());
3311 B2INFO("module ID = " << newelement->getSensorModuleID() << ", feb = " << newelement->getFEBserial() << ", hapd = " <<
3312 newelement->getHAPDserial());
3313 ARICHHapdInfo* newerelement = newelement->getHapdID();
3314 B2INFO("Hapd Serial = " << newerelement->getSerialNumber() << "; HV = " << newerelement->getHighVoltage() << "; qe400 = " <<
3315 newerelement->getQuantumEfficiency400());
3316 for (int i = 0; i < 4; i++) {
3317 ARICHHapdChipInfo* newestelement = newerelement->getHapdChipInfo(i);
3318 B2INFO("Hapd Serial = " << newestelement->getHapdSerial() << "; chip = " << newestelement->getChipLabel() << "; gain = " <<
3319 newestelement->getGain());
3320 }
3321 }
3322}
3323
3325{
3326 GearDir content = GearDir("/ArichData/AllData/magnetTest");
3327
3328 // define data array
3329 TClonesArray magnetConstants("Belle2::ARICHMagnetTest");
3330 int num = 0;
3331 string sn;
3332
3333 // loop over xml files and extract the data
3334 for (const auto& module : content.getNodes("module")) {
3335 // save data as an element of the array
3336 new (magnetConstants[num]) ARICHMagnetTest();
3337 auto* magnetConst = static_cast<ARICHMagnetTest*>(magnetConstants[num]);
3338
3339 int snint = module.getInt("hapdID");
3340 if (snint < 5000) sn = "KA";
3341 else sn = "ZJ";
3342 char hapdID[6];
3343 sprintf(hapdID, "%s%04d", sn.c_str(), snint);
3344 magnetConst->setSerialNumber(hapdID);
3345
3346 vector<float> deadtimes;
3347 for (const auto& time : module.getNodes("deadtime/measurement")) {
3348 if (time.getString(".") != "-") {
3349 float deadtime = (float) time.getDouble(".");
3350 deadtimes.push_back(deadtime);
3351 }
3352 }
3353 magnetConst->setDeadTime(deadtimes);
3354
3355 if (module.getString("lowerA") != "-") magnetConst->setDeadTimeLowerA((float) module.getDouble("lowerA"));
3356 if (module.getString("lowerB") != "-") magnetConst->setDeadTimeLowerB((float) module.getDouble("lowerB"));
3357 if (module.getString("lowerC") != "-") magnetConst->setDeadTimeLowerC((float) module.getDouble("lowerC"));
3358 if (module.getString("lowerD") != "-") magnetConst->setDeadTimeLowerD((float) module.getDouble("lowerD"));
3359
3360 bool getter_reactivation = module.getBool("getter");
3361 string comment = module.getString("comment");
3362 magnetConst->setGetter(getter_reactivation);
3363 magnetConst->setComment(comment);
3364
3365 num++;
3366 }
3367
3368 // store under default name:
3369 Database::Instance().storeData("ARICHMagnetTest", &magnetConstants, m_iov);
3370}
3371
3373{
3374
3375 DBArray<ARICHMagnetTest> elements("ARICHMagnetTest");
3376 elements.getEntries();
3377
3378 for (const auto& element : elements) {
3379 string getter = "no";
3380 if (element.getGetter() == 1) getter = "yes";
3381 B2INFO("SN = " << element.getSerialNumber() << "; after getter reactivation? " << getter);
3382 for (int i = 0; i < element.getDeadTimeSize();
3383 i++) B2INFO("dead time = " << element.getDeadTime(i) << " (" << (i + 1) << ". measurement)");
3384 if (element.getDeadTimeLowerA() > 0.) B2INFO("lower voltage on chip A = " << element.getDeadTimeLowerA());
3385 if (element.getDeadTimeLowerB() > 0.) B2INFO("lower voltage on chip B = " << element.getDeadTimeLowerB());
3386 if (element.getDeadTimeLowerC() > 0.) B2INFO("lower voltage on chip C = " << element.getDeadTimeLowerC());
3387 if (element.getDeadTimeLowerD() > 0.) B2INFO("lower voltage on chip D = " << element.getDeadTimeLowerD());
3388 B2INFO("comment = " << element.getComment());
3389 }
3390}
3391
3393{
3401}
Alignment parameters for aerogel tiles.
void setAlignmentElement(int id, const ARICHPositionElement &pars)
Sets alignment parameters (element) for aerogel tile.
The Class for ARICH aerogel tiles properties for even reconstruction.
void addMapping(int slot, int layer, float refractiveIndex, float transmissionLength, float thickness)
Add mapping entry.
Base class for geometry parameters.
Int_t GetBinIDFromRingColumn(Int_t ring, Int_t column)
Function which return histogram bin id from ring and column id's.
The Class for ARICH Aerogel Parameters.
float getAerogelVersion() const
Get aerogel version.
float getAerogelRefractiveIndex() const
Get refractive index of aerogel.
std::string getAerogelSN() const
Get aerogel serial number.
float getAerogelThickness() const
Get aerogel thickness.
float getAerogelTransmissionLength() const
Get transmission length at 400 nm.
Map of the Aerogel placement.
void setAerogelSN(const std::string &agelid)
Set Aerogel serial number.
The Class for ARICH aerogel Rayleigh scattering fit parameters.
Tested ASIC chips.
Definition: ARICHAsicInfo.h:25
void setAsicID(const std::string &id)
Set ASIC identifier.
Definition: ARICHAsicInfo.h:60
The Class for ARICH mapping of bias cables to modules.
void addMapping(int moduleID, int sectorID, int cableID, int innerID)
Add mapping entry.
This class provides ARICH mapping of HAPD modules to bias power supply channels.
void addMapping(int crate, int slot, int channelID, int pinID, int connectionID, int innerID, const std::string &type)
Add new entry to the mapping table.
This class provides ARICH bias voltages at gain 40.
void addMapping(int connectionID, std::vector< int > sectorCable)
Add new entry to the mapping table.
The Class for ARICH bias voltages at gain 40.
void addVoltages(const std::string &hapdID, std::vector< int > biasVoltages)
Add new entry to the mapping table.
ARICH histogram with HAPD plane 3 options for bin segmentation are available type 0 - one bin per HAP...
The Class for ARICH HAPD channel mapping.
int getAsicFromXY(unsigned xChn, unsigned yChn) const
Get asic channel number from HAPD channel X,Y numbers.
void mapXY2Asic(unsigned xChn, unsigned yChn, unsigned asicChn)
Add entry to channel map.
The Class for ARICH HAPD channel mask.
void setActiveCh(unsigned modId, unsigned chNo, bool active)
Set active/non-active channel.
The Class for ARICH mapping of merger to copper boards.
void addMapping(unsigned mergerID, unsigned copperID, unsigned finesse)
Add new entry to the mapping table.
void exportHapdQE()
Export HAPD quantum efficiency from the database.
void importModulesInfo()
Import HAPD modules info from the xml file and database (2D QE maps) Goes through the list of install...
std::vector< std::string > m_inputFilesHapdQA
Input root files for HAPD QA.
void exportModuleTest(const std::string &HVtest)
Export module test results.
int getAeroTileColumn(int slot)
Get aerogel ring number from global indetifier.
void importAeroTilesInfo()
Import optical information of aerogel tiles into database.
void importHvMappings()
Imports mappings of power supply to high voltage cables.
void importChannelMapping()
Imports HAPD (asic) channel mappings from the xml file.
void importAeroTilesAlignment()
Import aerogel tiles alignment parameters from ARICH-AeroTilesAlignment.xml.
void exportMagnetTest()
Export results of magnet test.
void printMergerMapping(bool dump=false)
Prints merger to FEB mappings from the database.
void printCopperMapping(bool dump=false)
Prints Copper to merger mappings from the database.
void importSensorModuleInfo()
Import module sensor info classes.
int getChannelPosition(const std::string &XY, const std::string &chip_2d, int chipnum)
Get position of channel on HAPD.
std::vector< std::pair< float, float > > getFwhm(int serialNum, const std::string &runSCAN)
Returns lists of FWHM values&sigmas.
void dumpModuleNumbering()
Dumps module numbering scheme into root file (module position on the detector plane -> module number)
tessellatedSolidStr readTessellatedSolidVerticesFromDATfile(const std::string &inDATfile)
reads merger cooling bodies geometry from dat files
void importAeroRayleighScatteringFit(std::string commentSingleWord="")
Import optical information of aerogel tiles into database.
void importAerogelInfoEventDep()
Import intrarun dependant ARICH aerogel data in the database.
std::vector< std::string > m_inputFilesFebTest
Input root files from FEB test (coarse/fine offset settings, test pulse)
void printAeroTileInfo(bool dump=false)
Prints mapping of aerogel tiles and their optical properties.
void dumpHvMappings()
Dumps detector map of HAPD modules to HV cable channels.
void printBiasMappings(bool dump=false)
Prints mappings of power supply to bias cables and cables to HAPDs and nominal values of bias voltage...
void importReconstructionParams()
Import reconstruction parameters (for now only initializes "default" values and imports)
void importFEBoardInfo()
Import module test results.
void exportFEBoardInfo()
Export module test results.
void exportSensorModuleMapInfo(int number)
Export module sensor map info classes from database.
void importMagnetTest()
Import results of magnet test.
IntervalOfValidity m_iov
interval of validity
std::vector< int > channelsList(std::string badCH)
Get lists of problematic ASIC channels.
void SetIOV(int experimentLow, int runLow, int experimentHigh, int runHigh)
Set Interval of Validity.
void setExperimentAndRun(int experiment, int run)
Set experiment and run number.
void importSimulationParams()
Import simulation parameters from the xml file (QE curve, etc.)
TTimeStamp timedate2(std::string time)
Convert date (FEB) to TTimeStamp.
TH2F * getBiasGraph(const std::string &chip_2d, const std::string &voltage_current, int *chipnum, float *bias_v_i)
Get histograms for bias voltage and current.
void printHvMappings(bool dump=false)
Prints mappings of power supply to HV cables and cables to HAPDs from the database.
std::tuple< std::string, float > getFebHVtestData(int serial, int hvRun)
Returns data from high voltage test.
void dumpQEMap(bool simple=false)
Dumps 2D QE map of full detector surface from the database into root file (from ARICHModulesInfo)
void dumpMergerMapping(bool sn=true)
Dumps module - merger mapping into root file.
void importHapdInfo()
Import ARICH HAPD data in the database.
std::vector< int > getDeadChFEB(const std::string &dna)
Returns list of dead channels on FEB.
void printChannelMapping(bool dump=false)
Prints HAPD (asic) channel mapping from the database.
auto printContainer(const Container_t &rContainer, std::ostream &rStream=std::cout) noexcept -> void
printContainer used for debugging purposes...
void exportHapdInfo()
Export ARICH HAPD info and chip info data from the database.
void exportAerogelInfoEventDep()
Export intrarun dependant ARICH aerogel data from the database.
void printNominalBiasVoltageForChannel(std::vector< int > channel)
Prints nominal bias voltage for channel on power supply from the database.
void importHapdQE()
Import HAPD quantum efficiency in the database.
void printGlobalAlignment(bool dump=false)
Prints global alignment constants.
void importFEMappings()
Imports mappings of FE electronics from the xml file (ARICH-FrontEndMapping.xml) to the database Mapp...
void importNominalBiasVoltages()
Imports mappings of nominal values of bias voltages.
void printBiasVoltagesForHapdChip(const std::string &serialNumber)
Export ARICH HAPD chip info data from the database and calculate bias voltages for one HAPD.
std::vector< TH3F * > getFebTestHistograms(const std::string &dna, const std::string &run, int febposition)
Returns TH3F histograms - offset settings.
void printModulesInfo(bool dump=false)
Print HAPD modules info from the database (lightweight class for sim/rec=)
void importFebTest()
Import ARICH FEB test data in the database.
void importAerogelMap()
Import ARICH aerogel map in the database.
void exportSensorModuleMap()
Export module sensor map classes from database.
void importBiasMappings()
Imports mappings of power supply to bias cables and cables to HAPDs and nominal values of bias voltag...
ARICHDatabaseImporter()
Default constructor.
void printChannelMask(bool makeHist=false, bool dump=false)
Print channel mask of all HAPD modules from the database (lightweight class for sim/rec)
std::vector< std::string > m_inputFilesHapdQE
Input root files for HAPD quantum efficiency.
void printFEMappings()
Prints electronics mappings for all modules (merger ID + SN, merger port, copper, finnese)
void importAsicInfoRoot()
Import large histograms from ARICH ASICs data in the database.
void importGlobalAlignment()
Import global alignment parameters from ARICH-GlobalAlignment.xml.
std::map< std::string, float > getAerogelParams(const std::string &aeroSerialNumber)
Function that returns refractive index, thickness and transmission length of aerogel.
void printNominalBiasVoltages(bool dump=false)
Prints mappings of nominal values of bias voltages from the database.
int getAeroTileRing(int slot)
Get aerogel ring number from global indetifier.
void printMirrorAlignment(bool dump=false)
Prints mirror alignment constants.
void exportFebTest()
Export ARICH FEB test data from the database.
void printSimulationPar(bool dump=false)
Print simulation parameters from the database (QE curve, etc.)
void exportAsicInfo()
Export ARICH ASICs data from the database.
void exportAerogelMap()
Export ARICH aerogel map in the database.
void exportAerogelInfo(int verboseLevel=0)
Export ARICH aerogel data from the database.
TTimeStamp timedate(std::string enddate)
Convert date (ASICs) to TTimeStamp.
void importModuleTest(const std::string &mypath, const std::string &HVtest)
Import module test results.
std::pair< std::vector< float >, std::vector< float > > getSlopes(int serialNum, const std::string &runSCAN)
Returns lists of slopes (fine & rough)
std::vector< std::string > m_inputFilesAsicTxt
Input txt files for ASICs.
void importGeometryConfig()
Import geometry configuration parameters to the database.
void exportAll()
Export all the data.
void importAerogelInfo(TString coreNameSuffix="")
Import ARICH aerogel data in the database.
TTimeStamp getAsicDate(const std::string &asicSerial, const std::string &type)
Get date for ASIC measurement.
void importChannelMask()
Import channel mask for all HAPD modules from the database (list of dead channels) Goes through the l...
void importCosmicTestGeometry()
Import parameters of the cosmic test geometry configuration.
void importSensorModuleMap()
Import module sensor map classes.
TGraph * getGraphGainCurrent(const std::string &bomb_aval, const std::string &g_i, const std::string &chip_label, int i, float *HV, float *gain_current)
Get graphs for bombardment and avalanche gain and current.
void printReconstructionPar(bool dump=false)
Prints reconstruction parameters.
void importAsicInfo()
Import ARICH ASICs data in the database.
void printAeroTilesAlignment(bool dump=false)
Prints aerogel tiles alignment constants.
void exportHapdQA()
Export ARICH HAPD QA data from the database.
std::vector< std::string > m_inputFilesAsicRoot
Input root files for ASICs.
void printGeometryConfig(bool dump=false)
Prints geometry configuration parameters from the database.
void importFebTestRoot()
Import large histograms from ARICH FEB test data in the database.
void printHapdPositionFromCrateSlot(int crate, int slot, int channelID)
Prints HAPD position (sector, ring, azimuth) and merger connection (merger, feb slot) from the databa...
void importMergerCoolingGeo()
Import Merger cooling bodies geometry.
void printMyParams(const std::string &aeroSerialNumber)
Example that shows how to use data from the database.
TH2F * getFebTestPulse(const std::string &dna, const std::string &run, int febposition)
Returns TH2F histogram of pulse test.
void dumpAerogelOpticalProperties(std::string outRootFileName="ARICH_AerogelOpticalProperties.root")
Dumps aerogel tile properties (aerogel optical properties - AOP) into root file with arich/utility/AR...
int getFebDaqSlot(unsigned febSlot)
Returns feb daq position from feb slot.
void importHapdChipInfo()
Import ARICH HAPD chip data in the database.
void exportHapdChipInfo()
Export ARICH HAPD chip data from the database.
std::vector< int > channelsListHapd(std::string chlist, std::string chipDelay)
Get lists of problematic HAPD channels.
std::tuple< std::string, float, float, float > getFebLVtestData(int serial, int lvRun)
Returns data from low voltage test.
void importHapdQA()
Import ARICH HAPD QA data in the database.
void importMirrorAlignment()
Import mirror alignment parameters from ARICH-MirrorAlignment.xml.
Front End Electronics Boards.
void setFEBoardSerial(int serial)
Set Front-End Board identifier.
ARICH FEB test data.
Definition: ARICHFebTest.h:30
void setFebSerial(int serial)
Set FEB serial number.
Definition: ARICHFebTest.h:66
Geometry parameters of HAPD.
Geometry parameters of ARICH Master volume (envelope)
double getOuterRadius() const
Get ARICH master volume outer radius.
double getInnerRadius() const
Get ARICH master volume inner radius.
void setVolume(double innerR, double outerR, double length, const std::string &material)
Sets parameters of ARICH master volume.
const std::string & getMaterial() const
Get material of ARICH master volume.
void setPlacement(double x, double y, double z, double rx, double ry, double rz)
Sets positioning of ARICH master volume in global Belle II coordinate system.
Geometry parameters of Merger Cooling System - version2 (v2).
void addMergerCoolingBodiesInfo(tessellatedSolidStr mergerCoolingBodiesStr)
Set vector of structures which holds apexes of the tessellation volumes for (merger cooling bodyes).
void checkMergerCoolingSystemDataConsistency() const
Check data consistency of the cooling system (v2) positions In case of failure print the basf2 ERROR ...
void setMergerCoolingBodiesMaterialName(const std::string &materialName)
Set material name of merger cooling bodies.
void setMergerCoolingPositionID(const std::vector< double > &mergerCoolingPositionID)
Set vector of merger cooling body shape id (positionID) for each merger PCB.
Geometry parameters of ARICH support structures and neutron shield.
void clearBoxes()
Clear container of boxes.
void addBox(const std::string &name, const std::string &material, double size[3], double position[3], double rotation[3])
Add box volume.
The Class for ARICH Geometry Parameters.
const ARICHGeoAerogelPlane & getAerogelPlane() const
Get geometry configuration of aerogel plane.
void setAerogelPlane(const ARICHGeoAerogelPlane &aerogelPlane)
Set geometry configuration of aerogel plane.
void setMasterVolume(const ARICHGeoMasterVolume &masterVolume)
Set master volume geometry configuration.
const ARICHGeoMasterVolume & getMasterVolume() const
Get ARICH master volume geometry configuration.
const ARICHGeoSupport & getSupportStructure() const
Get ARICH support structure geometry configuration.
void setSupportStructure(const ARICHGeoSupport &supportStructure)
Set support structure geometry configuration.
Geometry parameters of ARICH Master volume (envelope).
void setAlignmentElement(const ARICHPositionElement &align)
Sets alignment parameters (element).
Contains manufacturer data of one of the 4 photo sensors chips.
std::string getChipLabel() const
Get chip label.
int getGain() const
Get chip gain at operational voltage.
void setHapdSerial(const std::string &serial)
Set HAPD serial number.
std::string getHapdSerial() const
Get HAPD Serial number.
int getBiasVoltage() const
Get chip bias Voltage.
Contains manufacturer data of the photo sensor - HAPD.
Definition: ARICHHapdInfo.h:23
std::string getSerialNumber() const
Return HAPD Serial Number.
Definition: ARICHHapdInfo.h:61
float getHighVoltage() const
Return operational High Voltage.
Definition: ARICHHapdInfo.h:85
ARICHHapdChipInfo * getHapdChipInfo(unsigned int i) const
Return HapdChipInfo of the chip i.
float getQuantumEfficiency400() const
Return quantum efficiency at 400 nm.
Definition: ARICHHapdInfo.h:73
Contains manufacturer data of the photo sensor - HAPD.
Definition: ARICHHapdQA.h:26
Contains manufacturer data of the photo sensor - HAPD.
Definition: ARICHHapdQE.h:22
The Class for ARICH mapping of bias cables to modules.
void addMapping(int moduleID, int sectorID, int cableID, int innerID)
Add mapping entry.
The Class for ARICH mapping of bias power supply channels to modules.
void addMapping(int crate, int slot, int channelID, int connectionID, int pinID)
Add new entry to the mapping table.
The Class for ARICH bias voltages at gain 40.
void addMapping(int connectionID, std::vector< int > sectorCable)
Add new entry to the mapping table.
Contains fractions of dead times measured in a magnet.
The Class for ARICH mapping of modules to merger boards.
unsigned getModuleID(unsigned mergerID, unsigned febSlot) const
Get ID of module connected to merger at FEB slot.
void addMapping(unsigned moduleID, unsigned mergerID, unsigned febSlot, unsigned mergerSN)
Add mapping entry.
unsigned getMergerID(unsigned moduleID) const
Get ID of merger to which module is connected.
unsigned getFEBSlot(unsigned moduleID) const
Get FEB slot to which module is connected.
Mirror alignment parameters for ARICH.
void setAlignmentElement(int id, const ARICHPositionElement &pars)
Sets Alignment parameters (element) for mirror plate.
ARICH module test data.
void setFebSN(int serial)
Set FEB serial number.
The Class for information on HAPD modules installed in ARICH.
void addModule(unsigned modId, std::vector< float > &qeList, bool active)
Add installed module.
Position element for ARICH.
void print(const std::string &title="Parameters of position element") const override
Print the content of the class.
The Class for ARICH reconstruction parameters.
Sensor-module information.
int getSensorModuleID() const
Get sensor-module identifier.
int getFEBserial() const
Get FEB serial number.
std::string getHAPDserial() const
Get HAPD serial number.
ARICHHapdInfo * getHapdID() const
Get HAPD Identifier.
void setSensorModuleID(int id)
Set Sensor-module identifier.
Mapping of the sensor-board connections to the detector.
void setSensorModuleSextantID(int sextant)
Set sensor-module sextant identifier.
The Class for ARICH simulation parameters.
void setPeakQE(double peak)
Set peak QE value (for HAPD with maximal QE, at later stage HAPD dependent scaling is done)
void setQECurve(float lambdaFirst, float lambdaStep, const std::vector< float > &qe)
Set QE curve.
void setChipNegativeCrosstalk(double cross)
Set factor to suppress p.e.
void setWindowAbsorbtion(double abs)
Set absorption probability for photons internally reflected in HAPD window.
void setQEScaling(double qescale)
Set QE scaling factor for photons internally reflected in HAPD window.
void print() const
print class content
void setCollectionEff(double colEff)
Set HAPD collection efficiency.
IntervalOfValidity getIoV() const
Return current IoV of the object.
Class for accessing arrays of objects in the database.
Definition: DBArray.h:26
int getEntries() const
Get the number of objects in the array.
Definition: DBArray.h:42
bool import(const IntervalOfValidity &iov)
Import the object to database.
Definition: DBImportBase.cc:36
Class for importing a single object to the database.
void construct(Args &&... params)
Construct an object of type T in this DBImportObjPtr using the provided constructor arguments.
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
bool addPayload(const std::string &name, const std::string &fileName, const IntervalOfValidity &iov)
Add a payload file to the database.
Definition: Database.h:192
Class for handling changing conditions as a function of event number.
void add(unsigned int event, TObject *object)
Add an object to the intra run dependency.
Store event, run, and experiment numbers.
Definition: EventMetaData.h:33
GearDir is the basic class used for accessing the parameter store.
Definition: GearDir.h:31
virtual std::string getString(const std::string &path="") const noexcept(false) override
Get the parameter path as a string.
Definition: GearDir.h:69
A class that describes the interval of experiments/runs for which an object in the database is valid.
TObject * getObject(const EventMetaData &event) const
Get the conditions object that is valid for the given event.
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:95
static const double mm
[millimeters]
Definition: Unit.h:70
static const double nm
[nanometers]
Definition: Unit.h:72
double getAngle(const std::string &path="") const noexcept(false)
Get the parameter path as a double converted to the standard angle unit.
Definition: Interface.h:299
std::vector< double > getArray(const std::string &path) const noexcept(false)
Get the parameter path as a list of double values converted to the standard unit.
Definition: Interface.cc:123
double getDouble(const std::string &path="") const noexcept(false)
Get the parameter path as a double.
Definition: Interface.cc:41
double getLength(const std::string &path="") const noexcept(false)
Get the parameter path as a double converted to the standard length unit.
Definition: Interface.h:259
std::vector< GearDir > getNodes(const std::string &path="") const
Get vector of GearDirs which point to all the nodes the given path evaluates to.
Definition: Interface.cc:21
TH1F * hapd[6]
histogram of hits for each hapd
std::pair< TObject *, IntervalOfValidity > getData(const EventMetaData &event, const std::string &name)
Request an object from the database.
Definition: Database.cc:71
static Database & Instance()
Instance of a singleton Database.
Definition: Database.cc:41
bool storeData(const std::string &name, TObject *object, const IntervalOfValidity &iov)
Store an object in the database.
Definition: Database.cc:140
Abstract base class for different kinds of events.
STL namespace.
Structure which holds apexes of the tessellation volumes.
std::vector< std::vector< double > > posV1
x, y, z of apex1.
std::vector< std::vector< double > > posV3
x, y, z of apex3.
int tessellatedSolidID
tessellated solid ID
std::vector< std::vector< double > > posV2
x, y, z of apex2.
unsigned int nApexPerCell
number of apexes per cell
unsigned int nCells
number of cells
Point.