10 #include "art/Framework/Core/EDProducer.h"
11 #include "art/Framework/Core/ModuleMacros.h"
12 #include "art/Framework/Principal/Event.h"
13 #include "art/Framework/Principal/Handle.h"
14 #include "art/Framework/Principal/Run.h"
15 #include "art/Framework/Principal/SubRun.h"
16 #include "CLHEP/Random/RandFlat.h"
17 #include "CLHEP/Random/RandPoisson.h"
18 #include "CLHEP/Random/RandExponential.h"
20 #include "nurandom/RandomUtils/NuRandomService.h"
21 #include "canvas/Utilities/InputTag.h"
22 #include "fhiclcpp/ParameterSet.h"
23 #include "messagefacility/MessageLogger/MessageLogger.h"
31 #include "nusimdata/SimulationBase/MCTruth.h"
32 #include "nusimdata/SimulationBase/MCParticle.h"
35 #include <TLorentzVector.h>
42 explicit FakeFlash(fhicl::ParameterSet
const&
p);
53 void produce(art::Event&
e)
override;
54 void beginRun(art::Run& run)
override;
60 size_t mother_trackid,
61 const TLorentzVector& pos);
91 , fFlatEngine(art::ServiceHandle<rndm::NuRandomService>()->createEngine(*
this,
"HepJamesRandom",
"Gen",
p,
"Seed"))
94 _verbose =
p.get<
bool>(
"Verbose",
false);
95 auto min_photons =
p.get<
int>(
"MinPhotons",24000);
96 auto max_photons =
p.get<
int>(
"MaxPhotons",2400000);
97 assert(min_photons < max_photons && min_photons>0 && max_photons>0);
98 _min_photons = min_photons;
99 _max_photons = max_photons;
102 _fast_frac =
p.get<
double>(
"PromptLightFraction",0.23);
103 _fast_tau =
p.get<
double>(
"FastTimeConstant",0.006);
104 _slow_tau =
p.get<
double>(
"SlowTimeConstant",1.5);
107 auto geop = lar::providerFrom<geo::Geometry>();
109 _ch_max = geop->NOpChannels() - 1;
110 _ch_min =
p.get<
size_t>(
"ChannelMin",_ch_min);
111 _ch_max =
p.get<
size_t>(
"ChannelMax",_ch_max);
112 assert(_ch_min<_ch_max);
117 _tpc_v =
p.get<std::vector<size_t> >(
"TPCList");
118 _xmax =
p.get<
double>(
"XMax",1.0);
119 _xmin =
p.get<
double>(
"XMin",0.0);
120 _ymax =
p.get<
double>(
"YMax",1.0);
121 _ymin =
p.get<
double>(
"YMin",0.0);
122 _zmax =
p.get<
double>(
"ZMax",1.0);
123 _zmin =
p.get<
double>(
"ZMin",0.0);
124 assert(_xmax>=_xmin && _ymax>=_ymin && _zmax>=_zmin &&
125 _xmax<=1.0 && _ymax<=1.0 && _zmax<=1.0 &&
126 _xmin>=0.0 && _ymin>=0.0 && _zmin>=0.0 );
128 _frequency =
p.get<
double>(
"Frequency");
129 _duration =
p.get<
double>(
"Duration");
130 _tstart =
p.get<
double>(
"G4TStart");
131 produces<std::vector<sim::SimPhotons> >();
132 produces<std::vector<simb::MCTruth> >();
133 produces< sumdata::RunData, art::InRun >();
135 fFlatRandom =
new CLHEP::RandFlat(fFlatEngine,0,1);
136 fExpoRandom =
new CLHEP::RandExponential(fFlatEngine);
137 fPoisRandom =
new CLHEP::RandPoisson(fFlatEngine);
143 art::ServiceHandle<geo::Geometry> geo;
145 std::unique_ptr<sumdata::RunData> runData(
new sumdata::RunData(geo->DetectorName()));
147 run.put(std::move(runData));
157 auto geop = lar::providerFrom<geo::Geometry>();
158 for(
size_t c=0; c<geop->Ncryostats(); ++c) {
159 auto const& cryostat = geop->Cryostat(c);
160 if(!cryostat.HasTPC(tpc_id))
continue;
161 auto const& tpc = cryostat.TPC(tpc_id);
162 auto const& tpcabox = tpc.ActiveBoundingBox();
163 double xmin = tpcabox.MinX() + (tpcabox.MaxX() - tpcabox.MinX()) *
_xmin;
164 double xmax = tpcabox.MinX() + (tpcabox.MaxX() - tpcabox.MinX()) *
_xmax;
165 double ymin = tpcabox.MinY() + (tpcabox.MaxY() - tpcabox.MinY()) *
_ymin;
166 double ymax = tpcabox.MinY() + (tpcabox.MaxY() - tpcabox.MinY()) *
_ymax;
167 double zmin = tpcabox.MinZ() + (tpcabox.MaxZ() - tpcabox.MinZ()) *
_zmin;
168 double zmax = tpcabox.MinZ() + (tpcabox.MaxZ() - tpcabox.MinZ()) *
_zmax;
175 if(!found)
std::cerr<<
"\033[93mTPC " << tpc_id <<
" not found...\033[00m" << std::endl;
181 const TLorentzVector& pos)
183 art::ServiceHandle<phot::PhotonVisibilityService const> pvs;
188 auto const& Visibilities = pvs->GetAllVisibilities(xyz);
190 if(simph_v.empty()) {
196 size_t detected =
fPoisRandom->fire((
double)(nphotons) * Visibilities[opch]);
199 assert(time_array.size() == detected);
201 auto& simph = simph_v[opch];
202 for(
size_t idx=0; idx<detected; ++idx) {
204 phot.
Time = pos.T() + time_array[idx];
209 simph.emplace_back(phot);
216 std::vector<double> res(numphotons);
217 for(
int i=0; i<((int)numphotons); ++i) {
228 auto simph_v = std::unique_ptr<std::vector<sim::SimPhotons> >(
new std::vector<sim::SimPhotons>());
229 auto mct_v = std::unique_ptr<std::vector<simb::MCTruth> >(
new std::vector<simb::MCTruth>());
230 std::vector<simb::MCParticle> mcp_v;
237 double time =
_tstart + clock * 1.e3;
240 TLorentzVector pos(x,y,z,time);
243 this->
FillSimPhotons(*simph_v, (
int)(mcp_v.size()), nphotons, pos);
246 simb::MCParticle part(mcp_v.size(), 22,
"primary", 0, 0., 1);
247 TLorentzVector mom(0.,0.,0.,(
double)nphotons);
248 part.AddTrajectoryPoint(pos,mom);
249 mcp_v.emplace_back(std::move(part));
256 for(
auto& part : mcp_v)
258 mct_v->emplace_back(std::move(mct));
260 e.put(std::move(simph_v));
261 e.put(std::move(mct_v));
FakeFlash(fhicl::ParameterSet const &p)
process_name opflash particleana ie ie ie z
CLHEP::HepRandomEngine & fFlatEngine
Utilities related to art service access.
double _zmax
0.0-1.0 the z-position range in fraction of a TPC volume
std::vector< size_t > _tpc_v
List of TPC ID to be used.
double _fast_frac
fraction of prompt light
process_name opflash particleana ie x
BEGIN_PROLOG could also be cerr
double _slow_tau
scintillation emission time constant for slow component
CLHEP::RandExponential * fExpoRandom
All information of a photon entering the sensitive optical detector volume.
size_t _ch_max
channel range max to produce SimPhotons
CLHEP::RandFlat * fFlatRandom
std::vector< double > GenerateTime(size_t numphotons)
FakeFlash & operator=(FakeFlash const &)=delete
double _fast_tau
scintillation emission time constant for fast component
bool _verbose
verbosity for debugging
geo::Point_t InitialPosition
Scintillation position in world coordinates [cm].
process_name pandoraGausCryo1 vertexChargeCryo1 vertexStubCryo1 xmin
double _zmin
0.0-1.0 the z-position range in fraction of a TPC volume
Simulation objects for optical detectors.
double _ymax
0.0-1.0 the y-position range in fraction of a TPC volume
process_name opflash particleana ie ie y
double _ymin
0.0-1.0 the y-position range in fraction of a TPC volume
size_t _max_photons
[photons]
double _xmin
0.0-1.0 the x-position range in fraction of a TPC volume
void beginRun(art::Run &run) override
double _xmax
0.0-1.0 the x-position range in fraction of a TPC volume
size_t _ch_min
channel range min to produce SimPhotons
void FillSimPhotons(std::vector< sim::SimPhotons > &simph_v, int nphotons, size_t mother_trackid, const TLorentzVector &pos)
CLHEP::RandPoisson * fPoisRandom
Collection of photons which recorded on one channel.
void produce(art::Event &e) override
void GenPosition(double &x, double &y, double &z)
size_t _min_photons
[photons]
art framework interface to geometry description
int MotherTrackID
ID of the GEANT4 track causing the scintillation.