20 , m_dissonance(
nullptr)
21 , m_digitizer(
nullptr)
26 Gen::Fourdee::~Fourdee()
35 put(cfg,
"DepoSource",
"TrackDepos");
36 put(cfg,
"DepoFilter",
"");
37 put(cfg,
"Drifter",
"Drifter");
38 put(cfg,
"Ductor",
"Ductor");
39 put(cfg,
"Dissonance",
"SilentNoise");
40 put(cfg,
"Digitizer",
"Digitizer");
41 put(cfg,
"Filter",
"");
42 put(cfg,
"FrameSink",
"DumpFrames");
53 cerr <<
"Gen::Fourdee:configure:\n";
55 tn = get<string>(
cfg,
"DepoSource");
56 cerr <<
"\tDepoSource: " << tn <<
endl;
57 m_depos = Factory::find_maybe_tn<IDepoSource>(tn);
59 tn = get<string>(
cfg,
"DepoFilter");
62 cerr <<
"\tDepoFilter: none\n";
65 cerr <<
"\tDepoFilter: " << tn <<
endl;
69 tn = get<string>(
cfg,
"Drifter");
70 cerr <<
"\tDrifter: " << tn <<
endl;
71 m_drifter = Factory::find_maybe_tn<IDrifter>(tn);
73 tn = get<string>(
cfg,
"Ductor");
74 cerr <<
"\tDuctor: " << tn <<
endl;
75 m_ductor = Factory::find_maybe_tn<IDuctor>(tn);
78 tn = get<string>(
cfg,
"Dissonance",
"");
81 cerr <<
"\tDissonance: none\n";
85 cerr <<
"\tDissonance: " << tn <<
endl;
88 tn = get<string>(
cfg,
"Digitizer",
"");
91 cerr <<
"\tDigitizer: none\n";
94 m_digitizer = Factory::find_maybe_tn<IFrameFilter>(tn);
95 cerr <<
"\tDigitizer: " << tn <<
endl;
98 tn = get<string>(
cfg,
"Filter",
"");
101 cerr <<
"\tFilter: none\n";
104 m_filter = Factory::find_maybe_tn<IFrameFilter>(tn);
105 cerr <<
"\tFilter: " << tn <<
endl;
108 tn = get<string>(
cfg,
"FrameSink",
"");
111 cerr <<
"\tSink: none\n";
114 m_output = Factory::find_maybe_tn<IFrameSink>(tn);
115 cerr <<
"\tSink: " << tn <<
endl;
123 cerr <<
"Fourdee: dump: empty frame\n";
127 for (
auto tag: frame->frame_tags()) {
128 const auto& tlist = frame->tagged_traces(
tag);
129 cerr <<
"Fourdee: frame tag: " <<
tag <<
" with " << tlist.size() <<
" traces\n";
131 for (
auto tag: frame->trace_tags()) {
132 const auto& tlist = frame->tagged_traces(
tag);
133 cerr <<
"Fourdee: trace tag: " <<
tag <<
" with " << tlist.size() <<
" traces\n";
136 auto traces = frame->traces();
137 const int ntraces = traces->size();
140 cerr <<
"Fourdee: dump: no traces\n";
144 std::vector<int>
tbins, tlens;
145 for (
auto trace : *traces) {
146 const int tbin =
trace->tbin();
147 tbins.push_back(tbin);
148 tlens.push_back(tbin+
trace->charge().size());
151 int tmin = *(std::minmax_element(tbins.begin(), tbins.end()).first);
152 int tmax = *(std::minmax_element(tlens.begin(), tlens.end()).
second);
154 cerr <<
"frame: #" << frame->ident()
156 <<
"ms with " << ntraces <<
" traces, tbins in: " 157 <<
"[" << tmin <<
"," << tmax <<
"]" 161 template<
typename DEPOS>
164 if (depos.empty() or (depos.size() == 1 and !depos[0])) {
165 std::cerr <<
"Fourdee::dump: empty depos set\n";
169 std::vector<double>
t,
x,
y,
z;
173 for (
auto depo : depos) {
175 cerr <<
"Gen::Fourdee: null depo" <<
endl;
178 auto prior = depo->prior();
180 cerr <<
"Gen::Fourdee: null prior depo" <<
endl;
183 qorig += prior->charge();
185 t.push_back(depo->time());
186 x.push_back(depo->pos().x());
187 y.push_back(depo->pos().y());
188 z.push_back(depo->pos().z());
189 qtot += depo->charge();
192 auto tmm = std::minmax_element(t.begin(), t.end());
193 auto xmm = std::minmax_element(x.begin(), x.end());
194 auto ymm = std::minmax_element(y.begin(), y.end());
195 auto zmm = std::minmax_element(z.begin(), z.end());
196 const int ndepos = depos.size();
198 std::cerr <<
"Gen::FourDee: drifted " << ndepos <<
", extent:\n" 199 <<
"\tt in [ " << (*tmm.first)/
units::us <<
"," << (*tmm.second)/
units::us <<
"]us,\n" 226 if (iq.empty()) {
return false; }
232 std::cerr <<
"NoiseAdderProc eos\n";
233 boost::any out = iframe;
239 bool ok = (*noise_node)(nframe);
240 if (!ok)
return false;
242 boost::any anyout = nframe;
263 cerr <<
"Fourdee: no depos, can't do much" <<
endl;
268 std::cerr <<
"Fourdee: a Ductor is required for subsequent pipeline stages\n";
279 last_proc =
join(pipeline, last_proc, proc);
284 last_proc =
join(pipeline, last_proc, proc);
288 cerr <<
"Pipeline adding #"<<pipeline.size()<<
": " <<
type(*
m_ductor) <<
endl;
290 last_proc =
join(pipeline, last_proc, proc);
296 last_proc =
join(pipeline, last_proc, proc);
302 last_proc =
join(pipeline, last_proc, proc);
306 cerr <<
"Pipeline adding #"<<pipeline.size()<<
": " <<
type(*
m_filter) <<
endl;
308 last_proc =
join(pipeline, last_proc, proc);
312 cerr <<
"Pipeline adding #"<<pipeline.size()<<
": " <<
type(*m_output) <<
endl;
314 last_proc =
join(pipeline, last_proc, proc);
317 cerr <<
"Pipeline adding #"<<pipeline.size()<<
": sink\n";
319 last_proc =
join(pipeline, last_proc, sink);
323 pipeline.push_back(last_proc);
332 size_t pipelen = pipeline.size();
334 bool did_something =
false;
335 for (
size_t ind = pipelen-1; ind > 0; --ind) {
342 std::cerr <<
"Pipeline failed\n";
346 did_something =
true;
349 if (!did_something) {
350 bool ok = (*pipeline[0])();
352 std::cerr <<
"Source empty\n";
377 cerr <<
"Gen::Fourdee: starting\n";
383 cerr <<
"DepoSource is empty\n";
386 cerr <<
"Got null depo from source at loop iteration " << count <<
endl;
398 if (drifted.empty()) {
403 for (
auto drifted_depo : drifted) {
406 fdrifted.push_back(fdepo);
412 ndrifted += drifted.size();
413 cerr <<
"Gen::FourDee: seen " << ndrifted <<
" drifted\n";
416 for (
auto drifted_depo : drifted) {
418 if (!(*
m_ductor)(drifted_depo, frames)) {
422 if (frames.empty()) {
425 cerr <<
"Gen::FourDee: got " << frames.size() <<
" frames\n";
429 cerr <<
"voltframe: ";
433 cerr <<
"Gen::FourDee: including noise\n";
440 cerr <<
"noiseframe: ";
446 cerr <<
"Noise source is empty\n";
457 cerr <<
"digiframe: ";
461 adcframe = voltframe;
466 if (!(*
m_filter)(adcframe, filtframe)) {
470 adcframe = filtframe;
481 cerr <<
"Gen::Fourdee: frame with " << adcframe->traces()->size() <<
" traces\n";
std::vector< Proc * > Pipeline
WireCell::IDepoSource::pointer m_depos
std::shared_ptr< const IFrame > pointer
const CharType(& source)[N]
static const double eplus
virtual Pipe & input_pipe()
virtual Pipe & input_pipe()=0
void put(Configuration &cfg, const std::string &dotpath, const T &val)
Put value in configuration at the dotted path.
std::vector< pointer > vector
virtual ~NoiseAdderProc()
WireCell::IDepoFilter::pointer m_depofilter
std::deque< output_pointer > output_queue
virtual bool operator()()
Binning tbins(nticks, t0, t0+readout_time)
std::shared_ptr< const IFrame > input_pointer
virtual void execute_new()
WireCell::IDuctor::pointer m_ductor
virtual void execute()
Implement to run something.
Proc * join(Pipeline &pipeline, Proc *src, Proc *dst)
virtual void execute_old()
WireCell::IFrameSource::pointer m_dissonance
virtual Pipe & output_pipe()
std::shared_ptr< IFrameSource > pointer
virtual void configure(const WireCell::Configuration &config)
Accept a configuration.
NoiseAdderProc(IFrameSource::pointer nn)
std::shared_ptr< const IFrame > output_pointer
IFrame::pointer sum(std::vector< IFrame::pointer > frames, int ident)
IFrameSource::pointer noise_node
WireCell::IFrameSink::pointer m_output
virtual WireCell::Configuration default_configuration() const
Optional, override to return a hard-coded default configuration.
std::string type(const T &t)
Json::Value Configuration
WireCell::IDrifter::pointer m_drifter
std::queue< boost::any > Pipe
WireCell::IFrameFilter::pointer m_filter
WIRECELL_FACTORY(FourDee, WireCell::Gen::Fourdee, WireCell::IApplication, WireCell::IConfigurable) using namespace std
second_as<> second
Type of time stored in seconds, in double precision.
void dump(const IFrame::pointer frame)
std::string summary() const
Return summary up to now.
WireCell::IFrameFilter::pointer m_digitizer
QTextStream & endl(QTextStream &s)