All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Typedefs | Functions | Variables
database Namespace Reference

Typedefs

using ReadoutIDVec = std::vector< unsigned int >
 
using CrateNameReadoutIDPair = std::pair< std::string, ReadoutIDVec >
 
using TPCFragmentIDToReadoutIDMap = std::map< unsigned int, CrateNameReadoutIDPair >
 
using ChannelPlanePair = std::pair< unsigned int, unsigned int >
 
using ChannelPlanePairVec = std::vector< ChannelPlanePair >
 
using SlotChannelVecPair = std::pair< unsigned int, ChannelPlanePairVec >
 
using TPCReadoutBoardToChannelMap = std::map< unsigned int, SlotChannelVecPair >
 
using DigitizerChannelChannelIDPair = std::pair< size_t, size_t >
 
using DigitizerChannelChannelIDPairVec = std::vector< DigitizerChannelChannelIDPair >
 
using FragmentToDigitizerChannelMap = std::map< size_t, DigitizerChannelChannelIDPairVec >
 

Functions

int GetDataset (const std::string name, const std::string url, const std::string &dataType, Dataset &dataSet)
 
int BuildTPCFragmentIDToReadoutIDMap (TPCFragmentIDToReadoutIDMap &fragmentBoardMap)
 
int BuildTPCReadoutBoardToChannelMap (TPCReadoutBoardToChannelMap &rbChanMap)
 
char * Fragment_ID (int readout_board_ID)
 
std::vector< int > Channel_ID (int readout_board_ID)
 
int BuildFragmentToDigitizerChannelMap (FragmentToDigitizerChannelMap &fragmentToDigitizerChannelMap)
 
int PMTChannelIDFromPhysicalPMTPositionID (unsigned int pmtid)
 
int PMTChannelIDFromDigitizer (std::string digitizerlabel, int digitizerchannelnumber)
 

Variables

const unsigned int CHANNELSPERBOARD = 64
 

Typedef Documentation

using database::ChannelPlanePair = typedef std::pair<unsigned int, unsigned int>

Definition at line 229 of file TPCChannelmapping.h.

using database::ChannelPlanePairVec = typedef std::vector<ChannelPlanePair>

Definition at line 230 of file TPCChannelmapping.h.

using database::CrateNameReadoutIDPair = typedef std::pair<std::string,ReadoutIDVec>

Definition at line 57 of file TPCChannelmapping.h.

using database::DigitizerChannelChannelIDPair = typedef std::pair<size_t,size_t>

Definition at line 402 of file TPCChannelmapping.h.

Definition at line 403 of file TPCChannelmapping.h.

Definition at line 404 of file TPCChannelmapping.h.

using database::ReadoutIDVec = typedef std::vector<unsigned int>

Definition at line 56 of file TPCChannelmapping.h.

using database::SlotChannelVecPair = typedef std::pair<unsigned int, ChannelPlanePairVec>

Definition at line 231 of file TPCChannelmapping.h.

using database::TPCFragmentIDToReadoutIDMap = typedef std::map<unsigned int, CrateNameReadoutIDPair>

Definition at line 58 of file TPCChannelmapping.h.

using database::TPCReadoutBoardToChannelMap = typedef std::map<unsigned int, SlotChannelVecPair>

Definition at line 232 of file TPCChannelmapping.h.

Function Documentation

int database::BuildFragmentToDigitizerChannelMap ( FragmentToDigitizerChannelMap &  fragmentToDigitizerChannelMap)
inline

Definition at line 406 of file TPCChannelmapping.h.

407  {
408  // clearing is cleansing
409  fragmentToDigitizerChannelMap.clear();
410 
411  // Recover the information from the database on the mapping
412  const std::string name("Pmt_placement");
413  const std::string dburl("https://dbdata0vm.fnal.gov:9443/QE/hw/app/SQ/query?dbname=icarus_hardware_dev");
414  const std::string dataType("pmt_placements");
415  Dataset dataset;
416 
417  // Recover the data from the database
418  int error = GetDataset(name,dburl,dataType,dataset);
419 
420  // If there was an error the function above would have printed a message so bail out
421  if (error) throw(std::exception());
422 
423  // Ok, now we can start extracting the information
424  // We do this by looping through the database and building the map from that
425  for(int row = 1; row < getNtuples(dataset); row++)
426  {
427  // Recover the row
428  Tuple tuple = getTuple(dataset, row);
429 
430  if (tuple != NULL)
431  {
432  char digitizerBuffer[10];
433 
434  // Recover the digitizer label first
435  getStringValue(tuple, 8, digitizerBuffer, sizeof(digitizerBuffer), &error);
436 
437  if (error) throw std::runtime_error("Encountered error when trying to recover the PMT digitizer label");
438 
439  std::string digitizerLabel(digitizerBuffer, 8); //sizeof(digitizerBuffer));
440 
441  // Recover the fragment id
442  unsigned fragmentID = getLongValue(tuple, 18, &error);
443 
444  if (error) throw std::runtime_error("Encountered error when trying to recover the PMT fragment id");
445 
446  // Now recover the digitizer channel number
447  unsigned int digitizerChannelNo = getLongValue(tuple, 9, &error);
448 
449  if (error) throw std::runtime_error("Encountered error when trying to recover the PMT digitizer channel number");
450 
451  // Finally, get the LArsoft channel ID
452  unsigned int channelID = getLongValue(tuple, 17, &error);
453 
454  if (error) throw std::runtime_error("Encountered error when trying to recover the PMT channel ID");
455 
456  // Fill the map
457  fragmentToDigitizerChannelMap[fragmentID].emplace_back(digitizerChannelNo,channelID);
458 
459  releaseTuple(tuple);
460  }
461  }
462 
463  return error;
464  }
int GetDataset(const std::string name, const std::string url, const std::string &dataType, Dataset &dataSet)
void * Tuple
Definition: DBFolder.h:13
void * Dataset
Definition: DBFolder.h:12
then echo fcl name
int database::BuildTPCFragmentIDToReadoutIDMap ( TPCFragmentIDToReadoutIDMap &  fragmentBoardMap)
inline

Definition at line 60 of file TPCChannelmapping.h.

61  {
62  const unsigned int tpcIdentifier(0x00001000);
63  const std::string name("icarus_hw_readoutboard");
64  const std::string dburl("https://dbdata0vm.fnal.gov:9443/QE/hw/app/SQ/query?dbname=icarus_hardware_dev");
65  const std::string dataType("readout_boards");
66  Dataset dataset;
67 
68  // Recover the data from the database
69  int error = GetDataset(name,dburl,dataType,dataset);
70 
71  // Include a by hand mapping of fragement ID to crate
72  using FlangeIDToCrateMap = std::map<size_t,std::string>;
73 
74  FlangeIDToCrateMap flangeIDToCrateMap;
75 
76  flangeIDToCrateMap[19] = "WW01T";
77  flangeIDToCrateMap[68] = "WW01M";
78  flangeIDToCrateMap[41] = "WW01B";
79  flangeIDToCrateMap[11] = "WW02";
80  flangeIDToCrateMap[17] = "WW03";
81  flangeIDToCrateMap[36] = "WW04";
82  flangeIDToCrateMap[18] = "WW05";
83  flangeIDToCrateMap[58] = "WW06";
84  flangeIDToCrateMap[71] = "WW07";
85  flangeIDToCrateMap[14] = "WW08";
86  flangeIDToCrateMap[25] = "WW09";
87  flangeIDToCrateMap[34] = "WW10";
88  flangeIDToCrateMap[67] = "WW11";
89  flangeIDToCrateMap[33] = "WW12";
90  flangeIDToCrateMap[87] = "WW13";
91  flangeIDToCrateMap[10] = "WW14";
92  flangeIDToCrateMap[59] = "WW15";
93  flangeIDToCrateMap[95] = "WW16";
94  flangeIDToCrateMap[22] = "WW17";
95  flangeIDToCrateMap[91] = "WW18";
96  flangeIDToCrateMap[61] = "WW19";
97  flangeIDToCrateMap[55] = "WW20T";
98  flangeIDToCrateMap[97] = "WW20M";
99  flangeIDToCrateMap[100] = "WW20B";
100  flangeIDToCrateMap[83] = "WE01T";
101  flangeIDToCrateMap[85] = "WE01M";
102  flangeIDToCrateMap[7] = "WE01B";
103  flangeIDToCrateMap[80] = "WE02";
104  flangeIDToCrateMap[52] = "WE03";
105  flangeIDToCrateMap[32] = "WE04";
106  flangeIDToCrateMap[70] = "WE05";
107  flangeIDToCrateMap[74] = "WE06";
108  flangeIDToCrateMap[46] = "WE07";
109  flangeIDToCrateMap[81] = "WE08";
110  flangeIDToCrateMap[63] = "WE09";
111  flangeIDToCrateMap[30] = "WE10";
112  flangeIDToCrateMap[51] = "WE11";
113  flangeIDToCrateMap[90] = "WE12";
114  flangeIDToCrateMap[23] = "WE13";
115  flangeIDToCrateMap[93] = "WE14";
116  flangeIDToCrateMap[92] = "WE15";
117  flangeIDToCrateMap[88] = "WE16";
118  flangeIDToCrateMap[73] = "WE17";
119  flangeIDToCrateMap[1] = "WE18";
120  flangeIDToCrateMap[66] = "WE19";
121  flangeIDToCrateMap[48] = "WE20T";
122  flangeIDToCrateMap[13] = "WE20M";
123  flangeIDToCrateMap[56] = "WE20B";
124  flangeIDToCrateMap[94] = "EW01T";
125  flangeIDToCrateMap[77] = "EW01M";
126  flangeIDToCrateMap[72] = "EW01B";
127  flangeIDToCrateMap[65] = "EW02";
128  flangeIDToCrateMap[4] = "EW03";
129  flangeIDToCrateMap[89] = "EW04";
130  flangeIDToCrateMap[37] = "EW05";
131  flangeIDToCrateMap[76] = "EW06";
132  flangeIDToCrateMap[49] = "EW07";
133  flangeIDToCrateMap[60] = "EW08";
134  flangeIDToCrateMap[21] = "EW09";
135  flangeIDToCrateMap[6] = "EW10";
136  flangeIDToCrateMap[62] = "EW11";
137  flangeIDToCrateMap[2] = "EW12";
138  flangeIDToCrateMap[29] = "EW13";
139  flangeIDToCrateMap[44] = "EW14";
140  flangeIDToCrateMap[9] = "EW15";
141  flangeIDToCrateMap[31] = "EW16";
142  flangeIDToCrateMap[98] = "EW17";
143  flangeIDToCrateMap[38] = "EW18";
144  flangeIDToCrateMap[99] = "EW19";
145  flangeIDToCrateMap[53] = "EW20T";
146  flangeIDToCrateMap[82] = "EW20M";
147  flangeIDToCrateMap[35] = "EW20B";
148  flangeIDToCrateMap[96] = "EE01T";
149  flangeIDToCrateMap[28] = "EE01M";
150  flangeIDToCrateMap[16] = "EE01T";
151  flangeIDToCrateMap[69] = "EE02";
152  flangeIDToCrateMap[20] = "EE02";
153  flangeIDToCrateMap[79] = "EE02";
154  flangeIDToCrateMap[50] = "EE02";
155  flangeIDToCrateMap[45] = "EE02";
156  flangeIDToCrateMap[84] = "EE02";
157  flangeIDToCrateMap[42] = "EE02";
158  flangeIDToCrateMap[39] = "EE02";
159  flangeIDToCrateMap[26] = "EE02";
160  flangeIDToCrateMap[64] = "EE02";
161  flangeIDToCrateMap[43] = "EE02";
162  flangeIDToCrateMap[47] = "EE02";
163  flangeIDToCrateMap[15] = "EE02";
164  flangeIDToCrateMap[3] = "EE02";
165  flangeIDToCrateMap[27] = "EE02";
166  flangeIDToCrateMap[24] = "EE02";
167  flangeIDToCrateMap[40] = "EE02";
168  flangeIDToCrateMap[75] = "EE02";
169  flangeIDToCrateMap[86] = "EE20T";
170  flangeIDToCrateMap[54] = "EE20M";
171  flangeIDToCrateMap[8] = "EE20B";
172 
173  // If there was an error the function above would have printed a message so bail out
174  if (error) throw(std::exception());
175 
176  // Loop through the data to recover the channels
177  // NOTE that we skip the first row because that is just the labels
178  for(int row = 1; row < getNtuples(dataset); row++)
179  {
180  // Recover the row
181  Tuple tuple = getTuple(dataset, row);
182 
183  if (tuple != NULL)
184  {
185  // Note that the fragment ID is stored in the database as a string which reads as a hex number
186  // Meaning we have to read back as a string and decode to get the numerical value.
187  char fragmentBuffer[16];
188 
189  getStringValue(tuple, 8, fragmentBuffer, sizeof(fragmentBuffer), &error);
190 
191  if (error) throw std::runtime_error("Encountered error in trying to recover FragmentID from database");
192 
193  std::string fragmentIDString(fragmentBuffer,4);
194 
195  unsigned int fragmentID = std::stol(fragmentIDString,nullptr,16);
196 
197  if (!(fragmentID & tpcIdentifier)) continue;
198 
199  if (fragmentBoardMap.find(fragmentID) == fragmentBoardMap.end())
200  {
201  unsigned int flangeID = getLongValue(tuple, 1, &error);
202 
203  if (error) throw std::runtime_error("Encountered error in trying to recover Board Flange ID from database");
204 
205  fragmentBoardMap[fragmentID].first = flangeIDToCrateMap[flangeID];
206  }
207 
208  unsigned int readoutID = getLongValue(tuple, 0, &error);
209 
210  if (error) throw std::runtime_error("Encountered error in trying to recover Board ReadoutID from database");
211 
212  fragmentBoardMap[fragmentID].second.emplace_back(readoutID);
213 
214  releaseTuple(tuple);
215  }
216  }
217 
218  return error;
219  }
int GetDataset(const std::string name, const std::string url, const std::string &dataType, Dataset &dataSet)
void * Tuple
Definition: DBFolder.h:13
void * Dataset
Definition: DBFolder.h:12
then echo fcl name
int database::BuildTPCReadoutBoardToChannelMap ( TPCReadoutBoardToChannelMap &  rbChanMap)
inline

Definition at line 236 of file TPCChannelmapping.h.

237  {
238  const std::string name("icarus_hardware_dev");
239  const std::string dburl("https://dbdata0vm.fnal.gov:9443/QE/hw/app/SQ/query?dbname=icarus_hardware_dev");
240  const std::string dataType("daq_channels");
241  Dataset dataset;
242 
243  // Recover the data from the database
244  int error = GetDataset(name,dburl,dataType,dataset);
245 
246  // If there was an error the function above would have printed a message so bail out
247  if (error) throw std::runtime_error("Encountered error accessing the database with GetDataset");
248 
249  // Loop through the data to recover the channels, making sure to skip the first (header) row
250  for(int row = 1; row < getNtuples(dataset); row++)
251  {
252  // Recover the row
253  Tuple tuple = getTuple(dataset, row);
254 
255  if (tuple != NULL)
256  {
257  unsigned int readoutBoardID = getLongValue(tuple, 2, &error);
258 
259  if (error) throw std::runtime_error("Encountered error when trying to read Board ReadoutID");
260 
261  if (rbChanMap.find(readoutBoardID) == rbChanMap.end())
262  {
263  unsigned int readoutBoardSlot = getLongValue(tuple, 4, &error);
264 
265  if (error) throw std::runtime_error("Encountered error when trying to read Board Readout slot");
266 
267  rbChanMap[readoutBoardID].first = readoutBoardSlot;
268  rbChanMap[readoutBoardID].second.resize(CHANNELSPERBOARD);
269  }
270 
271  unsigned int channelNum = getLongValue(tuple, 5, &error);
272 
273  if (error) throw std::runtime_error("Encountered error when trying to read channel number");
274 
275  unsigned int channelID = getLongValue(tuple, 0, &error);
276 
277  if (error) throw std::runtime_error("Encountered error when recovering the channel ID list");
278 
279  // Recover the plane identifier
280  char fragmentBuffer[16];
281 
282  getStringValue(tuple, 10, fragmentBuffer, sizeof(fragmentBuffer), &error);
283 
284  if (error) throw std::runtime_error("Encountered error when trying to read plane type");
285 
286  // Make sure lower case... (sigh...)
287  for(size_t charIdx = 0; charIdx < sizeof(fragmentBuffer); charIdx++) fragmentBuffer[charIdx] = tolower(fragmentBuffer[charIdx]);
288 
289  unsigned int plane(3);
290 
291  if (strstr(fragmentBuffer,"collection")) plane = 2;
292  else if (strstr(fragmentBuffer,"induction 2")) plane = 1;
293  else if (strstr(fragmentBuffer,"induction 1")) plane = 0;
294 
295  if (plane > 2) std::cout << "YIKES!!! Plane is " << plane << " for channel " << channelID << " with type " << std::string(fragmentBuffer) << std::endl;
296 
297  rbChanMap[readoutBoardID].second[channelNum] = ChannelPlanePair(channelID,plane);
298  }
299  }
300 
301  return error;
302  }
int GetDataset(const std::string name, const std::string url, const std::string &dataType, Dataset &dataSet)
void * Tuple
Definition: DBFolder.h:13
void * Dataset
Definition: DBFolder.h:12
const unsigned int CHANNELSPERBOARD
then echo fcl name
std::pair< unsigned int, unsigned int > ChannelPlanePair
BEGIN_PROLOG could also be cout
std::vector<int> database::Channel_ID ( int  readout_board_ID)
inline

Definition at line 360 of file TPCChannelmapping.h.

361  {
362  Dataset ds;
363  const std::string name("icarus_hardware_dev");
364  const std::string dburl("https://dbdata0vm.fnal.gov:9443/QE/hw/app/SQ/query?dbname=icarus_hardware_dev");
365  const std::string dataType = "daq_channels";
366 
367  int error = GetDataset(name,dburl,dataType, ds);
368 
369  if (error) { // Check for curl library errors
370  fprintf(stderr, "error code=%d\n", error); perror("error message");
371  }
372  if (getHTTPstatus(ds) != 200) { // Check for HTTP error
373  fprintf(stderr, "HTTP code=%ld, message: '%s'\n", getHTTPstatus(ds), getHTTPmessage(ds));
374  }
375 
376  int channel_id;
377  std::vector<int> channelidvec;
378  int nrows = getNtuples(ds);
379  for (int rows = 0; rows < nrows; rows++ ){
380  Tuple tu = getTuple(ds, rows); // Get the row with double array
381 
382  // If we get the names print them
383  if (tu != NULL) {
384  int err(0);
385  // If everything is OK
386  int readoutboardid = (int)getDoubleValue(tu, 2, &err);
387 
388  if (readoutboardid == readout_board_ID){
389  channel_id = (int)getDoubleValue(tu, 0, &err);
390  channelidvec.push_back(channel_id);
391  }
392  releaseTuple(tu);
393  }
394  }
395  return channelidvec;
396  }
int GetDataset(const std::string name, const std::string url, const std::string &dataType, Dataset &dataSet)
EResult err(const char *call)
void * Tuple
Definition: DBFolder.h:13
void * Dataset
Definition: DBFolder.h:12
then echo fcl name
char* database::Fragment_ID ( int  readout_board_ID)
inline

Definition at line 309 of file TPCChannelmapping.h.

310  {
311  Dataset ds;
312  const std::string name("icarus_hw_readoutboard");
313  const std::string dburl("https://dbdata0vm.fnal.gov:9443/QE/hw/app/SQ/query?dbname=icarus_hardware_dev");
314  const std::string dataType = "readout_boards";
315 
316  int error = GetDataset(name,dburl,dataType, ds);
317 
318  if (error)
319  { // Check for curl library errors
320  fprintf(stderr, "error code=%d\n", error); perror("error message");
321  }
322  if (getHTTPstatus(ds) != 200)
323  { // Check for HTTP error
324  fprintf(stderr, "HTTP code=%ld, message: '%s'\n", getHTTPstatus(ds), getHTTPmessage(ds));
325  }
326 
327  char ss[10];
328  int err;
329  int readoutboard_id;
330  int nrows = getNtuples(ds);
331  Tuple tup;
332  for (int rows = 0; rows < nrows; rows++ ){
333  tup = getTuple(ds, rows); // Get the row with double array
334 
335  if (tup != NULL) {
336  //int nc = getNfields(tup);
337  //for (i = 0; i < nc; i++) {
338  //len = getStringValue(tup, i ,8, sizeof (ss), &err);
339  //fprintf(stderr, "[%d]: l=%d, s='%s'\n", i, len, ss);
340  //fprintf(stderr, "[4]: v=%i\n", getStringValue(tup, i ,ss, sizeof (ss), &err));
341  // }
342  readoutboard_id = (int)getDoubleValue(tup, 0, &err);
343  if (readoutboard_id == readout_board_ID){
344  getStringValue(tup, 8 ,ss, sizeof (ss), &err);
345  }
346  releaseTuple(tup);
347  }
348  }
349  char* fragment_id = new char[4];
350  std::strcpy(fragment_id, ss);
351  return fragment_id;
352  }
int GetDataset(const std::string name, const std::string url, const std::string &dataType, Dataset &dataSet)
EResult err(const char *call)
void * Tuple
Definition: DBFolder.h:13
void * Dataset
Definition: DBFolder.h:12
then echo fcl name
int database::GetDataset ( const std::string  name,
const std::string  url,
const std::string &  dataType,
Dataset &  dataSet 
)
inline

Definition at line 30 of file TPCChannelmapping.h.

31  {
32  const int timeout(200);
33  std::string dburl = url + "&t=" + dataType;
34 
35  int error(0);
36 
37  dataSet = getDataWithTimeout(dburl.data(),name.data(),timeout,&error);
38 
39  if (error)
40  {
41  std::string errorMsg = "Database access GetDataset failed with error " + std::to_string(error) + "\nDB url: "
42  + dburl + ", name: " + name + ", type: " + dataType;
43  std::cout << "****> Database retrieval error, code: " << error << std::endl;
44  throw std::runtime_error(errorMsg);
45  }
46 
47  return error;
48  }
std::string to_string(WindowPattern const &pattern)
then echo fcl name
BEGIN_PROLOG could also be cout
int database::PMTChannelIDFromDigitizer ( std::string  digitizerlabel,
int  digitizerchannelnumber 
)
inline

Definition at line 521 of file TPCChannelmapping.h.

522  {
523  const std::string name("icarus_hw_readoutboard");
524  const std::string dburl("https://dbdata0vm.fnal.gov:9443/QE/hw/app/SQ/query?dbname=icarus_hardware_dev");
525  const std::string dataType("pmt_placements");
526  Dataset dataset;
527 
528  // Recover the data from the database
529  int error = GetDataset(name,dburl,dataType,dataset);
530 
531  // If there was an error the function above would have printed a message so bail out
532  if (error) throw(std::exception());
533 
534  unsigned int PMTChannelID;
535 
536  // Loop through the data to recover the channels
537  // NOTE that we skip the first row because that is just the labels
538  for(int row = 1; row < getNtuples(dataset); row++)
539  {
540  // Recover the row
541  Tuple tuple = getTuple(dataset, row);
542 
543  if (tuple != NULL)
544  {
545  char digitizerBuffer[10];
546 
547  getStringValue(tuple, 8, digitizerBuffer, sizeof(digitizerBuffer), &error);
548  std::string digitizerLabel(digitizerBuffer, sizeof(digitizerBuffer));
549 
550  int digitizerChannelNumber = getDoubleValue(tuple, 9, &error);
551 
552 
553  int matchedcharacter = digitizerLabel.compare(digitizerlabel);
554 
555  // Not sure what I am doing wrong why 2 is coming for matchedcharacter,
556  // but I have tried a simple compare string with same name it is 0.
557  // std::string s1("EE-BOT-B");
558  // std::string s2("EE-BOT-B");
559  // int compare = s1.compare(s2);
560  // if (compare == 0) std::cout << "strings are equal" << std::endl;
561 
562  if(matchedcharacter == 2 && digitizerChannelNumber == digitizerchannelnumber){
563 
564  PMTChannelID = getLongValue(tuple, 17, &error);
565 
566  if (error) throw std::runtime_error("Encountered error in trying to recover Larsoft PMT Channel ID from database");
567 
568  }else continue;
569 
570  releaseTuple(tuple);
571  }
572  }
573 
574  return PMTChannelID;
575 
576  }
int GetDataset(const std::string name, const std::string url, const std::string &dataType, Dataset &dataSet)
void * Tuple
Definition: DBFolder.h:13
void * Dataset
Definition: DBFolder.h:12
then echo fcl name
int database::PMTChannelIDFromPhysicalPMTPositionID ( unsigned int  pmtid)
inline

Definition at line 471 of file TPCChannelmapping.h.

472  {
473  const std::string name("icarus_hw_readoutboard");
474  const std::string dburl("https://dbdata0vm.fnal.gov:9443/QE/hw/app/SQ/query?dbname=icarus_hardware_dev");
475  const std::string dataType("pmt_placements");
476  Dataset dataset;
477 
478  // Recover the data from the database
479  int error = GetDataset(name,dburl,dataType,dataset);
480 
481  // If there was an error the function above would have printed a message so bail out
482  if (error) throw(std::exception());
483 
484  unsigned int PhysicalPMTPositionID;
485  unsigned int PMTChannelID;
486 
487  // Loop through the data to recover the channels
488  // NOTE that we skip the first row because that is just the labels
489  for(int row = 1; row < getNtuples(dataset); row++)
490  {
491  // Recover the row
492  Tuple tuple = getTuple(dataset, row);
493 
494  if (tuple != NULL)
495  {
496 
497  PhysicalPMTPositionID = getLongValue(tuple, 0, &error);
498 
499  if (error) throw std::runtime_error("Encountered error when trying to read Physical PMT Position ID from database");
500 
501  if (PhysicalPMTPositionID == pmtid) {
502 
503  PMTChannelID = getLongValue(tuple, 17, &error);
504 
505  if (error) throw std::runtime_error("Encountered error in trying to recover Larsoft PMT Channel ID from database");
506 
507  }else continue;
508 
509  releaseTuple(tuple);
510  }
511  }
512 
513  return PMTChannelID;
514  }
int GetDataset(const std::string name, const std::string url, const std::string &dataType, Dataset &dataSet)
void * Tuple
Definition: DBFolder.h:13
void * Dataset
Definition: DBFolder.h:12
then echo fcl name

Variable Documentation

const unsigned int database::CHANNELSPERBOARD = 64

Definition at line 234 of file TPCChannelmapping.h.