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[ 10.4.p3 ] [ 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 /// \file eventgenerator/HepMC/HepMCEx02/src/H02DetectorConstruction.cc
 27 /// \brief Implementation of the H02DetectorConstruction class
 28 //
 29 
 30 #include "H02DetectorConstruction.hh"
 31 
 32 #include "H02Field.hh"
 33 #include "H02MuonSD.hh"
 34 
 35 #include "G4Box.hh"
 36 #include "G4ChordFinder.hh"
 37 #include "G4Element.hh"
 38 #include "G4FieldManager.hh"
 39 #include "G4LogicalVolume.hh"
 40 #include "G4Material.hh"
 41 #include "G4NistManager.hh"
 42 #include "G4PVPlacement.hh"
 43 #include "G4SDManager.hh"
 44 #include "G4SystemOfUnits.hh"
 45 #include "G4TransportationManager.hh"
 46 #include "G4Tubs.hh"
 47 #include "G4VisAttributes.hh"
 48 
 49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 50 // constants (detector parameters)
 51 // [experimental hall]
 52 static const G4double R_EXPHALL = 5. * m;
 53 static const G4double DZ_EXPHALL = 10. * m;
 54 
 55 // [calorimeter]
 56 static const G4double RIN_BARREL_CAL = 2. * m;
 57 static const G4double ROUT_BARREL_CAL = 3. * m;
 58 static const G4double DZ_BARREL_CAL = 5. * m;
 59 
 60 static const G4double RIN_ENDCAP_CAL = 1. * m;
 61 static const G4double ROUT_ENDCAP_CAL = 3. * m;
 62 static const G4double DZ_ENDCAP_CAL = 0.5 * m;
 63 
 64 // [muon system]
 65 static const G4double RIN_BARREL_MUON = 4.3 * m;
 66 // static const G4double ROUT_BARREL_MUON= 4.5*m;
 67 static const G4double DX_BARREL_MUON = RIN_BARREL_MUON * std::cos(67.5 * deg) - 5. * cm;
 68 static const G4double DY_BARREL_MUON = 10. * cm;
 69 static const G4double DZ_BARREL_MUON = 7. * m;
 70 
 71 static const G4double RIN_ENDCAP_MUON = 1. * m;
 72 static const G4double ROUT_ENDCAP_MUON = 4.5 * m;
 73 static const G4double DZ_ENDCAP_MUON = 10. * cm;
 74 
 75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 76 H02DetectorConstruction::H02DetectorConstruction() : G4VUserDetectorConstruction() {}
 77 
 78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 79 H02DetectorConstruction::~H02DetectorConstruction() {}
 80 
 81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 82 G4VPhysicalVolume* H02DetectorConstruction::Construct()
 83 {
 84   // ==============================================================
 85   // Materials
 86   // ==============================================================
 87 
 88   G4NistManager* nistManager = G4NistManager::Instance();
 89   G4Material* air = nistManager->FindOrBuildMaterial("G4_AIR");
 90   G4Material* lead = nistManager->FindOrBuildMaterial("G4_Pb");
 91 
 92   // Argon gas
 93   G4double a, z, density;
 94   a = 39.95 * g / mole;
 95   density = 1.782e-03 * g / cm3;
 96   G4Material* ar = new G4Material("ArgonGas", z = 18., a, density);
 97 
 98   // ==============================================================
 99   // Experimental Hall (world)
100   // ==============================================================
101   G4Tubs* expHallSolid = new G4Tubs("EXP_HALL", 0., R_EXPHALL, DZ_EXPHALL, 0., 360. * deg);
102 
103   G4LogicalVolume* expHallLV = new G4LogicalVolume(expHallSolid, air, "EXP_HALL_LV");
104 
105   // visualization attributes
106   G4VisAttributes* expHallVisAtt = new G4VisAttributes(false, G4Colour(1., 1., 1.));
107   // expHallVisAtt-> SetForceWireframe(TRUE);
108   expHallLV->SetVisAttributes(expHallVisAtt);
109 
110   G4PVPlacement* expHall =
111     new G4PVPlacement(0, G4ThreeVector(), "EXP_HALL_PV", expHallLV, 0, FALSE, 0);
112   //            ...                                    MV, MANY, copy#
113 
114   // ==============================================================
115   // each detector component
116   // ==============================================================
117   // calorimeter system
118   G4Tubs* barrelCalSolid =
119     new G4Tubs("BARREL_CAL", RIN_BARREL_CAL, ROUT_BARREL_CAL, DZ_BARREL_CAL, 0., 360. * deg);
120 
121   G4Tubs* endcapCalSolid =
122     new G4Tubs("ENDCAP_CAL", RIN_ENDCAP_CAL, ROUT_ENDCAP_CAL, DZ_ENDCAP_CAL, 0., 360. * deg);
123 
124   G4LogicalVolume* barrelCalLV = new G4LogicalVolume(barrelCalSolid, lead, "BARREL_CAL_LV");
125 
126   G4LogicalVolume* endcapCalLV = new G4LogicalVolume(endcapCalSolid, lead, "ENDCAP_CAL_LV");
127 
128   G4VisAttributes* calVisAtt = new G4VisAttributes(true, G4Colour(0., 1., 1.));
129   barrelCalLV->SetVisAttributes(calVisAtt);
130   endcapCalLV->SetVisAttributes(calVisAtt);
131 
132   // G4PVPlacement* barrelCal=
133   new G4PVPlacement(0, G4ThreeVector(), "BARREL_CAL_PV", barrelCalLV, expHall, FALSE, 0);
134 
135   G4ThreeVector posCal(0., 0., 6. * m);
136   // G4PVPlacement* endcapCal1=
137   new G4PVPlacement(0, posCal, "ENDCAP_CAL_PV", endcapCalLV, expHall, FALSE, 0);
138 
139   // G4PVPlacement* endcapCal2=
140   new G4PVPlacement(0, -posCal, "ENDCAP_CAL_PV", endcapCalLV, expHall, FALSE, 1);
141 
142   // muon system
143   G4Box* barrelMuonSolid = new G4Box("BARREL_MUON", DX_BARREL_MUON, DY_BARREL_MUON, DZ_BARREL_MUON);
144   G4Tubs* endcapMuonSolid =
145     new G4Tubs("ENDCAP_MUON", RIN_ENDCAP_MUON, ROUT_ENDCAP_MUON, DZ_ENDCAP_MUON, 0., 360. * deg);
146 
147   G4LogicalVolume* barrelMuonLV = new G4LogicalVolume(barrelMuonSolid, ar, "BARREL_MUON_LV");
148 
149   G4LogicalVolume* endcapMuonLV = new G4LogicalVolume(endcapMuonSolid, ar, "ENDCAP_MUON_LV");
150 
151   G4VisAttributes* muonVisAtt = new G4VisAttributes(true, G4Colour(1., 1., 0.5));
152   // muonVisAtt-> SetForceWireframe(TRUE);
153   barrelMuonLV->SetVisAttributes(muonVisAtt);
154   endcapMuonLV->SetVisAttributes(muonVisAtt);
155 
156   const G4double dangle = 45. * deg;
157   G4ThreeVector posM(RIN_BARREL_MUON + DY_BARREL_MUON / 2., 0., 0.);
158   G4RotationMatrix* rotM = new G4RotationMatrix;
159   rotM->rotateZ(90. * deg);
160 
161   for (G4int k = 0; k < 8; k++) {
162     G4Transform3D transformM(*rotM, posM);
163     new G4PVPlacement(transformM, "BARREL_MUON_PV", barrelMuonLV, expHall, FALSE, k);
164     rotM->rotateZ(dangle);
165     posM.rotateZ(dangle);
166   }
167 
168   G4ThreeVector posMuon(0., 0., 8. * m);
169   // G4PVPlacement* endcapMuon1=
170   new G4PVPlacement(0, posMuon, "ENDCAP_MUON_PV", endcapMuonLV, expHall, FALSE, 0);
171 
172   // G4PVPlacement* endcapMuon2=
173   new G4PVPlacement(0, -posMuon, "ENDCAP_MUON_PV", endcapMuonLV, expHall, FALSE, 1);
174 
175   // sensitive Detectors
176   G4SDManager* SDman = G4SDManager::GetSDMpointer();
177 
178   G4String muonSDname = "/mydet/muon";
179   H02MuonSD* muonSD = new H02MuonSD(muonSDname);
180   SDman->AddNewDetector(muonSD);
181   barrelMuonLV->SetSensitiveDetector(muonSD);
182   endcapMuonLV->SetSensitiveDetector(muonSD);
183 
184   // magnetic field
185   H02Field* myfield = new H02Field;
186   G4FieldManager* fieldMgr = G4TransportationManager::GetTransportationManager()->GetFieldManager();
187   fieldMgr->SetDetectorField(myfield);
188   fieldMgr->CreateChordFinder(myfield);
189 
190   return expHall;
191 }
192