RunningSumTPFinder_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: RunningSumTPFinder
3 // Plugin Type: producer (art v2_10_03)
4 // File: RunningSumTPFinder_module.cc
5 //
6 // Generated at Tue Jun 5 06:03:24 2018 by Philip Rodrigues using cetskelgen
7 // from cetlib version v3_02_00.
8 ////////////////////////////////////////////////////////////////////////
9 
18 #include "fhiclcpp/ParameterSet.h"
20 
23 
25 
26 #include <memory>
27 
28 class RunningSumTPFinder;
29 
30 
32 public:
33  explicit RunningSumTPFinder(fhicl::ParameterSet const & p);
34  // The compiler-generated destructor is fine for non-base
35  // classes without bare pointers or other resource use.
36 
37  // Plugins should not be copied or assigned.
38  RunningSumTPFinder(RunningSumTPFinder const &) = delete;
42 
43  // Required functions.
44  void produce(art::Event & e) override;
45 
46 private:
47  // The module name of the raw digits we're reading in
49  // The actual Service that's doing the trigger primitive finding
50  std::unique_ptr<RunningSumTPFinderTool> m_finder1;
51  std::unique_ptr<RunningSumTPFinderTool> m_finder2;
52 };
53 
54 
56  : EDProducer{p}, m_inputTag(p.get<std::string>("InputTag", "daq")),
57  m_finder1{art::make_tool<RunningSumTPFinderTool>(p.get<fhicl::ParameterSet>("finder1"))},
58  m_finder2{art::make_tool<RunningSumTPFinderTool>(p.get<fhicl::ParameterSet>("finder2"))}
59 {
60  produces<std::vector<recob::Hit>>();
61  produces<art::Assns<raw::RawDigit, recob::Hit>>();
62 }
63 
65 {
66  auto const& digits_handle=e.getValidHandle<std::vector<raw::RawDigit>>(m_inputTag);
67  auto& digits_in =*digits_handle;
68 
70  std::vector<std::vector<short>> induction_samples;
71  std::vector<std::vector<short>> collection_samples;
72  std::vector<unsigned int> induction_channel_numbers;
73  std::vector<unsigned int> collection_channel_numbers;
74  std::map<raw::ChannelID_t, const raw::RawDigit*> indChanToDigit;
75  std::map<raw::ChannelID_t, const raw::RawDigit*> colChanToDigit;
76  for(auto&& digit: digits_in){
77  // Select just the collection channels for the primitive-finding algorithm
78  const geo::SigType_t sigType = geo->SignalType(digit.Channel());
79  if(sigType==geo::kInduction){
80  indChanToDigit[digit.Channel()]=&digit;
81  induction_channel_numbers.push_back(digit.Channel());
82  induction_samples.push_back(digit.ADCs());
83  }
84  if(sigType==geo::kCollection){
85  colChanToDigit[digit.Channel()]=&digit;
86  collection_channel_numbers.push_back(digit.Channel());
87  collection_samples.push_back(digit.ADCs());
88  }
89  }
90 
91  // Pass the full list of collection channels to the hit finding algorithm
92  std::vector<RunningSumTPFinderTool::Hit> hits1=m_finder1->findHits( induction_channel_numbers, induction_samples);
93  std::vector<RunningSumTPFinderTool::Hit> hits2=m_finder2->findHits(collection_channel_numbers, collection_samples);
94 
95  // Loop over the returned trigger primitives and turn them into recob::Hits
96  recob::HitCollectionCreator hcol(e, false /* doWireAssns */, true /* doRawDigitAssns */);
97  for(auto const& hit : hits1){
98  const raw::RawDigit* digit=indChanToDigit[hit.channel];
99  if(!digit){
100  std::cout << "No digit with channel " << hit.channel << " found. Did you set the channel correctly?" << std::endl;
101  }
102  std::vector<geo::WireID> wids = geo->ChannelToWire(hit.channel);
103  geo::WireID wid = wids[0];
104 
105  recob::HitCreator lar_hit(*digit, //RAW DIGIT REFERENCE.
106  wid, //WIRE ID.
107  hit.startTime, //START TICK.
108  hit.startTime+hit.timeOverThreshold, //END TICK.
109  hit.timeOverThreshold, //RMS.
110  hit.startTime, //PEAK_TIME.
111  0, //SIGMA_PEAK_TIME.
112  0, //PEAK_AMPLITUDE.
113  0, //SIGMA_PEAK_AMPLITUDE.
114  hit.charge, //HIT_INTEGRAL.
115  0, //HIT_SIGMA_INTEGRAL.
116  hit.charge, //SUMMED CHARGE.
117  0, //MULTIPLICITY.
118  0, //LOCAL_INDEX.
119  0, //WIRE ID.
120  0 //DEGREES OF FREEDOM.
121  );
122  hcol.emplace_back(std::move(lar_hit), art::Ptr<raw::RawDigit>{digits_handle, 0});
123  }
124  // Loop over the returned trigger primitives and turn them into recob::Hits
125  for(auto const& hit : hits2){
126  const raw::RawDigit* digit=colChanToDigit[hit.channel];
127  if(!digit){
128  std::cout << "No digit with channel " << hit.channel << " found. Did you set the channel correctly?" << std::endl;
129  }
130  std::vector<geo::WireID> wids = geo->ChannelToWire(hit.channel);
131  geo::WireID wid = wids[0];
132 
133  recob::HitCreator lar_hit(*digit, //RAW DIGIT REFERENCE.
134  wid, //WIRE ID.
135  hit.startTime, //START TICK.
136  hit.startTime+hit.timeOverThreshold, //END TICK.
137  hit.timeOverThreshold, //RMS.
138  hit.startTime, //PEAK_TIME.
139  0, //SIGMA_PEAK_TIME.
140  0, //PEAK_AMPLITUDE.
141  0, //SIGMA_PEAK_AMPLITUDE.
142  hit.charge, //HIT_INTEGRAL.
143  0, //HIT_SIGMA_INTEGRAL.
144  hit.charge, //SUMMED CHARGE.
145  0, //MULTIPLICITY.
146  0, //LOCAL_INDEX.
147  0, //WIRE ID.
148  0 //DEGREES OF FREEDOM.
149  );
150  hcol.emplace_back(std::move(lar_hit), art::Ptr<raw::RawDigit>{digits_handle, 0});
151  }
152  hcol.put_into(e);
153 }
154 
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
art framework interface to geometry description
std::unique_ptr< RunningSumTPFinderTool > m_finder1
Class managing the creation of a new recob::Hit object.
Definition: HitCreator.h:83
Helper functions to create a hit.
const double e
A class handling a collection of hits and its associations.
Definition: HitCreator.h:508
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
Signal from induction planes.
Definition: geo_types.h:145
enum geo::_plane_sigtype SigType_t
def move(depos, offset)
Definition: depos.py:107
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
p
Definition: test.py:223
void emplace_back(recob::Hit &&hit, art::Ptr< recob::Wire > const &wire=art::Ptr< recob::Wire >(), art::Ptr< raw::RawDigit > const &digits=art::Ptr< raw::RawDigit >())
Adds the specified hit to the data collection.
Definition: HitCreator.cxx:290
void put_into(art::Event &)
Moves the data into an event.
Definition: HitCreator.h:652
Detector simulation of raw signals on wires.
void produce(art::Event &e) override
LArSoft geometry interface.
Definition: ChannelGeo.h:16
RunningSumTPFinder & operator=(RunningSumTPFinder const &)=delete
RunningSumTPFinder(fhicl::ParameterSet const &p)
QTextStream & endl(QTextStream &s)
Signal from collection planes.
Definition: geo_types.h:146
std::unique_ptr< RunningSumTPFinderTool > m_finder2