135 {
136 gErrorIgnoreLevel = kFatal;
137 besEMCGeometry->ComputeEMCParameters();
138 detectorMessenger = new BesEmcDetectorMessenger( this, besEMCGeometry );
139 emcEnd->ComputeParameters();
140
141 G4SDManager* SDman = G4SDManager::GetSDMpointer();
142 if ( !besEMCSD )
143 {
144 besEMCSD = new BesEmcSD( "CalorSD", this, besEMCGeometry );
145 SDman->AddNewDetector( besEMCSD );
146 }
147
148
151 {
153
154 if ( logicEMC )
155 {
156 physiEMC = new G4PVPlacement( 0, G4ThreeVector( 0.0, 0.0, 0.0 ), logicEMC, "physicalEMC",
158 G4cout << "logicEmc: === " << logicEMC << " physiEmc " << physiEMC << G4endl;
159
162 }
163 }
164 else
165 {
166
167
168
169 DefineMaterials();
170 phiNbCrystals = ( *besEMCGeometry ).BSCNbPhi;
171 thetaNbCrystals = ( *besEMCGeometry ).BSCNbTheta * 2;
172
173 G4double da = 0.001 * deg;
174
175
176
177
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 );
185
186 solidESC = new G4Cons( "solidESC", ( *emcEnd ).WorldRmin1, ( *emcEnd ).WorldRmax1,
187 ( *emcEnd ).WorldRmin2, ( *emcEnd ).WorldRmax2,
188 ( *emcEnd ).WorldDz / 2, 0. * deg, 360. * deg );
189
190 solidEMC = new G4UnionSolid( "solidEMC0", solidBSC, solidESC, 0,
191 G4ThreeVector( 0, 0, ( *emcEnd ).WorldZPosition ) );
192
193 G4RotationMatrix* rotateESC = new G4RotationMatrix();
194 rotateESC->rotateY( 180. * deg );
195
196 solidEMC = new G4UnionSolid( "solidEMC", solidEMC, solidESC, rotateESC,
197 G4ThreeVector( 0, 0, -( *emcEnd ).WorldZPosition ) );
198
199 logicEMC = new G4LogicalVolume( solidEMC, G4Material::GetMaterial( "Air" ), "logicalEMC" );
200
201 physiEMC = new G4PVPlacement( 0, G4ThreeVector(), logicEMC, "physicalEMC", logicBes, false,
203
204 solidBSCWorld =
205 new G4SubtractionSolid( "solidBSCWorld0", solidBSC, solidESC, 0,
206 G4ThreeVector( 0, 0, ( *emcEnd ).WorldZPosition ) );
207
208 solidBSCWorld =
209 new G4SubtractionSolid( "solidBSCWorld", solidBSCWorld, solidESC, rotateESC,
210 G4ThreeVector( 0, 0, -( *emcEnd ).WorldZPosition ) );
211
212 logicBSCWorld = new G4LogicalVolume( solidBSCWorld, G4Material::GetMaterial( "Air" ),
213 "logicalBSCWorld" );
214
215 G4RotationMatrix* rotBSC = new G4RotationMatrix();
216 rotBSC->rotateY( 180. * deg );
217 physiBSCWorld = new G4PVPlacement( rotBSC, G4ThreeVector(), logicBSCWorld,
218 "physicalBSCWorld", logicEMC,
false, 0,
CHECKLV1 );
219
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 ) );
231 G4double oij =
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;
255
256
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 );
265
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;
274
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 );
283
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 };
289
290 G4double zPlane1[4] = { -zTaperRing2, -zTaperRing1, zTaperRing1, zTaperRing2 };
291 G4double rInner1[4] = { rTaperRingOuter2, rTaperRingOuter1, rTaperRingOuter1,
292 rTaperRingOuter2 };
293 G4double rOuter1[4] = { ( *besEMCGeometry ).BSCRmax, ( *besEMCGeometry ).BSCRmax,
294 ( *besEMCGeometry ).BSCRmax, ( *besEMCGeometry ).BSCRmax };
295
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 );
304
305 logicBSCPhi =
306 new G4LogicalVolume( solidBSCPhi, G4Material::GetMaterial( "Air" ), "logicalBSCPhi" );
307
308 G4int i;
309 for ( G4int j = 0; j < ( *besEMCGeometry ).BSCNbPhi; j++ )
310 {
311 if ( j < ( *besEMCGeometry ).BSCNbPhi / 2 )
312 {
313 i = ( *besEMCGeometry ).BSCNbPhi / 2 - j - 1;
314 }
315 else
316 {
317 i = ( *besEMCGeometry ).BSCNbPhi * 3 / 2 - j - 1;
318 }
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 );
324
325
326
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 );
331 oz = 0 * cm;
332
333 ostringstream strPhi;
334 strPhi << "physicalBSCPhi" << j;
335
336 physiBSCPhi =
337 new G4PVPlacement( rotateMatrix[i], G4ThreeVector( ox, oy, oz ), logicBSCPhi,
338 strPhi.str(), logicBSCWorld,
false, j,
CHECKLV2 );
339
340
341
342 }
343
344
345
346
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++ )
363 {
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;
392 }
393 besEMCGeometry->ModifyForCasing();
394
395 solidBSCCrystal =
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 );
398
399 logicBSCCrystal =
400 new G4LogicalVolume( solidBSCCrystal, fCrystalMaterial, "logicalCrystal" );
401
402 crystalParam = new BesCrystalParameterisation( startID, thetaNbCrystals,
403 ( *besEMCGeometry ).BSCNbTheta * 2,
404 besEMCGeometry, verboseLevel );
405
406
407
408 solidRear =
409 new G4Box( "solidRearBox", ( *besEMCGeometry ).rearBoxLength / 2,
410 ( *besEMCGeometry ).rearBoxLength / 2, ( *besEMCGeometry ).rearBoxDz / 2 );
411
412 logicRear =
413 new G4LogicalVolume( solidRear, G4Material::GetMaterial( "Air" ), "logicalRearBox" );
414
415
416 solidOrgGlass = new G4Box( "solidOrganicGlass", ( *besEMCGeometry ).orgGlassLengthX / 2,
417 ( *besEMCGeometry ).orgGlassLengthY / 2,
418 ( *besEMCGeometry ).orgGlassLengthZ / 2 );
419
420 logicOrgGlass = new G4LogicalVolume( solidOrgGlass, organicGlass, "logicalOrganicGlass" );
421
422 physiOrgGlass = new G4PVPlacement(
423 0,
424 G4ThreeVector(
425 0, 0,
426 -( ( *besEMCGeometry ).rearBoxDz - ( *besEMCGeometry ).orgGlassLengthZ ) / 2 ),
427 logicOrgGlass,
"physicalOrganicGlass", logicRear,
false, 0,
CHECKLV4 );
428
429
430 solidCasingBox = new G4Box( "solidCasingBox", ( *besEMCGeometry ).rearBoxLength / 2,
431 ( *besEMCGeometry ).rearBoxLength / 2,
432 ( *besEMCGeometry ).rearCasingThickness / 2 );
433
434 solidAirHole =
435 new G4Box( "solidAirHole", ( *besEMCGeometry ).orgGlassLengthX / 2,
436 ( *besEMCGeometry ).orgGlassLengthY / 2,
437 ( *besEMCGeometry ).rearBoxDz / 2 );
438
439 solidRearCasing = new G4SubtractionSolid( "solidRearCasing", solidCasingBox, solidAirHole,
440 0, G4ThreeVector() );
441
442 logicRearCasing =
443 new G4LogicalVolume( solidRearCasing, rearCasingMaterial, "logicalRearCasing" );
444
445 physiRearCasing = new G4PVPlacement(
446 0,
447 G4ThreeVector(
448 0, 0,
449 -( ( *besEMCGeometry ).rearBoxDz - ( *besEMCGeometry ).rearCasingThickness ) / 2 ),
450 logicRearCasing,
"physicalRearCasing", logicRear,
false, 0,
CHECKLV4 );
451
452
453 solidAlBox =
454 new G4Box( "solidAlBox", ( *besEMCGeometry ).rearBoxLength / 2,
455 ( *besEMCGeometry ).rearBoxLength / 2, ( *besEMCGeometry ).AlPlateDz / 2 );
456
457 solidAlPlate =
458 new G4SubtractionSolid( "solidAlPlate", solidAlBox, solidAirHole, 0, G4ThreeVector() );
459
460 logicAlPlate = new G4LogicalVolume( solidAlPlate, G4Material::GetMaterial( "Aluminium" ),
461 "logicalAlPlate" );
462
463 physiAlPlate =
464 new G4PVPlacement( 0,
465 G4ThreeVector( 0, 0,
466 -( ( *besEMCGeometry ).rearBoxDz / 2 -
467 ( *besEMCGeometry ).rearCasingThickness -
468 ( *besEMCGeometry ).AlPlateDz / 2 ) ),
469 logicAlPlate,
"physicalAlPlate", logicRear,
false, 0,
CHECKLV4 );
470
471
472 solidPD =
473 new G4Box( "solidPD",
474 ( *besEMCGeometry ).PDLengthX,
475 ( *besEMCGeometry ).PDLengthY / 2, ( *besEMCGeometry ).PDLengthZ / 2 );
476
477 logicPD =
478 new G4LogicalVolume( solidPD, G4Material::GetMaterial( "M_Silicon" ), "logicalPD" );
479
480 physiPD = new G4PVPlacement( 0,
481 G4ThreeVector( 0, 0,
482 -( ( *besEMCGeometry ).rearBoxDz / 2 -
483 ( *besEMCGeometry ).orgGlassLengthZ -
484 ( *besEMCGeometry ).PDLengthZ / 2 ) ),
485 logicPD,
"physicalPD", logicRear,
false, 0,
CHECKLV4 );
486
487
488 solidPreAmpBox =
489 new G4Box( "solidPreAmpBox", ( *besEMCGeometry ).rearBoxLength / 2,
490 ( *besEMCGeometry ).rearBoxLength / 2, ( *besEMCGeometry ).PABoxDz / 2 );
491
492 logicPreAmpBox = new G4LogicalVolume(
493 solidPreAmpBox, G4Material::GetMaterial( "Aluminium" ), "logicalPreAmpBox" );
494
495 physiPreAmpBox = new G4PVPlacement(
496 0,
497 G4ThreeVector( 0, 0,
498 -( ( *besEMCGeometry ).rearBoxDz / 2 -
499 ( *besEMCGeometry ).rearCasingThickness -
500 ( *besEMCGeometry ).AlPlateDz - ( *besEMCGeometry ).PABoxDz / 2 ) ),
501 logicPreAmpBox,
"physicalPreAmpBox", logicRear,
false, 0,
CHECKLV4 );
502
503
504 solidAirInPABox =
505 new G4Box( "solidAirInPABox",
506 ( *besEMCGeometry ).rearBoxLength / 2 - ( *besEMCGeometry ).PABoxThickness,
507 ( *besEMCGeometry ).rearBoxLength / 2 - ( *besEMCGeometry ).PABoxThickness,
508 ( *besEMCGeometry ).PABoxDz / 2 - ( *besEMCGeometry ).PABoxThickness );
509
510 logicAirInPABox = new G4LogicalVolume( solidAirInPABox, G4Material::GetMaterial( "Air" ),
511 "logicalAirInPABox" );
512
513 physiAirInPABox =
514 new G4PVPlacement( 0, G4ThreeVector(), logicAirInPABox, "physicalAirInPABox",
515 logicPreAmpBox,
false, 0,
CHECKLV5 );
516
517
518 solidHangingPlate = new G4Box( "solidHangingPlate", ( *besEMCGeometry ).rearBoxLength / 2,
519 ( *besEMCGeometry ).rearBoxLength / 2,
520 ( *besEMCGeometry ).HangingPlateDz / 2 );
521
522 logicHangingPlate =
523 new G4LogicalVolume( solidHangingPlate, stainlessSteel, "logicalHangingPlate" );
524
525 physiHangingPlate = new G4PVPlacement(
526 0,
527 G4ThreeVector( 0, 0,
528 -( ( *besEMCGeometry ).rearBoxDz / 2 -
529 ( *besEMCGeometry ).rearCasingThickness -
530 ( *besEMCGeometry ).AlPlateDz - ( *besEMCGeometry ).PABoxDz -
531 ( *besEMCGeometry ).HangingPlateDz / 2 ) ),
532 logicHangingPlate,
"physicalHangingPlate", logicRear,
false, 0,
CHECKLV4 );
533
534
535 solidWaterPipe = new G4Tubs( "solidWaterPipe", 0, ( *besEMCGeometry ).waterPipeDr,
536 ( *besEMCGeometry ).BSCDz, 0. * deg, 360. * deg );
537
538 logicWaterPipe = new G4LogicalVolume( solidWaterPipe, waterPipe, "logicalWaterPipe" );
539
540 physiWaterPipe = new G4PVPlacement(
541 0,
542 G4ThreeVector( ( *besEMCGeometry ).cablePosX[0] - 2 * ( *besEMCGeometry ).cableDr,
543 ( *besEMCGeometry ).cablePosY[0] - ( *besEMCGeometry ).cableDr -
544 ( *besEMCGeometry ).waterPipeDr,
545 0 ),
546 logicWaterPipe,
"physicalWaterPipe", logicBSCPhi,
false, 0,
CHECKLV3 );
547
548
549
550
551
552 G4String nameCrystalAndCasing = "CrystalAndCasing";
553
554 G4int id = 0;
555 for ( i = startID; i <= thetaNbCrystals; i++ )
556 {
557 ostringstream strSolidCasing;
558 strSolidCasing << "solidBSCCasing" << i - 1;
559 ostringstream strVolumeCasing;
560 strVolumeCasing << "logicalBSCCasing" << i - 1;
561 ostringstream strPhysiCasing;
562 strPhysiCasing << "physicalBSCCasing" << i - 1;
563
564 if ( i > ( *besEMCGeometry ).BSCNbTheta )
565 {
566 id = i - ( *besEMCGeometry ).BSCNbTheta - 1;
567 solidBSCTheta =
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] );
571
572
573
574
575
576 logicBSCTheta =
577 new G4LogicalVolume( solidBSCTheta, fCasingMaterial, strVolumeCasing.str() );
578
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] );
582
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 );
587
588 if ( logicBSCTheta )
589 {
590 G4VisAttributes* rightVisAtt = new G4VisAttributes( G4Colour( 1.0, 0., 0. ) );
591 rightVisAtt->SetVisibility( true );
592 logicBSCTheta->SetVisAttributes( rightVisAtt );
593 logicBSCTheta->SetVisAttributes( G4VisAttributes::Invisible );
594 }
595
596 ostringstream strRear;
597 strRear << "physicalRearBox_1_" << i - 1;
598
599 physiRear =
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 );
605
606 ostringstream strGirder;
607 strGirder << "solidOpenningCutGirder_1_" << i - 1;
608 solidOCGirder =
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 );
614
615 ostringstream strVGirder;
616 strVGirder << "logicalOpenningCutGirder_1_" << i - 1;
617 logicOCGirder = new G4LogicalVolume( solidOCGirder, stainlessSteel, strVGirder.str() );
618 logicOCGirder->SetVisAttributes( G4VisAttributes::Invisible );
619
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 );
625
626 if ( id < ( *besEMCGeometry ).BSCNbTheta - 1 )
627 {
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 -
634 zLength / 2;
635
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 );
644
645 ostringstream strVGirder2;
646 strVGirder2 << "logicalOpenningCutGirder_2_" << i - 1;
647 logicOCGirder =
648 new G4LogicalVolume( solidOCGirder, stainlessSteel, strVGirder2.str() );
649 logicOCGirder->SetVisAttributes( G4VisAttributes::Invisible );
650
651 ostringstream strPGirder2;
652 strPGirder2 << "physicalOpenningCutGirder_2_" << i - 1;
653 physiOCGirder =
654 new G4PVPlacement( 0, G4ThreeVector( 0, 0, zPositionOCGirder ), logicOCGirder,
655 strPGirder2.str(), logicBSCPhi,
false, 0,
CHECKLV3 );
656 }
657
658 ostringstream strBSCCable;
659 strBSCCable << "solidBSCCable_1_" << i - 1;
660 solidCable =
661 new G4Tubs( strBSCCable.str(), 0, ( *besEMCGeometry ).cableDr,
662 ( *besEMCGeometry ).cableLength[id] / 2, 0. * deg, 360. * deg );
663
664 ostringstream strVBSCCable;
665 strVBSCCable << "logicalBSCCable_1_" << i - 1;
666 logicCable = new G4LogicalVolume( solidCable, cable, strVBSCCable.str() );
667
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 );
677 }
678 else
679 {
680 id = ( *besEMCGeometry ).BSCNbTheta - i;
681 solidBSCTheta =
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] );
685
686
687
688
689
690 logicBSCTheta =
691 new G4LogicalVolume( solidBSCTheta, fCasingMaterial, strVolumeCasing.str() );
692
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 +
696 thetaPosition[id] );
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 );
701 if ( logicBSCTheta )
702 {
703 G4VisAttributes* rightVisAtt = new G4VisAttributes( G4Colour( 1.0, 0., 0. ) );
704 rightVisAtt->SetVisibility( true );
705 logicBSCTheta->SetVisAttributes( rightVisAtt );
706 logicBSCTheta->SetVisAttributes( G4VisAttributes::Invisible );
707 }
708
709 ostringstream strRear;
710 strRear << "physicalRearBox_2_" << i - 1;
711
712 physiRear =
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 );
718
719 ostringstream strGirder;
720 strGirder << "solidOpenningCutGirder_3_" << i - 1;
721 solidOCGirder =
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 );
727
728 ostringstream strVGirder;
729 strVGirder << "logicalOpenningCutGirder_3_" << i - 1;
730 logicOCGirder = new G4LogicalVolume( solidOCGirder, stainlessSteel, strVGirder.str() );
731 logicOCGirder->SetVisAttributes( G4VisAttributes::Invisible );
732
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 );
738
739 if ( id < ( *besEMCGeometry ).BSCNbTheta - 1 )
740 {
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 -
747 zLength / 2;
748
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 );
757
758 ostringstream strVGirder2;
759 strVGirder2 << "logicalOpenningCutGirder_4_" << i - 1;
760 logicOCGirder =
761 new G4LogicalVolume( solidOCGirder, stainlessSteel, strVGirder2.str() );
762 logicOCGirder->SetVisAttributes( G4VisAttributes::Invisible );
763
764 ostringstream strPGirder2;
765 strPGirder2 << "physicalOpenningCutGirder_4_" << i - 1;
766 physiOCGirder =
767 new G4PVPlacement( 0, G4ThreeVector( 0, 0, -zPositionOCGirder ), logicOCGirder,
768 strPGirder2.str(), logicBSCPhi,
false, 0,
CHECKLV3 );
769 }
770
771 ostringstream strBSCCable;
772 strBSCCable << "solidBSCCable_2_" << i - 1;
773 solidCable =
774 new G4Tubs( strBSCCable.str(), 0, ( *besEMCGeometry ).cableDr,
775 ( *besEMCGeometry ).cableLength[id] / 2, 0. * deg, 360. * deg );
776
777 ostringstream strVBSCCable;
778 strVBSCCable << "logicalBSCCable_2_" << i - 1;
779 logicCable = new G4LogicalVolume( solidCable, cable, strVBSCCable.str() );
780
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 );
790 }
791
792 ostringstream strCrystal;
793 strCrystal << "physicalCrystal" << i - 1;
794 physiBSCCrystal =
795 new G4PVParameterised( strCrystal.str(), logicBSCCrystal, physiBSCTheta, kZAxis,
796 1,
797 crystalParam );
798 ( *besEMCGeometry ).physiBSCCrystal[i] = physiBSCCrystal;
799
800 physiBSCCrystal->SetCopyNo( i );
801 if (
CHECKLV4 ) physiBSCCrystal->CheckOverlaps();
802
803 if ( verboseLevel > 4 )
804 G4cout
805 << "BesEmcConstruction*****************************" << G4endl
806 << "point of crystal =" << physiBSCCrystal
807 << G4endl
808
809 << "point of excepted=" << physiBSCTheta << G4endl;
810
811 }
812
813
814
816
817
820 }
821
822
824
825
826 if ( logicEMC && physiEMC && verboseLevel > 4 )
827 {
828 G4cout << "logicEmc " << logicEMC << " physiEmc " << physiEMC << G4endl;
829 G4cout << "list geo tree" << G4endl;
830
831 int NdaughterofEMC = logicEMC->GetNoDaughters();
832
833 for ( int i = 0; i < NdaughterofEMC; i++ )
834 {
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++ )
840 {
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++ )
847 {
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++ )
855 {
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" ) )
862 {
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;
876
877 }
878 }
879 }
880 }
881 }
882 }
883}
double P(RecMdcKalTrack *trk)
double tan(const BesAngle a)
double sin(const BesAngle a)
double cos(const BesAngle a)
void ConstructSPFrame(G4LogicalVolume *, BesEmcGeometry *)
void ConstructEndGeometry(G4LogicalVolume *)
void PrintEMCParameters()
static EmcG4Geo * Instance()
Get a pointer to the single instance of EmcG4Geo.
G4LogicalVolume * GetTopVolume()
Get the top(world) volume;.