LArSoft  v07_13_02
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
 
bool fPointSource
 
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 188 of file LightSource_module.cc.

References art::EngineCreator::createEngine(), fCurrentVoxel, fDummyString, fEvID, fFileName, fFillTree, fFirstVoxel, fInputFile, fLastVoxel, fN, fP, fPDist, fPhotonsGenerated, fPointSource, 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().

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

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

313  {
314 
315  // grab the geometry object to see what geometry we are using
317  std::unique_ptr<sumdata::RunData> runcol(new sumdata::RunData(geo->DetectorName()));
318 
319  run.put(std::move(runcol));
320 
322 
323  return;
324  }
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 327 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().

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

References simb::MCTruth::Add(), simb::MCParticle::AddTrajectoryPoint(), DEFINE_ART_MODULE, fFillTree, fN, fP, fPDist, fPhotonsGenerated, fPointSource, 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().

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

Referenced by LightSource(), and produce().

int evgen::LightSource::fN
private

Definition at line 178 of file LightSource_module.cc.

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

double evgen::LightSource::fP
private

Definition at line 174 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().

bool evgen::LightSource::fPointSource
private

Definition at line 168 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 175 of file LightSource_module.cc.

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

double evgen::LightSource::fSigmaT
private

Definition at line 173 of file LightSource_module.cc.

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

double evgen::LightSource::fSigmaX
private

Definition at line 170 of file LightSource_module.cc.

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

double evgen::LightSource::fSigmaY
private

Definition at line 171 of file LightSource_module.cc.

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

double evgen::LightSource::fSigmaZ
private

Definition at line 172 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 169 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: