Creating your own detectors in ArtG4

To create your own detector in ArtG4, you need to write an Art service that,

  • Inherits from artg4::DetectorBase
  • Calls the DetectorBase constructor with the fhicl::ParameterSet, the name of the detector, the category of the detector, and the category of the mother volume (use empty string for world)
  • Overrides std::vector<G4LogicalVolume*> doBuildLVs(). This member function returns a vector of logical volumes (if there's only one detector, then the vector has size 1)
  • Overrides std::vector<G4VPhysicalVolume*> doPlaceToPVs(std::vector<G4LogicalVolume*>) This member function accepts a vector of mother logical volumes and places the logical volumes stored internally (accessible with the lvs() accessor) within. These physical volumes are returned.

If your detector produces hits, you need to also,

  • Override void doCallArtProduces(art::EDProducer * producer) and call producer->produces<MyProduct>(instance_label)
  • Override void doFillEventWithArtHits(G4HCofThisEvent* hc) and create your Art hits. Put them into the event. You can get the event with,
    art::ServiceHandle<artg4::DetectorHolderService> detectorHolder;
    art::Event & e = detectorHolder -> getCurrArtEvent();