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/CDCBadBoards.h>
30#include <cdc/dbobjects/CDCPropSpeeds.h>
31#include <cdc/dbobjects/CDCTimeWalks.h>
32#include <cdc/dbobjects/CDCXtRelations.h>
33#include <cdc/dbobjects/CDCSpaceResols.h>
34#include <cdc/dbobjects/CDCFudgeFactorsForSigma.h>
35#include <cdc/dbobjects/CDCAlphaScaleFactorForAsymmetry.h>
36#include <cdc/dbobjects/CDCDisplacement.h>
37#include <cdc/dbobjects/CDCAlignment.h>
38#include <cdc/dbobjects/CDCADCDeltaPedestals.h>
39#include <cdc/dbobjects/CDCFEElectronics.h>
40#include <cdc/dbobjects/CDCEDepToADCConversions.h>
41#include <cdc/dbobjects/CDCCorrToThresholds.h>
42#include <cdc/dbobjects/CDCWireHitRequirements.h>
43#include <cdc/dbobjects/CDCCrossTalkLibrary.h>
44#include <cdc/dbobjects/CDClayerTimeCut.h>
45#include <cdc/geometry/CDCGeometryPar.h>
47#include <TTreeReader.h>
49#include <Math/Vector3D.h>
53#include <boost/iostreams/filtering_stream.hpp>
54#include <boost/iostreams/device/file.hpp>
55#include <boost/iostreams/filter/gzip.hpp>
57#include <boost/property_tree/ptree.hpp>
58#include <boost/property_tree/json_parser.hpp>
75 stream.open(fileName.c_str());
77 B2ERROR(
"openFile: " << fileName <<
" *** failed to open");
80 B2INFO(fileName <<
": open for reading");
91 stream >> iL >> iC >> t0;
97 if (stream.eof())
break;
107 if (nRead !=
m_nSenseWires) B2FATAL(
"#lines read-in (=" << nRead <<
") is inconsistent with total #sense wires (=" <<
m_nSenseWires
114 B2INFO(
"Time zero table imported to database.");
121 std::ifstream stream;
122 stream.open(fileName.c_str());
124 B2ERROR(
"openFile: " << fileName <<
" *** failed to open");
127 B2INFO(fileName <<
": open for reading");
137 while (!stream.eof()) {
138 stream >> isl >> il >> iw >> iBoard >> iCh;
153 B2INFO(
"Channel map imported to database.");
160 std::ifstream stream;
161 stream.open(fileName.c_str());
163 B2ERROR(
"openFile: " << fileName <<
" *** failed to open");
166 B2INFO(fileName <<
": open for reading");
171 short ib, width, delay, aTh, tThmV;
174 while (stream >> ib) {
176 stream >> width >> delay >> aTh >> tThmV;
180 cf.
appendNew(ib, width, delay, aTh, tThmV);
189 B2INFO(
"FEEElectronics imported to database.");
195 std::ifstream stream;
196 stream.open(fileName.c_str());
198 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
201 B2INFO(fileName <<
": open for reading");
206 unsigned short paramMode(0), nParams(0);
207 stream >> paramMode >> nParams;
208 etoa->setParamMode(paramMode);
210 unsigned short groupId(0);
212 B2INFO(paramMode <<
" " << nParams <<
" " << groupId);
213 if (groupId > 1) B2FATAL(
"invalid groupId now !");
214 etoa->setGroupID(groupId);
216 unsigned short id = 0;
217 std::vector<float> coeffs(nParams);
220 while (stream >>
id) {
221 for (
unsigned short i = 0; i < nParams; ++i) {
232 etoa->setParams(
id, coeffs);
236 unsigned short nId = c_nSuperLayers;
238 nId = c_maxNSenseLayers;
239 }
else if (groupId == 2) {
242 if (nRead != nId) B2FATAL(
"#lines read-in (=" << nRead <<
") is not equal #ids (=" << nId <<
") !");
247 B2INFO(
"EDep-toADC table imported to database.");
253 std::ifstream stream;
254 stream.open(fileName.c_str());
256 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
259 B2INFO(fileName <<
": open for reading");
264 uint iL(0), iC(0), nRead(0);
268 stream >> iL >> iC >> effi;
269 if (stream.eof())
break;
276 bw->setWire(
WireID(iL, iC), effi);
283 if (nRead >
static_cast<int>(
m_nSenseWires)) B2FATAL(
"#lines read-in (=" << nRead <<
") is larger than #sense wires (=" <<
289 B2INFO(
"BadWire table imported to database.");
294 std::ifstream stream;
295 stream.open(fileName.c_str());
297 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
300 B2INFO(fileName <<
": open for reading");
309 stream >> iB >> effi;
310 if (stream.eof())
break;
311 bb->setBoard(iB, effi);
318 B2INFO(
"BadBoard table imported to database.");
324 std::ifstream stream;
325 stream.open(fileName.c_str());
327 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
330 B2INFO(fileName <<
": open for reading");
335 uint iCL(0), nRead(0);
339 stream >> iCL >> speed;
340 if (stream.eof())
break;
348 ps->setSpeed(iCL, speed);
356 if (nRead != c_maxNSenseLayers) B2FATAL(
"#lines read-in (=" << nRead <<
") is no equal #sense layers (=" << c_maxNSenseLayers <<
362 B2INFO(
"PropSpeed table imported to database.");
368 std::ifstream stream;
369 stream.open(fileName.c_str());
371 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
374 B2INFO(fileName <<
": open for reading");
379 uint iCL(0), nRead(0);
383 stream >> iCL >> param;
384 if (stream.eof())
break;
391 cr->setParam(iCL, param);
395 if (nRead != c_maxNSenseLayers) B2FATAL(
"#lines read-in (=" << nRead <<
") is not equal to #sense layers (=" << c_maxNSenseLayers <<
401 B2INFO(
"CorrToThreshold table imported to database.");
407 std::ifstream stream;
408 stream.open(fileName.c_str());
410 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
413 B2INFO(fileName <<
": open for reading");
418 unsigned short mode(0), nParams(0);
419 stream >> mode >> nParams;
420 tw->setTwParamMode(mode);
422 unsigned short iBoard(0);
423 std::vector<float> coeffs(nParams);
426 while (stream >> iBoard) {
427 for (
unsigned short i = 0; i < nParams; ++i) {
431 tw->setTimeWalkParams(iBoard, coeffs);
438 if (nRead != c_nBoards) B2FATAL(
"#lines read-in (=" << nRead <<
") is not equal #boards (=" << c_nBoards <<
") !");
443 B2INFO(
"Time-walk coeff. table imported to database.");
455 boost::iostreams::filtering_istream ifs;
456 if ((fileName.rfind(
".gz") != string::npos) && (fileName.length() - fileName.rfind(
".gz") == 3)) {
457 ifs.push(boost::iostreams::gzip_decompressor());
459 ifs.push(boost::iostreams::file_source(fileName));
461 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
463 B2INFO(fileName <<
": open for reading");
465 const double degrad = M_PI / 180.;
466 const double raddeg = 180. / M_PI;
468 unsigned short nAlphaBins = 0;
469 if (ifs >> nAlphaBins) {
470 if (nAlphaBins == 0 || nAlphaBins > c_maxNAlphaPoints) B2FATAL(
"Fail to read alpha bins !");
472 B2FATAL(
"Fail to read alpha bins !");
474 std::array<float, 3> alpha3;
475 for (
unsigned short i = 0; i < nAlphaBins; ++i) {
476 for (
unsigned short j = 0; j < 3; ++j) {
480 xt->setAlphaBin(alpha3);
484 unsigned short nThetaBins = 0;
485 if (ifs >> nThetaBins) {
486 if (nThetaBins == 0 || nThetaBins > c_maxNThetaPoints) B2FATAL(
"Fail to read theta bins !");
488 B2FATAL(
"Fail to read theta bins !");
490 std::array<float, 3> theta3;
492 for (
unsigned short i = 0; i < nThetaBins; ++i) {
493 for (
unsigned short j = 0; j < 3; ++j) {
497 xt->setThetaBin(theta3);
510 short xtParamMode, np;
511 unsigned short iCL, iLR;
512 const unsigned short npx = c_nXTParams - 1;
514 double theta, alpha, dummy1;
517 ifs >> xtParamMode >> np;
518 if (xtParamMode < 0 || xtParamMode > 1) B2FATAL(
"Invalid xt param mode read !");
519 if (np <= 0 || np > npx) B2FATAL(
"No. of xt-params. outside limits !");
521 xt->setXtParamMode(xtParamMode);
523 const double epsi = 0.1;
526 ifs >> theta >> alpha >> dummy1 >> iLR;
527 for (
int i = 0; i < np; ++i) {
540 for (
unsigned short i = 0; i < nAlphaBins; ++i) {
541 if (fabs(alpha - xt->getAlphaBin(i)[2]*raddeg) < epsi) {
546 if (ialpha < 0) B2FATAL(
"alphas in xt.dat are inconsistent !");
549 for (
unsigned short i = 0; i < nThetaBins; ++i) {
550 if (fabs(theta - xt->getThetaBin(i)[2]*raddeg) < epsi) {
555 if (itheta < 0) B2FATAL(
"thetas in xt.dat are inconsistent !");
558 std::vector<float> xtbuff;
559 for (
int i = 0; i < np; ++i) {
560 xtbuff.push_back(xtc[i]);
563 xt->setXtParams(iCL, iLR, ialpha, itheta, xtbuff);
567 boost::iostreams::close(ifs);
572 B2INFO(
"XT table imported to database.");
582 ifs.open(fileName.c_str());
584 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
586 B2INFO(fileName <<
": open for reading");
588 const double degrad = M_PI / 180.;
589 const double raddeg = 180. / M_PI;
591 unsigned short nAlphaBins = 0;
592 if (ifs >> nAlphaBins) {
593 if (nAlphaBins == 0 || nAlphaBins > c_maxNAlphaPoints) B2FATAL(
"Fail to read alpha bins !");
595 B2FATAL(
"Fail to read alpha bins !");
597 std::array<float, 3> alpha3;
598 for (
unsigned short i = 0; i < nAlphaBins; ++i) {
599 for (
unsigned short j = 0; j < 3; ++j) {
603 sg->setAlphaBin(alpha3);
607 unsigned short nThetaBins = 0;
608 if (ifs >> nThetaBins) {
609 if (nThetaBins == 0 || nThetaBins > c_maxNThetaPoints) B2FATAL(
"Fail to read theta bins !");
611 B2FATAL(
"Fail to read theta bins !");
613 std::array<float, 3> theta3;
615 for (
unsigned short i = 0; i < nThetaBins; ++i) {
616 for (
unsigned short j = 0; j < 3; ++j) {
620 sg->setThetaBin(theta3);
625 short sgParamMode, np;
626 unsigned short iCL, iLR;
627 const unsigned short npx = c_nSigmaParams;
632 ifs >> sgParamMode >> np;
633 if (sgParamMode < 0 || sgParamMode > 1) B2FATAL(
"Invalid sigma param mode read !");
634 if (np <= 0 || np > npx) B2FATAL(
"No. of sgm-params. outside limits !");
636 sg->setSigmaParamMode(sgParamMode);
640 sg->setMaxSpaceResol(maxSigma);
642 const double epsi = 0.1;
645 ifs >> theta >> alpha >> iLR;
646 for (
int i = 0; i < np; ++i) {
659 for (
unsigned short i = 0; i < nAlphaBins; ++i) {
660 if (fabs(alpha - sg->getAlphaBin(i)[2]*raddeg) < epsi) {
665 if (ialpha < 0) B2FATAL(
"alphas in sigma.dat are inconsistent !");
668 for (
unsigned short i = 0; i < nThetaBins; ++i) {
669 if (fabs(theta - sg->getThetaBin(i)[2]*raddeg) < epsi) {
674 if (itheta < 0) B2FATAL(
"thetas in sigma.dat are inconsistent !");
677 std::vector<float> sgbuff;
678 for (
int i = 0; i < np; ++i) {
679 sgbuff.push_back(sgm[i]);
682 sg->setSigmaParams(iCL, iLR, ialpha, itheta, sgbuff);
690 B2INFO(
"Sigma table imported to database.");
696 std::ifstream stream;
697 stream.open(fileName.c_str());
699 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
702 B2INFO(fileName <<
": open for reading");
707 unsigned short groupId(0), nParams(0);
708 stream >> groupId >> nParams;
709 B2INFO(groupId <<
" " << nParams);
710 if (groupId != 0) B2FATAL(
"invalid groupId now !");
711 etoa->setGroupID(groupId);
713 unsigned short id = 0;
714 std::vector<float> coeffs(nParams);
717 while (stream >>
id) {
718 for (
unsigned short i = 0; i < nParams; ++i) {
722 etoa->setFactors(
id, coeffs);
726 unsigned short nId = 1;
727 if (nRead != nId) B2FATAL(
"#lines read-in (=" << nRead <<
") is not equal #ids (=" << nId <<
") !");
732 B2INFO(
"Fudge factor table imported to database.");
737 std::ifstream stream;
738 stream.open(fileName.c_str());
740 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
743 B2INFO(fileName <<
": open for reading");
752 unsigned short iLayer = 0;
753 while (std::getline(stream, line)) {
754 std::stringstream ss(line);
757 B2FATAL(
"The number of layers " << iLayer + 1 <<
" is more than expected " <<
761 while (std::getline(ss, value,
',')) {
763 B2FATAL(
"The number of alpha scale factors is " << iElement + 1 <<
" for layer " << iLayer <<
", not equal " <<
765 alphaRatios[iLayer][iElement] = std::stof(value);
770 asf->setScaleFactors(alphaRatios);
780 B2INFO(
"Alpha scale factor table imported to database.");
789 boost::iostreams::filtering_istream ifs;
790 if ((fileName.rfind(
".gz") != string::npos) && (fileName.length() - fileName.rfind(
".gz") == 3)) {
791 ifs.push(boost::iostreams::gzip_decompressor());
793 ifs.push(boost::iostreams::file_source(fileName));
795 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
797 B2INFO(fileName <<
": open for reading");
803 double back[np], fwrd[np];
809 for (
int i = 0; i < np; ++i) {
812 for (
int i = 0; i < np; ++i) {
817 if (ifs.eof())
break;
826 ROOT::Math::XYZVector fwd(fwrd[0], fwrd[1], fwrd[2]);
827 ROOT::Math::XYZVector bwd(back[0], back[1], back[2]);
831 if (nRead !=
m_nSenseWires) B2FATAL(
"CDCDatabaseimporter::importDisplacement: #lines read-in (=" << nRead <<
832 ") is inconsistent with total #sense wires (=" <<
m_nSenseWires <<
") !");
835 boost::iostreams::close(ifs);
840 B2INFO(
"Wire displasement table imported to database.");
848 boost::iostreams::filtering_istream ifs;
849 if ((fileName.rfind(
".gz") != string::npos) && (fileName.length() - fileName.rfind(
".gz") == 3)) {
850 ifs.push(boost::iostreams::gzip_decompressor());
852 ifs.push(boost::iostreams::file_source(fileName));
854 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
857 B2INFO(fileName <<
": open for reading");
864 double back[np], fwrd[np], tension;
869 for (
int i = 0; i < np; ++i) {
872 for (
int i = 0; i < np; ++i) {
876 if (ifs.eof())
break;
885 for (
int i = 0; i < np; ++i) {
896 if (nRead !=
m_nSenseWires) B2FATAL(
"CDCDatabaseimporter::importWirPosAlign: #lines read-in (=" << nRead <<
897 ") is inconsistent with total #sense wires (=" <<
m_nSenseWires <<
") !");
900 boost::iostreams::close(ifs);
905 B2INFO(
"Wire alignment table imported to database.");
914 for (
const auto& cm : channelMaps) {
915 std::cout << cm.getISuperLayer() <<
" " << cm.getILayer()
916 <<
" " << cm.getIWire() <<
" "
917 << cm.getBoardID() <<
" " << cm.getBoardChannel() << std::endl;
925 for (
const auto& cf : fEElectronics) {
926 std::cout << cf.getBoardID() <<
" " << cf.getWidthOfTimeWindow() <<
" " << cf.getTrgDelay() <<
" " << cf.getADCThresh() <<
" " <<
927 cf.getTDCThreshInMV() << std::endl;
1005 for (
const auto& disp : displacements) {
1006 B2INFO(disp.getICLayer() <<
" " << disp.getIWire() <<
" "
1007 << disp.getXBwd() <<
" " << disp.getYBwd() <<
" " << disp.getZBwd() <<
" "
1008 << disp.getXFwd() <<
" " << disp.getYFwd() <<
" " << disp.getZFwd() <<
" " << disp.getTension());
1027 std::ifstream stream;
1028 stream.open(fileName.c_str());
1029 if (!stream.is_open()) {
1030 B2ERROR(
"openFile: " << fileName <<
" *** failed to open");
1033 B2INFO(fileName <<
": open for reading");
1048 stream >> iB >> iC >> ped;
1050 if (stream.eof())
break;
1053 B2FATAL(
"sample window is zero !");
1055 dbPed->setSamplingWindow(sample);
1057 dbPed->setPedestal(iB, iC, ped);
1068 B2INFO(
"ADC delta pedestal table imported to database.");
1081 B2INFO(
"ADC delta pedestal w/ zero imported to database.");
1095 boost::property_tree::ptree tree;
1100 B2INFO(
"Loading json file: " << jsonFileName);
1101 boost::property_tree::read_json(jsonFileName, tree);
1103 }
catch (boost::property_tree::ptree_error& e) {
1104 B2FATAL(
"Error when loading json file: " << e.what());
1112 dbWireHitReq.
import(iov);
1114 B2INFO(
"CDCWireHit requirements imported to database.");
1122 dbWireHitReq->dump();
1124 B2WARNING(
"DBObjPtr<CDCWireHitRequirements> not valid for the current run.");
1133 TFile fIn = TFile(rootFileName.c_str());
1134 TTreeReader reader(
"my_ttree", &fIn);
1135 TTreeReaderValue<UChar_t> Board(reader,
"Board");
1136 TTreeReaderValue<UChar_t> Channel(reader,
"Channel");
1137 TTreeReaderValue<Short_t> Asic_ADC0(reader,
"Asic_ADC0");
1138 TTreeReaderValue<Short_t> Asic_TDC0(reader,
"Asic_TDC0");
1139 TTreeReaderValue<Short_t> Asic_TOT0(reader,
"Asic_TOT0");
1140 TTreeReaderValue<Short_t> Asic_ADC1(reader,
"Asic_ADC1");
1141 TTreeReaderValue<Short_t> Asic_TDC1(reader,
"Asic_TDC1");
1142 TTreeReaderValue<Short_t> Asic_TOT1(reader,
"Asic_TOT1");
1143 TTreeReaderValue<Short_t> Asic_ADC2(reader,
"Asic_ADC2");
1144 TTreeReaderValue<Short_t> Asic_TDC2(reader,
"Asic_TDC2");
1145 TTreeReaderValue<Short_t> Asic_TOT2(reader,
"Asic_TOT2");
1146 TTreeReaderValue<Short_t> Asic_ADC3(reader,
"Asic_ADC3");
1147 TTreeReaderValue<Short_t> Asic_TDC3(reader,
"Asic_TDC3");
1148 TTreeReaderValue<Short_t> Asic_TOT3(reader,
"Asic_TOT3");
1149 TTreeReaderValue<Short_t> Asic_ADC4(reader,
"Asic_ADC4");
1150 TTreeReaderValue<Short_t> Asic_TDC4(reader,
"Asic_TDC4");
1151 TTreeReaderValue<Short_t> Asic_TOT4(reader,
"Asic_TOT4");
1152 TTreeReaderValue<Short_t> Asic_ADC5(reader,
"Asic_ADC5");
1153 TTreeReaderValue<Short_t> Asic_TDC5(reader,
"Asic_TDC5");
1154 TTreeReaderValue<Short_t> Asic_TOT5(reader,
"Asic_TOT5");
1155 TTreeReaderValue<Short_t> Asic_ADC6(reader,
"Asic_ADC6");
1156 TTreeReaderValue<Short_t> Asic_TDC6(reader,
"Asic_TDC6");
1157 TTreeReaderValue<Short_t> Asic_TOT6(reader,
"Asic_TOT6");
1158 TTreeReaderValue<Short_t> Asic_ADC7(reader,
"Asic_ADC7");
1159 TTreeReaderValue<Short_t> Asic_TDC7(reader,
"Asic_TDC7");
1160 TTreeReaderValue<Short_t> Asic_TOT7(reader,
"Asic_TOT7");
1162 while (reader.Next()) {
1174 UChar_t asicCh = *Channel % 8;
1175 Short_t ADC = record[asicCh].ADC;
1176 dbCDCCrossTalkLibrary->addAsicRecord(asicCh, ADC, record);
1182 fIn.GetObject(
"ProbXTalk", prob);
1183 for (
size_t a = 1; a <= 8196; a += 1) {
1184 probs[a - 1] = prob->GetBinContent(a);
1187 dbCDCCrossTalkLibrary->setPCrossTalk(probs);
1189 dbCDCCrossTalkLibrary->dump(0);
1192 dbCDCCrossTalkLibrary.
import(iov);
1193 B2INFO(
"CDCCrossTalkLibrary requirements imported to database.");
1199 if (dbCDCCrossTalkLib.
isValid()) {
1200 dbCDCCrossTalkLib->dump(1);
1202 B2ERROR(
"DBObjPtr<CDCCrossTalkLibrary> not valid for the current run.");
1210 if (dbCDCCrossTalkLib.
isValid()) {
1213 B2INFO(
"Performing CDCCrossTalkLibrary checks");
1214 auto timer =
new Utils::Timer(
"CDCCrossTalkLibrary checks took");
1217 for (Short_t ADC = 0; ADC < 8196; ADC += 1) {
1218 for (Short_t channel = 0; channel < 48; channel += 1) {
1219 for (
size_t rep = 0; rep < 100; rep += 1) {
1220 auto xtalk = dbCDCCrossTalkLib->getLibraryCrossTalk(channel, 4999, ADC, 5, 0,
false);
1222 size += xtalk.size();
1226 B2INFO(
"CDCCrossTalkLibrary called " << counter <<
" times. Total number of cross talk hits " << size);
1232 Short_t ADC_spot_checks[5] = {2, 100, 500, 1000, 5000};
1233 for (
auto ADC : ADC_spot_checks) {
1234 B2INFO(
"CHECK ADC=" << ADC);
1236 size_t NRep = ADC < 50 ? 100 : 10;
1237 for (
size_t rep = 0; rep < NRep; rep += 1) {
1238 auto xtalk = dbCDCCrossTalkLib->getLibraryCrossTalk(0, 4999, ADC, 5, 0,
true);
1239 B2INFO(
"Size = " << xtalk.size());
1240 for (
auto [channel, rec] : xtalk) {
1241 B2INFO(
"Channel:" << channel <<
" TDC,ADC,TOT:" << rec.TDC <<
"," << rec.ADC <<
"," << rec.TOT);
1246 B2ERROR(
"DBObjPtr<CDCCrossTalkLibrary> not valid for the current run.");
1254 boost::property_tree::ptree tree;
1257 B2INFO(
"Loading json file: " << jsonFileName);
1258 boost::property_tree::read_json(jsonFileName, tree);
1259 }
catch (boost::property_tree::ptree_error& e) {
1260 B2FATAL(
"Error when loading json file: " << e.what());
1268 dbCDClayerTimeCut.
import(iov);
1269 B2INFO(
"dbCDClayerTimeCut imported to database.");
1275 if (dbCDClayerTimeCut.
isValid()) {
1276 dbCDClayerTimeCut->dump();
1278 B2WARNING(
"DBObjPtr<CDClayerTimeCut> not valid for the current run.");
1289 ifs.open(fileName.c_str());
1291 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
1294 B2INFO(fileName <<
": open for reading");
1301 double back[np], fwrd[np], tension;
1306 for (
int i = 0; i < np; ++i) {
1309 for (
int i = 0; i < np; ++i) {
1313 if (ifs.eof())
break;
1318 for (
int i = 0; i < np; ++i) {
1329 if (nRead != m_nSenseWires) B2FATAL(
"CDCDatabaseimporter::importWirPosMisalign: #lines read-in (=" << nRead <<
1330 ") is inconsistent with total #sense wires (=" << m_nSenseWires <<
") !");
1335 m_lastExperiment, m_lastRun);
1337 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.
void printBadBoards()
Get the badboard table from the database and print it.
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.
int m_lastExperiment
Last experiment.
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 importBadBoards(std::string fileName)
Import badboards table 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.
int m_firstExperiment
CDC geometory parameter.
void importAlphaScaleFactors(std::string fileName)
Import alpha scale factors table to the database.
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 printAlphaScaleFactors()
Get the fudge factor table from the database and print it.
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