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];
271 tmpbtr.AddScintillationPhotons(trackID, time, 1, pos, edeposit);
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];
284 tmpbtr.AddScintillationPhotons(trackID, time, 1, pos, edeposit);
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");
346 if (pvs->StoreReflected())
348 event.put(
move(phot_ref),
"Reflected");
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
CLHEP::HepRandomEngine & fPhotonEngine
std::unique_ptr< ScintTime > fScintTime
All information of a photon entering the sensitive optical detector volume.
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].
std::map< int, int > PDChannelToSOCMapReflect
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
void AddOpDetBTR(std::vector< sim::OpDetBacktrackerRecord > &opbtr, std::map< int, int > &ChannelMap, sim::OpDetBacktrackerRecord btr)
static constexpr double eV
std::map< int, int > PDChannelToSOCMapDirect
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 SetInSD
Whether the photon reaches the sensitive detector.
float Energy
Scintillation photon energy [GeV].
std::unique_ptr< PropagationTimeModel > fPropTimeModel
bool UseLitePhotons() const
CLHEP::HepRandomEngine & fScintTimeEngine
QTextStream & endl(QTextStream &s)