136 gErrorIgnoreLevel = kFatal;
137 besEMCGeometry->ComputeEMCParameters();
139 emcEnd->ComputeParameters();
141 G4SDManager* SDman = G4SDManager::GetSDMpointer();
144 besEMCSD =
new BesEmcSD(
"CalorSD",
this, besEMCGeometry );
145 SDman->AddNewDetector( besEMCSD );
156 physiEMC =
new G4PVPlacement( 0, G4ThreeVector( 0.0, 0.0, 0.0 ), logicEMC,
"physicalEMC",
158 G4cout <<
"logicEmc: === " << logicEMC <<
" physiEmc " << physiEMC << G4endl;
170 phiNbCrystals = ( *besEMCGeometry ).BSCNbPhi;
171 thetaNbCrystals = ( *besEMCGeometry ).BSCNbTheta * 2;
173 G4double da = 0.001 * deg;
178 solidBSC =
new G4Tubs(
179 "solidBSC", ( *besEMCGeometry ).TaperRingRmin1,
180 ( *besEMCGeometry ).BSCRmax + ( *besEMCGeometry ).SPBarThickness +
181 ( *besEMCGeometry ).SPBarThickness1 + 2.1 * mm,
182 ( *besEMCGeometry ).BSCDz + ( *besEMCGeometry ).TaperRingThickness3 +
183 ( *besEMCGeometry ).EndRingDz,
184 0. * deg, 360. * deg );
186 solidESC =
new G4Cons(
"solidESC", ( *emcEnd ).WorldRmin1, ( *emcEnd ).WorldRmax1,
187 ( *emcEnd ).WorldRmin2, ( *emcEnd ).WorldRmax2,
188 ( *emcEnd ).WorldDz / 2, 0. * deg, 360. * deg );
190 solidEMC =
new G4UnionSolid(
"solidEMC0", solidBSC, solidESC, 0,
191 G4ThreeVector( 0, 0, ( *emcEnd ).WorldZPosition ) );
193 G4RotationMatrix* rotateESC =
new G4RotationMatrix();
194 rotateESC->rotateY( 180. * deg );
196 solidEMC =
new G4UnionSolid(
"solidEMC", solidEMC, solidESC, rotateESC,
197 G4ThreeVector( 0, 0, -( *emcEnd ).WorldZPosition ) );
199 logicEMC =
new G4LogicalVolume( solidEMC, G4Material::GetMaterial(
"Air" ),
"logicalEMC" );
201 physiEMC =
new G4PVPlacement( 0, G4ThreeVector(), logicEMC,
"physicalEMC", logicBes,
false,
205 new G4SubtractionSolid(
"solidBSCWorld0", solidBSC, solidESC, 0,
206 G4ThreeVector( 0, 0, ( *emcEnd ).WorldZPosition ) );
209 new G4SubtractionSolid(
"solidBSCWorld", solidBSCWorld, solidESC, rotateESC,
210 G4ThreeVector( 0, 0, -( *emcEnd ).WorldZPosition ) );
212 logicBSCWorld =
new G4LogicalVolume( solidBSCWorld, G4Material::GetMaterial(
"Air" ),
215 G4RotationMatrix* rotBSC =
new G4RotationMatrix();
216 rotBSC->rotateY( 180. * deg );
217 physiBSCWorld =
new G4PVPlacement( rotBSC, G4ThreeVector(), logicBSCWorld,
218 "physicalBSCWorld", logicEMC,
false, 0,
CHECKLV1 );
220 G4RotationMatrix* rotateMatrix[200];
221 G4double oOp, ox, oy, oz;
222 G4double delta = 0 * deg;
223 G4ThreeVector axis = G4ThreeVector( 0, 0, 0 );
224 oOp = ( *besEMCGeometry ).BSCRmin /
225 sin( 0.5 * ( *besEMCGeometry ).BSCPhiDphi + 90 * deg ) *
226 sin( ( *besEMCGeometry ).BSCAngleRotat );
227 G4double ll = ( *besEMCGeometry ).BSCCryLength;
228 G4double rr = ( *besEMCGeometry ).BSCRmin;
229 G4double oj = sqrt( ll * ll + rr * rr -
230 2 * ll * rr *
cos( 180. * deg - ( *besEMCGeometry ).BSCAngleRotat ) );
232 90. * deg - ( *besEMCGeometry ).BSCPhiDphi / 2. - ( *besEMCGeometry ).BSCAngleRotat;
233 G4double doj = asin(
sin( 180. * deg - ( *besEMCGeometry ).BSCAngleRotat ) / oj * ll );
234 G4double ioj = ( *besEMCGeometry ).BSCPhiDphi / 2. + doj;
235 G4double ij = oj /
sin( oij ) *
sin( ioj );
236 G4double dOp = rr /
sin( 90. * deg - ( *besEMCGeometry ).BSCPhiDphi / 2. ) *
237 sin( 90. * deg + ( *besEMCGeometry ).BSCPhiDphi / 2. -
238 ( *besEMCGeometry ).BSCAngleRotat );
239 G4double cOp = rr /
sin( 90. * deg + ( *besEMCGeometry ).BSCPhiDphi / 2. ) *
240 sin( 90. * deg - ( *besEMCGeometry ).BSCPhiDphi / 2. -
241 ( *besEMCGeometry ).BSCAngleRotat );
242 G4double ch = ( dOp + ll ) /
cos( ( *besEMCGeometry ).BSCPhiDphi ) - cOp;
243 G4double hi = ( dOp + ll ) *
tan( ( *besEMCGeometry ).BSCPhiDphi ) - ij;
244 G4double oh = sqrt( ch * ch + rr * rr -
245 2 * ch * rr *
cos( 180 * deg - ( *besEMCGeometry ).BSCAngleRotat ) );
246 G4double hoi = asin(
sin( 180 * deg - oij ) / oh * hi );
247 G4double dok = asin(
sin( 180 * deg - ( *besEMCGeometry ).BSCAngleRotat ) / oh * ch );
248 if ( verboseLevel > 3 )
249 G4cout <<
"oj=" << oj / cm << G4endl <<
"oij=" << oij / deg << G4endl
250 <<
"doj=" << doj / deg << G4endl <<
"ioj=" << ioj / deg << G4endl
251 <<
"ij=" << ij / cm << G4endl <<
"dOp=" << dOp / cm << G4endl
252 <<
"cOp=" << cOp / cm << G4endl <<
"ch=" << ch / cm << G4endl <<
"hi=" << hi / cm
253 << G4endl <<
"oh=" << oh / cm << G4endl <<
"hoi=" << hoi / deg << G4endl
254 <<
"dok=" << dok / deg << G4endl;
257 G4double cmo = asin(
sin( 180 * degree - ( *besEMCGeometry ).BSCAngleRotat ) /
258 ( *besEMCGeometry ).BSCRmax2 * dOp );
259 G4double cm = ( *besEMCGeometry ).BSCRmax2 /
260 sin( 180 * degree - ( *besEMCGeometry ).BSCAngleRotat ) *
261 sin( ( *besEMCGeometry ).BSCAngleRotat - cmo );
262 G4ThreeVector Pout( dOp + cm *
cos( ( *besEMCGeometry ).BSCAngleRotat ),
263 -cm *
sin( ( *besEMCGeometry ).BSCAngleRotat ),
264 ( *besEMCGeometry ).BSCDz );
266 G4double rTaperRingOuter1 =
267 ( *besEMCGeometry ).TaperRingRmin1 + ( *besEMCGeometry ).TaperRingThickness1;
268 G4double rTaperRingOuter2 =
269 ( *besEMCGeometry ).TaperRingRmin2 + ( *besEMCGeometry ).TaperRingDr;
270 G4double zTaperRing1 = ( *besEMCGeometry ).BSCDz +
271 ( *besEMCGeometry ).TaperRingThickness3 -
272 ( *besEMCGeometry ).TaperRingDz;
273 G4double zTaperRing2 = ( *besEMCGeometry ).BSCDz + ( *besEMCGeometry ).TaperRingThickness3;
275 G4RotationMatrix* rotIntersection =
new G4RotationMatrix();
276 rotIntersection->rotateZ( -( *besEMCGeometry ).BSCAngleRotat -
277 ( *besEMCGeometry ).BSCPhiDphi / 2. - hoi );
278 G4ThreeVector
P( oOp *
cos( -90. * deg + ( *besEMCGeometry ).BSCAngleRotat + hoi ),
279 oOp *
sin( -90. * deg + ( *besEMCGeometry ).BSCAngleRotat + hoi ), 0 );
280 G4AffineTransform Td( rotIntersection,
P );
281 G4ThreeVector md = Td.Inverse().TransformPoint( G4ThreeVector( 0, 0, 0 ) );
282 G4ThreeVector vd = Td.Inverse().TransformPoint( Pout );
284 G4double zPlane0[4] = { -( *besEMCGeometry ).BSCDz, -zTaperRing1, zTaperRing1,
285 ( *besEMCGeometry ).BSCDz };
286 G4double rInner0[4] = { vd.perp(), cOp, cOp, vd.perp() };
287 G4double rOuter0[4] = { ( *besEMCGeometry ).BSCPhiRmax, ( *besEMCGeometry ).BSCPhiRmax,
288 ( *besEMCGeometry ).BSCPhiRmax, ( *besEMCGeometry ).BSCPhiRmax };
290 G4double zPlane1[4] = { -zTaperRing2, -zTaperRing1, zTaperRing1, zTaperRing2 };
291 G4double rInner1[4] = { rTaperRingOuter2, rTaperRingOuter1, rTaperRingOuter1,
293 G4double rOuter1[4] = { ( *besEMCGeometry ).BSCRmax, ( *besEMCGeometry ).BSCRmax,
294 ( *besEMCGeometry ).BSCRmax, ( *besEMCGeometry ).BSCRmax };
296 G4VSolid* solidBSCPhi1 =
297 new G4Polycone(
"solidBSCPhi1", 0, 360 * deg, 4, zPlane1, rInner1, rOuter1 );
298 G4VSolid* solidBSCPhi0 =
299 new G4Polyhedra(
"solidBSCPhi0", 360. * deg - ( *besEMCGeometry ).BSCPhiDphi,
300 ( *besEMCGeometry ).BSCPhiDphi, ( *besEMCGeometry ).BSCNbPhi / 2, 4,
301 zPlane0, rInner0, rOuter0 );
302 G4IntersectionSolid* solidBSCPhi =
303 new G4IntersectionSolid(
"solidBSCPhi", solidBSCPhi0, solidBSCPhi1, 0, md );
306 new G4LogicalVolume( solidBSCPhi, G4Material::GetMaterial(
"Air" ),
"logicalBSCPhi" );
309 for ( G4int j = 0; j < ( *besEMCGeometry ).BSCNbPhi; j++ )
311 if ( j < ( *besEMCGeometry ).BSCNbPhi / 2 )
313 i = ( *besEMCGeometry ).BSCNbPhi / 2 - j - 1;
317 i = ( *besEMCGeometry ).BSCNbPhi * 3 / 2 - j - 1;
319 rotateMatrix[i] =
new G4RotationMatrix();
320 rotateMatrix[i]->rotateZ( -i * ( *besEMCGeometry ).BSCPhiDphi -
321 ( *besEMCGeometry ).BSCAngleRotat -
322 ( *besEMCGeometry ).BSCPhiDphi / 2. - hoi );
323 rotateMatrix[i]->getAngleAxis( delta, axis );
327 ox = oOp *
cos( -90. * deg + ( *besEMCGeometry ).BSCAngleRotat + hoi +
328 i * ( *besEMCGeometry ).BSCPhiDphi );
329 oy = oOp *
sin( -90. * deg + ( *besEMCGeometry ).BSCAngleRotat + hoi +
330 i * ( *besEMCGeometry ).BSCPhiDphi );
333 ostringstream strPhi;
334 strPhi <<
"physicalBSCPhi" << j;
337 new G4PVPlacement( rotateMatrix[i], G4ThreeVector( ox, oy, oz ), logicBSCPhi,
338 strPhi.str(), logicBSCWorld,
false, j,
CHECKLV2 );
347 G4double zHalfLength[50];
348 G4double thetaAxis[50];
349 G4double phiAxis[50];
350 G4double yHalfLength1[50];
351 G4double xHalfLength2[50];
352 G4double xHalfLength1[50];
353 G4double tanAlpha1[50];
354 G4double yHalfLength2[50];
355 G4double xHalfLength4[50];
356 G4double xHalfLength3[50];
357 G4double tanAlpha2[50];
358 G4double xPosition[50];
359 G4double yPosition[50];
360 G4double zPosition[50];
361 G4double thetaPosition[50];
362 for ( i = 0; i < ( *besEMCGeometry ).BSCNbTheta; i++ )
364 zHalfLength[i] = ( *besEMCGeometry ).zHalfLength[i];
365 thetaAxis[i] = ( *besEMCGeometry ).thetaAxis[i];
366 phiAxis[i] = ( *besEMCGeometry ).phiAxis[i];
367 yHalfLength1[i] = ( *besEMCGeometry ).yHalfLength1[i];
368 xHalfLength2[i] = ( *besEMCGeometry ).xHalfLength2[i];
369 xHalfLength1[i] = ( *besEMCGeometry ).xHalfLength1[i];
370 tanAlpha1[i] = ( *besEMCGeometry ).tanAlpha1[i];
371 yHalfLength2[i] = ( *besEMCGeometry ).yHalfLength2[i];
372 xHalfLength4[i] = ( *besEMCGeometry ).xHalfLength4[i];
373 xHalfLength3[i] = ( *besEMCGeometry ).xHalfLength3[i];
374 tanAlpha2[i] = ( *besEMCGeometry ).tanAlpha2[i];
375 xPosition[i] = ( *besEMCGeometry ).xPosition[i];
376 yPosition[i] = ( *besEMCGeometry ).yPosition[i];
377 zPosition[i] = ( *besEMCGeometry ).zPosition[i];
378 thetaPosition[i] = ( *besEMCGeometry ).thetaPosition[i];
379 if ( verboseLevel > 4 )
380 G4cout <<
"The sizes of the " << i + 1 <<
" crystal are:" << G4endl
381 <<
"zHalfLength =" << zHalfLength[i] / cm <<
"(cm)," << G4endl
382 <<
"thetaAxis =" << thetaAxis[i] / deg <<
"(deg)," << G4endl
383 <<
"phiAxis =" << phiAxis[i] / deg <<
"(deg)," << G4endl
384 <<
"yHalfLength1=" << yHalfLength1[i] / cm <<
"(cm)," << G4endl
385 <<
"xHalfLength1=" << xHalfLength1[i] / cm <<
"(cm)," << G4endl
386 <<
"xHalfLength2=" << xHalfLength2[i] / cm <<
"(cm)," << G4endl
387 <<
"tanAlpha1 =" << tanAlpha1[i] << G4endl
388 <<
"yHalfLength2=" << yHalfLength2[i] / cm <<
"(cm)," << G4endl
389 <<
"xHalfLength3=" << xHalfLength3[i] / cm <<
"(cm)," << G4endl
390 <<
"xHalfLength4=" << xHalfLength4[i] / cm <<
"(cm)," << G4endl
391 <<
"tanAlpha2 =" << tanAlpha2[i] <<
"." << G4endl;
393 besEMCGeometry->ModifyForCasing();
396 new G4Trap(
"solidCrystal", 100 * cm, 100 * deg, 100 * deg, 100 * cm, 100 * cm,
397 100 * cm, 100 * deg, 100 * cm, 100 * cm, 100 * cm, 100 * deg );
400 new G4LogicalVolume( solidBSCCrystal, fCrystalMaterial,
"logicalCrystal" );
403 ( *besEMCGeometry ).BSCNbTheta * 2,
404 besEMCGeometry, verboseLevel );
409 new G4Box(
"solidRearBox", ( *besEMCGeometry ).rearBoxLength / 2,
410 ( *besEMCGeometry ).rearBoxLength / 2, ( *besEMCGeometry ).rearBoxDz / 2 );
413 new G4LogicalVolume( solidRear, G4Material::GetMaterial(
"Air" ),
"logicalRearBox" );
416 solidOrgGlass =
new G4Box(
"solidOrganicGlass", ( *besEMCGeometry ).orgGlassLengthX / 2,
417 ( *besEMCGeometry ).orgGlassLengthY / 2,
418 ( *besEMCGeometry ).orgGlassLengthZ / 2 );
420 logicOrgGlass =
new G4LogicalVolume( solidOrgGlass, organicGlass,
"logicalOrganicGlass" );
422 physiOrgGlass =
new G4PVPlacement(
426 -( ( *besEMCGeometry ).rearBoxDz - ( *besEMCGeometry ).orgGlassLengthZ ) / 2 ),
427 logicOrgGlass,
"physicalOrganicGlass", logicRear,
false, 0,
CHECKLV4 );
430 solidCasingBox =
new G4Box(
"solidCasingBox", ( *besEMCGeometry ).rearBoxLength / 2,
431 ( *besEMCGeometry ).rearBoxLength / 2,
432 ( *besEMCGeometry ).rearCasingThickness / 2 );
435 new G4Box(
"solidAirHole", ( *besEMCGeometry ).orgGlassLengthX / 2,
436 ( *besEMCGeometry ).orgGlassLengthY / 2,
437 ( *besEMCGeometry ).rearBoxDz / 2 );
439 solidRearCasing =
new G4SubtractionSolid(
"solidRearCasing", solidCasingBox, solidAirHole,
440 0, G4ThreeVector() );
443 new G4LogicalVolume( solidRearCasing, rearCasingMaterial,
"logicalRearCasing" );
445 physiRearCasing =
new G4PVPlacement(
449 -( ( *besEMCGeometry ).rearBoxDz - ( *besEMCGeometry ).rearCasingThickness ) / 2 ),
450 logicRearCasing,
"physicalRearCasing", logicRear,
false, 0,
CHECKLV4 );
454 new G4Box(
"solidAlBox", ( *besEMCGeometry ).rearBoxLength / 2,
455 ( *besEMCGeometry ).rearBoxLength / 2, ( *besEMCGeometry ).AlPlateDz / 2 );
458 new G4SubtractionSolid(
"solidAlPlate", solidAlBox, solidAirHole, 0, G4ThreeVector() );
460 logicAlPlate =
new G4LogicalVolume( solidAlPlate, G4Material::GetMaterial(
"Aluminium" ),
464 new G4PVPlacement( 0,
466 -( ( *besEMCGeometry ).rearBoxDz / 2 -
467 ( *besEMCGeometry ).rearCasingThickness -
468 ( *besEMCGeometry ).AlPlateDz / 2 ) ),
469 logicAlPlate,
"physicalAlPlate", logicRear,
false, 0,
CHECKLV4 );
473 new G4Box(
"solidPD",
474 ( *besEMCGeometry ).PDLengthX,
475 ( *besEMCGeometry ).PDLengthY / 2, ( *besEMCGeometry ).PDLengthZ / 2 );
478 new G4LogicalVolume( solidPD, G4Material::GetMaterial(
"M_Silicon" ),
"logicalPD" );
480 physiPD =
new G4PVPlacement( 0,
482 -( ( *besEMCGeometry ).rearBoxDz / 2 -
483 ( *besEMCGeometry ).orgGlassLengthZ -
484 ( *besEMCGeometry ).PDLengthZ / 2 ) ),
485 logicPD,
"physicalPD", logicRear,
false, 0,
CHECKLV4 );
489 new G4Box(
"solidPreAmpBox", ( *besEMCGeometry ).rearBoxLength / 2,
490 ( *besEMCGeometry ).rearBoxLength / 2, ( *besEMCGeometry ).PABoxDz / 2 );
492 logicPreAmpBox =
new G4LogicalVolume(
493 solidPreAmpBox, G4Material::GetMaterial(
"Aluminium" ),
"logicalPreAmpBox" );
495 physiPreAmpBox =
new G4PVPlacement(
498 -( ( *besEMCGeometry ).rearBoxDz / 2 -
499 ( *besEMCGeometry ).rearCasingThickness -
500 ( *besEMCGeometry ).AlPlateDz - ( *besEMCGeometry ).PABoxDz / 2 ) ),
501 logicPreAmpBox,
"physicalPreAmpBox", logicRear,
false, 0,
CHECKLV4 );
505 new G4Box(
"solidAirInPABox",
506 ( *besEMCGeometry ).rearBoxLength / 2 - ( *besEMCGeometry ).PABoxThickness,
507 ( *besEMCGeometry ).rearBoxLength / 2 - ( *besEMCGeometry ).PABoxThickness,
508 ( *besEMCGeometry ).PABoxDz / 2 - ( *besEMCGeometry ).PABoxThickness );
510 logicAirInPABox =
new G4LogicalVolume( solidAirInPABox, G4Material::GetMaterial(
"Air" ),
511 "logicalAirInPABox" );
514 new G4PVPlacement( 0, G4ThreeVector(), logicAirInPABox,
"physicalAirInPABox",
515 logicPreAmpBox,
false, 0,
CHECKLV5 );
518 solidHangingPlate =
new G4Box(
"solidHangingPlate", ( *besEMCGeometry ).rearBoxLength / 2,
519 ( *besEMCGeometry ).rearBoxLength / 2,
520 ( *besEMCGeometry ).HangingPlateDz / 2 );
523 new G4LogicalVolume( solidHangingPlate, stainlessSteel,
"logicalHangingPlate" );
525 physiHangingPlate =
new G4PVPlacement(
528 -( ( *besEMCGeometry ).rearBoxDz / 2 -
529 ( *besEMCGeometry ).rearCasingThickness -
530 ( *besEMCGeometry ).AlPlateDz - ( *besEMCGeometry ).PABoxDz -
531 ( *besEMCGeometry ).HangingPlateDz / 2 ) ),
532 logicHangingPlate,
"physicalHangingPlate", logicRear,
false, 0,
CHECKLV4 );
535 solidWaterPipe =
new G4Tubs(
"solidWaterPipe", 0, ( *besEMCGeometry ).waterPipeDr,
536 ( *besEMCGeometry ).BSCDz, 0. * deg, 360. * deg );
538 logicWaterPipe =
new G4LogicalVolume( solidWaterPipe, waterPipe,
"logicalWaterPipe" );
540 physiWaterPipe =
new G4PVPlacement(
542 G4ThreeVector( ( *besEMCGeometry ).cablePosX[0] - 2 * ( *besEMCGeometry ).cableDr,
543 ( *besEMCGeometry ).cablePosY[0] - ( *besEMCGeometry ).cableDr -
544 ( *besEMCGeometry ).waterPipeDr,
546 logicWaterPipe,
"physicalWaterPipe", logicBSCPhi,
false, 0,
CHECKLV3 );
552 G4String nameCrystalAndCasing =
"CrystalAndCasing";
555 for ( i = startID; i <= thetaNbCrystals; i++ )
557 ostringstream strSolidCasing;
558 strSolidCasing <<
"solidBSCCasing" << i - 1;
559 ostringstream strVolumeCasing;
560 strVolumeCasing <<
"logicalBSCCasing" << i - 1;
561 ostringstream strPhysiCasing;
562 strPhysiCasing <<
"physicalBSCCasing" << i - 1;
564 if ( i > ( *besEMCGeometry ).BSCNbTheta )
566 id = i - ( *besEMCGeometry ).BSCNbTheta - 1;
568 new G4Trap( strSolidCasing.str(), zHalfLength[
id], thetaAxis[
id], -phiAxis[
id],
569 yHalfLength1[
id], xHalfLength2[
id], xHalfLength1[
id], -tanAlpha1[
id],
570 yHalfLength2[
id], xHalfLength4[
id], xHalfLength3[
id], -tanAlpha2[
id] );
577 new G4LogicalVolume( solidBSCTheta, fCasingMaterial, strVolumeCasing.str() );
579 rotateMatrix[( *besEMCGeometry ).BSCNbPhi + i - 1] =
new G4RotationMatrix();
580 rotateMatrix[( *besEMCGeometry ).BSCNbPhi + i - 1]->rotateZ( -90 * deg );
581 rotateMatrix[( *besEMCGeometry ).BSCNbPhi + i - 1]->rotateX( -thetaPosition[
id] );
583 physiBSCTheta =
new G4PVPlacement(
584 rotateMatrix[( *besEMCGeometry ).BSCNbPhi + i - 1],
585 G4ThreeVector( xPosition[
id], yPosition[
id], zPosition[
id] ), strPhysiCasing.str(),
586 logicBSCTheta, physiBSCPhi,
false, i - 1,
CHECKLV3 );
590 G4VisAttributes* rightVisAtt =
new G4VisAttributes( G4Colour( 1.0, 0., 0. ) );
591 rightVisAtt->SetVisibility(
true );
592 logicBSCTheta->SetVisAttributes( rightVisAtt );
593 logicBSCTheta->SetVisAttributes( G4VisAttributes::Invisible );
596 ostringstream strRear;
597 strRear <<
"physicalRearBox_1_" << i - 1;
600 new G4PVPlacement( rotateMatrix[( *besEMCGeometry ).BSCNbPhi + i - 1],
601 G4ThreeVector( ( *besEMCGeometry ).rearBoxPosX[
id],
602 ( *besEMCGeometry ).rearBoxPosY[
id],
603 ( *besEMCGeometry ).rearBoxPosZ[
id] ),
604 strRear.str(), logicRear, physiBSCPhi,
false, i - 1,
CHECKLV3 );
606 ostringstream strGirder;
607 strGirder <<
"solidOpenningCutGirder_1_" << i - 1;
609 new G4Cons( strGirder.str(), ( *besEMCGeometry ).OCGirderRmin1[
id],
610 ( *besEMCGeometry ).BSCPhiRmax, ( *besEMCGeometry ).OCGirderRmin2[
id],
611 ( *besEMCGeometry ).BSCPhiRmax, ( *besEMCGeometry ).OCGirderDz[
id] / 2,
612 360. * deg - ( *besEMCGeometry ).OCGirderAngle / 2,
613 ( *besEMCGeometry ).OCGirderAngle / 2 - da );
615 ostringstream strVGirder;
616 strVGirder <<
"logicalOpenningCutGirder_1_" << i - 1;
617 logicOCGirder =
new G4LogicalVolume( solidOCGirder, stainlessSteel, strVGirder.str() );
618 logicOCGirder->SetVisAttributes( G4VisAttributes::Invisible );
620 ostringstream strPGirder;
621 strPGirder <<
"physicalOpenningCutGirder_1_" << i - 1;
622 physiOCGirder =
new G4PVPlacement(
623 0, G4ThreeVector( 0, 0, ( *besEMCGeometry ).OCGirderPosZ[
id] ), logicOCGirder,
624 strPGirder.str(), logicBSCPhi,
false, 0,
CHECKLV3 );
626 if (
id < ( *besEMCGeometry ).BSCNbTheta - 1 )
628 G4double zLength = ( *besEMCGeometry ).OCGirderPosZ[
id + 1] -
629 ( *besEMCGeometry ).OCGirderPosZ[id] -
630 ( *besEMCGeometry ).OCGirderDz[
id + 1] / 2 -
631 ( *besEMCGeometry ).OCGirderDz[id] / 2;
632 G4double zPositionOCGirder = ( *besEMCGeometry ).OCGirderPosZ[
id + 1] -
633 ( *besEMCGeometry ).OCGirderDz[
id + 1] / 2 -
636 ostringstream strGirder2;
637 strGirder2 <<
"solidOpenningCutGirder_2_" << i - 1;
638 solidOCGirder =
new G4Cons( strGirder2.str(), ( *besEMCGeometry ).OCGirderRmin2[
id],
639 ( *besEMCGeometry ).BSCPhiRmax,
640 ( *besEMCGeometry ).OCGirderRmin1[
id + 1],
641 ( *besEMCGeometry ).BSCPhiRmax, zLength / 2,
642 360. * deg - ( *besEMCGeometry ).OCGirderAngle / 2,
643 ( *besEMCGeometry ).OCGirderAngle / 2 - da );
645 ostringstream strVGirder2;
646 strVGirder2 <<
"logicalOpenningCutGirder_2_" << i - 1;
648 new G4LogicalVolume( solidOCGirder, stainlessSteel, strVGirder2.str() );
649 logicOCGirder->SetVisAttributes( G4VisAttributes::Invisible );
651 ostringstream strPGirder2;
652 strPGirder2 <<
"physicalOpenningCutGirder_2_" << i - 1;
654 new G4PVPlacement( 0, G4ThreeVector( 0, 0, zPositionOCGirder ), logicOCGirder,
655 strPGirder2.str(), logicBSCPhi,
false, 0,
CHECKLV3 );
658 ostringstream strBSCCable;
659 strBSCCable <<
"solidBSCCable_1_" << i - 1;
661 new G4Tubs( strBSCCable.str(), 0, ( *besEMCGeometry ).cableDr,
662 ( *besEMCGeometry ).cableLength[
id] / 2, 0. * deg, 360. * deg );
664 ostringstream strVBSCCable;
665 strVBSCCable <<
"logicalBSCCable_1_" << i - 1;
666 logicCable =
new G4LogicalVolume( solidCable, cable, strVBSCCable.str() );
668 ostringstream strPBSCCable;
669 strPBSCCable <<
"physicalBSCCable_1_" << i - 1;
670 physiCable =
new G4PVPlacement( 0,
671 G4ThreeVector( ( *besEMCGeometry ).cablePosX[
id],
672 ( *besEMCGeometry ).cablePosY[
id],
673 ( *besEMCGeometry ).cablePosZ[
id] ),
674 logicCable, strPBSCCable.str(), logicBSCPhi,
false, 0,
676 logicCable->SetVisAttributes( G4VisAttributes::Invisible );
680 id = ( *besEMCGeometry ).BSCNbTheta - i;
682 new G4Trap( strSolidCasing.str(), zHalfLength[
id], thetaAxis[
id], phiAxis[
id],
683 yHalfLength1[
id], xHalfLength1[
id], xHalfLength2[
id], tanAlpha1[
id],
684 yHalfLength2[
id], xHalfLength3[
id], xHalfLength4[
id], tanAlpha2[
id] );
691 new G4LogicalVolume( solidBSCTheta, fCasingMaterial, strVolumeCasing.str() );
693 rotateMatrix[( *besEMCGeometry ).BSCNbPhi + i - 1] =
new G4RotationMatrix();
694 rotateMatrix[( *besEMCGeometry ).BSCNbPhi + i - 1]->rotateZ( -90 * deg );
695 rotateMatrix[( *besEMCGeometry ).BSCNbPhi + i - 1]->rotateX( -180 * deg +
697 physiBSCTheta =
new G4PVPlacement(
698 rotateMatrix[( *besEMCGeometry ).BSCNbPhi + i - 1],
699 G4ThreeVector( xPosition[
id], yPosition[
id], -zPosition[
id] ),
700 strPhysiCasing.str(), logicBSCTheta, physiBSCPhi,
false, i - 1,
CHECKLV3 );
703 G4VisAttributes* rightVisAtt =
new G4VisAttributes( G4Colour( 1.0, 0., 0. ) );
704 rightVisAtt->SetVisibility(
true );
705 logicBSCTheta->SetVisAttributes( rightVisAtt );
706 logicBSCTheta->SetVisAttributes( G4VisAttributes::Invisible );
709 ostringstream strRear;
710 strRear <<
"physicalRearBox_2_" << i - 1;
713 new G4PVPlacement( rotateMatrix[( *besEMCGeometry ).BSCNbPhi + i - 1],
714 G4ThreeVector( ( *besEMCGeometry ).rearBoxPosX[
id],
715 ( *besEMCGeometry ).rearBoxPosY[
id],
716 -( *besEMCGeometry ).rearBoxPosZ[
id] ),
717 strRear.str(), logicRear, physiBSCPhi,
false, i - 1,
CHECKLV3 );
719 ostringstream strGirder;
720 strGirder <<
"solidOpenningCutGirder_3_" << i - 1;
722 new G4Cons( strGirder.str(), ( *besEMCGeometry ).OCGirderRmin2[
id],
723 ( *besEMCGeometry ).BSCPhiRmax, ( *besEMCGeometry ).OCGirderRmin1[
id],
724 ( *besEMCGeometry ).BSCPhiRmax, ( *besEMCGeometry ).OCGirderDz[
id] / 2,
725 360. * deg - ( *besEMCGeometry ).OCGirderAngle / 2,
726 ( *besEMCGeometry ).OCGirderAngle / 2 - da );
728 ostringstream strVGirder;
729 strVGirder <<
"logicalOpenningCutGirder_3_" << i - 1;
730 logicOCGirder =
new G4LogicalVolume( solidOCGirder, stainlessSteel, strVGirder.str() );
731 logicOCGirder->SetVisAttributes( G4VisAttributes::Invisible );
733 ostringstream strPGirder;
734 strPGirder <<
"physicalOpenningCutGirder_3_" << i - 1;
735 physiOCGirder =
new G4PVPlacement(
736 0, G4ThreeVector( 0, 0, -( *besEMCGeometry ).OCGirderPosZ[
id] ), logicOCGirder,
737 strPGirder.str(), logicBSCPhi,
false, 0,
CHECKLV3 );
739 if (
id < ( *besEMCGeometry ).BSCNbTheta - 1 )
741 G4double zLength = ( *besEMCGeometry ).OCGirderPosZ[
id + 1] -
742 ( *besEMCGeometry ).OCGirderPosZ[id] -
743 ( *besEMCGeometry ).OCGirderDz[
id + 1] / 2 -
744 ( *besEMCGeometry ).OCGirderDz[id] / 2;
745 G4double zPositionOCGirder = ( *besEMCGeometry ).OCGirderPosZ[
id + 1] -
746 ( *besEMCGeometry ).OCGirderDz[
id + 1] / 2 -
749 ostringstream strGirder2;
750 strGirder2 <<
"solidOpenningCutGirder_4_" << i - 1;
751 solidOCGirder =
new G4Cons(
752 strGirder2.str(), ( *besEMCGeometry ).OCGirderRmin1[
id + 1],
753 ( *besEMCGeometry ).BSCPhiRmax, ( *besEMCGeometry ).OCGirderRmin2[
id],
754 ( *besEMCGeometry ).BSCPhiRmax, zLength / 2,
755 360. * deg - ( *besEMCGeometry ).OCGirderAngle / 2,
756 ( *besEMCGeometry ).OCGirderAngle / 2 - da );
758 ostringstream strVGirder2;
759 strVGirder2 <<
"logicalOpenningCutGirder_4_" << i - 1;
761 new G4LogicalVolume( solidOCGirder, stainlessSteel, strVGirder2.str() );
762 logicOCGirder->SetVisAttributes( G4VisAttributes::Invisible );
764 ostringstream strPGirder2;
765 strPGirder2 <<
"physicalOpenningCutGirder_4_" << i - 1;
767 new G4PVPlacement( 0, G4ThreeVector( 0, 0, -zPositionOCGirder ), logicOCGirder,
768 strPGirder2.str(), logicBSCPhi,
false, 0,
CHECKLV3 );
771 ostringstream strBSCCable;
772 strBSCCable <<
"solidBSCCable_2_" << i - 1;
774 new G4Tubs( strBSCCable.str(), 0, ( *besEMCGeometry ).cableDr,
775 ( *besEMCGeometry ).cableLength[
id] / 2, 0. * deg, 360. * deg );
777 ostringstream strVBSCCable;
778 strVBSCCable <<
"logicalBSCCable_2_" << i - 1;
779 logicCable =
new G4LogicalVolume( solidCable, cable, strVBSCCable.str() );
781 ostringstream strPBSCCable;
782 strPBSCCable <<
"physicalBSCCable_2_" << i - 1;
783 physiCable =
new G4PVPlacement( 0,
784 G4ThreeVector( ( *besEMCGeometry ).cablePosX[
id],
785 ( *besEMCGeometry ).cablePosY[
id],
786 -( *besEMCGeometry ).cablePosZ[
id] ),
787 logicCable, strPBSCCable.str(), logicBSCPhi,
false, 0,
789 logicCable->SetVisAttributes( G4VisAttributes::Invisible );
792 ostringstream strCrystal;
793 strCrystal <<
"physicalCrystal" << i - 1;
795 new G4PVParameterised( strCrystal.str(), logicBSCCrystal, physiBSCTheta, kZAxis,
798 ( *besEMCGeometry ).physiBSCCrystal[i] = physiBSCCrystal;
800 physiBSCCrystal->SetCopyNo( i );
801 if (
CHECKLV4 ) physiBSCCrystal->CheckOverlaps();
803 if ( verboseLevel > 4 )
805 <<
"BesEmcConstruction*****************************" << G4endl
806 <<
"point of crystal =" << physiBSCCrystal
809 <<
"point of excepted=" << physiBSCTheta << G4endl;
826 if ( logicEMC && physiEMC && verboseLevel > 4 )
828 G4cout <<
"logicEmc " << logicEMC <<
" physiEmc " << physiEMC << G4endl;
829 G4cout <<
"list geo tree" << G4endl;
831 int NdaughterofEMC = logicEMC->GetNoDaughters();
833 for (
int i = 0; i < NdaughterofEMC; i++ )
835 G4LogicalVolume* daughterofEmc = logicEMC->GetDaughter( i )->GetLogicalVolume();
836 G4cout << i <<
"/" << NdaughterofEMC <<
" name: " << daughterofEmc->GetName() <<
" "
837 << daughterofEmc <<
" shape: " << daughterofEmc->GetSolid()->GetName() << G4endl;
838 int NdaughterofEmc_2 = daughterofEmc->GetNoDaughters();
839 for (
int j = 0; j < NdaughterofEmc_2; j++ )
841 G4LogicalVolume* daughterofEmc_2 = daughterofEmc->GetDaughter( j )->GetLogicalVolume();
842 G4cout <<
" --> " << j <<
"/" << NdaughterofEmc_2
843 <<
" name: " << daughterofEmc_2->GetName() <<
" " << daughterofEmc_2
844 <<
" shape: " << daughterofEmc_2->GetSolid()->GetName() << G4endl;
845 int NdaughterofEmc_3 = daughterofEmc_2->GetNoDaughters();
846 for (
int k = 0; k < NdaughterofEmc_3; k++ )
848 G4LogicalVolume* daughterofEmc_3 =
849 daughterofEmc_2->GetDaughter( k )->GetLogicalVolume();
850 G4cout <<
" --> " << k <<
"/" << NdaughterofEmc_3
851 <<
" name: " << daughterofEmc_3->GetName() <<
" " << daughterofEmc_3
852 <<
" shape: " << daughterofEmc_3->GetSolid()->GetName() << G4endl;
853 int NdaughterofEmc_4 = daughterofEmc_3->GetNoDaughters();
854 for (
int m = 0; m < NdaughterofEmc_4; m++ )
856 G4LogicalVolume* daughterofEmc_4 =
857 daughterofEmc_3->GetDaughter( m )->GetLogicalVolume();
858 G4cout <<
" --> " << m <<
"/" << NdaughterofEmc_4
859 <<
" name: " << daughterofEmc_4->GetName() <<
" " << daughterofEmc_4
860 <<
" shape: " << daughterofEmc_4->GetSolid()->GetName() << G4endl;
861 if ( daughterofEmc_3->GetSolid()->GetName().contains(
"solidBSCCasing" ) )
863 G4Trap* Crystal = (G4Trap*)daughterofEmc_3->GetSolid();
864 double hz = Crystal->GetZHalfLength();
865 double hx1 = Crystal->GetXHalfLength1();
866 double hx2 = Crystal->GetXHalfLength2();
867 double hx3 = Crystal->GetXHalfLength3();
868 double hx4 = Crystal->GetXHalfLength4();
869 double hy1 = Crystal->GetYHalfLength1();
870 double hy2 = Crystal->GetYHalfLength2();
871 double tanalpha1 = Crystal->GetTanAlpha1();
872 double tanalpha2 = Crystal->GetTanAlpha2();
873 G4cout <<
" --> " << hx1 <<
" " << hx2 <<
" " << hx3 <<
" "
874 << hx4 <<
" " << hy1 <<
" " << hy2 <<
" " << hz <<
" " << tanalpha1 <<
" "
875 << tanalpha2 << G4endl;
889 if ( logEMC != logicEMC )
890 G4cout <<
"BesEmcConstruction::ConstructEndGeometry parameter transmit error!" << G4endl;
893 G4VisAttributes* crystalVisAtt =
new G4VisAttributes( G4Colour( 0.5, 0, 1.0 ) );
894 crystalVisAtt->SetVisibility(
false );
895 G4VisAttributes* endPhiVisAtt =
new G4VisAttributes( G4Colour( 0, 1.0, 0 ) );
896 endPhiVisAtt->SetVisibility(
false );
897 const G4double zoomConst = 0.995;
898 const G4double da = 0.001 * deg;
902 solidEnd =
new G4Cons(
"solidEndWorld", ( *emcEnd ).WorldRmin1, ( *emcEnd ).WorldRmax1,
903 ( *emcEnd ).WorldRmin2, ( *emcEnd ).WorldRmax2,
904 ( *emcEnd ).WorldDz / 2, 0. * deg, 360. * deg );
905 logicEnd =
new G4LogicalVolume( solidEnd, G4Material::GetMaterial(
"Aluminium" ),
906 "logicalEndWorld", 0, 0, 0 );
907 physiEnd =
new G4PVPlacement( 0,
908 G4ThreeVector( 0, 0, ( *emcEnd ).WorldZPosition ),
914 if ( logicEnd ) logicEnd->SetVisAttributes( G4VisAttributes::Invisible );
917 G4RotationMatrix* rotateEnd =
new G4RotationMatrix();
918 rotateEnd->rotateY( 180. * deg );
919 physiEnd =
new G4PVPlacement( rotateEnd, G4ThreeVector( 0, 0, -( *emcEnd ).WorldZPosition ),
920 logicEnd,
"physicalEndWorld2", logicEMC,
false, 2,
CHECKLV1 );
947 solidEndPhi =
new G4Cons(
"solidEndPhi0", ( *emcEnd ).SectorRmin1, ( *emcEnd ).SectorRmax1,
948 ( *emcEnd ).SectorRmin2, ( *emcEnd ).SectorRmax2,
949 ( *emcEnd ).SectorDz / 2, 0. * deg, 22.5 * deg - da );
950 logicEndPhi =
new G4LogicalVolume( solidEndPhi, G4Material::GetMaterial(
"Air" ),
951 "logicalEndPhi0", 0, 0, 0 );
952 for ( G4int i = 0; i < 14; i++ )
954 if ( ( i != 6 ) && ( i != 7 ) )
956 G4RotationMatrix* rotatePhi =
new G4RotationMatrix();
957 rotatePhi->rotateZ( -i * 22.5 * deg + 67.5 * deg );
958 ostringstream strEndPhi;
959 strEndPhi <<
"physicalEndPhi" << i;
961 new G4PVPlacement( rotatePhi,
962 G4ThreeVector( 0, 0, ( *emcEnd ).SectorZPosition ), logicEndPhi,
963 strEndPhi.str(), logicEnd,
false, i,
CHECKLV2 );
966 if ( logicEndPhi ) logicEndPhi->SetVisAttributes( endPhiVisAtt );
968 for ( G4int i = 0; i < 35; i++ )
970 ostringstream strEndCasing;
971 strEndCasing <<
"solidEndCasing_0_" << i;
974 G4ThreeVector newfPnt[8];
975 G4ThreeVector center( 0.0, 0.0, 0.0 );
976 G4ThreeVector rotAngle( 0.0, 0.0, 0.0 );
980 emcEnd->Zoom( newfPnt, zoomConst );
982 G4RotationMatrix* rotatePhiIrregBox =
new G4RotationMatrix();
983 rotatePhiIrregBox->rotateX( rotAngle.x() );
984 rotatePhiIrregBox->rotateY( rotAngle.y() );
985 rotatePhiIrregBox->rotateZ( rotAngle.z() );
988 solidEndCasing =
new G4IrregBox( strEndCasing.str(), ( *emcEnd ).zoomPoint );
990 ostringstream strVEndCasing;
991 strVEndCasing <<
"logicalEndCasing_0_" << i;
993 new G4LogicalVolume( solidEndCasing, fCasingMaterial, strVEndCasing.str() );
995 ostringstream strPEndCasing;
996 strPEndCasing <<
"physicalEndCasing_0_" << i;
998 new G4PVPlacement( rotatePhiIrregBox, center, logicEndCasing, strPEndCasing.str(),
1001 ostringstream strEndCrystal;
1002 strEndCrystal <<
"solidEndCrystal_0_" << i;
1004 emcEnd->ModifyForCasing( ( *emcEnd ).zoomPoint, i );
1005 solidEndCrystal =
new G4IrregBox( strEndCrystal.str(), ( *emcEnd ).cryPoint );
1007 ostringstream strVEndCrystal;
1008 strVEndCrystal <<
"logicalEndCrystal_0_" << i;
1010 new G4LogicalVolume( solidEndCrystal, fCrystalMaterial, strVEndCrystal.str() );
1012 ostringstream strPEndCrystal;
1013 strPEndCrystal <<
"physicalEndCrystal_0_" << i;
1015 new G4PVPlacement( 0, G4ThreeVector(), logicEndCrystal, strPEndCrystal.str(),
1018 logicEndCasing->SetVisAttributes( G4VisAttributes::Invisible );
1019 logicEndCrystal->SetVisAttributes( crystalVisAtt );
1020 logicEndCrystal->SetSensitiveDetector( besEMCSD );
1026 ( *emcEnd ).WorldRmin1 + ( ( *emcEnd ).WorldRmin2 - ( *emcEnd ).WorldRmin1 ) *
1027 ( *emcEnd ).SectorDz / ( *emcEnd ).WorldDz;
1029 ( *emcEnd ).WorldRmax1 + ( ( *emcEnd ).WorldRmax2 - ( *emcEnd ).WorldRmax1 ) *
1030 ( *emcEnd ).SectorDz / ( *emcEnd ).WorldDz;
1032 new G4Cons(
"solidEndPhi1", ( *emcEnd ).WorldRmin1, ( *emcEnd ).WorldRmax1, rmin2, rmax2,
1033 ( *emcEnd ).SectorDz / 2, 67.5 * deg, 22.5 * deg - da );
1034 logicEndPhi =
new G4LogicalVolume( solidEndPhi, G4Material::GetMaterial(
"Air" ),
1035 "logicalEndPhi1", 0, 0, 0 );
1036 for ( G4int i = 0; i < 2; i++ )
1038 G4RotationMatrix* rotatePhi =
new G4RotationMatrix();
1039 rotatePhi->rotateZ( -i * 180. * deg );
1040 ostringstream strEndPhi;
1041 strEndPhi <<
"physicalEndPhi" << i * 8 + 6;
1042 physiEndPhi =
new G4PVPlacement(
1043 rotatePhi, G4ThreeVector( 0, 0, ( *emcEnd ).SectorZPosition ), logicEndPhi,
1044 strEndPhi.str(), logicEnd,
false, i * 8 + 6,
CHECKLV2 );
1046 if ( logicEndPhi ) logicEndPhi->SetVisAttributes( endPhiVisAtt );
1048 for ( G4int i = 0; i < 35; i++ )
1050 ostringstream strEndCasing;
1051 strEndCasing <<
"solidEndCasing_1_" << i;
1054 G4ThreeVector newfPnt[8];
1055 G4ThreeVector center( 0.0, 0.0, 0.0 );
1056 G4ThreeVector rotAngle( 0.0, 0.0, 0.0 );
1060 emcEnd->Zoom( newfPnt, zoomConst );
1062 G4RotationMatrix* rotatePhiIrregBox =
new G4RotationMatrix();
1063 rotatePhiIrregBox->rotateX( rotAngle.x() );
1064 rotatePhiIrregBox->rotateY( rotAngle.y() );
1065 rotatePhiIrregBox->rotateZ( rotAngle.z() );
1068 solidEndCasing =
new G4IrregBox( strEndCasing.str(), ( *emcEnd ).zoomPoint );
1070 ostringstream strVEndCasing;
1071 strVEndCasing <<
"logicalEndCasing_1_" << i;
1073 new G4LogicalVolume( solidEndCasing, fCasingMaterial, strVEndCasing.str() );
1075 ostringstream strPEndCasing;
1076 strPEndCasing <<
"physicalEndCasing_1_" << i;
1078 new G4PVPlacement( rotatePhiIrregBox, center, logicEndCasing, strPEndCasing.str(),
1081 ostringstream strEndCrystal;
1082 strEndCrystal <<
"solidEndCrystal_1_" << i;
1084 emcEnd->ModifyForCasing( ( *emcEnd ).zoomPoint, i );
1085 solidEndCrystal =
new G4IrregBox( strEndCrystal.str(), ( *emcEnd ).cryPoint );
1087 ostringstream strVEndCrystal;
1088 strVEndCrystal <<
"logicalEndCrystal_1_" << i;
1090 new G4LogicalVolume( solidEndCrystal, fCrystalMaterial, strVEndCrystal.str() );
1092 ostringstream strPEndCrystal;
1093 strPEndCrystal <<
"physicalEndCrystal_1_" << i;
1095 new G4PVPlacement( 0, G4ThreeVector(), logicEndCrystal, strPEndCrystal.str(),
1098 logicEndCasing->SetVisAttributes( G4VisAttributes::Invisible );
1099 logicEndCrystal->SetVisAttributes( crystalVisAtt );
1100 logicEndCrystal->SetSensitiveDetector( besEMCSD );
1103 ( *emcEnd ).ReflectX();
1106 for ( G4int i = 0; i < 35; i++ )
1107 for ( G4int j = 0; j < 8; j++ ) ( *emcEnd ).fPnt1[i][j].rotateZ( -90. * deg );
1109 solidEndPhi =
new G4Cons(
"solidEndPhi2", ( *emcEnd ).WorldRmin1, ( *emcEnd ).WorldRmax1,
1110 rmin2, rmax2, ( *emcEnd ).SectorDz / 2, 0 * deg, 22.5 * deg - da );
1111 logicEndPhi =
new G4LogicalVolume( solidEndPhi, G4Material::GetMaterial(
"Air" ),
1112 "logicalEndPhi2", 0, 0, 0 );
1113 for ( G4int i = 0; i < 2; i++ )
1115 G4RotationMatrix* rotatePhi =
new G4RotationMatrix();
1116 rotatePhi->rotateZ( -i * 180. * deg - 90. * deg );
1117 ostringstream strEndPhi;
1118 strEndPhi <<
"physicalEndPhi" << i * 8 + 7;
1119 physiEndPhi =
new G4PVPlacement(
1120 rotatePhi, G4ThreeVector( 0, 0, ( *emcEnd ).SectorZPosition ), logicEndPhi,
1121 strEndPhi.str(), logicEnd,
false, i * 8 + 7,
CHECKLV2 );
1123 if ( logicEndPhi ) logicEndPhi->SetVisAttributes( endPhiVisAtt );
1125 for ( G4int i = 0; i < 35; i++ )
1127 ostringstream strEndCasing;
1128 strEndCasing <<
"solidEndCasing_2_" << i;
1131 G4ThreeVector newfPnt[8];
1132 G4ThreeVector center( 0.0, 0.0, 0.0 );
1133 G4ThreeVector rotAngle( 0.0, 0.0, 0.0 );
1137 emcEnd->Zoom( newfPnt, zoomConst );
1139 G4RotationMatrix* rotatePhiIrregBox =
new G4RotationMatrix();
1140 rotatePhiIrregBox->rotateX( rotAngle.x() );
1141 rotatePhiIrregBox->rotateY( rotAngle.y() );
1142 rotatePhiIrregBox->rotateZ( rotAngle.z() );
1145 solidEndCasing =
new G4IrregBox( strEndCasing.str(), ( *emcEnd ).zoomPoint );
1147 ostringstream strVEndCasing;
1148 strVEndCasing <<
"logicalEndCasing_2_" << i;
1150 new G4LogicalVolume( solidEndCasing, fCasingMaterial, strVEndCasing.str() );
1152 ostringstream strPEndCasing;
1153 strPEndCasing <<
"physicalEndCasing_2_" << i;
1155 new G4PVPlacement( rotatePhiIrregBox, center, logicEndCasing, strPEndCasing.str(),
1158 ostringstream strEndCrystal;
1159 strEndCrystal <<
"solidEndCrystal_2_" << i;
1161 emcEnd->ModifyForCasing( ( *emcEnd ).zoomPoint, i );
1162 solidEndCrystal =
new G4IrregBox( strEndCrystal.str(), ( *emcEnd ).cryPoint );
1164 ostringstream strVEndCrystal;
1165 strVEndCrystal <<
"logicalEndCrystal_2_" << i;
1167 new G4LogicalVolume( solidEndCrystal, fCrystalMaterial, strVEndCrystal.str() );
1169 ostringstream strPEndCrystal;
1170 strPEndCrystal <<
"physicalEndCrystal_2_" << i;
1172 new G4PVPlacement( 0, G4ThreeVector(), logicEndCrystal, strPEndCrystal.str(),
1175 logicEndCasing->SetVisAttributes( G4VisAttributes::Invisible );
1176 logicEndCrystal->SetVisAttributes( crystalVisAtt );
1177 logicEndCrystal->SetSensitiveDetector( besEMCSD );
1197 G4double rmax = ( *besEMCGeometry ).BSCRmax + 2. * mm;
1198 solidSupportBar =
new G4Tubs(
1199 "solidSupportBar0", rmax + ( *besEMCGeometry ).SPBarThickness1,
1200 rmax + ( *besEMCGeometry ).SPBarThickness + ( *besEMCGeometry ).SPBarThickness1,
1201 ( *besEMCGeometry ).BSCDz + ( *besEMCGeometry ).TaperRingThickness3 +
1202 ( *besEMCGeometry ).EndRingDz,
1203 0. * deg, 360. * deg );
1206 new G4LogicalVolume( solidSupportBar, stainlessSteel,
"logicalSupportBar0" );
1208 physiSupportBar =
new G4PVPlacement( 0, G4ThreeVector(), logicSupportBar,
1209 "physicalSupportBar0", logMother,
false, 0,
CHECKLV2 );
1212 new G4Tubs(
"solidSupportBar1", rmax, rmax + ( *besEMCGeometry ).SPBarThickness1,
1213 ( *besEMCGeometry ).BSCDz + ( *besEMCGeometry ).TaperRingThickness3,
1214 ( *besEMCGeometry ).BSCPhiDphi - ( *besEMCGeometry ).SPBarDphi / 2,
1215 ( *besEMCGeometry ).SPBarDphi );
1218 new G4LogicalVolume( solidSupportBar1, stainlessSteel,
"logicalSupportBar1" );
1220 for ( G4int i = 0; i < ( *besEMCGeometry ).BSCNbPhi / 2; i++ )
1222 G4RotationMatrix* rotateSPBar =
new G4RotationMatrix();
1223 rotateSPBar->rotateZ( ( *besEMCGeometry ).BSCPhiDphi -
1224 i * 2 * ( *besEMCGeometry ).BSCPhiDphi );
1225 ostringstream strSupportBar1;
1226 strSupportBar1 <<
"physicalSupportBar1_" << i;
1228 new G4PVPlacement( rotateSPBar, G4ThreeVector(), logicSupportBar1,
1229 strSupportBar1.str(), logMother,
false, 0,
CHECKLV2 );
1234 new G4Tubs(
"solidEndRing", ( *besEMCGeometry ).EndRingRmin,
1235 ( *besEMCGeometry ).EndRingRmin + ( *besEMCGeometry ).EndRingDr / 2,
1236 ( *besEMCGeometry ).EndRingDz / 2, 0. * deg, 360. * deg );
1238 solidGear =
new G4Tubs(
1239 "solidGear", ( *besEMCGeometry ).EndRingRmin + ( *besEMCGeometry ).EndRingDr / 2,
1240 ( *besEMCGeometry ).EndRingRmin + ( *besEMCGeometry ).EndRingDr,
1241 ( *besEMCGeometry ).EndRingDz / 2, 0. * deg, ( *besEMCGeometry ).BSCPhiDphi );
1245 new G4Tubs(
"solidTaperRing1", ( *besEMCGeometry ).TaperRingRmin1,
1246 ( *besEMCGeometry ).TaperRingRmin1 + ( *besEMCGeometry ).TaperRingThickness1,
1247 ( *besEMCGeometry ).TaperRingInnerLength / 2, 0. * deg, 360. * deg );
1250 new G4Cons(
"solidTaperRing2", ( *besEMCGeometry ).TaperRingRmin1,
1251 ( *besEMCGeometry ).TaperRingRmin1 + ( *besEMCGeometry ).TaperRingThickness1,
1252 ( *besEMCGeometry ).TaperRingRmin2,
1253 ( *besEMCGeometry ).TaperRingRmin2 + ( *besEMCGeometry ).TaperRingDr,
1254 ( *besEMCGeometry ).TaperRingDz / 2, 0. * deg, 360. * deg );
1257 new G4Cons(
"solidTaperRing3", ( *besEMCGeometry ).BSCRmax2,
1258 ( *besEMCGeometry ).BSCRmax2 + ( *besEMCGeometry ).TaperRingOuterLength1,
1259 ( *besEMCGeometry ).TaperRingRmin2 + ( *besEMCGeometry ).TaperRingDr,
1260 ( *besEMCGeometry ).TaperRingRmin2 + ( *besEMCGeometry ).TaperRingDr +
1261 ( *besEMCGeometry ).TaperRingOuterLength,
1262 ( *besEMCGeometry ).TaperRingThickness3 / 2, 0. * deg, 360. * deg );
1264 logicEndRing =
new G4LogicalVolume( solidEndRing, stainlessSteel,
"logicalEndRing" );
1265 logicGear =
new G4LogicalVolume( solidGear, stainlessSteel,
"logicalGear" );
1267 new G4LogicalVolume( solidTaperRing1, stainlessSteel,
"logicalTaperRing1" );
1269 new G4LogicalVolume( solidTaperRing2, stainlessSteel,
"logicalTaperRing2" );
1271 new G4LogicalVolume( solidTaperRing3, stainlessSteel,
"logicalTaperRing3" );
1273 for ( G4int i = 0; i < 2; i++ )
1275 G4RotationMatrix* rotateSPRing =
new G4RotationMatrix();
1276 G4double zEndRing, z1, z2, z3;
1279 zEndRing = ( *besEMCGeometry ).BSCDz + ( *besEMCGeometry ).TaperRingThickness3 +
1280 ( *besEMCGeometry ).EndRingDz / 2;
1281 z1 = ( *besEMCGeometry ).BSCDz + ( *besEMCGeometry ).TaperRingThickness3 -
1282 ( *besEMCGeometry ).TaperRingDz - ( *besEMCGeometry ).TaperRingInnerLength / 2;
1283 z2 = ( *besEMCGeometry ).BSCDz + ( *besEMCGeometry ).TaperRingThickness3 -
1284 ( *besEMCGeometry ).TaperRingDz / 2;
1285 z3 = ( *besEMCGeometry ).BSCDz + ( *besEMCGeometry ).TaperRingThickness3 / 2;
1289 rotateSPRing->rotateY( 180. * deg );
1290 zEndRing = -( ( *besEMCGeometry ).BSCDz + ( *besEMCGeometry ).TaperRingThickness3 +
1291 ( *besEMCGeometry ).EndRingDz / 2 );
1292 z1 = -( ( *besEMCGeometry ).BSCDz + ( *besEMCGeometry ).TaperRingThickness3 -
1293 ( *besEMCGeometry ).TaperRingDz - ( *besEMCGeometry ).TaperRingInnerLength / 2 );
1294 z2 = -( ( *besEMCGeometry ).BSCDz + ( *besEMCGeometry ).TaperRingThickness3 -
1295 ( *besEMCGeometry ).TaperRingDz / 2 );
1296 z3 = -( ( *besEMCGeometry ).BSCDz + ( *besEMCGeometry ).TaperRingThickness3 / 2 );
1299 ostringstream strEndRing;
1300 strEndRing <<
"physicalEndRing_" << i;
1302 new G4PVPlacement( rotateSPRing, G4ThreeVector( 0, 0, zEndRing ), logicEndRing,
1303 strEndRing.str(), logMother,
false, 0,
CHECKLV2 );
1305 for ( G4int j = 0; j < ( *besEMCGeometry ).BSCNbPhi / 2; j++ )
1307 G4RotationMatrix* rotateGear =
new G4RotationMatrix();
1308 rotateGear->rotateZ( ( *besEMCGeometry ).BSCPhiDphi / 2 -
1309 j * 2 * ( *besEMCGeometry ).BSCPhiDphi );
1311 ostringstream strGear;
1312 strGear <<
"physicalGear_" << i <<
"_" << j;
1313 physiGear =
new G4PVPlacement( rotateGear, G4ThreeVector( 0, 0, zEndRing ), logicGear,
1314 strGear.str(), logMother,
false, 0,
CHECKLV2 );
1317 ostringstream strTaperRing1;
1318 strTaperRing1 <<
"physicalTaperRing1_" << i;
1320 new G4PVPlacement( rotateSPRing, G4ThreeVector( 0, 0, z1 ), logicTaperRing1,
1321 strTaperRing1.str(), logMother,
false, 0,
CHECKLV2 );
1323 ostringstream strTaperRing2;
1324 strTaperRing2 <<
"physicalTaperRing2_" << i;
1326 new G4PVPlacement( rotateSPRing, G4ThreeVector( 0, 0, z2 ), logicTaperRing2,
1327 strTaperRing2.str(), logMother,
false, 0,
CHECKLV2 );
1329 ostringstream strTaperRing3;
1330 strTaperRing3 <<
"physicalTaperRing3_" << i;
1332 new G4PVPlacement( rotateSPRing, G4ThreeVector( 0, 0, z3 ), logicTaperRing3,
1333 strTaperRing3.str(), logMother,
false, 0,
CHECKLV2 );