52 #include "CLHEP/Random/RandPoissonQ.h" 53 #include "CLHEP/Units/SystemOfUnits.h" 65 void AddOpDetBTR(std::vector<sim::OpDetBacktrackerRecord>& opbtr,
66 std::vector<int>& ChannelMap,
111 mf::LogInfo(
"PDFastSimPVS") <<
"Initializing PDFastSimPVS." << std::endl;
118 <<
"Propagation time simulation requested, but VUVTiming not specified." 124 <<
"Reflected light propagation time simulation requested, but VISTiming not specified." 136 mf::LogInfo(
"PDFastSimPVS") <<
"Use Lite Photon." << std::endl;
137 produces<std::vector<sim::SimPhotonsLite>>();
138 produces<std::vector<sim::OpDetBacktrackerRecord>>();
141 mf::LogInfo(
"PDFastSimPVS") <<
"Store Reflected Photons";
142 produces<std::vector<sim::SimPhotonsLite>>(
"Reflected");
143 produces<std::vector<sim::OpDetBacktrackerRecord>>(
"Reflected");
148 produces<std::vector<sim::SimPhotons>>();
150 mf::LogInfo(
"PDFastSimPVS") <<
"Store Reflected Photons";
151 produces<std::vector<sim::SimPhotons>>(
"Reflected");
154 mf::LogInfo(
"PDFastSimPVS") <<
"PDFastSimPVS Initialization finish" << std::endl;
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];
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];
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));
354 std::vector<int>& ChannelMap,
358 if (ChannelMap[iChan] < 0) {
359 ChannelMap[iChan] = opbtr.size();
360 opbtr.emplace_back(std::move(btr));
363 size_t idtest = ChannelMap[iChan];
365 for (
auto const& timePDclockSDP : timePDclockSDPsMap) {
366 for (
auto const& sdp : timePDclockSDP.second) {
367 double xyz[3] = {sdp.x, sdp.y, sdp.z};
368 opbtr.at(idtest).AddScintillationPhotons(
369 sdp.trackID, timePDclockSDP.first, sdp.numPhotons, xyz, sdp.energy);
base_engine_t & createEngine(seed_t seed)
Store parameters for running LArG4.
CLHEP::HepRandomEngine & fPhotonEngine
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
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
art::ServiceHandle< PhotonVisibilityService const > fPVS
EDProducer(fhicl::ParameterSet const &pset)
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
Simulation objects for optical detectors.
int OpDetNum() const
Returns the readout Optical Detector this object describes.
#define DEFINE_ART_MODULE(klass)
PDFastSimPVS(fhicl::ParameterSet const &)
An art service to assist in the distribution of guaranteed unique seeds to all engines within an art ...
void AddScintillationPhotons(TrackID_t trackID, timePDclock_t timePDclock, double numberPhotons, double const *xyz, double energy)
Add scintillation photons and energy to this OpticalDetector.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
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
A container for photon visibility mapping data.
bool SetInSD
Whether the photon reaches the sensitive detector.
contains information for a single step in the detector simulation
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
const bool fDoFastComponent
const bool fUseLitePhotons
float Energy
Scintillation photon energy [GeV].
std::unique_ptr< PropagationTimeModel > fPropTimeModel
void produce(art::Event &) override
timePDclockSDPs_t const & timePDclockSDPsMap() const
Returns all the deposited energy information as stored.
CLHEP::HepRandomEngine & fScintTimeEngine
Event finding and building.
const bool fStoreReflected
int MotherTrackID
ID of the GEANT4 track causing the scintillation.