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