Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 ////////////////////////////////////////////// 26 /////////////////////////////////////////////////////////////////////////////// 27 // File: CCalDetectorConstruction.cc 27 // File: CCalDetectorConstruction.cc 28 // Description: CCalDetectorConstruction user 28 // Description: CCalDetectorConstruction user action class to construct 29 // detector geometry 29 // detector geometry 30 ////////////////////////////////////////////// 30 /////////////////////////////////////////////////////////////////////////////// 31 #include "CCalDetectorConstruction.hh" 31 #include "CCalDetectorConstruction.hh" 32 32 33 //#define debug 33 //#define debug 34 34 35 #ifdef debug 35 #ifdef debug 36 #include "G4Timer.hh" 36 #include "G4Timer.hh" 37 #endif 37 #endif 38 38 39 #include "CCalMaterialFactory.hh" 39 #include "CCalMaterialFactory.hh" 40 #include "CCalRotationMatrixFactory.hh" 40 #include "CCalRotationMatrixFactory.hh" 41 #include "CCalSensAssign.hh" 41 #include "CCalSensAssign.hh" 42 #include "CCalMagneticField.hh" 42 #include "CCalMagneticField.hh" 43 #include "CCalG4Hall.hh" 43 #include "CCalG4Hall.hh" 44 #include "CCalutils.hh" 44 #include "CCalutils.hh" 45 45 46 #include "CCalSensitiveConfiguration.hh" 46 #include "CCalSensitiveConfiguration.hh" 47 #include "CCalEcalOrganization.hh" 47 #include "CCalEcalOrganization.hh" 48 #include "CCalHcalOrganization.hh" 48 #include "CCalHcalOrganization.hh" 49 49 50 #include "G4SystemOfUnits.hh" 50 #include "G4SystemOfUnits.hh" 51 #include "G4SDManager.hh" 51 #include "G4SDManager.hh" 52 #include "G4FieldManager.hh" 52 #include "G4FieldManager.hh" 53 #include "G4ChordFinder.hh" 53 #include "G4ChordFinder.hh" 54 #include "G4Mag_UsualEqRhs.hh" 54 #include "G4Mag_UsualEqRhs.hh" 55 #include "G4PropagatorInField.hh" 55 #include "G4PropagatorInField.hh" 56 #include "G4TransportationManager.hh" 56 #include "G4TransportationManager.hh" 57 57 58 #include "G4ClassicalRK4.hh" 58 #include "G4ClassicalRK4.hh" 59 #include "G4SimpleRunge.hh" 59 #include "G4SimpleRunge.hh" 60 #include "G4ExplicitEuler.hh" 60 #include "G4ExplicitEuler.hh" 61 #include "G4ImplicitEuler.hh" 61 #include "G4ImplicitEuler.hh" 62 #include "G4SimpleHeum.hh" 62 #include "G4SimpleHeum.hh" 63 #include "G4HelixExplicitEuler.hh" 63 #include "G4HelixExplicitEuler.hh" 64 #include "G4HelixImplicitEuler.hh" 64 #include "G4HelixImplicitEuler.hh" 65 #include "G4HelixSimpleRunge.hh" 65 #include "G4HelixSimpleRunge.hh" 66 #include "G4CashKarpRKF45.hh" 66 #include "G4CashKarpRKF45.hh" 67 #include "G4RKG3_Stepper.hh" 67 #include "G4RKG3_Stepper.hh" 68 68 69 << 69 CCalDetectorConstruction::CCalDetectorConstruction() {} 70 CCalDetectorConstruction::CCalDetectorConstruc << 71 << 72 70 73 CCalDetectorConstruction::~CCalDetectorConstru 71 CCalDetectorConstruction::~CCalDetectorConstruction() {} 74 72 75 << 76 G4VPhysicalVolume* CCalDetectorConstruction::C 73 G4VPhysicalVolume* CCalDetectorConstruction::Construct() { 77 74 78 ///////// 75 ///////// 79 //Instantiate for the first time the materia 76 //Instantiate for the first time the materials and rotations 80 #ifdef debug 77 #ifdef debug 81 G4cout << "Retrieving materials...." << G4en 78 G4cout << "Retrieving materials...." << G4endl; 82 #endif 79 #endif 83 CCalMaterialFactory::getInstance("material.c 80 CCalMaterialFactory::getInstance("material.cms"); 84 81 85 #ifdef debug 82 #ifdef debug 86 G4cout << "Retrieving rotation matrices..... 83 G4cout << "Retrieving rotation matrices....." << G4endl; 87 #endif 84 #endif 88 CCalRotationMatrixFactory::getInstance("rota 85 CCalRotationMatrixFactory::getInstance("rotation.cms"); 89 86 90 #ifdef debug << 91 G4cout << tab << "CCalDetectorConstruction: << 92 << G4endl; << 93 G4Timer timer; << 94 timer.Start(); << 95 #endif << 96 << 97 //HCAL Test Beam 96 << 98 testBeamHCal96 = new CCalG4Hall("HcalTB96"); << 99 testBeamHCal96->constructHierarchy(); << 100 #ifdef debug << 101 timer.Stop(); << 102 G4cout << tab << "CCalDetectorConstruction: << 103 << "construct the geometry: " << time << 104 #endif //debug << 105 G4VPhysicalVolume* volume = testBeamHCal96-> << 106 << 107 return volume; << 108 } << 109 << 110 << 111 void CCalDetectorConstruction::ConstructSDandF << 112 // Create global magnetic field messenger. << 113 << 114 //------------------------------------------ 87 //------------------------------------------------------------------------- 115 // Magnetic field 88 // Magnetic field 116 //------------------------------------------ 89 //------------------------------------------------------------------------- 117 90 118 static G4bool fieldIsInitialized = false; 91 static G4bool fieldIsInitialized = false; 119 //And finally that it was not initialized pr 92 //And finally that it was not initialized previously 120 if (!fieldIsInitialized) { 93 if (!fieldIsInitialized) { 121 CCalMagneticField* ccalField=new CCalMagne 94 CCalMagneticField* ccalField=new CCalMagneticField("fmap.tb96"); 122 G4double field = ccalField->GetConstantFie 95 G4double field = ccalField->GetConstantFieldvalue(); 123 if (field == 0) { 96 if (field == 0) { 124 ccalField = NULL; 97 ccalField = NULL; 125 G4cout << "***************************" 98 G4cout << "***************************" << G4endl 126 << "* *" 99 << "* *" << G4endl 127 << "* Magnetic Field is off *" 100 << "* Magnetic Field is off *" << G4endl 128 << "* *" 101 << "* *" << G4endl 129 << "***************************" 102 << "***************************" << G4endl; 130 } else { 103 } else { 131 G4cout << "***************************" 104 G4cout << "***************************" << G4endl 132 << "* *" 105 << "* *" << G4endl 133 << "* Magnetic Field is on *" 106 << "* Magnetic Field is on *" << G4endl 134 << "* *" 107 << "* *" << G4endl 135 << "***************************" 108 << "***************************" << G4endl << G4endl 136 << " Field Value " << tab << fiel 109 << " Field Value " << tab << field << G4endl; 137 } 110 } 138 G4FieldManager* fieldMgr 111 G4FieldManager* fieldMgr 139 = G4TransportationManager::GetTransporta 112 = G4TransportationManager::GetTransportationManager()->GetFieldManager(); 140 fieldMgr->SetDetectorField(ccalField); 113 fieldMgr->SetDetectorField(ccalField); 141 G4Mag_UsualEqRhs *fEquation = new G4Mag_Us 114 G4Mag_UsualEqRhs *fEquation = new G4Mag_UsualEqRhs(ccalField); 142 115 143 G4MagIntegratorStepper *pStepper = new G4C 116 G4MagIntegratorStepper *pStepper = new G4ClassicalRK4 (fEquation); 144 //pStepper = new G4ExplicitEuler( fEquatio 117 //pStepper = new G4ExplicitEuler( fEquation ); 145 //pStepper = new G4ImplicitEuler( fEquatio 118 //pStepper = new G4ImplicitEuler( fEquation ); 146 //pStepper = new G4SimpleRunge( fEquation 119 //pStepper = new G4SimpleRunge( fEquation ); 147 //pStepper = new G4SimpleHeum( fEquation ) 120 //pStepper = new G4SimpleHeum( fEquation ); 148 //pStepper = new G4HelixExplicitEuler( fEq 121 //pStepper = new G4HelixExplicitEuler( fEquation ); 149 //pStepper = new G4HelixImplicitEuler( fEq 122 //pStepper = new G4HelixImplicitEuler( fEquation ); 150 //pStepper = new G4HelixSimpleRunge( fEqua 123 //pStepper = new G4HelixSimpleRunge( fEquation ); 151 //pStepper = new G4CashKarpRKF45( fEquatio 124 //pStepper = new G4CashKarpRKF45( fEquation ); 152 //pStepper = new G4RKG3_Stepper( fEquation 125 //pStepper = new G4RKG3_Stepper( fEquation ); 153 126 154 G4ChordFinder *pChordFinder = new G4ChordF 127 G4ChordFinder *pChordFinder = new G4ChordFinder(ccalField, 155 128 1.e-1*mm, pStepper); 156 pChordFinder->SetDeltaChord(1.0e-3*mm); 129 pChordFinder->SetDeltaChord(1.0e-3*mm); 157 fieldMgr->SetChordFinder(pChordFinder); 130 fieldMgr->SetChordFinder(pChordFinder); 158 fieldMgr->SetDeltaOneStep(1.0e-3*mm); 131 fieldMgr->SetDeltaOneStep(1.0e-3*mm); 159 fieldMgr->SetDeltaIntersection(1.0e-4*mm); 132 fieldMgr->SetDeltaIntersection(1.0e-4*mm); 160 G4PropagatorInField* fieldPropagator 133 G4PropagatorInField* fieldPropagator 161 = G4TransportationManager::GetTransporta 134 = G4TransportationManager::GetTransportationManager() 162 ->GetPropagatorInField(); 135 ->GetPropagatorInField(); 163 fieldPropagator->SetMinimumEpsilonStep(1.e 136 fieldPropagator->SetMinimumEpsilonStep(1.e-5*mm); 164 fieldPropagator->SetMaximumEpsilonStep(1.e 137 fieldPropagator->SetMaximumEpsilonStep(1.e-2*mm); 165 fieldIsInitialized = true; 138 fieldIsInitialized = true; 166 } 139 } 167 140 168 //Add sensitive detector types << 141 #ifdef debug 169 testBeamHCal96->sensitiveHandling(); << 142 G4cout << tab << "CCalDetectorConstruction: Starting timer!!!" 170 G4int sensitive = CCalSensitiveConfiguration << 143 << G4endl; 171 if ( sensitive > 0 ) { << 144 G4Timer timer; 172 CCalSensAssign::getInstance()->addCaloSD(" << 145 timer.Start(); 173 } << 146 #endif 174 sensitive = CCalSensitiveConfiguration::getI << 147 175 if ( sensitive > 0 ) { << 148 //HCAL Test Beam 96 176 CCalSensAssign::getInstance()->addCaloSD(" << 149 CCalG4Hall* testBeamHCal96 = new CCalG4Hall("HcalTB96"); 177 } << 150 testBeamHCal96->constructHierarchy(); 178 // Assign the sensitive detectors << 151 #ifdef debug 179 CCalSensAssign::getInstance()->assign(); << 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; >> 161 sensitive = CCalSensitiveConfiguration::getInstance()-> >> 162 getSensitiveFlag("HadronCalorimeter"); >> 163 if (sensitive>0) /*result =*/ CCalSensAssign::getInstance()-> >> 164 addCaloSD("HadronCalorimeter", new CCalHcalOrganization); >> 165 sensitive = CCalSensitiveConfiguration::getInstance()-> >> 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 >> 174 /*result =*/ CCalSensAssign::getInstance()->stackingAction(); >> 175 >> 176 return volume; >> 177 180 } 178 } 181 179