SToGS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
SToGS_SemiConductorGeDF.cc
Go to the documentation of this file.
1 
2 //
3 // ********************************************************************
4 // * License and Disclaimer *
5 // * *
6 // * The Geant4 software is copyright of the Copyright Holders of *
7 // * the Geant4 Collaboration. It is provided under the terms and *
8 // * conditions of the Geant4 Software License, included in the file *
9 // * LICENSE and available at http://cern.ch/geant4/license . These *
10 // * include a list of copyright holders. *
11 // * *
12 // * Neither the authors of this software system, nor their employing *
13 // * institutes,nor the agencies providing financial support for this *
14 // * work make any representation or warranty, express or implied, *
15 // * regarding this software system or assume any liability for its *
16 // * use. Please see the license in the file LICENSE and URL above *
17 // * for the full disclaimer and the limitation of liability. *
18 // * *
19 // * This code implementation is the result of the scientific and *
20 // * technical work of the GEANT4 collaboration. *
21 // * By using, copying, modifying or distributing the software (or *
22 // * any work based on the software) you agree to acknowledge its *
23 // * use in resulting scientific publications, and indicate your *
24 // * acceptance of all terms of the Geant4 Software license. *
25 // ********************************************************************
26 //
27 //
28 
29 // G4 includes
30 #include "G4Material.hh"
31 #include "G4Box.hh"
32 #include "G4Tubs.hh"
33 #include "G4Polyhedra.hh"
34 #include "G4Sphere.hh"
35 #include "G4GenericTrap.hh"
36 #include "G4Polycone.hh"
37 
38 #include "G4LogicalVolume.hh"
39 #include "G4AssemblyVolume.hh"
40 
41 #include "G4PVPlacement.hh"
42 #include "G4PVParameterised.hh"
43 #include "G4UserLimits.hh"
44 #include "G4VisAttributes.hh"
45 #include "G4Colour.hh"
46 #include "G4ios.hh"
47 #include "G4SubtractionSolid.hh"
48 #include "G4UnionSolid.hh"
49 #include "G4IntersectionSolid.hh"
50 
51 #include "G4PhysicalVolumeStore.hh"
52 #include "G4LogicalVolumeStore.hh"
53 #include "G4SDManager.hh"
54 #include "G4UnitsTable.hh"
55 
56 #include <stdlib.h>
57 
58 // Project includes
60 
61 #include "SToGS_DetectorFactory.hh"
64 
65 using namespace std;
66 
67 // list of all specific factories
68 namespace {
69 // all SemiConductors
70 SToGS::SemiConductorGeDF theGeFactory("SemiConductors/Ge/");
71 }
72 
73 G4VPhysicalVolume * SToGS::SemiConductorGeDF::MakeEXOCLOVER(G4String detname, G4String opt)
74 {
75 
76  // **************************************************************************
77  // * the WORLD *
78  // **************************************************************************
79 
80  G4bool do_caps = true;
81  // Option
82  if ( opt.contains("bare" ) )
83  {
84  do_caps = false;
85  }
86 
87  G4VPhysicalVolume *theDetector = 0x0; //it means is a pointer
88 
89  const G4double world_x = 50.*CLHEP::cm;
90  const G4double world_y = 50.*CLHEP::cm;
91  const G4double world_z = 100.*CLHEP::cm;
92 
93  // use a physical as a container to describe the detector
94  G4Box *detWorld= new G4Box(detname,world_x,world_y,world_z);
95  G4LogicalVolume *detlogicWorld= new G4LogicalVolume(detWorld, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("AIR"), detname, 0, 0, 0);
96 
97  // detlogicWorld->SetVisAttributes(G4VisAttributes::Invisible); // hide the world
98 
99  G4VisAttributes *detlogicWorldVisAtt= new G4VisAttributes(G4Colour(0.0,1.0,1.0)); //turquoise
100  detlogicWorld->SetVisAttributes(detlogicWorldVisAtt);
101 
102  // Must place the World Physical volume unrotated at (0,0,0).
103  theDetector = new G4PVPlacement(0, // no rotation
104  G4ThreeVector(), // at (0,0,0)
105  detlogicWorld, // its logical volume
106  detname, // its name
107  0, // its mother volume
108  false, // no boolean operations
109  -1); // copy number
110 
111  //here is where you construct your clover EXOGAM
112 
113  // **************************************************************************
114  // * CLOVER EXOGAM PLANS GANIL *
115  // **************************************************************************
116 
117  const G4double CrystalLength = 90.0*CLHEP::mm; // Ge crystal length
118  const G4double CrystalHoleDepth = 15.0*CLHEP::mm; // depth at which starts the hole
119 
120  const G4double CrystalOuterRadius = 30.0*CLHEP::mm; // outer radius for crystal
121  const G4double CrystalInnerRadius = 5.0*CLHEP::mm; // inner radius for hole in crystal
122 
123  const G4double CrystalEdgeOffset1 = 24.5*CLHEP::mm; // distance of the edge from the center of the crystal
124  const G4double CrystalEdgeOffset2 = 29*CLHEP::mm; // distance of the edge from the center of the crystal
125 
126  const G4double CrystalEdgeDepth = 30.0*CLHEP::mm; // depth to which the crystal is shaped
127  const G4double CrystalEdgeAngle = 22.5*CLHEP::deg; // bevel angle
128 
129  const G4double CapsuleWidth1 = 1.5*CLHEP::mm; // capsule width
130  const G4double CapsuleWidth2 = 2.0*CLHEP::mm; // capsule width
131  const G4double CapsuleLength = 147.*CLHEP::mm; // capsule length
132  const G4double CapsuleEdgeDepth = 43.25*CLHEP::mm; // not the same as crystal !!!
133  const G4double CrystalToCapsuleTOP = 7.*CLHEP::mm; // to be adjusted ..
134  const G4double CrystalToCapsuleLATERAL = 8.*CLHEP::mm; // to be adjusted ..
135 
136  const G4double BGOLength = 132.893*CLHEP::mm;
137  const G4double BGOWidth = 25.0*CLHEP::mm;
138 
139  const G4double CsILength = 38.8*CLHEP::mm;
140 
141  const G4double Tolerance = 0.1*CLHEP::mm; // distance between crystals
142  const G4double Space = 1.0*CLHEP::mm; // distance between Al capsule and BGO
143  const G4double AlcapstoBGO = 52.907*CLHEP::mm; // distance between the TOP Al capsule to the top of BGO
144 
145 
146 
147  // declaration of all Physical Volumes
148 
149  G4VPhysicalVolume *CrystalA_phys = 0x0;
150  G4VPhysicalVolume *CrystalB_phys = 0x0;
151  G4VPhysicalVolume *CrystalC_phys = 0x0;
152  G4VPhysicalVolume *CrystalD_phys = 0x0;
153  G4VPhysicalVolume *Capsule_phys = 0x0;
154  G4VPhysicalVolume *Capsule_OUT_phys = 0x0;
155  G4VPhysicalVolume *Capsule_IN_phys = 0x0;
156  G4VPhysicalVolume *CFPlate_phys= 0x0;
157  G4VPhysicalVolume *CF_int_phys = 0x0;
158  G4VPhysicalVolume *CF_OUT_phys= 0x0;
159  G4VPhysicalVolume *physiIntEnvColdFinger =0x0;
160  G4VPhysicalVolume *Dewar_phys=0x0;
161  G4VPhysicalVolume *IntDewar_phys=0x0;
162  G4VPhysicalVolume *physiCloverCan= 0x0;
163  G4VPhysicalVolume *BGO_phys = 0x0;
164  G4VPhysicalVolume *CsIBack_phys = 0x0;
165 
166  // define a coaxial shape that will be modify with SubstractSolid
167  // the Ge crystal dimensions
168  G4int nbZplanes = 4;
169  G4double zPlaneGe[4] = { 0.0*CLHEP::mm,
170  CrystalHoleDepth,
171  CrystalHoleDepth + 3.0*CLHEP::mm,
172  CrystalLength}; // depth where is the hole
173  G4double rInnerGe[4] = { 0.0*CLHEP::mm,
174  0.0*CLHEP::mm,
175  CrystalInnerRadius,
176  CrystalInnerRadius}; // to define the hole in the crystal
177  G4double rOuterGe[4] = { CrystalOuterRadius,
178  CrystalOuterRadius,
179  CrystalOuterRadius,
180  CrystalOuterRadius}; // to define the external surface
181 
182 
183  char sName[40]; // generic for named objects
184  sprintf(sName, "Crystal");
185 
186  G4Polycone *detCrystal= new G4Polycone(G4String(sName), //name
187  0.*CLHEP::deg, //phi Start
188  360.*CLHEP::deg, //phiTotal
189  nbZplanes, // number of sides
190  zPlaneGe, // number of Z planes
191  rInnerGe, // inner radius
192  rOuterGe); // outer radius
193 
194 
195  // box definition to remove some matter to the crystal
196 
197  G4double Edge[3];
198 
199  sprintf(sName, "LongEdge1");
200  Edge[0] = (CrystalOuterRadius-CrystalEdgeOffset1); // x half-width
201  Edge[1] = 1.001*CLHEP::mm*CrystalOuterRadius; // y half-width
202  Edge[2] = 1.001*CLHEP::mm*CrystalLength/2.0; // z half-width
203  G4Box *cutEdge1 = new G4Box(G4String(sName),Edge[0],Edge[1],Edge[2]);
204 
205  sprintf(sName, "LongEdge2");
206  Edge[0] = (CrystalOuterRadius-CrystalEdgeOffset2); // x half-width
207  Edge[1] = 1.001*CLHEP::mm*CrystalOuterRadius; // y half-width
208  Edge[2] = 1.001*CLHEP::mm*CrystalLength/2.0; // z half-width
209  G4Box *cutEdge2 = new G4Box(G4String(sName),Edge[0],Edge[1],Edge[2]);
210 
211  sprintf(sName, "Bevel");
212  Edge[0] = 1.001*CLHEP::mm*CrystalOuterRadius;
213  Edge[1] = sin(CrystalEdgeAngle)*(CrystalEdgeDepth);
214  Edge[2] = 1.001*CLHEP::mm*CrystalLength/2.0;
215  G4Box *cutBevel = new G4Box(G4String(sName),Edge[0],Edge[1],Edge[2]);
216 
217 
218  // **************************************************************************
219  // * SUBSTRACTIONS *
220  // **************************************************************************
221 
222  // now remove previously defined box from coax. The box must be placed correctly before
223  // since the box definition goes from negative to positive values.
224 
225  G4RotationMatrix rm; // rm.SetName(G4String("RotationEdge"));
226  sprintf(sName, "coax_cut1_edge");
227  G4SubtractionSolid *coax_cut1
228  = new G4SubtractionSolid (G4String(sName), detCrystal, cutEdge1, &rm, G4ThreeVector(-CrystalOuterRadius,0.0,CrystalLength/2.0));
229 
230  sprintf(sName, "coax_cut2_edge");
231  G4SubtractionSolid *coax_cut2
232  = new G4SubtractionSolid (G4String(sName), coax_cut1, cutEdge2, &rm, G4ThreeVector(CrystalOuterRadius,0.0,CrystalLength/2.0));
233 
234  sprintf(sName, "coax_cut3_edge");
235  rm.rotateZ(90.0*CLHEP::deg);
236  G4SubtractionSolid *coax_cut3
237  = new G4SubtractionSolid (G4String(sName), coax_cut2, cutEdge2, &rm, G4ThreeVector(0.0,CrystalOuterRadius,CrystalLength/2.0));
238 
239  sprintf(sName, "coax_cut4_edge");
240  G4SubtractionSolid *coax_cut4
241  = new G4SubtractionSolid (G4String(sName), coax_cut3, cutEdge1, &rm, G4ThreeVector(0.0,-CrystalOuterRadius,CrystalLength/2.0));
242  rm.rotateZ(-90.0*CLHEP::deg);
243 
244  sprintf(sName, "coax_cut5_edge");
245  rm.rotateX(CrystalEdgeAngle);
246  G4SubtractionSolid *coax_cut5
247  = new G4SubtractionSolid (G4String(sName), coax_cut4, cutBevel, &rm, G4ThreeVector(0.,CrystalEdgeOffset2,0.));
248  // rm.rotateX(-CrystalEdgeAngle);
249  //Bevel is already rotated X with CrystalEdgeAngle soyou have to put it in place to continu
250 
251  rm.rotateX(-CrystalEdgeAngle);
252  sprintf(sName, "coax_cut6_edge");
253  rm.rotateZ(90.0*CLHEP::deg);
254  rm.rotateX(CrystalEdgeAngle);
255  G4SubtractionSolid *coax_cut6
256  = new G4SubtractionSolid (G4String(sName), coax_cut5, cutBevel, &rm, G4ThreeVector(CrystalEdgeOffset2,0.,0.));
257  //rotation back
258  rm.rotateX(-CrystalEdgeAngle);
259  rm.rotateZ(-90.0*CLHEP::deg);
260 
261  //end substraction
262 
263  //Crystal A
264  G4RotationMatrix* Crystal_90deg = new G4RotationMatrix();
265  Crystal_90deg -> rotateZ(90*CLHEP::deg);
266 
267  sprintf(sName, "ShapedCrystalA");
268  G4LogicalVolume *pCrystalA = new G4LogicalVolume( coax_cut6, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Ge"), G4String(sName), 0, 0, 0 );
269  pCrystalA->SetSensitiveDetector( SToGS::UserActionInitialization::GetCopClusterSD() );
270 
271  CrystalA_phys = new G4PVPlacement(Crystal_90deg, // no rotation
272  G4ThreeVector(CrystalEdgeOffset1+Tolerance,-CrystalEdgeOffset1-Tolerance,CrystalToCapsuleTOP), // at (0,0,0)
273  pCrystalA, // its logical volume
274  "CrystalA_P", // its name
275  detlogicWorld, // its mother volume
276  false, // no boolean operations
277  0); // copy n
278  G4VisAttributes *CrystalA_VisAtt= new G4VisAttributes(G4Colour(0.0,0.0,1.0)); //blue
279  pCrystalA ->SetVisAttributes(CrystalA_VisAtt);
280 
281 
282  //Crystal B
283  G4RotationMatrix* Crystal_180deg = new G4RotationMatrix();
284  Crystal_180deg -> rotateZ(180*CLHEP::deg);
285 
286  sprintf(sName, "ShapedCrystalB");
287  G4LogicalVolume *pCrystalB = new G4LogicalVolume( coax_cut6, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Ge"), G4String(sName), 0, 0, 0 );
288  pCrystalB->SetSensitiveDetector( SToGS::UserActionInitialization::GetCopClusterSD() );
289 
290  CrystalB_phys = new G4PVPlacement(Crystal_180deg, // no rotation
291  G4ThreeVector(-CrystalEdgeOffset1-Tolerance,-CrystalEdgeOffset1-Tolerance,CrystalToCapsuleTOP), // at (-26*mm,-26*mm,3.5*mm)
292  pCrystalB, // its logical volume
293  "CrystalB_P", // its name
294  detlogicWorld, // its mother volume
295  false, // no boolean operations
296  1); // copy n
297  G4VisAttributes *CrystalB_VisAtt= new G4VisAttributes(G4Colour(0.0,1.0,0.0)); //green
298  pCrystalB ->SetVisAttributes(CrystalB_VisAtt);
299 
300 
301  //Crystal C
302  G4RotationMatrix* Crystal_270deg = new G4RotationMatrix();
303  Crystal_270deg -> rotateZ(270*CLHEP::deg);
304 
305  sprintf(sName, "ShapedCrystalC");
306  G4LogicalVolume *pCrystalC = new G4LogicalVolume( coax_cut6, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Ge"), G4String(sName), 0, 0, 0 );
307  pCrystalC->SetSensitiveDetector( SToGS::UserActionInitialization::GetCopClusterSD() );
308 
309  CrystalC_phys = new G4PVPlacement(Crystal_270deg, // no rotation
310  G4ThreeVector(-CrystalEdgeOffset1-Tolerance,CrystalEdgeOffset1+Tolerance,CrystalToCapsuleTOP), // at (0,0,0)
311  pCrystalC, // its logical volume
312  "CrystalC_P", // its name
313  detlogicWorld, // its mother volume
314  false, // no boolean operations
315  2); // copy n
316  G4VisAttributes *CrystalC_VisAtt= new G4VisAttributes(G4Colour(1.0,0.0,0.0)); //red
317  pCrystalC ->SetVisAttributes(CrystalC_VisAtt);
318 
319 
320  //Crystal D
321  sprintf(sName, "ShapedCrystalD");
322  G4LogicalVolume *pCrystalD = new G4LogicalVolume( coax_cut6, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Ge"), G4String(sName), 0, 0, 0 );
323 
324  pCrystalD->SetSensitiveDetector( SToGS::UserActionInitialization::GetCopClusterSD() );
325 
326  CrystalD_phys = new G4PVPlacement(0, // no rotation
327  G4ThreeVector(CrystalEdgeOffset1+Tolerance,CrystalEdgeOffset1+Tolerance,CrystalToCapsuleTOP), // at (26*mm,26*mm,3.5*mm)
328  pCrystalD, // its logical volume
329  "CrystalD_P", // its name
330  detlogicWorld, // its mother volume
331  false, // no boolean operations
332  3); // copy n
333  G4VisAttributes *CrystalD_VisAtt= new G4VisAttributes(G4Colour(1.0,1.0,0.0)); //yellow
334  pCrystalD ->SetVisAttributes(CrystalD_VisAtt);
335 
336 
337 
338 
339  // **************************************************************************
340  // * Al CAPSULE *
341  // **************************************************************************
342  G4int nbslice = 7;
343 
344  const G4double widthface = 44.085*CLHEP::mm;
345  // const G4double widthface = 45.5*CLHEP::mm;
346  G4double zSlice[7] = { 0.0*CLHEP::mm,
347  CapsuleWidth1-0.001*CLHEP::mm,
348  CapsuleWidth1,//1.5mm
349  CapsuleEdgeDepth,//43.25mm
350  CapsuleLength-CapsuleWidth2-0.001*CLHEP::mm,//145mm
351  CapsuleLength-CapsuleWidth2,
352  CapsuleLength
353  };
354  G4double InnRad[7] = { 0.00*CLHEP::mm,
355  0.00*CLHEP::mm,
356  44.085*CLHEP::mm,
357  60.001*CLHEP::mm,
358  60.001*CLHEP::mm,
359  0.0*CLHEP::mm,
360  0.0*CLHEP::mm
361  };
362 
363  G4double OutRad[7] = { widthface,//44.085*CLHEP::mm,
364  widthface+CapsuleWidth1,//45.585*CLHEP::mm,
365  widthface+CapsuleWidth1,//45.585*CLHEP::mm,
366  62*CLHEP::mm,
367  62*CLHEP::mm,
368  62*CLHEP::mm,
369  62*CLHEP::mm,
370  };
371 
372  G4RotationMatrix* Cap_45deg = new G4RotationMatrix();
373  Cap_45deg -> rotateZ(45*CLHEP::deg);
374 
375  G4Tubs *hole= new G4Tubs(G4String("ShapeHole"),
376  0.0*CLHEP::mm,
377  22.3*CLHEP::mm,//22.25mm Rout cold finger outside the Al capsule
378  3*CLHEP::mm,
379  0.0*CLHEP::deg,
380  360.*CLHEP::deg);
381 
382 
383 
384  if ( do_caps )
385  {
386 
387  G4Polyhedra *caps = new G4Polyhedra(G4String("ShapeCapsule"),
388  0.*CLHEP::deg,
389  360.*CLHEP::deg,
390  4,
391  nbslice,
392  zSlice,
393  InnRad,
394  OutRad);
395 
396  G4SubtractionSolid *hole_cut_Al_caps= new G4SubtractionSolid (G4String("cut_Alcaps"), caps, hole, &rm,G4ThreeVector(0.,0.,CapsuleLength*CLHEP::mm));
397 
398  sprintf(sName, "Capsule");
399  G4LogicalVolume * pCapsule = new G4LogicalVolume( hole_cut_Al_caps, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Al"), G4String(sName), 0, 0, 0 );
400 
401 
402  Capsule_phys = new G4PVPlacement(Cap_45deg, // no rotation
403  G4ThreeVector(), // at (0,0,0)
404  pCapsule, // its logical volume
405  "Capsule_P", // its name
406  detlogicWorld, // its mother volume
407  false, // no boolean operations
408  -1); // copy number
409 
410 
411  G4VisAttributes *Capsule_VisAtt= new G4VisAttributes(G4Colour(0.5,0.5,0.5,0.75)); //grey
412  pCapsule ->SetVisAttributes(Capsule_VisAtt);
413  }
414 
415  // **************************************************************************
416  // * COLD FINGER *
417  // **************************************************************************
418 
419 
420  // The copper plate at the bottom of Ge cristals
421 
422 
423  G4double x_CFPlate = 100.80*CLHEP::mm;//5.04*cm;
424  G4double y_CFPlate = 100.80*CLHEP::mm;//5.04*cm;
425  G4double z_CFPlate = 2.*CLHEP::mm;
426 
427  G4Box* CFPlate = new G4Box("CFPlate",x_CFPlate/2,y_CFPlate/2,z_CFPlate/2);
428 
429  G4LogicalVolume* logicCFPlate = new G4LogicalVolume(CFPlate,SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Cu"),"CFPlate");
430 
431  CFPlate_phys= new G4PVPlacement(0, // no rotation
432  G4ThreeVector(0,0,CapsuleLength-48.999*CLHEP::mm), // at (0,0,0) //very close to the Ge cristals
433  logicCFPlate, // its logical volume
434  "CFPlate_P", // its name
435  detlogicWorld, // its mother volume
436  false, // no boolean operations
437  -1); // copy number
438 
439  G4VisAttributes *CFPlate_VisAtt= new G4VisAttributes(G4Colour(0.45,0.25,0.0)); //brown
440  logicCFPlate->SetVisAttributes(CFPlate_VisAtt);
441 
442  //****************************************************
443  // The cold finger (part inside the Al Capsule) *
444  //****************************************************
445 
446 
447  G4double InnRadiusCF_Int = 0.*CLHEP::mm;
448  G4double OutRadiusCF_Int = 15*CLHEP::mm;
449  G4double HalfLengtCF_Int = 24.0*CLHEP::mm;
450  G4double startPhiCF_Int = 0.*CLHEP::deg;
451  G4double spanningAngleCF_Int = 360.*CLHEP::deg;
452 
453  G4Tubs* CF_int = new G4Tubs(G4String("ColdFinger"),
454  InnRadiusCF_Int,
455  OutRadiusCF_Int,
456  HalfLengtCF_Int,
457  startPhiCF_Int,
458  spanningAngleCF_Int);
459 
460  sprintf(sName,"CFinger_int");
461  G4LogicalVolume * pCF_int = new G4LogicalVolume(CF_int, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Cu"), G4String(sName), 0, 0, 0 );
462 
463  CF_int_phys = new G4PVPlacement(0, // no rotation
464  G4ThreeVector(0,0,CapsuleLength-23.999*CLHEP::mm), // at (0,0,0) //very close to the Ge cristals
465  pCF_int, // its logical volume
466  "CF_int_P", // its name
467  detlogicWorld, // its mother volume
468  false, // no boolean operations
469  -1); // copy number
470 
471 
472  G4VisAttributes *CF_int_VisAtt= new G4VisAttributes(G4Colour(0.45,0.25,0.0)); //brown
473  pCF_int ->SetVisAttributes(CF_int_VisAtt);
474 
475 
476  //********************************************************************************************
477  // The enveloppe of the cold finger from the outside of the Al capsule to the Dewar *
478  //********************************************************************************************
479 
480  G4double CF_OUT_HalfLength = 72.5*CLHEP::mm;
481  G4double PhiStart = 0.*CLHEP::deg;
482  G4double PhiTot = 360.*CLHEP::deg;
483  G4int nbZplanesColdFinger = 6;
484 
485  G4double zPlaneColdFinger[6] = { 0*CLHEP::mm,
486  70.5*CLHEP::mm,
487  70.5*CLHEP::mm,
488  78.5*CLHEP::mm,
489  78.5*CLHEP::mm,
490  CF_OUT_HalfLength*2
491  };
492  G4double rInnerColdFinger[6] = { 0.0*CLHEP::mm,
493  0.0*CLHEP::mm,
494  0.0*CLHEP::mm,
495  0.0*CLHEP::mm,
496  0.0*CLHEP::mm,
497  0.0*CLHEP::mm
498  };
499  G4double rOuterColdFinger[6] = { 22.25*CLHEP::mm,
500  22.25*CLHEP::mm,
501  31.*CLHEP::mm,
502  31.*CLHEP::mm,
503  22.25*CLHEP::mm,
504  22.25*CLHEP::mm
505  };
506 
507 
508 
509  G4Polycone* solidColdFinger = new G4Polycone("ShapeColdFinger",PhiStart,PhiTot,nbZplanesColdFinger,
510  zPlaneColdFinger,rInnerColdFinger,rOuterColdFinger);
511 
512  G4LogicalVolume *logicColdFinger = new G4LogicalVolume(solidColdFinger,SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Al"),"CFinger_out");
513 
514  CF_OUT_phys = new G4PVPlacement(0, // no rotation
515  G4ThreeVector(0,0,CapsuleLength+0.001*CLHEP::mm), // at (0,0,0)
516  logicColdFinger, // its logical volume
517  "CF_OUT_P", // its name
518  detlogicWorld, // its mother volume
519  false, // no boolean operations
520  -1); // copy number
521 
522 
523  G4VisAttributes *CF_OUT_VisAtt= new G4VisAttributes(G4Colour(0.8,0.8,0.8)); //grey(0.5,0.5,0.5,0.75)); //grey
524  logicColdFinger->SetVisAttributes(CF_OUT_VisAtt);
525 
526  // Its internal vacuum...
527 
528  G4double minRadiusIntEnvColdFinger = 0.*CLHEP::mm;//0.*cm;
529  G4double maxRadiusIntEnvColdFinger = 20.25*CLHEP::mm;//2.025*cm;
530  G4double HalfLengthIntEnvColdFinger = 72.4*CLHEP::mm;//7.24*cm;
531  G4double startPhiIntEnvColdFinger = 0.*CLHEP::deg;
532  G4double deltaPhiIntEnvColdFinger = 360.*CLHEP::deg;
533 
534  G4Tubs* solidIntEnvColdFinger = new G4Tubs("ShapeIntEnvColdFinger",minRadiusIntEnvColdFinger,maxRadiusIntEnvColdFinger,
535  HalfLengthIntEnvColdFinger,startPhiIntEnvColdFinger,deltaPhiIntEnvColdFinger);
536 
537  G4LogicalVolume* logicIntEnvColdFinger =
538  new G4LogicalVolume(solidIntEnvColdFinger,SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Vacuum_Ge"),"IntEnvColdFinger");
539 
540  // and its position in the cold finger enveloppe.
541 
542  physiIntEnvColdFinger = new G4PVPlacement(0, // no rotation
543  G4ThreeVector(0,0,CF_OUT_HalfLength*CLHEP::mm), // at (0,0,0)
544  logicIntEnvColdFinger, // its logical volume
545  "CF_intOUT_P", // its name
546  logicColdFinger, // its mother volume
547  false, // no boolean operations
548  -1); // copy number
549 
550 
551  G4VisAttributes *CF_intOUT_VisAtt= new G4VisAttributes(G4Colour(0.0,1.0,1.0)); //cyan 0.75,0.55,0.0)); //brown
552  logicIntEnvColdFinger->SetVisAttributes(CF_intOUT_VisAtt);
553 
554  // **************************************************************************
555  // * THE DEWAR *
556  // **************************************************************************
557  G4double minRadiusDewar = 111.*CLHEP::mm;
558  G4double maxRadiusDewar = 125.*CLHEP::mm;
559  const G4double HalfLengthDewar = 186.5*CLHEP::mm;//15.2*cm;
560  G4double startPhiDewar = 0.*CLHEP::deg;
561  G4double deltaPhiDewar = 360.*CLHEP::deg;
562 
563  G4int nbZDewar = 4;
564 
565 
566 
567  G4double ZDewar[4] = { 0.0*CLHEP::mm,
568  120*CLHEP::mm,
569  120*CLHEP::mm,
570  HalfLengthDewar*2
571  };
572  G4double InnRadDewar[4] = { 0.0*CLHEP::mm,
573  0.0*CLHEP::mm,
574  0.0*CLHEP::mm,
575  0.0*CLHEP::mm
576 
577  };
578 
579  G4double OutRadDewar[4] = {maxRadiusDewar,
580  maxRadiusDewar,
581  minRadiusDewar,
582  minRadiusDewar
583 
584  };
585 
586  G4Polycone* solidDewar = new G4Polycone("Dewar_OUT",
587  startPhiDewar,
588  deltaPhiDewar,
589  nbZDewar,
590  ZDewar,
591  InnRadDewar,
592  OutRadDewar);
593 
594 
595 
596 
597  G4LogicalVolume *logicDewar = new G4LogicalVolume(solidDewar,SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Al"),"Dewar_OUT");
598  Dewar_phys== new G4PVPlacement(0, // no rotation
599  G4ThreeVector(0,0,CapsuleLength+CF_OUT_HalfLength*2+0.001*CLHEP::mm), // at (0,0,0)
600  logicDewar, // its logical volume
601  "Dewar_P", // its name
602  detlogicWorld, // its mother volume
603  false, // no boolean operations
604  -1); // copy number
605 
606 
607  G4VisAttributes *Dewar_VisAtt= new G4VisAttributes(G4Colour(0.0,1.0,1.0)); //cyan
608  logicDewar->SetVisAttributes(Dewar_VisAtt);
609 
610 
611  // Its internal vacuum...
612 
613  G4double minRadiusIntDewar = 0.*CLHEP::mm;//0.*cm;
614  G4double maxRadiusIntDewar = 106.*CLHEP::mm;//10.4*cm;
615  G4double HalfLengthIntDewar = 181.*CLHEP::mm;//14.7*cm;
616  G4double startPhiIntDewar = 0.*CLHEP::deg;
617  G4double deltaPhiIntDewar = 360.*CLHEP::deg;
618 
619  G4Tubs* IntDewar = new G4Tubs("Int_Dewar",minRadiusIntDewar,maxRadiusIntDewar,
620  HalfLengthIntDewar,startPhiIntDewar,deltaPhiIntDewar);
621 
622  G4LogicalVolume* logicIntDewar = new G4LogicalVolume(IntDewar,SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Vacuum_Ge"),"Int_Dewar");
623  IntDewar_phys== new G4PVPlacement(0, // no rotation
624  G4ThreeVector(0,0,HalfLengthDewar), // at (0,0,0)
625  logicIntDewar, // its logical volume
626  "IntDewar_P", // its name
627  logicDewar, // its mother volume
628  false, // no boolean operations
629  -1); // copy number
630 
631 
632  G4VisAttributes *IntDewar_VisAtt= new G4VisAttributes(G4Colour( 1.0,0.0,1.0)); //magenta
633  logicIntDewar->SetVisAttributes(IntDewar_VisAtt);
634 
635 
636  // **************************************************************************
637  // * BGO AntiCompton1 *
638  // **************************************************************************
639 
640  // define a coaxial shape that will be modify with SubstractSolid
641 
642  G4int numZplane = 3;
643  G4double zSides[3] = { 0.0*CLHEP::mm,
644  0.0*CLHEP::mm,
645  BGOLength};
646  G4double rInnerBGO[3] = { CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsuleLATERAL + Space,
647  CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsuleLATERAL + Space ,
648  CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsuleLATERAL + Space };
649  G4double rOuterBGO[3] = { CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsuleLATERAL + Space+4.0*CLHEP::mm,
650  CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsuleLATERAL +BGOWidth,
651  CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsuleLATERAL + BGOWidth};
652 
653 
654  zSides[1] = BGOWidth / tan(CrystalEdgeAngle);
655 
656  G4Polyhedra *bgo = new G4Polyhedra(G4String("BGO"), //pName
657  0.*CLHEP::deg, //phiStart
658  360.*CLHEP::deg, //phiTotal
659  4, //numSide
660  numZplane, //numZPlanes
661  zSides, //zPlane[]
662  rInnerBGO, //rInner[]
663  rOuterBGO); //rOuter[]
664 
665  // G4Polyhedra *bgo = new G4Polyhedra(G4String("BGO"), 0.*deg, 360.*deg, 4, numZplane, zSides, rInnerBGO, rOuterBGO);
666  sprintf(sName, "BGORear");
667  G4LogicalVolume *pBGO = new G4LogicalVolume( bgo, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_BGO"), G4String(sName), 0, 0, 0 );
668  pBGO->SetSensitiveDetector( SToGS::UserActionInitialization::GetCopClusterSD() );
669 
670  BGO_phys = new G4PVPlacement(Cap_45deg, // no rotation
671  G4ThreeVector(0.0*CLHEP::mm,0.0*CLHEP::mm,AlcapstoBGO), // at (0,0,0)
672  pBGO, // its logical volume
673  "BGO_P", // its name
674  detlogicWorld, // its mother volume
675  false, // no boolean operations
676  4); // copy number
677 
678 
679  G4VisAttributes *BGO_VisAtt= new G4VisAttributes(G4Colour(0.0,0.0,1.0)); //blue
680  pBGO ->SetVisAttributes(BGO_VisAtt);
681 
682  // **************************************************************************
683  // * CsIBack Anticompton2 *
684  // **************************************************************************
685 
686  G4Tubs *hole_CsI= new G4Tubs(G4String("ShapeCsI_hole"),
687  0.0*CLHEP::mm,
688  22.3*CLHEP::mm,//22.25mm Rout cold finger outside the Al capsule
689  CsILength+0.3*CLHEP::mm,
690  0.0*CLHEP::deg,
691  360.*CLHEP::deg);
692 
693  G4Box *fullcsi= new G4Box(G4String("FullCsIBack"),
694  CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsuleLATERAL,
695  CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsuleLATERAL,
696  CsILength/2);
697 
698 
699  G4SubtractionSolid *hole_cut_csi= new G4SubtractionSolid (G4String("cut_csi"), fullcsi, hole_CsI, &rm,G4ThreeVector(0.,0.,0.));
700 
701  sprintf(sName, "CsIBack");
702  G4LogicalVolume *pCsIBack= new G4LogicalVolume( hole_cut_csi, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_CsI"), G4String(sName), 0, 0, 0 );
703  pCsIBack->SetSensitiveDetector( SToGS::UserActionInitialization::GetCopClusterSD() );
704  CsIBack_phys = new G4PVPlacement(0, // no rotation
705  G4ThreeVector(0.,0.,CapsuleLength+CsILength/2), // at (0,0,0)
706  pCsIBack, // its logical volume
707  "CsIBack_P", // its name
708  detlogicWorld, // its mother volume
709  false, // no boolean operations
710  5); // copy number
711 
712  G4VisAttributes *CsIBack_VisAtt= new G4VisAttributes(G4Colour(1.0,0.0,1.0)); //magenta
713  pCsIBack ->SetVisAttributes(CsIBack_VisAtt);
714  // CsIBack_VisAtt->SetForceWireframe(true);
715 
716 
717 
718  /*
719  // **************************************************************************
720  // * CLOVER EXOGAM PLANS GANIL VACUUM *
721  // **************************************************************************
722 
723  // **************************************************************************
724  // * Al CAPSULE PLANS GANIL VIDE *
725  // **************************************************************************
726 
727  // The Aluminum Clover can ( "CloverCan" )
728 
729  G4int nbslice = 3;
730  const G4double widthface = 44.085*CLHEP::mm;
731 
732 
733  const G4double HalfCapsuleLength = CapsuleLength/2.*CLHEP::mm;//7.35*cm;
734  const G4double HalfCapsule_in_Length = (CapsuleLength-CapsuleWidth1-CapsuleWidth1)/2.*CLHEP::mm;//71.75mm;
735  const G4double TaperLength_in_Can = 40.842*CLHEP::mm;
736 
737  G4double zSlice_IN[3] = { 1.5*CLHEP::mm,
738  CapsuleEdgeDepth,
739  CapsuleLength-2.0*CLHEP::mm,
740  };
741 
742 
743  G4double InnRad_IN[3] = { 0.0*CLHEP::mm,
744  0.0*CLHEP::mm,
745  0.0*CLHEP::mm,
746 
747  };
748 
749  G4double OutRad_IN[3] = { 43.084*CLHEP::mm,
750  60.0*CLHEP::mm,
751  60.0*CLHEP::mm,
752  };
753 
754 
755  G4double zSlice_OUT[3] = { 0.0*CLHEP::mm,
756  CapsuleEdgeDepth,
757  CapsuleLength,
758  };
759 
760 
761  G4double InnRad_OUT[3] = { 0.0*CLHEP::mm,
762  0.0*CLHEP::mm,
763  0.0*CLHEP::mm,
764  };
765 
766  G4double OutRad_OUT[3] = { widthface,
767  62.*CLHEP::mm,
768  62*CLHEP::mm,
769  };
770 
771 
772  G4RotationMatrix* Cap_45deg = new G4RotationMatrix();
773  Cap_45deg -> rotateZ(45*CLHEP::deg);
774 
775  if ( do_caps )
776  {
777  G4Polyhedra *caps_OUT = new G4Polyhedra(G4String("Capsule_OUT"),
778  0.*CLHEP::deg,
779  360.*CLHEP::deg,
780  4,
781  nbslice,
782  zSlice_OUT,
783  InnRad_OUT,
784  OutRad_OUT);
785  sprintf(sName, "Capsule_OUT");
786  G4LogicalVolume * pCapsule_OUT = new G4LogicalVolume( caps_OUT, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Al"), G4String(sName), 0, 0, 0 );
787 
788 
789  Capsule_OUT_phys = new G4PVPlacement(Cap_45deg, // no rotation
790  G4ThreeVector(), // at (0,0,0)
791  pCapsule_OUT, // its logical volume
792  "Capsule_OUT_P", // its name
793  detlogicWorld, // its mother volume
794  false, // no boolean operations
795  -1); // copy number
796 
797 
798  G4VisAttributes *Capsule_OUT_VisAtt= new G4VisAttributes(G4Colour(0.5,0.5,0.5,0.75)); //grey
799  pCapsule_OUT ->SetVisAttributes(Capsule_OUT_VisAtt);
800 
801  G4Polyhedra *caps_IN = new G4Polyhedra(G4String("Capsule_IN"),
802  0.*CLHEP::deg,
803  360.*CLHEP::deg,
804  4,
805  nbslice,
806  zSlice_IN,
807  InnRad_IN,
808  OutRad_IN);
809  sprintf(sName, "Capsule_IN");
810  G4LogicalVolume * pCapsule_IN = new G4LogicalVolume( caps_IN, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Vacuum_Ge"), G4String(sName), 0, 0, 0 );
811 
812 
813  Capsule_IN_phys = new G4PVPlacement(0, // no rotation
814  G4ThreeVector(), // at (0,0,0)
815  pCapsule_IN, // its logical volume
816  "Capsule_IN_P", // its name
817  pCapsule_OUT, // its mother volume
818  false, // no boolean operations
819  -1); // copy number
820 
821 
822  G4VisAttributes *Capsule_IN_VisAtt= new G4VisAttributes(G4Colour(0.0,1.0,1.0)); //cyan0.5,0.5,0.5,0.75)); //grey
823  pCapsule_IN ->SetVisAttributes(Capsule_IN_VisAtt);
824 
825  //Crystal A
826  G4RotationMatrix* Crystal_45deg = new G4RotationMatrix();
827  Crystal_45deg -> rotateZ(45*CLHEP::deg);
828 
829  sprintf(sName, "ShapedCrystalA");
830  G4LogicalVolume *pCrystalA = new G4LogicalVolume( coax_cut6, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Ge"), G4String(sName), 0, 0, 0 );
831  pCrystalA->SetSensitiveDetector( SToGS::UserActionInitialization::GetCopClusterSD() );
832 
833  CrystalA_phys = new G4PVPlacement(Crystal_45deg, // no rotation
834  G4ThreeVector(34.75*CLHEP::mm+Tolerance,-Tolerance,CrystalToCapsuleTOP), // at (0,0,0)
835  pCrystalA, // its logical volume
836  "CrystalA_P", // its name
837  pCapsule_IN, // its mother volume
838  false, // no boolean operations
839  0); // copy n
840  G4VisAttributes *CrystalA_VisAtt= new G4VisAttributes(G4Colour(0.0,0.0,1.0)); //blue
841  pCrystalA ->SetVisAttributes(CrystalA_VisAtt);
842 
843  // Testing detCrystal Volume
844  G4double CrystalVol = pCrystalA->GetSolid()->GetCubicVolume();
845  // G4cout << "Volume of Crystal A= " << CrystalVol/mm3 << " mm^3" << G4endl;
846 
847 
848 
849  //Crystal B
850  G4RotationMatrix* Crystal_135deg = new G4RotationMatrix();
851  Crystal_135deg -> rotateZ(135*CLHEP::deg);
852 
853  sprintf(sName, "ShapedCrystalB");
854  G4LogicalVolume *pCrystalB = new G4LogicalVolume( coax_cut6, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Ge"), G4String(sName), 0, 0, 0 );
855  pCrystalB->SetSensitiveDetector( SToGS::UserActionInitialization::GetCopClusterSD() );
856 
857  CrystalB_phys = new G4PVPlacement(Crystal_135deg , // no rotation
858  G4ThreeVector(-Tolerance,-34.75*CLHEP::mm-Tolerance,CrystalToCapsuleTOP), // at (-26*mm,-26*mm,3.5*mm)
859  pCrystalB, // its logical volume
860  "CrystalB_P", // its name
861  pCapsule_IN, // its mother volume
862  false, // no boolean operations
863  1); // copy n
864  G4VisAttributes *CrystalB_VisAtt= new G4VisAttributes(G4Colour(0.0,1.0,0.0)); //green
865  pCrystalB ->SetVisAttributes(CrystalB_VisAtt);
866 
867 
868  //Crystal C
869 
870  G4RotationMatrix* Crystal_225deg = new G4RotationMatrix();
871  Crystal_225deg -> rotateZ(225*CLHEP::deg);
872  sprintf(sName, "ShapedCrystalC");
873  G4LogicalVolume *pCrystalC = new G4LogicalVolume( coax_cut6, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Ge"), G4String(sName), 0, 0, 0 );
874  pCrystalC->SetSensitiveDetector( SToGS::UserActionInitialization::GetCopClusterSD() );
875 
876  CrystalC_phys = new G4PVPlacement(Crystal_225deg, // no rotation
877  G4ThreeVector(-34.75*CLHEP::mm-Tolerance,Tolerance,CrystalToCapsuleTOP), // at (0,0,0)
878  pCrystalC, // its logical volume
879  "CrystalC_P", // its name
880  pCapsule_IN, // its mother volume
881  false, // no boolean operations
882  2); // copy n
883  G4VisAttributes *CrystalC_VisAtt= new G4VisAttributes(G4Colour(1.0,0.0,0.0)); //red
884  pCrystalC ->SetVisAttributes(CrystalC_VisAtt);
885 
886 
887  //Crystal D
888 
889  G4RotationMatrix* Crystal_315deg = new G4RotationMatrix();
890  Crystal_315deg -> rotateZ(315*CLHEP::deg);
891  sprintf(sName, "ShapedCrystalD");
892  G4LogicalVolume *pCrystalD = new G4LogicalVolume( coax_cut6, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Ge"), G4String(sName), 0, 0, 0 );
893 
894  pCrystalD->SetSensitiveDetector( SToGS::UserActionInitialization::GetCopClusterSD() );
895 
896  CrystalD_phys = new G4PVPlacement(Crystal_315deg, // no rotation
897  G4ThreeVector(Tolerance,34.75*CLHEP::mm+Tolerance,CrystalToCapsuleTOP), // at (26*mm,26*mm,3.5*mm)
898  pCrystalD, // its logical volume
899  "CrystalD_P", // its name
900  pCapsule_IN, // its mother volume
901  false, // no boolean operations
902  3); // copy n
903  G4VisAttributes *CrystalD_VisAtt= new G4VisAttributes(G4Colour(1.0,1.0,0.0)); //yellow
904  pCrystalD ->SetVisAttributes(CrystalD_VisAtt);
905 
906  // **************************************************************************
907  // * COLD FINGER *
908  // **************************************************************************
909  //
910  // The copper plate at the bottom of Ge cristals
911  //
912 
913  G4double x_CFPlate = 100.80*CLHEP::mm;//5.04*cm;
914  G4double y_CFPlate = 100.80*CLHEP::mm;//5.04*cm;
915  G4double z_CFPlate = 2.*CLHEP::mm;
916 
917  G4Box* CFPlate = new G4Box("CFPlate",x_CFPlate/2,y_CFPlate/2,z_CFPlate/2);
918 
919  G4LogicalVolume* logicCFPlate = new G4LogicalVolume(CFPlate,SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Cu"),"CFPlate");
920 
921  CFPlate_phys= new G4PVPlacement(Crystal_45deg, // no rotation
922  G4ThreeVector(0,0,CapsuleLength-48.999*CLHEP::mm), // at (0,0,0) //very close to the Ge cristals
923  logicCFPlate, // its logical volume
924  "CFPlate_P", // its name
925  pCapsule_IN, // its mother volume
926  false, // no boolean operations
927  -1); // copy number
928 
929  G4VisAttributes *CFPlate_VisAtt= new G4VisAttributes(G4Colour(0.45,0.25,0.0)); //brown
930  logicCFPlate->SetVisAttributes(CFPlate_VisAtt);
931 
932  // The cold finger (part inside the Al Capsule)
933  //
934 
935  G4double InnRadiusCF_Int = 0.*CLHEP::mm;
936  G4double OutRadiusCF_Int = 15*CLHEP::mm;
937  G4double HalfLengtCF_Int = 23.0*CLHEP::mm;
938  G4double startPhiCF_Int = 0.*CLHEP::deg;
939  G4double spanningAngleCF_Int = 360.*CLHEP::deg;
940 
941  G4Tubs* CF_int = new G4Tubs(G4String("ColdFinger"),
942  InnRadiusCF_Int,
943  OutRadiusCF_Int,
944  HalfLengtCF_Int,
945  startPhiCF_Int,
946  spanningAngleCF_Int);
947 
948  sprintf(sName,"ColdFinger");
949  G4LogicalVolume * pCF_int = new G4LogicalVolume(CF_int, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Cu"), G4String(sName), 0, 0, 0 );
950 
951  CF_int_phys = new G4PVPlacement(0, // no rotation
952  G4ThreeVector(0,0,CapsuleLength-24.999*CLHEP::mm), // at (0,0,0) //very close to the Ge cristals
953  pCF_int, // its logical volume
954  "CF_int_P", // its name
955  pCapsule_IN, // its mother volume
956  false, // no boolean operations
957  -1); // copy number
958 
959 
960  G4VisAttributes *CF_int_VisAtt= new G4VisAttributes(G4Colour(0.45,0.25,0.0)); //brown
961  pCF_int ->SetVisAttributes(CF_int_VisAtt);
962 
963 
964  // The enveloppe of the cold finger from the outside of the Al capsule to the Dewar
965  //
966 
967  G4double zPlaneEnvColdFinger[6];
968  G4double rInnerEnvColdFinger[6];
969  G4double rOuterEnvColdFinger[6];
970 
971  G4double PhiStart = 0.*CLHEP::deg;
972  G4double PhiTot = 360.*CLHEP::deg;
973  G4double EnvColdFingerHalfLength = 72.5*CLHEP::mm;
974 
975  zPlaneEnvColdFinger[0] = -EnvColdFingerHalfLength;
976  zPlaneEnvColdFinger[1] = -EnvColdFingerHalfLength+70.5*CLHEP::mm;//41*CLHEP::mm;//AGATA
977  zPlaneEnvColdFinger[2] = -EnvColdFingerHalfLength+70.5*CLHEP::mm;//41*CLHEP::mm;
978  zPlaneEnvColdFinger[3] = -EnvColdFingerHalfLength+78.5*CLHEP::mm;//49*CLHEP::mm;
979  zPlaneEnvColdFinger[4] = -EnvColdFingerHalfLength+78.5*CLHEP::mm;//49*CLHEP::mm;
980  zPlaneEnvColdFinger[5] = EnvColdFingerHalfLength;
981 
982  rInnerEnvColdFinger[0]=rInnerEnvColdFinger[1]=rInnerEnvColdFinger[2]=0.*CLHEP::mm;
983  rInnerEnvColdFinger[3]=rInnerEnvColdFinger[4]=rInnerEnvColdFinger[5]=0.*CLHEP::mm;
984 
985  rOuterEnvColdFinger[0]=22.25*CLHEP::mm;//2.225*cm;
986  rOuterEnvColdFinger[1]=22.25*CLHEP::mm;//2.225*cm;
987  rOuterEnvColdFinger[2]=31.*CLHEP::mm;//3.1*cm;
988  rOuterEnvColdFinger[3]=31.*CLHEP::mm;//3.1*cm;
989  rOuterEnvColdFinger[4]=22.25*CLHEP::mm;//2.225*cm;
990  rOuterEnvColdFinger[5]=22.25*CLHEP::mm;//2.225*cm;
991 
992  G4Polycone* solidEnvColdFinger = new G4Polycone("ShapeEnvColdFinger",PhiStart,PhiTot,6,
993  zPlaneEnvColdFinger,rInnerEnvColdFinger,rOuterEnvColdFinger);
994 
995  G4LogicalVolume *logicEnvColdFinger = new G4LogicalVolume(solidEnvColdFinger,SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Al"),"EnvColdFinger");
996 
997  CF_OUT_phys = new G4PVPlacement(0, // no rotation
998  G4ThreeVector(0,0,CapsuleLength+EnvColdFingerHalfLength+0.001*CLHEP::mm), // at (0,0,0)
999  logicEnvColdFinger, // its logical volume
1000  "CF_OUT_P", // its name
1001  detlogicWorld, // its mother volume
1002  false, // no boolean operations
1003  -1); // copy number
1004 
1005 
1006  G4VisAttributes *CF_OUT_VisAtt= new G4VisAttributes(G4Colour(0.45,0.25,0.0)); //brown
1007  logicEnvColdFinger->SetVisAttributes(CF_OUT_VisAtt);
1008 
1009  // The position of the cold finger enveloppe in the SupClover:
1010 
1011 
1012  // Its internal vacuum...
1013 
1014  G4double minRadiusIntEnvColdFinger = 0.*CLHEP::mm;//0.*cm;
1015  G4double maxRadiusIntEnvColdFinger = 20.25*CLHEP::mm;//2.025*cm;
1016  G4double HalfLengthIntEnvColdFinger = 72.4*CLHEP::mm;//7.24*cm;
1017  G4double startPhiIntEnvColdFinger = 0.*CLHEP::deg;
1018  G4double deltaPhiIntEnvColdFinger = 360.*CLHEP::deg;
1019 
1020  G4Tubs* solidIntEnvColdFinger = new G4Tubs("ShapeIntEnvColdFinger",minRadiusIntEnvColdFinger,maxRadiusIntEnvColdFinger,
1021  HalfLengthIntEnvColdFinger,startPhiIntEnvColdFinger,deltaPhiIntEnvColdFinger);
1022 
1023  G4LogicalVolume* logicIntEnvColdFinger =
1024  new G4LogicalVolume(solidIntEnvColdFinger,SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Vacuum_Ge"),"IntEnvColdFinger");
1025 
1026  // and its position in the cold finger enveloppe.
1027 
1028  physiIntEnvColdFinger = new G4PVPlacement(0, // no rotation
1029  G4ThreeVector(0,0,0), // at (0,0,0)
1030  logicIntEnvColdFinger, // its logical volume
1031  "CF_intOUT_P", // its name
1032  logicEnvColdFinger, // its mother volume
1033  false, // no boolean operations
1034  -1); // copy number
1035 
1036 
1037  G4VisAttributes *CF_intOUT_VisAtt= new G4VisAttributes(G4Colour(0.0,1.0,1.0)); //cyan 0.75,0.55,0.0)); //brown
1038  logicIntEnvColdFinger->SetVisAttributes(CF_intOUT_VisAtt);
1039 
1040  // **************************************************************************
1041  // * THE DEWAR *
1042  // **************************************************************************
1043  G4double minRadiusDewar = 111.*CLHEP::mm;
1044  G4double maxRadiusDewar = 125.*CLHEP::mm;
1045  const G4double HalfLengthDewar = 186.5*CLHEP::mm;//15.2*cm;
1046  G4double startPhiDewar = 0.*CLHEP::deg;
1047  G4double deltaPhiDewar = 360.*CLHEP::deg;
1048 
1049  G4int nbZDewar = 4;
1050 
1051 
1052 
1053  G4double ZDewar[4] = { 0.0*CLHEP::mm,
1054  120*CLHEP::mm,
1055  120*CLHEP::mm,
1056  HalfLengthDewar*2
1057  };
1058  G4double InnRadDewar[4] = { 0.0*CLHEP::mm,
1059  0.0*CLHEP::mm,
1060  0.0*CLHEP::mm,
1061  0.0*CLHEP::mm
1062 
1063  };
1064 
1065  G4double OutRadDewar[4] = {maxRadiusDewar,
1066  maxRadiusDewar,
1067  minRadiusDewar,
1068  minRadiusDewar
1069 
1070  };
1071 
1072  G4Polycone* solidDewar = new G4Polycone("Dewar_OUT",
1073  startPhiDewar,
1074  deltaPhiDewar,
1075  nbZDewar,
1076  ZDewar,
1077  InnRadDewar,
1078  OutRadDewar);
1079 
1080 
1081 
1082 
1083  G4LogicalVolume *logicDewar = new G4LogicalVolume(solidDewar,SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Al"),"Dewar_OUT");
1084  Dewar_phys== new G4PVPlacement(0, // no rotation
1085  G4ThreeVector(0,0,CapsuleLength+EnvColdFingerHalfLength*2+0.001*CLHEP::mm), // at (0,0,0)
1086  logicDewar, // its logical volume
1087  "Dewar_P", // its name
1088  detlogicWorld, // its mother volume
1089  false, // no boolean operations
1090  -1); // copy number
1091 
1092 
1093  G4VisAttributes *Dewar_VisAtt= new G4VisAttributes(G4Colour(0.0,1.0,1.0)); //cyan
1094  logicDewar->SetVisAttributes(Dewar_VisAtt);
1095 
1096 
1097  // Its internal vacuum...
1098 
1099  G4double minRadiusIntDewar = 0.*CLHEP::mm;//0.*cm;
1100  G4double maxRadiusIntDewar = 106.*CLHEP::mm;//10.4*cm;
1101  G4double HalfLengthIntDewar = 181.*CLHEP::mm;//14.7*cm;
1102  G4double startPhiIntDewar = 0.*CLHEP::deg;
1103  G4double deltaPhiIntDewar = 360.*CLHEP::deg;
1104 
1105  G4Tubs* IntDewar = new G4Tubs("Int_Dewar",minRadiusIntDewar,maxRadiusIntDewar,
1106  HalfLengthIntDewar,startPhiIntDewar,deltaPhiIntDewar);
1107 
1108  G4LogicalVolume* logicIntDewar = new G4LogicalVolume(IntDewar,SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Vacuum_Ge"),"Int_Dewar");
1109  IntDewar_phys== new G4PVPlacement(0, // no rotation
1110  G4ThreeVector(0,0,HalfLengthDewar), // at (0,0,0)
1111  logicIntDewar, // its logical volume
1112  "IntDewar_P", // its name
1113  logicDewar, // its mother volume
1114  false, // no boolean operations
1115  -1); // copy number
1116 
1117 
1118  G4VisAttributes *IntDewar_VisAtt= new G4VisAttributes(G4Colour( 1.0,0.0,1.0)); //magenta
1119  logicIntDewar->SetVisAttributes(IntDewar_VisAtt);
1120 
1121 
1122  // **************************************************************************
1123  // * BGO AntiCompton1 *
1124  // **************************************************************************
1125 
1126  // define a coaxial shape that will be modify with SubstractSolid
1127 
1128  G4int numZplane = 3;
1129  G4double zSides[3] = { 0.0*CLHEP::mm,
1130  0.0*CLHEP::mm,
1131  BGOLength};
1132  G4double rInnerBGO[3] = { CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsuleLATERAL + Space,
1133  CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsuleLATERAL + Space ,
1134  CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsuleLATERAL + Space };
1135  G4double rOuterBGO[3] = { CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsuleLATERAL + Space+4.0*CLHEP::mm,
1136  CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsuleLATERAL +BGOWidth,
1137  CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsuleLATERAL + BGOWidth};
1138 
1139 
1140  zSides[1] = BGOWidth / tan(CrystalEdgeAngle);
1141 
1142  G4Polyhedra *bgo = new G4Polyhedra(G4String("BGO"), //pName
1143  0.*CLHEP::deg, //phiStart
1144  360.*CLHEP::deg, //phiTotal
1145  4, //numSide
1146  numZplane, //numZPlanes
1147  zSides, //zPlane[]
1148  rInnerBGO, //rInner[]
1149  rOuterBGO); //rOuter[]
1150 
1151  // G4Polyhedra *bgo = new G4Polyhedra(G4String("BGO"), 0.*deg, 360.*deg, 4, numZplane, zSides, rInnerBGO, rOuterBGO);
1152  sprintf(sName, "BGORear");
1153  G4LogicalVolume *pBGO = new G4LogicalVolume( bgo, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_BGO"), G4String(sName), 0, 0, 0 );
1154  pBGO->SetSensitiveDetector( SToGS::UserActionInitialization::GetCopClusterSD() );
1155 
1156  BGO_phys = new G4PVPlacement(Cap_45deg, // no rotation
1157  G4ThreeVector(0.0*CLHEP::mm,0.0*CLHEP::mm,AlcapstoBGO), // at (0,0,0)
1158  pBGO, // its logical volume
1159  "BGO_P", // its name
1160  detlogicWorld, // its mother volume
1161  false, // no boolean operations
1162  4); // copy number
1163 
1164 
1165  G4VisAttributes *BGO_VisAtt= new G4VisAttributes(G4Colour(0.0,0.0,1.0)); //blue
1166  pBGO ->SetVisAttributes(BGO_VisAtt);
1167 
1168  // **************************************************************************
1169  // * CsIBack Anticompton2 *
1170  // **************************************************************************
1171 
1172  G4Tubs *hole= new G4Tubs(G4String("ShapeCsI_hole"),
1173  0.0*CLHEP::mm,
1174  22.3*CLHEP::mm,//22.25mm Rout cold finger outside the Al capsule
1175  CsILength+0.3*CLHEP::mm,
1176  0.0*CLHEP::deg,
1177  360.*CLHEP::deg);
1178 
1179  G4Box *fullcsi= new G4Box(G4String("FullCsIBack"),
1180  CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsuleLATERAL,
1181  CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsuleLATERAL,
1182  CsILength/2);
1183 
1184 
1185  G4SubtractionSolid *hole_cut_csi= new G4SubtractionSolid (G4String("cut_csi"), fullcsi, hole, &rm,G4ThreeVector(0.,0.,0.));
1186 
1187  sprintf(sName, "CsIBack");
1188  G4LogicalVolume *pCsIBack= new G4LogicalVolume( hole_cut_csi, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_CsI"), G4String(sName), 0, 0, 0 );
1189  pCsIBack->SetSensitiveDetector( SToGS::UserActionInitialization::GetCopClusterSD() );
1190  CsIBack_phys = new G4PVPlacement(0, // no rotation
1191  G4ThreeVector(0.,0.,CapsuleLength+CsILength/2), // at (0,0,0)
1192  pCsIBack, // its logical volume
1193  "CsIBack_P", // its name
1194  detlogicWorld, // its mother volume
1195  false, // no boolean operations
1196  5); // copy number
1197 
1198  G4VisAttributes *CsIBack_VisAtt= new G4VisAttributes(G4Colour(1.0,0.0,1.0)); //magenta
1199  pCsIBack ->SetVisAttributes(CsIBack_VisAtt);
1200  // CsIBack_VisAtt->SetForceWireframe(true);
1201 
1202  }
1203 
1204 */
1205 
1206 
1207  /*
1208  // **************************************************************************
1209  // * CLOVER EXOGAM OLIVIER *
1210  // **************************************************************************
1211 
1212  const G4double CrystalLength = 90.0*CLHEP::mm; // Ge crystal length
1213  const G4double CrystalHoleDepth = 15.0*CLHEP::mm; // depth at which starts the hole
1214 
1215  const G4double CrystalOuterRadius = 30.0*CLHEP::mm; // outer radius for crystal
1216  const G4double CrystalInnerRadius = 5.0*CLHEP::mm; // inner radius for hole in crystal
1217 
1218  const G4double CrystalEdgeOffset1 = 26.0*CLHEP::mm; // distance of the edge from the center of the crystal
1219  const G4double CrystalEdgeOffset2 = 28.5*CLHEP::mm; // distance of the edge from the center of the crystal
1220 
1221  const G4double CrystalEdgeDepth = 30.0*CLHEP::mm; // depth to which the crystal is shaped
1222  const G4double CrystalEdgeAngle = 22.5*CLHEP::deg; // bevel angle
1223 
1224  const G4double CapsuleWidth = 1.5*CLHEP::mm; // capsule width
1225  const G4double CapsuleLength = 110.*CLHEP::mm; // capsule length
1226  const G4double CapsuleEdgeDepth = 3.3*CLHEP::cm; // same as crystal !
1227  const G4double CrystalToCapsule = 3.5*CLHEP::mm; // to be adjusted ..
1228 
1229  const G4double BGOLength = 120.0*CLHEP::mm;
1230  const G4double BGOWidth = 25.0*CLHEP::mm;
1231 
1232  const G4double CsILength = 20.0*CLHEP::mm;
1233 
1234  const G4double Tolerance = 0.1*CLHEP::mm; // distance between crystals
1235  const G4double Space = 1.0*CLHEP::mm; // distance between Al capsule and BGO
1236 
1237  // define a coaxial shape that will be modify with SubstractSolid
1238 
1239  G4VPhysicalVolume *CrystalA_phys = 0x0;
1240  G4VPhysicalVolume *CrystalB_phys = 0x0;
1241  G4VPhysicalVolume *CrystalC_phys = 0x0;
1242  G4VPhysicalVolume *CrystalD_phys = 0x0;
1243  G4VPhysicalVolume *Capsule_phys = 0x0;
1244  G4VPhysicalVolume *BGO_phys = 0x0;
1245  G4VPhysicalVolume *CsIBack_phys = 0x0;
1246  // the Ge crystal dimensions
1247  G4int nbZplanes = 4;
1248  G4double zPlaneGe[4] = { 0.0*CLHEP::mm,
1249  CrystalHoleDepth,
1250  CrystalHoleDepth + 3.0*CLHEP::mm,
1251  CrystalLength}; // depth where is the hole
1252  G4double rInnerGe[4] = { 0.0*CLHEP::mm,
1253  0.0*CLHEP::mm,
1254  CrystalInnerRadius,
1255  CrystalInnerRadius}; // to define the hole in the crystal
1256  G4double rOuterGe[4] = { CrystalOuterRadius,
1257  CrystalOuterRadius,
1258  CrystalOuterRadius,
1259  CrystalOuterRadius}; // to define the external surface
1260 
1261 
1262  char sName[40]; // generic for named objects
1263  sprintf(sName, "Crystal");
1264 
1265  G4Polycone *detCrystal= new G4Polycone(G4String(sName), //name
1266  0.*CLHEP::deg, //phi Start
1267  360.*CLHEP::deg, //phiTotal
1268  nbZplanes, // number of sides
1269  zPlaneGe, // number of Z planes
1270  rInnerGe, // inner radius
1271  rOuterGe); // outer radius
1272 
1273 
1274  // box definition to remove some matter to the crystal
1275 
1276  G4double Edge[3];
1277 
1278  sprintf(sName, "LongEdge1");
1279  Edge[0] = (CrystalOuterRadius-CrystalEdgeOffset1); // x half-width
1280  Edge[1] = 1.001*CrystalOuterRadius; // y half-width
1281  Edge[2] = 1.001*CrystalLength/2.0; // z half-width
1282  G4Box *cutEdge1 = new G4Box(G4String(sName),Edge[0],Edge[1],Edge[2]);
1283 
1284  sprintf(sName, "LongEdge2");
1285  Edge[0] = (CrystalOuterRadius-CrystalEdgeOffset2); // x half-width
1286  Edge[1] = 1.001*CrystalOuterRadius; // y half-width
1287  Edge[2] = 1.001*CrystalLength/2.0; // z half-width
1288  G4Box *cutEdge2 = new G4Box(G4String(sName),Edge[0],Edge[1],Edge[2]);
1289 
1290  sprintf(sName, "Bevel");
1291  Edge[0] = 1.001*CrystalOuterRadius;
1292  Edge[1] = sin(CrystalEdgeAngle)*(CrystalEdgeDepth);
1293  Edge[2] = 1.001*CrystalLength/2.0;
1294  G4Box *cutBevel = new G4Box(G4String(sName),Edge[0],Edge[1],Edge[2]);
1295 
1296 
1297  // **************************************************************************
1298  // * SUBSTRACTIONS *
1299  // **************************************************************************
1300 
1301  // now remove previously defined box from coax. The box must be placed correctly before
1302  // since the box definition goes from negative to positive values.
1303 
1304  G4RotationMatrix rm; // rm.SetName(G4String("RotationEdge"));
1305  sprintf(sName, "coax_cut1_edge");
1306  G4SubtractionSolid *coax_cut1
1307  = new G4SubtractionSolid (G4String(sName), detCrystal, cutEdge1, &rm, G4ThreeVector(-CrystalOuterRadius,0.0,CrystalLength/2.0));
1308 
1309  sprintf(sName, "coax_cut2_edge");
1310  G4SubtractionSolid *coax_cut2
1311  = new G4SubtractionSolid (G4String(sName), coax_cut1, cutEdge2, &rm, G4ThreeVector(CrystalOuterRadius,0.0,CrystalLength/2.0));
1312 
1313  sprintf(sName, "coax_cut3_edge");
1314  rm.rotateZ(90.0*CLHEP::deg);
1315  G4SubtractionSolid *coax_cut3
1316  = new G4SubtractionSolid (G4String(sName), coax_cut2, cutEdge2, &rm, G4ThreeVector(0.0,CrystalOuterRadius,CrystalLength/2.0));
1317 
1318  sprintf(sName, "coax_cut4_edge");
1319  G4SubtractionSolid *coax_cut4
1320  = new G4SubtractionSolid (G4String(sName), coax_cut3, cutEdge1, &rm, G4ThreeVector(0.0,-CrystalOuterRadius,CrystalLength/2.0));
1321  rm.rotateZ(-90.0*CLHEP::deg);
1322 
1323  sprintf(sName, "coax_cut5_edge");
1324  rm.rotateX(CrystalEdgeAngle);
1325  G4SubtractionSolid *coax_cut5
1326  = new G4SubtractionSolid (G4String(sName), coax_cut4, cutBevel, &rm, G4ThreeVector(0.,CrystalEdgeOffset2,0.));
1327  // rm.rotateX(-CrystalEdgeAngle);
1328  //Bevel is already rotated X with CrystalEdgeAngle soyou have to put it in place to continu
1329 
1330  rm.rotateX(-CrystalEdgeAngle);
1331  sprintf(sName, "coax_cut6_edge");
1332  rm.rotateZ(90.0*CLHEP::deg);
1333  rm.rotateX(CrystalEdgeAngle);
1334  G4SubtractionSolid *coax_cut6
1335  = new G4SubtractionSolid (G4String(sName), coax_cut5, cutBevel, &rm, G4ThreeVector(CrystalEdgeOffset2,0.,0.));
1336  //rotation back
1337  rm.rotateX(-CrystalEdgeAngle);
1338  rm.rotateZ(-90.0*CLHEP::deg);
1339 
1340  //end substraction
1341 
1342 
1343  //Crystal A
1344  G4RotationMatrix* Crystal_90deg = new G4RotationMatrix();
1345  Crystal_90deg -> rotateZ(90*CLHEP::deg);
1346 
1347  sprintf(sName, "ShapedCrystalA");
1348  G4LogicalVolume *pCrystalA = new G4LogicalVolume( coax_cut6, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Ge"), G4String(sName), 0, 0, 0 );
1349  pCrystalA->SetSensitiveDetector( SToGS::UserActionInitialization::GetCopClusterSD() );
1350 
1351  CrystalA_phys = new G4PVPlacement(Crystal_90deg, // no rotation
1352  G4ThreeVector(CrystalEdgeOffset1+Tolerance,-CrystalEdgeOffset1-Tolerance,CrystalToCapsule), // at (0,0,0)
1353  pCrystalA, // its logical volume
1354  "CrystalA_P", // its name
1355  detlogicWorld, // its mother volume
1356  false, // no boolean operations
1357  0); // copy n
1358  G4VisAttributes *CrystalA_VisAtt= new G4VisAttributes(G4Colour(0.0,0.0,1.0)); //blue
1359  pCrystalA ->SetVisAttributes(CrystalA_VisAtt);
1360 
1361 
1362  //Crystal B
1363  G4RotationMatrix* Crystal_180deg = new G4RotationMatrix();
1364  Crystal_180deg -> rotateZ(180*CLHEP::deg);
1365 
1366  sprintf(sName, "ShapedCrystalB");
1367  G4LogicalVolume *pCrystalB = new G4LogicalVolume( coax_cut6, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Ge"), G4String(sName), 0, 0, 0 );
1368  pCrystalB->SetSensitiveDetector( SToGS::UserActionInitialization::GetCopClusterSD() );
1369 
1370  CrystalB_phys = new G4PVPlacement(Crystal_180deg, // no rotation
1371  G4ThreeVector(-CrystalEdgeOffset1-Tolerance,-CrystalEdgeOffset1-Tolerance,CrystalToCapsule), // at (-26*mm,-26*mm,3.5*mm)
1372  pCrystalB, // its logical volume
1373  "CrystalB_P", // its name
1374  detlogicWorld, // its mother volume
1375  false, // no boolean operations
1376  1); // copy n
1377  G4VisAttributes *CrystalB_VisAtt= new G4VisAttributes(G4Colour(0.0,1.0,0.0)); //green
1378  pCrystalB ->SetVisAttributes(CrystalB_VisAtt);
1379 
1380 
1381  //Crystal C
1382  G4RotationMatrix* Crystal_270deg = new G4RotationMatrix();
1383  Crystal_270deg -> rotateZ(270*CLHEP::deg);
1384 
1385  sprintf(sName, "ShapedCrystalC");
1386  G4LogicalVolume *pCrystalC = new G4LogicalVolume( coax_cut6, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Ge"), G4String(sName), 0, 0, 0 );
1387  pCrystalC->SetSensitiveDetector( SToGS::UserActionInitialization::GetCopClusterSD() );
1388 
1389  CrystalC_phys = new G4PVPlacement(Crystal_270deg, // no rotation
1390  G4ThreeVector(-CrystalEdgeOffset1-Tolerance,CrystalEdgeOffset1+Tolerance,CrystalToCapsule), // at (0,0,0)
1391  pCrystalC, // its logical volume
1392  "CrystalC_P", // its name
1393  detlogicWorld, // its mother volume
1394  false, // no boolean operations
1395  2); // copy n
1396  G4VisAttributes *CrystalC_VisAtt= new G4VisAttributes(G4Colour(1.0,0.0,0.0)); //red
1397  pCrystalC ->SetVisAttributes(CrystalC_VisAtt);
1398 
1399 
1400  //Crystal D
1401  sprintf(sName, "ShapedCrystalD");
1402  G4LogicalVolume *pCrystalD = new G4LogicalVolume( coax_cut6, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Ge"), G4String(sName), 0, 0, 0 );
1403 
1404  pCrystalD->SetSensitiveDetector( SToGS::UserActionInitialization::GetCopClusterSD() );
1405 
1406  CrystalD_phys = new G4PVPlacement(0, // no rotation
1407  G4ThreeVector(CrystalEdgeOffset1+Tolerance,CrystalEdgeOffset1+Tolerance,CrystalToCapsule), // at (26*mm,26*mm,3.5*mm)
1408  pCrystalD, // its logical volume
1409  "CrystalD_P", // its name
1410  detlogicWorld, // its mother volume
1411  false, // no boolean operations
1412  3); // copy n
1413  G4VisAttributes *CrystalD_VisAtt= new G4VisAttributes(G4Colour(1.0,1.0,0.0)); //yellow
1414  pCrystalD ->SetVisAttributes(CrystalD_VisAtt);
1415 
1416 
1417 
1418 
1419  // **************************************************************************
1420  // * Al CAPSULE *
1421  // **************************************************************************
1422 
1423 
1424  G4int nbslice = 7;
1425  const G4double widthface = 45.5*CLHEP::mm;
1426  G4double zSlice[7] = { 0.0*CLHEP::mm,
1427  CapsuleWidth-0.1*CLHEP::mm,
1428  CapsuleWidth,
1429  CapsuleEdgeDepth,
1430  CapsuleLength-CapsuleWidth,
1431  CapsuleLength-CapsuleWidth+0.1*CLHEP::mm,
1432  CapsuleLength
1433  };
1434  G4double InnRad[7] = { 0.00*CLHEP::mm,
1435  0.00*CLHEP::mm,
1436  widthface-CapsuleWidth,
1437  CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule - CapsuleWidth,
1438  CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule - CapsuleWidth,
1439  0.0*CLHEP::mm,
1440  0.0*CLHEP::mm
1441  };
1442  G4double OutRad[7] = { widthface-1.5*CLHEP::mm,
1443  widthface,
1444  widthface,
1445  CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule,
1446  CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule,
1447  CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule,
1448  CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule
1449  };
1450 
1451  G4RotationMatrix* Cap_45deg = new G4RotationMatrix();
1452  Cap_45deg -> rotateZ(45*CLHEP::deg);
1453 
1454  if ( do_caps )
1455  {
1456 
1457  G4Polyhedra *caps = new G4Polyhedra(G4String("Capsule"),
1458  0.*CLHEP::deg,
1459  360.*CLHEP::deg,
1460  4,
1461  nbslice,
1462  zSlice,
1463  InnRad,
1464  OutRad);
1465  sprintf(sName, "Capsule");
1466  G4LogicalVolume * pCapsule = new G4LogicalVolume( caps, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_Al"), G4String(sName), 0, 0, 0 );
1467 
1468 
1469  Capsule_phys = new G4PVPlacement(Cap_45deg, // no rotation
1470  G4ThreeVector(), // at (0,0,0)
1471  pCapsule, // its logical volume
1472  "Capsule_P", // its name
1473  detlogicWorld, // its mother volume
1474  false, // no boolean operations
1475  -1); // copy number
1476 
1477 
1478  G4VisAttributes *Capsule_VisAtt= new G4VisAttributes(G4Colour(0.5,0.5,0.5,0.75)); //grey
1479  pCapsule ->SetVisAttributes(Capsule_VisAtt);
1480  }
1481 
1482  // **************************************************************************
1483  // * BGO AntiCompton1 *
1484  // **************************************************************************
1485 
1486  // define a coaxial shape that will be modify with SubstractSolid
1487 
1488  G4int numZplane = 3;
1489  G4double zSides[3] = { 0.0*CLHEP::mm,
1490  0.0*CLHEP::mm,
1491  BGOLength};
1492  G4double rInnerBGO[3] = { CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule + Space,
1493  CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule + Space ,
1494  CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule + Space };
1495  G4double rOuterBGO[3] = { CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule + Space,
1496  CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule + BGOWidth,
1497  CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule + BGOWidth};
1498 
1499 
1500  zSides[1] = BGOWidth / tan(CrystalEdgeAngle);
1501 
1502  G4Polyhedra *bgo = new G4Polyhedra(G4String("BGO"), //pName
1503  0.*CLHEP::deg, //phiStart
1504  360.*CLHEP::deg, //phiTotal
1505  4, //numSide
1506  numZplane, //numZPlanes
1507  zSides, //zPlane[]
1508  rInnerBGO, //rInner[]
1509  rOuterBGO); //rOuter[]
1510 
1511  // G4Polyhedra *bgo = new G4Polyhedra(G4String("BGO"), 0.*deg, 360.*deg, 4, numZplane, zSides, rInnerBGO, rOuterBGO);
1512  sprintf(sName, "BGORear");
1513  G4LogicalVolume *pBGO = new G4LogicalVolume( bgo, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_BGO"), G4String(sName), 0, 0, 0 );
1514  pBGO->SetSensitiveDetector( SToGS::UserActionInitialization::GetCopClusterSD() );
1515 
1516  BGO_phys = new G4PVPlacement(Cap_45deg, // no rotation
1517  G4ThreeVector(0.0*CLHEP::mm,0.0*CLHEP::mm,CrystalEdgeDepth+CrystalToCapsule), // at (0,0,0)
1518  pBGO, // its logical volume
1519  "BGO_P", // its name
1520  detlogicWorld, // its mother volume
1521  false, // no boolean operations
1522  4); // copy number
1523 
1524 
1525  G4VisAttributes *BGO_VisAtt= new G4VisAttributes(G4Colour(0.0,1.0,1.0)); //cyan
1526  pBGO ->SetVisAttributes(BGO_VisAtt);
1527 
1528  // **************************************************************************
1529  // * CsIBack Anticompton2 *
1530  // **************************************************************************
1531 
1532  G4Tubs *hole= new G4Tubs(G4String("ColdFinger"),
1533  0.0*CLHEP::mm,
1534  15.0*CLHEP::mm,
1535  CsILength+0.3*CLHEP::mm,
1536  0.0*CLHEP::deg,
1537  360.*CLHEP::deg);
1538 
1539  G4Box *fullcsi= new G4Box(G4String("FullCsIBack"),
1540  CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule,
1541  CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule,
1542  CsILength);
1543 
1544 
1545  G4SubtractionSolid *hole_cut_csi= new G4SubtractionSolid (G4String("cut_csi"), fullcsi, hole, &rm,G4ThreeVector(0.,0.,0.));
1546 
1547  sprintf(sName, "CsIBack");
1548  G4LogicalVolume *pCsIBack= new G4LogicalVolume( hole_cut_csi, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("SToGS_CsI"), G4String(sName), 0, 0, 0 );
1549  pCsIBack->SetSensitiveDetector( SToGS::UserActionInitialization::GetCopClusterSD() );
1550  CsIBack_phys = new G4PVPlacement(0, // no rotation
1551  G4ThreeVector(0.,0.,CrystalLength+ 40 *CLHEP::mm+CrystalToCapsule), // at (0,0,0)
1552  pCsIBack, // its logical volume
1553  "CsIBack_P", // its name
1554  detlogicWorld, // its mother volume
1555  false, // no boolean operations
1556  5); // copy number
1557 
1558  G4VisAttributes *CsIBack_VisAtt= new G4VisAttributes(G4Colour(1.0,0.0,1.0)); //magenta
1559  pCsIBack ->SetVisAttributes(CsIBack_VisAtt);
1560  // CsIBack_VisAtt->SetForceWireframe(true);
1561 */
1562  return theDetector;
1563 }
1564 
1565 
1566 
1567 
1568 G4VSolid *SToGS::SemiConductorGeDF::AGATAShaper(G4Polycone *polycone,
1569  G4double *xfront, G4double *yfront, G4double *xback, G4double *yback,
1570  G4double zback,
1571  G4double added_dilatation)
1572 {
1573  G4String name = polycone->GetName(), tmp;
1574 
1575  const G4int nb_edges = 6; G4double lxfront[nb_edges], lyfront[nb_edges], lxback[nb_edges], lyback[nb_edges];
1576  // apply scaling to the different shapes if required
1577  if ( added_dilatation == 0.0 ) {
1578  for (G4int i = 0; i < nb_edges; i++) {
1579  lxfront[i] = xfront[i];
1580  lyfront[i] = yfront[i];
1581  lxback[i] = xback[i];
1582  lyback[i] = yback[i];
1583  }
1584  }
1585  else {
1586  G4double D;
1587  for (G4int i = 0; i < nb_edges; i++) {
1588  D = std::sqrt( xfront[i]*xfront[i] + yfront[i]*yfront[i] );
1589  lxfront[i] = xfront[i] + added_dilatation*xfront[i]/D ;
1590  lyfront[i] = yfront[i] + added_dilatation*yfront[i]/D ;
1591  D = std::sqrt( xback[i]*xback[i] + yback[i]*yback[i] );
1592  lxback[i] = xback[i] + added_dilatation*xback[i]/D ;
1593  lyback[i] = yback[i] + added_dilatation*yback[i]/D ;
1594  }
1595  }
1596  // for each side of the hexagone, computes from the given point to remove an 'infinite' box [edge]
1597  G4double edge_length_x = 40*CLHEP::mm, edge_width_y = 10*CLHEP::mm, edge_depth_z = 1.2*zback/2.;
1598  G4int inext;
1599 
1600  G4VSolid *result = polycone;
1601  for (G4int i = 0; i < nb_edges; i++) {
1602 
1603  // a new box [edge] to cut the polygone
1604  tmp = name; tmp += "_edge_";
1605  std::stringstream s1;
1606  s1 << i;
1607  tmp += s1.str();
1608  //
1609  G4Box *edge = new G4Box(tmp,edge_length_x,edge_width_y,edge_depth_z);
1610 
1611  // now defines the edges in 3D
1612  if ( i == nb_edges-1 ) {
1613  inext = 0;
1614  }
1615  else inext = i + 1;
1616 
1617  G4ThreeVector T;
1618  // Compute the 3D vector that goes from middle of front segment to middle of back segment
1619  // --> this gives the rotatation angle the edge should be rotated alongst X
1620  G4ThreeVector v_RotX_1((lxback[i]+lxback[inext])/2.-(lxfront[i]+lxfront[inext])/2.,
1621  (lyback[i]+lyback[inext])/2.-(lyfront[i]+lyfront[inext])/2.,zback);
1622 
1623  // compute 2D vector at the center of the segment
1624  // --> it is used to determine the additional offset in X,Y
1625  // in order to have the face of the box tangent to the surface extracted from the face of the hexagone
1626  G4ThreeVector v_RotZ_0(lxfront[inext]+lxfront[i],lyfront[inext]+lyfront[i] , 0 );
1627  // compute 2D vector going from i -> inext.
1628  // --> it is used to detemine the rotation angle along Z for the box
1629  G4ThreeVector v_RotZ_1(lxfront[inext]-lxfront[i],lyfront[inext]-lyfront[i] , 0 );
1630 
1631  // the total rotation matrix on the edge
1632  G4RotationMatrix R;
1633  R.set(0,0,0);
1634  R.rotateX(v_RotX_1.theta());
1635  R.rotateZ(v_RotZ_1.phi());
1636  // the translation to bring the edge at the center of the cylinder
1637  T.setX( (lxback[inext]+lxfront[i])/2. );
1638  T.setY( (lyback[inext]+lyfront[i])/2. );
1639  T.setZ( zback / 2. );
1640  // the additionnal offset to take into account the wdth of the edge
1641  G4ThreeVector offset( std::cos(v_RotZ_0.phi())*edge_width_y, std::sin(v_RotZ_0.phi())*edge_width_y , 0 );
1642 
1643 #ifdef L_DEBUG
1644  G4cout << "Building Edges " << tmp << G4endl;
1645  G4cout << " hexogone def @ 0 and " << zback
1646  << " " << lxfront[i] << " " << lyfront[i] << " " << lxback[i] << " " << lyback[i] << G4endl;
1647  G4cout << " RotX[theta] " << v_RotX_1.theta()/CLHEP::deg << " RotZ[phi] " << v_RotZ_1.phi()/CLHEP::deg << G4endl;
1648  G4cout << "Translation to bring to center " << T << G4endl;
1649  G4cout << "Additionnal offset due to edge width " << offset << G4endl;
1650 #endif
1651 
1652  T = T + offset;
1653  tmp = name; tmp += "_step_";
1654  std::stringstream s2;
1655  s2 << i;
1656  tmp += s2.str();
1657  result = new G4SubtractionSolid(tmp, result, edge, G4Transform3D(R,T) );
1658  // used for visualization
1659  //result = new G4UnionSolid(tmp, result, edge, G4Transform3D((R),T) );
1660  }
1661 
1662  return result;
1663 }
1664 /*
1665 G4LogicalVolume *SToGS::SemiConductorGeDF::MakeAGATACapsule(G4String detname, G4String opt)
1666 {
1667  G4bool do_caps = true, do_passive = false; G4String tmp;
1668 
1669  // cotations
1670  G4double px[6], py[6], pX[6], pY[6], pz[6], pZ[6]; // definition of the front/back hexagone
1671 
1672  G4double HoleR; // Coaxial hole with radius HoleR
1673  G4double HoleL; // Hole starts at the depth HoleL
1674 
1675  G4double CylR; // Radius of the cylinder that is the base of the shaped crystal
1676  G4double CylL; // Length of the cylinder that is the base of the shaped crystal
1677  G4double CylX; // Additionnal offset
1678  G4double CylY; // Additionnal offset
1679  G4double CylZ; // Additionnal offset
1680 
1681  G4double ThickB; // Thickness of the passive area (back)
1682  G4double ThickC; // Thickness of the passive area (coaxial)
1683  G4double CapS; // The crystal-encapsulation spacing is capS
1684  G4double CapT; // The capsule is capT thick
1685  G4double Tolerance; // CapS+CapT+tol
1686 
1687  G4double ColX; // RGB color components
1688  G4double ColY; // RGB color components
1689  G4double ColZ; // RGB color components
1690 
1691  G4double eps = 0.*CLHEP::mm;
1692  // to avoid overlapping in G4, add/remove atrificially this quantities at borders between caps and Ge
1693 
1694  // file to read cotations
1695  ifstream infil; infil.open("DetectorFactory/SemiConductors/Ge/Builders/agata_capsule.geo");
1696  if ( !infil.is_open() ) {
1697  G4cout << "[SToGS] *** Cannot open file " << "DetectorFactory/SemiConductors/Ge/Builders/agata_capsule.geo"
1698  << endl; // end read the file.
1699  return 0x0 ;
1700  }
1701 
1702  // Options: bare -> no capsules, passive -> add passive
1703  G4int which_id = 0;
1704  if ( detname.contains("Green") ) {
1705  which_id = 1;
1706 // innername = "BGreen";
1707  }
1708  if ( detname.contains("Blue") ) {
1709  which_id = 2;
1710 // innername = "CBlue";
1711  }
1712  // if ( detname.contains("bare") )
1713  do_caps = false;
1714  // if ( detname.contains("passive") )
1715  // which_id = 2;
1716 
1717  int i1,i2,i3, nb_line = 0, nb_point = 0; double x,y,z,X,Y,Z; std::string line;
1718  while( infil.good() ) {
1719 
1720  getline(infil,line);
1721  //
1722  if ( line.size() < 2u )
1723  continue;
1724  if ( line[0] == '#' )
1725  continue;
1726 
1727  // decode the line
1728  if(sscanf(line.data(),"%d %d %d %lf %lf %lf %lf %lf %lf", &i1, &i2, &i3, &x, &y, &z, &X, &Y, &Z) != 9) {
1729  break;
1730  }
1731 
1732  if(which_id != i1) { // a new crystal is being defined, so init a new ASolid structure
1733  continue;
1734  }
1735  else nb_line++;
1736 
1737  if(i2==0 && i3==0) { // basic shape for the crystal
1738  HoleR = x * CLHEP::mm;
1739  CylR = y * CLHEP::mm;
1740  CylL = z * CLHEP::mm;
1741  CylX = X * CLHEP::mm;
1742  CylY = Y * CLHEP::mm;
1743  CylZ = Z * CLHEP::mm;
1744  }
1745  else if(i2==0 && i3==1) { // passive and capsule
1746  HoleL = x * CLHEP::mm;
1747  ThickB = y * CLHEP::mm;
1748  ThickC = z * CLHEP::mm;
1749  CapS = X * CLHEP::mm;
1750  CapT = Y * CLHEP::mm;
1751  Tolerance = Z * CLHEP::mm;
1752  }
1753  else if(i2==0 && i3==2) { // colors
1754  ColX = x;
1755  ColY = y;
1756  ColZ = z;
1757  }
1758  else { // a new point to define the ploygon
1759 
1760  px[nb_point] = x * CLHEP::mm;
1761  py[nb_point] = y * CLHEP::mm;
1762  pX[nb_point] = X * CLHEP::mm;
1763  pY[nb_point] = Y * CLHEP::mm;
1764 
1765  pz[nb_point] = z * CLHEP::mm;
1766  pZ[nb_point] = Z * CLHEP::mm;
1767 
1768  nb_point++;
1769  }
1770  } // while good
1771  infil.close();
1772  G4cout << " the file " << "DetectorFactory/SemiConductors/Ge/Builders/agata_capsule.geo"
1773  << " has been read " << endl; // end read the file.
1774 
1775  // use a physical as a container to describe the detector
1776  G4RotationMatrix R; G4ThreeVector T; G4Transform3D Tr;
1777 
1778  // the coax part :
1779  // the raw crystal
1780  G4double *zSliceGe = new G4double[4];
1781  zSliceGe[0] = (-CylL/2.+eps)*CLHEP::mm;
1782  zSliceGe[1] = (-CylL/2.+HoleL)*CLHEP::mm;
1783  zSliceGe[2] = (-CylL/2.+HoleL+0.1)*CLHEP::mm;
1784  zSliceGe[3] = (+CylL/2.-eps)*CLHEP::mm;
1785  //
1786  G4double *InnRadGe = new G4double[4];
1787  InnRadGe[0] = 0.;
1788  InnRadGe[1] = 0.;
1789  InnRadGe[2] = HoleR*CLHEP::mm;
1790  InnRadGe[3] = HoleR*CLHEP::mm;
1791  //
1792  G4double *OutRadGe = new G4double[4];
1793  OutRadGe[0] = CylR*CLHEP::mm;
1794  OutRadGe[1] = CylR*CLHEP::mm;
1795  OutRadGe[2] = CylR*CLHEP::mm;
1796  OutRadGe[3] = CylR*CLHEP::mm;
1797  //
1798  tmp = detname;
1799  tmp += "_coax";
1800  G4Polycone *coax = new G4Polycone(tmp, 0.*deg, 360.*deg, 4, zSliceGe, InnRadGe, OutRadGe ) ;
1801  // out of the shaper, the crystal with its complex shape
1802  tmp = detname;
1803  tmp += "_crystal";
1804  G4VSolid *crystal = AGATAShaper(coax,px,py,pX,pY,CylL);
1805  crystal->SetName(tmp);
1806 
1807  // set attributes of the capsule and place it
1808  G4LogicalVolume *crystal_logic =
1809  new G4LogicalVolume(crystal,
1810  SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("Ge"),tmp,0,0,0);
1811  G4VisAttributes *crystal_visatt = new G4VisAttributes( G4Colour(ColX, ColY, ColZ,1) );
1812  crystal_logic->SetVisAttributes( crystal_visatt );
1813  crystal_logic->SetSensitiveDetector( SToGS::UserActionInitialization::GetCopClusterSD() );
1814  // the coax part
1815 
1816  // encapsulation of the crystal
1817  G4LogicalVolume *capsule_logic = 0x0, *spacing_logic = 0x0;
1818  if (do_caps) {
1819  // spacing filled with air
1820  zSliceGe[0] = (-CylL/2. - CapT)*CLHEP::mm;
1821  zSliceGe[1] = (+CylL/2. + CapT)*CLHEP::mm;
1822  //
1823  InnRadGe[0] = 0.;
1824  InnRadGe[1] = 0.;
1825  //
1826  OutRadGe[0] = (CylR + CapT)*CLHEP::mm;
1827  OutRadGe[1] = (CylR + CapT)*CLHEP::mm;
1828  //
1829  tmp = detname;
1830  tmp += "_coax_spacing";
1831  G4Polycone *coax_spacing_shape = new G4Polycone(tmp, 0.*deg, 360.*deg, 2, zSliceGe, InnRadGe, OutRadGe);
1832  //
1833  tmp = detname;
1834  tmp += "_capsule_spacing";
1835  G4VSolid *spacing = AGATAShaper(coax_spacing_shape,px,py,pX,pY,CylL,CapT);
1836  spacing->SetName(tmp);
1837  //
1838  // set attributes
1839  spacing_logic = new G4LogicalVolume(spacing,
1840  SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("AIR"),tmp,0,0,0);
1841  // G4VisAttributes *spacing_visatt = new G4VisAttributes( G4Colour(ColX, ColY, ColZ,0.4) );
1842  // spacing_logic->SetVisAttributes( spacing_visatt );
1843  spacing_logic->SetVisAttributes( G4VisAttributes::Invisible );
1844 
1845  // spacing filled with air
1846  zSliceGe[0] = (-CylL/2. - CapT - CapS)*CLHEP::mm;
1847  zSliceGe[1] = (+CylL/2. + CapT + CapS)*CLHEP::mm;
1848  //
1849  InnRadGe[0] = 0.;
1850  InnRadGe[1] = 0.;
1851  //
1852  OutRadGe[0] = (CylR + CapT + CapS)*CLHEP::mm;
1853  OutRadGe[1] = (CylR + CapT + CapS)*CLHEP::mm;
1854  //
1855  tmp = detname;
1856  tmp += "_coax_encapsulation";
1857  G4Polycone *coax_caps_shape = new G4Polycone(tmp, 0.*deg, 360.*deg, 2, zSliceGe, InnRadGe, OutRadGe);
1858  //
1859  tmp = detname;
1860  tmp += "_capsule";
1861  G4VSolid *capsule = AGATAShaper(coax_caps_shape,px,py,pX,pY,CylL,CapT+CapS);
1862  capsule->SetName(tmp);
1863  //
1864  // set attributes
1865  capsule_logic = new G4LogicalVolume(capsule,
1866  SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("Al"),tmp,0,0,0);
1867  G4VisAttributes *capsule_visatt = new G4VisAttributes( G4Colour(0.3, 0.3, 0.3,0.8) );
1868  capsule_logic->SetVisAttributes( capsule_visatt );
1869  }
1870 
1871  if ( capsule_logic && spacing_logic ) {
1872  return capsule_logic;
1873  }
1874 
1875  return crystal_logic;
1876 }
1877  */
1878 
1879 
1880 G4VPhysicalVolume *SToGS::SemiConductorGeDF::MakeAGATACapsule(G4String detname, G4String opt, G4String geo_file)
1881 {
1882  G4VPhysicalVolume *theDetector = 0x0; G4bool do_caps = true; // do_passive = false;
1883  G4String tmp, crystal_name = "ARed", filename = geo_file; // file with definition
1884 
1885  // cotations
1886  G4double px[6], py[6], pX[6], pY[6], pz[6], pZ[6]; // definition of the front/back hexagone
1887 
1888  G4double HoleR; // Coaxial hole with radius HoleR
1889  G4double HoleL; // Hole starts at the depth HoleL
1890 
1891  G4double CylR; // Radius of the cylinder that is the base of the shaped crystal
1892  G4double CylL; // Length of the cylinder that is the base of the shaped crystal
1893  G4double CylX; // Additionnal offset
1894  G4double CylY; // Additionnal offset
1895  G4double CylZ; // Additionnal offset
1896 
1897  G4double ThickB; // Thickness of the passive area (back)
1898  G4double ThickC; // Thickness of the passive area (coaxial)
1899  G4double CapS; // The crystal-encapsulation spacing is capS
1900  G4double CapT; // The capsule is capT thick
1901  G4double Tolerance; // CapS+CapT+tol
1902 
1903  G4double ColX; // RGB color components
1904  G4double ColY; // RGB color components
1905  G4double ColZ; // RGB color components
1906 
1907  // file to read cotations
1908  ifstream infil; infil.open(filename.data());
1909  if ( !infil.is_open() ) {
1910  G4cout << "[SToGS] *** Cannot open file " << filename.data() << endl; // end read the file.
1911  return 0x0 ;
1912  }
1913 
1914  // Options: bare -> no capsules, passive -> add passive
1915  G4int which_id = 0;
1916  if ( detname.contains("Green") ) {
1917  crystal_name = "BGreen";
1918  which_id = 1;
1919  }
1920  if ( detname.contains("Blue") ) {
1921  crystal_name = "CBlue";
1922  which_id = 2;
1923  }
1924  if ( opt.contains("bare") )
1925  do_caps = false;
1926  // if ( detname.contains("passive") )
1927  // which_id = 2;
1928 
1929  // The detector
1930  G4LogicalVolume *detlogicWorld;
1931  G4Box *detWorld;
1932  detWorld = new G4Box(detname,10.*CLHEP::cm,10.*CLHEP::cm,25.*CLHEP::cm);
1933  detlogicWorld=
1934  new G4LogicalVolume(detWorld, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("AIR"), detname, 0, 0, 0);
1935  detlogicWorld->SetVisAttributes(G4VisAttributes::Invisible); // hide the world
1936  // Must place the World Physical volume unrotated at (0,0,0).
1937  theDetector = new G4PVPlacement(0, // no rotation
1938  G4ThreeVector(0,0,0), // at (0,0,0)
1939  detlogicWorld, // its logical volume
1940  detname, // its name
1941  0, // its mother volume
1942  false, // no boolean operations
1943  -1); // copy number
1944 
1945 
1946  int i1,i2,i3, nb_line = 0, nb_point = 0; double x,y,z,X,Y,Z; std::string line;
1947  while( infil.good() ) {
1948 
1949  getline(infil,line);
1950  //
1951  if ( line.size() < 2u )
1952  continue;
1953  if ( line[0] == '#' )
1954  continue;
1955 
1956  // decode the line
1957  if(sscanf(line.data(),"%d %d %d %lf %lf %lf %lf %lf %lf", &i1, &i2, &i3, &x, &y, &z, &X, &Y, &Z) != 9) {
1958  break;
1959  }
1960 
1961  if(which_id != i1) { // a new crystal is being defined, so init a new ASolid structure
1962  continue;
1963  }
1964  else nb_line++;
1965 
1966  if(i2==0 && i3==0) { // basic shape for the crystal
1967  HoleR = x * CLHEP::mm;
1968  CylR = y * CLHEP::mm;
1969  CylL = z * CLHEP::mm;
1970  CylX = X * CLHEP::mm;
1971  CylY = Y * CLHEP::mm;
1972  CylZ = Z * CLHEP::mm;
1973  }
1974  else if(i2==0 && i3==1) { // passive and capsule
1975  HoleL = x * CLHEP::mm;
1976  ThickB = y * CLHEP::mm;
1977  ThickC = z * CLHEP::mm;
1978  CapS = X * CLHEP::mm;
1979  CapT = Y * CLHEP::mm;
1980  Tolerance = Z * CLHEP::mm;
1981  }
1982  else if(i2==0 && i3==2) { // colors
1983  ColX = x;
1984  ColY = y;
1985  ColZ = z;
1986  }
1987  else { // a new point to define the ploygon
1988 
1989  px[i3] = x * CLHEP::mm;
1990  py[i3] = y * CLHEP::mm;
1991  pX[i3] = X * CLHEP::mm;
1992  pY[i3] = Y * CLHEP::mm;
1993 
1994  pz[i3] = z * CLHEP::mm;
1995  pZ[i3] = Z * CLHEP::mm;
1996 
1997  nb_point++;
1998  }
1999  } // while good
2000  infil.close();
2001  G4cout << " the file " << filename.data() << " has been read " << endl; // end read the file.
2002 
2003  // use a physical as a container to describe the detector
2004  G4RotationMatrix R; G4ThreeVector T; G4Transform3D Tr;
2005 
2006  // the coax part :
2007  // the raw crystal
2008  G4double *zSliceGe = new G4double[4];
2009  zSliceGe[0] = (0)*CLHEP::mm;
2010  zSliceGe[1] = (HoleL)*CLHEP::mm;
2011  zSliceGe[2] = (HoleL+0.1)*CLHEP::mm;
2012  zSliceGe[3] = (+CylL)*CLHEP::mm;
2013  //
2014  G4double *InnRadGe = new G4double[4];
2015  InnRadGe[0] = 0.;
2016  InnRadGe[1] = 0.;
2017  InnRadGe[2] = HoleR*CLHEP::mm;
2018  InnRadGe[3] = HoleR*CLHEP::mm;
2019  //
2020  G4double *OutRadGe = new G4double[4];
2021  OutRadGe[0] = CylR*CLHEP::mm;
2022  OutRadGe[1] = CylR*CLHEP::mm;
2023  OutRadGe[2] = CylR*CLHEP::mm;
2024  OutRadGe[3] = CylR*CLHEP::mm;
2025  //
2026  tmp = crystal_name;
2027  tmp += "ShapeCoax";
2028  G4Polycone *coax = new G4Polycone(tmp, 0.*CLHEP::deg, 360.*CLHEP::deg, 4, zSliceGe, InnRadGe, OutRadGe ) ;
2029  // out of the shaper, the crystal with its complex shape
2030  tmp = crystal_name;
2031  tmp += "ShapeCrystal";
2032  G4VSolid *crystal = AGATAShaper(coax,px,py,pX,pY,CylL);
2033  crystal->SetName(tmp);
2034  // set attributes of the capsule and place it
2035  tmp = crystal_name;
2036  tmp += "LV";
2037  G4LogicalVolume *crystal_logic =
2038  new G4LogicalVolume(crystal,
2039  SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("Ge"),tmp,0,0,0);
2040  G4VisAttributes *crystal_visatt = new G4VisAttributes( G4Colour(ColX, ColY, ColZ,1) );
2041  crystal_logic->SetVisAttributes( crystal_visatt );
2042  crystal_logic->SetSensitiveDetector( SToGS::UserActionInitialization::GetTrackerSD() );
2043 
2044  // encapsulation of the crystal
2045  G4LogicalVolume *capsule_logic = 0x0, *spacing_logic = 0x0;
2046  // spacing filled with air
2047  zSliceGe[0] = (0.0)*CLHEP::mm;
2048  zSliceGe[1] = (CylL + 2*CapS)*CLHEP::mm;
2049  //
2050  InnRadGe[0] = 0.;
2051  InnRadGe[1] = 0.;
2052  //
2053  OutRadGe[0] = (CylR + CapS)*CLHEP::mm;
2054  OutRadGe[1] = (CylR + CapS)*CLHEP::mm;
2055  //
2056  tmp = crystal_name;
2057  tmp += "ShapeCoaxSpacing";
2058  G4Polycone *coax_spacing_shape = new G4Polycone(tmp, 0.*CLHEP::deg, 360.*CLHEP::deg, 2, zSliceGe, InnRadGe, OutRadGe);
2059  //
2060  tmp = crystal_name;
2061  tmp += "ShapeSpacing";
2062  G4VSolid *spacing = AGATAShaper(coax_spacing_shape,px,py,pX,pY,CylL,CapS);
2063  spacing->SetName(tmp);
2064  //
2065  // set attributes
2066  tmp = crystal_name;
2067  tmp += "SpacingLV";
2068  spacing_logic = new G4LogicalVolume(spacing,
2069  SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("AIR"),tmp,0,0,0);
2070  G4VisAttributes *spacing_visatt = new G4VisAttributes( G4Colour(1, 1, 1,0.5) );
2071  spacing_logic->SetVisAttributes( spacing_visatt );
2072 
2073  // capsule filled with Al ... or AIR in case one would like to have only the Ge crystal ... to be used to know lost due to encapsulation
2074  zSliceGe[0] = (0.0)*CLHEP::mm;
2075  zSliceGe[1] = (CylL + 2*(CapT + CapS))*CLHEP::mm;
2076  //
2077  InnRadGe[0] = 0.;
2078  InnRadGe[1] = 0.;
2079  //
2080  OutRadGe[0] = (CylR + CapT + CapS)*CLHEP::mm;
2081  OutRadGe[1] = (CylR + CapT + CapS)*CLHEP::mm;
2082  //
2083  tmp = crystal_name;
2084  tmp += "ShapeCoaxEncapsulation";
2085  G4Polycone *coax_caps_shape = new G4Polycone(tmp, 0.*CLHEP::deg, 360.*CLHEP::deg, 2, zSliceGe, InnRadGe, OutRadGe);
2086  //
2087  tmp = crystal_name;
2088  tmp += "ShapeCapsule";
2089  G4VSolid *capsule = AGATAShaper(coax_caps_shape,px,py,pX,pY,CylL,(CapT+CapS));
2090  capsule->SetName(tmp);
2091  //
2092  // set attributes
2093  tmp = crystal_name;
2094  tmp += "CapsuleLV";
2095  // in case the capsule is not there, just set it as air
2096  if (do_caps) {
2097  capsule_logic = new G4LogicalVolume(capsule,
2098  SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("Al"),tmp,0,0,0);
2099  G4VisAttributes *capsule_visatt = new G4VisAttributes( G4Colour(0.6, 0.6, 0.6, 0.75) );
2100  capsule_logic->SetVisAttributes( capsule_visatt );
2101  }
2102  else {
2103  capsule_logic = new G4LogicalVolume(capsule,
2104  SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("AIR"),tmp,0,0,0);
2105  G4VisAttributes *capsule_visatt = new G4VisAttributes( G4Colour(1, 1, 1, 0.5) );
2106  capsule_logic->SetVisAttributes( capsule_visatt );
2107  }
2108 
2109  // place volumes
2110  if ( capsule_logic && spacing_logic ) {
2111  tmp = crystal_name;
2112  tmp += "Caps";
2113  T.setX( 0.0 );
2114  T.setY( 0.0 );
2115  T.setZ( 0.0 );
2116  new G4PVPlacement(0,T,capsule_logic,tmp,detlogicWorld,false,0);
2117  //
2118  tmp = crystal_name;
2119  tmp += "Spacing";
2120  T.setZ( CapT );
2121  new G4PVPlacement(0,T,spacing_logic,tmp,capsule_logic,false,-1);
2122  //
2123  T.setZ( CapS + CapT );
2124  new G4PVPlacement(0,T,crystal_logic,crystal_name,spacing_logic,false,0);
2125  }
2126 
2127  return theDetector;
2128 }
2129 
2130 G4VPhysicalVolume *SToGS::SemiConductorGeDF::MakeAGATACluster(G4String detname, G4String opt,G4String geo_file)
2131 {
2132  G4VPhysicalVolume *theDetector = 0x0; std::vector < G4String > capsules(3);
2133 
2134  ifstream infil; infil.open(geo_file.data());
2135  if ( !infil.is_open() ) {
2136  G4cout << "[SToGS] *** Cannot open file " << geo_file.data()
2137  << endl; // end read the file.
2138  return 0x0 ;
2139  }
2140 
2141  G4LogicalVolume *detlogicWorld;
2142  G4Box *detWorld;
2143  detWorld = new G4Box(detname,30.*CLHEP::cm,30.*CLHEP::cm,50.*CLHEP::cm);
2144  detlogicWorld=
2145  new G4LogicalVolume(detWorld,
2146  SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("AIR"), detname, 0, 0, 0);
2147  detlogicWorld->SetVisAttributes(G4VisAttributes::Invisible); // hide the world
2148  // Must place the World Physical volume unrotated at (0,0,0).
2149  theDetector = new G4PVPlacement(0, // no rotation
2150  G4ThreeVector(), // at (0,0,0)
2151  detlogicWorld, // its logical volume
2152  detname, // its name
2153  0, // its mother volume
2154  false, // no boolean operations
2155  -1); // copy number
2156 
2157  // treatment option ... careful, the real detection volume could be inside a capsule ...
2158  // one should then look for it before setting copy number ...
2159  //
2160  if ( opt.contains("bare") && !opt.contains("bare1") ) {
2161  capsules[0] = "DetectorFactory/SemiConductors/Ge/AGATA-ARed_bare";
2162  capsules[1] = "DetectorFactory/SemiConductors/Ge/AGATA-BGreen_bare";
2163  capsules[2] = "DetectorFactory/SemiConductors/Ge/AGATA-CBlue_bare";
2164 
2165  }
2166  else { // Ge encapsulation on
2167  capsules[0] = "DetectorFactory/SemiConductors/Ge/AGATA-ARed";
2168  capsules[1] = "DetectorFactory/SemiConductors/Ge/AGATA-BGreen";
2169  capsules[2] = "DetectorFactory/SemiConductors/Ge/AGATA-CBlue";
2170  }
2171  // Remap capsuel to give copy number 0 1 2 to Red, Green Blue
2172  ReMap(Get(capsules[0]),0);
2173  ReMap(Get(capsules[1]),1);
2174  ReMap(Get(capsules[2]),2);
2175 
2176  G4int i1,i2,i3, which = 0; G4double x,y,z,ps, th, ph; std::string line;
2177  while( infil.good() ) {
2178 
2179  // get euler angles from files
2180  getline(infil,line);
2181  //
2182  if ( line.size() < 2u )
2183  continue;
2184  if ( line[0] == '#' )
2185  continue;
2186  if(sscanf(line.data(),"%d %d %d %lf %lf %lf %lf %lf %lf", &i1, &i2, &i3, &ps, &th, &ph, &x, &y, &z) != 9) {
2187  break;
2188  }
2189 
2190  G4ThreeVector T;G4RotationMatrix R; R.set(0,0,0);
2191  which = i2;
2192  //
2193  T.setX(x*CLHEP::mm);
2194  T.setY(y*CLHEP::mm);
2195  T.setZ(z*CLHEP::mm);
2196  //
2197  R.rotateZ(G4double(ps)*CLHEP::deg);
2198  R.rotateY(G4double(th)*CLHEP::deg);
2199  R.rotateZ(G4double(ph)*CLHEP::deg);
2200  //
2201  G4Transform3D Tr(R,T);
2202  //
2203  Set(capsules[which],theDetector,0,&T,&R);
2204  }
2205  infil.close();
2206 
2207  return theDetector;
2208 }
2209 
2210 /*
2211 
2212 G4VPhysicalVolume * SemiConductorGeDF::MakeEURO_PI(G4String detname, G4String opt)
2213 {
2214  G4VPhysicalVolume *theDetector = 0x0; G4LogicalVolume *detlogicWorld; G4Box *detWorld; // G4bool do_caps = false, do_housing = false;
2215 
2216  // Option
2217  if ( opt != "bare" ) {
2218 // do_caps = true;
2219  }
2220  if ( housing_width != 0.0 ) {
2221  if ( opt != "bare" ) {
2222  do_housing = true;
2223  }
2224  }
2225 
2226 
2227  // use a physical as a container to describe the detector
2228  detWorld= new G4Box(detname,10.*cm,10.*cm,50.*cm);
2229  detlogicWorld= new G4LogicalVolume(detWorld, ParisMaterialConsultant::theConsultant()->FindOrBuildMaterial("AIR"), detname, 0, 0, 0);
2230 
2231  detlogicWorld->SetVisAttributes(G4VisAttributes::Invisible); // hide the world
2232  // Must place the World Physical volume unrotated at (0,0,0).
2233  theDetector = new G4PVPlacement(0, // no rotation
2234  G4ThreeVector(), // at (0,0,0)
2235  detlogicWorld, // its logical volume
2236  detname, // its name
2237  0, // its mother volume
2238  false, // no boolean operations
2239  -1); // copy number
2240 
2241  // Fron drawings
2242  const G4double TronCrystalLength = 70.0*mm; // cystal length
2243 
2244  const G4double TronCrystalEdgeDepth = 40.0*mm; // depth at which starts TronCrystalRadiusMax
2245  const G4double TronCrystalRadiusMin = 32.0*mm; // radius of the crystal at the entrance face
2246  const G4double TronCrystalRadiusMax = 35.0*mm; // radius of the crystal at the back face
2247 
2248  const G4double TronCrystalHoleDepth = 15.0*mm; // depth at which starts the hole
2249  const G4double TronCrystalHoleRadius = 5.0*mm; // radius of the hole
2250 
2251 
2252  G4int nbSlice = 5;
2253  G4double zSlice[5] = {
2254  0.0*mm,
2255  TronCrystalHoleDepth, TronCrystalHoleDepth + 1.0*mm,
2256  TronCrystalEdgeDepth, TronCrystalLength };
2257 
2258  G4double InnRad[5] = {
2259  0.0*mm,
2260  0.0*mm, TronCrystalHoleRadius,
2261  TronCrystalHoleRadius, TronCrystalHoleRadius };
2262 
2263  G4double OutRad[5] = {
2264  TronCrystalRadiusMin,
2265  TronCrystalRadiusMin + (TronCrystalRadiusMax-TronCrystalRadiusMin)*TronCrystalHoleDepth/TronCrystalEdgeDepth,
2266  TronCrystalRadiusMin + (TronCrystalRadiusMax-TronCrystalRadiusMin)*(TronCrystalHoleDepth+1.0*mm)/TronCrystalEdgeDepth,
2267  TronCrystalRadiusMax, TronCrystalRadiusMax };
2268 
2269  // the Germanim crystal
2270  G4Polycone *crys =
2271  new G4Polycone("CrystalEUROGAM_PI",0.0*deg,360.0*deg,nbSlice,zSlice,InnRad,OutRad);
2272  // G4LogicalVolume *crys_logical = new G4LogicalVolume( crys, matCrystal, G4String(sName), 0, 0, 0 );
2273 
2274  return theDetector;
2275 }
2276 */
2277 
2278 // it contains some usefull functions for the EUROBALL Part ... extracted from Doan's code
2279 #include "SToGS_EUROBALL.icc"
2280 
2281 G4VPhysicalVolume *SToGS::SemiConductorGeDF::MakeEURO_PI(G4String detname, G4String opt)
2282 {
2283  G4VPhysicalVolume *theDetector = 0x0; G4LogicalVolume *detlogicWorld; G4Box *detWorld;
2284  G4ThreeVector T;
2285 
2286  // use a physical as a container to describe the detector
2287  detWorld= new G4Box(detname,10.*CLHEP::cm,10.*CLHEP::cm,1.*CLHEP::m);
2288  detlogicWorld= new G4LogicalVolume(detWorld, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("AIR"), detname, 0, 0, 0);
2289 
2290  detlogicWorld->SetVisAttributes(G4VisAttributes::Invisible); // hide the world
2291  theDetector = new G4PVPlacement(0, // no rotation
2292  G4ThreeVector(), // at (0,0,0)
2293  detlogicWorld, // its logical volume
2294  detname, // its name
2295  0, // its mother volume
2296  false, // no boolean operations
2297  -1); // copy number
2298 
2299 
2300  G4LogicalVolume *theCrystal = GetEUROBALL_TCrystal_LV();
2301  G4VisAttributes *visatt1 = new G4VisAttributes( G4Colour(0.0, 1.0, 0.0, 1) );
2302  visatt1->SetVisibility(true);
2303  theCrystal->SetVisAttributes( visatt1 );
2304  theCrystal->SetSensitiveDetector( SToGS::UserActionInitialization::GetCopClusterSD() );
2305 
2306  G4LogicalVolume *theBGO = GetEUROBALL_TBGO_LV();
2307  G4VisAttributes *visatt2 = new G4VisAttributes( G4Colour(135./255, 233./255, 144./255, 0.8) );
2308  visatt2->SetVisibility(true);
2309  theBGO->SetVisAttributes( visatt2 );
2310  theBGO->SetSensitiveDetector( SToGS::UserActionInitialization::GetCopClusterSD() );
2311 
2312  // crystal
2313  T.setX( 0.0 );
2314  T.setY( 0.0 );
2315  T.setZ( 0.0 );
2316  new G4PVPlacement(0,T,theCrystal,"Crystal",detlogicWorld,false,0);
2317 
2318  T.setX( 0.0 );
2319  T.setY( 0.0 );
2320  T.setZ( -37.5*CLHEP::mm );
2321  new G4PVPlacement(0,T,theBGO,"Shield",detlogicWorld,false,1);
2322 
2323  if ( opt.contains("colli") ) {
2324 
2325  G4LogicalVolume *theCollimator = GetEUROBALL_TCOLLIMATOR_LV();
2326  G4VisAttributes *visatt3 = new G4VisAttributes( G4Colour(239./255, 220./255, 18./255, 1) );
2327  visatt3->SetVisibility(true);
2328  theCollimator->SetVisAttributes( visatt3 );
2329 
2330  T.setX( 0.0 );
2331  T.setY( 0.0 );
2332  T.setZ( -74.5*CLHEP::mm );
2333  new G4PVPlacement(0,T,theCollimator,"Collimator",detlogicWorld,false,-1);
2334  }
2335  if ( !opt.contains("bare") ) {
2336  // here are the different encapsulations
2337  G4VisAttributes *visatt4 = new G4VisAttributes( G4Colour(0.75, 0.75, 0.75, 0.7) );
2338  visatt4->SetVisibility(true);
2339 
2340  G4LogicalVolume *theHousing1 = GetEUROBALL_TCAPSULECRYS_LV();
2341  theHousing1->SetVisAttributes( visatt4 );
2342  T.setZ( 0.5*CLHEP::mm );
2343  new G4PVPlacement(0,T,theHousing1,"TCAPS",detlogicWorld,false,-1);
2344 
2345  G4LogicalVolume *theHousing2 = GetEUROBALL_TCAPSULEINNERBGO_LV();
2346  theHousing2->SetVisAttributes( visatt4 );
2347  new G4PVPlacement(0,T,theHousing2,"TBGOCAPSINNER",detlogicWorld,false,-1);
2348 
2349  G4LogicalVolume *theHousing3 = GetEUROBALL_TCAPSULEOUTERBGO_LV();
2350  theHousing3->SetVisAttributes( visatt4 );
2351  T.setZ( -39.5*CLHEP::mm );
2352  new G4PVPlacement(0,T,theHousing3,"TBGOCAPSOUTER",detlogicWorld,false,-1);
2353 
2354  G4LogicalVolume *theHousing4 = GetEUROBALL_TCAPSULEBACK_LV();
2355  theHousing4->SetVisAttributes( visatt4 );
2356  T.setZ( 0.5*CLHEP::mm );
2357  new G4PVPlacement(0,T,theHousing4,"TCAPSBACK",detlogicWorld,false,-1);
2358  }
2359 
2360  return theDetector;
2361 }
2362 
2363 G4VPhysicalVolume *SToGS::SemiConductorGeDF::MakeEURO_PII(G4String detname, G4String opt)
2364 {
2365  G4VPhysicalVolume *theDetector = 0x0; G4LogicalVolume *detlogicWorld; G4Box *detWorld;
2366  G4ThreeVector T;
2367  G4RotationMatrix Ra, Rb, Rc, Rd, RBGO;
2368 
2369  // use a physical as a container to describe the detector
2370  detWorld= new G4Box(detname,20.*CLHEP::cm,20.*CLHEP::cm,1.*CLHEP::m);
2371  detlogicWorld= new G4LogicalVolume(detWorld, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("AIR"), detname, 0, 0, 0);
2372 
2373  detlogicWorld->SetVisAttributes(G4VisAttributes::Invisible); // hide the world
2374  theDetector = new G4PVPlacement(0, // no rotation
2375  G4ThreeVector(), // at (0,0,0)
2376  detlogicWorld, // its logical volume
2377  detname, // its name
2378  0, // its mother volume
2379  false, // no boolean operations
2380  -1); // copy number
2381 
2382 
2383  G4LogicalVolume *theCrystal = GetEUROBALL_QCrystal_LV();
2384  G4VisAttributes *visatt1 = new G4VisAttributes( G4Colour(0.0, 0.0, 1.0, 1) );
2385  visatt1->SetVisibility(true);
2386  theCrystal->SetVisAttributes( visatt1 );
2387  theCrystal->SetSensitiveDetector( SToGS::UserActionInitialization::GetCopClusterSD() );
2388 
2389  // crystal a
2390  G4double crystal_offset = ClovCrystalRadiusOut-ClovCrystalCutOffset+ClovCrystalAdjacent/2;
2391  // Ra.rotateZ(0.0);
2392  new G4PVPlacement(G4Transform3D(Ra,Ra(G4ThreeVector(crystal_offset,crystal_offset,0.))),
2393  theCrystal,"a",detlogicWorld,false,0);
2394  Rb.rotateZ(-90*CLHEP::deg);
2395  new G4PVPlacement(G4Transform3D(Rb,Rb(G4ThreeVector(crystal_offset,crystal_offset,0.))),
2396  theCrystal,"b",detlogicWorld,false,1);
2397  Rc.rotateZ(-180*CLHEP::deg);
2398  new G4PVPlacement(G4Transform3D(Rc,Rc(G4ThreeVector(crystal_offset,crystal_offset,0.))),
2399  theCrystal,"c",detlogicWorld,false,2);
2400  Rd.rotateZ(-270*CLHEP::deg);
2401  new G4PVPlacement(G4Transform3D(Rd,Rd(G4ThreeVector(crystal_offset,crystal_offset,0.))),
2402  theCrystal,"d",detlogicWorld,false,3);
2403 
2404  //BGO
2405  G4LogicalVolume *theBGO = GetEUROBALL_QBGO_LV();
2406  G4VisAttributes *visatt2 = new G4VisAttributes( G4Colour(72./255, 61./255, 139./255, 0.8) );
2407  visatt2->SetVisibility(true);
2408  theBGO->SetVisAttributes( visatt2 );
2409  theBGO->SetSensitiveDetector( SToGS::UserActionInitialization::GetCopClusterSD() );
2410  T.setX( 0.0 );
2411  T.setY( 0.0 );
2412  T.setZ( -49.5*CLHEP::mm );
2413  RBGO.rotateZ(45.0*CLHEP::deg);
2414  new G4PVPlacement(G4Transform3D(RBGO,RBGO(T)),theBGO,"Shield",detlogicWorld,false,4);
2415 
2416  if ( opt.contains("colli") ) {
2417 
2418  G4LogicalVolume *theCollimator = GetEUROBALL_QCOLLIMATOR_LV();
2419  G4VisAttributes *visatt3 = new G4VisAttributes( G4Colour(239./255, 220./255, 18./255, 1) );
2420  visatt3->SetVisibility(true);
2421  theCollimator->SetVisAttributes( visatt3 );
2422 
2423  T.setX( 0.0 );
2424  T.setY( 0.0 );
2425  T.setZ( -91.5*CLHEP::mm );
2426  new G4PVPlacement(G4Transform3D(RBGO,RBGO(T)),theCollimator,"Collimator",detlogicWorld,false,-1);
2427  }
2428 
2429  if ( !opt.contains("bare") ) {
2430  // here are the different encapsulations
2431  G4VisAttributes *visatt4 = new G4VisAttributes( G4Colour(0.75, 0.75, 0.75, 0.7) );
2432  visatt4->SetVisibility(true);
2433 
2434  G4LogicalVolume *theHousing0 = GetEUROBALL_QGECAN_LV();
2435  theHousing0->SetVisAttributes( visatt4 );
2436  T.setZ( -21.4*CLHEP::mm );
2437  new G4PVPlacement(G4Transform3D(RBGO,RBGO(T)),theHousing0,"GeCan",detlogicWorld,false,-1);
2438 
2439  G4LogicalVolume *theHousing1 = GetEUROBALL_QBGOCAN_LV();
2440  theHousing1->SetVisAttributes( visatt4 );
2441  T.setZ( -52.4*CLHEP::mm );
2442  new G4PVPlacement(G4Transform3D(RBGO,RBGO(T)),theHousing1,"ShieldCanIn",detlogicWorld,false,-1);
2443 
2444  G4LogicalVolume *theHousing2 = GetEUROBALL_QBGOCANOUT_LV();
2445  theHousing2->SetVisAttributes( visatt4 );
2446  T.setZ( -51.9*CLHEP::mm );
2447  new G4PVPlacement(G4Transform3D(RBGO,RBGO(T)),theHousing2,"ShieldCanOut",detlogicWorld,false,-1);
2448  }
2449 
2450 
2451  return theDetector;
2452 }
2453 
2454 G4VPhysicalVolume *SToGS::SemiConductorGeDF::MakeEURO_PIII(G4String detname, G4String opt)
2455 {
2456  G4VPhysicalVolume *theDetector = 0x0; G4LogicalVolume *detlogicWorld; G4Box *detWorld;
2457  G4ThreeVector T;
2458  G4RotationMatrix Ra, Rb, Rc, Rd, Re, Rf, Rg;
2459 
2460  // use a physical as a container to describe the detector
2461  detWorld= new G4Box(detname,10.*CLHEP::cm,10.*CLHEP::cm,2.*CLHEP::m);
2462  detlogicWorld= new G4LogicalVolume(detWorld, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("AIR"), detname, 0, 0, 0);
2463 
2464  detlogicWorld->SetVisAttributes(G4VisAttributes::Invisible); // hide the world
2465  theDetector = new G4PVPlacement(0, // no rotation
2466  G4ThreeVector(), // at (0,0,0)
2467  detlogicWorld, // its logical volume
2468  detname, // its name
2469  0, // its mother volume
2470  false, // no boolean operations
2471  -1); // copy number
2472 
2473 
2474  G4LogicalVolume *theCrystal = GetEUROBALL_CCrystal_LV();
2475  G4VisAttributes *visatt1 = new G4VisAttributes( G4Colour(220./255, 20./255, 60./255, 1) );
2476  visatt1->SetVisibility(true);
2477  theCrystal->SetVisAttributes( visatt1 );
2478  theCrystal->SetSensitiveDetector( SToGS::UserActionInitialization::GetCopClusterSD() );
2479 
2480  // AngleClus2Clus angles calculated from EUROBALL clusters @ 44.5 cm from the target so that Ge are separated by 3mm
2481  // crystal
2482  Ra.rotateX(-AngleClus2Clus);
2483  // Ra.rotateZ(0.0*CLHEP::deg);
2484  T = Ra(G4ThreeVector(0,0,445.)) - G4ThreeVector(0,0,445.);
2485  new G4PVPlacement(G4Transform3D(Ra,T),
2486  theCrystal,"a",detlogicWorld,false,0);
2487  Rb.rotateX(-AngleClus2Clus);
2488  Rb.rotateZ(60.0*CLHEP::deg);
2489  T = Rb(G4ThreeVector(0,0,445.)) - G4ThreeVector(0,0,445.);
2490  new G4PVPlacement(G4Transform3D(Rb,T),
2491  theCrystal,"b",detlogicWorld,false,1);
2492  Rc.rotateX(-AngleClus2Clus);
2493  Rc.rotateZ(120.0*CLHEP::deg);
2494  T = Rc(G4ThreeVector(0,0,445.)) - G4ThreeVector(0,0,445.);
2495  new G4PVPlacement(G4Transform3D(Rc,T),
2496  theCrystal,"c",detlogicWorld,false,2);
2497  Rd.rotateX(-AngleClus2Clus);
2498  Rd.rotateZ(180.0*CLHEP::deg);
2499  T = Rd(G4ThreeVector(0,0,445.)) - G4ThreeVector(0,0,445.);
2500  new G4PVPlacement(G4Transform3D(Rd,T),
2501  theCrystal,"d",detlogicWorld,false,3);
2502  Re.rotateX(-AngleClus2Clus);
2503  Re.rotateZ(240.0*CLHEP::deg);
2504  T = Re(G4ThreeVector(0,0,445.)) - G4ThreeVector(0,0,445.);
2505  new G4PVPlacement(G4Transform3D(Re,T),
2506  theCrystal,"e",detlogicWorld,false,4);
2507  Rf.rotateX(-AngleClus2Clus);
2508  Rf.rotateZ(300.0*CLHEP::deg);
2509  T = Rf(G4ThreeVector(0,0,445.)) - G4ThreeVector(0,0,445.);
2510  new G4PVPlacement(G4Transform3D(Rf,T),
2511  theCrystal,"f",detlogicWorld,false,5);
2512  // g central one
2513  new G4PVPlacement(G4Transform3D(Rg,Rg(G4ThreeVector(0,0,0.))),
2514  theCrystal,"g",detlogicWorld,false,6);
2515 
2516  G4LogicalVolume *theBGO = GetEUROBALL_CBGO_LV();
2517  G4VisAttributes *visatt2 = new G4VisAttributes( G4Colour(255./255, 127./255, 80./255, 0.8) );
2518  visatt2->SetVisibility(true);
2519  theBGO->SetVisAttributes( visatt2 );
2520  theBGO->SetSensitiveDetector( SToGS::UserActionInitialization::GetCopClusterSD() );
2521  T.setX( 0.0 );
2522  T.setY( 0.0 );
2523  T.setZ( -20.0*CLHEP::mm );
2524  new G4PVPlacement(0,T,theBGO,"Shield",detlogicWorld,false,7);
2525 
2526  /*
2527  G4LogicalVolume *theBGO2 = GetEUROBALL_CBGOBACK_LV();
2528  theBGO2->SetVisAttributes( visatt2 );
2529  T.setZ( 0.*CLHEP::mm );
2530  new G4PVPlacement(0,T,theBGO2,"Shield2",detlogicWorld,false,-1); */
2531 
2532  if ( opt.contains("colli") ) {
2533 
2534  G4LogicalVolume *theCollimator = GetEUROBALL_CCOLLIMATOR_LV();
2535  G4VisAttributes *visatt3 = new G4VisAttributes( G4Colour(239./255, 220./255, 18./255, 1) );
2536  visatt3->SetVisibility(true);
2537  theCollimator->SetVisAttributes( visatt3 );
2538 
2539  T.setX( 0.0 );
2540  T.setY( 0.0 );
2541  T.setZ( -55*CLHEP::mm );
2542  new G4PVPlacement(0,T,theCollimator,"Collimator",detlogicWorld,false,-1);
2543  }
2544 
2545  // if ( !opt.contains("bare") ) {
2546  /*
2547  // here are the different encapsulations
2548  G4VisAttributes *visatt4 = new G4VisAttributes( G4Colour(0.75, 0.75, 0.75, 0.7) );
2549  visatt4->SetVisibility(true);
2550 
2551  G4LogicalVolume *theHousing1 = GetEUROBALL_CGECAN_LV();
2552  theHousing1->SetVisAttributes( visatt4 );
2553  T.setZ( 0.*CLHEP::mm );
2554  new G4PVPlacement(0,T,theHousing1,"Caps",detlogicWorld,false,-1);
2555 
2556  G4LogicalVolume *theHousing2 = GetEUROBALL_CBACK1_LV();
2557  theHousing2->SetVisAttributes( visatt4 );
2558  new G4PVPlacement(0,T,theHousing2,"CBGOCAPSINNER",detlogicWorld,false,-1);
2559 
2560  G4LogicalVolume *theHousing3 = GetEUROBALL_CBACK2_LV();
2561  theHousing3->SetVisAttributes( visatt4 );
2562  T.setZ( 0*CLHEP::mm );
2563  new G4PVPlacement(0,T,theHousing3,"CBGOCAPSOUTER",detlogicWorld,false,-1);
2564 
2565  G4LogicalVolume *theHousing4 = GetEUROBALL_CCAPSOUT_LV();
2566  theHousing4->SetVisAttributes( visatt4 );
2567  T.setZ( 0.*CLHEP::mm );
2568  new G4PVPlacement(0,T,theHousing4,"TCAPSBACK",detlogicWorld,false,-1); */
2569 
2570  // }
2571 
2572 
2573  return theDetector;
2574 
2575 }
2576 
2577 G4VPhysicalVolume * SToGS::SemiConductorGeDF::Make(G4String name, G4String version_string)
2578 {
2579  G4VPhysicalVolume *theDetector = 0x0; G4String detname;
2580 
2581  if ( name == "EXOCLOVER" ) {
2582  detname = GetDetName("EXOCLOVER",version_string);
2583  theDetector =
2584  MakeEXOCLOVER(detname,version_string);
2585  }
2586 
2587  //
2588  /*
2589  if ( name == "EXOGAM" ) {
2590  detname = GetDetName("EXOGAM",version_string);
2591  theDetector =
2592  MakeEXO_CLOVER(detname,version_string);
2593  }
2594  */
2595  if ( name.contains("AGATA") ) {
2596  if ( name.contains("ARed") || name.contains("BGreen") || name.contains("CBlue") ) {
2597  // AGATA asymmetric Capsules
2598  detname = GetDetName(name,version_string);
2599  theDetector =
2600  MakeAGATACapsule(detname,version_string);
2601  }
2602  }
2603  if ( name == "ATC" ) { // ATC
2604  detname = GetDetName(name,version_string);
2605  theDetector =
2606  MakeAGATACluster(detname,version_string);
2607  }
2608  if ( name.contains("EURO-") ) { // Euroball
2609  if ( name.contains("EURO-PI") ) {
2610  detname = GetDetName(name,version_string);
2611  theDetector =
2612  MakeEURO_PI(detname,version_string);
2613  }
2614  if ( name.contains("EURO-PII") ) {
2615  detname = GetDetName(name,version_string);
2616  theDetector =
2617  MakeEURO_PII(detname,version_string);
2618  }
2619  if ( name.contains("EURO-PIII") ) {
2620  detname = GetDetName(name,version_string);
2621  theDetector =
2622  MakeEURO_PIII(detname,version_string);
2623  }
2624  }
2625 
2626  return theDetector;
2627 }
2628 
2629 
2631 {
2632  // EUROGAM/BALL related
2634  MakeInStore("EURO-PI","bare"); //only Ge crystal + BGO shield
2636  MakeInStore("EURO-PI",""); // Ge + BGO + encapsulation for Ge and BGO
2638  MakeInStore("EURO-PI","colli"); // adds a collimator, the euroball3 ones
2640  MakeInStore("EURO-PII","bare"); //only Ge crystal + BGO shield
2642  MakeInStore("EURO-PII",""); // Ge + BGO + encapsulation for Ge and BGO
2644  MakeInStore("EURO-PII","colli"); // adds a collimator, the euroball3 ones
2645 
2647  MakeInStore("EURO-PIII",""); // adds a collimator, the euroball3 ones
2649  MakeInStore("EURO-PIII","colli"); // adds a collimator, the euroball3 ones
2650 
2651  // EXOGAM
2653  MakeInStore("EXOCLOVER","A-bare-GANIL"); //only Ge crystal
2655  MakeInStore("EXOCLOVER","A-AC-GANIL");//with Aluminium Capsule
2656 
2657  /* // EXOGAM
2658  SToGS::DetectorFactory::SetGCopyNb(0);
2659  MakeInStore("EXOCLOVER","A-bare"); //only Ge crystal
2660 
2661  SToGS::DetectorFactory::SetGCopyNb(0);
2662  MakeInStore("EXOCLOVER","A-AC");//with Aluminium Capsule
2663  */
2664  // AGATA Capsult and Cluster. Full array in Array factory
2666  MakeInStore("AGATA-ARed","bare");
2668  MakeInStore("AGATA-BGreen","bare");
2670  MakeInStore("AGATA-CBlue","bare");
2672  MakeInStore("ATC","bare");
2674 
2676  MakeInStore("AGATA-ARed","");
2678  MakeInStore("AGATA-BGreen","");
2680  MakeInStore("AGATA-CBlue","");
2683  MakeInStore("ATC","");
2684 
2685 
2686 }
2687 
2688 
2689 
2690 
G4VPhysicalVolume * MakeAGATACapsule(G4String which_capsule, G4String opt, G4String geo_file="DetectorFactory/SemiConductors/Ge/Builders/agata_capsule.geo")
From asolid file provided by AGATA, get a capsule.
G4VPhysicalVolume * MakeEURO_PII(G4String detname, G4String opt="")
void Clean()
clear factory i.e. in memory collections of physicals and assemblies
Base classe to build all Ge like detectors.
static DetectorFactory * theMainFactory()
to get the main factory
virtual G4VPhysicalVolume * Make(G4String, G4String)
Should be implemented in any sub factory. It built (C++) a detector and return it.
static G4int SetGCopyNb(G4int val)
static G4VSensitiveDetector * GetCopClusterSD(G4String name="/SToGS/SD/CopCluster")
to get a general SToGS Calorimeter. In Multi-threading mode, return a new instance otherwise a global...
G4VSolid * AGATAShaper(G4Polycone *polycone, G4double *xfront, G4double *yfront, G4double *xback, G4double *yback, G4double zback, G4double added_dilatation=0.0)
virtual void MakeStore()
build the default store i.e. all the Ge detectors.
G4VPhysicalVolume * MakeEURO_PI(G4String detname, G4String opt="")
static G4VSensitiveDetector * GetTrackerSD(G4String name="/SToGS/SD/Tracker")
to get a general SToGS tracker. In Multi-threading mode, return a new instance otherwise a global one...
G4VPhysicalVolume * MakeAGATACluster(G4String detname, G4String opt, G4String geo_file="DetectorFactory/SemiConductors/Ge/Builders/agata_cluster.geo")
from acluster file, provided by AGATA, get a triple cluter
G4VPhysicalVolume * MakeEXOCLOVER(G4String detname, G4String opt="")
A EXOGAM Clover.
G4VPhysicalVolume * MakeEURO_PIII(G4String detname, G4String opt="")