10 #include <cdc/calibration/CDCDatabaseImporter.h>
13 #include <framework/database/DBArray.h>
14 #include <framework/database/DBObjPtr.h>
15 #include <framework/database/IntervalOfValidity.h>
16 #include <framework/database/DBImportArray.h>
17 #include <framework/database/DBImportObjPtr.h>
20 #include <framework/logging/Logger.h>
22 #include <framework/utilities/Utils.h>
25 #include <cdc/dataobjects/WireID.h>
26 #include <cdc/dbobjects/CDCChannelMap.h>
27 #include <cdc/dbobjects/CDCTimeZeros.h>
28 #include <cdc/dbobjects/CDCBadWires.h>
29 #include <cdc/dbobjects/CDCPropSpeeds.h>
30 #include <cdc/dbobjects/CDCTimeWalks.h>
31 #include <cdc/dbobjects/CDCXtRelations.h>
32 #include <cdc/dbobjects/CDCSpaceResols.h>
33 #include <cdc/dbobjects/CDCFudgeFactorsForSigma.h>
34 #include <cdc/dbobjects/CDCDisplacement.h>
35 #include <cdc/dbobjects/CDCAlignment.h>
36 #include <cdc/dbobjects/CDCADCDeltaPedestals.h>
37 #include <cdc/dbobjects/CDCFEElectronics.h>
38 #include <cdc/dbobjects/CDCEDepToADCConversions.h>
39 #include <cdc/dbobjects/CDCCorrToThresholds.h>
40 #include <cdc/dbobjects/CDCWireHitRequirements.h>
41 #include <cdc/dbobjects/CDCCrossTalkLibrary.h>
42 #include <cdc/dbobjects/CDClayerTimeCut.h>
43 #include <cdc/geometry/CDCGeometryPar.h>
45 #include <TTreeReader.h>
50 #include <boost/iostreams/filtering_stream.hpp>
51 #include <boost/iostreams/device/file.hpp>
52 #include <boost/iostreams/filter/gzip.hpp>
54 #include <boost/property_tree/ptree.hpp>
55 #include <boost/property_tree/json_parser.hpp>
61 m_firstExperiment(fexp), m_firstRun(frun), m_lastExperiment(lexp), m_lastRun(lrun)
72 stream.open(fileName.c_str());
74 B2ERROR(
"openFile: " << fileName <<
" *** failed to open");
77 B2INFO(fileName <<
": open for reading");
88 stream >> iL >> iC >> t0;
90 if (iL < m_firstLayerOffset) {
94 if (stream.eof())
break;
104 if (nRead != m_nSenseWires) B2FATAL(
"#lines read-in (=" << nRead <<
") is inconsistent with total #sense wires (=" << m_nSenseWires
108 m_lastExperiment, m_lastRun);
111 B2INFO(
"Time zero table imported to database.");
118 std::ifstream stream;
119 stream.open(fileName.c_str());
121 B2ERROR(
"openFile: " << fileName <<
" *** failed to open");
124 B2INFO(fileName <<
": open for reading");
134 while (!stream.eof()) {
135 stream >> isl >> il >> iw >> iBoard >> iCh;
137 if (il < m_firstLayerOffset) {
146 m_lastExperiment, m_lastRun);
150 B2INFO(
"Channel map imported to database.");
157 std::ifstream stream;
158 stream.open(fileName.c_str());
160 B2ERROR(
"openFile: " << fileName <<
" *** failed to open");
163 B2INFO(fileName <<
": open for reading");
168 short ib, width, delay, aTh, tThmV;
171 while (stream >> ib) {
173 stream >> width >> delay >> aTh >> tThmV;
177 cf.
appendNew(ib, width, delay, aTh, tThmV);
182 m_lastExperiment, m_lastRun);
186 B2INFO(
"FEEElectronics imported to database.");
192 std::ifstream stream;
193 stream.open(fileName.c_str());
195 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
198 B2INFO(fileName <<
": open for reading");
203 unsigned short paramMode(0), nParams(0);
204 stream >> paramMode >> nParams;
205 etoa->setParamMode(paramMode);
207 unsigned short groupId(0);
209 B2INFO(paramMode <<
" " << nParams <<
" " << groupId);
210 if (groupId > 1) B2FATAL(
"invalid groupId now !");
211 etoa->setGroupID(groupId);
213 unsigned short id = 0;
214 std::vector<float> coeffs(nParams);
217 while (stream >>
id) {
218 for (
unsigned short i = 0; i < nParams; ++i) {
222 if (groupId == 0 and
id < m_superLayerOffset) {
225 if (groupId == 1 and
id < m_firstLayerOffset) {
229 etoa->setParams(
id, coeffs);
233 unsigned short nId = c_nSuperLayers;
235 nId = c_maxNSenseLayers;
236 }
else if (groupId == 2) {
239 if (nRead != nId) B2FATAL(
"#lines read-in (=" << nRead <<
") is not equal #ids (=" << nId <<
") !");
242 m_lastExperiment, m_lastRun);
244 B2INFO(
"EDep-toADC table imported to database.");
250 std::ifstream stream;
251 stream.open(fileName.c_str());
253 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
256 B2INFO(fileName <<
": open for reading");
261 uint iL(0), iC(0), nRead(0);
265 stream >> iL >> iC >> effi;
266 if (stream.eof())
break;
268 if (iL < m_firstLayerOffset) {
273 bw->setWire(
WireID(iL, iC), effi);
280 if (nRead >
static_cast<int>(m_nSenseWires)) B2FATAL(
"#lines read-in (=" << nRead <<
") is larger than #sense wires (=" <<
281 m_nSenseWires <<
") !");
284 m_lastExperiment, m_lastRun);
286 B2INFO(
"BadWire table imported to database.");
292 std::ifstream stream;
293 stream.open(fileName.c_str());
295 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
298 B2INFO(fileName <<
": open for reading");
303 uint iCL(0), nRead(0);
307 stream >> iCL >> speed;
308 if (stream.eof())
break;
310 if (iCL < m_firstLayerOffset) {
316 ps->setSpeed(iCL, speed);
324 if (nRead != c_maxNSenseLayers) B2FATAL(
"#lines read-in (=" << nRead <<
") is no equal #sense layers (=" << c_maxNSenseLayers <<
328 m_lastExperiment, m_lastRun);
330 B2INFO(
"PropSpeed table imported to database.");
336 std::ifstream stream;
337 stream.open(fileName.c_str());
339 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
342 B2INFO(fileName <<
": open for reading");
347 uint iCL(0), nRead(0);
351 stream >> iCL >> param;
352 if (stream.eof())
break;
354 if (iCL < m_firstLayerOffset) {
359 cr->setParam(iCL, param);
363 if (nRead != c_maxNSenseLayers) B2FATAL(
"#lines read-in (=" << nRead <<
") is not equal to #sense layers (=" << c_maxNSenseLayers <<
367 m_lastExperiment, m_lastRun);
369 B2INFO(
"CorrToThreshold table imported to database.");
375 std::ifstream stream;
376 stream.open(fileName.c_str());
378 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
381 B2INFO(fileName <<
": open for reading");
386 unsigned short mode(0), nParams(0);
387 stream >> mode >> nParams;
388 tw->setTwParamMode(mode);
390 unsigned short iBoard(0);
391 std::vector<float> coeffs(nParams);
394 while (stream >> iBoard) {
395 for (
unsigned short i = 0; i < nParams; ++i) {
399 tw->setTimeWalkParams(iBoard, coeffs);
406 if (nRead != c_nBoards) B2FATAL(
"#lines read-in (=" << nRead <<
") is not equal #boards (=" << c_nBoards <<
") !");
409 m_lastExperiment, m_lastRun);
411 B2INFO(
"Time-walk coeff. table imported to database.");
423 boost::iostreams::filtering_istream ifs;
424 if ((fileName.rfind(
".gz") != string::npos) && (fileName.length() - fileName.rfind(
".gz") == 3)) {
425 ifs.push(boost::iostreams::gzip_decompressor());
427 ifs.push(boost::iostreams::file_source(fileName));
429 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
431 B2INFO(fileName <<
": open for reading");
433 const double degrad = M_PI / 180.;
434 const double raddeg = 180. / M_PI;
436 unsigned short nAlphaBins = 0;
437 if (ifs >> nAlphaBins) {
438 if (nAlphaBins == 0 || nAlphaBins > c_maxNAlphaPoints) B2FATAL(
"Fail to read alpha bins !");
440 B2FATAL(
"Fail to read alpha bins !");
442 std::array<float, 3> alpha3;
443 for (
unsigned short i = 0; i < nAlphaBins; ++i) {
444 for (
unsigned short j = 0; j < 3; ++j) {
448 xt->setAlphaBin(alpha3);
452 unsigned short nThetaBins = 0;
453 if (ifs >> nThetaBins) {
454 if (nThetaBins == 0 || nThetaBins > c_maxNThetaPoints) B2FATAL(
"Fail to read theta bins !");
456 B2FATAL(
"Fail to read theta bins !");
458 std::array<float, 3> theta3;
460 for (
unsigned short i = 0; i < nThetaBins; ++i) {
461 for (
unsigned short j = 0; j < 3; ++j) {
465 xt->setThetaBin(theta3);
478 short xtParamMode, np;
479 unsigned short iCL, iLR;
480 const unsigned short npx = c_nXTParams - 1;
482 double theta, alpha, dummy1;
485 ifs >> xtParamMode >> np;
486 if (xtParamMode < 0 || xtParamMode > 1) B2FATAL(
"Invalid xt param mode read !");
487 if (np <= 0 || np > npx) B2FATAL(
"No. of xt-params. outside limits !");
489 xt->setXtParamMode(xtParamMode);
491 const double epsi = 0.1;
494 ifs >> theta >> alpha >> dummy1 >> iLR;
495 for (
int i = 0; i < np; ++i) {
501 if (iCL < m_firstLayerOffset) {
508 for (
unsigned short i = 0; i < nAlphaBins; ++i) {
509 if (fabs(alpha - xt->getAlphaBin(i)[2]*raddeg) < epsi) {
514 if (ialpha < 0) B2FATAL(
"alphas in xt.dat are inconsistent !");
517 for (
unsigned short i = 0; i < nThetaBins; ++i) {
518 if (fabs(theta - xt->getThetaBin(i)[2]*raddeg) < epsi) {
523 if (itheta < 0) B2FATAL(
"thetas in xt.dat are inconsistent !");
526 std::vector<float> xtbuff;
527 for (
int i = 0; i < np; ++i) {
528 xtbuff.push_back(xtc[i]);
531 xt->setXtParams(iCL, iLR, ialpha, itheta, xtbuff);
535 boost::iostreams::close(ifs);
538 m_lastExperiment, m_lastRun);
540 B2INFO(
"XT table imported to database.");
550 ifs.open(fileName.c_str());
552 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
554 B2INFO(fileName <<
": open for reading");
556 const double degrad = M_PI / 180.;
557 const double raddeg = 180. / M_PI;
559 unsigned short nAlphaBins = 0;
560 if (ifs >> nAlphaBins) {
561 if (nAlphaBins == 0 || nAlphaBins > c_maxNAlphaPoints) B2FATAL(
"Fail to read alpha bins !");
563 B2FATAL(
"Fail to read alpha bins !");
565 std::array<float, 3> alpha3;
566 for (
unsigned short i = 0; i < nAlphaBins; ++i) {
567 for (
unsigned short j = 0; j < 3; ++j) {
571 sg->setAlphaBin(alpha3);
575 unsigned short nThetaBins = 0;
576 if (ifs >> nThetaBins) {
577 if (nThetaBins == 0 || nThetaBins > c_maxNThetaPoints) B2FATAL(
"Fail to read theta bins !");
579 B2FATAL(
"Fail to read theta bins !");
581 std::array<float, 3> theta3;
583 for (
unsigned short i = 0; i < nThetaBins; ++i) {
584 for (
unsigned short j = 0; j < 3; ++j) {
588 sg->setThetaBin(theta3);
593 short sgParamMode, np;
594 unsigned short iCL, iLR;
595 const unsigned short npx = c_nSigmaParams;
600 ifs >> sgParamMode >> np;
601 if (sgParamMode < 0 || sgParamMode > 1) B2FATAL(
"Invalid sigma param mode read !");
602 if (np <= 0 || np > npx) B2FATAL(
"No. of sgm-params. outside limits !");
604 sg->setSigmaParamMode(sgParamMode);
608 sg->setMaxSpaceResol(maxSigma);
610 const double epsi = 0.1;
613 ifs >> theta >> alpha >> iLR;
614 for (
int i = 0; i < np; ++i) {
620 if (iCL < m_firstLayerOffset) {
627 for (
unsigned short i = 0; i < nAlphaBins; ++i) {
628 if (fabs(alpha - sg->getAlphaBin(i)[2]*raddeg) < epsi) {
633 if (ialpha < 0) B2FATAL(
"alphas in sigma.dat are inconsistent !");
636 for (
unsigned short i = 0; i < nThetaBins; ++i) {
637 if (fabs(theta - sg->getThetaBin(i)[2]*raddeg) < epsi) {
642 if (itheta < 0) B2FATAL(
"thetas in sigma.dat are inconsistent !");
645 std::vector<float> sgbuff;
646 for (
int i = 0; i < np; ++i) {
647 sgbuff.push_back(sgm[i]);
650 sg->setSigmaParams(iCL, iLR, ialpha, itheta, sgbuff);
656 m_lastExperiment, m_lastRun);
658 B2INFO(
"Sigma table imported to database.");
664 std::ifstream stream;
665 stream.open(fileName.c_str());
667 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
670 B2INFO(fileName <<
": open for reading");
675 unsigned short groupId(0), nParams(0);
676 stream >> groupId >> nParams;
677 B2INFO(groupId <<
" " << nParams);
678 if (groupId != 0) B2FATAL(
"invalid groupId now !");
679 etoa->setGroupID(groupId);
681 unsigned short id = 0;
682 std::vector<float> coeffs(nParams);
685 while (stream >>
id) {
686 for (
unsigned short i = 0; i < nParams; ++i) {
690 etoa->setFactors(
id, coeffs);
694 unsigned short nId = 1;
695 if (nRead != nId) B2FATAL(
"#lines read-in (=" << nRead <<
") is not equal #ids (=" << nId <<
") !");
698 m_lastExperiment, m_lastRun);
700 B2INFO(
"Fudge factor table imported to database.");
709 boost::iostreams::filtering_istream ifs;
710 if ((fileName.rfind(
".gz") != string::npos) && (fileName.length() - fileName.rfind(
".gz") == 3)) {
711 ifs.push(boost::iostreams::gzip_decompressor());
713 ifs.push(boost::iostreams::file_source(fileName));
715 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
717 B2INFO(fileName <<
": open for reading");
723 double back[np], fwrd[np];
729 for (
int i = 0; i < np; ++i) {
732 for (
int i = 0; i < np; ++i) {
737 if (ifs.eof())
break;
739 if (iL < m_firstLayerOffset) {
746 TVector3 fwd(fwrd[0], fwrd[1], fwrd[2]);
747 TVector3 bwd(back[0], back[1], back[2]);
751 if (nRead != m_nSenseWires) B2FATAL(
"CDCDatabaseimporter::importDisplacement: #lines read-in (=" << nRead <<
752 ") is inconsistent with total #sense wires (=" << m_nSenseWires <<
") !");
755 boost::iostreams::close(ifs);
758 m_lastExperiment, m_lastRun);
760 B2INFO(
"Wire displasement table imported to database.");
768 boost::iostreams::filtering_istream ifs;
769 if ((fileName.rfind(
".gz") != string::npos) && (fileName.length() - fileName.rfind(
".gz") == 3)) {
770 ifs.push(boost::iostreams::gzip_decompressor());
772 ifs.push(boost::iostreams::file_source(fileName));
774 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
777 B2INFO(fileName <<
": open for reading");
784 double back[np], fwrd[np], tension;
789 for (
int i = 0; i < np; ++i) {
792 for (
int i = 0; i < np; ++i) {
796 if (ifs.eof())
break;
798 if (iL < m_firstLayerOffset) {
805 for (
int i = 0; i < np; ++i) {
816 if (nRead != m_nSenseWires) B2FATAL(
"CDCDatabaseimporter::importWirPosAlign: #lines read-in (=" << nRead <<
817 ") is inconsistent with total #sense wires (=" << m_nSenseWires <<
") !");
820 boost::iostreams::close(ifs);
823 m_lastExperiment, m_lastRun);
825 B2INFO(
"Wire alignment table imported to database.");
834 for (
const auto& cm : channelMaps) {
835 std::cout << cm.getISuperLayer() <<
" " << cm.getILayer()
836 <<
" " << cm.getIWire() <<
" "
837 << cm.getBoardID() <<
" " << cm.getBoardChannel() << std::endl;
845 for (
const auto& cf : fEElectronics) {
846 std::cout << cf.getBoardID() <<
" " << cf.getWidthOfTimeWindow() <<
" " << cf.getTrgDelay() <<
" " << cf.getADCThresh() <<
" " <<
847 cf.getTDCThreshInMV() << std::endl;
913 for (
const auto& disp : displacements) {
914 B2INFO(disp.getICLayer() <<
" " << disp.getIWire() <<
" "
915 << disp.getXBwd() <<
" " << disp.getYBwd() <<
" " << disp.getZBwd() <<
" "
916 << disp.getXFwd() <<
" " << disp.getYFwd() <<
" " << disp.getZFwd() <<
" " << disp.getTension());
935 std::ifstream stream;
936 stream.open(fileName.c_str());
937 if (!stream.is_open()) {
938 B2ERROR(
"openFile: " << fileName <<
" *** failed to open");
941 B2INFO(fileName <<
": open for reading");
956 stream >> iB >> iC >> ped;
958 if (stream.eof())
break;
961 B2FATAL(
"sample window is zero !");
963 dbPed->setSamplingWindow(sample);
965 dbPed->setPedestal(iB, iC, ped);
973 m_lastExperiment, m_lastRun);
976 B2INFO(
"ADC delta pedestal table imported to database.");
986 m_lastExperiment, m_lastRun);
989 B2INFO(
"ADC delta pedestal w/ zero imported to database.");
1003 boost::property_tree::ptree tree;
1008 B2INFO(
"Loading json file: " << jsonFileName);
1009 boost::property_tree::read_json(jsonFileName, tree);
1011 }
catch (boost::property_tree::ptree_error& e) {
1012 B2FATAL(
"Error when loading json file: " << e.what());
1019 m_lastExperiment, m_lastRun);
1020 dbWireHitReq.
import(iov);
1022 B2INFO(
"CDCWireHit requirements imported to database.");
1030 dbWireHitReq->dump();
1032 B2WARNING(
"DBObjPtr<CDCWireHitRequirements> not valid for the current run.");
1041 TFile fIn = TFile(rootFileName.c_str());
1042 TTreeReader reader(
"my_ttree", &fIn);
1043 TTreeReaderValue<UChar_t> Board(reader,
"Board");
1044 TTreeReaderValue<UChar_t> Channel(reader,
"Channel");
1045 TTreeReaderValue<Short_t> Asic_ADC0(reader,
"Asic_ADC0");
1046 TTreeReaderValue<Short_t> Asic_TDC0(reader,
"Asic_TDC0");
1047 TTreeReaderValue<Short_t> Asic_TOT0(reader,
"Asic_TOT0");
1048 TTreeReaderValue<Short_t> Asic_ADC1(reader,
"Asic_ADC1");
1049 TTreeReaderValue<Short_t> Asic_TDC1(reader,
"Asic_TDC1");
1050 TTreeReaderValue<Short_t> Asic_TOT1(reader,
"Asic_TOT1");
1051 TTreeReaderValue<Short_t> Asic_ADC2(reader,
"Asic_ADC2");
1052 TTreeReaderValue<Short_t> Asic_TDC2(reader,
"Asic_TDC2");
1053 TTreeReaderValue<Short_t> Asic_TOT2(reader,
"Asic_TOT2");
1054 TTreeReaderValue<Short_t> Asic_ADC3(reader,
"Asic_ADC3");
1055 TTreeReaderValue<Short_t> Asic_TDC3(reader,
"Asic_TDC3");
1056 TTreeReaderValue<Short_t> Asic_TOT3(reader,
"Asic_TOT3");
1057 TTreeReaderValue<Short_t> Asic_ADC4(reader,
"Asic_ADC4");
1058 TTreeReaderValue<Short_t> Asic_TDC4(reader,
"Asic_TDC4");
1059 TTreeReaderValue<Short_t> Asic_TOT4(reader,
"Asic_TOT4");
1060 TTreeReaderValue<Short_t> Asic_ADC5(reader,
"Asic_ADC5");
1061 TTreeReaderValue<Short_t> Asic_TDC5(reader,
"Asic_TDC5");
1062 TTreeReaderValue<Short_t> Asic_TOT5(reader,
"Asic_TOT5");
1063 TTreeReaderValue<Short_t> Asic_ADC6(reader,
"Asic_ADC6");
1064 TTreeReaderValue<Short_t> Asic_TDC6(reader,
"Asic_TDC6");
1065 TTreeReaderValue<Short_t> Asic_TOT6(reader,
"Asic_TOT6");
1066 TTreeReaderValue<Short_t> Asic_ADC7(reader,
"Asic_ADC7");
1067 TTreeReaderValue<Short_t> Asic_TDC7(reader,
"Asic_TDC7");
1068 TTreeReaderValue<Short_t> Asic_TOT7(reader,
"Asic_TOT7");
1070 while (reader.Next()) {
1082 UChar_t asicCh = *Channel % 8;
1083 Short_t ADC = record[asicCh].
ADC;
1084 dbCDCCrossTalkLibrary->addAsicRecord(asicCh, ADC, record);
1090 fIn.GetObject(
"ProbXTalk", prob);
1091 for (
size_t a = 1; a <= 8196; a += 1) {
1092 probs[a - 1] = prob->GetBinContent(a);
1095 dbCDCCrossTalkLibrary->setPCrossTalk(probs);
1097 dbCDCCrossTalkLibrary->dump(0);
1099 m_lastExperiment, m_lastRun);
1100 dbCDCCrossTalkLibrary.
import(iov);
1101 B2INFO(
"CDCCrossTalkLibrary requirements imported to database.");
1107 if (dbCDCCrossTalkLib.
isValid()) {
1108 dbCDCCrossTalkLib->dump(1);
1110 B2ERROR(
"DBObjPtr<CDCCrossTalkLibrary> not valid for the current run.");
1118 if (dbCDCCrossTalkLib.
isValid()) {
1121 B2INFO(
"Performing CDCCrossTalkLibrary checks");
1122 auto timer =
new Utils::Timer(
"CDCCrossTalkLibrary checks took");
1125 for (Short_t ADC = 0; ADC < 8196; ADC += 1) {
1126 for (Short_t channel = 0; channel < 48; channel += 1) {
1127 for (
size_t rep = 0; rep < 100; rep += 1) {
1128 auto xtalk = dbCDCCrossTalkLib->getLibraryCrossTalk(channel, 4999, ADC, 5, 0,
false);
1130 size += xtalk.size();
1134 B2INFO(
"CDCCrossTalkLibrary called " << counter <<
" times. Total number of cross talk hits " << size);
1140 Short_t ADC_spot_checks[5] = {2, 100, 500, 1000, 5000};
1141 for (
auto ADC : ADC_spot_checks) {
1142 B2INFO(
"CHECK ADC=" << ADC);
1144 size_t NRep = ADC < 50 ? 100 : 10;
1145 for (
size_t rep = 0; rep < NRep; rep += 1) {
1146 auto xtalk = dbCDCCrossTalkLib->getLibraryCrossTalk(0, 4999, ADC, 5, 0,
true);
1147 B2INFO(
"Size = " << xtalk.size());
1148 for (
auto [channel, rec] : xtalk) {
1149 B2INFO(
"Channel:" << channel <<
" TDC,ADC,TOT:" << rec.TDC <<
"," << rec.ADC <<
"," << rec.TOT);
1154 B2ERROR(
"DBObjPtr<CDCCrossTalkLibrary> not valid for the current run.");
1162 boost::property_tree::ptree tree;
1165 B2INFO(
"Loading json file: " << jsonFileName);
1166 boost::property_tree::read_json(jsonFileName, tree);
1167 }
catch (boost::property_tree::ptree_error& e) {
1168 B2FATAL(
"Error when loading json file: " << e.what());
1175 m_lastExperiment, m_lastRun);
1176 dbCDClayerTimeCut.
import(iov);
1177 B2INFO(
"dbCDClayerTimeCut imported to database.");
1183 if (dbCDClayerTimeCut.
isValid()) {
1184 dbCDClayerTimeCut->dump();
1186 B2WARNING(
"DBObjPtr<CDClayerTimeCut> not valid for the current run.");
1197 ifs.open(fileName.c_str());
1199 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
1202 B2INFO(fileName <<
": open for reading");
1209 double back[np], fwrd[np], tension;
1214 for (
int i = 0; i < np; ++i) {
1217 for (
int i = 0; i < np; ++i) {
1221 if (ifs.eof())
break;
1226 for (
int i = 0; i < np; ++i) {
1237 if (nRead != m_nSenseWires) B2FATAL(
"CDCDatabaseimporter::importWirPosMisalign: #lines read-in (=" << nRead <<
1238 ") is inconsistent with total #sense wires (=" << m_nSenseWires <<
") !");
1243 m_lastExperiment, m_lastRun);
1245 B2INFO(
"Wire misalignment table imported to database.");
static const baseType wireBwdZ
Wire Z position w.r.t. nominal on backward endplate.
static const baseType wireBwdY
Wire Y position w.r.t. nominal on backward endplate.
static const baseType wireFwdZ
Wire Z position w.r.t. nominal on forward endplate.
static const baseType wireFwdY
Wire Y position w.r.t. nominal on forward endplate.
static const baseType wireFwdX
Wire X position w.r.t. nominal on forward endplate.
static const baseType wireBwdX
Wire X position w.r.t. nominal on backward endplate.
static const baseType wireTension
Wire tension w.r.t. nominal (=50. ?)
void printFFactor()
Get the fudge factor table from the database and print it.
void printEDepToADC()
Get edep-to-adc params.
void importWirPosMisalign(std::string fileName)
Import wire misalignment table to the database.
void printTimeWalk()
Get the time-walk coeff.
void printSigma()
Get the sigma table from the database and print it.
void printDisplacement()
Get the displacement of wire position from the database and print it.
void printCDCWireHitRequirements() const
Get CDCWireHits cut values from the database and print them.
void printPropSpeed()
Get the propspeed table from the database and print it.
void importDisplacement(std::string fileName)
Import displacement of wire position to the database.
void importBadWire(std::string fileName)
Import badwire table to the data base.
void importADCDeltaPedestal()
Import ADC delta pedestal with all 0.
ushort m_superLayerOffset
Offset of first super layer in case some CDC super layers are removed.
void importFFactor(std::string fileName)
Import fudge factor table to the database.
void printCDClayerTimeCut() const
Print content of CDClayerTimeCut.
void printWirPosMisalign()
Get the wire misalignment table from the database and print it.
void importCDCCrossTalkLibrary(const std::string &rootFileName) const
Import crosstalk library prepared in rootFileName.
ushort m_nSenseWires
Number of sense wires in the CDC.
void printXT()
Get the xt table from the database and print it.
void importSigma(std::string fileName)
Import sigma table to the database.
void printChannelMap()
Get the channel map from the database and print it.
void printADCDeltaPedestal()
Get the ADC delta pedestal table from the database and print it.
void printBadWire()
Get the badwire table from the database and print it.
void importCDClayerTimeCut(const std::string &jsonFileName) const
import CDClayerTimeCut
void printTimeZero()
Get the t0 table from the database and print it.
void importPropSpeed(std::string fileName)
Import propspeed table to the database.
void importChannelMap(std::string fileName)
Import channel map to the data base.
void importCorrToThreshold(std::string fileName)
Import corrtothreshold to the data base.
void importEDepToADC(std::string fileName)
Import edep-to-adc params.
CDCDatabaseImporter()
Default constructor.
void printCDCCrossTalkLibrary() const
Print the content of the crosstalk library.
void importXT(std::string fileName)
Import xt table to the database.
void printFEElectronics()
Get FEE params.
void printWirPosAlign()
Get the wire alignment table from the database and print it.
void testCDCCrossTalkLibrary(bool spotChecks=false) const
Do some basic testing of the CDCCrossTalkLibrary.
void importFEElectronics(std::string fileName)
Import FEE params.
void importTimeZero(std::string fileName)
Import t0 table to the data base.
ushort m_firstLayerOffset
Offset of first layer in case some CDC layers are removed.
void importWirPosAlign(std::string fileName)
Import wire alignment table to the database.
void importTimeWalk(std::string fileName)
Import time-walk coeff.
void importCDCWireHitRequirements(const std::string &jsonFileName) const
Import CDCWireHits cut values to the database.
static const baseType wireBwdZ
Wire Z position w.r.t. nominal on backward endplate.
static const baseType wireBwdY
Wire Y position w.r.t. nominal on backward endplate.
static const baseType wireFwdZ
Wire Z position w.r.t. nominal on forward endplate.
static const baseType wireFwdY
Wire Y position w.r.t. nominal on forward endplate.
static const baseType wireFwdX
Wire X position w.r.t. nominal on forward endplate.
static const baseType wireBwdX
Wire X position w.r.t. nominal on backward endplate.
static const baseType wireTension
Wire tension w.r.t. nominal (=50. ?)
The Class for CDC Geometry Parameters.
ushort getOffsetOfFirstLayer() const
Get the offset of the first layer.
static CDCGeometryPar & Instance(const CDCGeometry *=nullptr)
Static method to get a reference to the CDCGeometryPar instance.
ushort getOffsetOfFirstSuperLayer() const
Get the offset of the first super layer.
ushort getNumberOfSenseWires() const
Get the number of sense wires.
bool isValid() const
Check whether a valid object was obtained from the database.
Class for accessing arrays of objects in the database.
Class for importing array of objects to the database.
T * appendNew()
Construct a new T object at the end of 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.
A class that describes the interval of experiments/runs for which an object in the database is valid.
Small helper class that prints its lifetime when destroyed.
Class to identify a wire inside the CDC.
array< asicChannel, 8 > asicChannels
fixed sized array of ASIC channels
Abstract base class for different kinds of events.
record to be used to store ASIC info