LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
larg4::LArG4 Class Reference

Runs Geant4 simulation and propagation of electrons and photons to readout. More...

Inheritance diagram for larg4::LArG4:
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

 LArG4 (fhicl::ParameterSet const &pset)
 Standard constructor and destructor for an FMWK module. More...
 
virtual ~LArG4 ()
 
void produce (art::Event &evt)
 
void beginJob ()
 
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

std::unique_ptr< PositionInVolumeFilterCreateParticleVolumeFilter (std::set< std::string > const &vol_names) const
 Configures and returns a particle filter. More...
 

Private Attributes

g4b::G4HelperfG4Help
 G4 interface object. More...
 
larg4::LArVoxelListAction * flarVoxelListAction
 Geant4 user action to accumulate LAr voxel information. More...
 
larg4::ParticleListActionfparticleListAction
 Geant4 user action to particle information. More...
 
std::string fG4PhysListName
 predefined physics list to use if not making a custom one More...
 
std::string fG4MacroPath
 
bool fCheckOverlaps
 Whether to use the G4 overlap checker. More...
 
bool fdumpParticleList
 Whether each event's sim::ParticleList will be displayed. More...
 
bool fdumpSimChannels
 Whether each event's sim::Channel will be displayed. More...
 
bool fUseLitePhotons
 
int fSmartStacking
 Whether to instantiate and use class to. More...
 
double fOffPlaneMargin = 0.
 dictate how tracks are put on stack. More...
 
std::vector< std::string > fInputLabels
 
std::vector< std::string > fKeepParticlesInVolumes
 Only write particles that have trajectories through these volumes. More...
 
bool fSparsifyTrajectories
 Sparsify MCParticle Trajectories. More...
 

Detailed Description

Runs Geant4 simulation and propagation of electrons and photons to readout.

This module collects generated particles from one or more generators and processes them through Geant4.

Input

The module reads the particles to process from simb::MCTruth records. Each particle generator is required to produce a vector of such records: std::vector<simb::MCTruth>.

The module allows two operation modes:

  1. process specific generators: the label of the generator modules to be processed is specified explicitly in LArG4 configuration
  2. process all truth information generated so far: no generator is specified in the LArG4 module configuration, and the module will process all data products of type std::vector<simb::MCTruth>, in a non-specified order

For each simb::MCTruth, a Geant4 run is started. The interface with Geant4 is via a helper class provided by nutools. Only the particles in the truth record which have status code (simb::MCParticle::StatusCode()) equal to 1 are processed. These particles are called, in LArG4 jargon, primaries.

Output

The LArG4 module produces:

  • a collection of sim::SimChannel: each sim::SimChannel represents the set of energy depositions in liquid argon which drifted and were observed on a certain channel; it includes physics effects like attenuation, diffusion, electric field distortion, etc. Information of the generating Geant4 "track" is retained;
  • a collection of sim::SimPhotons or sim::SimPhotonsLite: each sim::SimPhotons represents the set of individual photons reaching a channel of the optical detector; it includes physics effects as well as quantum efficiency of the detector (to reduce data size early in the process); sim::SimPhotonsLite drops the information of the single photons and stores only collective information (e.g. their number).
  • a collection of sim::OpDetBacktrackerRecord (to be documented)
  • a collection of sim::AuxDetSimChannel (to be documented)
  • a collection of simb::MCParticle: the particles generated in the interaction of the primary particles with the material in the world are stored, but minor filtering by geometry and by physics is possible. An association of them with the originating simb::MCTruth object is also produced.

Notes on the conventions

  • all and the particles in the truth record (simb::MCTruth) which have status code (simb::MCParticle::StatusCode()) equal to 1 are passed to Geant4. These particles are called, in LArG4 jargon, primaries. The interface with Geant4 is via a helper class provided by nutools.
  • normally, information about each particle that Geant4 propagates (which Geant4 calls tracks), primary or not, is saved as an individual simb::MCParticle object into the output particle list. Each simb::MCParticle includes a Geant4-like track ID which is also recorded into each sim::IDE deposited by that particle. This information can be used to track all the deposition from a particle, or to backtrack the particle responsible of a deposition (but see below...). Note that the stored track ID may be different than the one Geant4 used (and, in particular, it's guaranteed to be unique within a sim::LArG4 instance output).
  • there are options (some set in sim::LArG4Parameters service) which allow for Geant4 tracks not to be saved as simb::MCParticle (e.g. ParticleKineticEnergyCut, KeepEMShowerDaughters). When these particles have deposited energy, their sim::IDE will report the ID of the first parent Geant4 track which is saved in the simb::MCParticle list, but with its sign flipped. Therefore, when tracking or backtracking (see above), comparisons should be performed using the absolute value of the sim::IDE (e.g. std::abs(ide.trackID)).

Timing

The LArG4 module produces sim::SimChannel objects from generated simb::MCParticle. Each particle ("primary") is assigned the time taken from its vertex (a 4-vector), which is expected to be represented in nanoseconds. The sim::SimChannel object is a collection of sim::IDE in time. The position in the sim::IDE is the location where some ionization occurred. The time associated to a sim::IDE is stored in tick units. The time it represents is the time when the ionization happened, which is the time of the primary particle plus the propagation time to the ionization location, plus the drift time, which the ionized electrons take to reach the anode wire. This time is then shifted to the frame of the electronics time via detinfo::DetectorClocks::G4ToElecTime(), which adds a configurable time offset. The time is converted into ticks via detinfo::DetectorClocks::TPCClock(), and this is the final value associated to the sim::IDE. For a more complete overview, see https://cdcvs.fnal.gov/redmine/projects/larsoft/wiki/Simulation#Simulation-Timing

Randomness

The random number generators used by this process are:

  • 'GEANT' instance: used by Geant4
  • 'propagation' instance: used in electron propagation

Configuration parameters

  • G4PhysListName (string, default: "larg4::PhysicsList"): whether to use the G4 overlap checker, which catches different issues than ROOT
  • CheckOverlaps (bool, default: false): whether to use the G4 overlap checker
  • DumpParticleList (bool, default: false): whether to print all MCParticles tracked
  • DumpSimChannels (bool, default: false): whether to print all depositions on each SimChannel
  • SmartStacking (int, default: 0): whether to use class to dictate how tracks are put on stack (nonzero is on)
  • KeepParticlesInVolumes (list of strings, default: empty): list of volumes in which to keep simb::MCParticle objects (empty keeps all)
  • GeantCommandFile (string, required): G4 macro file to pass to G4Helper for setting G4 command
  • Seed (integer, not defined by default): if defined, override the seed for random number generator used in Geant4 simulation (which is obtained from NuRandomService by default)
  • PropagationSeed (integer, not defined by default): if defined, override the seed for the random generator used for electrons propagation to the wire planes (obtained from the NuRandomService by default)
  • InputLabels (list of strings, default: process all truth): optional list of generator labels whose produced simb::MCTruth will be simulated; if not specified, all simb::MCTruth vector data products are simulated
  • ChargeRecoveryMargin (double, default: 0): sets the maximum distance from a plane for the wire charge recovery to occur, in centimeters; for details on how it works, see larg4::LArVoxelReadout::SetOffPlaneChargeRecoveryMargin(). A value of 0 effectively disables this feature. All TPCs will have the same margin applied.

Simulation details

Reflectivity to optical photons

Two models are supported for the simulation of (scintillation) light crossing detector surfaces:

  1. the standard one from GEANT4, implemented in G4OpBoundaryProcess
  2. a simplified one, implemented in larg4::OpBoundaryProcessSimple

The model is chosen according to the value of detinfo::DetectorProperties::SimpleBoundary(), and the choice is currently exerted by larg4::OpticalPhysics.

The simplified model is faster and simpler: it only deals with absorption and reflection (both specular and diffues). This is the "default" model used in most contexts.

GEANT4 model is more complete and slower. It may take some art to fully configure all the properties of the materials at the sides of the surfaces. The price is a detailed simulation that includes among others refraction and wavelength shifting.

Definition at line 296 of file LArG4_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

larg4::LArG4::LArG4 ( fhicl::ParameterSet const &  pset)
explicit

Standard constructor and destructor for an FMWK module.

Definition at line 342 of file LArG4_module.cc.

References art::errors::Configuration, art::EngineCreator::createEngine(), fG4MacroPath, sim::LArG4Parameters::FillSimEnergyDeposits(), fInputLabels, fSparsifyTrajectories, fUseLitePhotons, LOG_DEBUG, sim::LArG4Parameters::NoElectronPropagation(), sim::LArG4Parameters::NoPhotonPropagation(), art::ProductRegistryHelper::produces(), art::EngineCreator::rng(), and sim::LArG4Parameters::UseLitePhotons().

343  : fG4Help (0)
344  , flarVoxelListAction (0)
345  , fparticleListAction (0)
346  , fG4PhysListName (pset.get< std::string >("G4PhysListName","larg4::PhysicsList"))
347  , fCheckOverlaps (pset.get< bool >("CheckOverlaps",false) )
348  , fdumpParticleList (pset.get< bool >("DumpParticleList",false) )
349  , fdumpSimChannels (pset.get< bool >("DumpSimChannels", false) )
350  , fSmartStacking (pset.get< int >("SmartStacking",0) )
351  , fOffPlaneMargin (pset.get< double >("ChargeRecoveryMargin",0.0) )
352  , fKeepParticlesInVolumes (pset.get< std::vector< std::string > >("KeepParticlesInVolumes",{}))
353  , fSparsifyTrajectories (pset.get< bool >("SparsifyTrajectories",false) )
354 
355  {
356  LOG_DEBUG("LArG4") << "Debug: LArG4()";
358 
359  if (pset.has_key("Seed")) {
361  << "The configuration of LArG4 module has the discontinued 'Seed' parameter.\n"
362  "Seeds are now controlled by two parameters: 'GEANTSeed' and 'PropagationSeed'.";
363  }
364  // setup the random number service for Geant4, the "G4Engine" label is a
365  // special tag setting up a global engine for use by Geant4/CLHEP;
366  // obtain the random seed from NuRandomService,
367  // unless overridden in configuration with key "Seed" or "GEANTSeed"
369  ->createEngine(*this, "G4Engine", "GEANT", pset, "GEANTSeed");
370  // same thing for the propagation engine:
372  ->createEngine(*this, "HepJamesRandom", "propagation", pset, "PropagationSeed");
373 
374  //get a list of generators to use, otherwise, we'll end up looking for anything that's
375  //made an MCTruth object
376  bool useInputLabels = pset.get_if_present< std::vector<std::string> >("InputLabels",fInputLabels);
377  if(!useInputLabels) fInputLabels.resize(0);
378 
380 
382  if(!lgp->NoPhotonPropagation()){
383  if(!fUseLitePhotons) produces< std::vector<sim::SimPhotons> >();
384  else{
385  produces< std::vector<sim::SimPhotonsLite> >();
386  produces< std::vector<sim::OpDetBacktrackerRecord> >();
387  }
388  }
389 
390  if(lgp->FillSimEnergyDeposits()){
391  produces < std::vector<sim::SimEnergyDeposit> >("TPCActive");
392  produces < std::vector<sim::SimEnergyDeposit> >("Other");
393  }
394 
395  produces< std::vector<simb::MCParticle> >();
396  if(!lgp->NoElectronPropagation()) produces< std::vector<sim::SimChannel> >();
397  produces< std::vector<sim::AuxDetSimChannel> >();
398  produces< art::Assns<simb::MCTruth, simb::MCParticle, sim::GeneratedParticleInfo> >();
399 
400  // constructor decides if initialized value is a path or an environment variable
401  cet::search_path sp("FW_SEARCH_PATH");
402 
403  sp.find_file(pset.get< std::string >("GeantCommandFile"), fG4MacroPath);
404  struct stat sb;
405  if (fG4MacroPath.empty() || stat(fG4MacroPath.c_str(), &sb)!=0)
406  // failed to resolve the file name
407  throw cet::exception("NoG4Macro") << "G4 macro file "
408  << fG4MacroPath
409  << " not found!\n";
410 
411  }
std::vector< std::string > fInputLabels
std::string fG4MacroPath
void produces(std::string const &instanceName={}, Persistable const persistable=Persistable::Yes)
larg4::LArVoxelListAction * flarVoxelListAction
Geant4 user action to accumulate LAr voxel information.
bool NoPhotonPropagation() const
std::vector< std::string > fKeepParticlesInVolumes
Only write particles that have trajectories through these volumes.
bool fSparsifyTrajectories
Sparsify MCParticle Trajectories.
int fSmartStacking
Whether to instantiate and use class to.
bool fdumpSimChannels
Whether each event&#39;s sim::Channel will be displayed.
larg4::ParticleListAction * fparticleListAction
Geant4 user action to particle information.
base_engine_t & createEngine(seed_t seed)
bool NoElectronPropagation() const
g4b::G4Helper * fG4Help
G4 interface object.
bool FillSimEnergyDeposits() const
bool fdumpParticleList
Whether each event&#39;s sim::ParticleList will be displayed.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
bool fUseLitePhotons
std::string fG4PhysListName
predefined physics list to use if not making a custom one
#define LOG_DEBUG(id)
bool fCheckOverlaps
Whether to use the G4 overlap checker.
double fOffPlaneMargin
dictate how tracks are put on stack.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
bool UseLitePhotons() const
larg4::LArG4::~LArG4 ( )
virtual

Definition at line 415 of file LArG4_module.cc.

References fG4Help.

416  {
417  if(fG4Help) delete fG4Help;
418  }
g4b::G4Helper * fG4Help
G4 interface object.

Member Function Documentation

void larg4::LArG4::beginJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 421 of file LArG4_module.cc.

References g4b::UserActionManager::AddAndAdoptAction(), g4b::G4Helper::ConstructDetector(), larg4::IonizationAndScintillation::CreateInstance(), fCheckOverlaps, fG4Help, fG4MacroPath, fG4PhysListName, fOffPlaneMargin, fparticleListAction, fSmartStacking, geo::GeometryCore::GDMLFile(), larg4::MaterialPropertyLoader::GetPropertiesFromServices(), g4b::G4Helper::GetRunManager(), g4b::G4Helper::InitPhysics(), g4b::UserActionManager::Instance(), sim::LArG4Parameters::KeepEMShowerDaughters(), larg4::LArVoxelReadout::Setup_t::offPlaneMargin, geo::GeometryCore::OpDetGeoName(), sim::LArG4Parameters::ParticleKineticEnergyCut(), larg4::LArVoxelReadoutGeometry::Setup_t::readoutSetup, art::EngineCreator::rng(), g4b::G4Helper::SetOverlapCheck(), g4b::G4Helper::SetParallelWorlds(), g4b::G4Helper::SetUserAction(), sim::LArG4Parameters::StoreTrajectories(), and larg4::MaterialPropertyLoader::UpdateGeometry().

422  {
425 
429 
430  // Get the logical volume store and assign material properties
433  MPL->UpdateGeometry(G4LogicalVolumeStore::GetInstance());
434 
435  // Tell the detector about the parallel LAr voxel geometry.
436  std::vector<G4VUserParallelWorld*> pworlds;
437  // Intialize G4 physics and primary generator action
438  fG4Help->InitPhysics();
439 
440  // create the ionization and scintillation calculator;
441  // this is a singleton (!) so it does not make sense
442  // to create it in LArVoxelReadoutGeometry
443  IonizationAndScintillation::CreateInstance(rng->getEngine("propagation"));
444 
445  // make a parallel world for each TPC in the detector
446  LArVoxelReadoutGeometry::Setup_t readoutGeomSetupData;
447  readoutGeomSetupData.readoutSetup.offPlaneMargin = fOffPlaneMargin;
448  readoutGeomSetupData.readoutSetup.propGen
449  = &(rng->getEngine("propagation"));
450  pworlds.push_back(new LArVoxelReadoutGeometry
451  ("LArVoxelReadoutGeometry", readoutGeomSetupData)
452  );
453  pworlds.push_back( new OpDetReadoutGeometry( geom->OpDetGeoName() ));
454  pworlds.push_back( new AuxDetReadoutGeometry("AuxDetReadoutGeometry") );
455 
456  fG4Help->SetParallelWorlds(pworlds);
457 
458  // moved up
459  // Intialize G4 physics and primary generator action
460  fG4Help->InitPhysics();
461 
462  // Use the UserActionManager to handle all the Geant4 user hooks.
464 
465  // User-action class for accumulating LAr voxels.
467 
468  // UserAction for getting past a bug in v4.9.4.p02 of Geant4.
469  // This action will not be used once the bug has been fixed
470  // The techniques used in this UserAction are not to be repeated
471  // as in general they are a very bad idea, ie they take a const
472  // pointer and jump through hoops to change it
473  // 08-Apr-2014 WGS: It appears that with the shift to Geant 4.9.6 or
474  // above, there's no longer any need for the "Bad Idea Action" fix.
475  // larg4::G4BadIdeaAction *bia = new larg4::G4BadIdeaAction(fSmartStacking);
476  // uaManager->AddAndAdoptAction(bia);
477 
478  // remove IonizationAndScintillationAction for now as we are ensuring
479  // the Reset for each G4Step within the G4SensitiveVolumes
480  //larg4::IonizationAndScintillationAction *iasa = new larg4::IonizationAndScintillationAction();
481  //uaManager->AddAndAdoptAction(iasa);
482 
483  // User-action class for accumulating particles and trajectories
484  // produced in the detector.
486  lgp->StoreTrajectories(),
487  lgp->KeepEMShowerDaughters());
489 
490  // UserActionManager is now configured so continue G4 initialization
492 
493  // With an enormous detector with lots of rock ala LAr34 (nee LAr20)
494  // we need to be smarter about stacking.
495  if (fSmartStacking>0){
496  G4UserStackingAction* stacking_action = new LArStackingAction(fSmartStacking);
497  fG4Help->GetRunManager()->SetUserAction(stacking_action);
498  }
499 
500 
501 
502  }
bool KeepEMShowerDaughters() const
std::string fG4MacroPath
Stores material properties and sends them to GEANT4 geometry.
std::string OpDetGeoName(unsigned int c=0) const
Returns gdml string which gives sensitive opdet name.
void SetUserAction()
Initialization for the Geant4 Monte Carlo.
Definition: G4Helper.cxx:432
void ConstructDetector(std::string const &gdmlFile)
Definition: G4Helper.cxx:368
void SetParallelWorlds(std::vector< G4VUserParallelWorld * > pworlds)
Definition: G4Helper.cxx:357
G4RunManager * GetRunManager()
Definition: G4Helper.h:100
bool StoreTrajectories() const
void InitPhysics()
Initialization for the Geant4 Monte Carlo.
Definition: G4Helper.cxx:407
int fSmartStacking
Whether to instantiate and use class to.
std::string GDMLFile() const
Returns the full directory path to the GDML file source.
larg4::ParticleListAction * fparticleListAction
Geant4 user action to particle information.
void SetOverlapCheck(bool check)
Definition: G4Helper.h:128
g4b::G4Helper * fG4Help
G4 interface object.
static void AddAndAdoptAction(UserAction *a)
static IonizationAndScintillation * CreateInstance(CLHEP::HepRandomEngine &engine)
void UpdateGeometry(G4LogicalVolumeStore *lvs)
Updates the material properties with the collected values.
double ParticleKineticEnergyCut() const
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
static UserActionManager * Instance()
std::string fG4PhysListName
predefined physics list to use if not making a custom one
bool fCheckOverlaps
Whether to use the G4 overlap checker.
void GetPropertiesFromServices()
Imports properties from LArSoft services.
double fOffPlaneMargin
dictate how tracks are put on stack.
void larg4::LArG4::beginRun ( art::Run run)
virtual

Reimplemented from art::EDProducer.

Definition at line 504 of file LArG4_module.cc.

References CreateParticleVolumeFilter(), fKeepParticlesInVolumes, fparticleListAction, and larg4::ParticleListAction::ParticleFilter().

504  {
505  // prepare the filter object (null if no filtering)
506 
507  std::set<std::string> volnameset(fKeepParticlesInVolumes.begin(), fKeepParticlesInVolumes.end());
509 
510  }
std::vector< std::string > fKeepParticlesInVolumes
Only write particles that have trajectories through these volumes.
std::unique_ptr< PositionInVolumeFilter > CreateParticleVolumeFilter(std::set< std::string > const &vol_names) const
Configures and returns a particle filter.
larg4::ParticleListAction * fparticleListAction
Geant4 user action to particle information.
void ParticleFilter(std::unique_ptr< PositionInVolumeFilter > &&filter)
Grabs a particle filter.
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()
std::unique_ptr< PositionInVolumeFilter > larg4::LArG4::CreateParticleVolumeFilter ( std::set< std::string > const &  vol_names) const
private

Configures and returns a particle filter.

Definition at line 513 of file LArG4_module.cc.

Referenced by beginRun().

514  {
515 
516  // if we don't have favourite volumes, don't even bother creating a filter
517  if (vol_names.empty()) return {};
518 
519  auto const& geom = *art::ServiceHandle<geo::Geometry>();
520 
521  std::vector<std::vector<TGeoNode const*>> node_paths
522  = geom.FindAllVolumePaths(vol_names);
523 
524  // collection of interesting volumes
526  GeoVolumePairs.reserve(node_paths.size()); // because we are obsessed
527 
528  //for each interesting volume, follow the node path and collect
529  //total rotations and translations
530  for (size_t iVolume = 0; iVolume < node_paths.size(); ++iVolume) {
531  std::vector<TGeoNode const*> path = node_paths[iVolume];
532 
533  TGeoTranslation* pTransl = new TGeoTranslation(0.,0.,0.);
534  TGeoRotation* pRot = new TGeoRotation();
535  for (TGeoNode const* node: path) {
536  TGeoTranslation thistranslate(*node->GetMatrix());
537  TGeoRotation thisrotate(*node->GetMatrix());
538  pTransl->Add(&thistranslate);
539  *pRot=*pRot * thisrotate;
540  }
541 
542  //for some reason, pRot and pTransl don't have tr and rot bits set correctly
543  //make new translations and rotations so bits are set correctly
544  TGeoTranslation* pTransl2 = new TGeoTranslation(pTransl->GetTranslation()[0],
545  pTransl->GetTranslation()[1],
546  pTransl->GetTranslation()[2]);
547  double phi=0.,theta=0.,psi=0.;
548  pRot->GetAngles(phi,theta,psi);
549  TGeoRotation* pRot2 = new TGeoRotation();
550  pRot2->SetAngles(phi,theta,psi);
551 
552  TGeoCombiTrans* pTransf = new TGeoCombiTrans(*pTransl2,*pRot2);
553 
554  GeoVolumePairs.emplace_back(node_paths[iVolume].back()->GetVolume(), pTransf);
555 
556  }
557 
558  return std::make_unique<PositionInVolumeFilter>(std::move(GeoVolumePairs));
559 
560  } // CreateParticleVolumeFilter()
std::vector< VolumeInfo_t > AllVolumeInfo_t
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 larg4::LArG4::produce ( art::Event evt)
virtual

The main routine of this module: Fetch the primary particles from the event, simulate their evolution in the detctor, and produce the detector response.

Implements art::EDProducer.

Definition at line 563 of file LArG4_module.cc.

References geo::GeometryCore::AuxDet(), sim::SimChannel::Channel(), larg4::AuxDetReadout::clear(), larg4::OpDetPhotonTable::ClearEnergyDeposits(), larg4::OpDetPhotonTable::ClearTable(), geo::GeometryCore::Cryostat(), DEFINE_ART_MODULE, sim::SimPhotonsLite::DetectedPhotons, sim::dump::DumpMCParticle(), sim::dump::DumpMCTruth(), fdumpParticleList, fdumpSimChannels, fG4Help, sim::LArG4Parameters::FillSimEnergyDeposits(), fInputLabels, fparticleListAction, fSparsifyTrajectories, fUseLitePhotons, g4b::G4Helper::G4Run(), art::Ptr< T >::get(), larg4::AuxDetReadout::GetAuxDetSimChannel(), art::DataViewImpl::getByLabel(), larg4::OpDetPhotonTable::GetLitePhotons(), art::DataViewImpl::getManyByType(), larg4::OpDetPhotonTable::GetPhotons(), larg4::ParticleListAction::GetPrimaryTruthIndex(), larg4::LArVoxelReadout::GetSimChannelMap(), larg4::OpDetPhotonTable::GetSimEnergyDeposits(), art::Event::id(), larg4::OpDetPhotonTable::Instance(), larg4::ParticleListAction::isDropped(), LOG_DEBUG, art::errors::LogicError, simb::MCParticle::Mother(), geo::GeometryCore::NAuxDets(), geo::GeometryCore::Ncryostats(), sim::LArG4Parameters::NoElectronPropagation(), geo::GeometryCore::NOpDets(), sim::LArG4Parameters::NoPhotonPropagation(), geo::AuxDetGeo::NSensitiveVolume(), geo::CryostatGeo::NTPC(), sim::SimPhotonsLite::OpChannel, art::Handle< T >::provenance(), art::Event::put(), larg4::ParticleListAction::ResetTrackIDOffset(), simb::MCParticle::SparsifyTrajectory(), sim::SimChannel::TDCIDEMap(), simb::MCParticle::TrackId(), larg4::ParticleListAction::YieldList(), and larg4::OpDetPhotonTable::YieldOpDetBacktrackerRecords().

564  {
565  LOG_DEBUG("LArG4") << "produce()";
566 
567  // loop over the lists and put the particles and voxels into the event as collections
568  std::unique_ptr< std::vector<sim::SimChannel> > scCol (new std::vector<sim::SimChannel>);
569  std::unique_ptr< std::vector< sim::AuxDetSimChannel > > adCol (new std::vector<sim::AuxDetSimChannel> );
570  auto tpassn = std::make_unique<art::Assns<simb::MCTruth, simb::MCParticle, sim::GeneratedParticleInfo>>();
571  std::unique_ptr< std::vector<simb::MCParticle> > partCol (new std::vector<simb::MCParticle >);
572  std::unique_ptr< std::vector<sim::SimPhotons> > PhotonCol (new std::vector<sim::SimPhotons>);
573  std::unique_ptr< std::vector<sim::SimPhotonsLite> > LitePhotonCol (new std::vector<sim::SimPhotonsLite>);
574  std::unique_ptr< std::vector< sim::OpDetBacktrackerRecord > > cOpDetBacktrackerRecordCol (new std::vector<sim::OpDetBacktrackerRecord>);
575 
576  art::PtrMaker<simb::MCParticle> makeMCPartPtr(evt, *this);
577 
578  //for energy deposits
579  std::unique_ptr< std::vector<sim::SimEnergyDeposit> > edepCol_TPCActive (new std::vector<sim::SimEnergyDeposit>);
580  std::unique_ptr< std::vector<sim::SimEnergyDeposit> > edepCol_Other (new std::vector<sim::SimEnergyDeposit>);
581 
582  // Fetch the lists of LAr voxels and particles.
585 
586  // Clear the detected photon table
588  if(lgp->FillSimEnergyDeposits())
590 
591  // reset the track ID offset as we have a new collection of interactions
593 
594  //look to see if there is any MCTruth information for this
595  //event
596  std::vector< art::Handle< std::vector<simb::MCTruth> > > mclists;
597  if(fInputLabels.size()==0)
598  evt.getManyByType(mclists);
599  else{
600  mclists.resize(fInputLabels.size());
601  for(size_t i=0; i<fInputLabels.size(); i++)
602  evt.getByLabel(fInputLabels[i],mclists[i]);
603  }
604 
605  unsigned int nGeneratedParticles = 0;
606 
607  // Need to process Geant4 simulation for each interaction separately.
608  for(size_t mcl = 0; mcl < mclists.size(); ++mcl){
609 
610  art::Handle< std::vector<simb::MCTruth> > mclistHandle = mclists[mcl];
611 
612  for(size_t m = 0; m < mclistHandle->size(); ++m){
613  art::Ptr<simb::MCTruth> mct(mclistHandle, m);
614 
615  LOG_DEBUG("LArG4") << *(mct.get());
616 
617  // The following tells Geant4 to track the particles in this interaction.
618  fG4Help->G4Run(mct);
619 
620  // receive the particle list
622 
623  for(auto const& partPair: particleList) {
624  simb::MCParticle& p = *(partPair.second);
625  ++nGeneratedParticles;
626 
627  // if the particle has been marked as dropped, we don't save it
628  // (as of LArSoft ~v5.6 this does not ever happen because
629  // ParticleListAction has already taken care of deleting them)
630  if (ParticleListAction::isDropped(&p)) continue;
631 
632  sim::GeneratedParticleInfo const truthInfo{
634  };
635  if (!truthInfo.hasGeneratedParticleIndex() && (p.Mother() == 0)) {
636  // this means it's primary but with no information; logic error!!
638  error << "Failed to match primary particle:\n";
640  error << "\nwith particles from the truth record '"
641  << mclistHandle.provenance()->inputTag() << "':\n";
642  sim::dump::DumpMCTruth(error, *mct, 2U, " "); // 2 points per line
643  error << "\n";
644  throw error;
645  }
646 
648 
649  partCol->push_back(std::move(p));
650 
651  tpassn->addSingle(mct, makeMCPartPtr(partCol->size() - 1), truthInfo);
652 
653  } // for(particleList)
654 
655 
656  // Has the user request a detailed dump of the output objects?
657  if (fdumpParticleList){
658  mf::LogInfo("LArG4") << "Dump sim::ParticleList; size()="
659  << particleList.size() << "\n"
660  << particleList;
661  }
662 
663  }
664 
665  }// end loop over interactions
666 
667  // get the electrons from the LArVoxelReadout sensitive detector
668  // Get the sensitive-detector manager.
669  G4SDManager* sdManager = G4SDManager::GetSDMpointer();
670 
671  // Find the sensitive detector with the name "LArVoxelSD".
672  OpDetSensitiveDetector *theOpDetDet = dynamic_cast<OpDetSensitiveDetector*>(sdManager->FindSensitiveDetector("OpDetSensitiveDetector"));
673 
674  // Store the contents of the detected photon table
675  //
676  if(theOpDetDet){
677 
678  if(!lgp->NoPhotonPropagation()){
679 
680  if(!fUseLitePhotons){
681  LOG_DEBUG("Optical") << "Storing OpDet Hit Collection in Event";
682  std::vector<sim::SimPhotons>& ThePhotons = OpDetPhotonTable::Instance()->GetPhotons();
683  PhotonCol->reserve(ThePhotons.size());
684  for(auto& it : ThePhotons)
685  PhotonCol->push_back(std::move(it));
686  }
687  else{
688  LOG_DEBUG("Optical") << "Storing OpDet Hit Collection in Event";
689 
690  std::map<int, std::map<int, int> > ThePhotons = OpDetPhotonTable::Instance()->GetLitePhotons();
691 
692  if(ThePhotons.size() > 0){
693  LitePhotonCol->reserve(ThePhotons.size());
694  for(auto const& it : ThePhotons){
696  ph.OpChannel = it.first;
697  ph.DetectedPhotons = it.second;
698  LitePhotonCol->push_back(ph);
699  }
700  }
701  *cOpDetBacktrackerRecordCol = OpDetPhotonTable::Instance()->YieldOpDetBacktrackerRecords();
702  }
703  }//end if no photon propagation
704 
705  if(lgp->FillSimEnergyDeposits())
706  {
707  auto const& edepMap = OpDetPhotonTable::Instance()->GetSimEnergyDeposits();
708  for(auto const& edepCol : edepMap){
709  if(boost::contains(edepCol.first,"TPCActive"))
710  edepCol_TPCActive->insert(edepCol_TPCActive->end(),
711  edepCol.second.begin(),edepCol.second.end());
712  else
713  edepCol_Other->insert(edepCol_Other->end(),
714  edepCol.second.begin(),edepCol.second.end());
715  }
716  }
717  }//end if theOpDetDet
718 
719 
720  if(!lgp->NoElectronPropagation())
721  {
722 
723  // only put the sim::SimChannels into the event once, not once for every
724  // MCTruth in the event
725 
726  std::set<LArVoxelReadout*> ReadoutList; // to be cleared later on
727 
728  for(unsigned int c = 0; c < geom->Ncryostats(); ++c){
729 
730  // map to keep track of which channels we already have SimChannels for in scCol
731  // remake this map on each cryostat as channels ought not to be shared between
732  // cryostats, just between TPC's
733 
734  std::map<unsigned int, unsigned int> channelToscCol;
735 
736  unsigned int ntpcs = geom->Cryostat(c).NTPC();
737  for(unsigned int t = 0; t < ntpcs; ++t){
738  std::string name("LArVoxelSD");
739  std::ostringstream sstr;
740  sstr << name << "_Cryostat" << c << "_TPC" << t;
741 
742  // try first to find the sensitive detector specific for this TPC;
743  // do not bother writing on screen if there is none (yet)
744  G4VSensitiveDetector* sd
745  = sdManager->FindSensitiveDetector(sstr.str(), false);
746  // if there is none, catch the general one (called just "LArVoxelSD")
747  if (!sd) sd = sdManager->FindSensitiveDetector(name, false);
748  // If this didn't work, then a sensitive detector with
749  // the name "LArVoxelSD" does not exist.
750  if ( !sd ){
751  throw cet::exception("LArG4") << "Sensitive detector for cryostat "
752  << c << " TPC " << t << " not found (neither '"
753  << sstr.str() << "' nor '" << name << "' exist)\n";
754  }
755 
756  // Convert the G4VSensitiveDetector* to a LArVoxelReadout*.
757  LArVoxelReadout* larVoxelReadout = dynamic_cast<LArVoxelReadout*>(sd);
758 
759  // If this didn't work, there is a "LArVoxelSD" detector, but
760  // it's not a LArVoxelReadout object.
761  if ( !larVoxelReadout ){
762  throw cet::exception("LArG4") << "Sensitive detector '"
763  << sd->GetName()
764  << "' is not a LArVoxelReadout object\n";
765  }
766 
767  LArVoxelReadout::ChannelMap_t& channels = larVoxelReadout->GetSimChannelMap(c, t);
768  if (!channels.empty()) {
769  LOG_DEBUG("LArG4") << "now put " << channels.size() << " SimChannels"
770  " from C=" << c << " T=" << t << " into the event";
771  }
772 
773  for(auto ch_pair: channels){
774  sim::SimChannel& sc = ch_pair.second;
775 
776  // push sc onto scCol but only if we haven't already put something in scCol for this channel.
777  // if we have, then merge the ionization deposits. Skip the check if we only have one TPC
778 
779  if (ntpcs > 1) {
780  unsigned int ichan = sc.Channel();
781  std::map<unsigned int, unsigned int>::iterator itertest = channelToscCol.find(ichan);
782  if (itertest == channelToscCol.end()) {
783  channelToscCol[ichan] = scCol->size();
784  scCol->emplace_back(std::move(sc));
785  }
786  else {
787  unsigned int idtest = itertest->second;
788  auto const& tdcideMap = sc.TDCIDEMap();
789  for(auto const& tdcide : tdcideMap){
790  for(auto const& ide : tdcide.second){
791  double xyz[3] = {ide.x, ide.y, ide.z};
792  scCol->at(idtest).AddIonizationElectrons(ide.trackID,
793  tdcide.first,
794  ide.numElectrons,
795  xyz,
796  ide.energy);
797  } // end loop to add ionization electrons to scCol->at(idtest)
798  }// end loop over tdc to vector<sim::IDE> map
799  } // end if check to see if we've put SimChannels in for ichan yet or not
800  }
801  else {
802  scCol->emplace_back(std::move(sc));
803  } // end of check if we only have one TPC (skips check for multiple simchannels if we have just one TPC)
804  } // end loop over simchannels for this TPC
805 
806 
807  // mark it for clearing
808  ReadoutList.insert(const_cast<LArVoxelReadout*>(larVoxelReadout));
809 
810  } // end loop over tpcs
811  }// end loop over cryostats
812 
813  for (LArVoxelReadout* larVoxelReadout: ReadoutList){
814  larVoxelReadout->ClearSimChannels();
815  }
816  }//endif electron prop
817 
818  // only put the sim::AuxDetSimChannels into the event once, not once for every
819  // MCTruth in the event
820 
821  adCol->reserve(geom->NAuxDets());
822  for(unsigned int a = 0; a < geom->NAuxDets(); ++a){
823 
824  // there should always be at least one senstive volume because
825  // we make one for the full aux det if none are specified in the
826  // gdml file - see AuxDetGeo.cxx
827  for(size_t sv = 0; sv < geom->AuxDet(a).NSensitiveVolume(); ++sv){
828 
829  // N.B. this name convention is used when creating the
830  // AuxDetReadout SD in AuxDetReadoutGeometry
831  std::stringstream name;
832  name << "AuxDetSD_AuxDet" << a << "_" << sv;
833  G4VSensitiveDetector* sd = sdManager->FindSensitiveDetector(name.str().c_str());
834  if ( !sd ){
835  throw cet::exception("LArG4") << "Sensitive detector '"
836  << name.str()
837  << "' does not exist\n";
838  }
839 
840  // Convert the G4VSensitiveDetector* to a AuxDetReadout*.
841  larg4::AuxDetReadout *auxDetReadout = dynamic_cast<larg4::AuxDetReadout*>(sd);
842 
843  LOG_DEBUG("LArG4") << "now put the AuxDetSimTracks in the event";
844 
845  const sim::AuxDetSimChannel adsc = auxDetReadout->GetAuxDetSimChannel();
846  adCol->push_back(adsc);
847  auxDetReadout->clear();
848  }
849 
850  } // Loop over AuxDets
851 
852  mf::LogInfo("LArG4")
853  << "Geant4 simulated " << nGeneratedParticles << " MC particles, we keep "
854  << partCol->size() << " .";
855 
856  if (fdumpSimChannels) {
857  mf::LogVerbatim("DumpSimChannels")
858  << "Event " << evt.id()
859  << ": " << scCol->size() << " channels with signal";
860  unsigned int nChannels = 0;
861  for (const sim::SimChannel& sc: *scCol) {
862  mf::LogVerbatim out("DumpSimChannels");
863  out << " #" << nChannels << ": ";
864  // dump indenting with " ", but not on the first line
865  sc.Dump(out, " ");
866  ++nChannels;
867  } // for
868  } // if dump SimChannels
869 
870  if(!lgp->NoElectronPropagation()) evt.put(std::move(scCol));
871 
872  evt.put(std::move(adCol));
873  evt.put(std::move(partCol));
874  if(!lgp->NoPhotonPropagation()){
875  if(!fUseLitePhotons) evt.put(std::move(PhotonCol));
876  else{
877  evt.put(std::move(LitePhotonCol));
878  evt.put(std::move(cOpDetBacktrackerRecordCol));
879  }
880  }
881  evt.put(std::move(tpassn));
882 
883  if(lgp->FillSimEnergyDeposits()){
884  evt.put(std::move(edepCol_TPCActive),"TPCActive");
885  evt.put(std::move(edepCol_Other),"Other");
886  }
887  return;
888  } // LArG4::produce()
std::vector< std::string > fInputLabels
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
void SparsifyTrajectory()
Definition: MCParticle.h:268
Energy deposited on a readout channel by simulated tracks.
Definition: SimChannel.h:143
intermediate_table::iterator iterator
std::vector< sim::SimPhotons > & GetPhotons()
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
bool G4Run(std::vector< const simb::MCTruth * > &primaries)
Definition: G4Helper.cxx:503
int Mother() const
Definition: MCParticle.h:217
void Dump(Stream &&out, std::string indent, std::string first_indent) const
Dumps the full content of the SimChannel into a stream.
Definition: SimChannel.h:340
bool NoPhotonPropagation() const
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
int TrackId() const
Definition: MCParticle.h:214
std::map< int, int > DetectedPhotons
Definition: SimPhotons.h:65
bool fSparsifyTrajectories
Sparsify MCParticle Trajectories.
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
Collection of particles crossing one auxiliary detector cell.
bool fdumpSimChannels
Whether each event&#39;s sim::Channel will be displayed.
larg4::ParticleListAction * fparticleListAction
Geant4 user action to particle information.
sim::ParticleList && YieldList()
std::map< unsigned int, sim::SimChannel > ChannelMap_t
Type of map channel -> sim::SimChannel.
bool NoElectronPropagation() const
g4b::G4Helper * fG4Help
G4 interface object.
static bool isDropped(simb::MCParticle const *p)
returns whether the specified particle has been marked as dropped
Provenance const * provenance() const
Definition: Handle.h:204
std::unordered_map< std::string, std::vector< sim::SimEnergyDeposit > > & GetSimEnergyDeposits()
virtual void clear()
void DumpMCTruth(Stream &&out, simb::MCTruth const &truth, unsigned int pointsPerLine, std::string indent, std::string firstIndent)
Dumps the content of the specified MC truth in the output stream.
Definition: MCDumpers.h:346
bool FillSimEnergyDeposits() const
void getManyByType(std::vector< Handle< PROD >> &results) const
Definition: DataViewImpl.h:446
unsigned int NTPC() const
Number of TPCs in this cryostat.
Definition: CryostatGeo.h:155
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
size_t NSensitiveVolume() const
Definition: AuxDetGeo.h:160
GeneratedParticleIndex_t GetPrimaryTruthIndex(int trackId) const
Returns the index of primary truth (sim::NoGeneratorIndex if none).
bool fdumpParticleList
Whether each event&#39;s sim::ParticleList will be displayed.
std::map< int, std::map< int, int > > GetLitePhotons()
AuxDetGeo const & AuxDet(unsigned int const ad=0) const
Returns the specified auxiliary detector.
unsigned int NOpDets() const
Number of OpDets in the whole detector.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
raw::ChannelID_t Channel() const
Returns the readout channel this object describes.
Definition: SimChannel.h:332
static OpDetPhotonTable * Instance(bool LitePhotons=false)
bool fUseLitePhotons
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
std::vector< sim::OpDetBacktrackerRecord > YieldOpDetBacktrackerRecords()
Contains information about a generated particle.
#define LOG_DEBUG(id)
TDCIDEs_t const & TDCIDEMap() const
Returns all the deposited energy information as stored.
Definition: SimChannel.h:331
void ClearTable(size_t nch=0)
EventID id() const
Definition: Event.h:56
sim::AuxDetSimChannel const GetAuxDetSimChannel() const
Definition: AuxDetReadout.h:73
void DumpMCParticle(Stream &&out, simb::MCParticle const &particle, std::string indent, std::string firstIndent)
Dumps the content of the specified particle in the output stream.
Definition: MCDumpers.h:228
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
unsigned int NAuxDets() const
Returns the number of auxiliary detectors.
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

bool larg4::LArG4::fCheckOverlaps
private

Whether to use the G4 overlap checker.

Definition at line 318 of file LArG4_module.cc.

Referenced by beginJob().

bool larg4::LArG4::fdumpParticleList
private

Whether each event's sim::ParticleList will be displayed.

Definition at line 319 of file LArG4_module.cc.

Referenced by produce().

bool larg4::LArG4::fdumpSimChannels
private

Whether each event's sim::Channel will be displayed.

Definition at line 320 of file LArG4_module.cc.

Referenced by produce().

g4b::G4Helper* larg4::LArG4::fG4Help
private

G4 interface object.

Definition at line 311 of file LArG4_module.cc.

Referenced by beginJob(), produce(), and ~LArG4().

std::string larg4::LArG4::fG4MacroPath
private

directory path for Geant4 macro file to be executed before main MC processing.

Definition at line 316 of file LArG4_module.cc.

Referenced by beginJob(), and LArG4().

std::string larg4::LArG4::fG4PhysListName
private

predefined physics list to use if not making a custom one

Definition at line 315 of file LArG4_module.cc.

Referenced by beginJob().

std::vector<std::string> larg4::LArG4::fInputLabels
private

Definition at line 325 of file LArG4_module.cc.

Referenced by LArG4(), and produce().

std::vector<std::string> larg4::LArG4::fKeepParticlesInVolumes
private

Only write particles that have trajectories through these volumes.

Definition at line 326 of file LArG4_module.cc.

Referenced by beginRun().

larg4::LArVoxelListAction* larg4::LArG4::flarVoxelListAction
private

Geant4 user action to accumulate LAr voxel information.

Definition at line 312 of file LArG4_module.cc.

double larg4::LArG4::fOffPlaneMargin = 0.
private

dictate how tracks are put on stack.

Off-plane charge recovery margin

Definition at line 323 of file LArG4_module.cc.

Referenced by beginJob().

larg4::ParticleListAction* larg4::LArG4::fparticleListAction
private

Geant4 user action to particle information.

Definition at line 313 of file LArG4_module.cc.

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

int larg4::LArG4::fSmartStacking
private

Whether to instantiate and use class to.

Definition at line 322 of file LArG4_module.cc.

Referenced by beginJob().

bool larg4::LArG4::fSparsifyTrajectories
private

Sparsify MCParticle Trajectories.

Definition at line 328 of file LArG4_module.cc.

Referenced by LArG4(), and produce().

bool larg4::LArG4::fUseLitePhotons
private

Definition at line 321 of file LArG4_module.cc.

Referenced by LArG4(), and produce().


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