/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Simulation/BOOST/TofSim/TofSim-00-02-33/src/BesTofConstruction.cc

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------//
00002 //      BOOST --- BESIII Object_Oriented Simulation Tool                     //
00003 //---------------------------------------------------------------------------//
00004 //Description:  Geometry Construction for barrel and endcap Tof
00005 //Author: Dengzy
00006 //Created: Mar, 2004
00007 //Modified: Way of reading txt file in dat/ is changed.
00008 //The material for BC404 and BC408 has been exchanged. The original
00009 //one is opposite. (Liu Yong @ Dec 2008)
00010 //$Id: BesTofConstruction.cc
00011 //
00012 
00013 #include "GaudiKernel/MsgStream.h"
00014 #include "GaudiKernel/Bootstrap.h"
00015 #include "GaudiKernel/PropertyMgr.h"
00016 #include "GaudiKernel/IJobOptionsSvc.h"
00017 #include "GaudiKernel/ISvcLocator.h"
00018 #include "GaudiKernel/IDataProviderSvc.h"
00019 
00020 #include "BesTofConstruction.hh"
00021 #include "BesTofGeoParameter.hh"
00022 #include "PartProduce.hh"
00023 #include "BesTofSD.hh"
00024 #include "G4Geo/TofG4Geo.h"
00025 #include "G4Geo/MRPCG4Geo.h"
00026 #include "ReadBoostRoot.hh"
00027 
00028 #include "G4Material.hh"
00029 #include "G4Trap.hh"
00030 #include "G4Tubs.hh"
00031 #include "G4Box.hh"
00032 #include "G4Trd.hh"
00033 #include "G4Cons.hh"
00034 #include "G4UnionSolid.hh"
00035 #include "G4SubtractionSolid.hh"
00036 #include "G4IntersectionSolid.hh"
00037 
00038 #include "G4LogicalVolume.hh"
00039 #include "G4Transform3D.hh"
00040 #include "G4PVPlacement.hh"
00041 #include "G4AssemblyVolume.hh"
00042 #include "G4SDManager.hh"
00043 #include "G4UnitsTable.hh"
00044 #include "G4ios.hh"
00045 #include "G4Colour.hh"
00046 #include "G4VisAttributes.hh"
00047 #include "G4UnionSolid.hh"
00048 #include "G4UserLimits.hh"
00049 
00050 
00051 
00052 BesTofConstruction::BesTofConstruction()    //Constructor, set variables (G4logical or G4physical volumes) declared in BesTofConstruction.hh
00053 {
00054     PropertyMgr m_propMgr1;
00055     m_propMgr1.declareProperty("UserLimits", m_userLimits = 0.03);
00056     m_propMgr1.declareProperty("IonE", m_ionE = 75);
00057     IJobOptionsSvc* jobSvc1;
00058     Gaudi::svcLocator()->service("JobOptionsSvc", jobSvc1);
00059     jobSvc1->setMyProperties("BesTofConstruction", &m_propMgr1);
00060 
00061     logicalTof  = 0;
00062     physicalTof = 0;
00063 
00064     logicalBrTof = 0;
00065     logicalEcTofWest=0;
00066     logicalEcTofEast=0;
00067 
00068     logicalScinBr1  = 0;
00069     logicalScinBr2  = 0;
00070     physicalScinBr1 = 0;
00071     physicalScinBr2 = 0;
00072 
00073     logicalAlBr1 = 0;
00074     logicalAlBr2 = 0;
00075     physicalAlBr1 = 0;
00076     physicalAlBr2 = 0;
00077 
00078     logicalPVFBr1 = 0;
00079     logicalPVFBr2 = 0;
00080     physicalPVFBr1 = 0;
00081     physicalPVFBr2 = 0;
00082 
00083     logicalBucketBr1= 0;
00084     logicalBucketBr2= 0;
00085 
00086     physicalBucket1Br1 = 0;
00087     physicalBucket2Br1 = 0;
00088     physicalBucket1Br2 = 0;
00089     physicalBucket2Br2 = 0;
00090 
00091     logicalScinEcWest   = 0;
00092     logicalScinEcEast = 0;
00093     physicalScinEcWest = 0;
00094     physicalScinEcEast = 0;
00095 
00096     logicalAlEcWest = 0;
00097     logicalAlEcEast = 0;
00098     physicalAlEcWest = 0;
00099     physicalAlEcEast = 0;
00100 
00101     logicalPVFEcWest = 0;
00102     logicalPVFEcEast = 0;
00103     physicalPVFEcWest = 0;
00104     physicalPVFEcEast = 0;
00105 
00106     logicalBucketEc = 0;
00107     physicalBucketEc = 0;
00108 
00109     BC404 = 0;
00110     BC408 = 0;
00111     PVF = 0;
00112     PMTmaterial = 0;
00113 
00114     //MRPC 
00115     logical_gasLayer=0;
00116 }
00117 
00118 BesTofConstruction::~BesTofConstruction()
00119 {}
00120 
00121 void BesTofConstruction::Construct(G4LogicalVolume* logicalBes)
00122 {
00123     DefineMaterial(); //This function just defines my material, used for the TOF
00124 
00125     if ( ReadBoostRoot::GetTof() == 2 )   
00126     {
00127         TofG4Geo* aTofG4Geo = new TofG4Geo();
00128         logicalTof = aTofG4Geo->GetTopVolume();
00129         if (!logicalTof)
00130           G4cout<<"BesTofConstruction::Construct(), logicalTof not found"<<G4endl;
00131         else
00132         {
00133             //produce the logical Tof
00134             physicalTof = new G4PVPlacement(0,G4ThreeVector(0,0,0),
00135                         logicalTof,"physicalTof",logicalBes,false,0); // Class representing a single volume positioned within and relative to a mother volume.
00136 
00137             //for visual attributes
00138             logicalScinBr1  = FindLogicalVolume("logicalScinBr1");
00139             logicalScinBr2  = FindLogicalVolume("logicalScinBr2");
00140 
00141             logicalAlBr1 = FindLogicalVolume("logicalAlBr1");
00142             logicalAlBr2 = FindLogicalVolume("logicalAlBr2");
00143             logicalPVFBr1 = FindLogicalVolume("logicalPVFBr1");
00144             logicalPVFBr2 = FindLogicalVolume("logicalPVFBr2");
00145             logicalBucketBr1 = FindLogicalVolume("logicalBucketBr1");
00146             logicalBucketBr2 = FindLogicalVolume("logicalBucketBr2");
00147 
00148             logicalScinEcWest = FindLogicalVolume("logicalScinEcWest");
00149             logicalScinEcEast = FindLogicalVolume("logicalScinEcEast");
00150             logicalBucketEc = FindLogicalVolume("logicalBucketEc");
00151         }
00152         //m_sxp.Finalize();
00153         delete aTofG4Geo;
00154     } //close (ReadBoostRoot::GetTof() == 2)
00155 
00156     else if(ReadBoostRoot::GetTof() == 3 ) //start TOF with MRPC Endcaps
00157     {
00158         //This part intialize a function where the Parameter of the TOF are saved!
00159         BesTofGeoParameter* tofPara = BesTofGeoParameter::GetInstance();
00160 
00161         //Get the coordinates of the TOF
00162         G4double r1=380; //Newly changed from 399 for MRPC to avoid overlap 
00163         G4double r2=tofPara->GetBucketPosR()+0.5*tofPara->GetBucketDEc()+1;  //=474
00164         G4double r3=810;
00165         G4double r4=925;
00166         G4double a1=1382+tofPara->GetBucketLEc()+1; //1463
00167         G4double a2=1381; // Changed from 1382 to avoid overlapping with EMC
00168         //to make the center of tub6 is tofPara.GetzPosEastEc()=1356
00169         G4double a3=1330;
00170         G4cout<<"Tof Volume: "<<r1<<" "<<r2<<" "<<r3<<" "<<r4<<" "<<a1<<" "<<a2<<" "<<a3<<G4endl;
00171 
00172         //Tof:  produce a cylinder with inner radius r1 and outer radius r2, z height: 2a1, starting angle 0 untill 360
00173         G4Tubs* tub1 = new G4Tubs("tub1",r1,r2,a1,0,360);     
00174         G4Tubs* tub2 = new G4Tubs("tub2",r2-4,r4,a2,0,360);
00175         G4Tubs* tub3 = new G4Tubs("tub3",0,r3,a3,0,360);
00176         G4UnionSolid* tub4 = new G4UnionSolid("tub4",tub1,tub2,0,G4ThreeVector(0,0,0) );  //Vereinigt tub 1 und 2 in tub4
00177         G4SubtractionSolid* solidTof = new G4SubtractionSolid("solidTof",tub4,tub3,0, G4ThreeVector(0,0,0) );  //Subtracts tub4  - tub3
00178         logicalTof = new G4LogicalVolume(solidTof, G4Material::GetMaterial("Air"),"logicalTof"); //book logical Tof VOlume
00179         physicalTof = new G4PVPlacement(0,G4ThreeVector(0,0,0),logicalTof,"physicalTof",logicalBes,false,0);
00180 
00181         //Logical + Physical volumes for the barrel
00182         G4Tubs* tub5 = new G4Tubs("tub5",r3,r4,a3,0,360);
00183         logicalBrTof = new G4LogicalVolume(tub5, G4Material::GetMaterial("Air"),"logicalBrTof");  //book logical Barrel TOF
00184         G4VPhysicalVolume* physicalBrTof = new G4PVPlacement(0,G4ThreeVector(0,0,0),logicalBrTof,"physicalBrTof",logicalTof,false,0); 
00185 
00186 
00187         //Logical + Physical volumes for the endcaps
00188         G4Tubs* tub6 = new G4Tubs("tub6",r1,r4,(a2-a3)/2,0,360);  //ring: dz/2=2.55cm, xy=52.6 cm
00189         G4Tubs* tub7 = new G4Tubs("tub7",r1,r2,(a1-a2)/2,0,360);  //ring: dz/2=0.1cm, xy=7.5 cm 
00190         G4UnionSolid* tub8 = new G4UnionSolid("tub8",tub6,tub7,0,G4ThreeVector(0,0,(a3-a1)/2)); //Unify both tubes,translate z-axes -6.15 cm to the originally one  
00191         logicalEcTofWest = new G4LogicalVolume(tub8, G4Material::GetMaterial("Air"),"logicalEcTofWest");
00192         G4VPhysicalVolume* physicalEcTofWest = new G4PVPlacement(0,G4ThreeVector(0,0,tofPara->GetzPosWestEc()),logicalEcTofWest,"physicalEcTofWest",logicalTof,false,0);
00193 
00194         G4UnionSolid* tub9 = new G4UnionSolid("tub9",tub6,tub7,0,G4ThreeVector(0,0,(a1-a3)/2) ); //Unify both tubes,translate z-axes +6.15 cm to the originally one
00195         logicalEcTofEast = new G4LogicalVolume(tub9, G4Material::GetMaterial("Air"),"logicalEcTofEast");
00196         G4VPhysicalVolume* physicalEcTofEast = new G4PVPlacement(0,G4ThreeVector(0,0,tofPara->GetzPosEastEc()),logicalEcTofEast,"physicalEcTofEast",logicalTof,false,0);
00197 
00198 
00199         //Functions which construct the different parts of the TOF -->See below
00200         //Construct Tape
00201         //put these lines before ConstructBr1Tof();
00202         //so in BesTofSD.cc, no need to change the tofid caculation method
00203         G4Tubs* tubTape = new G4Tubs("tubTape",866, 866.3, 1150, 0, 360);
00204         G4LogicalVolume* logicalTape = new G4LogicalVolume(tubTape,G4Material::GetMaterial("tape"),"logicalTape");
00205         G4VPhysicalVolume* physicalTape = new G4PVPlacement(0,G4ThreeVector(0,0,0),logicalTape,"physicalTape",logicalBrTof,false,0);
00206         logicalTape->SetVisAttributes(G4VisAttributes::Invisible);
00207 
00208         ConstructBr1Tof();  
00209         ConstructBr2Tof();
00210         ConstructEcTof_mrpc();
00211     }
00212 
00213     else if (ReadBoostRoot::GetTof() == 4 ) //start TOF with MRPC Endcaps GDML Construction
00214     {
00215         MRPCG4Geo* aTofG4Geo = new MRPCG4Geo();
00216         logicalTof = aTofG4Geo->GetTopVolume();
00217         if (!logicalTof)
00218           G4cout<<"BesTofConstruction::Construct(), logicalTof not found"<<G4endl;
00219         else
00220         {
00221             physicalTof = new G4PVPlacement(0,G4ThreeVector(0,0,0),logicalTof,"physicalTof",logicalBes,false,0);
00222 
00223             logicalScinBr1  = FindLogicalVolume("logicalScinBr1");
00224             logicalScinBr2  = FindLogicalVolume("logicalScinBr2");
00225 
00226             logicalAlBr1 = FindLogicalVolume("logicalAlBr1");
00227             logicalAlBr2 = FindLogicalVolume("logicalAlBr2");
00228             logicalPVFBr1 = FindLogicalVolume("logicalPVFBr1");
00229             logicalPVFBr2 = FindLogicalVolume("logicalPVFBr2");
00230             logicalBucketBr1 = FindLogicalVolume("logicalBucketBr1");
00231             logicalBucketBr2 = FindLogicalVolume("logicalBucketBr2");
00232 
00233             logical_gasLayer=FindLogicalVolume("logical_gasLayer");
00234         }  
00235         delete aTofG4Geo;
00236     } //close else if(==4)
00237 
00238     else
00239     {
00240         //-----------------logicalTof added here
00241         BesTofGeoParameter* tofPara = BesTofGeoParameter::GetInstance();  
00242 
00243         //Get the coordinates of the TOF
00244         G4double r1=tofPara->GetEcR1()-1;  //=399 
00245         G4double r2=tofPara->GetBucketPosR()+0.5*tofPara->GetBucketDEc()+1;  //=474
00246         G4double r3=810;;
00247         G4double r4=925;
00248         G4double a1=1382+tofPara->GetBucketLEc()+1; //1463
00249         G4double a2=1381; // Changed from 1382 to avoid overlapping with EMC
00250         //to make the center of tub6 is tofPara.GetzPosEastEc()=1356
00251         G4double a3=1330;
00252         G4cout<<"Tof Volume: "<<r1<<" "<<r2<<" "<<r3<<" "<<r4<<" "<<a1<<" "<<a2<<" "<<a3<<G4endl;
00253 
00254         G4Tubs* tub1 = new G4Tubs("tub1",r1,r2,a1,0,360);     //Just produce a cylinder with inner radius r1 and outer radius r2, z height: 2a1, starting angle 0 untill 360
00255         G4Tubs* tub2 = new G4Tubs("tub2",r2-4,r4,a2,0,360);
00256         G4Tubs* tub3 = new G4Tubs("tub3",0,r3,a3,0,360);
00257         G4UnionSolid* tub4 = new G4UnionSolid("tub4",tub1,tub2,0,G4ThreeVector(0,0,0) );  //Vereinigt tub 1 und 2 in tub4
00258         G4SubtractionSolid* solidTof = new G4SubtractionSolid("solidTof",tub4,tub3,0, G4ThreeVector(0,0,0) );  //Subtracts tub4  - tub3
00259         logicalTof = new G4LogicalVolume(solidTof, G4Material::GetMaterial("Air"),"logicalTof"); //book logical Tof VOlume
00260         physicalTof = new G4PVPlacement(0,G4ThreeVector(0,0,0),logicalTof,"physicalTof",logicalBes,false,0);
00261 
00262         G4Tubs* tub5 = new G4Tubs("tub5",r3,r4,a3,0,360);
00263         logicalBrTof = new G4LogicalVolume(tub5, G4Material::GetMaterial("Air"),"logicalBrTof");  //book logical Barrel TOF
00264         G4VPhysicalVolume* physicalBrTof = new G4PVPlacement(0,G4ThreeVector(0,0,0),logicalBrTof,"physicalBrTof",logicalTof,false,0); 
00265 
00266         //Logical + Physical volumes for the endcaps
00267         G4Tubs* tub6 = new G4Tubs("tub6",r1,r4,(a2-a3)/2,0,360);//r1=39.9cm, r4=92.5cm, zlength=2.55 cm
00268         G4Tubs* tub7 = new G4Tubs("tub7",r1,r2,(a1-a2)/2,0,360);//r1=39.9cm, r2=47.4cm, zlength=4.05 cm 
00269         G4UnionSolid* tub8 = new G4UnionSolid("tub8",tub6,tub7,0,G4ThreeVector(0,0,(a3-a1)/2) );// -6.65cm
00270         logicalEcTofWest = new G4LogicalVolume(tub8, G4Material::GetMaterial("Air"),"logicalEcTofWest");
00271         G4VPhysicalVolume* physicalEcTofWest = new G4PVPlacement(0,G4ThreeVector(0,0,tofPara->GetzPosWestEc()),logicalEcTofWest,"physicalEcTofWest",logicalTof,false,0);
00272 
00273         G4UnionSolid* tub9 = new G4UnionSolid("tub9",tub6,tub7,0,G4ThreeVector(0,0,(a1-a3)/2) );
00274         logicalEcTofEast = new G4LogicalVolume(tub9, G4Material::GetMaterial("Air"),"logicalEcTofEast");
00275         G4VPhysicalVolume* physicalEcTofEast = new G4PVPlacement(0,G4ThreeVector(0,0,tofPara->GetzPosEastEc()),logicalEcTofEast,"physicalEcTofEast",logicalTof,false,0);
00276 
00277 
00278         //Construct Tape
00279         //put these lines before ConstructBr1Tof();
00280         //so in BesTofSD.cc, no need to change the tofid caculation method
00281         G4Tubs* tubTape = new G4Tubs("tubTape",866, 866.3, 1150, 0, 360);
00282         G4LogicalVolume* logicalTape = new G4LogicalVolume(tubTape,G4Material::GetMaterial("tape"),"logicalTape");
00283         G4VPhysicalVolume* physicalTape = new G4PVPlacement(0,G4ThreeVector(0,0,0),logicalTape,"physicalTape",logicalBrTof,false,0);
00284         logicalTape->SetVisAttributes(G4VisAttributes::Invisible);
00285 
00286         //Functions which construct the different parts of the TOF -->See below
00287         ConstructBr1Tof();  
00288         ConstructBr2Tof();
00289         ConstructEcTof();
00290     }
00291 
00292 
00293     //sensitive detector
00294     G4SDManager* SDman = G4SDManager::GetSDMpointer();
00295     BesTofSD* tofSD = new BesTofSD("BesTofSD");
00296     SDman->AddNewDetector(tofSD);
00297 
00298     if (logicalScinBr1)     logicalScinBr1->SetSensitiveDetector(tofSD);
00299     if (logicalScinBr2)     logicalScinBr2->SetSensitiveDetector(tofSD);
00300     if (logicalScinEcWest)  logicalScinEcWest->SetSensitiveDetector(tofSD);
00301     if (logicalScinEcEast)  logicalScinEcEast->SetSensitiveDetector(tofSD);
00302     if(logical_gasLayer)   
00303     {
00304         logical_gasLayer->SetSensitiveDetector(tofSD); 
00305         G4cout<<"!!! Find logical_gasLayer !!!"<<G4endl;
00306 
00307         //For limits smaller than 0.02 one has to use the PAI-Model for ionisation!
00308         logical_gasLayer->SetUserLimits (new G4UserLimits(m_userLimits*mm));
00309         //logical_gasLayer->SetUserLimits (new G4UserLimits(0.03*mm));
00310     }
00311 
00312 
00313     G4VisAttributes* visBrTof = new G4VisAttributes(G4Colour(1.,0.,0.));
00314     G4VisAttributes* visEcTof = new G4VisAttributes(G4Colour(0.,1.,0.));
00315 
00316     if (logicalTof)
00317       logicalTof->SetVisAttributes(G4VisAttributes::Invisible);
00318     if (logicalBrTof)
00319       logicalBrTof->SetVisAttributes(G4VisAttributes::Invisible);
00320     //logicalBrTof->SetVisAttributes(visBrTof);
00321     if (logicalEcTofWest)
00322       logicalEcTofWest->SetVisAttributes(G4VisAttributes::Invisible);
00323     //logicalEcTofWest->SetVisAttributes(visEcTof);
00324     if (logicalEcTofEast)
00325       logicalEcTofEast->SetVisAttributes(G4VisAttributes::Invisible);
00326     //logicalEcTofEast->SetVisAttributes(visEcTof);
00327 
00328 
00329     if (logicalScinBr1)
00330       logicalScinBr1->SetVisAttributes(G4VisAttributes::Invisible); 
00331     if (logicalScinBr2)
00332       logicalScinBr2->SetVisAttributes(G4VisAttributes::Invisible); 
00333 
00334     if (logicalAlBr1)
00335       logicalAlBr1->SetVisAttributes(G4VisAttributes::Invisible);
00336     if (logicalAlBr2)
00337       logicalAlBr2->SetVisAttributes(G4VisAttributes::Invisible);
00338 
00339     if (logicalPVFBr1)
00340       logicalPVFBr1->SetVisAttributes(G4VisAttributes::Invisible);
00341     if (logicalPVFBr2)
00342       logicalPVFBr2->SetVisAttributes(G4VisAttributes::Invisible);
00343 
00344     G4VisAttributes* visAttBrBuck = new G4VisAttributes(G4Colour(1.,1.,0.));
00345     if (logicalBucketBr1)
00346       logicalBucketBr1->SetVisAttributes(visAttBrBuck);
00347     //logicalBucketBr1->SetVisAttributes(G4VisAttributes::Invisible);
00348     if (logicalBucketBr2)
00349       logicalBucketBr2->SetVisAttributes(visAttBrBuck);
00350     //logicalBucketBr2->SetVisAttributes(G4VisAttributes::Invisible);
00351 
00352     G4VisAttributes* visAttEcTof = new G4VisAttributes(G4Colour(0.,1.,1.));
00353     if (logicalScinEcWest)
00354       logicalScinEcWest->SetVisAttributes(visAttEcTof);
00355     //logicalScinEc->SetVisAttributes(G4VisAttributes::Invisible);
00356     if (logicalScinEcEast)
00357       logicalScinEcEast->SetVisAttributes(visAttEcTof);
00358 
00359     G4VisAttributes* visAttEcBuck = new G4VisAttributes(G4Colour(1.,1.,0.));
00360     if (logicalBucketEc)
00361       logicalBucketEc->SetVisAttributes(visAttEcBuck);
00362     //logicalBucketEc->SetVisAttributes(G4VisAttributes::Invisible);
00363 
00364     if (logicalAlEcWest)
00365       logicalAlEcWest->SetVisAttributes(G4VisAttributes::Invisible);
00366     if (logicalAlEcEast)
00367       logicalAlEcEast->SetVisAttributes(G4VisAttributes::Invisible);
00368     if (logicalPVFEcWest)
00369       logicalPVFEcWest->SetVisAttributes(G4VisAttributes::Invisible);
00370     if (logicalPVFEcEast)
00371       logicalPVFEcEast->SetVisAttributes(G4VisAttributes::Invisible);
00372 }
00373 
00374 void BesTofConstruction::ConstructBr1Tof()
00375 {
00376     BesTofGeoParameter* tofPara = BesTofGeoParameter::GetInstance();
00377 
00378     //Get barrel tof layer1 geometry data
00379     G4int nScinBr=tofPara->GetnScinBr();           //number of barrel scintillators
00380     G4double br1L=tofPara->GetBr1L();
00381     G4double br1TrapW1=tofPara->GetBr1TrapW1();
00382     G4double br1TrapW2=tofPara->GetBr1TrapW2();
00383     G4double br1TrapH=tofPara->GetBr1TrapH();
00384     G4double br1R1=tofPara->GetBr1R1();
00385     G4double AlThickness=tofPara->GetAlThickness();
00386     G4double PVFThickness=tofPara->GetPVFThickness();
00387     //barrel PMT bucket geometry data
00388     G4double bucketDBr=tofPara->GetBucketDBr();    //diameter of barrel PMT bucket
00389     G4double bucketLBr=tofPara->GetBucketLBr();    //length of barrel PMT bucket
00390 
00391     //computer from the original data
00392     G4double angleBr=360./nScinBr*deg;
00393     G4double scinTrapdx1,scinTrapdx2,scinTrapdx3,scinTrapdx4;
00394     scinTrapdx1=scinTrapdx3=br1TrapW1/2.;
00395     scinTrapdx2=scinTrapdx4=br1TrapW2/2.;
00396     G4double scinTrapdy1,scinTrapdy2;
00397     scinTrapdy1=scinTrapdy2=0.5*br1TrapH;
00398     G4double scinTrapdz=br1L/2.;
00399     G4double scinPosR=br1R1+scinTrapdy1;
00400     G4double theta = atan((br1TrapW2/2.-br1TrapW1/2.)/br1TrapH);
00401     G4double delta13 = AlThickness*(1/cos(theta)-tan(theta));
00402     G4double delta24 = AlThickness*(1/cos(theta)+tan(theta));
00403     G4double delta13P = (PVFThickness+AlThickness)*(1/cos(theta)-tan(theta));
00404     G4double delta24P = (PVFThickness+AlThickness)*(1/cos(theta)+tan(theta));
00405 
00406     //construct barrel tof scintillator
00407     G4Trap* solidScinBr1=new G4Trap("solidScinBr1",scinTrapdz,0*deg,0*deg,
00408                 scinTrapdy1,scinTrapdx1,scinTrapdx2,0*deg,
00409                 scinTrapdy2,scinTrapdx3,scinTrapdx4,0*deg); 
00410     logicalScinBr1 = new G4LogicalVolume(solidScinBr1,BC408,"logicalScinBr1"); 
00411 
00412     //construct barrel Al film and PVF film
00413     G4Trap* solidAlBr1 = new  G4Trap("solidAlBr1", scinTrapdz+0.001,0*deg,0*deg,
00414                 scinTrapdy1+AlThickness, scinTrapdx1+delta13, scinTrapdx2+delta24 ,0*deg,
00415                 scinTrapdy2+AlThickness, scinTrapdx3+delta13, scinTrapdx4+delta24 ,0*deg);
00416 
00417     logicalAlBr1 = new G4LogicalVolume(solidAlBr1,G4Material::GetMaterial("Aluminium"),"logicalAlBr1");
00418     G4Trap* solidPVFBr1 = new G4Trap("solidPVFBr1",scinTrapdz+0.002,0*deg,0*deg,
00419                 scinTrapdy1+AlThickness+PVFThickness,scinTrapdx1+delta13P, scinTrapdx2+delta24P,0*deg,
00420                 scinTrapdy2+AlThickness+PVFThickness,scinTrapdx3+delta13P, scinTrapdx4+delta24P,0*deg);
00421 
00422     logicalPVFBr1 = new  G4LogicalVolume(solidPVFBr1,PVF,"logicalPVFBr1");
00423     //put daughter in mother logical volume
00424     physicalAlBr1 = new G4PVPlacement(0,G4ThreeVector(0,0,0),logicalAlBr1, "physicalAlBr1",logicalPVFBr1, false,0); 
00425     physicalScinBr1 = new G4PVPlacement(0,G4ThreeVector(0,0,0),logicalScinBr1, "physicalScinBr1",logicalAlBr1, false, 0); 
00426 
00427     //construct barrel PMT  bucket  (bucket=Behaelter)
00428     G4Tubs* solidBucketBr1= new G4Tubs("solidBucketBr1",0,bucketDBr/2.,
00429                 bucketLBr/2., 0, 360.*deg);
00430     logicalBucketBr1=new G4LogicalVolume(solidBucketBr1,PMTmaterial,"logicalBucketBr1");
00431 
00432 
00433     //Rotate the crystalls:
00434     G4RotationMatrix trapRot;
00435     trapRot.rotateZ(0.5*angleBr-90.*deg);
00436     //                       /|                                    y
00437     //-------               / |                                   |
00438     //\     /              |  | rotate->(0.5*angleBr-90.*deg):    |
00439     // \   /       ->>>>   |  |                                    -----x
00440     //  ---                 \ |
00441     //                       \|
00442     G4ThreeVector pos(0,0,0);
00443     G4double x,y;
00444     for (int i=0;i<nScinBr;i++)
00445     {
00446         ostringstream osnamePVFBr1;
00447         osnamePVFBr1 << "physicalPVFBr1_"<<i;
00448         ostringstream osnameBucket1Br1;
00449         osnameBucket1Br1 << "physicalBucket1Br1_"<<i;
00450         ostringstream osnameBucket2Br1;
00451         osnameBucket2Br1 << "physicalBucket2Br1_"<<i;
00452 
00453         //scintillator and casing
00454         x=scinPosR*cos((i+0.5)*angleBr); //+0.5: start from phi=0
00455         y=scinPosR*sin((i+0.5)*angleBr);
00456         pos.setX(x);
00457         pos.setY(y);
00458         pos.setZ(0);
00459 
00460         //to make code consistent with gdml
00461         double a, b, c;
00462         getXYZ(trapRot, a, b ,c);   //Function is defined below
00463         G4RotationMatrix trapRotTemp;
00464         trapRotTemp.rotateZ(c);
00465         G4Transform3D transform(trapRotTemp,pos);
00466 
00467         //G4PVPlacement: Class representing a single volume positioned within and relative to a mother volume.
00468         //G4Transform3D transform(trapRot,pos);
00469         physicalPVFBr1 = new G4PVPlacement(transform,logicalPVFBr1,osnamePVFBr1.str(), logicalBrTof,false,i);
00470         //bucket --> Two PMT, one on each side
00471         pos.setZ(-(bucketLBr+br1L)/2.-0.01);
00472         physicalBucket1Br1 = new G4PVPlacement(0,pos,logicalBucketBr1,osnameBucket1Br1.str(),logicalBrTof,false,0);
00473         pos.setZ((bucketLBr+br1L)/2.+0.01);
00474         physicalBucket2Br1 = new G4PVPlacement(0,pos,logicalBucketBr1,osnameBucket2Br1.str(),logicalBrTof,false,0);
00475 
00476         //rotate for next scintillator
00477         trapRot.rotateZ(angleBr);  
00478     }
00479 }
00480 
00481 void BesTofConstruction::ConstructBr2Tof()
00482 {
00483     BesTofGeoParameter* tofPara = BesTofGeoParameter::GetInstance();
00484 
00485     //barrel tof layer2 geometry data
00486     G4int nScinBr=tofPara->GetnScinBr();           //number of barrel scintillators
00487     G4double br2L=tofPara->GetBr2L();
00488     G4double br2TrapW1=tofPara->GetBr2TrapW1();
00489     G4double br2TrapW2=tofPara->GetBr2TrapW2();
00490     G4double br2TrapH=tofPara->GetBr2TrapH();
00491     G4double br2R1=tofPara->GetBr2R1();
00492     G4double AlThickness=tofPara->GetAlThickness();
00493     G4double PVFThickness=tofPara->GetPVFThickness();
00494     //barrel PMT bucket geometry data
00495     G4double bucketDBr=tofPara->GetBucketDBr();    //diameter of barrel PMT bucket
00496     G4double bucketLBr=tofPara->GetBucketLBr();    //length of barrel PMT bucket
00497 
00498     //computer from the original data
00499     G4double angleBr=360./nScinBr*deg;
00500     G4double scinTrapdx1,scinTrapdx2,scinTrapdx3,scinTrapdx4;
00501     scinTrapdx1=scinTrapdx3=br2TrapW1/2.;
00502     scinTrapdx2=scinTrapdx4=br2TrapW2/2.;
00503     G4double scinTrapdy1,scinTrapdy2;
00504     scinTrapdy1=scinTrapdy2=0.5*br2TrapH;
00505     G4double scinTrapdz=br2L/2.;
00506     G4double scinPosR=br2R1+scinTrapdy1;
00507     G4double theta = atan((br2TrapW2/2.-br2TrapW1/2.)/br2TrapH);
00508     G4double delta13 = AlThickness*(1/cos(theta)-tan(theta));
00509     G4double delta24 = AlThickness*(1/cos(theta)+tan(theta));
00510     G4double delta13P = (PVFThickness+AlThickness)*(1/cos(theta)-tan(theta));
00511     G4double delta24P = (PVFThickness+AlThickness)*(1/cos(theta)+tan(theta));
00512 
00513     //construct barrel tof scintillator
00514     G4Trap* solidScinBr2=new G4Trap("solidScinBr2",scinTrapdz,0*deg,0*deg,
00515                 scinTrapdy1,scinTrapdx1,scinTrapdx2,0*deg,
00516                 scinTrapdy2,scinTrapdx3,scinTrapdx4,0*deg);
00517     logicalScinBr2 = new G4LogicalVolume(solidScinBr2,BC408,"logicalScinBr2");
00518 
00519     //construct barrel Al film and PVF film
00520     G4Trap* solidAlBr2 = new  G4Trap("solidAlBr2", scinTrapdz+0.001,0*deg,0*deg,
00521                 scinTrapdy1+AlThickness, scinTrapdx1+delta13, scinTrapdx2+delta24 ,0*deg,
00522                 scinTrapdy2+AlThickness, scinTrapdx3+delta13, scinTrapdx4+delta24 ,0*deg);
00523 
00524     logicalAlBr2 = new G4LogicalVolume(solidAlBr2,G4Material::GetMaterial("Aluminium"),"logicalAlBr2");
00525     G4Trap* solidPVFBr2 = new G4Trap("solidPVFBr2",scinTrapdz+0.002,0*deg,0*deg,
00526                 scinTrapdy1+AlThickness+PVFThickness,scinTrapdx1+delta13P, scinTrapdx2+delta24P,0*deg,
00527                 scinTrapdy2+AlThickness+PVFThickness,scinTrapdx3+delta13P, scinTrapdx4+delta24P,0*deg);
00528 
00529     logicalPVFBr2 = new  G4LogicalVolume(solidPVFBr2,PVF,"logicalPVFBr2");
00530     //put daughter in mother logical volume
00531     physicalAlBr2 = new G4PVPlacement(0,G4ThreeVector(0,0,0),logicalAlBr2, "physicalAlBr2",logicalPVFBr2, false,0);
00532     physicalScinBr2 = new G4PVPlacement(0,G4ThreeVector(0,0,0),logicalScinBr2, "physicalScinBr2",logicalAlBr2, false, 0);
00533 
00534     //construct barrel PMT  bucket
00535     G4Tubs* solidBucketBr2= new G4Tubs("solidBucketBr2",0,bucketDBr/2.,
00536                 bucketLBr/2., 0, 360.*deg);
00537     logicalBucketBr2=new G4LogicalVolume(solidBucketBr2,PMTmaterial,"logicalBucketBr2");
00538 
00539     G4RotationMatrix trapRot;
00540     trapRot.rotateZ(-90.*deg);
00541     //                       /|                                    y
00542     //-------               / |                                   |
00543     //\     /              |  | rotate->(-90.*deg):    |
00544     // \   /       ->>>>   |  |                                    -----x
00545     //  ---                 \ |
00546     //                       \|
00547     G4ThreeVector pos(0,0,0);
00548     G4double x,y;
00549     for (int i=0;i<nScinBr;i++)
00550     {
00551         ostringstream osnamePVFBr2;
00552         osnamePVFBr2 << "physicalPVFBr2_"<<i;
00553         ostringstream osnameBucket1Br2;
00554         osnameBucket1Br2 << "physicalBucket1Br2_"<<i;
00555         ostringstream osnameBucket2Br2;
00556         osnameBucket2Br2 << "physicalBucket2Br2_"<<i;
00557 
00558         //scintillator and casing
00559         x=scinPosR*cos(i*angleBr); //+0.5: start from phi=0
00560         y=scinPosR*sin(i*angleBr);
00561         pos.setX(x);
00562         pos.setY(y);
00563         pos.setZ(0);
00564         //to make code consistent with gdml
00565         double a, b, c;
00566         getXYZ(trapRot, a, b ,c);
00567         G4RotationMatrix trapRotTemp;
00568         trapRotTemp.rotateZ(c);
00569         G4Transform3D transform(trapRotTemp,pos);
00570         //G4Transform3D transform(trapRot,pos);
00571         physicalPVFBr2 = new G4PVPlacement(transform,logicalPVFBr2,osnamePVFBr2.str(), logicalBrTof,false,i);
00572         //bucket
00573         pos.setZ(-(bucketLBr+br2L)/2.-0.01);
00574         physicalBucket1Br2 = new G4PVPlacement(0,pos,logicalBucketBr2,osnameBucket1Br2.str(),logicalBrTof,false,0);
00575         pos.setZ((bucketLBr+br2L)/2.+0.01);
00576         physicalBucket2Br2 = new G4PVPlacement(0,pos,logicalBucketBr2,osnameBucket2Br2.str(),logicalBrTof,false,0);
00577 
00578         //rotate for next scintillator
00579         trapRot.rotateZ(angleBr);
00580     }
00581 
00582 }
00583 
00584 void BesTofConstruction::ConstructEcTof()
00585 {
00586     BesTofGeoParameter* tofPara = BesTofGeoParameter::GetInstance();
00587 
00588     //Get all interesting parameters for the TOF construction
00589     //endcap geometry data
00590     G4int nScinEc = tofPara->GetnScinEc();  //number of endcap scintillators
00591     G4double ecL = tofPara->GetEcL();
00592     G4double ecTrapW1 = tofPara->GetEcTrapW1();
00593     G4double ecTrapW2 = tofPara->GetEcTrapW2();
00594     G4double ecTrapH = tofPara->GetEcTrapH();
00595     G4double ecTrapH1 = tofPara->GetEcTrapH1();
00596     G4double zPosEastEc = tofPara->GetzPosEastEc();  //z position of east endcap
00597     G4double zPosWestEc = tofPara->GetzPosWestEc();  //z position of west endcap
00598     G4double ecR1 = tofPara->GetEcR1();
00599     //G4double ecR2 = tofPara.GetEcR2();
00600 
00601     //endcap PMT bucket geometry data
00602     G4double bucketDEc = tofPara->GetBucketDEc(); //diameter of endcap PMT bucket
00603     G4double bucketLEc = tofPara->GetBucketLEc(); //length of endcap PMT bucket
00604     G4double bucketPosR = tofPara->GetBucketPosR(); //R  of bucket center
00605 
00606     G4double AlThickness=tofPara->GetAlThickness();
00607     G4double PVFThickness=tofPara->GetPVFThickness();
00608 
00609     G4double angleEc=360./nScinEc*deg;
00610     G4double ecTrapW3 = ecTrapW1 + (ecTrapW2-ecTrapW1)*ecTrapH1/ecTrapH;
00611     G4double ecTrapH2 = ecTrapH-ecTrapH1;
00612     G4double pdz = ecL/2;
00613     G4double ptheta = atan(ecTrapH1/(2*ecL));
00614     G4double pdy1 = ecTrapH2/2;
00615     G4double pdx1 = ecTrapW3/2;
00616     G4double pdx2 = ecTrapW2/2;
00617     G4double pdy2 = ecTrapH/2;
00618     G4double pdx3 = ecTrapW1/2;
00619     G4double pdx4 = ecTrapW2/2;
00620 
00621     //because of removing a heighth of H1,
00622     //plus initial center position ecR=ecR1+ecTrapH/2 with ecTrapH1/4
00623     G4double ecR = ecR1+ecTrapH/2+ecTrapH1/4;
00624 
00625     //construct endcap scintillator
00626     G4Trap* solidScinEc=new G4Trap("solidScinEc",pdz,ptheta, 270*deg,
00627                 pdy1,pdx1,pdx2,0*deg,pdy2,pdx3,pdx4,0*deg);
00628 
00629     logicalScinEcWest=new G4LogicalVolume(solidScinEc,BC404,"logicalScinEcWest");
00630     logicalScinEcEast=new G4LogicalVolume(solidScinEc,BC404,"logicalScinEcEast");
00631 
00632     //construct endcap PMT bucket
00633     G4Tubs* solidBucketEc = new G4Tubs("solidBucketEc", 0, bucketDEc/2.,
00634                 bucketLEc/2., 0, 360.*deg);
00635     logicalBucketEc = new G4LogicalVolume(solidBucketEc, PMTmaterial, "logicalBucketEc");
00636 
00637     //construct Al and PVF film
00638     G4double pthetaAl = atan(ecTrapH1/(2*(ecL+AlThickness*2)));
00639     G4double theta1 = atan((ecTrapW2/2.-ecTrapW3/2.)/ecTrapH2);
00640     G4double theta2 = atan((ecTrapW2/2.-ecTrapW1/2.)/ecTrapH);
00641 
00642     G4double delta1 = AlThickness*(1/cos(theta1)-tan(theta1));
00643     G4double delta2 = AlThickness*(1/cos(theta1)+tan(theta1));
00644     G4double delta3 = AlThickness*(1/cos(theta2)-tan(theta2));
00645     G4double delta4 = AlThickness*(1/cos(theta2)+tan(theta2));
00646 
00647     G4double thick = AlThickness+PVFThickness;
00648     G4double pthetaPVF = atan(ecTrapH1/(2*(ecL+thick*2)));
00649     G4double delta1P = thick*(1/cos(theta1)-tan(theta1));
00650     G4double delta2P = thick*(1/cos(theta1)+tan(theta1));
00651     G4double delta3P = thick*(1/cos(theta2)-tan(theta2));
00652     G4double delta4P = thick*(1/cos(theta2)+tan(theta2));
00653 
00654     G4Trap* solidAlEc= new G4Trap("solidAlEc",pdz+AlThickness,pthetaAl,270*deg,pdy1+AlThickness,pdx1+delta1,pdx2+delta2,0*deg,pdy2+AlThickness,pdx3+delta3,pdx4+delta4,0*deg);
00655 
00656     logicalAlEcWest = new G4LogicalVolume(solidAlEc,G4Material::GetMaterial("Aluminium"),"logicalAlEcWest");
00657     logicalAlEcEast = new G4LogicalVolume(solidAlEc,G4Material::GetMaterial("Aluminium"),"logicalAlEcEast");
00658 
00659     G4Trap* solidPVFEc = new G4Trap("solidPVFEc",pdz+thick,pthetaPVF,270*deg,
00660                 pdy1+thick,pdx1+delta1P,pdx2+delta2P,0*deg,
00661                 pdy2+thick,pdx3+delta3P,pdx4+delta4P,0*deg);
00662 
00663     logicalPVFEcWest = new G4LogicalVolume(solidPVFEc,PVF,"logicalPVFEcWest");
00664     logicalPVFEcEast = new G4LogicalVolume(solidPVFEc,PVF,"logicalPVFEcEast");
00665 
00666     //put scintilator in Al, then put Al in PVF
00667     physicalAlEcWest = new G4PVPlacement(0,G4ThreeVector(0,0,0),logicalAlEcWest, "physicalAlEcWest",logicalPVFEcWest, false,0);
00668     physicalScinEcWest = new G4PVPlacement(0,G4ThreeVector(0,0,0),logicalScinEcWest, "physicalScinEcWest",logicalAlEcWest, false, 0);
00669 
00670 
00671     //put scintilator in Al, then put Al in PVF
00672     physicalAlEcEast = new G4PVPlacement(0,G4ThreeVector(0,0,0),logicalAlEcEast, "physicalAlEcEast",logicalPVFEcEast, false,0);
00673     physicalScinEcEast = new G4PVPlacement(0,G4ThreeVector(0,0,0),logicalScinEcEast, "physicalScinEcEast",logicalAlEcEast, false, 0);
00674 
00675     //zPosWestEc<0, zPosEastEc>0, direction of axis z: west--->east
00676     //construct west endcap first
00677     //when no rotation, the first tub is start from phi=90
00678     //after rotation, the first tub is start from 0, rotate angle = 0.5*angleEc
00679     G4ThreeVector posW(0,0,0);
00680     G4ThreeVector posE(0,0,0);
00681     G4RotationMatrix trapRot;
00682     trapRot.rotateY(180.*deg);
00683     trapRot.rotateZ(0.5*angleEc-90*deg);
00684     for (int i=0;i<nScinEc;i++)
00685     {
00686         ostringstream osnamePVFEc;
00687         osnamePVFEc << "physicalPVFEcWest_"<<i;
00688         ostringstream osnameBucketEc;
00689         osnameBucketEc << "physicalBucketEcWest_"<<i;
00690 
00691         posW.setX( ecR*cos((0.5+i)*angleEc) );
00692         posW.setY( ecR*sin((0.5+i)*angleEc) );
00693         //posW.setZ( zPosWestEc );
00694         posW.setZ(0);
00695 
00696         //to make code consistent with gdml
00697         double a, b, c;
00698         getXYZ(trapRot, a, b ,c);
00699         G4RotationMatrix trapRotTemp;
00700         trapRotTemp.rotateX(a);
00701         trapRotTemp.rotateY(b);
00702         trapRotTemp.rotateZ(c);
00703         G4Transform3D transform(trapRotTemp,posW);
00704         //G4Transform3D transform(trapRot,posW);
00705         physicalPVFEcWest = new G4PVPlacement(transform,logicalPVFEcWest,osnamePVFEc.str(), logicalEcTofWest,false,i);
00706         posW.setX( bucketPosR*cos((0.5+i)*angleEc) );
00707         posW.setY( bucketPosR*sin((0.5+i)*angleEc) );
00708         //posW.setZ( zPosWestEc-ecL/2-thick-bucketLEc/2-0.01 );
00709         posW.setZ(-ecL/2-thick-bucketLEc/2-0.01 );
00710         physicalBucketEc = new  G4PVPlacement(0,posW,logicalBucketEc,osnameBucketEc.str(),logicalEcTofWest,false,0);
00711         trapRot.rotateZ(angleEc);  //pay attention: not i*angleEc
00712     }
00713     //to make east scintillator start from phi=0
00714     //        _                               _
00715     //    _ -                             _ -
00716     //  - - - -  ====>  - - - -  ====>  - - - -
00717     //                    ~ - _
00718     //
00719     trapRot.rotateZ(-angleEc);
00720     trapRot.rotateX(180.*deg);  //make east bucket point to the center
00721     for (int i=0;i<nScinEc;i++)
00722     {
00723         ostringstream osnamePVFEc;
00724         osnamePVFEc << "physicalPVFEcEast_"<<i;
00725         ostringstream osnameBucketEc;
00726         osnameBucketEc << "physicalBucketEcEast_"<<i;
00727 
00728         posE.setX( ecR*cos((0.5+i)*angleEc) );
00729         posE.setY( ecR*sin((0.5+i)*angleEc) );
00730         //posE.setZ( zPosEastEc );
00731         posE.setZ(0);
00732 
00733         //to make code consistent with gdml
00734         double a, b, c;
00735         getXYZ(trapRot, a, b ,c);
00736         G4RotationMatrix trapRotTemp;
00737         trapRotTemp.rotateX(a);
00738         trapRotTemp.rotateY(b);
00739         trapRotTemp.rotateZ(c);
00740         G4Transform3D transform(trapRotTemp,posE);
00741         //G4Transform3D transform(trapRot,posE);
00742         physicalPVFEcEast = new G4PVPlacement(transform,logicalPVFEcEast,osnamePVFEc.str(), logicalEcTofEast,false,i);
00743         posE.setX( bucketPosR*cos((0.5+i)*angleEc) );
00744         posE.setY( bucketPosR*sin((0.5+i)*angleEc) );
00745         //posE.setZ( zPosEastEc+ecL/2+thick+bucketLEc/2+0.01 );
00746         posE.setZ(ecL/2+thick+bucketLEc/2+0.01 );
00747         physicalBucketEc = new  G4PVPlacement(0,posE,logicalBucketEc,osnameBucketEc.str(),logicalEcTofEast,false,0);
00748         trapRot.rotateZ(angleEc);  //pay attention: not i*angleEc
00749     }
00750 }
00751 
00752 
00753 //This function construct the TOF_Endcap_MRPC
00754 void BesTofConstruction::ConstructEcTof_mrpc()
00755 {
00756     //I construct my detector in the Geant4 coordinate system. It will be rotated into the BES coordinatesystem later!
00757     //                  |z              ___________
00758     //                  |  /y           \         /
00759     //                  | /              \       /
00760     //                  |/______x         \_____/         
00761 
00762 
00763     G4double smallL = 0.01*mm;
00764     G4RotationMatrix rot_dummy(0*deg,0*deg,0*deg);
00765     IniParam_mrpc();
00766     PartProduce* partProduce = new PartProduce();
00767     partProduce->IniParam();
00768     bool checkOverlap = false;
00769 
00770     //Get the parts and place them in the container
00771     //container
00772     std::ostringstream name;
00773     //Create 4 containers and gasContainers
00774     //0: top module, closer to IP, longer bottom cover;
00775     //1: same to [0], with gas sensitive detector overturned;
00776     //2: bottom module, next to EMC, shorter bottom cover;
00777     //3: same to [2], with gas sensitive detector overturned
00778     G4LogicalVolume* logical_container[4];
00779     G4LogicalVolume* logical_gasContainer[4];
00780     for(int kk=0; kk<4; kk++)
00781     {
00782         name.str("");
00783         name<<"logical_container_m"<<kk;
00784         logical_container[kk] = partProduce->lg_container((int)kk/2, name.str());
00785 
00786         name.str("");
00787         name<<"logical_gasContainer_m"<<kk;
00788         logical_gasContainer[kk] = partProduce->lg_gasContainer(name.str());
00789     }
00790 
00791 
00792     //The parts that compose the container
00793     G4LogicalVolume* logical_containerFrame = partProduce->lg_containerFrame("logical_containerFrame");
00794     G4LogicalVolume* logical_upCover = partProduce->lg_upCover("logical_upCover");
00795     G4LogicalVolume* logical_lowCover1 = partProduce->lg_lowCover1("logical_lowCover1");
00796     G4LogicalVolume* logical_lowCover2 = partProduce->lg_lowCover2("logical_lowCover2");
00797     G4LogicalVolume* logical_upFEE = partProduce->lg_upFEE("logical_upFEE");
00798     G4LogicalVolume* logical_sideFEE = partProduce->lg_sideFEE("logical_sideFEE");
00799     G4LogicalVolume* logical_castingDie = partProduce->lg_castingDie("logical_castingDie");
00800     G4LogicalVolume* logical_bareChamber = partProduce->lg_bareChamber("logical_bareChamber");
00801     G4LogicalVolume* logical_bracket = partProduce->lg_bracket("logical_bracket");
00802     G4LogicalVolume* logical_sideStopBlock = partProduce->lg_sideStopBlock("logical_sideStopBlock");
00803     G4LogicalVolume* logical_upStopBlock = partProduce->lg_upStopBlock("logical_upStopBlock");
00804 
00805 
00806     //Place the parts in the container
00807     for(int kk=0; kk<4; kk++)
00808     {
00809         //container frame
00810         name.str("");
00811         name<<"physical_containerFrame_m"<<kk;
00812         new G4PVPlacement(0, G4ThreeVector(0,0,0), logical_containerFrame, name.str(), logical_container[kk], false, 0, checkOverlap);
00813 
00814         //top cover
00815         G4ThreeVector translation_upCover(0, (containerOut_y+upCover_y)/2+smallL, (upCover_z-containerOut_z)/2-upCover_posz);
00816         name.str("");
00817         name<<"physical_upCover_m"<<kk;
00818         new G4PVPlacement(0, translation_upCover, logical_upCover, name.str(), logical_container[kk], false, 0, checkOverlap);
00819 
00820         //bottom cover
00821         name.str("");
00822         name<<"physical_lowCover_m"<<kk;
00823         if(kk<2)
00824         {
00825             G4ThreeVector translation_lowCover(0, -1*(containerOut_y+upCover_y)/2, (lowCover1_z-containerOut_z)/2-lowCover1_posz);
00826             new G4PVPlacement(0, translation_lowCover, logical_lowCover1, name.str(), logical_container[kk], false, 0, checkOverlap);
00827         }
00828         else
00829         {
00830             G4ThreeVector translation_lowCover(0, -1*(containerOut_y+upCover_y)/2, (lowCover2_z-containerOut_z)/2-lowCover2_posz);
00831             new G4PVPlacement(0, translation_lowCover, logical_lowCover2, name.str(), logical_container[kk], false, 0, checkOverlap);
00832         }
00833 
00834         //FEE on the top cover
00835         G4ThreeVector translation_upFEE(0, containerOut_y/2+upCover_y+upFEE_y/2+smallL, upCover_z-upFEE_posz-upFEE_z/2-upCover_posz-containerOut_z/2);
00836         name.str("");
00837         name<<"physical_upFEE_m"<<kk;
00838         new G4PVPlacement(0, translation_upFEE, logical_upFEE, name.str(), logical_container[kk], false, 0, checkOverlap);
00839 
00840         //FEE at the side
00841         double angle_containerFrameSide = atan((containerOut_xup-containerOut_xdown)/2/containerOut_z) *rad;
00842         double l_containerFrameSide = containerOut_z/cos(angle_containerFrameSide);
00843         double x_sideFEE = (l_containerFrameSide/2-sideFEE_posl)*sin(angle_containerFrameSide)+(containerOut_xup+containerOut_xdown)/4+sideFEE_x/2*cos(angle_containerFrameSide);
00844         double z_sideFEE = (l_containerFrameSide/2-sideFEE_posl)*cos(angle_containerFrameSide)-sideFEE_x/2*sin(angle_containerFrameSide);
00845         G4ThreeVector translation_sideFEE_left(-x_sideFEE, 0, z_sideFEE);
00846         G4RotationMatrix rot_sideFEE_left;
00847         rot_sideFEE_left.rotateY(-angle_containerFrameSide);
00848         G4Transform3D transform_sideFEE_left(rot_sideFEE_left, translation_sideFEE_left);
00849         name.str("");
00850         name<<"physical_sideFEE_left_m"<<kk;
00851         new G4PVPlacement(transform_sideFEE_left, logical_sideFEE, name.str(), logical_container[kk], false, 0, checkOverlap);
00852 
00853         G4ThreeVector translation_sideFEE_right(x_sideFEE, 0, z_sideFEE);
00854         G4RotationMatrix rot_sideFEE_right;
00855         rot_sideFEE_right.rotateZ(180*deg);
00856         rot_sideFEE_right.rotateY(angle_containerFrameSide);
00857         G4Transform3D transform_sideFEE_right(rot_sideFEE_right, translation_sideFEE_right);
00858         name.str("");
00859         name<<"physical_sideFEE_right_m"<<kk;
00860         new G4PVPlacement(transform_sideFEE_right, logical_sideFEE, name.str(), logical_container[kk], false, 0, checkOverlap);
00861 
00862         //casting die
00863         G4RotationMatrix rot_castingDie;
00864         rot_castingDie.rotateX(-90*deg);
00865         G4ThreeVector translation_castingDie_1(0, containerOut_y/2+upCover_y+castingDie_z/2+smallL, -containerOut_z/2+upCover_posz+castingDie_posz1);
00866         G4Transform3D transform_castingDie_1(rot_castingDie, translation_castingDie_1);
00867         name.str("");
00868         name<<"physical_castingDie_1_m"<<kk;
00869         new G4PVPlacement(transform_castingDie_1, logical_castingDie, name.str(), logical_container[kk], false, 0, checkOverlap);
00870 
00871         G4ThreeVector translation_castingDie_2(0, containerOut_y/2+upCover_y+castingDie_z/2+smallL, -containerOut_z/2+upCover_posz+castingDie_posz2);
00872         G4Transform3D transform_castingDie_2(rot_castingDie, translation_castingDie_2);
00873         name.str("");
00874         name<<"physical_castingDie_2_m"<<kk;
00875         new G4PVPlacement(transform_castingDie_2, logical_castingDie, name.str(), logical_container[kk], false, 0, checkOverlap);
00876 
00877         //gas container
00878         G4ThreeVector translation_gasContainer(0, 0, (container_lowBorder-container_thickness)/2);
00879         name.str("");
00880         name<<"physical_gasContainer_m"<<kk;
00881         new G4PVPlacement(0, translation_gasContainer, logical_gasContainer[kk], name.str(), logical_container[kk], false, 0, checkOverlap);
00882     }
00883 
00884 
00885     //Fill in the inside of the container
00886     //1mm from the bottom cover in design. Considering the modules's position are not real, change this number to make the bare chamber in the right place
00887     double l_chamber = honeyComb_y*2+tape_mrpc_y*2+pcbBoard_y0*2+pcbBoard_y1+mylar_y*4+glass0_y*4+glass1_y*10+gasLayer_y*12;
00888     double y_chamber;
00889     double z_chamber = (containerIn_z-pcbBoard_z)/2-smallL;
00890     for(int kk=0; kk<4; kk++)
00891     {
00892         if(kk<2) y_chamber = -(containerIn_y-l_chamber)/2+chamber_in_posy;
00893         else y_chamber = -(containerIn_y-l_chamber)/2+chamber_out_posy;
00894         G4Transform3D transform_bareChamber;
00895         if(kk==0 || kk==2)
00896         {
00897             transform_bareChamber = G4Transform3D(rot_dummy, G4ThreeVector(0,y_chamber,z_chamber));
00898         }
00899         else
00900         {
00901             G4RotationMatrix rot_bareChamber;
00902             rot_bareChamber.rotateZ(180*deg);
00903             transform_bareChamber = G4Transform3D(rot_bareChamber, G4ThreeVector(0,y_chamber,z_chamber));
00904         }
00905         new G4PVPlacement(transform_bareChamber, logical_bareChamber, "physical_bareChamber", logical_gasContainer[kk], false, 0, checkOverlap);
00906 
00907         //lower bracket
00908         G4double z_bracket = -(containerIn_z-bracket_z)/2+smallL;
00909         new G4PVPlacement(0, G4ThreeVector(-bracket_posx, 0, z_bracket), logical_bracket, "physical_bracket_0", logical_gasContainer[kk], false, 0, checkOverlap);
00910         new G4PVPlacement(0, G4ThreeVector(bracket_posx, 0, z_bracket), logical_bracket, "physical_bracket_1", logical_gasContainer[kk], false, 0, checkOverlap);
00911 
00912         //side stop block
00913         G4Transform3D transform_sideStopBlock;
00914         G4double angle_gasContainerSide = (atan((containerIn_xup-containerIn_xdown)/2/(containerIn_z))) *rad;
00915         G4double x_sideStopBlock = (containerIn_xup+containerIn_xdown)/4+sideStopBlock_posz0*tan(angle_gasContainerSide)-sideStopBlock_x/2*cos(angle_gasContainerSide);
00916         G4double z_sideStopBlock = sideStopBlock_posz0+sideStopBlock_x/2*sin(angle_gasContainerSide);
00917 
00918         G4RotationMatrix rot_sideStopBlock;
00919         rot_sideStopBlock.rotateY(angle_gasContainerSide);
00920         rot_sideStopBlock.rotateZ(180*deg);
00921         transform_sideStopBlock = G4Transform3D(rot_sideStopBlock, G4ThreeVector(-x_sideStopBlock, 0, z_sideStopBlock));
00922         new G4PVPlacement(transform_sideStopBlock, logical_sideStopBlock, "physical_sideStopBlock_0", logical_gasContainer[kk], false, 0, checkOverlap);
00923 
00924         rot_sideStopBlock = G4RotationMatrix(0,0,0);
00925         rot_sideStopBlock.rotateY(angle_gasContainerSide);
00926         transform_sideStopBlock = G4Transform3D(rot_sideStopBlock, G4ThreeVector(x_sideStopBlock, 0, z_sideStopBlock));
00927         new G4PVPlacement(transform_sideStopBlock, logical_sideStopBlock, "physical_sideStopBlock_1", logical_gasContainer[kk], false, 0, checkOverlap);
00928 
00929         x_sideStopBlock =  (containerIn_xup+containerIn_xdown)/4+sideStopBlock_posz1*tan(angle_gasContainerSide)-sideStopBlock_x/2*cos(angle_gasContainerSide);
00930         z_sideStopBlock = sideStopBlock_posz1+sideStopBlock_x/2*sin(angle_gasContainerSide);
00931         rot_sideStopBlock = G4RotationMatrix(0,0,0);
00932         rot_sideStopBlock.rotateY(angle_gasContainerSide);
00933         rot_sideStopBlock.rotateZ(180*deg);
00934         transform_sideStopBlock = G4Transform3D(rot_sideStopBlock, G4ThreeVector(-x_sideStopBlock, 0, z_sideStopBlock));
00935         new G4PVPlacement(transform_sideStopBlock, logical_sideStopBlock, "physical_sideStopBlock_2", logical_gasContainer[kk], false, 0, checkOverlap);
00936 
00937         rot_sideStopBlock = G4RotationMatrix(0,0,0);
00938         rot_sideStopBlock.rotateY(angle_gasContainerSide);
00939         transform_sideStopBlock = G4Transform3D(rot_sideStopBlock, G4ThreeVector(x_sideStopBlock, 0, z_sideStopBlock));
00940         new G4PVPlacement(transform_sideStopBlock, logical_sideStopBlock, "physical_sideStopBlock_3", logical_gasContainer[kk], false, 0, checkOverlap);
00941     }
00942 
00943     //stop block
00944     //upper stop block
00945     G4double x_upStopBlock = containerIn_xup/4;
00946     G4double y_upStopBlock = pcbBoard_y1/2.+mylar_y+glass0_y+glass1_y*2.5+gasLayer_y*3;
00947     G4double z_upStopBlock = (pcbBoard_z-upStopBlock_z)/2-smallL;
00948     new G4PVPlacement(0, G4ThreeVector(-x_upStopBlock, -y_upStopBlock, z_upStopBlock ), logical_upStopBlock, "physical_upStopBlock_0", logical_bareChamber, false,0, checkOverlap);
00949     new G4PVPlacement(0, G4ThreeVector(-x_upStopBlock, y_upStopBlock, z_upStopBlock ), logical_upStopBlock, "physical_upStopBlock_1", logical_bareChamber, false,0, checkOverlap);
00950     new G4PVPlacement(0, G4ThreeVector(x_upStopBlock, -y_upStopBlock, z_upStopBlock ), logical_upStopBlock, "physical_upStopBlock_2", logical_bareChamber, false,0, checkOverlap);
00951     new G4PVPlacement(0, G4ThreeVector(x_upStopBlock, y_upStopBlock, z_upStopBlock ), logical_upStopBlock, "physical_upStopBlock_3", logical_bareChamber, false,0, checkOverlap);
00952 
00953 
00954     //honeyComb
00955     G4LogicalVolume* logical_honeyComb = partProduce->lg_honeyComb("logical_honeyComb");
00956     G4double y_honeyComb = (honeyComb_y+pcbBoard_y1)/2+tape_mrpc_y+pcbBoard_y0+mylar_y*2+glass0_y*2+glass1_y*5+gasLayer_y*6;
00957     G4double z_honeyComb = (pcbBoard_z-honeyComb_z)/2-honeyComb_posz;
00958     new G4PVPlacement(0,G4ThreeVector(0,y_honeyComb,z_honeyComb), logical_honeyComb,"physical_honeyComb_0",logical_bareChamber,false,0, checkOverlap);
00959     new G4PVPlacement(0,G4ThreeVector(0,-1*y_honeyComb,z_honeyComb), logical_honeyComb,"physical_honeyComb_1",logical_bareChamber,false,1, checkOverlap);
00960 
00961     //tape_mrpc
00962     G4LogicalVolume* logical_tape_mrpc = partProduce->lg_tape_mrpc("logical_tape_mrpc");
00963     G4double y_tape_mrpc = (tape_mrpc_y+pcbBoard_y1)/2+pcbBoard_y0+mylar_y*2+glass0_y*2+glass1_y*5+gasLayer_y*6;
00964     G4double z_tape_mrpc = (pcbBoard_z-tape_mrpc_z)/2-tape_mrpc_posz;
00965     new G4PVPlacement(0,G4ThreeVector(0,y_tape_mrpc,z_tape_mrpc), logical_tape_mrpc,"physical_tape_mrpc_0",logical_bareChamber,false,0, checkOverlap);
00966     new G4PVPlacement(0,G4ThreeVector(0,-1*y_tape_mrpc,z_tape_mrpc), logical_tape_mrpc,"physical_tape_mrpc_1",logical_bareChamber,false,1, checkOverlap);
00967 
00968     //pcbBoard
00969     G4LogicalVolume* logical_pcbBoard0 = partProduce->lg_pcbBoard(0, "logical_pcbBoard0");
00970     G4double y_pcbBoard = (pcbBoard_y0+pcbBoard_y1)/2+mylar_y*2+glass0_y*2+glass1_y*5+gasLayer_y*6;
00971     new G4PVPlacement(0,G4ThreeVector(0,y_pcbBoard,0),logical_pcbBoard0,"physical_pcbBoard0_0",logical_bareChamber,false,0, checkOverlap);
00972     //Notice!!! I rotate 180 deg in order to make the strips near the PCB surface, 
00973     //but keep in mind that this will make the readout strips not mirror symmetry, but Z axial symmetry
00974     G4RotationMatrix* rot_pcbBoard = new G4RotationMatrix();
00975     rot_pcbBoard->rotateZ(180*degree);
00976     new G4PVPlacement(rot_pcbBoard,G4ThreeVector(0,-1*y_pcbBoard,0),logical_pcbBoard0,"physical_pcbBoard0_1",logical_bareChamber,false,1, checkOverlap);
00977 
00978     G4LogicalVolume* logical_pcbBoard1 = partProduce->lg_pcbBoard(1, "logical_pcbBoard1");
00979     new G4PVPlacement(0,G4ThreeVector(0,0,0),logical_pcbBoard1,"physical_pcbBoard1",logical_bareChamber,false,0, checkOverlap);
00980 
00981     //readout strip
00982     G4AssemblyVolume* logical_strip = partProduce->lg_strip("logical_strip");
00983     G4double z_strip = (pcbBoard_z-12*strip_z-11*strip_gap)/2-strip_posz;
00984     G4Transform3D transform_strip(rot_dummy, G4ThreeVector(0, pcbBoard_y0/2.-strip_y/2-smallL, z_strip));
00985     logical_strip->MakeImprint(logical_pcbBoard0, transform_strip);
00986     transform_strip = G4Transform3D(rot_dummy, G4ThreeVector(0,0,z_strip));
00987     logical_strip->MakeImprint(logical_pcbBoard1, transform_strip);
00988 
00989     //mylar
00990     G4LogicalVolume* logical_mylar = partProduce->lg_mylar("logical_mylar");
00991     G4double y_mylar = (mylar_y+pcbBoard_y1)/2+mylar_y+glass0_y*2+glass1_y*5+gasLayer_y*6;
00992     G4double z_mylar = (pcbBoard_z-mylar_z)/2-mylar_posz;
00993     new G4PVPlacement(0,G4ThreeVector(0,y_mylar,z_mylar),logical_mylar,"physical_mylar_0",logical_bareChamber,false,0, checkOverlap);
00994     new G4PVPlacement(0,G4ThreeVector(0,-y_mylar,z_mylar),logical_mylar,"physical_mylar_3",logical_bareChamber,false,3, checkOverlap);
00995 
00996     y_mylar = (mylar_y+pcbBoard_y1)/2;
00997     new G4PVPlacement(0,G4ThreeVector(0,y_mylar,z_mylar),logical_mylar,"physical_mylar_1",logical_bareChamber,false,1, checkOverlap);
00998     new G4PVPlacement(0,G4ThreeVector(0,-y_mylar,z_mylar),logical_mylar,"physical_mylar_2",logical_bareChamber,false,2, checkOverlap);
00999 
01000     //glass
01001     G4LogicalVolume* logical_glass0 = partProduce->lg_glass(0, "logical_glass0");
01002     G4double y_glass = (glass0_y+pcbBoard_y1)/2.+mylar_y+glass0_y+glass1_y*5+gasLayer_y*6;
01003     G4double z_glass = (pcbBoard_z-glass0_z)/2.-glass0_posz;
01004     new G4PVPlacement(0, G4ThreeVector(0, y_glass, z_glass), logical_glass0, "physical_glass0_0", logical_bareChamber, false, 0, checkOverlap);
01005     new G4PVPlacement(0, G4ThreeVector(0, -y_glass, z_glass), logical_glass0, "physical_glass0_3", logical_bareChamber, false, 3, checkOverlap);
01006     y_glass = pcbBoard_y1/2.+mylar_y+glass0_y/2.;
01007     new G4PVPlacement(0, G4ThreeVector(0, y_glass, z_glass), logical_glass0, "physical_glass0_1", logical_bareChamber, false, 1, checkOverlap);
01008     new G4PVPlacement(0, G4ThreeVector(0, -y_glass, z_glass), logical_glass0, "physical_glass0_2", logical_bareChamber, false, 2, checkOverlap);
01009 
01010     G4LogicalVolume* logical_glass1 = partProduce->lg_glass(1, "logical_glass1");
01011     z_glass = (pcbBoard_z-glass1_z)/2.-glass1_posz;
01012     for(G4int i=0; i<5; i++)
01013     {
01014         y_glass = pcbBoard_y1/2.+mylar_y+glass0_y+glass1_y*(4.5-i)+gasLayer_y*(5-i);
01015         name.str("");
01016         name<<"physical_glass1_"<<i;
01017         new G4PVPlacement(0, G4ThreeVector(0, y_glass, z_glass), logical_glass1, name.str(), logical_bareChamber, false, i, checkOverlap);
01018         name.str("");
01019         name<<"physical_glass1_"<<9-i;
01020         new G4PVPlacement(0, G4ThreeVector(0, -y_glass, z_glass), logical_glass1, name.str(), logical_bareChamber, false, 9-i, checkOverlap);
01021     }
01022 
01023     //gas
01024     logical_gasLayer = partProduce->lg_gasLayer("logical_gasLayer");
01025     G4double y_gasLayer;
01026     G4double z_gasLayer = (pcbBoard_z-gasLayer_z)/2.-gasLayer_posz;
01027     G4VPhysicalVolume* physical_gasLayer[12];
01028     for(G4int i=0; i<6; i++)  //y->larger, gasNp->larger
01029     {
01030         y_gasLayer = pcbBoard_y1/2.+mylar_y+glass0_y+glass1_y*(5-i)+gasLayer_y*(5.5-i);
01031         name.str("");
01032         name<<"physical_gasLayer_"<<11-i;
01033         physical_gasLayer[i] = new G4PVPlacement(0, G4ThreeVector(0, -y_gasLayer, z_gasLayer), logical_gasLayer, name.str(), logical_bareChamber, false, 11-i, checkOverlap);
01034     }
01035     for(G4int i=6; i<12; i++)
01036     {
01037         y_gasLayer = pcbBoard_y1/2.+mylar_y+glass0_y+glass1_y*(i-6)+gasLayer_y*(-5.5+i);
01038         name.str("");
01039         name<<"physical_gasLayer_"<<11-i;
01040         physical_gasLayer[i] = new G4PVPlacement(0, G4ThreeVector(0, y_gasLayer, z_gasLayer), logical_gasLayer, name.str(), logical_bareChamber, false, 11-i, checkOverlap);
01041     }
01042 
01043 
01044     //arrange the 72 modules in the endcap, it's assumed to form two semicircles with a gap of about 2mm
01045 
01046     // Z: East; y: Up; x: North
01047     //      /y                                            |z  y                   y|/|   
01048     //   |z/              ___________    rotateX          |  /        rotateZ     /| | 
01049     //   |/_____x         \         /                  ___|_/_                    ||_|____x
01050     //                     \       /     ->>>>        /   |/__\___x    ->>>>      |  |
01051     //            small end \_____/  bigger end      /_________\                   \ |
01052     //                                                                              \|   
01053 
01054     const G4int n_module = 36;
01055     G4double angle = 360.0*deg/n_module;
01056     G4double z_layerIn = endcap_length/2-containerOut_y/2-lowCover1_y-layer_posz;
01057     G4double z_layerOut = endcap_length/2-containerOut_y/2-lowCover2_y-layer_posz;
01058     //Adjusting parameters
01059     //rOffset_east: along R direction
01060     //angle_east: along phi direction
01061     //angleOffset_east: along self asymmetric axis
01062     rOffset_east = tofPara->GetVec("rOffset_east");
01063     angle_east = tofPara->GetVec("angle_east");
01064     angleOffset_east = tofPara->GetVec("angleOffset_east");
01065     rOffset_west = tofPara->GetVec("rOffset_west");
01066     angle_west = tofPara->GetVec("angle_west");
01067     angleOffset_west = tofPara->GetVec("angleOffset_west");
01068 
01069 
01070     //arrange east endcap
01071     for(int i=0; i<n_module; i++)
01072     {
01073         G4double angle_module = startAngle_east+angle_east[i]+i*angle;
01074         G4double r_module = endcap_r+rOffset_east[i];
01075 
01076         G4RotationMatrix rot_layerIn_east;
01077         rot_layerIn_east.rotateX(90.*deg);
01078         rot_layerIn_east.rotateZ(90.*deg);
01079         rot_layerIn_east.rotateZ(angle_module+angleOffset_east[i]);
01080 
01081         G4ThreeVector translation_layerIn_east = G4ThreeVector(r_module*cos(angle_module), r_module*sin(angle_module), -z_layerIn);
01082         G4Transform3D transform_layerIn_east = G4Transform3D(rot_layerIn_east, translation_layerIn_east);
01083 
01084 
01085         G4RotationMatrix rot_layerOut_east;
01086         rot_layerOut_east.rotateZ(180.*deg);
01087         rot_layerOut_east.rotateX(90.*deg);
01088         rot_layerOut_east.rotateZ(90.*deg);
01089         rot_layerOut_east.rotateZ(angle_module+angleOffset_east[i]);
01090 
01091         G4ThreeVector translation_layerOut_east = G4ThreeVector(r_module*cos(angle_module), r_module*sin(angle_module), z_layerOut);
01092         G4Transform3D transform_layerOut_east = G4Transform3D(rot_layerOut_east, translation_layerOut_east);
01093 
01094         name.str("");
01095         name<<"physical_mrpc_east_"<<i;
01096         if(i%2==0)
01097         {
01098             new G4PVPlacement(transform_layerOut_east, logical_container[3], name.str(), logicalEcTofEast, false, i, checkOverlap);
01099         }
01100         else
01101         {
01102             new G4PVPlacement(transform_layerIn_east, logical_container[0], name.str(), logicalEcTofEast, false, i, checkOverlap);
01103         }
01104     }
01105 
01106     //arrange west endcap
01107     for(int i=0; i<n_module; i++)
01108     {
01109         G4double angle_module = startAngle_west+angle_west[i]+i*angle;
01110         G4double r_module = endcap_r+rOffset_west[i];
01111 
01112         G4RotationMatrix rot_layerIn_west;
01113         rot_layerIn_west.rotateZ(180.*deg);
01114         rot_layerIn_west.rotateX(90.*deg);
01115         rot_layerIn_west.rotateZ(90.*deg);
01116         rot_layerIn_west.rotateZ(angle_module+angleOffset_west[i]);
01117 
01118         G4ThreeVector translation_layerIn_west = G4ThreeVector(r_module*cos(angle_module), r_module*sin(angle_module), z_layerIn);
01119         G4Transform3D transform_layerIn_west = G4Transform3D(rot_layerIn_west, translation_layerIn_west);
01120 
01121 
01122         G4RotationMatrix rot_layerOut_west;
01123         rot_layerOut_west.rotateX(90.*deg);
01124         rot_layerOut_west.rotateZ(90.*deg);
01125         rot_layerOut_west.rotateZ(angle_module+angleOffset_west[i]);
01126 
01127         G4ThreeVector translation_layerOut_west = G4ThreeVector(r_module*cos(angle_module), r_module*sin(angle_module), -z_layerOut);
01128         G4Transform3D transform_layerOut_west = G4Transform3D(rot_layerOut_west, translation_layerOut_west);
01129 
01130         name.str("");
01131         name<<"physical_mrpc_west_"<<i;
01132         if(i%2==0)
01133         {
01134             new G4PVPlacement(transform_layerOut_west, logical_container[2], name.str(), logicalEcTofWest, false, i, checkOverlap);
01135         }
01136         else
01137         {
01138             new G4PVPlacement(transform_layerIn_west, logical_container[1], name.str(), logicalEcTofWest, false, i, checkOverlap);
01139         }
01140     }
01141 } 
01142 
01143 
01144 
01145 void BesTofConstruction::DefineMaterial()   //This fucntion just "build" my materials 
01146 {
01147     G4double a,z,density,fraction;
01148     G4int nel, natoms, ncomponents;
01149     G4String name, symbol;
01150 
01151 
01152     G4Element* H=G4Element::GetElement("Hydrogen");
01153     if (!H)
01154       H = new G4Element(name="Hydrogen",symbol="H" , z= 1., a=1.01*g/mole);
01155 
01156     G4Element* C=G4Element::GetElement("Carbon");
01157     if (!C)
01158       C = new G4Element(name="Carbon"  ,symbol="C" , z= 6., a=12.01*g/mole);
01159 
01160     G4Element* F=G4Element::GetElement("Fluorin");
01161     if (!F)
01162       F = new G4Element(name="Fluorin", symbol="F", z=9., a=18.01*g/mole);
01163 
01164     G4Element* O=G4Element::GetElement("Oxygen");
01165     if (!O)
01166       O = new G4Element(name="Oxygen",symbol="O",z= 8., a= 16.00*g/mole);
01167 
01168     G4Element* N=G4Element::GetElement("Nitrogen");
01169     if (!N)
01170       N = new G4Element(name="Nitrogen",symbol="N",z= 7., a= 14.01*g/mole);
01171 
01172     G4Element* S=G4Element::GetElement("Sulfur");
01173     if(!S)
01174       S = new G4Element(name="Sulfur",symbol="S",z= 16., a= 32.06*g/mole);
01175 
01176 
01177     BC404 = new G4Material("BC404",density=1.032*g/cm3,nel=2);
01178     BC404->AddElement(C,10);
01179     BC404->AddElement(H,11);
01180 
01181     BC408 = new G4Material("BC408",density=1.032*g/cm3,nel=2);
01182     BC408->AddElement(C,1000);
01183     BC408->AddElement(H,1104);
01184 
01185     PVF = new G4Material("PVF",density=1.45*g/cm3,nel=3);
01186     PVF->AddElement(C,2);
01187     PVF->AddElement(H,3);
01188     PVF->AddElement(F,1);
01189 
01190     //PMT mixed material
01191     G4Material* Cu = G4Material::GetMaterial("Copper");
01192     G4Material* Al = G4Material::GetMaterial("Aluminium");
01193 
01194     //vacuum
01195     //G4Material* Vacuum = new G4Material("Galactic", z=1., a=1.01*g/mole,
01196     //density= universe_mean_density, kStateGas, 3.e-18*pascal, 2.73*kelvin);
01197 
01198     density = 1.4618815*g/cm3;
01199     PMTmaterial =  new G4Material(name="PMTmaterial", density,  4);
01200     PMTmaterial->AddMaterial(Al, 0.4495);
01201     PMTmaterial->AddMaterial(Cu,0.35);
01202     PMTmaterial->AddMaterial(G4Material::GetMaterial("SiO2"),0.2);
01203     PMTmaterial->AddMaterial(G4Material::GetMaterial("Air"),0.0005);
01204     //PMTmaterial->AddMaterial(Vacuum,0.1);
01205     G4cout<<PMTmaterial;
01206 
01207     density = 1.002*g/cm3;
01208     G4Material* tape = new G4Material(name="tape",density,nel=2);
01209     tape->AddElement(C,2);
01210     tape->AddElement(H,5);
01211 
01212 
01213     //MRPC material
01214     //The stop block in the gas container
01215     G4Material* Nylon = new G4Material("Nylon", density=1.15*g/cm3, ncomponents=4);
01216     Nylon->AddElement(C, natoms=2);
01217     Nylon->AddElement(H, natoms=3);
01218     Nylon->AddElement(O, natoms=1);
01219     Nylon->AddElement(N, natoms=1);
01220     G4cout<<Nylon<<G4endl;
01221 
01222     //The core of honeyComb is thought to be cellulose
01223     G4Material* honeycombCore = new G4Material("honeycombCore", density=0.024*g/cm3, ncomponents=3);
01224     honeycombCore->AddElement(C,natoms=6);
01225     honeycombCore->AddElement(H,natoms=10);
01226     honeycombCore->AddElement(O,natoms=5);
01227     G4cout<<honeycombCore<<G4endl;
01228 
01229     //The honeyComb surface and the PCB board are thought to be composed of SiO2(60%) and epoxy resins(40%)
01230     G4Material* epoxy = new G4Material("epoxy", density=1.2*g/cm3, ncomponents=3);
01231     epoxy->AddElement(C,natoms=11);
01232     epoxy->AddElement(H,natoms=12);
01233     epoxy->AddElement(O,natoms=3);
01234     G4cout<<epoxy<<G4endl;
01235 
01236     G4Material* insulationBoard = new G4Material("insulationBoard", density=1.85*g/cm3, 2);
01237     insulationBoard->AddMaterial(G4Material::GetMaterial("SiO2"), 0.6);
01238     insulationBoard->AddMaterial(epoxy, 0.4);
01239     G4cout<<insulationBoard<<G4endl;
01240 
01241     //Mylar and tape are thought to be PET
01242     G4Material* PET = new G4Material("PET", density= 1.39*g/cm3, ncomponents=3);
01243     PET->AddElement(C,natoms=10);
01244     PET->AddElement(H,natoms=8);
01245     PET->AddElement(O,natoms=4);
01246     G4cout<<PET<<G4endl;
01247 
01248     //MRPC gas: 90% r134a, 5% isobutan, 5% SF6 
01249     G4Material* FreonR134A = new G4Material("FreonR134A", density =4.241*mg/cm3,ncomponents=3);
01250     FreonR134A->AddElement(C,natoms=2);
01251     FreonR134A->AddElement(H,natoms=2);
01252     FreonR134A->AddElement(F,natoms=4);
01253     G4cout<<FreonR134A<<G4endl;
01254 
01255     G4Material* SF6 = new G4Material("SF6", density =6.14*mg/cm3,ncomponents=2);
01256     SF6->AddElement(S,natoms=1);
01257     SF6->AddElement(F,natoms=6);
01258     G4cout<<SF6<<G4endl;
01259 
01260     G4Material* Isobutan = new G4Material("Isobutan", density =2.487*mg/cm3,ncomponents=2);
01261     Isobutan->AddElement(C, natoms=4);
01262     Isobutan->AddElement(H, natoms=10);
01263     G4cout<<Isobutan<<G4endl;
01264 
01265     G4Material* MRPCGas = new G4Material(name="MRPCGas", density=4.17*mg/cm3,ncomponents=3);
01266     MRPCGas->AddMaterial(FreonR134A, fraction= 89.69*perCent);
01267     MRPCGas->AddMaterial(SF6, fraction=7.34*perCent);
01268     MRPCGas->AddMaterial(Isobutan, fraction=2.97*perCent);
01269 
01270     //This setting is to produce ion pairs, default is 0 
01271     if(0.0 == MRPCGas->GetIonisation()->GetMeanEnergyPerIonPair())
01272     {
01273         //MRPCGas->GetIonisation()->SetMeanEnergyPerIonPair(20*eV);
01274         MRPCGas->GetIonisation()->SetMeanEnergyPerIonPair(m_ionE*eV);
01275     }
01276     G4cout<<MRPCGas<<G4endl;
01277 }
01278 
01279 void  BesTofConstruction::getXYZ( const G4RotationMatrix r, double& a, double& b, double& c) const
01280 {
01281     double cosb = sqrt( r.xx()*r.xx() + r.yx()*r.yx() );
01282 
01283     if (cosb > 16*FLT_EPSILON)
01284     {
01285         a = atan2(  r.zy(), r.zz() );
01286         b = atan2( -r.zx(), cosb    );
01287         c = atan2(  r.yx(), r.xx() );
01288     }
01289     else
01290     {
01291         a = atan2( -r.yz(), r.yy() );
01292         b = atan2( -r.zx(), cosb    );
01293         c = 0.;
01294     }
01295     //std::cout.precision(20);
01296     //std::cout<<"in    getXYZ   :( "<<r.xx()<<" "<<r.xy()<<" "<<r.xz()<<std::endl;
01297     //std::cout<<"                  "<<r.yx()<<" "<<r.yy()<<" "<<r.yz()<<std::endl;
01298     //std::cout<<"                  "<<r.zx()<<" "<<r.zy()<<" "<<r.zz()<<std::endl;
01299     //std::cout<<"details: cosb="<<cosb<<" a="<<a<<" b="<<b<<" c="<<c<<" min="<<16*FLT_EPSILON<<std::endl;
01300 
01301 
01302     G4RotationMatrix temp;
01303     temp.rotateZ((c/deg)*deg);
01304     //std::cout.precision(20);
01305     //std::cout<<"in detail temp2:( "<<temp.xx()<<" "<<temp.xy()<<" "<<temp.xz()<<std::endl;
01306     //std::cout<<"                  "<<temp.yx()<<" "<<temp.yy()<<" "<<temp.yz()<<std::endl;
01307     //std::cout<<"                  "<<temp.zx()<<" "<<temp.zy()<<" "<<temp.zz()<<std::endl;
01308 }
01309 
01310 
01311 void BesTofConstruction::IniParam_mrpc()
01312 {
01313     tofPara = BesTofGeoParameter::GetInstance();
01314 
01315     //All the values are in units of mm or deg
01316     containerOut_xdown = tofPara->Get("containerOut_xdown");
01317     containerOut_xup = tofPara->Get("containerOut_xup");
01318     containerOut_y = tofPara->Get("containerOut_y");
01319     containerOut_z = tofPara->Get("containerOut_z");
01320     container_thickness = tofPara->Get("container_thickness");
01321     container_lowBorder = tofPara->Get("container_lowBorder");
01322 
01323     containerIn_xdown = tofPara->Get("containerIn_xdown");
01324     containerIn_xup = tofPara->Get("containerIn_xup");
01325     containerIn_y = tofPara->Get("containerIn_y");
01326     containerIn_z = tofPara->Get("containerIn_z");
01327 
01328     upCover_xdown = tofPara->Get("upCover_xdown");
01329     upCover_xup = tofPara->Get("upCover_xup");
01330     upCover_y = tofPara->Get("upCover_y");
01331     upCover_z = tofPara->Get("upCover_z");
01332     upCover_posz = tofPara->Get("upCover_posz");
01333 
01334     lowCover1_xdown = tofPara->Get("lowCover1_xdown");
01335     lowCover1_xup = tofPara->Get("lowCover1_xup");
01336     lowCover1_y = tofPara->Get("lowCover1_y");
01337     lowCover1_z = tofPara->Get("lowCover1_z");
01338     lowCover1_addx = tofPara->Get("lowCover1_addx");
01339     lowCover1_addz = tofPara->Get("lowCover1_addz");
01340     lowCover1_posz = tofPara->Get("lowCover1_posz");
01341 
01342     lowCover2_xdown = tofPara->Get("lowCover2_xdown");
01343     lowCover2_xup = tofPara->Get("lowCover2_xup");
01344     lowCover2_y = tofPara->Get("lowCover2_y");
01345     lowCover2_z = tofPara->Get("lowCover2_z");
01346     lowCover2_posz = tofPara->Get("lowCover2_posz");
01347 
01348     upFEE_xdown = tofPara->Get("upFEE_xdown");
01349     upFEE_xup = tofPara->Get("upFEE_xup");
01350     upFEE_y = tofPara->Get("upFEE_y");
01351     upFEE_z = tofPara->Get("upFEE_z");
01352     FEE_thickness = tofPara->Get("FEE_thickness");
01353     upFEE_posz = tofPara->Get("upFEE_posz");
01354 
01355     upFEE_pcb_xdown = tofPara->Get("upFEE_pcb_xdown");
01356     upFEE_pcb_xup = tofPara->Get("upFEE_pcb_xup");
01357     upFEE_pcb_y = tofPara->Get("upFEE_pcb_y");
01358     upFEE_pcb_z = tofPara->Get("upFEE_pcb_z");
01359 
01360     sideFEE_x = tofPara->Get("sideFEE_x");
01361     sideFEE_y = tofPara->Get("sideFEE_y");
01362     sideFEE_z = tofPara->Get("sideFEE_z");
01363     sideFEE_posl = tofPara->Get("sideFEE_posl");
01364 
01365     sideFEE_pcb_x = tofPara->Get("sideFEE_pcb_x");
01366     sideFEE_pcb_y = tofPara->Get("sideFEE_pcb_y");
01367     sideFEE_pcb_z = tofPara->Get("sideFEE_pcb_z");
01368 
01369     castingDie_x = tofPara->Get("castingDie_x");
01370     castingDie_y = tofPara->Get("castingDie_y");
01371     castingDie_z = tofPara->Get("castingDie_z");
01372     castingDie_addr = tofPara->Get("castingDie_addr");
01373     castingDie_subtractx = tofPara->Get("castingDie_subtractx");
01374     castingDie_subtract_posz = tofPara->Get("castingDie_subtract_posz");
01375     castingDie_posz1 = tofPara->Get("castingDie_posz1");
01376     castingDie_posz2 = tofPara->Get("castingDie_posz2");
01377 
01378     chamber_in_posy = tofPara->Get("chamber_in_posy");
01379     chamber_out_posy = tofPara->Get("chamber_out_posy");
01380 
01381     bracket_x = tofPara->Get("bracket_x");
01382     bracket_y = tofPara->Get("bracket_y");
01383     bracket_z = tofPara->Get("bracket_z");
01384     bracket_r = tofPara->Get("bracket_r");
01385     bracket_posx = tofPara->Get("bracket_posx");
01386 
01387     upStopBlock_x = tofPara->Get("upStopBlock_x");
01388     upStopBlock_y = tofPara->Get("upStopBlock_y");
01389     upStopBlock_z = tofPara->Get("upStopBlock_z");
01390     upStopBlock_subtractr = tofPara->Get("upStopBlock_subtractr");
01391     upStopBlock_subtractposz = tofPara->Get("upStopBlock_subtractposz");
01392 
01393     sideStopBlock_x = tofPara->Get("sideStopBlock_x");
01394     sideStopBlock_y = tofPara->Get("sideStopBlock_y");
01395     sideStopBlock_z = tofPara->Get("sideStopBlock_z");
01396     sideStopBlock_thickness = tofPara->Get("sideStopBlock_thickness");
01397     sideStopBlock_posz0 = tofPara->Get("sideStopBlock_posz0");
01398     sideStopBlock_posz1 = tofPara->Get("sideStopBlock_posz1");
01399 
01400 
01401     honeyComb_xdown = tofPara->Get("honeyComb_xdown");
01402     honeyComb_xup = tofPara->Get("honeyComb_xup");
01403     honeyComb_y = tofPara->Get("honeyComb_y");
01404     honeyComb_z = tofPara->Get("honeyComb_z");
01405     honeyComb_surface_y = tofPara->Get("honeyComb_surface_y");
01406     honeyComb_posz = tofPara->Get("honeyComb_posz");
01407 
01408     tape_mrpc_xdown = tofPara->Get("tape_mrpc_xdown");
01409     tape_mrpc_xup = tofPara->Get("tape_mrpc_xup");
01410     tape_mrpc_y = tofPara->Get("tape_mrpc_y");
01411     tape_mrpc_z = tofPara->Get("tape_mrpc_z");
01412     tape_mrpc_posz = tofPara->Get("tape_mrpc_posz");
01413 
01414     pcbBoard_xdown = tofPara->Get("pcbBoard_xdown");
01415     pcbBoard_xup = tofPara->Get("pcbBoard_xup");
01416     pcbBoard_y0 = tofPara->Get("pcbBoard_y0");
01417     pcbBoard_y1 = tofPara->Get("pcbBoard_y1");
01418     pcbBoard_z = tofPara->Get("pcbBoard_z");
01419 
01420     strip_x[0] = tofPara->Get("strip_x[0]");
01421     strip_x[1] = tofPara->Get("strip_x[1]");
01422     strip_x[2] = tofPara->Get("strip_x[2]");
01423     strip_x[3] = tofPara->Get("strip_x[3]");
01424     strip_x[4] = tofPara->Get("strip_x[4]");
01425     strip_x[5] = tofPara->Get("strip_x[5]");
01426     strip_x[6] = tofPara->Get("strip_x[6]");
01427     strip_x[7] = tofPara->Get("strip_x[7]");
01428     strip_x[8] = tofPara->Get("strip_x[8]");
01429     strip_x[9] = tofPara->Get("strip_x[9]");
01430     strip_x[10] = tofPara->Get("strip_x[10]");
01431     strip_x[11] = tofPara->Get("strip_x[11]");
01432     strip_y = tofPara->Get("strip_y");
01433     strip_z = tofPara->Get("strip_z");
01434     strip_gap = tofPara->Get("strip_gap");
01435     strip_posz = tofPara->Get("strip_posz");
01436 
01437     mylar_xdown = tofPara->Get("mylar_xdown");
01438     mylar_xup = tofPara->Get("mylar_xup");
01439     mylar_y = tofPara->Get("mylar_y");
01440     mylar_z = tofPara->Get("mylar_z");
01441     mylar_posz = tofPara->Get("mylar_posz");
01442 
01443     glass0_xdown = tofPara->Get("glass0_xdown");
01444     glass0_xup = tofPara->Get("glass0_xup");
01445     glass0_y = tofPara->Get("glass0_y");
01446     glass0_z = tofPara->Get("glass0_z");
01447     glass0_posz = tofPara->Get("glass0_posz");
01448 
01449     glass1_xdown = tofPara->Get("glass1_xdown");
01450     glass1_xup = tofPara->Get("glass1_xup");
01451     glass1_y = tofPara->Get("glass1_y");
01452     glass1_z = tofPara->Get("glass1_z");
01453     glass1_posz = tofPara->Get("glass1_posz");
01454 
01455     gasLayer_xdown = tofPara->Get("gasLayer_xdown");
01456     gasLayer_xup = tofPara->Get("gasLayer_xup");
01457     gasLayer_y = tofPara->Get("gasLayer_y");
01458     gasLayer_z = tofPara->Get("gasLayer_z");
01459     gasLayer_posz = tofPara->Get("gasLayer_posz");
01460 
01461     endcap_r = tofPara->Get("endcap_r");
01462     endcap_length = tofPara->Get("endcap_length");
01463     layer_posz = tofPara->Get("layer_posz");
01464     startAngle_east = tofPara->Get("startAngle_east");
01465     startAngle_west = tofPara->Get("startAngle_west");
01466 }

Generated on Tue Nov 29 23:14:31 2016 for BOSS_7.0.2 by  doxygen 1.4.7