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