All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Private Attributes | List of all members
butcher::EventButcher Class Reference
Inheritance diagram for butcher::EventButcher:

Public Types

using Parameters = art::EDProducer::Table< EventButcherConfig >
 

Public Member Functions

 EventButcher (Parameters const &params)
 
virtual ~EventButcher ()
 
void produce (art::Event &evt)
 

Private Attributes

const EventButcherConfig m_cfg
 
art::InputTag m_rawtag
 
art::InputTag m_sigtag
 

Detailed Description

Definition at line 51 of file EventButcher_module.cc.

Member Typedef Documentation

using butcher::EventButcher::Parameters = art::EDProducer::Table<EventButcherConfig>

Definition at line 54 of file EventButcher_module.cc.

Constructor & Destructor Documentation

butcher::EventButcher::EventButcher ( Parameters const &  params)
explicit

Definition at line 76 of file EventButcher_module.cc.

77  : EDProducer{params}
78  , m_cfg(params())
81 // , m_rawtok{consumes< std::vector<raw::RawDigit> >(m_rawtag)}
82 // , m_sigtok{consumes< std::vector<recob::Wire> >(m_sigtag)}
83 {
84  //cerr << "Producing: outraw:"<<m_cfg.outRawTag()<<" outsig:"<<m_cfg.outSigTag()<<" outras:" << m_cfg.outAssnTag() << endl;
85  produces< std::vector<raw::RawDigit> >(m_cfg.outRawTag());
86  produces< std::vector<recob::Wire> >(m_cfg.outSigTag());
87  produces< art::Assns<raw::RawDigit,recob::Wire> >(m_cfg.outAssnTag());
88 }
fhicl::Atom< std::string > outRawTag
fhicl::Atom< std::string > outAssnTag
fhicl::Atom< std::string > inSigTag
fhicl::Atom< std::string > inRawTag
fhicl::Atom< std::string > outSigTag
const EventButcherConfig m_cfg
butcher::EventButcher::~EventButcher ( )
virtual

Definition at line 90 of file EventButcher_module.cc.

91 {
92 }

Member Function Documentation

void butcher::EventButcher::produce ( art::Event &  evt)

Definition at line 95 of file EventButcher_module.cc.

96 {
97 
98  //cerr <<"In raw=" << m_rawtag << " in sig=" << m_sigtag << "\n";
99 
100  art::Handle< std::vector<raw::RawDigit> > raw;
101  //event.getByToken(m_rawtok, raw);
102  event.getByLabel(m_rawtag, raw);
103  const size_t nraw = raw->size();
104 
105  art::Handle< std::vector<recob::Wire> > sig;
106  //event.getByToken(m_sigtok, sig);
107  event.getByLabel(m_sigtag, sig);
108  const size_t nsig = sig->size();
109 
110  // https://cdcvs.fnal.gov/redmine/projects/art/wiki/The_PtrMaker_utility
111  art::PtrMaker<raw::RawDigit> RawPtr(event, m_cfg.outRawTag());
112  art::PtrMaker<recob::Wire> SigPtr(event, m_cfg.outSigTag());
113 
114  // keep track of raw digit Ptr by its channel id, for later look
115  // up in making associations.
116  std::unordered_map<raw::ChannelID_t, art::Ptr<raw::RawDigit> > chid2rawptr;
117 
118  // raw-signal association
119  auto outrsa = std::make_unique< art::Assns<raw::RawDigit,recob::Wire> >();
120  auto outraw = std::make_unique< std::vector<raw::RawDigit> >();
121  auto outsig = std::make_unique< std::vector<recob::Wire> >();
122 
123  const int ndrop = m_cfg.ndrop();
124  const int nkeep = m_cfg.nkeep();
125  const double sigscale = m_cfg.sigscale();
126 
127  // Truncate the raw digits
128  for (size_t iraw=0; iraw != nraw; ++iraw) {
129  const auto& inrd = raw->at(iraw);
130  const auto& inadcs = inrd.ADCs();
131  const size_t inlen = inadcs.size();
132 
133  const int outlen = std::min(inlen-ndrop, nkeep < 0 ? inlen : nkeep);
134 
135  if (outlen <= 0) {
136  continue; // add a "keep_empty" option and save an empty place holder RawDigit here?
137  }
138 
139  size_t outind = outraw->size();
140  const raw::ChannelID_t chid = inrd.Channel();
141  raw::RawDigit::ADCvector_t outadc(inadcs.begin()+ndrop, inadcs.begin()+ndrop+outlen);
142  outraw->emplace_back(raw::RawDigit(chid, outlen, outadc, raw::kNone));
143  // given the truncationn, this is technically a BOGUS thing to do
144  auto& outrd = outraw->back();
145  outrd.SetPedestal(inrd.GetPedestal(), inrd.GetSigma());
146 
147  chid2rawptr[chid] = RawPtr(outind);
148  }
149 
150 
151  // Truncate the signal and make assns
152  for (size_t isig=0; isig != nsig; ++isig) {
153  const auto& inw = sig->at(isig);
154  std::vector<float> wave = inw.Signal();
155  const size_t inlen = wave.size();
156 
157  const int outlen = std::min(inlen-ndrop, nkeep < 0 ? inlen : nkeep);
158 
159  if (outlen <= 0) {
160  continue;
161  }
162 
163  const auto chid = inw.Channel();
164  const auto view = inw.View();
165 
166  // resparsify
168  auto first = wave.begin()+ndrop;
169  auto done = wave.begin()+ndrop+outlen;
170  auto beg = first;
171  while (true) {
172  beg = std::find_if(beg, done, [](float v){return v != 0.0;});
173  if (beg == done) {
174  break;
175  }
176  auto end = std::find_if(beg, done, [](float v){return v == 0.0;});
177 
178  std::vector<float> scaled(beg, end);
179  for (int ind=0; ind<end-beg; ++ind) {
180  scaled[ind] *= sigscale;
181  }
182  roi.add_range(beg-first, scaled.begin(), scaled.end());
183  beg = end;
184  }
185 
186  const size_t outind = outsig->size();
187  outsig->emplace_back(recob::Wire(roi, chid, view));
188 
189  // associate
190  auto rawit = chid2rawptr.find(chid);
191  if (rawit == chid2rawptr.end()) {
192  continue; // emit warning about no accompaning raw digit?
193  }
194  auto const& rawptr = rawit->second;
195  auto const sigptr = SigPtr(outind);
196  outrsa->addSingle(rawptr, sigptr);
197  }
198 
199  event.put(std::move(outraw), m_cfg.outRawTag());
200  event.put(std::move(outsig), m_cfg.outSigTag());
201  event.put(std::move(outrsa), m_cfg.outAssnTag());
202 
203 }
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
Definition: RawDigit.h:73
fhicl::Atom< double > sigscale
no compression
Definition: RawTypes.h:9
fhicl::Atom< std::string > outRawTag
fhicl::Atom< std::string > outAssnTag
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
fhicl::Atom< std::string > outSigTag
Class holding the regions of interest of signal from a channel.
Definition: Wire.h:118
const EventButcherConfig m_cfg
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28

Member Data Documentation

const EventButcherConfig butcher::EventButcher::m_cfg
private

Definition at line 63 of file EventButcher_module.cc.

art::InputTag butcher::EventButcher::m_rawtag
private

Definition at line 65 of file EventButcher_module.cc.

art::InputTag butcher::EventButcher::m_sigtag
private

Definition at line 65 of file EventButcher_module.cc.


The documentation for this class was generated from the following file: