TestHardwareMapper_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: TestHardwareMapper
3 // Module Type: analyzer
4 // File: TestHardwareMapper_module.cc
5 //
6 // Jonathan Davies j.p.davies@sussex.ac.uk
7 // August 2016
8 //
9 ////////////////////////////////////////////////////////////////////////
10 
19 #include "fhiclcpp/ParameterSet.h"
21 
22 //We need a hardware mapper service, so we should include the header
25 
26 class TestHardwareMapper;
27 
29 
30 public:
31 
32  explicit TestHardwareMapper(fhicl::ParameterSet const & pset);
33 
34  // Plugins should not be copied or assigned.
35  TestHardwareMapper(TestHardwareMapper const &) = delete;
39 
40  // The main guts...
41  void analyze(art::Event const& evt) override;
42 
43  void beginJob() override;
44 
45  void reconfigure(fhicl::ParameterSet const & pset);
46 
47 private:
48  unsigned int fLogLevel;
51 };
52 
53 //......................................................
55  : EDAnalyzer(pset), fLogLevel(1), fModuleName("TestHardwareMapper")
56 {
57  pset.get_if_present<unsigned int>("LogLevel", fLogLevel);
58  std::string func_name("TestHardwareMapper");
59  if(fLogLevel>1) mf::LogInfo(fModuleName) << " in Function: " << func_name;
60  this->reconfigure(pset);
61 }
62 
63 //......................................................
65  std::string func_name("TestHardwareMapper");
66  if(fLogLevel>1) mf::LogInfo(fModuleName) << " in Function: " << func_name;
67 }
68 
69 //......................................................
71  std::string func_name("TestHardwareMapper");
72  if(fLogLevel>1) mf::LogInfo(fModuleName) << " in Function: " << func_name;
73 
74  //jpd -- this is how to loop through TPCs, asking the hardware mapper for the channels associated with each one
75  unsigned int num_tpcs = mapperService->getNTPCs();
76  {
77  mf::LogInfo loginfo(fModuleName);
78  for(unsigned int tpc_id = 0; tpc_id < num_tpcs; tpc_id++){
79  //jpd -- now get the vector of channels
80  std::vector<raw::ChannelID_t> tpc_channel_vector = mapperService->getTPCChannels(tpc_id);
81  loginfo << "Got TPC number: " << tpc_id
82  << " - it has " << tpc_channel_vector.size() << " channels"
83  << " - first channel is " << tpc_channel_vector.at(0)
84  << "\n";
85  }//loop over TPCs
86  }//annonymous to wrap loginfo
87 
88  //jpd -- this is how to loop through APAs, asking the hardware mapper for the channels associated with each one
89  unsigned int num_apas = mapperService->getNAPAs();
90  {
91  mf::LogInfo loginfo(fModuleName);
92  for(unsigned int apa_id = 0; apa_id < num_apas; apa_id++){
93  //jpd -- now get the vector of channels
94  std::vector<raw::ChannelID_t> apa_channel_vector = mapperService->getAPAChannels(apa_id);
95  loginfo << "Got APA number: " << apa_id
96  << " - it has " << apa_channel_vector.size() << " channels"
97  << " - first channel is " << apa_channel_vector.at(0)
98  << "\n";
99  }//loop over APAs
100  }//annonymous to wrap loginfo
101 }
102 
103 //......................................................
105  std::string func_name("TestHardwareMapper");
106  if(fLogLevel>1) mf::LogInfo(fModuleName) << " in Function: " << func_name;
108 }
109 
110 //......................................................
111 
112 //......................................................
113 
114 //......................................................
115 
116 //......................................................
117 
TestHardwareMapper(fhicl::ParameterSet const &pset)
std::vector< raw::ChannelID_t > const & getAPAChannels(Hardware::ID apa_id)
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
unsigned int getNAPAs() const
std::vector< raw::ChannelID_t > const & getTPCChannels(Hardware::ID tpc_id)
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
art::ServiceHandle< HardwareMapperService > mapperService
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
void reconfigure(fhicl::ParameterSet const &pset)
void analyze(art::Event const &evt) override
unsigned int getNTPCs() const
std::optional< T > get_if_present(std::string const &key) const
Definition: ParameterSet.h:224
TestHardwareMapper & operator=(TestHardwareMapper const &)=delete
TCEvent evt
Definition: DataStructs.cxx:7