Belle II Software development
CDCDatabaseImporter Class Reference

CDC database importer. More...

#include <CDCDatabaseImporter.h>

Public Member Functions

 CDCDatabaseImporter ()
 Default constructor.
 
 CDCDatabaseImporter (int fexp, int frun, int lexp, int lrun)
 Constructor.
 
virtual ~CDCDatabaseImporter ()
 Destructor.
 
void importChannelMap (std::string fileName)
 Import channel map to the data base.
 
void printChannelMap ()
 Get the channel map from the database and print it.
 
void importFEElectronics (std::string fileName)
 Import FEE params.
 
void printFEElectronics ()
 Get FEE params.
 
void importEDepToADC (std::string fileName)
 Import edep-to-adc params.
 
void printEDepToADC ()
 Get edep-to-adc params.
 
void importCorrToThreshold (std::string fileName)
 Import corrtothreshold to the data base.
 
void printCorrToThreshold ()
 Get corrtothreshold from the database and print.
 
void importTimeZero (std::string fileName)
 Import t0 table to the data base.
 
void printTimeZero ()
 Get the t0 table from the database and print it.
 
void importADCDeltaPedestal (std::string fileName)
 Import ADC delta pedestal table to the data base specifying the text data.
 
void importADCDeltaPedestal ()
 Import ADC delta pedestal with all 0.
 
void printADCDeltaPedestal ()
 Get the ADC delta pedestal table from the database and print it.
 
void importBadWire (std::string fileName)
 Import badwire table to the data base.
 
void printBadWire ()
 Get the badwire table from the database and print it.
 
void importPropSpeed (std::string fileName)
 Import propspeed table to the database.
 
void printPropSpeed ()
 Get the propspeed table from the database and print it.
 
void importTimeWalk (std::string fileName)
 Import time-walk coeff.
 
void printTimeWalk ()
 Get the time-walk coeff.
 
void importXT (std::string fileName)
 Import xt table to the database.
 
void printXT ()
 Get the xt table from the database and print it.
 
void importSigma (std::string fileName)
 Import sigma table to the database.
 
void printSigma ()
 Get the sigma table from the database and print it.
 
void importFFactor (std::string fileName)
 Import fudge factor table to the database.
 
void printFFactor ()
 Get the fudge factor table from the database and print it.
 
void importDisplacement (std::string fileName)
 Import displacement of wire position to the database.
 
void printDisplacement ()
 Get the displacement of wire position from the database and print it.
 
void importWirPosAlign (std::string fileName)
 Import wire alignment table to the database.
 
void printWirPosAlign ()
 Get the wire alignment table from the database and print it.
 
void importWirPosMisalign (std::string fileName)
 Import wire misalignment table to the database.
 
void printWirPosMisalign ()
 Get the wire misalignment table from the database and print it.
 
void importCDCWireHitRequirements (const std::string &jsonFileName) const
 Import CDCWireHits cut values to the database.
 
void printCDCWireHitRequirements () const
 Get CDCWireHits cut values from the database and print them.
 
void importCDCCrossTalkLibrary (const std::string &rootFileName) const
 Import crosstalk library prepared in rootFileName.
 
void printCDCCrossTalkLibrary () const
 Print the content of the crosstalk library.
 
void testCDCCrossTalkLibrary (bool spotChecks=false) const
 Do some basic testing of the CDCCrossTalkLibrary.
 
void importCDClayerTimeCut (const std::string &jsonFileName) const
 import CDClayerTimeCut
 
void printCDClayerTimeCut () const
 Print content of CDClayerTimeCut.
 

Private Attributes

int m_firstExperiment
 CDC geometory parameter.
 
int m_firstRun
 First run.
 
int m_lastExperiment
 Last experiment.
 
int m_lastRun
 Last run.
 
ushort m_firstLayerOffset = 0
 Offset of first layer in case some CDC layers are removed.
 
ushort m_superLayerOffset = 0
 Offset of first super layer in case some CDC super layers are removed.
 
ushort m_nSenseWires = 14336
 Number of sense wires in the CDC.
 

Detailed Description

CDC database importer.

Definition at line 22 of file CDCDatabaseImporter.h.

Constructor & Destructor Documentation

◆ CDCDatabaseImporter() [1/2]

CDCDatabaseImporter ( )
inline

Default constructor.

Definition at line 29 of file CDCDatabaseImporter.h.

29 :
32 {
33 }
int m_lastExperiment
Last experiment.
int m_firstExperiment
CDC geometory parameter.

◆ CDCDatabaseImporter() [2/2]

CDCDatabaseImporter ( int  fexp,
int  frun,
int  lexp,
int  lrun 
)

Constructor.

Definition at line 61 of file CDCDatabaseImporter.cc.

61 :
63{
68}
ushort m_superLayerOffset
Offset of first super layer in case some CDC super layers are removed.
ushort m_nSenseWires
Number of sense wires in the CDC.
ushort m_firstLayerOffset
Offset of first layer in case some CDC layers are removed.
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.

◆ ~CDCDatabaseImporter()

virtual ~CDCDatabaseImporter ( )
inlinevirtual

Destructor.

Definition at line 44 of file CDCDatabaseImporter.h.

45 {}

Member Function Documentation

◆ importADCDeltaPedestal() [1/2]

void importADCDeltaPedestal ( )

Import ADC delta pedestal with all 0.

Definition at line 980 of file CDCDatabaseImporter.cc.

981{
982
984 dbPed.construct();
985
988 dbPed.import(iov);
989
990 B2INFO("ADC delta pedestal w/ zero imported to database.");
991}
bool import(const IntervalOfValidity &iov)
Import the object to database.
Definition: DBImportBase.cc:36
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.
A class that describes the interval of experiments/runs for which an object in the database is valid.

◆ importADCDeltaPedestal() [2/2]

void importADCDeltaPedestal ( std::string  fileName)

Import ADC delta pedestal table to the data base specifying the text data.

Definition at line 934 of file CDCDatabaseImporter.cc.

935{
936 std::ifstream stream;
937 stream.open(fileName.c_str());
938 if (!stream.is_open()) {
939 B2ERROR("openFile: " << fileName << " *** failed to open");
940 return;
941 }
942 B2INFO(fileName << ": open for reading");
943
945 dbPed.construct();
946
947 int iB(0);
948 int iC(0);
949 float ped(0);
950 int nRead(0);
951 int sample(0);
952
953 while (true) {
954 if (nRead == 0) {
955 stream >> sample;
956 } else {
957 stream >> iB >> iC >> ped;
958 }
959 if (stream.eof()) break;
960 if (nRead == 0) {
961 if (sample == 0) {
962 B2FATAL("sample window is zero !");
963 }
964 dbPed->setSamplingWindow(sample);
965 } else {
966 dbPed->setPedestal(iB, iC, ped);
967 }
968 ++nRead;
969
970 }
971 stream.close();
972
975 dbPed.import(iov);
976
977 B2INFO("ADC delta pedestal table imported to database.");
978}

◆ importBadWire()

void importBadWire ( std::string  fileName)

Import badwire table to the data base.

Definition at line 249 of file CDCDatabaseImporter.cc.

250{
251 std::ifstream stream;
252 stream.open(fileName.c_str());
253 if (!stream) {
254 B2FATAL("openFile: " << fileName << " *** failed to open");
255 return;
256 }
257 B2INFO(fileName << ": open for reading");
258
260 bw.construct();
261
262 uint iL(0), iC(0), nRead(0);
263 double effi(0.);
264
265 while (true) {
266 stream >> iL >> iC >> effi;
267 if (stream.eof()) break;
268
269 if (iL < m_firstLayerOffset) {
270 continue;
271 }
272
273 ++nRead;
274 bw->setWire(WireID(iL, iC), effi);
275 // if (m_debug) {
276 // std::cout << iL << " " << iC << " " << effi << std::endl;
277 // }
278 }
279 stream.close();
280
281 if (nRead > static_cast<int>(m_nSenseWires)) B2FATAL("#lines read-in (=" << nRead << ") is larger than #sense wires (=" <<
282 m_nSenseWires << ") !");
283
286 bw.import(iov);
287 B2INFO("BadWire table imported to database.");
288}
Class to identify a wire inside the CDC.
Definition: WireID.h:34

◆ importCDCCrossTalkLibrary()

void importCDCCrossTalkLibrary ( const std::string &  rootFileName) const

Import crosstalk library prepared in rootFileName.

Definition at line 1037 of file CDCDatabaseImporter.cc.

1038{
1039 DBImportObjPtr<CDCCrossTalkLibrary> dbCDCCrossTalkLibrary;
1040 dbCDCCrossTalkLibrary.construct();
1041
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");
1070
1071 while (reader.Next()) {
1072 asicChannels record{
1073 asicChannel{*Asic_TDC0, *Asic_ADC0, *Asic_TOT0},
1074 asicChannel{*Asic_TDC1, *Asic_ADC1, *Asic_TOT1},
1075 asicChannel{*Asic_TDC2, *Asic_ADC2, *Asic_TOT2},
1076 asicChannel{*Asic_TDC3, *Asic_ADC3, *Asic_TOT3},
1077 asicChannel{*Asic_TDC4, *Asic_ADC4, *Asic_TOT4},
1078 asicChannel{*Asic_TDC5, *Asic_ADC5, *Asic_TOT5},
1079 asicChannel{*Asic_TDC6, *Asic_ADC6, *Asic_TOT6},
1080 asicChannel{*Asic_TDC7, *Asic_ADC7, *Asic_TOT7}
1081 };
1082 // Determine ADC of the signal
1083 UChar_t asicCh = *Channel % 8;
1084 Short_t ADC = record[asicCh].ADC;
1085 dbCDCCrossTalkLibrary->addAsicRecord(asicCh, ADC, record);
1086 }
1087
1088 // Now also get the x-talk probability
1089 double probs[8196];
1090 TH1F* prob;
1091 fIn.GetObject("ProbXTalk", prob);
1092 for (size_t a = 1; a <= 8196; a += 1) {
1093 probs[a - 1] = prob->GetBinContent(a);
1094 }
1095 fIn.Close();
1096 dbCDCCrossTalkLibrary->setPCrossTalk(probs);
1097
1098 dbCDCCrossTalkLibrary->dump(0);
1101 dbCDCCrossTalkLibrary.import(iov);
1102 B2INFO("CDCCrossTalkLibrary requirements imported to database.");
1103}
array< asicChannel, 8 > asicChannels
fixed sized array of ASIC channels
record to be used to store ASIC info

◆ importCDClayerTimeCut()

void importCDClayerTimeCut ( const std::string &  jsonFileName) const

import CDClayerTimeCut

Definition at line 1160 of file CDCDatabaseImporter.cc.

1161{
1162 // Create a property tree
1163 boost::property_tree::ptree tree;
1164 try {
1165 // Load the json file in this property 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());
1170 }
1171
1172 DBImportObjPtr<CDClayerTimeCut> dbCDClayerTimeCut;
1173 dbCDClayerTimeCut.construct(tree);
1174
1177 dbCDClayerTimeCut.import(iov);
1178 B2INFO("dbCDClayerTimeCut imported to database.");
1179}

◆ importCDCWireHitRequirements()

void importCDCWireHitRequirements ( const std::string &  jsonFileName) const

Import CDCWireHits cut values to the database.

The cut values are read from a json file. An example of legal json file can be found at cdc/data/CDCWireHitRequirements_example.json In the json file, upper values of -1 stand for unbounded.

Definition at line 1000 of file CDCDatabaseImporter.cc.

1001{
1002
1003 // Create a property tree
1004 boost::property_tree::ptree tree;
1005
1006 try {
1007
1008 // Load the json file in this property tree.
1009 B2INFO("Loading json file: " << jsonFileName);
1010 boost::property_tree::read_json(jsonFileName, tree);
1011
1012 } catch (boost::property_tree::ptree_error& e) {
1013 B2FATAL("Error when loading json file: " << e.what());
1014 }
1015
1017 dbWireHitReq.construct(tree);
1018
1021 dbWireHitReq.import(iov);
1022
1023 B2INFO("CDCWireHit requirements imported to database.");
1024}

◆ importChannelMap()

void importChannelMap ( std::string  fileName)

Import channel map to the data base.

Definition at line 117 of file CDCDatabaseImporter.cc.

118{
119 std::ifstream stream;
120 stream.open(fileName.c_str());
121 if (!stream) {
122 B2ERROR("openFile: " << fileName << " *** failed to open");
123 return;
124 }
125 B2INFO(fileName << ": open for reading");
126
128
129 uint isl;
130 uint il;
131 uint iw;
132 uint iBoard;
133 uint iCh;
134
135 while (!stream.eof()) {
136 stream >> isl >> il >> iw >> iBoard >> iCh;
137
138 if (il < m_firstLayerOffset) {
139 continue;
140 }
141
142 cm.appendNew(isl, il, iw, iBoard, iCh);
143 }
144 stream.close();
145
148
149 cm.import(iov);
150
151 B2INFO("Channel map imported to database.");
152
153}
Class for importing array of objects to the database.
Definition: DBImportArray.h:25
T * appendNew()
Construct a new T object at the end of the array.
Definition: DBImportArray.h:67

◆ importCorrToThreshold()

void importCorrToThreshold ( std::string  fileName)

Import corrtothreshold to the data base.

Definition at line 335 of file CDCDatabaseImporter.cc.

336{
337 std::ifstream stream;
338 stream.open(fileName.c_str());
339 if (!stream) {
340 B2FATAL("openFile: " << fileName << " *** failed to open");
341 return;
342 }
343 B2INFO(fileName << ": open for reading");
344
346 cr.construct();
347
348 uint iCL(0), nRead(0);
349 double param(1.);
350
351 while (true) {
352 stream >> iCL >> param;
353 if (stream.eof()) break;
354
355 if (iCL < m_firstLayerOffset) {
356 continue;
357 }
358
359 ++nRead;
360 cr->setParam(iCL, param);
361 }
362 stream.close();
363
364 if (nRead != c_maxNSenseLayers) B2FATAL("#lines read-in (=" << nRead << ") is not equal to #sense layers (=" << c_maxNSenseLayers <<
365 ") !");
366
369 cr.import(iov);
370 B2INFO("CorrToThreshold table imported to database.");
371}

◆ importDisplacement()

void importDisplacement ( std::string  fileName)

Import displacement of wire position to the database.

Definition at line 705 of file CDCDatabaseImporter.cc.

706{
707 //read alpha bins
708 // std::ifstream ifs;
709 // ifs.open(fileName.c_str());
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());
713 }
714 ifs.push(boost::iostreams::file_source(fileName));
715 if (!ifs) {
716 B2FATAL("openFile: " << fileName << " *** failed to open");
717 }
718 B2INFO(fileName << ": open for reading");
719
721
722 uint iL(0), iC(0);
723 const int np = 3;
724 double back[np], fwrd[np];
725 double tension = 0.;
726 unsigned nRead = 0;
727
728 while (true) {
729 ifs >> iL >> iC;
730 for (int i = 0; i < np; ++i) {
731 ifs >> back[i];
732 }
733 for (int i = 0; i < np; ++i) {
734 ifs >> fwrd[i];
735 }
736 ifs >> tension;
737
738 if (ifs.eof()) break;
739
740 if (iL < m_firstLayerOffset) {
741 continue;
742 }
743
744
745 ++nRead;
746 WireID wire(iL, iC);
747 ROOT::Math::XYZVector fwd(fwrd[0], fwrd[1], fwrd[2]);
748 ROOT::Math::XYZVector bwd(back[0], back[1], back[2]);
749 disp.appendNew(wire, fwd, bwd, tension);
750 }
751
752 if (nRead != m_nSenseWires) B2FATAL("CDCDatabaseimporter::importDisplacement: #lines read-in (=" << nRead <<
753 ") is inconsistent with total #sense wires (=" << m_nSenseWires << ") !");
754
755 // ifs.close();
756 boost::iostreams::close(ifs);
757
760 disp.import(iov);
761 B2INFO("Wire displasement table imported to database.");
762}

◆ importEDepToADC()

void importEDepToADC ( std::string  fileName)

Import edep-to-adc params.

to the data base.

Definition at line 191 of file CDCDatabaseImporter.cc.

192{
193 std::ifstream stream;
194 stream.open(fileName.c_str());
195 if (!stream) {
196 B2FATAL("openFile: " << fileName << " *** failed to open");
197 return;
198 }
199 B2INFO(fileName << ": open for reading");
200
202 etoa.construct();
203
204 unsigned short paramMode(0), nParams(0);
205 stream >> paramMode >> nParams;
206 etoa->setParamMode(paramMode);
207
208 unsigned short groupId(0);
209 stream >> groupId;
210 B2INFO(paramMode << " " << nParams << " " << groupId);
211 if (groupId > 1) B2FATAL("invalid groupId now !");
212 etoa->setGroupID(groupId);
213
214 unsigned short id = 0;
215 std::vector<float> coeffs(nParams);
216 uint nRead = 0;
217
218 while (stream >> id) {
219 for (unsigned short i = 0; i < nParams; ++i) {
220 stream >> coeffs[i];
221 }
222 // TODO: check these two if conditions
223 if (groupId == 0 and id < m_superLayerOffset) {
224 continue;
225 }
226 if (groupId == 1 and id < m_firstLayerOffset) {
227 continue;
228 }
229 ++nRead;
230 etoa->setParams(id, coeffs);
231 }
232 stream.close();
233
234 unsigned short nId = c_nSuperLayers;
235 if (groupId == 1) {
236 nId = c_maxNSenseLayers;
237 } else if (groupId == 2) {
238 nId = m_nSenseWires;
239 }
240 if (nRead != nId) B2FATAL("#lines read-in (=" << nRead << ") is not equal #ids (=" << nId << ") !");
241
244 etoa.import(iov);
245 B2INFO("EDep-toADC table imported to database.");
246}

◆ importFEElectronics()

void importFEElectronics ( std::string  fileName)

Import FEE params.

to the data base.

Definition at line 156 of file CDCDatabaseImporter.cc.

157{
158 std::ifstream stream;
159 stream.open(fileName.c_str());
160 if (!stream) {
161 B2ERROR("openFile: " << fileName << " *** failed to open");
162 return;
163 }
164 B2INFO(fileName << ": open for reading");
165
167
168 // short width, delay, aTh, tThmV, tTheV, l1late;
169 short ib, width, delay, aTh, tThmV;
170
171 // int i=-1;
172 while (stream >> ib) {
173 // stream >> delay >> aTh >> tThmV >> tTheV >> l1late;
174 stream >> width >> delay >> aTh >> tThmV;
175 // ++i;
176 // std::cout << i <<" "<< width << std::endl;
177 // cf.appendNew(width, delay, aTh, tThmV, tTheV, l1late);
178 cf.appendNew(ib, width, delay, aTh, tThmV);
179 }
180 stream.close();
181
184
185 cf.import(iov);
186
187 B2INFO("FEEElectronics imported to database.");
188}

◆ importFFactor()

void importFFactor ( std::string  fileName)

Import fudge factor table to the database.

Definition at line 663 of file CDCDatabaseImporter.cc.

664{
665 std::ifstream stream;
666 stream.open(fileName.c_str());
667 if (!stream) {
668 B2FATAL("openFile: " << fileName << " *** failed to open");
669 return;
670 }
671 B2INFO(fileName << ": open for reading");
672
674 etoa.construct();
675
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);
681
682 unsigned short id = 0;
683 std::vector<float> coeffs(nParams);
684 int nRead = 0;
685
686 while (stream >> id) {
687 for (unsigned short i = 0; i < nParams; ++i) {
688 stream >> coeffs[i];
689 }
690 ++nRead;
691 etoa->setFactors(id, coeffs);
692 }
693 stream.close();
694
695 unsigned short nId = 1;
696 if (nRead != nId) B2FATAL("#lines read-in (=" << nRead << ") is not equal #ids (=" << nId << ") !");
697
700 etoa.import(iov);
701 B2INFO("Fudge factor table imported to database.");
702}

◆ importPropSpeed()

void importPropSpeed ( std::string  fileName)

Import propspeed table to the database.

Definition at line 291 of file CDCDatabaseImporter.cc.

292{
293 std::ifstream stream;
294 stream.open(fileName.c_str());
295 if (!stream) {
296 B2FATAL("openFile: " << fileName << " *** failed to open");
297 return;
298 }
299 B2INFO(fileName << ": open for reading");
300
302 ps.construct();
303
304 uint iCL(0), nRead(0);
305 double speed(0.);
306
307 while (true) {
308 stream >> iCL >> speed;
309 if (stream.eof()) break;
310
311 if (iCL < m_firstLayerOffset) {
312 continue;
313 }
314
315 ++nRead;
316 // ps->setSpeed(speed);
317 ps->setSpeed(iCL, speed);
318 // ps->setSpeed(iCL, speed);
319 // if (m_debug) {
320 // std::cout << iCL << " " << value << std::endl;
321 // }
322 }
323 stream.close();
324
325 if (nRead != c_maxNSenseLayers) B2FATAL("#lines read-in (=" << nRead << ") is no equal #sense layers (=" << c_maxNSenseLayers <<
326 ") !");
327
330 ps.import(iov);
331 B2INFO("PropSpeed table imported to database.");
332}

◆ importSigma()

void importSigma ( std::string  fileName)

Import sigma table to the database.

Definition at line 544 of file CDCDatabaseImporter.cc.

545{
547 sg.construct();
548
549 //read alpha bins
550 std::ifstream ifs;
551 ifs.open(fileName.c_str());
552 if (!ifs) {
553 B2FATAL("openFile: " << fileName << " *** failed to open");
554 }
555 B2INFO(fileName << ": open for reading");
556
557 const double degrad = M_PI / 180.;
558 const double raddeg = 180. / M_PI;
559
560 unsigned short nAlphaBins = 0;
561 if (ifs >> nAlphaBins) {
562 if (nAlphaBins == 0 || nAlphaBins > c_maxNAlphaPoints) B2FATAL("Fail to read alpha bins !");
563 } else {
564 B2FATAL("Fail to read alpha bins !");
565 }
566 std::array<float, 3> alpha3;
567 for (unsigned short i = 0; i < nAlphaBins; ++i) {
568 for (unsigned short j = 0; j < 3; ++j) {
569 ifs >> alpha3[j];
570 alpha3[j] *= degrad;
571 }
572 sg->setAlphaBin(alpha3);
573 }
574
575 //read theta bins
576 unsigned short nThetaBins = 0;
577 if (ifs >> nThetaBins) {
578 if (nThetaBins == 0 || nThetaBins > c_maxNThetaPoints) B2FATAL("Fail to read theta bins !");
579 } else {
580 B2FATAL("Fail to read theta bins !");
581 }
582 std::array<float, 3> theta3;
583
584 for (unsigned short i = 0; i < nThetaBins; ++i) {
585 for (unsigned short j = 0; j < 3; ++j) {
586 ifs >> theta3[j];
587 theta3[j] *= degrad;
588 }
589 sg->setThetaBin(theta3);
590 }
591
592
593 //read sigma params.
594 short sgParamMode, np;
595 unsigned short iCL, iLR;
596 const unsigned short npx = c_nSigmaParams;
597 double sgm[npx];
598 double theta, alpha;
599 // unsigned nRead = 0;
600
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 !");
604
605 sg->setSigmaParamMode(sgParamMode);
606
607 float maxSigma;
608 ifs >> maxSigma;
609 sg->setMaxSpaceResol(maxSigma);
610
611 const double epsi = 0.1;
612
613 while (ifs >> iCL) {
614 ifs >> theta >> alpha >> iLR;
615 for (int i = 0; i < np; ++i) {
616 ifs >> sgm[i];
617 }
618
619 // TODO: check whether this is correct, as nRead isn't used, it might also be possible to only
620 // perform sg->setSigmaParams() below if the condition is met
621 if (iCL < m_firstLayerOffset) {
622 continue;
623 }
624
625 // ++nRead;
626
627 int ialpha = -99;
628 for (unsigned short i = 0; i < nAlphaBins; ++i) {
629 if (fabs(alpha - sg->getAlphaBin(i)[2]*raddeg) < epsi) {
630 ialpha = i;
631 break;
632 }
633 }
634 if (ialpha < 0) B2FATAL("alphas in sigma.dat are inconsistent !");
635
636 int itheta = -99;
637 for (unsigned short i = 0; i < nThetaBins; ++i) {
638 if (fabs(theta - sg->getThetaBin(i)[2]*raddeg) < epsi) {
639 itheta = i;
640 break;
641 }
642 }
643 if (itheta < 0) B2FATAL("thetas in sigma.dat are inconsistent !");
644
645 // std::vector<float> sgbuff = std::vector<float>(np);
646 std::vector<float> sgbuff;
647 for (int i = 0; i < np; ++i) {
648 sgbuff.push_back(sgm[i]);
649 }
650 // std::cout <<"iCL,iLR,ialpha,itheta= " << iCL <<" "<< iLR <<" "<< ialpha <<" "<< itheta << std::endl;
651 sg->setSigmaParams(iCL, iLR, ialpha, itheta, sgbuff);
652 }
653
654 ifs.close();
655
658 sg.import(iov);
659 B2INFO("Sigma table imported to database.");
660}

◆ importTimeWalk()

void importTimeWalk ( std::string  fileName)

Import time-walk coeff.

table to the database.

Definition at line 374 of file CDCDatabaseImporter.cc.

375{
376 std::ifstream stream;
377 stream.open(fileName.c_str());
378 if (!stream) {
379 B2FATAL("openFile: " << fileName << " *** failed to open");
380 return;
381 }
382 B2INFO(fileName << ": open for reading");
383
385 tw.construct();
386
387 unsigned short mode(0), nParams(0);
388 stream >> mode >> nParams;
389 tw->setTwParamMode(mode);
390
391 unsigned short iBoard(0);
392 std::vector<float> coeffs(nParams);
393 int nRead(0);
394
395 while (stream >> iBoard) {
396 for (unsigned short i = 0; i < nParams; ++i) {
397 stream >> coeffs[i];
398 }
399 ++nRead;
400 tw->setTimeWalkParams(iBoard, coeffs);
401 // if (m_debug) {
402 // std::cout << iBoard << " " << coeff << std::endl;
403 // }
404 }
405 stream.close();
406
407 if (nRead != c_nBoards) B2FATAL("#lines read-in (=" << nRead << ") is not equal #boards (=" << c_nBoards << ") !");
408
411 tw.import(iov);
412 B2INFO("Time-walk coeff. table imported to database.");
413}

◆ importTimeZero()

void importTimeZero ( std::string  fileName)

Import t0 table to the data base.

Definition at line 70 of file CDCDatabaseImporter.cc.

71{
72 std::ifstream stream;
73 stream.open(fileName.c_str());
74 if (!stream) {
75 B2ERROR("openFile: " << fileName << " *** failed to open");
76 return;
77 }
78 B2INFO(fileName << ": open for reading");
79
81 tz.construct();
82
83 uint iL(0);
84 int iC(0);
85 double t0(0.);
86 int nRead(0);
87
88 while (true) {
89 stream >> iL >> iC >> t0;
90
91 if (iL < m_firstLayerOffset) {
92 continue;
93 }
94
95 if (stream.eof()) break;
96 ++nRead;
97 WireID wire(iL, iC);
98 tz->setT0(wire, t0);
99 // if (m_debug) {
100 // std::cout << iL << " " << iC << " " << t0 << std::endl;
101 // }
102 }
103 stream.close();
104
105 if (nRead != m_nSenseWires) B2FATAL("#lines read-in (=" << nRead << ") is inconsistent with total #sense wires (=" << m_nSenseWires
106 << ") !");
107
110 tz.import(iov);
111
112 B2INFO("Time zero table imported to database.");
113
114}

◆ importWirPosAlign()

void importWirPosAlign ( std::string  fileName)

Import wire alignment table to the database.

Definition at line 765 of file CDCDatabaseImporter.cc.

766{
767 // std::ifstream ifs;
768 // ifs.open(fileName.c_str());
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());
772 }
773 ifs.push(boost::iostreams::file_source(fileName));
774 if (!ifs) {
775 B2FATAL("openFile: " << fileName << " *** failed to open");
776 return;
777 }
778 B2INFO(fileName << ": open for reading");
779
781 al.construct();
782
783 uint iL(0), iC(0);
784 const int np = 3;
785 double back[np], fwrd[np], tension;
786 unsigned nRead = 0;
787
788 while (true) {
789 ifs >> iL >> iC;
790 for (int i = 0; i < np; ++i) {
791 ifs >> back[i];
792 }
793 for (int i = 0; i < np; ++i) {
794 ifs >> fwrd[i];
795 }
796 ifs >> tension;
797 if (ifs.eof()) break;
798
799 if (iL < m_firstLayerOffset) {
800 continue;
801 }
802
803 ++nRead;
804 WireID wire(iL, iC);
805
806 for (int i = 0; i < np; ++i) {
807 al->set(wire, CDCAlignment::wireBwdX, back[0]);
808 al->set(wire, CDCAlignment::wireBwdY, back[1]);
809 al->set(wire, CDCAlignment::wireBwdZ, back[2]);
810 al->set(wire, CDCAlignment::wireFwdX, fwrd[0]);
811 al->set(wire, CDCAlignment::wireFwdY, fwrd[1]);
812 al->set(wire, CDCAlignment::wireFwdZ, fwrd[2]);
813 }
814 al->set(wire, CDCAlignment::wireTension, tension);
815 }
816
817 if (nRead != m_nSenseWires) B2FATAL("CDCDatabaseimporter::importWirPosAlign: #lines read-in (=" << nRead <<
818 ") is inconsistent with total #sense wires (=" << m_nSenseWires << ") !");
819
820 // ifs.close();
821 boost::iostreams::close(ifs);
822
825 al.import(iov);
826 B2INFO("Wire alignment table imported to database.");
827}
static const baseType wireBwdZ
Wire Z position w.r.t. nominal on backward endplate.
Definition: CDCAlignment.h:33
static const baseType wireBwdY
Wire Y position w.r.t. nominal on backward endplate.
Definition: CDCAlignment.h:31
static const baseType wireFwdZ
Wire Z position w.r.t. nominal on forward endplate.
Definition: CDCAlignment.h:39
static const baseType wireFwdY
Wire Y position w.r.t. nominal on forward endplate.
Definition: CDCAlignment.h:37
static const baseType wireFwdX
Wire X position w.r.t. nominal on forward endplate.
Definition: CDCAlignment.h:35
static const baseType wireBwdX
Wire X position w.r.t. nominal on backward endplate.
Definition: CDCAlignment.h:29
static const baseType wireTension
Wire tension w.r.t. nominal (=50. ?)
Definition: CDCAlignment.h:43

◆ importXT()

void importXT ( std::string  fileName)

Import xt table to the database.

Definition at line 416 of file CDCDatabaseImporter.cc.

417{
419 xt.construct();
420
421 //read alpha bins
422 // std::ifstream ifs;
423 // ifs.open(fileName.c_str());
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());
427 }
428 ifs.push(boost::iostreams::file_source(fileName));
429 if (!ifs) {
430 B2FATAL("openFile: " << fileName << " *** failed to open");
431 }
432 B2INFO(fileName << ": open for reading");
433
434 const double degrad = M_PI / 180.;
435 const double raddeg = 180. / M_PI;
436
437 unsigned short nAlphaBins = 0;
438 if (ifs >> nAlphaBins) {
439 if (nAlphaBins == 0 || nAlphaBins > c_maxNAlphaPoints) B2FATAL("Fail to read alpha bins !");
440 } else {
441 B2FATAL("Fail to read alpha bins !");
442 }
443 std::array<float, 3> alpha3;
444 for (unsigned short i = 0; i < nAlphaBins; ++i) {
445 for (unsigned short j = 0; j < 3; ++j) {
446 ifs >> alpha3[j];
447 alpha3[j] *= degrad;
448 }
449 xt->setAlphaBin(alpha3);
450 }
451
452 //read theta bins
453 unsigned short nThetaBins = 0;
454 if (ifs >> nThetaBins) {
455 if (nThetaBins == 0 || nThetaBins > c_maxNThetaPoints) B2FATAL("Fail to read theta bins !");
456 } else {
457 B2FATAL("Fail to read theta bins !");
458 }
459 std::array<float, 3> theta3;
460
461 for (unsigned short i = 0; i < nThetaBins; ++i) {
462 for (unsigned short j = 0; j < 3; ++j) {
463 ifs >> theta3[j];
464 theta3[j] *= degrad;
465 }
466 xt->setThetaBin(theta3);
467 }
468
469
470 //read xt params.
471 /* std::ifstream ifs;
472 ifs.open(fileName.c_str());
473 if (!ifs) {
474 B2FATAL("openFile: " << fileName << " *** failed to open");
475 return;
476 }
477 B2INFO(fileName << ": open for reading");
478 */
479 short xtParamMode, np;
480 unsigned short iCL, iLR;
481 const unsigned short npx = c_nXTParams - 1;
482 double xtc[npx];
483 double theta, alpha, dummy1;
484 // unsigned nRead = 0;
485
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 !");
489
490 xt->setXtParamMode(xtParamMode);
491
492 const double epsi = 0.1;
493
494 while (ifs >> iCL) {
495 ifs >> theta >> alpha >> dummy1 >> iLR;
496 for (int i = 0; i < np; ++i) {
497 ifs >> xtc[i];
498 }
499
500 // TODO: check whether this is correct, as nRead isn't used, it might also be possible to only
501 // perform xt->setXtParams() below if the condition is met
502 if (iCL < m_firstLayerOffset) {
503 continue;
504 }
505
506 // ++nRead;
507
508 int ialpha = -99;
509 for (unsigned short i = 0; i < nAlphaBins; ++i) {
510 if (fabs(alpha - xt->getAlphaBin(i)[2]*raddeg) < epsi) {
511 ialpha = i;
512 break;
513 }
514 }
515 if (ialpha < 0) B2FATAL("alphas in xt.dat are inconsistent !");
516
517 int itheta = -99;
518 for (unsigned short i = 0; i < nThetaBins; ++i) {
519 if (fabs(theta - xt->getThetaBin(i)[2]*raddeg) < epsi) {
520 itheta = i;
521 break;
522 }
523 }
524 if (itheta < 0) B2FATAL("thetas in xt.dat are inconsistent !");
525
526 // std::vector<float> xtbuff = std::vector<float>(np);
527 std::vector<float> xtbuff;
528 for (int i = 0; i < np; ++i) {
529 xtbuff.push_back(xtc[i]);
530 }
531 // std::cout <<"iCL,iLR,ialpha,itheta= " << iCL <<" "<< iLR <<" "<< ialpha <<" "<< itheta << std::endl;
532 xt->setXtParams(iCL, iLR, ialpha, itheta, xtbuff);
533 }
534
535 // ifs.close();
536 boost::iostreams::close(ifs);
537
540 xt.import(iov);
541 B2INFO("XT table imported to database.");
542}

◆ printADCDeltaPedestal()

void printADCDeltaPedestal ( )

Get the ADC delta pedestal table from the database and print it.

Definition at line 993 of file CDCDatabaseImporter.cc.

994{
995
997 dbPed->dump();
998}
Class for accessing objects in the database.
Definition: DBObjPtr.h:21

◆ printBadWire()

void printBadWire ( )

Get the badwire table from the database and print it.

Definition at line 875 of file CDCDatabaseImporter.cc.

876{
878 bw->dump();
879}

◆ printCDCCrossTalkLibrary()

void printCDCCrossTalkLibrary ( ) const

Print the content of the crosstalk library.

Definition at line 1105 of file CDCDatabaseImporter.cc.

1106{
1107 DBObjPtr<CDCCrossTalkLibrary> dbCDCCrossTalkLib;
1108 if (dbCDCCrossTalkLib.isValid()) {
1109 dbCDCCrossTalkLib->dump(1);
1110 } else {
1111 B2ERROR("DBObjPtr<CDCCrossTalkLibrary> not valid for the current run.");
1112 }
1113}
bool isValid() const
Check whether a valid object was obtained from the database.

◆ printCDClayerTimeCut()

void printCDClayerTimeCut ( ) const

Print content of CDClayerTimeCut.

Definition at line 1181 of file CDCDatabaseImporter.cc.

1182{
1183 DBObjPtr<CDClayerTimeCut> dbCDClayerTimeCut;
1184 if (dbCDClayerTimeCut.isValid()) {
1185 dbCDClayerTimeCut->dump();
1186 } else {
1187 B2WARNING("DBObjPtr<CDClayerTimeCut> not valid for the current run.");
1188 }
1189
1190}

◆ printCDCWireHitRequirements()

void printCDCWireHitRequirements ( ) const

Get CDCWireHits cut values from the database and print them.

Definition at line 1026 of file CDCDatabaseImporter.cc.

1027{
1028
1030 if (dbWireHitReq.isValid()) {
1031 dbWireHitReq->dump();
1032 } else {
1033 B2WARNING("DBObjPtr<CDCWireHitRequirements> not valid for the current run.");
1034 }
1035}

◆ printChannelMap()

void printChannelMap ( )

Get the channel map from the database and print it.

Definition at line 830 of file CDCDatabaseImporter.cc.

831{
832
833 DBArray<CDCChannelMap> channelMaps;
834
835 for (const auto& cm : channelMaps) {
836 std::cout << cm.getISuperLayer() << " " << cm.getILayer()
837 << " " << cm.getIWire() << " "
838 << cm.getBoardID() << " " << cm.getBoardChannel() << std::endl;
839 }
840
841}
Class for accessing arrays of objects in the database.
Definition: DBArray.h:26

◆ printDisplacement()

void printDisplacement ( )

Get the displacement of wire position from the database and print it.

Definition at line 911 of file CDCDatabaseImporter.cc.

912{
913 DBArray<CDCDisplacement> displacements;
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());
918 }
919}

◆ printEDepToADC()

void printEDepToADC ( )

Get edep-to-adc params.

from the database and print.

Definition at line 855 of file CDCDatabaseImporter.cc.

856{
858 etoa->dump();
859}

◆ printFEElectronics()

void printFEElectronics ( )

Get FEE params.

from the database and print.

Definition at line 843 of file CDCDatabaseImporter.cc.

844{
845 DBArray<CDCFEElectronics> fEElectronics;
846 for (const auto& cf : fEElectronics) {
847 std::cout << cf.getBoardID() << " " << cf.getWidthOfTimeWindow() << " " << cf.getTrgDelay() << " " << cf.getADCThresh() << " " <<
848 cf.getTDCThreshInMV() << std::endl;
849 }
850 // << cf.getTDCThreshInMV() << " "
851 // << cf.getTDCThreshInEV() << " "
852 // << cf.getL1TrgLatency() << std::endl;
853}

◆ printFFactor()

void printFFactor ( )

Get the fudge factor table from the database and print it.

Definition at line 905 of file CDCDatabaseImporter.cc.

906{
908 ff->dump();
909}

◆ printPropSpeed()

void printPropSpeed ( )

Get the propspeed table from the database and print it.

Definition at line 881 of file CDCDatabaseImporter.cc.

882{
884 ps->dump();
885}

◆ printSigma()

void printSigma ( )

Get the sigma table from the database and print it.

Definition at line 899 of file CDCDatabaseImporter.cc.

900{
902 sgm->dump();
903}

◆ printTimeWalk()

void printTimeWalk ( )

Get the time-walk coeff.

table from the database and print it.

Definition at line 887 of file CDCDatabaseImporter.cc.

888{
890 tw->dump();
891}

◆ printTimeZero()

void printTimeZero ( )

Get the t0 table from the database and print it.

Definition at line 861 of file CDCDatabaseImporter.cc.

862{
863
864 DBObjPtr<CDCTimeZeros> timeZeros;
865
866 /* for (const auto& tz : timeZeros) {
867 std::cout << tz.getICLayer() << " " << tz.getIWire() << " "
868 << tz.getT0() << std::endl;
869 }
870 */
871 timeZeros->dump();
872
873}

◆ printWirPosAlign()

void printWirPosAlign ( )

Get the wire alignment table from the database and print it.

Definition at line 921 of file CDCDatabaseImporter.cc.

922{
924 al->dump();
925}

◆ printWirPosMisalign()

void printWirPosMisalign ( )

Get the wire misalignment table from the database and print it.

Definition at line 927 of file CDCDatabaseImporter.cc.

928{
930 mal->dump();
931}

◆ printXT()

void printXT ( )

Get the xt table from the database and print it.

Definition at line 893 of file CDCDatabaseImporter.cc.

894{
896 xt->dump();
897}

◆ testCDCCrossTalkLibrary()

void testCDCCrossTalkLibrary ( bool  spotChecks = false) const

Do some basic testing of the CDCCrossTalkLibrary.

Definition at line 1115 of file CDCDatabaseImporter.cc.

1116{
1117 DBObjPtr<CDCCrossTalkLibrary> dbCDCCrossTalkLib;
1118
1119 if (dbCDCCrossTalkLib.isValid()) {
1120
1121 if (! spotChecks) {
1122 B2INFO("Performing CDCCrossTalkLibrary checks");
1123 auto timer = new Utils::Timer("CDCCrossTalkLibrary checks took"); // use "new" to avoid cpp-check warning
1124 int counter = 0;
1125 int size = 0;
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);
1130 counter += 1;
1131 size += xtalk.size();
1132 }
1133 }
1134 }
1135 B2INFO("CDCCrossTalkLibrary called " << counter << " times. Total number of cross talk hits " << size);
1136 delete timer;
1137 return;
1138 }
1139
1140
1141 Short_t ADC_spot_checks[5] = {2, 100, 500, 1000, 5000};
1142 for (auto ADC : ADC_spot_checks) {
1143 B2INFO("CHECK ADC=" << ADC);
1144
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);
1151 }
1152 }
1153 }
1154 } else {
1155 B2ERROR("DBObjPtr<CDCCrossTalkLibrary> not valid for the current run.");
1156 }
1157}
Small helper class that prints its lifetime when destroyed.
Definition: Utils.h:79

Member Data Documentation

◆ m_firstExperiment

int m_firstExperiment
private

CDC geometory parameter.

First experiment.

Definition at line 235 of file CDCDatabaseImporter.h.

◆ m_firstLayerOffset

ushort m_firstLayerOffset = 0
private

Offset of first layer in case some CDC layers are removed.

Definition at line 240 of file CDCDatabaseImporter.h.

◆ m_firstRun

int m_firstRun
private

First run.

Definition at line 236 of file CDCDatabaseImporter.h.

◆ m_lastExperiment

int m_lastExperiment
private

Last experiment.

Definition at line 237 of file CDCDatabaseImporter.h.

◆ m_lastRun

int m_lastRun
private

Last run.

Definition at line 238 of file CDCDatabaseImporter.h.

◆ m_nSenseWires

ushort m_nSenseWires = 14336
private

Number of sense wires in the CDC.

Definition at line 242 of file CDCDatabaseImporter.h.

◆ m_superLayerOffset

ushort m_superLayerOffset = 0
private

Offset of first super layer in case some CDC super layers are removed.

Definition at line 241 of file CDCDatabaseImporter.h.


The documentation for this class was generated from the following files: