All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
phot::PDFastSimPVS Class Reference
Inheritance diagram for phot::PDFastSimPVS:

Public Member Functions

 PDFastSimPVS (fhicl::ParameterSet const &)
 
void produce (art::Event &) override
 
void AddOpDetBTR (std::vector< sim::OpDetBacktrackerRecord > &opbtr, std::vector< int > &ChannelMap, const sim::OpDetBacktrackerRecord &btr) const
 

Private Attributes

art::ServiceHandle
< PhotonVisibilityService
const > 
fPVS
 
const bool fDoFastComponent
 
const bool fDoSlowComponent
 
const bool fIncludePropTime
 
const bool fUseLitePhotons
 
const bool fStoreReflected
 
const size_t fNOpChannels
 
const art::InputTag simTag
 
CLHEP::HepRandomEngine & fScintTimeEngine
 
std::unique_ptr< ScintTimefScintTime
 
CLHEP::HepRandomEngine & fPhotonEngine
 
std::unique_ptr
< CLHEP::RandPoissonQ > 
fRandPoissPhot
 
std::unique_ptr
< PropagationTimeModel
fPropTimeModel
 
fhicl::ParameterSet fVUVTimingParams
 
fhicl::ParameterSet fVISTimingParams
 

Detailed Description

Definition at line 62 of file PDFastSimPVS_module.cc.

Constructor & Destructor Documentation

phot::PDFastSimPVS::PDFastSimPVS ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 92 of file PDFastSimPVS_module.cc.

93  : art::EDProducer{pset}
94  , fPVS(art::ServiceHandle<PhotonVisibilityService const>())
95  , fDoFastComponent(pset.get<bool>("DoFastComponent", true))
96  , fDoSlowComponent(pset.get<bool>("DoSlowComponent", true))
97  , fIncludePropTime(pset.get<bool>("IncludePropTime", false))
98  , fUseLitePhotons(art::ServiceHandle<sim::LArG4Parameters const>()->UseLitePhotons())
99  , fStoreReflected(fPVS->StoreReflected())
100  , fNOpChannels(fPVS->NOpChannels())
101  , simTag{pset.get<art::InputTag>("SimulationLabel")}
102  , fScintTimeEngine(art::ServiceHandle<rndm::NuRandomService>()->createEngine(*this, "HepJamesRandom", "scinttime", pset, "SeedScintTime"))
103  , fScintTime{art::make_tool<phot::ScintTime>(pset.get<fhicl::ParameterSet>("ScintTimeTool"))}
104  , fPhotonEngine(art::ServiceHandle<rndm::NuRandomService>{}->createEngine(*this, "HepJamesRandom", "photon", pset, "SeedPhoton"))
CLHEP::HepRandomEngine & fPhotonEngine
std::unique_ptr< ScintTime > fScintTime
art::ServiceHandle< PhotonVisibilityService const > fPVS
const art::InputTag simTag
CLHEP::HepRandomEngine & fScintTimeEngine
services LArG4Parameters UseLitePhotons

Member Function Documentation

void phot::PDFastSimPVS::AddOpDetBTR ( std::vector< sim::OpDetBacktrackerRecord > &  opbtr,
std::vector< int > &  ChannelMap,
const sim::OpDetBacktrackerRecord btr 
) const

Definition at line 329 of file PDFastSimPVS_module.cc.

332  {
333  int iChan = btr.OpDetNum();
334  if (ChannelMap[iChan] < 0) {
335  ChannelMap[iChan] = opbtr.size();
336  opbtr.emplace_back(std::move(btr));
337  }
338  else {
339  size_t idtest = ChannelMap[iChan];
340  auto const& timePDclockSDPsMap = btr.timePDclockSDPsMap();
341  for(auto const& timePDclockSDP : timePDclockSDPsMap) {
342  for(auto const& sdp : timePDclockSDP.second) {
343  double xyz[3] = {sdp.x, sdp.y, sdp.z};
344  opbtr.at(idtest).AddScintillationPhotons(sdp.trackID,
345  timePDclockSDP.first,
346  sdp.numPhotons,
347  xyz,
348  sdp.energy);
349  }
350  }
351  }
352  }
int OpDetNum() const
Returns the readout Optical Detector this object describes.
timePDclockSDPs_t const & timePDclockSDPsMap() const
Returns all the deposited energy information as stored.
void phot::PDFastSimPVS::produce ( art::Event &  event)
override

Definition at line 149 of file PDFastSimPVS_module.cc.

150  {
151  std::vector<int> PDChannelToSOCMapDirect(fNOpChannels, -1); // Where each OpChan is.
152  std::vector<int> PDChannelToSOCMapReflect(fNOpChannels, -1); // Where each OpChan is.
153 
154  // SimPhotonsLite
155  auto phlit = std::make_unique<std::vector<sim::SimPhotonsLite>>();
156  auto opbtr = std::make_unique<std::vector<sim::OpDetBacktrackerRecord>>();
157  auto phlit_ref = std::make_unique<std::vector<sim::SimPhotonsLite>>();
158  auto opbtr_ref = std::make_unique<std::vector<sim::OpDetBacktrackerRecord>>();
159  auto& dir_phlitcol(*phlit);
160  auto& ref_phlitcol(*phlit_ref);
161  // SimPhotons
162  auto phot = std::make_unique<std::vector<sim::SimPhotons>>();
163  auto phot_ref = std::make_unique<std::vector<sim::SimPhotons>>();
164  auto& dir_photcol(*phot);
165  auto& ref_photcol(*phot_ref);
166  if(fUseLitePhotons){
167  dir_phlitcol.resize(fNOpChannels);
168  ref_phlitcol.resize(fNOpChannels);
169  for (unsigned int i = 0; i < fNOpChannels; i ++) {
170  dir_phlitcol[i].OpChannel = i;
171  ref_phlitcol[i].OpChannel = i;
172  }
173  }
174  else{ // SimPhotons
175  dir_photcol.resize(fNOpChannels);
176  ref_photcol.resize(fNOpChannels);
177  for (unsigned int i = 0; i < fNOpChannels; i ++) {
178  dir_photcol[i].fOpChannel = i;
179  ref_photcol[i].fOpChannel = i;
180  }
181  }
182 
183  art::Handle< std::vector<sim::SimEnergyDeposit> > edepHandle;
184  if (!event.getByLabel(simTag, edepHandle)) {
185  mf::LogWarning("PDFastSimPVS") << "PDFastSimPVS Module Cannot getByLabel: " << simTag;
186  return;
187  }
188 
189  int num_points = 0;
190  auto const& edeps = edepHandle;
191  for (auto const& edepi: *edeps) {
192  num_points ++;
193 
194  int nphot_fast = edepi.NumFPhotons();
195  int nphot_slow = edepi.NumSPhotons();
196  if(!((nphot_fast > 0 && fDoFastComponent) ||
197  (nphot_slow > 0 && fDoSlowComponent))) continue;
198 
199  auto const& prt = edepi.MidPoint();
200 
201  MappedCounts_t Visibilities = fPVS->GetAllVisibilities(prt);
202  MappedCounts_t Visibilities_Ref;
203  if(fStoreReflected) {
204  Visibilities_Ref = fPVS->GetAllVisibilities(prt, true);
205  if(!Visibilities_Ref) mf::LogWarning("PDFastSimPVS") << "Fail to get visibilities for reflected photons.";
206  }
207 
208  if(!Visibilities) {
209  //throw cet::exception("PDFastSimPVS")
210  mf::LogWarning("PDFastSimPVS")
211  << "There is no entry in the PhotonLibrary for this position in space. Position: " << edepi.MidPoint()
212  << "\n Move to next point";
213  continue;
214  }
215 
216  int trackID = edepi.TrackID();
217  int nphot = edepi.NumPhotons();
218  double edeposit = edepi.Energy()/nphot;
219  double pos[3] = {edepi.MidPointX(), edepi.MidPointY(), edepi.MidPointZ()};
220 
221  geo::Point_t const ScintPoint = {pos[0], pos[1], pos[2]};
222 
223  // loop through direct photons then reflected photons cases
224  size_t DoReflected = (fStoreReflected) ? 1 : 0;
225  for (size_t Reflected = 0; Reflected <= DoReflected; ++Reflected) {
226  for (unsigned int channel = 0; channel < fNOpChannels; ++ channel) {
227 
228  double visibleFraction = (Reflected) ? Visibilities_Ref[channel] : Visibilities[channel];
229  if (visibleFraction < 1e-9) continue; // voxel is not visible at this optical channel
230 
231  // number of detected photons
232  int ndetected_fast = (nphot_fast > 0) ? fRandPoissPhot->fire(nphot_fast * visibleFraction) : 0;
233  int ndetected_slow = (nphot_slow > 0) ? fRandPoissPhot->fire(nphot_slow * visibleFraction) : 0;
234  if(!((ndetected_fast > 0 && fDoFastComponent) ||
235  (ndetected_slow > 0 && fDoSlowComponent))) continue;
236 
237  // calculate propagation times if included, does not matter whether fast or slow photon
238  std::vector<double> transport_time;
239  if (fIncludePropTime) {
240  transport_time.resize(ndetected_fast + ndetected_slow);
241  fPropTimeModel->propagationTime(transport_time, ScintPoint, channel, Reflected);
242  }
243 
244  // SimPhotonsLite case
245  if (fUseLitePhotons) {
246  sim::OpDetBacktrackerRecord tmpbtr(channel);
247  if (ndetected_fast > 0 && fDoFastComponent) {
248  for (int i = 0; i < ndetected_fast; ++i) {
249  // calculate the time at which each photon is seen
250  fScintTime->GenScintTime(true, fScintTimeEngine);
251  int time;
252  if (fIncludePropTime) time = static_cast<int>(edepi.StartT() + fScintTime->GetScintTime() + transport_time[i]);
253  else time = static_cast<int>(edepi.StartT() + fScintTime->GetScintTime());
254  if (Reflected) ++ref_phlitcol[channel].DetectedPhotons[time];
255  else ++dir_phlitcol[channel].DetectedPhotons[time];
256  tmpbtr.AddScintillationPhotons(trackID, time, 1, pos, edeposit);
257  }
258  }
259  if ((ndetected_slow > 0) && fDoSlowComponent) {
260  for (int i = 0; i < ndetected_slow; ++i) {
261  // calculate the time at which each photon is seen
262  fScintTime->GenScintTime(false, fScintTimeEngine);
263  int time;
264  if (fIncludePropTime) time = static_cast<int>(edepi.StartT() + fScintTime->GetScintTime() + transport_time[ndetected_fast + i]);
265  else time = static_cast<int>(edepi.StartT() + fScintTime->GetScintTime());
266  if (Reflected) ++ref_phlitcol[channel].DetectedPhotons[time];
267  else ++dir_phlitcol[channel].DetectedPhotons[time];
268  tmpbtr.AddScintillationPhotons(trackID, time, 1, pos, edeposit);
269  }
270  }
271  if (Reflected) AddOpDetBTR(*opbtr_ref, PDChannelToSOCMapReflect, tmpbtr);
272  else AddOpDetBTR(*opbtr, PDChannelToSOCMapDirect, tmpbtr);
273  }
274 
275  // SimPhotons case
276  else {
278  photon.SetInSD = false;
279  photon.InitialPosition = edepi.End();
280  if (Reflected) photon.Energy = 2.9 * CLHEP::eV; // 430 nm
281  else photon.Energy = 9.7 * CLHEP::eV; // 128 nm
282  if (ndetected_fast > 0 && fDoFastComponent) {
283  for (int i = 0; i < ndetected_fast; ++i) {
284  // calculates the time at which the photon was produced
285  fScintTime->GenScintTime(true, fScintTimeEngine);
286  int time;
287  if (fIncludePropTime) time = static_cast<int>(edepi.StartT() + fScintTime->GetScintTime() + transport_time[i]);
288  else time = static_cast<int>(edepi.StartT() + fScintTime->GetScintTime());
289  photon.Time = time;
290  if(Reflected) ref_photcol[channel].insert(ref_photcol[channel].end(), 1, photon);
291  else dir_photcol[channel].insert(dir_photcol[channel].end(), 1, photon);
292  }
293  }
294  if (ndetected_slow > 0 && fDoSlowComponent) {
295  for (int i = 0; i < ndetected_slow; ++i) {
296  fScintTime->GenScintTime(false, fScintTimeEngine);
297  int time;
298  if (fIncludePropTime) time = static_cast<int>(edepi.StartT() + fScintTime->GetScintTime() + transport_time[ndetected_fast + i]);
299  else time = static_cast<int>(edepi.StartT() + fScintTime->GetScintTime());
300  photon.Time = time;
301  if(Reflected) ref_photcol[channel].insert(ref_photcol[channel].end(), 1, photon);
302  else dir_photcol[channel].insert(dir_photcol[channel].end(), 1, photon);
303  }
304  }
305  }
306  }
307  }
308  }
309 
310  if (fUseLitePhotons) {
311  event.put(move(phlit));
312  event.put(move(opbtr));
313  if (fStoreReflected) {
314  event.put(move(phlit_ref), "Reflected");
315  event.put(move(opbtr_ref), "Reflected");
316  }
317  }
318  else {
319  event.put(move(phot));
320  if (fStoreReflected) {
321  event.put(move(phot_ref), "Reflected");
322  }
323  }
324 
325  return;
326  }
process_name can override from command line with o or output photon
Definition: runPID.fcl:28
std::unique_ptr< ScintTime > fScintTime
void AddOpDetBTR(std::vector< sim::OpDetBacktrackerRecord > &opbtr, std::vector< int > &ChannelMap, const sim::OpDetBacktrackerRecord &btr) const
art::ServiceHandle< PhotonVisibilityService const > fPVS
All information of a photon entering the sensitive optical detector volume.
Definition: SimPhotons.h:64
std::unique_ptr< CLHEP::RandPoissonQ > fRandPoissPhot
phot::IPhotonMappingTransformations::MappedOpDetData_t< phot::IPhotonLibrary::Counts_t > MappedCounts_t
Type of mapped visibility counts.
Energy deposited on a readout Optical Detector by simulated tracks.
geo::Point_t InitialPosition
Scintillation position in world coordinates [cm].
Definition: SimPhotons.h:67
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
const art::InputTag simTag
bool SetInSD
Whether the photon reaches the sensitive detector.
Definition: SimPhotons.h:88
do i e
float Energy
Scintillation photon energy [GeV].
Definition: SimPhotons.h:82
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184
std::unique_ptr< PropagationTimeModel > fPropTimeModel
CLHEP::HepRandomEngine & fScintTimeEngine

Member Data Documentation

const bool phot::PDFastSimPVS::fDoFastComponent
private

Definition at line 73 of file PDFastSimPVS_module.cc.

const bool phot::PDFastSimPVS::fDoSlowComponent
private

Definition at line 74 of file PDFastSimPVS_module.cc.

const bool phot::PDFastSimPVS::fIncludePropTime
private

Definition at line 75 of file PDFastSimPVS_module.cc.

const size_t phot::PDFastSimPVS::fNOpChannels
private

Definition at line 78 of file PDFastSimPVS_module.cc.

CLHEP::HepRandomEngine& phot::PDFastSimPVS::fPhotonEngine
private

Definition at line 82 of file PDFastSimPVS_module.cc.

std::unique_ptr<PropagationTimeModel> phot::PDFastSimPVS::fPropTimeModel
private

Definition at line 85 of file PDFastSimPVS_module.cc.

art::ServiceHandle<PhotonVisibilityService const> phot::PDFastSimPVS::fPVS
private

Definition at line 72 of file PDFastSimPVS_module.cc.

std::unique_ptr<CLHEP::RandPoissonQ> phot::PDFastSimPVS::fRandPoissPhot
private

Definition at line 83 of file PDFastSimPVS_module.cc.

std::unique_ptr<ScintTime> phot::PDFastSimPVS::fScintTime
private

Definition at line 81 of file PDFastSimPVS_module.cc.

CLHEP::HepRandomEngine& phot::PDFastSimPVS::fScintTimeEngine
private

Definition at line 80 of file PDFastSimPVS_module.cc.

const bool phot::PDFastSimPVS::fStoreReflected
private

Definition at line 77 of file PDFastSimPVS_module.cc.

const bool phot::PDFastSimPVS::fUseLitePhotons
private

Definition at line 76 of file PDFastSimPVS_module.cc.

fhicl::ParameterSet phot::PDFastSimPVS::fVISTimingParams
private

Definition at line 88 of file PDFastSimPVS_module.cc.

fhicl::ParameterSet phot::PDFastSimPVS::fVUVTimingParams
private

Definition at line 87 of file PDFastSimPVS_module.cc.

const art::InputTag phot::PDFastSimPVS::simTag
private

Definition at line 79 of file PDFastSimPVS_module.cc.


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