diff --git a/examples/noviceN04/exampleN04.cc b/examples/noviceN04/exampleN04.cc index db0e2178b7e78a032cd70579e14ff3b229dcb9f8..d9b2ac3b151d27b92dc4281f1bf00c5fbada5f38 100644 --- a/examples/noviceN04/exampleN04.cc +++ b/examples/noviceN04/exampleN04.cc @@ -69,8 +69,8 @@ int main(int argc,char** argv) if( argc < 3 ){ std::cout << " --- Usage: \n " - << " [1] exampleN04 file:../DDExamples/ILDExDet/compact/ILDEx.xml file:../DDExamples/ILDExDet/compact/geant4.xml run1_g4.mac \n" - << " [2] exampleN04 -i file:../DDExamples/ILDExDet/compact/ILDEx.xml file:../DDExamples/ILDExDet/compact/geant4.xml \n" + << " [1] exampleN04 file:../compact/N04.xml file:../compact/geant4.xml ../exampleN04.in \n" + << " [2] exampleN04 -i file:../compact/N04.xml file:../compact/geant4.xml \n" << " [1]: batch mode - [2]: interactive " << std::endl ; exit( 0 ) ; } diff --git a/examples/noviceN04/src/SDWrapper.cc b/examples/noviceN04/src/SDWrapper.cc index 8c713d274301ef76d08262025f3582093ae9e4a9..9686d18be8d138a1986b88cd6035f66a0bfcfb4d 100644 --- a/examples/noviceN04/src/SDWrapper.cc +++ b/examples/noviceN04/src/SDWrapper.cc @@ -11,48 +11,84 @@ namespace DD4hep { namespace Simulation { - /** Factory class to create an instance of ExN04CalorimeterSD + /** Factory method to create an instance of ExN04CalorimeterSD */ - class DD4hepExN04CalorimeterSD : public DD4hep::Simulation::G4SDFactory { - public: - virtual G4VSensitiveDetector* createSD(const std::string& name, Geometry::LCDD& lcdd){ - - G4String calorimeterSDname = "/mydet/calorimeter"; - ExN04CalorimeterSD * calorimeterSD = new ExN04CalorimeterSD(calorimeterSDname); - G4String ROgeometryName = "CalorimeterROGeom"; - G4VReadOutGeometry* calRO = new ExN04CalorimeterROGeometry(ROgeometryName); - calRO->BuildROGeometry(); - calRO->SetName(ROgeometryName); - calorimeterSD->SetROgeometry(calRO); - return calorimeterSD ; - } - } ; - /** Factory class to create an instance of ExN04TrackerSD + static G4VSensitiveDetector* create_calo_sd(const std::string& name, DD4hep::Geometry::LCDD& lcdd) { + G4String calorimeterSDname = "/mydet/calorimeter"; + ExN04CalorimeterSD * calorimeterSD = new ExN04CalorimeterSD(calorimeterSDname); + G4String ROgeometryName = "CalorimeterROGeom"; + G4VReadOutGeometry* calRO = new ExN04CalorimeterROGeometry(ROgeometryName); + calRO->BuildROGeometry(); + calRO->SetName(ROgeometryName); + calorimeterSD->SetROgeometry(calRO); + + std::cout << "############ create_calo_sd : " << name << std::endl ; + return calorimeterSD ; + } + + /** Factory method to create an instance of ExN04TrackerSD */ - class DD4hepExN04TrackerSD : public DD4hep::Simulation::G4SDFactory{ - public: - virtual G4VSensitiveDetector* createSD(const std::string& name, Geometry::LCDD& lcdd){ - G4String trackerSDname = "/mydet/tracker"; - return new ExN04TrackerSD(trackerSDname); - } - } ; - - /** Factory class to create an instance of ExN04MuonSD + static G4VSensitiveDetector* create_tracker_sd(const std::string& name, DD4hep::Geometry::LCDD& lcdd) { + G4String trackerSDname = "/mydet/tracker"; + + std::cout << "############ create_tracker_sd : " << name << std::endl ; + return new ExN04TrackerSD(trackerSDname); + } + + + /** Factory method to create an instance of ExN04MuonSD */ - class DD4hepExN04MuonSD : public DD4hep::Simulation::G4SDFactory{ - public: - virtual G4VSensitiveDetector* createSD(const std::string& name, Geometry::LCDD& lcdd){ - G4String muonSDname = "/mydet/muon"; - return new ExN04MuonSD(muonSDname); - } - } ; + static G4VSensitiveDetector* create_muon_sd(const std::string& name, DD4hep::Geometry::LCDD& lcdd) { + G4String muonSDname = "/mydet/muon"; + + std::cout << "############ create_muon_sd : " << name << std::endl ; + return new ExN04MuonSD(muonSDname); + } + + // /** Factory class to create an instance of ExN04CalorimeterSD + // */ + // class DD4hepExN04CalorimeterSD : public DD4hep::Simulation::G4SDFactory { + // public: + // virtual G4VSensitiveDetector* createSD(const std::string& name, Geometry::LCDD& lcdd){ + + // G4String calorimeterSDname = "/mydet/calorimeter"; + // ExN04CalorimeterSD * calorimeterSD = new ExN04CalorimeterSD(calorimeterSDname); + // G4String ROgeometryName = "CalorimeterROGeom"; + // G4VReadOutGeometry* calRO = new ExN04CalorimeterROGeometry(ROgeometryName); + // calRO->BuildROGeometry(); + // calRO->SetName(ROgeometryName); + // calorimeterSD->SetROgeometry(calRO); + // return calorimeterSD ; + // } + // } ; + // /** Factory class to create an instance of ExN04TrackerSD + // */ + // class DD4hepExN04TrackerSD : public DD4hep::Simulation::G4SDFactory{ + // public: + // virtual G4VSensitiveDetector* createSD(const std::string& name, Geometry::LCDD& lcdd){ + // G4String trackerSDname = "/mydet/tracker"; + // return new ExN04TrackerSD(trackerSDname); + // } + // } ; + + // /** Factory class to create an instance of ExN04MuonSD + // */ + // class DD4hepExN04MuonSD : public DD4hep::Simulation::G4SDFactory{ + // public: + // virtual G4VSensitiveDetector* createSD(const std::string& name, Geometry::LCDD& lcdd){ + // G4String muonSDname = "/mydet/muon"; + // return new ExN04MuonSD(muonSDname); + // } + // } ; } } // End namespace DD4hep::Simulation -DECLARE_G4SDFACTORY(DD4hepExN04CalorimeterSD) -DECLARE_G4SDFACTORY(DD4hepExN04MuonSD) -DECLARE_G4SDFACTORY(DD4hepExN04TrackerSD) - +// DECLARE_G4SDFACTORY(DD4hepExN04CalorimeterSD) +// DECLARE_G4SDFACTORY(DD4hepExN04MuonSD) +// DECLARE_G4SDFACTORY(DD4hepExN04TrackerSD) +DECLARE_EXTERNAL_GEANT4SENSITIVEDETECTOR(DD4hepExN04CalorimeterSD,create_calo_sd) +DECLARE_EXTERNAL_GEANT4SENSITIVEDETECTOR(DD4hepExN04TrackerSD,create_tracker_sd) +DECLARE_EXTERNAL_GEANT4SENSITIVEDETECTOR(DD4hepExN04MuonSD,create_muon_sd)