160 std::vector<int> PDChannelToSOCMapDirect(
fNOpChannels, -1);
161 std::vector<int> PDChannelToSOCMapReflect(
fNOpChannels, -1);
164 auto phlit = std::make_unique<std::vector<sim::SimPhotonsLite>>();
165 auto opbtr = std::make_unique<std::vector<sim::OpDetBacktrackerRecord>>();
166 auto phlit_ref = std::make_unique<std::vector<sim::SimPhotonsLite>>();
167 auto opbtr_ref = std::make_unique<std::vector<sim::OpDetBacktrackerRecord>>();
168 auto& dir_phlitcol(*phlit);
169 auto& ref_phlitcol(*phlit_ref);
171 auto phot = std::make_unique<std::vector<sim::SimPhotons>>();
172 auto phot_ref = std::make_unique<std::vector<sim::SimPhotons>>();
173 auto& dir_photcol(*
phot);
174 auto& ref_photcol(*phot_ref);
179 dir_phlitcol[i].OpChannel = i;
180 ref_phlitcol[i].OpChannel = i;
187 dir_photcol[i].fOpChannel = i;
188 ref_photcol[i].fOpChannel = i;
199 auto const& edeps = edepHandle;
200 for (
auto const& edepi : *edeps) {
203 int nphot_fast = edepi.NumFPhotons();
204 int nphot_slow = edepi.NumSPhotons();
207 auto const& prt = edepi.MidPoint();
212 Visibilities_Ref =
fPVS->GetAllVisibilities(prt,
true);
213 if (!Visibilities_Ref)
214 mf::LogWarning(
"PDFastSimPVS") <<
"Fail to get visibilities for reflected photons.";
220 <<
"There is no entry in the PhotonLibrary for this position in space. Position: " 221 << edepi.MidPoint() <<
"\n Move to next point";
225 int trackID = edepi.TrackID();
226 int nphot = edepi.NumPhotons();
227 double edeposit = edepi.Energy() / nphot;
228 double pos[3] = {edepi.MidPointX(), edepi.MidPointY(), edepi.MidPointZ()};
230 geo::Point_t const ScintPoint = {pos[0], pos[1], pos[2]};
234 for (
size_t Reflected = 0; Reflected <= DoReflected; ++Reflected) {
235 for (
unsigned int channel = 0; channel <
fNOpChannels; ++channel) {
237 double visibleFraction = (Reflected) ? Visibilities_Ref[channel] : Visibilities[channel];
238 if (visibleFraction < 1
e-9)
continue;
242 (nphot_fast > 0) ?
fRandPoissPhot->fire(nphot_fast * visibleFraction) : 0;
244 (nphot_slow > 0) ?
fRandPoissPhot->fire(nphot_slow * visibleFraction) : 0;
250 std::vector<double> transport_time;
252 transport_time.resize(ndetected_fast + ndetected_slow);
253 fPropTimeModel->propagationTime(transport_time, ScintPoint, channel, Reflected);
260 for (
int i = 0; i < ndetected_fast; ++i) {
262 double dtime = edepi.StartT() +
fScintTime->fastScintTime();
264 int time(dtime > static_cast<double>(std::numeric_limits<int>::max()) ?
265 std::numeric_limits<int>::max() :
266 static_cast<int>(std::round(dtime)));
268 ++ref_phlitcol[channel].DetectedPhotons[time];
270 ++dir_phlitcol[channel].DetectedPhotons[time];
271 tmpbtr.AddScintillationPhotons(trackID, time, 1, pos, edeposit);
275 for (
int i = 0; i < ndetected_slow; ++i) {
277 double dtime = edepi.StartT() +
fScintTime->slowScintTime();
279 int time(dtime > static_cast<double>(std::numeric_limits<int>::max()) ?
280 std::numeric_limits<int>::max() :
281 static_cast<int>(std::round(dtime)));
283 ++ref_phlitcol[channel].DetectedPhotons[time];
285 ++dir_phlitcol[channel].DetectedPhotons[time];
286 tmpbtr.AddScintillationPhotons(trackID, time, 1, pos, edeposit);
290 AddOpDetBTR(*opbtr_ref, PDChannelToSOCMapReflect, tmpbtr);
292 AddOpDetBTR(*opbtr, PDChannelToSOCMapDirect, tmpbtr);
302 photon.
Energy = 2.9 * CLHEP::eV;
304 photon.
Energy = 9.7 * CLHEP::eV;
307 for (
int i = 0; i < ndetected_fast; ++i) {
309 double dtime = edepi.StartT() +
fScintTime->fastScintTime();
311 int time =
static_cast<int>(std::round(dtime));
314 ref_photcol[channel].insert(ref_photcol[channel].
end(), 1, photon);
316 dir_photcol[channel].insert(dir_photcol[channel].
end(), 1, photon);
320 for (
int i = 0; i < ndetected_slow; ++i) {
321 double dtime = edepi.StartT() +
fScintTime->slowScintTime();
323 int time =
static_cast<int>(std::round(dtime));
326 ref_photcol[channel].insert(ref_photcol[channel].
end(), 1, photon);
328 dir_photcol[channel].insert(dir_photcol[channel].
end(), 1, photon);
337 event.put(move(phlit));
338 event.put(move(opbtr));
340 event.put(move(phlit_ref),
"Reflected");
341 event.put(move(opbtr_ref),
"Reflected");
345 event.put(move(
phot));
const art::InputTag fSimTag
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.
std::unique_ptr< CLHEP::RandPoissonQ > fRandPoissPhot
Energy deposited on a readout Optical Detector by simulated tracks.
geo::Point_t InitialPosition
Scintillation position in world coordinates [cm].
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
const bool fIncludePropTime
const bool fDoSlowComponent
const size_t fNOpChannels
phot::IPhotonMappingTransformations::MappedOpDetData_t< phot::IPhotonLibrary::Counts_t > MappedCounts_t
Type of mapped visibility counts.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
General LArSoft Utilities.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
bool SetInSD
Whether the photon reaches the sensitive detector.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
const bool fDoFastComponent
const bool fUseLitePhotons
float Energy
Scintillation photon energy [GeV].
std::unique_ptr< PropagationTimeModel > fPropTimeModel
const bool fStoreReflected
int MotherTrackID
ID of the GEANT4 track causing the scintillation.