LArG4Detector_service.h
Go to the documentation of this file.
1 //=============================================================================
2 // GDMLDetector_service.hh:
3 // GDMLDetectorService is the service that constructs the Geant 4 Geometry
4 // as specified in a gdml file.
5 // To use this service, all you need to do is put it in the services section
6 // of the fcl configuration file, like this:
7 //
8 // <pre>
9 // services: {
10 // ...
11 // user: {
12 // ...
13 // GDMLDetector :
14 // {
15 // category: "world"
16 // gdmlFileName_ : "ta_target.gdml"
17 // }
18 // }
19 // }
20 // </pre>
21 // Author: Hans Wenzel (Fermilab)
22 // Modified: David Rivera - add ability to set step limits for different volumes
23 //=============================================================================
24 
25 // Include guard
26 #ifndef GDMLDETECTOR_SERVICE_HH
27 #define GDMLDETECTOR_SERVICE_HH
28 
29 // Includes
32 #include "fhiclcpp/ParameterSet.h"
34 
35 #include "Geant4/G4GDMLParser.hh"
36 #include "Geant4/G4LogicalVolume.hh"
37 #include "Geant4/G4LogicalVolumeStore.hh"
38 #include "Geant4/G4VPhysicalVolume.hh"
39 #include <string>
40 #include <unordered_map>
41 #include <vector>
42 
43 // Get the base class
44 #include "artg4tk/Core/DetectorBase.hh"
45 
46 namespace larg4 {
47 
48  class LArG4DetectorService : public artg4tk::DetectorBase {
49  public:
51 
52  private:
53  std::vector<G4LogicalVolume*> doBuildLVs() override;
54  std::vector<G4VPhysicalVolume*> doPlaceToPVs(std::vector<G4LogicalVolume*>) override;
55 
56  // -- D.R. Set the step limits for specific volumes from the configuration file
57  void setStepLimits();
58 
59  // We need to add something to the art event, so we need these two methods:
60 
61  std::string instanceName(std::string const&) const;
62 
63  // Tell Art what we'll produce
64  void doCallArtProduces(art::ProducesCollector& collector) override;
65 
66  // Actually produce
67  void doFillEventWithArtHits(G4HCofThisEvent* hc) override;
68 
69  std::string gdmlFileName_; // name of the gdml file
70  bool checkOverlaps_; // enable/disable check of overlaps
71  std::vector<std::string> volumeNames_; // list of volume names for which step limits should be set
72  std::vector<float> stepLimits_; // corresponding step limits to be set for each volume in the list of volumeNames, [mm]
73  size_t inputVolumes_; // number of stepLimits to be set
74  bool dumpMP_; // enable/disable dump of material properties
75 
76  std::vector<std::pair<std::string, std::string>> detectors_{};
77  std::map<std::string, G4double> overrideGDMLStepLimit_Map{};
78  std::unordered_map<std::string, float> setGDMLVolumes_{}; // holds all <volume, steplimit> pairs set from the GDML file
79 };
80 }
81 
83 
84 #endif
std::string string
Definition: nybbler.cc:12
std::vector< G4LogicalVolume * > doBuildLVs() override
void doCallArtProduces(art::ProducesCollector &collector) override
Geant4 interface.
void doFillEventWithArtHits(G4HCofThisEvent *hc) override
LArG4DetectorService(fhicl::ParameterSet const &)
std::string instanceName(std::string const &) const
std::vector< std::pair< std::string, std::string > > detectors_
#define DECLARE_ART_SERVICE(svc, scope)
std::vector< std::string > volumeNames_
std::vector< G4VPhysicalVolume * > doPlaceToPVs(std::vector< G4LogicalVolume * >) override
std::vector< float > stepLimits_
std::map< std::string, G4double > overrideGDMLStepLimit_Map
std::unordered_map< std::string, float > setGDMLVolumes_