50 #include "CLHEP/Random/RandFlat.h" 51 #include "CLHEP/Random/RandPoissonQ.h" 58 #include "cetlib_except/exception.h" 79 double single_exp(
double t,
double tau2)
81 return exp((-1.0 * t) / tau2) / tau2;
84 double bi_exp(
double t,
double tau1,
double tau2)
86 return (((exp((-1.0 * t) / tau2) * (1.0 - exp((-1.0 * t) / tau1))) / tau2) / tau2) * (tau1 + tau2);
94 double GetScintTime(
double tau1,
double tau2, CLHEP::RandFlat& randflatscinttime)
98 if ((tau1 == 0.0) || (tau1 == -1.0)) {
99 return -tau2 * log(randflatscinttime());
102 auto ran1 = randflatscinttime();
103 auto ran2 = randflatscinttime();
104 auto d = (tau1 + tau2) / tau2;
105 auto t = -tau2 * log(1 - ran1);
106 auto g =
d * single_exp(t, tau2);
107 if (ran2 <= bi_exp(t, tau1, tau2) / g) {
170 PhotonLibraryPropagation::~PhotonLibraryPropagation()
175 : fRiseTimeFast{p.
get<
double>(
"RiseTimeFast", 0.0)}
178 ,
fEDepTags{p.get<vector<art::InputTag>>(
"EDepModuleLabels")}
184 produces<vector<sim::SimPhotonsLite>>();
187 produces<vector<sim::SimPhotons>>();
195 auto const* larp = lar::providerFrom<detinfo::LArPropertiesService>();
197 auto& engine_photon = rng->getEngine(
"photon");
198 CLHEP::RandPoissonQ randpoisphot{engine_photon};
199 auto& engine_scinttime = rng->getEngine(
"scinttime");
200 CLHEP::RandFlat randflatscinttime{engine_scinttime};
201 auto const nOpChannels =
static_cast<int>(pvs->NOpChannels());
202 fISAlg.
Initialize(larp, lar::providerFrom<detinfo::DetectorPropertiesService>(), &*lgp, lar::providerFrom<spacecharge::SpaceChargeService>());
203 unique_ptr<vector<sim::SimPhotons>> photCol{
new vector<sim::SimPhotons>{}};
204 auto& photonCollection{*photCol};
205 photonCollection.resize(nOpChannels);
206 unique_ptr<vector<sim::SimPhotonsLite>> photLiteCol{
new vector<sim::SimPhotonsLite>{}};
207 auto& photonLiteCollection{*photLiteCol};
208 photonLiteCollection.resize(nOpChannels);
209 for (
int i = 0; i < nOpChannels; ++i) {
210 photonLiteCollection[i].OpChannel = i;
211 photonCollection[i].fOpChannel = i;
213 vector<vector<sim::SimEnergyDeposit>
const*> edep_vecs;
215 auto const& edep_handle = e.
getValidHandle<vector<sim::SimEnergyDeposit>>(label);
216 edep_vecs.push_back(edep_handle);
218 for (
auto const& edeps : edep_vecs) {
219 for (
auto const& edep : *edeps) {
221 double const xyz[3] = {edep.
X(), edep.
Y(), edep.
Z()};
222 float const* Visibilities = pvs->GetAllVisibilities(xyz);
223 if (Visibilities ==
nullptr) {
225 <<
"There is no entry in the PhotonLibrary for this position in space. " 226 "Position x: "<< xyz[0] <<
"y: " << xyz[1] <<
"z: " << xyz[2];
233 double nphot_fast =
static_cast<int>(GetScintYield(edep, *larp) * nphot);
235 double nphot_slow = nphot - nphot_fast;
236 for (
int channel = 0; channel < nOpChannels; ++channel) {
237 auto visibleFraction = Visibilities[channel];
238 if (visibleFraction == 0.0) {
243 if (nphot_fast > 0) {
245 auto n =
static_cast<int>(randpoisphot.fire(nphot_fast * visibleFraction));
246 for (
long i = 0; i <
n; ++i) {
249 ++photonLiteCollection[channel].DetectedPhotons[time];
254 auto n = randpoisphot.fire(nphot_slow * visibleFraction);
255 for (
long i = 0; i <
n; ++i) {
258 ++photonLiteCollection[channel].DetectedPhotons[time];
267 if (nphot_fast > 0) {
269 auto n = randpoisphot.fire(nphot_fast * visibleFraction);
274 photonCollection[channel].insert(photonCollection[channel].
end(),
n, photon);
279 auto n = randpoisphot.fire(nphot_slow * visibleFraction);
284 photonCollection[channel].insert(photonCollection[channel].
end(),
n, photon);
293 e.
put(move(photLiteCol));
297 e.
put(move(photCol));
virtual double ElectronScintYieldRatio() const =0
Store parameters for running LArG4.
virtual double ScintYieldRatio() const =0
void Initialize(const detinfo::LArProperties *larp, const detinfo::DetectorProperties *detp, const sim::LArG4Parameters *lgp, const spacecharge::SpaceCharge *sce)
void CalculateIonizationAndScintillation(sim::SimEnergyDeposit const &edep)
virtual double AlphaScintYieldRatio() const =0
void produce(art::Event &) override
virtual double ScintSlowTimeConst() const =0
virtual double ScintFastTimeConst() const =0
virtual double ProtonScintYieldRatio() const =0
ProductID put(std::unique_ptr< PROD > &&product)
double NumberScintillationPhotons() const
virtual double PionScintYieldRatio() const =0
contains objects relating to OpDet hits
base_engine_t & createEngine(seed_t seed)
#define DEFINE_ART_MODULE(klass)
T get(std::string const &key) const
larg4::ISCalcSeparate fISAlg
vector< art::InputTag > fEDepTags
An art service to assist in the distribution of guaranteed unique seeds to all engines within an art ...
General LArSoft Utilities.
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
contains information for a single step in the detector simulation
virtual double MuonScintYieldRatio() const =0
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
virtual double KaonScintYieldRatio() const =0
virtual bool ScintByParticleType() const =0
cet::coded_exception< error, detail::translate > exception
bool UseLitePhotons() const