94{
98
99 G4SDManager* SDman = G4SDManager::GetSDMpointer();
100 if (!besEMCSD) {
101 besEMCSD =
new BesEmcSD(
"CalorSD",
this,besEMCGeometry);
102 SDman->AddNewDetector( besEMCSD );
103 }
104
105
108 {
110
111 if(logicEMC){
112 physiEMC = new G4PVPlacement(0,
113 G4ThreeVector(0.0 ,0.0 ,0.0),
114 logicEMC, "physicalEMC",logicBes, false, 0);
115 G4cout<<"logicEmc: === "<<logicEMC<<" physiEmc "<<physiEMC<<G4endl;
116
119 }
120 }
121 else {
122
123
124
125 DefineMaterials();
126 phiNbCrystals = (*besEMCGeometry).BSCNbPhi;
127 thetaNbCrystals = (*besEMCGeometry).BSCNbTheta*2;
128
129 G4double da=0.001*deg;
130
131
132
133
134 solidBSC = new G4Tubs("solidBSC",
135 (*besEMCGeometry).TaperRingRmin1,
136 (*besEMCGeometry).BSCRmax+(*besEMCGeometry).SPBarThickness+(*besEMCGeometry).SPBarThickness1+2.1*mm,
137 (*besEMCGeometry).BSCDz+(*besEMCGeometry).TaperRingThickness3+(*besEMCGeometry).EndRingDz,
138 0.*deg,
139 360.*deg);
140
141 solidESC = new G4Cons("solidESC",(*emcEnd).WorldRmin1,(*emcEnd).WorldRmax1,
142 (*emcEnd).WorldRmin2,(*emcEnd).WorldRmax2,
143 (*emcEnd).WorldDz/2,0.*deg,360.*deg);
144
145 solidEMC = new G4UnionSolid("solidEMC0",
146 solidBSC,
147 solidESC,
148 0,
149 G4ThreeVector(0,0,(*emcEnd).WorldZPosition));
150
151 G4RotationMatrix *rotateESC = new G4RotationMatrix();
152 rotateESC->rotateY(180.*deg);
153
154 solidEMC = new G4UnionSolid("solidEMC",
155 solidEMC,
156 solidESC,
157 rotateESC,
158 G4ThreeVector(0,0,-(*emcEnd).WorldZPosition));
159
160 logicEMC = new G4LogicalVolume(solidEMC,
161 G4Material::GetMaterial("Air"),
162 "logicalEMC");
163
164 physiEMC = new G4PVPlacement(0,
165 0,
166 logicEMC,
167 "physicalEMC",
168 logicBes,
169 false,
170 0);
171
172 solidBSCWorld = new G4SubtractionSolid("solidBSCWorld0",
173 solidBSC,
174 solidESC,
175 0,
176 G4ThreeVector(0,0,(*emcEnd).WorldZPosition));
177
178 solidBSCWorld = new G4SubtractionSolid("solidBSCWorld",
179 solidBSCWorld,
180 solidESC,
181 rotateESC,
182 G4ThreeVector(0,0,-(*emcEnd).WorldZPosition));
183
184 logicBSCWorld = new G4LogicalVolume(solidBSCWorld,
185 G4Material::GetMaterial("Air"),
186 "logicalBSCWorld");
187
188 G4RotationMatrix *rotBSC = new G4RotationMatrix();
189 rotBSC->rotateY(180.*deg);
190 physiBSCWorld = new G4PVPlacement(rotBSC,
191 0,
192 logicBSCWorld,
193 "physicalBSCWorld",
194 logicEMC,
195 false,
196 0);
197
198 G4RotationMatrix *rotateMatrix[200];
199 G4double oOp,ox,oy,oz;
200 G4double delta = 0*deg;
201 G4ThreeVector axis = G4ThreeVector(0,0,0);
202 oOp=(*besEMCGeometry).BSCRmin/
sin(0.5*(*besEMCGeometry).BSCPhiDphi+90*deg)
203 *
sin((*besEMCGeometry).BSCAngleRotat);
204 G4double ll=(*besEMCGeometry).BSCCryLength;
205 G4double rr=(*besEMCGeometry).BSCRmin;
206 G4double oj=sqrt(ll*ll+rr*rr-2*ll*rr*
cos(180.*deg-(*besEMCGeometry).BSCAngleRotat));
207 G4double oij=90.*deg-(*besEMCGeometry).BSCPhiDphi/2.-(*besEMCGeometry).BSCAngleRotat;
208 G4double doj=asin(
sin(180.*deg-(*besEMCGeometry).BSCAngleRotat)/oj*ll);
209 G4double ioj=(*besEMCGeometry).BSCPhiDphi/2.+doj;
210 G4double ij=oj/
sin(oij)*
sin(ioj);
211 G4double dOp=rr/
sin(90.*deg-(*besEMCGeometry).BSCPhiDphi/2.)
212 *
sin(90.*deg+(*besEMCGeometry).BSCPhiDphi/2.-(*besEMCGeometry).BSCAngleRotat);
213 G4double cOp=rr/
sin(90.*deg+(*besEMCGeometry).BSCPhiDphi/2.)
214 *
sin(90.*deg-(*besEMCGeometry).BSCPhiDphi/2.-(*besEMCGeometry).BSCAngleRotat);
215 G4double ch=(dOp+ll)/
cos((*besEMCGeometry).BSCPhiDphi)-cOp;
216 G4double hi=(dOp+ll)*
tan((*besEMCGeometry).BSCPhiDphi)-ij;
217 G4double oh=sqrt(ch*ch+rr*rr-2*ch*rr*
cos(180*deg-(*besEMCGeometry).BSCAngleRotat));
218 G4double hoi=asin(
sin(180*deg-oij)/oh*hi);
219 G4double dok=asin(
sin(180*deg-(*besEMCGeometry).BSCAngleRotat)/oh*ch);
220 if(verboseLevel>3)
221 G4cout << "oj=" <<oj/cm<<G4endl
222 << "oij="<<oij/deg<<G4endl
223 << "doj="<<doj/deg<<G4endl
224 << "ioj="<<ioj/deg<<G4endl
225 << "ij="<<ij/cm<<G4endl
226 << "dOp="<<dOp/cm<<G4endl
227 << "cOp="<<cOp/cm<<G4endl
228 << "ch="<<ch/cm<<G4endl
229 << "hi="<<hi/cm<<G4endl
230 << "oh="<<oh/cm<<G4endl
231 << "hoi="<<hoi/deg<<G4endl
232 << "dok="<<dok/deg<<G4endl;
233
234
235 solidBSCPhiTub = new G4Tubs(
236 "solidBSCPhiTub",
237 dOp,
238 (*besEMCGeometry).BSCPhiRmax,
239 (*besEMCGeometry).BSCDz,
240 360.*deg-(*besEMCGeometry).BSCPhiDphi,
241 (*besEMCGeometry).BSCPhiDphi);
242 solidConsPhi = new G4Cons("consPhi1",
243 (*besEMCGeometry).BSCRmin1,
244 (*besEMCGeometry).BSCRmax1,
245 (*besEMCGeometry).BSCRmin2,
246 (*besEMCGeometry).BSCRmax2,
247 (*besEMCGeometry).BSCDz1/2,
248 0.*deg,
249 360.*deg);
250 solidBSCPhi1 = new G4SubtractionSolid("solidBSCPhi1",
251 solidBSCPhiTub,
252 solidConsPhi,
253 0,
254 G4ThreeVector(0,0,(*besEMCGeometry).BSCDz-(*besEMCGeometry).BSCDz1/2));
255 solidConsPhi = new G4Cons("consPhi2",
256 (*besEMCGeometry).BSCRmin2,
257 (*besEMCGeometry).BSCRmax2,
258 (*besEMCGeometry).BSCRmin1,
259 (*besEMCGeometry).BSCRmax1,
260 (*besEMCGeometry).BSCDz1/2,
261 0.*deg,
262 360.*deg);
263 solidBSCPhi = new G4SubtractionSolid("solidBSCPhi",
264 solidBSCPhi1,
265 solidConsPhi,
266 0,
267 G4ThreeVector(0,0,(*besEMCGeometry).BSCDz1/2-(*besEMCGeometry).BSCDz));
268
269 logicBSCPhi = new G4LogicalVolume(solidBSCPhi,
270 G4Material::GetMaterial("Air"),
271 "logicalBSCPhi");
272
273 G4int i;
274 for(G4int j=0;j<(*besEMCGeometry).BSCNbPhi;j++)
275 {
276 if(j<(*besEMCGeometry).BSCNbPhi/2) {
277 i=(*besEMCGeometry).BSCNbPhi/2-j-1;
278 } else {
279 i=(*besEMCGeometry).BSCNbPhi*3/2-j-1;
280 }
281 rotateMatrix[i] = new G4RotationMatrix();
282 rotateMatrix[i]->rotateZ(-i*(*besEMCGeometry).BSCPhiDphi
283 -(*besEMCGeometry).BSCAngleRotat
284 -(*besEMCGeometry).BSCPhiDphi/2.
285 -hoi);
286 rotateMatrix[i]->getAngleAxis(delta, axis);
287
288
289
290 ox=oOp*
cos(-90.*deg+(*besEMCGeometry).BSCAngleRotat+hoi
291 +i*(*besEMCGeometry).BSCPhiDphi);
292 oy=oOp*
sin(-90.*deg+(*besEMCGeometry).BSCAngleRotat+hoi
293 +i*(*besEMCGeometry).BSCPhiDphi);
294 oz=0*cm;
295
296 ostringstream strPhi;
297 strPhi << "physicalBSCPhi" << j;
298
299 physiBSCPhi = new G4PVPlacement(rotateMatrix[i],
300 G4ThreeVector(ox,oy,oz),
301 logicBSCPhi,
302 strPhi.str(),
303 logicBSCWorld,
304 false,
305 j);
306
307
308 }
309
310
311
312
313 G4double zHalfLength[50];
314 G4double thetaAxis[50];
315 G4double phiAxis[50];
316 G4double yHalfLength1[50];
317 G4double xHalfLength2[50];
318 G4double xHalfLength1[50];
319 G4double tanAlpha1[50];
320 G4double yHalfLength2[50];
321 G4double xHalfLength4[50];
322 G4double xHalfLength3[50];
323 G4double tanAlpha2[50];
324 G4double xPosition[50];
325 G4double yPosition[50];
326 G4double zPosition[50];
327 G4double thetaPosition[50];
328 for(i=0;i<(*besEMCGeometry).BSCNbTheta;i++)
329 {
330 zHalfLength[i] = (*besEMCGeometry).zHalfLength[i];
331 thetaAxis[i] = (*besEMCGeometry).thetaAxis[i];
332 phiAxis[i] = (*besEMCGeometry).phiAxis[i];
333 yHalfLength1[i] = (*besEMCGeometry).yHalfLength1[i];
334 xHalfLength2[i] = (*besEMCGeometry).xHalfLength2[i];
335 xHalfLength1[i] = (*besEMCGeometry).xHalfLength1[i];
336 tanAlpha1[i] = (*besEMCGeometry).tanAlpha1[i];
337 yHalfLength2[i] = (*besEMCGeometry).yHalfLength2[i];
338 xHalfLength4[i] = (*besEMCGeometry).xHalfLength4[i];
339 xHalfLength3[i] = (*besEMCGeometry).xHalfLength3[i];
340 tanAlpha2[i] = (*besEMCGeometry).tanAlpha2[i];
341 xPosition[i] = (*besEMCGeometry).xPosition[i];
342 yPosition[i] = (*besEMCGeometry).yPosition[i];
343 zPosition[i] = (*besEMCGeometry).zPosition[i];
344 thetaPosition[i]= (*besEMCGeometry).thetaPosition[i];
345 if(verboseLevel>4)
346 G4cout << "The sizes of the "<<i+1<<" crystal are:" << G4endl
347 <<"zHalfLength ="<<zHalfLength[i]/cm<< "(cm)," << G4endl
348 << "thetaAxis ="<<thetaAxis[i]/deg << "(deg),"<< G4endl
349 << "phiAxis ="<< phiAxis[i]/deg << "(deg),"<< G4endl
350 << "yHalfLength1="<<yHalfLength1[i]/cm<<"(cm),"<< G4endl
351 << "xHalfLength1="<<xHalfLength1[i]/cm<<"(cm),"<< G4endl
352 << "xHalfLength2="<<xHalfLength2[i]/cm<<"(cm),"<< G4endl
353 << "tanAlpha1 ="<< tanAlpha1[i] << G4endl
354 << "yHalfLength2="<<yHalfLength2[i]/cm<<"(cm),"<< G4endl
355 << "xHalfLength3="<<xHalfLength3[i]/cm<<"(cm),"<< G4endl
356 << "xHalfLength4="<<xHalfLength4[i]/cm<<"(cm),"<< G4endl
357 << "tanAlpha2 =" << tanAlpha2[i] << "." << G4endl;
358 }
360
361 solidBSCCrystal = new G4Trap("solidCrystal",
362 100*cm, 100*deg, 100*deg,
363 100*cm, 100*cm, 100*cm, 100*deg,
364 100*cm, 100*cm, 100*cm, 100*deg);
365
366 logicBSCCrystal = new G4LogicalVolume(solidBSCCrystal,
367 fCrystalMaterial,
368 "logicalCrystal");
369
371 (startID,
372 thetaNbCrystals,
373 (*besEMCGeometry).BSCNbTheta*2,
374 besEMCGeometry,
375 verboseLevel);
376
377
378
379 solidRear = new G4Box("solidRearBox",
380 (*besEMCGeometry).rearBoxLength/2,
381 (*besEMCGeometry).rearBoxLength/2,
382 (*besEMCGeometry).rearBoxDz/2);
383
384 logicRear = new G4LogicalVolume(solidRear,
385 G4Material::GetMaterial("Air"),
386 "logicalRearBox");
387
388
389 solidOrgGlass = new G4Box("solidOrganicGlass",
390 (*besEMCGeometry).orgGlassLengthX/2,
391 (*besEMCGeometry).orgGlassLengthY/2,
392 (*besEMCGeometry).orgGlassLengthZ/2);
393
394 logicOrgGlass = new G4LogicalVolume(solidOrgGlass,
395 organicGlass,
396 "logicalOrganicGlass");
397
398 physiOrgGlass = new G4PVPlacement(0,
399 G4ThreeVector(0,0,-((*besEMCGeometry).rearBoxDz-(*besEMCGeometry).orgGlassLengthZ)/2),
400 logicOrgGlass,
401 "physicalOrganicGlass",
402 logicRear,
403 false,
404 0);
405
406
407 solidCasingBox = new G4Box("solidCasingBox",
408 (*besEMCGeometry).rearBoxLength/2,
409 (*besEMCGeometry).rearBoxLength/2,
410 (*besEMCGeometry).rearCasingThickness/2);
411
412 solidAirHole = new G4Box("solidAirHole",
413 (*besEMCGeometry).orgGlassLengthX/2,
414 (*besEMCGeometry).orgGlassLengthY/2,
415 (*besEMCGeometry).rearBoxDz/2);
416
417 solidRearCasing = new G4SubtractionSolid("solidRearCasing",
418 solidCasingBox,
419 solidAirHole,
420 0,
421 0);
422
423 logicRearCasing = new G4LogicalVolume(solidRearCasing,
424 rearCasingMaterial,
425 "logicalRearCasing");
426
427 physiRearCasing = new G4PVPlacement(0,
428 G4ThreeVector(0,0,-((*besEMCGeometry).rearBoxDz-(*besEMCGeometry).rearCasingThickness)/2),
429 logicRearCasing,
430 "physicalRearCasing",
431 logicRear,
432 false,
433 0);
434
435
436 solidAlBox = new G4Box("solidAlBox",
437 (*besEMCGeometry).rearBoxLength/2,
438 (*besEMCGeometry).rearBoxLength/2,
439 (*besEMCGeometry).AlPlateDz/2);
440
441 solidAlPlate = new G4SubtractionSolid("solidAlPlate",
442 solidAlBox,
443 solidAirHole,
444 0,
445 0);
446
447 logicAlPlate = new G4LogicalVolume(solidAlPlate,
448 G4Material::GetMaterial("Aluminium"),
449 "logicalAlPlate");
450
451 physiAlPlate = new G4PVPlacement(0,
452 G4ThreeVector(0,0,-((*besEMCGeometry).rearBoxDz/2
453 -(*besEMCGeometry).rearCasingThickness
454 -(*besEMCGeometry).AlPlateDz/2)),
455 logicAlPlate,
456 "physicalAlPlate",
457 logicRear,
458 false,
459 0);
460
461
462 solidPD = new G4Box("solidPD",
463 (*besEMCGeometry).PDLengthX,
464 (*besEMCGeometry).PDLengthY/2,
465 (*besEMCGeometry).PDLengthZ/2);
466
467 logicPD = new G4LogicalVolume(solidPD,
468 G4Material::GetMaterial("M_Silicon"),
469 "logicalPD");
470
471 physiPD = new G4PVPlacement(0,
472 G4ThreeVector(0,0,-((*besEMCGeometry).rearBoxDz/2
473 -(*besEMCGeometry).orgGlassLengthZ
474 -(*besEMCGeometry).PDLengthZ/2)),
475 logicPD,
476 "physicalPD",
477 logicRear,
478 false,
479 0);
480
481
482 solidPreAmpBox = new G4Box("solidPreAmpBox",
483 (*besEMCGeometry).rearBoxLength/2,
484 (*besEMCGeometry).rearBoxLength/2,
485 (*besEMCGeometry).PABoxDz/2);
486
487 logicPreAmpBox = new G4LogicalVolume(solidPreAmpBox,
488 G4Material::GetMaterial("Aluminium"),
489 "logicalPreAmpBox");
490
491 physiPreAmpBox = new G4PVPlacement(0,
492 G4ThreeVector(0,0,-((*besEMCGeometry).rearBoxDz/2
493 -(*besEMCGeometry).rearCasingThickness
494 -(*besEMCGeometry).AlPlateDz
495 -(*besEMCGeometry).PABoxDz/2)),
496 logicPreAmpBox,
497 "physicalPreAmpBox",
498 logicRear,
499 false,
500 0);
501
502
503 solidAirInPABox = new G4Box("solidAirInPABox",
504 (*besEMCGeometry).rearBoxLength/2-(*besEMCGeometry).PABoxThickness,
505 (*besEMCGeometry).rearBoxLength/2-(*besEMCGeometry).PABoxThickness,
506 (*besEMCGeometry).PABoxDz/2-(*besEMCGeometry).PABoxThickness);
507
508 logicAirInPABox = new G4LogicalVolume(solidAirInPABox,
509 G4Material::GetMaterial("Air"),
510 "logicalAirInPABox");
511
512 physiAirInPABox = new G4PVPlacement(0,
513 0,
514 logicAirInPABox,
515 "physicalAirInPABox",
516 logicPreAmpBox,
517 false,
518 0);
519
520
521 solidHangingPlate = new G4Box("solidHangingPlate",
522 (*besEMCGeometry).rearBoxLength/2,
523 (*besEMCGeometry).rearBoxLength/2,
524 (*besEMCGeometry).HangingPlateDz/2);
525
526 logicHangingPlate = new G4LogicalVolume(solidHangingPlate,stainlessSteel,"logicalHangingPlate");
527
528 physiHangingPlate = new G4PVPlacement(0,
529 G4ThreeVector(0,0,-((*besEMCGeometry).rearBoxDz/2
530 -(*besEMCGeometry).rearCasingThickness
531 -(*besEMCGeometry).AlPlateDz
532 -(*besEMCGeometry).PABoxDz
533 -(*besEMCGeometry).HangingPlateDz/2)),
534 logicHangingPlate,
535 "physicalHangingPlate",
536 logicRear,
537 false,
538 0);
539
540
541 solidWaterPipe = new G4Tubs("solidWaterPipe",
542 0,
543 (*besEMCGeometry).waterPipeDr,
544 (*besEMCGeometry).BSCDz,
545 0.*deg,
546 360.*deg);
547
548 logicWaterPipe = new G4LogicalVolume(solidWaterPipe,waterPipe,"logicalWaterPipe");
549
550 physiWaterPipe = new G4PVPlacement(0,
551 G4ThreeVector((*besEMCGeometry).cablePosX[0]-2*(*besEMCGeometry).cableDr,
552 (*besEMCGeometry).cablePosY[0]-(*besEMCGeometry).cableDr-(*besEMCGeometry).waterPipeDr,
553 0),
554 logicWaterPipe,
555 "physicalWaterPipe",
556 logicBSCPhi,
557 false,
558 0);
559
560
561
562
563
564
565 G4String nameCrystalAndCasing="CrystalAndCasing";
566
567 G4int id=0;
568 for(i=startID;i<=thetaNbCrystals;i++)
569 {
570 ostringstream strSolidCasing;
571 strSolidCasing << "solidBSCCasing" << i-1;
572 ostringstream strVolumeCasing;
573 strVolumeCasing << "logicalBSCCasing" << i-1;
574 ostringstream strPhysiCasing;
575 strPhysiCasing << "physicalBSCCasing" << i-1;
576
577 if(i>(*besEMCGeometry).BSCNbTheta)
578 {
579 id=i-(*besEMCGeometry).BSCNbTheta-1;
580 solidBSCTheta = new G4Trap(strSolidCasing.str(),
581 zHalfLength[id],
582 thetaAxis[id],
583 -phiAxis[id],
584 yHalfLength1[id],
585 xHalfLength2[id],
586 xHalfLength1[id],
587 -tanAlpha1[id],
588 yHalfLength2[id],
589 xHalfLength4[id],
590 xHalfLength3[id],
591 -tanAlpha2[id]);
592
593
594
595
596 logicBSCTheta = new G4LogicalVolume(solidBSCTheta,
597 fCasingMaterial,
598 strVolumeCasing.str());
599
600 rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1] = new G4RotationMatrix();
601 rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1]->rotateZ(-90*deg);
602 rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1]
603 ->rotateX(-thetaPosition[id]);
604
605
606 physiBSCTheta =
607 new G4PVPlacement(rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1],
608 G4ThreeVector(xPosition[id],
609 yPosition[id],
610 zPosition[id]),
611 strPhysiCasing.str(),
612 logicBSCTheta,
613 physiBSCPhi,
614 false,
615 i-1);
616
617 if(logicBSCTheta)
618 {
619 G4VisAttributes* rightVisAtt= new G4VisAttributes(G4Colour(1.0,0.,0.));
620 rightVisAtt->SetVisibility(true);
621 logicBSCTheta->SetVisAttributes(rightVisAtt);
622 logicBSCTheta->SetVisAttributes(G4VisAttributes::Invisible);
623 }
624
625 ostringstream strRear;
626 strRear << "physicalRearBox_1_" << i-1;
627
628 physiRear = new G4PVPlacement(rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1],
629 G4ThreeVector((*besEMCGeometry).rearBoxPosX[id],
630 (*besEMCGeometry).rearBoxPosY[id],
631 (*besEMCGeometry).rearBoxPosZ[id]),
632 strRear.str(),
633 logicRear,
634 physiBSCPhi,
635 false,
636 i-1);
637
638 ostringstream strGirder;
639 strGirder << "solidOpenningCutGirder_1_" << i-1;
640 solidOCGirder = new G4Cons(strGirder.str(),
641 (*besEMCGeometry).OCGirderRmin1[id],
642 (*besEMCGeometry).BSCPhiRmax,
643 (*besEMCGeometry).OCGirderRmin2[id],
644 (*besEMCGeometry).BSCPhiRmax,
645 (*besEMCGeometry).OCGirderDz[id]/2,
646 360.*deg-(*besEMCGeometry).OCGirderAngle/2,
647 (*besEMCGeometry).OCGirderAngle/2-da);
648
649 ostringstream strVGirder;
650 strVGirder << "logicalOpenningCutGirder_1_" << i-1;
651 logicOCGirder = new G4LogicalVolume(solidOCGirder,stainlessSteel,strVGirder.str());
652 logicOCGirder->SetVisAttributes(G4VisAttributes::Invisible);
653
654 ostringstream strPGirder;
655 strPGirder << "physicalOpenningCutGirder_1_" << i-1;
656 physiOCGirder = new G4PVPlacement(0,
657 G4ThreeVector(0,0,(*besEMCGeometry).OCGirderPosZ[id]),
658 logicOCGirder,
659 strPGirder.str(),
660 logicBSCPhi,
661 false,
662 0);
663
664 if(id<(*besEMCGeometry).BSCNbTheta-1)
665 {
666 G4double zLength = (*besEMCGeometry).OCGirderPosZ[id+1]
667 -(*besEMCGeometry).OCGirderPosZ[id]
668 -(*besEMCGeometry).OCGirderDz[id+1]/2-(*besEMCGeometry).OCGirderDz[id]/2;
669 G4double zPosition = (*besEMCGeometry).OCGirderPosZ[id+1]
670 -(*besEMCGeometry).OCGirderDz[id+1]/2-zLength/2;
671
672 ostringstream strGirder2;
673 strGirder2 << "solidOpenningCutGirder_2_" << i-1;
674 solidOCGirder = new G4Cons(strGirder2.str(),
675 (*besEMCGeometry).OCGirderRmin2[id],
676 (*besEMCGeometry).BSCPhiRmax,
677 (*besEMCGeometry).OCGirderRmin1[id+1],
678 (*besEMCGeometry).BSCPhiRmax,
679 zLength/2,
680 360.*deg-(*besEMCGeometry).OCGirderAngle/2,
681 (*besEMCGeometry).OCGirderAngle/2-da);
682
683 ostringstream strVGirder2;
684 strVGirder2 << "logicalOpenningCutGirder_2_" << i-1;
685 logicOCGirder = new G4LogicalVolume(solidOCGirder,stainlessSteel,strVGirder2.str());
686 logicOCGirder->SetVisAttributes(G4VisAttributes::Invisible);
687
688 ostringstream strPGirder2;
689 strPGirder2 << "physicalOpenningCutGirder_2_" << i-1;
690 physiOCGirder = new G4PVPlacement(0,
691 G4ThreeVector(0,0,zPosition),
692 logicOCGirder,
693 strPGirder2.str(),
694 logicBSCPhi,
695 false,
696 0);
697 }
698
699 ostringstream strBSCCable;
700 strBSCCable << "solidBSCCable_1_" << i-1;
701 solidCable = new G4Tubs(strBSCCable.str(),
702 0,
703 (*besEMCGeometry).cableDr,
704 (*besEMCGeometry).cableLength[id]/2,
705 0.*deg,
706 360.*deg);
707
708 ostringstream strVBSCCable;
709 strVBSCCable << "logicalBSCCable_1_" << i-1;
710 logicCable = new G4LogicalVolume(solidCable,cable,strVBSCCable.str());
711
712 ostringstream strPBSCCable;
713 strPBSCCable << "physicalBSCCable_1_" << i-1;
714 physiCable = new G4PVPlacement(0,
715 G4ThreeVector((*besEMCGeometry).cablePosX[id],
716 (*besEMCGeometry).cablePosY[id],
717 (*besEMCGeometry).cablePosZ[id]),
718 logicCable,
719 strPBSCCable.str(),
720 logicBSCPhi,
721 false,
722 0);
723 logicCable->SetVisAttributes(G4VisAttributes::Invisible);
724 }
725 else
726 {
727 id=(*besEMCGeometry).BSCNbTheta-i;
728 solidBSCTheta = new G4Trap(strSolidCasing.str(),
729 zHalfLength[id],
730 thetaAxis[id],
731 phiAxis[id],
732 yHalfLength1[id],
733 xHalfLength1[id],
734 xHalfLength2[id],
735 tanAlpha1[id],
736 yHalfLength2[id],
737 xHalfLength3[id],
738 xHalfLength4[id],
739 tanAlpha2[id]);
740
741
742
743
744 logicBSCTheta = new G4LogicalVolume(solidBSCTheta,
745 fCasingMaterial,
746 strVolumeCasing.str());
747
748 rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1] = new G4RotationMatrix();
749 rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1]->rotateZ(-90*deg);
750 rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1]
751 ->rotateX(-180*deg+thetaPosition[id]);
752 physiBSCTheta =
753 new G4PVPlacement(rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1],
754 G4ThreeVector(xPosition[id],
755 yPosition[id],
756 -zPosition[id]),
757 strPhysiCasing.str(),
758 logicBSCTheta,
759 physiBSCPhi,
760 false,
761 i-1);
762 if(logicBSCTheta)
763 {
764 G4VisAttributes* rightVisAtt= new G4VisAttributes(G4Colour(1.0,0.,0.));
765 rightVisAtt->SetVisibility(true);
766 logicBSCTheta->SetVisAttributes(rightVisAtt);
767 logicBSCTheta->SetVisAttributes(G4VisAttributes::Invisible);
768 }
769
770 ostringstream strRear;
771 strRear << "physicalRearBox_2_" << i-1;
772
773 physiRear = new G4PVPlacement(rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1],
774 G4ThreeVector((*besEMCGeometry).rearBoxPosX[id],
775 (*besEMCGeometry).rearBoxPosY[id],
776 -(*besEMCGeometry).rearBoxPosZ[id]),
777 strRear.str(),
778 logicRear,
779 physiBSCPhi,
780 false,
781 i-1);
782
783 ostringstream strGirder;
784 strGirder << "solidOpenningCutGirder_3_" << i-1;
785 solidOCGirder = new G4Cons(strGirder.str(),
786 (*besEMCGeometry).OCGirderRmin2[id],
787 (*besEMCGeometry).BSCPhiRmax,
788 (*besEMCGeometry).OCGirderRmin1[id],
789 (*besEMCGeometry).BSCPhiRmax,
790 (*besEMCGeometry).OCGirderDz[id]/2,
791 360.*deg-(*besEMCGeometry).OCGirderAngle/2,
792 (*besEMCGeometry).OCGirderAngle/2-da);
793
794 ostringstream strVGirder;
795 strVGirder << "logicalOpenningCutGirder_3_" << i-1;
796 logicOCGirder = new G4LogicalVolume(solidOCGirder,stainlessSteel,strVGirder.str());
797 logicOCGirder->SetVisAttributes(G4VisAttributes::Invisible);
798
799 ostringstream strPGirder;
800 strPGirder << "physicalOpenningCutGirder_3_" << i-1;
801 physiOCGirder = new G4PVPlacement(0,
802 G4ThreeVector(0,0,-(*besEMCGeometry).OCGirderPosZ[id]),
803 logicOCGirder,
804 strPGirder.str(),
805 logicBSCPhi,
806 false,
807 0);
808
809 if(id<(*besEMCGeometry).BSCNbTheta-1)
810 {
811 G4double zLength = (*besEMCGeometry).OCGirderPosZ[id+1]-(*besEMCGeometry).OCGirderPosZ[id]
812 -(*besEMCGeometry).OCGirderDz[id+1]/2-(*besEMCGeometry).OCGirderDz[id]/2;
813 G4double zPosition = (*besEMCGeometry).OCGirderPosZ[id+1]-(*besEMCGeometry).OCGirderDz[id+1]/2-zLength/2;
814
815 ostringstream strGirder2;
816 strGirder2 << "solidOpenningCutGirder_4_" << i-1;
817 solidOCGirder = new G4Cons(strGirder2.str(),
818 (*besEMCGeometry).OCGirderRmin1[id+1],
819 (*besEMCGeometry).BSCPhiRmax,
820 (*besEMCGeometry).OCGirderRmin2[id],
821 (*besEMCGeometry).BSCPhiRmax,
822 zLength/2,
823 360.*deg-(*besEMCGeometry).OCGirderAngle/2,
824 (*besEMCGeometry).OCGirderAngle/2-da);
825
826 ostringstream strVGirder2;
827 strVGirder2 << "logicalOpenningCutGirder_4_" << i-1;
828 logicOCGirder
829 = new G4LogicalVolume(solidOCGirder,stainlessSteel,strVGirder2.str());
830 logicOCGirder->SetVisAttributes(G4VisAttributes::Invisible);
831
832 ostringstream strPGirder2;
833 strPGirder2 << "physicalOpenningCutGirder_4_" << i-1;
834 physiOCGirder = new G4PVPlacement(0,
835 G4ThreeVector(0,0,-zPosition),
836 logicOCGirder,
837 strPGirder2.str(),
838 logicBSCPhi,
839 false,
840 0);
841 }
842
843 ostringstream strBSCCable;
844 strBSCCable << "solidBSCCable_2_" << i-1;
845 solidCable = new G4Tubs(strBSCCable.str(),
846 0,
847 (*besEMCGeometry).cableDr,
848 (*besEMCGeometry).cableLength[id]/2,
849 0.*deg,
850 360.*deg);
851
852 ostringstream strVBSCCable;
853 strVBSCCable << "logicalBSCCable_2_" << i-1;
854 logicCable = new G4LogicalVolume(solidCable,cable,strVBSCCable.str());
855
856 ostringstream strPBSCCable;
857 strPBSCCable << "physicalBSCCable_2_" << i-1;
858 physiCable = new G4PVPlacement(0,
859 G4ThreeVector((*besEMCGeometry).cablePosX[id],
860 (*besEMCGeometry).cablePosY[id],
861 -(*besEMCGeometry).cablePosZ[id]),
862 logicCable,
863 strPBSCCable.str(),
864 logicBSCPhi,
865 false,
866 0);
867 logicCable->SetVisAttributes(G4VisAttributes::Invisible);
868
869 }
870
871 ostringstream strCrystal;
872 strCrystal << "physicalCrystal" << i-1;
873 physiBSCCrystal = new G4PVParameterised(
874 strCrystal.str(),
875 logicBSCCrystal,
876 physiBSCTheta,
877 kZAxis,
878 1,
879 crystalParam);
880 (*besEMCGeometry).physiBSCCrystal[i]=physiBSCCrystal;
881
882 physiBSCCrystal->SetCopyNo(i);
883
884
885 if(verboseLevel>4)
886 G4cout << "BesEmcConstruction*****************************"<< G4endl
887 << "point of crystal =" <<physiBSCCrystal << G4endl
888
889 << "point of excepted=" <<physiBSCTheta << G4endl;
890
891 }
892
893
894
895
897
898
901 }
902
903
905
906
907 if(logicEMC&&physiEMC&&verboseLevel>4){
908 G4cout<<"logicEmc "<<logicEMC<<" physiEmc "<<physiEMC<<G4endl;
909 G4cout<<"list geo tree"<<G4endl;
910
911 int NdaughterofEMC = logicEMC->GetNoDaughters();
912
913 for(int i = 0; i < NdaughterofEMC; i++)
914 {
915 G4LogicalVolume *daughterofEmc = logicEMC->GetDaughter(i)->GetLogicalVolume();
916 G4cout<<i<<"/"<<NdaughterofEMC<<" name: "<<daughterofEmc->GetName()<<" "<<daughterofEmc<<" shape: "<<daughterofEmc->GetSolid()->GetName()<<G4endl;
917 int NdaughterofEmc_2 = daughterofEmc->GetNoDaughters();
918 for(int j = 0; j < NdaughterofEmc_2; j++)
919 {
920 G4LogicalVolume *daughterofEmc_2 = daughterofEmc->GetDaughter(j)->GetLogicalVolume();
921 G4cout<<" --> "<<j<<"/"<<NdaughterofEmc_2<<" name: "<<daughterofEmc_2->GetName()<<" "<<daughterofEmc_2<<" shape: "<<daughterofEmc_2->GetSolid()->GetName()<<G4endl;
922 int NdaughterofEmc_3 = daughterofEmc_2->GetNoDaughters();
923 for(int k = 0; k < NdaughterofEmc_3; k++)
924 {
925 G4LogicalVolume *daughterofEmc_3 = daughterofEmc_2->GetDaughter(k)->GetLogicalVolume();
926 G4cout<<" --> "<<k<<"/"<<NdaughterofEmc_3<<" name: "<<daughterofEmc_3->GetName()<<" "<<daughterofEmc_3<<" shape: "<<daughterofEmc_3->GetSolid()->GetName()<<G4endl;
927 int NdaughterofEmc_4 = daughterofEmc_3->GetNoDaughters();
928 for(int m = 0; m < NdaughterofEmc_4; m++)
929 {
930 G4LogicalVolume *daughterofEmc_4 = daughterofEmc_3->GetDaughter(m)->GetLogicalVolume();
931 G4cout<<" --> "<<m<<"/"<<NdaughterofEmc_4<<" name: "<<daughterofEmc_4->GetName()<<" "<<daughterofEmc_4<<" shape: "<<daughterofEmc_4->GetSolid()->GetName()<<G4endl;
932 if(daughterofEmc_3->GetSolid()->GetName().contains("solidBSCCasing"))
933 {
934 G4Trap *Crystal = (G4Trap *)daughterofEmc_3->GetSolid();
935 double hz = Crystal->GetZHalfLength();
936 double hx1 = Crystal->GetXHalfLength1();
937 double hx2 = Crystal->GetXHalfLength2();
938 double hx3 = Crystal->GetXHalfLength3();
939 double hx4 = Crystal->GetXHalfLength4();
940 double hy1 = Crystal->GetYHalfLength1();
941 double hy2 = Crystal->GetYHalfLength2();
942 double tanalpha1 = Crystal->GetTanAlpha1();
943 double tanalpha2 = Crystal->GetTanAlpha2();
944 G4cout<<" --> "<<hx1<<" "<<hx2<<" "<<hx3<<" "<<hx4<<" "<<hy1<<" "<<hy2<<" "<<hz<<" "<<tanalpha1<<" "<<tanalpha2<<G4endl;
945
946 }
947 }
948 }
949 }
950 }
951 }
952
953
954}
double tan(const BesAngle a)
double sin(const BesAngle a)
double cos(const BesAngle a)
void ConstructSPFrame(G4LogicalVolume *, BesEmcGeometry *)
void ConstructEndGeometry(G4LogicalVolume *)
void PrintEMCParameters()
void ComputeEMCParameters()
static EmcG4Geo * Instance()
Get a pointer to the single instance of EmcG4Geo.
G4LogicalVolume * GetTopVolume()
Get the top(world) volume;.