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

Tests an instanciation of the ChannelStatusService. More...

Inheritance diagram for lariov::SimpleChannelStatusTest:

Public Member Functions

 SimpleChannelStatusTest (fhicl::ParameterSet const &pset)
 
virtual void analyze (art::Event const &) override
 
virtual void beginRun (art::Run const &run) override
 

Private Member Functions

template<typename Obj >
unsigned int testObject (Obj const *pChStatus) const
 

Private Attributes

std::vector< unsigned int > KnownGoodChannels
 
std::vector< unsigned int > KnownNoisyChannels
 
std::vector< unsigned int > KnownBadChannels
 

Static Private Attributes

static const std::vector
< unsigned int > 
EmptyVect
 for initializations More...
 

Detailed Description

Tests an instanciation of the ChannelStatusService.

Configuration parameters

Definition at line 41 of file SimpleChannelStatusTest_module.cc.

Constructor & Destructor Documentation

lariov::SimpleChannelStatusTest::SimpleChannelStatusTest ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 72 of file SimpleChannelStatusTest_module.cc.

73  : EDAnalyzer(pset)
75  (pset.get<std::vector<unsigned int>>("TestGoodChannels", EmptyVect))
77  (pset.get<std::vector<unsigned int>>("TestNoisyChannels", EmptyVect))
79  (pset.get<std::vector<unsigned int>>("TestBadChannels", EmptyVect))
80  {
81  mf::LogInfo log("SimpleChannelStatusTest");
82 
83  log << "Channels known as good: " << KnownGoodChannels.size();
84  if (!KnownGoodChannels.empty()) {
85  log << " (";
86  for (unsigned int chId: KnownGoodChannels) log << " " << chId;
87  log << ")";
88  } // if known good channels
89 
90  log << "\nChannels known as noisy: " << KnownNoisyChannels.size();
91  if (!KnownNoisyChannels.empty()) {
92  log << " (";
93  for (unsigned int chId: KnownNoisyChannels) log << " " << chId;
94  log << ")";
95  } // if known noisy channels
96 
97  log << "\nChannels known as bad: " << KnownBadChannels.size();
98  if (!KnownBadChannels.empty()) {
99  log << " (";
100  for (unsigned int chId: KnownBadChannels) log << " " << chId;
101  log << ")";
102  } // if known bad channels
103 
104  } // SimpleChannelStatusTest::SimpleChannelStatusTest()
static const std::vector< unsigned int > EmptyVect
for initializations
std::vector< unsigned int > KnownNoisyChannels

Member Function Documentation

virtual void lariov::SimpleChannelStatusTest::analyze ( art::Event const &  )
inlineoverridevirtual

Definition at line 45 of file SimpleChannelStatusTest_module.cc.

45 {}
void lariov::SimpleChannelStatusTest::beginRun ( art::Run const &  run)
overridevirtual

Definition at line 108 of file SimpleChannelStatusTest_module.cc.

108  {
109 
110  mf::LogInfo("SimpleChannelStatusTest") << "New run: " << run.run();
111 
112  unsigned int nErrors = 0;
113 
114  //---
115  mf::LogVerbatim("SimpleChannelStatusTest")
116  << "\nTesting service interface...";
117  art::ServiceHandle<lariov::ChannelStatusService const> StatusSrvHandle;
118  /* // since the service does not share the interface of the provider,
119  // this test can't be
120  const lariov::ChannelStatusService* pStatusSrv = &*StatusSrvHandle;
121  nErrors = testObject(pStatusSrv);
122  if (nErrors > 0) {
123  throw art::Exception(art::errors::LogicError)
124  << nErrors << " errors while testing ChannelStatusService!";
125  } // if errors
126  */
127 
128  //---
129  mf::LogVerbatim("SimpleChannelStatusTest")
130  << "\nTesting base interface...";
131  lariov::ChannelStatusProvider const* pChStatus
132  = StatusSrvHandle->GetProviderPtr();
133  nErrors = testObject(pChStatus);
134  if (nErrors > 0) {
135  throw art::Exception(art::errors::LogicError)
136  << nErrors << " errors while testing ChannelStatusProvider!";
137  } // if errors
138 
139  } // SimpleChannelStatusTest::beginRun()
Class providing information about the quality of channels.
unsigned int testObject(Obj const *pChStatus) const
template<typename Obj >
unsigned int lariov::SimpleChannelStatusTest::testObject ( Obj const *  pChStatus) const
private

Definition at line 144 of file SimpleChannelStatusTest_module.cc.

145  {
146  // 1. print all the channels marked non-good
147  {
148  mf::LogInfo log("SimpleChannelStatusTest");
149 
150 
151  // this is a copy of the list;
152  // to avoid creating temporary objects, check channels one by one
153  auto BadChannels = pChStatus->BadChannels();
154  log << "\nChannels marked as bad: " << BadChannels.size();
155  if (!BadChannels.empty()) {
156  log << " (";
157  for (unsigned int chId: BadChannels) log << " " << chId;
158  log << ")";
159  } // if bad channels
160 
161  auto NoisyChannels = pChStatus->NoisyChannels();
162  log << "\nChannels marked as noisy: " << NoisyChannels.size();
163  if (!NoisyChannels.empty()) {
164  log << " (";
165  for (unsigned int chId: NoisyChannels) log << " " << chId;
166  log << ")";
167  } // if noisy channels
168  } // print test
169 
170  // 2. test the channels as in the configuration
171  unsigned int nErrors = 0;
172  for (const auto chId: KnownBadChannels) {
173  if (!pChStatus->IsBad(chId)) {
174  mf::LogError("SimpleChannelStatusTest")
175  << "channel #" << chId << " is not bad as it should";
176  ++nErrors;
177  }
178  } // for knwon bad channels
179 
180  for (const auto chId: KnownNoisyChannels) {
181  if (!pChStatus->IsNoisy(chId)) {
182  mf::LogError("SimpleChannelStatusTest")
183  << "channel #" << chId << " is not noisy as it should";
184  ++nErrors;
185  }
186  } // for knwon noisy channels
187 
188  for (const auto chId: KnownGoodChannels) {
189  if (pChStatus->IsBad(chId)) {
190  mf::LogError("SimpleChannelStatusTest")
191  << "channel #" << chId << " is bad, while it should not";
192  ++nErrors;
193  }
194  if (pChStatus->IsNoisy(chId)) {
195  mf::LogError("SimpleChannelStatusTest")
196  << "channel #" << chId << " is noisy, while it should not";
197  ++nErrors;
198  }
199  } // for knwon good channels
200 
201  return nErrors;
202  } // SimpleChannelStatusTest::testObject()
BEGIN_PROLOG NoisyChannels
std::vector< unsigned int > KnownNoisyChannels

Member Data Documentation

const std::vector< unsigned int > lariov::SimpleChannelStatusTest::EmptyVect
staticprivate

for initializations

Definition at line 57 of file SimpleChannelStatusTest_module.cc.

std::vector<unsigned int> lariov::SimpleChannelStatusTest::KnownBadChannels
private

Definition at line 51 of file SimpleChannelStatusTest_module.cc.

std::vector<unsigned int> lariov::SimpleChannelStatusTest::KnownGoodChannels
private

Definition at line 49 of file SimpleChannelStatusTest_module.cc.

std::vector<unsigned int> lariov::SimpleChannelStatusTest::KnownNoisyChannels
private

Definition at line 50 of file SimpleChannelStatusTest_module.cc.


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