All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
icarusDB::ChannelMapSQLite Class Reference

ChannelMapSQLite class definiton. More...

Inheritance diagram for icarusDB::ChannelMapSQLite:
icarusDB::IChannelMapping

Public Member Functions

 ChannelMapSQLite (fhicl::ParameterSet const &pset)
 Constructor. More...
 
 ~ChannelMapSQLite ()
 Destructor. More...
 
virtual int BuildTPCFragmentIDToReadoutIDMap (TPCFragmentIDToReadoutIDMap &) const override
 Define the returned data structures for a mapping between TPC Fragment IDs and the related crate and readout information. Then define the function interface to fill these data structures. More...
 
virtual int BuildTPCReadoutBoardToChannelMap (TPCReadoutBoardToChannelMap &) const override
 Define the returned data structures for a mapping between TPC readout boards and the channel information Then define the function interface to fill these data structures. More...
 
virtual int BuildFragmentToDigitizerChannelMap (FragmentToDigitizerChannelMap &) const override
 Define the returned data structures for a mapping between PMT Fragment IDs and the related crate and readout information. Then define the function interface to fill these data structures. More...
 
virtual int BuildCRTChannelIDToHWtoSimMacAddressPairMap (CRTChannelIDToHWtoSimMacAddressPairMap &) const override
 Define the returned data structures for a mapping between CRT hardware mac_address to the simulated mac_address. Then define the function interface to fill these data structures. More...
 
virtual int BuildTopCRTHWtoSimMacAddressPairMap (TopCRTHWtoSimMacAddressPairMap &) const override
 
virtual int BuildSideCRTCalibrationMap (SideCRTChannelToCalibrationMap &) const override
 
- Public Member Functions inherited from icarusDB::IChannelMapping
virtual ~IChannelMapping () noexcept=default
 Virtual Destructor. More...
 

Private Member Functions

int GetDataset (const std::string &, int func(void *, int, char **, char **), void *) const
 

Private Attributes

std::string fDBFileName
 
std::string fCalibDBFileName
 
std::string fTag
 

Additional Inherited Members

- Public Types inherited from icarusDB::IChannelMapping
using ReadoutIDVec = std::vector< unsigned int >
 Define the returned data structures for a mapping between TPC Fragment IDs and the related crate and readout information. Then define the function interface to fill these data structures. More...
 
using CrateNameReadoutIDPair = std::pair< std::string, ReadoutIDVec >
 
using TPCFragmentIDToReadoutIDMap = std::map< unsigned int, CrateNameReadoutIDPair >
 
using ChannelPlanePair = std::pair< unsigned int, unsigned int >
 Define the returned data structures for a mapping between TPC readout boards and the channel information Then define the function interface to fill these data structures. More...
 
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 >
 Define the returned data structures for a mapping between PMT Fragment IDs and the related crate and readout information. Then define the function interface to fill these data structures. More...
 
using DigitizerChannelChannelIDPairVec = std::vector< DigitizerChannelChannelIDPair >
 
using FragmentToDigitizerChannelMap = std::map< size_t, DigitizerChannelChannelIDPairVec >
 
using CRTHWtoSimMacAddressPair = std::pair< unsigned int, unsigned int >
 Define the returned data structures for a mapping between CRT hardware mac_address to the simulated mac_address. Then define the function interface to fill these data structures. More...
 
using CRTChannelIDToHWtoSimMacAddressPairMap = std::map< unsigned int, CRTHWtoSimMacAddressPair >
 
using TopCRTHWtoSimMacAddressPairMap = std::map< unsigned int, unsigned int >
 
using SideCRTMac5ToChannelPair = std::pair< unsigned int, unsigned int >
 
using SideCRTGainToPedPair = std::pair< double, double >
 
using SideCRTChannelToCalibrationMap = std::map< SideCRTMac5ToChannelPair, SideCRTGainToPedPair >
 

Detailed Description

ChannelMapSQLite class definiton.

Definition at line 37 of file ChannelMapSQLite_tool.cc.

Constructor & Destructor Documentation

icarusDB::ChannelMapSQLite::ChannelMapSQLite ( fhicl::ParameterSet const &  pset)
explicit

Constructor.

Parameters
pset

Definition at line 94 of file ChannelMapSQLite_tool.cc.

95 {
96  fDBFileName = pset.get<std::string>("DBFileName");
97  fCalibDBFileName = pset.get<std::string>("CalibDBFileName");
98  fTag = pset.get<std::string>("Tag");
99 
100  return;
101 }
icarusDB::ChannelMapSQLite::~ChannelMapSQLite ( )

Destructor.

Definition at line 105 of file ChannelMapSQLite_tool.cc.

106 {
107 }

Member Function Documentation

int icarusDB::ChannelMapSQLite::BuildCRTChannelIDToHWtoSimMacAddressPairMap ( CRTChannelIDToHWtoSimMacAddressPairMap crtChannelIDToHWtoSimMacAddressPairMap) const
overridevirtual

Define the returned data structures for a mapping between CRT hardware mac_address to the simulated mac_address. Then define the function interface to fill these data structures.

Implements icarusDB::IChannelMapping.

Definition at line 433 of file ChannelMapSQLite_tool.cc.

434  {
435  // clearing is cleansing
436  crtChannelIDToHWtoSimMacAddressPairMap.clear();
437  // Recover the information from the database on the mapping
438  const std::string dataType("feb_channels");
439 
440  // Recover the data from the database
441  int error = GetDataset(dataType,buildCRTChannelIDToHWtoSimMacAddressPairMap_callback,&crtChannelIDToHWtoSimMacAddressPairMap);
442 
443  // If there was an error the function above would have printed a message so bail out
444  if (error)
445  throw cet::exception("ChannelMapSQLite::BuildCRTChannelIDToHWtoSimMacAddressPairMap") << "Encountered error in reading the database: '" << error << "'\n";
446 
447  return error;
448  }
int buildCRTChannelIDToHWtoSimMacAddressPairMap_callback(void *dataIn, int argc, char **argv, char **azColName)
int GetDataset(const std::string &, int func(void *, int, char **, char **), void *) const
int icarusDB::ChannelMapSQLite::BuildFragmentToDigitizerChannelMap ( FragmentToDigitizerChannelMap fragmentToDigitizerChannelMap) const
overridevirtual

Define the returned data structures for a mapping between PMT Fragment IDs and the related crate and readout information. Then define the function interface to fill these data structures.

Implements icarusDB::IChannelMapping.

Definition at line 392 of file ChannelMapSQLite_tool.cc.

393  {
394  // clearing is cleansing
395  fragmentToDigitizerChannelMap.clear();
396  // Recover the information from the database on the mapping
397  const std::string dataType("pmt_placements");
398 
399  // Recover the data from the database
400  int error = GetDataset(dataType,buildFragmentToDigitizerChannelMap_callback,&fragmentToDigitizerChannelMap);
401 
402  // If there was an error the function above would have printed a message so bail out
403  if (error)
404  throw cet::exception("ChannelMapSQLite::BuildFragmentToDigitizerChannelMap") << "Encountered error in reading the database: '" << error << "'\n";
405 
406  return error;
407  }
int GetDataset(const std::string &, int func(void *, int, char **, char **), void *) const
int buildFragmentToDigitizerChannelMap_callback(void *dataIn, int argc, char **argv, char **azColName)
int icarusDB::ChannelMapSQLite::BuildSideCRTCalibrationMap ( SideCRTChannelToCalibrationMap sideCRTChannelToCalibrationMap) const
overridevirtual

Implements icarusDB::IChannelMapping.

Definition at line 486 of file ChannelMapSQLite_tool.cc.

487  {
488  // clearing is cleansing
489  sideCRTChannelToCalibrationMap.clear();
490 
491  std::string fullFileName;
492  cet::search_path searchPath("FW_SEARCH_PATH");
493 
494 
495  if (!searchPath.find_file(fCalibDBFileName+".db", fullFileName)){
496  std::cout << "******* Succesfully found calibration input file: " << fCalibDBFileName << std::endl;
497  throw cet::exception("ChannelMapSQLite::GetDataset") << "Can't find calibration input file: '" << fCalibDBFileName << "'\n";
498  }
499 
500  lariov::DBFolder database(fCalibDBFileName, "", "", fTag, true, false);
501 
502  database.UpdateData(1638918271*1e9);
503 
504  std::vector<unsigned int> channels;
505  database.GetChannelList(channels);
506 
507  for (auto it = channels.begin(); it != channels.end(); ++it) {
508 
509  long mac5, chan;
510  double gain, ped;
511 
512  // Start extracting info
513  database.GetNamedChannelData(*it, "mac5", mac5);
514  database.GetNamedChannelData(*it, "localchannel", chan);
515  database.GetNamedChannelData(*it, "gain", gain);
516  database.GetNamedChannelData(*it, "pedestal", ped);
517 
518  // Fill the map
519  sideCRTChannelToCalibrationMap.insert(std::make_pair(std::make_pair((int)mac5,(int)chan), std::make_pair(gain,ped)));
520  }
521 
522  return 0;
523  }
BEGIN_PROLOG could also be cout
int icarusDB::ChannelMapSQLite::BuildTopCRTHWtoSimMacAddressPairMap ( TopCRTHWtoSimMacAddressPairMap topcrtHWtoSimMacAddressPairMap) const
overridevirtual

Implements icarusDB::IChannelMapping.

Definition at line 466 of file ChannelMapSQLite_tool.cc.

467  {
468  // clearing is cleansing
469  topcrtHWtoSimMacAddressPairMap.clear();
470  // Recover the information from the database on the mapping
471  const std::string dataType("crtfeb");
472 
473  // Recover the data from the database
474  int error = GetDataset(dataType,buildTopCRTHWtoSimMacAddressPairMap_callback,&topcrtHWtoSimMacAddressPairMap);
475 
476  // If there was an error the function above would have printed a message so bail out
477  if (error)
478  throw cet::exception("ChannelMapSQLite::BuildTopCRTHWtoSimMacAddressPairMap") << "Encountered error in reading the database: '" << error << "'\n";
479 
480  return error;
481  }
int GetDataset(const std::string &, int func(void *, int, char **, char **), void *) const
int buildTopCRTHWtoSimMacAddressPairMap_callback(void *dataIn, int argc, char **argv, char **azColName)
int icarusDB::ChannelMapSQLite::BuildTPCFragmentIDToReadoutIDMap ( TPCFragmentIDToReadoutIDMap fragmentBoardMap) const
overridevirtual

Define the returned data structures for a mapping between TPC Fragment IDs and the related crate and readout information. Then define the function interface to fill these data structures.

Implements icarusDB::IChannelMapping.

Definition at line 304 of file ChannelMapSQLite_tool.cc.

305  {
306  const std::string dataType("readout_boards");
307 
308  // Recover the data from the database
309  int error = GetDataset(dataType,buildTPCFragmentIDToReadoutIDMap_callback,&fragmentBoardMap);
310 
311  // If there was an error the function above would have printed a message so bail out
312  if (error)
313  throw cet::exception("ChannelMapSQLite::BuildTPCFragmentIDToReadoutIDMap") << "Encountered error in reading the database: '" << error << "'\n";
314 
315  return error;
316  }
int GetDataset(const std::string &, int func(void *, int, char **, char **), void *) const
int buildTPCFragmentIDToReadoutIDMap_callback(void *dataIn, int argc, char **argv, char **azColName)
int icarusDB::ChannelMapSQLite::BuildTPCReadoutBoardToChannelMap ( TPCReadoutBoardToChannelMap rbChanMap) const
overridevirtual

Define the returned data structures for a mapping between TPC readout boards and the channel information Then define the function interface to fill these data structures.

Implements icarusDB::IChannelMapping.

Definition at line 361 of file ChannelMapSQLite_tool.cc.

362  {
363  const std::string dataType("daq_channels");
364 
365  // Recover the data from the database
367 
368  // If there was an error the function above would have printed a message so bail out
369  if (error)
370  throw cet::exception("ChannelMapSQLite::BuildTPCReadoutBoardToChannelMap") << "Encountered error in reading the database: '" << error << "'\n";
371 
372  return error;
373  }
int buildTPCReadoutBoardToChannelMap_callback(void *dataIn, int argc, char **argv, char **azColName)
int GetDataset(const std::string &, int func(void *, int, char **, char **), void *) const
int icarusDB::ChannelMapSQLite::GetDataset ( const std::string &  table,
int   funcvoid *, int, char **, char **,
void *  data 
) const
private

Definition at line 131 of file ChannelMapSQLite_tool.cc.

132  {
133  std::string fullFileName;
134  cet::search_path searchPath("FW_SEARCH_PATH");
135 
136  if (!searchPath.find_file(fDBFileName, fullFileName))
137  throw cet::exception("ChannelMapSQLite::GetDataset") << "Can't find input file: '" << fDBFileName << "'\n";
138 
139  // Set up to open the database
140  sqlite3* database;
141 
142  int rc = sqlite3_open(fullFileName.c_str(), &database);
143 
144  if (rc)
145  throw cet::exception("ChannelMapSQLite::GetDataset") << "Can't open the database, return code:" << sqlite3_errmsg(database) << "'\n";
146 
147  // Test reading the database
148  std::string select = "SELECT * FROM " + table;
149 
150  char* zErrMsg = 0;
151 
152  rc = sqlite3_exec(database, select.c_str(), func, data, &zErrMsg);
153 
154  if( rc != SQLITE_OK )
155  {
156  std::cout << "ChannelMapSQLite::GetDataset: SQL error: " << zErrMsg << std::endl;
157  sqlite3_free(zErrMsg);
158  }
159  else
160  {
161  std::cout << "ChannelMapSQLite::GetDataset: Successfully read database" << std::endl;
162  }
163 
164  sqlite3_close(database);
165 
166  return 0;
167  }
BEGIN_PROLOG could also be cout

Member Data Documentation

std::string icarusDB::ChannelMapSQLite::fCalibDBFileName
private

Definition at line 90 of file ChannelMapSQLite_tool.cc.

std::string icarusDB::ChannelMapSQLite::fDBFileName
private

Definition at line 89 of file ChannelMapSQLite_tool.cc.

std::string icarusDB::ChannelMapSQLite::fTag
private

Definition at line 91 of file ChannelMapSQLite_tool.cc.


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