Geant4  10.02
Par02DetectorConstruction.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // $Id: $
27 //
30 
32 #include "G4ProductionCuts.hh"
33 #include "G4SystemOfUnits.hh"
34 #include "G4RegionStore.hh"
35 #include "G4GDMLParser.hh"
36 #include "G4AutoDelete.hh"
37 
38 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
39 
41 
42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
43 
45 
46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
47 
50  parser.Read( "Par02FullDetector.gdml" );
51  G4cout << "Geometry loaded from file .......Par02FullDetector.gdml " << G4endl;
52 
53  // This GDML detector description uses the auxiliary information part to store
54  // information regarding which Geant4 volumes have a fast simulation model.
55 
56  const G4GDMLAuxMapType* aAuxMap = parser.GetAuxMap();
57  for ( G4GDMLAuxMapType::const_iterator iter = aAuxMap->begin();
58  iter != aAuxMap->end(); ++iter ) {
59  for ( G4GDMLAuxListType::const_iterator vit = (*iter).second.begin();
60  vit != (*iter).second.end(); ++vit ) {
61  if ( (*vit).type == "FastSimModel" ) {
62  G4LogicalVolume* myvol = (*iter).first;
63  if ( ( myvol->GetName() ).find( "Tracker" ) != std::string::npos ) {
64  fTrackerList.push_back( new G4Region( myvol->GetName() ) );
65  fTrackerList.back()->AddRootLogicalVolume( myvol );
66  } else if ( ( myvol->GetName() ).find( "HCal" ) != std::string::npos ) {
67  fHCalList.push_back( new G4Region( myvol->GetName() ) );
68  fHCalList.back()->AddRootLogicalVolume( myvol );
69  } else if ( ( myvol->GetName() ).find( "ECal" ) != std::string::npos ) {
70  fECalList.push_back( new G4Region( myvol->GetName() ) );
71  fECalList.back()->AddRootLogicalVolume( myvol );
72  } else if ( ( myvol->GetName() ).find( "Muon" ) != std::string::npos ) {
73  fMuonList.push_back( new G4Region( myvol->GetName() ) );
74  fMuonList.back()->AddRootLogicalVolume( myvol );
75  } else {
76  G4cout << G4endl << "NOT A KNOWN DETECTOR !!!" << G4endl;
77  }
78  }
79  }
80  }
81  for ( G4int iterTracker = 0; iterTracker < G4int( fTrackerList.size() );
82  iterTracker++ ) {
83  fTrackerList[ iterTracker ]->SetProductionCuts( new G4ProductionCuts() );
84  fTrackerList[ iterTracker ]->GetProductionCuts()->SetProductionCut
85  ( 1.0* ( ( *fTrackerList[ iterTracker ]->GetRootLogicalVolumeIterator() )->
86  GetMaterial()->GetRadlen() ) );
87  fTrackerList[ iterTracker ]->GetProductionCuts()->
88  SetProductionCut( 1.0*m, idxG4GammaCut );
89  }
90  for ( G4int iterECal = 0; iterECal < G4int( fECalList.size() ); iterECal++ ) {
91  fECalList[ iterECal ]->SetProductionCuts( new G4ProductionCuts() );
92  fECalList[ iterECal ]->GetProductionCuts()->SetProductionCut
93  ( 0.5* ( ( *fECalList[ iterECal ]->GetRootLogicalVolumeIterator() )->
94  GetMaterial()->GetRadlen() ) );
95  fECalList[ iterECal ]->GetProductionCuts()->
96  SetProductionCut( 0.1*m, idxG4GammaCut );
97  }
98  for ( G4int iterHCal = 0; iterHCal < G4int( fHCalList.size() ); iterHCal++ ) {
99  fHCalList[ iterHCal ]->SetProductionCuts( new G4ProductionCuts() );
100  fHCalList[ iterHCal ]->GetProductionCuts()->SetProductionCut(
101  0.5* ( ( *fHCalList[iterHCal]->GetRootLogicalVolumeIterator() )->
102  GetMaterial()->GetRadlen() ) );
103  fHCalList[ iterHCal ]->GetProductionCuts()->
104  SetProductionCut( 1.0*m, idxG4GammaCut );
105  }
106 
107  // Returns the pointer to the physical world.
108  return parser.GetWorldVolume();
109 }
110 
111 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
112 
114  for ( G4int iterTracker = 0; iterTracker < G4int( fTrackerList.size() );
115  iterTracker++ ) {
116  // Bound the fast simulation model for the tracker subdetector
117  // to all the corresponding Geant4 regions
118  Par02FastSimModelTracker* fastSimModelTracker
119  = new Par02FastSimModelTracker( "fastSimModelTracker", fTrackerList[ iterTracker ],
121 
122  // Register the fast simulation model for deleting
123  G4AutoDelete::Register(fastSimModelTracker);
124  }
125  for ( G4int iterECal = 0; iterECal < G4int( fECalList.size() ); iterECal++ ) {
126  // Bound the fast simulation model for the electromagnetic calorimeter
127  // to all the corresponding Geant4 regions
128  Par02FastSimModelEMCal* fastSimModelEMCal
129  = new Par02FastSimModelEMCal( "fastSimModelEMCal", fECalList[ iterECal ],
131 
132  // Register the fast simulation model for deleting
133  G4AutoDelete::Register(fastSimModelEMCal);
134  }
135  for ( G4int iterHCal = 0; iterHCal < G4int( fHCalList.size() ); iterHCal++ ) {
136  // Bound the fast simulation model for the hadronic calorimeter
137  // to all the corresponding Geant4 regions
138  Par02FastSimModelHCal* fastSimModelHCal
139  = new Par02FastSimModelHCal( "fastSimModelHCal", fHCalList[ iterHCal ],
141 
142  // Register the fast simulation model for deleting
143  G4AutoDelete::Register(fastSimModelHCal);
144  }
145  // Currently we don't have a fast muon simulation model to be bound
146  // to all the corresponding Geant4 regions.
147  // But it could be added in future, in a similar way as done above for
148  // the tracker subdetector and the electromagnetic and hadronic calorimeters.
149 }
150 
151 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
152 
Shortcut to the ordinary tracking for hadronic calorimeters.
G4VPhysicalVolume * GetWorldVolume(const G4String &setupName="Default") const
std::vector< G4Region * > fTrackerList
A vector of the tracking detector regions.
int G4int
Definition: G4Types.hh:78
void Register(T *inst)
Definition: G4AutoDelete.hh:65
G4GLOB_DLL std::ostream G4cout
Par02DetectorConstruction()
A default constructor.
Shortcut to the ordinary tracking for tracking detectors.
Shortcut to the ordinary tracking for electromagnetic calorimeters.
CommandLineParser * parser(0)
std::vector< G4Region * > fMuonList
A vector of the muon detector regions.
const G4GDMLAuxMapType * GetAuxMap() const
void Read(const G4String &filename, G4bool Validate=true)
virtual G4VPhysicalVolume * Construct()
A method invoked by G4RunManager::Initialize()
std::vector< G4Region * > fHCalList
A vector of the the hadronic calorimeter regions.
#define G4endl
Definition: G4ios.hh:61
static const double m
Definition: G4SIunits.hh:128
Definition of the Par02DetectorConstruction class.
const G4String & GetName() const
std::map< G4LogicalVolume *, G4GDMLAuxListType > G4GDMLAuxMapType
virtual void ConstructSDandField()
A method invoked by G4RunManager::Initialize() to construct thread local objects. ...
std::vector< G4Region * > fECalList
A vector of the the electromagnetic calorimeter regions.