TriggerPrimitiveFinder_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: TriggerPrimitiveFinder
3 // Plugin Type: producer (art v2_10_03)
4 // File: TriggerPrimitiveFinder_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 
29 
30 
32 public:
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.
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<TriggerPrimitiveFinderTool> m_finder;
51 };
52 
53 
55  : EDProducer{p}, m_inputTag(p.get<std::string>("InputTag", "daq")),
56  m_finder{art::make_tool<TriggerPrimitiveFinderTool>(p.get<fhicl::ParameterSet>("finder"))}
57 {
58  produces<std::vector<recob::Hit>>();
59  produces<art::Assns<raw::RawDigit, recob::Hit>>();
60 }
61 
63 {
64  auto const& digits_handle=e.getValidHandle<std::vector<raw::RawDigit>>(m_inputTag);
65  auto& digits_in =*digits_handle;
66 
68  std::vector<std::vector<short>> collection_samples;
69  std::vector<unsigned int> channel_numbers;
70  std::map<raw::ChannelID_t, const raw::RawDigit*> chanToDigit;
71  for(auto&& digit: digits_in){
72  // Select just the collection channels for the primitive-finding algorithm
73  const geo::SigType_t sigType = geo->SignalType(digit.Channel());
74  if(sigType==geo::kCollection){
75  chanToDigit[digit.Channel()]=&digit;
76  channel_numbers.push_back(digit.Channel());
77  collection_samples.push_back(digit.ADCs());
78  }
79  }
80 
81  // Pass the full list of collection channels to the hit finding algorithm
82  std::vector<TriggerPrimitiveFinderTool::Hit> hits=m_finder->findHits(channel_numbers, collection_samples);
83 
84  // Loop over the returned trigger primitives and turn them into recob::Hits
85  recob::HitCollectionCreator hcol(e, false /* doWireAssns */, true /* doRawDigitAssns */);
86  for(auto const& hit : hits){
87  const raw::RawDigit* digit=chanToDigit[hit.channel];
88  if(!digit){
89  std::cout << "No digit with channel " << hit.channel << " found. Did you set the channel correctly?" << std::endl;
90  }
91  std::vector<geo::WireID> wids = geo->ChannelToWire(hit.channel);
92  geo::WireID wid = wids[0];
93 
94  recob::HitCreator lar_hit(*digit, //RAW DIGIT REFERENCE.
95  wid, //WIRE ID.
96  hit.startTime, //START TICK.
97  hit.startTime+hit.timeOverThreshold, //END TICK.
98  hit.timeOverThreshold, //RMS.
99  hit.startTime, //PEAK_TIME.
100  0, //SIGMA_PEAK_TIME.
101  0, //PEAK_AMPLITUDE.
102  0, //SIGMA_PEAK_AMPLITUDE.
103  hit.charge, //HIT_INTEGRAL.
104  0, //HIT_SIGMA_INTEGRAL.
105  hit.charge, //SUMMED CHARGE.
106  0, //MULTIPLICITY.
107  0, //LOCAL_INDEX.
108  0, //WIRE ID.
109  0 //DEGREES OF FREEDOM.
110  );
111  hcol.emplace_back(std::move(lar_hit), art::Ptr<raw::RawDigit>{digits_handle, 0});
112  }
113  hcol.put_into(e);
114 }
115 
std::unique_ptr< TriggerPrimitiveFinderTool > m_finder
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
void produce(art::Event &e) override
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
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
TriggerPrimitiveFinder(fhicl::ParameterSet const &p)
TriggerPrimitiveFinder & operator=(TriggerPrimitiveFinder const &)=delete
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.
LArSoft geometry interface.
Definition: ChannelGeo.h:16
QTextStream & endl(QTextStream &s)
Signal from collection planes.
Definition: geo_types.h:146