~chris-rogers/maus/emr_mc_digitization

« back to all changes in this revision

Viewing changes to src/common_cpp/DetModel/EMR/EMRBar.cc

  • Committer: Chris Rogers
  • Date: 2014-04-16 11:48:45 UTC
  • mfrom: (707 merge)
  • mto: This revision was merged to the branch mainline in revision 711.
  • Revision ID: chris.rogers@stfc.ac.uk-20140416114845-h3u3q7pdcxkxvovs
Update to trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of MAUS: http://micewww.pp.rl.ac.uk:8080/projects/maus
 
2
 *
 
3
 * MAUS is free software: you can redistribute it and/or modify
 
4
 * it under the terms of the GNU General Public License as published by
 
5
 * the Free Software Foundation, either version 3 of the License, or
 
6
 * (at your option) any later version.
 
7
 *
 
8
 * MAUS is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with MAUS.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 */
 
17
// C++
 
18
#include <stdio.h>
 
19
#include <iostream>
 
20
 
 
21
// CLHEP
 
22
#include "CLHEP/Vector/Rotation.h"
 
23
 
 
24
 
 
25
#include "Geant4/G4NistManager.hh"
 
26
#include "Geant4/G4Material.hh"
 
27
#include "Geant4/G4Tubs.hh"
 
28
#include "Geant4/G4Box.hh"
 
29
#include "Geant4/G4Trap.hh"
 
30
#include "Geant4/G4LogicalVolume.hh"
 
31
#include "Geant4/G4PVPlacement.hh"
 
32
#include "Geant4/G4PVParameterised.hh"
 
33
#include "Geant4/G4UserLimits.hh"
 
34
#include "Geant4/G4VisAttributes.hh"
 
35
#include "Geant4/G4Colour.hh"
 
36
#include "Geant4/G4ios.hh"
 
37
#include "Geant4/G4ThreeVector.hh"
 
38
#include "Geant4/G4RotationMatrix.hh"
 
39
#include "Geant4/globals.hh"
 
40
#include "Geant4/G4SDManager.hh"
 
41
 
 
42
#include "DetModel/EMR/EMRBar.hh"
 
43
#include "DetModel/EMR/EMRSD.hh"
 
44
#include "DetModel/EMR/BarParameterisation.hh"
 
45
 
 
46
EMRBar::EMRBar(MiceModule* mod,
 
47
               G4Material* mater,
 
48
               G4VPhysicalVolume *mlv) {
 
49
 
 
50
 
 
51
  // --------- Material definition ---------
 
52
  G4NistManager* nistMan = G4NistManager::Instance();
 
53
  nistMan->SetVerbose(2);
 
54
  // nistMan->ListMaterials("all";)
 
55
 
 
56
  G4Material* Air = nistMan->FindOrBuildMaterial("G4_Galactic");
 
57
  G4Material* Polystyrene = nistMan->FindOrBuildMaterial("G4_POLYSTYRENE");
 
58
 
 
59
  G4String symbol;             // a=mass of a mole;
 
60
  G4double a, z, density;      // z=mean number of protons;
 
61
  G4int ncomponents, natoms;
 
62
 
 
63
  G4Element* H = new G4Element("Hydrogen", symbol="H", z = 1., a = 1.01*g/mole);
 
64
  G4Element* C = new G4Element("Carbon"  , symbol="C", z = 6., a = 12.01*g/mole);
 
65
  G4Element* O = new G4Element("Oxygen"  , symbol="O", z = 8., a = 15.9994*g/mole);
 
66
 
 
67
  G4Material* Glue = new G4Material("EpoxyGlue", density = 1.36*g/cm3, ncomponents = 3);
 
68
  Glue->AddElement(C, natoms = 261);
 
69
  Glue->AddElement(H, natoms = 304);
 
70
  Glue->AddElement(O, natoms = 40);
 
71
 
 
72
  G4Material* Acr = new G4Material("Acrylic", density = 1.18*g/cm3, ncomponents = 3);
 
73
  Acr->AddElement(C, natoms = 5);
 
74
  Acr->AddElement(O, natoms = 2);
 
75
  Acr->AddElement(H, natoms = 8);
 
76
 
 
77
  // Print all the materials defined.
 
78
  //
 
79
  // G4cout << G4endl << "The materials defined are : " << G4endl << G4endl;
 
80
  // G4cout << *(G4Material::GetMaterialTable()) << G4endl;
 
81
 
 
82
  // --------- Sizes of the principal geometrical components (solids)  ---------
 
83
 
 
84
  G4double fNbOfBars = mod->propertyDouble("NbOfBars");
 
85
  // std::cerr << "NUMBER OF BARS " << fNbOfBars << std::endl;
 
86
  G4double fBarWidth = mod->propertyDouble("BarWidth");
 
87
  G4double fBarHeight = mod->propertyDouble("BarHeight");
 
88
  G4double fBarLength = mod->propertyDouble("BarLength");
 
89
  G4double fHoleRad = mod->propertyDouble("HoleRad");
 
90
  G4double fFiberCladdingExtRadius = mod->propertyDouble("FiberCladdingExtRadius");
 
91
 
 
92
  G4double fFiberCoreRadius = 0.95*fFiberCladdingExtRadius;
 
93
  G4Material* BarMater = Polystyrene;
 
94
  G4Material* HoleMater = Glue;
 
95
  G4Material* FiberCladdingExtMater = Acr;
 
96
  G4Material* FiberCoreMater = Polystyrene;
 
97
  G4double fCalorimeterLength = 1.2*fBarLength;
 
98
//   G4double fWorldLength = 1.2*fCalorimeterLength;
 
99
  // ----------------------------------------------------------------------------
 
100
 
 
101
  // ------------------------------
 
102
  // Calorimeter
 
103
  // ------------------------------
 
104
  G4double HalfCaloLength = 0.5*fCalorimeterLength;
 
105
 
 
106
  solidCalorimeter = new G4Box("calorimeter",
 
107
                               HalfCaloLength,
 
108
                               HalfCaloLength,
 
109
                               HalfCaloLength);
 
110
 
 
111
  logicCalorimeter = new G4LogicalVolume(solidCalorimeter, Air, "Calorimeter", 0, 0, 0);
 
112
  physiCalorimeter = new G4PVPlacement(0,                   // no rotation
 
113
                                       mod->position(),
 
114
                                       logicCalorimeter,    // its logical volume
 
115
                                       "Calorimeter",       // its name
 
116
                                       mlv->GetLogicalVolume(), // its mother  volume
 
117
                                       false,               // no boolean operations
 
118
                                       0);                  // copy number
 
119
 
 
120
  // ----------------------------------------------------------------------------
 
121
 
 
122
  G4double pDz    = 0.5*fBarHeight; // Half-length along the z-axis
 
123
 
 
124
  G4double pTheta = 0.0;            // Polar angle of the line joining
 
125
                                    // the centres of the faces at -/+pDz
 
126
 
 
127
  G4double pPhi   = 0.0;            // Azimuthal angle of the line joing the centre of the face at
 
128
                                    // -pDz to the centre of the face at +pDz
 
129
 
 
130
  G4double pDy1   = 0.5*fBarWidth;  // Half-length along y of the face at -pDz
 
131
 
 
132
  G4double pDx1   = 0.5*fBarLength; // Half-length along x of the side at
 
133
                                    // y=-pDy1 of the face at -pDz
 
134
 
 
135
  G4double pDx2   = 0.5*fBarLength; // Half-length along x of the side at
 
136
                                    // y=+pDy1 of the face at -pDz
 
137
 
 
138
  G4double pAlp1  = 0.0;     // Angle with respect to the y axis from the centre of the side
 
139
                             // at y=-pDy1 to the centre at y=+pDy1 of the face at -pDz
 
140
 
 
141
  G4double pDy2   = 0.01*cm; // Half-length along y of the face at +pDz
 
142
 
 
143
  G4double pDx3   = pDx1;    // Half-length along x of the side at y=-pDy2 of the face at +pDz
 
144
 
 
145
  G4double pDx4   = pDx1;    // Half-length along x of the side at y=+pDy2 of the face at +pDz
 
146
 
 
147
  G4double pAlp2  = pAlp1;   // Angle with respect to the y axis from the centre of the side
 
148
                             // at y=-pDy2 to the centre at y=+pDy2 of the face at +pDz
 
149
 
 
150
  solidBar = new G4Trap("bar", pDz, pTheta, pPhi, pDy1, pDx1,
 
151
                        pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2);
 
152
 
 
153
  logicBar = new G4LogicalVolume(solidBar, BarMater, "Bar", 0, 0, 0);
 
154
 
 
155
  barParam = new BarParameterisation(fBarWidth,
 
156
                                     fBarHeight,
 
157
                                     fNbOfBars,
 
158
                                     0.05*cm);
 
159
 
 
160
  // dummy value : kZAxis -- modified by parameterised volume
 
161
  physiBar = new G4PVParameterised("Bar",            // their name
 
162
                                   logicBar,         // their logical volume
 
163
                                   logicCalorimeter, // Mother logical volume
 
164
                                   kZAxis,           // Are placed along this axis
 
165
                                   fNbOfBars,        // Number of bars
 
166
                                   barParam);        // The parametrisation
 
167
 
 
168
  fAddWLSFiber = mod->propertyBool("AddWLSFiber");
 
169
 
 
170
  if (fAddWLSFiber) {
 
171
    // ------------------------------
 
172
    // Hole
 
173
    // ------------------------------
 
174
    G4RotationMatrix roty = G4RotationMatrix();
 
175
    roty.rotateY(90*deg);
 
176
    G4ThreeVector positionH = G4ThreeVector(0., 0., 0.05*mm);
 
177
    G4Transform3D transformH = G4Transform3D(roty, positionH);
 
178
 
 
179
    solidHole = new G4Tubs("Hole", 0.*mm, fHoleRad/2, fBarLength/2, 0.*deg, 360.*deg);
 
180
    logicHole = new G4LogicalVolume(solidHole, HoleMater, "Hole", 0, 0, 0);
 
181
    physiHole = new G4PVPlacement(transformH, // at (x,y,z)
 
182
                                  logicHole,  // its logical volume
 
183
                                  "Hole",     // its name
 
184
                                  logicBar,   // its mother  volume
 
185
                                  false,      // no boolean operations
 
186
                                  0);         // copy number
 
187
 
 
188
    // ------------------------------
 
189
    // Fiber Cladding
 
190
    // ------------------------------
 
191
    solidFiberCladding = new G4Tubs("FiberCladding",
 
192
                                    0.*mm,
 
193
                                    fFiberCladdingExtRadius/2,
 
194
                                    fBarLength/2,
 
195
                                    0.*deg,
 
196
                                    360.*deg);
 
197
 
 
198
    logicFiberCladding = new G4LogicalVolume(solidFiberCladding,
 
199
                                             FiberCladdingExtMater,
 
200
                                            "FiberCladding",
 
201
                                             0, 0, 0);
 
202
 
 
203
    physiFiberCladding =
 
204
    new G4PVPlacement(0,                     // no rotation
 
205
                      G4ThreeVector((fHoleRad-fFiberCladdingExtRadius)/2, 0., 0.),
 
206
                      logicFiberCladding,    // its logical volume
 
207
                      "FiberCladding",       // its name
 
208
                      logicHole,             // its mother  volume
 
209
                      false,                 // no boolean operations
 
210
                      0);                    // copy number
 
211
 
 
212
    // ------------------------------
 
213
    // Fiber Core
 
214
    // ------------------------------
 
215
    solidFiberCore = new G4Tubs("FiberCladding",
 
216
                                0.*mm,
 
217
                                fFiberCoreRadius/2,
 
218
                                fBarLength/2,
 
219
                                0.*deg,
 
220
                                360.*deg);
 
221
 
 
222
    logicFiberCore = new G4LogicalVolume(solidFiberCore,
 
223
                                         FiberCoreMater,
 
224
                                         "FiberCore",
 
225
                                         0, 0, 0);
 
226
 
 
227
    physiFiberCore = new G4PVPlacement(0,                  // no rotation
 
228
                                       G4ThreeVector(),
 
229
                                       logicFiberCore,     // its logical volume
 
230
                                       "FiberCore",        // its name
 
231
                                       logicFiberCladding, // its mother  volume
 
232
                                       false,              // no boolean operations
 
233
                                       0);                 // copy number
 
234
    // ------------------------------
 
235
  }// if (fAddWLSFiber)
 
236
}
 
237
 
 
238
EMRBar::~EMRBar() {
 
239
  //  delete physiCore;
 
240
}
 
241
 
 
242
 
 
243