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/CDCWireHitRequirements.h>
40 #include <cdc/dbobjects/CDCCrossTalkLibrary.h>
42 #include <cdc/geometry/CDCGeometryPar.h>
44 #include <TTreeReader.h>
49 #include <boost/iostreams/filtering_stream.hpp>
50 #include <boost/iostreams/device/file.hpp>
51 #include <boost/iostreams/filter/gzip.hpp>
53 #include <boost/property_tree/ptree.hpp>
54 #include <boost/property_tree/json_parser.hpp>
59 void CDCDatabaseImporter::importTimeZero(std::string fileName)
62 stream.open(fileName.c_str());
64 B2ERROR(
"openFile: " << fileName <<
" *** failed to open");
67 B2INFO(fileName <<
": open for reading");
78 stream >> iL >> iC >> t0;
79 if (stream.eof())
break;
89 if (nRead != nSenseWires) B2FATAL(
"#lines read-in (=" << nRead <<
") is inconsistent with total #sense wires (=" << nSenseWires <<
93 m_lastExperiment, m_lastRun);
96 B2RESULT(
"Time zero table imported to database.");
101 void CDCDatabaseImporter::importChannelMap(std::string fileName)
103 std::ifstream stream;
104 stream.open(fileName.c_str());
106 B2ERROR(
"openFile: " << fileName <<
" *** failed to open");
109 B2INFO(fileName <<
": open for reading");
119 while (!stream.eof()) {
120 stream >> isl >> il >> iw >> iBoard >> iCh;
126 m_lastExperiment, m_lastRun);
130 B2RESULT(
"Channel map imported to database.");
135 void CDCDatabaseImporter::importFEElectronics(std::string fileName)
137 std::ifstream stream;
138 stream.open(fileName.c_str());
140 B2ERROR(
"openFile: " << fileName <<
" *** failed to open");
143 B2INFO(fileName <<
": open for reading");
148 short ib, width, delay, aTh, tThmV;
151 while (stream >> ib) {
153 stream >> width >> delay >> aTh >> tThmV;
157 cf.
appendNew(ib, width, delay, aTh, tThmV);
162 m_lastExperiment, m_lastRun);
166 B2RESULT(
"FEEElectronics imported to database.");
170 void CDCDatabaseImporter::importEDepToADC(std::string fileName)
172 std::ifstream stream;
173 stream.open(fileName.c_str());
175 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
178 B2INFO(fileName <<
": open for reading");
183 unsigned short paramMode(0), nParams(0);
184 stream >> paramMode >> nParams;
185 etoa->setParamMode(paramMode);
187 unsigned short groupId(0);
189 B2INFO(paramMode <<
" " << nParams <<
" " << groupId);
190 if (groupId > 1) B2FATAL(
"invalid groupId now !");
191 etoa->setGroupID(groupId);
193 unsigned short id = 0;
194 std::vector<float> coeffs(nParams);
197 while (stream >>
id) {
198 for (
unsigned short i = 0; i < nParams; ++i) {
202 etoa->setParams(
id, coeffs);
206 unsigned short nId = nSuperLayers;
209 }
else if (groupId == 2) {
212 if (nRead != nId) B2FATAL(
"#lines read-in (=" << nRead <<
") is not equal #ids (=" << nId <<
") !");
215 m_lastExperiment, m_lastRun);
217 B2RESULT(
"EDep-toADC table imported to database.");
221 void CDCDatabaseImporter::importBadWire(std::string fileName)
223 std::ifstream stream;
224 stream.open(fileName.c_str());
226 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
229 B2INFO(fileName <<
": open for reading");
234 int iL(0), iC(0), nRead(0);
238 stream >> iL >> iC >> effi;
239 if (stream.eof())
break;
241 bw->setWire(
WireID(iL, iC), effi);
248 if (nRead >
static_cast<int>(nSenseWires)) B2FATAL(
"#lines read-in (=" << nRead <<
") is larger than #sense wires (=" << nSenseWires
252 m_lastExperiment, m_lastRun);
254 B2RESULT(
"BadWire table imported to database.");
258 void CDCDatabaseImporter::importPropSpeed(std::string fileName)
260 std::ifstream stream;
261 stream.open(fileName.c_str());
263 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
266 B2INFO(fileName <<
": open for reading");
271 int iCL(0), nRead(0);
275 stream >> iCL >> speed;
276 if (stream.eof())
break;
279 ps->setSpeed(iCL, speed);
287 if (nRead != MAX_N_SLAYERS) B2FATAL(
"#lines read-in (=" << nRead <<
") is no equal #sense layers (=" << MAX_N_SLAYERS <<
") !");
290 m_lastExperiment, m_lastRun);
292 B2RESULT(
"PropSpeed table imported to database.");
296 void CDCDatabaseImporter::importTimeWalk(std::string fileName)
298 std::ifstream stream;
299 stream.open(fileName.c_str());
301 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
304 B2INFO(fileName <<
": open for reading");
309 unsigned short mode(0), nParams(0);
310 stream >> mode >> nParams;
311 tw->setTwParamMode(mode);
313 unsigned short iBoard(0);
314 std::vector<float> coeffs(nParams);
317 while (stream >> iBoard) {
318 for (
unsigned short i = 0; i < nParams; ++i) {
322 tw->setTimeWalkParams(iBoard, coeffs);
329 if (nRead != nBoards) B2FATAL(
"#lines read-in (=" << nRead <<
") is not equal #boards (=" << nBoards <<
") !");
332 m_lastExperiment, m_lastRun);
334 B2RESULT(
"Time-walk coeff. table imported to database.");
338 void CDCDatabaseImporter::importXT(std::string fileName)
346 boost::iostreams::filtering_istream ifs;
347 if ((fileName.rfind(
".gz") != string::npos) && (fileName.length() - fileName.rfind(
".gz") == 3)) {
348 ifs.push(boost::iostreams::gzip_decompressor());
350 ifs.push(boost::iostreams::file_source(fileName));
352 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
354 B2INFO(fileName <<
": open for reading");
356 const double degrad = M_PI / 180.;
357 const double raddeg = 180. / M_PI;
359 unsigned short nAlphaBins = 0;
360 if (ifs >> nAlphaBins) {
361 if (nAlphaBins == 0 || nAlphaBins > maxNAlphaPoints) B2FATAL(
"Fail to read alpha bins !");
363 B2FATAL(
"Fail to read alpha bins !");
365 std::array<float, 3> alpha3;
366 for (
unsigned short i = 0; i < nAlphaBins; ++i) {
367 for (
unsigned short j = 0; j < 3; ++j) {
371 xt->setAlphaBin(alpha3);
375 unsigned short nThetaBins = 0;
376 if (ifs >> nThetaBins) {
377 if (nThetaBins == 0 || nThetaBins > maxNThetaPoints) B2FATAL(
"Fail to read theta bins !");
379 B2FATAL(
"Fail to read theta bins !");
381 std::array<float, 3> theta3;
383 for (
unsigned short i = 0; i < nThetaBins; ++i) {
384 for (
unsigned short j = 0; j < 3; ++j) {
388 xt->setThetaBin(theta3);
401 short xtParamMode, np;
402 unsigned short iCL, iLR;
403 const unsigned short npx = nXTParams - 1;
405 double theta, alpha, dummy1;
408 ifs >> xtParamMode >> np;
409 if (xtParamMode < 0 || xtParamMode > 1) B2FATAL(
"Invalid xt param mode read !");
410 if (np <= 0 || np > npx) B2FATAL(
"No. of xt-params. outside limits !");
412 xt->setXtParamMode(xtParamMode);
414 const double epsi = 0.1;
417 ifs >> theta >> alpha >> dummy1 >> iLR;
418 for (
int i = 0; i < np; ++i) {
424 for (
unsigned short i = 0; i < nAlphaBins; ++i) {
425 if (fabs(alpha - xt->getAlphaBin(i)[2]*raddeg) < epsi) {
430 if (ialpha < 0) B2FATAL(
"alphas in xt.dat are inconsistent !");
433 for (
unsigned short i = 0; i < nThetaBins; ++i) {
434 if (fabs(theta - xt->getThetaBin(i)[2]*raddeg) < epsi) {
439 if (itheta < 0) B2FATAL(
"thetas in xt.dat are inconsistent !");
442 std::vector<float> xtbuff;
443 for (
int i = 0; i < np; ++i) {
444 xtbuff.push_back(xtc[i]);
447 xt->setXtParams(iCL, iLR, ialpha, itheta, xtbuff);
451 boost::iostreams::close(ifs);
454 m_lastExperiment, m_lastRun);
456 B2RESULT(
"XT table imported to database.");
459 void CDCDatabaseImporter::importSigma(std::string fileName)
466 ifs.open(fileName.c_str());
468 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
470 B2INFO(fileName <<
": open for reading");
472 const double degrad = M_PI / 180.;
473 const double raddeg = 180. / M_PI;
475 unsigned short nAlphaBins = 0;
476 if (ifs >> nAlphaBins) {
477 if (nAlphaBins == 0 || nAlphaBins > maxNAlphaPoints) B2FATAL(
"Fail to read alpha bins !");
479 B2FATAL(
"Fail to read alpha bins !");
481 std::array<float, 3> alpha3;
482 for (
unsigned short i = 0; i < nAlphaBins; ++i) {
483 for (
unsigned short j = 0; j < 3; ++j) {
487 sg->setAlphaBin(alpha3);
491 unsigned short nThetaBins = 0;
492 if (ifs >> nThetaBins) {
493 if (nThetaBins == 0 || nThetaBins > maxNThetaPoints) B2FATAL(
"Fail to read theta bins !");
495 B2FATAL(
"Fail to read theta bins !");
497 std::array<float, 3> theta3;
499 for (
unsigned short i = 0; i < nThetaBins; ++i) {
500 for (
unsigned short j = 0; j < 3; ++j) {
504 sg->setThetaBin(theta3);
509 short sgParamMode, np;
510 unsigned short iCL, iLR;
511 const unsigned short npx = nSigmaParams;
516 ifs >> sgParamMode >> np;
517 if (sgParamMode < 0 || sgParamMode > 1) B2FATAL(
"Invalid sigma param mode read !");
518 if (np <= 0 || np > npx) B2FATAL(
"No. of sgm-params. outside limits !");
520 sg->setSigmaParamMode(sgParamMode);
524 sg->setMaxSpaceResol(maxSigma);
526 const double epsi = 0.1;
529 ifs >> theta >> alpha >> iLR;
530 for (
int i = 0; i < np; ++i) {
536 for (
unsigned short i = 0; i < nAlphaBins; ++i) {
537 if (fabs(alpha - sg->getAlphaBin(i)[2]*raddeg) < epsi) {
542 if (ialpha < 0) B2FATAL(
"alphas in sigma.dat are inconsistent !");
545 for (
unsigned short i = 0; i < nThetaBins; ++i) {
546 if (fabs(theta - sg->getThetaBin(i)[2]*raddeg) < epsi) {
551 if (itheta < 0) B2FATAL(
"thetas in sigma.dat are inconsistent !");
554 std::vector<float> sgbuff;
555 for (
int i = 0; i < np; ++i) {
556 sgbuff.push_back(sgm[i]);
559 sg->setSigmaParams(iCL, iLR, ialpha, itheta, sgbuff);
565 m_lastExperiment, m_lastRun);
567 B2RESULT(
"Sigma table imported to database.");
571 void CDCDatabaseImporter::importFFactor(std::string fileName)
573 std::ifstream stream;
574 stream.open(fileName.c_str());
576 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
579 B2INFO(fileName <<
": open for reading");
584 unsigned short groupId(0), nParams(0);
585 stream >> groupId >> nParams;
586 B2INFO(groupId <<
" " << nParams);
587 if (groupId != 0) B2FATAL(
"invalid groupId now !");
588 etoa->setGroupID(groupId);
590 unsigned short id = 0;
591 std::vector<float> coeffs(nParams);
594 while (stream >>
id) {
595 for (
unsigned short i = 0; i < nParams; ++i) {
599 etoa->setFactors(
id, coeffs);
603 unsigned short nId = 1;
604 if (nRead != nId) B2FATAL(
"#lines read-in (=" << nRead <<
") is not equal #ids (=" << nId <<
") !");
607 m_lastExperiment, m_lastRun);
609 B2RESULT(
"Fudge factor table imported to database.");
613 void CDCDatabaseImporter::importDisplacement(std::string fileName)
618 boost::iostreams::filtering_istream ifs;
619 if ((fileName.rfind(
".gz") != string::npos) && (fileName.length() - fileName.rfind(
".gz") == 3)) {
620 ifs.push(boost::iostreams::gzip_decompressor());
622 ifs.push(boost::iostreams::file_source(fileName));
624 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
626 B2INFO(fileName <<
": open for reading");
632 double back[np], fwrd[np];
638 for (
int i = 0; i < np; ++i) {
641 for (
int i = 0; i < np; ++i) {
646 if (ifs.eof())
break;
650 TVector3 fwd(fwrd[0], fwrd[1], fwrd[2]);
651 TVector3 bwd(back[0], back[1], back[2]);
655 if (nRead != nSenseWires) B2FATAL(
"CDCDatabaseimporter::importDisplacement: #lines read-in (=" << nRead <<
656 ") is inconsistent with total #sense wires (=" << nSenseWires <<
") !");
659 boost::iostreams::close(ifs);
662 m_lastExperiment, m_lastRun);
664 B2RESULT(
"Wire displasement table imported to database.");
668 void CDCDatabaseImporter::importWirPosAlign(std::string fileName)
672 boost::iostreams::filtering_istream ifs;
673 if ((fileName.rfind(
".gz") != string::npos) && (fileName.length() - fileName.rfind(
".gz") == 3)) {
674 ifs.push(boost::iostreams::gzip_decompressor());
676 ifs.push(boost::iostreams::file_source(fileName));
678 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
681 B2INFO(fileName <<
": open for reading");
688 double back[np], fwrd[np], tension;
693 for (
int i = 0; i < np; ++i) {
696 for (
int i = 0; i < np; ++i) {
700 if (ifs.eof())
break;
705 for (
int i = 0; i < np; ++i) {
706 al->set(wire, CDCAlignment::wireBwdX, back[0]);
707 al->set(wire, CDCAlignment::wireBwdY, back[1]);
708 al->set(wire, CDCAlignment::wireBwdZ, back[2]);
709 al->set(wire, CDCAlignment::wireFwdX, fwrd[0]);
710 al->set(wire, CDCAlignment::wireFwdY, fwrd[1]);
711 al->set(wire, CDCAlignment::wireFwdZ, fwrd[2]);
713 al->set(wire, CDCAlignment::wireTension, tension);
716 if (nRead != nSenseWires) B2FATAL(
"CDCDatabaseimporter::importWirPosAlign: #lines read-in (=" << nRead <<
717 ") is inconsistent with total #sense wires (=" << nSenseWires <<
") !");
720 boost::iostreams::close(ifs);
723 m_lastExperiment, m_lastRun);
725 B2RESULT(
"Wire alignment table imported to database.");
729 void CDCDatabaseImporter::printChannelMap()
734 for (
const auto& cm : channelMaps) {
735 std::cout << cm.getISuperLayer() <<
" " << cm.getILayer()
736 <<
" " << cm.getIWire() <<
" "
737 << cm.getBoardID() <<
" " << cm.getBoardChannel() << std::endl;
742 void CDCDatabaseImporter::printFEElectronics()
745 for (
const auto& cf : fEElectronics) {
746 std::cout << cf.getBoardID() <<
" " << cf.getWidthOfTimeWindow() <<
" " << cf.getTrgDelay() <<
" " << cf.getADCThresh() <<
" " <<
747 cf.getTDCThreshInMV() << std::endl;
754 void CDCDatabaseImporter::printEDepToADC()
760 void CDCDatabaseImporter::printTimeZero()
774 void CDCDatabaseImporter::printBadWire()
780 void CDCDatabaseImporter::printPropSpeed()
786 void CDCDatabaseImporter::printTimeWalk()
792 void CDCDatabaseImporter::printXT()
798 void CDCDatabaseImporter::printSigma()
804 void CDCDatabaseImporter::printFFactor()
810 void CDCDatabaseImporter::printDisplacement()
813 for (
const auto& disp : displacements) {
814 B2INFO(disp.getICLayer() <<
" " << disp.getIWire() <<
" "
815 << disp.getXBwd() <<
" " << disp.getYBwd() <<
" " << disp.getZBwd() <<
" "
816 << disp.getXFwd() <<
" " << disp.getYFwd() <<
" " << disp.getZFwd() <<
" " << disp.getTension());
820 void CDCDatabaseImporter::printWirPosAlign()
826 void CDCDatabaseImporter::printWirPosMisalign()
833 void CDCDatabaseImporter::importADCDeltaPedestal(std::string fileName)
835 std::ifstream stream;
836 stream.open(fileName.c_str());
837 if (!stream.is_open()) {
838 B2ERROR(
"openFile: " << fileName <<
" *** failed to open");
841 B2INFO(fileName <<
": open for reading");
856 stream >> iB >> iC >> ped;
858 if (stream.eof())
break;
861 B2FATAL(
"sample window is zero !");
863 dbPed->setSamplingWindow(sample);
865 dbPed->setPedestal(iB, iC, ped);
873 m_lastExperiment, m_lastRun);
876 B2RESULT(
"ADC delta pedestal table imported to database.");
879 void CDCDatabaseImporter::importADCDeltaPedestal()
886 m_lastExperiment, m_lastRun);
889 B2RESULT(
"ADC delta pedestal w/ zero imported to database.");
892 void CDCDatabaseImporter::printADCDeltaPedestal()
899 void CDCDatabaseImporter::importCDCWireHitRequirements(
const std::string& jsonFileName)
const
903 boost::property_tree::ptree tree;
908 B2INFO(
"Loading json file: " << jsonFileName);
909 boost::property_tree::read_json(jsonFileName, tree);
911 }
catch (boost::property_tree::ptree_error& e) {
912 B2FATAL(
"Error when loading json file: " << e.what());
919 m_lastExperiment, m_lastRun);
922 B2RESULT(
"CDCWireHit requirements imported to database.");
925 void CDCDatabaseImporter::printCDCWireHitRequirements()
const
930 dbWireHitReq->dump();
932 B2WARNING(
"DBObjPtr<CDCWireHitRequirements> not valid for the current run.");
936 void CDCDatabaseImporter::importCDCCrossTalkLibrary(
const std::string& rootFileName)
const
941 TFile fIn = TFile(rootFileName.c_str());
942 TTreeReader reader(
"my_ttree", &fIn);
943 TTreeReaderValue<UChar_t> Board(reader,
"Board");
944 TTreeReaderValue<UChar_t> Channel(reader,
"Channel");
945 TTreeReaderValue<Short_t> Asic_ADC0(reader,
"Asic_ADC0");
946 TTreeReaderValue<Short_t> Asic_TDC0(reader,
"Asic_TDC0");
947 TTreeReaderValue<Short_t> Asic_TOT0(reader,
"Asic_TOT0");
948 TTreeReaderValue<Short_t> Asic_ADC1(reader,
"Asic_ADC1");
949 TTreeReaderValue<Short_t> Asic_TDC1(reader,
"Asic_TDC1");
950 TTreeReaderValue<Short_t> Asic_TOT1(reader,
"Asic_TOT1");
951 TTreeReaderValue<Short_t> Asic_ADC2(reader,
"Asic_ADC2");
952 TTreeReaderValue<Short_t> Asic_TDC2(reader,
"Asic_TDC2");
953 TTreeReaderValue<Short_t> Asic_TOT2(reader,
"Asic_TOT2");
954 TTreeReaderValue<Short_t> Asic_ADC3(reader,
"Asic_ADC3");
955 TTreeReaderValue<Short_t> Asic_TDC3(reader,
"Asic_TDC3");
956 TTreeReaderValue<Short_t> Asic_TOT3(reader,
"Asic_TOT3");
957 TTreeReaderValue<Short_t> Asic_ADC4(reader,
"Asic_ADC4");
958 TTreeReaderValue<Short_t> Asic_TDC4(reader,
"Asic_TDC4");
959 TTreeReaderValue<Short_t> Asic_TOT4(reader,
"Asic_TOT4");
960 TTreeReaderValue<Short_t> Asic_ADC5(reader,
"Asic_ADC5");
961 TTreeReaderValue<Short_t> Asic_TDC5(reader,
"Asic_TDC5");
962 TTreeReaderValue<Short_t> Asic_TOT5(reader,
"Asic_TOT5");
963 TTreeReaderValue<Short_t> Asic_ADC6(reader,
"Asic_ADC6");
964 TTreeReaderValue<Short_t> Asic_TDC6(reader,
"Asic_TDC6");
965 TTreeReaderValue<Short_t> Asic_TOT6(reader,
"Asic_TOT6");
966 TTreeReaderValue<Short_t> Asic_ADC7(reader,
"Asic_ADC7");
967 TTreeReaderValue<Short_t> Asic_TDC7(reader,
"Asic_TDC7");
968 TTreeReaderValue<Short_t> Asic_TOT7(reader,
"Asic_TOT7");
970 while (reader.Next()) {
982 UChar_t asicCh = *Channel % 8;
983 Short_t ADC = record[asicCh].
ADC;
984 dbCDCCrossTalkLibrary->addAsicRecord(asicCh, ADC, record);
990 fIn.GetObject(
"ProbXTalk", prob);
991 for (
size_t a = 1; a <= 8196; a += 1) {
992 probs[a - 1] = prob->GetBinContent(a);
995 dbCDCCrossTalkLibrary->setPCrossTalk(probs);
997 dbCDCCrossTalkLibrary->dump(0);
999 m_lastExperiment, m_lastRun);
1000 dbCDCCrossTalkLibrary.
import(iov);
1001 B2RESULT(
"CDCCrossTalkLibrary requirements imported to database.");
1004 void CDCDatabaseImporter::printCDCCrossTalkLibrary()
const
1007 if (dbCDCCrossTalkLib.
isValid()) {
1008 dbCDCCrossTalkLib->dump(1);
1010 B2ERROR(
"DBObjPtr<CDCCrossTalkLibrary> not valid for the current run.");
1014 void CDCDatabaseImporter::testCDCCrossTalkLibrary(
bool spotChecks)
const
1018 if (dbCDCCrossTalkLib.
isValid()) {
1021 B2INFO(
"Performing CDCCrossTalkLibrary checks");
1022 auto timer =
new Utils::Timer(
"CDCCrossTalkLibrary checks took");
1025 for (Short_t ADC = 0; ADC < 8196; ADC += 1) {
1026 for (Short_t channel = 0; channel < 48; channel += 1) {
1027 for (
size_t rep = 0; rep < 100; rep += 1) {
1028 auto xtalk = dbCDCCrossTalkLib->getLibraryCrossTalk(channel, 4999, ADC, 5, 0,
false);
1030 size += xtalk.size();
1034 B2INFO(
"CDCCrossTalkLibrary called " << counter <<
" times. Total number of cross talk hits " << size);
1040 Short_t ADC_spot_checks[5] = {2, 100, 500, 1000, 5000};
1041 for (
auto ADC : ADC_spot_checks) {
1042 B2INFO(
"CHECK ADC=" << ADC);
1044 size_t NRep = ADC < 50 ? 100 : 10;
1045 for (
size_t rep = 0; rep < NRep; rep += 1) {
1046 auto xtalk = dbCDCCrossTalkLib->getLibraryCrossTalk(0, 4999, ADC, 5, 0,
true);
1047 B2INFO(
"Size = " << xtalk.size());
1048 for (
auto [channel, rec] : xtalk) {
1049 B2INFO(
"Channel:" << channel <<
" TDC,ADC,TOT:" << rec.TDC <<
"," << rec.ADC <<
"," << rec.TOT);
1054 B2ERROR(
"DBObjPtr<CDCCrossTalkLibrary> not valid for the current run.");
1061 void CDCDatabaseImporter::importWirPosMisalign(std::string fileName)
1064 ifs.open(fileName.c_str());
1066 B2FATAL(
"openFile: " << fileName <<
" *** failed to open");
1069 B2INFO(fileName <<
": open for reading");
1076 double back[np], fwrd[np], tension;
1081 for (
int i = 0; i < np; ++i) {
1084 for (
int i = 0; i < np; ++i) {
1088 if (ifs.eof())
break;
1093 for (
int i = 0; i < np; ++i) {
1094 mal->set(wire, CDCMisalignment::wireBwdX, back[0]);
1095 mal->set(wire, CDCMisalignment::wireBwdY, back[1]);
1096 mal->set(wire, CDCMisalignment::wireBwdZ, back[2]);
1097 mal->set(wire, CDCMisalignment::wireFwdX, fwrd[0]);
1098 mal->set(wire, CDCMisalignment::wireFwdY, fwrd[1]);
1099 mal->set(wire, CDCMisalignment::wireFwdZ, fwrd[2]);
1101 mal->set(wire, CDCMisalignment::wireTension, tension);
1104 if (nRead != nSenseWires) B2FATAL(
"CDCDatabaseimporter::importWirPosMisalign: #lines read-in (=" << nRead <<
1105 ") is inconsistent with total #sense wires (=" << nSenseWires <<
") !");
1110 m_lastExperiment, m_lastRun);
1112 B2RESULT(
"Wire misalignment table imported to database.");
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