Public Member Functions | Private Member Functions | Private Attributes | List of all members
gar::garg4::GArG4 Class Reference

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

Inheritance diagram for gar::garg4::GArG4:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 GArG4 (fhicl::ParameterSet const &pset)
 Standard constructor and destructor for an FMWK module. More...
 
virtual ~GArG4 ()
 
void produce (::art::Event &evt)
 
void beginJob ()
 
void beginRun (::art::Run &run)
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

std::unique_ptr< PositionInVolumeFilterCreateParticleVolumeFilter (std::set< std::string > const &vol_names) const
 Configures and returns a particle filter. More...
 
void SetLimitsAndCuts ()
 Set the user limits and production cuts per region. More...
 

Private Attributes

g4b::G4Helper * fG4Help
 G4 interface object. More...
 
garg4::EnergyDepositActionfEDepAction
 Geant4 user action to handle GAr energy depositions. More...
 
garg4::AuxDetActionfAuxDetAction
 Geant4 user action to handle GAr energy depositions. More...
 
garg4::ParticleListActionfParticleListAction
 Geant4 user action to particle information. More...
 
fhicl::ParameterSet fEDepActionPSet
 configuration for GArAction More...
 
fhicl::ParameterSet fAuxDetActionPSet
 configuration for AuxAction More...
 
std::vector< std::stringfDetRegionNames
 Name of the volumes used to defined regions. More...
 
std::string fG4PhysListName
 predefined physics list to use if not making a custom one More...
 
std::string fG4MacroPath
 executed before main MC processing. More...
 
bool fCheckOverlaps
 Whether to use the G4 overlap checker. More...
 
bool fdumpParticleList
 Whether each event's sim::ParticleList will be displayed. More...
 
int fSmartStacking
 dictate how tracks are put on stack. More...
 
std::vector< float > fMaxStepSize
 maximum step size in mm per sub-detector region More...
 
float fProductionCut
 G4 will check if a produced particle should travel this far and drop it if not. More...
 
std::vector< std::stringfInputLabels
 
std::vector< std::stringfKeepParticlesInVolumes
 Only write particles that have trajectories through these volumes. More...
 
const geo::GeometryCoregeo
 
CLHEP::HepRandomEngine & fEngine
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

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

Randomness

The random number generators used by this process are:

Configuration parameters

Definition at line 152 of file GArG4_module.cc.

Constructor & Destructor Documentation

gar::garg4::GArG4::GArG4 ( fhicl::ParameterSet const &  pset)
explicit

Standard constructor and destructor for an FMWK module.

Definition at line 205 of file GArG4_module.cc.

206  : art::EDProducer{pset}
207  , fG4Help (nullptr)
208  , fEDepAction (nullptr)
209  , fAuxDetAction (nullptr)
210  , fParticleListAction (nullptr)
211  , fEDepActionPSet (pset.get<fhicl::ParameterSet>("EDepActionPSet") )
212  , fAuxDetActionPSet (pset.get<fhicl::ParameterSet>("AuxDetActionPSet") )
213  , fDetRegionNames (pset.get< std::vector< std::string > >("DetRegionName", {}) )
214  , fG4PhysListName (pset.get< std::string >("G4PhysListName", "garg4::PhysicsList") )
215  , fCheckOverlaps (pset.get< bool >("CheckOverlaps", false) )
216  , fdumpParticleList (pset.get< bool >("DumpParticleList", false) )
217  , fSmartStacking (pset.get< int >("SmartStacking", 0) )
218  , fMaxStepSize (pset.get< std::vector< float > >("MaxStepSize", {} ) )//in mm
219  , fProductionCut (pset.get< float >("ProductionCut", 0.05) )//in mm
220  , fKeepParticlesInVolumes(pset.get< std::vector< std::string > >("KeepParticlesInVolumes", {}) )
221  , fEngine(art::ServiceHandle<rndm::NuRandomService>()->createEngine(*this, pset, "GEANTSeed") )
222  {
223  geo = providerFrom<geo::GeometryGAr>();
224 
225  // initialize the GArSimulationParameters singleton
226  G4SimulationParameters::CreateInstance(pset.get<fhicl::ParameterSet>("GArSimParsPSet"));
227 
228  MF_LOG_DEBUG("GArG4") << "Debug: GArG4()";
229  //art::ServiceHandle<rndm::NuRandomService>()->createEngine(*this);
231 
232  // setup the random number service for Geant4, the "G4Engine" label is a
233  // special tag setting up a global engine for use by Geant4/CLHEP;
234  // obtain the random seed from NuRandomService,
235  // unless overridden in configuration with key "Seed" or "GEANTSeed"
236  // same thing for the propagation engine:
237  // and again for radio decay
238 
239 
240  //get a list of generators to use, otherwise, we'll end up looking for anything that's
241  //made an MCTruth object
242  bool useInputLabels = pset.get_if_present< std::vector<std::string> >("InputLabels", fInputLabels);
243  if(!useInputLabels) fInputLabels.resize(0);
244 
245  produces< std::vector<simb::MCParticle> >();
246  produces< ::art::Assns<simb::MCTruth, simb::MCParticle> >();
247 
248  produces< std::vector<sdp::LArDeposit> >();
249  produces< std::vector<sdp::EnergyDeposit> >();
250 
251  if(geo->HasECALDetector())
252  produces< std::vector<sdp::CaloDeposit> >("ECAL");//ECAL
253  if(geo->HasTrackerScDetector())
254  produces< std::vector<sdp::CaloDeposit> >("TrackerSc");//TrackerSc
255  if(geo->HasMuonDetector())
256  produces< std::vector<sdp::CaloDeposit> >("MuID");//MuID
257 
258  // constructor decides if initialized value is a path or an environment variable
259  cet::search_path sp("FW_SEARCH_PATH");
260 
261  sp.find_file(pset.get< std::string >("GeantCommandFile"), fG4MacroPath);
262  struct stat sb;
263  if (fG4MacroPath.empty() || stat(fG4MacroPath.c_str(), &sb)!=0)
264  // failed to resolve the file name
265  throw cet::exception("NoG4Macro")
266  << "G4 macro file "
267  << fG4MacroPath
268  << " not found!\n";
269 
270  }
base_engine_t & createEngine(seed_t seed)
std::string string
Definition: nybbler.cc:12
void produces(std::string const &instanceName={}, Persistable const persistable=Persistable::Yes)
std::string fG4PhysListName
predefined physics list to use if not making a custom one
std::string fG4MacroPath
executed before main MC processing.
bool fdumpParticleList
Whether each event&#39;s sim::ParticleList will be displayed.
std::vector< std::string > fInputLabels
fhicl::ParameterSet fEDepActionPSet
configuration for GArAction
garg4::EnergyDepositAction * fEDepAction
Geant4 user action to handle GAr energy depositions.
std::vector< std::string > fDetRegionNames
Name of the volumes used to defined regions.
std::vector< std::string > fKeepParticlesInVolumes
Only write particles that have trajectories through these volumes.
CLHEP::HepRandomEngine & fEngine
int fSmartStacking
dictate how tracks are put on stack.
g4b::G4Helper * fG4Help
G4 interface object.
garg4::ParticleListAction * fParticleListAction
Geant4 user action to particle information.
std::vector< float > fMaxStepSize
maximum step size in mm per sub-detector region
#define MF_LOG_DEBUG(id)
float fProductionCut
G4 will check if a produced particle should travel this far and drop it if not.
bool fCheckOverlaps
Whether to use the G4 overlap checker.
LArSoft geometry interface.
Definition: ChannelGeo.h:16
static ServiceHandle< RandomNumberGenerator > & rng()
garg4::AuxDetAction * fAuxDetAction
Geant4 user action to handle GAr energy depositions.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
static G4SimulationParameters * CreateInstance(fhicl::ParameterSet const &pset)
fhicl::ParameterSet fAuxDetActionPSet
configuration for AuxAction
gar::garg4::GArG4::~GArG4 ( )
virtual

Definition at line 274 of file GArG4_module.cc.

275  {
276  if(fG4Help) delete fG4Help;
277  }
g4b::G4Helper * fG4Help
G4 interface object.

Member Function Documentation

void gar::garg4::GArG4::beginJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 335 of file GArG4_module.cc.

336  {
337  //auto* rng = &*(::art::ServiceHandle<::art::RandomNumberGenerator>());
338 
339  fG4Help = new g4b::G4Helper(fG4MacroPath, fG4PhysListName);
340  if(fCheckOverlaps) fG4Help->SetOverlapCheck(true);
341  fG4Help->ConstructDetector(geo->GDMLFile()); //TO DO!!! This create a problem when we want to use a custom magnetic field!!! (it calls under the service mag::Magnetic field)
342 
343  G4LogicalVolumeStore *store = G4LogicalVolumeStore::GetInstance();
344  if(store == nullptr) {
345  MF_LOG_INFO("GArG4")
346  << "G4LogicalVolumeStore::GetInstance() not available";
347  }
348 
349  // Get the logical volume store and assign material properties
350  garg4::MaterialPropertyLoader* MPL = new garg4::MaterialPropertyLoader();
351  MPL->GetPropertiesFromServices();
352  MPL->UpdateGeometry(store);
353 
354  this->SetLimitsAndCuts();
355 
356  // Intialize G4 physics and primary generator action
357  fG4Help->InitPhysics();
358 
359  // Use the UserActionManager to handle all the Geant4 user hooks.
360  g4b::UserActionManager* uaManager = g4b::UserActionManager::Instance();
361 
362  // User-action class for accumulating particles and trajectories
363  // produced in the detector.
365 
366  fParticleListAction = new garg4::ParticleListAction(g4SimPars->KineticEnergyCut(),
367  g4SimPars->StoreTrajectories(),
368  g4SimPars->KeepEMShowerDaughters(),
369  g4SimPars->EMShowerDaughterMatRegex());
370 
371  uaManager->AddAndAdoptAction(fParticleListAction);
372 
373 
374  // add UserAction for handling steps in gaseous argon
375  fEDepAction = new garg4::EnergyDepositAction(&(fEngine),
377  uaManager->AddAndAdoptAction(fEDepAction);
378 
379  // add UserAction for handling steps in auxiliary detectors
380  fAuxDetAction = new garg4::AuxDetAction(&(fEngine),
382  uaManager->AddAndAdoptAction(fAuxDetAction);
383 
384 
385  // UserActionManager is now configured so continue G4 initialization
386  fG4Help->SetUserAction();
387 
388  MF_LOG_INFO("GArG4") << "BeginJob() -- end ";
389 
390  return;
391  }
static G4SimulationParameters * Instance()
std::string fG4PhysListName
predefined physics list to use if not making a custom one
std::string fG4MacroPath
executed before main MC processing.
fhicl::ParameterSet fEDepActionPSet
configuration for GArAction
garg4::EnergyDepositAction * fEDepAction
Geant4 user action to handle GAr energy depositions.
CLHEP::HepRandomEngine & fEngine
#define MF_LOG_INFO(category)
g4b::G4Helper * fG4Help
G4 interface object.
garg4::ParticleListAction * fParticleListAction
Geant4 user action to particle information.
bool fCheckOverlaps
Whether to use the G4 overlap checker.
void SetLimitsAndCuts()
Set the user limits and production cuts per region.
LArSoft geometry interface.
Definition: ChannelGeo.h:16
garg4::AuxDetAction * fAuxDetAction
Geant4 user action to handle GAr energy depositions.
fhicl::ParameterSet fAuxDetActionPSet
configuration for AuxAction
void gar::garg4::GArG4::beginRun ( ::art::Run run)

Definition at line 394 of file GArG4_module.cc.

395  {
396  // prepare the filter object (null if no filtering)
397 
398  std::set<std::string> volnameset(fKeepParticlesInVolumes.begin(), fKeepParticlesInVolumes.end());
400 
401  return;
402  }
std::unique_ptr< PositionInVolumeFilter > CreateParticleVolumeFilter(std::set< std::string > const &vol_names) const
Configures and returns a particle filter.
std::vector< std::string > fKeepParticlesInVolumes
Only write particles that have trajectories through these volumes.
garg4::ParticleListAction * fParticleListAction
Geant4 user action to particle information.
void ParticleFilter(std::unique_ptr< PositionInVolumeFilter > &&filter)
Grabs a particle filter.
std::unique_ptr< PositionInVolumeFilter > gar::garg4::GArG4::CreateParticleVolumeFilter ( std::set< std::string > const &  vol_names) const
private

Configures and returns a particle filter.

Definition at line 405 of file GArG4_module.cc.

406  {
407 
408  // if we don't have favourite volumes, don't even bother creating a filter
409  if (vol_names.empty()) return {};
410  std::vector<std::vector<TGeoNode const*>> node_paths = geo->FindAllVolumePaths(vol_names);
411 
412  // collection of interesting volumes
414  GeoVolumePairs.reserve(node_paths.size()); // because we are obsessed
415 
416  //for each interesting volume, follow the node path and collect
417  //total rotations and translations
418  for(auto const& path : node_paths){
419 
420  TGeoTranslation* pTransl = new TGeoTranslation(0.,0.,0.);
421  TGeoRotation* pRot = new TGeoRotation();
422  for (TGeoNode const* node: path) {
423  TGeoTranslation thistranslate(*node->GetMatrix());
424  TGeoRotation thisrotate(*node->GetMatrix());
425  pTransl->Add(&thistranslate);
426  *pRot=*pRot * thisrotate;
427  }
428 
429  //for some reason, pRot and pTransl don't have tr and rot bits set correctly
430  //make new translations and rotations so bits are set correctly
431  TGeoTranslation* pTransl2 = new TGeoTranslation(pTransl->GetTranslation()[0],
432  pTransl->GetTranslation()[1],
433  pTransl->GetTranslation()[2]);
434  double phi=0.,theta=0.,psi=0.;
435  pRot->GetAngles(phi,theta,psi);
436  TGeoRotation* pRot2 = new TGeoRotation();
437  pRot2->SetAngles(phi,theta,psi);
438 
439  TGeoCombiTrans* pTransf = new TGeoCombiTrans(*pTransl2,*pRot2);
440 
441  GeoVolumePairs.emplace_back(path.back()->GetVolume(), pTransf);
442 
443  }
444 
445  return std::make_unique<PositionInVolumeFilter>(std::move(GeoVolumePairs));
446 
447  } // CreateParticleVolumeFilter()
def move(depos, offset)
Definition: depos.py:107
std::vector< VolumeInfo_t > AllVolumeInfo_t
LArSoft geometry interface.
Definition: ChannelGeo.h:16
void gar::garg4::GArG4::produce ( ::art::Event evt)

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

Definition at line 451 of file GArG4_module.cc.

452  {
453  MF_LOG_DEBUG("GArG4") << "produce()";
454 
455  // loop over the lists and put the particles and voxels into the event as collections
456  std::unique_ptr< std::vector<simb::MCParticle> > partCol(new std::vector<simb::MCParticle> );
457  std::unique_ptr< std::vector<sdp::EnergyDeposit> > TPCCol (new std::vector<sdp::EnergyDeposit> );
458  std::unique_ptr< ::art::Assns<simb::MCTruth, simb::MCParticle> > tpassn (new ::art::Assns<simb::MCTruth, simb::MCParticle>);
459  std::unique_ptr< std::vector< sdp::CaloDeposit > > ECALCol (new std::vector<sdp::CaloDeposit> );
460  std::unique_ptr< std::vector< sdp::CaloDeposit > > MuIDCol (new std::vector<sdp::CaloDeposit> );
461  std::unique_ptr< std::vector< sdp::LArDeposit > > LArCol (new std::vector<sdp::LArDeposit> );
462 
463  // reset the track ID offset as we have a new collection of interactions
465 
466  // look to see if there is any MCTruth information for this
467  // event
468  std::vector< ::art::Handle< std::vector<simb::MCTruth> > > mclists;
469  if(fInputLabels.size() < 1)
470  {
471  mclists = evt.getMany< std::vector<simb::MCTruth> >();
472  }
473  else{
474  mclists.resize(fInputLabels.size());
475  for(size_t i = 0; i < fInputLabels.size(); ++i)
476  mclists.at(i) = evt.getHandle< std::vector<simb::MCTruth> >(fInputLabels.at(i));
477  }
478 
479  // create a vector of art::Ptrs to MCTruths for use with the
480  // association creation and a vector of const* for use with
481  // G4Helper
482  std::vector< ::art::Ptr<simb::MCTruth> > mctPtrs;
483  std::vector< const simb::MCTruth* > mcts;
484 
485  for(size_t mc = 0; mc < mclists.size(); ++mc){
486  for(size_t i = 0; i < mclists[mc]->size(); ++i){
487  art::Ptr<simb::MCTruth> ptr(mclists[mc], i);
488  mctPtrs.push_back(ptr);
489  mcts .push_back(ptr.get());
490  }
491  }
492 
493  // Process Geant4 simulation for the mctruths
494  fG4Help->G4Run(mcts);
495 
496  // receive the particle list
497  auto particleList = fParticleListAction->YieldList();
498  auto const trackIDToMCT = fParticleListAction->TrackIDToMCTruthIndexMap();
499 
500  int trackID = std::numeric_limits<int>::max();
501  size_t mctidx = 0;
502  size_t nGeneratedParticles = 0;
503 
504  // Has the user request a detailed dump of the output objects?
505  if (fdumpParticleList){
506  MF_LOG_INFO("GArG4")
507  << "Dump sim::ParticleList; size() = "
508  << particleList.size()
509  << "\n"
510  << particleList;
511  }
512 
513  auto iPartPair = particleList.begin();
514  while (iPartPair != particleList.end()) {
515  simb::MCParticle& p = *(iPartPair->second);
516 
517  trackID = p.TrackId();
518 
519  partCol->push_back(std::move(p));
520  if( trackIDToMCT.count(trackID) > 0){
521 
522  mctidx = trackIDToMCT.find(trackID)->second;
523 
524  util::CreateAssn(*this,
525  evt,
526  *partCol,
527  mctPtrs[mctidx],
528  *tpassn,
529  nGeneratedParticles);
530  }
531  else
532  throw cet::exception("GArG4")
533  << "Cannot find MCTruth for Track Id: "
534  << trackID
535  << " to create association between Particle and MCTruth";
536 
537  // FIXME workaround until https://cdcvs.fnal.gov/redmine/issues/12067
538  // is solved and adopted in GArSoft, after which moving will suffice
539  // to avoid dramatic memory usage spikes;
540  // for now, we immediately disposed of used particles
541  iPartPair = particleList.erase(iPartPair);
542 
543  ++nGeneratedParticles;
544  } // while(particleList)
545 
546 
547  // Now for the sdp::EnergyDepositions
548  for(auto const& tpc : fEDepAction->EnergyDeposits()){
549  MF_LOG_DEBUG("GArG4")
550  << "adding TPC deposits for track id: "
551  << tpc.TrackID();
552 
553  TPCCol->emplace_back(tpc);
554  }
555 
556  // And finally the sdp::CaloDepositions
557  std::vector<gar::sdp::CaloDeposit> deposits = fAuxDetAction->CaloDeposits();
558  if (geo->HasTrackerScDetector())
559  deposits = fAuxDetAction->TrackerScDeposits();
560 
561  for (auto const &hit : deposits)
562  {
563  MF_LOG_DEBUG("GArG4")
564  << "adding calo deposits for track id: "
565  << hit.TrackID();
566 
567  ECALCol->emplace_back(hit);
568  }
569 
570  // And finally the sdp::CaloDepositions
571  for(auto const& hit : fAuxDetAction->MuIDDeposits())
572  {
573  MF_LOG_DEBUG("GArG4")
574  << "adding muid deposits for track id: "
575  << hit.TrackID();
576 
577  MuIDCol->emplace_back(hit);
578  }
579 
580  // And finally the sdp::CaloDepositions
581  for(auto const& hit : fAuxDetAction->LArDeposits())
582  {
583  MF_LOG_DEBUG("GArG4")
584  << "adding LAr deposits for track id: "
585  << hit.TrackID();
586 
587  LArCol->emplace_back(hit);
588  }
589 
590  evt.put(std::move(TPCCol));
591 
592  std::string instanceName = "ECAL";
593  if(geo->HasTrackerScDetector())
594  instanceName = "TrackerSc";
595 
596  evt.put(std::move(ECALCol), instanceName);
597 
598  if(geo->HasMuonDetector())
599  evt.put(std::move(MuIDCol), "MuID");
600 
601  evt.put(std::move(LArCol));
602 
603  evt.put(std::move(partCol));
604  evt.put(std::move(tpassn));
605 
606  return;
607  } // GArG4::produce()
std::vector< gar::sdp::CaloDeposit > const & CaloDeposits() const
Definition: AuxDetAction.h:60
std::vector< gar::sdp::CaloDeposit > const & MuIDDeposits() const
Definition: AuxDetAction.h:64
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
std::string string
Definition: nybbler.cc:12
std::map< int, size_t > TrackIDToMCTruthIndexMap() const
int TrackId() const
Definition: MCParticle.h:210
bool fdumpParticleList
Whether each event&#39;s sim::ParticleList will be displayed.
std::vector< std::string > fInputLabels
garg4::EnergyDepositAction * fEDepAction
Geant4 user action to handle GAr energy depositions.
std::vector< Handle< PROD > > getMany(SelectorBase const &selector=MatchAllSelector{}) const
Definition: DataViewImpl.h:479
def move(depos, offset)
Definition: depos.py:107
p
Definition: test.py:223
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
static int max(int a, int b)
#define MF_LOG_INFO(category)
Detector simulation of raw signals on wires.
g4b::G4Helper * fG4Help
G4 interface object.
std::vector< gar::sdp::LArDeposit > const & LArDeposits() const
Definition: AuxDetAction.h:58
std::vector< gar::sdp::EnergyDeposit > const & EnergyDeposits() const
garg4::ParticleListAction * fParticleListAction
Geant4 user action to particle information.
#define MF_LOG_DEBUG(id)
LArSoft geometry interface.
Definition: ChannelGeo.h:16
std::vector< gar::sdp::CaloDeposit > const & TrackerScDeposits() const
Definition: AuxDetAction.h:62
garg4::AuxDetAction * fAuxDetAction
Geant4 user action to handle GAr energy depositions.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void gar::garg4::GArG4::SetLimitsAndCuts ( )
private

Set the user limits and production cuts per region.

Definition at line 280 of file GArG4_module.cc.

281  {
282  // Regions {TPC, Inner ECAL, Outer ECAL, Endcap ECAL}
283  if(fMaxStepSize.size() != fDetRegionNames.size())
284  {
285  MF_LOG_INFO("GArG4")
286  << "Step size vector has "
287  << fMaxStepSize.size()
288  << " elements != DetRegionName has "
289  << fDetRegionNames.size()
290  << " elements"
291  << " will use default step size of 2 mm";
292  }
293 
294  unsigned int index = 0;
295  for(auto &name : fDetRegionNames)
296  {
297  G4Region* aRegion = new G4Region(name);
298  G4LogicalVolume* calorLogical = G4LogicalVolumeStore::GetInstance()->GetVolume(name);
299  calorLogical->SetRegion(aRegion);
300  aRegion->AddRootLogicalVolume(calorLogical);
301 
302  G4Region* reg = G4RegionStore::GetInstance()->GetRegion(name);
303 
304  MF_LOG_INFO("GArG4")
305  << "Setting production cuts for region "
306  << reg->GetName()
307  << " production cut set to "
309  << " mm";
310 
311  G4ProductionCuts* cuts = new G4ProductionCuts();
312  cuts->SetProductionCut(fProductionCut*CLHEP::mm);
313  reg->SetProductionCuts(cuts);
314 
315  G4UserLimits* limits = new G4UserLimits();
316 
317  if(fMaxStepSize.size() != fDetRegionNames.size())
318  limits->SetMaxAllowedStep(2.0*CLHEP::mm);
319  else{
320  MF_LOG_INFO("GArG4")
321  << "Setting user limits for region "
322  << reg->GetName()
323  << " max step length set to "
324  << fMaxStepSize.at(index)*CLHEP::mm
325  << " mm";
326  limits->SetMaxAllowedStep(fMaxStepSize.at(index)*CLHEP::mm);
327  }
328 
329  reg->SetUserLimits(limits);
330  index++;
331  }
332  }
static QCString name
Definition: declinfo.cpp:673
std::vector< std::string > fDetRegionNames
Name of the volumes used to defined regions.
#define MF_LOG_INFO(category)
std::vector< float > fMaxStepSize
maximum step size in mm per sub-detector region
static constexpr double mm
Definition: Units.h:65
float fProductionCut
G4 will check if a produced particle should travel this far and drop it if not.

Member Data Documentation

garg4::AuxDetAction* gar::garg4::GArG4::fAuxDetAction
private

Geant4 user action to handle GAr energy depositions.

Definition at line 169 of file GArG4_module.cc.

fhicl::ParameterSet gar::garg4::GArG4::fAuxDetActionPSet
private

configuration for AuxAction

Definition at line 172 of file GArG4_module.cc.

bool gar::garg4::GArG4::fCheckOverlaps
private

Whether to use the G4 overlap checker.

Definition at line 177 of file GArG4_module.cc.

std::vector< std::string > gar::garg4::GArG4::fDetRegionNames
private

Name of the volumes used to defined regions.

Definition at line 173 of file GArG4_module.cc.

bool gar::garg4::GArG4::fdumpParticleList
private

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

Definition at line 178 of file GArG4_module.cc.

garg4::EnergyDepositAction* gar::garg4::GArG4::fEDepAction
private

Geant4 user action to handle GAr energy depositions.

Definition at line 168 of file GArG4_module.cc.

fhicl::ParameterSet gar::garg4::GArG4::fEDepActionPSet
private

configuration for GArAction

Definition at line 171 of file GArG4_module.cc.

CLHEP::HepRandomEngine& gar::garg4::GArG4::fEngine
private

Definition at line 195 of file GArG4_module.cc.

g4b::G4Helper* gar::garg4::GArG4::fG4Help
private

G4 interface object.

Definition at line 167 of file GArG4_module.cc.

std::string gar::garg4::GArG4::fG4MacroPath
private

executed before main MC processing.

directory path for Geant4 macro file to be

Definition at line 175 of file GArG4_module.cc.

std::string gar::garg4::GArG4::fG4PhysListName
private

predefined physics list to use if not making a custom one

Definition at line 174 of file GArG4_module.cc.

std::vector<std::string> gar::garg4::GArG4::fInputLabels
private

Definition at line 183 of file GArG4_module.cc.

std::vector<std::string> gar::garg4::GArG4::fKeepParticlesInVolumes
private

Only write particles that have trajectories through these volumes.

Definition at line 184 of file GArG4_module.cc.

std::vector<float> gar::garg4::GArG4::fMaxStepSize
private

maximum step size in mm per sub-detector region

Definition at line 181 of file GArG4_module.cc.

garg4::ParticleListAction* gar::garg4::GArG4::fParticleListAction
private

Geant4 user action to particle information.

Definition at line 170 of file GArG4_module.cc.

float gar::garg4::GArG4::fProductionCut
private

G4 will check if a produced particle should travel this far and drop it if not.

Definition at line 182 of file GArG4_module.cc.

int gar::garg4::GArG4::fSmartStacking
private

dictate how tracks are put on stack.

Whether to instantiate and use class to

Definition at line 179 of file GArG4_module.cc.

const geo::GeometryCore* gar::garg4::GArG4::geo
private

Definition at line 191 of file GArG4_module.cc.


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