GArG4_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file GArG4.cxx
3 /// \brief Use Geant4 to run the GArSoft detector simulation
4 ///
5 /// \version $Id: GArG4.cxx,v 1.22 2010/07/20 06:08:30 bjpjones Exp $
6 /// \author seligman@nevis.columbia.edu
7 ////////////////////////////////////////////////////////////////////////
8 
9 /// This a module. It has the following functions:
10 ///
11 /// - Initialize Geant4 physics, detector geometry, and other
12 /// processing.
13 ///
14 /// - Accept sim::MCTruth objects from the MC branch of the FMWK
15 /// Event structure.
16 ///
17 /// - Pass the primary particles to the Geant4 simulation to calculate
18 /// "truth" information for the detector response.
19 ///
20 /// - Pass the truth information to the DetSim branch of the FMWK event.
21 
22 #ifndef GARG4GARG4H
23 #define GARG4GARG4H 1
24 
25 #include "nug4/G4Base/G4Helper.h"
26 #include "nug4/G4Base/ConvertMCTruthToG4.h"
27 
28 // C++ Includes
29 #include <sstream> // std::ostringstream
30 #include <vector> // std::ostringstream
31 #include <map> // std::ostringstream
32 #include <set> // std::ostringstream
33 #include <iostream>
34 // #include <cstring>
35 #include <sys/stat.h>
36 
37 // Framework includes
41 #include "fhiclcpp/ParameterSet.h"
48 #include "cetlib_except/exception.h"
49 #include "cetlib/search_path.h"
50 
51 // nutools extensions
53 #include "nug4/ParticleNavigation/ParticleList.h"
54 #include "nug4/G4Base/DetectorConstruction.h"
55 #include "nug4/G4Base/UserActionManager.h"
56 #include "nurandom/RandomUtils/NuRandomService.h"
57 
58 // GArSoft Includes
59 #include "GArG4/AuxDetAction.h"
61 #include "GArG4/PhysicsList.h"
64 #include "GArG4/ParticleFilters.h" // garg4::PositionInVolumeFilter
66 #include "Utilities/AssociationUtil.h"
70 #include "Geometry/GeometryGAr.h"
71 #include "CoreUtils/ServiceUtil.h"
72 
73 // G4 Includes
74 #include "Geant4/G4RunManager.hh"
75 #include "Geant4/G4UImanager.hh"
76 #include "Geant4/G4VUserDetectorConstruction.hh"
77 #include "Geant4/G4VUserPrimaryGeneratorAction.hh"
78 #include "Geant4/G4VUserPhysicsList.hh"
79 #include "Geant4/G4UserRunAction.hh"
80 #include "Geant4/G4UserEventAction.hh"
81 #include "Geant4/G4UserTrackingAction.hh"
82 #include "Geant4/G4UserSteppingAction.hh"
83 #include "Geant4/G4UserStackingAction.hh"
84 #include "Geant4/G4VisExecutive.hh"
85 #include "Geant4/G4VUserPhysicsList.hh"
86 #include "Geant4/G4SDManager.hh"
87 #include "Geant4/G4LogicalVolumeStore.hh"
88 #include "Geant4/G4RegionStore.hh"
89 #include "Geant4/Randomize.hh"
90 #include "Geant4/G4SDManager.hh"
91 #include "Geant4/G4VSensitiveDetector.hh"
92 #include "Geant4/globals.hh"
93 #include "Geant4/G4ProductionCuts.hh"
94 #include "Geant4/G4UserLimits.hh"
95 
96 // ROOT Includes
97 #include "TGeoManager.h"
98 
99 // Forward declarations
100 class G4RunManager;
101 class G4UImanager;
102 class G4VisExecutive;
103 
104 ///Geant4 interface
105 namespace gar {
106  namespace garg4 {
107 
108  // Forward declarations within namespace.
109  class ParticleListAction;
110 
111  /**
112  * @brief Runs Geant4 simulation and propagation of electrons and photons to readout
113  *
114  *
115  * Randomness
116  * -----------
117  *
118  * The random number generators used by this process are:
119  * - 'GEANT' instance: used by Geant4
120  * - 'propagation' instance: used in electron propagation
121  * - 'radio' instance: used for radiological decay
122  *
123  *
124  * Configuration parameters
125  * -------------------------
126  *
127  * - <b>G4PhysListName</b> (string, default "garg4::PhysicsList"):
128  * whether to use the G4 overlap checker, which catches different issues than ROOT
129  * - <b>CheckOverlaps</b> (bool, default false):
130  * whether to use the G4 overlap checker
131  * - <b>DumpParticleList</b> (bool, default false):
132  * whether to print all MCParticles tracked
133  * - <b>SmartStacking</b> (int, default 0):
134  * whether to use class to dictate how tracks are put on stack (nonzero is on)
135  * - <b>KeepParticlesInVolumes</b> (vector<string>, default empty):
136  * list of volumes in which to keep MCParticles (empty keeps all)
137  * - <b>GeantCommandFile</b> (string, required):
138  * G4 macro file to pass to G4Helper for setting G4 command
139  * - <b>Seed</b> (pset key, not defined by default): if defined, override the seed for
140  * random number generator used in Geant4 simulation (which is obtained from
141  * NuRandomService by default)
142  * - <b>PropagationSeed</b> (pset key, not defined by default): if defined,
143  * override the seed for the random generator used for electrons propagation
144  * to the wire planes (obtained from the NuRandomService by default)
145  * - <b>RadioSeed</b> (pset key, not defined by default): if defined,
146  * override the seed for the random generator used for radiological decay
147  * (obtained from the NuRandomService by default)
148  * - <b>InputLabels</b> (vector<string>, defualt unnecessary):
149  * optional list of generator labels which produce MCTruth;
150  * otherwise look for anything that has made MCTruth
151  */
152  class GArG4 : public ::art::EDProducer{
153  public:
154 
155  /// Standard constructor and destructor for an FMWK module.
156  explicit GArG4(fhicl::ParameterSet const& pset);
157  virtual ~GArG4();
158 
159  /// The main routine of this module: Fetch the primary particles
160  /// from the event, simulate their evolution in the detctor, and
161  /// produce the detector response.
162  void produce (::art::Event& evt);
163  void beginJob();
164  void beginRun(::art::Run& run);
165 
166  private:
167  g4b::G4Helper* fG4Help; ///< G4 interface object
168  garg4::EnergyDepositAction* fEDepAction; ///< Geant4 user action to handle GAr energy depositions
169  garg4::AuxDetAction* fAuxDetAction; ///< Geant4 user action to handle GAr energy depositions
170  garg4::ParticleListAction* fParticleListAction; ///< Geant4 user action to particle information.
171  fhicl::ParameterSet fEDepActionPSet; ///< configuration for GArAction
172  fhicl::ParameterSet fAuxDetActionPSet; ///< configuration for AuxAction
173  std::vector< std::string > fDetRegionNames; ///< Name of the volumes used to defined regions
174  std::string fG4PhysListName; ///< predefined physics list to use if not making a custom one
175  std::string fG4MacroPath; ///< directory path for Geant4 macro file to be
176  ///< executed before main MC processing.
177  bool fCheckOverlaps; ///< Whether to use the G4 overlap checker
178  bool fdumpParticleList; ///< Whether each event's sim::ParticleList will be displayed.
179  int fSmartStacking; ///< Whether to instantiate and use class to
180  ///< dictate how tracks are put on stack.
181  std::vector<float> fMaxStepSize; ///< maximum step size in mm per sub-detector region
182  float fProductionCut; ///< G4 will check if a produced particle should travel this far and drop it if not
183  std::vector<std::string> fInputLabels;
184  std::vector<std::string> fKeepParticlesInVolumes; ///<Only write particles that have trajectories through these volumes
185 
186  /// Configures and returns a particle filter
187  std::unique_ptr<PositionInVolumeFilter> CreateParticleVolumeFilter
188  (std::set<std::string> const& vol_names) const;
189 
190  //Geometry
192 
193  ///Set the user limits and production cuts per region
194  void SetLimitsAndCuts();
195  CLHEP::HepRandomEngine &fEngine;
196 
197  };
198 
199  } // namespace garg4
200 
201  namespace garg4 {
202 
203  //----------------------------------------------------------------------
204  // Constructor
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  }
271 
272  //----------------------------------------------------------------------
273  // Destructor
275  {
276  if(fG4Help) delete fG4Help;
277  }
278 
279  //----------------------------------------------------------------------
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  }
333 
334  //----------------------------------------------------------------------
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
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
377  uaManager->AddAndAdoptAction(fEDepAction);
378 
379  // add UserAction for handling steps in auxiliary detectors
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  }
392 
393  //--------------------------------------------------------------------------
394  void GArG4::beginRun(::art::Run& /* run */)
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  }
403 
404  //--------------------------------------------------------------------------
405  std::unique_ptr<PositionInVolumeFilter> GArG4::CreateParticleVolumeFilter(std::set<std::string> const& vol_names) const
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()
448 
449 
450  //--------------------------------------------------------------------------
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()
608 
609  } // namespace garg4
610 
611  namespace garg4 {
612 
614 
615  } // namespace garg4
616 } // gar
617 #endif // GARG4GARG4H
static QCString name
Definition: declinfo.cpp:673
GArG4(fhicl::ParameterSet const &pset)
Standard constructor and destructor for an FMWK module.
base_engine_t & createEngine(seed_t seed)
std::vector< gar::sdp::CaloDeposit > const & CaloDeposits() const
Definition: AuxDetAction.h:60
std::unique_ptr< PositionInVolumeFilter > CreateParticleVolumeFilter(std::set< std::string > const &vol_names) const
Configures and returns a particle filter.
Runs Geant4 simulation and propagation of electrons and photons to readout.
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
const geo::GeometryCore * geo
static G4SimulationParameters * Instance()
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
void UpdateGeometry(G4LogicalVolumeStore *)
void produces(std::string const &instanceName={}, Persistable const persistable=Persistable::Yes)
Description of geometry of one entire detector.
Definition: GeometryCore.h:436
list of energy deposits from Geant4
std::map< int, size_t > TrackIDToMCTruthIndexMap() const
std::string fG4PhysListName
predefined physics list to use if not making a custom one
Definition: Run.h:17
int TrackId() const
Definition: MCParticle.h:210
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
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
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.
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
CLHEP::HepRandomEngine & fEngine
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.
void beginRun(::art::Run &run)
int fSmartStacking
dictate how tracks are put on stack.
std::vector< VolumeInfo_t > AllVolumeInfo_t
General GArSoft Utilities.
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.
std::vector< float > fMaxStepSize
maximum step size in mm per sub-detector region
#define MF_LOG_DEBUG(id)
std::string find_file(std::string const &filename) const
Definition: search_path.cc:96
void produce(::art::Event &evt)
static constexpr double mm
Definition: Units.h:65
list of energy deposits from Geant4
Definition: AuxDetAction.h:39
void ParticleFilter(std::unique_ptr< PositionInVolumeFilter > &&filter)
Grabs a particle filter.
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.
void SetLimitsAndCuts()
Set the user limits and production cuts per region.
TCEvent evt
Definition: DataStructs.cxx:7
T const * get() const
Definition: Ptr.h:149
LArSoft geometry interface.
Definition: ChannelGeo.h:16
art framework interface to geometry description
std::vector< gar::sdp::CaloDeposit > const & TrackerScDeposits() const
Definition: AuxDetAction.h:62
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