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

Public Member Functions

 MixAnalyzer (fhicl::ParameterSet const &p)
 
- 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 Types

using mv_t = cet::map_vector< unsigned int >
 
using mvv_t = mv_t::value_type
 
using mvm_t = mv_t::mapped_type
 

Private Member Functions

void analyze (art::Event const &e) override
 

Private Attributes

size_t eventCounter_ {}
 
size_t nSecondaries_
 
std::string mixFilterLabel_
 

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 30 of file MixAnalyzer_module.cc.

Member Typedef Documentation

using arttest::MixAnalyzer::mv_t = cet::map_vector<unsigned int>
private

Definition at line 37 of file MixAnalyzer_module.cc.

Definition at line 39 of file MixAnalyzer_module.cc.

Definition at line 38 of file MixAnalyzer_module.cc.

Constructor & Destructor Documentation

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

Definition at line 46 of file MixAnalyzer_module.cc.

48  , nSecondaries_{p.get<size_t>("numSecondaries", 1)}
49  , mixFilterLabel_{p.get<std::string>("mixFilterLabel", "mixFilter")}
50 {}
std::string string
Definition: nybbler.cc:12
p
Definition: test.py:228

Member Function Documentation

void arttest::MixAnalyzer::analyze ( art::Event const &  e)
overrideprivatevirtual

Implements art::EDAnalyzer.

Definition at line 53 of file MixAnalyzer_module.cc.

54 {
55  ++eventCounter_;
56 
57  // Double
59  e.getByLabel(mixFilterLabel_, "doubleLabel", dH);
60  double dExpected =
61  ((2 * eventCounter_ - 1) * nSecondaries_ + 1) * nSecondaries_ / 2;
62  assert(*dH == dExpected);
63 
64  // IntProduct
66  BOOST_REQUIRE(e.getByLabel(mixFilterLabel_, "IntProductLabel", ipH));
67  BOOST_REQUIRE_EQUAL(ipH->value, dExpected + 1000000 * nSecondaries_);
68 
69  // String
71  BOOST_REQUIRE(e.getByLabel(mixFilterLabel_, "stringLabel", sH));
72  std::ostringstream sExp;
73  for (size_t i = 1; i <= nSecondaries_; ++i) {
74  sExp << "string value: " << std::setfill('0') << std::setw(7)
75  << (eventCounter_ - 1) * nSecondaries_ + i << "\n";
76  }
77  BOOST_REQUIRE_EQUAL(*sH, sExp.str());
78 
79  // 1. std::vector<double>
81  BOOST_REQUIRE(e.getByLabel(mixFilterLabel_, "doubleCollectionLabel", vdH));
82  BOOST_REQUIRE_EQUAL(vdH->size(), 10 * nSecondaries_);
83  for (size_t i = 0; i < nSecondaries_; ++i) {
84  for (size_t j = 1; j < 11; ++j) {
85  BOOST_REQUIRE_EQUAL((*vdH)[i * 10 + j - 1],
86  j + 10 * (i + (eventCounter_ - 1) * nSecondaries_));
87  }
88  }
89 
90  // 2. std::vector<art::Ptr<double> >
91  // 3. art::PtrVector<double>
92  // 4. ProductWithPtrs
95  e.getByLabel(mixFilterLabel_, "doubleVectorPtrLabel", vpdH)); // 2.
96 #ifndef ART_NO_MIX_PTRVECTOR
99  e.getByLabel(mixFilterLabel_, "doublePtrVectorLabel", pvdH)); // 3.
100 #endif
103  e.getByLabel(mixFilterLabel_, "ProductWithPtrsLabel", pwpH)); // 4.
104 
105  for (size_t i = 0; i < nSecondaries_; ++i) {
106  BOOST_REQUIRE_EQUAL(*(*vpdH)[i * 3 + 0], (*vdH)[(i * 10) + 0]); // 2.
107  BOOST_REQUIRE_EQUAL(*(*vpdH)[i * 3 + 1], (*vdH)[(i * 10) + 4]); // 2.
108  BOOST_REQUIRE_EQUAL(*(*vpdH)[i * 3 + 2], (*vdH)[(i * 10) + 8]); // 2.
109 #ifndef ART_NO_MIX_PTRVECTOR
110  BOOST_REQUIRE_EQUAL(*(*pvdH)[i * 3 + 0], (*vdH)[(i * 10) + 1]); // 3.
111  BOOST_REQUIRE_EQUAL(*(*pvdH)[i * 3 + 1], (*vdH)[(i * 10) + 5]); // 3.
112  BOOST_REQUIRE_EQUAL(*(*pvdH)[i * 3 + 2], (*vdH)[(i * 10) + 9]); // 3.
113 #endif
114  BOOST_REQUIRE_EQUAL(*(pwpH->vectorPtrDouble())[i * 3 + 0],
115  *(*vpdH)[i * 3 + 0]); // 4.
116  BOOST_REQUIRE_EQUAL(*(pwpH->vectorPtrDouble())[i * 3 + 1],
117  *(*vpdH)[i * 3 + 1]); // 4.
118  BOOST_REQUIRE_EQUAL(*(pwpH->vectorPtrDouble())[i * 3 + 2],
119  *(*vpdH)[i * 3 + 2]); // 4.
120 #ifndef ART_NO_MIX_PTRVECTOR
121  BOOST_REQUIRE_EQUAL(*(pwpH->ptrVectorDouble())[i * 3 + 0],
122  *(*pvdH)[i * 3 + 0]); // 4.
123  BOOST_REQUIRE_EQUAL(*(pwpH->ptrVectorDouble())[i * 3 + 1],
124  *(*pvdH)[i * 3 + 1]); // 4.
125  BOOST_REQUIRE_EQUAL(*(pwpH->ptrVectorDouble())[i * 3 + 2],
126  *(*pvdH)[i * 3 + 2]); // 4.
127 #endif
128  }
129 
130  // map_vector<unsigned int>
132  BOOST_REQUIRE(e.getByLabel(mixFilterLabel_, "mapVectorLabel", mv));
133  BOOST_REQUIRE_EQUAL(mv->size(), 5 * nSecondaries_);
134  {
135  auto it = mv->begin();
136  size_t delta = 0;
137  size_t index = 0;
138  for (size_t i = 0; i < nSecondaries_; ++i, delta = index + 1) {
139  for (size_t j = 0; j < 5; ++j, ++it) {
140  index =
141  1 + j * 2 + delta + 10 * (i + nSecondaries_ * (eventCounter_ - 1));
142  BOOST_REQUIRE_EQUAL(it->first, static_cast<cet::map_vector_key>(index));
143  size_t answer = j + 1 + 5 * i + (eventCounter_ - 1) * 5 * nSecondaries_;
144  BOOST_REQUIRE_EQUAL(it->second, answer);
145  BOOST_REQUIRE_EQUAL(*mv->getOrNull(cet::map_vector_key(index)), answer);
146  }
147  }
148  std::cerr << "\n";
149  }
150 
151  // Ptrs into map_vector
153  BOOST_REQUIRE(e.getByLabel(mixFilterLabel_, "intVectorPtrLabel", mvvp));
154  BOOST_REQUIRE_EQUAL(mvvp->size(), 5 * nSecondaries_);
155  {
156  auto it = mvvp->begin();
157  size_t delta = 0;
158  size_t index_base = 0;
159  for (size_t i = 0; i < nSecondaries_; ++i, delta = index_base + 9, ++it) {
160  std::cerr << "delta = " << delta << "\n";
161  index_base = delta + 1 + 10 * (i + nSecondaries_ * (eventCounter_ - 1));
162  size_t answer_base = (eventCounter_ - 1) * 5 * nSecondaries_ + i * 5 + 1;
163  BOOST_REQUIRE_EQUAL((*it)->first,
164  static_cast<cet::map_vector_key>(index_base + 6));
165  BOOST_REQUIRE_EQUAL((*it)->second, answer_base + 3);
166  ++it;
167  BOOST_REQUIRE_EQUAL((*it)->first,
168  static_cast<cet::map_vector_key>(index_base + 0));
169  BOOST_REQUIRE_EQUAL((*it)->second, answer_base + 0);
170  ++it;
171  BOOST_REQUIRE_EQUAL((*it)->first,
172  static_cast<cet::map_vector_key>(index_base + 2));
173  BOOST_REQUIRE_EQUAL((*it)->second, answer_base + 1);
174  ++it;
175  BOOST_REQUIRE_EQUAL((*it)->first,
176  static_cast<cet::map_vector_key>(index_base + 8));
177  BOOST_REQUIRE_EQUAL((*it)->second, answer_base + 4);
178  ++it;
179  BOOST_REQUIRE_EQUAL((*it)->first,
180  static_cast<cet::map_vector_key>(index_base + 4));
181  BOOST_REQUIRE_EQUAL((*it)->second, answer_base + 2);
182  }
183  }
184 
185  // Bookkeeping.
187  BOOST_REQUIRE(e.getByLabel(mixFilterLabel_, bsH));
188  BOOST_REQUIRE_EQUAL((*bsH), "BlahBlahBlah");
189 
191  BOOST_REQUIRE((e.getByLabel(mixFilterLabel_, eidsH)));
192  for (size_t i = 0; i < nSecondaries_; ++i) {
193  BOOST_REQUIRE_EQUAL((*eidsH)[i].event() + ((*eidsH)[i].subRun() * 100) +
194  (((*eidsH)[i].run() - 1) * 500),
195  (eventCounter_ - 1) * nSecondaries_ + i + 1);
196  }
197 }
const double e
BOOST_REQUIRE(inFile)
unsigned int run

Member Data Documentation

size_t arttest::MixAnalyzer::eventCounter_ {}
private

Definition at line 41 of file MixAnalyzer_module.cc.

std::string arttest::MixAnalyzer::mixFilterLabel_
private

Definition at line 43 of file MixAnalyzer_module.cc.

size_t arttest::MixAnalyzer::nSecondaries_
private

Definition at line 42 of file MixAnalyzer_module.cc.


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