~c-e-pidcott/maus/devel

« back to all changes in this revision

Viewing changes to src/common_cpp/DetModel/SciFi/SciFiPlane.cc

  • Committer: Chris Rogers
  • Date: 2011-11-04 16:46:18 UTC
  • mfrom: (656.1.27 maus-trunk3)
  • Revision ID: chris.rogers@stfc.ac.uk-20111104164618-4gaisprgsgivebix
Changes for release 0.1.0

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
 
 
18
#include <G4Material.hh>
 
19
#include <G4Tubs.hh>
 
20
#include <G4LogicalVolume.hh>
 
21
#include <G4PVPlacement.hh>
 
22
#include <G4PVParameterised.hh>
 
23
#include <G4UserLimits.hh>
 
24
#include <G4VisAttributes.hh>
 
25
#include <G4Colour.hh>
 
26
#include <G4ios.hh>
 
27
#include <G4ThreeVector.hh>
 
28
#include <G4RotationMatrix.hh>
 
29
#include <globals.hh>
 
30
#include <G4SDManager.hh>
 
31
 
 
32
#include "DetModel/SciFi/SciFiPlane.hh"
 
33
#include "DetModel/SciFi/SciFiSD.hh"
 
34
#include "DetModel/SciFi/DoubletFiberParam.hh"
 
35
 
 
36
#include "CLHEP/Vector/Rotation.h"
 
37
 
 
38
// NOTE: not sure how Geant4 deals with the deletion
 
39
// of Logical and Solid Volumes;
 
40
// possible bug in the destructor.
 
41
 
 
42
G4int SciFiPlane::SciFi_numFibres = 0;
 
43
 
 
44
// SciFiPlane - Specific parameterisation of the SciFi station
 
45
// to be called by the generic MICE detector construction code
 
46
SciFiPlane::SciFiPlane(MiceModule* mod,
 
47
                       G4Material* mater,
 
48
                       G4VPhysicalVolume *mlv) {
 
49
  G4double tr = mod->dimensions().x();
 
50
  G4double fd = mod->propertyDouble("FibreDiameter");
 
51
  G4double fp = mod->propertyDouble("Pitch");
 
52
  G4double cd = mod->propertyDouble("CoreDiameter");
 
53
  G4double ar = mod->propertyDouble("ActiveRadius");
 
54
 
 
55
  G4double doubletThickness = mod->dimensions().y();
 
56
 
 
57
  G4String doubletName = mod->fullName() + "Doublet";
 
58
  G4String coreName = mod->fullName() + "DoubletCores";
 
59
  G4String clad1Name = mod->fullName() + "DoubletClad1";
 
60
  G4String clad2Name = mod->fullName() + "DoubletClad2";
 
61
 
 
62
  // Getting the rotations right.
 
63
  // A "z-flip" is a rotation of 180 degrees over the y axis.
 
64
  // Remember that the rotation matrix for
 
65
  // a rotation over the y axis is given by:
 
66
  //
 
67
  //             [cos(theta)  0    sin(theta)]
 
68
  // R_y(theta) =[0           1        0     ]
 
69
  //             [-sin(theta) 0    cos(theta)]
 
70
  //
 
71
 
 
72
  CLHEP::HepRotation zflip;
 
73
  const Hep3Vector rowx(-1., 0, 0);
 
74
  const Hep3Vector rowy(0, 1., 0);
 
75
  const Hep3Vector rowz(0, 0, -1.);
 
76
  zflip.setRows(rowx, rowy, rowz);
 
77
 
 
78
  G4RotationMatrix* trot = new G4RotationMatrix(mod->globalRotation());
 
79
  // this is the rotation of the fibre array
 
80
  (*trot) = (*trot)*zflip;
 
81
 
 
82
  // this is a fibre
 
83
  solidDoublet = new G4Tubs(doubletName, 0.0,
 
84
                            tr, doubletThickness / 2.0,
 
85
                            0.0 * deg, 360.0 * deg);
 
86
 
 
87
  logicDoublet = new G4LogicalVolume(solidDoublet, mater, doubletName, 0, 0, 0);
 
88
 
 
89
  physiDoublet = placeCore = new G4PVPlacement(trot, mod->position(),
 
90
                                               logicDoublet, doubletName,
 
91
                                               mlv->GetLogicalVolume(),
 
92
                                               false, 0);
 
93
 
 
94
  // lenght of the tube of fibre
 
95
  G4double tlen = 1.0 * mm;
 
96
 
 
97
  // the number of fibres to be simulated
 
98
  SciFiPlane::SciFi_numFibres = (G4int)floor(2. * ar / (0.5 * fp));
 
99
 
 
100
  // Beginning of the fiber core definitions
 
101
  solidCore = new G4Tubs(coreName, 0.0, cd / 2., tlen, 0.0 * deg, 360.0 * deg);
 
102
 
 
103
  logicCore = new G4LogicalVolume(solidCore, mater, coreName, 0, 0, 0);
 
104
 
 
105
  G4VPVParameterisation* coreParam = new DoubletFiberParam(ar, ar, cd,
 
106
                                                           0.0, fd, fp / fd);
 
107
 
 
108
  physiCore = new G4PVParameterised(coreName, logicCore, physiDoublet,
 
109
                                    kUndefined, SciFi_numFibres, coreParam);
 
110
}
 
111
 
 
112
SciFiPlane::~SciFiPlane() {
 
113
  delete physiDoublet;
 
114
 
 
115
  delete physiCore;
 
116
}