Classes | Namespaces | Functions
SimpleDerivedAnalyzer_module.cc File Reference
#include "art/Framework/Core/EDAnalyzer.h"
#include "art/Framework/Core/ModuleMacros.h"
#include "art/Framework/Principal/Event.h"
#include "art/Framework/Principal/View.h"
#include "art/test/TestObjects/ToyProducts.h"
#include "canvas/Persistency/Common/PtrVector.h"
#include "canvas/Persistency/Provenance/EventID.h"
#include "cetlib_except/exception.h"
#include "fhiclcpp/ParameterSet.h"
#include <iostream>
#include <memory>
#include <string>
#include <vector>

Go to the source code of this file.

Classes

struct  dummy
 
class  arttest::SimpleDerivedAnalyzer
 
struct  arttest::SimpleDerivedAnalyzer::Config
 

Namespaces

 arttest
 

Functions

template<typename T >
void check_for_conversion (art::View< T > const &v)
 
template<class T >
void verify_elements (std::vector< T > const &ptrs, std::size_t sz, art::EventNumber_t event_num, std::size_t)
 
template<typename T >
void test_view (art::Event const &e, art::ViewToken< T > const &token, art::ViewToken< T > const &tokenForCurrentProcess, std::size_t const nvalues)
 

Function Documentation

template<typename T >
void check_for_conversion ( art::View< T > const &  v)

Definition at line 30 of file SimpleDerivedAnalyzer_module.cc.

31 {
32  assert(v.vals().size() > 0);
33 }
auto vals() -> auto &
Definition: View.h:76
template<typename T >
void test_view ( art::Event const &  e,
art::ViewToken< T > const &  token,
art::ViewToken< T > const &  tokenForCurrentProcess,
std::size_t const  nvalues 
)

Definition at line 139 of file SimpleDerivedAnalyzer_module.cc.

143 {
144  auto const event_num = e.id().event();
145  std::vector<T const*> ptrs;
146  auto sz = e.getView(token, ptrs);
147  assert(sz == nvalues);
148  verify_elements(ptrs, sz, event_num, nvalues);
149  ptrs.clear();
150  sz = e.getView(tokenForCurrentProcess, ptrs);
151  assert(sz == nvalues);
152  verify_elements(ptrs, sz, event_num, nvalues);
153  art::View<T> v;
154  assert(e.getView(token, v));
155  assert(v.vals().size() == nvalues);
156  verify_elements(v.vals(), v.vals().size(), event_num, nvalues);
157  art::View<T> v2;
158  assert(e.getView(tokenForCurrentProcess, v2));
159  assert(v2.vals().size() == nvalues);
160  verify_elements(v2.vals(), v2.vals().size(), event_num, nvalues);
161  // Fill a PtrVector from the view... after zeroing the first
162  // element.
163  v.vals().front() = 0; // zero out the first pointer...
164  art::PtrVector<T> pvec;
165  v.fill(pvec);
166  for (std::size_t i = 0, sz = pvec.size(); i != sz; ++i) {
167  assert(*pvec[i] == *v.vals()[i + 1]);
168  }
169 }
void fill(PtrVector< T > &pv) const
Definition: View.h:158
const double e
void verify_elements(std::vector< T > const &ptrs, std::size_t sz, art::EventNumber_t event_num, std::size_t)
Definition: fwd.h:43
auto vals() -> auto &
Definition: View.h:76
size_type size() const
Definition: PtrVector.h:308
template<class T >
void verify_elements ( std::vector< T > const &  ptrs,
std::size_t  sz,
art::EventNumber_t  event_num,
std::size_t   
)

Definition at line 124 of file SimpleDerivedAnalyzer_module.cc.

128 {
129  for (std::size_t k = 0; k != sz; ++k) {
130  assert((unsigned)ptrs[k]->key == sz - k + event_num);
131  double expect = 1.5 * k + 100.0;
132  assert(ptrs[k]->value == expect);
133  assert(ptrs[k]->dummy() == 16.25);
134  }
135 }
cet::LibraryManager dummy("noplugin")