Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:19:38

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 ///////////////////////////////////////////////////////////////////////////////
0027 // File: CCalDetectorConstruction.cc
0028 // Description: CCalDetectorConstruction user action class to construct 
0029 //              detector geometry
0030 ///////////////////////////////////////////////////////////////////////////////
0031 #include "CCalDetectorConstruction.hh"
0032 
0033 //#define debug
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   //Instantiate for the first time the materials and rotations
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   //HCAL Test Beam 96
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 //debug
0105   G4VPhysicalVolume* volume = testBeamHCal96->PhysicalVolume(0);
0106   
0107   return volume;
0108 }
0109 
0110 
0111 void CCalDetectorConstruction::ConstructSDandField() {
0112   // Create global magnetic field messenger.
0113 
0114   //-------------------------------------------------------------------------
0115   // Magnetic field
0116   //-------------------------------------------------------------------------
0117 
0118   static G4bool fieldIsInitialized = false;
0119   //And finally that it was not initialized previously
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     //pStepper = new G4ExplicitEuler( fEquation );
0145     //pStepper = new G4ImplicitEuler( fEquation );      
0146     //pStepper = new G4SimpleRunge( fEquation );        
0147     //pStepper = new G4SimpleHeum( fEquation );         
0148     //pStepper = new G4HelixExplicitEuler( fEquation ); 
0149     //pStepper = new G4HelixImplicitEuler( fEquation ); 
0150     //pStepper = new G4HelixSimpleRunge( fEquation );   
0151     //pStepper = new G4CashKarpRKF45( fEquation );      
0152     //pStepper = new G4RKG3_Stepper( fEquation );       
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   //Add sensitive detector types
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   // Assign the sensitive detectors
0179   CCalSensAssign::getInstance()->assign();
0180 }