23 #include "cetlib_except/exception.h" 26 #include "CLHEP/Random/RandFlat.h" 27 #include "CLHEP/Random/RandPoissonQ.h" 36 double single_exp(
double t,
double tau2)
38 return exp((-1.0 * t) / tau2) / tau2;
41 double bi_exp(
double t,
double tau1,
double tau2)
43 return (((exp((-1.0 * t) / tau2) * (1.0 - exp((-1.0 * t) / tau1))) / tau2) / tau2) *
51 double GetScintTime(
double tau1,
double tau2, CLHEP::RandFlat& randflatscinttime)
55 if ((tau1 == 0.0) || (tau1 == -1.0)) {
return -tau2 * log(randflatscinttime()); }
57 auto ran1 = randflatscinttime();
58 auto ran2 = randflatscinttime();
59 auto d = (tau1 + tau2) / tau2;
60 auto t = -tau2 * log(1 - ran1);
61 auto g =
d * single_exp(t, tau2);
62 if (ran2 <= bi_exp(t, tau1, tau2) / g) {
return t; }
166 ,
fEDepTags{p.get<vector<art::InputTag>>(
"EDepModuleLabels")}
181 produces<vector<sim::SimPhotonsLite>>();
184 produces<vector<sim::SimPhotons>>();
192 auto const* larp = lar::providerFrom<detinfo::LArPropertiesService>();
196 auto const nOpChannels = pvs->NOpChannels();
197 unique_ptr<vector<sim::SimPhotons>> photCol{
new vector<sim::SimPhotons>{}};
198 auto& photonCollection{*photCol};
199 photonCollection.resize(nOpChannels);
200 unique_ptr<vector<sim::SimPhotonsLite>> photLiteCol{
new vector<sim::SimPhotonsLite>{}};
201 auto& photonLiteCollection{*photLiteCol};
202 photonLiteCollection.resize(nOpChannels);
203 for (
unsigned int i = 0; i < nOpChannels; ++i) {
204 photonLiteCollection[i].OpChannel = i;
205 photonCollection[i].SetChannel(i);
207 vector<vector<sim::SimEnergyDeposit>
const*> edep_vecs;
209 auto const& edep_handle = e.
getValidHandle<vector<sim::SimEnergyDeposit>>(label);
210 edep_vecs.push_back(edep_handle);
212 for (
auto const& edeps : edep_vecs) {
213 for (
auto const& edep : *edeps) {
216 auto const& Visibilities = pvs->GetAllVisibilities(p);
219 <<
"There is no entry in the PhotonLibrary for this position in space. " 225 double nphot =
static_cast<int>(isCalcData.numPhotons);
227 double nphot_fast =
static_cast<int>(GetScintYield(edep, *larp) * nphot);
229 double nphot_slow = nphot - nphot_fast;
230 for (
unsigned int channel = 0; channel < nOpChannels; ++channel) {
231 auto visibleFraction = Visibilities[channel];
232 if (visibleFraction == 0.0) {
237 if (nphot_fast > 0) {
239 auto n =
static_cast<int>(randpoisphot.fire(nphot_fast * visibleFraction));
240 for (
long i = 0; i <
n; ++i) {
245 ++photonLiteCollection[channel].DetectedPhotons[time];
250 auto n = randpoisphot.fire(nphot_slow * visibleFraction);
251 for (
long i = 0; i <
n; ++i) {
256 ++photonLiteCollection[channel].DetectedPhotons[time];
265 if (nphot_fast > 0) {
267 auto n = randpoisphot.fire(nphot_fast * visibleFraction);
274 photonCollection[channel].insert(photonCollection[channel].
end(),
n, photon);
279 auto n = randpoisphot.fire(nphot_slow * visibleFraction);
286 photonCollection[channel].insert(photonCollection[channel].
end(),
n, photon);
295 e.
put(move(photLiteCol));
299 e.
put(move(photCol));
base_engine_t & createEngine(seed_t seed)
virtual double ElectronScintYieldRatio() const =0
Store parameters for running LArG4.
virtual double ScintYieldRatio() const =0
Utilities related to art service access.
virtual double AlphaScintYieldRatio() const =0
void produce(art::Event &) override
virtual double ScintSlowTimeConst() const =0
All information of a photon entering the sensitive optical detector volume.
virtual double ScintFastTimeConst() const =0
CLHEP::HepRandomEngine & fScintTimeEngine
ISCalcData CalcIonAndScint(detinfo::DetectorPropertiesData const &detProp, sim::SimEnergyDeposit const &edep) override
virtual double ProtonScintYieldRatio() const =0
geo::Point_t InitialPosition
Scintillation position in world coordinates [cm].
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
virtual double PionScintYieldRatio() const =0
Simulation objects for optical detectors.
#define DEFINE_ART_MODULE(klass)
Fast simulation of propagating the photons created from SimEnergyDeposits.
larg4::ISCalcSeparate fISAlg
geo::Point_t MidPoint() const
vector< art::InputTag > fEDepTags
CLHEP::HepRandomEngine & fPhotonEngine
An art service to assist in the distribution of guaranteed unique seeds to all engines within an art ...
General LArSoft Utilities.
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
bool SetInSD
Whether the photon reaches the sensitive detector.
contains information for a single step in the detector simulation
Energy deposition in the active material.
virtual double MuonScintYieldRatio() const =0
float Energy
Scintillation photon energy [GeV].
virtual double KaonScintYieldRatio() const =0
virtual bool ScintByParticleType() const =0
cet::coded_exception< error, detail::translate > exception
bool UseLitePhotons() const