00001 #include "TrkExtAlg/ExtBesEmcConstruction.h"
00002
00003 #include "G4ThreeVector.hh"
00004 #include "G4PVPlacement.hh"
00005 #include "G4LogicalVolume.hh"
00006 #include "G4VPhysicalVolume.hh"
00007
00008
00009 #include "G4ReflectionFactory.hh"
00010
00011
00012
00013 #include "TrkExtAlg/ExtBesEmcGeometry.h"
00014 #include "TrkExtAlg/ExtBesCrystalParameterisation.h"
00015 #include "TrkExtAlg/ExtBesEmcEndGeometry.h"
00016
00017
00018
00019 #include "G4IrregBox.hh"
00020 #include "G4Box.hh"
00021 #include "G4Transform3D.hh"
00022 #include "G4Tubs.hh"
00023 #include "G4Cons.hh"
00024 #include "G4Trap.hh"
00025 #include "G4UnionSolid.hh"
00026 #include "G4SubtractionSolid.hh"
00027 #include "G4Polyhedra.hh"
00028
00029
00030 #include "G4Material.hh"
00031
00032 #include "G4PVParameterised.hh"
00033 #include "G4PVReplica.hh"
00034 #include "globals.hh"
00035 #include "G4UniformMagField.hh"
00036 #include "G4FieldManager.hh"
00037 #include "G4TransportationManager.hh"
00038 #include "G4SDManager.hh"
00039 #include "G4RunManager.hh"
00040 #include "G4VisAttributes.hh"
00041 #include "G4Color.hh"
00042
00043 #include "G4ios.hh"
00044
00045 #include "G4Geo/EmcG4Geo.h"
00046
00047
00048 ExtBesEmcConstruction* ExtBesEmcConstruction::fBesEmcConstruction=0;
00049
00050 ExtBesEmcConstruction::ExtBesEmcConstruction()
00051 :verboseLevel(0),
00052 solidEMC(0),logicEMC(0),physiEMC(0),
00053 solidBSCPhi(0),logicBSCPhi(0),physiBSCPhi(0),
00054 solidBSCTheta(0),logicBSCTheta(0),physiBSCTheta(0),
00055 solidBSCCrystal(0),logicBSCCrystal(0),physiBSCCrystal(0),
00056 magField(0),detectorMessenger(0),
00057 besEMCSD(0),crystalParam(0)
00058 {
00059 if(!fBesEmcConstruction) fBesEmcConstruction=this;
00060
00061 startID = 1;
00062 phiNbCrystals = 0;
00063 thetaNbCrystals = 0;
00064 besEMCGeometry = new ExtBesEmcGeometry();
00065 emcEnd = new ExtBesEmcEndGeometry();
00066 }
00067
00068 ExtBesEmcConstruction::~ExtBesEmcConstruction()
00069 {
00070 if(crystalParam) delete crystalParam;
00071 if(besEMCGeometry) delete besEMCGeometry;
00072 if(emcEnd) delete emcEnd;
00073 }
00074
00075 void ExtBesEmcConstruction::Construct(G4LogicalVolume* logicBes)
00076 {
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 logicEMC = EmcG4Geo::Instance()->GetTopVolume();
00099 if(logicEMC) physiEMC = new G4PVPlacement(0,G4ThreeVector(0.0 ,0.0 ,0.0),logicEMC, "physicalEMC",logicBes, false, 0);
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848 }
00849
00850
00851 void ExtBesEmcConstruction::DefineMaterials()
00852 {
00853 G4String name, symbol;
00854 G4double a, z, density;
00855
00856
00857
00858 G4int ncomponents, natoms;
00859 G4double fractionmass;
00860
00861
00862
00863
00864
00865
00866
00867
00868 G4Element* H=G4Element::GetElement("Hydrogen");
00869 if(!H)
00870 {
00871 a = 1.01*g/mole;
00872 H = new G4Element(name="Hydrogen",symbol="H" , z= 1., a);
00873 }
00874 G4Element* C=G4Element::GetElement("Carbon");
00875 if(!C)
00876 {
00877 a = 12.01*g/mole;
00878 C = new G4Element(name="Carbon" ,symbol="C" , z= 6., a);
00879 }
00880 G4Element* O=G4Element::GetElement("Oxygen");
00881 if(!O)
00882 {
00883 a = 16.00*g/mole;
00884 O = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a);
00885 }
00886
00887 density = 0.344*g/cm3;
00888 G4Material* Tyvek = new G4Material(name="Polyethylene", density, ncomponents=2);
00889 Tyvek->AddElement(C, natoms=1);
00890 Tyvek->AddElement(H, natoms=2);
00891
00892 density = 1.39*g/cm3;
00893 G4Material* Mylar = new G4Material(name="PolyethyleneTerephthlate", density, ncomponents=3);
00894 Mylar->AddElement(C, natoms=5);
00895 Mylar->AddElement(H, natoms=4);
00896 Mylar->AddElement(O, natoms=2);
00897
00898 density = 1.18*g/cm3;
00899 organicGlass = new G4Material(name="OrganicGlass", density, ncomponents=3);
00900 organicGlass->AddElement(C, natoms=5);
00901 organicGlass->AddElement(H, natoms=7);
00902 organicGlass->AddElement(O, natoms=2);
00903
00904 G4Material *Fe = new G4Material(name="Iron", z=26., a=55.85*g/mole, density=7.87*g/cm3);
00905 G4Material *Cr = new G4Material(name="Chromium", z=24., a=52.00*g/mole, density=8.72*g/cm3);
00906 G4Material *Ni = new G4Material(name="Nickel", z=28., a=58.69*g/mole, density=8.72*g/cm3);
00907
00908 stainlessSteel = new G4Material(name="0Cr18Ni9", density=7.85*g/cm3, ncomponents=3);
00909 stainlessSteel->AddMaterial(Fe, fractionmass=73.*perCent);
00910 stainlessSteel->AddMaterial(Cr, fractionmass=18.*perCent);
00911 stainlessSteel->AddMaterial(Ni, fractionmass=9.*perCent);
00912
00913 G4Material *H2O = G4Material::GetMaterial("Water");
00914 G4Material *Cu = G4Material::GetMaterial("Copper");
00915 G4double dWater = 1.*g/cm3;
00916 G4double dCopper = 8.96*g/cm3;
00917 G4double aWater = ((*besEMCGeometry).waterPipeDr-(*besEMCGeometry).waterPipeThickness)
00918 *((*besEMCGeometry).waterPipeDr-(*besEMCGeometry).waterPipeThickness);
00919 G4double aCopper = (*besEMCGeometry).waterPipeDr*(*besEMCGeometry).waterPipeDr-aWater;
00920 density = (dWater*aWater+dCopper*aCopper)/(aWater+aCopper);
00921
00922 waterPipe = new G4Material(name="WaterPipe", density, ncomponents=2);
00923 fractionmass = dWater*aWater/(dWater*aWater+dCopper*aCopper);
00924 waterPipe->AddMaterial(H2O, fractionmass);
00925 fractionmass = dCopper*aCopper/(dWater*aWater+dCopper*aCopper);
00926 waterPipe->AddMaterial(Cu, fractionmass);
00927
00928 cable = new G4Material(name="Cable", density=4.*g/cm3, ncomponents=1);
00929 cable->AddMaterial(Cu,1);
00930
00931
00932
00933
00934
00935
00936
00937 G4Material* Al=G4Material::GetMaterial("Aluminium");
00938 if(Al==NULL)
00939 {
00940 Al = new G4Material(name="Aluminium", z=13., a=26.98*g/mole, density=2.700*g/cm3);
00941 }
00942
00943 G4Material *Si=G4Material::GetMaterial("Silicon");
00944 if(Si==NULL)
00945 {
00946 Si = new G4Material(name="Silicon", z=14., a=28.0855*g/mole, density=2.33*g/cm3);
00947 }
00948
00949
00950 G4double totalThickness=(*besEMCGeometry).fTyvekThickness
00951 +(*besEMCGeometry).fAlThickness+(*besEMCGeometry).fMylarThickness;
00952 density = (Tyvek->GetDensity()*(*besEMCGeometry).fTyvekThickness+
00953 Al->GetDensity()*(*besEMCGeometry).fAlThickness+
00954 Mylar->GetDensity()*(*besEMCGeometry).fMylarThickness)
00955 /totalThickness;
00956 G4Material* Casing = new G4Material(name="Casing", density, ncomponents=3);
00957 Casing->AddMaterial(
00958 Tyvek,
00959 fractionmass=Tyvek->GetDensity()/density
00960 *(*besEMCGeometry).fTyvekThickness
00961 /totalThickness);
00962 Casing->AddMaterial(
00963 Al,
00964 fractionmass=Al->GetDensity()/density
00965 *(*besEMCGeometry).fAlThickness
00966 /totalThickness);
00967 Casing->AddMaterial(
00968 Mylar,
00969 fractionmass=Mylar->GetDensity()/density
00970 *(*besEMCGeometry).fMylarThickness
00971 /totalThickness);
00972 fCasingMaterial = Casing;
00973 rearCasingMaterial = Tyvek;
00974
00975
00976 fCrystalMaterial = G4Material::GetMaterial("Cesiumiodide");
00977 }
00978
00979
00980 void ExtBesEmcConstruction::ConstructEndGeometry(G4LogicalVolume* logicEM)
00981 {
00982 G4Material* fCrystalMaterial = G4Material::GetMaterial("Cesiumiodide");
00983
00984
00985
00986
00987
00988
00989
00990 solidEnd = new G4Cons("EndWorld",(*emcEnd).WorldRmin1,(*emcEnd).WorldRmax1,(*emcEnd).WorldRmin2,(*emcEnd).WorldRmax2,
00991 (*emcEnd).WorldDz/2,0.*deg,360.*deg);
00992 logicEnd = new G4LogicalVolume(solidEnd, G4Material::GetMaterial("Air"), "EndWorld", 0, 0, 0);
00993 physiEnd = new G4PVPlacement(0,
00994 G4ThreeVector(0,0,(*emcEnd).WorldZPosition),
00995 logicEnd,
00996 "EndWorld",
00997 logicEMC,
00998 false,
00999 0);
01000
01001
01002
01003
01004
01005 G4RotationMatrix *rotateEnd = new G4RotationMatrix();
01006 rotateEnd->rotateY(180.*deg);
01007 physiEnd = new G4PVPlacement(rotateEnd,
01008 G4ThreeVector(0,0,-(*emcEnd).WorldZPosition),
01009 logicEnd,
01010 "EndWorld",
01011 logicEMC,
01012 false,
01013 2);
01014
01016
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01037
01038
01039
01040 solidEndPhi = new G4Cons("EndPhi",(*emcEnd).WorldRmin1,(*emcEnd).WorldRmax1,(*emcEnd).WorldRmin2,(*emcEnd).WorldRmax2,
01041 (*emcEnd).WorldDz/2,0*deg,22.5*deg);
01042 logicEndPhi = new G4LogicalVolume(solidEndPhi, G4Material::GetMaterial("Air"), "EndPhi", 0, 0, 0);
01043 for(G4int i=0;i<14;i++)
01044 {
01045 if((i!=6)&&(i!=7))
01046 {
01047 G4RotationMatrix *rotatePhi = new G4RotationMatrix();
01048 rotatePhi->rotateZ(-i*22.5*deg+67.5*deg);
01049 physiEndPhi = new G4PVPlacement(rotatePhi,0,logicEndPhi,"EndPhi",logicEnd,false,i);
01050 }
01051 }
01052
01053
01054
01055 for(G4int i=0;i<35;i++)
01056 {
01057 G4int copyNb = ComputeEndCopyNb(i);
01058
01059 solidEndCasing = new G4IrregBox("EndCasing",(*emcEnd).fPnt[i]);
01060 logicEndCasing = new G4LogicalVolume(solidEndCasing,fCasingMaterial,"EndCasing");
01061 physiEndCasing = new G4PVPlacement(0,0,logicEndCasing,"EndCasing",logicEndPhi,false,copyNb);
01062
01063 emcEnd->ModifyForCasing((*emcEnd).fPnt[i],i);
01064 solidEndCrystal = new G4IrregBox("EndCrystal",(*emcEnd).cryPoint);
01065 logicEndCrystal = new G4LogicalVolume(solidEndCrystal,fCrystalMaterial,"EndCrystal");
01066 physiEndCrystal = new G4PVPlacement(0,0,logicEndCrystal,"EndCrystal",logicEndCasing,false,copyNb);
01067
01068
01069
01070
01071 }
01072
01073
01074
01075
01076 solidEndPhi = new G4Cons("EndPhi",(*emcEnd).WorldRmin1,(*emcEnd).WorldRmax1,(*emcEnd).WorldRmin2,(*emcEnd).WorldRmax2,
01077 (*emcEnd).WorldDz/2,67.5*deg,22.5*deg);
01078 logicEndPhi = new G4LogicalVolume(solidEndPhi, G4Material::GetMaterial("Air"), "EndPhi", 0, 0, 0);
01079 for(G4int i=0;i<2;i++)
01080 {
01081 G4RotationMatrix *rotatePhi = new G4RotationMatrix();
01082 rotatePhi->rotateZ(-i*180.*deg);
01083 physiEndPhi = new G4PVPlacement(rotatePhi,0,logicEndPhi,"EndPhi",logicEnd,false,i*8+6);
01084 }
01085
01086
01087
01088 for(G4int i=0;i<35;i++)
01089 {
01090 G4int copyNb = ComputeEndCopyNb(i);
01091 solidEndCasing = new G4IrregBox("EndCasing",(*emcEnd).fPnt1[i]);
01092 logicEndCasing = new G4LogicalVolume(solidEndCasing,fCasingMaterial,"EndCasing");
01093 physiEndCasing = new G4PVPlacement(0,0,logicEndCasing,"EndCasing",logicEndPhi,false,copyNb);
01094
01095 emcEnd->ModifyForCasing((*emcEnd).fPnt1[i],i);
01096 solidEndCrystal = new G4IrregBox("EndCrystal",(*emcEnd).cryPoint);
01097 logicEndCrystal = new G4LogicalVolume(solidEndCrystal,fCrystalMaterial,"EndCrystal");
01098 physiEndCrystal = new G4PVPlacement(0,0,logicEndCrystal,"EndCrystal",logicEndCasing,false,copyNb);
01099
01100
01101
01102
01103 }
01104
01105 (*emcEnd).ReflectX();
01106
01107
01108 for(G4int i=0;i<35;i++)
01109 for (G4int j=0;j<8;j++)
01110 (*emcEnd).fPnt1[i][j].rotateZ(-90.*deg);
01111
01112 solidEndPhi = new G4Cons("EndPhi",(*emcEnd).WorldRmin1,(*emcEnd).WorldRmax1,(*emcEnd).WorldRmin2,(*emcEnd).WorldRmax2,
01113 (*emcEnd).WorldDz/2,0*deg,22.5*deg);
01114 logicEndPhi = new G4LogicalVolume(solidEndPhi, G4Material::GetMaterial("Air"), "EndPhi", 0, 0, 0);
01115 for(G4int i=0;i<2;i++)
01116 {
01117 G4RotationMatrix *rotatePhi = new G4RotationMatrix();
01118 rotatePhi->rotateZ(-i*180.*deg-90.*deg);
01119 physiEndPhi = new G4PVPlacement(rotatePhi,0,logicEndPhi,"EndPhi",logicEnd,false,i*8+7);
01120 }
01121
01122
01123
01124 for(G4int i=0;i<35;i++)
01125 {
01126 G4int copyNb = ComputeEndCopyNb(i);
01127 solidEndCasing = new G4IrregBox("EndCasing",(*emcEnd).fPnt1[i]);
01128 logicEndCasing = new G4LogicalVolume(solidEndCasing,fCrystalMaterial,"EndCasing");
01129 physiEndCasing = new G4PVPlacement(0,0,logicEndCasing,"EndCasing",logicEndPhi,false,copyNb);
01130
01131 emcEnd->ModifyForCasing((*emcEnd).fPnt1[i],i);
01132 solidEndCrystal = new G4IrregBox("EndCrystal",(*emcEnd).cryPoint);
01133 logicEndCrystal = new G4LogicalVolume(solidEndCrystal,fCrystalMaterial,"EndCrystal");
01134 physiEndCrystal = new G4PVPlacement(0,0,logicEndCrystal,"EndCrystal",logicEndCasing,false,copyNb);
01135
01136
01137
01138
01139 }
01140 }
01141
01143 void ExtBesEmcConstruction::ConstructSPFrame(G4LogicalVolume* logicEMC, ExtBesEmcGeometry* besEMCGeometry)
01144 {
01145
01146
01147
01148 solidSupportBar = new G4Tubs("SupportBar",
01149 (*besEMCGeometry).BSCRmax+(*besEMCGeometry).SPBarThickness1,
01150 (*besEMCGeometry).BSCRmax+(*besEMCGeometry).SPBarThickness+(*besEMCGeometry).SPBarThickness1,
01151 (*besEMCGeometry).BSCDz+(*besEMCGeometry).TaperRingThickness3+(*besEMCGeometry).EndRingDz,
01152 0.*deg,
01153 360.*deg);
01154
01155 logicSupportBar = new G4LogicalVolume(solidSupportBar,stainlessSteel,"SupportBar");
01156
01157 physiSupportBar = new G4PVPlacement(0,0,logicSupportBar,"SupportBar",logicEMC,false,0);
01158
01159 solidSupportBar1 = new G4Tubs("SupportBar1",
01160 (*besEMCGeometry).BSCRmax,
01161 (*besEMCGeometry).BSCRmax+(*besEMCGeometry).SPBarThickness1,
01162 (*besEMCGeometry).BSCDz+(*besEMCGeometry).TaperRingThickness3,
01163 (*besEMCGeometry).BSCPhiDphi-(*besEMCGeometry).SPBarDphi/2,
01164 (*besEMCGeometry).SPBarDphi);
01165
01166 logicSupportBar1 = new G4LogicalVolume(solidSupportBar1,stainlessSteel,"SupportBar1");
01167
01168 for(G4int i=0;i<(*besEMCGeometry).BSCNbPhi/2;i++)
01169 {
01170 G4RotationMatrix *rotateSPBar = new G4RotationMatrix();
01171 rotateSPBar->rotateZ((*besEMCGeometry).BSCPhiDphi-i*2*(*besEMCGeometry).BSCPhiDphi);
01172 physiSupportBar1 = new G4PVPlacement(rotateSPBar,0,logicSupportBar1,"SupportBar1",logicEMC,false,0);
01173 }
01174
01175
01176 solidEndRing = new G4Tubs("EndRing",
01177 (*besEMCGeometry).EndRingRmin,
01178 (*besEMCGeometry).EndRingRmin+(*besEMCGeometry).EndRingDr/2,
01179 (*besEMCGeometry).EndRingDz/2,
01180 0.*deg,
01181 360.*deg);
01182
01183 solidGear = new G4Tubs("Gear",
01184 (*besEMCGeometry).EndRingRmin+(*besEMCGeometry).EndRingDr/2,
01185 (*besEMCGeometry).EndRingRmin+(*besEMCGeometry).EndRingDr,
01186 (*besEMCGeometry).EndRingDz/2,
01187 0.*deg,
01188 (*besEMCGeometry).BSCPhiDphi);
01189
01190
01191 solidTaperRing1 = new G4Tubs("TaperRing1",
01192 (*besEMCGeometry).TaperRingRmin1,
01193 (*besEMCGeometry).TaperRingRmin1+(*besEMCGeometry).TaperRingThickness1,
01194 (*besEMCGeometry).TaperRingInnerLength/2,
01195 0.*deg,
01196 360.*deg);
01197
01198 solidTaperRing2 = new G4Cons("TaperRing2",
01199 (*besEMCGeometry).TaperRingRmin1,
01200 (*besEMCGeometry).TaperRingRmin1+(*besEMCGeometry).TaperRingDr,
01201 (*besEMCGeometry).TaperRingRmin2,
01202 (*besEMCGeometry).TaperRingRmin2+(*besEMCGeometry).TaperRingDr,
01203 (*besEMCGeometry).TaperRingDz/2,
01204 0.*deg,
01205 360.*deg);
01206
01207 solidTaperRing3 = new G4Cons("TaperRing3",
01208 (*besEMCGeometry).BSCRmax2,
01209 (*besEMCGeometry).BSCRmax2+(*besEMCGeometry).TaperRingOuterLength1,
01210 (*besEMCGeometry).TaperRingRmin2+(*besEMCGeometry).TaperRingDr,
01211 (*besEMCGeometry).TaperRingRmin2+(*besEMCGeometry).TaperRingDr+(*besEMCGeometry).TaperRingOuterLength,
01212 (*besEMCGeometry).TaperRingThickness3/2,
01213 0.*deg,
01214 360.*deg);
01215
01216 logicEndRing = new G4LogicalVolume(solidEndRing,stainlessSteel,"EmcEndRing");
01217 logicGear = new G4LogicalVolume(solidGear,stainlessSteel,"Gear");
01218 logicTaperRing1 = new G4LogicalVolume(solidTaperRing1,stainlessSteel,"TaperRing1");
01219 logicTaperRing2 = new G4LogicalVolume(solidTaperRing2,stainlessSteel,"TaperRing2");
01220 logicTaperRing3 = new G4LogicalVolume(solidTaperRing3,stainlessSteel,"TaperRing3");
01221
01222 for(G4int i=0;i<2;i++)
01223 {
01224 G4RotationMatrix *rotateSPRing = new G4RotationMatrix();
01225 G4double zEndRing,z1,z2,z3;
01226 if(i==0)
01227 {
01228 zEndRing = (*besEMCGeometry).BSCDz+(*besEMCGeometry).TaperRingThickness3+(*besEMCGeometry).EndRingDz/2;
01229 z1 = (*besEMCGeometry).BSCDz+(*besEMCGeometry).TaperRingThickness3
01230 -(*besEMCGeometry).TaperRingDz-(*besEMCGeometry).TaperRingInnerLength/2;
01231 z2 = (*besEMCGeometry).BSCDz+(*besEMCGeometry).TaperRingThickness3-(*besEMCGeometry).TaperRingDz/2;
01232 z3 = (*besEMCGeometry).BSCDz+(*besEMCGeometry).TaperRingThickness3/2;
01233 }
01234 else
01235 {
01236 rotateSPRing->rotateY(180.*deg);
01237 zEndRing = -((*besEMCGeometry).BSCDz+(*besEMCGeometry).TaperRingThickness3+(*besEMCGeometry).EndRingDz/2);
01238 z1 = -((*besEMCGeometry).BSCDz+(*besEMCGeometry).TaperRingThickness3
01239 -(*besEMCGeometry).TaperRingDz-(*besEMCGeometry).TaperRingInnerLength/2);
01240 z2 = -((*besEMCGeometry).BSCDz+(*besEMCGeometry).TaperRingThickness3-(*besEMCGeometry).TaperRingDz/2);
01241 z3 = -((*besEMCGeometry).BSCDz+(*besEMCGeometry).TaperRingThickness3/2);
01242 }
01243
01244 physiEndRing = new G4PVPlacement(rotateSPRing,G4ThreeVector(0,0,zEndRing),
01245 logicEndRing,"EndRing",logicEMC,false,0);
01246
01247 for(G4int j=0;j<(*besEMCGeometry).BSCNbPhi/2;j++)
01248 {
01249 G4RotationMatrix *rotateGear = new G4RotationMatrix();
01250 rotateGear->rotateZ((*besEMCGeometry).BSCPhiDphi/2-j*2*(*besEMCGeometry).BSCPhiDphi);
01251 physiGear = new G4PVPlacement(rotateGear,G4ThreeVector(0,0,zEndRing),
01252 logicGear,"Gear",logicEMC,false,0);
01253 }
01254
01255 physiTaperRing1 = new G4PVPlacement(rotateSPRing,G4ThreeVector(0,0,z1),
01256 logicTaperRing1,"TaperRing1",logicEMC,false,0);
01257
01258 physiTaperRing2 = new G4PVPlacement(rotateSPRing,G4ThreeVector(0,0,z2),
01259 logicTaperRing2,"TaperRing2",logicEMC,false,0);
01260
01261 physiTaperRing3 = new G4PVPlacement(rotateSPRing,G4ThreeVector(0,0,z3),
01262 logicTaperRing3,"TaperRing3",logicEMC,false,0);
01263 }
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273 }
01274
01275 G4int ExtBesEmcConstruction::ComputeEndCopyNb(G4int num)
01276 {
01277 G4int copyNb;
01278 switch(num){
01279 case 30:
01280 copyNb = 5;
01281 break;
01282 case 31:
01283 copyNb = 6;
01284 break;
01285 case 32:
01286 copyNb = 14;
01287 break;
01288 case 33:
01289 copyNb = 15;
01290 break;
01291 case 34:
01292 copyNb = 16;
01293 break;
01294 default:
01295 copyNb = num;
01296 break;
01297 }
01298 return copyNb;
01299 }
01300
01301
01302 void ExtBesEmcConstruction::PrintEMCParameters()
01303 {
01304 G4cout << "-------------------------------------------------------"<< G4endl
01305 << "---> There are "
01306 << phiNbCrystals << "(max=" << (*besEMCGeometry).BSCNbPhi
01307 << ") crystals along phi direction and "
01308 << thetaNbCrystals << "(max=" << (*besEMCGeometry).BSCNbTheta
01309 << ") crystals along theta direction."<< G4endl
01310 << "The crystals have sizes of "
01311 << (*besEMCGeometry).BSCCryLength/cm << "cm(L) and "
01312 << (*besEMCGeometry).BSCYFront/cm << "cm(Y) with "
01313 << fCrystalMaterial->GetName() <<"."<< G4endl
01314 << "The casing is layer of "
01315 << (*besEMCGeometry).fTyvekThickness/mm << "mm tyvek,"
01316 << (*besEMCGeometry).fAlThickness/mm << "mm aluminum and"
01317 << (*besEMCGeometry).fMylarThickness/mm << "mm mylar."<< G4endl
01318 << "-------------------------------------------------------"<< G4endl;
01319 G4cout << G4Material::GetMaterial("PolyethyleneTerephthlate") << G4endl
01320 << G4Material::GetMaterial("Casing") << G4endl
01321 << G4Material::GetMaterial("Polyethylene") << G4endl
01322 << "-------------------------------------------------------"<< G4endl;
01323 }
01324
01325
01326
01327 void ExtBesEmcConstruction::SetCrystalMaterial(G4String materialChoice)
01328 {
01329
01330 G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
01331 if (pttoMaterial)
01332 {fCrystalMaterial = pttoMaterial;
01333 logicBSCCrystal->SetMaterial(pttoMaterial);
01334 PrintEMCParameters();
01335 }
01336 }
01337
01338
01339 void ExtBesEmcConstruction::SetCasingMaterial(G4String materialChoice)
01340 {
01341
01342 G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
01343 if (pttoMaterial)
01344 {fCasingMaterial = pttoMaterial;
01345 logicBSCTheta->SetMaterial(pttoMaterial);
01346 PrintEMCParameters();
01347 }
01348 }
01349
01350
01351
01352 void ExtBesEmcConstruction::SetCasingThickness(G4ThreeVector val)
01353 {
01354
01355 (*besEMCGeometry).fTyvekThickness = val('X');
01356 (*besEMCGeometry).fAlThickness = val('Y');
01357 (*besEMCGeometry).fMylarThickness = val('Z');
01358 }
01359
01360
01361
01362 void ExtBesEmcConstruction::SetBSCRmin(G4double val)
01363 {
01364 (*besEMCGeometry).BSCRmin = val;
01365 }
01366
01367
01368
01369 void ExtBesEmcConstruction::SetBSCNbPhi(G4int val)
01370 {
01371 (*besEMCGeometry).BSCNbPhi = val;
01372 }
01373
01374
01375
01376 void ExtBesEmcConstruction::SetBSCNbTheta(G4int val)
01377 {
01378 (*besEMCGeometry).BSCNbTheta = val;
01379 }
01380
01381 void ExtBesEmcConstruction::SetStartIDTheta(G4int val)
01382 {
01383 startID = val;
01384 }
01385
01386
01387
01388
01389 void ExtBesEmcConstruction::SetBSCCrystalLength(G4double val)
01390 {
01391 (*besEMCGeometry).BSCCryLength = val;
01392 }
01393
01394
01395
01396 void ExtBesEmcConstruction::SetBSCYFront0(G4double val)
01397 {
01398 (*besEMCGeometry).BSCYFront0 = val;
01399 }
01400
01401
01402
01403
01404 void ExtBesEmcConstruction::SetBSCYFront(G4double val)
01405 {
01406 (*besEMCGeometry).BSCYFront = val;
01407 }
01408
01409
01410
01411 void ExtBesEmcConstruction::SetBSCPosition0(G4double val)
01412 {
01413 (*besEMCGeometry).BSCPosition0 = val;
01414 }
01415
01416
01417
01418 void ExtBesEmcConstruction::SetBSCPosition1(G4double val)
01419 {
01420 (*besEMCGeometry).BSCPosition1 = val;
01421 }
01422
01423
01424
01425 void ExtBesEmcConstruction::SetMagField(G4double fieldValue)
01426 {
01427
01428 G4FieldManager* fieldMgr
01429 = G4TransportationManager::GetTransportationManager()->GetFieldManager();
01430
01431 if(magField) delete magField;
01432
01433 if(fieldValue!=0.)
01434 { magField = new G4UniformMagField(G4ThreeVector(0.,0.,fieldValue));
01435 fieldMgr->SetDetectorField(magField);
01436 fieldMgr->CreateChordFinder(magField);
01437 fmagField=fieldValue;
01438 } else {
01439 magField = 0;
01440 fieldMgr->SetDetectorField(magField);
01441 fmagField=0.;
01442 }
01443 }
01444
01445
01446
01447 void ExtBesEmcConstruction::UpdateGeometry()
01448 {
01449 ;
01450 }