Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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"
38 #include "G4AutoDelete.hh"
39 
40 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
41 
43 
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45 
47 
48 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
49 
52  parser.Read( "Par02FullDetector.gdml" );
53  G4cout << "Geometry loaded from file .......Par02FullDetector.gdml " << G4endl;
54 
55  // This GDML detector description uses the auxiliary information part to store
56  // information regarding which Geant4 volumes have a fast simulation model.
57 
58  const G4GDMLAuxMapType* aAuxMap = parser.GetAuxMap();
59  for ( G4GDMLAuxMapType::const_iterator iter = aAuxMap->begin();
60  iter != aAuxMap->end(); ++iter ) {
61  for ( G4GDMLAuxListType::const_iterator vit = (*iter).second.begin();
62  vit != (*iter).second.end(); ++vit ) {
63  if ( (*vit).type == "FastSimModel" ) {
64  G4LogicalVolume* myvol = (*iter).first;
65  if ( ( myvol->GetName() ).find( "Tracker" ) != std::string::npos ) {
66  fTrackerList.push_back( new G4Region( myvol->GetName() ) );
67  fTrackerList.back()->AddRootLogicalVolume( myvol );
68  G4cout << G4endl << "tracker !!!" << G4endl;
69  } else if ( ( myvol->GetName() ).find( "HCal" ) != std::string::npos ) {
70  fHCalList.push_back( new G4Region( myvol->GetName() ) );
71  fHCalList.back()->AddRootLogicalVolume( myvol );
72  G4cout << G4endl << "hcal !!!" << G4endl;
73  } else if ( ( myvol->GetName() ).find( "ECal" ) != std::string::npos ) {
74  fECalList.push_back( new G4Region( myvol->GetName() ) );
75  fECalList.back()->AddRootLogicalVolume( myvol );
76  G4cout << G4endl << "ecal !!!" << G4endl;
77  } else if ( ( myvol->GetName() ).find( "Muon" ) != std::string::npos ) {
78  fMuonList.push_back( new G4Region( myvol->GetName() ) );
79  fMuonList.back()->AddRootLogicalVolume( myvol );
80  } else {
81  G4cout << G4endl << "NOT A KNOWN DETECTOR !!!" << G4endl;
82  }
83  }
84  }
85  }
86  for ( G4int iterTracker = 0; iterTracker < G4int( fTrackerList.size() );
87  iterTracker++ ) {
88  fTrackerList[ iterTracker ]->SetProductionCuts( new G4ProductionCuts() );
89  fTrackerList[ iterTracker ]->GetProductionCuts()->SetProductionCut
90  ( 1.0* ( ( *fTrackerList[ iterTracker ]->GetRootLogicalVolumeIterator() )->
91  GetMaterial()->GetRadlen() ) );
92  fTrackerList[ iterTracker ]->GetProductionCuts()->
93  SetProductionCut( 1.0*m, idxG4GammaCut );
94  }
95  for ( G4int iterECal = 0; iterECal < G4int( fECalList.size() ); iterECal++ ) {
96  fECalList[ iterECal ]->SetProductionCuts( new G4ProductionCuts() );
97  fECalList[ iterECal ]->GetProductionCuts()->SetProductionCut
98  ( 0.5* ( ( *fECalList[ iterECal ]->GetRootLogicalVolumeIterator() )->
99  GetMaterial()->GetRadlen() ) );
100  fECalList[ iterECal ]->GetProductionCuts()->
101  SetProductionCut( 0.1*m, idxG4GammaCut );
102  }
103  for ( G4int iterHCal = 0; iterHCal < G4int( fHCalList.size() ); iterHCal++ ) {
104  fHCalList[ iterHCal ]->SetProductionCuts( new G4ProductionCuts() );
105  fHCalList[ iterHCal ]->GetProductionCuts()->SetProductionCut(
106  0.5* ( ( *fHCalList[iterHCal]->GetRootLogicalVolumeIterator() )->
107  GetMaterial()->GetRadlen() ) );
108  fHCalList[ iterHCal ]->GetProductionCuts()->
109  SetProductionCut( 1.0*m, idxG4GammaCut );
110  }
111 
112  // Returns the pointer to the physical world.
113  return parser.GetWorldVolume();
114 }
115 
116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
117 
119  for ( G4int iterTracker = 0; iterTracker < G4int( fTrackerList.size() );
120  iterTracker++ ) {
121  // Bound the fast simulation model for the tracker subdetector
122  // to all the corresponding Geant4 regions
123  Par02FastSimModelTracker* fastSimModelTracker
124  = new Par02FastSimModelTracker( "fastSimModelTracker", fTrackerList[ iterTracker ],
126 
127  // Register the fast simulation model for deleting
128  G4AutoDelete::Register(fastSimModelTracker);
129  }
130  for ( G4int iterECal = 0; iterECal < G4int( fECalList.size() ); iterECal++ ) {
131  // Bound the fast simulation model for the electromagnetic calorimeter
132  // to all the corresponding Geant4 regions
133  Par02FastSimModelEMCal* fastSimModelEMCal
134  = new Par02FastSimModelEMCal( "fastSimModelEMCal", fECalList[ iterECal ],
136 
137  // Register the fast simulation model for deleting
138  G4AutoDelete::Register(fastSimModelEMCal);
139  }
140  for ( G4int iterHCal = 0; iterHCal < G4int( fHCalList.size() ); iterHCal++ ) {
141  // Bound the fast simulation model for the hadronic calorimeter
142  // to all the corresponding Geant4 regions
143  Par02FastSimModelHCal* fastSimModelHCal
144  = new Par02FastSimModelHCal( "fastSimModelHCal", fHCalList[ iterHCal ],
146 
147  // Register the fast simulation model for deleting
148  G4AutoDelete::Register( fastSimModelHCal );
149  }
150  // Currently we don't have a fast muon simulation model to be bound
151  // to all the corresponding Geant4 regions.
152  // But it could be added in future, in a similar way as done above for
153  // the tracker subdetector and the electromagnetic and hadronic calorimeters.
154 
155  // Add global magnetic field
156  G4ThreeVector fieldValue = G4ThreeVector();
157  fMagFieldMessenger = new G4GlobalMagFieldMessenger( fieldValue );
159 }
160 
161 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
162 
void SetVerboseLevel(G4int verboseLevel)
CLHEP::Hep3Vector G4ThreeVector
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
static constexpr double m
Definition: G4SIunits.hh:129
Par02DetectorConstruction()
A default constructor.
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()
std::vector< G4Region * > fHCalList
A vector of the the hadronic calorimeter regions.
#define G4endl
Definition: G4ios.hh:61
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.
G4GlobalMagFieldMessenger * fMagFieldMessenger
Messenger of the magnetic field.