Public Types | Public Member Functions | Private Attributes | List of all members
butcher::EventButcher Class Reference
Inheritance diagram for butcher::EventButcher:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Types

using Parameters = art::EDProducer::Table< EventButcherConfig >
 
- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 

Public Member Functions

 EventButcher (Parameters const &params)
 
virtual ~EventButcher ()
 
void produce (art::Event &evt)
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Attributes

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

Additional Inherited Members

- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 51 of file EventButcher_module.cc.

Member Typedef Documentation

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.

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 }
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
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)
virtual

Implements art::EDProducer.

Definition at line 95 of file EventButcher_module.cc.

96 {
97 
98  //cerr <<"In raw=" << m_rawtag << " in sig=" << m_sigtag << "\n";
99 
101  //event.getByToken(m_rawtok, raw);
102  event.getByLabel(m_rawtag, raw);
103  const size_t nraw = raw->size();
104 
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
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 }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
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
def move(depos, offset)
Definition: depos.py:107
fhicl::Atom< std::string > outSigTag
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
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
Event finding and building.

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: