Public Member Functions | Private Attributes | List of all members
arttest::AssnsReaderTest Class Reference
Inheritance diagram for arttest::AssnsReaderTest:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Member Functions

 AssnsReaderTest (fhicl::ParameterSet const &p)
 
void analyze (art::Event const &e) override
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
void doBeginJob ()
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
std::string const & processName () const
 
bool wantAllEvents () const
 
bool wantEvent (Event const &e)
 
fhicl::ParameterSetID selectorConfig () const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Attributes

std::string const inputLabel_
 
std::string const process_
 
std::string const wantVoid_
 
bool const wantMV_
 
bool const wantMany_
 
bool const wantAmbiguous_
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- Protected Member Functions inherited from art::Observer
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &paths, fhicl::ParameterSet const &config)
 
detail::ProcessAndEventSelectorsprocessAndEventSelectors ()
 

Detailed Description

Definition at line 37 of file AssnsReaderTest_module.cc.

Constructor & Destructor Documentation

arttest::AssnsReaderTest::AssnsReaderTest ( fhicl::ParameterSet const &  p)
explicit

Definition at line 65 of file AssnsReaderTest_module.cc.

67  , inputLabel_(ps.get<std::string>("inputLabel"))
68  , process_(ps.get<std::string>("process", {}))
69  , wantVoid_(ps.get<std::string>("wantVoid", "ALL"))
70  , wantMV_(ps.get<bool>("wantMV", true))
71  , wantMany_(ps.get<bool>("wantMany", true))
72  , wantAmbiguous_(ps.get<bool>("wantAmbiguous", false))
73 {
74  // consumes<AssnsABV_t>(inputLabel_);
75  // consumes<AssnsBAV_t>(inputLabel_);
76  // consumes<AssnsABV_t>({inputLabel_, "many"s});
77  // consumes<AssnsBAV_t>({inputLabel_, "many"s});
78  // consumes<AssnsABV_t>({inputLabel_, "mapvec"s});
79  // consumes<AssnsBAV_t>({inputLabel_, "mapvec"s});
80  // consumes<AssnsABV_t>({inputLabel_, "manymapvec"s});
81  // consumes<AssnsBAV_t>({inputLabel_, "manymapvec"s});
82 
83  // consumes<AssnsABX_t>(inputLabel_);
84  // consumes<AssnsBAX_t>(inputLabel_);
85  // consumes<AssnsABX_t>({inputLabel_, "many"s});
86  // consumes<AssnsBAX_t>({inputLabel_, "many"s});
87  // consumes<AssnsABX_t>({inputLabel_, "mapvec"s});
88  // consumes<AssnsBAX_t>({inputLabel_, "mapvec"s});
89  // consumes<AssnsABX_t>({inputLabel_, "manymapvec"s});
90  // consumes<AssnsBAX_t>({inputLabel_, "manymapvec"s});
91 
92  // consumesMany<AssnsABV_t>();
93  // consumesMany<AssnsBAV_t>();
94  // consumesMany<AssnsABX_t>();
95  // consumesMany<AssnsBAX_t>();
96 }
static const double ps
Definition: Units.h:103
std::string string
Definition: nybbler.cc:12

Member Function Documentation

void arttest::AssnsReaderTest::analyze ( art::Event const &  e)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 149 of file AssnsReaderTest_module.cc.

150 {
151  std::size_t const vSize = (wantVoid_ == "ALL"s) ? 4ull : 3ull;
152  std::size_t const mvVSize = (wantVoid_ != "NONE"s) ? 4ull : 3ull;
153 
154  auto const vSizeM = vSize + ((wantVoid_ == "ALL"s) ? 2ull : 1ull);
155  auto const mvVSizeM = mvVSize + ((wantVoid_ != "NONE"s) ? 2ull : 1ull);
156 
157  // Check <A, B> and <B, A>.
159  try {
160  e.getByLabel(inputLabel_, hABV);
161  BOOST_CHECK_EQUAL(hABV->size(), vSize);
162  if (!process_.empty()) {
163  BOOST_CHECK_EQUAL(hABV.provenance()->processName(), process_);
164  }
165  }
166  catch (art::Exception const& e) {
167  if (!wantAmbiguous_ || wantVoid_ == "ALL") {
168  throw; // Shouldn't have gotten here.
169  } else { // Expected exception.
170  BOOST_REQUIRE(e.categoryCode() == art::errors::ProductNotFound);
171  BOOST_CHECK_EQUAL(
172  std::string(e.what()).substr(29, 69),
173  "getByLabel: Found 2 products rather than one which match all criteria"s);
174  }
175  }
176 
178  try {
179  e.getByLabel(inputLabel_, hBAV);
180  BOOST_CHECK_EQUAL(hBAV->size(), vSize);
181  if (!process_.empty()) {
182  BOOST_CHECK_EQUAL(hBAV.provenance()->processName(), process_);
183  }
184  }
185  catch (art::Exception const& e) {
186  if (!wantAmbiguous_ || wantVoid_ == "ALL") {
187  throw; // Shouldn't have gotten here.
188  } else { // Expected exception.
189  BOOST_REQUIRE(e.categoryCode() == art::errors::ProductNotFound);
190  BOOST_CHECK_EQUAL(
191  std::string(e.what()).substr(29, 69),
192  "getByLabel: Found 2 products rather than one which match all criteria"s);
193  }
194  }
195 
196  if (wantMany_) {
197  auto const hABVM = e.getValidHandle<AssnsABV_t>({inputLabel_, "many"s});
198  BOOST_CHECK_EQUAL(hABVM->size(), vSizeM);
199  auto const hBAVM = e.getValidHandle<AssnsBAV_t>({inputLabel_, "many"s});
200  BOOST_CHECK_EQUAL(hBAVM->size(), vSizeM);
201  if (!process_.empty()) {
202  BOOST_CHECK_EQUAL(hABVM.provenance()->processName(), process_);
203  BOOST_CHECK_EQUAL(hBAVM.provenance()->processName(), process_);
204  }
205  }
206  if (wantMV_) {
207  auto const hmvABV = e.getValidHandle<AssnsABV_t>({inputLabel_, "mapvec"s});
208  BOOST_CHECK_EQUAL(hmvABV->size(), mvVSize);
209  auto const hmvBAV = e.getValidHandle<AssnsBAV_t>({inputLabel_, "mapvec"s});
210  BOOST_CHECK_EQUAL(hmvBAV->size(), mvVSize);
211  if (!process_.empty()) {
212  BOOST_CHECK_EQUAL(hmvABV.provenance()->processName(), process_);
213  BOOST_CHECK_EQUAL(hmvBAV.provenance()->processName(), process_);
214  }
215  if (wantMany_) {
216  auto const hmvABVM =
217  e.getValidHandle<AssnsABV_t>({inputLabel_, "manymapvec"s});
218  BOOST_CHECK_EQUAL(hmvABVM->size(), mvVSizeM);
219  auto const hmvBAVM =
220  e.getValidHandle<AssnsBAV_t>({inputLabel_, "manymapvec"s});
221  BOOST_CHECK_EQUAL(hmvBAVM->size(), mvVSizeM);
222  if (!process_.empty()) {
223  BOOST_CHECK_EQUAL(hmvABVM.provenance()->processName(), process_);
224  BOOST_CHECK_EQUAL(hmvBAVM.provenance()->processName(), process_);
225  }
226  }
227  }
228 
229  // Check all <A, B, V> and <B, A, V>.
230  BOOST_CHECK_EQUAL(e.getValidHandle<AssnsABX_t>(inputLabel_)->size(), 3ull);
231  BOOST_CHECK_EQUAL(e.getValidHandle<AssnsBAX_t>(inputLabel_)->size(), 3ull);
232  if (wantMany_) {
233  BOOST_CHECK_EQUAL(
234  e.getValidHandle<AssnsABX_t>({inputLabel_, "many"s})->size(), 4ull);
235  BOOST_CHECK_EQUAL(
236  e.getValidHandle<AssnsBAX_t>({inputLabel_, "many"s})->size(), 4ull);
237  }
238  if (wantMV_) {
239  BOOST_CHECK_EQUAL(
240  e.getValidHandle<AssnsABX_t>({inputLabel_, "mapvec"s})->size(), 3ull);
241  BOOST_CHECK_EQUAL(
242  e.getValidHandle<AssnsBAX_t>({inputLabel_, "mapvec"s})->size(), 3ull);
243  if (wantMany_) {
244  BOOST_CHECK_EQUAL(
245  e.getValidHandle<AssnsABX_t>({inputLabel_, "manymapvec"s})->size(),
246  4ull);
247  BOOST_CHECK_EQUAL(
248  e.getValidHandle<AssnsBAX_t>({inputLabel_, "manymapvec"s})->size(),
249  4ull);
250  }
251  }
252 
253  // Check expected behavior of getManyByType().
254  std::vector<art::Handle<AssnsABV_t>> hSet1;
255  e.getManyByType(hSet1);
256  checkExpectedSize(
258  std::vector<art::Handle<AssnsBAV_t>> hSet2;
259  e.getManyByType(hSet2);
260  checkExpectedSize(
262  std::vector<art::Handle<AssnsABX_t>> hSet3;
263  e.getManyByType(hSet3);
264  checkExpectedSize(
266  std::vector<art::Handle<AssnsBAX_t>> hSet4;
267  e.getManyByType(hSet4);
268  checkExpectedSize(
270 }
size_type size() const
Definition: Assns.h:447
std::string string
Definition: nybbler.cc:12
const double e
Provenance const * provenance() const
Definition: Handle.h:204
BOOST_REQUIRE(inFile)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
static const double s
Definition: Units.h:99

Member Data Documentation

std::string const arttest::AssnsReaderTest::inputLabel_
private

Definition at line 44 of file AssnsReaderTest_module.cc.

std::string const arttest::AssnsReaderTest::process_
private

Definition at line 45 of file AssnsReaderTest_module.cc.

bool const arttest::AssnsReaderTest::wantAmbiguous_
private

Definition at line 49 of file AssnsReaderTest_module.cc.

bool const arttest::AssnsReaderTest::wantMany_
private

Definition at line 48 of file AssnsReaderTest_module.cc.

bool const arttest::AssnsReaderTest::wantMV_
private

Definition at line 47 of file AssnsReaderTest_module.cc.

std::string const arttest::AssnsReaderTest::wantVoid_
private

Definition at line 46 of file AssnsReaderTest_module.cc.


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