CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
ExtBesEmcConstruction.cxx
Go to the documentation of this file.
1#include "TrkExtAlg/ExtBesEmcConstruction.h"
2
3#include "G4ThreeVector.hh"
4#include "G4PVPlacement.hh"
5#include "G4LogicalVolume.hh"
6#include "G4VPhysicalVolume.hh"
7
8//For code construction --------------------
9#include "G4ReflectionFactory.hh"
10
11//#include "BesEmcConstruction.hh"
12//#include "BesEmcDetectorMessenger.hh"
13#include "TrkExtAlg/ExtBesEmcGeometry.h"
14#include "TrkExtAlg/ExtBesCrystalParameterisation.h"
15#include "TrkExtAlg/ExtBesEmcEndGeometry.h"
16//#include "ReadBoostRoot.hh"
17
18//#include "BesEmcSD.hh"
19#include "G4IrregBox.hh"
20#include "G4Box.hh"
21#include "G4Transform3D.hh"
22#include "G4Tubs.hh"
23#include "G4Cons.hh"
24#include "G4Trap.hh"
25#include "G4UnionSolid.hh"
26#include "G4SubtractionSolid.hh"
27#include "G4Polyhedra.hh"
28//#include "G4LogicalVolume.hh"
29//#include "G4VPhysicalVolume.hh"
30#include "G4Material.hh"
31//#include "G4PVPlacement.hh"
32#include "G4PVParameterised.hh"
33#include "G4PVReplica.hh"
34#include "globals.hh"
35#include "G4UniformMagField.hh"
36#include "G4FieldManager.hh"
37#include "G4TransportationManager.hh"
38#include "G4SDManager.hh"
39#include "G4RunManager.hh"
40#include "G4VisAttributes.hh"
41#include "G4Color.hh"
42
43#include "G4ios.hh"
44//--------------------------------------------
45#include "G4Geo/EmcG4Geo.h"
46
47
48ExtBesEmcConstruction* ExtBesEmcConstruction::fBesEmcConstruction=0;
49
51 :verboseLevel(0),
52 solidEMC(0),logicEMC(0),physiEMC(0),
53 solidBSCPhi(0),logicBSCPhi(0),physiBSCPhi(0),
54 solidBSCTheta(0),logicBSCTheta(0),physiBSCTheta(0),
55 solidBSCCrystal(0),logicBSCCrystal(0),physiBSCCrystal(0),
56 magField(0),detectorMessenger(0),
57 besEMCSD(0),crystalParam(0)
58{
59 if(!fBesEmcConstruction) fBesEmcConstruction=this;
60
61 startID = 1;
62 phiNbCrystals = 0;
63 thetaNbCrystals = 0;
64 besEMCGeometry = new ExtBesEmcGeometry();
65 emcEnd = new ExtBesEmcEndGeometry();
66}
67
69{
70 if(crystalParam) delete crystalParam;
71 if(besEMCGeometry) delete besEMCGeometry;
72 if(emcEnd) delete emcEnd;
73}
74
75void ExtBesEmcConstruction::Construct(G4LogicalVolume* logicBes)
76{
77 /*
78 G4String GeometryPath = getenv("SIMUTILROOT");
79 GeometryPath+="/dat/Emc.gdml";
80
81 m_config.SetURI(GeometryPath);
82 m_config.SetSetupName( "Emc" );
83 m_config.SetSetupVersion( "1.0" );
84 m_config.SetType( "G4" );
85 m_sxp.Configure(&m_config);
86 m_sxp.Initialize();
87
88 //construct Emc
89 m_sxp.Run();
90
91 logicalEmc = FindLogicalVolume("logicalEmc");
92 physicalEmc = new G4PVPlacement(0,G4ThreeVector(0.0 ,0.0 ,0.0),logicalEmc, "BSC",logicBes, false, 0);
93
94 m_sxp.Finalize();
95 */
96
97//new version of geometry construction from gdml
98 logicEMC = EmcG4Geo::Instance()->GetTopVolume();
99 if(logicEMC) physiEMC = new G4PVPlacement(0,G4ThreeVector(0.0 ,0.0 ,0.0),logicEMC, "physicalEMC",logicBes, false, 0);
100
101
102//geometry construction by code
103/*
104 besEMCGeometry->ComputeEMCParameters();
105 emcEnd->ComputeParameters();
106 DefineMaterials();
107 phiNbCrystals = (*besEMCGeometry).BSCNbPhi;
108 thetaNbCrystals = (*besEMCGeometry).BSCNbTheta*2;
109 //
110 //BSC
111 //
112 //G4cout << "Acquired " << G4Material::GetMaterial("Air") << G4endl;
113
114 solidBSC = new G4Tubs("BSC",
115 (*besEMCGeometry).TaperRingRmin1,
116 (*besEMCGeometry).BSCRmax+(*besEMCGeometry).SPBarThickness+(*besEMCGeometry).SPBarThickness1,
117 (*besEMCGeometry).BSCDz+(*besEMCGeometry).TaperRingThickness3+(*besEMCGeometry).EndRingDz,
118 0.*deg,
119 360.*deg);
120
121 solidESC = new G4Tubs("ESC",(*emcEnd).WorldRmin2,(*emcEnd).WorldRmax2,(*emcEnd).WorldDz/2,0.*deg,360.*deg);
122
123 solidEMC = new G4UnionSolid("EMC",
124 solidBSC,
125 solidESC,
126 0,
127 G4ThreeVector(0,0,(*emcEnd).WorldZPosition));
128
129 solidEMC = new G4UnionSolid("EMC",
130 solidEMC,
131 solidESC,
132 0,
133 G4ThreeVector(0,0,-(*emcEnd).WorldZPosition));
134
135 logicEMC = new G4LogicalVolume(solidEMC,
136 G4Material::GetMaterial("Air"),
137 "EMC");
138
139 physiEMC = new G4PVPlacement(0,
140 0,
141 logicEMC,
142 "EMC",
143 logicBes,
144 false,
145 0);
146
147 // G4RotationMatrix *rotateMatrixBSC;
148 // rotateMatrixBSC = new G4RotationMatrix();
149 // G4ThreeVector newAxisX=G4ThreeVector(1.,0,0);
150 // G4ThreeVector newAxisY=G4ThreeVector(0,-1.,0);
151 // G4ThreeVector newAxisZ=G4ThreeVector(0,0,-1.);
152 // rotateMatrixBSC->rotateAxes(newAxisX,newAxisY,newAxisZ);
153 // rotateMatrixBSC->rotateX(180.*deg);
154 // physiBSC = new G4PVPlacement(rotateMatrixBSC,
155 // G4ThreeVector(0,0,-BSCDz/2.),
156 // "BSC",
157 // logicBSC,
158 // logicEMC,
159 // false,
160 // 1);
161 //
162 // Phi Cell
163 solidBSCPhiTub = new G4Tubs(
164 "BSCPhiTub",
165 (*besEMCGeometry).BSCRmin,
166 (*besEMCGeometry).BSCPhiRmax,
167 (*besEMCGeometry).BSCDz,
168 360.*deg-(*besEMCGeometry).BSCPhiDphi,
169 (*besEMCGeometry).BSCPhiDphi);
170 solidConsPhi = new G4Cons("consPhi",
171 (*besEMCGeometry).BSCRmin1,
172 (*besEMCGeometry).BSCRmax1,
173 (*besEMCGeometry).BSCRmin2,
174 (*besEMCGeometry).BSCRmax2,
175 (*besEMCGeometry).BSCDz1/2,
176 0.*deg,
177 360.*deg);
178 solidBSCPhi1 = new G4SubtractionSolid("BSCPhi1",
179 solidBSCPhiTub,
180 solidConsPhi,
181 0,
182 G4ThreeVector(0,0,(*besEMCGeometry).BSCDz-(*besEMCGeometry).BSCDz1/2));
183 solidConsPhi = new G4Cons("consPhi",
184 (*besEMCGeometry).BSCRmin2,
185 (*besEMCGeometry).BSCRmax2,
186 (*besEMCGeometry).BSCRmin1,
187 (*besEMCGeometry).BSCRmax1,
188 (*besEMCGeometry).BSCDz1/2,
189 0.*deg,
190 360.*deg);
191 solidBSCPhi = new G4SubtractionSolid("BSCPhi",
192 solidBSCPhi1,
193 solidConsPhi,
194 0,
195 G4ThreeVector(0,0,(*besEMCGeometry).BSCDz1/2-(*besEMCGeometry).BSCDz));
196
197 logicBSCPhi = new G4LogicalVolume(solidBSCPhi,
198 G4Material::GetMaterial("Air"),
199 "BSCPhi");
200
201 //new geometry by Fu Chengdong
202 G4RotationMatrix *rotateMatrix[200];
203 G4double oOp,ox,oy,oz;
204 G4int i;
205 G4double delta = 0*deg;
206 G4ThreeVector axis = G4ThreeVector(0,0,0);
207 oOp=(*besEMCGeometry).BSCRmin/sin(0.5*(*besEMCGeometry).BSCPhiDphi+90*deg)
208 *sin((*besEMCGeometry).BSCAngleRotat);
209 G4double ll=(*besEMCGeometry).BSCCryLength;
210 G4double rr=(*besEMCGeometry).BSCRmin;
211 G4double oj=sqrt(ll*ll+rr*rr-2*ll*rr*cos(180.*deg-(*besEMCGeometry).BSCAngleRotat));
212 G4double oij=90.*deg-(*besEMCGeometry).BSCPhiDphi/2.-(*besEMCGeometry).BSCAngleRotat;
213 G4double doj=asin(sin(180.*deg-(*besEMCGeometry).BSCAngleRotat)/oj*ll);
214 G4double ioj=(*besEMCGeometry).BSCPhiDphi/2.+doj;
215 G4double ij=oj/sin(oij)*sin(ioj);
216 G4double dOp=rr/sin(90.*deg-(*besEMCGeometry).BSCPhiDphi/2.)
217 *sin(90.*deg+(*besEMCGeometry).BSCPhiDphi/2.-(*besEMCGeometry).BSCAngleRotat);
218 G4double cOp=rr/sin(90.*deg+(*besEMCGeometry).BSCPhiDphi/2.)
219 *sin(90.*deg-(*besEMCGeometry).BSCPhiDphi/2.-(*besEMCGeometry).BSCAngleRotat);
220 G4double ch=(dOp+ll)/cos((*besEMCGeometry).BSCPhiDphi)-cOp;
221 G4double hi=(dOp+ll)*tan((*besEMCGeometry).BSCPhiDphi)-ij;
222 G4double oh=sqrt(ch*ch+rr*rr-2*ch*rr*cos(180*deg-(*besEMCGeometry).BSCAngleRotat));
223 G4double hoi=asin(sin(180*deg-oij)/oh*hi);
224 G4double dok=asin(sin(180*deg-(*besEMCGeometry).BSCAngleRotat)/oh*ch);
225
226 i=1;
227 for(i=1;i<=(*besEMCGeometry).BSCNbPhi;i++)
228 {
229 rotateMatrix[i-1] = new G4RotationMatrix();
230 rotateMatrix[i-1]->rotateZ(-(i-1)*(*besEMCGeometry).BSCPhiDphi
231 -(*besEMCGeometry).BSCAngleRotat
232 -(*besEMCGeometry).BSCPhiDphi/2.
233 -hoi);
234 rotateMatrix[i-1]->getAngleAxis(delta, axis);
235 //G4cout << "The axis of crystals in the world system is: "
236 // << delta/deg << "(deg)(delta) "
237 //<< axis << "(Z axis)"<< G4endl;
238 ox=oOp*cos(-90.*deg+(*besEMCGeometry).BSCAngleRotat
239 +(i-1)*(*besEMCGeometry).BSCPhiDphi);
240 oy=oOp*sin(-90.*deg+(*besEMCGeometry).BSCAngleRotat
241 +(i-1)*(*besEMCGeometry).BSCPhiDphi);
242 oz=0*cm;
243 physiBSCPhi = new G4PVPlacement(rotateMatrix[i-1],
244 G4ThreeVector(ox,oy,oz),
245 logicBSCPhi,
246 "BSCPhi",
247 logicEMC,
248 false,
249 i-1);
250 }
251*/
252 /*
253 G4RotationMatrix *rotateMatrix[200];
254 // rotateMatrix = new G4RotationMatrix();
255 // rotateMatrix->rotateZ(BSCAngleRotat-BSCPhiDphi);
256 G4double oOp,ox,oy,oz;
257 G4int i;
258 G4double delta = 0*deg;
259 G4ThreeVector axis = G4ThreeVector(0,0,0);
260 oOp=(*besEMCGeometry).BSCRmin/sin(0.5*(*besEMCGeometry).BSCPhiDphi+90*deg)
261 *sin((*besEMCGeometry).BSCAngleRotat);
262 i=1;
263 for(i=1;i<=(*besEMCGeometry).BSCNbPhi;i++)
264 {
265 rotateMatrix[i-1] = new G4RotationMatrix();
266 rotateMatrix[i-1]->rotateZ(-(i-1)*(*besEMCGeometry).BSCPhiDphi
267 +(*besEMCGeometry).BSCAngleRotat
268 +(*besEMCGeometry).BSCPhiDphi/2.);
269 rotateMatrix[i-1]->getAngleAxis(delta, axis);
270 //G4cout << "The axis of crystals in the world system is: "
271 // << delta/deg << "(deg)(delta) "
272 //<< axis << "(Z axis)"<< G4endl;
273 ox=oOp*cos(90.*deg-(*besEMCGeometry).BSCAngleRotat
274 +(i-1)*(*besEMCGeometry).BSCPhiDphi);
275 oy=oOp*sin(90.*deg-(*besEMCGeometry).BSCAngleRotat
276 +(i-1)*(*besEMCGeometry).BSCPhiDphi);
277 oz=0*cm;
278 physiBSCPhi = new G4PVPlacement(rotateMatrix[i-1],
279 G4ThreeVector(ox,oy,oz),
280 logicBSCPhi,
281 "BSCPhi",
282 logicEMC,
283 false,
284 i);
285 //G4cout << G4ThreeVector(ox/cm,oy/cm,oz/cm) <<"(cm)" << G4endl
286 // << (-(*besEMCGeometry).BSCAngleRotat+(i-1)*(*besEMCGeometry).BSCPhiDphi)/deg <<"(degree)" << G4endl;
287 }*/
288 //
289 //Crystals
290 //
291/* G4double zHalfLength[50];
292 G4double thetaAxis[50];
293 G4double phiAxis[50];
294 G4double yHalfLength1[50];
295 G4double xHalfLength2[50];
296 G4double xHalfLength1[50];
297 G4double tanAlpha1[50];
298 G4double yHalfLength2[50];
299 G4double xHalfLength4[50];
300 G4double xHalfLength3[50];
301 G4double tanAlpha2[50];
302 G4double xPosition[50];
303 G4double yPosition[50];
304 G4double zPosition[50];
305 G4double thetaPosition[50];
306 for(i=0;i<(*besEMCGeometry).BSCNbTheta;i++)
307 {
308 zHalfLength[i] = (*besEMCGeometry).zHalfLength[i];
309 thetaAxis[i] = (*besEMCGeometry).thetaAxis[i];
310 phiAxis[i] = (*besEMCGeometry).phiAxis[i];
311 yHalfLength1[i] = (*besEMCGeometry).yHalfLength1[i];
312 xHalfLength2[i] = (*besEMCGeometry).xHalfLength2[i];
313 xHalfLength1[i] = (*besEMCGeometry).xHalfLength1[i];
314 tanAlpha1[i] = (*besEMCGeometry).tanAlpha1[i];
315 yHalfLength2[i] = (*besEMCGeometry).yHalfLength2[i];
316 xHalfLength4[i] = (*besEMCGeometry).xHalfLength4[i];
317 xHalfLength3[i] = (*besEMCGeometry).xHalfLength3[i];
318 tanAlpha2[i] = (*besEMCGeometry).tanAlpha2[i];
319 xPosition[i] = (*besEMCGeometry).xPosition[i];
320 yPosition[i] = (*besEMCGeometry).yPosition[i];
321 zPosition[i] = (*besEMCGeometry).zPosition[i];
322 thetaPosition[i]= (*besEMCGeometry).thetaPosition[i];
323 }
324
325 besEMCGeometry->ModifyForCasing();
326
327 solidBSCCrystal = new G4Trap("Crystal",
328 100*cm, 100*deg, 100*deg,
329 100*cm, 100*cm, 100*cm, 100*deg,
330 100*cm, 100*cm, 100*cm, 100*deg);
331
332 logicBSCCrystal = new G4LogicalVolume(solidBSCCrystal,
333 fCrystalMaterial,
334 "Crystal");
335
336 crystalParam = new ExtBesCrystalParameterisation
337 (startID,
338 thetaNbCrystals,
339 (*besEMCGeometry).BSCNbTheta*2,
340 besEMCGeometry,
341 verboseLevel);
342
343 //---------------------------------------------------------------------------------
344 //rear substance
345 solidRear = new G4Box("RearBox",
346 (*besEMCGeometry).rearBoxLength/2,
347 (*besEMCGeometry).rearBoxLength/2,
348 (*besEMCGeometry).rearBoxDz/2);
349
350 logicRear = new G4LogicalVolume(solidRear,
351 G4Material::GetMaterial("Air"),
352 "RearBox");
353
354 //organic glass
355 solidOrgGlass = new G4Box("OrganicGlass",
356 (*besEMCGeometry).orgGlassLengthX/2,
357 (*besEMCGeometry).orgGlassLengthY/2,
358 (*besEMCGeometry).orgGlassLengthZ/2);
359
360 logicOrgGlass = new G4LogicalVolume(solidOrgGlass,
361 organicGlass,
362 "OrganicGlass");
363
364 physiOrgGlass = new G4PVPlacement(0,
365 G4ThreeVector(0,0,-((*besEMCGeometry).rearBoxDz-(*besEMCGeometry).orgGlassLengthZ)/2),
366 logicOrgGlass,
367 "OrganicGlass",
368 logicRear,
369 false,
370 0);
371
372 //casing
373 solidCasingBox = new G4Box("CasingBox",
374 (*besEMCGeometry).rearBoxLength/2,
375 (*besEMCGeometry).rearBoxLength/2,
376 (*besEMCGeometry).rearCasingThickness/2);
377
378 solidAirHole = new G4Box("AirHole",
379 (*besEMCGeometry).orgGlassLengthX/2,
380 (*besEMCGeometry).orgGlassLengthY/2,
381 (*besEMCGeometry).rearBoxDz/2); //any value more than casing thickness
382
383 solidRearCasing = new G4SubtractionSolid("RearCasing",
384 solidCasingBox,
385 solidAirHole,
386 0,
387 0);
388
389 logicRearCasing = new G4LogicalVolume(solidRearCasing,
390 rearCasingMaterial,
391 "RearCasing");
392
393 physiRearCasing = new G4PVPlacement(0,
394 G4ThreeVector(0,0,-((*besEMCGeometry).rearBoxDz-(*besEMCGeometry).rearCasingThickness)/2),
395 logicRearCasing,
396 "RearCasing",
397 logicRear,
398 false,
399 0);
400
401 //Al Plate
402 solidAlBox = new G4Box("AlBox",
403 (*besEMCGeometry).rearBoxLength/2,
404 (*besEMCGeometry).rearBoxLength/2,
405 (*besEMCGeometry).AlPlateDz/2);
406
407 solidAlPlate = new G4SubtractionSolid("AlPlate",
408 solidAlBox,
409 solidAirHole,
410 0,
411 0);
412
413 logicAlPlate = new G4LogicalVolume(solidAlPlate,
414 G4Material::GetMaterial("Aluminium"),
415 "AlPlate");
416
417 physiAlPlate = new G4PVPlacement(0,
418 G4ThreeVector(0,0,-((*besEMCGeometry).rearBoxDz/2
419 -(*besEMCGeometry).rearCasingThickness
420 -(*besEMCGeometry).AlPlateDz/2)),
421 logicAlPlate,
422 "AlPlate",
423 logicRear,
424 false,
425 0);
426
427 //photodiode
428 solidPD = new G4Box("PD",
429 (*besEMCGeometry).PDLengthX, //two PD
430 (*besEMCGeometry).PDLengthY/2,
431 (*besEMCGeometry).PDLengthZ/2);
432
433 logicPD = new G4LogicalVolume(solidPD,
434 G4Material::GetMaterial("Silicon"),
435 "PD");
436
437 physiPD = new G4PVPlacement(0,
438 G4ThreeVector(0,0,-((*besEMCGeometry).rearBoxDz/2
439 -(*besEMCGeometry).orgGlassLengthZ
440 -(*besEMCGeometry).PDLengthZ/2)),
441 logicPD,
442 "PD",
443 logicRear,
444 false,
445 0);
446
447 //preamplifier box
448 solidPreAmpBox = new G4Box("PreAmpBox",
449 (*besEMCGeometry).rearBoxLength/2,
450 (*besEMCGeometry).rearBoxLength/2,
451 (*besEMCGeometry).PABoxDz/2);
452
453 logicPreAmpBox = new G4LogicalVolume(solidPreAmpBox,
454 G4Material::GetMaterial("Aluminium"),
455 "PreAmpBox");
456
457 physiPreAmpBox = new G4PVPlacement(0,
458 G4ThreeVector(0,0,-((*besEMCGeometry).rearBoxDz/2
459 -(*besEMCGeometry).rearCasingThickness
460 -(*besEMCGeometry).AlPlateDz
461 -(*besEMCGeometry).PABoxDz/2)),
462 logicPreAmpBox,
463 "PreAmpBox",
464 logicRear,
465 false,
466 0);
467
468 //air in preamplifier box
469 solidAirInPABox = new G4Box("AirInPABox",
470 (*besEMCGeometry).rearBoxLength/2-(*besEMCGeometry).PABoxThickness,
471 (*besEMCGeometry).rearBoxLength/2-(*besEMCGeometry).PABoxThickness,
472 (*besEMCGeometry).PABoxDz/2-(*besEMCGeometry).PABoxThickness);
473
474 logicAirInPABox = new G4LogicalVolume(solidAirInPABox,
475 G4Material::GetMaterial("Air"),
476 "AirInPABox");
477
478 physiAirInPABox = new G4PVPlacement(0,
479 0,
480 logicAirInPABox,
481 "AirInPABox",
482 logicPreAmpBox,
483 false,
484 0);
485
486 //stainless steel for hanging the crystal
487 solidHangingPlate = new G4Box("HangingPlate",
488 (*besEMCGeometry).rearBoxLength/2,
489 (*besEMCGeometry).rearBoxLength/2,
490 (*besEMCGeometry).HangingPlateDz/2);
491
492 logicHangingPlate = new G4LogicalVolume(solidHangingPlate,stainlessSteel,"HangingPlate");
493
494 physiHangingPlate = new G4PVPlacement(0,
495 G4ThreeVector(0,0,-((*besEMCGeometry).rearBoxDz/2
496 -(*besEMCGeometry).rearCasingThickness
497 -(*besEMCGeometry).AlPlateDz
498 -(*besEMCGeometry).PABoxDz
499 -(*besEMCGeometry).HangingPlateDz/2)),
500 logicHangingPlate,
501 "HangingPlate",
502 logicRear,
503 false,
504 0);
505
506 //water pipe
507 solidWaterPipe = new G4Tubs("WaterPipe",
508 0,
509 (*besEMCGeometry).waterPipeDr,
510 (*besEMCGeometry).BSCDz,
511 0.*deg,
512 360.*deg);
513
514 logicWaterPipe = new G4LogicalVolume(solidWaterPipe,stainlessSteel,"WaterPipe");
515
516 physiWaterPipe = new G4PVPlacement(0,
517 G4ThreeVector((*besEMCGeometry).cablePosX[0]-2*(*besEMCGeometry).cableDr,
518 (*besEMCGeometry).cablePosY[0]-(*besEMCGeometry).cableDr-(*besEMCGeometry).waterPipeDr,
519 0),
520 logicWaterPipe,
521 "WaterPipe",
522 logicBSCPhi,
523 false,
524 0);
525 //---------------------------------------------------------------------------------
526
527 //
528 //Theta Cell
529 //
530 G4String nameCrystalAndCasing="CrystalAndCasing";
531 G4int id=0; //ID of crystals after distinguishing left and right
532 for(i=startID;i<=thetaNbCrystals;i++)
533 {
534 if(i>(*besEMCGeometry).BSCNbTheta)
535 {
536 id=i-(*besEMCGeometry).BSCNbTheta-1;
537 solidBSCTheta = new G4Trap(nameCrystalAndCasing,
538 zHalfLength[id],
539 thetaAxis[id],
540 -phiAxis[id],
541 yHalfLength1[id],
542 xHalfLength2[id],
543 xHalfLength1[id],
544 -tanAlpha1[id],
545 yHalfLength2[id],
546 xHalfLength4[id],
547 xHalfLength3[id],
548 -tanAlpha2[id]);
549
550 logicBSCTheta = new G4LogicalVolume(solidBSCTheta,
551 fCasingMaterial,
552 nameCrystalAndCasing);
553
554 rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1] = new G4RotationMatrix();
555 rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1]->rotateZ(-90*deg);
556 rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1]
557 ->rotateX(-thetaPosition[id]);
558 physiBSCTheta =
559 new G4PVPlacement(rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1],
560 G4ThreeVector(xPosition[id],
561 yPosition[id],
562 zPosition[id]),
563 nameCrystalAndCasing,
564 logicBSCTheta,
565 physiBSCPhi,
566 false,
567 thetaNbCrystals-i);
568 if(logicBSCTheta)
569 logicBSCTheta->SetVisAttributes(G4VisAttributes::Invisible);
570
571 if(id<(*besEMCGeometry).BSCNbTheta-1)
572 {
573 physiRear = new G4PVPlacement(rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1],
574 G4ThreeVector((*besEMCGeometry).rearBoxPosX[id],
575 (*besEMCGeometry).rearBoxPosY[id],
576 (*besEMCGeometry).rearBoxPosZ[id]),
577 "RearBox",
578 logicRear,
579 physiBSCPhi,
580 false,
581 thetaNbCrystals-i);
582
583 solidOCGirder = new G4Cons("OpenningCutGirder",
584 (*besEMCGeometry).OCGirderRmin1[id],
585 (*besEMCGeometry).BSCPhiRmax,
586 (*besEMCGeometry).OCGirderRmin2[id],
587 (*besEMCGeometry).BSCPhiRmax,
588 (*besEMCGeometry).OCGirderDz[id]/2,
589 360.*deg-(*besEMCGeometry).OCGirderAngle/2,
590 (*besEMCGeometry).OCGirderAngle/2);
591
592 logicOCGirder = new G4LogicalVolume(solidOCGirder,stainlessSteel,"OpenningCutGirder");
593 //logicOCGirder->SetVisAttributes(G4VisAttributes::Invisible);
594
595 physiOCGirder = new G4PVPlacement(0,
596 G4ThreeVector(0,0,(*besEMCGeometry).OCGirderPosZ[id]),
597 logicOCGirder,
598 "OpenningCutGirder",
599 logicBSCPhi,
600 false,
601 0);
602
603 G4double zLength = (*besEMCGeometry).OCGirderPosZ[id+1]-(*besEMCGeometry).OCGirderPosZ[id]
604 -(*besEMCGeometry).OCGirderDz[id+1]/2-(*besEMCGeometry).OCGirderDz[id]/2;
605 G4double zPosition = (*besEMCGeometry).OCGirderPosZ[id+1]-(*besEMCGeometry).OCGirderDz[id+1]/2-zLength/2;
606
607 solidOCGirder = new G4Cons("OpenningCutGirder",
608 (*besEMCGeometry).OCGirderRmin2[id],
609 (*besEMCGeometry).BSCPhiRmax,
610 (*besEMCGeometry).OCGirderRmin1[id+1],
611 (*besEMCGeometry).BSCPhiRmax,
612 zLength/2,
613 360.*deg-(*besEMCGeometry).OCGirderAngle/2,
614 (*besEMCGeometry).OCGirderAngle/2);
615
616 logicOCGirder = new G4LogicalVolume(solidOCGirder,stainlessSteel,"OpenningCutGirder");
617 //logicOCGirder->SetVisAttributes(G4VisAttributes::Invisible);
618
619 physiOCGirder = new G4PVPlacement(0,
620 G4ThreeVector(0,0,zPosition),
621 logicOCGirder,
622 "OpenningCutGirder",
623 logicBSCPhi,
624 false,
625 0);
626 }
627
628 solidCable = new G4Tubs("BSCCable",
629 0,
630 (*besEMCGeometry).cableDr,
631 (*besEMCGeometry).cableLength[id]/2,
632 0.*deg,
633 360.*deg);
634
635 logicCable = new G4LogicalVolume(solidCable,cable,"BSCCable");
636
637 physiCable = new G4PVPlacement(0,
638 G4ThreeVector((*besEMCGeometry).cablePosX[id],
639 (*besEMCGeometry).cablePosY[id],
640 (*besEMCGeometry).cablePosZ[id]),
641 logicCable,
642 "BSCCable",
643 logicBSCPhi,
644 false,
645 0);
646 //logicCable->SetVisAttributes(G4VisAttributes::Invisible);
647
648 }
649 else
650 {
651 id=(*besEMCGeometry).BSCNbTheta-i;
652 solidBSCTheta = new G4Trap(nameCrystalAndCasing,
653 zHalfLength[id],
654 thetaAxis[id],
655 phiAxis[id],
656 yHalfLength1[id],
657 xHalfLength1[id],
658 xHalfLength2[id],
659 tanAlpha1[id],
660 yHalfLength2[id],
661 xHalfLength3[id],
662 xHalfLength4[id],
663 tanAlpha2[id]);
664
665 logicBSCTheta = new G4LogicalVolume(solidBSCTheta,
666 fCasingMaterial,
667 nameCrystalAndCasing);
668
669 rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1] = new G4RotationMatrix();
670 rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1]->rotateZ(-90*deg);
671 rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1]
672 ->rotateX(-180*deg+thetaPosition[id]);
673 physiBSCTheta =
674 new G4PVPlacement(rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1],
675 G4ThreeVector(xPosition[id],
676 yPosition[id],
677 -zPosition[id]),
678 nameCrystalAndCasing,
679 logicBSCTheta,
680 physiBSCPhi,
681 false,
682 thetaNbCrystals-i);
683 if(logicBSCTheta)
684 {
685 //G4VisAttributes* rightVisAtt= new G4VisAttributes(G4Colour(1.0,0.,0.));
686 //rightVisAtt->SetVisibility(true);
687 //logicBSCTheta->SetVisAttributes(rightVisAtt);
688 //logicBSCTheta->SetVisAttributes(G4VisAttributes::Invisible);
689 }
690
691 if(id<(*besEMCGeometry).BSCNbTheta-1)
692 {
693 physiRear = new G4PVPlacement(rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1],
694 G4ThreeVector((*besEMCGeometry).rearBoxPosX[id],
695 (*besEMCGeometry).rearBoxPosY[id],
696 -(*besEMCGeometry).rearBoxPosZ[id]),
697 "RearBox",
698 logicRear,
699 physiBSCPhi,
700 false,
701 thetaNbCrystals-i);
702
703 solidOCGirder = new G4Cons("OpenningCutGirder",
704 (*besEMCGeometry).OCGirderRmin2[id],
705 (*besEMCGeometry).BSCPhiRmax,
706 (*besEMCGeometry).OCGirderRmin1[id],
707 (*besEMCGeometry).BSCPhiRmax,
708 (*besEMCGeometry).OCGirderDz[id]/2,
709 360.*deg-(*besEMCGeometry).OCGirderAngle/2,
710 (*besEMCGeometry).OCGirderAngle/2);
711
712 logicOCGirder = new G4LogicalVolume(solidOCGirder,stainlessSteel,"OpenningCutGirder");
713 //logicOCGirder->SetVisAttributes(G4VisAttributes::Invisible);
714
715 physiOCGirder = new G4PVPlacement(0,
716 G4ThreeVector(0,0,-(*besEMCGeometry).OCGirderPosZ[id]),
717 logicOCGirder,
718 "OpenningCutGirder",
719 logicBSCPhi,
720 false,
721 0);
722
723 G4double zLength = (*besEMCGeometry).OCGirderPosZ[id+1]-(*besEMCGeometry).OCGirderPosZ[id]
724 -(*besEMCGeometry).OCGirderDz[id+1]/2-(*besEMCGeometry).OCGirderDz[id]/2;
725 G4double zPosition = (*besEMCGeometry).OCGirderPosZ[id+1]-(*besEMCGeometry).OCGirderDz[id+1]/2-zLength/2;
726
727 solidOCGirder = new G4Cons("OpenningCutGirder",
728 (*besEMCGeometry).OCGirderRmin1[id+1],
729 (*besEMCGeometry).BSCPhiRmax,
730 (*besEMCGeometry).OCGirderRmin2[id],
731 (*besEMCGeometry).BSCPhiRmax,
732 zLength/2,
733 360.*deg-(*besEMCGeometry).OCGirderAngle/2,
734 (*besEMCGeometry).OCGirderAngle/2);
735
736 logicOCGirder = new G4LogicalVolume(solidOCGirder,stainlessSteel,"OpenningCutGirder");
737 //logicOCGirder->SetVisAttributes(G4VisAttributes::Invisible);
738
739 physiOCGirder = new G4PVPlacement(0,
740 G4ThreeVector(0,0,-zPosition),
741 logicOCGirder,
742 "OpenningCutGirder",
743 logicBSCPhi,
744 false,
745 0);
746 }
747
748 solidCable = new G4Tubs("BSCCable",
749 0,
750 (*besEMCGeometry).cableDr,
751 (*besEMCGeometry).cableLength[id]/2,
752 0.*deg,
753 360.*deg);
754
755 logicCable = new G4LogicalVolume(solidCable,cable,"BSCCable");
756
757 physiCable = new G4PVPlacement(0,
758 G4ThreeVector((*besEMCGeometry).cablePosX[id],
759 (*besEMCGeometry).cablePosY[id],
760 -(*besEMCGeometry).cablePosZ[id]),
761 logicCable,
762 "BSCCable",
763 logicBSCPhi,
764 false,
765 0);
766 //logicCable->SetVisAttributes(G4VisAttributes::Invisible);
767 }
768
769 physiBSCCrystal = new G4PVParameterised(
770 "Crystal",
771 logicBSCCrystal,
772 physiBSCTheta,
773 kZAxis,
774 1,//for this method,it must be 1.
775 crystalParam);
776 (*besEMCGeometry).physiBSCCrystal[i]=physiBSCCrystal;
777 //G4cout << (*besEMCGeometry).physiBSCCrystal[i] << G4endl;
778 physiBSCCrystal->SetCopyNo(thetaNbCrystals-i);
779 if(verboseLevel>4)
780 G4cout << "BesEmcConstruction*****************************"<< G4endl
781 << "point of crystal =" <<physiBSCCrystal << G4endl
782 // << "point of mother =" <<physiBSCCrystal->GetMotherPhysical() << G4endl
783 << "point of excepted=" <<physiBSCTheta << G4endl;
784 //G4Exception("BesEMCConstruction::Construct() starting............");
785 }
786*/
787 //
788 // Sensitive Detectors: Absorber and Gap
789 //
790 //if (logicBSCCrystal)
791 // logicBSCCrystal->SetSensitiveDetector(besEMCSD);
792
793 //
794 // Visualization attributes
795 //
796 /* if(logicEMC)
797 {
798 G4VisAttributes* bscVisAtt= new G4VisAttributes(G4Colour(0.5,0.5,0.5));
799 bscVisAtt->SetVisibility(false);
800 logicEMC->SetVisAttributes(bscVisAtt);
801 //logicBSC->SetVisAttributes(G4VisAttributes::Invisible);
802 }
803 if(logicBSCPhi)
804 {
805 G4VisAttributes* rightVisAtt= new G4VisAttributes(G4Colour(1.0,0.,1.0));
806 rightVisAtt->SetVisibility(false);
807 logicBSCPhi->SetVisAttributes(rightVisAtt);
808 //logicBSCPhi->SetVisAttributes(G4VisAttributes::Invisible);
809 }
810 if(logicBSCCrystal)
811 {
812 G4VisAttributes* crystalVisAtt= new G4VisAttributes(G4Colour(0,0,1.0));
813 crystalVisAtt->SetVisibility(true);
814 logicBSCCrystal->SetVisAttributes(crystalVisAtt);
815 //logicBSCCrystal->SetVisAttributes(G4VisAttributes::Invisible);
816 }
817 if(logicOrgGlass)
818 {
819 G4VisAttributes* glassVisAtt = new G4VisAttributes(G4Colour(0.5,1.0,1.0));
820 glassVisAtt->SetVisibility(false);
821 logicOrgGlass->SetVisAttributes(glassVisAtt);
822 }
823 if(logicRearCasing)
824 {
825 logicRearCasing->SetVisAttributes(G4VisAttributes::Invisible);
826 }
827 if(logicAlPlate)
828 {
829 G4VisAttributes* AlPlateVisAtt = new G4VisAttributes(G4Colour(0.9,0.9,1.0));
830 AlPlateVisAtt->SetVisibility(true);
831 logicAlPlate->SetVisAttributes(AlPlateVisAtt);
832 logicAlPlate->SetVisAttributes(G4VisAttributes::Invisible);
833 }
834 logicRear->SetVisAttributes(G4VisAttributes::Invisible);
835 logicPreAmpBox->SetVisAttributes(G4VisAttributes::Invisible);
836 logicHangingPlate->SetVisAttributes(G4VisAttributes::Invisible);
837 logicAirInPABox->SetVisAttributes(G4VisAttributes::Invisible);
838 logicPD->SetVisAttributes(G4VisAttributes::Invisible);
839 logicWaterPipe->SetVisAttributes(G4VisAttributes::Invisible);
840 //
841 //always return the physical World
842 //
843 if(verboseLevel>0)PrintEMCParameters();
844 // return physiBSC;
845 */
846// ConstructEndGeometry(logicEMC);
847// ConstructSPFrame(logicEMC,besEMCGeometry);
848}
849
850
851void ExtBesEmcConstruction::DefineMaterials()
852{
853 G4String name, symbol; //a=mass of a mole;
854 G4double a, z, density; //z=mean number of protons;
855 // G4int iz, n; //iz=number of protons in an isotope;
856 // n=number of nucleons in an isotope;
857
858 G4int ncomponents, natoms;
859 G4double fractionmass;
860 //G4double abundance, fractionmass;
861 // G4double temperature, pressure;
862
863 //for debug
864 // G4Exception("BesEmcConstruction::DefineMaterials() starting...........");
865 //
866 // define Elements
867 //
868 G4Element* H=G4Element::GetElement("Hydrogen");
869 if(!H)
870 {
871 a = 1.01*g/mole;
872 H = new G4Element(name="Hydrogen",symbol="H" , z= 1., a);
873 }
874 G4Element* C=G4Element::GetElement("Carbon");
875 if(!C)
876 {
877 a = 12.01*g/mole;
878 C = new G4Element(name="Carbon" ,symbol="C" , z= 6., a);
879 }
880 G4Element* O=G4Element::GetElement("Oxygen");
881 if(!O)
882 {
883 a = 16.00*g/mole;
884 O = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a);
885 }
886
887 density = 0.344*g/cm3;
888 G4Material* Tyvek = new G4Material(name="Polyethylene", density, ncomponents=2);
889 Tyvek->AddElement(C, natoms=1);
890 Tyvek->AddElement(H, natoms=2);
891
892 density = 1.39*g/cm3;
893 G4Material* Mylar = new G4Material(name="PolyethyleneTerephthlate", density, ncomponents=3);
894 Mylar->AddElement(C, natoms=5);
895 Mylar->AddElement(H, natoms=4);
896 Mylar->AddElement(O, natoms=2);
897
898 density = 1.18*g/cm3;
899 organicGlass = new G4Material(name="OrganicGlass", density, ncomponents=3);
900 organicGlass->AddElement(C, natoms=5);
901 organicGlass->AddElement(H, natoms=7);
902 organicGlass->AddElement(O, natoms=2);
903
904 G4Material *Fe = new G4Material(name="Iron", z=26., a=55.85*g/mole, density=7.87*g/cm3);
905 G4Material *Cr = new G4Material(name="Chromium", z=24., a=52.00*g/mole, density=8.72*g/cm3);
906 G4Material *Ni = new G4Material(name="Nickel", z=28., a=58.69*g/mole, density=8.72*g/cm3);
907
908 stainlessSteel = new G4Material(name="0Cr18Ni9", density=7.85*g/cm3, ncomponents=3);
909 stainlessSteel->AddMaterial(Fe, fractionmass=73.*perCent);
910 stainlessSteel->AddMaterial(Cr, fractionmass=18.*perCent);
911 stainlessSteel->AddMaterial(Ni, fractionmass=9.*perCent);
912
913 G4Material *H2O = G4Material::GetMaterial("Water");
914 G4Material *Cu = G4Material::GetMaterial("Copper");
915 G4double dWater = 1.*g/cm3; //density
916 G4double dCopper = 8.96*g/cm3;
917 G4double aWater = ((*besEMCGeometry).waterPipeDr-(*besEMCGeometry).waterPipeThickness)
918 *((*besEMCGeometry).waterPipeDr-(*besEMCGeometry).waterPipeThickness); //area
919 G4double aCopper = (*besEMCGeometry).waterPipeDr*(*besEMCGeometry).waterPipeDr-aWater;
920 density = (dWater*aWater+dCopper*aCopper)/(aWater+aCopper);
921
922 waterPipe = new G4Material(name="WaterPipe", density, ncomponents=2);
923 fractionmass = dWater*aWater/(dWater*aWater+dCopper*aCopper);
924 waterPipe->AddMaterial(H2O, fractionmass);
925 fractionmass = dCopper*aCopper/(dWater*aWater+dCopper*aCopper);
926 waterPipe->AddMaterial(Cu, fractionmass);
927
928 cable = new G4Material(name="Cable", density=4.*g/cm3, ncomponents=1);
929 cable->AddMaterial(Cu,1);
930
931 //for debug
932 //G4Exception("BesEmcConstruction::DefineMaterials() running one.........");
933 //
934 // predigest the casing of crystals to a mixture
935 //
936
937 G4Material* Al=G4Material::GetMaterial("Aluminium");
938 if(Al==NULL)
939 {
940 Al = new G4Material(name="Aluminium", z=13., a=26.98*g/mole, density=2.700*g/cm3);
941 }
942
943 G4Material *Si=G4Material::GetMaterial("Silicon");
944 if(Si==NULL)
945 {
946 Si = new G4Material(name="Silicon", z=14., a=28.0855*g/mole, density=2.33*g/cm3);
947 }
948
949 //for debug
950 G4double totalThickness=(*besEMCGeometry).fTyvekThickness
951 +(*besEMCGeometry).fAlThickness+(*besEMCGeometry).fMylarThickness;
952 density = (Tyvek->GetDensity()*(*besEMCGeometry).fTyvekThickness+
953 Al->GetDensity()*(*besEMCGeometry).fAlThickness+
954 Mylar->GetDensity()*(*besEMCGeometry).fMylarThickness)
955 /totalThickness;
956 G4Material* Casing = new G4Material(name="Casing", density, ncomponents=3);
957 Casing->AddMaterial(
958 Tyvek,
959 fractionmass=Tyvek->GetDensity()/density
960 *(*besEMCGeometry).fTyvekThickness
961 /totalThickness);
962 Casing->AddMaterial(
963 Al,
964 fractionmass=Al->GetDensity()/density
965 *(*besEMCGeometry).fAlThickness
966 /totalThickness);
967 Casing->AddMaterial(
968 Mylar,
969 fractionmass=Mylar->GetDensity()/density
970 *(*besEMCGeometry).fMylarThickness
971 /totalThickness);
972 fCasingMaterial = Casing;
973 rearCasingMaterial = Tyvek;
974 //for debug
975 // G4Exception("BesEmcConstruction::DefineMaterials() running two........");
976 fCrystalMaterial = G4Material::GetMaterial("Cesiumiodide");
977}
978
979
981{
982 G4Material* fCrystalMaterial = G4Material::GetMaterial("Cesiumiodide");
983 // G4VisAttributes* crystalVisAtt= new G4VisAttributes(G4Colour(0.5,0,1.0));
984 //crystalVisAtt->SetVisibility(true);
985 //G4VisAttributes* endPhiVisAtt= new G4VisAttributes(G4Colour(0,1.0,0));
986 //endPhiVisAtt->SetVisibility(false);
987
988 //world volume of endcap
989 //east end
990 solidEnd = new G4Cons("EndWorld",(*emcEnd).WorldRmin1,(*emcEnd).WorldRmax1,(*emcEnd).WorldRmin2,(*emcEnd).WorldRmax2,
991 (*emcEnd).WorldDz/2,0.*deg,360.*deg);
992 logicEnd = new G4LogicalVolume(solidEnd, G4Material::GetMaterial("Air"), "EndWorld", 0, 0, 0);
993 physiEnd = new G4PVPlacement(0, // no rotation
994 G4ThreeVector(0,0,(*emcEnd).WorldZPosition),
995 logicEnd, // its logical volume
996 "EndWorld", // its name
997 logicEMC, // its mother volume
998 false, // no boolean operations
999 0); // no field specific to volume
1000 // if(logicEnd)
1001 // logicEnd->SetVisAttributes(G4VisAttributes::Invisible);
1002
1003
1004 //west end
1005 G4RotationMatrix *rotateEnd = new G4RotationMatrix();
1006 rotateEnd->rotateY(180.*deg);
1007 physiEnd = new G4PVPlacement(rotateEnd,
1008 G4ThreeVector(0,0,-(*emcEnd).WorldZPosition),
1009 logicEnd,
1010 "EndWorld",
1011 logicEMC,
1012 false,
1013 2);
1014
1015 ////////////////////////////////////////////////////////////////////////
1016 // emc endcap sectors (east) //
1017 //////////////////////////////////////////////////////////////////////////
1018 // 20mm gap //
1019 // || //
1020 // \ 7 || 6 / //
1021 // - 8 \ || / 5 - //
1022 // - \ || / - //
1023 // _ 9 - \ || / - 4 _ //
1024 // - _ - \ || / - _ - //
1025 // - _ - \||/ - _ - //
1026 // 10 - -||- - 3 //
1027 // ----------------||---------------- //
1028 // 11 - -||- - 2 //
1029 // _ - - /||\ - - _ //
1030 // _ - - / || \ - - _ //
1031 // - 12 - / || \ - 1 - //
1032 // - / || \ - //
1033 // - 13 / || \ 0 - //
1034 // / 14 || 15 \ //
1035 // || //
1036 ////////////////////////////////////////////////////////////////////////
1037
1038 // 1/16 of endcap world,which has some symmetry
1039 // sector 0-6,8-14
1040 solidEndPhi = new G4Cons("EndPhi",(*emcEnd).WorldRmin1,(*emcEnd).WorldRmax1,(*emcEnd).WorldRmin2,(*emcEnd).WorldRmax2,
1041 (*emcEnd).WorldDz/2,0*deg,22.5*deg);
1042 logicEndPhi = new G4LogicalVolume(solidEndPhi, G4Material::GetMaterial("Air"), "EndPhi", 0, 0, 0);
1043 for(G4int i=0;i<14;i++)
1044 {
1045 if((i!=6)&&(i!=7))
1046 {
1047 G4RotationMatrix *rotatePhi = new G4RotationMatrix();
1048 rotatePhi->rotateZ(-i*22.5*deg+67.5*deg);
1049 physiEndPhi = new G4PVPlacement(rotatePhi,0,logicEndPhi,"EndPhi",logicEnd,false,i);
1050 }
1051 }
1052 //if(logicEndPhi)
1053 // logicEndPhi->SetVisAttributes(endPhiVisAtt);
1054
1055 for(G4int i=0;i<35;i++)
1056 {
1057 G4int copyNb = ComputeEndCopyNb(i);
1058
1059 solidEndCasing = new G4IrregBox("EndCasing",(*emcEnd).fPnt[i]);
1060 logicEndCasing = new G4LogicalVolume(solidEndCasing,fCasingMaterial,"EndCasing");
1061 physiEndCasing = new G4PVPlacement(0,0,logicEndCasing,"EndCasing",logicEndPhi,false,copyNb);
1062
1063 emcEnd->ModifyForCasing((*emcEnd).fPnt[i],i);
1064 solidEndCrystal = new G4IrregBox("EndCrystal",(*emcEnd).cryPoint);
1065 logicEndCrystal = new G4LogicalVolume(solidEndCrystal,fCrystalMaterial,"EndCrystal");
1066 physiEndCrystal = new G4PVPlacement(0,0,logicEndCrystal,"EndCrystal",logicEndCasing,false,copyNb);
1067
1068 //logicEndCasing->SetVisAttributes(G4VisAttributes::Invisible);
1069 //logicEndCrystal->SetVisAttributes(crystalVisAtt);
1070 //logicEndCrystal->SetSensitiveDetector(besEMCSD);
1071 }
1072
1073
1074 // the top area which has 20 mm gap
1075 // sector 6,14
1076 solidEndPhi = new G4Cons("EndPhi",(*emcEnd).WorldRmin1,(*emcEnd).WorldRmax1,(*emcEnd).WorldRmin2,(*emcEnd).WorldRmax2,
1077 (*emcEnd).WorldDz/2,67.5*deg,22.5*deg);
1078 logicEndPhi = new G4LogicalVolume(solidEndPhi, G4Material::GetMaterial("Air"), "EndPhi", 0, 0, 0);
1079 for(G4int i=0;i<2;i++)
1080 {
1081 G4RotationMatrix *rotatePhi = new G4RotationMatrix();
1082 rotatePhi->rotateZ(-i*180.*deg);
1083 physiEndPhi = new G4PVPlacement(rotatePhi,0,logicEndPhi,"EndPhi",logicEnd,false,i*8+6);
1084 }
1085 //if(logicEndPhi)
1086 // logicEndPhi->SetVisAttributes(endPhiVisAtt);
1087
1088 for(G4int i=0;i<35;i++)
1089 {
1090 G4int copyNb = ComputeEndCopyNb(i);
1091 solidEndCasing = new G4IrregBox("EndCasing",(*emcEnd).fPnt1[i]);
1092 logicEndCasing = new G4LogicalVolume(solidEndCasing,fCasingMaterial,"EndCasing");
1093 physiEndCasing = new G4PVPlacement(0,0,logicEndCasing,"EndCasing",logicEndPhi,false,copyNb);
1094
1095 emcEnd->ModifyForCasing((*emcEnd).fPnt1[i],i);
1096 solidEndCrystal = new G4IrregBox("EndCrystal",(*emcEnd).cryPoint);
1097 logicEndCrystal = new G4LogicalVolume(solidEndCrystal,fCrystalMaterial,"EndCrystal");
1098 physiEndCrystal = new G4PVPlacement(0,0,logicEndCrystal,"EndCrystal",logicEndCasing,false,copyNb);
1099
1100 //logicEndCasing->SetVisAttributes(G4VisAttributes::Invisible);
1101 //logicEndCrystal->SetVisAttributes(crystalVisAtt);
1102 //logicEndCrystal->SetSensitiveDetector(besEMCSD);
1103 }
1104
1105 (*emcEnd).ReflectX();
1106
1107 // sector 7,15
1108 for(G4int i=0;i<35;i++)
1109 for (G4int j=0;j<8;j++)
1110 (*emcEnd).fPnt1[i][j].rotateZ(-90.*deg);
1111
1112 solidEndPhi = new G4Cons("EndPhi",(*emcEnd).WorldRmin1,(*emcEnd).WorldRmax1,(*emcEnd).WorldRmin2,(*emcEnd).WorldRmax2,
1113 (*emcEnd).WorldDz/2,0*deg,22.5*deg);
1114 logicEndPhi = new G4LogicalVolume(solidEndPhi, G4Material::GetMaterial("Air"), "EndPhi", 0, 0, 0);
1115 for(G4int i=0;i<2;i++)
1116 {
1117 G4RotationMatrix *rotatePhi = new G4RotationMatrix();
1118 rotatePhi->rotateZ(-i*180.*deg-90.*deg);
1119 physiEndPhi = new G4PVPlacement(rotatePhi,0,logicEndPhi,"EndPhi",logicEnd,false,i*8+7);
1120 }
1121 //if(logicEndPhi)
1122 // logicEndPhi->SetVisAttributes(endPhiVisAtt);
1123
1124 for(G4int i=0;i<35;i++)
1125 {
1126 G4int copyNb = ComputeEndCopyNb(i);
1127 solidEndCasing = new G4IrregBox("EndCasing",(*emcEnd).fPnt1[i]);
1128 logicEndCasing = new G4LogicalVolume(solidEndCasing,fCrystalMaterial,"EndCasing");
1129 physiEndCasing = new G4PVPlacement(0,0,logicEndCasing,"EndCasing",logicEndPhi,false,copyNb);
1130
1131 emcEnd->ModifyForCasing((*emcEnd).fPnt1[i],i);
1132 solidEndCrystal = new G4IrregBox("EndCrystal",(*emcEnd).cryPoint);
1133 logicEndCrystal = new G4LogicalVolume(solidEndCrystal,fCrystalMaterial,"EndCrystal");
1134 physiEndCrystal = new G4PVPlacement(0,0,logicEndCrystal,"EndCrystal",logicEndCasing,false,copyNb);
1135
1136 //logicEndCasing->SetVisAttributes(G4VisAttributes::Invisible);
1137 //logicEndCrystal->SetVisAttributes(crystalVisAtt);
1138 //logicEndCrystal->SetSensitiveDetector(besEMCSD);
1139 }
1140}
1141
1142//////////////////////////////////////////////////////////////////////////////////////////////////////
1143void ExtBesEmcConstruction::ConstructSPFrame(G4LogicalVolume* logicEMC, ExtBesEmcGeometry* besEMCGeometry)
1144{
1145 //G4VisAttributes* ringVisAtt= new G4VisAttributes(G4Colour(0.5,0.25,0.));
1146 //ringVisAtt->SetVisibility(false);
1147
1148 solidSupportBar = new G4Tubs("SupportBar",
1149 (*besEMCGeometry).BSCRmax+(*besEMCGeometry).SPBarThickness1,
1150 (*besEMCGeometry).BSCRmax+(*besEMCGeometry).SPBarThickness+(*besEMCGeometry).SPBarThickness1,
1151 (*besEMCGeometry).BSCDz+(*besEMCGeometry).TaperRingThickness3+(*besEMCGeometry).EndRingDz,
1152 0.*deg,
1153 360.*deg);
1154
1155 logicSupportBar = new G4LogicalVolume(solidSupportBar,stainlessSteel,"SupportBar");
1156
1157 physiSupportBar = new G4PVPlacement(0,0,logicSupportBar,"SupportBar",logicEMC,false,0);
1158
1159 solidSupportBar1 = new G4Tubs("SupportBar1",
1160 (*besEMCGeometry).BSCRmax,
1161 (*besEMCGeometry).BSCRmax+(*besEMCGeometry).SPBarThickness1,
1162 (*besEMCGeometry).BSCDz+(*besEMCGeometry).TaperRingThickness3,
1163 (*besEMCGeometry).BSCPhiDphi-(*besEMCGeometry).SPBarDphi/2,
1164 (*besEMCGeometry).SPBarDphi);
1165
1166 logicSupportBar1 = new G4LogicalVolume(solidSupportBar1,stainlessSteel,"SupportBar1");
1167
1168 for(G4int i=0;i<(*besEMCGeometry).BSCNbPhi/2;i++)
1169 {
1170 G4RotationMatrix *rotateSPBar = new G4RotationMatrix();
1171 rotateSPBar->rotateZ((*besEMCGeometry).BSCPhiDphi-i*2*(*besEMCGeometry).BSCPhiDphi);
1172 physiSupportBar1 = new G4PVPlacement(rotateSPBar,0,logicSupportBar1,"SupportBar1",logicEMC,false,0);
1173 }
1174
1175 //end ring
1176 solidEndRing = new G4Tubs("EndRing",
1177 (*besEMCGeometry).EndRingRmin,
1178 (*besEMCGeometry).EndRingRmin+(*besEMCGeometry).EndRingDr/2,
1179 (*besEMCGeometry).EndRingDz/2,
1180 0.*deg,
1181 360.*deg);
1182
1183 solidGear = new G4Tubs("Gear",
1184 (*besEMCGeometry).EndRingRmin+(*besEMCGeometry).EndRingDr/2,
1185 (*besEMCGeometry).EndRingRmin+(*besEMCGeometry).EndRingDr,
1186 (*besEMCGeometry).EndRingDz/2,
1187 0.*deg,
1188 (*besEMCGeometry).BSCPhiDphi);
1189
1190 //taper ring
1191 solidTaperRing1 = new G4Tubs("TaperRing1",
1192 (*besEMCGeometry).TaperRingRmin1,
1193 (*besEMCGeometry).TaperRingRmin1+(*besEMCGeometry).TaperRingThickness1,
1194 (*besEMCGeometry).TaperRingInnerLength/2,
1195 0.*deg,
1196 360.*deg);
1197
1198 solidTaperRing2 = new G4Cons("TaperRing2",
1199 (*besEMCGeometry).TaperRingRmin1,
1200 (*besEMCGeometry).TaperRingRmin1+(*besEMCGeometry).TaperRingDr,
1201 (*besEMCGeometry).TaperRingRmin2,
1202 (*besEMCGeometry).TaperRingRmin2+(*besEMCGeometry).TaperRingDr,
1203 (*besEMCGeometry).TaperRingDz/2,
1204 0.*deg,
1205 360.*deg);
1206
1207 solidTaperRing3 = new G4Cons("TaperRing3",
1208 (*besEMCGeometry).BSCRmax2,
1209 (*besEMCGeometry).BSCRmax2+(*besEMCGeometry).TaperRingOuterLength1,
1210 (*besEMCGeometry).TaperRingRmin2+(*besEMCGeometry).TaperRingDr,
1211 (*besEMCGeometry).TaperRingRmin2+(*besEMCGeometry).TaperRingDr+(*besEMCGeometry).TaperRingOuterLength,
1212 (*besEMCGeometry).TaperRingThickness3/2,
1213 0.*deg,
1214 360.*deg);
1215
1216 logicEndRing = new G4LogicalVolume(solidEndRing,stainlessSteel,"EmcEndRing");
1217 logicGear = new G4LogicalVolume(solidGear,stainlessSteel,"Gear");
1218 logicTaperRing1 = new G4LogicalVolume(solidTaperRing1,stainlessSteel,"TaperRing1");
1219 logicTaperRing2 = new G4LogicalVolume(solidTaperRing2,stainlessSteel,"TaperRing2");
1220 logicTaperRing3 = new G4LogicalVolume(solidTaperRing3,stainlessSteel,"TaperRing3");
1221
1222 for(G4int i=0;i<2;i++)
1223 {
1224 G4RotationMatrix *rotateSPRing = new G4RotationMatrix();
1225 G4double zEndRing,z1,z2,z3;
1226 if(i==0)
1227 {
1228 zEndRing = (*besEMCGeometry).BSCDz+(*besEMCGeometry).TaperRingThickness3+(*besEMCGeometry).EndRingDz/2;
1229 z1 = (*besEMCGeometry).BSCDz+(*besEMCGeometry).TaperRingThickness3
1230 -(*besEMCGeometry).TaperRingDz-(*besEMCGeometry).TaperRingInnerLength/2;
1231 z2 = (*besEMCGeometry).BSCDz+(*besEMCGeometry).TaperRingThickness3-(*besEMCGeometry).TaperRingDz/2;
1232 z3 = (*besEMCGeometry).BSCDz+(*besEMCGeometry).TaperRingThickness3/2;
1233 }
1234 else
1235 {
1236 rotateSPRing->rotateY(180.*deg);
1237 zEndRing = -((*besEMCGeometry).BSCDz+(*besEMCGeometry).TaperRingThickness3+(*besEMCGeometry).EndRingDz/2);
1238 z1 = -((*besEMCGeometry).BSCDz+(*besEMCGeometry).TaperRingThickness3
1239 -(*besEMCGeometry).TaperRingDz-(*besEMCGeometry).TaperRingInnerLength/2);
1240 z2 = -((*besEMCGeometry).BSCDz+(*besEMCGeometry).TaperRingThickness3-(*besEMCGeometry).TaperRingDz/2);
1241 z3 = -((*besEMCGeometry).BSCDz+(*besEMCGeometry).TaperRingThickness3/2);
1242 }
1243
1244 physiEndRing = new G4PVPlacement(rotateSPRing,G4ThreeVector(0,0,zEndRing),
1245 logicEndRing,"EndRing",logicEMC,false,0);
1246
1247 for(G4int j=0;j<(*besEMCGeometry).BSCNbPhi/2;j++)
1248 {
1249 G4RotationMatrix *rotateGear = new G4RotationMatrix();
1250 rotateGear->rotateZ((*besEMCGeometry).BSCPhiDphi/2-j*2*(*besEMCGeometry).BSCPhiDphi);
1251 physiGear = new G4PVPlacement(rotateGear,G4ThreeVector(0,0,zEndRing),
1252 logicGear,"Gear",logicEMC,false,0);
1253 }
1254
1255 physiTaperRing1 = new G4PVPlacement(rotateSPRing,G4ThreeVector(0,0,z1),
1256 logicTaperRing1,"TaperRing1",logicEMC,false,0);
1257
1258 physiTaperRing2 = new G4PVPlacement(rotateSPRing,G4ThreeVector(0,0,z2),
1259 logicTaperRing2,"TaperRing2",logicEMC,false,0);
1260
1261 physiTaperRing3 = new G4PVPlacement(rotateSPRing,G4ThreeVector(0,0,z3),
1262 logicTaperRing3,"TaperRing3",logicEMC,false,0);
1263 }
1264 /*
1265 logicSupportBar->SetVisAttributes(ringVisAtt);
1266 logicSupportBar1->SetVisAttributes(ringVisAtt);
1267 logicEndRing->SetVisAttributes(ringVisAtt);
1268 logicGear->SetVisAttributes(ringVisAtt);
1269 logicTaperRing1->SetVisAttributes(ringVisAtt);
1270 logicTaperRing2->SetVisAttributes(ringVisAtt);
1271 logicTaperRing3->SetVisAttributes(ringVisAtt);
1272 */
1273}
1274
1276{
1277 G4int copyNb;
1278 switch(num){
1279 case 30:
1280 copyNb = 5;
1281 break;
1282 case 31:
1283 copyNb = 6;
1284 break;
1285 case 32:
1286 copyNb = 14;
1287 break;
1288 case 33:
1289 copyNb = 15;
1290 break;
1291 case 34:
1292 copyNb = 16;
1293 break;
1294 default:
1295 copyNb = num;
1296 break;
1297 }
1298 return copyNb;
1299}
1300
1301
1303{
1304 G4cout << "-------------------------------------------------------"<< G4endl
1305 << "---> There are "
1306 << phiNbCrystals << "(max=" << (*besEMCGeometry).BSCNbPhi
1307 << ") crystals along phi direction and "
1308 << thetaNbCrystals << "(max=" << (*besEMCGeometry).BSCNbTheta
1309 << ") crystals along theta direction."<< G4endl
1310 << "The crystals have sizes of "
1311 << (*besEMCGeometry).BSCCryLength/cm << "cm(L) and "
1312 << (*besEMCGeometry).BSCYFront/cm << "cm(Y) with "
1313 << fCrystalMaterial->GetName() <<"."<< G4endl
1314 << "The casing is layer of "
1315 << (*besEMCGeometry).fTyvekThickness/mm << "mm tyvek,"
1316 << (*besEMCGeometry).fAlThickness/mm << "mm aluminum and"
1317 << (*besEMCGeometry).fMylarThickness/mm << "mm mylar."<< G4endl
1318 << "-------------------------------------------------------"<< G4endl;
1319 G4cout << G4Material::GetMaterial("PolyethyleneTerephthlate") << G4endl
1320 << G4Material::GetMaterial("Casing") << G4endl
1321 << G4Material::GetMaterial("Polyethylene") << G4endl
1322 << "-------------------------------------------------------"<< G4endl;
1323}
1324
1325//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
1326
1328{
1329 // search the material by its name
1330 G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
1331 if (pttoMaterial)
1332 {fCrystalMaterial = pttoMaterial;
1333 logicBSCCrystal->SetMaterial(pttoMaterial);
1335 }
1336}
1337
1338
1339void ExtBesEmcConstruction::SetCasingMaterial(G4String materialChoice)
1340{
1341 // search the material by its name
1342 G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
1343 if (pttoMaterial)
1344 {fCasingMaterial = pttoMaterial;
1345 logicBSCTheta->SetMaterial(pttoMaterial);
1347 }
1348}
1349
1350//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
1351
1353{
1354 // change Gap thickness and recompute the calorimeter parameters
1355 (*besEMCGeometry).fTyvekThickness = val('X');
1356 (*besEMCGeometry).fAlThickness = val('Y');
1357 (*besEMCGeometry).fMylarThickness = val('Z');
1358}
1359
1360//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
1361
1363{
1364 (*besEMCGeometry).BSCRmin = val;
1365}
1366
1367//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
1368
1370{
1371 (*besEMCGeometry).BSCNbPhi = val;
1372}
1373
1374//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
1375
1377{
1378 (*besEMCGeometry).BSCNbTheta = val;
1379}
1380
1382{
1383 startID = val;
1384}
1385
1386
1387//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
1388
1390{
1391 (*besEMCGeometry).BSCCryLength = val;
1392}
1393
1394//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
1395
1397{
1398 (*besEMCGeometry).BSCYFront0 = val;
1399}
1400
1401
1402//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
1403
1405{
1406 (*besEMCGeometry).BSCYFront = val;
1407}
1408
1409//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
1410
1412{
1413 (*besEMCGeometry).BSCPosition0 = val;
1414}
1415
1416//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
1417
1419{
1420 (*besEMCGeometry).BSCPosition1 = val;
1421}
1422
1423//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
1424
1425void ExtBesEmcConstruction::SetMagField(G4double fieldValue)
1426{
1427 //apply a global uniform magnetic field along Z axis
1428 G4FieldManager* fieldMgr
1429 = G4TransportationManager::GetTransportationManager()->GetFieldManager();
1430
1431 if(magField) delete magField; //delete the existing magn field
1432
1433 if(fieldValue!=0.) // create a new one if non nul
1434 { magField = new G4UniformMagField(G4ThreeVector(0.,0.,fieldValue));
1435 fieldMgr->SetDetectorField(magField);
1436 fieldMgr->CreateChordFinder(magField);
1437 fmagField=fieldValue;
1438 } else {
1439 magField = 0;
1440 fieldMgr->SetDetectorField(magField);
1441 fmagField=0.;
1442 }
1443}
1444
1445//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
1446//???????????????????????????????????????????????
1448{
1449 ;//G4RunManager::GetRunManager()->DefineWorldVolume(BesDetectorConstruction::Construct());
1450}
***************************************************************************************Pseudo Class RRes *****************************************************************************************Parameters and physical constants **Maarten sept ************************************************************************DOUBLE PRECISION xsmu **************************************************************************PARTICLE DATA all others are from PDG *Only resonances with known widths into electron pairs are sept ************************************************************************C Declarations C
Definition: RRes.h:29
static EmcG4Geo * Instance()
Get a pointer to the single instance of EmcG4Geo.
Definition: EmcG4Geo.cxx:52
void ConstructEndGeometry(G4LogicalVolume *)
void SetCasingThickness(G4ThreeVector)
void Construct(G4LogicalVolume *)
void ConstructSPFrame(G4LogicalVolume *, ExtBesEmcGeometry *)
void ModifyForCasing(G4ThreeVector pos[8], G4int CryNb)
G4LogicalVolume * GetTopVolume()
Get the top(world) volume;.
IMPLICIT REAL *A H
Definition: myXsection.h:1
int num[96]
Definition: ranlxd.c:373