Namespaces | Classes | Functions
WireCell::Gen Namespace Reference

Namespaces

 Noise
 
 Test
 

Classes

class  AddNoise
 
class  AnodeFace
 
class  AnodePlane
 
class  BinnedDiffusion
 
class  BinnedDiffusion_transform
 
class  BirksRecombination
 
class  BlipSource
 
class  BoxRecombination
 
class  DepoBagger
 
class  DepoChunker
 
class  DepoFanout
 
class  DepoFramer
 
class  DepoMerger
 
class  DepoPlaneX
 
class  DepoSetFanout
 
class  DepoSplat
 
class  DepoTransform
 
class  DepoZipper
 
class  Digitizer
 
class  Drifter
 
class  Ductor
 
class  DumpFrames
 
class  ElecResponse
 
class  EmpiricalNoiseModel
 
class  Fourdee
 
class  FrameFanin
 
class  FrameFanout
 
class  FrameSummer
 
struct  GausDesc
 
class  GaussianDiffusion
 
class  ImpactData
 Information that has been collected at one impact position. More...
 
class  ImpactResponse
 
class  ImpactTransform
 
class  ImpactZipper
 
class  MegaAnodePlane
 
class  MipRecombination
 Model for a MIP, dQ = (Rmip/Wi)*dE. More...
 
class  Misconfigure
 
class  MultiDuctor
 
class  NoiseSource
 
class  PerChannelVariation
 
class  PlaneImpactResponse
 
class  Random
 
class  RCResponse
 
class  Reframer
 
class  ResponseSys
 
class  Retagger
 
class  SilentNoise
 
class  StaticChannelStatus
 
class  TimeGatedDepos
 
class  TrackDepos
 A producer of depositions created from some number of simple, linear tracks. More...
 
class  TransportedDepo
 
class  TruthSmearer
 
class  TruthTraceID
 
class  WireBoundedDepos
 
class  WirePlane
 
class  WireSchemaFile
 

Functions

IFrame::pointer sum (std::vector< IFrame::pointer > frames, int ident)
 

Function Documentation

IFrame::pointer WireCell::Gen::sum ( std::vector< IFrame::pointer frames,
int  ident 
)

Sum a vector of frames, returning a new one with the given ident. The start time of the new one will be the minimum time of all frames. The sample period (tick) of all frames must be identical. Traces on a common channel are summed producing a single trace which covers a time domain spanning the minimum and maximum tbin of all the traces in the channel. Zeros are padded for any intervening samples outside of any individual trace.

Definition at line 15 of file FrameUtil.cxx.

16 {
17  // Extract starting times and ticks of all frames
18  const int nframes = frames.size();
19  std::vector<double> times(nframes), ticks(nframes);
20  for (int ind=0; ind<nframes; ++ind) {
21  times[ind] = frames[ind]->time();
22  ticks[ind] = frames[ind]->tick();
23  }
24  auto tick_mm = std::minmax_element(ticks.begin(), ticks.end());
25  if (*tick_mm.first != *tick_mm.second) {
26  return nullptr;
27  }
28  const double tick = ticks[0];
29  auto times_mm = std::minmax_element(times.begin(), times.end());
30  const double start_time = *times_mm.first;
31 
32  // Make an temporary index mapping channel to all the trace data,
33  // applying time offsets as we fill.
35  for (int ind=0; ind<nframes; ++ind) {
36  IFrame::pointer frame = frames[ind];
37  const double dt = frame->time() - start_time;
38  const int tbinoff = dt/tick;
39  for (auto trace : *frame->traces()) {
40  const int ch = trace->channel();
41  const int new_tbin = tbinoff + trace->tbin();
42  index[ch].push_back(make_pair(new_tbin, &(trace->charge())));
43  }
44  }
45 
46  // Process each channel to make flattened trace.
47  ITrace::vector out_traces;
48  for (auto ctc : index) {
49  auto ch = ctc.first;
50  auto tcv = ctc.second; // vector of tbin_charge_t
51  vector<int> tbins;
52  for (auto tc : tcv) { // go through once to find tbin bounds
53  const int tbin = tc.first;
54  tbins.push_back(tbin);
55  tbins.push_back(tbin+tc.second->size());
56  }
57  auto tbin_mm = std::minmax_element(tbins.begin(), tbins.end());
58  const int trace_tbin = *tbin_mm.first;
59  const int trace_nbins = *tbin_mm.second-trace_tbin;
60  vector<float> charge(trace_nbins, 0.0);
61  for (auto tc : tcv) {
62  int ind = tc.first - trace_tbin;
63  for (auto q : *tc.second) {
64  charge[ind] += q;
65  ++ind;
66  }
67  }
68  ITrace::pointer trace = make_shared<SimpleTrace>(ch, trace_tbin, charge);
69  out_traces.push_back(trace);
70  }
71 
72  return make_shared<SimpleFrame>(ident, start_time, out_traces, tick);
73 }
struct vector vector
std::map< int, std::vector< tbin_charge_t > > channel_index_t
Definition: FrameUtil.cxx:13
tick ticks
Alias for common language habits.
Definition: electronics.h:77
const double tick
Binning tbins(nticks, t0, t0+readout_time)
const GenericPointer< typename T::ValueType > & pointer
Definition: pointer.h:1124