All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrackProxyHitMaker_module.cc
Go to the documentation of this file.
1 /**
2  * @file TrackProxyHitMaker_module.cc
3  * @brief Test producer creating a few dummy hits.
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date June 23, 2017
6  *
7  * This started as a copy of `lar::test::AssnsChainHitMaker` test module.
8  */
9 
10 // LArSoft libraries
12 #include "larcoreobj/SimpleTypesAndConstants/geo_types.h" // geo namespace
13 #include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" // raw namespace
14 
15 // framework libraries
16 #include "art/Framework/Core/EDProducer.h"
17 #include "art/Framework/Core/ModuleMacros.h"
18 #include "art/Framework/Principal/Event.h"
19 #include "messagefacility/MessageLogger/MessageLogger.h"
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 <utility> // std::move()
26 #include <memory> // std::make_unique()
27 
28 
29 namespace lar {
30  namespace test {
31 
32  // -------------------------------------------------------------------------
33  /**
34  * @brief Creates some dummy hits.
35  *
36  * The produced hits are not associated to wires or raw digits.
37  *
38  * Configuration parameters
39  * =========================
40  *
41  * * *nHits* (unsigned integer, default: 100): number of hits to produce
42  *
43  */
44  class TrackProxyHitMaker: public art::EDProducer {
45  public:
46 
47  struct Config {
48  using Name = fhicl::Name;
49  using Comment = fhicl::Comment;
50 
51  fhicl::Atom<unsigned int> nHits{
52  Name("nHits"),
53  Comment("number of dummy hits to be generated"),
54  100
55  };
56 
57  }; // struct Config
58 
59  using Parameters = art::EDProducer::Table<Config>;
60 
61  explicit TrackProxyHitMaker(Parameters const& config)
62  : EDProducer{config}, nHits(config().nHits())
63  {
64  produces<std::vector<recob::Hit>>();
65  }
66 
67  virtual void produce(art::Event& event) override;
68 
69  private:
70  unsigned int nHits; ///< Number of hits to be generated.
71 
72  }; // TrackProxyHitMaker
73 
74  // -------------------------------------------------------------------------
75 
76 
77  } // namespace test
78 } // namespace lar
79 
80 
81 // -----------------------------------------------------------------------------
82 void lar::test::TrackProxyHitMaker::produce(art::Event& event) {
83 
84  auto hits = std::make_unique<std::vector<recob::Hit>>();
85 
86  for (unsigned int i = 0; i < nHits; ++i) {
87 
88  hits->emplace_back(
89  raw::ChannelID_t(i + 1), // channel
90  raw::TDCtick_t(10*i), // start_tick
91  raw::TDCtick_t(10*i + 40), // end_tick
92  10.0 * i, // peak_time
93  1.0, // sigma_peak_time
94  0.5, // RMS
95  200.0 + i, // peak_amplitude
96  10.0, // sigma_peak_amplitude
97  400.0, // summedADC
98  400.0, // hit_integral
99  10.0, // hit_sigma_integral
100  1, // multiplicity
101  0, // local_index
102  1.0, // goodness_of_fit
103  37, // DOF
104  geo::kUnknown, // view
105  geo::kCollection, // signal_type
106  geo::WireID{ 0, 1, 2, i } // wire ID
107  );
108 
109  } // for
110 
111  mf::LogInfo("TrackProxyHitMaker") << "Produced " << hits->size() << " hits.";
112 
113  event.put(std::move(hits));
114 
115 } // lar::test::TrackProxyHitMaker::produce()
116 
117 // -----------------------------------------------------------------------------
118 DEFINE_ART_MODULE(lar::test::TrackProxyHitMaker)
119 
120 // -----------------------------------------------------------------------------
virtual void produce(art::Event &event) override
Unknown view.
Definition: geo_types.h:136
Declaration of signal hit object.
int TDCtick_t
Type representing a TDC tick.
Definition: RawTypes.h:25
unsigned int nHits
Number of hits to be generated.
BEGIN_PROLOG vertical distance to the surface Name
Definition of data types for geometry description.
art::EDProducer::Table< Config > Parameters
BEGIN_PROLOG hitmakerfive clustermakerfour pfparticlemakerthree showermakertwo END_PROLOG hitmakerfive clustermakerfour pfparticlemakerthree sequence::inline_paths sequence::inline_paths sequence::inline_paths showermakers test
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
TrackProxyHitMaker(Parameters const &config)
Signal from collection planes.
Definition: geo_types.h:146