BlipMaker_module.cc
Go to the documentation of this file.
5 
7 
8 namespace bogoblip {
9  // struct BlipMakerConfig {
10  // };
11  class BlipMaker : public art::EDProducer {
12  public:
13 
14  // using Parameters = art::EDProducer::Table<BlipMakerConfig>;
15 
16  // explicit BlipMaker(Parameters const& params);
17  explicit BlipMaker(fhicl::ParameterSet const& pset);
18 
19  void produce(art::Event & evt);
20 
21  private:
22 
23  // const BlipMakerConfig m_cfg;
24  int m_count;
25 
26  std::vector<double> m_head; // start of the ray [cm]
27  std::vector<double> m_tail; // end of the ray [cm]
28  double m_time; // depo's time [ns]
29  double m_charge; // charge per step [electron]
30  double m_step; // step length [cm]
31  };
32 }
33 
34 #include <string>
35 const std::string instance = "bogus"; // fixme: make configurable
36 
37 // bogoblip::BlipMaker::BlipMaker(Parameters const& params)
38 // : EDProducer{params}
39 // , m_cfg(params())
40 // , m_count(0)
41 // {
42 // produces< std::vector<sim::SimEnergyDeposit> >(instance);
43 // }
44 
46  : EDProducer{pset}
47  , m_count(0)
48  , m_head {pset.get< std::vector<double> >("Head", {100.,0.,0.})}
49  , m_tail {pset.get< std::vector<double> >("Tail", {50.,10.,50.})}
50  , m_time {pset.get< double >("Time", 0.0)}
51  , m_charge {pset.get< double >("ElectronPerCm", 50000)}
52  , m_step {pset.get< double >("StepSize", 0.1)}
53 {
54  produces< std::vector<sim::SimEnergyDeposit> >(instance);
55 }
56 
57 
59 {
60  ++m_count;
61 
62  std::cout << "head: " << m_head.at(0) << " " << m_head.at(1) << " " << m_head.at(2) << std::endl;
63  std::cout << "tail: " << m_tail.at(0) << " " << m_tail.at(1) << " " << m_tail.at(2) << std::endl;
64  std::cout << "time: " << m_time << " e/cm: " << m_charge << " step: " << m_step << std::endl;
65 
66  auto out = std::make_unique< std::vector<sim::SimEnergyDeposit> >();
67 
68  int nphotons = 0;
69  const int nelepercm = m_charge; // 50000;
70  const double mevpercm = 2.0;
71 
72  double t0 = 0.;
73  double t1 = 0.;
74  int trackid = 0;
75 
76  // implicit units are cm, ns and MeV.
77  sim::SimEnergyDeposit::Point_t start = {m_head.at(0), m_head.at(1), m_head.at(2)}; // {100.,0.,0.};
78  sim::SimEnergyDeposit::Point_t end = {m_tail.at(0), m_tail.at(1), m_tail.at(2)}; // {150.,10.,50.};
79  const auto vdiff = end-start;
80  const auto vlen = sqrt(vdiff.Mag2());
81  const auto vdir = vdiff.unit();
82 
83  const double stepsize = m_step; // 0.1; // cm
84  const int nsteps = vlen/stepsize;
85 
86  // larsoft works in ns
87  const double ns = 1.0;
88  // const double us = 1000.0*ns;
89  // const double ms = 1000.0*us;
90 
91  // MB: WCT sim should cut the first, the second should just be on
92  // the edge of time acceptance. The last two bracket the BNB beam
93  // gate.
94  for (double jump : {m_time * ns} /*{ -1.6*ms, -1*ms, +3125*ns, (3125+1600)*ns, }*/) {
95  sim::SimEnergyDeposit::Point_t last = start;
96  for (int istep=1; istep<nsteps; ++istep) {
97  const sim::SimEnergyDeposit::Point_t next(start + stepsize*istep*vdir);
98  //std::cerr << last << " -> " << next << "\n";
99  out->emplace_back(sim::SimEnergyDeposit(nphotons,
100  stepsize * nelepercm,
101  1.0, //scintillatin yield ratio
102  stepsize * mevpercm,
103  last, next,
104  jump + t0,
105  jump + t1, trackid));
106  last = next;
107  }
108  }
109 
110  std::cerr << "BlipMaker making " << out->size() << " depos to instance: " << instance << std::endl;
111 
112 
113  event.put(std::move(out), instance);
114 }
115 
116 
117 namespace bogoblip {
119 }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
code to link reconstructed objects back to the MC truth information
std::vector< double > m_head
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
const std::string instance
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
def move(depos, offset)
Definition: depos.py:107
std::vector< double > m_tail
void produce(art::Event &evt)
contains information for a single step in the detector simulation
Energy deposition in the active material.
TCEvent evt
Definition: DataStructs.cxx:7
QAsciiDict< Entry > ns
QTextStream & endl(QTextStream &s)
Event finding and building.
BlipMaker(fhicl::ParameterSet const &pset)