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

Public Types

typedef art::PtrVector< int > product_t
 
- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 PtrVectorAnalyzer (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 input_label_
 
unsigned nvalues_
 

Additional Inherited Members

- 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 24 of file PtrVectorAnalyzer_module.cc.

Member Typedef Documentation

Definition at line 26 of file PtrVectorAnalyzer_module.cc.

Constructor & Destructor Documentation

arttest::PtrVectorAnalyzer::PtrVectorAnalyzer ( fhicl::ParameterSet const &  p)
inline

Definition at line 28 of file PtrVectorAnalyzer_module.cc.

30  , input_label_(p.get<std::string>("input_label"))
31  , nvalues_(p.get<unsigned>("nvalues"))
32  {}
std::string string
Definition: nybbler.cc:12
p
Definition: test.py:228

Member Function Documentation

void arttest::PtrVectorAnalyzer::analyze ( art::Event const &  e)
inlineoverridevirtual

Implements art::EDAnalyzer.

Definition at line 35 of file PtrVectorAnalyzer_module.cc.

36  {
38  e.getByLabel(input_label_, h);
39 
40  size_t sz = h->size();
41  if (sz != nvalues_) {
42  throw cet::exception("SizeMismatch")
43  << "Expected a PtrVector of size " << nvalues_
44  << " but the obtained size is " << sz << '\n';
45  }
46 
47  int value = e.id().event();
48  size_t count = 0;
49  for (const auto ptr : *h) {
50  if (*ptr != value) {
51  throw cet::exception("ValueMismatch")
52  << "At position " << count << " expected value " << value
53  << " but obtained " << *ptr << '\n';
54  }
55  ++value;
56  ++count;
57  }
58  if (count != sz) {
59  throw cet::exception("CountMismatch")
60  << "Expected to iterate over " << sz << " values, but found " << count
61  << '\n';
62  }
63 
64  // Make a copy of the PtrVector, so we can call sort on it.
65  product_t local(*h);
66  // Make sure we're not sorted yet...
67  sz = local.size();
68  assert(sz > 1);
69 
70  local.sort();
71  assert(sz == local.size());
72  for (size_t i = 1; i != sz; ++i)
73  assert(*local[i - 1] < *local[i]);
74 
75  std::greater<int> gt;
76  local.sort(gt);
77  assert(sz == local.size());
78  for (size_t i = 1; i != sz; ++i)
79  assert(*local[i - 1] > *local[i]);
80 
81  // Make a new PtrVector so we can range-insert into it.
82  product_t insert_test;
83  auto half_size = h->size() / 2;
84  insert_test.insert(
85  insert_test.begin(), h->cbegin(), h->cbegin() + half_size);
86  auto it =
87  insert_test.insert(insert_test.end(), h->cbegin() + half_size, h->cend());
88  assert(it == insert_test.begin() + half_size);
89  assert(insert_test.size() == h->size());
90  it = insert_test.insert(it, h->cbegin(), h->end());
91  assert(it == insert_test.begin() + half_size);
92  assert(insert_test.size() == h->size() * 2);
93  } // analyze()
const double e
size_type size() const
Definition: PtrVector.h:308
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
h
training ###############################
Definition: train_cnn.py:186

Member Data Documentation

std::string arttest::PtrVectorAnalyzer::input_label_
private

Definition at line 96 of file PtrVectorAnalyzer_module.cc.

unsigned arttest::PtrVectorAnalyzer::nvalues_
private

Definition at line 97 of file PtrVectorAnalyzer_module.cc.


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