Public Member Functions | Private Attributes | List of all members
WireCell::Gen::DepoTransform Class Reference

#include <DepoTransform.h>

Inheritance diagram for WireCell::Gen::DepoTransform:
WireCell::IDepoFramer WireCell::IConfigurable WireCell::IFunctionNode< IDepoSet, IFrame > WireCell::IComponent< IConfigurable > WireCell::IFunctionNodeBase WireCell::Interface WireCell::INode WireCell::IComponent< INode > WireCell::Interface

Public Member Functions

 DepoTransform ()
 
virtual ~DepoTransform ()
 
virtual bool operator() (const input_pointer &in, output_pointer &out)
 The calling signature: More...
 
virtual void configure (const WireCell::Configuration &cfg)
 Accept a configuration. More...
 
virtual WireCell::Configuration default_configuration () const
 Optional, override to return a hard-coded default configuration. More...
 
virtual IDepo::pointer modify_depo (WirePlaneId wpid, IDepo::pointer depo)
 
- Public Member Functions inherited from WireCell::IDepoFramer
virtual ~IDepoFramer ()
 
virtual std::string signature ()
 Set the signature for all subclasses. More...
 
- Public Member Functions inherited from WireCell::IFunctionNode< IDepoSet, IFrame >
virtual ~IFunctionNode ()
 
virtual bool operator() (const boost::any &anyin, boost::any &anyout)
 The calling signature: More...
 
virtual std::vector< std::stringinput_types ()
 
virtual std::vector< std::stringoutput_types ()
 
- Public Member Functions inherited from WireCell::IFunctionNodeBase
virtual ~IFunctionNodeBase ()
 
virtual NodeCategory category ()
 Return the behavior category type. More...
 
virtual int concurrency ()
 By default assume all subclasses are stateless. More...
 
- Public Member Functions inherited from WireCell::INode
virtual ~INode ()
 
virtual void reset ()
 
- Public Member Functions inherited from WireCell::IComponent< INode >
virtual ~IComponent ()
 
- Public Member Functions inherited from WireCell::Interface
virtual ~Interface ()
 
- Public Member Functions inherited from WireCell::IConfigurable
virtual ~IConfigurable ()
 
- Public Member Functions inherited from WireCell::IComponent< IConfigurable >
virtual ~IComponent ()
 

Private Attributes

IAnodePlane::pointer m_anode
 
IRandom::pointer m_rng
 
std::vector< IPlaneImpactResponse::pointerm_pirs
 
double m_start_time
 
double m_readout_time
 
double m_tick
 
double m_drift_speed
 
double m_nsigma
 
int m_frame_count
 
Log::logptr_t l
 

Additional Inherited Members

- Public Types inherited from WireCell::IFunctionNode< IDepoSet, IFrame >
typedef IDepoSet input_type
 
typedef IFrame output_type
 
typedef std::shared_ptr< const IDepoSetinput_pointer
 
typedef std::shared_ptr< const IFrameoutput_pointer
 
typedef IFunctionNode< IDepoSet, IFramesignature_type
 
- Public Types inherited from WireCell::IFunctionNodeBase
typedef std::shared_ptr< IFunctionNodeBasepointer
 
- Public Types inherited from WireCell::INode
enum  NodeCategory {
  unknown, sourceNode, sinkNode, functionNode,
  queuedoutNode, joinNode, splitNode, faninNode,
  fanoutNode, multioutNode, hydraNode
}
 
- Public Types inherited from WireCell::IComponent< INode >
typedef std::shared_ptr< INodepointer
 Access subclass facet by pointer. More...
 
typedef std::vector< pointervector
 Vector of shared pointers. More...
 
- Public Types inherited from WireCell::Interface
typedef std::shared_ptr< Interfacepointer
 
- Public Types inherited from WireCell::IComponent< IConfigurable >
typedef std::shared_ptr< IConfigurablepointer
 Access subclass facet by pointer. More...
 
typedef std::vector< pointervector
 Vector of shared pointers. More...
 

Detailed Description

Definition at line 19 of file DepoTransform.h.

Constructor & Destructor Documentation

Gen::DepoTransform::DepoTransform ( )

Definition at line 57 of file DepoTransform.cxx.

58  : m_start_time(0.0*units::ns)
60  , m_tick(0.5*units::us)
62  , m_nsigma(3.0)
63  , m_frame_count(0)
64  , l(Log::logger("sim"))
65 {
66 }
static const double ms
Definition: Units.h:104
static const double ns
Definition: Units.h:102
logptr_t logger(std::string name)
Definition: Logging.cxx:71
static const double mm
Definition: Units.h:55
static const double us
Definition: Units.h:105
Gen::DepoTransform::~DepoTransform ( )
virtual

Definition at line 68 of file DepoTransform.cxx.

69 {
70 }

Member Function Documentation

void Gen::DepoTransform::configure ( const WireCell::Configuration config)
virtual

Accept a configuration.

Implements WireCell::IConfigurable.

Definition at line 72 of file DepoTransform.cxx.

73 {
74  auto anode_tn = get<string>(cfg, "anode", "");
75  m_anode = Factory::find_tn<IAnodePlane>(anode_tn);
76 
77  m_nsigma = get<double>(cfg, "nsigma", m_nsigma);
78  bool fluctuate = get<bool>(cfg, "fluctuate", false);
79  m_rng = nullptr;
80  if (fluctuate) {
81  auto rng_tn = get<string>(cfg, "rng", "");
82  m_rng = Factory::find_tn<IRandom>(rng_tn);
83  }
84 
85  m_readout_time = get<double>(cfg, "readout_time", m_readout_time);
86  m_tick = get<double>(cfg, "tick", m_tick);
87  m_start_time = get<double>(cfg, "start_time", m_start_time);
88  m_drift_speed = get<double>(cfg, "drift_speed", m_drift_speed);
89  m_frame_count = get<int>(cfg, "first_frame_number", m_frame_count);
90 
91  auto jpirs = cfg["pirs"];
92  if (jpirs.isNull() or jpirs.empty()) {
93  std::string msg = "must configure with some plane impact response components";
94  l->error(msg);
95  THROW(ValueError() << errmsg{"Gen::Ductor: " + msg});
96  }
97  m_pirs.clear();
98  for (auto jpir : jpirs) {
99  auto tn = jpir.asString();
100  auto pir = Factory::find_tn<IPlaneImpactResponse>(tn);
101  m_pirs.push_back(pir);
102  }
103 
104 }
void msg(const char *fmt,...)
Definition: message.cpp:107
std::string string
Definition: nybbler.cc:12
boost::error_info< struct tag_errmsg, std::string > errmsg
Definition: Exceptions.h:54
IAnodePlane::pointer m_anode
Definition: DepoTransform.h:40
cfg
Definition: dbjson.py:29
std::vector< IPlaneImpactResponse::pointer > m_pirs
Definition: DepoTransform.h:42
#define THROW(e)
Definition: Exceptions.h:25
WireCell::Configuration Gen::DepoTransform::default_configuration ( ) const
virtual

Optional, override to return a hard-coded default configuration.

How many Gaussian sigma due to diffusion to keep before truncating.

Whether to fluctuate the final Gaussian deposition.

The open a gate. This is actually a "readin" time measured at the input ("reference") plane.

The time span for each readout. This is actually a "readin" time span measured at the input ("reference") plane.

The sample period

The nominal speed of drifting electrons

Allow for a custom starting frame number

Name of component providing the anode plane.

Name of component providing the anode pseudo random number generator.

Plane impact responses

Reimplemented from WireCell::IConfigurable.

Definition at line 105 of file DepoTransform.cxx.

106 {
108 
109 
110  /// How many Gaussian sigma due to diffusion to keep before truncating.
111  put(cfg, "nsigma", m_nsigma);
112 
113  /// Whether to fluctuate the final Gaussian deposition.
114  put(cfg, "fluctuate", false);
115 
116  /// The open a gate. This is actually a "readin" time measured at
117  /// the input ("reference") plane.
118  put(cfg, "start_time", m_start_time);
119 
120  /// The time span for each readout. This is actually a "readin"
121  /// time span measured at the input ("reference") plane.
122  put(cfg, "readout_time", m_readout_time);
123 
124  /// The sample period
125  put(cfg, "tick", m_tick);
126 
127  /// The nominal speed of drifting electrons
128  put(cfg, "drift_speed", m_drift_speed);
129 
130  /// Allow for a custom starting frame number
131  put(cfg, "first_frame_number", m_frame_count);
132 
133  /// Name of component providing the anode plane.
134  put(cfg, "anode", "");
135  /// Name of component providing the anode pseudo random number generator.
136  put(cfg, "rng", "");
137 
138  /// Plane impact responses
139  cfg["pirs"] = Json::arrayValue;
140 
141 
142  return cfg;
143 }
void put(Configuration &cfg, const std::string &dotpath, const T &val)
Put value in configuration at the dotted path.
cfg
Definition: dbjson.py:29
Json::Value Configuration
Definition: Configuration.h:50
virtual IDepo::pointer WireCell::Gen::DepoTransform::modify_depo ( WirePlaneId  wpid,
IDepo::pointer  depo 
)
inlinevirtual

dummy depo modifier used for the application of the charge scaling bases on dQdx calibration see the detailed implementation in larwirecell or uboonecode

Definition at line 34 of file DepoTransform.h.

34  {
35  return depo;
36  }
bool Gen::DepoTransform::operator() ( const input_pointer in,
output_pointer out 
)
virtual

The calling signature:

Implements WireCell::IFunctionNode< IDepoSet, IFrame >.

Definition at line 145 of file DepoTransform.cxx.

146 {
147  if (!in) {
148  out = nullptr;
149  return true;
150  }
151 
152  auto depos = in->depos();
153 
155  ITrace::vector traces;
156  for (auto face : m_anode->faces()) {
157 
158  // Select the depos which are in this face's sensitive volume
159  IDepo::vector face_depos, dropped_depos;
160  auto bb = face->sensitive();
161  if (bb.empty()) {
162  l->debug("anode {} face {} is marked insensitive, skipping",
163  m_anode->ident(), face->ident());
164  continue;
165  }
166 
167  for (auto depo : (*depos)) {
168  if (bb.inside(depo->pos())) {
169  face_depos.push_back(depo);
170  }
171  else {
172  dropped_depos.push_back(depo);
173  }
174  }
175 
176  if (face_depos.size()) {
177  auto ray = bb.bounds();
178  l->debug("anode: {}, face: {}, processing {} depos spanning "
179  "t:[{},{}]ms, bb:[{}-->{}]cm",
180  m_anode->ident(), face->ident(), face_depos.size(),
181  face_depos.front()->time()/units::ms,
182  face_depos.back()->time()/units::ms,
183  ray.first/units::cm,ray.second/units::cm);
184  }
185  if (dropped_depos.size()) {
186  auto ray = bb.bounds();
187  l->debug("anode: {}, face: {}, dropped {} depos spanning "
188  "t:[{},{}]ms, outside bb:[{}-->{}]cm",
189  m_anode->ident(), face->ident(),
190  dropped_depos.size(),
191  dropped_depos.front()->time()/units::ms,
192  dropped_depos.back()->time()/units::ms,
193  ray.first/units::cm, ray.second/units::cm);
194 
195  }
196 
197  int iplane = -1;
198  for (auto plane : face->planes()) {
199  ++iplane;
200 
201  const Pimpos* pimpos = plane->pimpos();
202 
205 
206  Gen::BinnedDiffusion_transform bindiff(*pimpos, tbins, m_nsigma, m_rng);
207  for (auto depo : face_depos) {
208  depo = modify_depo(plane->planeid(), depo);
209  bindiff.add(depo, depo->extent_long() / m_drift_speed, depo->extent_tran());
210  }
211 
212  auto& wires = plane->wires();
213 
214  auto pir = m_pirs.at(iplane);
215  Gen::ImpactTransform transform(pir, bindiff);
216 
217  const int nwires = pimpos->region_binning().nbins();
218  for (int iwire=0; iwire<nwires; ++iwire) {
219  auto wave = transform.waveform(iwire);
220 
221  auto mm = Waveform::edge(wave);
222  if (mm.first == (int)wave.size()) { // all zero
223  continue;
224  }
225 
226  int chid = wires[iwire]->channel();
227  int tbin = mm.first;
228 
229  ITrace::ChargeSequence charge(wave.begin()+mm.first, wave.begin()+mm.second);
230  auto trace = make_shared<SimpleTrace>(chid, tbin, charge);
231  traces.push_back(trace);
232  }
233  }
234  }
235 
236  auto frame = make_shared<SimpleFrame>(m_frame_count, m_start_time, traces, m_tick);
237  ++m_frame_count;
238  out = frame;
239  return true;
240 }
const int nwires
IAnodePlane::pointer m_anode
Definition: DepoTransform.h:40
std::vector< pointer > vector
Definition: IData.h:21
std::pair< int, int > edge(const realseq_t &wave)
Definition: Waveform.cxx:121
static const double ms
Definition: Units.h:104
std::vector< IPlaneImpactResponse::pointer > m_pirs
Definition: DepoTransform.h:42
tagset_t transform(const tagset_t &ts, const ruleset_t &rs, bool all_rules=true)
Definition: TagRules.cxx:43
Binning tbins(nticks, t0, t0+readout_time)
static const double cm
Definition: Units.h:59
static const double mm
Definition: Units.h:73
Pimpos pimpos(nwires, min_wire_pitch, max_wire_pitch)
virtual IDepo::pointer modify_depo(WirePlaneId wpid, IDepo::pointer depo)
Definition: DepoTransform.h:34
std::vector< float > ChargeSequence
Sequential collection of charge.
Definition: ITrace.h:21

Member Data Documentation

Log::logptr_t WireCell::Gen::DepoTransform::l
private

Definition at line 50 of file DepoTransform.h.

IAnodePlane::pointer WireCell::Gen::DepoTransform::m_anode
private

Definition at line 40 of file DepoTransform.h.

double WireCell::Gen::DepoTransform::m_drift_speed
private

Definition at line 47 of file DepoTransform.h.

int WireCell::Gen::DepoTransform::m_frame_count
private

Definition at line 49 of file DepoTransform.h.

double WireCell::Gen::DepoTransform::m_nsigma
private

Definition at line 48 of file DepoTransform.h.

std::vector<IPlaneImpactResponse::pointer> WireCell::Gen::DepoTransform::m_pirs
private

Definition at line 42 of file DepoTransform.h.

double WireCell::Gen::DepoTransform::m_readout_time
private

Definition at line 45 of file DepoTransform.h.

IRandom::pointer WireCell::Gen::DepoTransform::m_rng
private

Definition at line 41 of file DepoTransform.h.

double WireCell::Gen::DepoTransform::m_start_time
private

Definition at line 44 of file DepoTransform.h.

double WireCell::Gen::DepoTransform::m_tick
private

Definition at line 46 of file DepoTransform.h.


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