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

A producer of depositions created from some number of simple, linear tracks. More...

#include <TrackDepos.h>

Inheritance diagram for WireCell::Gen::TrackDepos:
WireCell::IDepoSource WireCell::IConfigurable WireCell::ISourceNode< IDepo > WireCell::IComponent< IConfigurable > WireCell::ISourceNodeBase WireCell::Interface WireCell::INode WireCell::IComponent< INode > WireCell::Interface

Public Types

typedef std::tuple< double, Ray, double > track_t
 
- Public Types inherited from WireCell::IDepoSource
typedef std::shared_ptr< IDepoSourcepointer
 
- Public Types inherited from WireCell::ISourceNode< IDepo >
typedef IDepo output_type
 
typedef ISourceNode< IDeposignature_type
 
typedef std::shared_ptr< signature_typepointer
 
typedef std::shared_ptr< const IDepooutput_pointer
 
- Public Types inherited from WireCell::ISourceNodeBase
typedef std::shared_ptr< ISourceNodeBasepointer
 
- 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...
 

Public Member Functions

 TrackDepos (double stepsize=1.0 *units::millimeter, double clight=1.0)
 
virtual ~TrackDepos ()
 
virtual void configure (const WireCell::Configuration &config)
 Accept a configuration. More...
 
virtual WireCell::Configuration default_configuration () const
 Optional, override to return a hard-coded default configuration. More...
 
void add_track (double time, const WireCell::Ray &ray, double dedx=-1.0)
 
virtual bool operator() (IDepo::pointer &out)
 ISourceNode. More...
 
WireCell::IDepo::vector depos ()
 
std::vector< track_ttracks () const
 
- Public Member Functions inherited from WireCell::IDepoSource
virtual ~IDepoSource ()
 
virtual std::string signature ()
 Set the signature for all subclasses. More...
 
- Public Member Functions inherited from WireCell::ISourceNode< IDepo >
virtual ~ISourceNode ()
 
virtual NodeCategory category ()
 Return the behavior category type. More...
 
virtual bool operator() (boost::any &anyout)
 
virtual std::vector< std::stringoutput_types ()
 
- Public Member Functions inherited from WireCell::ISourceNodeBase
virtual ~ISourceNodeBase ()
 
- Public Member Functions inherited from WireCell::INode
virtual ~INode ()
 
virtual int concurrency ()
 
virtual std::vector< std::stringinput_types ()
 
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

double m_stepsize
 
double m_clight
 
std::deque< WireCell::IDepo::pointerm_depos
 
std::vector< track_tm_tracks
 
int m_count
 
Log::logptr_t l
 

Detailed Description

A producer of depositions created from some number of simple, linear tracks.

Definition at line 17 of file TrackDepos.h.

Member Typedef Documentation

typedef std::tuple<double, Ray, double> WireCell::Gen::TrackDepos::track_t

Definition at line 40 of file TrackDepos.h.

Constructor & Destructor Documentation

Gen::TrackDepos::TrackDepos ( double  stepsize = 1.0*units::millimeter,
double  clight = 1.0 
)

Create tracks with depositions every stepsize and assumed to be traveling at clight.

Definition at line 18 of file TrackDepos.cxx.

19  : m_stepsize(stepsize)
20  , m_clight(clight)
21  , m_count(0)
22  , l(Log::logger("sim"))
23 {
24 }
float clight
Definition: units.py:274
logptr_t logger(std::string name)
Definition: Logging.cxx:71
Gen::TrackDepos::~TrackDepos ( )
virtual

Definition at line 26 of file TrackDepos.cxx.

27 {
28 }

Member Function Documentation

void Gen::TrackDepos::add_track ( double  time,
const WireCell::Ray ray,
double  dedx = -1.0 
)

Add track starting at given <time> and stretching across given ray. The <dedx> gives a uniform charge/distance and if < 0 then it gives the (negative of) absolute amount of charge per deposition.

Definition at line 85 of file TrackDepos.cxx.

86 {
87  l->debug("add_track({} us, ({} -> {})cm, {})",
88  time/units::us, ray.first/units::cm, ray.second/units::cm, charge);
89  m_tracks.push_back(track_t(time, ray, charge));
90 
92  const double length = WireCell::ray_length(ray);
93  double step = 0;
94  int count = 0;
95 
96  double charge_per_depo = units::eplus; // charge of one positron
97  if (charge > 0) {
98  charge_per_depo = -charge / (length / m_stepsize);
99  }
100  else if (charge <= 0) {
101  charge_per_depo = charge;
102  }
103 
104  while (step < length) {
105  const double now = time + step/(m_clight*units::clight);
106  const WireCell::Point here = ray.first + dir * step;
107  SimpleDepo* sdepo = new SimpleDepo(now, here, charge_per_depo);
108  m_depos.push_back(WireCell::IDepo::pointer(sdepo));
109  step += m_stepsize;
110  ++count;
111  }
112 
113  // earliest first
114  std::sort(m_depos.begin(), m_depos.end(), ascending_time);
115  l->debug("depos: {} over {}mm", m_depos.size(), length/units::mm);
116 }
std::shared_ptr< const IDepo > pointer
Definition: IData.h:19
static const double eplus
Definition: Units.h:110
static const double clight
Definition: Units.h:275
string dir
double ray_length(const Ray &ray)
Definition: Point.cxx:62
std::deque< WireCell::IDepo::pointer > m_depos
Definition: TrackDepos.h:46
Vector ray_unit(const Ray &ray)
Definition: Point.cxx:71
std::vector< track_t > m_tracks
Definition: TrackDepos.h:47
static const double cm
Definition: Units.h:59
static const double mm
Definition: Units.h:55
bool ascending_time(const WireCell::IDepo::pointer &lhs, const WireCell::IDepo::pointer &rhs)
Compare two IDepo::pointer by time (ascending). x is used to break tie.
Definition: IDepo.cxx:17
static const double us
Definition: Units.h:105
std::tuple< double, Ray, double > track_t
Definition: TrackDepos.h:40
void Gen::TrackDepos::configure ( const WireCell::Configuration config)
virtual

Accept a configuration.

Implements WireCell::IConfigurable.

Definition at line 45 of file TrackDepos.cxx.

46 {
47  m_stepsize = get<double>(cfg, "step_size", m_stepsize);
48  Assert(m_stepsize > 0);
49  m_clight = get<double>(cfg, "clight", m_clight);
50  for (auto track : cfg["tracks"]) {
51  double time = get<double>(track, "time", 0.0);
52  double charge = get<double>(track, "charge", -1.0);
53  Ray ray = get<Ray>(track, "ray");
54  add_track(time, ray, charge);
55  }
56  double gt = get<double>(cfg, "group_time", -1);
57  if (m_depos.empty() or gt <= 0.0) {
58  m_depos.push_back(nullptr);
59  return;
60  }
61  std::deque<WireCell::IDepo::pointer> grouped;
62  double now = m_depos.front()->time();
63  double end = now + gt;
64  for (auto depo : m_depos) {
65  if (depo->time() < end) {
66  grouped.push_back(depo);
67  continue;
68  }
69  grouped.push_back(nullptr);
70  now = depo->time();
71  end = now + gt;
72  grouped.push_back(depo);
73  }
74  grouped.push_back(nullptr);
75  m_depos = grouped;
76 }
std::pair< Point, Point > Ray
A line segment running from a first (tail) to a second (head) point.
Definition: Point.h:21
void add_track(double time, const WireCell::Ray &ray, double dedx=-1.0)
Definition: TrackDepos.cxx:85
cfg
Definition: dbjson.py:29
#define Assert
Definition: Testing.h:7
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:72
std::deque< WireCell::IDepo::pointer > m_depos
Definition: TrackDepos.h:46
Configuration Gen::TrackDepos::default_configuration ( ) const
virtual

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

Reimplemented from WireCell::IConfigurable.

Definition at line 30 of file TrackDepos.cxx.

31 {
33  cfg["step_size"] = 1.0*units::mm;
34  cfg["clight"] = 1.0; // fraction of speed of light the track goes
35  cfg["tracks"] = Json::arrayValue;
36  cfg["group_time"] = -1; // if positive then chunk the
37  // stream of output depos into
38  // groups delineated by EOS
39  // markers and such that each
40  // group spans a time period no
41  // more than group_time.
42  return cfg;
43 }
cfg
Definition: dbjson.py:29
static const double mm
Definition: Units.h:55
Json::Value Configuration
Definition: Configuration.h:50
WireCell::IDepo::vector Gen::TrackDepos::depos ( )

Definition at line 137 of file TrackDepos.cxx.

138 {
139  return WireCell::IDepo::vector(m_depos.begin(), m_depos.end());
140 }
std::vector< pointer > vector
Definition: IData.h:21
std::deque< WireCell::IDepo::pointer > m_depos
Definition: TrackDepos.h:46
bool Gen::TrackDepos::operator() ( IDepo::pointer out)
virtual

ISourceNode.

Implements WireCell::ISourceNode< IDepo >.

Definition at line 119 of file TrackDepos.cxx.

120 {
121  if (m_depos.empty()) {
122  return false;
123  }
124  out = m_depos.front();
125  m_depos.pop_front();
126 
127  if (!out) { // chirp
128  l->debug("EOS at call {}", m_count);
129  }
130 
131  ++m_count;
132  return true;
133 }
std::deque< WireCell::IDepo::pointer > m_depos
Definition: TrackDepos.h:46
std::vector<track_t> WireCell::Gen::TrackDepos::tracks ( void  ) const
inline

Definition at line 41 of file TrackDepos.h.

41 { return m_tracks; }
std::vector< track_t > m_tracks
Definition: TrackDepos.h:47

Member Data Documentation

Log::logptr_t WireCell::Gen::TrackDepos::l
private

Definition at line 49 of file TrackDepos.h.

double WireCell::Gen::TrackDepos::m_clight
private

Definition at line 45 of file TrackDepos.h.

int WireCell::Gen::TrackDepos::m_count
private

Definition at line 48 of file TrackDepos.h.

std::deque<WireCell::IDepo::pointer> WireCell::Gen::TrackDepos::m_depos
private

Definition at line 46 of file TrackDepos.h.

double WireCell::Gen::TrackDepos::m_stepsize
private

Definition at line 44 of file TrackDepos.h.

std::vector<track_t> WireCell::Gen::TrackDepos::m_tracks
private

Definition at line 47 of file TrackDepos.h.


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