Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-16 07:42:02

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 /// \file Par02DetectorConstruction.cc
0027 /// \brief Implementation of the Par02DetectorConstruction class
0028 
0029 #include "Par02DetectorConstruction.hh"
0030 
0031 #include "G4AutoDelete.hh"
0032 #include "G4GDMLParser.hh"
0033 #include "G4GlobalMagFieldMessenger.hh"
0034 #include "G4ProductionCuts.hh"
0035 #include "G4RegionStore.hh"
0036 #include "G4SystemOfUnits.hh"
0037 
0038 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0039 
0040 Par02DetectorConstruction::Par02DetectorConstruction() = default;
0041 
0042 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0043 
0044 Par02DetectorConstruction::~Par02DetectorConstruction() = default;
0045 
0046 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0047 
0048 G4VPhysicalVolume* Par02DetectorConstruction::Construct()
0049 {
0050   G4GDMLParser parser;
0051   parser.Read("Par02FullDetector.gdml");
0052   G4cout << "Geometry loaded from  file .......Par02FullDetector.gdml " << G4endl;
0053 
0054   // This GDML detector description uses the auxiliary information part to store
0055   // information regarding which Geant4 volumes have a fast simulation model.
0056 
0057   const G4GDMLAuxMapType* aAuxMap = parser.GetAuxMap();
0058   for (G4GDMLAuxMapType::const_iterator iter = aAuxMap->begin(); iter != aAuxMap->end(); ++iter) {
0059     for (G4GDMLAuxListType::const_iterator vit = (*iter).second.begin();
0060          vit != (*iter).second.end(); ++vit)
0061     {
0062       if ((*vit).type == "FastSimModel") {
0063         G4LogicalVolume* myvol = (*iter).first;
0064         if ((myvol->GetName()).find("Tracker") != std::string::npos) {
0065           fTrackerList.push_back(new G4Region(myvol->GetName()));
0066           fTrackerList.back()->AddRootLogicalVolume(myvol);
0067           G4cout << G4endl << "tracker !!!" << G4endl;
0068         }
0069         else if ((myvol->GetName()).find("HCal") != std::string::npos) {
0070           fHCalList.push_back(new G4Region(myvol->GetName()));
0071           fHCalList.back()->AddRootLogicalVolume(myvol);
0072           G4cout << G4endl << "hcal !!!" << G4endl;
0073         }
0074         else if ((myvol->GetName()).find("ECal") != std::string::npos) {
0075           fECalList.push_back(new G4Region(myvol->GetName()));
0076           fECalList.back()->AddRootLogicalVolume(myvol);
0077           G4cout << G4endl << "ecal !!!" << G4endl;
0078         }
0079         else if ((myvol->GetName()).find("Muon") != std::string::npos) {
0080           fMuonList.push_back(new G4Region(myvol->GetName()));
0081           fMuonList.back()->AddRootLogicalVolume(myvol);
0082         }
0083         else {
0084           G4cout << G4endl << "NOT A KNOWN DETECTOR !!!" << G4endl;
0085         }
0086       }
0087     }
0088   }
0089   for (G4int iterTracker = 0; iterTracker < G4int(fTrackerList.size()); iterTracker++) {
0090     fTrackerList[iterTracker]->SetProductionCuts(new G4ProductionCuts());
0091     fTrackerList[iterTracker]->GetProductionCuts()->SetProductionCut(
0092       1.0
0093       * ((*fTrackerList[iterTracker]->GetRootLogicalVolumeIterator())->GetMaterial()->GetRadlen()));
0094     fTrackerList[iterTracker]->GetProductionCuts()->SetProductionCut(1.0 * m, idxG4GammaCut);
0095   }
0096   for (G4int iterECal = 0; iterECal < G4int(fECalList.size()); iterECal++) {
0097     fECalList[iterECal]->SetProductionCuts(new G4ProductionCuts());
0098     fECalList[iterECal]->GetProductionCuts()->SetProductionCut(
0099       0.5 * ((*fECalList[iterECal]->GetRootLogicalVolumeIterator())->GetMaterial()->GetRadlen()));
0100     fECalList[iterECal]->GetProductionCuts()->SetProductionCut(0.1 * m, idxG4GammaCut);
0101   }
0102   for (G4int iterHCal = 0; iterHCal < G4int(fHCalList.size()); iterHCal++) {
0103     fHCalList[iterHCal]->SetProductionCuts(new G4ProductionCuts());
0104     fHCalList[iterHCal]->GetProductionCuts()->SetProductionCut(
0105       0.5 * ((*fHCalList[iterHCal]->GetRootLogicalVolumeIterator())->GetMaterial()->GetRadlen()));
0106     fHCalList[iterHCal]->GetProductionCuts()->SetProductionCut(1.0 * m, idxG4GammaCut);
0107   }
0108 
0109   // Returns the pointer to the physical world.
0110   return parser.GetWorldVolume();
0111 }
0112 
0113 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0114 
0115 void Par02DetectorConstruction::ConstructSDandField()
0116 {
0117   for (G4int iterTracker = 0; iterTracker < G4int(fTrackerList.size()); iterTracker++) {
0118     // Bound the fast simulation model for the tracker subdetector
0119     // to all the corresponding Geant4 regions
0120     Par02FastSimModelTracker* fastSimModelTracker = new Par02FastSimModelTracker(
0121       "fastSimModelTracker", fTrackerList[iterTracker], Par02DetectorParametrisation::eCMS);
0122 
0123     // Register the fast simulation model for deleting
0124     G4AutoDelete::Register(fastSimModelTracker);
0125   }
0126   for (G4int iterECal = 0; iterECal < G4int(fECalList.size()); iterECal++) {
0127     // Bound the fast simulation model for the electromagnetic calorimeter
0128     // to all the corresponding Geant4 regions
0129     Par02FastSimModelEMCal* fastSimModelEMCal = new Par02FastSimModelEMCal(
0130       "fastSimModelEMCal", fECalList[iterECal], Par02DetectorParametrisation::eCMS);
0131 
0132     // Register the fast simulation model for deleting
0133     G4AutoDelete::Register(fastSimModelEMCal);
0134   }
0135   for (G4int iterHCal = 0; iterHCal < G4int(fHCalList.size()); iterHCal++) {
0136     // Bound the fast simulation model for the hadronic calorimeter
0137     // to all the corresponding Geant4 regions
0138     Par02FastSimModelHCal* fastSimModelHCal = new Par02FastSimModelHCal(
0139       "fastSimModelHCal", fHCalList[iterHCal], Par02DetectorParametrisation::eCMS);
0140 
0141     // Register the fast simulation model for deleting
0142     G4AutoDelete::Register(fastSimModelHCal);
0143   }
0144   // Currently we don't have a fast muon simulation model to be bound
0145   // to all the corresponding Geant4 regions.
0146   // But it could be added in future, in a similar way as done above for
0147   // the tracker subdetector and the electromagnetic and hadronic calorimeters.
0148 
0149   // Add global magnetic field
0150   G4ThreeVector fieldValue = G4ThreeVector();
0151   fMagFieldMessenger = new G4GlobalMagFieldMessenger(fieldValue);
0152   fMagFieldMessenger->SetVerboseLevel(1);
0153 }
0154 
0155 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......