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;
302 tmpOpDetBTRecord.AddScintillationPhotons(thisG4TrackID, photonTime, numPhotons, xyzPos, energy);
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 " ;
static constexpr double cm
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
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.
std::map< int, int > DetectedPhotons
Number of photons detected at each given time: time tick -> photons.
void AddPhoton(size_t opchannel, sim::OnePhoton &&photon, bool Reflected=false)
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)
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
unsigned int NOpDets() const
Number of OpDets in the whole detector.
static OpDetPhotonTable * Instance(bool LitePhotons=false)
Compact representation of photons on a channel.
std::vector< sim::OpDetBacktrackerRecord > YieldOpDetBacktrackerRecords()
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
std::map< int, std::map< int, int > > GetLitePhotons(bool Reflected=false)
CLHEP::HepRandomEngine & fPhotonEngine
void ClearTable(size_t nch=0)
QTextStream & endl(QTextStream &s)