All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 // Include guard
25 #ifndef LARG4DETECTOR_SERVICE_HH
26 #define LARG4DETECTOR_SERVICE_HH
27 
28 #include "artg4tk/Core/DetectorBase.hh"
29 
30 #include "art/Framework/Services/Registry/ServiceDeclarationMacros.h"
31 
32 namespace art {
33  class ProducesCollector;
34 }
35 
36 namespace fhicl {
37  class ParameterSet;
38 }
39 
40 class G4HCofThisEvent;
41 class G4LogicalVolume;
42 class G4VPhysicalVolume;
43 
44 #include "Geant4/G4Types.hh"
45 
46 #include <map>
47 #include <string>
48 #include <unordered_map>
49 #include <utility>
50 #include <vector>
51 
52 namespace larg4 {
53 
54  class LArG4DetectorService : public artg4tk::DetectorBase {
55  public:
56  explicit LArG4DetectorService(fhicl::ParameterSet const&);
57 
58  private:
59  std::vector<G4LogicalVolume*> doBuildLVs() override;
60  std::vector<G4VPhysicalVolume*> doPlaceToPVs(std::vector<G4LogicalVolume*>) override;
61 
62  // -- D.R. Set the step limits for specific volumes from the configuration file
63  void setStepLimits();
64 
65  // We need to add something to the art event, so we need these two methods:
66 
67  std::string instanceName(std::string const&) const;
68 
69  // Tell Art what we'll produce
70  void doCallArtProduces(art::ProducesCollector& collector) override;
71 
72  // Actually produce
73  void doFillEventWithArtHits(G4HCofThisEvent* hc) override;
74 
75  std::string gdmlFileName_; // name of the gdml file
76  bool checkOverlaps_; // enable/disable check of overlaps
77  bool updateSimEnergyDeposits_; // enable/disable change of TrackID for Tracks where no MCParticle was created
78  std::vector<std::string> volumeNames_; // list of volume names for which step limits should be set
79  std::vector<float> stepLimits_; // corresponding step limits to be set for each volume in the list of volumeNames, [mm]
80  size_t inputVolumes_; // number of stepLimits to be set
81  bool dumpMP_; // enable/disable dump of material properties
82 
83  std::vector<std::pair<std::string, std::string>> detectors_{};
84  std::map<std::string, G4double> overrideGDMLStepLimit_Map{};
85  std::unordered_map<std::string, float> setGDMLVolumes_{}; // holds all <volume, steplimit> pairs set from the GDML file
86 };
87 }
88 
89 DECLARE_ART_SERVICE(larg4::LArG4DetectorService, LEGACY)
90 
91 #endif // LARG4DETECTOR_SERVICE_HH
void doCallArtProduces(art::ProducesCollector &collector) override
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_
std::vector< std::string > volumeNames_
std::vector< float > stepLimits_
std::vector< G4LogicalVolume * > doBuildLVs() override
std::vector< G4VPhysicalVolume * > doPlaceToPVs(std::vector< G4LogicalVolume * >) override
std::map< std::string, G4double > overrideGDMLStepLimit_Map
std::unordered_map< std::string, float > setGDMLVolumes_