Public Member Functions | Private Member Functions | Private Attributes | List of all members
phot::PhotonLibraryPropagation Class Reference

Fast simulation of propagating the photons created from SimEnergyDeposits. More...

Inheritance diagram for phot::PhotonLibraryPropagation:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 PhotonLibraryPropagation (fhicl::ParameterSet const &)
 
 PhotonLibraryPropagation (PhotonLibraryPropagation const &)=delete
 
 PhotonLibraryPropagation (PhotonLibraryPropagation &&)=delete
 
PhotonLibraryPropagationoperator= (PhotonLibraryPropagation const &)=delete
 
PhotonLibraryPropagationoperator= (PhotonLibraryPropagation &&)=delete
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

void produce (art::Event &) override
 

Private Attributes

double fRiseTimeFast
 
double fRiseTimeSlow
 
bool fDoSlowComponent
 
vector< art::InputTagfEDepTags
 
larg4::ISCalcSeparate fISAlg
 
CLHEP::HepRandomEngine & fPhotonEngine
 
CLHEP::HepRandomEngine & fScintTimeEngine
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Fast simulation of propagating the photons created from SimEnergyDeposits.

This module does a fast simulation of propagating the photons created from SimEnergyDeposits, which is the Geant4 output after each step, to each of the optical detectors. This simulation is done using the PhotonLibrary, which stores the visibilities of each optical channel with respect to each optical voxel in the TPC volume, to avoid propagating single photons using Geant4. At the end of this module a collection of the propagated photons either as sim::SimPhotonsLite or as sim::SimPhotons is placed into the art event.

Keep in mind that at this stage the LArG4 main module is not capable of running the full optical simulation, because the necessary code has not yet been written.

In the future when the PhotonLibrary has the propagation time included, it could be possible to enhance sim::SimPhotons and sim::SimPhotonsLite to contain the propagation time. At this point the time recorded for the photon is the creation time of the photon.

The steps this module takes are:

the total amount of visible photons produced during the current Geant4 step equals the sum of counts for each time.

and if sim::SimPhotons produced:

This module should only be run for the fast optical simulation even though it can create sim::SimPhotonsLite and sim::SimPhotons as data products. If there is need to create sim::SimPhotons, there are some considerations you must be aware of. Since the amount of sim::SimPhotons produced even at low energies and in small geometries quickly exceeds the memory capacity of the job, right now it is actually impossible to produce sim::SimPhotons for any realistic geometry. A possible way around the problem is to implement a scaling of the produced sim::SimPhotons, to only produce a fraction of them.

Definition at line 143 of file PhotonLibraryPropagation_module.cc.

Constructor & Destructor Documentation

phot::PhotonLibraryPropagation::PhotonLibraryPropagation ( fhicl::ParameterSet const &  p)
explicit

Definition at line 163 of file PhotonLibraryPropagation_module.cc.

164  : art::EDProducer{p}
165  , fRiseTimeFast{p.get<double>("RiseTimeFast", 0.0)}
166  , fRiseTimeSlow{p.get<double>("RiseTimeSlow", 0.0)}
167  , fDoSlowComponent{p.get<bool>("DoSlowComponent")}
168  , fEDepTags{p.get<vector<art::InputTag>>("EDepModuleLabels")}
170  ->createEngine(*this, "HepJamesRandom", "photon", p, "SeedPhoton"))
172  ->createEngine(*this, "HepJamesRandom", "scinttime", p, "SeedScintTime"))
173  {
175  produces<vector<sim::SimPhotonsLite>>();
176  }
177  else {
178  produces<vector<sim::SimPhotons>>();
179  }
180  }
p
Definition: test.py:223
bool UseLitePhotons() const
phot::PhotonLibraryPropagation::PhotonLibraryPropagation ( PhotonLibraryPropagation const &  )
delete
phot::PhotonLibraryPropagation::PhotonLibraryPropagation ( PhotonLibraryPropagation &&  )
delete

Member Function Documentation

PhotonLibraryPropagation& phot::PhotonLibraryPropagation::operator= ( PhotonLibraryPropagation const &  )
delete
PhotonLibraryPropagation& phot::PhotonLibraryPropagation::operator= ( PhotonLibraryPropagation &&  )
delete
void phot::PhotonLibraryPropagation::produce ( art::Event e)
overrideprivatevirtual

Implements art::EDProducer.

Definition at line 183 of file PhotonLibraryPropagation_module.cc.

184  {
187  auto const* larp = lar::providerFrom<detinfo::LArPropertiesService>();
188  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(e);
189  CLHEP::RandPoissonQ randpoisphot{fPhotonEngine};
190  CLHEP::RandFlat randflatscinttime{fScintTimeEngine};
191  auto const nOpChannels = pvs->NOpChannels();
192  unique_ptr<vector<sim::SimPhotons>> photCol{new vector<sim::SimPhotons>{}};
193  auto& photonCollection{*photCol};
194  photonCollection.resize(nOpChannels);
195  unique_ptr<vector<sim::SimPhotonsLite>> photLiteCol{new vector<sim::SimPhotonsLite>{}};
196  auto& photonLiteCollection{*photLiteCol};
197  photonLiteCollection.resize(nOpChannels);
198  for (unsigned int i = 0; i < nOpChannels; ++i) {
199  photonLiteCollection[i].OpChannel = i;
200  photonCollection[i].SetChannel(i);
201  }
202  vector<vector<sim::SimEnergyDeposit> const*> edep_vecs;
203  for (auto label : fEDepTags) {
204  auto const& edep_handle = e.getValidHandle<vector<sim::SimEnergyDeposit>>(label);
205  edep_vecs.push_back(edep_handle);
206  }
207  for (auto const& edeps : edep_vecs) { //loop over modules
208  for (auto const& edep : *edeps) { //loop over energy deposits: one per step
209  //int count_onePhot =0; // unused
210  auto const& p = edep.MidPoint();
211  auto const& Visibilities = pvs->GetAllVisibilities(p);
212  if (!Visibilities) {
213  throw cet::exception("PhotonLibraryPropagation")
214  << "There is no entry in the PhotonLibrary for this position in space. "
215  "Position: "
216  << edep.MidPoint();
217  }
218  auto const isCalcData = fISAlg.CalcIonAndScint(detProp, edep);
219  //total amount of scintillation photons
220  double nphot = static_cast<int>(isCalcData.numPhotons);
221  //amount of scintillated photons created via the fast scintillation process
222  double nphot_fast = static_cast<int>(GetScintYield(edep, *larp) * nphot);
223  //amount of scintillated photons created via the slow scintillation process
224  double nphot_slow = nphot - nphot_fast;
225  for (unsigned int channel = 0; channel < nOpChannels; ++channel) {
226  auto visibleFraction = Visibilities[channel];
227  if (visibleFraction == 0.0) {
228  // Voxel is not visible at this optical channel, skip doing anything for this channel.
229  continue;
230  }
231  if (lgp->UseLitePhotons()) {
232  if (nphot_fast > 0) {
233  //throwing a random number from a poisson distribution with a mean of the amount of photons visible at this channel
234  auto n = static_cast<int>(randpoisphot.fire(nphot_fast * visibleFraction));
235  for (long i = 0; i < n; ++i) {
236  //calculates the time at which the photon was produced
237  auto time = static_cast<int>(edep.T0() + GetScintTime(fRiseTimeFast,
238  larp->ScintFastTimeConst(),
239  randflatscinttime));
240  ++photonLiteCollection[channel].DetectedPhotons[time];
241  }
242  }
243  if ((nphot_slow > 0) && fDoSlowComponent) {
244  //throwing a random number from a poisson distribution with a mean of the amount of photons visible at this channel
245  auto n = randpoisphot.fire(nphot_slow * visibleFraction);
246  for (long i = 0; i < n; ++i) {
247  //calculates the time at which the photon was produced
248  auto time = static_cast<int>(edep.T0() + GetScintTime(fRiseTimeSlow,
249  larp->ScintSlowTimeConst(),
250  randflatscinttime));
251  ++photonLiteCollection[channel].DetectedPhotons[time];
252  }
253  }
254  }
255  else {
256  sim::OnePhoton photon;
257  photon.SetInSD = false;
258  photon.InitialPosition = edep.End();
259  photon.Energy = 9.7e-6;
260  if (nphot_fast > 0) {
261  //throwing a random number from a poisson distribution with a mean of the amount of photons visible at this channel
262  auto n = randpoisphot.fire(nphot_fast * visibleFraction);
263  if (n > 0) {
264  //calculates the time at which the photon was produced
265  photon.Time =
266  edep.T0() +
267  GetScintTime(fRiseTimeFast, larp->ScintFastTimeConst(), randflatscinttime);
268  // add n copies of sim::OnePhoton photon to the photon collection for a given OpChannel
269  photonCollection[channel].insert(photonCollection[channel].end(), n, photon);
270  }
271  }
272  if ((nphot_slow > 0) && fDoSlowComponent) {
273  //throwing a random number from a poisson distribution with a mean of the amount of photons visible at this channel
274  auto n = randpoisphot.fire(nphot_slow * visibleFraction);
275  if (n > 0) {
276  //calculates the time at which the photon was produced
277  photon.Time =
278  edep.T0() +
279  GetScintTime(fRiseTimeSlow, larp->ScintSlowTimeConst(), randflatscinttime);
280  // add n copies of sim::OnePhoton photon to the photon collection for a given OpChannel
281  photonCollection[channel].insert(photonCollection[channel].end(), n, photon);
282  }
283  }
284  }
285  }
286  }
287  }
288  if (lgp->UseLitePhotons()) {
289  // put the photon collection of LitePhotons into the art event
290  e.put(move(photLiteCol));
291  }
292  else {
293  //put the photon collection of SimPhotons into the art event
294  e.put(move(photCol));
295  }
296  }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
All information of a photon entering the sensitive optical detector volume.
Definition: SimPhotons.h:64
ISCalcData CalcIonAndScint(detinfo::DetectorPropertiesData const &detProp, sim::SimEnergyDeposit const &edep) override
uint8_t channel
Definition: CRTFragment.hh:201
geo::Point_t InitialPosition
Scintillation position in world coordinates [cm].
Definition: SimPhotons.h:67
std::void_t< T > n
def move(depos, offset)
Definition: depos.py:107
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
p
Definition: test.py:223
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
bool SetInSD
Whether the photon reaches the sensitive detector.
Definition: SimPhotons.h:88
float Energy
Scintillation photon energy [GeV].
Definition: SimPhotons.h:82
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
bool UseLitePhotons() const

Member Data Documentation

bool phot::PhotonLibraryPropagation::fDoSlowComponent
private

Definition at line 147 of file PhotonLibraryPropagation_module.cc.

vector<art::InputTag> phot::PhotonLibraryPropagation::fEDepTags
private

Definition at line 148 of file PhotonLibraryPropagation_module.cc.

larg4::ISCalcSeparate phot::PhotonLibraryPropagation::fISAlg
private

Definition at line 149 of file PhotonLibraryPropagation_module.cc.

CLHEP::HepRandomEngine& phot::PhotonLibraryPropagation::fPhotonEngine
private

Definition at line 150 of file PhotonLibraryPropagation_module.cc.

double phot::PhotonLibraryPropagation::fRiseTimeFast
private

Definition at line 145 of file PhotonLibraryPropagation_module.cc.

double phot::PhotonLibraryPropagation::fRiseTimeSlow
private

Definition at line 146 of file PhotonLibraryPropagation_module.cc.

CLHEP::HepRandomEngine& phot::PhotonLibraryPropagation::fScintTimeEngine
private

Definition at line 151 of file PhotonLibraryPropagation_module.cc.


The documentation for this class was generated from the following file: