source: trunk/examples/advanced/gammaray_telescope/src/GammaRayTelDetectorConstruction.cc @ 1314

Last change on this file since 1314 was 1230, checked in by garnier, 14 years ago

update to geant4.9.3

File size: 25.6 KB
Line 
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//
27// $Id: GammaRayTelDetectorConstruction.cc,v 1.15 2006/06/29 15:56:22 gunter Exp $
28// GEANT4 tag $Name: geant4-09-03-cand-01 $
29// ------------------------------------------------------------
30//      GEANT 4 class implementation file
31//      CERN Geneva Switzerland
32//
33//
34//      ------------ GammaRayTelDetectorConstruction  ------
35//           by F.Longo, R.Giannitrapani & G.Santin (13 nov 2000)
36//
37// ************************************************************
38//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
39//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
40
41#include "GammaRayTelDetectorConstruction.hh"
42#include "GammaRayTelDetectorMessenger.hh"
43
44#include "GammaRayTelTrackerSD.hh"
45#include "GammaRayTelTrackerROGeometry.hh"
46
47#include "GammaRayTelAnticoincidenceSD.hh"
48#include "GammaRayTelCalorimeterSD.hh"
49
50#include "G4Material.hh"
51#include "G4Box.hh"
52#include "G4LogicalVolume.hh"
53#include "G4PVPlacement.hh"
54#include "G4PVReplica.hh"
55#include "G4UniformMagField.hh"
56#include "G4FieldManager.hh"
57#include "G4TransportationManager.hh"
58#include "G4SDManager.hh"
59#include "G4RunManager.hh"
60
61#include "G4VisAttributes.hh"
62#include "G4Colour.hh"
63
64#include "G4ios.hh"
65#include "G4RegionStore.hh"
66
67
68//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
69
70GammaRayTelDetectorConstruction::GammaRayTelDetectorConstruction()
71  :solidWorld(0),logicWorld(0),physiWorld(0),
72   solidPayload(0),logicPayload(0),physiPayload(0),
73   solidTKR(0),logicTKR(0),physiTKR(0),
74   solidCAL(0),logicCAL(0),physiCAL(0),
75   solidACT(0),logicACT(0),physiACT(0),
76   solidACL1(0),logicACL1(0),physiACL1(0),
77   solidACL2(0),logicACL2(0),physiACL2(0),
78   solidTKRDetectorX(0),logicTKRDetectorX(0),physiTKRDetectorX(0),
79   solidTKRDetectorY(0),logicTKRDetectorY(0),physiTKRDetectorY(0),
80   solidCALLayerX(0),logicCALLayerX(0),physiCALLayerX(0),
81   solidCALLayerY(0),logicCALLayerY(0),physiCALLayerY(0),
82   solidCALDetectorX(0),logicCALDetectorX(0),physiCALDetectorX(0),
83   solidCALDetectorY(0),logicCALDetectorY(0),physiCALDetectorY(0),
84   solidPlane(0),logicPlane(0),physiPlane(0),
85   solidConverter(0),logicConverter(0),physiConverter(0),
86   trackerSD(0),calorimeterSD(0),anticoincidenceSD(0),
87   aTKRRegion(0), aCALRegion(0)
88{
89  // default parameter values of the payload
90 
91  ConverterThickness = 300.*micrometer;
92  TKRSiliconThickness = 400.*micrometer;
93  TKRSiliconTileXY = 9.*cm;
94  TKRSiliconPitch = 200.*micrometer; 
95  TKRLayerDistance = 3.*cm;
96  SiliconGuardRing = 1.5*mm;
97  TKRViewsDistance = 1.*mm;
98  NbOfTKRLayers = 15;
99  NbOfTKRTiles = 4;
100  CALBarThickness = 1.5*cm;
101  NbOfCALBars = 12;
102  NbOfCALLayers = 5;
103  ACDThickness = 1.*cm;
104  NbOfACDTopTiles = 1;
105  NbOfACDLateralTiles = 2;
106
107  TilesSeparation = 100.*micrometer;
108  ACDTKRDistance = 5.*cm;
109  CALTKRDistance = 1.5*cm;
110
111  ComputePayloadParameters();
112
113  // create commands for interactive definition of the payload
114  detectorMessenger = new GammaRayTelDetectorMessenger(this);
115
116}
117
118//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
119
120GammaRayTelDetectorConstruction::~GammaRayTelDetectorConstruction()
121{ delete detectorMessenger;}
122
123//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
124
125G4VPhysicalVolume* GammaRayTelDetectorConstruction::Construct()
126{
127  DefineMaterials();
128  return ConstructPayload();
129}
130
131//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
132
133void GammaRayTelDetectorConstruction::DefineMaterials()
134{ 
135 
136  G4String name, symbol;   
137  G4double a, z, density;           
138 
139  G4int ncomponents, natoms;
140  G4double fractionmass;
141  G4double temperature, pressure;
142
143  //
144  // define Elements
145  //
146 
147  a = 1.01*g/mole;
148  G4Element* H  = new G4Element(name="Hydrogen",symbol="H" , z= 1., a);
149 
150  a = 12.01*g/mole;
151  G4Element* C  = new G4Element(name="Carbon"  ,symbol="C" , z= 6., a);
152
153  a = 14.006*g/mole;
154  G4Element* N  = new G4Element(name="Nitrogen"  ,symbol="N" , z= 7., a);
155 
156  a = 15.99*g/mole;
157  G4Element* O  = new G4Element(name="Oxygen"  ,symbol="O" , z= 8., a);
158
159  a = 26.98*g/mole;
160  G4Element* Alumin = new G4Element(name="Aluminum"  ,symbol="Al" , z= 13., a);
161
162  a = 28.09*g/mole;
163  G4Element* Silicon = new G4Element(name="Silicon", symbol="Si", z=14., a);
164 
165  a= 55.845*g/mole;
166  G4Element* Iron = new G4Element(name="Iron", symbol="Fe", z=26.,a);
167
168  a = 126.904*g/mole;
169  G4Element* I  = new G4Element(name="Iodine"  ,symbol="I" , z= 53., a);
170 
171  a = 132.905*g/mole;
172  G4Element* Cs  = new G4Element(name="Cesium"  ,symbol="Cs" , z= 55., a);
173
174  a = 207.19*g/mole;
175  G4Element* Lead = new G4Element(name="Lead", symbol="Pb", z=82., a);
176
177  //
178  // define simple materials
179  //
180
181  density = 19.3*g/cm3;
182  a = 183.84*g/mole;
183  G4Material* W = new G4Material(name="Tungsten", z=74., a, density);
184 
185     
186  //
187  // define a material from elements.   case 1: chemical molecule
188  //
189 
190  density = 1.032*g/cm3;
191  G4Material* Sci = new G4Material(name="Scintillator", density, ncomponents=2);
192  Sci->AddElement(C, natoms=9);
193  Sci->AddElement(H, natoms=10);
194 
195  density = 4.53*g/cm3;
196  G4Material* CsI = new G4Material(name="CesiumIodide", density, ncomponents=2);
197  CsI->AddElement(Cs, natoms=5);
198  CsI->AddElement(I, natoms=5);
199 
200  //
201  // define a material from elements.   case 2: mixture by fractional mass
202  //
203 
204  density = 1.290*mg/cm3;
205  G4Material* Air = new G4Material(name="Air"  , density, ncomponents=2);
206  Air->AddElement(N, fractionmass=0.7);
207  Air->AddElement(O, fractionmass=0.3);
208
209  density = 2.700*g/cm3;
210  G4Material* Al = new G4Material(name="Aluminum", density, ncomponents=1);
211  Al->AddElement(Alumin, fractionmass=1.);
212
213  density = 2.333*g/cm3; 
214  G4Material* Si = new G4Material(name="Silicon", density, ncomponents=1);
215  Si->AddElement(Silicon, fractionmass=1.);
216 
217  density = 7.87*g/cm3;
218  G4Material* Fe = new G4Material(name="Iron", density, ncomponents=1);
219  Fe->AddElement(Iron, fractionmass=1.);
220 
221  density = 11.35*g/cm3;
222  G4Material* Pb = new G4Material(name="Lead", density, ncomponents=1);
223  Pb->AddElement(Lead, fractionmass=1.);
224
225  //
226  // examples of vacuum
227  //
228 
229  density     = universe_mean_density;    //from PhysicalConstants.h
230  pressure    = 3.e-18*pascal;
231  temperature = 2.73*kelvin;
232  G4Material* vacuum = new G4Material(name="Galactic", z=1., a=1.01*g/mole, density,kStateGas,temperature,pressure);
233 
234  density     = 1.e-5*g/cm3;
235  pressure    = 2.e-2*bar;
236  temperature = STP_Temperature;         //from PhysicalConstants.h
237  G4Material* beam = new G4Material(name="Beam", density, ncomponents=1,
238                                    kStateGas,temperature,pressure);
239  beam->AddMaterial(Air, fractionmass=1.);
240 
241  G4cout << *(G4Material::GetMaterialTable()) << G4endl;
242 
243  //default materials of the payload
244
245  ConverterMaterial = W;
246  defaultMaterial  = vacuum;
247  ACDMaterial = Sci;
248  CALMaterial = CsI;
249  TKRMaterial = Si;
250
251}
252
253//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
254
255G4VPhysicalVolume* GammaRayTelDetectorConstruction::ConstructPayload()
256{
257  // complete the Payload parameters definition
258  ComputePayloadParameters();
259 
260  //     
261  // World
262  //
263
264  solidWorld = new G4Box("World",                                   
265                         WorldSizeXY/2,WorldSizeXY/2,WorldSizeZ/2); 
266 
267  logicWorld = new G4LogicalVolume(solidWorld,         
268                                   defaultMaterial,     
269                                   "World");           
270 
271  physiWorld = new G4PVPlacement(0,G4ThreeVector(),"World",logicWorld,
272                                 0,false,0);                   
273 
274  //                               
275  // Payload
276  // 
277 
278  /* solidPayload=0; logicPayload=0; physiPayload=0;
279  solidTKR=0;logicTKR=0;physiTKR=0;
280  solidCAL=0;logicCAL=0;physiCAL=0;
281  solidACT=0;logicACT=0;physiACT=0;
282  solidACL1=0;logicACL1=0;physiACL1=0;
283  solidACL2=0;logicACL2=0;physiACL2=0;
284  solidConverter=0;logicConverter=0;physiConverter=0;
285  solidTKRDetectorX=0;logicTKRDetectorX=0;
286  solidTKRDetectorY=0;logicTKRDetectorY=0;
287  physiTKRDetectorX=0;physiTKRDetectorY=0;
288  solidCALDetectorX=0;logicCALDetectorX=0;physiCALDetectorX=0;
289  solidCALDetectorY=0;logicCALDetectorY=0;physiCALDetectorY=0;
290  solidPlane=0;logicPlane=0;physiPlane=0;
291  aCALRegion=0; aTKRRegion=0;
292  */
293  //
294  // Payload
295  //
296 
297  solidPayload = new G4Box("Payload",           
298                           PayloadSizeXY/2,
299                           PayloadSizeXY/2,
300                           PayloadSizeZ/2);
301 
302  logicPayload = new G4LogicalVolume(solidPayload,     
303                                     defaultMaterial,   
304                                     "Payload"); 
305 
306  physiPayload = new G4PVPlacement(0,           
307                                   G4ThreeVector(),     
308                                   "Payload",   
309                                   logicPayload,       
310                                   physiWorld, 
311                                   false,               
312                                   0);         
313  //                                 
314  // Calorimeter (CAL)
315  //
316 
317  solidCAL = new G4Box("CAL",                   
318                       CALSizeXY/2,CALSizeXY/2,CALSizeZ/2); 
319 
320  logicCAL = new G4LogicalVolume(solidCAL,
321                                 defaultMaterial,
322                                 "CAL");       
323  physiCAL = new G4PVPlacement(0,               
324                               G4ThreeVector(0,0,
325                                             -PayloadSizeZ/2+CALSizeZ/2),
326                               "CAL",           
327                               logicCAL,
328                               physiPayload,
329                               false,   
330                               0);     
331  //                                 
332  // Tracker (TKR)
333      //
334 
335  solidTKR = new G4Box("TKR",                   
336                           TKRSizeXY/2,TKRSizeXY/2,TKRSizeZ/2); 
337 
338  logicTKR = new G4LogicalVolume(solidTKR,
339                                 defaultMaterial,
340                                 "TKR");       
341  physiTKR = new G4PVPlacement(0,               
342                               G4ThreeVector(0,0,
343                                             -PayloadSizeZ/2+CALSizeZ+
344                                             CALTKRDistance+TKRSizeZ/2),
345                               "TKR",           
346                               logicTKR,
347                               physiPayload,
348                               false,   
349                               0);     
350 
351 
352  //                               
353  // Anticoincidence Top (ACT)
354  //
355 
356  solidACT = new G4Box("ACT",                   
357                       ACTSizeXY/2,ACTSizeXY/2,ACTSizeZ/2); 
358 
359  logicACT = new G4LogicalVolume(solidACT,ACDMaterial,"ACT");
360 
361  physiACT = new G4PVPlacement(0,               
362                               G4ThreeVector(0,0,
363                                             -PayloadSizeZ/2+CALSizeZ+
364                                             CALTKRDistance+TKRSizeZ+
365                                             ACDTKRDistance+ACTSizeZ/2),
366                               "ACT",           
367                               logicACT,
368                               physiPayload,
369                               false,   
370                               0);     
371 
372  //                               
373  // Anticoincidence Lateral Side (ACL)
374  //
375 
376  solidACL1 = new G4Box("ACL1",                 
377                        ACL1SizeX/2,ACL1SizeY/2,ACL1SizeZ/2); 
378 
379  logicACL1 = new G4LogicalVolume(solidACL1,ACDMaterial,"ACL"); 
380 
381  physiACL1 = new G4PVPlacement(0, 
382                                G4ThreeVector(-PayloadSizeXY/2+ACL1SizeX/2,
383                                              -PayloadSizeXY/2+ACL1SizeY/2,
384                                              -PayloadSizeZ/2+ACL1SizeZ/2),
385                                "ACL1",         
386                                logicACL1,
387                                physiPayload,
388                                false, 
389                                0);     
390 
391  physiACL1 = new G4PVPlacement(0,
392                                G4ThreeVector(PayloadSizeXY/2-ACL1SizeX/2,
393                                              PayloadSizeXY/2-ACL1SizeY/2,
394                                              -PayloadSizeZ/2+ACL1SizeZ/2),
395                                "ACL1",         
396                                logicACL1,
397                                physiPayload,
398                                false, 
399                                1);     
400 
401  solidACL2 = new G4Box("ACL2",                 
402                        ACL2SizeX/2,ACL2SizeY/2,ACL2SizeZ/2); 
403 
404  logicACL2 = new G4LogicalVolume(solidACL2,
405                                  ACDMaterial,
406                                  "ACL2");     
407 
408 
409  physiACL2 = new G4PVPlacement(0, 
410                                G4ThreeVector(-PayloadSizeXY/2+ACL2SizeX/2,
411                                              PayloadSizeXY/2-ACL2SizeY/2,
412                                              -PayloadSizeZ/2+ACL2SizeZ/2),
413                                "ACL2",         
414                                logicACL2,
415                                physiPayload,
416                                false, 
417                                0);     
418 
419  physiACL2 = new G4PVPlacement(0, 
420                                G4ThreeVector(PayloadSizeXY/2-ACL2SizeX/2,
421                                              -PayloadSizeXY/2+ACL2SizeY/2,
422                                              -PayloadSizeZ/2+ACL2SizeZ/2),
423                                "ACL2",         
424                                logicACL2,
425                                physiPayload,
426                                false, 
427                                1);     
428 
429 
430  // Tracker Structure (Plane + Converter + TKRDetectorX + TKRDetectorY)
431 
432  solidPlane = new G4Box("Plane",                       
433                         TKRSizeXY/2,TKRSizeXY/2,TKRSupportThickness/2); 
434 
435  logicPlane = new G4LogicalVolume(solidPlane,
436                                   defaultMaterial, 
437                                   "Plane");   
438 
439  solidTKRDetectorY = new G4Box
440    ("TKRDetectorY",TKRSizeXY/2,TKRSizeXY/2,TKRSiliconThickness/2); 
441 
442  logicTKRDetectorY = new G4LogicalVolume(solidTKRDetectorY,
443                                          TKRMaterial, 
444                                          "TKRDetector Y");     
445 
446 
447  solidTKRDetectorX = new G4Box
448    ("TKRDetectorX",TKRSizeXY/2,TKRSizeXY/2,TKRSiliconThickness/2); 
449 
450  logicTKRDetectorX = new G4LogicalVolume(solidTKRDetectorX,
451                                          TKRMaterial, 
452                                          "TKRDetector X");     
453 
454 
455  solidConverter = new G4Box
456    ("Converter",TKRSizeXY/2,TKRSizeXY/2,ConverterThickness/2); 
457 
458  logicConverter = new G4LogicalVolume(solidConverter,
459                                       ConverterMaterial, 
460                                       "Converter");   
461 
462  G4int i=0;
463 
464  for (i = 0; i < NbOfTKRLayers; i++)
465    {
466     
467      physiTKRDetectorY = 
468        new G4PVPlacement(0,G4ThreeVector(0.,0.,-TKRSizeZ/2
469                                          +TKRSiliconThickness/2 
470                                          +(i)*TKRLayerDistance),
471                          "TKRDetectorY",               
472                          logicTKRDetectorY,
473                          physiTKR,
474                          false,       
475                          i);
476     
477      physiTKRDetectorX = 
478        new G4PVPlacement(0,G4ThreeVector(0.,0.,
479                                          -TKRSizeZ/2+
480                                          TKRSiliconThickness/2 +
481                                          TKRViewsDistance+
482                                          TKRSiliconThickness+
483                                          (i)*TKRLayerDistance),
484                          "TKRDetectorX",               
485                          logicTKRDetectorX,
486                          physiTKR,
487                          false,       
488                          i);
489     
490     
491      physiConverter = 
492        new G4PVPlacement(0,G4ThreeVector(0.,0.,
493                                          -TKRSizeZ/2+
494                                          2*TKRSiliconThickness +
495                                          TKRViewsDistance+
496                                          ConverterThickness/2+
497                                          (i)*TKRLayerDistance),
498                          "Converter",         
499                          logicConverter,
500                          physiTKR,
501                          false,       
502                          i);
503
504           
505     
506      physiPlane =
507        new G4PVPlacement(0,G4ThreeVector(0.,0.,
508                                          -TKRSizeZ/2+
509                                          2*TKRSiliconThickness +
510                                          TKRViewsDistance+
511                                          ConverterThickness+
512                                          TKRSupportThickness/2+
513                                          (i)*TKRLayerDistance),
514                          "Plane",             
515                          logicPlane,
516                          physiTKR,
517                          false,       
518                          i);   
519     
520    }
521 
522 
523 
524  G4VSolid * solidTKRActiveTileX = new
525    G4Box("Active Tile X", TKRActiveTileXY/2,
526          TKRActiveTileXY/2,TKRActiveTileZ/2);
527 
528 
529  G4VSolid * solidTKRActiveTileY = new
530    G4Box("Active Tile Y", TKRActiveTileXY/2,
531          TKRActiveTileXY/2,TKRActiveTileZ/2);
532 
533 
534  G4LogicalVolume* logicTKRActiveTileX = 
535    new G4LogicalVolume(solidTKRActiveTileX, TKRMaterial,
536                        "Active Tile X",0,0,0);
537 
538 
539  G4LogicalVolume* logicTKRActiveTileY = 
540    new G4LogicalVolume(solidTKRActiveTileY, TKRMaterial,
541                        "Active Tile Y",0,0,0);
542 
543 
544  G4int j=0;
545  G4int k=0;
546 
547  G4VPhysicalVolume* physiTKRActiveTileX = 0;
548  G4VPhysicalVolume* physiTKRActiveTileY = 0;
549 
550  G4double x=0.;
551  G4double y=0.;
552  G4double z=0.;
553 
554  for (i=0;i< NbOfTKRTiles; i++)
555    { 
556      for (j=0;j< NbOfTKRTiles; j++)
557        {
558          k = i*NbOfTKRTiles + j;
559         
560         
561          x = -TKRSizeXY/2+TilesSeparation+SiliconGuardRing+
562            TKRActiveTileXY/2+(i)*((2*SiliconGuardRing)+
563                                   TilesSeparation+TKRActiveTileXY);
564          y = -TKRSizeXY/2+TilesSeparation+SiliconGuardRing+
565            TKRActiveTileXY/2+(j)*((2*SiliconGuardRing)+TilesSeparation+
566                                   TKRActiveTileXY);
567          z = 0.;
568         
569          physiTKRActiveTileY =
570            new G4PVPlacement(0,
571                              G4ThreeVector(x,y,z),
572                              "Active Tile Y",         
573                              logicTKRActiveTileY,
574                              physiTKRDetectorY,
575                              false,   
576                              k);
577         
578
579          x = -TKRSizeXY/2+TilesSeparation+SiliconGuardRing+
580            TKRActiveTileXY/2+(j)*((2*SiliconGuardRing)+
581                                   TilesSeparation+TKRActiveTileXY);
582          y = -TKRSizeXY/2+TilesSeparation+SiliconGuardRing+
583            TKRActiveTileXY/2+(i)*((2*SiliconGuardRing)+
584                                   TilesSeparation+TKRActiveTileXY);
585          z = 0.;
586             
587          physiTKRActiveTileX =
588            new G4PVPlacement(0,
589                              G4ThreeVector(x,y,z),
590                              "Active Tile X",         
591                              logicTKRActiveTileX,
592                              physiTKRDetectorX,
593                              false,   
594                              k);       
595         
596        }
597    }
598 
599
600  // Calorimeter Structure (CALLayerX + CALLayerY)
601 
602 
603  solidCALLayerX = new G4Box("CALLayerX",                       
604                             CALSizeXY/2,CALSizeXY/2,CALBarThickness/2); 
605 
606  logicCALLayerX = new G4LogicalVolume(solidCALLayerX,
607                                       CALMaterial, 
608                                       "CALLayerX");   
609 
610  solidCALLayerY = new G4Box("CALLayerY",                       
611                             CALSizeXY/2,CALSizeXY/2,CALBarThickness/2); 
612 
613  logicCALLayerY = new G4LogicalVolume(solidCALLayerY,
614                                       CALMaterial, 
615                                       "CALLayerY");   
616 
617  for (i = 0; i < NbOfCALLayers; i++)
618    {
619     
620      physiCALLayerY = 
621        new G4PVPlacement(0,G4ThreeVector(0,0,
622                                          -CALSizeZ/2+
623                                          CALBarThickness/2 +
624                                          (i)*2*CALBarThickness),
625                          "CALLayerY",         
626                          logicCALLayerY,
627                          physiCAL,
628                          false,       
629                          i);   
630     
631      physiCALLayerX = 
632        new G4PVPlacement(0,G4ThreeVector(0,0,
633                                          -CALSizeZ/2+
634                                          CALBarThickness/2 + 
635                                          CALBarThickness +
636                                          (i)*2*CALBarThickness),
637                          "CALLayerX",         
638                          logicCALLayerX,
639                          physiCAL,
640                          false,       
641                          i);   
642     
643    }
644 
645  // Calorimeter Structure (CALDetectorX + CALDetectorY)
646 
647  solidCALDetectorX = new G4Box("CALDetectorX",                 
648                                CALBarX/2,CALBarY/2,CALBarThickness/2); 
649 
650  logicCALDetectorX = new G4LogicalVolume(solidCALDetectorX,
651                                          CALMaterial, 
652                                          "CALDetectorX");     
653 
654  solidCALDetectorY = new G4Box("CALDetectorY",                 
655                                CALBarY/2,CALBarX/2,CALBarThickness/2); 
656 
657  logicCALDetectorY = new G4LogicalVolume(solidCALDetectorY,
658                                          CALMaterial, 
659                                          "CALDetectorY");     
660 
661  for (i = 0; i < NbOfCALBars; i++)
662    {
663     
664      physiCALDetectorY = 
665        new G4PVPlacement(0,
666                          G4ThreeVector(-CALSizeXY/2+ CALBarY/2 +
667                                        (i)*CALBarY, 0, 0),
668                          "CALDetectorY",               
669                          logicCALDetectorY,
670                          physiCALLayerY,
671                          false,       
672                          i);   
673     
674      physiCALDetectorX = 
675        new G4PVPlacement(0,
676                          G4ThreeVector(0,-CALSizeXY/2+ CALBarY/2 +
677                                        (i)*CALBarY, 0),
678                          "CALDetectorX",               
679                          logicCALDetectorX,
680                          physiCALLayerX,
681                          false,       
682                          i);   
683     
684    }
685 
686 
687  // Cuts by Regions
688
689
690  G4String regName[] = {"Calorimeter","Tracker"};
691  if (aCALRegion) delete aCALRegion;
692
693  aCALRegion = new G4Region(regName[0]);
694  logicCAL->SetRegion(aCALRegion);
695  aCALRegion->AddRootLogicalVolume(logicCAL);
696
697  if (aTKRRegion) delete aTKRRegion;
698
699  aTKRRegion = new G4Region(regName[1]);
700  logicTKR->SetRegion(aTKRRegion);
701  aTKRRegion->AddRootLogicalVolume(logicTKR);
702
703  //Sensitive Detector Manager
704 
705  G4SDManager* SDman = G4SDManager::GetSDMpointer();
706 
707  //
708  // Sensitive Detectors - Tracker
709  //
710                               
711 
712  if(!trackerSD)
713    {
714      trackerSD = new GammaRayTelTrackerSD("TrackerSD");
715      SDman->AddNewDetector( trackerSD );               
716    }
717
718
719  G4String ROgeometryName = "TrackerROGeom";
720  G4VReadOutGeometry* trackerRO = 
721    new GammaRayTelTrackerROGeometry(ROgeometryName);
722 
723  trackerRO->BuildROGeometry();
724  trackerSD->SetROgeometry(trackerRO);
725
726  if (logicTKRActiveTileX)
727    logicTKRActiveTileX->SetSensitiveDetector(trackerSD); // ActiveTileX
728  if (logicTKRActiveTileY)
729    logicTKRActiveTileY->SetSensitiveDetector(trackerSD); // ActiveTileY
730
731  //
732  // Sensitive Detectors: Calorimeter
733  //
734
735
736
737  if(!calorimeterSD)
738    {
739      calorimeterSD = new GammaRayTelCalorimeterSD("CalorimeterSD");
740      SDman->AddNewDetector( calorimeterSD );           
741    }
742 
743  if (logicCALDetectorX)
744    logicCALDetectorX->SetSensitiveDetector(calorimeterSD); // BarX
745  if (logicCALDetectorY)
746    logicCALDetectorY->SetSensitiveDetector(calorimeterSD); // BarY
747
748  //
749  // Sensitive Detectors: Anticoincidence
750  //
751
752  if(!anticoincidenceSD)
753    {
754      anticoincidenceSD = new GammaRayTelAnticoincidenceSD
755        ("AnticoincidenceSD");
756      SDman->AddNewDetector( anticoincidenceSD );               
757    }
758 
759  if (logicACT)
760    logicACT->SetSensitiveDetector(anticoincidenceSD); // ACD top
761  if (logicACL1)
762    logicACL1->SetSensitiveDetector(anticoincidenceSD); // ACD lateral side
763  if (logicACL2)
764    logicACL2->SetSensitiveDetector(anticoincidenceSD); // ACD lateral side
765
766  //                                       
767  // Visualization attributes
768  //
769 
770  // Invisible Volume
771  logicWorld->SetVisAttributes (G4VisAttributes::Invisible);
772  logicPayload->SetVisAttributes (G4VisAttributes::Invisible);
773  logicTKR->SetVisAttributes(G4VisAttributes::Invisible); 
774  logicTKRActiveTileX->SetVisAttributes(G4VisAttributes::Invisible); 
775  logicTKRActiveTileY->SetVisAttributes(G4VisAttributes::Invisible); 
776  logicPlane->SetVisAttributes(G4VisAttributes::Invisible); 
777  logicConverter->SetVisAttributes(G4VisAttributes::Invisible);
778  logicCAL->SetVisAttributes(G4VisAttributes::Invisible);
779  logicCALLayerX->SetVisAttributes(G4VisAttributes::Invisible);
780  logicCALLayerY->SetVisAttributes(G4VisAttributes::Invisible);
781 
782  // Some visualization styles
783
784  G4VisAttributes* VisAtt1= new G4VisAttributes(G4Colour(0.3,0.8,0.1));
785  VisAtt1->SetVisibility(true);
786  VisAtt1->SetForceSolid(TRUE);
787
788  G4VisAttributes* VisAtt2= new G4VisAttributes(G4Colour(0.2,0.3,0.8));
789  VisAtt2->SetVisibility(true);
790  VisAtt2->SetForceSolid(FALSE);
791
792  G4VisAttributes* VisAtt3= new G4VisAttributes(G4Colour(0.8,0.2,0.3));
793  VisAtt3->SetVisibility(true);
794  VisAtt3->SetForceWireframe(TRUE);
795 
796  // Visible Volumes
797
798  logicCALDetectorX->SetVisAttributes(VisAtt1);
799  logicCALDetectorY->SetVisAttributes(VisAtt1);
800  logicTKRDetectorX->SetVisAttributes(VisAtt2);
801  logicTKRDetectorY->SetVisAttributes(VisAtt2);
802  logicACT->SetVisAttributes(VisAtt3); 
803  logicACL1->SetVisAttributes(VisAtt3); 
804  logicACL2->SetVisAttributes(VisAtt3);
805
806
807  //
808  //always return the physical World
809  //
810  PrintPayloadParameters();
811  return physiWorld;
812}
813
814//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
815
816void GammaRayTelDetectorConstruction::PrintPayloadParameters()
817{
818  G4cout << "\n------------------------------------------------------------"
819         << "\n---> The Tracker is " << NbOfTKRLayers << " layers of:  "
820         << ConverterThickness/mm << "mm of " << ConverterMaterial->GetName() 
821         << "\n------------------------------------------------------------\n";
822}
823
824//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
825
826
827//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
828
829void GammaRayTelDetectorConstruction::SetConverterMaterial(G4String materialChoice)
830{
831  // search the material by its name   
832  G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);     
833  if (pttoMaterial)
834    {
835      ConverterMaterial = pttoMaterial;
836      logicConverter->SetMaterial(pttoMaterial); 
837      PrintPayloadParameters();
838    }             
839}
840
841void GammaRayTelDetectorConstruction::SetConverterThickness(G4double val)
842{
843  ConverterThickness = val;
844} 
845
846//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
847
848void GammaRayTelDetectorConstruction::SetTKRSiliconThickness(G4double val)
849{
850  TKRSiliconThickness = val;
851} 
852
853
854void GammaRayTelDetectorConstruction::SetTKRSiliconPitch(G4double val)
855{
856  TKRSiliconPitch = val;
857} 
858
859
860void GammaRayTelDetectorConstruction::SetTKRTileSizeXY(G4double val)
861{
862  TKRSiliconTileXY = val;
863} 
864
865
866void GammaRayTelDetectorConstruction::SetNbOfTKRLayers(G4int val)
867{
868  NbOfTKRLayers = val;
869}
870
871
872void GammaRayTelDetectorConstruction::SetNbOfTKRTiles(G4int val)
873{
874  NbOfTKRTiles = val;
875}
876
877void GammaRayTelDetectorConstruction::SetTKRLayerDistance(G4double val)
878{
879  TKRLayerDistance = val;
880}
881
882void GammaRayTelDetectorConstruction::SetTKRViewsDistance(G4double val)
883{
884  TKRViewsDistance = val;
885}
886
887
888//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
889
890void GammaRayTelDetectorConstruction::SetNbOfCALLayers(G4int val)
891{
892  NbOfCALLayers = val;
893}
894
895void GammaRayTelDetectorConstruction::SetNbOfCALBars(G4int val)
896{
897  NbOfCALBars = val;
898}
899
900void GammaRayTelDetectorConstruction::SetCALBarThickness(G4double val)
901{
902  CALBarThickness = val;
903}
904
905//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
906
907void GammaRayTelDetectorConstruction::SetACDThickness(G4double val)
908{
909  ACDThickness = val;
910}
911
912//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
913
914void GammaRayTelDetectorConstruction::SetMagField(G4double fieldValue)
915{
916  //apply a global uniform magnetic field along Z axis
917  G4FieldManager* fieldMgr
918    = G4TransportationManager::GetTransportationManager()->GetFieldManager();
919   
920  if(magField) delete magField;         //delete the existing magn field
921 
922  if(fieldValue!=0.)                    // create a new one if non nul
923    { magField = new G4UniformMagField(G4ThreeVector(0.,0.,fieldValue));       
924    fieldMgr->SetDetectorField(magField);
925    fieldMgr->CreateChordFinder(magField);
926    } else {
927      magField = 0;
928      fieldMgr->SetDetectorField(magField);
929    }
930}
931
932//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
933 
934void GammaRayTelDetectorConstruction::UpdateGeometry()
935{
936  //  delete payloadSD;
937  G4RunManager::GetRunManager()->DefineWorldVolume(ConstructPayload());
938  G4RunManager::GetRunManager()->PhysicsHasBeenModified();
939  G4RegionStore::GetInstance()->UpdateMaterialList(physiWorld);
940
941
942}
943
944//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
Note: See TracBrowser for help on using the repository browser.