Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:33

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