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

#include <BlipSource.h>

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

Classes

struct  PointMaker
 
struct  ScalarMaker
 

Public Member Functions

 BlipSource ()
 
virtual ~BlipSource ()
 
virtual bool operator() (IDepo::pointer &depo)
 IDepoSource. More...
 
virtual void configure (const WireCell::Configuration &cfg)
 IConfigurable. More...
 
virtual WireCell::Configuration default_configuration () const
 Optional, override to return a hard-coded default configuration. More...
 
- 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

std::string m_rng_tn
 
IRandom::pointer m_rng
 
double m_time
 
double m_stop
 
ScalarMakerm_ene
 
ScalarMakerm_tim
 
PointMakerm_pos
 
int m_blip_count
 
bool m_eos
 

Additional Inherited Members

- 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...
 

Detailed Description

Definition at line 16 of file BlipSource.h.

Constructor & Destructor Documentation

Gen::BlipSource::BlipSource ( )

Definition at line 14 of file BlipSource.cxx.

15  : m_rng_tn("Random")
16  , m_time(0.0)
17  , m_ene(nullptr)
18  , m_tim(nullptr)
19  , m_pos(nullptr)
20  , m_blip_count(0)
21  , m_eos(false)
22 {
23 }
Gen::BlipSource::~BlipSource ( )
virtual

Definition at line 25 of file BlipSource.cxx.

26 {
27  delete m_ene; m_ene = nullptr;
28  delete m_tim; m_tim = nullptr;
29  delete m_pos; m_pos = nullptr;
30 }

Member Function Documentation

void Gen::BlipSource::configure ( const WireCell::Configuration cfg)
virtual

IConfigurable.

Implements WireCell::IConfigurable.

Definition at line 128 of file BlipSource.cxx.

129 {
130  m_rng_tn = get(cfg, "rng", m_rng_tn);
131  m_rng = Factory::find_tn<IRandom>(m_rng_tn);
132 
133  auto ene = cfg["charge"];
134  if (ene["type"].asString() == "mono") {
135  m_ene = new ReturnValue(ene["value"].asDouble());
136  }
137  else if (ene["type"].asString() == "pdf") {
138  m_ene = new Pdf(m_rng, get< std::vector<double> >(ene, "pdf"), get< std::vector<double> >(ene, "edges"));
139  }
140  else {
141  std::cerr <<"BlipSource: no charge configuration\n";
142  THROW(ValueError() << errmsg{"BlipSource: no charge configuration"});
143  }
144 
145  auto tim = cfg["time"];
146  m_time = tim["start"].asDouble();
147  m_stop = tim["stop"].asDouble();
148  if (tim["type"].asString() == "decay") {
149  m_tim = new DecayTime(m_rng, tim["activity"].asDouble());
150  }
151  else {
152  std::cerr <<"BlipSource: no time configuration\n";
153  THROW(ValueError() << errmsg{"BlipSource: no time configuration"});
154  }
155 
156  auto pos = cfg["position"];
157  if (pos["type"].asString() == "box") {
158  Ray box = WireCell::convert<Ray>(pos["extent"]);
159  std::cerr << "Box: \n\t" << box.first/units::mm << "mm\n\t" << box.second/units::mm << "mm\n";
160  m_pos = new UniformBox(m_rng, box);
161  }
162  else {
163  std::cerr <<"BlipSource: no position configuration\n";
164  THROW(ValueError() << errmsg{"BlipSource: no position configuration"});
165  }
166 }
std::pair< Point, Point > Ray
A line segment running from a first (tail) to a second (head) point.
Definition: Point.h:21
boost::error_info< struct tag_errmsg, std::string > errmsg
Definition: Exceptions.h:54
cfg
Definition: dbjson.py:29
IRandom::pointer m_rng
Definition: BlipSource.h:41
#define THROW(e)
Definition: Exceptions.h:25
static const double mm
Definition: Units.h:55
WireCell::Configuration Gen::BlipSource::default_configuration ( ) const
virtual

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

Reimplemented from WireCell::IConfigurable.

Definition at line 34 of file BlipSource.cxx.

35 {
37  cfg["rng"] = "Random";
38 
39  Configuration ene;
40  ene["type"] = "mono"; // future: spectrum, uniform, Ar39
41  ene["value"] = 20000.0;
42  cfg["charge"] = ene;
43  // also, in Jsonnet can support PDFs giving probability for certain number of electrons
44  // { type="pdf",
45  // edges=[(0.1+b*0.1)*wc.MeV for b in std.range(0,10)], // energy edges
46  // pdf=[my_pdf_function(self.edges)]}
47 
48 
49  Configuration tim;
50  tim["type"] = "decay";
51  tim["start"] = 0.0;
52  tim["stop"] = 10.0*units::ms;
53  tim["activity"] = 100000*units::Bq; // Ar39 in 2 DUNE drift volumes
54  cfg["time"] = tim;
55 
57  pos["type"] = "box";
58  Configuration tail, head, extent;
59  tail["x"] = -1*units::m; tail["y"] = -1*units::m; tail["z"] = -1*units::m;
60  head["x"] = +1*units::m; head["y"] = +1*units::m; head["z"] = +1*units::m;
61  extent["tail"] = tail; extent["head"] = head;
62  pos["extent"] = extent;
63 
64  cfg["position"] = pos;
65 
66  return cfg;
67 
68 }
static const double m
Definition: Units.h:63
cfg
Definition: dbjson.py:29
static const double Bq
Definition: Units.h:235
static const double ms
Definition: Units.h:104
Json::Value Configuration
Definition: Configuration.h:50
bool Gen::BlipSource::operator() ( IDepo::pointer depo)
virtual

IDepoSource.

Implements WireCell::ISourceNode< IDepo >.

Definition at line 168 of file BlipSource.cxx.

169 {
170  if (m_eos) {
171  return false;
172  }
173 
174  m_time += (*m_tim)();
175  if (m_time > m_stop) {
176  std::cerr <<"BlipSource: reached stop time: "
177  << m_time/units::ms << " > " << m_stop/units::ms << std::endl;
178  depo = nullptr;
179  m_eos = true;
180  return true;
181  }
182  ++m_blip_count;
183  depo = std::make_shared<SimpleDepo>(m_time, (*m_pos)(), (*m_ene)(),
184  nullptr, 0, 0, m_blip_count);
185  return true;
186 }
static const double ms
Definition: Units.h:104
QTextStream & endl(QTextStream &s)

Member Data Documentation

int WireCell::Gen::BlipSource::m_blip_count
private

Definition at line 46 of file BlipSource.h.

ScalarMaker* WireCell::Gen::BlipSource::m_ene
private

Definition at line 44 of file BlipSource.h.

bool WireCell::Gen::BlipSource::m_eos
private

Definition at line 47 of file BlipSource.h.

PointMaker* WireCell::Gen::BlipSource::m_pos
private

Definition at line 45 of file BlipSource.h.

IRandom::pointer WireCell::Gen::BlipSource::m_rng
private

Definition at line 41 of file BlipSource.h.

std::string WireCell::Gen::BlipSource::m_rng_tn
private

Definition at line 40 of file BlipSource.h.

double WireCell::Gen::BlipSource::m_stop
private

Definition at line 43 of file BlipSource.h.

ScalarMaker * WireCell::Gen::BlipSource::m_tim
private

Definition at line 44 of file BlipSource.h.

double WireCell::Gen::BlipSource::m_time
private

Definition at line 43 of file BlipSource.h.


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