10 #include "art/Utilities/make_tool.h"
11 #include "messagefacility/MessageLogger/MessageLogger.h"
12 #include "fhiclcpp/ParameterSet.h"
13 #include "cetlib_except/exception.h"
14 #include "cetlib/cpu_timer.h"
32 mf::LogInfo(
"ICARUSChannelMapProvider") <<
"Building the channel mapping" ;
37 const fhicl::ParameterSet&channelMappingParams = pset.get<fhicl::ParameterSet>(
"ChannelMappingTool");
42 cet::cpu_timer theClockFragmentIDs;
44 theClockFragmentIDs.start();
48 throw cet::exception(
"ICARUSChannelMapProvider") <<
"Cannot recover the Fragment ID channel map from the database \n";
54 << pair.second.first <<
", # boards: " << std::dec << pair.second.second.size() << std::endl;
58 theClockFragmentIDs.stop();
60 double fragmentIDsTime = theClockFragmentIDs.accumulated_real_time();
62 cet::cpu_timer theClockReadoutIDs;
64 theClockReadoutIDs.start();
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";
75 throw cet::exception(
"ICARUSChannelMapProvider") <<
"Cannot recover the Fragment ID channel map from the database \n";
81 << std::dec << pair.second.size() << std::endl;
87 throw cet::exception(
"CRTDecoder") <<
"Cannot recover the HW MAC Address from the database \n";
93 <<
", hw mac address: " << pair.second.first
94 <<
", sim mac address: " << pair.second.second << std::endl;
102 throw cet::exception(
"CRTDecoder") <<
"Cannot recover the Top CRT HW MAC Address from the database \n";
108 <<
", sim mac address: " << pair.second << std::endl;
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";
123 <<
", chan: " << pair.first.second
124 <<
", Gain: " << pair.second.first
125 <<
", Pedestal: " << pair.second.second << std::endl;
129 theClockReadoutIDs.stop();
131 double readoutIDsTime = theClockReadoutIDs.accumulated_real_time();
134 mf::LogInfo(
"ICARUSChannelMapProvider") <<
"==> FragmentID map time: " << fragmentIDsTime <<
", Readout IDs time: " << readoutIDsTime << std::endl;
152 IChannelMapping::TPCFragmentIDToReadoutIDMap::const_iterator fragToReadoutItr =
fFragmentToReadoutMap.find(fragmentID);
155 throw cet::exception(
"ICARUSChannelMapProvider") <<
"Fragment ID " << fragmentID <<
" not found in lookup map when looking up crate name \n";
157 return fragToReadoutItr->second.first;
162 IChannelMapping::TPCFragmentIDToReadoutIDMap::const_iterator fragToReadoutItr =
fFragmentToReadoutMap.find(fragmentID);
165 throw cet::exception(
"ICARUSChannelMapProvider") <<
"Fragment ID " << fragmentID <<
" not found in lookup map when looking up board vector \n";
167 return fragToReadoutItr->second.second;
193 throw cet::exception(
"ICARUSChannelMapProvider") <<
"Board ID " << boardID <<
" not found in lookup map when looking up board slot \n";
195 return readoutBoardItr->second.first;
203 throw cet::exception(
"ICARUSChannelMapProvider") <<
"Board ID " << boardID <<
" not found in lookup map when looking up channel/plane pair \n";
205 return readoutBoardItr->second.second;
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";
231 unsigned int simmacaddress = 0;
234 if (pair.second.first == hwmacaddress)
235 simmacaddress = pair.second.second;
238 return simmacaddress;
243 unsigned int simmacaddress = 0;
246 if (pair.first == hwmacaddress)
247 simmacaddress = pair.second;
250 return simmacaddress;
262 ? std::pair{ -99., -99. }: itGainAndPedestal->second;
268 auto it = fFragmentToDigitizerMap.find(PMTfragmentIDtoDBkey(fragmentID));
269 return (it == fFragmentToDigitizerMap.end())?
nullptr: &(it->second);
274 (
unsigned int fragmentID)
283 assert(((fragmentID & ~0xFF) == 0x00) || ((fragmentID & ~0xFF) == 0x20));
285 return fragmentID & 0xFF;
300 assert((DBkey & 0xFF) < 24);
302 return (DBkey & 0xFF) | 0x2000;
bool hasBoardID(const unsigned int) const override
std::vector< ChannelPlanePair > ChannelPlanePairVec
std::vector< DigitizerChannelChannelIDPair > DigitizerChannelChannelIDPairVec
std::vector< unsigned int > ReadoutIDVec
const ChannelPlanePairVec & getChannelPlanePair(const unsigned int) const override
static constexpr unsigned int DBkeyToPMTfragmentID(unsigned int DBkey)
Returns the PMT fragment ID for the specified channel mapping database key.
This provides an art tool interface definition for tools handle the channel mapping The idea is to be...
unsigned int nTPCboardIDs() const override
Returns the number of TPC board IDs known to the service.
IChannelMapping::SideCRTChannelToCalibrationMap fSideCRTChannelToCalibrationMap
IChannelMapping::TopCRTHWtoSimMacAddressPairMap fTopCRTHWtoSimMacAddressPairMap
DigitizerChannelChannelIDPairVec const * findPMTfragmentEntry(unsigned int fragmentID) const
const ReadoutIDVec & getReadoutBoardVec(const unsigned int) const override
std::pair< double, double > getSideCRTCalibrationMap(int mac5, int chan) const override
Returns the Gain and Pedestal for Side CRT.
const std::string & getCrateName(const unsigned int) const override
IChannelMapping::TPCFragmentIDToReadoutIDMap fFragmentToReadoutMap
unsigned int nPMTfragmentIDs() const override
Returns the number of PMT fragment IDs known to the service.
ICARUSChannelMapProvider(const fhicl::ParameterSet &pset)
unsigned int nTPCfragmentIDs() const override
Returns the number of TPC fragment IDs known to the service.
const TPCReadoutBoardToChannelMap & getReadoutBoardToChannelMap() const override
const DigitizerChannelChannelIDPairVec & getChannelIDPairVec(const unsigned int) const override
bool hasFragmentID(const unsigned int) const override
std::map< unsigned int, SlotChannelVecPair > TPCReadoutBoardToChannelMap
static constexpr unsigned int PMTfragmentIDtoDBkey(unsigned int fragmentID)
Returns the channel mapping database key for the specified PMT fragment ID.
unsigned int getSimMacAddress(const unsigned int) const override
std::unique_ptr< IChannelMapping > fChannelMappingTool
unsigned int getBoardSlot(const unsigned int) const override
IChannelMapping::CRTChannelIDToHWtoSimMacAddressPairMap fCRTChannelIDToHWtoSimMacAddressPairMap
IChannelMapping::FragmentToDigitizerChannelMap fFragmentToDigitizerMap
bool hasPMTDigitizerID(const unsigned int) const override
BEGIN_PROLOG could also be cout
unsigned int gettopSimMacAddress(const unsigned int) const override
IChannelMapping::TPCReadoutBoardToChannelMap fReadoutBoardToChannelMap