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