source: trunk/examples/advanced/composite_calorimeter/src/CCalDetectorConstruction.cc@ 1313

Last change on this file since 1313 was 807, checked in by garnier, 17 years ago

update

File size: 6.9 KB
Line 
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///////////////////////////////////////////////////////////////////////////////
27// File: CCalDetectorConstruction.cc
28// Description: CCalDetectorConstruction user action class to construct
29// detector geometry
30///////////////////////////////////////////////////////////////////////////////
31#include "CCalDetectorConstruction.hh"
32
33//#define debug
34
35#ifdef debug
36#include "G4Timer.hh"
37#endif
38
39#include "CCalMaterialFactory.hh"
40#include "CCalRotationMatrixFactory.hh"
41#include "CCalSensAssign.hh"
42#include "CCalMagneticField.hh"
43#include "CCalG4Hall.hh"
44#include "CCalutils.hh"
45
46#include "CCalSensitiveConfiguration.hh"
47#include "CCalEcalOrganization.hh"
48#include "CCalHcalOrganization.hh"
49#include "G4SDManager.hh"
50
51#include "G4FieldManager.hh"
52#include "G4ChordFinder.hh"
53#include "G4Mag_UsualEqRhs.hh"
54#include "G4PropagatorInField.hh"
55#include "G4TransportationManager.hh"
56
57#include "G4ClassicalRK4.hh"
58#include "G4SimpleRunge.hh"
59#include "G4ExplicitEuler.hh"
60#include "G4ImplicitEuler.hh"
61#include "G4SimpleHeum.hh"
62#include "G4HelixExplicitEuler.hh"
63#include "G4HelixImplicitEuler.hh"
64#include "G4HelixSimpleRunge.hh"
65#include "G4CashKarpRKF45.hh"
66#include "G4RKG3_Stepper.hh"
67
68CCalDetectorConstruction::CCalDetectorConstruction() {}
69
70CCalDetectorConstruction::~CCalDetectorConstruction() {}
71
72G4VPhysicalVolume* CCalDetectorConstruction::Construct() {
73
74 /////////
75 //Instantiate for the first time the materials and rotations
76#ifdef debug
77 G4cout << "Retrieving materials...." << G4endl;
78#endif
79 CCalMaterialFactory::getInstance("material.cms");
80
81#ifdef debug
82 G4cout << "Retrieving rotation matrices....." << G4endl;
83#endif
84 CCalRotationMatrixFactory::getInstance("rotation.cms");
85
86 //-------------------------------------------------------------------------
87 // Magnetic field
88 //-------------------------------------------------------------------------
89
90 static G4bool fieldIsInitialized = false;
91 //And finally that it was not initialized previously
92 if (!fieldIsInitialized) {
93 CCalMagneticField* ccalField=new CCalMagneticField("fmap.tb96");
94 G4double field = ccalField->GetConstantFieldvalue();
95 if (field == 0) {
96 ccalField = NULL;
97 G4cout << "***************************" << G4endl
98 << "* *" << G4endl
99 << "* Magnetic Field is off *" << G4endl
100 << "* *" << G4endl
101 << "***************************" << G4endl;
102 } else {
103 G4cout << "***************************" << G4endl
104 << "* *" << G4endl
105 << "* Magnetic Field is on *" << G4endl
106 << "* *" << G4endl
107 << "***************************" << G4endl << G4endl
108 << " Field Value " << tab << field << G4endl;
109 }
110 G4FieldManager* fieldMgr
111 = G4TransportationManager::GetTransportationManager()->GetFieldManager();
112 fieldMgr->SetDetectorField(ccalField);
113 G4Mag_UsualEqRhs *fEquation = new G4Mag_UsualEqRhs(ccalField);
114
115 G4MagIntegratorStepper *pStepper = new G4ClassicalRK4 (fEquation);
116 //pStepper = new G4ExplicitEuler( fEquation );
117 //pStepper = new G4ImplicitEuler( fEquation );
118 //pStepper = new G4SimpleRunge( fEquation );
119 //pStepper = new G4SimpleHeum( fEquation );
120 //pStepper = new G4HelixExplicitEuler( fEquation );
121 //pStepper = new G4HelixImplicitEuler( fEquation );
122 //pStepper = new G4HelixSimpleRunge( fEquation );
123 //pStepper = new G4CashKarpRKF45( fEquation );
124 //pStepper = new G4RKG3_Stepper( fEquation );
125
126 G4ChordFinder *pChordFinder = new G4ChordFinder(ccalField,
127 1.e-1*mm, pStepper);
128 pChordFinder->SetDeltaChord(1.0e-3*mm);
129 fieldMgr->SetChordFinder(pChordFinder);
130 fieldMgr->SetDeltaOneStep(1.0e-3*mm);
131 fieldMgr->SetDeltaIntersection(1.0e-4*mm);
132 G4PropagatorInField* fieldPropagator
133 = G4TransportationManager::GetTransportationManager()
134 ->GetPropagatorInField();
135 fieldPropagator->SetMinimumEpsilonStep(1.e-5*mm);
136 fieldPropagator->SetMaximumEpsilonStep(1.e-2*mm);
137 fieldIsInitialized = true;
138 }
139
140#ifdef debug
141 G4cout << tab << "CCalDetectorConstruction: Starting timer!!!"
142 << G4endl;
143 G4Timer timer;
144 timer.Start();
145#endif
146
147 //HCAL Test Beam 96
148 CCalG4Hall* testBeamHCal96 = new CCalG4Hall("HcalTB96");
149 testBeamHCal96->constructHierarchy();
150#ifdef debug
151 timer.Stop();
152 G4cout << tab << "CCalDetectorConstruction: Total time to "
153 << "construct the geometry: " << timer << G4endl;
154#endif //debug
155 G4VPhysicalVolume* volume = testBeamHCal96->PhysicalVolume(0);
156
157 //Addsenistive detector types
158 G4bool result;
159 G4int sensitive;
160 sensitive = CCalSensitiveConfiguration::getInstance()->
161 getSensitiveFlag("HadronCalorimeter");
162 if (sensitive>0) result = CCalSensAssign::getInstance()->
163 addCaloSD("HadronCalorimeter", new CCalHcalOrganization);
164 sensitive = CCalSensitiveConfiguration::getInstance()->
165 getSensitiveFlag("CrystalMatrixModule");
166 if (sensitive>0) result = CCalSensAssign::getInstance()->
167 addCaloSD("CrystalMatrix", new CCalEcalOrganization);
168
169 //Assign the sensitive detectors
170 result = CCalSensAssign::getInstance()->assign();
171
172 //Create the stacking manager required by Calorimeter
173 result = CCalSensAssign::getInstance()->stackingAction();
174
175 return volume;
176
177}
Note: See TracBrowser for help on using the repository browser.