38 #include "nurandom/RandomUtils/NuRandomService.h" 53 #include "CLHEP/Random/RandFlat.h" 54 #include "CLHEP/Random/RandPoissonQ.h" 66 void AddOpDetBTR(std::vector< sim::OpDetBacktrackerRecord > & opbtr,
67 std::map<int, int> & ChannelMap,
100 std::cout <<
"PDFastSimPVS Module Construct" <<
std::endl;
106 std::cout <<
"Use Lite Photon." <<
std::endl;
107 produces< std::vector<sim::SimPhotonsLite> >();
108 produces< std::vector<sim::OpDetBacktrackerRecord> >();
110 if(pvs->StoreReflected())
112 std::cout <<
"Store Reflected Photons" <<
std::endl;
113 produces< std::vector<sim::SimPhotonsLite> >(
"Reflected");
114 produces< std::vector<sim::OpDetBacktrackerRecord> >(
"Reflected");
119 std::cout <<
"Use Sim Photon." <<
std::endl;
120 produces< std::vector<sim::SimPhotons> >();
121 if(pvs->StoreReflected())
123 std::cout <<
"Store Reflected Photons" <<
std::endl;
124 produces< std::vector<sim::SimPhotons> >(
"Reflected");
133 <<
"Propagation time simulation requested, but VUVTiming not specified." <<
"\n";
139 <<
"Reflected light propagation time simulation requested, but VISTiming not specified." <<
"\n";
149 std::cout <<
"PDFastSimPVS Module Producer" <<
std::endl;
153 auto const nOpChannels = pvs->NOpChannels();
157 std::unique_ptr< std::vector< sim::SimPhotons > >
phot (
new std::vector<sim::SimPhotons>);
158 std::unique_ptr< std::vector< sim::SimPhotonsLite > > phlit (
new std::vector<sim::SimPhotonsLite>);
159 std::unique_ptr< std::vector< sim::OpDetBacktrackerRecord > > opbtr (
new std::vector<sim::OpDetBacktrackerRecord>);
161 std::unique_ptr< std::vector< sim::SimPhotons > > phot_ref (
new std::vector<sim::SimPhotons>);
162 std::unique_ptr< std::vector< sim::SimPhotonsLite > > phlit_ref (
new std::vector<sim::SimPhotonsLite>);
163 std::unique_ptr< std::vector< sim::OpDetBacktrackerRecord > > opbtr_ref (
new std::vector<sim::OpDetBacktrackerRecord>);
165 auto& dir_photcol(*phot);
166 auto& ref_photcol(*phot_ref);
167 auto& dir_phlitcol(*phlit);
168 auto& ref_phlitcol(*phlit_ref);
169 dir_photcol.resize(nOpChannels);
170 ref_photcol.resize(nOpChannels);
171 dir_phlitcol.resize(nOpChannels);
172 ref_phlitcol.resize(nOpChannels);
173 for (
unsigned int i = 0; i < nOpChannels; i ++) {
174 dir_photcol[i].fOpChannel = i;
175 ref_photcol[i].fOpChannel = i;
176 dir_phlitcol[i].OpChannel = i;
177 ref_phlitcol[i].OpChannel = i;
183 std::cout <<
"PDFastSimPVS Module Cannot getByLabel: " <<
simTag <<
std::endl;
188 std::cout <<
"PDFastSimPVS Module getByLabel: " <<
simTag <<
std::endl;
191 auto const& edeps = edepHandle;
195 for (
auto const& edepi: *edeps) {
201 auto const& prt = edepi.MidPoint();
202 Visibilities = pvs->GetAllVisibilities(prt);
203 if(pvs->StoreReflected()) {
204 Visibilities_Ref = pvs->GetAllVisibilities(prt,
true);
205 if(!Visibilities_Ref) std::cout <<
"Fail to get visibilities for reflected photons." <<
std::endl;
211 std::cout <<
"There is no entry in the PhotonLibrary for this position in space. Position: " << edepi.MidPoint();
212 std::cout <<
"\n Move to next point" <<
std::endl;
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 int nphot_fast = edepi.NumFPhotons();
221 int nphot_slow = edepi.NumSPhotons();
224 std::vector<double> transport_time;
226 geo::Point_t const ScintPoint = {pos[0], pos[1], pos[2]};
229 for (
size_t Reflected = 0; Reflected <= 1; ++Reflected) {
232 if (Reflected && !pvs->StoreReflected())
continue;
238 double visibleFraction;
239 if (Reflected) visibleFraction = Visibilities_Ref[
channel];
240 else visibleFraction = Visibilities[
channel];
242 if (visibleFraction == 0.0)
continue;
245 int ndetected_fast = 0;
246 int ndetected_slow = 0;
248 if (nphot_fast > 0) ndetected_fast =
static_cast<int>(randpoisphot.fire(nphot_fast * visibleFraction));
249 if (nphot_slow > 0) ndetected_slow =
static_cast<int>(randpoisphot.fire(nphot_slow * visibleFraction));
253 transport_time.resize(ndetected_fast + ndetected_slow);
263 for (
long i = 0; i < ndetected_fast; ++i) {
268 else time =
static_cast<int>(edepi.StartT() +
fScintTime->GetScintTime());
269 if (Reflected) ++ref_phlitcol[
channel].DetectedPhotons[time];
270 else ++dir_phlitcol[
channel].DetectedPhotons[time];
276 for (
long i = 0; i < ndetected_slow; ++i) {
280 if (
fIncludePropTime) time =
static_cast<int>(edepi.StartT() +
fScintTime->GetScintTime() + transport_time[ndetected_fast + i]);
281 else time =
static_cast<int>(edepi.StartT() +
fScintTime->GetScintTime());
282 if (Reflected) ++ref_phlitcol[
channel].DetectedPhotons[time];
283 else ++dir_phlitcol[
channel].DetectedPhotons[time];
302 for (
long i = 0; i < ndetected_fast; ++i) {
307 else time =
static_cast<int>(edepi.StartT() +
fScintTime->GetScintTime());
309 if(Reflected) ref_photcol[
channel].insert(ref_photcol[
channel].
end(), 1, photon);
315 for (
long i = 0; i < ndetected_slow; ++i) {
318 if (
fIncludePropTime) time =
static_cast<int>(edepi.StartT() +
fScintTime->GetScintTime() + transport_time[ndetected_fast + i]);
319 else time =
static_cast<int>(edepi.StartT() +
fScintTime->GetScintTime());
321 if(Reflected) ref_photcol[
channel].insert(ref_photcol[
channel].
end(), 1, photon);
335 event.put(
move(phlit));
336 event.put(
move(opbtr));
337 if (pvs->StoreReflected())
339 event.put(
move(phlit_ref),
"Reflected");
340 event.put(
move(opbtr_ref),
"Reflected");
345 event.put(
move(phot));
346 if (pvs->StoreReflected())
348 event.put(
move(phot_ref),
"Reflected");
357 std::map<int, int> & ChannelMap,
363 if (channelPosition == ChannelMap.end() )
365 ChannelMap[iChan] = opbtr.size();
370 unsigned int idtest = channelPosition->second;
373 for(
auto const& timePDclockSDP : timePDclockSDPsMap)
375 for(
auto const& sdp : timePDclockSDP.second)
377 double xyz[3] = {sdp.x, sdp.y, sdp.z};
378 opbtr.at(idtest).AddScintillationPhotons(sdp.trackID,
379 timePDclockSDP.first,
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
Store parameters for running LArG4.
CLHEP::HepRandomEngine & fPhotonEngine
std::unique_ptr< ScintTime > fScintTime
EDProducer(fhicl::ParameterSet const &pset)
All information of a photon entering the sensitive optical detector volume.
fhicl::ParameterSet fVISTimingParams
Energy deposited on a readout Optical Detector by simulated tracks.
geo::Point_t InitialPosition
Scintillation position in world coordinates [cm].
art framework interface to geometry description
Simulation objects for optical detectors.
std::map< int, int > PDChannelToSOCMapReflect
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
int OpDetNum() const
Returns the readout Optical Detector this object describes.
void AddOpDetBTR(std::vector< sim::OpDetBacktrackerRecord > &opbtr, std::map< int, int > &ChannelMap, sim::OpDetBacktrackerRecord btr)
#define DEFINE_ART_MODULE(klass)
static constexpr double eV
fhicl::ParameterSet fVUVTimingParams
PDFastSimPVS(fhicl::ParameterSet const &)
std::map< int, int > PDChannelToSOCMapDirect
void AddScintillationPhotons(TrackID_t trackID, timePDclock_t timePDclock, double numberPhotons, double const *xyz, double energy)
Add scintillation photons and energy to this OpticalDetector.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
General LArSoft Utilities.
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
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.
bool UseLitePhotons() const
QTextStream & endl(QTextStream &s)
CLHEP::HepRandomEngine & fScintTimeEngine
Event finding and building.