LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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  // using Parameters = art::EDProducer::Table<BlipMakerConfig>;
14 
15  // explicit BlipMaker(Parameters const& params);
16  explicit BlipMaker(fhicl::ParameterSet const& pset);
17 
18  void produce(art::Event& evt);
19 
20  private:
21  // const BlipMakerConfig m_cfg;
22  int m_count;
23 
24  std::vector<double> m_head; // start of the ray [cm]
25  std::vector<double> m_tail; // end of the ray [cm]
26  double m_time; // depo's time [ns]
27  double m_charge; // charge per step [electron]
28  double m_step; // step length [cm]
29  };
30 }
31 
32 #include <string>
33 const std::string instance = "bogus"; // fixme: make configurable
34 
35 // bogoblip::BlipMaker::BlipMaker(Parameters const& params)
36 // : EDProducer{params}
37 // , m_cfg(params())
38 // , m_count(0)
39 // {
40 // produces< std::vector<sim::SimEnergyDeposit> >(instance);
41 // }
42 
44  : EDProducer{pset}
45  , m_count(0)
46  , m_head{pset.get<std::vector<double>>("Head", {100., 0., 0.})}
47  , m_tail{pset.get<std::vector<double>>("Tail", {50., 10., 50.})}
48  , m_time{pset.get<double>("Time", 0.0)}
49  , m_charge{pset.get<double>("ElectronPerCm", 50000)}
50  , m_step{pset.get<double>("StepSize", 0.1)}
51 {
52  produces<std::vector<sim::SimEnergyDeposit>>(instance);
53 }
54 
56 {
57  ++m_count;
58 
59  std::cout << "head: " << m_head.at(0) << " " << m_head.at(1) << " " << m_head.at(2) << std::endl;
60  std::cout << "tail: " << m_tail.at(0) << " " << m_tail.at(1) << " " << m_tail.at(2) << std::endl;
61  std::cout << "time: " << m_time << " e/cm: " << m_charge << " step: " << m_step << std::endl;
62 
63  auto out = std::make_unique<std::vector<sim::SimEnergyDeposit>>();
64 
65  int nphotons = 0;
66  const int nelepercm = m_charge; // 50000;
67  const double mevpercm = 2.0;
68 
69  double t0 = 0.;
70  double t1 = 0.;
71  int trackid = 0;
72 
73  // implicit units are cm, ns and MeV.
75  m_head.at(0), m_head.at(1), m_head.at(2)}; // {100.,0.,0.};
77  m_tail.at(0), m_tail.at(1), m_tail.at(2)}; // {150.,10.,50.};
78  const auto vdiff = end - start;
79  const auto vlen = sqrt(vdiff.Mag2());
80  const auto vdir = vdiff.unit();
81 
82  const double stepsize = m_step; // 0.1; // cm
83  const int nsteps = vlen / stepsize;
84 
85  // larsoft works in ns
86  const double ns = 1.0;
87  // const double us = 1000.0*ns;
88  // const double ms = 1000.0*us;
89 
90  // MB: WCT sim should cut the first, the second should just be on
91  // the edge of time acceptance. The last two bracket the BNB beam
92  // gate.
93  for (double jump : {m_time * ns} /*{ -1.6*ms, -1*ms, +3125*ns, (3125+1600)*ns, }*/) {
94  sim::SimEnergyDeposit::Point_t last = start;
95  for (int istep = 1; istep < nsteps; ++istep) {
96  const sim::SimEnergyDeposit::Point_t next(start + stepsize * istep * vdir);
97  //std::cerr << last << " -> " << next << "\n";
98  out->emplace_back(sim::SimEnergyDeposit(nphotons,
99  stepsize * nelepercm,
100  1.0, //scintillatin yield ratio
101  stepsize * mevpercm,
102  last,
103  next,
104  jump + t0,
105  jump + t1,
106  trackid));
107  last = next;
108  }
109  }
110 
111  std::cerr << "BlipMaker making " << out->size() << " depos to instance: " << instance
112  << std::endl;
113 
114  event.put(std::move(out), instance);
115 }
116 
117 namespace bogoblip {
119 }
code to link reconstructed objects back to the MC truth information
std::vector< double > m_head
TTree * t1
Definition: plottest35.C:26
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
const std::string instance
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:65
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:8
Event finding and building.
BlipMaker(fhicl::ParameterSet const &pset)