QwGeant4
QweakSimTriggerScintillator.cc
Go to the documentation of this file.
1 //=============================================================================
2 //
3 // ---------------------------
4 // | Doxygen File Information |
5 // ---------------------------
6 //
7 /**
8 
9  \file QweakSimTriggerScintillator.cc
10 
11  $Revision: 1.2 $
12  $Date: 2005/12/27 19:15:51 $
13 
14  \author Klaus Hans Grimm
15 
16 */
17 //=============================================================================
18 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
19 
21 
22 // geant4 includes
23 #include "G4RunManager.hh"
24 
25 // user includes
26 #include "QweakSimSolids.hh"
27 #include "QweakSimMaterial.hh"
31 
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
34 {
35  // initialize some pointers
37  pMaterial = NULL;
38 
40  // TriggerScintillatorContainer_Physical = NULL;
43 
47 
48 
49  //Rotation_TriggerScintillatorContainer = NULL;
50 
51  // pointer to the sensitive detector
52  TriggerScintillatorSD = NULL;
53 
54 
55  TriggerScintillatorMessenger = new QweakSimTriggerScintillatorMessenger(this); //Messenger for first TS Control
56  TriggerScintillatorMessenger = new QweakSimTriggerScintillatorMessenger(this,1); // Messenger for second TS Control
57 
59 
60  // get cerenkov material
61  //CerenkovContainer_Material = pMaterial->GetMaterial("HeGas");
62 
65 
66  // define container values
67  Container_FullLength_X = 220.0*cm; // Full X length
68  Container_FullLength_Y = 60.0*cm; // Full Y length
69  Container_FullLength_Z = 1.27*cm; // Full Z length , just a bit thicker to get an air gap
70 
71  // define container values
72  StraightBar_FullLength = 210.00*cm; // Full X length
73  StraightBar_FullHeight = 58.00*cm; // Full Y length
74  StraightBar_FullThickness = 1.00*cm; // Full Z length
75 
76  // tilting angle of V-shaped TriggerScintillator against the vertical plane
77  Tilting_Angle = 0.0*degree;
78 
79  //Phi angle of TriggerScintillator of Package 1
80  Phi_Angle = 0.0*degree;
81 
86  for (size_t i=0; i< Position_TriggerScintillatorContainer_Z.size();i++)
87  {
88  // define center position of Container in MotherVolume
90 
91 //jpan@nuclear.uwinnipeg.ca
92  //Position_TriggerScintillatorContainer_Y = 319.0*cm;
94 
95 //jpan@nuclear.uwinnipeg.ca
96  //Position_TriggerScintillatorContainer_Z = 555.0*cm; // adjusted by Jie
97  Position_TriggerScintillatorContainer_Z[i] = 545.0*cm; // adjusted by Jie
98 
99  // define Rotation matrix for Container orientated in MotherVolume
100  Rotation_TriggerScintillatorContainer[i] = new G4RotationMatrix();
101 
102  }
103 
104  }
105 
106 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
108 {
109 
110 // if (Rotation_TriggerScintillatorContainer) delete Rotation_TriggerScintillatorContainer;
111 
114 
115  // if (TriggerScintillatorContainer_Physical) delete TriggerScintillatorContainer_Physical;
117 
119 }
120 
121 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
123 {
124  G4cout << G4endl << "###### Calling QweakSimTriggerScintillator::DefineTriggerScintillatorGeometry() " << G4endl << G4endl;
125  G4cout << G4endl << "###### Leaving QweakSimTriggerScintillator::DefineTriggerScintillatorGeometry() " << G4endl << G4endl;
126 }
127 
128 
129 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
130 void QweakSimTriggerScintillator::ConstructComponent(G4VPhysicalVolume* MotherVolume)
131 {
132  G4cout << G4endl << "###### Calling QweakSimTriggerScintillator::ConstructComponent() " << G4endl << G4endl;
133  theMotherPV = MotherVolume; //Saving pointer to the MotherVolume
134  //-----------------------------------------------------------
135  // location and orientation of the TriggerScintillator Container
136  //-----------------------------------------------------------
137 
138  // I prefere to tilt the Detector inside its container rather than
139  // tilting the container. Why? I don't know what to do if
140  // I want to place 8 containers, each tilted by Tilting_Angle,
141  // but to which axis then ?!
142  // Rotation_TriggerScintillatorContainer->rotateX(Tilting_Angle);
143 
144 
145  // define Container for the V shape Scintillator Detector
146  G4cout << G4endl << "###### QweakSimTriggerScintillator: Define TriggerScintillatorContainer_Solid " << G4endl << G4endl;
147 
148  G4Box* TriggerScintillatorContainer_Solid = new G4Box("TriggerScintillatorContainer_Solid",
149  0.5 * Container_FullLength_X , // half X length required by Geant4
150  0.5 * Container_FullLength_Y , // half Y length required by Geant4
151  0.5 * Container_FullLength_Z ); // half Z length required by Geant4
152 
153  // define Container logical volume
154  G4cout << G4endl << "###### QweakSimTriggerScintillator: Define TriggerScintillatorContainer_Logical " << G4endl << G4endl;
155 
156  TriggerScintillatorContainer_Logical = new G4LogicalVolume(TriggerScintillatorContainer_Solid,
158  "TriggerScintillatorContainer_Logical",
159  0,0,0);
160 
161 
162  // define ScintillatorContainer physical volume
164 
165  G4Box* StraightBar_Solid = new G4Box("StraightBar_Sol",
166  0.5 * StraightBar_FullLength, // half X length required by Geant4
167  0.5 * StraightBar_FullHeight, // half Y length required by Geant4
168  0.5 * StraightBar_FullThickness ); // half Z length required by Geant4
169 
170 
171 // Testing: use unly straight bar (w/o chambers)
172  TriggerScintillator_Logical = new G4LogicalVolume( StraightBar_Solid,
174  "TriggerScintillator_Logical",
175  0,0,0);
176 
177 
178  // define center position of TriggerScintillator within Container
179  G4ThreeVector Position_TriggerScintillator = G4ThreeVector(0,0,0);
180 
181  // define Scintillator physical volume
182  G4cout << G4endl << "###### QweakSimShieldingWall: Define TriggerScintillator Physical " << G4endl << G4endl;
183  TriggerScintillator_Physical = new G4PVPlacement(0,
184  Position_TriggerScintillator,
186  "TriggerScintillator_Physical",
188  false,
189  0,
190  pSurfChk);
191 
192 
193  G4cout << G4endl << "###### QweakSimTriggerScintillator: Setting Sensitive Detectors " << G4endl << G4endl;
194 
195  // Sensitive detectors
196  //------------------------------------------------
197  // All managed (deleted) by SDManager
198 
199  G4SDManager* SDman = G4SDManager::GetSDMpointer();
200 
201 
202  //#######################################################
203  // define drift chamber elements as sensitiv detectors
204  // "sensitivity" will be handled by class QweakSimVDCSD
205  //#######################################################
206 
207 
208  //***********************************************************
209  TriggerScintillatorSD = new QweakSimTriggerScintillator_DetectorSD("/TriggerScintillatorSD");
210  SDman->AddNewDetector(TriggerScintillatorSD);
211 
212  // add Scintillator detector as a sensitiv element
213  //TriggerScintillator_Logical->SetSensitiveDetector(TriggerScintillatorSD);
215  //***********************************************************
216 
217 
218 G4cout << G4endl << "###### QweakSimTriggerScintillator: Setting Attributes " << G4endl << G4endl;
219 
220  G4Colour orange ( 255/255., 127/255., 0/255.);
221  G4Colour blue ( 0/255., 0/255., 255/255.);
222  // G4Colour magenta ( 255/255., 0/255., 255/255.);
223  G4Colour grey ( 127/255., 127/255., 127/255.);
224  G4Colour lightblue ( 139/255., 208/255., 255/255.);
225  G4Colour lightorange ( 255/255., 189/255., 165/255.);
226 
227  //------------------------------------------
228  // Visual Attributes for: ScintillatorContainer
229  //------------------------------------------
230  G4VisAttributes* TriggerScintillatorContainerVisAtt = new G4VisAttributes(blue);
231  //TriggerScintillatorContainerVisAtt->SetVisibility(false);
232  TriggerScintillatorContainerVisAtt->SetVisibility(true);
233  TriggerScintillatorContainerVisAtt->SetForceWireframe(true);
234  //TriggerScintillatorContainerVisAtt->SetForceSolid(true);
235  TriggerScintillatorContainer_Logical->SetVisAttributes(TriggerScintillatorContainerVisAtt);
236 
237  //-----------------------------------------
238  // Visual Attributes for: TriggerScintillator
239  //-----------------------------------------
240 // G4VisAttributes* TriggerScintillatorVisAtt = new G4VisAttributes(lightblue);
241 // TriggerScintillatorVisAtt->SetVisibility(true);
242 // // Needed for the correct visualization using Coin3D
243 // //TriggerScintillatorVisAtt->SetForceSolid(true);
244 // //TriggerScintillatorVisAtt->SetForceWireframe(true);
245 // TriggerScintillator_Logical->SetVisAttributes(TriggerScintillatorVisAtt);
246 //
247 G4cout << G4endl << "###### Leaving QweakSimTriggerScintillator::ConstructComponent() " << G4endl << G4endl;
248 
249 } // end of QweakSimTriggerScintillator::ConstructComponent()
250 
251 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
252 
254 {
255  // search the material by its name
256  G4Material* pttoMaterial = G4Material::GetMaterial(materialName);
257  if (pttoMaterial)
258  {
259  G4cout << "==== Changing TriggerScintillator Detector Material: Looking up Material " << G4endl;
260  TriggerScintillator_Logical->SetMaterial(pttoMaterial);
261  G4cout << "==== Changing Scintillator detector Material: Now the TriggerScintillator is made of " << materialName << G4endl;
262  }
263  else {
264  G4cerr << "==== ERROR: Changing TriggerScintillator Detector Material failed" << G4endl;
265  }
266 
267 }
268 
269 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
270 
272 {
273 }
274 
275 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
277 {
278  G4cout << G4endl << "###### Calling QweakSimTriggerScintillator::SetTriggerScintillatorThickness() " << G4endl << G4endl;
279 
280  G4Box *box = NULL;
281 
282  Thickness = thickness;
283 
285  box = (G4Box*) TriggerScintillator_Logical->GetSolid();
286  if(box)
287  box->SetZHalfLength(0.5*Thickness);
288 
289 
290  G4RunManager::GetRunManager()->GeometryHasBeenModified();
291 
292  G4cout << G4endl << "###### Leaving QweakSimTriggerScintillator::SetTriggerScintillatorThickness() " << G4endl << G4endl;
293 }
294 
295 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
297 {
298  G4cout << G4endl << "###### Calling QweakSimTriggerScintillator::SetScintillatorCenterPositionInX() " << G4endl << G4endl;
299 
302 
303  G4cout << G4endl << "###### Leaving QweakSimTriggerScintillator::SetTriggerScintillatorCenterPositionInX() " << G4endl << G4endl;
304 }
305 
306 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
308 {
309  G4cout << G4endl << "###### Calling QweakSimTriggerScintillator::SetTriggerScintillatorCenterPositionInY() " << G4endl << G4endl;
310 
313 
314  G4cout << G4endl << "###### Leaving QweakSimTriggerScintillator::SetTriggerScintillatorCenterPositionInY() " << G4endl << G4endl;
315 }
316 
317 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
319 {
320  G4cout << G4endl << "###### Calling QweakSimTriggerScintillator::SetTriggerScintillatorCenterPositionInZ() " << G4endl << G4endl;
321 
324 
325  G4cout << G4endl << "###### Leaving QweakSimTriggerScintillator::SetTriggerScintillatorCenterPositionInZ() " << G4endl << G4endl;
326 }
327 
328 
329 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
331 {
332  G4cout << G4endl << "###### Calling QweakSimTriggerScintillator::SetTriggerScintillatorTiltAngle() " << G4endl << G4endl;
333 
334  // assign new tilting
335  Tilting_Angle = tiltangle;
336 
338 
339  G4cout << G4endl << "###### Leaving QweakSimTriggerScintillator::SetTriggerScintillatorTiltAngle() " << G4endl << G4endl;
340 }
341 
342 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
344 {
345  //G4cout << G4endl << "###### Calling QweakSimTriggerScintillator::SetTriggerScintillatorPhiAngle() " << G4endl << G4endl;
346 
347  // assign new azimuthal angle
348  Phi_Angle = phiangle -90.0*degree;
349 
351 
352  G4cout << G4endl << "###### Leaving QweakSimTriggerScintillator::SetTriggerScintillatorPhiAngle() " << G4endl << G4endl;
353 
354 }
355 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
357 {
358  G4cout << G4endl << "###### QweakSimTriggerScintillator: Define TriggerScintillatorContainer_Physical " << G4endl << G4endl;
359  for (size_t i=0; i< TriggerScintillatorContainer_Physical.size();i++)
360  {
361 
362  G4double phi = Phi_Angle + i * 180.0 * degree;
363  Rotation_TriggerScintillatorContainer[i] = new G4RotationMatrix();
364  Rotation_TriggerScintillatorContainer[i]->rotateZ(-phi);
366 
370 
372 
375  "TriggerScintillatorContainer_Physical",
377  theMotherPV,
378  false,
379  i,
380  pSurfChk);
381  }
382 }
384 {
385  for (size_t i=0; i< TriggerScintillatorContainer_Physical.size();i++) {
388 
391 
394 
395  }
396 
398 }
std::vector< G4double > Position_TriggerScintillatorContainer_Y
G4VSensitiveDetector * TriggerScintillatorSD
void SetTriggerScintillatorCenterPositionInZ(G4double zPos, G4int pkg=0)
std::vector< G4double > Position_TriggerScintillatorContainer_Z
void SetTriggerScintillatorCenterPositionInY(G4double yPos, G4int pkg=0)
static QweakSimMaterial * GetInstance()
QweakSimTriggerScintillatorMessenger * TriggerScintillatorMessenger
G4LogicalVolume * TriggerScintillatorContainer_Logical
static const G4bool pSurfChk
G4VPhysicalVolume * TriggerScintillator_Physical
std::vector< G4VPhysicalVolume * > TriggerScintillatorContainer_Physical
void SetTriggerScintillatorTiltAngle(G4double tiltangle)
G4Material * GetMaterial(G4String material)
std::vector< G4RotationMatrix * > Rotation_TriggerScintillatorContainer
Storing hit information of the Trigger Scintillator detector.
void SetTriggerScintillatorCenterPositionInX(G4double xPos, G4int pkg=0)
void SetTriggerScintillatorThickness(G4double thickness)
Scans the input file for /Scintillator/xyz commands.
void SetTriggerScintillatorMaterial(G4String materialName)
void ConstructComponent(G4VPhysicalVolume *MotherVolume)
std::vector< G4double > Position_TriggerScintillatorContainer_X
void SetTriggerScintillatorPhiAngle(G4double phiangle)