SplitterAnalyzer_module.cc
Go to the documentation of this file.
1 //--------------------------------------------------------------------
2 //
3 // SplitterAnalyzer to test SplitterInput source
4 //
5 //--------------------------------------------------------------------
6 
11 #include "fhiclcpp/ParameterSet.h"
13 
14 // lardata
16 
17 // C++
18 #include <cassert>
19 
20 namespace arttest {
21 
22  using rawDigits_t = std::vector<raw::RawDigit>;
23 
25  public:
26 
28  art::EDAnalyzer(ps),
29  inputTag_("SplitterInput:TPC"),
30  nExpectedEvts_(ps.get<std::size_t>("nExpectedEvents")),
31  nEvts_(),
32  nExpDigitsLastEvt_(ps.get<std::size_t>("nExpDigitsLastEvent")),
33  nExpDigitsPerEvt_(ps.get<std::size_t>("nExpDigitsPerEvent"))
34  {}
35 
36  virtual ~SplitterAnalyzer(){}
37 
38  virtual void analyze( art::Event const & e ) override {
39 
40  ++nEvts_;
41  auto rawDigitsH = e.getValidHandle<rawDigits_t>( inputTag_ );
42  mf::LogDebug("DigitsTest") << "analyzing event: " << e.id() << " : " << rawDigitsH->size() << " digits present";
43  std::vector< art::Ptr<raw::RawDigit> > Digits;
44  art::fill_ptr_vector(Digits, rawDigitsH);
45 
46  assert (Digits.size() > 0);
47  art::Ptr<raw::RawDigit> digit = Digits.at(0);
48  std::size_t ticks = digit->Samples();
49 
50 
51  if ( nEvts_ < nExpectedEvts_ ) {
52  assert( ticks == nExpDigitsPerEvt_ );
53  }
54  else {
55  assert( ticks == nExpDigitsLastEvt_ );
56  }
57 
58  }
59 
60  private:
62  std::size_t nExpectedEvts_;
63  std::size_t nEvts_;
64  std::size_t nExpDigitsLastEvt_;
65  std::size_t nExpDigitsPerEvt_;
66 
67  }; // SplitterAnalyzer
68 
69 }
70 
static const double ps
Definition: Units.h:102
STL namespace.
Definition of basic raw digits.
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:27
tick ticks
Alias for common language habits.
Definition: electronics.h:78
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:69
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:491
std::vector< raw::RawDigit > rawDigits_t
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
virtual void analyze(art::Event const &e) override
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:291
SplitterAnalyzer(fhicl::ParameterSet const &ps)
EventID id() const
Definition: Event.cc:37