All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HitCollectionCreatorTest_module.cc
Go to the documentation of this file.
1 /**
2  * @file HitCollectionCreatorTest_module.cc
3  * @brief Tests classes derived from `recob::HitAndAssociationsWriterBase`.
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date June 7, 2017
6  * @see lardata/ArtDataHelper/HitCollector.h
7  */
8 
9 // LArSoft libraries
10 #include "lardata/ArtDataHelper/HitCreator.h" // recob::HitCollectionCreator
12 #include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" // raw::InvalidChannelID
13 #include "larcoreobj/SimpleTypesAndConstants/geo_types.h" // geo::kMysteryType, ...
14 
15 // framework libraries
16 #include "art/Framework/Core/ModuleMacros.h"
17 #include "art/Framework/Core/EDProducer.h"
18 #include "art/Framework/Principal/Event.h"
19 
20 #include "fhiclcpp/types/Atom.h"
21 #include "fhiclcpp/types/Name.h"
22 #include "fhiclcpp/types/Comment.h"
23 
24 // C/C++ standard libraries
25 #include <string>
26 
27 
28 namespace recob {
29  namespace test {
30 
31  /**
32  * @brief Test module for `recob::HitCollector`.
33  *
34  * Currently exercises:
35  * @todo
36  *
37  * Throws an exception on failure.
38  *
39  * Service requirements
40  * =====================
41  *
42  * This module requires no service.
43  *
44  * Configuration parameters
45  * =========================
46  *
47  * * *instanceName* (string, default: empty): name of the data product
48  * instance to produce
49  *
50  */
51  class HitCollectionCreatorTest: public art::EDProducer {
52 
53  public:
54 
55  struct Config {
56 
57  using Name = fhicl::Name;
58  using Comment = fhicl::Comment;
59 
60  fhicl::Atom<std::string> instanceName {
61  Name("instanceName"),
62  Comment("name of the data product instance to produce"),
63  "" /* default: empty */
64  };
65 
66  }; // Config
67 
68  using Parameters = art::EDProducer::Table<Config>;
69 
70  explicit HitCollectionCreatorTest(Parameters const& config);
71 
72  virtual void produce(art::Event& event) override;
73 
74 
75 
76  private:
77 
79 
80  std::string fInstanceName; ///< Instance name to be used for products.
81 
82 
83 
84  /// Produces a collection of hits and stores it into the event.
85  void produceHits(art::Event& event, std::string instanceName);
86 
87  }; // HitCollectionCreatorTest
88 
89  DEFINE_ART_MODULE(HitCollectionCreatorTest)
90 
91  } // namespace test
92 } // namespace recob::
93 
94 
95 //------------------------------------------------------------------------------
96 //--- implementation
97 //---
98 //----------------------------------------------------------------------------
100  (Parameters const& config)
101  : art::EDProducer(config)
102  , hitCollManager(
103  producesCollector(), config().instanceName(),
104  false /* doWireAssns */, false /* doRawDigitAssns */
105  ) // produces<>() hit collections
106  {}
107 
108 
109 //----------------------------------------------------------------------------
111  produceHits(event, fInstanceName);
112 } // HitCollectionCreatorTest::produce()
113 
114 
115 //----------------------------------------------------------------------------
117  (art::Event& event, std::string instanceName)
118 {
119 
120  // this object will contain al the hits until they are moved into the event;
121  // while it's useful to test the creation of the associations, that is too
122  // onerous for this test
123  auto Hits = hitCollManager.collectionWriter(event);
124 
125  // create hits, one by one
126  for (double time: { 0.0, 200.0, 400.0 }) {
127  Hits.emplace_back(
128  recob::Hit(
129  raw::InvalidChannelID, /* channel */
130  raw::TDCtick_t(1000 + time), /* start_tick */
131  raw::TDCtick_t(1010 + time), /* end_tick */
132  time, /* peak_time */
133  1.0, /* sigma_peak_time */
134  5.0, /* rms */
135  100.0, /* peak_amplitude */
136  1.0, /* sigma_peak_amplitude */
137  500.0, /* summedADC */
138  500.0, /* hit_integral */
139  1.0, /* hit_sigma_integral */
140  1, /* multiplicity */
141  0, /* local_index */
142  1.0, /* goodness_of_fit */
143  7, /* dof */
144  geo::kUnknown, /* view */
145  geo::kMysteryType, /* signal_type */
146  geo::WireID{} /* wireID */
147  )
148  );
149  } // for hits
150 
151  Hits.put_into(event);
152 
153 } // recob::test::HitCollectionCreatorTest::produceHits()
154 
155 
156 //----------------------------------------------------------------------------
Who knows?
Definition: geo_types.h:147
Unknown view.
Definition: geo_types.h:136
Declaration of signal hit object.
virtual void produce(art::Event &event) override
int TDCtick_t
Type representing a TDC tick.
Definition: RawTypes.h:25
Helper functions to create a hit.
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
Definition: RawTypes.h:32
BEGIN_PROLOG vertical distance to the surface Name
recob::HitCollectionCreatorManager hitCollManager
Definition of data types for geometry description.
art::PtrVector< recob::Hit > Hits
std::string fInstanceName
Instance name to be used for products.
void produceHits(art::Event &event, std::string instanceName)
Produces a collection of hits and stores it into the event.
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
BEGIN_PROLOG hitmakerfive clustermakerfour pfparticlemakerthree showermakertwo END_PROLOG hitmakerfive clustermakerfour pfparticlemakerthree sequence::inline_paths sequence::inline_paths sequence::inline_paths showermakers test