41 #include "nurandom/RandomUtils/NuRandomService.h"    62 #include "CLHEP/Random/RandFlat.h"    63 #include "CLHEP/Random/RandPoissonQ.h"    65 #include "Geant4/G4DynamicParticle.hh"    66 #include "Geant4/G4EmProcessSubType.hh"    67 #include "Geant4/G4EmSaturation.hh"    68 #include "Geant4/G4Material.hh"    69 #include "Geant4/G4MaterialPropertiesTable.hh"    70 #include "Geant4/G4OpticalPhoton.hh"    71 #include "Geant4/G4ParticleMomentum.hh"    72 #include "Geant4/G4PhysicsOrderedFreeVector.hh"    73 #include "Geant4/G4PhysicsTable.hh"    74 #include "Geant4/G4Poisson.hh"    75 #include "Geant4/G4ThreeVector.hh"    76 #include "Geant4/G4VPhysicalVolume.hh"    77 #include "Geant4/G4VRestDiscreteProcess.hh"    78 #include "Geant4/Randomize.hh"    79 #include "Geant4/globals.hh"    80 #include "Geant4/templates.hh"    83 #include "cetlib_except/exception.h"   128                             const std::map<size_t, double>& OpDetVisibilities, 
   129                             const double NumPhotons);
   131     void AddOpDetBTR(std::vector<sim::OpDetBacktrackerRecord>& opbtr,
   132                      std::map<size_t, int>& ChannelMap,
   193     , 
fISTPC{*(lar::providerFrom<geo::Geometry>())}
   222           << 
"Propagation time simulation requested, but VUVTiming not specified." << 
"\n";
   227           << 
"Reflected light simulation requested, but VisHits not specified." << 
"\n";
   232           << 
"Reflected light propagation time simulation requested, but VISTiming not specified." << 
"\n";
   237           << 
"Anode reflections light simulation requested, but VisHits not specified." << 
"\n";
   244         mf::LogInfo(
"PDFastSimPAR") << 
"Using Lite Photons";
   245         produces< std::vector<sim::SimPhotonsLite> >();
   246         produces< std::vector<sim::OpDetBacktrackerRecord> >();
   250             mf::LogInfo(
"PDFastSimPAR") << 
"Storing Reflected Photons";
   251             produces< std::vector<sim::SimPhotonsLite> >(
"Reflected");
   252             produces< std::vector<sim::OpDetBacktrackerRecord> >(
"Reflected");
   257         mf::LogInfo(
"PDFastSimPAR") << 
"Using Sim Photons";
   258         produces< std::vector<sim::SimPhotons> >();
   261             mf::LogInfo(
"PDFastSimPAR") << 
"Storing Reflected Photons";
   262             produces< std::vector<sim::SimPhotons> >(
"Reflected");
   271     mf::LogTrace(
"PDFastSimPAR") << 
"PDFastSimPAR Module Producer"   272                                  << 
"EventID: " << 
event.event();
   274     auto phot = std::make_unique<std::vector<sim::SimPhotons>>();
   275     auto phlit = std::make_unique<std::vector<sim::SimPhotonsLite>>();
   276     auto opbtr = std::make_unique<std::vector<sim::OpDetBacktrackerRecord>>();
   278     auto phot_ref = std::make_unique<std::vector<sim::SimPhotons>>();
   279     auto phlit_ref = std::make_unique<std::vector<sim::SimPhotonsLite>>();
   280     auto opbtr_ref = std::make_unique<std::vector<sim::OpDetBacktrackerRecord>>();
   282     auto& dir_photcol(*
phot);
   283     auto& ref_photcol(*phot_ref);
   284     auto& dir_phlitcol(*phlit);
   285     auto& ref_phlitcol(*phlit_ref);
   290     for (
unsigned int i = 0; i < 
nOpDets; i ++)
   292         dir_photcol[i].fOpChannel  = i;
   293         ref_photcol[i].fOpChannel  = i;
   294         dir_phlitcol[i].OpChannel  = i;
   295         ref_phlitcol[i].OpChannel  = i;
   304     auto const& edeps = edepHandle;
   312     for (
auto const& edepi : *edeps) {
   315       int trackID = edepi.TrackID();
   316       double nphot = edepi.NumPhotons();
   317       double edeposit = edepi.Energy() / nphot;
   318       double pos[3] = {edepi.MidPointX(), edepi.MidPointY(), edepi.MidPointZ()};
   319       geo::Point_t const ScintPoint = {pos[0], pos[1], pos[2]};
   323       double nphot_fast = edepi.NumFPhotons();
   324       double nphot_slow = edepi.NumSPhotons();
   326       num_fastph += nphot_fast;
   327       num_slowph += nphot_slow;
   330       std::map<size_t, int> DetectedNumFast;
   331       std::map<size_t, int> DetectedNumSlow;
   335         std::map<size_t, double> OpDetVisibilities;
   336         fVisibilityModel->detectedDirectVisibilities(OpDetVisibilities, ScintPoint);
   341           std::map<size_t, int> AnodeDetectedNumFast;
   342           std::map<size_t, int> AnodeDetectedNumSlow;
   344           std::map<size_t, double> OpDetVisibilitiesAnode;
   345           fVisibilityModel->detectedReflectedVisibilities(OpDetVisibilitiesAnode, ScintPoint, 
true);
   350           for (
auto const& 
x : AnodeDetectedNumFast) DetectedNumFast[
x.first] += 
x.second;
   351           for (
auto const& 
x : AnodeDetectedNumSlow) DetectedNumSlow[
x.first] += 
x.second;
   356       std::map<size_t, int> ReflDetectedNumFast;
   357       std::map<size_t, int> ReflDetectedNumSlow;
   360         std::map<size_t, double> OpDetVisibilitiesRefl;
   361         fVisibilityModel->detectedReflectedVisibilities(OpDetVisibilitiesRefl, ScintPoint, 
false);
   367       std::vector<double> transport_time;
   370       for (
size_t Reflected = 0; Reflected <= 1; ++Reflected) {
   379           int ndetected_fast = DetectedNumFast[
channel];
   380           int ndetected_slow = DetectedNumSlow[
channel];
   382             ndetected_fast = ReflDetectedNumFast[
channel];
   383             ndetected_slow = ReflDetectedNumSlow[
channel];
   388             transport_time.resize(ndetected_fast + ndetected_slow);
   389             fPropTimeModel->propagationTime(transport_time, ScintPoint, channel, Reflected);
   398               int n = ndetected_fast;
   400               for (
long i = 0; i < 
n; ++i) {
   405                 else time = 
static_cast<int>(edepi.StartT() + 
fScintTime->GetScintTime());
   406                 if (Reflected) ++ref_phlitcol[
channel].DetectedPhotons[time];
   407                 else ++dir_phlitcol[
channel].DetectedPhotons[time];
   413               int n = ndetected_slow;
   415               for (
long i = 0; i < 
n; ++i) {
   418                 if (
fIncludePropTime) time = 
static_cast<int>(edepi.StartT() + 
fScintTime->GetScintTime() + transport_time[ndetected_fast + i]);
   419                 else time = 
static_cast<int>(edepi.StartT() + 
fScintTime->GetScintTime());
   420                 if (Reflected) ++ref_phlitcol[
channel].DetectedPhotons[time];
   421                 else ++dir_phlitcol[
channel].DetectedPhotons[time];
   439               int n = ndetected_fast;
   441               for (
long i = 0; i < 
n; ++i) {
   446                 else time = 
static_cast<int>(edepi.StartT() + 
fScintTime->GetScintTime());
   448                 if(Reflected) ref_photcol[
channel].insert(ref_photcol[channel].
end(), 1, photon);
   449                 else dir_photcol[
channel].insert(dir_photcol[channel].
end(), 1, photon);
   454               int n = ndetected_slow;
   456               for (
long i = 0; i < 
n; ++i) {
   459                 if (
fIncludePropTime) time = 
static_cast<int>(edepi.StartT() + 
fScintTime->GetScintTime() + transport_time[ndetected_fast + i]);
   460                 else time = 
static_cast<int>(edepi.StartT() + 
fScintTime->GetScintTime());
   462                 if(Reflected) ref_photcol[
channel].insert(ref_photcol[channel].
end(), 1, photon);
   463                 else dir_photcol[
channel].insert(dir_photcol[channel].
end(), 1, photon);
   471     mf::LogTrace(
"PDFastSimPAR") << 
"Total points: " << num_points
   472                                  << 
", total fast photons: " << num_fastph
   473                                  << 
", total slow photons: " << num_slowph
   474                                  << 
"\ndetected fast photons: " << num_fastdp
   475                                  << 
", detected slow photons: " << num_slowdp;
   481         event.put(
move(phlit));
   482         event.put(
move(opbtr));
   484             event.put(
move(phlit_ref), 
"Reflected");
   485             event.put(
move(opbtr_ref), 
"Reflected");
   491             event.put(
move(phot_ref), 
"Reflected");
   501                             std::map<size_t, int>& ChannelMap,
   506     auto channelPosition = ChannelMap.find(iChan);
   508     if (channelPosition == ChannelMap.end()) {
   509       ChannelMap[iChan] = opbtr.size();
   513       unsigned int idtest = channelPosition->second;
   516       for (
auto const& timePDclockSDP : timePDclockSDPsMap) {
   517         for (
auto const& sdp : timePDclockSDP.second) {
   518           double xyz[3] = {sdp.x, sdp.y, sdp.z};
   519           opbtr.at(idtest).AddScintillationPhotons(
   520             sdp.trackID, timePDclockSDP.first, sdp.numPhotons, xyz, sdp.energy);
   530     std::cout << 
"PDFastSimPAR Initialization" << 
std::endl;
   531     std::cout << 
"Initializing the geometry of the detector." << 
std::endl;
   532     std::cout << 
"Simulate using semi-analytic model for number of hits." << 
std::endl;
   549       auto log = 
mf::LogTrace(
"PDFastSimPAR") << 
"PDFastSimPAR: active volume boundaries from "   552         log << 
"\n - C:" << iCryo << 
": " << box.Min() << 
" -- " << box.Max() << 
" cm";
   556     if (geom.Ncryostats() > 1U) {
   559           << 
std::string(80, 
'=') << 
"\nA detector with " << geom.Ncryostats()
   560           << 
" cryostats is configured"   561           << 
" , and semi-analytic model is requested for scintillation photon propagation."   562           << 
" THIS CONFIGURATION IS NOT SUPPORTED and it is open to bugs"   563           << 
" (e.g. scintillation may be detected only in cryostat #0)."   564           << 
"\nThis would be normally a fatal error, but it has been forcibly overridden."   570           << 
"Photon propagation via semi-analytic model is not supported yet"   571           << 
" on detectors with more than one cryostat.";
   586       for (
auto const& 
x : OpDetVisibilities)
   601     if (((ScintPoint.X() < 0.) != (OpDetPoint.X() < 0.)) &&
 std::map< size_t, int > PDChannelToSOCMapDirect
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
std::vector< geo::Point_t > fOpDetCenter
base_engine_t & createEngine(seed_t seed)
fhicl::ParameterSet fVISHitsParams
bool isOpDetInSameTPC(geo::Point_t const &ScintPoint, geo::Point_t const &OpDetPoint) const 
static std::vector< geo::BoxBoundedGeo > extractActiveLArVolume(geo::GeometryCore const &geom)
void detectedNumPhotons(std::map< size_t, int > &DetectedNumPhotons, const std::map< size_t, double > &OpDetVisibilities, const double NumPhotons)
Encapsulate the construction of a single cyostat. 
Definition of util::enumerate(). 
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::unique_ptr< PropagationTimeModel > fPropTimeModel
fhicl::Atom< bool > DoSlowComponent
EDProducer(fhicl::ParameterSet const &pset)
PDFastSimPAR(Parameters const &config)
All information of a photon entering the sensitive optical detector volume. 
std::vector< geo::BoxBoundedGeo > fActiveVolumes
ChannelGroupService::Name Name
fhicl::Atom< bool > DoReflectedLight
void GetCenter(double *xyz, double localz=0.0) const 
std::unique_ptr< ScintTime > fScintTime
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
Energy deposited on a readout Optical Detector by simulated tracks. 
geo::Point_t InitialPosition
Scintillation position in world coordinates [cm]. 
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration. 
fhicl::Atom< bool > UseLitePhotons
std::unique_ptr< CLHEP::RandPoissonQ > fRandPoissPhot
CLHEP::HepRandomEngine & fScintTimeEngine
Simulation objects for optical detectors. 
fhicl::ParameterSet fVISTimingParams
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. 
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop. 
std::map< size_t, int > PDChannelToSOCMapReflect
#define DEFINE_ART_MODULE(klass)                                                                                          
static constexpr double eV
std::unique_ptr< SemiAnalyticalModel > fVisibilityModel
fhicl::Atom< bool > OpaqueCathode
fhicl::ParameterSet fVUVTimingParams
fhicl::Atom< bool > IncludeAnodeReflections
void produce(art::Event &) override
bool fIncludeAnodeReflections
Test of util::counter and support utilities. 
Description of geometry of one entire detector. 
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. 
Encapsulate the geometry of an optical detector. 
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
General LArSoft Utilities. 
fhicl::Atom< bool > GeoPropTimeOnly
CLHEP::HepRandomEngine & fPhotonEngine
Declaration of types related to photon visibility. 
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
fhicl::Atom< art::InputTag > SimulationLabel
MaybeLogger_< ELseverityLevel::ELsev_success, true > LogTrace
fhicl::Atom< bool > IncludePropTime
float Energy
Scintillation photon energy [GeV]. 
fhicl::Atom< bool > OnlyActiveVolume
bool isScintInActiveVolume(geo::Point_t const &ScintPoint)
void AddOpDetBTR(std::vector< sim::OpDetBacktrackerRecord > &opbtr, std::map< size_t, int > &ChannelMap, sim::OpDetBacktrackerRecord btr)
timePDclockSDPs_t const & timePDclockSDPsMap() const 
Returns all the deposited energy information as stored. 
fhicl::Atom< bool > OnlyOneCryostat
fhicl::Atom< bool > DoFastComponent
QTextStream & endl(QTextStream &s)
Event finding and building. 
fhicl::ParameterSet fVUVHitsParams