File indexing completed on 2025-02-23 09:19:38
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 #include "CCalDetectorConstruction.hh"
0032
0033
0034
0035 #ifdef debug
0036 #include "G4Timer.hh"
0037 #endif
0038
0039 #include "CCalMaterialFactory.hh"
0040 #include "CCalRotationMatrixFactory.hh"
0041 #include "CCalSensAssign.hh"
0042 #include "CCalMagneticField.hh"
0043 #include "CCalG4Hall.hh"
0044 #include "CCalutils.hh"
0045
0046 #include "CCalSensitiveConfiguration.hh"
0047 #include "CCalEcalOrganization.hh"
0048 #include "CCalHcalOrganization.hh"
0049
0050 #include "G4SystemOfUnits.hh"
0051 #include "G4SDManager.hh"
0052 #include "G4FieldManager.hh"
0053 #include "G4ChordFinder.hh"
0054 #include "G4Mag_UsualEqRhs.hh"
0055 #include "G4PropagatorInField.hh"
0056 #include "G4TransportationManager.hh"
0057
0058 #include "G4ClassicalRK4.hh"
0059 #include "G4SimpleRunge.hh"
0060 #include "G4ExplicitEuler.hh"
0061 #include "G4ImplicitEuler.hh"
0062 #include "G4SimpleHeum.hh"
0063 #include "G4HelixExplicitEuler.hh"
0064 #include "G4HelixImplicitEuler.hh"
0065 #include "G4HelixSimpleRunge.hh"
0066 #include "G4CashKarpRKF45.hh"
0067 #include "G4RKG3_Stepper.hh"
0068
0069
0070 CCalDetectorConstruction::CCalDetectorConstruction() : testBeamHCal96( nullptr ) {}
0071
0072
0073 CCalDetectorConstruction::~CCalDetectorConstruction() {}
0074
0075
0076 G4VPhysicalVolume* CCalDetectorConstruction::Construct() {
0077
0078
0079
0080 #ifdef debug
0081 G4cout << "Retrieving materials...." << G4endl;
0082 #endif
0083 CCalMaterialFactory::getInstance("material.cms");
0084
0085 #ifdef debug
0086 G4cout << "Retrieving rotation matrices....." << G4endl;
0087 #endif
0088 CCalRotationMatrixFactory::getInstance("rotation.cms");
0089
0090 #ifdef debug
0091 G4cout << tab << "CCalDetectorConstruction: Starting timer!!!"
0092 << G4endl;
0093 G4Timer timer;
0094 timer.Start();
0095 #endif
0096
0097
0098 testBeamHCal96 = new CCalG4Hall("HcalTB96");
0099 testBeamHCal96->constructHierarchy();
0100 #ifdef debug
0101 timer.Stop();
0102 G4cout << tab << "CCalDetectorConstruction: Total time to "
0103 << "construct the geometry: " << timer << G4endl;
0104 #endif
0105 G4VPhysicalVolume* volume = testBeamHCal96->PhysicalVolume(0);
0106
0107 return volume;
0108 }
0109
0110
0111 void CCalDetectorConstruction::ConstructSDandField() {
0112
0113
0114
0115
0116
0117
0118 static G4bool fieldIsInitialized = false;
0119
0120 if (!fieldIsInitialized) {
0121 CCalMagneticField* ccalField=new CCalMagneticField("fmap.tb96");
0122 G4double field = ccalField->GetConstantFieldvalue();
0123 if (field == 0) {
0124 ccalField = NULL;
0125 G4cout << "***************************" << G4endl
0126 << "* *" << G4endl
0127 << "* Magnetic Field is off *" << G4endl
0128 << "* *" << G4endl
0129 << "***************************" << G4endl;
0130 } else {
0131 G4cout << "***************************" << G4endl
0132 << "* *" << G4endl
0133 << "* Magnetic Field is on *" << G4endl
0134 << "* *" << G4endl
0135 << "***************************" << G4endl << G4endl
0136 << " Field Value " << tab << field << G4endl;
0137 }
0138 G4FieldManager* fieldMgr
0139 = G4TransportationManager::GetTransportationManager()->GetFieldManager();
0140 fieldMgr->SetDetectorField(ccalField);
0141 G4Mag_UsualEqRhs *fEquation = new G4Mag_UsualEqRhs(ccalField);
0142
0143 G4MagIntegratorStepper *pStepper = new G4ClassicalRK4 (fEquation);
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154 G4ChordFinder *pChordFinder = new G4ChordFinder(ccalField,
0155 1.e-1*mm, pStepper);
0156 pChordFinder->SetDeltaChord(1.0e-3*mm);
0157 fieldMgr->SetChordFinder(pChordFinder);
0158 fieldMgr->SetDeltaOneStep(1.0e-3*mm);
0159 fieldMgr->SetDeltaIntersection(1.0e-4*mm);
0160 G4PropagatorInField* fieldPropagator
0161 = G4TransportationManager::GetTransportationManager()
0162 ->GetPropagatorInField();
0163 fieldPropagator->SetMinimumEpsilonStep(1.e-5*mm);
0164 fieldPropagator->SetMaximumEpsilonStep(1.e-2*mm);
0165 fieldIsInitialized = true;
0166 }
0167
0168
0169 testBeamHCal96->sensitiveHandling();
0170 G4int sensitive = CCalSensitiveConfiguration::getInstance()->getSensitiveFlag("HadronCalorimeter");
0171 if ( sensitive > 0 ) {
0172 CCalSensAssign::getInstance()->addCaloSD("HadronCalorimeter", new CCalHcalOrganization);
0173 }
0174 sensitive = CCalSensitiveConfiguration::getInstance()->getSensitiveFlag("CrystalMatrixModule");
0175 if ( sensitive > 0 ) {
0176 CCalSensAssign::getInstance()->addCaloSD("CrystalMatrix", new CCalEcalOrganization);
0177 }
0178
0179 CCalSensAssign::getInstance()->assign();
0180 }