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>
47#include <Math/Vector3D.h>
51#include <boost/iostreams/filtering_stream.hpp>
52#include <boost/iostreams/device/file.hpp>
53#include <boost/iostreams/filter/gzip.hpp>
55#include <boost/property_tree/ptree.hpp>
56#include <boost/property_tree/json_parser.hpp>
62 m_firstExperiment(fexp), m_firstRun(frun), m_lastExperiment(lexp), m_lastRun(lrun)
73 stream.open(fileName.c_str());
75 B2ERROR(
"openFile: " << fileName <<
" *** failed to open");
78 B2INFO(fileName <<
": open for reading");
89 stream >> iL >> iC >> t0;
91 if (iL < m_firstLayerOffset) {
95 if (stream.eof())
break;
105 if (nRead != m_nSenseWires) B2FATAL(
"#lines read-in (=" << nRead <<
") is inconsistent with total #sense wires (=" << m_nSenseWires
109 m_lastExperiment, m_lastRun);
112 B2INFO(
"Time zero table imported to database.");
119 std::ifstream stream;
120 stream.open(fileName.c_str());
122 B2ERROR(
"openFile: " << fileName <<
" *** failed to open");
125 B2INFO(fileName <<
": open for reading");
135 while (!stream.eof()) {
136 stream >> isl >> il >> iw >> iBoard >> iCh;
138 if (il < m_firstLayerOffset) {
147 m_lastExperiment, m_lastRun);
151 B2INFO(
"Channel map imported to database.");
158 std::ifstream stream;
159 stream.open(fileName.c_str());
161 B2ERROR(
"openFile: " << fileName <<
" *** failed to open");
164 B2INFO(fileName <<
": open for reading");
169 short ib, width, delay, aTh, tThmV;
172 while (stream >> ib) {
174 stream >> width >> delay >> aTh >> tThmV;
178 cf.
appendNew(ib, width, delay, aTh, tThmV);
183 m_lastExperiment, m_lastRun);
187 B2INFO(
"FEEElectronics imported to database.");
193 std::ifstream stream;
194 stream.open(fileName.c_str());
196 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
199 B2INFO(fileName <<
": open for reading");
204 unsigned short paramMode(0), nParams(0);
205 stream >> paramMode >> nParams;
206 etoa->setParamMode(paramMode);
208 unsigned short groupId(0);
210 B2INFO(paramMode <<
" " << nParams <<
" " << groupId);
211 if (groupId > 1) B2FATAL(
"invalid groupId now !");
212 etoa->setGroupID(groupId);
214 unsigned short id = 0;
215 std::vector<float> coeffs(nParams);
218 while (stream >>
id) {
219 for (
unsigned short i = 0; i < nParams; ++i) {
223 if (groupId == 0 and
id < m_superLayerOffset) {
226 if (groupId == 1 and
id < m_firstLayerOffset) {
230 etoa->setParams(
id, coeffs);
234 unsigned short nId = c_nSuperLayers;
236 nId = c_maxNSenseLayers;
237 }
else if (groupId == 2) {
240 if (nRead != nId) B2FATAL(
"#lines read-in (=" << nRead <<
") is not equal #ids (=" << nId <<
") !");
243 m_lastExperiment, m_lastRun);
245 B2INFO(
"EDep-toADC table imported to database.");
251 std::ifstream stream;
252 stream.open(fileName.c_str());
254 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
257 B2INFO(fileName <<
": open for reading");
262 uint iL(0), iC(0), nRead(0);
266 stream >> iL >> iC >> effi;
267 if (stream.eof())
break;
269 if (iL < m_firstLayerOffset) {
274 bw->setWire(
WireID(iL, iC), effi);
281 if (nRead >
static_cast<int>(m_nSenseWires)) B2FATAL(
"#lines read-in (=" << nRead <<
") is larger than #sense wires (=" <<
282 m_nSenseWires <<
") !");
285 m_lastExperiment, m_lastRun);
287 B2INFO(
"BadWire table imported to database.");
293 std::ifstream stream;
294 stream.open(fileName.c_str());
296 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
299 B2INFO(fileName <<
": open for reading");
304 uint iCL(0), nRead(0);
308 stream >> iCL >> speed;
309 if (stream.eof())
break;
311 if (iCL < m_firstLayerOffset) {
317 ps->setSpeed(iCL, speed);
325 if (nRead != c_maxNSenseLayers) B2FATAL(
"#lines read-in (=" << nRead <<
") is no equal #sense layers (=" << c_maxNSenseLayers <<
329 m_lastExperiment, m_lastRun);
331 B2INFO(
"PropSpeed table imported to database.");
337 std::ifstream stream;
338 stream.open(fileName.c_str());
340 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
343 B2INFO(fileName <<
": open for reading");
348 uint iCL(0), nRead(0);
352 stream >> iCL >> param;
353 if (stream.eof())
break;
355 if (iCL < m_firstLayerOffset) {
360 cr->setParam(iCL, param);
364 if (nRead != c_maxNSenseLayers) B2FATAL(
"#lines read-in (=" << nRead <<
") is not equal to #sense layers (=" << c_maxNSenseLayers <<
368 m_lastExperiment, m_lastRun);
370 B2INFO(
"CorrToThreshold table imported to database.");
376 std::ifstream stream;
377 stream.open(fileName.c_str());
379 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
382 B2INFO(fileName <<
": open for reading");
387 unsigned short mode(0), nParams(0);
388 stream >> mode >> nParams;
389 tw->setTwParamMode(mode);
391 unsigned short iBoard(0);
392 std::vector<float> coeffs(nParams);
395 while (stream >> iBoard) {
396 for (
unsigned short i = 0; i < nParams; ++i) {
400 tw->setTimeWalkParams(iBoard, coeffs);
407 if (nRead != c_nBoards) B2FATAL(
"#lines read-in (=" << nRead <<
") is not equal #boards (=" << c_nBoards <<
") !");
410 m_lastExperiment, m_lastRun);
412 B2INFO(
"Time-walk coeff. table imported to database.");
424 boost::iostreams::filtering_istream ifs;
425 if ((fileName.rfind(
".gz") != string::npos) && (fileName.length() - fileName.rfind(
".gz") == 3)) {
426 ifs.push(boost::iostreams::gzip_decompressor());
428 ifs.push(boost::iostreams::file_source(fileName));
430 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
432 B2INFO(fileName <<
": open for reading");
434 const double degrad = M_PI / 180.;
435 const double raddeg = 180. / M_PI;
437 unsigned short nAlphaBins = 0;
438 if (ifs >> nAlphaBins) {
439 if (nAlphaBins == 0 || nAlphaBins > c_maxNAlphaPoints) B2FATAL(
"Fail to read alpha bins !");
441 B2FATAL(
"Fail to read alpha bins !");
443 std::array<float, 3> alpha3;
444 for (
unsigned short i = 0; i < nAlphaBins; ++i) {
445 for (
unsigned short j = 0; j < 3; ++j) {
449 xt->setAlphaBin(alpha3);
453 unsigned short nThetaBins = 0;
454 if (ifs >> nThetaBins) {
455 if (nThetaBins == 0 || nThetaBins > c_maxNThetaPoints) B2FATAL(
"Fail to read theta bins !");
457 B2FATAL(
"Fail to read theta bins !");
459 std::array<float, 3> theta3;
461 for (
unsigned short i = 0; i < nThetaBins; ++i) {
462 for (
unsigned short j = 0; j < 3; ++j) {
466 xt->setThetaBin(theta3);
479 short xtParamMode, np;
480 unsigned short iCL, iLR;
481 const unsigned short npx = c_nXTParams - 1;
483 double theta, alpha, dummy1;
486 ifs >> xtParamMode >> np;
487 if (xtParamMode < 0 || xtParamMode > 1) B2FATAL(
"Invalid xt param mode read !");
488 if (np <= 0 || np > npx) B2FATAL(
"No. of xt-params. outside limits !");
490 xt->setXtParamMode(xtParamMode);
492 const double epsi = 0.1;
495 ifs >> theta >> alpha >> dummy1 >> iLR;
496 for (
int i = 0; i < np; ++i) {
502 if (iCL < m_firstLayerOffset) {
509 for (
unsigned short i = 0; i < nAlphaBins; ++i) {
510 if (fabs(alpha - xt->getAlphaBin(i)[2]*raddeg) < epsi) {
515 if (ialpha < 0) B2FATAL(
"alphas in xt.dat are inconsistent !");
518 for (
unsigned short i = 0; i < nThetaBins; ++i) {
519 if (fabs(theta - xt->getThetaBin(i)[2]*raddeg) < epsi) {
524 if (itheta < 0) B2FATAL(
"thetas in xt.dat are inconsistent !");
527 std::vector<float> xtbuff;
528 for (
int i = 0; i < np; ++i) {
529 xtbuff.push_back(xtc[i]);
532 xt->setXtParams(iCL, iLR, ialpha, itheta, xtbuff);
536 boost::iostreams::close(ifs);
539 m_lastExperiment, m_lastRun);
541 B2INFO(
"XT table imported to database.");
551 ifs.open(fileName.c_str());
553 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
555 B2INFO(fileName <<
": open for reading");
557 const double degrad = M_PI / 180.;
558 const double raddeg = 180. / M_PI;
560 unsigned short nAlphaBins = 0;
561 if (ifs >> nAlphaBins) {
562 if (nAlphaBins == 0 || nAlphaBins > c_maxNAlphaPoints) B2FATAL(
"Fail to read alpha bins !");
564 B2FATAL(
"Fail to read alpha bins !");
566 std::array<float, 3> alpha3;
567 for (
unsigned short i = 0; i < nAlphaBins; ++i) {
568 for (
unsigned short j = 0; j < 3; ++j) {
572 sg->setAlphaBin(alpha3);
576 unsigned short nThetaBins = 0;
577 if (ifs >> nThetaBins) {
578 if (nThetaBins == 0 || nThetaBins > c_maxNThetaPoints) B2FATAL(
"Fail to read theta bins !");
580 B2FATAL(
"Fail to read theta bins !");
582 std::array<float, 3> theta3;
584 for (
unsigned short i = 0; i < nThetaBins; ++i) {
585 for (
unsigned short j = 0; j < 3; ++j) {
589 sg->setThetaBin(theta3);
594 short sgParamMode, np;
595 unsigned short iCL, iLR;
596 const unsigned short npx = c_nSigmaParams;
601 ifs >> sgParamMode >> np;
602 if (sgParamMode < 0 || sgParamMode > 1) B2FATAL(
"Invalid sigma param mode read !");
603 if (np <= 0 || np > npx) B2FATAL(
"No. of sgm-params. outside limits !");
605 sg->setSigmaParamMode(sgParamMode);
609 sg->setMaxSpaceResol(maxSigma);
611 const double epsi = 0.1;
614 ifs >> theta >> alpha >> iLR;
615 for (
int i = 0; i < np; ++i) {
621 if (iCL < m_firstLayerOffset) {
628 for (
unsigned short i = 0; i < nAlphaBins; ++i) {
629 if (fabs(alpha - sg->getAlphaBin(i)[2]*raddeg) < epsi) {
634 if (ialpha < 0) B2FATAL(
"alphas in sigma.dat are inconsistent !");
637 for (
unsigned short i = 0; i < nThetaBins; ++i) {
638 if (fabs(theta - sg->getThetaBin(i)[2]*raddeg) < epsi) {
643 if (itheta < 0) B2FATAL(
"thetas in sigma.dat are inconsistent !");
646 std::vector<float> sgbuff;
647 for (
int i = 0; i < np; ++i) {
648 sgbuff.push_back(sgm[i]);
651 sg->setSigmaParams(iCL, iLR, ialpha, itheta, sgbuff);
657 m_lastExperiment, m_lastRun);
659 B2INFO(
"Sigma table imported to database.");
665 std::ifstream stream;
666 stream.open(fileName.c_str());
668 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
671 B2INFO(fileName <<
": open for reading");
676 unsigned short groupId(0), nParams(0);
677 stream >> groupId >> nParams;
678 B2INFO(groupId <<
" " << nParams);
679 if (groupId != 0) B2FATAL(
"invalid groupId now !");
680 etoa->setGroupID(groupId);
682 unsigned short id = 0;
683 std::vector<float> coeffs(nParams);
686 while (stream >>
id) {
687 for (
unsigned short i = 0; i < nParams; ++i) {
691 etoa->setFactors(
id, coeffs);
695 unsigned short nId = 1;
696 if (nRead != nId) B2FATAL(
"#lines read-in (=" << nRead <<
") is not equal #ids (=" << nId <<
") !");
699 m_lastExperiment, m_lastRun);
701 B2INFO(
"Fudge factor table imported to database.");
710 boost::iostreams::filtering_istream ifs;
711 if ((fileName.rfind(
".gz") != string::npos) && (fileName.length() - fileName.rfind(
".gz") == 3)) {
712 ifs.push(boost::iostreams::gzip_decompressor());
714 ifs.push(boost::iostreams::file_source(fileName));
716 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
718 B2INFO(fileName <<
": open for reading");
724 double back[np], fwrd[np];
730 for (
int i = 0; i < np; ++i) {
733 for (
int i = 0; i < np; ++i) {
738 if (ifs.eof())
break;
740 if (iL < m_firstLayerOffset) {
747 ROOT::Math::XYZVector fwd(fwrd[0], fwrd[1], fwrd[2]);
748 ROOT::Math::XYZVector bwd(back[0], back[1], back[2]);
752 if (nRead != m_nSenseWires) B2FATAL(
"CDCDatabaseimporter::importDisplacement: #lines read-in (=" << nRead <<
753 ") is inconsistent with total #sense wires (=" << m_nSenseWires <<
") !");
756 boost::iostreams::close(ifs);
759 m_lastExperiment, m_lastRun);
761 B2INFO(
"Wire displasement table imported to database.");
769 boost::iostreams::filtering_istream ifs;
770 if ((fileName.rfind(
".gz") != string::npos) && (fileName.length() - fileName.rfind(
".gz") == 3)) {
771 ifs.push(boost::iostreams::gzip_decompressor());
773 ifs.push(boost::iostreams::file_source(fileName));
775 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
778 B2INFO(fileName <<
": open for reading");
785 double back[np], fwrd[np], tension;
790 for (
int i = 0; i < np; ++i) {
793 for (
int i = 0; i < np; ++i) {
797 if (ifs.eof())
break;
799 if (iL < m_firstLayerOffset) {
806 for (
int i = 0; i < np; ++i) {
817 if (nRead != m_nSenseWires) B2FATAL(
"CDCDatabaseimporter::importWirPosAlign: #lines read-in (=" << nRead <<
818 ") is inconsistent with total #sense wires (=" << m_nSenseWires <<
") !");
821 boost::iostreams::close(ifs);
824 m_lastExperiment, m_lastRun);
826 B2INFO(
"Wire alignment table imported to database.");
835 for (
const auto& cm : channelMaps) {
836 std::cout << cm.getISuperLayer() <<
" " << cm.getILayer()
837 <<
" " << cm.getIWire() <<
" "
838 << cm.getBoardID() <<
" " << cm.getBoardChannel() << std::endl;
846 for (
const auto& cf : fEElectronics) {
847 std::cout << cf.getBoardID() <<
" " << cf.getWidthOfTimeWindow() <<
" " << cf.getTrgDelay() <<
" " << cf.getADCThresh() <<
" " <<
848 cf.getTDCThreshInMV() << std::endl;
914 for (
const auto& disp : displacements) {
915 B2INFO(disp.getICLayer() <<
" " << disp.getIWire() <<
" "
916 << disp.getXBwd() <<
" " << disp.getYBwd() <<
" " << disp.getZBwd() <<
" "
917 << disp.getXFwd() <<
" " << disp.getYFwd() <<
" " << disp.getZFwd() <<
" " << disp.getTension());
936 std::ifstream stream;
937 stream.open(fileName.c_str());
938 if (!stream.is_open()) {
939 B2ERROR(
"openFile: " << fileName <<
" *** failed to open");
942 B2INFO(fileName <<
": open for reading");
957 stream >> iB >> iC >> ped;
959 if (stream.eof())
break;
962 B2FATAL(
"sample window is zero !");
964 dbPed->setSamplingWindow(sample);
966 dbPed->setPedestal(iB, iC, ped);
974 m_lastExperiment, m_lastRun);
977 B2INFO(
"ADC delta pedestal table imported to database.");
987 m_lastExperiment, m_lastRun);
990 B2INFO(
"ADC delta pedestal w/ zero imported to database.");
1004 boost::property_tree::ptree tree;
1009 B2INFO(
"Loading json file: " << jsonFileName);
1010 boost::property_tree::read_json(jsonFileName, tree);
1012 }
catch (boost::property_tree::ptree_error& e) {
1013 B2FATAL(
"Error when loading json file: " << e.what());
1020 m_lastExperiment, m_lastRun);
1021 dbWireHitReq.
import(iov);
1023 B2INFO(
"CDCWireHit requirements imported to database.");
1031 dbWireHitReq->dump();
1033 B2WARNING(
"DBObjPtr<CDCWireHitRequirements> not valid for the current run.");
1042 TFile fIn = TFile(rootFileName.c_str());
1043 TTreeReader reader(
"my_ttree", &fIn);
1044 TTreeReaderValue<UChar_t> Board(reader,
"Board");
1045 TTreeReaderValue<UChar_t> Channel(reader,
"Channel");
1046 TTreeReaderValue<Short_t> Asic_ADC0(reader,
"Asic_ADC0");
1047 TTreeReaderValue<Short_t> Asic_TDC0(reader,
"Asic_TDC0");
1048 TTreeReaderValue<Short_t> Asic_TOT0(reader,
"Asic_TOT0");
1049 TTreeReaderValue<Short_t> Asic_ADC1(reader,
"Asic_ADC1");
1050 TTreeReaderValue<Short_t> Asic_TDC1(reader,
"Asic_TDC1");
1051 TTreeReaderValue<Short_t> Asic_TOT1(reader,
"Asic_TOT1");
1052 TTreeReaderValue<Short_t> Asic_ADC2(reader,
"Asic_ADC2");
1053 TTreeReaderValue<Short_t> Asic_TDC2(reader,
"Asic_TDC2");
1054 TTreeReaderValue<Short_t> Asic_TOT2(reader,
"Asic_TOT2");
1055 TTreeReaderValue<Short_t> Asic_ADC3(reader,
"Asic_ADC3");
1056 TTreeReaderValue<Short_t> Asic_TDC3(reader,
"Asic_TDC3");
1057 TTreeReaderValue<Short_t> Asic_TOT3(reader,
"Asic_TOT3");
1058 TTreeReaderValue<Short_t> Asic_ADC4(reader,
"Asic_ADC4");
1059 TTreeReaderValue<Short_t> Asic_TDC4(reader,
"Asic_TDC4");
1060 TTreeReaderValue<Short_t> Asic_TOT4(reader,
"Asic_TOT4");
1061 TTreeReaderValue<Short_t> Asic_ADC5(reader,
"Asic_ADC5");
1062 TTreeReaderValue<Short_t> Asic_TDC5(reader,
"Asic_TDC5");
1063 TTreeReaderValue<Short_t> Asic_TOT5(reader,
"Asic_TOT5");
1064 TTreeReaderValue<Short_t> Asic_ADC6(reader,
"Asic_ADC6");
1065 TTreeReaderValue<Short_t> Asic_TDC6(reader,
"Asic_TDC6");
1066 TTreeReaderValue<Short_t> Asic_TOT6(reader,
"Asic_TOT6");
1067 TTreeReaderValue<Short_t> Asic_ADC7(reader,
"Asic_ADC7");
1068 TTreeReaderValue<Short_t> Asic_TDC7(reader,
"Asic_TDC7");
1069 TTreeReaderValue<Short_t> Asic_TOT7(reader,
"Asic_TOT7");
1071 while (reader.Next()) {
1083 UChar_t asicCh = *Channel % 8;
1084 Short_t ADC = record[asicCh].ADC;
1085 dbCDCCrossTalkLibrary->addAsicRecord(asicCh, ADC, record);
1091 fIn.GetObject(
"ProbXTalk", prob);
1092 for (
size_t a = 1; a <= 8196; a += 1) {
1093 probs[a - 1] = prob->GetBinContent(a);
1096 dbCDCCrossTalkLibrary->setPCrossTalk(probs);
1098 dbCDCCrossTalkLibrary->dump(0);
1100 m_lastExperiment, m_lastRun);
1101 dbCDCCrossTalkLibrary.
import(iov);
1102 B2INFO(
"CDCCrossTalkLibrary requirements imported to database.");
1108 if (dbCDCCrossTalkLib.
isValid()) {
1109 dbCDCCrossTalkLib->dump(1);
1111 B2ERROR(
"DBObjPtr<CDCCrossTalkLibrary> not valid for the current run.");
1119 if (dbCDCCrossTalkLib.
isValid()) {
1122 B2INFO(
"Performing CDCCrossTalkLibrary checks");
1123 auto timer =
new Utils::Timer(
"CDCCrossTalkLibrary checks took");
1126 for (Short_t ADC = 0; ADC < 8196; ADC += 1) {
1127 for (Short_t channel = 0; channel < 48; channel += 1) {
1128 for (
size_t rep = 0; rep < 100; rep += 1) {
1129 auto xtalk = dbCDCCrossTalkLib->getLibraryCrossTalk(channel, 4999, ADC, 5, 0,
false);
1131 size += xtalk.size();
1135 B2INFO(
"CDCCrossTalkLibrary called " << counter <<
" times. Total number of cross talk hits " << size);
1141 Short_t ADC_spot_checks[5] = {2, 100, 500, 1000, 5000};
1142 for (
auto ADC : ADC_spot_checks) {
1143 B2INFO(
"CHECK ADC=" << ADC);
1145 size_t NRep = ADC < 50 ? 100 : 10;
1146 for (
size_t rep = 0; rep < NRep; rep += 1) {
1147 auto xtalk = dbCDCCrossTalkLib->getLibraryCrossTalk(0, 4999, ADC, 5, 0,
true);
1148 B2INFO(
"Size = " << xtalk.size());
1149 for (
auto [channel, rec] : xtalk) {
1150 B2INFO(
"Channel:" << channel <<
" TDC,ADC,TOT:" << rec.TDC <<
"," << rec.ADC <<
"," << rec.TOT);
1155 B2ERROR(
"DBObjPtr<CDCCrossTalkLibrary> not valid for the current run.");
1163 boost::property_tree::ptree tree;
1166 B2INFO(
"Loading json file: " << jsonFileName);
1167 boost::property_tree::read_json(jsonFileName, tree);
1168 }
catch (boost::property_tree::ptree_error& e) {
1169 B2FATAL(
"Error when loading json file: " << e.what());
1176 m_lastExperiment, m_lastRun);
1177 dbCDClayerTimeCut.
import(iov);
1178 B2INFO(
"dbCDClayerTimeCut imported to database.");
1184 if (dbCDClayerTimeCut.
isValid()) {
1185 dbCDClayerTimeCut->dump();
1187 B2WARNING(
"DBObjPtr<CDClayerTimeCut> not valid for the current run.");
1198 ifs.open(fileName.c_str());
1200 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
1203 B2INFO(fileName <<
": open for reading");
1210 double back[np], fwrd[np], tension;
1215 for (
int i = 0; i < np; ++i) {
1218 for (
int i = 0; i < np; ++i) {
1222 if (ifs.eof())
break;
1227 for (
int i = 0; i < np; ++i) {
1238 if (nRead != m_nSenseWires) B2FATAL(
"CDCDatabaseimporter::importWirPosMisalign: #lines read-in (=" << nRead <<
1239 ") is inconsistent with total #sense wires (=" << m_nSenseWires <<
") !");
1244 m_lastExperiment, m_lastRun);
1246 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