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 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 //
  2 // ********************************************************************
  3 // * License and Disclaimer                                           *
  4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.                             *
 10 // *                                                                  *
 11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                                                  *
 18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // ********************************************************************
 25 //
 26 //
 27 /// \file Par02DetectorConstruction.cc
 28 /// \brief Implementation of the Par02DetectorConstruction class
 29 
 30 #include "Par02DetectorConstruction.hh"
 31 
 32 #include "G4AutoDelete.hh"
 33 #include "G4GDMLParser.hh"
 34 #include "G4GlobalMagFieldMessenger.hh"
 35 #include "G4ProductionCuts.hh"
 36 #include "G4RegionStore.hh"
 37 #include "G4SystemOfUnits.hh"
 38 
 39 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 40 
 41 Par02DetectorConstruction::Par02DetectorConstruction() = default;
 42 
 43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 44 
 45 Par02DetectorConstruction::~Par02DetectorConstruction() = default;
 46 
 47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 48 
 49 G4VPhysicalVolume* Par02DetectorConstruction::Construct()
 50 {
 51   G4GDMLParser parser;
 52   parser.Read("Par02FullDetector.gdml");
 53   G4cout << "Geometry loaded from  file .......Par02FullDetector.gdml " << G4endl;
 54 
 55   // This GDML detector description uses the auxiliary information part to store
 56   // information regarding which Geant4 volumes have a fast simulation model.
 57 
 58   const G4GDMLAuxMapType* aAuxMap = parser.GetAuxMap();
 59   for (G4GDMLAuxMapType::const_iterator iter = aAuxMap->begin(); iter != aAuxMap->end(); ++iter) {
 60     for (G4GDMLAuxListType::const_iterator vit = (*iter).second.begin();
 61          vit != (*iter).second.end(); ++vit)
 62     {
 63       if ((*vit).type == "FastSimModel") {
 64         G4LogicalVolume* myvol = (*iter).first;
 65         if ((myvol->GetName()).find("Tracker") != std::string::npos) {
 66           fTrackerList.push_back(new G4Region(myvol->GetName()));
 67           fTrackerList.back()->AddRootLogicalVolume(myvol);
 68           G4cout << G4endl << "tracker !!!" << G4endl;
 69         }
 70         else if ((myvol->GetName()).find("HCal") != std::string::npos) {
 71           fHCalList.push_back(new G4Region(myvol->GetName()));
 72           fHCalList.back()->AddRootLogicalVolume(myvol);
 73           G4cout << G4endl << "hcal !!!" << G4endl;
 74         }
 75         else if ((myvol->GetName()).find("ECal") != std::string::npos) {
 76           fECalList.push_back(new G4Region(myvol->GetName()));
 77           fECalList.back()->AddRootLogicalVolume(myvol);
 78           G4cout << G4endl << "ecal !!!" << G4endl;
 79         }
 80         else if ((myvol->GetName()).find("Muon") != std::string::npos) {
 81           fMuonList.push_back(new G4Region(myvol->GetName()));
 82           fMuonList.back()->AddRootLogicalVolume(myvol);
 83         }
 84         else {
 85           G4cout << G4endl << "NOT A KNOWN DETECTOR !!!" << G4endl;
 86         }
 87       }
 88     }
 89   }
 90   for (G4int iterTracker = 0; iterTracker < G4int(fTrackerList.size()); iterTracker++) {
 91     fTrackerList[iterTracker]->SetProductionCuts(new G4ProductionCuts());
 92     fTrackerList[iterTracker]->GetProductionCuts()->SetProductionCut(
 93       1.0
 94       * ((*fTrackerList[iterTracker]->GetRootLogicalVolumeIterator())->GetMaterial()->GetRadlen()));
 95     fTrackerList[iterTracker]->GetProductionCuts()->SetProductionCut(1.0 * m, idxG4GammaCut);
 96   }
 97   for (G4int iterECal = 0; iterECal < G4int(fECalList.size()); iterECal++) {
 98     fECalList[iterECal]->SetProductionCuts(new G4ProductionCuts());
 99     fECalList[iterECal]->GetProductionCuts()->SetProductionCut(
100       0.5 * ((*fECalList[iterECal]->GetRootLogicalVolumeIterator())->GetMaterial()->GetRadlen()));
101     fECalList[iterECal]->GetProductionCuts()->SetProductionCut(0.1 * m, idxG4GammaCut);
102   }
103   for (G4int iterHCal = 0; iterHCal < G4int(fHCalList.size()); iterHCal++) {
104     fHCalList[iterHCal]->SetProductionCuts(new G4ProductionCuts());
105     fHCalList[iterHCal]->GetProductionCuts()->SetProductionCut(
106       0.5 * ((*fHCalList[iterHCal]->GetRootLogicalVolumeIterator())->GetMaterial()->GetRadlen()));
107     fHCalList[iterHCal]->GetProductionCuts()->SetProductionCut(1.0 * m, idxG4GammaCut);
108   }
109 
110   // Returns the pointer to the physical world.
111   return parser.GetWorldVolume();
112 }
113 
114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
115 
116 void Par02DetectorConstruction::ConstructSDandField()
117 {
118   for (G4int iterTracker = 0; iterTracker < G4int(fTrackerList.size()); iterTracker++) {
119     // Bound the fast simulation model for the tracker subdetector
120     // to all the corresponding Geant4 regions
121     Par02FastSimModelTracker* fastSimModelTracker = new Par02FastSimModelTracker(
122       "fastSimModelTracker", fTrackerList[iterTracker], Par02DetectorParametrisation::eCMS);
123 
124     // Register the fast simulation model for deleting
125     G4AutoDelete::Register(fastSimModelTracker);
126   }
127   for (G4int iterECal = 0; iterECal < G4int(fECalList.size()); iterECal++) {
128     // Bound the fast simulation model for the electromagnetic calorimeter
129     // to all the corresponding Geant4 regions
130     Par02FastSimModelEMCal* fastSimModelEMCal = new Par02FastSimModelEMCal(
131       "fastSimModelEMCal", fECalList[iterECal], Par02DetectorParametrisation::eCMS);
132 
133     // Register the fast simulation model for deleting
134     G4AutoDelete::Register(fastSimModelEMCal);
135   }
136   for (G4int iterHCal = 0; iterHCal < G4int(fHCalList.size()); iterHCal++) {
137     // Bound the fast simulation model for the hadronic calorimeter
138     // to all the corresponding Geant4 regions
139     Par02FastSimModelHCal* fastSimModelHCal = new Par02FastSimModelHCal(
140       "fastSimModelHCal", fHCalList[iterHCal], Par02DetectorParametrisation::eCMS);
141 
142     // Register the fast simulation model for deleting
143     G4AutoDelete::Register(fastSimModelHCal);
144   }
145   // Currently we don't have a fast muon simulation model to be bound
146   // to all the corresponding Geant4 regions.
147   // But it could be added in future, in a similar way as done above for
148   // the tracker subdetector and the electromagnetic and hadronic calorimeters.
149 
150   // Add global magnetic field
151   G4ThreeVector fieldValue = G4ThreeVector();
152   fMagFieldMessenger = new G4GlobalMagFieldMessenger(fieldValue);
153   fMagFieldMessenger->SetVerboseLevel(1);
154 }
155 
156 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
157