QwGeant4
QweakSimLumiDetector.cc
Go to the documentation of this file.
1 /*
2 
3  \file QweakSimLumiDetector.cc
4  \author Wade Duvall
5 
6 */
7 
9 #include "G4RunManager.hh"
10 #include "G4VisAttributes.hh"
11 #include "QweakSimSolids.hh"
12 #include "QweakSimMaterial.hh"
14 #include "QweakSimLumiMessenger.hh"
15 
16 
18 {
19 
20  // Initialize pointers to objects
21  LumiMessenger = NULL;
22  USLumi_Rot = NULL;
23  USLumi_Solid = NULL;
24  USLumi_Logical = NULL;
25  USLumi_Physical = NULL;
26  DSLumi_Rot = NULL;
27  DSLumi_Solid = NULL;
28  DSLumi_Logical = NULL;
29  DSLumi_Physical = NULL;
30 
31  /* Geometries are for the detector in the 1 slot:
32  * https://qweak.jlab.org/wiki/images/Qweak-Coordinate-Systems.png
33  *
34  * FIXME: These need to be double checked by me.
35  */
36 
37  /* USLumi geometries */
38  USLumi_Length_X = 7.0*cm;
39  USLumi_Length_Y = 25.0*cm;
40  USLumi_Length_Z = 2.0*cm;
41  // DSLumi geometries
42  DSLumi_Length_X = 2.0*cm;
43  DSLumi_Length_Y = 6.0*cm;
44  DSLumi_Length_Z = 4.0*cm;
45 
46  // USLumi positions
47  USLumi_Position_X = 25.0*cm;
48  USLumi_Position_Y = 0.0*cm;
49  USLumi_Position_Z = -387.5*cm;
50  // DSLumi positions
51  DSLumi_Position_X = 0*cm;
52  DSLumi_Position_Y = 0*cm;
53  DSLumi_Position_Z = 0*cm;
54 
55  // Create lumi messenger
57 
58  // Access to material definition
60 
61  // Get quartz for lumi bars
62  QuartzBar = pMaterial->GetMaterial("Quartz");
63 }
64 
66 
67 void QweakSimLumiDetector::ConstructComponent(G4VPhysicalVolume* MotherVolume)
68 {
69  // Create G4RotationMatrix and set rotation to zero for now
70  USLumi_Rot = new G4RotationMatrix();
71  DSLumi_Rot = new G4RotationMatrix();
72  USLumi_Rot->rotateX(0);
73  DSLumi_Rot->rotateX(0);
74 
75  // Create G4ThreeVector for lumi positions
78 
79  //DSLumi_Position = new G4PVPlacement(USLumi_Rot,G4ThreeVector(DSLumi_Position_X, DSLumi_Position_Y, DSLumi_Position_Z));
80 
81  // Create upstream lumi bar
82  USLumi_Solid = new G4Box("USLumi", // Object name
83  USLumi_Length_X/2.0, // X size
84  USLumi_Length_Y/2.0, // Y size
85  USLumi_Length_Z/2.0); // Z Size
86 
87  // Place the lumi bar into a quartz lv
88  USLumi_Logical = new G4LogicalVolume(USLumi_Solid, // Solid placed in lv
89  QuartzBar, // Material for lv
90  "USLumi_Logical", // Name for object
91  0,0,0); // Set all options to zero for now
92 
93  //DSLumi_Logical = new G4LogicalVolume(DSLumi_Solid, // Solid placed in lv
94  // QuartzBar, // Material for lv
95  // "DSLumi_Logical", // Name for object
96  // 0,0,0); // Set all options to zero for now
97 
98  // Create G4PVPlacement with uslumi position
99  USLumi_Physical = new G4PVPlacement(USLumi_Rot,
100  USLumi_XYZ,
101  "USLumi_Physical",
103  MotherVolume,
104  false,
105  0,
106  pSurfChk);
107 
108  // Create G4PVPlacement with dslumi position
109  //DSLumi_Physical = new G4PVPlacement(DSLumi_Rot,
110  // DSLumi_XYZ,
111  // "DSLumi_Physical",
112  // DSLumi_Logical,
113  // MotherVolume,
114  // false,
115  // 0);
116 
117  // Define sensitive detectors for USLumi and DSLumi
118  G4SDManager* SDman = G4SDManager::GetSDMpointer();
119 
120  USLumiSD = new QweakSimLumi_DetectorSD("USLumiSD");
121  SDman->AddNewDetector(USLumiSD);
122  USLumi_Logical->SetSensitiveDetector(USLumiSD);
123 
124  //Make it pretty...
125  G4Colour red (1.,0.,0.);
126  G4Colour blue (0.,0.,1.);
127 
128  USLumi_VisAtt = new G4VisAttributes(red);
129  //G4VisAttributes* DSLumi_VisAtt = new G4VisAttributes(blue);
130  USLumi_VisAtt->SetVisibility(true);
131  USLumi_Logical->SetVisAttributes(USLumi_VisAtt);
132 
133 }
134 
136  /* Set USLumi X position. */
137 
138  G4cout << "=== Calling QweakSimLumi::SetUSLumi_PositionInX() " << G4endl;
139  USLumi_Position_X = xPos;
140  USLumi_Physical->SetTranslation(G4ThreeVector(USLumi_Position_X,
143  G4cout << "=== Leaving QweakSimLumi::SetUSLumi_PositionInX() " << G4endl << G4endl;
144 }
145 
147  /* Set USLumi Y position. */
148 
149  G4cout << "=== Calling QweakSimLumi::SetUSLumi_PositionInY() " << G4endl;
150  USLumi_Position_Y = yPos;
151  USLumi_Physical->SetTranslation(G4ThreeVector(USLumi_Position_Y,
154  G4cout << "=== Leaving QweakSimLumi::SetUSLumi_PositionInY() " << G4endl << G4endl;
155 }
156 
158  /* Set USLumi Z position. */
159 
160  G4cout << "=== Calling QweakSimLumi::SetUSLumi_PositionInZ() " << G4endl;
161  USLumi_Position_Z = zPos;
162  USLumi_Physical->SetTranslation(G4ThreeVector(USLumi_Position_Z,
165  G4cout << "=== Leaving QweakSimLumi::SetUSLumi_PositionInZ() " << G4endl << G4endl;
166 }
167 
168 void QweakSimLumiDetector::SetUSLumi_Material(G4String materialName) {
169  //--- Set USLumi Material
170 
171  G4Material* pttoMaterial = G4Material::GetMaterial(materialName);
172 
173  if (pttoMaterial)
174  {
175  G4cout << "=== Changing USLumi material: Look up material " << G4endl;
176  USLumi_Logical -> SetMaterial(pttoMaterial);
177  G4cout << "=== Changing USLumi material: Now the material is " << materialName << G4endl;
178  }
179  else
180  G4cerr << "=== Error: Changing USLumi material FAILED! " << G4endl << G4endl;
181 
182 }
183 
185  //--- Enable the USLumi
186 
187  G4cout << "=== Calling QweakSimLumi::SetUSLumi_Enabled() " << G4endl;
188  USLumi_VisAtt->SetVisibility(true);
189  SetUSLumi_Material(QuartzBar -> GetName());
190  USLumi_Physical->SetTranslation(G4ThreeVector(USLumi_Position_X,
193  G4cout << "=== Leaving QweakSimLumi::SetUSLumi_Enabled() " << G4endl << G4endl;
194 }
195 
196 
197 
198 /////// --------------------------------------------------------------------
199 
201  //--- Disable the USLumi
202 
203  G4cout << "=== Calling QweakSimLumi::SetUSLumi_Disabled() " << G4endl;
204  USLumi_VisAtt -> SetVisibility(false);
205  SetUSLumi_Material("Air");
206  USLumi_Physical->SetTranslation(G4ThreeVector(USLumi_Position_X,
208  USLumi_Position_Z + 400*cm));
209  G4cout << "=== Leaving QweakSimLumi::SetLumi_Disabled() " << G4endl << G4endl;
210 }
static QweakSimMaterial * GetInstance()
G4LogicalVolume * USLumi_Logical
G4VPhysicalVolume * USLumi_Physical
QweakSimMaterial * pMaterial
QweakSimLumiMessenger * LumiMessenger
void SetUSLumi_Material(G4String)
G4Material * GetMaterial(G4String material)
G4VSensitiveDetector * USLumiSD
void SetUSLumi_PositionInX(G4double)
void SetUSLumi_PositionInY(G4double)
G4LogicalVolume * DSLumi_Logical
static const G4bool pSurfChk
G4VPhysicalVolume * DSLumi_Physical
void ConstructComponent(G4VPhysicalVolume *)
G4RotationMatrix * USLumi_Rot
G4RotationMatrix * DSLumi_Rot
G4VisAttributes * USLumi_VisAtt
void SetUSLumi_PositionInZ(G4double)