57 #include "CLHEP/Random/RandFlat.h" 58 #include "CLHEP/Random/RandPoissonQ.h" 74 std::unique_ptr<TFLoader>
81 void AddOpDetBTR(std::vector<sim::OpDetBacktrackerRecord>& opbtr,
82 std::map<int, int>& ChannelMap,
107 std::cout <<
"PDFastSimANN Module Construct" << std::endl;
110 std::cout <<
"Use Lite Photon." << std::endl;
111 produces<std::vector<sim::SimPhotonsLite>>();
112 produces<std::vector<sim::OpDetBacktrackerRecord>>();
115 std::cout <<
"Use Sim Photon." << std::endl;
116 produces<std::vector<sim::SimPhotons>>();
123 std::cout <<
"PDFastSimANN beginJob." << std::endl;
129 std::cout <<
"Number of optical detectors: " <<
nOpChannels << std::endl;
137 std::cout <<
"PDFastSimANN endJob." << std::endl;
146 std::cout <<
"PDFastSimANN Module Producer..." << std::endl;
150 std::unique_ptr<std::vector<sim::SimPhotons>>
phot(
new std::vector<sim::SimPhotons>);
151 std::unique_ptr<std::vector<sim::SimPhotonsLite>> phlit(
new std::vector<sim::SimPhotonsLite>);
152 std::unique_ptr<std::vector<sim::OpDetBacktrackerRecord>> opbtr(
153 new std::vector<sim::OpDetBacktrackerRecord>);
155 auto& photonCollection(*phot);
156 auto& photonLiteCollection(*phlit);
162 photonCollection[i].fOpChannel = i;
163 photonLiteCollection[i].OpChannel = i;
168 std::cout <<
"PDFastSimANN Module Cannot getByLabel: " <<
simTag << std::endl;
173 auto const& edeps = edepHandle;
176 float vis_scale = 1.0;
177 for (
auto const& edepi : *edeps) {
179 int trackID = edepi.TrackID();
180 int nphot = edepi.NumPhotons();
181 double edeposit = edepi.Energy() / nphot;
182 double pos[3] = {edepi.MidPointX(), edepi.MidPointY(), edepi.MidPointZ()};
184 int nphot_fast = edepi.NumFPhotons();
185 int nphot_slow = edepi.NumSPhotons();
187 std::vector<double> pars;
188 pars.push_back(pos[0]);
189 pars.push_back(pos[1]);
190 pars.push_back(pos[2]);
192 std::vector<double> Visibilities =
fTFGenerator->GetPrediction();
193 if (
int(Visibilities.size()) != nOpChannels) {
194 std::cout <<
"PDFastSimANN get channels from graph " << Visibilities.size()
195 <<
" is not the same as from geometry: " << nOpChannels << std::endl;
199 for (
int channel = 0; channel < int(Visibilities.size()); ++channel) {
200 auto visibleFraction =
201 Visibilities[channel] * vis_scale;
203 if (visibleFraction == 0.0) {
209 if (nphot_fast > 0) {
211 auto n =
static_cast<int>(randpoisphot.fire(nphot_fast * visibleFraction));
212 for (
long i = 0; i <
n; ++i) {
215 auto time =
static_cast<int>(edepi.StartT() +
fScintTime->GetScintTime());
216 ++photonLiteCollection[channel].DetectedPhotons[time];
222 auto n =
static_cast<int>(randpoisphot.fire(nphot_slow * visibleFraction));
223 for (
long i = 0; i <
n; ++i) {
225 auto time =
static_cast<int>(edepi.StartT() +
fScintTime->GetScintTime());
226 ++photonLiteCollection[channel].DetectedPhotons[time];
236 photon.
InitialPosition = {edepi.MidPointX(), edepi.MidPointY(), edepi.MidPointZ()};
239 if (nphot_fast > 0) {
241 auto n =
static_cast<int>(randpoisphot.fire(nphot_fast * visibleFraction));
244 auto time =
static_cast<int>(edepi.StartT() +
fScintTime->GetScintTime());
247 photonCollection[channel].insert(photonCollection[channel].
end(),
n, photon);
252 auto n =
static_cast<int>(randpoisphot.fire(nphot_slow * visibleFraction));
255 auto time =
static_cast<int>(edepi.StartT() +
fScintTime->GetScintTime());
258 photonCollection[channel].insert(photonCollection[channel].
end(),
n, photon);
264 std::cout <<
"PDFastSimANN module produced " << num_points <<
" images..." << std::endl;
268 event.put(move(phlit));
269 event.put(move(opbtr));
272 event.put(move(phot));
280 std::map<int, int>& ChannelMap,
286 if (channelPosition == ChannelMap.end()) {
287 ChannelMap[iChan] = opbtr.size();
288 opbtr.emplace_back(std::move(btr));
291 unsigned int idtest = channelPosition->second;
294 for (
auto const& timePDclockSDP : timePDclockSDPsMap) {
295 for (
auto const& sdp : timePDclockSDP.second) {
296 double xyz[3] = {sdp.x, sdp.y, sdp.z};
297 opbtr.at(idtest).AddScintillationPhotons(
298 sdp.trackID, timePDclockSDP.first, sdp.numPhotons, xyz, sdp.energy);
base_engine_t & createEngine(seed_t seed)
Store parameters for running LArG4.
Utilities related to art service access.
Definition of util::enumerate().
EDProducer(fhicl::ParameterSet const &pset)
All information of a photon entering the sensitive optical detector volume.
CLHEP::HepRandomEngine & fPhotonEngine
CryostatGeo const & Cryostat(CryostatID const &cryoid=cryostat_zero) const
Returns the specified cryostat.
Energy deposited on a readout Optical Detector by simulated tracks.
geo::Point_t InitialPosition
Scintillation position in world coordinates [cm].
std::unique_ptr< ScintTime > fScintTime
std::unique_ptr< TFLoader > fTFGenerator
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
PDFastSimANN(fhicl::ParameterSet const &)
Simulation objects for optical detectors.
int OpDetNum() const
Returns the readout Optical Detector this object describes.
#define DEFINE_ART_MODULE(klass)
Definitions of geometry vector data types.
void produce(art::Event &) override
Test of util::counter and support utilities.
An art service to assist in the distribution of guaranteed unique seeds to all engines within an art ...
Provides a base class aware of world box coordinates.
void AddScintillationPhotons(TrackID_t trackID, timePDclock_t timePDclock, double numberPhotons, double const *xyz, double energy)
Add scintillation photons and energy to this OpticalDetector.
Encapsulate the geometry of an optical detector.
void AddOpDetBTR(std::vector< sim::OpDetBacktrackerRecord > &opbtr, std::map< int, int > &ChannelMap, sim::OpDetBacktrackerRecord btr)
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.
unsigned int NOpDet() const
Number of optical detectors in this TPC.
contains information for a single step in the detector simulation
const bool fDoSlowComponent
float Energy
Scintillation photon energy [GeV].
const bool fUseLitePhotons
std::map< int, int > PDChannelToSOCMap
Namespace collecting geometry-related classes utilities.
CLHEP::HepRandomEngine & fScintTimeEngine
timePDclockSDPs_t const & timePDclockSDPsMap() const
Returns all the deposited energy information as stored.
art framework interface to geometry description
Event finding and building.