FindManySpeedTestAnalyzer_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: FindManySpeedTestAnalyzer
3 // Module Type: analyzer
4 // File: FindManySpeedTestAnalyzer_module.cc
5 //
6 // Generated at Wed Sep 10 15:06:37 2014 by Christopher Green using artmod
7 // from cetpkgsupport v1_07_01.
8 ////////////////////////////////////////////////////////////////////////
9 
18 #include "canvas/Persistency/Common/FindManyP.h"
20 #include "cetlib/cpu_timer.h"
21 #include "fhiclcpp/ParameterSet.h"
23 
24 #include <cassert>
25 #include <iostream>
26 
27 namespace arttest {
28  class FindManySpeedTestAnalyzer;
29 }
30 
32 public:
34  // The destructor generated by the compiler is fine for classes
35  // without bare pointers or other resource use.
36 
37  // Plugins should not be copied or assigned.
41  delete;
43 
44  // Required functions.
45  void analyze(art::Event const& e) override;
46 
47 private:
49  bool const perTrackDiag_;
50 };
51 
53  fhicl::ParameterSet const& p)
54  : EDAnalyzer(p)
55  , producerLabel_(p.get<std::string>("producerLabel"))
56  , perTrackDiag_(p.get<bool>("perTrackDiag", false))
57 {}
58 
59 void
61 {
62  auto hH = e.getValidHandle<std::vector<Hit>>(producerLabel_);
63  std::cout << "Hit collection size: " << hH->size() << ".\n";
64  auto hT = e.getValidHandle<std::vector<Track>>(producerLabel_);
65  std::cout << "Track collection size: " << hT->size() << ".\n";
67  std::cout << "Assns size = " << hA->size() << ".\n";
68 
69  // Make a collection of Ptrs so we can exercise the algorithm at
70  // issue.
74  tv.fill(tPtrs);
75  assert(tPtrs.size() == hT->size());
76 
77  // Time the activity under test.
78  cet::cpu_timer timer;
79  timer.start();
80  art::FindManyP<Hit> fmp(tPtrs, e, producerLabel_);
81  timer.stop();
82  std::cout << "FindManyP size = " << fmp.size() << ".\n";
83  std::cout << "FindManyP construction time (CPU, real): (" << timer.cpuTime()
84  << ", " << timer.realTime() << ") s.\n";
85  if (perTrackDiag_) {
86  for (size_t i = 0, e = fmp.size(); i != e; ++i) {
87  std::cout << "Track # " << i << " has " << fmp.at(i).size()
88  << " associated hits.\n";
89  }
90  }
91 }
92 
size_type size() const
Definition: Assns.h:447
std::string string
Definition: nybbler.cc:12
STL namespace.
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:27
void fill(PtrVector< T > &pv) const
Definition: View.h:158
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:68
FindManySpeedTestAnalyzer & operator=(FindManySpeedTestAnalyzer const &)=delete
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:480
Definition: fwd.h:43
p
Definition: test.py:228
FindManySpeedTestAnalyzer(fhicl::ParameterSet const &p)
std::size_t getView(std::string const &moduleLabel, std::string const &productInstanceName, std::string const &processName, std::vector< ELEMENT const * > &result) const
Definition: DataViewImpl.h:525
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
void analyze(art::Event const &e) override
void start()
Definition: cpu_timer.cc:83