11 #include <arich/calibration/ARICHDatabaseImporter.h>
12 #include <arich/calibration/ARICHDatabaseTools.h>
13 #include <arich/dbobjects/ARICHAerogelMap.h>
14 #include <arich/dbobjects/ARICHAerogelInfo.h>
15 #include <arich/dbobjects/ARICHAerogelRayleighScatteringFit.h>
16 #include <arich/dbobjects/ARICHAsicInfo.h>
17 #include <arich/dbobjects/ARICHHapdQA.h>
18 #include <arich/dbobjects/ARICHFebTest.h>
19 #include <arich/dbobjects/ARICHHapdChipInfo.h>
20 #include <arich/dbobjects/ARICHHapdInfo.h>
21 #include <arich/dbobjects/ARICHHapdQE.h>
22 #include <arich/dbobjects/ARICHMagnetTest.h>
23 #include <arich/dbobjects/ARICHModuleTest.h>
24 #include <arich/dbobjects/ARICHSensorModuleInfo.h>
25 #include <arich/dbobjects/ARICHSensorModuleMap.h>
26 #include <arich/dbobjects/ARICHBiasCablesMapping.h>
27 #include <arich/dbobjects/ARICHBiasChannelsMapping.h>
28 #include <arich/dbobjects/ARICHBiasVoltages.h>
29 #include <arich/dbobjects/ARICHBiasCrateCableMapping.h>
30 #include <arich/dbobjects/ARICHHvCablesMapping.h>
31 #include <arich/dbobjects/ARICHHvChannelsMapping.h>
32 #include <arich/dbobjects/ARICHHvCrateCableMapping.h>
34 #include <arich/dbobjects/ARICHChannelMask.h>
35 #include <arich/dbobjects/ARICHChannelMapping.h>
36 #include <arich/dbobjects/ARICHModulesInfo.h>
37 #include <arich/dbobjects/ARICHMergerMapping.h>
38 #include <arich/dbobjects/ARICHCopperMapping.h>
39 #include <arich/dbobjects/ARICHSimulationPar.h>
40 #include <arich/dbobjects/ARICHReconstructionPar.h>
41 #include <arich/dbobjects/ARICHGeometryConfig.h>
42 #include <arich/dbobjects/ARICHAeroTilesInfo.h>
43 #include <arich/dbobjects/ARICHGlobalAlignment.h>
44 #include <arich/dbobjects/ARICHMirrorAlignment.h>
45 #include <arich/dbobjects/ARICHPositionElement.h>
46 #include <arich/dbobjects/ARICHAeroTilesAlignment.h>
47 #include <arich/dbobjects/ARICHGeoMergerCooling.h>
50 #include <arich/utility/ARICHChannelHist.h>
51 #include <arich/utility/ARICHAerogelHist.h>
53 #include <framework/gearbox/GearDir.h>
54 #include <framework/gearbox/Unit.h>
55 #include <framework/logging/Logger.h>
56 #include <framework/database/EventDependency.h>
58 #include <framework/database/IntervalOfValidity.h>
59 #include <framework/database/Database.h>
60 #include <framework/database/DBArray.h>
61 #include <framework/database/DBObjPtr.h>
62 #include <framework/database/DBImportObjPtr.h>
77 #include <TClonesArray.h>
85 ARICHDatabaseImporter::ARICHDatabaseImporter(
const vector<string>& inputFilesHapdQA,
const vector<string>& inputFilesAsicRoot,
86 const vector<string>& inputFilesAsicTxt,
const vector<string>& inputFilesHapdQE,
const vector<string>& inputFilesFebTest)
88 m_inputFilesHapdQA.reserve(inputFilesHapdQA.size());
89 m_inputFilesAsicRoot.reserve(inputFilesAsicRoot.size());
90 m_inputFilesAsicTxt.reserve(inputFilesAsicTxt.size());
91 m_inputFilesHapdQE.reserve(inputFilesHapdQE.size());
92 m_inputFilesFebTest.reserve(inputFilesFebTest.size());
93 for (
unsigned int i = 0; i < inputFilesHapdQA.size(); i++) { m_inputFilesHapdQA.push_back(inputFilesHapdQA[i]); }
94 for (
unsigned int i = 0; i < inputFilesAsicRoot.size(); i++) { m_inputFilesAsicRoot.push_back(inputFilesAsicRoot[i]); }
95 for (
unsigned int i = 0; i < inputFilesAsicTxt.size(); i++) { m_inputFilesAsicTxt.push_back(inputFilesAsicTxt[i]); }
96 for (
unsigned int i = 0; i < inputFilesHapdQE.size(); i++) { m_inputFilesHapdQE.push_back(inputFilesHapdQE[i]); }
97 for (
unsigned int i = 0; i < inputFilesFebTest.size(); i++) { m_inputFilesFebTest.push_back(inputFilesFebTest[i]); }
101 ARICHDatabaseImporter::ARICHDatabaseImporter(
int experiment,
int run)
104 meta->setRun(run); meta->setExperiment(experiment);
105 B2INFO(
"Experiment " << experiment <<
", run " << run);
109 void ARICHDatabaseImporter::SetIOV(
int experimentLow,
int runLow,
int experimentHigh ,
int runHigh)
115 void ARICHDatabaseImporter::setExperimentAndRun(
int experiment,
int run)
118 meta->setRun(run); meta->setExperiment(experiment);
119 B2INFO(
"Experiment " << experiment <<
", run " << run);
123 void ARICHDatabaseImporter::importModulesInfo()
138 GearDir content =
GearDir(
"/Detector/DetectorComponent[@name='ARICH']/Content/ChannelMapping");
139 istringstream chstream;
141 chstream.str(content.getString(
"QAChannelMapping"));
142 while (chstream >> x >> y >> asic) {
147 GearDir installedModules =
GearDir(
"/Detector/DetectorComponent[@name='ARICH']/Content/InstalledModules");
148 B2INFO(
"Installed modules\n");
150 std::vector<std::string> installed;
153 std::string hapdID = module.getString(
"@hapdID");
155 unsigned sector = module.getInt(
"Sector");
156 unsigned ring = module.getInt(
"Ring");
157 unsigned azimuth = module.getInt(
"Azimuth");
158 bool isActive = (bool)module.getInt(
"isActive");
159 B2INFO(
" " << hapdID <<
": S " << sector <<
" R " << ring <<
" Z " << azimuth <<
", isActive: " << isActive <<
'\n');
161 if (std::find(installed.begin(), installed.end(), hapdID) != installed.end()) {
162 B2WARNING(
"ARICHDatabaseImporter::importModulesInfo: hapd " << hapdID <<
" installed multiple times!");
163 }
else installed.push_back(hapdID);
165 unsigned moduleID = geoConfig->getDetectorPlane().getSlotIDFromSRF(sector, ring, azimuth);
168 std::vector<float> qs;
171 for (
const auto& QEMap : QEMaps) {
172 if (hapdID == QEMap.getHapdSerialNumber()) {
173 TH2F* qe2d = QEMap.getQuantumEfficiency2D();
174 for (
int k = 1; k < 13; k++) {
175 for (
int l = 1; l < 13; l++) {
177 qs[asicCh] = qe2d->GetBinContent(k, l);
181 B2INFO(
" Channels QE map found and set.\n");
186 for (
int k = 0; k < 144; k++) {
189 B2WARNING(
"ARICHDatabaseImporter::importModulesInfo: QE map for hapd " << hapdID <<
" not found! Setting 27% QE for all channels!");
192 modInfo.
addModule(moduleID, qs, isActive);
202 void ARICHDatabaseImporter::importGlobalAlignment()
205 GearDir content =
GearDir(
"/Detector/DetectorComponent[@name='ARICH']/Content");
206 GearDir alignPars(content,
"GlobalAlignment");
218 void ARICHDatabaseImporter::importMirrorAlignment()
221 GearDir content =
GearDir(
"/Detector/DetectorComponent[@name='ARICH']/Content");
222 GearDir alignPars(content,
"MirrorAlignment");
228 for (
auto plate : alignPars.
getNodes(
"Plate")) {
229 int id = plate.getInt(
"@id");
230 double r = plate.getLength(
"r");
231 double phi = plate.getAngle(
"phi");
232 double z = plate.getLength(
"z");
233 double alpha = plate.getLength(
"alpha");
234 double beta = plate.getLength(
"beta");
235 double gamma = plate.getLength(
"gamma");
236 double origPhi = geoConfig->getMirrors().getPoint(
id).Phi();
237 ARICHPositionElement alignEl(r * cos(origPhi + phi), r * sin(origPhi + phi), z, alpha, beta, gamma);
248 void ARICHDatabaseImporter::importAeroTilesAlignment()
251 GearDir content =
GearDir(
"/Detector/DetectorComponent[@name='ARICH']/Content");
252 GearDir alignPars(content,
"AeroTilesAlignment");
256 for (
auto tile : alignPars.
getNodes(
"Slot")) {
257 int id = tile.getInt(
"@id");
258 double r = tile.getLength(
"r");
259 double phi = tile.getAngle(
"phi");
260 double z = tile.getLength(
"z");
261 double alpha = tile.getLength(
"alpha");
262 double beta = tile.getLength(
"beta");
263 double gamma = tile.getLength(
"gamma");
276 void ARICHDatabaseImporter::importChannelMask()
287 GearDir content =
GearDir(
"/Detector/DetectorComponent[@name='ARICH']/Content/InstalledModules");
288 B2INFO(
"Installed modules\n");
289 for (
const GearDir& module : content.getNodes(
"Module")) {
290 std::string hapdID = module.getString(
"@hapdID");
291 unsigned sector = module.getInt(
"Sector");
292 unsigned ring = module.getInt(
"Ring");
293 unsigned azimuth = module.getInt(
"Azimuth");
294 bool isActive = (bool)module.getInt(
"isActive");
295 B2INFO(
" " << hapdID <<
": S " << sector <<
" R " << ring <<
" Z " << azimuth <<
", isActive: " << isActive <<
'\n');
296 unsigned moduleID = geoConfig->getDetectorPlane().getSlotIDFromSRF(sector, ring, azimuth);
300 for (
const auto& test : moduleTest) {
301 if (hapdID == test.getHapdSN()) {
304 for (
int i = 0; i < test.getDeadChsSize(); i++) {
305 unsigned asicCh = test.getDeadCh(i);
306 if (asicCh > 143)B2ERROR(
"ARICHDatabaseImporter::importLWClasses: Asic channel for HAPD " << hapdID <<
" is out of range!");
310 B2INFO(
" List of dead channels (from module test) found and set.\n");
315 B2WARNING(
"ARICHDatabaseImporter::importLWClasses: List of dead channels for hapd " << hapdID <<
316 " not found! All channels set to active.");
327 void ARICHDatabaseImporter::importMergerCoolingGeo()
331 GearDir mergerCoolingParams =
GearDir(
"/Detector/DetectorComponent[@name='ARICH']/Content/mergerCoolingBodiesv2");
335 for (
auto mergerCoolingNode : mergerCoolingParams.
getNodes(
"BodiesDatFileName/Body")) {
337 tessellatedSolidStr mergerTessellation = readTessellatedSolidVerticesFromDATfile(mergerCoolingNode.getString());
346 B2INFO(
"--> Mergers cooling bodies geometry imported.");
351 tessellatedSolidStr ARICHDatabaseImporter::readTessellatedSolidVerticesFromDATfile(
const std::string& inDATfile)
356 std::ifstream infile(inDATfile.c_str(), std::ifstream::in);
358 if (infile.is_open()) {
360 while (infile >> mot) {
361 if (mot ==
"BodyPositionID")
362 infile >> solidStr.tessellatedSolidID;
367 infile >> solidStr.nCells;
371 if (mot ==
"nApexPerCell")
372 infile >> solidStr.nApexPerCell;
376 TString apexNamesStr[3][3] = { {
"Apex_1_x",
"Apex_1_y",
"Apex_1_z" },
377 {
"Apex_2_x",
"Apex_2_y",
"Apex_2_z" },
378 {
"Apex_3_x",
"Apex_3_y",
"Apex_3_z" }
380 for (
unsigned int i = 0; i < 3; i++) {
382 if (mot != apexNamesStr[0][i])
384 std::vector<double> valv;
385 for (
unsigned int j = 0; j < solidStr.nCells; j++) {
389 solidStr.posV1.push_back(valv);
392 for (
unsigned int i = 0; i < 3; i++) {
394 if (mot != apexNamesStr[1][i])
396 std::vector<double> valv;
397 for (
unsigned int j = 0; j < solidStr.nCells; j++) {
401 solidStr.posV2.push_back(valv);
404 for (
unsigned int i = 0; i < 3; i++) {
406 if (mot != apexNamesStr[2][i])
408 std::vector<double> valv;
409 for (
unsigned int j = 0; j < solidStr.nCells; j++) {
413 solidStr.posV3.push_back(valv);
418 B2WARNING(
"Unable to open file : " << inDATfile <<
" with cooling bodies geometry.");
423 void ARICHDatabaseImporter::importChannelMask(TH1* h)
426 B2ERROR(
"--> NULL Histogram");
432 int numChannels = h->GetNbinsX();
433 const int NumberOfChannelsPerHapd = 144;
434 const int NumberOfHapds = 420;
436 if (numChannels != NumberOfHapds * NumberOfChannelsPerHapd) {
437 B2ERROR(
"There should be " << NumberOfHapds * NumberOfChannelsPerHapd <<
" in the histogram!");
441 for (
int bin = 1; bin <= numChannels; ++bin) {
442 int moduleID = (bin - 1) / NumberOfChannelsPerHapd + 1;
443 int channelID = (bin - 1) % NumberOfChannelsPerHapd;
444 bool value = (h->GetBinContent(bin) > 0);
445 if (!value) inactive++;
448 mask.setActiveCh(moduleID, channelID, value);
454 B2INFO(
"--> Channel Mask imported. Number of disabled channels=" << inactive <<
" Number of all channels=" << numChannels);
459 void ARICHDatabaseImporter::importReconstructionParams()
470 void ARICHDatabaseImporter::importSimulationParams()
475 GearDir content =
GearDir(
"/Detector/DetectorComponent[@name='ARICH']/Content/SimulationParameters");
477 double qeScale = content.getDouble(
"qeScale");
478 double winAbs = content.getDouble(
"windowAbsorbtion");
479 double crossTalk = content.getDouble(
"chipNegativeCrosstalk");
480 double colEff = content.getDouble(
"colEff");
482 GearDir qeParams(content,
"QE");
483 float lambdaFirst = qeParams.
getLength(
"LambdaFirst") / Unit::nm;
484 float lambdaStep = qeParams.
getLength(
"LambdaStep") / Unit::nm;
485 double peakQE = qeParams.
getDouble(
"peakQE");
487 std::vector<float> qes;
488 for (
const auto& qeff : qeParams.
getNodes(
"Qeffi")) {
489 qes.push_back(qeff.getDouble(
"qe"));
492 simPar.
setQECurve(lambdaFirst, lambdaStep, qes);
507 void ARICHDatabaseImporter::importChannelMapping()
509 GearDir content =
GearDir(
"/Detector/DetectorComponent[@name='ARICH']/Content");
512 istringstream chstream;
514 chstream.str(content.getString(
"ChannelMapping/SoftChannelMapping"));
516 B2INFO(
"Importing channel x,y to asic channel map\n");
517 B2INFO(
" x y asic\n");
518 while (chstream >> x >> y >> asic) {
520 B2INFO(
" " << setw(2) << x <<
" " << setw(2) << y <<
" " << setw(3) << asic <<
'\n');
525 importObjMap.
import(m_iov);
529 void ARICHDatabaseImporter::importFEMappings()
532 GearDir content =
GearDir(
"/Detector/DetectorComponent[@name='ARICH']/Content");
538 GearDir mapping(content,
"FrontEndMapping");
541 unsigned mergerID = (unsigned) merger.getInt(
"@id");
542 unsigned mergerSN = (unsigned) merger.getInt(
"@sn");
543 B2INFO(
'\n' <<
"Mapping of modules to merger no. " << mergerID <<
", SN = " << mergerSN <<
'\n');
544 for (
const GearDir& module : merger.getNodes(
"Modules/Module")) {
545 unsigned sector = module.getInt(
"Sector");
546 unsigned ring = module.getInt(
"Ring");
547 unsigned azimuth = module.getInt(
"Azimuth");
548 std::cout <<
"ring = " << ring <<
'\n';
549 unsigned moduleID = geoConfig->getDetectorPlane().getSlotIDFromSRF(sector, ring, azimuth);
550 std::cout <<
"moduleID = " << moduleID <<
'\n';
551 unsigned slot = (unsigned) module.getInt(
"@FEBSlot");
552 mergerMap.
addMapping(moduleID, mergerID, slot, mergerSN);
553 std::cout <<
'\n' <<
" FEB slot: " << slot <<
", module position: S" << sector <<
" R" << ring <<
" Z" << azimuth <<
554 ", module ID: " << moduleID <<
'\n';
555 std::cout <<
" crosscheck: mergerMap.getMergerID(" << moduleID <<
") = " << mergerMap.
getMergerID(
556 moduleID) <<
", mergerMap.getFEBSlot(" << moduleID <<
") = " << mergerMap.
getFEBSlot(moduleID) <<
", mergerMap.getModuleID(" <<
557 mergerID <<
"," << slot <<
") = " << mergerMap.
getModuleID(mergerID, slot) <<
'\n';
562 unsigned copperID = (unsigned) merger.getInt(
"COPPERid");
563 string finesseSlot = merger.getString(
"FinesseSlot");
565 if (finesseSlot ==
"A") {finesse = 0;}
566 else if (finesseSlot ==
"B") {finesse = 1;}
567 else if (finesseSlot ==
"C") {finesse = 2;}
568 else if (finesseSlot ==
"D") {finesse = 3;}
570 B2ERROR(merger.getPath() <<
"/FinesseSlot " << finesseSlot <<
571 " ***invalid slot (valid are A, B, C, D)");
574 copperMap.
addMapping(mergerID, copperID, finesse);
575 std::cout <<
"Merger " << mergerID <<
" connected to copper " << copperID <<
", finesse " << finesse <<
'\n';
581 importObjMerger.
import(m_iov);
585 importObjCopper.
import(m_iov);
589 void ARICHDatabaseImporter::importGeometryConfig()
592 GearDir content =
GearDir(
"/Detector/DetectorComponent[@name='ARICH']/Content");
596 importObj.
construct(arichGeometryConfig);
601 void ARICHDatabaseImporter::importCosmicTestGeometry()
603 GearDir content =
GearDir(
"/Detector/DetectorComponent[@name='ARICH']/Content");
604 GearDir cosmic(content,
"CosmicTest");
612 GearDir masterDir(cosmic,
"MasterVolume");
620 GearDir aerogel(cosmic,
"Aerogel");
623 plane.setSimple(par);
626 GearDir scints(cosmic,
"Scintilators");
628 std::string scintMat = scints.
getString(
"Material");
633 std::string name = scint.getString(
"@name");
634 double position[3] = {scint.getLength(
"Position/x"), scint.getLength(
"Position/y"), scint.getLength(
"Position/z")};
635 double rotation[3] = {scint.getAngle(
"Rotation/x"), scint.getAngle(
"Rotation/y"), scint.getAngle(
"Rotation/z")};
636 support.
addBox(name, scintMat, size, position, rotation);
646 void ARICHDatabaseImporter::importAeroTilesInfo()
651 elements.getEntries();
655 for (
int slot = 1; slot < 125; slot++) {
656 int ring = ARICHDatabaseImporter::getAeroTileRing(slot);
657 int column = ARICHDatabaseImporter::getAeroTileColumn(slot);
658 std::string aeroID =
"";
659 float refractiveIndex = 0.;
660 float transmissionLength = 0.;
661 float thickness = 0.;
662 for (
int layer = 0; layer < 2; layer++) {
663 for (
const auto& element : elements) {
664 if (element.getAerogelLayer(layer) == 1 && element.getAerogelRingID() == ring
665 && element.getAerogelColumnID() == column) aeroID = element.getAerogelSN();
667 for (
const auto& elementInfo : elementsInfo) {
668 if (elementInfo.getAerogelSN() == aeroID) {
669 refractiveIndex = elementInfo.getAerogelRefractiveIndex();
670 transmissionLength = elementInfo.getAerogelTransmissionLength();
671 thickness = elementInfo.getAerogelThickness();
675 B2INFO(
"adding mapping... slot " << slot
676 <<
", layer " << layer
677 <<
", refIn " << refractiveIndex
678 <<
", transLen " << transmissionLength
679 <<
", thick " << thickness <<
'\n');
680 tilesInfo.
addMapping(slot, layer, refractiveIndex, transmissionLength, thickness);
690 int ARICHDatabaseImporter::getAeroTileRing(
int slot)
693 if (slot < 23) ring = 1;
694 else if (slot > 22 && slot < 51) ring = 2;
695 else if (slot > 50 && slot < 85) ring = 3;
701 int ARICHDatabaseImporter::getAeroTileColumn(
int slot)
704 if (slot < 23) column = slot;
705 else if (slot > 22 && slot < 51) column = slot - 22;
706 else if (slot > 50 && slot < 85) column = slot - 50;
707 else column = slot - 84;
713 void ARICHDatabaseImporter::printAeroTileInfo()
719 void ARICHDatabaseImporter::printGlobalAlignment()
725 void ARICHDatabaseImporter::printMirrorAlignment()
731 void ARICHDatabaseImporter::printAeroTilesAlignment()
739 void ARICHDatabaseImporter::importBiasMappings()
742 GearDir content =
GearDir(
"/DetectorCables[@name='ARICH']/Content");
747 GearDir mapping(content,
"biasCableMapping");
750 unsigned cableID = (unsigned) module.getInt(
"cableID");
751 unsigned innerID = module.getInt(
"innerID");
752 unsigned ring = module.getInt(
"ring");
753 unsigned azimuth = module.getInt(
"azimuth");
754 for (
unsigned sector = 1; sector < 7; sector++) {
755 unsigned moduleID = geoConfig->getDetectorPlane().getSlotIDFromSRF(sector, ring, azimuth);
756 biasMap.
addMapping(moduleID, sector, cableID, innerID);
761 GearDir mappingCH(content,
"biasChannelMapping");
764 int crate = module.getInt(
"crate");
765 int slot = module.getInt(
"slot");
766 int channelID = module.getInt(
"channelID");
767 int pinID = module.getInt(
"pinID");
768 int connectionID = module.getInt(
"connectionID");
769 int innerID = module.getInt(
"innerID");
770 std::string type = module.getString(
"type");
771 channelsMap.
addMapping(crate, slot, channelID, pinID, connectionID, innerID, type);
775 GearDir mappingCrate(content,
"biasCrateToCable");
778 int connectionID = module.getInt(
"connectionID");
779 int sector = module.getInt(
"sector");
780 int cable = module.getInt(
"cable");
781 std::vector<int> sectorCable{sector, cable};
783 crateMap.
addMapping(connectionID, sectorCable);
788 importObjBias.
import(m_iov);
792 importObjBiasCH.
import(m_iov);
796 importObjBiasCrate.
import(m_iov);
799 void ARICHDatabaseImporter::importHvMappings()
802 GearDir content =
GearDir(
"/DetectorCables[@name='ARICH']/Content");
807 GearDir mapping(content,
"hvCableToModuleMapping");
810 unsigned cableID = (unsigned) module.getInt(
"cableID");
811 unsigned innerID = module.getInt(
"innerID");
812 unsigned ring = module.getInt(
"ring");
813 unsigned azimuth = module.getInt(
"azimuth");
814 for (
unsigned sector = 1; sector < 7; sector++) {
815 unsigned moduleID = geoConfig->getDetectorPlane().getSlotIDFromSRF(sector, ring, azimuth);
816 hvMap.
addMapping(moduleID, sector, cableID, innerID);
821 GearDir mappingCH(content,
"hvChannelMapping");
824 int crate = module.getInt(
"crate");
825 int slot = module.getInt(
"slot");
826 int channelID = module.getInt(
"channelID");
827 int connectionID = module.getInt(
"connectionID");
828 int pinID = module.getInt(
"pinID");
829 channelsMap.
addMapping(crate, slot, channelID, connectionID, pinID);
833 GearDir mappingCrate(content,
"hvCrateToCable");
836 int connectionID = module.getInt(
"connectionID");
837 int sector = module.getInt(
"sector");
838 int cable = module.getInt(
"cable");
839 std::vector<int> sectorCable{sector, cable};
841 crateMap.
addMapping(connectionID, sectorCable);
846 importObjHv.
import(m_iov);
850 importObjHvCH.
import(m_iov);
854 importObjHvCrate.
import(m_iov);
859 void ARICHDatabaseImporter::importNominalBiasVoltages()
862 GearDir content =
GearDir(
"/DetectorCables[@name='ARICH']/Content");
867 GearDir biasVoltages(content,
"biasVoltages");
870 std::string hapdID = module.getString(
"@id");
871 int biasA = module.getInt(
"biasA");
872 int biasB = module.getInt(
"biasB");
873 int biasC = module.getInt(
"biasC");
874 int biasD = module.getInt(
"biasD");
875 int guard = module.getInt(
"guard");
876 std::vector<int> voltages{biasA, biasB, biasC, biasD, guard};
882 importObjBiasVolt.
import(m_iov);
886 void ARICHDatabaseImporter::printBiasMappings()
891 channelsMap->print();
896 void ARICHDatabaseImporter::printHvMappings()
904 void ARICHDatabaseImporter::dumpHvMappings()
909 for (
int hapdID = 1; hapdID < 421; hapdID++) {
910 int val = hvMap->getCableID(hapdID) * 100 + hvMap->getInnerID(hapdID);
911 hist->setBinContent(hapdID, val);
913 hist->SetOption(
"TEXT");
914 hist->SaveAs(
"HVMapping.root");
917 void ARICHDatabaseImporter::printNominalBiasVoltages()
923 void ARICHDatabaseImporter::printNominalBiasVoltageForChannel(std::vector<int> channel)
930 elements.getEntries();
932 int connectionID = std::get<0>(channelsMap->getInnerConnection(channel));
933 int innerCable = std::get<1>(channelsMap->getInnerConnection(channel));
934 std::string biasType = std::get<2>(channelsMap->getInnerConnection(channel));
936 int sector = crateMap->getSector(connectionID);
937 int outerCable = crateMap->getCable(connectionID);
939 int moduleID = (int) biasMap->getModuleID(sector, outerCable, innerCable);
940 std::string hapdID =
"";
941 for (
const auto& element : elements) {
942 if (element.getSensorModuleID() == moduleID) hapdID = element.getHAPDserial();
945 std::vector<int> voltages = biasVolt->getBiasVoltages(hapdID);
946 int appliedVoltage = 0;
948 if (biasType ==
"bias-a") appliedVoltage = voltages[0];
949 if (biasType ==
"bias-b") appliedVoltage = voltages[1];
950 if (biasType ==
"bias-c") appliedVoltage = voltages[2];
951 if (biasType ==
"bias-d") appliedVoltage = voltages[3];
952 if (biasType ==
"guard") appliedVoltage = voltages[4];
955 B2INFO(
"Crate " << channel[0] <<
", slot " << channel[1] <<
", slot channel " << channel[2] <<
" belongs to hapd " << hapdID <<
956 " (module ID = " << moduleID <<
") in sector " << sector <<
".\n Corresponding cable is " << sector <<
"-" << outerCable <<
957 ".\n Cable type is " << biasType <<
" with applied voltage " << appliedVoltage <<
" V.");
961 void ARICHDatabaseImporter::printHapdPositionFromCrateSlot(
int crate,
int slot,
int channelID)
969 elements.getEntries();
971 std::vector<int> channel{crate, slot, channelID};
972 int connectionID = std::get<0>(channelsMap->getInnerConnection(channel));
973 int innerCableNum = std::get<1>(channelsMap->getInnerConnection(channel));
974 std::string biasType = channelsMap->getType(channel);
976 int sector = crateMap->getSector(connectionID);
977 int outerCable = crateMap->getCable(connectionID);
979 int moduleID = (int)biasMap->getModuleID(sector, outerCable, innerCableNum);
981 unsigned mergerID = mrgMap->getMergerID((
unsigned)moduleID);
982 unsigned mergerSN = mrgMap->getMergerSN((
unsigned)mergerID);
983 unsigned febSlot = mrgMap->getFEBSlot((
unsigned)moduleID);
984 int febSlotDaq = ARICHDatabaseImporter::getFebDaqSlot(febSlot);
986 for (
const auto& element : elements) {
987 if (element.getSensorGlobalID() == moduleID) B2INFO(
"HAPD for crate " << crate + 1 <<
", slot " << slot <<
", inner cable " <<
988 innerCableNum <<
" has ID number " << moduleID <<
". Bias cable number is " << sector <<
"-" << outerCable <<
989 ".\n Position is: RING " << element.getSensorModuleRingID() <<
" COLUMN " << element.getSensorModuleColumnID() <<
990 ". \n Bias type for channel " << channelID <<
" is " << biasType <<
".\n It belongs to merger " << mergerID <<
" (SN " <<
991 mergerSN <<
") and has DAQ feb slot " << febSlotDaq);
996 int ARICHDatabaseImporter::getFebDaqSlot(
unsigned febSlot)
998 std::map<unsigned, int> febSlots;
999 febSlots.insert(std::pair<unsigned, int>(6, 0));
1000 febSlots.insert(std::pair<unsigned, int>(5, 1));
1001 febSlots.insert(std::pair<unsigned, int>(4, 2));
1002 febSlots.insert(std::pair<unsigned, int>(1, 3));
1003 febSlots.insert(std::pair<unsigned, int>(2, 4));
1004 febSlots.insert(std::pair<unsigned, int>(3, 5));
1006 int febDaqSlot = febSlots.find(febSlot)->second;
1011 void ARICHDatabaseImporter::printSimulationPar()
1017 void ARICHDatabaseImporter::printGeometryConfig()
1024 void ARICHDatabaseImporter::printChannelMapping()
1030 void ARICHDatabaseImporter::printMergerMapping()
1036 void ARICHDatabaseImporter::printCopperMapping()
1042 void ARICHDatabaseImporter::printModulesInfo()
1048 void ARICHDatabaseImporter::printReconstructionPar()
1055 void ARICHDatabaseImporter::printChannelMask(
bool makeHist)
1063 for (
int hapdID = 1; hapdID < 421; hapdID++) {
1064 for (
int ichn = 0; ichn < 144; ichn++) {
1065 if (chMask->isActive(hapdID, ichn)) hist->setBinContent(hapdID, ichn, 1.0);
1068 hist->SaveAs(
"channelMask.root");
1072 void ARICHDatabaseImporter::dumpMergerMapping(
bool sn)
1076 for (
int hapdID = 1; hapdID < 421; hapdID++) {
1077 int val = mgrMap->getMergerID(hapdID);
1078 if (sn) val = mgrMap->getMergerSN(val);
1079 hist->setBinContent(hapdID, val);
1081 hist->SetOption(
"TEXT");
1082 hist->SaveAs(
"MergerMapping.root");
1086 void ARICHDatabaseImporter::printFEMappings()
1093 GearDir content =
GearDir(
"/Detector/DetectorComponent[@name='ARICH']/Content/InstalledModules");
1095 cout <<
"{ \"hapdmap\": [" << endl;
1096 for (
unsigned hapdID = 1; hapdID < 421; hapdID++) {
1098 for (
const GearDir& module : content.getNodes(
"Module")) {
1099 hapdsn = module.getString(
"@hapdID");
1100 unsigned sector = module.getInt(
"Sector");
1101 unsigned ring = module.getInt(
"Ring");
1102 unsigned azimuth = module.getInt(
"Azimuth");
1103 unsigned moduleID = geoConfig->getDetectorPlane().getSlotIDFromSRF(sector, ring, azimuth);
1104 if (moduleID == hapdID)
break;
1107 int val = mgrMap->getMergerID(hapdID);
1108 cout <<
"{\n" <<
"\"ID\": \"" << hapdID <<
"\"," << endl;
1109 cout <<
"\"sn\": \"" << hapdsn <<
"\"," << endl;
1110 cout <<
"\"mrg\": \"" << val <<
"\"," << endl;
1111 cout <<
"\"mrgSN\": \"" << mgrMap->getMergerSN(val) <<
"\"," << endl;
1112 cout <<
"\"feb\": \"" << mgrMap->getFEBSlot(hapdID) - 1 <<
"\"," << endl;
1113 cout <<
"\"cpr\": \"" << cprMap->getCopperID(val) <<
"\"," << endl;
1114 cout <<
"\"hslb\": \"" << cprMap->getFinesse(val) <<
"\"" << endl;
1115 if (hapdID < 420) cout <<
"}," << endl;
1116 else cout <<
"}" << endl;
1118 cout <<
"]}" << endl;
1123 void ARICHDatabaseImporter::dumpModuleNumbering()
1127 for (
int hapdID = 1; hapdID < 421; hapdID++) {
1128 hist->setBinContent(hapdID, hapdID);
1130 hist->SetOption(
"TEXT");
1131 hist->SaveAs(
"ModuleNumbering.root");
1135 void ARICHDatabaseImporter::dumpQEMap(
bool simple)
1142 TGraph2D* gr =
new TGraph2D();
1144 for (
int i = 1; i < 421; i++) {
1145 if (modInfo->isInstalled(i)) {
1146 for (
int j = 0; j < 144; j++) {
1148 chMap->getXYFromAsic(j, xCh, yCh);
1149 TVector2 chPos = geoConfig->getChannelPosition(i, xCh, yCh);
1150 gr->SetPoint(point, chPos.X(), chPos.Y(), modInfo->getChannelQE(i, j));
1155 gr->SaveAs(
"QEMap.root");
1158 for (
int hapdID = 1; hapdID < 421; hapdID++) {
1159 if (!modInfo->isInstalled(hapdID))
continue;
1160 for (
int chID = 0; chID < 144; chID++) {
1161 hist->setBinContent(hapdID, chID, modInfo->getChannelQE(hapdID, chID));
1164 hist->SaveAs(
"QEMap.root");
1168 void ARICHDatabaseImporter::dumpAerogelOpticalProperties(std::string outRootFileName)
1178 std::string condDBname =
"ARICHdata";
1180 if (condDBname ==
"ARICHdata") {
1189 for (
const auto& elementM : elementsM) {
1190 if (elementM.getAerogelLayer(0) == 1) {
1191 for (
const auto& elementI : elementsI) {
1192 if (elementI.getAerogelSN() == elementM.getAerogelSN()) {
1195 elementM.getAerogelColumnID()), elementI.getAerogelRefractiveIndex());
1196 h2_aerogel_down_transmL->SetBinContent(h2_aerogel_down_transmL->
GetBinIDFromRingColumn(elementM.getAerogelRingID(),
1197 elementM.getAerogelColumnID()), elementI.getAerogelTransmissionLength());
1198 h2_aerogel_down_thick->SetBinContent(h2_aerogel_down_thick->
GetBinIDFromRingColumn(elementM.getAerogelRingID(),
1199 elementM.getAerogelColumnID()), elementI.getAerogelThickness());
1203 if (elementM.getAerogelLayer(1) == 1) {
1204 for (
const auto& elementI : elementsI) {
1205 if (elementI.getAerogelSN() == elementM.getAerogelSN()) {
1207 h2_aerogel_up_n->SetBinContent(h2_aerogel_up_n->
GetBinIDFromRingColumn(elementM.getAerogelRingID(), elementM.getAerogelColumnID()),
1208 elementI.getAerogelRefractiveIndex());
1209 h2_aerogel_up_transmL->SetBinContent(h2_aerogel_up_transmL->
GetBinIDFromRingColumn(elementM.getAerogelRingID(),
1210 elementM.getAerogelColumnID()), elementI.getAerogelTransmissionLength());
1211 h2_aerogel_up_thick->SetBinContent(h2_aerogel_up_thick->
GetBinIDFromRingColumn(elementM.getAerogelRingID(),
1212 elementM.getAerogelColumnID()), elementI.getAerogelThickness());
1224 TFile* rootFile =
new TFile(outRootFileName.c_str(),
"RECREATE",
" Histograms", 1);
1226 if (rootFile->IsZombie()) {
1227 B2ERROR(
" ERROR ---> file : " << outRootFileName.c_str() <<
" is zombi");
1229 h2_aerogel_up_n->Write();
1230 h2_aerogel_up_transmL->Write();
1231 h2_aerogel_up_thick->Write();
1232 h2_aerogel_down_n->Write();
1233 h2_aerogel_down_transmL->Write();
1234 h2_aerogel_down_thick->Write();
1239 void ARICHDatabaseImporter::importAeroRayleighScatteringFit(std::string commentSingleWord)
1246 TClonesArray agelFitConstants(
"Belle2::ARICHAerogelRayleighScatteringFit");
1249 float version = (float) content.getDouble(
"version");
1252 for (
const auto& aerogel : content.getNodes(
"aerogeltile")) {
1254 serial = aerogel.getString(
"serial");
1256 vPar.push_back((
float)aerogel.getDouble(
"p0"));
1257 vPar.push_back((
float)aerogel.getDouble(
"p1"));
1258 vPar.push_back((
float)aerogel.getDouble(
"p2"));
1259 vPar.push_back((
float)aerogel.getDouble(
"p3"));
1260 vPar.push_back((
float)aerogel.getDouble(
"p4"));
1261 vPar.push_back((
float)aerogel.getDouble(
"p5"));
1262 vPar.push_back((
float)aerogel.getDouble(
"p6"));
1268 agelFitConstants[agel] = aeroRayScatFit;
1275 TString coreName =
"ARICHAerogelRayleighScatteringFit";
1276 TString coreNameSuffix = commentSingleWord;
1277 if (coreNameSuffix !=
"")
1278 coreName += coreNameSuffix;
1279 Database::Instance().storeData(coreName.Data(), &agelFitConstants, m_iov);
1284 void ARICHDatabaseImporter::importAerogelInfo(TString coreNameSuffix)
1286 GearDir content =
GearDir(
"/ArichData/AllData/AerogelData/Content");
1289 TClonesArray agelConstants(
"Belle2::ARICHAerogelInfo");
1293 for (
const auto& aerogel : content.getNodes(
"aerogel")) {
1294 float version = (float) aerogel.getDouble(
"version");
1295 string serial = aerogel.getString(
"serial");
1296 string id = aerogel.getString(
"id");
1297 float index = (float) aerogel.getDouble(
"index");
1298 float trlen = ((float) aerogel.getDouble(
"translength")) * Unit::mm;
1299 float thickness = ((float) aerogel.getDouble(
"thick")) * Unit::mm;
1300 vector<int> lambdas;
1301 vector<float> transmittances;
1302 for (
const auto& transmittance : aerogel.getNodes(
"transmittance/transpoint")) {
1303 int lambda = transmittance.getInt(
"@lambda");
1304 float val = (float) transmittance.getDouble(
".");
1305 lambdas.push_back(lambda);
1306 transmittances.push_back(val);
1310 new(agelConstants[agel])
ARICHAerogelInfo(version, serial,
id, index, trlen, thickness, lambdas, transmittances);
1319 TString coreName =
"ARICHAerogelInfo";
1320 if (coreNameSuffix !=
"")
1321 coreName += coreNameSuffix;
1322 Database::Instance().storeData(coreName.Data(), &agelConstants, m_iov);
1325 void ARICHDatabaseImporter::exportAerogelInfo(
int verboseLevel)
1362 elements.getEntries();
1365 for (
const auto& element : elements) {
1366 B2INFO(
"Version = " << element.getAerogelVersion() <<
", serial = " << element.getAerogelSN() <<
1367 ", id = " << element.getAerogelID() <<
", n = " << element.getAerogelRefractiveIndex() <<
", transmLength = " <<
1368 element.getAerogelTransmissionLength() <<
", thickness = " << element.getAerogelThickness());
1369 if (verboseLevel > 0) {
1370 unsigned int ii = 0;
1372 while (lllambda > 0) {
1373 lllambda = element.getAerogelTransmittanceLambda(ii);
1376 float llval = element.getAerogelTransmittance(ii);
1377 B2INFO(
" Lambda = " << lllambda <<
" Transmittance = " << llval);
1386 void ARICHDatabaseImporter::importAerogelMap()
1391 TClonesArray agelMap(
"Belle2::ARICHAerogelMap");
1394 for (
int layer = 0; layer < 2; layer++) {
1396 for (
const auto& aerogel : content.getNodes(
"position")) {
1397 string agelserial =
"";
1398 int ring = aerogel.getInt(
"ring");
1399 int phi = aerogel.getInt(
"phi");
1400 if (layer == 1) agelserial = aerogel.getString(
"upaerogelserial");
1401 if (layer == 0) agelserial = aerogel.getString(
"downaerogelserial");
1407 agelConst->setAerogelRingID(ring);
1408 agelConst->setAerogelColumnID(phi);
1409 agelConst->setAerogelLayer(layer, 1);
1416 Database::Instance().storeData(
"ARICHAerogelMap", &agelMap, m_iov);
1421 void ARICHDatabaseImporter::exportAerogelMap()
1425 elements.getEntries();
1428 for (
const auto& element : elements) {
1430 if (element.getAerogelLayer(0) == 1) layer =
"down";
1431 if (element.getAerogelLayer(1) == 1) layer =
"up";
1432 B2INFO(
"ID = " << element.getAerogelSN() <<
", ring = " << element.getAerogelRingID() <<
1433 ", column = " << element.getAerogelColumnID() <<
", layer: " << layer);
1438 void ARICHDatabaseImporter::importAerogelInfoEventDep()
1440 GearDir content =
GearDir(
"/ArichData/AllData/AerogelData/Content");
1443 TClonesArray agelConstantsA(
"Belle2::ARICHAerogelInfo");
1444 TClonesArray agelConstantsB(
"Belle2::ARICHAerogelInfo");
1445 TClonesArray agelConstantsC(
"Belle2::ARICHAerogelInfo");
1448 for (
int someint = 0; someint < 3; someint++) {
1451 for (
const auto& aerogel : content.getNodes(
"aerogel")) {
1455 if (someint == 0) version = (float) aerogel.getDouble(
"version");
1456 if (someint == 1) version = 4.0;
1457 if (someint == 2) version = 5.0;
1459 string serial = aerogel.getString(
"serial");
1460 string id = aerogel.getString(
"id");
1461 float index = (float) aerogel.getDouble(
"index");
1462 float trlen = ((float) aerogel.getDouble(
"translength")) * Unit::mm;
1463 float thickness = ((float) aerogel.getDouble(
"thick")) * Unit::mm;
1464 vector<int> lambdas;
1465 vector<float> transmittances;
1466 for (
const auto& transmittance : aerogel.getNodes(
"transmittance/transpoint")) {
1467 int lambda = transmittance.getInt(
"@lambda");
1468 float val = (float) transmittance.getDouble(
".");
1469 lambdas.push_back(lambda);
1470 transmittances.push_back(val);
1474 if (someint == 0)
new(agelConstantsA[agel])
ARICHAerogelInfo(version, serial,
id, index, trlen, thickness, lambdas,
1476 if (someint == 1)
new(agelConstantsB[agel])
ARICHAerogelInfo(version, serial,
id, index, trlen, thickness, lambdas,
1478 if (someint == 2)
new(agelConstantsC[agel])
ARICHAerogelInfo(version, serial,
id, index, trlen, thickness, lambdas,
1485 TObject* agelObj[3];
1486 agelObj[0] =
static_cast<TObject*
>(&agelConstantsA);
1487 agelObj[1] =
static_cast<TObject*
>(&agelConstantsB);
1488 agelObj[2] =
static_cast<TObject*
>(&agelConstantsC);
1492 intraRun.
add(500, agelObj[1]);
1493 intraRun.
add(1000, agelObj[2]);
1496 Database::Instance().storeData(
"ARICHAerogelInfoEventDep", &intraRun, m_iov);
1500 void ARICHDatabaseImporter::exportAerogelInfoEventDep()
1512 std::pair<TObject*, IntervalOfValidity> podatki = Database::Instance().getData(event,
"ARICHAerogelInfoEventDep");
1520 TObject* data = std::get<0>(podatki);
1522 TObject* myobject = data2->
getObject(event);
1523 TClonesArray* elements =
static_cast<TClonesArray*
>(myobject);
1526 (*elements).GetEntries();
1527 for (
int i = 0; i < elements->GetSize(); i++) {
1552 void ARICHDatabaseImporter::importHapdQA()
1555 TClonesArray hapdQAConstants(
"Belle2::ARICHHapdQA");
1559 for (
const string& inputFile : m_inputFilesHapdQA) {
1560 TFile* f = TFile::Open(inputFile.c_str(),
"READ");
1562 int size = inputFile.length();
1563 string hapdSerial = inputFile.substr(size - 16, 6);
1565 vector<TGraph*> leakCurrent;
1566 TH2F* hitData2D = 0;
1567 vector<TGraph*> noise;
1568 vector<TH1S*> hitCount;
1569 TTimeStamp arrivalDate;
1574 TIter next(f->GetListOfKeys());
1576 while ((key = (TKey*)next())) {
1578 string strime = key->GetName();
1580 if (strime.compare(0, 8,
"gcurrent") == 0) {
1581 TGraph* graphcurrent = (TGraph*)f->Get(strime.c_str());
1582 leakCurrent.push_back(graphcurrent);
1585 else if (strime.compare(0, 7,
"h2dscan") == 0) {
1586 hitData2D = (TH2F*)f->Get(strime.c_str());
1587 hitData2D->SetDirectory(0);
1590 else if (strime.compare(0, 9,
"gnoise_ch") == 0) {
1591 TGraph* graphnoise = (TGraph*)f->Get(strime.c_str());
1592 noise.push_back(graphnoise);
1595 else if (strime.compare(0, 7,
"hchscan") == 0) {
1596 TH1F* hhist3 = (TH1F*)f->Get(strime.c_str());
1597 hhist3->SetDirectory(0);
1601 const char* hhist3_ime = hhist3->GetName();
1602 const char* hhist3_naslov = hhist3->GetTitle();
1603 int hhist3_nbins = hhist3->GetSize();
1604 TH1S* hhist3short =
new TH1S(hhist3_ime, hhist3_naslov, hhist3_nbins - 2, 0, 1);
1605 for (
int bin = 0; bin < hhist3_nbins; bin++) {
1606 hhist3short->SetBinContent(bin, hhist3->GetBinContent(bin));
1608 hhist3short->SetDirectory(0);
1609 hitCount.push_back(hhist3short);
1612 else if (strime.compare(0, 4,
"tree") == 0) {
1613 tree = (TTree*)f->Get(strime.c_str());
1614 tree->SetBranchAddress(
"arrival", &arrival);
1616 arrivalDate = TTimeStamp(arrival, 0);
1619 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()); }
1623 new(hapdQAConstants[
hapd])
ARICHHapdQA(hapdSerial, arrivalDate, leakCurrent, hitData2D, noise, hitCount);
1628 Database::Instance().storeData(
"ARICHHapdQA", &hapdQAConstants, m_iov);
1632 void ARICHDatabaseImporter::exportHapdQA()
1635 elements.getEntries();
1638 for (
const auto& element : elements) {
1639 B2INFO(
"Serial number = " << element.getHapdSerialNumber() <<
"; arrival date = " << element.getHapdArrivalDate());
1643 void ARICHDatabaseImporter::importAsicInfo()
1647 TClonesArray asicConstants(
"Belle2::ARICHAsicInfo");
1650 for (
const auto& asiclist : content.getNodes(
"asicinfo")) {
1651 string asicSerial = asiclist.getString(
"serial");
1652 string comment = asiclist.getString(
"comment");
1653 string numCH = asiclist.getString(
"num");
1656 TTimeStamp timeFinishGain = ARICHDatabaseImporter::getAsicDate(asicSerial,
"gain");
1657 TTimeStamp timeFinishOffset = ARICHDatabaseImporter::getAsicDate(asicSerial,
"offset");
1660 vector<int> nosignalCHs = ARICHDatabaseImporter::channelsList(asiclist.getString(
"nosignal"));
1661 vector<int> badconnCHs = ARICHDatabaseImporter::channelsList(asiclist.getString(
"badconn"));
1662 vector<int> badoffsetCHs = ARICHDatabaseImporter::channelsList(asiclist.getString(
"badoffset"));
1663 vector<int> badlinCHs = ARICHDatabaseImporter::channelsList(asiclist.getString(
"badlin"));
1666 if (numCH.find(
"many") != string::npos) {num = 5000; }
1667 else if (numCH.find(
"all") != string::npos) {num = 10000; }
1668 else {num = atoi(numCH.c_str()); }
1673 auto* asicConst =
static_cast<ARICHAsicInfo*
>(asicConstants[asic]);
1676 asicConst->setTimeFinishGain(timeFinishGain);
1677 asicConst->setTimeFinishOffset(timeFinishOffset);
1678 asicConst->setDeadChannels(nosignalCHs);
1679 asicConst->setBadConnChannels(badconnCHs);
1680 asicConst->setBadOffsetChannels(badoffsetCHs);
1681 asicConst->setBadLinChannels(badlinCHs);
1682 asicConst->setNumOfProblematicChannels(num);
1683 asicConst->setComment(comment);
1688 Database::Instance().storeData(
"ARICHAsicInfo", &asicConstants, m_iov);
1691 void ARICHDatabaseImporter::importAsicInfoRoot()
1693 TFile f1(
"asicInfoHistograms.root",
"recreate");
1700 string asicSerial =
"";
1703 TTree* tree =
new TTree(
"asicInfo",
"asic info data");
1705 tree->Branch(
"asicSerial", (
void*)asicSerial.c_str(),
"string/C", 1024);
1706 tree->Branch(
"gain0",
"TH3F", &gain0);
1707 tree->Branch(
"gain1",
"TH3F", &gain1);
1708 tree->Branch(
"gain2",
"TH3F", &gain2);
1709 tree->Branch(
"gain3",
"TH3F", &gain3);
1710 tree->Branch(
"offsetF",
"TH3F", &offsetF);
1711 tree->Branch(
"offsetR",
"TH3F", &offsetR);
1714 for (
const string& inputFile : m_inputFilesAsicRoot) {
1716 string inputFileNew = (string) inputFile;
1717 string asicName = inputFileNew.substr(inputFileNew.find(
"/asicData") + 17);
1718 size_t findRoot = asicName.find(
".root");
1719 if (findRoot != string::npos) {
1721 TFile* f = TFile::Open(inputFile.c_str(),
"READ",
"", 0);
1722 TIter next(f->GetListOfKeys());
1726 while ((key = (TKey*)next())) {
1727 string strname = key->GetName();
1728 if (strname.find(
"_g0") != string::npos) gain0 = (TH3F*)f->Get(strname.c_str());
1729 else if (strname.find(
"_g1") != string::npos) gain1 = (TH3F*)f->Get(strname.c_str());
1730 else if (strname.find(
"_g2") != string::npos) gain2 = (TH3F*)f->Get(strname.c_str());
1731 else if (strname.find(
"_g3") != string::npos) gain3 = (TH3F*)f->Get(strname.c_str());
1732 else if (strname.find(
"_f") != string::npos) offsetF = (TH3F*)f->Get(strname.c_str());
1733 else if (strname.find(
"_c") != string::npos) offsetR = (TH3F*)f->Get(strname.c_str());
1734 else B2INFO(
"Key name does not match any of the following: gain, offset!");
1747 Database::Instance().addPayload(
"ARICHAsicInfoRoot",
"asicInfoHistograms.root", m_iov);
1750 TTimeStamp ARICHDatabaseImporter::getAsicDate(
const std::string& asicSerial,
const std::string& type)
1752 TTimeStamp timeFinish;
1754 size_t findText = 100;
1757 for (
const string& inputFile : m_inputFilesAsicTxt) {
1758 string inputFileNew = (string) inputFile;
1759 if (type ==
"gain") { findText = inputFileNew.find(
"dateGain.txt"); }
1760 else if (type ==
"offset") { findText = inputFileNew.find(
"dateOffset.txt"); }
1761 else {B2INFO(
"Check type of measurement!"); }
1762 if (findText != string::npos) {
1763 std::ifstream ifs(inputFile);
1764 if (ifs.is_open()) {
1765 while (ifs.good()) {
1766 std::getline(ifs, line);
1767 string asicSerial2 = asicSerial +
":";
1768 size_t findSerial = line.find(asicSerial2);
1769 if (findSerial != string::npos) {timeFinish = ARICHDatabaseImporter::timedate(line);}
1779 TTimeStamp ARICHDatabaseImporter::timedate(std::string enddate)
1782 string dateEnd = enddate.substr(enddate.find(
":") + 2);
1783 string yearStr = dateEnd.substr(0, 4);
1784 string monthStr = dateEnd.substr(4, 2);
1785 string dayStr = dateEnd.substr(6, 2);
1786 string hourStr = dateEnd.substr(8, 2);
1787 string minStr = dateEnd.substr(10, 2);
1788 int year = atoi(yearStr.c_str());
1789 int month = atoi(monthStr.c_str());
1790 int day = atoi(dayStr.c_str());
1791 int hour = atoi(hourStr.c_str());
1792 int min = atoi(minStr.c_str());
1793 TTimeStamp datum = TTimeStamp(year, month, day, hour, min, 0, 0, kTRUE, -9 * 60 * 60);
1797 vector<int> ARICHDatabaseImporter::channelsList(std::string badCH)
1802 if ((badCH.find(
"many") != string::npos) || (badCH.find(
"all") != string::npos)) CHs.emplace_back(-1);
1803 else ARICHTools::StringToVector::convert<int>(badCH,
',');
1809 void ARICHDatabaseImporter::exportAsicInfo()
1813 elements.getEntries();
1816 for (
const auto& element : elements) {
1817 B2INFO(
"asic SN: " << element.getAsicID());
1822 void ARICHDatabaseImporter::importFebTest()
1826 TClonesArray febConstants(
"Belle2::ARICHFebTest");
1832 GearDir content2 =
GearDir(
"/ArichData/AllData/FEBData/Content");
1834 for (
const auto& runserial : content.getNodes(
"run")) {
1835 int serial = runserial.getInt(
"sn");
1838 auto* febConst =
static_cast<ARICHFebTest*
>(febConstants[feb]);
1841 string runLV = runserial.getString(
"lv");
1842 string runHV = runserial.getString(
"hv");
1843 string runSCAN = runserial.getString(
"scan");
1844 string comment = runserial.getString(
"comment");
1846 febConst->setRunLV(runLV);
1847 febConst->setRunHV(runHV);
1848 febConst->setRunSlowC(runSCAN);
1849 febConst->setComment(comment);
1854 for (
const auto& febmap : content1.
getNodes(
"febps")) {
1855 string somedna = febmap.getString(
"@dna");
1856 int sn = febmap.getInt(
"sn");
1857 if ((l == 0) && (sn == serial)) {
1859 febConst->setFebDna(dna);
1866 if (!runSCAN.empty()) {
1868 if (stoi(runSCAN.c_str()) < 23) {scanRun = stoi(runSCAN.c_str());}
1869 else {scanRun = stoi(runSCAN.c_str()) - 77;}
1870 for (
const auto& testFEB : content2.
getNodes(
"febtest[" + std::to_string(scanRun) +
"]")) {
1871 string timeSlowC = testFEB.getString(
"time");
1873 int positionOld = 0;
1875 for (
const auto& testFEBslowctest : testFEB.getNodes(
"slowc")) {
1876 int position = testFEBslowctest.getInt(
"id");
1877 if (position == positionOld) {i++; }
1880 string dnaNew = testFEBslowctest.getString(
"dna");
1881 if (dnaNew == dna) {
1882 float tmon0 = (float) testFEBslowctest.getDouble(
"TMON0");
1883 float tmon1 = (float) testFEBslowctest.getDouble(
"TMON1");
1884 float vdd = (float) testFEBslowctest.getDouble(
"VDD");
1885 float v2p = (float) testFEBslowctest.getDouble(
"V2P");
1886 float v2n = (float) testFEBslowctest.getDouble(
"V2N");
1887 float vss = (float) testFEBslowctest.getDouble(
"VSS");
1888 float vth1 = (float) testFEBslowctest.getDouble(
"VTH1");
1889 float vth2 = (float) testFEBslowctest.getDouble(
"VTH2");
1890 float vcc12 = (float) testFEBslowctest.getDouble(
"VCC12");
1891 float vcc15 = (float) testFEBslowctest.getDouble(
"VCC15");
1892 float vcc25 = (float) testFEBslowctest.getDouble(
"VCC25");
1893 float v38p = (float) testFEBslowctest.getDouble(
"V38P");
1895 febConst->setTemperature0(tmon0);
1896 febConst->setTemperature1(tmon1);
1897 febConst->setVdd(vdd);
1898 febConst->setV2p(v2p);
1899 febConst->setV2n(v2n);
1900 febConst->setVss(vss);
1901 febConst->setVth1(vth1);
1902 febConst->setVth2(vth2);
1903 febConst->setVcc12(vcc12);
1904 febConst->setVcc15(vcc15);
1905 febConst->setVcc25(vcc25);
1906 febConst->setV38p(v38p);
1907 febConst->setTimeSlowC(ARICHDatabaseImporter::timedate2(timeSlowC));
1911 positionOld = position;
1916 pair<vector<float>, vector<float>> slopes = ARICHDatabaseImporter::getSlopes(serial, runSCAN);
1918 febConst->setSlopesFine(slopes.first);
1919 febConst->setSlopesRough(slopes.second);
1922 vector<pair<float, float>> fwhm = ARICHDatabaseImporter::getFwhm(serial, runSCAN);
1923 febConst->setFWHM(fwhm);
1928 if (!runHV.empty()) {
1930 if (stoi(runHV.c_str()) < 43) {hvRun = stoi(runHV.c_str());}
1931 else {hvRun = stoi(runHV.c_str()) - 57;}
1932 tuple<string, float> HVtest = ARICHDatabaseImporter::getFebHVtestData(serial, hvRun);
1933 febConst->setTimeHV(ARICHDatabaseImporter::timedate2(get<0>(HVtest)));
1934 febConst->setCurrentV99p(get<1>(HVtest));
1939 if (!runLV.empty()) {
1941 if (stoi(runLV.c_str()) < 43) {lvRun = stoi(runLV.c_str());}
1942 else {lvRun = stoi(runLV.c_str()) - 57;}
1943 tuple<string, float, float, float> LVtest = ARICHDatabaseImporter::getFebLVtestData(serial, lvRun);
1944 febConst->setTimeLV(ARICHDatabaseImporter::timedate2(get<0>(LVtest)));
1945 febConst->setCurrentV20p(get<1>(LVtest));
1946 febConst->setCurrentV21n(get<2>(LVtest));
1947 febConst->setCurrentV38p(get<3>(LVtest));
1955 Database::Instance().storeData(
"ARICHFebTest", &febConstants, m_iov);
1960 void ARICHDatabaseImporter::importFebTestRoot()
1962 TFile f(
"febTestHistograms.root",
"recreate");
1963 TH3F* offsetRough = 0;
1964 TH3F* offsetFine = 0;
1965 TH2F* testPulse = 0;
1969 TTree* tree =
new TTree(
"febTest",
"feb test data");
1971 tree->Branch(
"serial", &serial,
"sn/I");
1972 tree->Branch(
"offsetRough",
"TH3F", &offsetRough);
1973 tree->Branch(
"offsetFine",
"TH3F", &offsetFine);
1974 tree->Branch(
"testPulse",
"TH2F", &testPulse);
1976 int febposition = -1;
1980 GearDir content2 =
GearDir(
"/ArichData/AllData/FEBData/Content");
1982 for (
const auto& runserial : content.getNodes(
"run")) {
1983 serial = runserial.getInt(
"sn");
1984 string runSCAN = runserial.getString(
"scan");
1988 for (
const auto& febmap : content1.
getNodes(
"febps")) {
1989 string somedna = febmap.getString(
"@dna");
1990 int sn = febmap.getInt(
"sn");
1991 if ((l == 0) && (sn == serial)) {
1997 if (!runSCAN.empty()) {
1999 if (stoi(runSCAN.c_str()) < 23) {scanRun = stoi(runSCAN.c_str());}
2000 else {scanRun = stoi(runSCAN.c_str()) - 77;}
2001 for (
const auto& testFEB : content2.
getNodes(
"febtest[" + std::to_string(scanRun) +
"]")) {
2003 int positionOld = 0;
2005 for (
const auto& testFEBslowctest : testFEB.getNodes(
"slowc")) {
2006 int position = testFEBslowctest.getInt(
"id");
2007 if (position == positionOld) {i++; }
2010 string dnaNew = testFEBslowctest.getString(
"dna");
2011 if (dnaNew == dna) febposition = position;
2013 positionOld = position;
2016 vector<TH3F*> histograms = getFebTestHistograms(dna, runSCAN, febposition);
2017 offsetRough = histograms[0];
2018 offsetFine = histograms[1];
2020 testPulse = ARICHDatabaseImporter::getFebTestPulse(dna, runSCAN, febposition);
2022 testPulse->SetDirectory(0);
2023 offsetRough->SetDirectory(0);
2024 offsetFine->SetDirectory(0);
2040 Database::Instance().addPayload(
"ARICHFebTestRoot",
"febTestHistograms.root", m_iov);
2044 std::tuple<std::string, float, float, float> ARICHDatabaseImporter::getFebLVtestData(
int serial,
int lvRun)
2046 GearDir content2LV =
GearDir(
"/ArichData/AllData/FEBDataLV/Content");
2047 std::tuple<std::string, float, float, float> LVtest;
2048 float currentV20p = 0.0, currentV21n = 0.0, currentV38p = 0.0;
2050 for (
const auto& testFEBlv : content2LV.
getNodes(
"febtest[" + std::to_string(lvRun) +
"]")) {
2051 string timeLV = testFEBlv.getString(
"time");
2052 for (
const auto& testFEBlv_sn : testFEBlv.getNodes(
"lvtest/feb[sn='" + to_string(serial) +
"']/febps/n[@id='14']")) {
2053 for (
const auto& testFEBlv_pw : testFEBlv_sn.getNodes(
"pw18")) {
2054 if (testFEBlv_pw.getInt(
"@id") == 0) { currentV20p = (float) testFEBlv_pw.getDouble(
"I"); }
2055 if (testFEBlv_pw.getInt(
"@id") == 1) { currentV21n = (float) testFEBlv_pw.getDouble(
"I"); }
2056 if (testFEBlv_pw.getInt(
"@id") == 2) { currentV38p = (float) testFEBlv_pw.getDouble(
"I"); }
2057 LVtest = make_tuple(timeLV, currentV20p, currentV21n, currentV38p);
2065 std::tuple<std::string, float> ARICHDatabaseImporter::getFebHVtestData(
int serial,
int hvRun)
2067 GearDir content2HV =
GearDir(
"/ArichData/AllData/FEBDataHV/Content");
2068 std::tuple<std::string, float> HVtest;
2069 for (
const auto& testFEBhv : content2HV.
getNodes(
"febtest[" + std::to_string(hvRun) +
"]")) {
2070 string timeHV = testFEBhv.getString(
"time");
2071 for (
const auto& testFEBhv_sn : testFEBhv.getNodes(
"hvtest/feb[sn='" + to_string(serial) +
"']/febhv/n[@id='9']")) {
2072 float currentV99p = (float) testFEBhv_sn.getDouble(
"n1470/I");
2073 HVtest = std::make_tuple(timeHV, currentV99p);
2079 std::vector<int> ARICHDatabaseImporter::getDeadChFEB(
const std::string& dna)
2081 vector<int> listCHs;
2083 ifstream fileFEB(
"febTest/FEBdeadChannels.txt");
2084 if (fileFEB.is_open()) {
2085 while (getline(fileFEB, line)) {
2086 string ch2 = line.substr(line.find(
",") + 1);
2087 string dna2 = line.erase(line.find(
",") - 1);
2088 if (dna2 == dna) { listCHs.push_back(atoi(ch2.c_str())); }
2090 }
else { B2INFO(
"No file FEBdeadChannels.txt"); }
2096 TTimeStamp ARICHDatabaseImporter::timedate2(std::string time)
2099 string dateMeas = time.substr(4);
2100 string yearStr = dateMeas.substr(16, 4);
2101 string monthStr = dateMeas.substr(0, 3);
2102 string dayStr = dateMeas.substr(4, 2);
2103 string hourStr = dateMeas.substr(7, 2);
2104 string minStr = dateMeas.substr(10, 2);
2105 string secStr = dateMeas.substr(13, 2);
2107 int year = atoi(yearStr.c_str());
2108 int day = atoi(dayStr.c_str());
2109 int hour = atoi(hourStr.c_str());
2110 int min = atoi(minStr.c_str());
2111 int sec = atoi(secStr.c_str());
2112 map<string, int> months {
2113 {
"Jan", 1 }, {
"Feb", 2 }, {
"Mar", 3 }, {
"Apr", 4 }, {
"May", 5 }, {
"Jun", 6 }, {
"Jul", 7 }, {
"Aug", 8 }, {
"Sep", 9 }, {
"Oct", 10 }, {
"Nov", 11 }, {
"Dec", 12 }
2115 int month = months.find(monthStr)->second;
2117 TTimeStamp datum = TTimeStamp(year, month, day, hour, min, sec, 0, kTRUE, 0);
2121 std::pair<std::vector<float>, std::vector<float>> ARICHDatabaseImporter::getSlopes(
int serialNum,
const std::string& run)
2123 GearDir contentData =
GearDir(
"/ArichData/AllData/SlopesFebTest/Content");
2124 pair<vector<float>, vector<float>> slopesFebTest;
2125 vector<float> slopesCoarse, slopesFine;
2127 for (
const auto& contentSlopes : contentData.
getNodes(
"febtest")) {
2128 if ((contentSlopes.getInt(
"@id") == serialNum) && (contentSlopes.getString(
"@run") == run)) {
2129 for (
int i = 0; i < 144; i++) {
2130 for (
const auto& contSlopes : contentSlopes.getNodes(
"slope/ch[@id='" + to_string(i) +
"']")) {
2131 float slopeCoarse = ((float) contSlopes.getDouble(
"coarse")) * 2.5 / 1024;
2132 float slopeFine = ((float) contSlopes.getDouble(
"fine")) * 2.5 / 1024;
2133 slopesCoarse.push_back(slopeCoarse);
2134 slopesFine.push_back(slopeFine);
2138 slopesFebTest = std::make_pair(slopesFine, slopesCoarse);
2140 return slopesFebTest;
2143 std::vector<std::pair<float, float>> ARICHDatabaseImporter::getFwhm(
int serialNum,
const std::string& run)
2145 GearDir contentData =
GearDir(
"/ArichData/AllData/SlopesFebTest/Content");
2146 vector<pair<float, float>> fwhm;
2148 for (
const auto& contentSlopes : contentData.
getNodes(
"febtest")) {
2149 if ((contentSlopes.getInt(
"@id") == serialNum) && (contentSlopes.getString(
"@run") == run)) {
2150 for (
const auto& contSlopes : contentSlopes.getNodes(
"data/ch")) {
2151 float fwhmVal = (float) contSlopes.getDouble(
"fwhm");
2152 float fwhmSig = (float) contSlopes.getDouble(
"sigma");
2153 pair<float, float> fwhmPair = std::make_pair(fwhmVal, fwhmSig);
2154 fwhm.push_back(fwhmPair);
2161 std::vector<TH3F*> ARICHDatabaseImporter::getFebTestHistograms(
const std::string& dna,
const std::string& run,
int febposition)
2163 vector<TH3F*> histogrami;
2165 for (
const string& inputFile : m_inputFilesFebTest) {
2167 if (inputFile.find(run) != string::npos) {
2168 TFile* f = TFile::Open(inputFile.c_str(),
"READ");
2169 int iMIN = 0, iMAX = 0, delta, stepsNum = 16, i = 0, point2 = 24;
2171 float stepsMax = 15.5;
2174 TIter next(f->GetListOfKeys());
2176 while ((key = (TKey*)next())) {
2177 string strime = key->GetName();
2178 if (strime.compare(0, 5,
"h2d_0") == 0) i++;
2182 for (
int k = 0; k < 2; k++) {
2187 if (k == 0) { option =
"coarse"; iMIN = 2; iMAX = 16; delta = 2;}
2188 if (k == 1) { option =
"fine"; iMIN = 17; iMAX = 31; delta = 17; }
2190 if (k == 0) { option =
"coarse"; iMIN = 2; iMAX = 17; delta = 2; }
2191 if (k == 1) { option =
"fine"; iMIN = 18; iMAX = 33; delta = 18; }
2194 TH3F* histogram =
new TH3F((option +
" " + dna).c_str(), (option +
" " + dna).c_str(), 144, -0.5, 143.5, 250, 299, 799, stepsNum,
2197 for (
int j = iMIN; j < iMAX + 1; j++) {
2198 TH2F* hist2d = (TH2F*)f->Get((
"h2d_0;" + std::to_string(j)).c_str());
2199 hist2d->SetDirectory(0);
2202 if ((j - delta) < 8) {binZ = 8 - (j - delta);}
2203 if ((j - delta) > 7) {binZ = point2 - (j - delta);}
2205 for (
int binX = 144 * febposition + 1; binX < 144 * (febposition + 1) + 1; binX++) {
2206 for (
int binY = 1; binY < 251; binY++) {
2207 histogram->SetBinContent(binX - 144 * febposition, binY, binZ, hist2d->GetBinContent(binX, binY));
2211 histogram->SetDirectory(0);
2212 histogrami.push_back(histogram);
2213 for (
int kanal = 1; kanal < 145; kanal ++) {
2214 for (
int offset = 1; offset < stepsNum + 1; offset++) {
2215 TH1D* h1 = histogram->ProjectionY(
"A", kanal, kanal, offset, offset);
2216 h1->SetName((dna +
" kanal: " + to_string(kanal) +
", offset: " + to_string(offset)).c_str());
2227 TH2F* ARICHDatabaseImporter::getFebTestPulse(
const std::string& dna,
const std::string& run,
int febposition)
2229 TH2F* testPulse =
new TH2F((
"test pulse " + dna).c_str(), (
"test pulse " + dna).c_str(), 144, -0.5, 143.5, 250, 299, 799);
2231 for (
const string& inputFile : m_inputFilesFebTest) {
2232 if (inputFile.find(run) != string::npos) {
2233 TFile* f = TFile::Open(inputFile.c_str(),
"READ");
2234 TH2F* pulseTest = (TH2F*)f->Get(
"h2d_0;1");
2235 pulseTest->SetDirectory(0);
2236 for (
int binX = 144 * febposition + 1; binX < 144 * (febposition + 1) + 1; binX++) {
2237 for (
int binY = 1; binY < 251; binY++) {
2238 testPulse->SetBinContent(binX - 144 * febposition, binY, pulseTest->GetBinContent(binX, binY));
2249 void ARICHDatabaseImporter::exportFebTest()
2253 elements.getEntries();
2256 for (
const auto& element : elements) {
2257 B2INFO(
"Serial = " << element.getFebSerial() <<
"; dna = " << element.getFebDna() <<
"; slope R (ch143) = " <<
2258 element.getSlopeRough(143) <<
"; slope F (ch143) = " << element.getSlopeFine(143) <<
"; comment = " << element.getComment());
2263 void ARICHDatabaseImporter::importHapdChipInfo()
2266 GearDir content =
GearDir(
"/ArichData/AllData/hapdData/Content");
2269 TClonesArray chipConstants(
"Belle2::ARICHHapdChipInfo");
2272 for (
const auto& hapdInfo : content.getNodes(
"hapd")) {
2274 string sn = hapdInfo.getString(
"serial");
2278 int channel_label_aval[4], bias[4], gain[4];
2279 TGraph** bombardmentGain, **avalancheGain;
2280 bombardmentGain =
new TGraph *[4];
2281 avalancheGain =
new TGraph *[4];
2282 TH2F** bias2DV, **bias2DI;
2283 bias2DV =
new TH2F *[4];
2284 bias2DI =
new TH2F *[4];
2285 vector<int> badlist[4], cutlist[4];
2286 vector<TGraph*> bombCurrents[4], avalCurrents[4];
2290 for (
const auto& chipInfo : hapdInfo.getNodes(
"chipinfo")) {
2291 chip[chip_ABCD] = chipInfo.getString(
"chip");
2292 bias[chip_ABCD] = chipInfo.getInt(
"bias");
2293 string badL = chipInfo.getString(
"deadlist");
2294 string cutL = chipInfo.getString(
"cutlist");
2295 if (badL.find(
"ch") != string::npos) {
string badLsub = badL.substr(3); badlist[chip_ABCD] = ARICHDatabaseImporter::channelsListHapd(badLsub.c_str(), chip[chip_ABCD]); }
2296 if (cutL.find(
"ch") != string::npos) {
string cutLsub = cutL.substr(3); cutlist[chip_ABCD] = ARICHDatabaseImporter::channelsListHapd(cutLsub.c_str(), chip[chip_ABCD]); }
2297 string gain_str = chipInfo.getString(
"gain");
2298 gain[chip_ABCD] = atoi(gain_str.c_str());
2306 float hv_bomb[n3], gain_bomb[n3], current1_bomb[n3], current2_bomb[n3], current3_bomb[n3];
2308 for (
const auto& BG : hapdInfo.getNodes(
"bombardmentgain/ch")) {
2309 string value = BG.getString(
"value");
2310 string chip_label = value.erase(1);
2311 for (
const auto& BG2 : BG.getNodes(
"point")) {
2312 hv_bomb[i3] = (float) BG2.getDouble(
"hv");
2313 gain_bomb[i3] = (float) BG2.getDouble(
"gain");
2314 current1_bomb[i3] = (float) BG2.getDouble(
"current1");
2315 current2_bomb[i3] = (float) BG2.getDouble(
"current2");
2316 current3_bomb[i3] = (float) BG2.getDouble(
"current3");
2320 bombardmentGain[chip_ABCD] = ARICHDatabaseImporter::getGraphGainCurrent(
"Bombardment",
"gain", chip_label, i3, hv_bomb, gain_bomb);
2321 TGraph* bombardmentCurrent1 = ARICHDatabaseImporter::getGraphGainCurrent(
"Bombardment",
"current1", chip_label, i3, hv_bomb,
2323 TGraph* bombardmentCurrent2 = ARICHDatabaseImporter::getGraphGainCurrent(
"Bombardment",
"current2", chip_label, i3, hv_bomb,
2325 TGraph* bombardmentCurrent3 = ARICHDatabaseImporter::getGraphGainCurrent(
"Bombardment",
"current3", chip_label, i3, hv_bomb,
2327 bombCurrents[chip_ABCD].push_back(bombardmentCurrent1);
2328 bombCurrents[chip_ABCD].push_back(bombardmentCurrent2);
2329 bombCurrents[chip_ABCD].push_back(bombardmentCurrent3);
2337 float hv_aval[n4], gain_aval[n4], current1_aval[n4], current2_aval[n4], current3_aval[n4];
2339 for (
const auto& BG : hapdInfo.getNodes(
"avalanchegain/ch")) {
2340 string value = BG.getString(
"value");
2341 string value_1 = value;
2342 string chip_label = value.erase(1);
2343 string value_2 = value_1.substr(2);
2344 channel_label_aval[chip_ABCD] = atoi(value_2.c_str());
2345 for (
const auto& BG2 : BG.getNodes(
"point")) {
2346 hv_aval[i4] = (float) BG2.getDouble(
"biasv");
2347 gain_aval[i4] = (float) BG2.getDouble(
"gain");
2348 current1_aval[i4] = (float) BG2.getDouble(
"current1");
2349 current2_aval[i4] = (float) BG2.getDouble(
"current2");
2350 current3_aval[i4] = (float) BG2.getDouble(
"current3");
2354 avalancheGain[chip_ABCD] = ARICHDatabaseImporter::getGraphGainCurrent(
"Avalanche",
"gain", chip_label, i4, hv_aval, gain_aval);
2355 TGraph* avalancheCurrent1 = ARICHDatabaseImporter::getGraphGainCurrent(
"Avalanche",
"current1", chip_label, i4, hv_aval,
2357 TGraph* avalancheCurrent2 = ARICHDatabaseImporter::getGraphGainCurrent(
"Avalanche",
"current2", chip_label, i4, hv_aval,
2359 TGraph* avalancheCurrent3 = ARICHDatabaseImporter::getGraphGainCurrent(
"Avalanche",
"current3", chip_label, i4, hv_aval,
2361 avalCurrents[chip_ABCD].push_back(avalancheCurrent1);
2362 avalCurrents[chip_ABCD].push_back(avalancheCurrent2);
2363 avalCurrents[chip_ABCD].push_back(avalancheCurrent3);
2373 int i5 = 0, chipnum[n5];
2374 float biasv[n5], biasi[n5];
2375 for (
const auto& HI : hapdInfo.getNodes(
"bias2d/biasvalue")) {
2376 string chip_2d = HI.getString(
"@chip");
2377 chipnum[i5] = HI.getInt(
"@ch");
2378 biasv[i5] = (float) HI.getDouble(
"biasv");
2379 biasi[i5] = (float) HI.getDouble(
"biasi");
2380 if (chipnum[i5] == 36) {
2381 bias2DV[chip_ABCD] = ARICHDatabaseImporter::getBiasGraph(chip_2d,
"voltage", chipnum, biasv);
2382 bias2DI[chip_ABCD] = ARICHDatabaseImporter::getBiasGraph(chip_2d,
"current", chipnum, biasi);
2390 for (
unsigned int l = 0; l < 4; l++) {
2392 auto* chipConst =
static_cast<ARICHHapdChipInfo*
>(chipConstants[4 * chip_i + l]);
2395 chipConst->setChipLabel(chip[l]);
2396 chipConst->setBiasVoltage(bias[l]);
2397 chipConst->setGain(gain[l]);
2398 chipConst->setBadChannel(badlist[l]);
2399 chipConst->setCutChannel(cutlist[l]);
2400 chipConst->setBombardmentGain(bombardmentGain[l]);
2401 chipConst->setBombardmentCurrent(bombCurrents[l]);
2402 chipConst->setAvalancheGain(avalancheGain[l]);
2403 chipConst->setAvalancheCurrent(avalCurrents[l]);
2404 chipConst->setChannelNumber(channel_label_aval[l]);
2405 chipConst->setBiasVoltage2D(bias2DV[l]);
2406 chipConst->setBiasCurrent2D(bias2DI[l]);
2411 delete[] bombardmentGain;
2412 delete[] avalancheGain;
2418 Database::Instance().storeData(
"ARICHHapdChipInfo", &chipConstants, m_iov);
2421 void ARICHDatabaseImporter::exportHapdChipInfo()
2424 elements.getEntries();
2426 for (
const auto& element : elements) {
2427 B2INFO(
"Serial = " << element.getHapdSerial() <<
", chip = " << element.getChipLabel() <<
", bias= " << element.getBiasVoltage());
2433 void ARICHDatabaseImporter::importHapdInfo()
2436 GearDir content =
GearDir(
"/ArichData/AllData/hapdData/Content");
2439 TClonesArray hapdConstants(
"Belle2::ARICHHapdInfo");
2442 for (
const auto& hapdInfo : content.getNodes(
"hapd")) {
2445 auto* hapdConst =
static_cast<ARICHHapdInfo*
>(hapdConstants[hapd_i]);
2448 string serial = hapdInfo.getString(
"serial");
2449 float qe400 = (float) hapdInfo.getDouble(
"qe400");
2450 float hv = 1000 * (float) hapdInfo.getDouble(
"hv");
2451 float current = (float) hapdInfo.getDouble(
"current");
2452 string gb = hapdInfo.getString(
"guardbias");
2453 int guardbias = atoi(gb.c_str());
2457 float lambda[n1], qepoint[n1];
2459 for (
const auto& QE : hapdInfo.getNodes(
"qe/qepoint")) {
2460 lambda[i1] = (float) QE.getInt(
"@lambda");
2461 qepoint[i1] = (float) QE.getDouble(
".");
2464 TGraph* qe =
new TGraph(i1, lambda, qepoint);
2467 qe->GetXaxis()->SetTitle(
"lambda");
2468 qe->GetYaxis()->SetTitle(
"qe");
2471 const int n2 = 4100;
2472 int channel_adc[n2], pulse_adc[n2];
2474 for (
const auto& ADC : hapdInfo.getNodes(
"adc/value")) {
2475 channel_adc[i2] = ADC.getInt(
"@ch");
2476 string str = ADC.getString(
".");
2477 pulse_adc[i2] = atoi(str.c_str());
2480 TGraph* adc =
new TGraph(i2, channel_adc, pulse_adc);
2481 adc->SetName(
"adc");
2482 adc->SetTitle(
"Pulse Height Distribution");
2483 adc->GetXaxis()->SetTitle(
"channel");
2484 adc->GetYaxis()->SetTitle(
"pulse height");
2487 hapdConst->setSerialNumber(serial);
2488 hapdConst->setQuantumEfficiency400(qe400);
2489 hapdConst->setHighVoltage(hv);
2490 hapdConst->setGuardBias(guardbias);
2491 hapdConst->setCurrent(current);
2492 hapdConst->setQuantumEfficiency(qe);
2493 hapdConst->setPulseHeightDistribution(adc);
2499 for (
const auto& element : elementsChip) {
2500 if (element.getHapdSerial() == serial) {
2502 if (element.getChipLabel() ==
"A") hapdConst->setHapdChipInfo(0, &elementValue);
2503 if (element.getChipLabel() ==
"B") hapdConst->setHapdChipInfo(1, &elementValue);
2504 if (element.getChipLabel() ==
"C") hapdConst->setHapdChipInfo(2, &elementValue);
2505 if (element.getChipLabel() ==
"D") hapdConst->setHapdChipInfo(3, &elementValue);
2513 Database::Instance().storeData(
"ARICHHapdInfo", &hapdConstants, m_iov);
2518 std::vector<int> ARICHDatabaseImporter::channelsListHapd(std::string chlist, std::string chipDelay)
2520 B2INFO(
"channel list = " << chlist <<
", chip = " << chipDelay);
2521 string chlistDig = ARICHTools::remove_chars_if_not(chlist,
"0123456789,~");
2523 vector<int> CHs = ARICHTools::getDeadCutList(*chipDelay.c_str(), ARICHTools::StringToVector::parse<int>(chlistDig,
','));
2525 B2INFO(
"All channels: ");
2526 printContainer(CHs);
2531 TGraph* ARICHDatabaseImporter::getGraphGainCurrent(
const std::string& bomb_aval,
const std::string& g_i,
2532 const std::string& chip_label,
int i,
float* HV,
2533 float* gain_current)
2535 TGraph* hapd_graph =
new TGraph(i, HV, gain_current);
2536 string title = bomb_aval +
" " + g_i +
", chip " + chip_label;
2537 hapd_graph->SetTitle(title.c_str());
2538 hapd_graph->GetXaxis()->SetTitle(
"high voltage");
2539 hapd_graph->GetYaxis()->SetTitle(g_i.c_str());
2544 int ARICHDatabaseImporter::getChannelPosition(
const std::string&
XY,
const std::string& chip_2d,
int chipnum)
2546 int x = 100, y = 100;
2547 if (chip_2d ==
"A") {
2554 }
else if (chip_2d ==
"B") {
2561 }
else if (chip_2d ==
"C") {
2568 }
else if (chip_2d ==
"D") {
2577 if (
XY ==
"x") {
return x;}
2578 else if (
XY ==
"y") {
return y;}
2583 TH2F* ARICHDatabaseImporter::getBiasGraph(
const std::string& chip_2d,
const std::string& voltage_current,
int* chipnum,
2586 string name =
"bias " + voltage_current +
", chip " + chip_2d;
2587 TH2F* bias2d =
new TH2F(
"bias2d", name.c_str(), 6, 0, 6, 6, 0, 6);
2588 for (
int XYname = 0; XYname < 6; XYname++) {
2589 bias2d->GetXaxis()->SetBinLabel(XYname + 1, to_string(XYname).c_str());
2590 bias2d->GetYaxis()->SetBinLabel(XYname + 1, to_string(6 * XYname).c_str());
2592 for (
int XY = 0;
XY < 36;
XY++) {
2594 int y = 0 + chipnum[
XY];
2599 bias2d->SetBinContent(x, y, bias_v_i[
XY]);
2601 bias2d->SetDirectory(0);
2605 void ARICHDatabaseImporter::exportHapdInfo()
2609 elements.getEntries();
2611 for (
const auto& element : elements) {
2612 B2INFO(
"Serial = " << element.getSerialNumber() <<
"; HV = " << element.getHighVoltage() <<
"; qe400 = " <<
2613 element.getQuantumEfficiency400());
2614 for (
int n = 0; n < 4; n++) {
2616 B2INFO(
"biasV(chip" << n <<
") = " << newelement->
getBiasVoltage());
2627 void ARICHDatabaseImporter::importHapdQE()
2630 TClonesArray hapdQEConstants(
"Belle2::ARICHHapdQE");
2634 for (
const string& inputFile : m_inputFilesHapdQE) {
2636 TFile* f = TFile::Open(inputFile.c_str(),
"READ");
2638 int size = inputFile.length();
2639 string hapdSerial = inputFile.substr(size - 11, 6);
2643 TIter next(f->GetListOfKeys());
2645 while ((key = (TKey*)next())) {
2647 string strime = key->GetName();
2649 if (strime.compare(0, 11,
"hqe2d_pixel") == 0) {
2650 qe2D = (TH2F*)f->Get(strime.c_str());
2651 qe2D->SetTitle(
"quantum efficiency");
2652 qe2D->SetName(
"QE");
2653 qe2D->SetDirectory(0);
2656 else { B2INFO(
"Key name does not match 'hqe2d_pixel'!"); }
2666 Database::Instance().storeData(
"ARICHHapdQE", &hapdQEConstants, m_iov);
2670 void ARICHDatabaseImporter::exportHapdQE()
2673 elements.getEntries();
2674 gROOT->SetBatch(kTRUE);
2677 for (
const auto& element : elements) {
2678 B2INFO(
" SN = " << element.getHapdSerialNumber());
2679 TH2F* qe2d = element.getQuantumEfficiency2D();
2680 TFile file(
"QEhists.root",
"update");
2687 void ARICHDatabaseImporter::printBiasVoltagesForHapdChip(
const std::string& serialNumber)
2693 elements.getEntries();
2695 for (
const auto& element : elements) {
2696 if (element.getHapdSerial() == serialNumber) {
2697 TGraph* avalgain = element.getAvalancheGain();
2722 TGraph* gainnew =
new TGraph(avalgain->GetN());
2723 double xpoint, ypoint;
2724 for (
int j = 0; j < avalgain->GetN(); j++) {
2725 avalgain->GetPoint(j, xpoint, ypoint);
2726 gainnew->SetPoint(j, ypoint, xpoint);
2728 B2INFO(
"serial#-chip = " << element.getHapdSerial() <<
"-" << element.getChipLabel() <<
"; " <<
"V(gain=40) = " << (
int)(
2729 gainnew->Eval(40) + 0.5));
2734 void ARICHDatabaseImporter::printMyParams(
const std::string& aeroSerialNumber)
2736 map<string, float> aerogelParams = ARICHDatabaseImporter::getAerogelParams(aeroSerialNumber);
2738 B2INFO(
"SN = " << aeroSerialNumber <<
"; n = " << aerogelParams.find(
"refractiveIndex")->second <<
"; transLen = " <<
2739 aerogelParams.find(
"transmissionLength")->second <<
"; thickness = " << aerogelParams.find(
"thickness")->second);
2743 std::map<std::string, float> ARICHDatabaseImporter::getAerogelParams(
const std::string& aeroSerialNumber)
2749 std::map<std::string, float> aerogelParams;
2751 elements.getEntries();
2752 for (
const auto& element : elements) {
2753 if ((element.getAerogelSN()) == aeroSerialNumber) {
2755 {
"refractiveIndex", element.getAerogelRefractiveIndex() },
2756 {
"transmissionLength", element.getAerogelTransmissionLength() },
2757 {
"thickness", element.getAerogelThickness() }
2761 return aerogelParams;
2764 void ARICHDatabaseImporter::importFEBoardInfo()
2770 TClonesArray febConstants(
"Belle2::ARICHFEBoardInfo");
2774 for (
const auto& febinfo : content.getNodes(
"febasic")) {
2775 int febSN = (float) febinfo.getInt(
"sn");
2776 string asic1 = febinfo.getString(
"asic1");
2777 string asic2 = febinfo.getString(
"asic2");
2778 string asic3 = febinfo.getString(
"asic3");
2779 string asic4 = febinfo.getString(
"asic4");
2780 string delivery = febinfo.getString(
"delivered");
2781 string sentKEK = febinfo.getString(
"sentKEK");
2783 if (delivery.size() != 10) cout <<
"feb sn " << febSN <<
" check delivery time!" << endl;
2785 string year = delivery.substr(6, 4);
2786 delivery = febinfo.getString(
"delivered");
2787 string month = delivery.substr(3, 2);
2788 delivery = febinfo.getString(
"delivered");
2789 string day = delivery.substr(0, 2);
2791 int deliveryINT = atoi((year + month + day +
"u").c_str());
2792 TTimeStamp deliverytime(deliveryINT, 0u, 0u);
2794 string location =
"";
2795 if (!sentKEK.empty()) location =
"KEK";
2801 febConst->setAsicPosition(0, asic1);
2802 febConst->setAsicPosition(1, asic2);
2803 febConst->setAsicPosition(2, asic3);
2804 febConst->setAsicPosition(3, asic4);
2805 febConst->setTimeStamp(deliverytime);
2806 febConst->setFEBoardLocation(location);
2810 for (
const auto& element : elementsAsic) {
2811 if (element.getAsicID() == asic1) {
2813 febConst->setAsicInfo(0, &elementValue);
2815 if (element.getAsicID() == asic2) {
2817 febConst->setAsicInfo(1, &elementValue);
2819 if (element.getAsicID() == asic3) {
2821 febConst->setAsicInfo(2, &elementValue);
2823 if (element.getAsicID() == asic4) {
2825 febConst->setAsicInfo(3, &elementValue);
2833 Database::Instance().storeData(
"ARICHFEBoardInfo", &febConstants, m_iov);
2836 void ARICHDatabaseImporter::exportFEBoardInfo()
2839 elements.getEntries();
2841 for (
const auto& element : elements) {
2842 B2INFO(
"Feb sn = " << element.getFEBoardSerial());
2843 for (
int i = 0; i < 4; i++) {
2844 B2INFO(
"ASIC " << i <<
" = " << element.getAsicPosition(i));
2850 void ARICHDatabaseImporter::importModuleTest(
const std::string& mypath,
const std::string& HVtest)
2855 if (HVtest ==
"no") path =
"/ArichData/AllData/moduletest";
2856 else if (HVtest ==
"yes") path =
"/ArichData/AllData/moduletestHV";
2857 else B2INFO(
"Check HVB test parameter!");
2862 TClonesArray moduleConstants(
"Belle2::ARICHModuleTest");
2866 for (
const auto& moduletest : content.getNodes(
"module")) {
2867 int febSN = (float) moduletest.getInt(
"febserial");
2868 string hapdSN = moduletest.getString(
"hapdserial");
2870 if (HVtest ==
"yes") hvbSN = (float) moduletest.getInt(
"hvbserial");
2871 int run = moduletest.getInt(
"run");
2872 int runposition = moduletest.getInt(
"runposition");
2873 int isok = moduletest.getInt(
"isok");
2875 if (isok == 1) isOK =
true;
2876 string comment = moduletest.getString(
"comment");
2878 vector<int> deadChannels;
2880 if (HVtest ==
"no") {
2881 auto ids = ARICHTools::StringToVector::convert<ARICHTools::ModuleID_t>(moduletest.getString(
"dead"),
',');
2882 deadChannels.reserve(ids.size());
2883 for (
const auto& rID : ids)
2884 deadChannels.emplace_back(rID.getNumbering());
2889 if (HVtest ==
"yes") {
2890 deadChannels = ARICHTools::StringToVector::convert<int>(moduletest.getString(
"dead"),
',');
2893 B2INFO(
"Dead channels: ");
2894 printContainer(deadChannels);
2896 TGraph* guardBias_th = 0;
2897 TGraph* chipVdiff_th[4] = {0};
2898 TGraph* chipLeak_th[4] = {0};
2901 TGraph* guardBias_2Dx = 0;
2902 TGraph* chipVdiff_2Dx[4] = {0};
2903 TGraph* chipLeak_2Dx[4] = {0};
2906 TGraph* guardBias_2Dy = 0;
2907 TGraph* chipVdiff_2Dy[4] = {0};
2908 TGraph* chipLeak_2Dy[4] = {0};
2918 if (run < 10) runStr =
"000" + to_string(run);
2919 if ((run > 9) && (run < 100)) runStr =
"00" + to_string(run);
2920 if (run > 99) runStr =
"0" + to_string(run);
2921 TFile* f = TFile::Open((mypath + runStr +
"/" + runStr +
"_" + hapdSN +
"_out.root").c_str(),
"READ");
2924 TIter next(f->GetListOfKeys());
2926 while ((key = (TKey*)next())) {
2928 string strime = key->GetName();
2930 if (strime.find(
"Guard") != string::npos) {
2931 if (strime.find(
"_T_0") != string::npos) {
2932 guardBias_th = (TGraph*)f->Get(strime.c_str());
2934 if (strime.find(
"_T_1") != string::npos) {
2935 guardBias_2Dx = (TGraph*)f->Get(strime.c_str());
2937 if (strime.find(
"_T_2") != string::npos) {
2938 guardBias_2Dy = (TGraph*)f->Get(strime.c_str());
2942 if (strime.find(
"BiasDifference") != string::npos) {
2943 for (
int i = 0; i < 4; i++) {
2944 if (strime.find((
"CHIP_" + to_string(i) +
"_T_0").c_str()) != string::npos) {
2945 chipVdiff_th[i] = (TGraph*)f->Get(strime.c_str());
2947 if (strime.find((
"CHIP_" + to_string(i) +
"_T_1").c_str()) != string::npos) {
2948 chipVdiff_2Dx[i] = (TGraph*)f->Get(strime.c_str());
2950 if (strime.find((
"CHIP_" + to_string(i) +
"_T_2").c_str()) != string::npos) {
2951 chipVdiff_2Dy[i] = (TGraph*)f->Get(strime.c_str());
2956 if (strime.find(
"LeakageCurrent") != string::npos) {
2957 for (
int i = 0; i < 4; i++) {
2958 if (strime.find((
"CHIP_" + to_string(i) +
"_T_0").c_str()) != string::npos) {
2959 chipLeak_th[i] = (TGraph*)f->Get(strime.c_str());
2961 if (strime.find((
"CHIP_" + to_string(i) +
"_T_1").c_str()) != string::npos) {
2962 chipLeak_2Dx[i] = (TGraph*)f->Get(strime.c_str());
2964 if (strime.find((
"CHIP_" + to_string(i) +
"_T_2").c_str()) != string::npos) {
2965 chipLeak_2Dy[i] = (TGraph*)f->Get(strime.c_str());
2970 if (strime.find(
"HV") != string::npos) {
2971 if (strime.find(
"_T_0") != string::npos) {
2972 HV_th = (TGraph*)f->Get(strime.c_str());
2974 if (strime.find(
"_T_1") != string::npos) {
2975 HV_2Dx = (TGraph*)f->Get(strime.c_str());
2977 if (strime.find(
"_T_2") != string::npos) {
2978 HV_2Dy = (TGraph*)f->Get(strime.c_str());
2982 if (strime.find(
"Gain_1D") != string::npos) {
2983 gain = (TH1F*)f->Get(strime.c_str());
2984 gain->SetDirectory(0);
2987 if (strime.find(
"Charge_2D") != string::npos) {
2988 charge = (TH2D*)f->Get(strime.c_str());
2989 charge->SetDirectory(0);
2992 if (strime.find(
"Threshold_2D") != string::npos) {
2993 th = (TH2D*)f->Get(strime.c_str());
2994 th->SetDirectory(0);
2997 if (strime.find(
"Scan_2D_X") != string::npos) {
2998 scanX = (TH2D*)f->Get(strime.c_str());
2999 scanX->SetDirectory(0);
3002 if (strime.find(
"Scan_2D_Y") != string::npos) {
3003 scanY = (TH2D*)f->Get(strime.c_str());
3004 scanY->SetDirectory(0);
3010 auto* moduleConst =
static_cast<ARICHModuleTest*
>(moduleConstants[module]);
3012 moduleConst->setHapdSN(hapdSN);
3013 moduleConst->setRun(run);
3014 moduleConst->setRunPosition(runposition);
3015 moduleConst->setOK(isOK);
3016 moduleConst->setDeadChs(deadChannels);
3017 moduleConst->setComment(comment);
3018 moduleConst->setGuardBiasTH(guardBias_th);
3019 moduleConst->setHighVoltageTH(HV_th);
3020 moduleConst->setGuardBias2Dx(guardBias_2Dx);
3021 moduleConst->setHighVoltage2Dx(HV_2Dx);
3022 moduleConst->setGuardBias2Dy(guardBias_2Dy);
3023 moduleConst->setHighVoltage2Dy(HV_2Dy);
3024 moduleConst->setGain(gain);
3025 moduleConst->setChargeScan(charge);
3026 moduleConst->setTresholdScan(th);
3027 moduleConst->setLaserScanX(scanX);
3028 moduleConst->setLaserScanY(scanY);
3030 for (
int i = 0; i < 4; i++) {
3031 moduleConst->setChipVdiffTH(i, chipVdiff_th[i]);
3032 moduleConst->setChipLeakTH(i, chipLeak_th[i]);
3033 moduleConst->setChipVdiff2Dx(i, chipVdiff_2Dx[i]);
3034 moduleConst->setChipLeak2Dx(i, chipLeak_2Dx[i]);
3035 moduleConst->setChipVdiff2Dy(i, chipVdiff_2Dy[i]);
3036 moduleConst->setChipLeak2Dy(i, chipLeak_2Dy[i]);
3038 if (HVtest ==
"yes") moduleConst->setHvbSN(hvbSN);
3041 B2INFO(
"module no " << module - 1 <<
" saved to DB. HAPD SN = " << hapdSN <<
", FEB SN = " << febSN);
3046 if (HVtest ==
"no") Database::Instance().storeData(
"ARICHModuleTest", &moduleConstants, m_iov);
3047 if (HVtest ==
"yes") Database::Instance().storeData(
"ARICHModuleTestHV", &moduleConstants, m_iov);
3050 void ARICHDatabaseImporter::exportModuleTest(
const std::string& HVtest)
3053 if (HVtest ==
"no") {
3055 elements.getEntries();
3056 for (
const auto& element : elements) {
3057 B2INFO(
"Feb sn = " << element.getFebSN() <<
", hapd sn = " << element.getHapdSN() <<
", run = " << element.getRun() <<
3058 ", run position = " << element.getRunPosition() <<
", module is ok = " << element.getOK() <<
", comment = " <<
3059 element.getComment());
3060 for (
int i = 0; i < element.getDeadChsSize(); i++) {
3061 B2INFO(
"dead channel = " << element.getDeadCh(i) <<
" (hapd mapping)");
3066 if (HVtest ==
"yes") {
3068 elements.getEntries();
3069 for (
const auto& element : elements) {
3070 B2INFO(
"Feb sn = " << element.getFebSN() <<
", hapd sn = " << element.getHapdSN() <<
", hvb sn = " << element.getHvbSN() <<
3071 ", run = " << element.getRun() <<
", run position = " << element.getRunPosition() <<
", module is ok = " << element.getOK() <<
3072 ", comment = " << element.getComment());
3073 for (
int i = 0; i < element.getDeadChsSize(); i++) {
3074 B2INFO(
"dead channel = " << element.getDeadCh(i) <<
" (asic mapping)");
3080 void ARICHDatabaseImporter::importSensorModuleInfo()
3085 TClonesArray moduleInfoConstants(
"Belle2::ARICHSensorModuleInfo");
3090 for (
const auto& sensor : content.getNodes(
"position")) {
3091 int febSerial = sensor.getInt(
"febserial");
3092 string hapdSerial = sensor.getString(
"hapdserial");
3093 int id = sensor.getInt(
"moduleID");
3094 int hvSerial = sensor.getInt(
"HVserial");
3100 moduleInfoConst->setFEBserial(febSerial);
3101 moduleInfoConst->setHAPDserial(hapdSerial);
3102 moduleInfoConst->setHVboardID(hvSerial);
3106 for (
const auto& element : elementsHapd) {
3107 if (element.getSerialNumber() == hapdSerial) {
3109 moduleInfoConst->setHapdID(&elementValue);
3115 for (
const auto& element : elementsFeb) {
3116 if (element.getFEBoardSerial() == febSerial) {
3118 moduleInfoConst->setFEBoardID(&elementValue);
3124 for (
const auto& element : elementsModule) {
3125 if (element.getFebSN() == febSerial) {
3127 moduleInfoConst->setModuleTest(&elementValue);
3135 Database::Instance().storeData(
"ARICHSensorModuleInfo", &moduleInfoConstants, m_iov);
3139 void ARICHDatabaseImporter::importSensorModuleMap()
3145 TClonesArray moduleMapConstants(
"Belle2::ARICHSensorModuleMap");
3150 for (
const auto& sensor : content.getNodes(
"position")) {
3151 int sextant = sensor.getInt(
"sector");
3152 int ring = sensor.getInt(
"ring");
3153 int column = sensor.getInt(
"column");
3154 int id = sensor.getInt(
"moduleID");
3160 moduleMapConst->setSensorModuleRingID(ring);
3161 moduleMapConst->setSensorModuleColumnID(column);
3162 moduleMapConst->setSensorGlobalID(
id);
3166 for (
const auto& element : elementsModule) {
3167 if (element.getSensorModuleID() ==
id) {
3169 moduleMapConst->setSensorModuleId(&elementValue);
3177 Database::Instance().storeData(
"ARICHSensorModuleMap", &moduleMapConstants, m_iov);
3180 void ARICHDatabaseImporter::exportSensorModuleMap()
3183 elements.getEntries();
3185 for (
const auto& element : elements) {
3186 B2INFO(
"Sextant = " << element.getSensorModuleSextantID() <<
", ring = " << element.getSensorModuleRingID() <<
", column = " <<
3187 element.getSensorModuleColumnID());
3194 for (
int i = 0; i < 4; i++) {
3196 B2INFO(
"Hapd Serial = " << newestelement->
getHapdSerial() <<
"; chip = " << newestelement->
getChipLabel() <<
"; gain = " <<
3202 void ARICHDatabaseImporter::exportSensorModuleMapInfo(
int number)
3205 elements.getEntries();
3207 for (
const auto& element : elements) {
3210 B2INFO(
"Sextant = " << element.getSensorModuleSextantID() <<
", ring = " << element.getSensorModuleRingID() <<
", column = " <<
3211 element.getSensorModuleColumnID());
3217 for (
int i = 0; i < 4; i++) {
3219 B2INFO(
"Hapd Serial = " << newestelement->
getHapdSerial() <<
"; chip = " << newestelement->
getChipLabel() <<
"; gain = " <<
3225 void ARICHDatabaseImporter::importMagnetTest()
3230 TClonesArray magnetConstants(
"Belle2::ARICHMagnetTest");
3235 for (
const auto& module : content.getNodes(
"module")) {
3238 auto* magnetConst =
static_cast<ARICHMagnetTest*
>(magnetConstants[num]);
3240 int snint = module.getInt(
"hapdID");
3241 if (snint < 5000) sn =
"KA";
3244 sprintf(hapdID,
"%s%04d", sn.c_str(), snint);
3245 magnetConst->setSerialNumber(hapdID);
3247 vector<float> deadtimes;
3248 for (
const auto& time : module.getNodes(
"deadtime/measurement")) {
3249 if (time.getString(
".") !=
"-") {
3250 float deadtime = (float) time.getDouble(
".");
3251 deadtimes.push_back(deadtime);
3254 magnetConst->setDeadTime(deadtimes);
3256 if (module.getString(
"lowerA") !=
"-") magnetConst->setDeadTimeLowerA((
float) module.getDouble(
"lowerA"));
3257 if (module.getString(
"lowerB") !=
"-") magnetConst->setDeadTimeLowerB((
float) module.getDouble(
"lowerB"));
3258 if (module.getString(
"lowerC") !=
"-") magnetConst->setDeadTimeLowerC((
float) module.getDouble(
"lowerC"));
3259 if (module.getString(
"lowerD") !=
"-") magnetConst->setDeadTimeLowerD((
float) module.getDouble(
"lowerD"));
3261 bool getter_reactivation = module.getBool(
"getter");
3262 string comment = module.getString(
"comment");
3263 magnetConst->setGetter(getter_reactivation);
3264 magnetConst->setComment(comment);
3270 Database::Instance().storeData(
"ARICHMagnetTest", &magnetConstants, m_iov);
3273 void ARICHDatabaseImporter::exportMagnetTest()
3277 elements.getEntries();
3279 for (
const auto& element : elements) {
3280 string getter =
"no";
3281 if (element.getGetter() == 1) getter =
"yes";
3282 B2INFO(
"SN = " << element.getSerialNumber() <<
"; after getter reactivation? " << getter);
3283 for (
int i = 0; i < element.getDeadTimeSize();
3284 i++) B2INFO(
"dead time = " << element.getDeadTime(i) <<
" (" << (i + 1) <<
". measurement)");
3285 if (element.getDeadTimeLowerA() > 0.) B2INFO(
"lower voltage on chip A = " << element.getDeadTimeLowerA());
3286 if (element.getDeadTimeLowerB() > 0.) B2INFO(
"lower voltage on chip B = " << element.getDeadTimeLowerB());
3287 if (element.getDeadTimeLowerC() > 0.) B2INFO(
"lower voltage on chip C = " << element.getDeadTimeLowerC());
3288 if (element.getDeadTimeLowerD() > 0.) B2INFO(
"lower voltage on chip D = " << element.getDeadTimeLowerD());
3289 B2INFO(
"comment = " << element.getComment());
3293 void ARICHDatabaseImporter::exportAll()
3295 ARICHDatabaseImporter::exportAerogelInfo();
3296 ARICHDatabaseImporter::exportHapdQE();
3297 ARICHDatabaseImporter::exportModuleTest(
"no");
3298 ARICHDatabaseImporter::exportModuleTest(
"yes");
3299 ARICHDatabaseImporter::exportFEBoardInfo();
3300 ARICHDatabaseImporter::exportFebTest();
3301 ARICHDatabaseImporter::exportSensorModuleMap();