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

#include <ICARUSChannelMapProvider.h>

Inheritance diagram for icarusDB::ICARUSChannelMapProvider:
icarusDB::IICARUSChannelMap icarusDB::ICARUSChannelMap

Public Member Functions

 ICARUSChannelMapProvider (const fhicl::ParameterSet &pset)
 
bool hasFragmentID (const unsigned int) const override
 
unsigned int nTPCfragmentIDs () const override
 Returns the number of TPC fragment IDs known to the service. More...
 
const std::string & getCrateName (const unsigned int) const override
 
const ReadoutIDVecgetReadoutBoardVec (const unsigned int) const override
 
const TPCReadoutBoardToChannelMapgetReadoutBoardToChannelMap () const override
 
bool hasBoardID (const unsigned int) const override
 
unsigned int nTPCboardIDs () const override
 Returns the number of TPC board IDs known to the service. More...
 
unsigned int getBoardSlot (const unsigned int) const override
 
const ChannelPlanePairVecgetChannelPlanePair (const unsigned int) const override
 
bool hasPMTDigitizerID (const unsigned int) const override
 
unsigned int nPMTfragmentIDs () const override
 Returns the number of PMT fragment IDs known to the service. More...
 
const
DigitizerChannelChannelIDPairVec
getChannelIDPairVec (const unsigned int) const override
 
unsigned int getSimMacAddress (const unsigned int) const override
 
unsigned int gettopSimMacAddress (const unsigned int) const override
 
std::pair< double, double > getSideCRTCalibrationMap (int mac5, int chan) const override
 Returns the Gain and Pedestal for Side CRT. More...
 
- Public Member Functions inherited from icarusDB::IICARUSChannelMap
virtual ~IICARUSChannelMap () noexcept=default
 

Static Public Member Functions

static constexpr unsigned int PMTfragmentIDtoDBkey (unsigned int fragmentID)
 Returns the channel mapping database key for the specified PMT fragment ID. More...
 
static constexpr unsigned int DBkeyToPMTfragmentID (unsigned int DBkey)
 Returns the PMT fragment ID for the specified channel mapping database key. More...
 

Private Member Functions

DigitizerChannelChannelIDPairVec
const * 
findPMTfragmentEntry (unsigned int fragmentID) const
 

Private Attributes

bool fDiagnosticOutput
 
IChannelMapping::TPCFragmentIDToReadoutIDMap fFragmentToReadoutMap
 
IChannelMapping::TPCReadoutBoardToChannelMap fReadoutBoardToChannelMap
 
IChannelMapping::FragmentToDigitizerChannelMap fFragmentToDigitizerMap
 
IChannelMapping::CRTChannelIDToHWtoSimMacAddressPairMap fCRTChannelIDToHWtoSimMacAddressPairMap
 
IChannelMapping::TopCRTHWtoSimMacAddressPairMap fTopCRTHWtoSimMacAddressPairMap
 
IChannelMapping::SideCRTChannelToCalibrationMap fSideCRTChannelToCalibrationMap
 
std::unique_ptr< IChannelMappingfChannelMappingTool
 

Detailed Description

Definition at line 25 of file ICARUSChannelMapProvider.h.

Constructor & Destructor Documentation

icarusDB::ICARUSChannelMapProvider::ICARUSChannelMapProvider ( const fhicl::ParameterSet &  pset)

Definition at line 30 of file ICARUSChannelMapProvider.cxx.

30  {
31 
32  mf::LogInfo("ICARUSChannelMapProvider") << "Building the channel mapping" ;
33 
34  fDiagnosticOutput = pset.get<bool>("DiagnosticOutput", false);
35 
36  // Recover the vector of fhicl parameters for the ROI tools
37  const fhicl::ParameterSet&channelMappingParams = pset.get<fhicl::ParameterSet>("ChannelMappingTool");
38 
39  // Get instance of the mapping tool (allowing switch between database instances)
40  fChannelMappingTool = art::make_tool<IChannelMapping>(channelMappingParams);
41 
42  cet::cpu_timer theClockFragmentIDs;
43 
44  theClockFragmentIDs.start();
45 
46  if (fChannelMappingTool->BuildTPCFragmentIDToReadoutIDMap(fFragmentToReadoutMap))
47  {
48  throw cet::exception("ICARUSChannelMapProvider") << "Cannot recover the Fragment ID channel map from the database \n";
49  }
50  else if (fDiagnosticOutput)
51  {
52  std::cout << "FragmentID to Readout ID map has " << fFragmentToReadoutMap.size() << " elements";
53  for(const auto& pair : fFragmentToReadoutMap) std::cout << " Frag: " << std::hex << pair.first << ", Crate: "
54  << pair.second.first << ", # boards: " << std::dec << pair.second.second.size() << std::endl;
55 
56  }
57 
58  theClockFragmentIDs.stop();
59 
60  double fragmentIDsTime = theClockFragmentIDs.accumulated_real_time();
61 
62  cet::cpu_timer theClockReadoutIDs;
63 
64  theClockReadoutIDs.start();
65 
66  if (fChannelMappingTool->BuildTPCReadoutBoardToChannelMap(fReadoutBoardToChannelMap))
67  {
68  std::cout << "******* FAILED TO CONFIGURE CHANNEL MAP ********" << std::endl;
69  throw cet::exception("ICARUSChannelMapProvider") << "POS didn't read the F'ing database again \n";
70  }
71 
72  // Do the channel mapping initialization
73  if (fChannelMappingTool->BuildFragmentToDigitizerChannelMap(fFragmentToDigitizerMap))
74  {
75  throw cet::exception("ICARUSChannelMapProvider") << "Cannot recover the Fragment ID channel map from the database \n";
76  }
77  else if (fDiagnosticOutput)
78  {
79  std::cout << "FragmentID to Readout ID map has " << fFragmentToDigitizerMap.size() << " Fragment IDs";
80  for(const auto& pair : fFragmentToDigitizerMap) std::cout << " Frag: " << std::hex << pair.first << ", # pairs: "
81  << std::dec << pair.second.size() << std::endl;
82  }
83 
84  // Do the channel mapping initialization for CRT
85  if (fChannelMappingTool->BuildCRTChannelIDToHWtoSimMacAddressPairMap(fCRTChannelIDToHWtoSimMacAddressPairMap))
86  {
87  throw cet::exception("CRTDecoder") << "Cannot recover the HW MAC Address from the database \n";
88  }
89  else if (fDiagnosticOutput)
90  {
91  std::cout << "ChannelID to MacAddress map has " << fCRTChannelIDToHWtoSimMacAddressPairMap.size() << " Channel IDs";
92  for(const auto& pair : fCRTChannelIDToHWtoSimMacAddressPairMap) std::cout <<" ChannelID: "<< pair.first
93  << ", hw mac address: " << pair.second.first
94  <<", sim mac address: " << pair.second.second << std::endl;
95 
96  }
97 
98 
99  // Do the channel mapping initialization for top CRT
100  if (fChannelMappingTool->BuildTopCRTHWtoSimMacAddressPairMap(fTopCRTHWtoSimMacAddressPairMap))
101  {
102  throw cet::exception("CRTDecoder") << "Cannot recover the Top CRT HW MAC Address from the database \n";
103  }
104  else if (fDiagnosticOutput)
105  {
106  std::cout << "Top CRT MacAddress map has " << fTopCRTHWtoSimMacAddressPairMap.size() << " rows";
107  for(const auto& pair : fTopCRTHWtoSimMacAddressPairMap) std::cout << ", hw mac address: " << pair.first
108  <<", sim mac address: " << pair.second << std::endl;
109  }
110 
111 
112  // Do the CRT Charge Calibration initialization
113  if (fChannelMappingTool->BuildSideCRTCalibrationMap(fSideCRTChannelToCalibrationMap))
114  {
115  std::cout << "******* FAILED TO CONFIGURE CRT Calibration ********" << std::endl;
116  throw cet::exception("ICARUSChannelMapProvider") << "Cannot recover the charge calibration information from the database \n";
117  }
118  else if (fDiagnosticOutput)
119  {
120  std::cout << "side crt calibration map has " << fSideCRTChannelToCalibrationMap.size() << " list of rows \n";
121 
122  for(const auto& pair : fSideCRTChannelToCalibrationMap) std::cout <<" mac5: "<< pair.first.first
123  << ", chan: " << pair.first.second
124  << ", Gain: " << pair.second.first
125  << ", Pedestal: " << pair.second.second << std::endl;
126 
127  }
128 
129  theClockReadoutIDs.stop();
130 
131  double readoutIDsTime = theClockReadoutIDs.accumulated_real_time();
132 
133 
134  mf::LogInfo("ICARUSChannelMapProvider") << "==> FragmentID map time: " << fragmentIDsTime << ", Readout IDs time: " << readoutIDsTime << std::endl;
135 
136  return;
137 }
IChannelMapping::SideCRTChannelToCalibrationMap fSideCRTChannelToCalibrationMap
IChannelMapping::TopCRTHWtoSimMacAddressPairMap fTopCRTHWtoSimMacAddressPairMap
IChannelMapping::TPCFragmentIDToReadoutIDMap fFragmentToReadoutMap
std::unique_ptr< IChannelMapping > fChannelMappingTool
IChannelMapping::CRTChannelIDToHWtoSimMacAddressPairMap fCRTChannelIDToHWtoSimMacAddressPairMap
IChannelMapping::FragmentToDigitizerChannelMap fFragmentToDigitizerMap
BEGIN_PROLOG could also be cout
IChannelMapping::TPCReadoutBoardToChannelMap fReadoutBoardToChannelMap

Member Function Documentation

constexpr unsigned int icarusDB::ICARUSChannelMapProvider::DBkeyToPMTfragmentID ( unsigned int  DBkey)
static

Returns the PMT fragment ID for the specified channel mapping database key.

Definition at line 291 of file ICARUSChannelMapProvider.cxx.

292 {
293  /*
294  * PMT channel mapping database stores the board number (0-23) as key.
295  * Fragment ID are currently in the pattern 0x20xx, with xx the board number.
296  */
297 
298  // protest if this is a fragment not from the PMT;
299  // but make an exception for old PMT fragment IDs (legacy)
300  assert((DBkey & 0xFF) < 24);
301 
302  return (DBkey & 0xFF) | 0x2000;
303 
304 } // ICARUSChannelMapProvider::PMTfragmentIDtoDBkey()
auto icarusDB::ICARUSChannelMapProvider::findPMTfragmentEntry ( unsigned int  fragmentID) const
private

Returns the list of board channel-to-PMT channel ID mapping within the specified fragment.

Returns
a pointer to the mapping list, or nullptr if invalid fragment

Definition at line 265 of file ICARUSChannelMapProvider.cxx.

267 {
268  auto it = fFragmentToDigitizerMap.find(PMTfragmentIDtoDBkey(fragmentID));
269  return (it == fFragmentToDigitizerMap.end())? nullptr: &(it->second);
270 }
static constexpr unsigned int PMTfragmentIDtoDBkey(unsigned int fragmentID)
Returns the channel mapping database key for the specified PMT fragment ID.
IChannelMapping::FragmentToDigitizerChannelMap fFragmentToDigitizerMap
unsigned int icarusDB::ICARUSChannelMapProvider::getBoardSlot ( const unsigned int  boardID) const
overridevirtual

Implements icarusDB::IICARUSChannelMap.

Definition at line 188 of file ICARUSChannelMapProvider.cxx.

189 {
190  IChannelMapping::TPCReadoutBoardToChannelMap::const_iterator readoutBoardItr = fReadoutBoardToChannelMap.find(boardID);
191 
192  if (readoutBoardItr == fReadoutBoardToChannelMap.end())
193  throw cet::exception("ICARUSChannelMapProvider") << "Board ID " << boardID << " not found in lookup map when looking up board slot \n";
194 
195  return readoutBoardItr->second.first;
196 }
IChannelMapping::TPCReadoutBoardToChannelMap fReadoutBoardToChannelMap
const DigitizerChannelChannelIDPairVec & icarusDB::ICARUSChannelMapProvider::getChannelIDPairVec ( const unsigned int  fragmentID) const
overridevirtual

Implements icarusDB::IICARUSChannelMap.

Definition at line 220 of file ICARUSChannelMapProvider.cxx.

221 {
222  DigitizerChannelChannelIDPairVec const* digitizerPair = findPMTfragmentEntry(fragmentID);
223 
224  if (digitizerPair) return *digitizerPair;
225  throw cet::exception("ICARUSChannelMapProvider") << "Fragment ID " << fragmentID << " not found in lookup map when looking for PMT channel info \n";
226 
227 }
std::vector< DigitizerChannelChannelIDPair > DigitizerChannelChannelIDPairVec
DigitizerChannelChannelIDPairVec const * findPMTfragmentEntry(unsigned int fragmentID) const
const ChannelPlanePairVec & icarusDB::ICARUSChannelMapProvider::getChannelPlanePair ( const unsigned int  boardID) const
overridevirtual

Implements icarusDB::IICARUSChannelMap.

Definition at line 198 of file ICARUSChannelMapProvider.cxx.

199 {
200  IChannelMapping::TPCReadoutBoardToChannelMap::const_iterator readoutBoardItr = fReadoutBoardToChannelMap.find(boardID);
201 
202  if (readoutBoardItr == fReadoutBoardToChannelMap.end())
203  throw cet::exception("ICARUSChannelMapProvider") << "Board ID " << boardID << " not found in lookup map when looking up channel/plane pair \n";
204 
205  return readoutBoardItr->second.second;
206 
207 }
IChannelMapping::TPCReadoutBoardToChannelMap fReadoutBoardToChannelMap
const std::string & icarusDB::ICARUSChannelMapProvider::getCrateName ( const unsigned int  fragmentID) const
overridevirtual

Implements icarusDB::IICARUSChannelMap.

Definition at line 150 of file ICARUSChannelMapProvider.cxx.

151 {
152  IChannelMapping::TPCFragmentIDToReadoutIDMap::const_iterator fragToReadoutItr = fFragmentToReadoutMap.find(fragmentID);
153 
154  if (fragToReadoutItr == fFragmentToReadoutMap.end())
155  throw cet::exception("ICARUSChannelMapProvider") << "Fragment ID " << fragmentID << " not found in lookup map when looking up crate name \n";
156 
157  return fragToReadoutItr->second.first;
158 }
IChannelMapping::TPCFragmentIDToReadoutIDMap fFragmentToReadoutMap
const TPCReadoutBoardToChannelMap & icarusDB::ICARUSChannelMapProvider::getReadoutBoardToChannelMap ( ) const
overridevirtual

Implements icarusDB::IICARUSChannelMap.

Definition at line 171 of file ICARUSChannelMapProvider.cxx.

172 {
174 }
IChannelMapping::TPCReadoutBoardToChannelMap fReadoutBoardToChannelMap
const ReadoutIDVec & icarusDB::ICARUSChannelMapProvider::getReadoutBoardVec ( const unsigned int  fragmentID) const
overridevirtual

Implements icarusDB::IICARUSChannelMap.

Definition at line 160 of file ICARUSChannelMapProvider.cxx.

161 {
162  IChannelMapping::TPCFragmentIDToReadoutIDMap::const_iterator fragToReadoutItr = fFragmentToReadoutMap.find(fragmentID);
163 
164  if (fragToReadoutItr == fFragmentToReadoutMap.end())
165  throw cet::exception("ICARUSChannelMapProvider") << "Fragment ID " << fragmentID << " not found in lookup map when looking up board vector \n";
166 
167  return fragToReadoutItr->second.second;
168 
169 }
IChannelMapping::TPCFragmentIDToReadoutIDMap fFragmentToReadoutMap
std::pair< double, double > icarusDB::ICARUSChannelMapProvider::getSideCRTCalibrationMap ( int  mac5,
int  chan 
) const
overridevirtual

Returns the Gain and Pedestal for Side CRT.

Implements icarusDB::IICARUSChannelMap.

Definition at line 258 of file ICARUSChannelMapProvider.cxx.

259  {
260  auto const itGainAndPedestal = fSideCRTChannelToCalibrationMap.find({ mac5, chan });
261  return (itGainAndPedestal == fSideCRTChannelToCalibrationMap.cend())
262  ? std::pair{ -99., -99. }: itGainAndPedestal->second;
263  }
IChannelMapping::SideCRTChannelToCalibrationMap fSideCRTChannelToCalibrationMap
unsigned int icarusDB::ICARUSChannelMapProvider::getSimMacAddress ( const unsigned int  hwmacaddress) const
overridevirtual

Implements icarusDB::IICARUSChannelMap.

Definition at line 229 of file ICARUSChannelMapProvider.cxx.

230  {
231  unsigned int simmacaddress = 0;
232 
233  for(const auto& pair : fCRTChannelIDToHWtoSimMacAddressPairMap){
234  if (pair.second.first == hwmacaddress)
235  simmacaddress = pair.second.second;
236  }
237 
238  return simmacaddress;
239  }
IChannelMapping::CRTChannelIDToHWtoSimMacAddressPairMap fCRTChannelIDToHWtoSimMacAddressPairMap
unsigned int icarusDB::ICARUSChannelMapProvider::gettopSimMacAddress ( const unsigned int  hwmacaddress) const
overridevirtual

Implements icarusDB::IICARUSChannelMap.

Definition at line 241 of file ICARUSChannelMapProvider.cxx.

242  {
243  unsigned int simmacaddress = 0;
244 
245  for(const auto& pair : fTopCRTHWtoSimMacAddressPairMap){
246  if (pair.first == hwmacaddress)
247  simmacaddress = pair.second;
248  }
249 
250  return simmacaddress;
251 
252  /* untested:
253  auto const it = fTopCRTHWtoSimMacAddressPairMap.find(hwmacaddress);
254  return (it == fTopCRTHWtoSimMacAddressPairMap.end())? 0: it->second;
255  */
256  }
IChannelMapping::TopCRTHWtoSimMacAddressPairMap fTopCRTHWtoSimMacAddressPairMap
bool icarusDB::ICARUSChannelMapProvider::hasBoardID ( const unsigned int  boardID) const
overridevirtual

Implements icarusDB::IICARUSChannelMap.

Definition at line 177 of file ICARUSChannelMapProvider.cxx.

178 {
179  return fReadoutBoardToChannelMap.find(boardID) != fReadoutBoardToChannelMap.end();
180 }
IChannelMapping::TPCReadoutBoardToChannelMap fReadoutBoardToChannelMap
bool icarusDB::ICARUSChannelMapProvider::hasFragmentID ( const unsigned int  fragmentID) const
overridevirtual

Implements icarusDB::IICARUSChannelMap.

Definition at line 139 of file ICARUSChannelMapProvider.cxx.

140 {
141  return fFragmentToReadoutMap.find(fragmentID) != fFragmentToReadoutMap.end();
142 }
IChannelMapping::TPCFragmentIDToReadoutIDMap fFragmentToReadoutMap
bool icarusDB::ICARUSChannelMapProvider::hasPMTDigitizerID ( const unsigned int  fragmentID) const
overridevirtual

Implements icarusDB::IICARUSChannelMap.

Definition at line 209 of file ICARUSChannelMapProvider.cxx.

210 {
211  return findPMTfragmentEntry(fragmentID) != nullptr;
212 }
DigitizerChannelChannelIDPairVec const * findPMTfragmentEntry(unsigned int fragmentID) const
unsigned int icarusDB::ICARUSChannelMapProvider::nPMTfragmentIDs ( ) const
overridevirtual

Returns the number of PMT fragment IDs known to the service.

Implements icarusDB::IICARUSChannelMap.

Definition at line 215 of file ICARUSChannelMapProvider.cxx.

215  {
216  return fFragmentToDigitizerMap.size();
217 }
IChannelMapping::FragmentToDigitizerChannelMap fFragmentToDigitizerMap
unsigned int icarusDB::ICARUSChannelMapProvider::nTPCboardIDs ( ) const
overridevirtual

Returns the number of TPC board IDs known to the service.

Implements icarusDB::IICARUSChannelMap.

Definition at line 183 of file ICARUSChannelMapProvider.cxx.

183  {
184  return fReadoutBoardToChannelMap.size();
185 }
IChannelMapping::TPCReadoutBoardToChannelMap fReadoutBoardToChannelMap
unsigned int icarusDB::ICARUSChannelMapProvider::nTPCfragmentIDs ( ) const
overridevirtual

Returns the number of TPC fragment IDs known to the service.

Implements icarusDB::IICARUSChannelMap.

Definition at line 145 of file ICARUSChannelMapProvider.cxx.

145  {
146  return fFragmentToReadoutMap.size();
147 }
IChannelMapping::TPCFragmentIDToReadoutIDMap fFragmentToReadoutMap
constexpr unsigned int icarusDB::ICARUSChannelMapProvider::PMTfragmentIDtoDBkey ( unsigned int  fragmentID)
static

Returns the channel mapping database key for the specified PMT fragment ID.

Definition at line 274 of file ICARUSChannelMapProvider.cxx.

275 {
276  /*
277  * PMT channel mapping database stores the board number (0-23) as key.
278  * Fragment ID are currently in the pattern 0x20xx, with xx the board number.
279  */
280 
281  // protest if this is a fragment not from the PMT;
282  // but make an exception for old PMT fragment IDs (legacy)
283  assert(((fragmentID & ~0xFF) == 0x00) || ((fragmentID & ~0xFF) == 0x20));
284 
285  return fragmentID & 0xFF;
286 
287 } // ICARUSChannelMapProvider::PMTfragmentIDtoDBkey()

Member Data Documentation

std::unique_ptr<IChannelMapping> icarusDB::ICARUSChannelMapProvider::fChannelMappingTool
private

Definition at line 85 of file ICARUSChannelMapProvider.h.

IChannelMapping::CRTChannelIDToHWtoSimMacAddressPairMap icarusDB::ICARUSChannelMapProvider::fCRTChannelIDToHWtoSimMacAddressPairMap
private

Definition at line 79 of file ICARUSChannelMapProvider.h.

bool icarusDB::ICARUSChannelMapProvider::fDiagnosticOutput
private

Definition at line 71 of file ICARUSChannelMapProvider.h.

IChannelMapping::FragmentToDigitizerChannelMap icarusDB::ICARUSChannelMapProvider::fFragmentToDigitizerMap
private

Definition at line 77 of file ICARUSChannelMapProvider.h.

IChannelMapping::TPCFragmentIDToReadoutIDMap icarusDB::ICARUSChannelMapProvider::fFragmentToReadoutMap
private

Definition at line 73 of file ICARUSChannelMapProvider.h.

IChannelMapping::TPCReadoutBoardToChannelMap icarusDB::ICARUSChannelMapProvider::fReadoutBoardToChannelMap
private

Definition at line 75 of file ICARUSChannelMapProvider.h.

IChannelMapping::SideCRTChannelToCalibrationMap icarusDB::ICARUSChannelMapProvider::fSideCRTChannelToCalibrationMap
private

Definition at line 83 of file ICARUSChannelMapProvider.h.

IChannelMapping::TopCRTHWtoSimMacAddressPairMap icarusDB::ICARUSChannelMapProvider::fTopCRTHWtoSimMacAddressPairMap
private

Definition at line 81 of file ICARUSChannelMapProvider.h.


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