LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
evgen::LightSource Class Reference

A module for optical MC testing and library building. More...

Inheritance diagram for evgen::LightSource:
art::EDProducer art::ProducerBase art::Consumer art::EngineCreator art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = ProducerBase::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 LightSource (fhicl::ParameterSet const &pset)
 
void produce (art::Event &evt)
 
void beginRun (art::Run &run)
 
template<typename PROD , BranchType B = InEvent>
ProductID getProductID (std::string const &instanceName={}) const
 
template<typename PROD , BranchType B>
ProductID getProductID (ModuleDescription const &moduleDescription, std::string const &instanceName) const
 
bool modifiesEvent () const
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > consumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > consumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > mayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > mayConsumeView (InputTag const &it)
 
base_engine_tcreateEngine (seed_t seed)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make, label_t const &engine_label)
 
seed_t get_seed_value (fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Member Functions

CurrentProcessingContext const * currentContext () const
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Private Member Functions

void Sample (simb::MCTruth &truth)
 

Private Attributes

std::string fVersion
 
std::ifstream fInputFile
 
std::string fFileName
 
char fDummyString [256]
 
TTree * fPhotonsGenerated
 
TLorentzVector fShotPos
 
TLorentzVector fShotMom
 
Int_t fEvID
 
int fSourceMode
 
bool fFillTree
 
int fPosDist
 
int fTDist
 
int fPDist
 
int fXSteps
 
int fYSteps
 
int fZSteps
 
sim::PhotonVoxelDef fThePhotonVoxelDef
 
int fVoxelCount
 
int fCurrentVoxel
 
TVector3 fTPCCenter
 
TVector3 fTPCDimensions
 
std::vector< double > fRegionMin
 
std::vector< double > fRegionMax
 
bool fUseCustomRegion
 
double fX
 
double fY
 
double fZ
 
double fT
 
double fSigmaX
 
double fSigmaY
 
double fSigmaZ
 
double fSigmaT
 
double fP
 
double fSigmaP
 
int fN
 
int fFirstVoxel
 
int fLastVoxel
 

Static Private Attributes

static const int kUNIF = 0
 
static const int kGAUS = 1
 
static const int kFILE = 0
 
static const int kSCAN = 1
 

Detailed Description

A module for optical MC testing and library building.

Light source event generator which simulate an extended isotropic photon source.

The light source can be run in two modes, file mode or scan mode. Each requires the specification of a different set of parameters.

File mode

Light source position, intensity and shape are supplied on an event by event basis in a text file. See the example provided for the format. Pararmeters required:

int32   SourceMode = 0      - sets light source to file mode
string  FileName            - file of per event light source specifications
int32   PosDist             - how to distribute production points sampled in momentum, position
int32   PDist                   and time ranges specified.  For all of these :
int32   TDist                   0 = uniform and 1 = gauss
bool    FillTree            - whether to write a tree of photon production points to fileservice

Upon reaching the end of the file, the light source will loop back to the first point. hence a one line text file will give a constant light source size, position and intensity.

Scan mode

Divide volume into cuboidal regions and produce an isotropic light source in each, using one region per event. User can specify either to use the full detector volume or some custom specified volume.

This mode is used when building a fast photon sim library, and performing volume scan sensitivity studies.

int32   SourceMode = 1      - sets light source to scan mode
int32   N                   - number of photons to shoot from each point
double  P                   - peak photon momentum (or energy) in eV
double  SigmaP              - momentum distribution width
double  XSteps              - Number of regions to divide volume into in each direction 
double  YSteps
double  ZSteps
double  T0                  - Peak time of photon production
double  SigmaT              - time distribution width
int32   PosDist             - how to distribute production points sampled in momentum, position
int32   PDist                 and time ranges specified.  For all of these :
int32   TDist                   0 = uniform and 1 = gaussian
bool    FillTree            - whether to write a tree of photon production points to fileservice
bool    UseCustomRegion     - supply our own volme specification or use the full detector volume?
vdouble[3]  RegionMin       - bounding corners of the custom volume specification 
vdouble[3]  RegionMax           (only used if UseCustomRegion=true)

Definition at line 106 of file LightSource_module.cc.

Member Typedef Documentation

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::EDProducer::Table = ProducerBase::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 43 of file EDProducer.h.

using art::EDProducer::WorkerType = WorkerT<EDProducer>
inherited

Definition at line 35 of file EDProducer.h.

Constructor & Destructor Documentation

evgen::LightSource::LightSource ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 187 of file LightSource_module.cc.

References art::EngineCreator::createEngine(), fCurrentVoxel, fDummyString, fEvID, fFileName, fFillTree, fFirstVoxel, fInputFile, fLastVoxel, fN, fP, fPDist, fPhotonsGenerated, fPosDist, fRegionMax, fRegionMin, fShotMom, fShotPos, fSigmaP, fSigmaT, fSigmaX, fSigmaY, fSigmaZ, fSourceMode, fT, fTDist, fThePhotonVoxelDef, fUseCustomRegion, fVoxelCount, fXSteps, fYSteps, fZSteps, fhicl::ParameterSet::get(), sim::PhotonVoxelDef::GetNVoxels(), phot::PhotonVisibilityService::GetVoxelDef(), sim::PhotonVoxelDef::GetVoxelSize(), kFILE, kSCAN, and art::TFileDirectory::make().

188  {
189 
190  // get the random number seed, use a random default if not specified
191  // in the configuration file.
192 
193  fSourceMode = (pset.get<int >("SourceMode") );
194  fFillTree = (pset.get<bool>("FillTree") );
195  fPosDist = (pset.get<int >("PosDist") );
196  fPDist = (pset.get<int >("PDist") );
197  fTDist = (pset.get<int >("TDist") );
198 
199  // create a default random engine; obtain the random seed from NuRandomService,
200  // unless overridden in configuration with key "Seed"
202  ->createEngine(*this, pset, "Seed");
203 
204  // load optional parameters in function
205  produces< sumdata::RunData, art::InRun >();
206  produces< std::vector<simb::MCTruth> >();
207 
208  if(fSourceMode==kFILE)
209  {
210  fFileName = pset.get<std::string>("SteeringFile");
211  fInputFile.open(fFileName.c_str());
212  fInputFile.getline(fDummyString,256);
213 
214  }
215  else if (fSourceMode==kSCAN)
216  {
217  fT = pset.get<double>("T0");
218  fSigmaT = pset.get<double>("SigmaT");
219  fN = pset.get<int >("N");
220 
221  fFirstVoxel = pset.get<int >("FirstVoxel");
222  fLastVoxel = pset.get<int >("LastVoxel");
223 
224  fP = pset.get<double>("P");
225  fSigmaP = pset.get<double>("SigmaP");
226 
227  fUseCustomRegion = pset.get<bool>("UseCustomRegion");
228 
229  if(fUseCustomRegion)
230  {
231  fRegionMin = pset.get< std::vector<double> >("RegionMin");
232  fRegionMax = pset.get< std::vector<double> >("RegionMax");
233  fXSteps = pset.get<int >("XSteps");
234  fYSteps = pset.get<int >("YSteps");
235  fZSteps = pset.get<int >("ZSteps");
236  }
237 
239  // get TPC dimensions removed. -TA
240 
241 
242  fCurrentVoxel=0;
243 
244  // define voxelization based on parameters read from config.
245  // There are two modes - either read the dimensions of the TPC from
246  // the geometry, or use values specified by the user.
247  if(!fUseCustomRegion)
248  {
251  }
252  else
253  {
255  fRegionMax[0],
256  fXSteps,
257  fRegionMin[1],
258  fRegionMax[1],
259  fYSteps,
260  fRegionMin[2],
261  fRegionMax[2],
262  fZSteps);
263  }
264 
265 
266  // Set distribution widths to voxel size
267 
271 
272  // Get number of voxels we will step through
273 
275 
276  if(fLastVoxel<0) fLastVoxel = fVoxelCount;
277 
278  mf::LogVerbatim("LightSource") << "Light Source : Determining voxel params : "
279  << fVoxelCount << " "
280  << fSigmaX << " "
281  << fSigmaY << " "
282  <<fSigmaZ;
283 
284  }
285  else{
286  throw cet::exception("LightSource") << "EVGEN Light Source : Unrecognised light source mode\n";
287  }
288 
289 
290 
291 
292  if(fFillTree)
293  {
295  fPhotonsGenerated = tfs->make<TTree>("PhotonsGenerated","PhotonsGenerated");
296  fPhotonsGenerated->Branch("X",&(fShotPos[0]),"X/D");
297  fPhotonsGenerated->Branch("Y",&(fShotPos[1]),"Y/D");
298  fPhotonsGenerated->Branch("Z",&(fShotPos[2]),"Z/D");
299  fPhotonsGenerated->Branch("T",&(fShotPos[3]),"T/D");
300  fPhotonsGenerated->Branch("PX",&(fShotMom[0]),"PX/D");
301  fPhotonsGenerated->Branch("PY",&(fShotMom[1]),"PY/D");
302  fPhotonsGenerated->Branch("PZ",&(fShotMom[2]),"PZ/D");
303  fPhotonsGenerated->Branch("PT",&(fShotMom[3]),"PT/D");
304  fPhotonsGenerated->Branch("EventID",&fEvID,"EventID/I");
305  }
306  }
std::vector< double > fRegionMin
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
static const int kSCAN
std::vector< double > fRegionMax
int GetNVoxels() const
base_engine_t & createEngine(seed_t seed)
TVector3 GetVoxelSize() const
sim::PhotonVoxelDef fThePhotonVoxelDef
const sim::PhotonVoxelDef & GetVoxelDef() const
T * make(ARGS...args) const
static const int kFILE
Namespace collecting geometry-related classes utilities.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33

Member Function Documentation

void evgen::LightSource::beginRun ( art::Run run)
virtual

Reimplemented from art::EDProducer.

Definition at line 310 of file LightSource_module.cc.

References geo::GeometryCore::DetectorName(), fCurrentVoxel, fFirstVoxel, and art::Run::put().

311  {
312 
313  // grab the geometry object to see what geometry we are using
315  std::unique_ptr<sumdata::RunData> runcol(new sumdata::RunData(geo->DetectorName()));
316 
317  run.put(std::move(runcol));
318 
320 
321  return;
322  }
art::ProductID put(std::unique_ptr< PROD > &&)
Definition: Run.h:148
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
Namespace collecting geometry-related classes utilities.
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 147 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

148 {
149  if (!moduleContext_)
150  return ProductToken<T>::invalid();
151 
152  consumables_[BT].emplace_back(ConsumableType::Product,
153  TypeID{typeid(T)},
154  it.label(),
155  it.instance(),
156  it.process());
157  return ProductToken<T>{it};
158 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 162 of file Consumer.h.

163 {
164  if (!moduleContext_)
165  return;
166 
167  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
168 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 172 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

173 {
174  if (!moduleContext_)
175  return ViewToken<T>::invalid();
176 
177  consumables_[BT].emplace_back(ConsumableType::ViewElement,
178  TypeID{typeid(T)},
179  it.label(),
180  it.instance(),
181  it.process());
182  return ViewToken<T>{it};
183 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited

Definition at line 32 of file EngineCreator.cc.

References art::EngineCreator::rng().

34 {
35  return rng()->createEngine(
36  placeholder_schedule_id(), seed, kind_of_engine_to_make);
37 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited

Definition at line 40 of file EngineCreator.cc.

References art::EngineCreator::rng().

43 {
44  return rng()->createEngine(
45  placeholder_schedule_id(), seed, kind_of_engine_to_make, engine_label);
46 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
CurrentProcessingContext const * art::EDProducer::currentContext ( ) const
protectedinherited

Definition at line 120 of file EDProducer.cc.

References art::EDProducer::current_context_.

121  {
122  return current_context_.get();
123  }
CPC_exempt_ptr current_context_
Definition: EDProducer.h:116
EngineCreator::seed_t EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited

Definition at line 49 of file EngineCreator.cc.

References fhicl::ParameterSet::get().

Referenced by art::MixFilter< T >::initEngine_().

52 {
53  auto const& explicit_seeds = pset.get<std::vector<int>>(key, {});
54  return explicit_seeds.empty() ? implicit_seed : explicit_seeds.front();
55 }
template<typename PROD , BranchType B>
ProductID art::EDProducer::getProductID ( std::string const &  instanceName = {}) const
inlineinherited

Definition at line 123 of file EDProducer.h.

References art::EDProducer::moduleDescription_.

124  {
125  return ProducerBase::getProductID<PROD, B>(moduleDescription_,
126  instanceName);
127  }
ModuleDescription moduleDescription_
Definition: EDProducer.h:115
template<typename PROD , BranchType B>
ProductID art::ProducerBase::getProductID ( ModuleDescription const &  moduleDescription,
std::string const &  instanceName 
) const
inherited

Definition at line 56 of file ProducerBase.h.

References B, and art::ModuleDescription::moduleLabel().

Referenced by art::ProducerBase::modifiesEvent().

58  {
59  auto const& pd =
60  get_ProductDescription<PROD>(B, md.moduleLabel(), instanceName);
61  return pd.productID();
62  }
Int_t B
Definition: plot.C:25
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 190 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

191 {
192  if (!moduleContext_)
193  return ProductToken<T>::invalid();
194 
195  consumables_[BT].emplace_back(ConsumableType::Product,
196  TypeID{typeid(T)},
197  it.label(),
198  it.instance(),
199  it.process());
200  return ProductToken<T>{it};
201 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 205 of file Consumer.h.

206 {
207  if (!moduleContext_)
208  return;
209 
210  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
211 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 215 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

216 {
217  if (!moduleContext_)
218  return ViewToken<T>::invalid();
219 
220  consumables_[BT].emplace_back(ConsumableType::ViewElement,
221  TypeID{typeid(T)},
222  it.label(),
223  it.instance(),
224  it.process());
225  return ViewToken<T>{it};
226 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
bool art::ProducerBase::modifiesEvent ( ) const
inlineinherited

Definition at line 40 of file ProducerBase.h.

References art::ProducerBase::getProductID().

41  {
42  return true;
43  }
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited

Definition at line 89 of file Consumer.cc.

References fhicl::ParameterSet::get_if_present().

Referenced by art::EDProducer::doBeginJob(), art::EDFilter::doBeginJob(), and art::EDAnalyzer::doBeginJob().

90 {
91  if (!moduleContext_)
92  return;
93 
94  pset.get_if_present("errorOnMissingConsumes", requireConsumes_);
95  for (auto& consumablesPerBranch : consumables_) {
96  cet::sort_all(consumablesPerBranch);
97  }
98 }
bool requireConsumes_
Definition: Consumer.h:137
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
void evgen::LightSource::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 325 of file LightSource_module.cc.

References e, fCurrentVoxel, fDummyString, fFileName, fFirstVoxel, fInputFile, fLastVoxel, fN, fP, fSigmaP, fSigmaT, fSigmaX, fSigmaY, fSigmaZ, fSourceMode, fT, fThePhotonVoxelDef, fX, fY, fZ, sim::PhotonVoxel::GetCenter(), sim::PhotonVoxelDef::GetPhotonVoxel(), phot::PhotonVisibilityService::IsBuildJob(), kFILE, kSCAN, simb::kSingleParticle, art::Event::put(), Sample(), art::errors::ServiceNotFound, simb::MCTruth::SetOrigin(), and phot::PhotonVisibilityService::StoreLightProd().

326  {
327 
328  // FILE MODE -
329  // Each event, read coordinates of gun and number of photons to shoot from file
330 
331  if(fSourceMode==kFILE)
332  {
333  // Loop file if required
334  if(fInputFile.eof()){
335  mf::LogWarning("LightSource") << "EVGEN Light Source : Warning, reached end of file,"
336  << " looping back to beginning";
337  fInputFile.seekg(0,std::ios::beg);
338  fInputFile.clear();
339  }
340 
341  if(!fInputFile.is_open() || fInputFile.fail() ){
342  throw cet::exception("LightSource") << "EVGEN Light Source : File error in "
343  << fFileName << "\n";
344  }
345  else{
346  // read in one line
347  fInputFile >> fX >> fY >> fZ >> fT
348  >> fSigmaX >> fSigmaY >> fSigmaZ >> fSigmaT
349  >> fP >> fSigmaP >> fN;
350  fInputFile.getline(fDummyString,256);
352  fX + fSigmaX,
353  1,
354  fY - fSigmaY,
355  fY + fSigmaY,
356  1,
357  fZ - fSigmaZ,
358  fZ + fSigmaZ,
359  1);
360 
361  fCurrentVoxel=0;
362  }
363  }
364 
365 
366  // SCAN MODE -
367  // Step through detector using a number of steps provided in the config file
368  // firing a constant number of photons from each point
369  else if(fSourceMode==kSCAN)
370  {
371 
372 
373  TVector3 VoxelCenter = fThePhotonVoxelDef.GetPhotonVoxel(fCurrentVoxel).GetCenter();
374 
375  fX = VoxelCenter.X();
376  fY = VoxelCenter.Y();
377  fZ = VoxelCenter.Z();
378 
379  }
380 
381 
382  // UNRECOGNISED MODE
383  // - neither file or scan mode, probably a config file error
384 
385  else{
386  throw cet::exception("LightSource") <<"EVGEN : Light Source, unrecognised source mode\n";
387  }
388 
389 
390 
391  // std::cout<<"EVGEN Light source to be placed at (x, y, z, t, dx, dy, dz, dt, n) " <<
392  // fX << " " << fY << " " <<fZ << " " << fT << " " <<
393  // fSigmaX << " " << fSigmaY << " " << fSigmaZ << " " << fSigmaT << " " <<
394  // fN << std::endl<<std::endl;
395 
396 
397  std::unique_ptr< std::vector<simb::MCTruth> > truthcol(new std::vector<simb::MCTruth>);
398 
399  simb::MCTruth truth;
401  Sample(truth);
402 
403  // std::cout << "put mctruth into the vector" << std::endl;
404  truthcol->push_back(truth);
405 
406  // std::cout << "add vector to the event " << truthcol->size() << std::endl;
407  evt.put(std::move(truthcol));
408 
409  phot::PhotonVisibilityService* vis = nullptr;
410  try {
412  }
413  catch (art::Exception const& e) {
414  // if the service is not configured, then this is not a build job
415  // (it is a simple generation job instead)
416  if (e.categoryCode() != art::errors::ServiceNotFound) throw;
417  }
418 
419  if(vis && vis->IsBuildJob())
420  {
421  mf::LogVerbatim("LightSource") << "Light source : Stowing voxel params ";
423  }
424 
426  {
427  ++fCurrentVoxel;
428  }
429  else
430  {
431  mf::LogVerbatim("LightSource") << "EVGEN Light Source fully scanned detector. Starting over.";
433  }
434 
435  return;
436 
437 
438  }
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
void SetOrigin(simb::Origin_t origin)
Definition: MCTruth.h:78
static const int kSCAN
TVector3 GetCenter() const
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
single particles thrown at the detector
Definition: MCTruth.h:24
sim::PhotonVoxelDef fThePhotonVoxelDef
void Sample(simb::MCTruth &truth)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
static const int kFILE
Event generator information.
Definition: MCTruth.h:30
Float_t e
Definition: plot.C:34
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
PhotonVoxel GetPhotonVoxel(int ID) const
void evgen::LightSource::Sample ( simb::MCTruth truth)
private

Definition at line 441 of file LightSource_module.cc.

References simb::MCTruth::Add(), simb::MCParticle::AddTrajectoryPoint(), DEFINE_ART_MODULE, fFillTree, fN, fP, fPDist, fPhotonsGenerated, fPosDist, fShotMom, fShotPos, fSigmaP, fSigmaT, fSigmaX, fSigmaY, fSigmaZ, fT, fTDist, fX, fY, fZ, art::RandomNumberGenerator::getEngine(), kGAUS, part, art::EngineCreator::rng(), and x.

Referenced by produce().

442  {
443  mf::LogVerbatim("LightSource") <<"Light source debug : Shooting at " << fX <<" " << fY<<" "<< fZ;
444 
445  // get the random number generator service and make some CLHEP generators
447  CLHEP::HepRandomEngine &engine = rng->getEngine();
448  CLHEP::RandFlat flat(engine);
449  CLHEP::RandGaussQ gauss(engine);
450 
451  for(int j=0; j!=fN; ++j){
452  // Choose momentum (supplied in eV, convert to GeV)
453  double p = fP;
454  if (fPDist == kGAUS) {
455  p = gauss.fire(fP, fSigmaP);
456  }
457  else {
458  p = fP + fSigmaP*(2.0*flat.fire()-1.0);
459  }
460  p /= 1000000000.;
461 
462  // Choose position
463  TVector3 x;
464  if (fPosDist == kGAUS) {
465  x[0] = gauss.fire(fX, fSigmaX);
466  x[1] = gauss.fire(fY, fSigmaY);
467  x[2] = gauss.fire(fZ, fSigmaZ);
468  }
469  else {
470  x[0] = fX + fSigmaX*(2.0*flat.fire()-1.0);
471  x[1] = fY + fSigmaY*(2.0*flat.fire()-1.0);
472  x[2] = fZ + fSigmaZ*(2.0*flat.fire()-1.0);
473  }
474 
475  // Choose time
476  double t;
477  if (fTDist == kGAUS) {
478  t = gauss.fire(fT, fSigmaT);
479  }
480  else {
481  t = fT + fSigmaT * (2.0 * flat.fire()-1.0);
482  }
483 
484 
485  //assume the position is relative to the center of the TPC
486  //x += fTPCCenter;
487 
488  fShotPos = TLorentzVector(x[0], x[1], x[2], t);
489 
490 
491  // Choose angles
492  double costh = 2 * flat.fire() - 1;
493  double sinth = pow(1-pow(costh,2),0.5);
494  double phi = 2 * M_PI * flat.fire();
495 
496  // Generate momentum 4-vector
497 
498  fShotMom = TLorentzVector( p*sinth*cos(phi),
499  p*sinth*sin(phi),
500  p*costh,
501  p );
502 
503  int trackid = -1*(j+1); // set track id to -i as these are all primary particles and have id <= 0
504  std::string primary("primary");
505  int PDG=0; //optical photons have PDG 0
506 
507  simb::MCParticle part(trackid, PDG, primary);
508  part.AddTrajectoryPoint(fShotPos, fShotMom);
509 
510  if(fFillTree)
511  fPhotonsGenerated->Fill();
512 
513  mct.Add(part);
514  }
515 
516  }
Float_t x
Definition: compare.C:6
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
static const int kGAUS
base_engine_t & getEngine() const
TString part[npart]
Definition: Style.C:32
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Definition at line 125 of file Consumer.cc.

Referenced by art::EDProducer::doEndJob(), art::EDFilter::doEndJob(), art::EDAnalyzer::doEndJob(), and art::RootOutput::endJob().

126 {
127  if (!moduleContext_)
128  return;
129 
130  // If none of the branches have missing consumes statements, exit early.
131  if (std::all_of(cbegin(missingConsumes_),
132  cend(missingConsumes_),
133  [](auto const& perBranch) { return perBranch.empty(); }))
134  return;
135 
136  constexpr cet::HorizontalRule rule{60};
137  mf::LogPrint log{"MTdiagnostics"};
138  log << '\n'
139  << rule('=') << '\n'
140  << "The following consumes (or mayConsume) statements are missing from\n"
141  << module_context(moduleDescription_) << '\n'
142  << rule('-') << '\n';
143 
144  cet::for_all_with_index(
145  missingConsumes_, [&log](std::size_t const i, auto const& perBranch) {
146  for (auto const& pi : perBranch) {
147  log << " "
148  << assemble_consumes_statement(static_cast<BranchType>(i), pi)
149  << '\n';
150  }
151  });
152  log << rule('=');
153 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139
void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Definition at line 101 of file Consumer.cc.

References art::errors::ProductRegistrationFailure.

103 {
104  // Early exits if consumes tracking has been disabled or if the
105  // consumed product is an allowed consumable.
106  if (!moduleContext_)
107  return;
108 
109  if (cet::binary_search_all(consumables_[bt], pi))
110  return;
111 
112  if (requireConsumes_) {
114  "Consumer: an error occurred during validation of a "
115  "retrieved product\n\n")
116  << "The following consumes (or mayConsume) statement is missing from\n"
117  << module_context(moduleDescription_) << ":\n\n"
118  << " " << assemble_consumes_statement(bt, pi) << "\n\n";
119  }
120 
121  missingConsumes_[bt].insert(pi);
122 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
bool requireConsumes_
Definition: Consumer.h:137
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139

Member Data Documentation

int evgen::LightSource::fCurrentVoxel
private

Definition at line 153 of file LightSource_module.cc.

Referenced by beginRun(), LightSource(), and produce().

char evgen::LightSource::fDummyString[256]
private

Definition at line 130 of file LightSource_module.cc.

Referenced by LightSource(), and produce().

Int_t evgen::LightSource::fEvID
private

Definition at line 136 of file LightSource_module.cc.

Referenced by LightSource().

std::string evgen::LightSource::fFileName
private

Definition at line 129 of file LightSource_module.cc.

Referenced by LightSource(), and produce().

bool evgen::LightSource::fFillTree
private

Definition at line 140 of file LightSource_module.cc.

Referenced by LightSource(), and Sample().

int evgen::LightSource::fFirstVoxel
private

Definition at line 179 of file LightSource_module.cc.

Referenced by beginRun(), LightSource(), and produce().

std::ifstream evgen::LightSource::fInputFile
private

Definition at line 128 of file LightSource_module.cc.

Referenced by LightSource(), and produce().

int evgen::LightSource::fLastVoxel
private

Definition at line 180 of file LightSource_module.cc.

Referenced by LightSource(), and produce().

int evgen::LightSource::fN
private

Definition at line 177 of file LightSource_module.cc.

Referenced by LightSource(), produce(), and Sample().

double evgen::LightSource::fP
private

Definition at line 173 of file LightSource_module.cc.

Referenced by LightSource(), produce(), and Sample().

int evgen::LightSource::fPDist
private

Definition at line 143 of file LightSource_module.cc.

Referenced by LightSource(), and Sample().

TTree* evgen::LightSource::fPhotonsGenerated
private

Definition at line 133 of file LightSource_module.cc.

Referenced by LightSource(), and Sample().

int evgen::LightSource::fPosDist
private

Definition at line 141 of file LightSource_module.cc.

Referenced by LightSource(), and Sample().

std::vector<double> evgen::LightSource::fRegionMax
private

Definition at line 160 of file LightSource_module.cc.

Referenced by LightSource().

std::vector<double> evgen::LightSource::fRegionMin
private

Definition at line 159 of file LightSource_module.cc.

Referenced by LightSource().

TLorentzVector evgen::LightSource::fShotMom
private

Definition at line 135 of file LightSource_module.cc.

Referenced by LightSource(), and Sample().

TLorentzVector evgen::LightSource::fShotPos
private

Definition at line 134 of file LightSource_module.cc.

Referenced by LightSource(), and Sample().

double evgen::LightSource::fSigmaP
private

Definition at line 174 of file LightSource_module.cc.

Referenced by LightSource(), produce(), and Sample().

double evgen::LightSource::fSigmaT
private

Definition at line 172 of file LightSource_module.cc.

Referenced by LightSource(), produce(), and Sample().

double evgen::LightSource::fSigmaX
private

Definition at line 169 of file LightSource_module.cc.

Referenced by LightSource(), produce(), and Sample().

double evgen::LightSource::fSigmaY
private

Definition at line 170 of file LightSource_module.cc.

Referenced by LightSource(), produce(), and Sample().

double evgen::LightSource::fSigmaZ
private

Definition at line 171 of file LightSource_module.cc.

Referenced by LightSource(), produce(), and Sample().

int evgen::LightSource::fSourceMode
private

Definition at line 139 of file LightSource_module.cc.

Referenced by LightSource(), and produce().

double evgen::LightSource::fT
private

Definition at line 168 of file LightSource_module.cc.

Referenced by LightSource(), produce(), and Sample().

int evgen::LightSource::fTDist
private

Definition at line 142 of file LightSource_module.cc.

Referenced by LightSource(), and Sample().

sim::PhotonVoxelDef evgen::LightSource::fThePhotonVoxelDef
private

Definition at line 150 of file LightSource_module.cc.

Referenced by LightSource(), and produce().

TVector3 evgen::LightSource::fTPCCenter
private

Definition at line 157 of file LightSource_module.cc.

TVector3 evgen::LightSource::fTPCDimensions
private

Definition at line 158 of file LightSource_module.cc.

bool evgen::LightSource::fUseCustomRegion
private

Definition at line 161 of file LightSource_module.cc.

Referenced by LightSource().

std::string evgen::LightSource::fVersion
private

Definition at line 119 of file LightSource_module.cc.

int evgen::LightSource::fVoxelCount
private

Definition at line 152 of file LightSource_module.cc.

Referenced by LightSource().

double evgen::LightSource::fX
private

Definition at line 165 of file LightSource_module.cc.

Referenced by produce(), and Sample().

int evgen::LightSource::fXSteps
private

Definition at line 146 of file LightSource_module.cc.

Referenced by LightSource().

double evgen::LightSource::fY
private

Definition at line 166 of file LightSource_module.cc.

Referenced by produce(), and Sample().

int evgen::LightSource::fYSteps
private

Definition at line 147 of file LightSource_module.cc.

Referenced by LightSource().

double evgen::LightSource::fZ
private

Definition at line 167 of file LightSource_module.cc.

Referenced by produce(), and Sample().

int evgen::LightSource::fZSteps
private

Definition at line 148 of file LightSource_module.cc.

Referenced by LightSource().

const int evgen::LightSource::kFILE = 0
staticprivate

Definition at line 124 of file LightSource_module.cc.

Referenced by LightSource(), and produce().

const int evgen::LightSource::kGAUS = 1
staticprivate

Definition at line 123 of file LightSource_module.cc.

Referenced by Sample().

const int evgen::LightSource::kSCAN = 1
staticprivate

Definition at line 125 of file LightSource_module.cc.

Referenced by LightSource(), and produce().

const int evgen::LightSource::kUNIF = 0
staticprivate

Definition at line 122 of file LightSource_module.cc.


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