File indexing completed on 2026-09-18 08:32:55
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #include "G04DetectorConstruction.hh"
0030
0031 #include "G04SensitiveDetector.hh"
0032
0033 #include "G4GDMLParser.hh"
0034 #include "G4SDManager.hh"
0035
0036
0037
0038 G04DetectorConstruction::G04DetectorConstruction(const G4GDMLParser& parser)
0039 : G4VUserDetectorConstruction(), fParser(parser)
0040 {}
0041
0042
0043
0044 G4VPhysicalVolume* G04DetectorConstruction::Construct()
0045 {
0046 return fParser.GetWorldVolume();
0047 }
0048
0049
0050
0051 void G04DetectorConstruction::ConstructSDandField()
0052 {
0053
0054
0055
0056
0057 G4SDManager* SDman = G4SDManager::GetSDMpointer();
0058
0059 G4String trackerChamberSDname = "Tracker";
0060 G04SensitiveDetector* aTrackerSD = new G04SensitiveDetector(trackerChamberSDname);
0061 SDman->AddNewDetector(aTrackerSD);
0062
0063
0064
0065
0066
0067 const G4GDMLAuxMapType* auxmap = fParser.GetAuxMap();
0068 G4cout << "Found " << auxmap->size() << " volume(s) with auxiliary information." << G4endl
0069 << G4endl;
0070 for (G4GDMLAuxMapType::const_iterator iter = auxmap->begin(); iter != auxmap->end(); iter++) {
0071 G4cout << "Volume " << ((*iter).first)->GetName()
0072 << " has the following list of auxiliary information: " << G4endl << G4endl;
0073 for (G4GDMLAuxListType::const_iterator vit = (*iter).second.begin();
0074 vit != (*iter).second.end(); vit++)
0075 {
0076 G4cout << "--> Type: " << (*vit).type << " Value: " << (*vit).value << G4endl;
0077 }
0078 }
0079 G4cout << G4endl;
0080
0081
0082
0083
0084 for (G4GDMLAuxMapType::const_iterator iter = auxmap->begin(); iter != auxmap->end(); iter++) {
0085 G4cout << "Volume " << ((*iter).first)->GetName()
0086 << " has the following list of auxiliary information: " << G4endl << G4endl;
0087 for (G4GDMLAuxListType::const_iterator vit = (*iter).second.begin();
0088 vit != (*iter).second.end(); vit++)
0089 {
0090 if ((*vit).type == "SensDet") {
0091 G4cout << "Attaching sensitive detector " << (*vit).value << " to volume "
0092 << ((*iter).first)->GetName() << G4endl << G4endl;
0093
0094 G4VSensitiveDetector* mydet = SDman->FindSensitiveDetector((*vit).value);
0095 if (mydet) {
0096 G4LogicalVolume* myvol = (*iter).first;
0097 myvol->SetSensitiveDetector(mydet);
0098 }
0099 else {
0100 G4cout << (*vit).value << " detector not found" << G4endl;
0101 }
0102 }
0103 }
0104 }
0105 }