LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
DetectorHolder_service.hh
Go to the documentation of this file.
1 // Declarations for the @DetectorHolderService@ Art service.
2 
3 // @DetectorHolderService@ is a globally-accessible service that manages the
4 // simulation geometry and detector components. All geometry construction
5 // occurs in classes derived from @DetectorBase@, which are registered with
6 // the service at Art's @beginJob@. Registration of a detector requires that
7 // the detector's logical volumes be constructed, and allows for the placement
8 // of these volumes to create the detector physical volume. Furthermore,
9 // detector objects can, if they choose, overload @DetectorBase@'s
10 // @convertGeantToArtHits@ method, which is called at the end of each event,
11 // to construct artized hits for the event.
12 
13 // Any class can @#include@ and access the @DetectorHolderService@ service to get
14 // the collection of registered geometry components, retrieve parameter sets
15 // describing geometry and detector configuration, or get a single detector
16 // object of a given category.
17 
18 // Authors: Tasha Arvanitis, Adam Lyon
19 // Date: July 2012
20 
21 #ifndef artg4tk_services_DetectorHolder_service_hh
22 #define artg4tk_services_DetectorHolder_service_hh
23 
24 // Includes
25 #include "art/Framework/Core/fwd.h"
28 #include "fhiclcpp/fwd.h"
29 
30 #include <map>
31 
32 class G4HCofThisEvent;
33 class G4VPhysicalVolume;
34 
35 // Everything for the Art G4 simulation goes in the @artg4tk@ namespace
36 namespace artg4tk {
37 
38  class DetectorBase;
39 
41  public:
42  // Constructor for GeometryHolder
44 
45  // This registers the passed detector with the service.
46  void registerDetector(DetectorBase* const db);
47 
48  // Initialize - run initialize on all detectors after the particle list is set up
49  void initialize();
50 
51  // This returns the world physical volume, if it has been fully
52  // constructed, and throws an exception otherwise
53  // This can't be const because, if the world hasn't already been set up,
54  // it constructs all the physical volumes, and thus changes its member
55  // data.
56  G4VPhysicalVolume* worldPhysicalVolume();
57 
58  // This returns the map of detectors we have been passed so far.
59  // std::map<std::string, DetectorBase *> const & getDetectorMap() const;
60 
61  // Returns a pointer to the DetectorBase for the given category, if it
62  // exists. If the category was never registered, it throws an
63  // exception.
64  DetectorBase* getDetectorForCategory(std::string category) const;
65 
66  // Returns the FHiCL parameter set for the given category, if it exists.
67  // If the category was never registered, it throws an exception.
68  fhicl::ParameterSet const getParametersForCategory(std::string category);
69 
70  // Tell Art what the detectors produce
72 
73  // Convert GEANT4 hits to Art hits and put them in the event.
75 
76  // Set/get the current Art event
77  void
79  {
81  }
82  art::Event&
84  {
85  return *currentArtEvent_;
86  }
87 
88  // Construct all the logical volumes.
89  void constructAllLVs();
90 
91  private:
92  // Construct all the physical volumes and assign the world physical volume
93  // to worldPV_.
94  void constructAllPVs();
95 
96  // Add the passed DetectorBase to our category map (a complete list
97  // of the detector services we have so far). The key is the DB's category
98  // (without repeats), and the value is a pointer to the DB.
99  void addDBtoCategoryMap(DetectorBase* const db);
100 
101  // Find the given detector's mother logical volume and pass it on to the
102  // given detector.
103  void placeDetector(DetectorBase* const db);
104 
105  // A complete map containing all of the detectors that
106  // have registered with us so far. Key: DB's category (a string).
107  // Value: pointer to the DetectorBase object.
108  // Repeated keys not permitted!
109  std::map<std::string, DetectorBase*> categoryMap_;
110 
111  // Hold on to the world physical volume so we can return it later.
112  G4VPhysicalVolume* worldPV_;
113 
114  // Hold on to the current Art event
116  };
117 
118 } // end namespace artg4tk
119 
121 
122 #endif /* artg4tk_services_DetectorHolder_service_hh */
G4VPhysicalVolume * worldPhysicalVolume()
DetectorHolderService(fhicl::ParameterSet const &)
fhicl::ParameterSet const getParametersForCategory(std::string category)
std::map< std::string, DetectorBase * > categoryMap_
void placeDetector(DetectorBase *const db)
void addDBtoCategoryMap(DetectorBase *const db)
void registerDetector(DetectorBase *const db)
#define DECLARE_ART_SERVICE(svc, scope)
DetectorBase * getDetectorForCategory(std::string category) const
void callArtProduces(art::ProducesCollector &)
void fillEventWithArtHits(G4HCofThisEvent *hc)
Float_t e
Definition: plot.C:35