]> git.uio.no Git - u/mrichter/AliRoot.git/blob - Flugg/examples/fluggEx/T36flugg/src/MyDetectorConstruction.cc
6fdadcaae38102115438c13ff062606fa8770792
[u/mrichter/AliRoot.git] / Flugg / examples / fluggEx / T36flugg / src / MyDetectorConstruction.cc
1 // $Id$
2 // Flugg tag $Name$
3
4 //
5 // MyDetectorConstruction.hh, 3/III/1998  -  Sara Vanini
6 // T36 calorimeter with parametric volumes insted of replicans
7 //
8 // 
9
10 //#include "T36EMCalorimeterSD.hh"
11 //#include "T36HADCalorimeterSD.hh"
12 #include "MyDetectorConstruction.hh"
13 //#include "T36ModuleParam.hh"
14 #include "T36LayerParam.hh"
15
16 #include "G4Material.hh"
17 #include "G4Box.hh"
18 #include "G4Tubs.hh"
19 #include "G4LogicalVolume.hh"
20 #include "G4PVPlacement.hh"
21 #include "G4PVReplica.hh"
22 #include "G4PVParameterised.hh"
23 #include "G4VPVParameterisation.hh"
24 //#include "G4SDManager.hh"
25 //#include "G4RunManager.hh"
26 #include "G4UniformMagField.hh"
27 #include "G4FieldManager.hh"
28 #include "G4TransportationManager.hh"
29 #include "G4VisAttributes.hh"
30 #include "G4Colour.hh"
31 #include "G4ios.hh"
32
33
34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
35
36
37 MyDetectorConstruction::MyDetectorConstruction()
38 :solidWorld(NULL),logicWorld(NULL),physiWorld(NULL),
39  solidCalor(NULL),logicCalor(NULL),physiCalor(NULL),
40  solidModule(NULL),logicModule(NULL),physiModule(NULL),
41  EMsolidModule(NULL),EMlogicModule(NULL),EMphysiModule(NULL),
42  HADsolidModule(NULL),HADlogicModule(NULL),HADphysiModule(NULL),
43  solidFrontVac(NULL),logicFrontVac(NULL),physiFrontVac(NULL),
44
45  solidEMWLS(NULL),logicEMWLS(NULL),solidHADWLS(NULL),logicHADWLS(NULL),
46  solidAl(NULL),logicAl(NULL),physiAl(NULL),
47  solidSpace(NULL),logicSpace(NULL),physiSpace(NULL),
48  EMsolidLayer(NULL),EMlogicLayer(NULL),EMphysiLayer(NULL),
49  HADsolidLayer(NULL),HADlogicLayer(NULL),HADphysiLayer(NULL),
50
51  EMsolidAbsorber(NULL),EMlogicAbsorber(NULL),EMphysiAbsorber(NULL),
52  HADsolidAbsorber(NULL),HADlogicAbsorber(NULL),HADphysiAbsorber(NULL),
53  lastHADsolidAbsorber(NULL),lastHADlogicAbsorber(NULL),lastHADphysiAbsorber(NULL),
54  lastHADphysiAbMedShield(NULL),lastHADphysiAbExShield(NULL),
55  EMsolidAbMedShield(NULL),EMlogicAbMedShield(NULL),EMphysiAbMedShield(NULL),
56  EMsolidAbExShield(NULL),EMlogicAbExShield(NULL),EMphysiAbExShield(NULL),
57  HADsolidAbMedShield(NULL),HADlogicAbMedShield(NULL),HADphysiAbMedShield(NULL),
58  HADsolidAbExShield(NULL),HADlogicAbExShield(NULL),HADphysiAbExShield(NULL),
59
60
61  EMsolidGap(NULL),EMlogicGap(NULL),EMphysiGap(NULL),
62  HADsolidGap(NULL),HADlogicGap(NULL),HADphysiGap(NULL),
63  EMsolidSc(NULL),EMlogicSc(NULL),EMphysiSc(NULL),
64  HADsolidSc(NULL),HADlogicSc(NULL),HADphysiSc(NULL),
65  AbsorberMaterial(NULL),GapMaterial(NULL),ScMaterial(NULL),WLSMaterial(NULL),
66  RodMaterial(NULL),defaultMaterial(NULL),SpacerMaterial(NULL),
67  frontPlateMaterial(NULL),MedAbsMaterial(NULL),ExAbsMaterial(NULL),
68  EMsolidRod(NULL),HADsolidRod(NULL),EMlogicRod(NULL),HADlogicRod(NULL),
69  EMsolidSpacer(NULL),HADsolidSpacer(NULL),EMlogicSpacer(NULL),HADlogicSpacer(NULL)
70
71 {
72   WorldSizeX = 4000*mm; 
73   WorldSizeY = 4000*mm;
74   WorldSizeZ = 4000*mm;    
75
76   // default parameter values of the calorimeter
77   // EMWLSSizeX       = 1103.5*mm; //copre tutta la torre
78   EMWLSSizeZ       = 5*mm;    
79   // HADWLSSizeX      = 887.5*mm;  //come input fluka: dal layer 17 per tutta la torre
80   HADWLSSizeZ      = 3.5*mm;  
81   ScSizeY          = 218*mm;
82   ScThickness      = 2.5*mm;
83   RodRad           = 1*mm;
84   AlSizeX          = 20*mm;
85   SpaSizeX         = 1*mm;
86   EMModuleSizeZ    = 218*mm;
87   HADModuleSizeZ   = 211*mm;
88   SpacerThickness  = 3.5*mm;
89   SpacerSizeY      = 21*mm;
90
91
92   AbsorberThickness = 10.*mm;
93   AbMedShieldThickness = 8.*mm;
94   AbExShieldThickness = 1.*mm;
95   GapThickness      = 3.5*mm;
96   NbOfEMLayers      = 16;
97   NbOfHADLayers     = 65;
98   EMModuleSizeZ     = 218*mm;
99   HADModuleSizeZ     = 211*mm;
100
101   ModuleSizeY       = 700*mm;
102   NbOfModules       = 3;
103 }
104
105
106 MyDetectorConstruction::~MyDetectorConstruction()
107 {}
108
109
110 G4VPhysicalVolume* MyDetectorConstruction::Construct()
111 {
112   DefineMaterials();
113   return ConstructCalorimeter();
114 }
115
116
117 void MyDetectorConstruction::DefineMaterials()
118
119  //This function illustrates the possible ways to define materials
120  
121 G4String name, symbol;             //a=mass of a mole;
122 G4double a, z, density;            //z=mean number of protons;  
123 G4int iz, n;                       //iz=number of protons  in an isotope; 
124                                    // n=number of nucleons in an isotope;
125
126 G4int ncomponents, natoms;
127 G4double abundance, fractionmass;
128 G4double temperature, pressure;
129
130 //
131 // define Elements
132 //
133
134 a = 1.0079*g/mole;
135 G4Element* H  = new G4Element(name="Hydrogen",symbol="H" , z= 1., a);
136
137 a = 12.01*g/mole;
138 G4Element* C  = new G4Element(name="Carbon"  ,symbol="C" , z= 6., a);
139
140 a = 14.007*g/mole;
141 G4Element* N  = new G4Element(name="Nitrogen",symbol="N" , z= 7., a);
142
143 a = 15.999*g/mole;
144 G4Element* O  = new G4Element(name="Oxygen"  ,symbol="O" , z= 8., a);
145
146 a = 39.948*g/mole;
147 G4Element* Ar  = new G4Element(name="Argon"  ,symbol="Ar" , z= 18., a);
148
149 a = 207.19*g/mole;
150 G4Element* Pb  = new G4Element(name="Lead"  ,symbol="Pb" , z= 82., a);
151
152 a = 121.75*g/mole;
153 G4Element* Sb  = new G4Element(name="Antimony"  ,symbol="Sb" , z= 51., a);
154
155
156 //
157 // define simple materials
158 //
159
160 density     = universe_mean_density;    //from PhysicalConstants.h
161 pressure    = 3.e-18*pascal;
162 temperature = 2.73*kelvin;
163 G4Material* vacuum = new G4Material(name="Galactic", z=1., a=1.01*g/mole, density,
164                    kStateGas,temperature,pressure);
165
166 density = 2.700*g/cm3;
167 a = 26.982*g/mole;
168 G4Material* Al = new G4Material(name="Aluminium", z=13., a, density);
169
170 // il numero di atomi e` stato normalizzato al numero di atomi della molecola!
171 // posso usare la formula chimica minimale, quindi moltiplicare per un 
172 // fattore comune fino ad ottenere interi.
173
174 density = 1.170*g/cm3;
175 G4Material* WLSMat = new G4Material(name="PMMAWLS", density, ncomponents=3);
176 WLSMat->AddElement(H, natoms=100);
177 WLSMat->AddElement(C, natoms=57);
178 WLSMat->AddElement(O, natoms=57);
179
180 //N.B. le frazioni di massa sono state normalizzate ad 1 rispetto all`input di fluka!
181 density = 11.3*g/cm3;
182 G4Material* ExLead = new G4Material(name="LeadSB", density, ncomponents=2);
183 ExLead->AddElement(Pb, fractionmass=0.96);
184 ExLead->AddElement(Sb, fractionmass=0.04);
185
186 density = 11.3*g/cm3;
187 G4Material* MedLead = new G4Material(name="LeadSB0", density, ncomponents=2);  
188 MedLead->AddElement(Pb, fractionmass=0.96);
189 MedLead->AddElement(Sb, fractionmass=0.04);
190
191 density = 0.001225*g/cm3;
192 G4Material* Air = new G4Material(name="Air", density, ncomponents=3);
193 Air->AddElement(N, fractionmass=0.7555795);
194 Air->AddElement(O, fractionmass=0.23158806);
195 Air->AddElement(Ar, fractionmass=0.012832444);
196
197 density = 1.044*g/cm3;
198 G4Material* SciMat = new G4Material(name="SCSN38", density, ncomponents=2);
199 SciMat->AddElement(H, natoms=1);
200 SciMat->AddElement(C, natoms=1);
201
202
203 //G4cout << *(G4Material::GetMaterialTable()) << endl;
204
205   //default materials of the calorimeter
206   GapMaterial      = Air;
207   defaultMaterial  = Air;
208   SpacerMaterial   = Al;
209   RodMaterial      = SciMat;
210   ScMaterial       = SciMat;
211
212   WLSMaterial          = WLSMat;
213   frontPlateMaterial   = Al;
214   MedAbsMaterial      = MedLead;
215   ExAbsMaterial       = ExLead;
216 }
217
218
219
220   
221 G4VPhysicalVolume* MyDetectorConstruction::ConstructCalorimeter()
222 {
223   // complete the Calor parameters definition 
224   ComputeCalorParameters();
225    
226   //     
227   // World
228   //
229   solidWorld = new G4Box("World",                               //its name
230                    WorldSizeX/2,WorldSizeY/2,WorldSizeZ/2);     //its size
231                          
232   logicWorld = new G4LogicalVolume(solidWorld,          //its solid
233                                    defaultMaterial,     //vacuum
234                                    "World");            //its name
235                                    
236   physiWorld = new G4PVPlacement(0,                     //no rotation
237                                  G4ThreeVector(),       //at (0,0,0)
238                                  "World",               //its name
239                                  logicWorld,            //its logical volume
240                                  NULL,                  //its mother  volume
241                                  false,                 //no boolean operation
242                                  0);                    //copy number
243   
244   //                               
245   // Calorimeter
246   //
247       solidCalor = new G4Box("Calorimeter",             //its name
248                        ModuleSizeX/2,ModuleSizeY/2,CalorSizeZ/2);//size
249                              
250       logicCalor = new G4LogicalVolume(solidCalor,      //its solid
251                                        defaultMaterial, //its material
252                                        "Calorimeter");  //its name
253                                        
254       physiCalor = new G4PVPlacement(0,                 //no rotation
255       G4ThreeVector(ModuleSizeX/2-AlSizeX-SpaSizeX,0.,0.),
256                                      "Calorimeter",     //its name
257                                      logicCalor,        //its logical volume
258                                      physiWorld,        //its mother  volume
259                                      false,             //no boolean operation
260                                      0);                //copy number
261   //                               
262   // Module
263   //
264       solidModule = new G4Box("Module",         //its name
265                        ModuleSizeX/2,ModuleSizeY/2,ModuleSizeZ/2);//size
266                              
267       logicModule = new G4LogicalVolume(solidModule,            //its solid
268                                        defaultMaterial,         //its material
269                                        "Module");               //its name
270
271
272   for(int iMod=0;iMod<NbOfModules;iMod++)
273     {
274      new G4PVPlacement(0,
275                        G4ThreeVector(0.,0.,
276                        -ModuleSizeZ/2*(NbOfModules-1)+iMod*ModuleSizeZ),
277                        "Module",
278                        logicModule,
279                        physiCalor,
280                        false,
281                        iMod);
282     }
283
284
285   //
286   // EMWLS
287   //
288       solidEMWLS = new G4Box("EMWLS",           //its name
289                        EMWLSSizeX/2,ModuleSizeY/2,EMWLSSizeZ/2);//size
290                              
291       logicEMWLS = new G4LogicalVolume(solidEMWLS,              //its solid
292                                        WLSMaterial,             //its material
293                                        "EMWLS");                //its name
294       //right and left side of module
295       for(int t=0; t<2; t++)
296         {
297           int b=2*t-1;
298           new G4PVPlacement(0,                  //no rotation
299           G4ThreeVector(-ModuleSizeX/2+EMWLSSizeX/2+AlSizeX+SpaSizeX,
300                         0.,b*(-ModuleSizeZ/2+EMWLSSizeZ/2)),    //
301                                      logicEMWLS,        //its logical volume 
302                                      "EMWLS",           //its name
303                                      logicModule,       //its mother  volume
304                                      false,             //no boolean operation
305                                      t);                //copy number
306         }
307                                                                     
308   //
309   // HADWLS
310   //
311       solidHADWLS = new G4Box("HADWLS",         //its name
312                        HADWLSSizeX/2,ModuleSizeY/2,HADWLSSizeZ/2);//size
313                              
314       logicHADWLS = new G4LogicalVolume(solidHADWLS,            //its solid
315                                        WLSMaterial,             //its material
316                                        "HADWLS");               //its name
317       //left and right side of module
318       for(int u=0; u<2; u++)
319         {
320           int c=2*u-1;
321           new G4PVPlacement(0,                  //no rotation
322           G4ThreeVector(ModuleSizeX/2-HADWLSSizeX/2,
323                         0.,c*(ModuleSizeZ/2-EMWLSSizeZ-HADWLSSizeZ/2)),
324                                      logicHADWLS,       //its logical volume
325                                      "HADWLS",          //its name
326                                      logicModule,       //its mother  volume
327                                      false,             //no boolean operation
328                                      u);                //copy number
329         }               
330                                                            
331   
332   //
333   // Al front plate
334   //
335       solidAl = new G4Box("AlFrontPlate",               //its name
336                        AlSizeX/2,ModuleSizeY/2,ModuleSizeZ/2);//size
337                              
338       logicAl = new G4LogicalVolume(solidAl,            //its solid
339                                     frontPlateMaterial,                 //its material
340                                     "AlFrontPlate");            //its name
341                                        
342       physiAl = new G4PVPlacement(0,                    //no rotation
343                 G4ThreeVector(-ModuleSizeX/2+AlSizeX/2,0.,0.),  
344                                      logicAl,           //its logical volume
345                                      "AlFrontPlate",            //its name
346                                      logicModule,       //its mother  volume
347                                      false,             //no boolean operation
348                                      0);                //copy number
349                                         
350   //
351   // front space with vacuum 
352   //
353       solidSpace = new G4Box("VacFrontSpace",           //its name
354                        SpaSizeX/2,ModuleSizeY/2,ModuleSizeZ/2);//size
355                              
356       logicSpace = new G4LogicalVolume(solidSpace,              //its solid
357                                        defaultMaterial,            //its material
358                                     "VacFrontSpace");           //its name
359                                        
360       physiSpace = new G4PVPlacement(0,                 //no rotation
361                 G4ThreeVector(-ModuleSizeX/2+AlSizeX+SpaSizeX/2,0.,0.),
362                                      logicSpace,                //its logical vo
363                                      "VacFrontSpace",           //its name
364                                      logicModule,       //its mother  volume
365                                      false,             //no boolean operation
366                                      0);                //copy number
367   
368
369
370
371
372   // *******************************                              
373   // ********    EMModule    *******
374   // *******************************
375
376       EMsolidModule = new G4Box("EMModule",             //its name
377                        EMModuleThickness/2,ModuleSizeY/2,EMModuleSizeZ/2);//size
378                              
379       EMlogicModule = new G4LogicalVolume(EMsolidModule,        //its solid
380                                        defaultMaterial,         //its material
381                                        "EMModule");             //its name
382                                        
383       EMphysiModule = new G4PVPlacement(0,              //no rotation
384       G4ThreeVector(-ModuleSizeX/2+AlSizeX+SpaSizeX+EMModuleThickness/2,
385                     0.,0.), 
386                                      EMlogicModule,     //its logical volume
387                                      "EMModule",        //its name
388                                      logicModule,       //its mother  volume
389                                      false,             //no boolean operation
390                                      0);                //copy number
391   //                                 
392   // EMLayer
393   //
394       EMsolidLayer = new G4Box("EMLayer",                       //its name
395                        LayerThickness/2,ModuleSizeY/2,EMModuleSizeZ/2); //size
396                        
397       EMlogicLayer = new G4LogicalVolume(EMsolidLayer,          //its solid
398                                        defaultMaterial,         //its material
399                                        "EMLayer");              //its name
400       
401       G4VPVParameterisation * EMLayersParam = 
402                      new T36LayerParam(LayerThickness,NbOfEMLayers);
403
404       EMphysiLayer = new G4PVParameterised("EMLayer",     //its name
405                                    EMlogicLayer,          //its logical volume
406                                    EMphysiModule,         //its mother
407                                    kXAxis,                //axis of param
408                                    NbOfEMLayers,          //number of param
409                                    EMLayersParam);        //param
410
411   //                               
412   // Pb EMAbsorber
413   //
414       EMsolidAbsorber = new G4Box("EMAbsorber",         //its name
415                           AbsorberThickness/2,ModuleSizeY/2,EMModuleSizeZ/2); 
416                           
417       EMlogicAbsorber = new G4LogicalVolume(EMsolidAbsorber,    //its solid
418                                           defaultMaterial,     //its material
419                                           "EMAbsorber");        //its name
420                                           
421       EMphysiAbsorber = new G4PVPlacement(0,                 //no rotation
422                     G4ThreeVector(-GapThickness/2,0.,0.),    //its position
423                                         "EMAbsorber",        //its name
424                                         EMlogicAbsorber,     //its logical volume
425                                         EMphysiLayer,        //its mother
426                                         false,               //no boulean operat
427                                         0);                  //copy number
428
429   //                               
430   // Pb EMAbsorber Medium Shield
431   //
432       EMsolidAbMedShield = new G4Box("EMAbMedShield",           //its name
433                           AbMedShieldThickness/2,ModuleSizeY/2,EMModuleSizeZ/2); 
434                           
435       EMlogicAbMedShield = new G4LogicalVolume(EMsolidAbMedShield,    //its solid
436                                           MedAbsMaterial,                    //its material
437                                           "EMAbMedShield");           //its name
438                                           
439       EMphysiAbMedShield = new G4PVPlacement(0,              //no rotation
440                                         G4ThreeVector(0.,0.,0.),    //its position
441                                         "EMAbMedShield",        //its name
442                                         EMlogicAbMedShield,     //its logical volume
443                                         EMphysiAbsorber,        //its mother
444                                         false,               //no boulean operat
445                                         0);                  //copy number
446
447   //                               
448   // 2 Pb EMAbsorber External Shields
449   //
450       EMsolidAbExShield = new G4Box("EMAbExShield",             //its name
451                           AbExShieldThickness/2,ModuleSizeY/2,EMModuleSizeZ/2); 
452                           
453       EMlogicAbExShield = new G4LogicalVolume(EMsolidAbExShield,    //its solid
454                                           ExAbsMaterial,                   //its material
455                                           "EMAbExShield");          //its name
456                                                                       
457                                          
458       for(int s=0; s<2; s++)
459         {
460          EMphysiAbExShield = new G4PVPlacement(0,                    //no rotation
461          G4ThreeVector((2*s-1)*(AbsorberThickness/2-AbExShieldThickness/2),0.,0.),    //its position
462                                         "EMAbExShield",        //its name
463                                         EMlogicAbExShield,     //its logical volume
464                                         EMphysiAbsorber,        //its mother
465                                         false,               //no boulean operat
466                                         s);                  //copy number
467                                                                  
468         }
469
470   
471   //                                 
472   // EMGap
473   //
474       EMsolidGap = new G4Box("EMGap",
475                            GapThickness/2,ModuleSizeY/2,EMModuleSizeZ/2);
476                            
477       EMlogicGap = new G4LogicalVolume(EMsolidGap,
478                                      GapMaterial,
479                                      "EMGap");
480                                      
481       EMphysiGap = new G4PVPlacement(0,                      //no rotation
482                G4ThreeVector(AbsorberThickness/2,0.,0.),     //its position
483                                    "EMGap",                  //its name
484                                    EMlogicGap,               //its logical volume
485                                    EMphysiLayer,             //its mother
486                                    false,                    //no boulean operat
487                                    0);                       //copy number
488    
489
490   //
491   // 3 EMScPlates
492   //
493       EMsolidSc = new G4Box("EMSc",
494                            ScThickness/2,ScSizeY/2,EMModuleSizeZ/2);
495                            
496       EMlogicSc = new G4LogicalVolume(EMsolidSc,
497                                      ScMaterial,
498                                      "EMSc");
499                                      
500
501       for(int i=0; i<+3; i++)
502         {
503           EMphysiSc = new G4PVPlacement(0,                   //no rotation
504             G4ThreeVector(0.,(i-1)*(ScSizeY+2*RodRad),0.),   //its position
505                                    "EMSc",                   //its name
506                                    EMlogicSc,                //its logical volume
507                                    EMphysiGap,               //its mother
508                                    false,                    //no boulean operat
509                                    i);
510         }  
511
512
513   //
514   // EMRod                                              
515   //
516       EMsolidRod = new G4Tubs("EMRod",
517                            0.,RodRad,EMModuleSizeZ/2,0*deg,360*deg);
518                            
519       EMlogicRod = new G4LogicalVolume(EMsolidRod,
520                                      RodMaterial,
521                                      "EMRod");
522                                      
523       for(int h=0; h<2; h++)
524         {
525           new G4PVPlacement(0,                                 //no rotation
526           G4ThreeVector(0.,(2*h-1)*(ScSizeY/2+RodRad),0.),     //its position
527                                    "EMRod",                    //its name
528                                    EMlogicRod,                 //its logical volume
529                                    EMphysiGap,                 //its mother
530                                    false,                      //no boulean operat
531                                    h);          
532         }
533
534   //
535   // EMSpacer
536   //
537       EMsolidSpacer = new G4Box("EMSpacer",
538                            SpacerThickness/2,SpacerSizeY/2,EMModuleSizeZ/2);
539                            
540       EMlogicSpacer = new G4LogicalVolume(EMsolidSpacer,
541                                      SpacerMaterial,
542                                      "EMSpacer");
543                 
544       for(int k=0; k<2; k++)
545         {
546           int v=2*k-1;
547           new G4PVPlacement(0,                       //no rotation
548           G4ThreeVector(0.,v*(3*ScSizeY/2+2*RodRad+SpacerSizeY/2),0.),   //its position
549                                    "EMSpacer",                   //its name
550                                    EMlogicSpacer,                //its logical volume
551                                    EMphysiGap,                   //its mother
552                                    false,                        //no boulean operat
553                                    k);
554         }
555
556
557
558   // *******************************                              
559   // ********    HADModule    *******
560   // *******************************
561
562       HADsolidModule = new G4Box("HADModule",           //its name
563                        HADModuleThickness/2,ModuleSizeY/2,HADModuleSizeZ/2);//size
564                              
565       HADlogicModule = new G4LogicalVolume(HADsolidModule,      //its solid
566                                        defaultMaterial,         //its material
567                                        "HADModule");            //its name
568                                        
569       HADphysiModule = new G4PVPlacement(0,                     //no rotation
570       G4ThreeVector(ModuleSizeX/2-HADModuleThickness/2-
571                     AbsorberThickness,0.,0.),   //at (0,0,0)
572                                      HADlogicModule,    //its logical volume
573                                      "HADModule",       //its name
574                                      logicModule,       //its mother  volume
575                                      false,             //no boolean operation
576                                      0);                //copy number
577   
578   //                                 
579   // HADLayer
580   //
581       HADsolidLayer = new G4Box("HADLayer",                     //its name
582                        LayerThickness/2,ModuleSizeY/2,HADModuleSizeZ/2); //size
583                        
584       HADlogicLayer = new G4LogicalVolume(HADsolidLayer,                //its solid
585                                        defaultMaterial,         //its material
586                                        "HADLayer");             //its name
587                                       
588       G4VPVParameterisation * HADLayersParam = 
589                      new T36LayerParam(LayerThickness,NbOfHADLayers);
590
591       HADphysiLayer = new G4PVParameterised("HADLayer",     //its name
592                                    HADlogicLayer,         //its logical volume
593                                    HADphysiModule,        //its mother
594                                    kXAxis,                //axis of param
595                                    NbOfHADLayers,         //number of param
596                                    HADLayersParam);        //param
597   //                               
598   // Pb HADAbsorber
599   //
600       HADsolidAbsorber = new G4Box("HADAbsorber",               //its name
601                           AbsorberThickness/2,ModuleSizeY/2,HADModuleSizeZ/2); 
602                           
603       HADlogicAbsorber = new G4LogicalVolume(HADsolidAbsorber,    //its solid
604                                           defaultMaterial,     //its material
605                                           "HADAbsorber");        //its name
606                                           
607       HADphysiAbsorber = new G4PVPlacement(0,                //no rotation
608                     G4ThreeVector(-GapThickness/2,0.,0.),    //its position
609                                         "HADAbsorber",        //its name
610                                         HADlogicAbsorber,     //its logical volume
611                                         HADphysiLayer,        //its mother
612                                         false,               //no boulean operat
613                                         0);                  //copy number
614
615
616   //                               
617   // Pb HADAbsorber Medium Shield
618   //
619       HADsolidAbMedShield = new G4Box("HADAbMedShield",         //its name
620                           AbMedShieldThickness/2,ModuleSizeY/2,HADModuleSizeZ/2); 
621                           
622       HADlogicAbMedShield = new G4LogicalVolume(HADsolidAbMedShield,    //its solid
623                                           MedAbsMaterial,                      //its material
624                                           "HADAbMedShield");            //its name
625                                           
626       HADphysiAbMedShield = new G4PVPlacement(0,                     //no rotation
627                                         G4ThreeVector(0.,0.,0.),    //its position
628                                         "HADAbMedShield",        //its name
629                                         HADlogicAbMedShield,     //its logical volume
630                                         HADphysiAbsorber,        //its mother
631                                         false,               //no boulean operat
632                                         0);                  //copy number
633
634   //                               
635   // 2 Pb HADAbsorber External Shields
636   //
637       HADsolidAbExShield = new G4Box("HADAbExShield",           //its name
638                           AbExShieldThickness/2,ModuleSizeY/2,HADModuleSizeZ/2); 
639                           
640       HADlogicAbExShield = new G4LogicalVolume(HADsolidAbExShield,    //its solid
641                                           ExAbsMaterial,             //its material
642                                           "HADAbExShield");           //its name
643                                          
644       for(int hs=0; hs<2; hs++)
645         {
646          HADphysiAbExShield = new G4PVPlacement(0,                   //no rotation
647          G4ThreeVector((2*hs-1)*(AbsorberThickness/2-AbExShieldThickness/2),0.,0.),    //its position
648                                         "HADAbExShield",        //its name
649                                         HADlogicAbExShield,     //its logical volume
650                                         HADphysiAbsorber,        //its mother
651                                         false,               //no boulean operat
652                                         hs);                  //copy number
653                                                                  
654         }
655
656   //                               
657   // last Pb HADAbsorber
658   //
659
660
661        lastHADsolidAbsorber = new G4Box("lastHADAbsorber",             //its name
662                            AbsorberThickness/2,ModuleSizeY/2,HADModuleSizeZ/2);
663
664        lastHADlogicAbsorber = new G4LogicalVolume(lastHADsolidAbsorber,    //its solid
665                            defaultMaterial,                                //its material
666                            "lastHADAbsorber");                             //its name
667
668        lastHADphysiAbsorber = new G4PVPlacement(0,                   //no rotation
669                     G4ThreeVector(ModuleSizeX/2-AbsorberThickness/2,0.,0.),    //its position
670                                         lastHADlogicAbsorber,     //its logical volume
671                                         "lastHADAbsorber",        //its name
672                                         logicModule,        //its mother
673                                         false,               //no boulean operat
674                                         0);                  //copy number
675               
676   //                               
677   // last Pb HADAbsorber Medium Shield
678   //
679       lastHADphysiAbMedShield = new G4PVPlacement(0,                 //no rotation
680                                         G4ThreeVector(0.,0.,0.),    //its position
681                                         "lastHADAbMedShield",        //its name
682                                         HADlogicAbMedShield,     //its logical volume
683                                         lastHADphysiAbsorber,        //its mother
684                                         false,               //no boulean operat
685                                         0);                  //copy number
686
687   //                               
688   // 2 last Pb HADAbsorber External Shields
689   //
690       for(int ls=0; ls<2; ls++)
691         {
692          lastHADphysiAbMedShield = new G4PVPlacement(0,              //no rotation
693          G4ThreeVector((2*ls-1)*(AbsorberThickness/2-AbExShieldThickness/2),0.,0.),    //its position
694                                         "lastHADAbExShield",        //its name
695                                         HADlogicAbExShield,     //its logical volume
696                                         lastHADphysiAbsorber,        //its mother
697                                         false,               //no boulean operat
698                                         s);                  //copy number
699                                                                  
700         }                                              
701   
702
703   //                                 
704   // HADGap
705   //
706       HADsolidGap = new G4Box("HADGap",
707                            GapThickness/2,ModuleSizeY/2,HADModuleSizeZ/2);
708                            
709       HADlogicGap = new G4LogicalVolume(HADsolidGap,
710                                      GapMaterial,
711                                      "HADGap");
712                                      
713       HADphysiGap = new G4PVPlacement(0,                      //no rotation
714                G4ThreeVector(AbsorberThickness/2,0.,0.),     //its position
715                                    "HADGap",                  //its name
716                                    HADlogicGap,               //its logical volume
717                                    HADphysiLayer,             //its mother
718                                    false,                    //no boulean operat
719                                    0);                       //copy number
720    
721
722   //
723   // 3 HADScPlates
724   //
725       HADsolidSc = new G4Box("HADSc",
726                            ScThickness/2,ScSizeY/2,HADModuleSizeZ/2);
727                            
728       HADlogicSc = new G4LogicalVolume(HADsolidSc,
729                                      ScMaterial,
730                                      "HADSc");
731                                      
732
733       for(int m=0; m<+3; m++)
734         {
735           HADphysiSc = new G4PVPlacement(0,                  //no rotation
736             G4ThreeVector(0.,(m-1)*(ScSizeY+2*RodRad),0.),   //its position
737                                    "HADSc",                   //its name
738                                    HADlogicSc,                //its logical volume
739                                    HADphysiGap,               //its mother
740                                    false,                    //no boulean operat
741                                    m);
742         }  
743
744
745   //
746   // HADRod                                             
747   //
748       HADsolidRod = new G4Tubs("HADRod",
749                            0.,RodRad,HADModuleSizeZ/2,0*deg,360*deg);
750                            
751       HADlogicRod = new G4LogicalVolume(HADsolidRod,
752                                      RodMaterial,
753                                      "HADRod");
754                                      
755       for(int q=0; q<2; q++)
756         {
757           new G4PVPlacement(0,                                 //no rotation
758           G4ThreeVector(0.,(2*q-1)*(ScSizeY/2+RodRad),0.),     //its position
759                                    "HADRod",                    //its name
760                                    HADlogicRod,                 //its logical volume
761                                    HADphysiGap,                 //its mother
762                                    false,                      //no boulean operat
763                                    q);          
764         }
765
766   //
767   // HADSpacer
768   //
769       HADsolidSpacer = new G4Box("HADSpacer",
770                            SpacerThickness/2,SpacerSizeY/2,HADModuleSizeZ/2);
771                            
772       HADlogicSpacer = new G4LogicalVolume(HADsolidSpacer,
773                                      SpacerMaterial,
774                                      "HADSpacer");
775                 
776       for(int z=0; z<2; z++)
777         {
778           int y=2*z-1;
779           new G4PVPlacement(0,                       //no rotation
780           G4ThreeVector(0.,y*(3*ScSizeY/2+2*RodRad+SpacerSizeY/2),0.),   //its position
781                                    "HADSpacer",                   //its name
782                                    HADlogicSpacer,                //its logical volume
783                                    HADphysiGap,                   //its mother
784                                    false,                        //no boulean operat
785                                    z);
786         }
787       /*
788   //
789   // Sensitive EM and HAD Detectors: Absorber and Gap
790   //
791   G4SDManager* SDman = G4SDManager::GetSDMpointer();
792   SDman->SetVerboseLevel(1);
793
794   //for N02: N.B. non basta dichiarare la "madre" volume sensibile, bisogna 
795   // dichiarare anche ogni figlio!!!
796
797   if(!EMcalorimeterSD)
798   {
799     G4String EMcaloSDname = "/mydet/EMcalorimeter";
800     EMcalorimeterSD = new T36EMCalorimeterSD(EMcaloSDname,this);
801     SDman->AddNewDetector( EMcalorimeterSD );
802   }
803
804   if (EMlogicAbsorber)
805       EMlogicAbsorber->SetSensitiveDetector(EMcalorimeterSD);
806   if (EMlogicAbExShield)
807       EMlogicAbExShield->SetSensitiveDetector(EMcalorimeterSD);
808   if (EMlogicAbMedShield)
809       EMlogicAbMedShield->SetSensitiveDetector(EMcalorimeterSD);
810
811   if (EMlogicGap)
812       EMlogicGap->SetSensitiveDetector(EMcalorimeterSD);
813   if (EMlogicSc)
814       EMlogicSc->SetSensitiveDetector(EMcalorimeterSD);
815   if (EMlogicRod)
816        EMlogicRod->SetSensitiveDetector(EMcalorimeterSD);
817   if (EMlogicSpacer)
818        EMlogicSpacer->SetSensitiveDetector(EMcalorimeterSD);
819
820   if(!HADcalorimeterSD)
821   {
822     G4String HADcaloSDname = "/mydet/HADcalorimeter";
823     HADcalorimeterSD = new T36HADCalorimeterSD(HADcaloSDname,this);
824     SDman->AddNewDetector( HADcalorimeterSD );
825   }
826
827   if (HADlogicAbsorber)
828       HADlogicAbsorber->SetSensitiveDetector(HADcalorimeterSD);
829   if (HADlogicAbExShield)
830       HADlogicAbExShield->SetSensitiveDetector(HADcalorimeterSD);
831   if (HADlogicAbMedShield)
832       HADlogicAbMedShield->SetSensitiveDetector(HADcalorimeterSD);
833
834   if (HADlogicGap)
835       HADlogicGap->SetSensitiveDetector(HADcalorimeterSD);
836   if (HADlogicSc)
837       HADlogicSc->SetSensitiveDetector(HADcalorimeterSD);
838   if (HADlogicRod)
839        HADlogicRod->SetSensitiveDetector(HADcalorimeterSD);
840   if (HADlogicSpacer)
841        HADlogicSpacer->SetSensitiveDetector(HADcalorimeterSD);
842       
843   if (lastHADlogicAbsorber)
844       lastHADlogicAbsorber->SetSensitiveDetector(HADcalorimeterSD);
845       */
846
847   /*
848
849   //                                        
850   // Visualization attributes
851   //
852                                                                  
853   logicWorld->SetVisAttributes (G4VisAttributes::Invisible);
854   G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
855   simpleBoxVisAtt->SetVisibility(true);
856   logicCalor->SetVisAttributes(simpleBoxVisAtt);
857   
858   */
859   //
860   //always return the physical World
861   //
862   return physiWorld;
863 }
864
865 void MyDetectorConstruction::PrintCalorParameters()
866 {
867   G4cout << "\n The calorimeter is made of " << NbOfEMLayers << "EM layers and "
868        << NbOfHADLayers << "HAD layers of: [ "
869        << AbsorberThickness/mm << "mm of " << MedAbsMaterial->GetName()
870        << " + "
871        << GapThickness/mm << "mm of " << GapMaterial->GetName() << " ] "
872        << endl;
873 }
874
875 void MyDetectorConstruction::SetMagField(G4double fieldValue)
876 {
877   //apply a global uniform magnetic field along Z axis
878   G4FieldManager* fieldMgr
879    = G4TransportationManager::GetTransportationManager()->GetFieldManager();
880
881   if(magField) delete magField;         //delete the existing magn field
882   
883   if(fieldValue!=0.)                    // create a new one if non nul
884   { magField = new G4UniformMagField(G4ThreeVector(0.,0.,fieldValue));        
885     fieldMgr->SetDetectorField(magField);
886     fieldMgr->CreateChordFinder(magField);
887   } else {
888     magField = NULL;
889     fieldMgr->SetDetectorField(magField);
890   }
891 }
892
893   
894
895