File indexing completed on 2025-02-23 09:22:37
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
0030 #include "G04DetectorConstruction.hh"
0031
0032 #include "G04SensitiveDetector.hh"
0033
0034 #include "G4GDMLParser.hh"
0035 #include "G4SDManager.hh"
0036
0037
0038
0039 G04DetectorConstruction::G04DetectorConstruction(const G4GDMLParser& parser)
0040 : G4VUserDetectorConstruction(), fParser(parser)
0041 {}
0042
0043
0044
0045 G4VPhysicalVolume* G04DetectorConstruction::Construct()
0046 {
0047 return fParser.GetWorldVolume();
0048 }
0049
0050
0051
0052 void G04DetectorConstruction::ConstructSDandField()
0053 {
0054
0055
0056
0057
0058 G4SDManager* SDman = G4SDManager::GetSDMpointer();
0059
0060 G4String trackerChamberSDname = "Tracker";
0061 G04SensitiveDetector* aTrackerSD = new G04SensitiveDetector(trackerChamberSDname);
0062 SDman->AddNewDetector(aTrackerSD);
0063
0064
0065
0066
0067
0068 const G4GDMLAuxMapType* auxmap = fParser.GetAuxMap();
0069 G4cout << "Found " << auxmap->size() << " volume(s) with auxiliary information." << G4endl
0070 << G4endl;
0071 for (G4GDMLAuxMapType::const_iterator iter = auxmap->begin(); iter != auxmap->end(); iter++) {
0072 G4cout << "Volume " << ((*iter).first)->GetName()
0073 << " has the following list of auxiliary information: " << G4endl << G4endl;
0074 for (G4GDMLAuxListType::const_iterator vit = (*iter).second.begin();
0075 vit != (*iter).second.end(); vit++)
0076 {
0077 G4cout << "--> Type: " << (*vit).type << " Value: " << (*vit).value << G4endl;
0078 }
0079 }
0080 G4cout << G4endl;
0081
0082
0083
0084
0085 for (G4GDMLAuxMapType::const_iterator iter = auxmap->begin(); iter != auxmap->end(); iter++) {
0086 G4cout << "Volume " << ((*iter).first)->GetName()
0087 << " has the following list of auxiliary information: " << G4endl << G4endl;
0088 for (G4GDMLAuxListType::const_iterator vit = (*iter).second.begin();
0089 vit != (*iter).second.end(); vit++)
0090 {
0091 if ((*vit).type == "SensDet") {
0092 G4cout << "Attaching sensitive detector " << (*vit).value << " to volume "
0093 << ((*iter).first)->GetName() << G4endl << G4endl;
0094
0095 G4VSensitiveDetector* mydet = SDman->FindSensitiveDetector((*vit).value);
0096 if (mydet) {
0097 G4LogicalVolume* myvol = (*iter).first;
0098 myvol->SetSensitiveDetector(mydet);
0099 }
0100 else {
0101 G4cout << (*vit).value << " detector not found" << G4endl;
0102 }
0103 }
0104 }
0105 }
0106 }