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>
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>
48 #include <arich/utility/ARICHChannelHist.h>
49 #include <arich/utility/ARICHAerogelHist.h>
51 #include <framework/gearbox/GearDir.h>
52 #include <framework/gearbox/Unit.h>
53 #include <framework/logging/Logger.h>
54 #include <framework/database/EventDependency.h>
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>
75 #include <TClonesArray.h>
83 ARICHDatabaseImporter::ARICHDatabaseImporter(
const vector<string>& inputFilesHapdQA,
const vector<string>& inputFilesAsicRoot,
84 const vector<string>& inputFilesAsicTxt,
const vector<string>& inputFilesHapdQE,
const vector<string>& inputFilesFebTest)
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]); }
99 ARICHDatabaseImporter::ARICHDatabaseImporter(
int experiment,
int run)
102 meta->setRun(run); meta->setExperiment(experiment);
103 B2INFO(
"Experiment " << experiment <<
", run " << run);
107 void ARICHDatabaseImporter::SetIOV(
int experimentLow,
int runLow,
int experimentHigh,
int runHigh)
113 void ARICHDatabaseImporter::setExperimentAndRun(
int experiment,
int run)
116 meta->setRun(run); meta->setExperiment(experiment);
117 B2INFO(
"Experiment " << experiment <<
", run " << run);
121 void ARICHDatabaseImporter::importModulesInfo()
136 GearDir content =
GearDir(
"/Detector/DetectorComponent[@name='ARICH']/Content/ChannelMapping");
137 istringstream chstream;
139 chstream.str(content.getString(
"QAChannelMapping"));
140 while (chstream >> x >> y >> asic) {
145 GearDir installedModules =
GearDir(
"/Detector/DetectorComponent[@name='ARICH']/Content/InstalledModules");
146 B2INFO(
"Installed modules\n");
148 std::vector<std::string> installed;
151 std::string hapdID = module.getString(
"@hapdID");
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');
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);
163 unsigned moduleID = geoConfig->getDetectorPlane().getSlotIDFromSRF(sector, ring, azimuth);
166 std::vector<float> qs;
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++) {
175 qs[asicCh] = qe2d->GetBinContent(k, l);
179 B2INFO(
" Channels QE map found and set.\n");
184 for (
int k = 0; k < 144; k++) {
187 B2WARNING(
"ARICHDatabaseImporter::importModulesInfo: QE map for hapd " << hapdID <<
" not found! Setting 27% QE for all channels!");
190 modInfo.
addModule(moduleID, qs, isActive);
200 void ARICHDatabaseImporter::importGlobalAlignment()
203 GearDir content =
GearDir(
"/Detector/DetectorComponent[@name='ARICH']/Content");
204 GearDir alignPars(content,
"GlobalAlignment");
216 void ARICHDatabaseImporter::importMirrorAlignment()
219 GearDir content =
GearDir(
"/Detector/DetectorComponent[@name='ARICH']/Content");
220 GearDir alignPars(content,
"MirrorAlignment");
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);
246 void ARICHDatabaseImporter::importAeroTilesAlignment()
249 GearDir content =
GearDir(
"/Detector/DetectorComponent[@name='ARICH']/Content");
250 GearDir alignPars(content,
"AeroTilesAlignment");
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");
274 void ARICHDatabaseImporter::importChannelMask()
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);
298 for (
const auto& test : moduleTest) {
299 if (hapdID == test.getHapdSN()) {
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!");
308 B2INFO(
" List of dead channels (from module test) found and set.\n");
313 B2WARNING(
"ARICHDatabaseImporter::importLWClasses: List of dead channels for hapd " << hapdID <<
314 " not found! All channels set to active.");
325 void ARICHDatabaseImporter::importMergerCoolingGeo()
329 GearDir mergerCoolingParams =
GearDir(
"/Detector/DetectorComponent[@name='ARICH']/Content/mergerCoolingBodiesv2");
333 for (
auto mergerCoolingNode : mergerCoolingParams.
getNodes(
"BodiesDatFileName/Body")) {
335 tessellatedSolidStr mergerTessellation = readTessellatedSolidVerticesFromDATfile(mergerCoolingNode.getString());
344 B2INFO(
"--> Mergers cooling bodies geometry imported.");
349 tessellatedSolidStr ARICHDatabaseImporter::readTessellatedSolidVerticesFromDATfile(
const std::string& inDATfile)
354 std::ifstream infile(inDATfile.c_str(), std::ifstream::in);
356 if (infile.is_open()) {
358 while (infile >> mot) {
359 if (mot ==
"BodyPositionID")
360 infile >> solidStr.tessellatedSolidID;
365 infile >> solidStr.nCells;
369 if (mot ==
"nApexPerCell")
370 infile >> solidStr.nApexPerCell;
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" }
378 for (
unsigned int i = 0; i < 3; i++) {
380 if (mot != apexNamesStr[0][i])
382 std::vector<double> valv;
383 for (
unsigned int j = 0; j < solidStr.nCells; j++) {
387 solidStr.posV1.push_back(valv);
390 for (
unsigned int i = 0; i < 3; i++) {
392 if (mot != apexNamesStr[1][i])
394 std::vector<double> valv;
395 for (
unsigned int j = 0; j < solidStr.nCells; j++) {
399 solidStr.posV2.push_back(valv);
402 for (
unsigned int i = 0; i < 3; i++) {
404 if (mot != apexNamesStr[2][i])
406 std::vector<double> valv;
407 for (
unsigned int j = 0; j < solidStr.nCells; j++) {
411 solidStr.posV3.push_back(valv);
416 B2WARNING(
"Unable to open file : " << inDATfile <<
" with cooling bodies geometry.");
421 void ARICHDatabaseImporter::importChannelMask(TH1* h)
424 B2ERROR(
"--> NULL Histogram");
430 int numChannels = h->GetNbinsX();
431 const int NumberOfChannelsPerHapd = 144;
432 const int NumberOfHapds = 420;
434 if (numChannels != NumberOfHapds * NumberOfChannelsPerHapd) {
435 B2ERROR(
"There should be " << NumberOfHapds * NumberOfChannelsPerHapd <<
" in the histogram!");
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++;
446 mask.setActiveCh(moduleID, channelID, value);
452 B2INFO(
"--> Channel Mask imported. Number of disabled channels=" << inactive <<
" Number of all channels=" << numChannels);
457 void ARICHDatabaseImporter::importReconstructionParams()
460 recPar.initializeDefault();
468 void ARICHDatabaseImporter::importSimulationParams()
473 GearDir content =
GearDir(
"/Detector/DetectorComponent[@name='ARICH']/Content/SimulationParameters");
475 double qeScale = content.getDouble(
"qeScale");
476 double winAbs = content.getDouble(
"windowAbsorbtion");
477 double crossTalk = content.getDouble(
"chipNegativeCrosstalk");
478 double colEff = content.getDouble(
"colEff");
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");
485 std::vector<float> qes;
486 for (
const auto& qeff : qeParams.
getNodes(
"Qeffi")) {
487 qes.push_back(qeff.getDouble(
"qe"));
490 simPar.
setQECurve(lambdaFirst, lambdaStep, qes);
505 void ARICHDatabaseImporter::importChannelMapping()
507 GearDir content =
GearDir(
"/Detector/DetectorComponent[@name='ARICH']/Content");
510 istringstream chstream;
512 chstream.str(content.getString(
"ChannelMapping/SoftChannelMapping"));
514 B2INFO(
"Importing channel x,y to asic channel map\n");
515 B2INFO(
" x y asic\n");
516 while (chstream >> x >> y >> asic) {
518 B2INFO(
" " << setw(2) << x <<
" " << setw(2) << y <<
" " << setw(3) << asic <<
'\n');
523 importObjMap.
import(m_iov);
527 void ARICHDatabaseImporter::importFEMappings()
530 GearDir content =
GearDir(
"/Detector/DetectorComponent[@name='ARICH']/Content");
536 GearDir mapping(content,
"FrontEndMapping");
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';
560 unsigned copperID = (unsigned) merger.getInt(
"COPPERid");
561 string finesseSlot = merger.getString(
"FinesseSlot");
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;}
568 B2ERROR(merger.getPath() <<
"/FinesseSlot " << finesseSlot <<
569 " ***invalid slot (valid are A, B, C, D)");
572 copperMap.
addMapping(mergerID, copperID, finesse);
573 std::cout <<
"Merger " << mergerID <<
" connected to copper " << copperID <<
", finesse " << finesse <<
'\n';
579 importObjMerger.
import(m_iov);
583 importObjCopper.
import(m_iov);
587 void ARICHDatabaseImporter::importGeometryConfig()
590 GearDir content =
GearDir(
"/Detector/DetectorComponent[@name='ARICH']/Content");
594 importObj.
construct(arichGeometryConfig);
599 void ARICHDatabaseImporter::importCosmicTestGeometry()
601 GearDir content =
GearDir(
"/Detector/DetectorComponent[@name='ARICH']/Content");
602 GearDir cosmic(content,
"CosmicTest");
610 GearDir masterDir(cosmic,
"MasterVolume");
618 GearDir aerogel(cosmic,
"Aerogel");
621 plane.setSimple(par);
624 GearDir scints(cosmic,
"Scintilators");
626 std::string scintMat = scints.
getString(
"Material");
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);
644 void ARICHDatabaseImporter::importAeroTilesInfo()
649 elements.getEntries();
653 for (
int slot = 1; slot < 125; slot++) {
654 int ring = ARICHDatabaseImporter::getAeroTileRing(slot);
655 int column = ARICHDatabaseImporter::getAeroTileColumn(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();
665 for (
const auto& elementInfo : elementsInfo) {
666 if (elementInfo.getAerogelSN() == aeroID) {
667 refractiveIndex = elementInfo.getAerogelRefractiveIndex();
668 transmissionLength = elementInfo.getAerogelTransmissionLength();
669 thickness = elementInfo.getAerogelThickness();
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);
688 int ARICHDatabaseImporter::getAeroTileRing(
int slot)
691 if (slot < 23) ring = 1;
692 else if (slot < 51) ring = 2;
693 else if (slot < 85) ring = 3;
699 int ARICHDatabaseImporter::getAeroTileColumn(
int slot)
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;
711 void ARICHDatabaseImporter::printAeroTileInfo()
717 void ARICHDatabaseImporter::printGlobalAlignment()
723 void ARICHDatabaseImporter::printMirrorAlignment()
729 void ARICHDatabaseImporter::printAeroTilesAlignment()
737 void ARICHDatabaseImporter::importBiasMappings()
740 GearDir content =
GearDir(
"/DetectorCables[@name='ARICH']/Content");
745 GearDir mapping(content,
"biasCableMapping");
748 unsigned cableID = (unsigned) module.getInt(
"cableID");
749 unsigned innerID = module.getInt(
"innerID");
750 unsigned ring = module.getInt(
"ring");
751 unsigned azimuth = module.getInt(
"azimuth");
752 for (
unsigned sector = 1; sector < 7; sector++) {
753 unsigned moduleID = geoConfig->getDetectorPlane().getSlotIDFromSRF(sector, ring, azimuth);
754 biasMap.
addMapping(moduleID, sector, cableID, innerID);
759 GearDir mappingCH(content,
"biasChannelMapping");
762 int crate = module.getInt(
"crate");
763 int slot = module.getInt(
"slot");
764 int channelID = module.getInt(
"channelID");
765 int pinID = module.getInt(
"pinID");
766 int connectionID = module.getInt(
"connectionID");
767 int innerID = module.getInt(
"innerID");
768 std::string type = module.getString(
"type");
769 channelsMap.
addMapping(crate, slot, channelID, pinID, connectionID, innerID, type);
773 GearDir mappingCrate(content,
"biasCrateToCable");
776 int connectionID = module.getInt(
"connectionID");
777 int sector = module.getInt(
"sector");
778 int cable = module.getInt(
"cable");
779 std::vector<int> sectorCable{sector, cable};
781 crateMap.
addMapping(connectionID, sectorCable);
786 importObjBias.
import(m_iov);
790 importObjBiasCH.
import(m_iov);
794 importObjBiasCrate.
import(m_iov);
797 void ARICHDatabaseImporter::importHvMappings()
800 GearDir content =
GearDir(
"/DetectorCables[@name='ARICH']/Content");
805 GearDir mapping(content,
"hvCableToModuleMapping");
808 unsigned cableID = (unsigned) module.getInt(
"cableID");
809 unsigned innerID = module.getInt(
"innerID");
810 unsigned ring = module.getInt(
"ring");
811 unsigned azimuth = module.getInt(
"azimuth");
812 for (
unsigned sector = 1; sector < 7; sector++) {
813 unsigned moduleID = geoConfig->getDetectorPlane().getSlotIDFromSRF(sector, ring, azimuth);
814 hvMap.
addMapping(moduleID, sector, cableID, innerID);
819 GearDir mappingCH(content,
"hvChannelMapping");
822 int crate = module.getInt(
"crate");
823 int slot = module.getInt(
"slot");
824 int channelID = module.getInt(
"channelID");
825 int connectionID = module.getInt(
"connectionID");
826 int pinID = module.getInt(
"pinID");
827 channelsMap.
addMapping(crate, slot, channelID, connectionID, pinID);
831 GearDir mappingCrate(content,
"hvCrateToCable");
834 int connectionID = module.getInt(
"connectionID");
835 int sector = module.getInt(
"sector");
836 int cable = module.getInt(
"cable");
837 std::vector<int> sectorCable{sector, cable};
839 crateMap.
addMapping(connectionID, sectorCable);
844 importObjHv.
import(m_iov);
848 importObjHvCH.
import(m_iov);
852 importObjHvCrate.
import(m_iov);
857 void ARICHDatabaseImporter::importNominalBiasVoltages()
860 GearDir content =
GearDir(
"/DetectorCables[@name='ARICH']/Content");
865 GearDir biasVoltages(content,
"biasVoltages");
868 std::string hapdID = module.getString(
"@id");
869 int biasA = module.getInt(
"biasA");
870 int biasB = module.getInt(
"biasB");
871 int biasC = module.getInt(
"biasC");
872 int biasD = module.getInt(
"biasD");
873 int guard = module.getInt(
"guard");
874 std::vector<int> voltages{biasA, biasB, biasC, biasD, guard};
880 importObjBiasVolt.
import(m_iov);
884 void ARICHDatabaseImporter::printBiasMappings()
889 channelsMap->print();
894 void ARICHDatabaseImporter::printHvMappings()
902 void ARICHDatabaseImporter::dumpHvMappings()
907 for (
int hapdID = 1; hapdID < 421; hapdID++) {
908 int val = hvMap->getCableID(hapdID) * 100 + hvMap->getInnerID(hapdID);
909 hist->setBinContent(hapdID, val);
911 hist->SetOption(
"TEXT");
912 hist->SaveAs(
"HVMapping.root");
915 void ARICHDatabaseImporter::printNominalBiasVoltages()
921 void ARICHDatabaseImporter::printNominalBiasVoltageForChannel(std::vector<int> channel)
928 elements.getEntries();
930 int connectionID = std::get<0>(channelsMap->getInnerConnection(channel));
931 int innerCable = std::get<1>(channelsMap->getInnerConnection(channel));
932 std::string biasType = std::get<2>(channelsMap->getInnerConnection(channel));
934 int sector = crateMap->getSector(connectionID);
935 int outerCable = crateMap->getCable(connectionID);
937 int moduleID = (int) biasMap->getModuleID(sector, outerCable, innerCable);
938 std::string hapdID =
"";
939 for (
const auto& element : elements) {
940 if (element.getSensorModuleID() == moduleID) hapdID = element.getHAPDserial();
943 std::vector<int> voltages = biasVolt->getBiasVoltages(hapdID);
944 int appliedVoltage = 0;
946 if (biasType ==
"bias-a") appliedVoltage = voltages[0];
947 if (biasType ==
"bias-b") appliedVoltage = voltages[1];
948 if (biasType ==
"bias-c") appliedVoltage = voltages[2];
949 if (biasType ==
"bias-d") appliedVoltage = voltages[3];
950 if (biasType ==
"guard") appliedVoltage = voltages[4];
953 B2INFO(
"Crate " << channel[0] <<
", slot " << channel[1] <<
", slot channel " << channel[2] <<
" belongs to hapd " << hapdID <<
954 " (module ID = " << moduleID <<
") in sector " << sector <<
".\n Corresponding cable is " << sector <<
"-" << outerCable <<
955 ".\n Cable type is " << biasType <<
" with applied voltage " << appliedVoltage <<
" V.");
959 void ARICHDatabaseImporter::printHapdPositionFromCrateSlot(
int crate,
int slot,
int channelID)
967 elements.getEntries();
969 std::vector<int> channel{crate, slot, channelID};
970 int connectionID = std::get<0>(channelsMap->getInnerConnection(channel));
971 int innerCableNum = std::get<1>(channelsMap->getInnerConnection(channel));
972 std::string biasType = channelsMap->getType(channel);
974 int sector = crateMap->getSector(connectionID);
975 int outerCable = crateMap->getCable(connectionID);
977 int moduleID = (int)biasMap->getModuleID(sector, outerCable, innerCableNum);
979 unsigned mergerID = mrgMap->getMergerID((
unsigned)moduleID);
980 unsigned mergerSN = mrgMap->getMergerSN((
unsigned)mergerID);
981 unsigned febSlot = mrgMap->getFEBSlot((
unsigned)moduleID);
982 int febSlotDaq = ARICHDatabaseImporter::getFebDaqSlot(febSlot);
984 for (
const auto& element : elements) {
985 if (element.getSensorGlobalID() == moduleID) B2INFO(
"HAPD for crate " << crate + 1 <<
", slot " << slot <<
", inner cable " <<
986 innerCableNum <<
" has ID number " << moduleID <<
". Bias cable number is " << sector <<
"-" << outerCable <<
987 ".\n Position is: RING " << element.getSensorModuleRingID() <<
" COLUMN " << element.getSensorModuleColumnID() <<
988 ". \n Bias type for channel " << channelID <<
" is " << biasType <<
".\n It belongs to merger " << mergerID <<
" (SN " <<
989 mergerSN <<
") and has DAQ feb slot " << febSlotDaq);
994 int ARICHDatabaseImporter::getFebDaqSlot(
unsigned febSlot)
996 std::map<unsigned, int> febSlots;
997 febSlots.insert(std::pair<unsigned, int>(6, 0));
998 febSlots.insert(std::pair<unsigned, int>(5, 1));
999 febSlots.insert(std::pair<unsigned, int>(4, 2));
1000 febSlots.insert(std::pair<unsigned, int>(1, 3));
1001 febSlots.insert(std::pair<unsigned, int>(2, 4));
1002 febSlots.insert(std::pair<unsigned, int>(3, 5));
1004 int febDaqSlot = febSlots.find(febSlot)->second;
1009 void ARICHDatabaseImporter::printSimulationPar()
1015 void ARICHDatabaseImporter::printGeometryConfig()
1022 void ARICHDatabaseImporter::printChannelMapping()
1028 void ARICHDatabaseImporter::printMergerMapping()
1034 void ARICHDatabaseImporter::printCopperMapping()
1040 void ARICHDatabaseImporter::printModulesInfo()
1046 void ARICHDatabaseImporter::printReconstructionPar()
1053 void ARICHDatabaseImporter::printChannelMask(
bool makeHist)
1061 for (
int hapdID = 1; hapdID < 421; hapdID++) {
1062 for (
int ichn = 0; ichn < 144; ichn++) {
1063 if (chMask->isActive(hapdID, ichn)) hist->setBinContent(hapdID, ichn, 1.0);
1066 hist->SaveAs(
"channelMask.root");
1070 void ARICHDatabaseImporter::dumpMergerMapping(
bool sn)
1074 for (
int hapdID = 1; hapdID < 421; hapdID++) {
1075 int val = mgrMap->getMergerID(hapdID);
1076 if (sn) val = mgrMap->getMergerSN(val);
1077 hist->setBinContent(hapdID, val);
1079 hist->SetOption(
"TEXT");
1080 hist->SaveAs(
"MergerMapping.root");
1084 void ARICHDatabaseImporter::printFEMappings()
1091 GearDir content =
GearDir(
"/Detector/DetectorComponent[@name='ARICH']/Content/InstalledModules");
1093 cout <<
"{ \"hapdmap\": [" << endl;
1094 for (
unsigned hapdID = 1; hapdID < 421; hapdID++) {
1096 for (
const GearDir& module : content.getNodes(
"Module")) {
1097 hapdsn = module.getString(
"@hapdID");
1098 unsigned sector = module.getInt(
"Sector");
1099 unsigned ring = module.getInt(
"Ring");
1100 unsigned azimuth = module.getInt(
"Azimuth");
1101 unsigned moduleID = geoConfig->getDetectorPlane().getSlotIDFromSRF(sector, ring, azimuth);
1102 if (moduleID == hapdID)
break;
1105 int val = mgrMap->getMergerID(hapdID);
1106 cout <<
"{\n" <<
"\"ID\": \"" << hapdID <<
"\"," << endl;
1107 cout <<
"\"sn\": \"" << hapdsn <<
"\"," << endl;
1108 cout <<
"\"mrg\": \"" << val <<
"\"," << endl;
1109 cout <<
"\"mrgSN\": \"" << mgrMap->getMergerSN(val) <<
"\"," << endl;
1110 cout <<
"\"feb\": \"" << mgrMap->getFEBSlot(hapdID) - 1 <<
"\"," << endl;
1111 cout <<
"\"cpr\": \"" << cprMap->getCopperID(val) <<
"\"," << endl;
1112 cout <<
"\"hslb\": \"" << cprMap->getFinesse(val) <<
"\"" << endl;
1113 if (hapdID < 420) cout <<
"}," << endl;
1114 else cout <<
"}" << endl;
1116 cout <<
"]}" << endl;
1121 void ARICHDatabaseImporter::dumpModuleNumbering()
1125 for (
int hapdID = 1; hapdID < 421; hapdID++) {
1126 hist->setBinContent(hapdID, hapdID);
1128 hist->SetOption(
"TEXT");
1129 hist->SaveAs(
"ModuleNumbering.root");
1133 void ARICHDatabaseImporter::dumpQEMap(
bool simple)
1140 TGraph2D* gr =
new TGraph2D();
1142 for (
int i = 1; i < 421; i++) {
1143 if (modInfo->isInstalled(i)) {
1144 for (
int j = 0; j < 144; j++) {
1146 chMap->getXYFromAsic(j, xCh, yCh);
1147 TVector2 chPos = geoConfig->getChannelPosition(i, xCh, yCh);
1148 gr->SetPoint(point, chPos.X(), chPos.Y(), modInfo->getChannelQE(i, j));
1153 gr->SaveAs(
"QEMap.root");
1156 for (
int hapdID = 1; hapdID < 421; hapdID++) {
1157 if (!modInfo->isInstalled(hapdID))
continue;
1158 for (
int chID = 0; chID < 144; chID++) {
1159 hist->setBinContent(hapdID, chID, modInfo->getChannelQE(hapdID, chID));
1162 hist->SaveAs(
"QEMap.root");
1166 void ARICHDatabaseImporter::dumpAerogelOpticalProperties(std::string outRootFileName)
1176 std::string condDBname =
"ARICHdata";
1178 if (condDBname ==
"ARICHdata") {
1187 for (
const auto& elementM : elementsM) {
1188 if (elementM.getAerogelLayer(0) == 1) {
1189 for (
const auto& elementI : elementsI) {
1190 if (elementI.getAerogelSN() == elementM.getAerogelSN()) {
1193 elementM.getAerogelColumnID()), elementI.getAerogelRefractiveIndex());
1194 h2_aerogel_down_transmL->SetBinContent(h2_aerogel_down_transmL->
GetBinIDFromRingColumn(elementM.getAerogelRingID(),
1195 elementM.getAerogelColumnID()), elementI.getAerogelTransmissionLength());
1196 h2_aerogel_down_thick->SetBinContent(h2_aerogel_down_thick->
GetBinIDFromRingColumn(elementM.getAerogelRingID(),
1197 elementM.getAerogelColumnID()), elementI.getAerogelThickness());
1201 if (elementM.getAerogelLayer(1) == 1) {
1202 for (
const auto& elementI : elementsI) {
1203 if (elementI.getAerogelSN() == elementM.getAerogelSN()) {
1205 h2_aerogel_up_n->SetBinContent(h2_aerogel_up_n->
GetBinIDFromRingColumn(elementM.getAerogelRingID(), elementM.getAerogelColumnID()),
1206 elementI.getAerogelRefractiveIndex());
1207 h2_aerogel_up_transmL->SetBinContent(h2_aerogel_up_transmL->
GetBinIDFromRingColumn(elementM.getAerogelRingID(),
1208 elementM.getAerogelColumnID()), elementI.getAerogelTransmissionLength());
1209 h2_aerogel_up_thick->SetBinContent(h2_aerogel_up_thick->
GetBinIDFromRingColumn(elementM.getAerogelRingID(),
1210 elementM.getAerogelColumnID()), elementI.getAerogelThickness());
1222 TFile* rootFile =
new TFile(outRootFileName.c_str(),
"RECREATE",
" Histograms", 1);
1224 if (rootFile->IsZombie()) {
1225 B2ERROR(
" ERROR ---> file : " << outRootFileName.c_str() <<
" is zombi");
1227 h2_aerogel_up_n->Write();
1228 h2_aerogel_up_transmL->Write();
1229 h2_aerogel_up_thick->Write();
1230 h2_aerogel_down_n->Write();
1231 h2_aerogel_down_transmL->Write();
1232 h2_aerogel_down_thick->Write();
1237 void ARICHDatabaseImporter::importAeroRayleighScatteringFit(std::string commentSingleWord)
1244 TClonesArray agelFitConstants(
"Belle2::ARICHAerogelRayleighScatteringFit");
1247 float version = (float) content.getDouble(
"version");
1250 for (
const auto& aerogel : content.getNodes(
"aerogeltile")) {
1252 serial = aerogel.getString(
"serial");
1254 vPar.push_back((
float)aerogel.getDouble(
"p0"));
1255 vPar.push_back((
float)aerogel.getDouble(
"p1"));
1256 vPar.push_back((
float)aerogel.getDouble(
"p2"));
1257 vPar.push_back((
float)aerogel.getDouble(
"p3"));
1258 vPar.push_back((
float)aerogel.getDouble(
"p4"));
1259 vPar.push_back((
float)aerogel.getDouble(
"p5"));
1260 vPar.push_back((
float)aerogel.getDouble(
"p6"));
1266 agelFitConstants[agel] = aeroRayScatFit;
1273 TString coreName =
"ARICHAerogelRayleighScatteringFit";
1274 TString coreNameSuffix = commentSingleWord;
1275 if (coreNameSuffix !=
"")
1276 coreName += coreNameSuffix;
1277 Database::Instance().storeData(coreName.Data(), &agelFitConstants, m_iov);
1282 void ARICHDatabaseImporter::importAerogelInfo(TString coreNameSuffix)
1284 GearDir content =
GearDir(
"/ArichData/AllData/AerogelData/Content");
1287 TClonesArray agelConstants(
"Belle2::ARICHAerogelInfo");
1291 for (
const auto& aerogel : content.getNodes(
"aerogel")) {
1292 float version = (float) aerogel.getDouble(
"version");
1293 string serial = aerogel.getString(
"serial");
1294 string id = aerogel.getString(
"id");
1295 float index = (float) aerogel.getDouble(
"index");
1296 float trlen = ((float) aerogel.getDouble(
"translength")) * Unit::mm;
1297 float thickness = ((float) aerogel.getDouble(
"thick")) * Unit::mm;
1298 vector<int> lambdas;
1299 vector<float> transmittances;
1300 for (
const auto& transmittance : aerogel.getNodes(
"transmittance/transpoint")) {
1301 int lambda = transmittance.getInt(
"@lambda");
1302 float val = (float) transmittance.getDouble(
".");
1303 lambdas.push_back(lambda);
1304 transmittances.push_back(val);
1308 new (agelConstants[agel])
ARICHAerogelInfo(version, serial,
id, index, trlen, thickness, lambdas, transmittances);
1317 TString coreName =
"ARICHAerogelInfo";
1318 if (coreNameSuffix !=
"")
1319 coreName += coreNameSuffix;
1320 Database::Instance().storeData(coreName.Data(), &agelConstants, m_iov);
1323 void ARICHDatabaseImporter::exportAerogelInfo(
int verboseLevel)
1360 elements.getEntries();
1363 for (
const auto& element : elements) {
1364 B2INFO(
"Version = " << element.getAerogelVersion() <<
", serial = " << element.getAerogelSN() <<
1365 ", id = " << element.getAerogelID() <<
", n = " << element.getAerogelRefractiveIndex() <<
", transmLength = " <<
1366 element.getAerogelTransmissionLength() <<
", thickness = " << element.getAerogelThickness());
1367 if (verboseLevel > 0) {
1368 unsigned int ii = 0;
1370 while (lllambda > 0) {
1371 lllambda = element.getAerogelTransmittanceLambda(ii);
1374 float llval = element.getAerogelTransmittance(ii);
1375 B2INFO(
" Lambda = " << lllambda <<
" Transmittance = " << llval);
1384 void ARICHDatabaseImporter::importAerogelMap()
1389 TClonesArray agelMap(
"Belle2::ARICHAerogelMap");
1392 for (
int layer = 0; layer < 2; layer++) {
1394 for (
const auto& aerogel : content.getNodes(
"position")) {
1395 string agelserial =
"";
1396 int ring = aerogel.getInt(
"ring");
1397 int phi = aerogel.getInt(
"phi");
1398 if (layer == 1) agelserial = aerogel.getString(
"upaerogelserial");
1399 if (layer == 0) agelserial = aerogel.getString(
"downaerogelserial");
1405 agelConst->setAerogelRingID(ring);
1406 agelConst->setAerogelColumnID(phi);
1407 agelConst->setAerogelLayer(layer, 1);
1414 Database::Instance().storeData(
"ARICHAerogelMap", &agelMap, m_iov);
1419 void ARICHDatabaseImporter::exportAerogelMap()
1423 elements.getEntries();
1426 for (
const auto& element : elements) {
1428 if (element.getAerogelLayer(0) == 1) layer =
"down";
1429 if (element.getAerogelLayer(1) == 1) layer =
"up";
1430 B2INFO(
"ID = " << element.getAerogelSN() <<
", ring = " << element.getAerogelRingID() <<
1431 ", column = " << element.getAerogelColumnID() <<
", layer: " << layer);
1436 void ARICHDatabaseImporter::importAerogelInfoEventDep()
1438 GearDir content =
GearDir(
"/ArichData/AllData/AerogelData/Content");
1441 TClonesArray agelConstantsA(
"Belle2::ARICHAerogelInfo");
1442 TClonesArray agelConstantsB(
"Belle2::ARICHAerogelInfo");
1443 TClonesArray agelConstantsC(
"Belle2::ARICHAerogelInfo");
1446 for (
int someint = 0; someint < 3; someint++) {
1449 for (
const auto& aerogel : content.getNodes(
"aerogel")) {
1453 if (someint == 0) version = (float) aerogel.getDouble(
"version");
1454 if (someint == 1) version = 4.0;
1455 if (someint == 2) version = 5.0;
1457 string serial = aerogel.getString(
"serial");
1458 string id = aerogel.getString(
"id");
1459 float index = (float) aerogel.getDouble(
"index");
1460 float trlen = ((float) aerogel.getDouble(
"translength")) * Unit::mm;
1461 float thickness = ((float) aerogel.getDouble(
"thick")) * Unit::mm;
1462 vector<int> lambdas;
1463 vector<float> transmittances;
1464 for (
const auto& transmittance : aerogel.getNodes(
"transmittance/transpoint")) {
1465 int lambda = transmittance.getInt(
"@lambda");
1466 float val = (float) transmittance.getDouble(
".");
1467 lambdas.push_back(lambda);
1468 transmittances.push_back(val);
1472 if (someint == 0)
new (agelConstantsA[agel])
ARICHAerogelInfo(version, serial,
id, index, trlen, thickness, lambdas,
1474 if (someint == 1)
new (agelConstantsB[agel])
ARICHAerogelInfo(version, serial,
id, index, trlen, thickness, lambdas,
1476 if (someint == 2)
new (agelConstantsC[agel])
ARICHAerogelInfo(version, serial,
id, index, trlen, thickness, lambdas,
1483 TObject* agelObj[3];
1484 agelObj[0] =
static_cast<TObject*
>(&agelConstantsA);
1485 agelObj[1] =
static_cast<TObject*
>(&agelConstantsB);
1486 agelObj[2] =
static_cast<TObject*
>(&agelConstantsC);
1490 intraRun.
add(500, agelObj[1]);
1491 intraRun.
add(1000, agelObj[2]);
1494 Database::Instance().storeData(
"ARICHAerogelInfoEventDep", &intraRun, m_iov);
1498 void ARICHDatabaseImporter::exportAerogelInfoEventDep()
1510 std::pair<TObject*, IntervalOfValidity> podatki = Database::Instance().getData(event,
"ARICHAerogelInfoEventDep");
1518 TObject* data = std::get<0>(podatki);
1520 TObject* myobject = data2->
getObject(event);
1521 TClonesArray* elements =
static_cast<TClonesArray*
>(myobject);
1524 (*elements).GetEntries();
1525 for (
int i = 0; i < elements->GetSize(); i++) {
1550 void ARICHDatabaseImporter::importHapdQA()
1553 TClonesArray hapdQAConstants(
"Belle2::ARICHHapdQA");
1557 for (
const string& inputFile : m_inputFilesHapdQA) {
1558 TFile* f = TFile::Open(inputFile.c_str(),
"READ");
1560 int size = inputFile.length();
1561 string hapdSerial = inputFile.substr(size - 16, 6);
1563 vector<TGraph*> leakCurrent;
1564 TH2F* hitData2D = 0;
1565 vector<TGraph*> noise;
1566 vector<TH1S*> hitCount;
1567 TTimeStamp arrivalDate;
1572 TIter next(f->GetListOfKeys());
1574 while ((key = (TKey*)next())) {
1576 string strime = key->GetName();
1578 if (strime.compare(0, 8,
"gcurrent") == 0) {
1579 TGraph* graphcurrent = (TGraph*)f->Get(strime.c_str());
1580 leakCurrent.push_back(graphcurrent);
1583 else if (strime.compare(0, 7,
"h2dscan") == 0) {
1584 hitData2D = (TH2F*)f->Get(strime.c_str());
1585 hitData2D->SetDirectory(0);
1588 else if (strime.compare(0, 9,
"gnoise_ch") == 0) {
1589 TGraph* graphnoise = (TGraph*)f->Get(strime.c_str());
1590 noise.push_back(graphnoise);
1593 else if (strime.compare(0, 7,
"hchscan") == 0) {
1594 TH1F* hhist3 = (TH1F*)f->Get(strime.c_str());
1595 hhist3->SetDirectory(0);
1599 const char* hhist3_ime = hhist3->GetName();
1600 const char* hhist3_naslov = hhist3->GetTitle();
1601 int hhist3_nbins = hhist3->GetSize();
1602 TH1S* hhist3short =
new TH1S(hhist3_ime, hhist3_naslov, hhist3_nbins - 2, 0, 1);
1603 for (
int bin = 0; bin < hhist3_nbins; bin++) {
1604 hhist3short->SetBinContent(bin, hhist3->GetBinContent(bin));
1606 hhist3short->SetDirectory(0);
1607 hitCount.push_back(hhist3short);
1610 else if (strime.compare(0, 4,
"tree") == 0) {
1611 tree = (TTree*)f->Get(strime.c_str());
1612 tree->SetBranchAddress(
"arrival", &arrival);
1614 arrivalDate = TTimeStamp(arrival, 0);
1617 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()); }
1621 new (hapdQAConstants[
hapd])
ARICHHapdQA(hapdSerial, arrivalDate, leakCurrent, hitData2D, noise, hitCount);
1626 Database::Instance().storeData(
"ARICHHapdQA", &hapdQAConstants, m_iov);
1630 void ARICHDatabaseImporter::exportHapdQA()
1633 elements.getEntries();
1636 for (
const auto& element : elements) {
1637 B2INFO(
"Serial number = " << element.getHapdSerialNumber() <<
"; arrival date = " << element.getHapdArrivalDate());
1641 void ARICHDatabaseImporter::importAsicInfo()
1645 TClonesArray asicConstants(
"Belle2::ARICHAsicInfo");
1648 for (
const auto& asiclist : content.getNodes(
"asicinfo")) {
1649 string asicSerial = asiclist.getString(
"serial");
1650 string comment = asiclist.getString(
"comment");
1651 string numCH = asiclist.getString(
"num");
1654 TTimeStamp timeFinishGain = ARICHDatabaseImporter::getAsicDate(asicSerial,
"gain");
1655 TTimeStamp timeFinishOffset = ARICHDatabaseImporter::getAsicDate(asicSerial,
"offset");
1658 vector<int> nosignalCHs = ARICHDatabaseImporter::channelsList(asiclist.getString(
"nosignal"));
1659 vector<int> badconnCHs = ARICHDatabaseImporter::channelsList(asiclist.getString(
"badconn"));
1660 vector<int> badoffsetCHs = ARICHDatabaseImporter::channelsList(asiclist.getString(
"badoffset"));
1661 vector<int> badlinCHs = ARICHDatabaseImporter::channelsList(asiclist.getString(
"badlin"));
1664 if (numCH.find(
"many") != string::npos) {num = 5000; }
1665 else if (numCH.find(
"all") != string::npos) {num = 10000; }
1666 else {num = atoi(numCH.c_str()); }
1671 auto* asicConst =
static_cast<ARICHAsicInfo*
>(asicConstants[asic]);
1674 asicConst->setTimeFinishGain(timeFinishGain);
1675 asicConst->setTimeFinishOffset(timeFinishOffset);
1676 asicConst->setDeadChannels(nosignalCHs);
1677 asicConst->setBadConnChannels(badconnCHs);
1678 asicConst->setBadOffsetChannels(badoffsetCHs);
1679 asicConst->setBadLinChannels(badlinCHs);
1680 asicConst->setNumOfProblematicChannels(num);
1681 asicConst->setComment(comment);
1686 Database::Instance().storeData(
"ARICHAsicInfo", &asicConstants, m_iov);
1689 void ARICHDatabaseImporter::importAsicInfoRoot()
1691 TFile f1(
"asicInfoHistograms.root",
"recreate");
1698 string asicSerial =
"";
1701 TTree* tree =
new TTree(
"asicInfo",
"asic info data");
1703 tree->Branch(
"asicSerial", (
void*)asicSerial.c_str(),
"string/C", 1024);
1704 tree->Branch(
"gain0",
"TH3F", &gain0);
1705 tree->Branch(
"gain1",
"TH3F", &gain1);
1706 tree->Branch(
"gain2",
"TH3F", &gain2);
1707 tree->Branch(
"gain3",
"TH3F", &gain3);
1708 tree->Branch(
"offsetF",
"TH3F", &offsetF);
1709 tree->Branch(
"offsetR",
"TH3F", &offsetR);
1712 for (
const string& inputFile : m_inputFilesAsicRoot) {
1714 string inputFileNew = (string) inputFile;
1715 string asicName = inputFileNew.substr(inputFileNew.find(
"/asicData") + 17);
1716 size_t findRoot = asicName.find(
".root");
1717 if (findRoot != string::npos) {
1719 TFile* f = TFile::Open(inputFile.c_str(),
"READ",
"", 0);
1720 TIter next(f->GetListOfKeys());
1724 while ((key = (TKey*)next())) {
1725 string strname = key->GetName();
1726 if (strname.find(
"_g0") != string::npos) gain0 = (TH3F*)f->Get(strname.c_str());
1727 else if (strname.find(
"_g1") != string::npos) gain1 = (TH3F*)f->Get(strname.c_str());
1728 else if (strname.find(
"_g2") != string::npos) gain2 = (TH3F*)f->Get(strname.c_str());
1729 else if (strname.find(
"_g3") != string::npos) gain3 = (TH3F*)f->Get(strname.c_str());
1730 else if (strname.find(
"_f") != string::npos) offsetF = (TH3F*)f->Get(strname.c_str());
1731 else if (strname.find(
"_c") != string::npos) offsetR = (TH3F*)f->Get(strname.c_str());
1732 else B2INFO(
"Key name does not match any of the following: gain, offset!");
1745 Database::Instance().addPayload(
"ARICHAsicInfoRoot",
"asicInfoHistograms.root", m_iov);
1748 TTimeStamp ARICHDatabaseImporter::getAsicDate(
const std::string& asicSerial,
const std::string& type)
1750 TTimeStamp timeFinish;
1752 size_t findText = 100;
1755 for (
const string& inputFile : m_inputFilesAsicTxt) {
1756 string inputFileNew = (string) inputFile;
1757 if (type ==
"gain") { findText = inputFileNew.find(
"dateGain.txt"); }
1758 else if (type ==
"offset") { findText = inputFileNew.find(
"dateOffset.txt"); }
1759 else {B2INFO(
"Check type of measurement!"); }
1760 if (findText != string::npos) {
1761 std::ifstream ifs(inputFile);
1762 if (ifs.is_open()) {
1763 while (ifs.good()) {
1764 std::getline(ifs, line);
1765 string asicSerial2 = asicSerial +
":";
1766 size_t findSerial = line.find(asicSerial2);
1767 if (findSerial != string::npos) {timeFinish = ARICHDatabaseImporter::timedate(line);}
1777 TTimeStamp ARICHDatabaseImporter::timedate(std::string enddate)
1780 string dateEnd = enddate.substr(enddate.find(
":") + 2);
1781 string yearStr = dateEnd.substr(0, 4);
1782 string monthStr = dateEnd.substr(4, 2);
1783 string dayStr = dateEnd.substr(6, 2);
1784 string hourStr = dateEnd.substr(8, 2);
1785 string minStr = dateEnd.substr(10, 2);
1786 int year = atoi(yearStr.c_str());
1787 int month = atoi(monthStr.c_str());
1788 int day = atoi(dayStr.c_str());
1789 int hour = atoi(hourStr.c_str());
1790 int min = atoi(minStr.c_str());
1791 TTimeStamp datum = TTimeStamp(year, month, day, hour, min, 0, 0, kTRUE, -9 * 60 * 60);
1795 vector<int> ARICHDatabaseImporter::channelsList(std::string badCH)
1800 if ((badCH.find(
"many") != string::npos) || (badCH.find(
"all") != string::npos)) CHs.emplace_back(-1);
1801 else ARICHTools::StringToVector::convert<int>(badCH,
',');
1807 void ARICHDatabaseImporter::exportAsicInfo()
1811 elements.getEntries();
1814 for (
const auto& element : elements) {
1815 B2INFO(
"asic SN: " << element.getAsicID());
1820 void ARICHDatabaseImporter::importFebTest()
1824 TClonesArray febConstants(
"Belle2::ARICHFebTest");
1830 GearDir content2 =
GearDir(
"/ArichData/AllData/FEBData/Content");
1832 for (
const auto& runserial : content.getNodes(
"run")) {
1833 int serial = runserial.getInt(
"sn");
1836 auto* febConst =
static_cast<ARICHFebTest*
>(febConstants[feb]);
1839 string runLV = runserial.getString(
"lv");
1840 string runHV = runserial.getString(
"hv");
1841 string runSCAN = runserial.getString(
"scan");
1842 string comment = runserial.getString(
"comment");
1844 febConst->setRunLV(runLV);
1845 febConst->setRunHV(runHV);
1846 febConst->setRunSlowC(runSCAN);
1847 febConst->setComment(comment);
1852 for (
const auto& febmap : content1.
getNodes(
"febps")) {
1853 string somedna = febmap.getString(
"@dna");
1854 int sn = febmap.getInt(
"sn");
1855 if ((l == 0) && (sn == serial)) {
1857 febConst->setFebDna(dna);
1864 if (!runSCAN.empty()) {
1866 if (stoi(runSCAN.c_str()) < 23) {scanRun = stoi(runSCAN.c_str());}
1867 else {scanRun = stoi(runSCAN.c_str()) - 77;}
1868 for (
const auto& testFEB : content2.
getNodes(
"febtest[" + std::to_string(scanRun) +
"]")) {
1869 string timeSlowC = testFEB.getString(
"time");
1871 int positionOld = 0;
1873 for (
const auto& testFEBslowctest : testFEB.getNodes(
"slowc")) {
1874 int position = testFEBslowctest.getInt(
"id");
1875 if (position == positionOld) {i++; }
1878 string dnaNew = testFEBslowctest.getString(
"dna");
1879 if (dnaNew == dna) {
1880 float tmon0 = (float) testFEBslowctest.getDouble(
"TMON0");
1881 float tmon1 = (float) testFEBslowctest.getDouble(
"TMON1");
1882 float vdd = (float) testFEBslowctest.getDouble(
"VDD");
1883 float v2p = (float) testFEBslowctest.getDouble(
"V2P");
1884 float v2n = (float) testFEBslowctest.getDouble(
"V2N");
1885 float vss = (float) testFEBslowctest.getDouble(
"VSS");
1886 float vth1 = (float) testFEBslowctest.getDouble(
"VTH1");
1887 float vth2 = (float) testFEBslowctest.getDouble(
"VTH2");
1888 float vcc12 = (float) testFEBslowctest.getDouble(
"VCC12");
1889 float vcc15 = (float) testFEBslowctest.getDouble(
"VCC15");
1890 float vcc25 = (float) testFEBslowctest.getDouble(
"VCC25");
1891 float v38p = (float) testFEBslowctest.getDouble(
"V38P");
1893 febConst->setTemperature0(tmon0);
1894 febConst->setTemperature1(tmon1);
1895 febConst->setVdd(vdd);
1896 febConst->setV2p(v2p);
1897 febConst->setV2n(v2n);
1898 febConst->setVss(vss);
1899 febConst->setVth1(vth1);
1900 febConst->setVth2(vth2);
1901 febConst->setVcc12(vcc12);
1902 febConst->setVcc15(vcc15);
1903 febConst->setVcc25(vcc25);
1904 febConst->setV38p(v38p);
1905 febConst->setTimeSlowC(ARICHDatabaseImporter::timedate2(timeSlowC));
1909 positionOld = position;
1914 pair<vector<float>, vector<float>> slopes = ARICHDatabaseImporter::getSlopes(serial, runSCAN);
1916 febConst->setSlopesFine(slopes.first);
1917 febConst->setSlopesRough(slopes.second);
1920 vector<pair<float, float>> fwhm = ARICHDatabaseImporter::getFwhm(serial, runSCAN);
1921 febConst->setFWHM(fwhm);
1926 if (!runHV.empty()) {
1928 if (stoi(runHV.c_str()) < 43) {hvRun = stoi(runHV.c_str());}
1929 else {hvRun = stoi(runHV.c_str()) - 57;}
1930 tuple<string, float> HVtest = ARICHDatabaseImporter::getFebHVtestData(serial, hvRun);
1931 febConst->setTimeHV(ARICHDatabaseImporter::timedate2(get<0>(HVtest)));
1932 febConst->setCurrentV99p(get<1>(HVtest));
1937 if (!runLV.empty()) {
1939 if (stoi(runLV.c_str()) < 43) {lvRun = stoi(runLV.c_str());}
1940 else {lvRun = stoi(runLV.c_str()) - 57;}
1941 tuple<string, float, float, float> LVtest = ARICHDatabaseImporter::getFebLVtestData(serial, lvRun);
1942 febConst->setTimeLV(ARICHDatabaseImporter::timedate2(get<0>(LVtest)));
1943 febConst->setCurrentV20p(get<1>(LVtest));
1944 febConst->setCurrentV21n(get<2>(LVtest));
1945 febConst->setCurrentV38p(get<3>(LVtest));
1953 Database::Instance().storeData(
"ARICHFebTest", &febConstants, m_iov);
1958 void ARICHDatabaseImporter::importFebTestRoot()
1960 TFile f(
"febTestHistograms.root",
"recreate");
1961 TH3F* offsetRough = 0;
1962 TH3F* offsetFine = 0;
1963 TH2F* testPulse = 0;
1967 TTree* tree =
new TTree(
"febTest",
"feb test data");
1969 tree->Branch(
"serial", &serial,
"sn/I");
1970 tree->Branch(
"offsetRough",
"TH3F", &offsetRough);
1971 tree->Branch(
"offsetFine",
"TH3F", &offsetFine);
1972 tree->Branch(
"testPulse",
"TH2F", &testPulse);
1974 int febposition = -1;
1978 GearDir content2 =
GearDir(
"/ArichData/AllData/FEBData/Content");
1980 for (
const auto& runserial : content.getNodes(
"run")) {
1981 serial = runserial.getInt(
"sn");
1982 string runSCAN = runserial.getString(
"scan");
1986 for (
const auto& febmap : content1.
getNodes(
"febps")) {
1987 string somedna = febmap.getString(
"@dna");
1988 int sn = febmap.getInt(
"sn");
1989 if ((l == 0) && (sn == serial)) {
1995 if (!runSCAN.empty()) {
1997 if (stoi(runSCAN.c_str()) < 23) {scanRun = stoi(runSCAN.c_str());}
1998 else {scanRun = stoi(runSCAN.c_str()) - 77;}
1999 for (
const auto& testFEB : content2.
getNodes(
"febtest[" + std::to_string(scanRun) +
"]")) {
2001 int positionOld = 0;
2003 for (
const auto& testFEBslowctest : testFEB.getNodes(
"slowc")) {
2004 int position = testFEBslowctest.getInt(
"id");
2005 if (position == positionOld) {i++; }
2008 string dnaNew = testFEBslowctest.getString(
"dna");
2009 if (dnaNew == dna) febposition = position;
2011 positionOld = position;
2014 vector<TH3F*> histograms = getFebTestHistograms(dna, runSCAN, febposition);
2015 offsetRough = histograms[0];
2016 offsetFine = histograms[1];
2018 testPulse = ARICHDatabaseImporter::getFebTestPulse(dna, runSCAN, febposition);
2020 testPulse->SetDirectory(0);
2021 offsetRough->SetDirectory(0);
2022 offsetFine->SetDirectory(0);
2038 Database::Instance().addPayload(
"ARICHFebTestRoot",
"febTestHistograms.root", m_iov);
2042 std::tuple<std::string, float, float, float> ARICHDatabaseImporter::getFebLVtestData(
int serial,
int lvRun)
2044 GearDir content2LV =
GearDir(
"/ArichData/AllData/FEBDataLV/Content");
2045 std::tuple<std::string, float, float, float> LVtest;
2046 float currentV20p = 0.0, currentV21n = 0.0, currentV38p = 0.0;
2048 for (
const auto& testFEBlv : content2LV.
getNodes(
"febtest[" + std::to_string(lvRun) +
"]")) {
2049 string timeLV = testFEBlv.getString(
"time");
2050 for (
const auto& testFEBlv_sn : testFEBlv.getNodes(
"lvtest/feb[sn='" + to_string(serial) +
"']/febps/n[@id='14']")) {
2051 for (
const auto& testFEBlv_pw : testFEBlv_sn.getNodes(
"pw18")) {
2052 if (testFEBlv_pw.getInt(
"@id") == 0) { currentV20p = (float) testFEBlv_pw.getDouble(
"I"); }
2053 if (testFEBlv_pw.getInt(
"@id") == 1) { currentV21n = (float) testFEBlv_pw.getDouble(
"I"); }
2054 if (testFEBlv_pw.getInt(
"@id") == 2) { currentV38p = (float) testFEBlv_pw.getDouble(
"I"); }
2055 LVtest = make_tuple(timeLV, currentV20p, currentV21n, currentV38p);
2063 std::tuple<std::string, float> ARICHDatabaseImporter::getFebHVtestData(
int serial,
int hvRun)
2065 GearDir content2HV =
GearDir(
"/ArichData/AllData/FEBDataHV/Content");
2066 std::tuple<std::string, float> HVtest;
2067 for (
const auto& testFEBhv : content2HV.
getNodes(
"febtest[" + std::to_string(hvRun) +
"]")) {
2068 string timeHV = testFEBhv.getString(
"time");
2069 for (
const auto& testFEBhv_sn : testFEBhv.getNodes(
"hvtest/feb[sn='" + to_string(serial) +
"']/febhv/n[@id='9']")) {
2070 float currentV99p = (float) testFEBhv_sn.getDouble(
"n1470/I");
2071 HVtest = std::make_tuple(timeHV, currentV99p);
2077 std::vector<int> ARICHDatabaseImporter::getDeadChFEB(
const std::string& dna)
2079 vector<int> listCHs;
2081 ifstream fileFEB(
"febTest/FEBdeadChannels.txt");
2082 if (fileFEB.is_open()) {
2083 while (getline(fileFEB, line)) {
2084 string ch2 = line.substr(line.find(
",") + 1);
2085 string dna2 = line.erase(line.find(
",") - 1);
2086 if (dna2 == dna) { listCHs.push_back(atoi(ch2.c_str())); }
2088 }
else { B2INFO(
"No file FEBdeadChannels.txt"); }
2094 TTimeStamp ARICHDatabaseImporter::timedate2(std::string time)
2097 string dateMeas = time.substr(4);
2098 string yearStr = dateMeas.substr(16, 4);
2099 string monthStr = dateMeas.substr(0, 3);
2100 string dayStr = dateMeas.substr(4, 2);
2101 string hourStr = dateMeas.substr(7, 2);
2102 string minStr = dateMeas.substr(10, 2);
2103 string secStr = dateMeas.substr(13, 2);
2105 int year = atoi(yearStr.c_str());
2106 int day = atoi(dayStr.c_str());
2107 int hour = atoi(hourStr.c_str());
2108 int min = atoi(minStr.c_str());
2109 int sec = atoi(secStr.c_str());
2110 map<string, int> months {
2111 {
"Jan", 1 }, {
"Feb", 2 }, {
"Mar", 3 }, {
"Apr", 4 }, {
"May", 5 }, {
"Jun", 6 }, {
"Jul", 7 }, {
"Aug", 8 }, {
"Sep", 9 }, {
"Oct", 10 }, {
"Nov", 11 }, {
"Dec", 12 }
2113 int month = months.find(monthStr)->second;
2115 TTimeStamp datum = TTimeStamp(year, month, day, hour, min, sec, 0, kTRUE, 0);
2119 std::pair<std::vector<float>, std::vector<float>> ARICHDatabaseImporter::getSlopes(
int serialNum,
const std::string& run)
2121 GearDir contentData =
GearDir(
"/ArichData/AllData/SlopesFebTest/Content");
2122 pair<vector<float>, vector<float>> slopesFebTest;
2123 vector<float> slopesCoarse, slopesFine;
2125 for (
const auto& contentSlopes : contentData.
getNodes(
"febtest")) {
2126 if ((contentSlopes.getInt(
"@id") == serialNum) && (contentSlopes.getString(
"@run") == run)) {
2127 for (
int i = 0; i < 144; i++) {
2128 for (
const auto& contSlopes : contentSlopes.getNodes(
"slope/ch[@id='" + to_string(i) +
"']")) {
2129 float slopeCoarse = ((float) contSlopes.getDouble(
"coarse")) * 2.5 / 1024;
2130 float slopeFine = ((float) contSlopes.getDouble(
"fine")) * 2.5 / 1024;
2131 slopesCoarse.push_back(slopeCoarse);
2132 slopesFine.push_back(slopeFine);
2136 slopesFebTest = std::make_pair(slopesFine, slopesCoarse);
2138 return slopesFebTest;
2141 std::vector<std::pair<float, float>> ARICHDatabaseImporter::getFwhm(
int serialNum,
const std::string& run)
2143 GearDir contentData =
GearDir(
"/ArichData/AllData/SlopesFebTest/Content");
2144 vector<pair<float, float>> fwhm;
2146 for (
const auto& contentSlopes : contentData.
getNodes(
"febtest")) {
2147 if ((contentSlopes.getInt(
"@id") == serialNum) && (contentSlopes.getString(
"@run") == run)) {
2148 for (
const auto& contSlopes : contentSlopes.getNodes(
"data/ch")) {
2149 float fwhmVal = (float) contSlopes.getDouble(
"fwhm");
2150 float fwhmSig = (float) contSlopes.getDouble(
"sigma");
2151 pair<float, float> fwhmPair = std::make_pair(fwhmVal, fwhmSig);
2152 fwhm.push_back(fwhmPair);
2159 std::vector<TH3F*> ARICHDatabaseImporter::getFebTestHistograms(
const std::string& dna,
const std::string& run,
int febposition)
2161 vector<TH3F*> histogrami;
2163 for (
const string& inputFile : m_inputFilesFebTest) {
2165 if (inputFile.find(run) != string::npos) {
2166 TFile* f = TFile::Open(inputFile.c_str(),
"READ");
2167 int iMIN = 0, iMAX = 0, delta, stepsNum = 16, i = 0, point2 = 24;
2169 float stepsMax = 15.5;
2172 TIter next(f->GetListOfKeys());
2174 while ((key = (TKey*)next())) {
2175 string strime = key->GetName();
2176 if (strime.compare(0, 5,
"h2d_0") == 0) i++;
2180 for (
int k = 0; k < 2; k++) {
2185 if (k == 0) { option =
"coarse"; iMIN = 2; iMAX = 16; delta = 2;}
2186 if (k == 1) { option =
"fine"; iMIN = 17; iMAX = 31; delta = 17; }
2188 if (k == 0) { option =
"coarse"; iMIN = 2; iMAX = 17; delta = 2; }
2189 if (k == 1) { option =
"fine"; iMIN = 18; iMAX = 33; delta = 18; }
2192 TH3F* histogram =
new TH3F((option +
" " + dna).c_str(), (option +
" " + dna).c_str(), 144, -0.5, 143.5, 250, 299, 799, stepsNum,
2195 for (
int j = iMIN; j < iMAX + 1; j++) {
2196 TH2F* hist2d = (TH2F*)f->Get((
"h2d_0;" + std::to_string(j)).c_str());
2197 hist2d->SetDirectory(0);
2200 if ((j - delta) < 8) {binZ = 8 - (j - delta);}
2201 if ((j - delta) > 7) {binZ = point2 - (j - delta);}
2203 for (
int binX = 144 * febposition + 1; binX < 144 * (febposition + 1) + 1; binX++) {
2204 for (
int binY = 1; binY < 251; binY++) {
2205 histogram->SetBinContent(binX - 144 * febposition, binY, binZ, hist2d->GetBinContent(binX, binY));
2209 histogram->SetDirectory(0);
2210 histogrami.push_back(histogram);
2211 for (
int kanal = 1; kanal < 145; kanal ++) {
2212 for (
int offset = 1; offset < stepsNum + 1; offset++) {
2213 TH1D* h1 = histogram->ProjectionY(
"A", kanal, kanal, offset, offset);
2214 h1->SetName((dna +
" kanal: " + to_string(kanal) +
", offset: " + to_string(offset)).c_str());
2225 TH2F* ARICHDatabaseImporter::getFebTestPulse(
const std::string& dna,
const std::string& run,
int febposition)
2227 TH2F* testPulse =
new TH2F((
"test pulse " + dna).c_str(), (
"test pulse " + dna).c_str(), 144, -0.5, 143.5, 250, 299, 799);
2229 for (
const string& inputFile : m_inputFilesFebTest) {
2230 if (inputFile.find(run) != string::npos) {
2231 TFile* f = TFile::Open(inputFile.c_str(),
"READ");
2232 TH2F* pulseTest = (TH2F*)f->Get(
"h2d_0;1");
2233 pulseTest->SetDirectory(0);
2234 for (
int binX = 144 * febposition + 1; binX < 144 * (febposition + 1) + 1; binX++) {
2235 for (
int binY = 1; binY < 251; binY++) {
2236 testPulse->SetBinContent(binX - 144 * febposition, binY, pulseTest->GetBinContent(binX, binY));
2247 void ARICHDatabaseImporter::exportFebTest()
2251 elements.getEntries();
2254 for (
const auto& element : elements) {
2255 B2INFO(
"Serial = " << element.getFebSerial() <<
"; dna = " << element.getFebDna() <<
"; slope R (ch143) = " <<
2256 element.getSlopeRough(143) <<
"; slope F (ch143) = " << element.getSlopeFine(143) <<
"; comment = " << element.getComment());
2261 void ARICHDatabaseImporter::importHapdChipInfo()
2264 GearDir content =
GearDir(
"/ArichData/AllData/hapdData/Content");
2267 TClonesArray chipConstants(
"Belle2::ARICHHapdChipInfo");
2270 for (
const auto& hapdInfo : content.getNodes(
"hapd")) {
2272 string sn = hapdInfo.getString(
"serial");
2276 int channel_label_aval[4], bias[4], gain[4];
2277 TGraph** bombardmentGain, **avalancheGain;
2278 bombardmentGain =
new TGraph *[4];
2279 avalancheGain =
new TGraph *[4];
2280 TH2F** bias2DV, **bias2DI;
2281 bias2DV =
new TH2F *[4];
2282 bias2DI =
new TH2F *[4];
2283 vector<int> badlist[4], cutlist[4];
2284 vector<TGraph*> bombCurrents[4], avalCurrents[4];
2288 for (
const auto& chipInfo : hapdInfo.getNodes(
"chipinfo")) {
2289 chip[chip_ABCD] = chipInfo.getString(
"chip");
2290 bias[chip_ABCD] = chipInfo.getInt(
"bias");
2291 string badL = chipInfo.getString(
"deadlist");
2292 string cutL = chipInfo.getString(
"cutlist");
2293 if (badL.find(
"ch") != string::npos) {
string badLsub = badL.substr(3); badlist[chip_ABCD] = ARICHDatabaseImporter::channelsListHapd(badLsub.c_str(), chip[chip_ABCD]); }
2294 if (cutL.find(
"ch") != string::npos) {
string cutLsub = cutL.substr(3); cutlist[chip_ABCD] = ARICHDatabaseImporter::channelsListHapd(cutLsub.c_str(), chip[chip_ABCD]); }
2295 string gain_str = chipInfo.getString(
"gain");
2296 gain[chip_ABCD] = atoi(gain_str.c_str());
2304 float hv_bomb[n3], gain_bomb[n3], current1_bomb[n3], current2_bomb[n3], current3_bomb[n3];
2306 for (
const auto& BG : hapdInfo.getNodes(
"bombardmentgain/ch")) {
2307 string value = BG.getString(
"value");
2308 string chip_label = value.erase(1);
2309 for (
const auto& BG2 : BG.getNodes(
"point")) {
2310 hv_bomb[i3] = (float) BG2.getDouble(
"hv");
2311 gain_bomb[i3] = (float) BG2.getDouble(
"gain");
2312 current1_bomb[i3] = (float) BG2.getDouble(
"current1");
2313 current2_bomb[i3] = (float) BG2.getDouble(
"current2");
2314 current3_bomb[i3] = (float) BG2.getDouble(
"current3");
2318 bombardmentGain[chip_ABCD] = ARICHDatabaseImporter::getGraphGainCurrent(
"Bombardment",
"gain", chip_label, i3, hv_bomb, gain_bomb);
2319 TGraph* bombardmentCurrent1 = ARICHDatabaseImporter::getGraphGainCurrent(
"Bombardment",
"current1", chip_label, i3, hv_bomb,
2321 TGraph* bombardmentCurrent2 = ARICHDatabaseImporter::getGraphGainCurrent(
"Bombardment",
"current2", chip_label, i3, hv_bomb,
2323 TGraph* bombardmentCurrent3 = ARICHDatabaseImporter::getGraphGainCurrent(
"Bombardment",
"current3", chip_label, i3, hv_bomb,
2325 bombCurrents[chip_ABCD].push_back(bombardmentCurrent1);
2326 bombCurrents[chip_ABCD].push_back(bombardmentCurrent2);
2327 bombCurrents[chip_ABCD].push_back(bombardmentCurrent3);
2335 float hv_aval[n4], gain_aval[n4], current1_aval[n4], current2_aval[n4], current3_aval[n4];
2337 for (
const auto& BG : hapdInfo.getNodes(
"avalanchegain/ch")) {
2338 string value = BG.getString(
"value");
2339 string value_1 = value;
2340 string chip_label = value.erase(1);
2341 string value_2 = value_1.substr(2);
2342 channel_label_aval[chip_ABCD] = atoi(value_2.c_str());
2343 for (
const auto& BG2 : BG.getNodes(
"point")) {
2344 hv_aval[i4] = (float) BG2.getDouble(
"biasv");
2345 gain_aval[i4] = (float) BG2.getDouble(
"gain");
2346 current1_aval[i4] = (float) BG2.getDouble(
"current1");
2347 current2_aval[i4] = (float) BG2.getDouble(
"current2");
2348 current3_aval[i4] = (float) BG2.getDouble(
"current3");
2352 avalancheGain[chip_ABCD] = ARICHDatabaseImporter::getGraphGainCurrent(
"Avalanche",
"gain", chip_label, i4, hv_aval, gain_aval);
2353 TGraph* avalancheCurrent1 = ARICHDatabaseImporter::getGraphGainCurrent(
"Avalanche",
"current1", chip_label, i4, hv_aval,
2355 TGraph* avalancheCurrent2 = ARICHDatabaseImporter::getGraphGainCurrent(
"Avalanche",
"current2", chip_label, i4, hv_aval,
2357 TGraph* avalancheCurrent3 = ARICHDatabaseImporter::getGraphGainCurrent(
"Avalanche",
"current3", chip_label, i4, hv_aval,
2359 avalCurrents[chip_ABCD].push_back(avalancheCurrent1);
2360 avalCurrents[chip_ABCD].push_back(avalancheCurrent2);
2361 avalCurrents[chip_ABCD].push_back(avalancheCurrent3);
2371 int i5 = 0, chipnum[n5];
2372 float biasv[n5], biasi[n5];
2373 for (
const auto& HI : hapdInfo.getNodes(
"bias2d/biasvalue")) {
2374 string chip_2d = HI.getString(
"@chip");
2375 chipnum[i5] = HI.getInt(
"@ch");
2376 biasv[i5] = (float) HI.getDouble(
"biasv");
2377 biasi[i5] = (float) HI.getDouble(
"biasi");
2378 if (chipnum[i5] == 36) {
2379 bias2DV[chip_ABCD] = ARICHDatabaseImporter::getBiasGraph(chip_2d,
"voltage", chipnum, biasv);
2380 bias2DI[chip_ABCD] = ARICHDatabaseImporter::getBiasGraph(chip_2d,
"current", chipnum, biasi);
2388 for (
unsigned int l = 0; l < 4; l++) {
2390 auto* chipConst =
static_cast<ARICHHapdChipInfo*
>(chipConstants[4 * chip_i + l]);
2393 chipConst->setChipLabel(chip[l]);
2394 chipConst->setBiasVoltage(bias[l]);
2395 chipConst->setGain(gain[l]);
2396 chipConst->setBadChannel(badlist[l]);
2397 chipConst->setCutChannel(cutlist[l]);
2398 chipConst->setBombardmentGain(bombardmentGain[l]);
2399 chipConst->setBombardmentCurrent(bombCurrents[l]);
2400 chipConst->setAvalancheGain(avalancheGain[l]);
2401 chipConst->setAvalancheCurrent(avalCurrents[l]);
2402 chipConst->setChannelNumber(channel_label_aval[l]);
2403 chipConst->setBiasVoltage2D(bias2DV[l]);
2404 chipConst->setBiasCurrent2D(bias2DI[l]);
2409 delete[] bombardmentGain;
2410 delete[] avalancheGain;
2416 Database::Instance().storeData(
"ARICHHapdChipInfo", &chipConstants, m_iov);
2419 void ARICHDatabaseImporter::exportHapdChipInfo()
2422 elements.getEntries();
2424 for (
const auto& element : elements) {
2425 B2INFO(
"Serial = " << element.getHapdSerial() <<
", chip = " << element.getChipLabel() <<
", bias= " << element.getBiasVoltage());
2431 void ARICHDatabaseImporter::importHapdInfo()
2434 GearDir content =
GearDir(
"/ArichData/AllData/hapdData/Content");
2437 TClonesArray hapdConstants(
"Belle2::ARICHHapdInfo");
2440 for (
const auto& hapdInfo : content.getNodes(
"hapd")) {
2443 auto* hapdConst =
static_cast<ARICHHapdInfo*
>(hapdConstants[hapd_i]);
2446 string serial = hapdInfo.getString(
"serial");
2447 float qe400 = (float) hapdInfo.getDouble(
"qe400");
2448 float hv = 1000 * (float) hapdInfo.getDouble(
"hv");
2449 float current = (float) hapdInfo.getDouble(
"current");
2450 string gb = hapdInfo.getString(
"guardbias");
2451 int guardbias = atoi(gb.c_str());
2455 float lambda[n1], qepoint[n1];
2457 for (
const auto& QE : hapdInfo.getNodes(
"qe/qepoint")) {
2458 lambda[i1] = (float) QE.getInt(
"@lambda");
2459 qepoint[i1] = (float) QE.getDouble(
".");
2462 TGraph* qe =
new TGraph(i1, lambda, qepoint);
2465 qe->GetXaxis()->SetTitle(
"lambda");
2466 qe->GetYaxis()->SetTitle(
"qe");
2469 const int n2 = 4100;
2470 int channel_adc[n2], pulse_adc[n2];
2472 for (
const auto& ADC : hapdInfo.getNodes(
"adc/value")) {
2473 channel_adc[i2] = ADC.getInt(
"@ch");
2474 string str = ADC.getString(
".");
2475 pulse_adc[i2] = atoi(str.c_str());
2478 TGraph* adc =
new TGraph(i2, channel_adc, pulse_adc);
2479 adc->SetName(
"adc");
2480 adc->SetTitle(
"Pulse Height Distribution");
2481 adc->GetXaxis()->SetTitle(
"channel");
2482 adc->GetYaxis()->SetTitle(
"pulse height");
2485 hapdConst->setSerialNumber(serial);
2486 hapdConst->setQuantumEfficiency400(qe400);
2487 hapdConst->setHighVoltage(hv);
2488 hapdConst->setGuardBias(guardbias);
2489 hapdConst->setCurrent(current);
2490 hapdConst->setQuantumEfficiency(qe);
2491 hapdConst->setPulseHeightDistribution(adc);
2497 for (
const auto& element : elementsChip) {
2498 if (element.getHapdSerial() == serial) {
2500 if (element.getChipLabel() ==
"A") hapdConst->setHapdChipInfo(0, &elementValue);
2501 if (element.getChipLabel() ==
"B") hapdConst->setHapdChipInfo(1, &elementValue);
2502 if (element.getChipLabel() ==
"C") hapdConst->setHapdChipInfo(2, &elementValue);
2503 if (element.getChipLabel() ==
"D") hapdConst->setHapdChipInfo(3, &elementValue);
2511 Database::Instance().storeData(
"ARICHHapdInfo", &hapdConstants, m_iov);
2516 std::vector<int> ARICHDatabaseImporter::channelsListHapd(std::string chlist, std::string chipDelay)
2518 B2INFO(
"channel list = " << chlist <<
", chip = " << chipDelay);
2519 string chlistDig = ARICHTools::remove_chars_if_not(chlist,
"0123456789,~");
2521 vector<int> CHs = ARICHTools::getDeadCutList(*chipDelay.c_str(), ARICHTools::StringToVector::parse<int>(chlistDig,
','));
2523 B2INFO(
"All channels: ");
2524 printContainer(CHs);
2529 TGraph* ARICHDatabaseImporter::getGraphGainCurrent(
const std::string& bomb_aval,
const std::string& g_i,
2530 const std::string& chip_label,
int i,
float* HV,
2531 float* gain_current)
2533 TGraph* hapd_graph =
new TGraph(i, HV, gain_current);
2534 string title = bomb_aval +
" " + g_i +
", chip " + chip_label;
2535 hapd_graph->SetTitle(title.c_str());
2536 hapd_graph->GetXaxis()->SetTitle(
"high voltage");
2537 hapd_graph->GetYaxis()->SetTitle(g_i.c_str());
2542 int ARICHDatabaseImporter::getChannelPosition(
const std::string&
XY,
const std::string& chip_2d,
int chipnum)
2544 int x = 100, y = 100;
2545 if (chip_2d ==
"A") {
2552 }
else if (chip_2d ==
"B") {
2559 }
else if (chip_2d ==
"C") {
2566 }
else if (chip_2d ==
"D") {
2575 if (
XY ==
"x") {
return x;}
2576 else if (
XY ==
"y") {
return y;}
2581 TH2F* ARICHDatabaseImporter::getBiasGraph(
const std::string& chip_2d,
const std::string& voltage_current,
int* chipnum,
2584 string name =
"bias " + voltage_current +
", chip " + chip_2d;
2585 TH2F* bias2d =
new TH2F(
"bias2d", name.c_str(), 6, 0, 6, 6, 0, 6);
2586 for (
int XYname = 0; XYname < 6; XYname++) {
2587 bias2d->GetXaxis()->SetBinLabel(XYname + 1, to_string(XYname).c_str());
2588 bias2d->GetYaxis()->SetBinLabel(XYname + 1, to_string(6 * XYname).c_str());
2590 for (
int XY = 0;
XY < 36;
XY++) {
2592 int y = 0 + chipnum[
XY];
2597 bias2d->SetBinContent(x, y, bias_v_i[
XY]);
2599 bias2d->SetDirectory(0);
2603 void ARICHDatabaseImporter::exportHapdInfo()
2607 elements.getEntries();
2609 for (
const auto& element : elements) {
2610 B2INFO(
"Serial = " << element.getSerialNumber() <<
"; HV = " << element.getHighVoltage() <<
"; qe400 = " <<
2611 element.getQuantumEfficiency400());
2612 for (
int n = 0; n < 4; n++) {
2614 B2INFO(
"biasV(chip" << n <<
") = " << newelement->
getBiasVoltage());
2625 void ARICHDatabaseImporter::importHapdQE()
2628 TClonesArray hapdQEConstants(
"Belle2::ARICHHapdQE");
2632 for (
const string& inputFile : m_inputFilesHapdQE) {
2634 TFile* f = TFile::Open(inputFile.c_str(),
"READ");
2636 int size = inputFile.length();
2637 string hapdSerial = inputFile.substr(size - 11, 6);
2641 TIter next(f->GetListOfKeys());
2643 while ((key = (TKey*)next())) {
2645 string strime = key->GetName();
2647 if (strime.compare(0, 11,
"hqe2d_pixel") == 0) {
2648 qe2D = (TH2F*)f->Get(strime.c_str());
2649 qe2D->SetTitle(
"quantum efficiency");
2650 qe2D->SetName(
"QE");
2651 qe2D->SetDirectory(0);
2654 else { B2INFO(
"Key name does not match 'hqe2d_pixel'!"); }
2664 Database::Instance().storeData(
"ARICHHapdQE", &hapdQEConstants, m_iov);
2668 void ARICHDatabaseImporter::exportHapdQE()
2671 elements.getEntries();
2672 gROOT->SetBatch(kTRUE);
2675 for (
const auto& element : elements) {
2676 B2INFO(
" SN = " << element.getHapdSerialNumber());
2677 TH2F* qe2d = element.getQuantumEfficiency2D();
2678 TFile file(
"QEhists.root",
"update");
2685 void ARICHDatabaseImporter::printBiasVoltagesForHapdChip(
const std::string& serialNumber)
2691 elements.getEntries();
2693 for (
const auto& element : elements) {
2694 if (element.getHapdSerial() == serialNumber) {
2695 TGraph* avalgain = element.getAvalancheGain();
2720 TGraph* gainnew =
new TGraph(avalgain->GetN());
2721 double xpoint, ypoint;
2722 for (
int j = 0; j < avalgain->GetN(); j++) {
2723 avalgain->GetPoint(j, xpoint, ypoint);
2724 gainnew->SetPoint(j, ypoint, xpoint);
2726 B2INFO(
"serial#-chip = " << element.getHapdSerial() <<
"-" << element.getChipLabel() <<
"; " <<
"V(gain=40) = " << (
int)(
2727 gainnew->Eval(40) + 0.5));
2732 void ARICHDatabaseImporter::printMyParams(
const std::string& aeroSerialNumber)
2734 map<string, float> aerogelParams = ARICHDatabaseImporter::getAerogelParams(aeroSerialNumber);
2736 B2INFO(
"SN = " << aeroSerialNumber <<
"; n = " << aerogelParams.find(
"refractiveIndex")->second <<
"; transLen = " <<
2737 aerogelParams.find(
"transmissionLength")->second <<
"; thickness = " << aerogelParams.find(
"thickness")->second);
2741 std::map<std::string, float> ARICHDatabaseImporter::getAerogelParams(
const std::string& aeroSerialNumber)
2747 std::map<std::string, float> aerogelParams;
2749 elements.getEntries();
2750 for (
const auto& element : elements) {
2751 if ((element.getAerogelSN()) == aeroSerialNumber) {
2753 {
"refractiveIndex", element.getAerogelRefractiveIndex() },
2754 {
"transmissionLength", element.getAerogelTransmissionLength() },
2755 {
"thickness", element.getAerogelThickness() }
2759 return aerogelParams;
2762 void ARICHDatabaseImporter::importFEBoardInfo()
2768 TClonesArray febConstants(
"Belle2::ARICHFEBoardInfo");
2772 for (
const auto& febinfo : content.getNodes(
"febasic")) {
2773 int febSN = (float) febinfo.getInt(
"sn");
2774 string asic1 = febinfo.getString(
"asic1");
2775 string asic2 = febinfo.getString(
"asic2");
2776 string asic3 = febinfo.getString(
"asic3");
2777 string asic4 = febinfo.getString(
"asic4");
2778 string delivery = febinfo.getString(
"delivered");
2779 string sentKEK = febinfo.getString(
"sentKEK");
2781 if (delivery.size() != 10) cout <<
"feb sn " << febSN <<
" check delivery time!" << endl;
2783 string year = delivery.substr(6, 4);
2784 delivery = febinfo.getString(
"delivered");
2785 string month = delivery.substr(3, 2);
2786 delivery = febinfo.getString(
"delivered");
2787 string day = delivery.substr(0, 2);
2789 int deliveryINT = atoi((year + month + day +
"u").c_str());
2790 TTimeStamp deliverytime(deliveryINT, 0u, 0u);
2792 string location =
"";
2793 if (!sentKEK.empty()) location =
"KEK";
2799 febConst->setAsicPosition(0, asic1);
2800 febConst->setAsicPosition(1, asic2);
2801 febConst->setAsicPosition(2, asic3);
2802 febConst->setAsicPosition(3, asic4);
2803 febConst->setTimeStamp(deliverytime);
2804 febConst->setFEBoardLocation(location);
2808 for (
const auto& element : elementsAsic) {
2809 if (element.getAsicID() == asic1) {
2811 febConst->setAsicInfo(0, &elementValue);
2813 if (element.getAsicID() == asic2) {
2815 febConst->setAsicInfo(1, &elementValue);
2817 if (element.getAsicID() == asic3) {
2819 febConst->setAsicInfo(2, &elementValue);
2821 if (element.getAsicID() == asic4) {
2823 febConst->setAsicInfo(3, &elementValue);
2831 Database::Instance().storeData(
"ARICHFEBoardInfo", &febConstants, m_iov);
2834 void ARICHDatabaseImporter::exportFEBoardInfo()
2837 elements.getEntries();
2839 for (
const auto& element : elements) {
2840 B2INFO(
"Feb sn = " << element.getFEBoardSerial());
2841 for (
int i = 0; i < 4; i++) {
2842 B2INFO(
"ASIC " << i <<
" = " << element.getAsicPosition(i));
2848 void ARICHDatabaseImporter::importModuleTest(
const std::string& mypath,
const std::string& HVtest)
2853 if (HVtest ==
"no") path =
"/ArichData/AllData/moduletest";
2854 else if (HVtest ==
"yes") path =
"/ArichData/AllData/moduletestHV";
2855 else B2INFO(
"Check HVB test parameter!");
2860 TClonesArray moduleConstants(
"Belle2::ARICHModuleTest");
2864 for (
const auto& moduletest : content.getNodes(
"module")) {
2865 int febSN = (float) moduletest.getInt(
"febserial");
2866 string hapdSN = moduletest.getString(
"hapdserial");
2868 if (HVtest ==
"yes") hvbSN = (float) moduletest.getInt(
"hvbserial");
2869 int run = moduletest.getInt(
"run");
2870 int runposition = moduletest.getInt(
"runposition");
2871 int isok = moduletest.getInt(
"isok");
2873 if (isok == 1) isOK =
true;
2874 string comment = moduletest.getString(
"comment");
2876 vector<int> deadChannels;
2878 if (HVtest ==
"no") {
2879 auto ids = ARICHTools::StringToVector::convert<ARICHTools::ModuleID_t>(moduletest.getString(
"dead"),
',');
2880 deadChannels.reserve(ids.size());
2881 for (
const auto& rID : ids)
2882 deadChannels.emplace_back(rID.getNumbering());
2887 if (HVtest ==
"yes") {
2888 deadChannels = ARICHTools::StringToVector::convert<int>(moduletest.getString(
"dead"),
',');
2891 B2INFO(
"Dead channels: ");
2892 printContainer(deadChannels);
2894 TGraph* guardBias_th = 0;
2895 TGraph* chipVdiff_th[4] = {0};
2896 TGraph* chipLeak_th[4] = {0};
2899 TGraph* guardBias_2Dx = 0;
2900 TGraph* chipVdiff_2Dx[4] = {0};
2901 TGraph* chipLeak_2Dx[4] = {0};
2904 TGraph* guardBias_2Dy = 0;
2905 TGraph* chipVdiff_2Dy[4] = {0};
2906 TGraph* chipLeak_2Dy[4] = {0};
2916 if (run < 10) runStr =
"000" + to_string(run);
2917 if ((run > 9) && (run < 100)) runStr =
"00" + to_string(run);
2918 if (run > 99) runStr =
"0" + to_string(run);
2919 TFile* f = TFile::Open((mypath + runStr +
"/" + runStr +
"_" + hapdSN +
"_out.root").c_str(),
"READ");
2922 TIter next(f->GetListOfKeys());
2924 while ((key = (TKey*)next())) {
2926 string strime = key->GetName();
2928 if (strime.find(
"Guard") != string::npos) {
2929 if (strime.find(
"_T_0") != string::npos) {
2930 guardBias_th = (TGraph*)f->Get(strime.c_str());
2932 if (strime.find(
"_T_1") != string::npos) {
2933 guardBias_2Dx = (TGraph*)f->Get(strime.c_str());
2935 if (strime.find(
"_T_2") != string::npos) {
2936 guardBias_2Dy = (TGraph*)f->Get(strime.c_str());
2940 if (strime.find(
"BiasDifference") != string::npos) {
2941 for (
int i = 0; i < 4; i++) {
2942 if (strime.find((
"CHIP_" + to_string(i) +
"_T_0").c_str()) != string::npos) {
2943 chipVdiff_th[i] = (TGraph*)f->Get(strime.c_str());
2945 if (strime.find((
"CHIP_" + to_string(i) +
"_T_1").c_str()) != string::npos) {
2946 chipVdiff_2Dx[i] = (TGraph*)f->Get(strime.c_str());
2948 if (strime.find((
"CHIP_" + to_string(i) +
"_T_2").c_str()) != string::npos) {
2949 chipVdiff_2Dy[i] = (TGraph*)f->Get(strime.c_str());
2954 if (strime.find(
"LeakageCurrent") != string::npos) {
2955 for (
int i = 0; i < 4; i++) {
2956 if (strime.find((
"CHIP_" + to_string(i) +
"_T_0").c_str()) != string::npos) {
2957 chipLeak_th[i] = (TGraph*)f->Get(strime.c_str());
2959 if (strime.find((
"CHIP_" + to_string(i) +
"_T_1").c_str()) != string::npos) {
2960 chipLeak_2Dx[i] = (TGraph*)f->Get(strime.c_str());
2962 if (strime.find((
"CHIP_" + to_string(i) +
"_T_2").c_str()) != string::npos) {
2963 chipLeak_2Dy[i] = (TGraph*)f->Get(strime.c_str());
2968 if (strime.find(
"HV") != string::npos) {
2969 if (strime.find(
"_T_0") != string::npos) {
2970 HV_th = (TGraph*)f->Get(strime.c_str());
2972 if (strime.find(
"_T_1") != string::npos) {
2973 HV_2Dx = (TGraph*)f->Get(strime.c_str());
2975 if (strime.find(
"_T_2") != string::npos) {
2976 HV_2Dy = (TGraph*)f->Get(strime.c_str());
2980 if (strime.find(
"Gain_1D") != string::npos) {
2981 gain = (TH1F*)f->Get(strime.c_str());
2982 gain->SetDirectory(0);
2985 if (strime.find(
"Charge_2D") != string::npos) {
2986 charge = (TH2D*)f->Get(strime.c_str());
2987 charge->SetDirectory(0);
2990 if (strime.find(
"Threshold_2D") != string::npos) {
2991 th = (TH2D*)f->Get(strime.c_str());
2992 th->SetDirectory(0);
2995 if (strime.find(
"Scan_2D_X") != string::npos) {
2996 scanX = (TH2D*)f->Get(strime.c_str());
2997 scanX->SetDirectory(0);
3000 if (strime.find(
"Scan_2D_Y") != string::npos) {
3001 scanY = (TH2D*)f->Get(strime.c_str());
3002 scanY->SetDirectory(0);
3008 auto* moduleConst =
static_cast<ARICHModuleTest*
>(moduleConstants[module]);
3010 moduleConst->setHapdSN(hapdSN);
3011 moduleConst->setRun(run);
3012 moduleConst->setRunPosition(runposition);
3013 moduleConst->setOK(isOK);
3014 moduleConst->setDeadChs(deadChannels);
3015 moduleConst->setComment(comment);
3016 moduleConst->setGuardBiasTH(guardBias_th);
3017 moduleConst->setHighVoltageTH(HV_th);
3018 moduleConst->setGuardBias2Dx(guardBias_2Dx);
3019 moduleConst->setHighVoltage2Dx(HV_2Dx);
3020 moduleConst->setGuardBias2Dy(guardBias_2Dy);
3021 moduleConst->setHighVoltage2Dy(HV_2Dy);
3022 moduleConst->setGain(gain);
3023 moduleConst->setChargeScan(charge);
3024 moduleConst->setTresholdScan(th);
3025 moduleConst->setLaserScanX(scanX);
3026 moduleConst->setLaserScanY(scanY);
3028 for (
int i = 0; i < 4; i++) {
3029 moduleConst->setChipVdiffTH(i, chipVdiff_th[i]);
3030 moduleConst->setChipLeakTH(i, chipLeak_th[i]);
3031 moduleConst->setChipVdiff2Dx(i, chipVdiff_2Dx[i]);
3032 moduleConst->setChipLeak2Dx(i, chipLeak_2Dx[i]);
3033 moduleConst->setChipVdiff2Dy(i, chipVdiff_2Dy[i]);
3034 moduleConst->setChipLeak2Dy(i, chipLeak_2Dy[i]);
3036 if (HVtest ==
"yes") moduleConst->setHvbSN(hvbSN);
3039 B2INFO(
"module no " << module - 1 <<
" saved to DB. HAPD SN = " << hapdSN <<
", FEB SN = " << febSN);
3044 if (HVtest ==
"no") Database::Instance().storeData(
"ARICHModuleTest", &moduleConstants, m_iov);
3045 if (HVtest ==
"yes") Database::Instance().storeData(
"ARICHModuleTestHV", &moduleConstants, m_iov);
3048 void ARICHDatabaseImporter::exportModuleTest(
const std::string& HVtest)
3051 if (HVtest ==
"no") {
3053 elements.getEntries();
3054 for (
const auto& element : elements) {
3055 B2INFO(
"Feb sn = " << element.getFebSN() <<
", hapd sn = " << element.getHapdSN() <<
", run = " << element.getRun() <<
3056 ", run position = " << element.getRunPosition() <<
", module is ok = " << element.getOK() <<
", comment = " <<
3057 element.getComment());
3058 for (
int i = 0; i < element.getDeadChsSize(); i++) {
3059 B2INFO(
"dead channel = " << element.getDeadCh(i) <<
" (hapd mapping)");
3064 if (HVtest ==
"yes") {
3066 elements.getEntries();
3067 for (
const auto& element : elements) {
3068 B2INFO(
"Feb sn = " << element.getFebSN() <<
", hapd sn = " << element.getHapdSN() <<
", hvb sn = " << element.getHvbSN() <<
3069 ", run = " << element.getRun() <<
", run position = " << element.getRunPosition() <<
", module is ok = " << element.getOK() <<
3070 ", comment = " << element.getComment());
3071 for (
int i = 0; i < element.getDeadChsSize(); i++) {
3072 B2INFO(
"dead channel = " << element.getDeadCh(i) <<
" (asic mapping)");
3078 void ARICHDatabaseImporter::importSensorModuleInfo()
3083 TClonesArray moduleInfoConstants(
"Belle2::ARICHSensorModuleInfo");
3088 for (
const auto& sensor : content.getNodes(
"position")) {
3089 int febSerial = sensor.getInt(
"febserial");
3090 string hapdSerial = sensor.getString(
"hapdserial");
3091 int id = sensor.getInt(
"moduleID");
3092 int hvSerial = sensor.getInt(
"HVserial");
3098 moduleInfoConst->setFEBserial(febSerial);
3099 moduleInfoConst->setHAPDserial(hapdSerial);
3100 moduleInfoConst->setHVboardID(hvSerial);
3104 for (
const auto& element : elementsHapd) {
3105 if (element.getSerialNumber() == hapdSerial) {
3107 moduleInfoConst->setHapdID(&elementValue);
3113 for (
const auto& element : elementsFeb) {
3114 if (element.getFEBoardSerial() == febSerial) {
3116 moduleInfoConst->setFEBoardID(&elementValue);
3122 for (
const auto& element : elementsModule) {
3123 if (element.getFebSN() == febSerial) {
3125 moduleInfoConst->setModuleTest(&elementValue);
3133 Database::Instance().storeData(
"ARICHSensorModuleInfo", &moduleInfoConstants, m_iov);
3137 void ARICHDatabaseImporter::importSensorModuleMap()
3143 TClonesArray moduleMapConstants(
"Belle2::ARICHSensorModuleMap");
3148 for (
const auto& sensor : content.getNodes(
"position")) {
3149 int sextant = sensor.getInt(
"sector");
3150 int ring = sensor.getInt(
"ring");
3151 int column = sensor.getInt(
"column");
3152 int id = sensor.getInt(
"moduleID");
3158 moduleMapConst->setSensorModuleRingID(ring);
3159 moduleMapConst->setSensorModuleColumnID(column);
3160 moduleMapConst->setSensorGlobalID(
id);
3164 for (
const auto& element : elementsModule) {
3165 if (element.getSensorModuleID() ==
id) {
3167 moduleMapConst->setSensorModuleId(&elementValue);
3175 Database::Instance().storeData(
"ARICHSensorModuleMap", &moduleMapConstants, m_iov);
3178 void ARICHDatabaseImporter::exportSensorModuleMap()
3181 elements.getEntries();
3183 for (
const auto& element : elements) {
3184 B2INFO(
"Sextant = " << element.getSensorModuleSextantID() <<
", ring = " << element.getSensorModuleRingID() <<
", column = " <<
3185 element.getSensorModuleColumnID());
3192 for (
int i = 0; i < 4; i++) {
3194 B2INFO(
"Hapd Serial = " << newestelement->
getHapdSerial() <<
"; chip = " << newestelement->
getChipLabel() <<
"; gain = " <<
3200 void ARICHDatabaseImporter::exportSensorModuleMapInfo(
int number)
3203 elements.getEntries();
3205 for (
const auto& element : elements) {
3208 B2INFO(
"Sextant = " << element.getSensorModuleSextantID() <<
", ring = " << element.getSensorModuleRingID() <<
", column = " <<
3209 element.getSensorModuleColumnID());
3215 for (
int i = 0; i < 4; i++) {
3217 B2INFO(
"Hapd Serial = " << newestelement->
getHapdSerial() <<
"; chip = " << newestelement->
getChipLabel() <<
"; gain = " <<
3223 void ARICHDatabaseImporter::importMagnetTest()
3228 TClonesArray magnetConstants(
"Belle2::ARICHMagnetTest");
3233 for (
const auto& module : content.getNodes(
"module")) {
3236 auto* magnetConst =
static_cast<ARICHMagnetTest*
>(magnetConstants[num]);
3238 int snint = module.getInt(
"hapdID");
3239 if (snint < 5000) sn =
"KA";
3242 sprintf(hapdID,
"%s%04d", sn.c_str(), snint);
3243 magnetConst->setSerialNumber(hapdID);
3245 vector<float> deadtimes;
3246 for (
const auto& time : module.getNodes(
"deadtime/measurement")) {
3247 if (time.getString(
".") !=
"-") {
3248 float deadtime = (float) time.getDouble(
".");
3249 deadtimes.push_back(deadtime);
3252 magnetConst->setDeadTime(deadtimes);
3254 if (module.getString(
"lowerA") !=
"-") magnetConst->setDeadTimeLowerA((
float) module.getDouble(
"lowerA"));
3255 if (module.getString(
"lowerB") !=
"-") magnetConst->setDeadTimeLowerB((
float) module.getDouble(
"lowerB"));
3256 if (module.getString(
"lowerC") !=
"-") magnetConst->setDeadTimeLowerC((
float) module.getDouble(
"lowerC"));
3257 if (module.getString(
"lowerD") !=
"-") magnetConst->setDeadTimeLowerD((
float) module.getDouble(
"lowerD"));
3259 bool getter_reactivation = module.getBool(
"getter");
3260 string comment = module.getString(
"comment");
3261 magnetConst->setGetter(getter_reactivation);
3262 magnetConst->setComment(comment);
3268 Database::Instance().storeData(
"ARICHMagnetTest", &magnetConstants, m_iov);
3271 void ARICHDatabaseImporter::exportMagnetTest()
3275 elements.getEntries();
3277 for (
const auto& element : elements) {
3278 string getter =
"no";
3279 if (element.getGetter() == 1) getter =
"yes";
3280 B2INFO(
"SN = " << element.getSerialNumber() <<
"; after getter reactivation? " << getter);
3281 for (
int i = 0; i < element.getDeadTimeSize();
3282 i++) B2INFO(
"dead time = " << element.getDeadTime(i) <<
" (" << (i + 1) <<
". measurement)");
3283 if (element.getDeadTimeLowerA() > 0.) B2INFO(
"lower voltage on chip A = " << element.getDeadTimeLowerA());
3284 if (element.getDeadTimeLowerB() > 0.) B2INFO(
"lower voltage on chip B = " << element.getDeadTimeLowerB());
3285 if (element.getDeadTimeLowerC() > 0.) B2INFO(
"lower voltage on chip C = " << element.getDeadTimeLowerC());
3286 if (element.getDeadTimeLowerD() > 0.) B2INFO(
"lower voltage on chip D = " << element.getDeadTimeLowerD());
3287 B2INFO(
"comment = " << element.getComment());
3291 void ARICHDatabaseImporter::exportAll()
3293 ARICHDatabaseImporter::exportAerogelInfo();
3294 ARICHDatabaseImporter::exportHapdQE();
3295 ARICHDatabaseImporter::exportModuleTest(
"no");
3296 ARICHDatabaseImporter::exportModuleTest(
"yes");
3297 ARICHDatabaseImporter::exportFEBoardInfo();
3298 ARICHDatabaseImporter::exportFebTest();
3299 ARICHDatabaseImporter::exportSensorModuleMap();
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
Return Aerogel Version.
float getAerogelRefractiveIndex() const
Return Refractive Index of Aerogel.
std::string getAerogelSN() const
Return Aerogel Serial number.
float getAerogelThickness() const
Return Aerogel Thickness.
float getAerogelTransmissionLength() const
Return 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.
void setAsicID(const std::string &id)
Set Asic Identifier.
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 pinID, int connectionID, int innerID, const std::string &type)
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.
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.
Front End Electronics Boards.
void setFEBoardSerial(int serial)
Set Front End Board Identifier.
The Class for ARICH Aerogel Parameters.
void setFebSerial(int serial)
Set FEB serial number.
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.
void setAerogelPlane(const ARICHGeoAerogelPlane &aerogelPlane)
Set geometry configuration of aerogel plane.
void setMasterVolume(const ARICHGeoMasterVolume &masterVolume)
Set master volume geometry configuration.
const ARICHGeoAerogelPlane & getAerogelPlane() const
Get geometry configuration of aerogel plane.
const ARICHGeoSupport & getSupportStructure() const
Get ARICH support structure geometry configuration.
const ARICHGeoMasterVolume & getMasterVolume() const
Get ARICH master volume 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
Return Chip label.
int getGain() const
Return Chip Gain at Operational Voltage.
void setHapdSerial(const std::string &serial)
Set Hapd Serial number.
std::string getHapdSerial() const
Return Hapd Serial number.
int getBiasVoltage() const
Return Chip Bias Voltage.
Contains manufacturer data of the photo sensor - HAPD.
std::string getSerialNumber() const
Return HAPD Serial Number.
float getHighVoltage() const
Return operational High Voltage.
ARICHHapdChipInfo * getHapdChipInfo(unsigned int i) const
Return HapdChipInfo of the chip i.
float getQuantumEfficiency400() const
Return quantum efficiency at 400 nm.
Contains manufacturer data of the photo sensor - HAPD.
Contains manufacturer data of the photo sensor - HAPD.
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.
The Class for ARICH Aerogel Parameters.
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="Parmeters 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 SensorModule 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 absorbtion 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.
Class for accessing arrays of objects in the database.
int getEntries() const
Get the number of objects in the array.
bool import(const IntervalOfValidity &iov)
Import the object to database.
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.
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.
GearDir is the basic class used for accessing the parameter store.
virtual std::string getString(const std::string &path="") const noexcept(false) override
Get the parameter path as a string.
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.
double getAngle(const std::string &path="") const noexcept(false)
Get the parameter path as a double converted to the standard angle unit.
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.
double getDouble(const std::string &path="") const noexcept(false)
Get the parameter path as a double.
double getLength(const std::string &path="") const noexcept(false)
Get the parameter path as a double converted to the standard length unit.
std::vector< GearDir > getNodes(const std::string &path="") const
Get vector of GearDirs which point to all the nodes the given path evaluates to.
TH1F * hapd[6]
histogram of hits for each hapd
Abstract base class for different kinds of events.
Structure which holds apexes of the tessellation volumes.