All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
FakeFlash Class Reference
Inheritance diagram for FakeFlash:

Public Member Functions

 FakeFlash (fhicl::ParameterSet const &p)
 
 FakeFlash (FakeFlash const &)=delete
 
 FakeFlash (FakeFlash &&)=delete
 
FakeFlashoperator= (FakeFlash const &)=delete
 
FakeFlashoperator= (FakeFlash &&)=delete
 
void produce (art::Event &e) override
 
void beginRun (art::Run &run) override
 

Private Member Functions

void GenPosition (double &x, double &y, double &z)
 
void FillSimPhotons (std::vector< sim::SimPhotons > &simph_v, int nphotons, size_t mother_trackid, const TLorentzVector &pos)
 
std::vector< double > GenerateTime (size_t numphotons)
 

Private Attributes

bool _verbose
 verbosity for debugging More...
 
double _frequency
 [MHz] More...
 
double _duration
 [us] More...
 
double _tstart
 [ns] More...
 
size_t _min_photons
 [photons] More...
 
size_t _max_photons
 [photons] More...
 
std::vector< size_t > _tpc_v
 List of TPC ID to be used. More...
 
double _fast_frac
 fraction of prompt light More...
 
double _fast_tau
 scintillation emission time constant for fast component More...
 
double _slow_tau
 scintillation emission time constant for slow component More...
 
size_t _ch_min
 channel range min to produce SimPhotons More...
 
size_t _ch_max
 channel range max to produce SimPhotons More...
 
double _xmax
 0.0-1.0 the x-position range in fraction of a TPC volume More...
 
double _ymax
 0.0-1.0 the y-position range in fraction of a TPC volume More...
 
double _zmax
 0.0-1.0 the z-position range in fraction of a TPC volume More...
 
double _xmin
 0.0-1.0 the x-position range in fraction of a TPC volume More...
 
double _ymin
 0.0-1.0 the y-position range in fraction of a TPC volume More...
 
double _zmin
 0.0-1.0 the z-position range in fraction of a TPC volume More...
 
CLHEP::HepRandomEngine & fFlatEngine
 
CLHEP::RandFlat * fFlatRandom
 
CLHEP::RandExponential * fExpoRandom
 
CLHEP::RandPoisson * fPoisRandom
 

Detailed Description

Definition at line 40 of file FakeFlash_module.cc.

Constructor & Destructor Documentation

FakeFlash::FakeFlash ( fhicl::ParameterSet const &  p)
explicit

Definition at line 89 of file FakeFlash_module.cc.

90  : EDProducer{p}
91  , fFlatEngine(art::ServiceHandle<rndm::NuRandomService>()->createEngine(*this, "HepJamesRandom", "Gen", p, "Seed"))
92  // More initializers here.
93 {
94  _verbose = p.get<bool>("Verbose",false); // If you want someone to talk to you
95  auto min_photons = p.get<int>("MinPhotons",24000); // Min of the range of photons to be injected in one shot
96  auto max_photons = p.get<int>("MaxPhotons",2400000); // Max of the range of photons to be injected in one shot
97  assert(min_photons < max_photons && min_photons>0 && max_photons>0);
98  _min_photons = min_photons;
99  _max_photons = max_photons;
100 
101  // scintillation params (yeah fine you can replace these w/ service)
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);
105 
106  // channel range to simulate
107  auto geop = lar::providerFrom<geo::Geometry>();
108  _ch_min = 0;
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);
113  // Given in micro-seconds as larsoft default time unit, but then we convert to ns to record as photon time
114  _fast_tau *= 1.e3;
115  _slow_tau *= 1.e3;
116  // TPC list + range
117  _tpc_v = p.get<std::vector<size_t> >("TPCList"); // The list of TPC in which flash can happen
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 );
127  // generation timing info
128  _frequency = p.get<double>("Frequency"); // The frequency of photon(s) injection
129  _duration = p.get<double>("Duration"); // The duration of photon(s) injection period
130  _tstart = p.get<double>("G4TStart"); // The start time of photon injection period
131  produces<std::vector<sim::SimPhotons> >();
132  produces<std::vector<simb::MCTruth> >();
134 
135  fFlatRandom = new CLHEP::RandFlat(fFlatEngine,0,1);
136  fExpoRandom = new CLHEP::RandExponential(fFlatEngine);
137  fPoisRandom = new CLHEP::RandPoisson(fFlatEngine);
138 }
CLHEP::HepRandomEngine & fFlatEngine
double _frequency
[MHz]
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
double _slow_tau
scintillation emission time constant for slow component
CLHEP::RandExponential * fExpoRandom
pdgs p
Definition: selectors.fcl:22
produces< sumdata::RunData, art::InRun >()
size_t _ch_max
channel range max to produce SimPhotons
CLHEP::RandFlat * fFlatRandom
double _fast_tau
scintillation emission time constant for fast component
bool _verbose
verbosity for debugging
double _zmin
0.0-1.0 the z-position range in fraction of a TPC volume
double _ymax
0.0-1.0 the y-position range in fraction of a TPC volume
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
double _xmax
0.0-1.0 the x-position range in fraction of a TPC volume
double _tstart
[ns]
size_t _ch_min
channel range min to produce SimPhotons
CLHEP::RandPoisson * fPoisRandom
double _duration
[us]
size_t _min_photons
[photons]
FakeFlash::FakeFlash ( FakeFlash const &  )
delete
FakeFlash::FakeFlash ( FakeFlash &&  )
delete

Member Function Documentation

void FakeFlash::beginRun ( art::Run &  run)
override

Definition at line 140 of file FakeFlash_module.cc.

141 {
142  // grab the geometry object to see what geometry we are using
143  art::ServiceHandle<geo::Geometry> geo;
144 
145  std::unique_ptr<sumdata::RunData> runData(new sumdata::RunData(geo->DetectorName()));
146 
147  run.put(std::move(runData));
148 
149  return;
150 }
void FakeFlash::FillSimPhotons ( std::vector< sim::SimPhotons > &  simph_v,
int  nphotons,
size_t  mother_trackid,
const TLorentzVector &  pos 
)
private

Definition at line 178 of file FakeFlash_module.cc.

182 {
183  art::ServiceHandle<phot::PhotonVisibilityService const> pvs;
184  double xyz[3];
185  xyz[0] = pos.X();
186  xyz[1] = pos.Y();
187  xyz[2] = pos.Z();
188  auto const& Visibilities = pvs->GetAllVisibilities(xyz);
189  // Now loop over optical channels and fill SimPhotons array
190  if(simph_v.empty()) {
191  for(size_t opch=_ch_min; opch<=_ch_max; ++opch)
192  simph_v.push_back(sim::SimPhotons(opch));
193  }
194  for(size_t opch=_ch_min; opch <= _ch_max; ++opch) {
195  // get visibility
196  size_t detected = fPoisRandom->fire((double)(nphotons) * Visibilities[opch]);
197  //std::cout<<opch<<","<<detected<<std::endl;
198  auto time_array = this->GenerateTime(detected);
199  assert(time_array.size() == detected);
200  // record
201  auto& simph = simph_v[opch];
202  for(size_t idx=0; idx<detected; ++idx) {
203  sim::OnePhoton phot;
204  phot.Time = pos.T() + time_array[idx];
205  phot.InitialPosition.SetX(pos.X());
206  phot.InitialPosition.SetY(pos.Y());
207  phot.InitialPosition.SetZ(pos.Z());
208  phot.MotherTrackID = mother_trackid;
209  simph.emplace_back(phot);
210  }
211  }
212 }
All information of a photon entering the sensitive optical detector volume.
Definition: SimPhotons.h:64
size_t _ch_max
channel range max to produce SimPhotons
std::vector< double > GenerateTime(size_t numphotons)
geo::Point_t InitialPosition
Scintillation position in world coordinates [cm].
Definition: SimPhotons.h:67
size_t _ch_min
channel range min to produce SimPhotons
CLHEP::RandPoisson * fPoisRandom
Collection of photons which recorded on one channel.
Definition: SimPhotons.h:136
int MotherTrackID
ID of the GEANT4 track causing the scintillation.
Definition: SimPhotons.h:85
std::vector< double > FakeFlash::GenerateTime ( size_t  numphotons)
private

Definition at line 214 of file FakeFlash_module.cc.

214  {
215 
216  std::vector<double> res(numphotons);
217  for(int i=0; i<((int)numphotons); ++i) {
218  if(fFlatRandom->fire(0.,1.) < _fast_frac)
219  res[i] = fExpoRandom->fire(_fast_tau);
220  else res[i] = fExpoRandom->fire(_slow_tau);
221  }
222  return res;
223 }
double _fast_frac
fraction of prompt light
double _slow_tau
scintillation emission time constant for slow component
CLHEP::RandExponential * fExpoRandom
CLHEP::RandFlat * fFlatRandom
double _fast_tau
scintillation emission time constant for fast component
void FakeFlash::GenPosition ( double &  x,
double &  y,
double &  z 
)
private

Definition at line 152 of file FakeFlash_module.cc.

152  {
153 
154  size_t tpc_id = (size_t)(fFlatRandom->fire(0,_tpc_v.size()));
155  bool found = false;
156  // Implementation of required member function here.
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;
169  x = fFlatRandom->fire(xmin,xmax);
170  y = fFlatRandom->fire(ymin,ymax);
171  z = fFlatRandom->fire(zmin,zmax);
172  found = true;
173  break;
174  }
175  if(!found) std::cerr<< "\033[93mTPC " << tpc_id << " not found...\033[00m" << std::endl;
176 }
process_name opflash particleana ie ie ie z
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.
process_name opflash particleana ie x
BEGIN_PROLOG could also be cerr
CLHEP::RandFlat * fFlatRandom
process_name pandoraGausCryo1 vertexChargeCryo1 vertexStubCryo1 xmin
double _zmin
0.0-1.0 the z-position range in fraction of a TPC volume
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
double _xmin
0.0-1.0 the x-position range in fraction of a TPC volume
double _xmax
0.0-1.0 the x-position range in fraction of a TPC volume
FakeFlash& FakeFlash::operator= ( FakeFlash const &  )
delete
FakeFlash& FakeFlash::operator= ( FakeFlash &&  )
delete
void FakeFlash::produce ( art::Event &  e)
override

Definition at line 225 of file FakeFlash_module.cc.

226 {
227 
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;
231  double clock = 0.;
232  while(clock <= _duration) {
233  // Determine photon count
234  int nphotons = _min_photons + (_max_photons - _min_photons) * (fFlatRandom->fire(0,1));
235 
236  // Generate position 4 vector
237  double time = _tstart + clock * 1.e3;
238  double x,y,z;
239  this->GenPosition(x,y,z);
240  TLorentzVector pos(x,y,z,time);
241 
242  // Fill SimPhotons
243  this->FillSimPhotons(*simph_v, (int)(mcp_v.size()), nphotons, pos);
244 
245  // Record a fake photon particle
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));
250 
251  // count time
252  clock += (1./_frequency);
253  }
254 
255  simb::MCTruth mct;
256  for(auto& part : mcp_v)
257  mct.Add(part);
258  mct_v->emplace_back(std::move(mct));
259 
260  e.put(std::move(simph_v));
261  e.put(std::move(mct_v));
262 }
process_name opflash particleana ie ie ie z
double _frequency
[MHz]
process_name opflash particleana ie x
CLHEP::RandFlat * fFlatRandom
process_name opflash particleana ie ie y
size_t _max_photons
[photons]
double _tstart
[ns]
void FillSimPhotons(std::vector< sim::SimPhotons > &simph_v, int nphotons, size_t mother_trackid, const TLorentzVector &pos)
double _duration
[us]
do i e
void GenPosition(double &x, double &y, double &z)
size_t _min_photons
[photons]

Member Data Documentation

size_t FakeFlash::_ch_max
private

channel range max to produce SimPhotons

Definition at line 75 of file FakeFlash_module.cc.

size_t FakeFlash::_ch_min
private

channel range min to produce SimPhotons

Definition at line 74 of file FakeFlash_module.cc.

double FakeFlash::_duration
private

[us]

Definition at line 66 of file FakeFlash_module.cc.

double FakeFlash::_fast_frac
private

fraction of prompt light

Definition at line 71 of file FakeFlash_module.cc.

double FakeFlash::_fast_tau
private

scintillation emission time constant for fast component

Definition at line 72 of file FakeFlash_module.cc.

double FakeFlash::_frequency
private

[MHz]

Definition at line 65 of file FakeFlash_module.cc.

size_t FakeFlash::_max_photons
private

[photons]

Definition at line 69 of file FakeFlash_module.cc.

size_t FakeFlash::_min_photons
private

[photons]

Definition at line 68 of file FakeFlash_module.cc.

double FakeFlash::_slow_tau
private

scintillation emission time constant for slow component

Definition at line 73 of file FakeFlash_module.cc.

std::vector<size_t> FakeFlash::_tpc_v
private

List of TPC ID to be used.

Definition at line 70 of file FakeFlash_module.cc.

double FakeFlash::_tstart
private

[ns]

Definition at line 67 of file FakeFlash_module.cc.

bool FakeFlash::_verbose
private

verbosity for debugging

Definition at line 64 of file FakeFlash_module.cc.

double FakeFlash::_xmax
private

0.0-1.0 the x-position range in fraction of a TPC volume

Definition at line 76 of file FakeFlash_module.cc.

double FakeFlash::_xmin
private

0.0-1.0 the x-position range in fraction of a TPC volume

Definition at line 79 of file FakeFlash_module.cc.

double FakeFlash::_ymax
private

0.0-1.0 the y-position range in fraction of a TPC volume

Definition at line 77 of file FakeFlash_module.cc.

double FakeFlash::_ymin
private

0.0-1.0 the y-position range in fraction of a TPC volume

Definition at line 80 of file FakeFlash_module.cc.

double FakeFlash::_zmax
private

0.0-1.0 the z-position range in fraction of a TPC volume

Definition at line 78 of file FakeFlash_module.cc.

double FakeFlash::_zmin
private

0.0-1.0 the z-position range in fraction of a TPC volume

Definition at line 81 of file FakeFlash_module.cc.

CLHEP::RandExponential* FakeFlash::fExpoRandom
private

Definition at line 84 of file FakeFlash_module.cc.

CLHEP::HepRandomEngine& FakeFlash::fFlatEngine
private

Definition at line 82 of file FakeFlash_module.cc.

CLHEP::RandFlat* FakeFlash::fFlatRandom
private

Definition at line 83 of file FakeFlash_module.cc.

CLHEP::RandPoisson* FakeFlash::fPoisRandom
private

Definition at line 85 of file FakeFlash_module.cc.


The documentation for this class was generated from the following file: