All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Functions
PMTChannelMapDumper.cxx File Reference

Utility dumping the content of PMT channel mapping on screen. More...

#include "icaruscode/Decode/ChannelMapping/ICARUSChannelMapProvider.h"
#include "larcorealg/CoreUtils/enumerate.h"
#include "larcorealg/TestUtils/unit_test_base.h"
#include "messagefacility/MessageLogger/MessageLogger.h"
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <array>

Go to the source code of this file.

Classes

struct  SortByElement< KeyNo >
 

Functions

int main (int argc, char **argv)
 

Detailed Description

Utility dumping the content of PMT channel mapping on screen.

Author
Gianluca Petrillo (petri.nosp@m.llo@.nosp@m.slac..nosp@m.stan.nosp@m.ford..nosp@m.edu)

This utility can be run with any configuration file including a configuration for IICARUSChannel service.

It is using art facilities for tool loading, but it does not run in art environment. So it may break without warning and without solution.

Definition in file PMTChannelMapDumper.cxx.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 51 of file PMTChannelMapDumper.cxx.

51  {
52 
53  using Environment
55 
56  testing::BasicEnvironmentConfiguration config("PMTchannelMappingDumper");
57 
58  //
59  // parameter parsing
60  //
61  int iParam = 0;
62 
63  // first argument: configuration file (mandatory)
64  if (++iParam < argc)
65  config.SetConfigurationPath(argv[iParam]);
66  else {
67  std::cerr << "FHiCL configuration file path required as first argument!"
68  << std::endl;
69  return 1;
70  }
71 
72  Environment const Env { config };
73 
74  icarusDB::ICARUSChannelMapProvider const channelMapping
75  { Env.ServiceParameters("IICARUSChannelMap") };
76 
77  // hard-coded list of fragment ID; don't like it?
78  // ask for an extension of the channel mapping features.
79  std::array<unsigned int, 24U> FragmentIDs;
80  std::iota(FragmentIDs.begin(), FragmentIDs.end(), 0x2000);
81 
82  mf::LogVerbatim("PMTchannelMappingDumper") << "Fragment IDs:";
83  for (auto const [ iFragment, fragmentID]: util::enumerate(FragmentIDs)) {
84  unsigned int const effFragmentID = fragmentID & 0xFF;
85 
86  if (!channelMapping.hasPMTDigitizerID(effFragmentID)) {
87  mf::LogVerbatim("PMTchannelMappingDumper")
88  << "[" << iFragment << "] " << std::hex << fragmentID << std::dec
89  << " not found in the database (as "
90  << std::hex << effFragmentID << std::dec << ")";
91  continue;
92  }
93 
95  = channelMapping.getChannelIDPairVec(effFragmentID);
96 
97  std::sort
98  (digitizerChannels.begin(), digitizerChannels.end(), SortByElement<1U>{});
99 
100 
101  mf::LogVerbatim log("PMTchannelMappingDumper");
102  log
103  << "[" << iFragment << "] " << std::hex << fragmentID << std::dec
104  << " includes " << digitizerChannels.size()
105  << " LArSoft channels between " << digitizerChannels.front().second
106  << " and " << digitizerChannels.back().second
107  << " [board channel index in brackets]:";
108  constexpr unsigned int Cols = 8U;
109  unsigned int n = 0;
110  for(auto const [ digitizerChannel, channelID ]: digitizerChannels) {
111  if (n-- == 0) { log << "\n "; n = Cols - 1U; }
112  log << " " << std::setw(3) << channelID
113  << " [" << std::setw(3) << digitizerChannel << "]";
114  } // for channel
115 
116  } // for fragment
117 
118  return 0;
119 } // main()
BEGIN_PROLOG or simple_flux see Environment
Definition: genie.fcl:8
std::vector< DigitizerChannelChannelIDPair > DigitizerChannelChannelIDPairVec
BEGIN_PROLOG could also be cerr
Class holding a configuration for a test environment.
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
const DigitizerChannelChannelIDPairVec & getChannelIDPairVec(const unsigned int) const override
A test environment with some support for service providers.