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
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  */
52 
53  public:
54 
55  struct Config {
56 
57  using Name = fhicl::Name;
59 
61  Name("instanceName"),
62  Comment("name of the data product instance to produce"),
63  "" /* default: empty */
64  };
65 
66  }; // Config
67 
69 
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.
86 
87  }; // HitCollectionCreatorTest
88 
90 
91  } // namespace test
92 } // namespace recob::
93 
94 
95 //------------------------------------------------------------------------------
96 //--- implementation
97 //---
98 //----------------------------------------------------------------------------
101  : art::EDProducer(config)
102  , hitCollManager(
104  false /* doWireAssns */, false /* doRawDigitAssns */
105  ) // produces<>() hit collections
106  {}
107 
108 
109 //----------------------------------------------------------------------------
111  produceHits(event, fInstanceName);
112 } // HitCollectionCreatorTest::produce()
113 
114 
115 //----------------------------------------------------------------------------
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 }) {
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 //----------------------------------------------------------------------------
Reconstruction base classes.
Who knows?
Definition: geo_types.h:147
std::string string
Definition: nybbler.cc:12
Writer_t collectionWriter(art::Event &event) const
Returns a new writer already configured.
Definition: HitCreator.h:1106
Unknown view.
Definition: geo_types.h:136
ChannelGroupService::Name Name
virtual void produce(art::Event &event) override
void emplace_back(Args &&...args)
Definition: PtrVector.h:448
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
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
static Config * config
Definition: config.cpp:1054
recob::HitCollectionCreatorManager hitCollManager
Definition of data types for geometry description.
ProducesCollector & producesCollector() noexcept
art::PtrVector< recob::Hit > Hits
Declaration of signal hit object.
#define Comment
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
Event finding and building.