16 #include "WireCellUtil/Units.h" 17 #include "WireCellUtil/String.h" 18 #include "WireCellUtil/NamedFactory.h" 19 #include "WireCellIface/SimpleDepo.h" 20 #include "WireCellIface/IRecombinationModel.h" 23 WireCell::IDepoSource, WireCell::IConfigurable)
54 WireCell::IRecombinationModel::pointer
m_model;
58 : m_model(model), m_scale(scale) {}
62 return m_scale * (*m_model)(dE);
68 WireCell::IRecombinationModel::pointer
m_model;
72 : m_model(model), m_scale(scale) {}
77 return m_scale * (*m_model)(dE, dX);
86 SimDepoSource::SimDepoSource()
113 cfg[
"assn_art_tag"] =
"";
125 std::string model_tn = WireCell::get<std::string>(cfg,
"model",
"");
127 if (!model_tn.empty()) {
131 if (model_type ==
"" or model_type ==
"electrons") {
135 auto model = WireCell::Factory::lookup_tn<WireCell::IRecombinationModel>(model_tn);
137 std::cerr <<
"wcls::SimDepoSource: unknown recombination model: \"" << model_tn <<
"\"\n";
140 if (model_type ==
"MipRecombination") {
143 if (model_type ==
"BirksRecombination" || model_type ==
"BoxRecombination") {
149 m_assnTag = cfg[
"assn_art_tag"].asString();
157 bool okay =
event.getByLabel(
m_inputTag, sedvh);
161 THROW(WireCell::RuntimeError() << WireCell::errmsg{msg});
165 const size_t ndepos = sedvh->size();
167 std::cerr <<
"SimDepoSource got " << ndepos
169 <<
"\" returns: " << (okay ?
"okay" :
"fail") <<
std::endl;
172 std::cerr <<
"SimDepoSource dropping " <<
m_depos.size()
173 <<
" unused, prior depos\n";
178 std::vector<sim::SimEnergyDeposit> assn_sedv;
181 okay =
event.getByLabel(
m_assnTag, assn_sedvh);
185 THROW(WireCell::RuntimeError() << WireCell::errmsg{msg});
188 std::cout <<
"Larwirecell::SimDepoSource got " << assn_sedvh->size()
190 assn_sedv.insert(assn_sedv.end(), assn_sedvh->begin(), assn_sedvh->end() );
193 if (ndepos != assn_sedv.size()) {
194 std::string msg =
"Larwirecell::SimDepoSource Inconsistent size of SimDepoSources";
196 THROW(WireCell::RuntimeError() << WireCell::errmsg{msg});
200 for (
size_t ind=0; ind<ndepos; ++ind) {
201 auto const& sed = sedvh->at(ind);
202 auto pt = sed.MidPoint();
205 double wq = (*m_adapter)(sed);
206 int wid = sed.TrackID();
207 int pdg = sed.PdgCode();
210 if (assn_sedv.size() == 0) {
211 WireCell::IDepo::pointer depo
212 = std::make_shared<WireCell::SimpleDepo>(wt, wpt, wq,
nullptr, 0.0, 0.0, wid,
pdg, we);
220 auto const& sed1 = assn_sedv.at(ind);
221 auto pt1 = sed1.MidPoint();
224 double wq1 = (*m_adapter)(sed1);
225 int wid1 = sed1.TrackID();
226 int pdg1 = sed1.PdgCode();
229 WireCell::IDepo::pointer assn_depo
230 = std::make_shared<WireCell::SimpleDepo>(wt1, wpt1, wq1,
nullptr, 0.0, 0.0, wid1, pdg1, we1);
232 WireCell::IDepo::pointer depo
233 = std::make_shared<WireCell::SimpleDepo>(wt, wpt, wq, assn_depo, 0.0, 0.0, wid,
pdg, we);
245 WireCell::IDepo::pointer depo
246 = std::make_shared<WireCell::SimpleDepo>(0, wpt, 0,
nullptr, 0.0, 0.0);
251 std::sort(
m_depos.begin(),
m_depos.end(), WireCell::ascending_time);
252 std::cerr <<
"SimDepoSource: ready with " <<
m_depos.size() <<
" depos spanning: [" static constexpr double cm
geo::Length_t StepLength() const
static constexpr double us
virtual WireCell::Configuration default_configuration() const
IConfigurable.
void msg(const char *fmt,...)
ElectronsAdapter(double scale=1.0)
virtual double operator()(const sim::SimEnergyDeposit &sed) const
std::deque< WireCell::IDepo::pointer > m_depos
PointAdapter(WireCell::IRecombinationModel::pointer model, double scale=1.0)
static constexpr double MeV
WireCell::IRecombinationModel::pointer m_model
WIRECELL_FACTORY(wclsSimDepoSource, wcls::SimDepoSource, wcls::IArtEventVisitor, WireCell::IDepoSource, WireCell::IConfigurable) namespace units
virtual void configure(const WireCell::Configuration &config)
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
virtual bool operator()(WireCell::IDepo::pointer &out)
IDepoSource.
virtual double operator()(const sim::SimEnergyDeposit &sed) const
virtual void visit(art::Event &event)
IArtEventVisitor.
bits::DepoAdapter * m_adapter
StepAdapter(WireCell::IRecombinationModel::pointer model, double scale=1.0)
contains information for a single step in the detector simulation
Energy deposition in the active material.
virtual double operator()(const sim::SimEnergyDeposit &sed) const
void split(std::string const &s, char c, OutIter dest)
auto const & get(AssnsNode< L, R, D > const &r)
virtual ~ElectronsAdapter()
WireCell::IRecombinationModel::pointer m_model
QTextStream & endl(QTextStream &s)
Event finding and building.