16 #include "nurandom/RandomUtils/NuRandomService.h" 27 #include "Geant4/G4VUserTrackInformation.hh" 41 #include "CLHEP/Random/RandFlat.h" 42 #include "CLHEP/Random/RandPoissonQ.h" 54 #include "TGeoManager.h" 77 void Print(std::map<
int, std::map<int, int>>* StepPhotonTable);
91 ,
fGain{
p.get<
double>(
"Gain",500)}
100 produces< std::vector<sim::OpDetBacktrackerRecord> >();
101 produces< std::vector<sim::SimPhotonsLite> >();
103 else produces< std::vector<sim::SimPhotons> >();
116 if (!pvs->IncludeParPropTime())
mf::LogInfo(
"PhotonLibraryPropagationS2") <<
"Parametrized Propagation Time is not set up for S2. The propagation of S2 light will be instantaneous."<<
std::endl;
135 std::unique_ptr< std::vector<sim::SimPhotonsLite> > LitePhotonCol (
new std::vector<sim::SimPhotonsLite>);
136 std::unique_ptr< std::vector< sim::OpDetBacktrackerRecord > > cOpDetBacktrackerRecordCol (
new std::vector<sim::OpDetBacktrackerRecord>);
146 else mf::LogError(
"PhotonLibraryPropagationS2") <<
"Error creating S2 light, SimPhotons data product is not supported."<<
std::endl;
153 int detectedcounter=0;
155 double const xyz[3] = { ElectronCluster.FinalPositionX(), ElectronCluster.FinalPositionY(), ElectronCluster.FinalPositionZ() };
156 float const* Visibilities = pvs->GetAllVisibilities(xyz);
160 TF1 *ParPropTimeTF1 =
nullptr;
162 if(pvs->IncludeParPropTime())
164 ParPropTimeTF1 = pvs->GetTimingTF1(xyz);
173 nphot =ElectronCluster.NumberOfElectrons()*
fGain;
186 std::map<int, int> DetectedNum;
190 G4int DetThisPMT = G4int(randpoisphot.fire(Visibilities[OpDet] * nphot));
195 DetectedNum[OpDet]=DetThisPMT;
204 std::map<int, std::map<int, int>> StepPhotonTable;
206 Print(&StepPhotonTable);
209 itdetphot!=DetectedNum.end(); ++itdetphot)
213 std::map<int, int> StepPhotons;
269 for (G4int i = 0; i < itdetphot->second; ++i)
271 G4double deltaTime = ElectronCluster.Time();
273 if(pvs->IncludeParPropTime())
275 deltaTime += ParPropTimeTF1[itdetphot->first].GetRandom();
277 G4double aSecondaryTime = deltaTime;
278 float Time = aSecondaryTime;
279 int ticks =
static_cast<int>(Time);
280 StepPhotons[
ticks]++;detectedcounter++;
284 StepPhotonTable[itdetphot->first] = StepPhotons;
289 int thisG4TrackID = ElectronCluster.TrackID();
290 double xO = ( ElectronCluster.FinalPositionX() /
CLHEP::cm );
291 double yO = ( ElectronCluster.FinalPositionY() /
CLHEP::cm );
292 double zO = ( ElectronCluster.FinalPositionZ() /
CLHEP::cm );
293 double const xyzPos[3] = {xO,yO,zO};
300 int photonTime = stepPhotonsIt->first;
301 int numPhotons = stepPhotonsIt->second;
311 mf::LogError(
"PhotonLibraryPropagationS2") <<
"Error creating S2 light, SimPhotons data product is not supported."<<
std::endl;
315 mf::LogInfo(
"PhotonLibraryPropagationS2") << counter <<
" electron clusters processed. "<< ElectronCluster.NumberOfElectrons() <<
" electron arrives. "<< nphot <<
" S2 photons have been created in " << ElectronCluster.FinalPositionX() <<
" " << ElectronCluster.FinalPositionY() <<
" "<< ElectronCluster.FinalPositionZ()<<
" at time " << ElectronCluster.Time() <<
std::endl;counter++;
325 mf::LogError(
"PhotonLibraryPropagationS2") <<
"Error creating S2 light, SimPhotons data product is not supported."<<
std::endl;
336 mf::LogDebug(
"PhotonLibraryPropagationS2") <<
"Converting Photon Map in SimPhotonLite data product";
337 std::map<int, std::map<int, int> > ThePhotons = litefst->
GetLitePhotons();
338 if(ThePhotons.size() > 0)
340 LitePhotonCol->reserve(ThePhotons.size());
342 for(
auto const& it : ThePhotons)
348 LitePhotonCol->push_back(ph);
358 mf::LogError(
"PhotonLibraryPropagationS2") <<
"Error creating S2 light, SimPhotons data product is not supported."<<
std::endl;
363 mf::LogDebug(
"PhotonLibraryPropagationS2") <<
"Storing S2 Photon Collection in event " ;
372 for(
auto it = StepPhotonTable->begin(); it!=StepPhotonTable->end(); it++)
374 for(
auto in_it = it->second.begin(); in_it!=it->second.end(); in_it++)
376 std::cout << in_it->second <<
" ";
static constexpr double cm
Definitions of voxel data structures.
Store parameters for running LArG4.
Encapsulate the construction of a single cyostat.
contains objects relating to SimDriftedElectronCluster
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
EDProducer(fhicl::ParameterSet const &pset)
PhotonLibraryPropagationS2 & operator=(PhotonLibraryPropagationS2 const &)=delete
CLHEP::HepRandomEngine & fScintTimeEngine
void Print(std::map< int, std::map< int, int >> *StepPhotonTable)
static constexpr double MeV
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
tick ticks
Alias for common language habits.
Energy deposited on a readout Optical Detector by simulated tracks.
art framework interface to geometry description
std::map< int, int > DetectedPhotons
Number of photons detected at each given time: time tick -> photons.
Simulation objects for optical detectors.
void AddPhoton(size_t opchannel, sim::OnePhoton &&photon, bool Reflected=false)
#define DEFINE_ART_MODULE(klass)
PhotonLibraryPropagationS2(fhicl::ParameterSet const &p)
std::string fDriftEModuleLabel
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
int OpChannel
Optical detector channel associated to this data.
void AddOpDetBacktrackerRecord(sim::OpDetBacktrackerRecord soc, bool Reflected=false)
void produce(art::Event &e) override
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
unsigned int NOpDets() const
Number of OpDets in the whole detector.
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.
static OpDetPhotonTable * Instance(bool LitePhotons=false)
General LArSoft Utilities.
Compact representation of photons on a channel.
std::vector< sim::OpDetBacktrackerRecord > YieldOpDetBacktrackerRecords()
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
contains information for a single step in the detector simulation
std::map< int, std::map< int, int > > GetLitePhotons(bool Reflected=false)
CLHEP::HepRandomEngine & fPhotonEngine
void ClearTable(size_t nch=0)
bool UseLitePhotons() const
QTextStream & endl(QTextStream &s)