00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "BesCrystalParameterisation.hh"
00011
00012 #include "BesEmcConstruction.hh"
00013 #include "BesEmcGeometry.hh"
00014
00015
00016 #include "G4VPhysicalVolume.hh"
00017 #include "G4LogicalVolume.hh"
00018 #include "G4ThreeVector.hh"
00019 #include "G4Trap.hh"
00020
00021
00022
00023 BesCrystalParameterisation::BesCrystalParameterisation(
00024 const G4int startID,
00025 const G4int endID,
00026 const G4int thetaAllCrystals,
00027 BesEmcGeometry* besEMCGeometry,
00028 const G4int verboseLevel
00029 ):fVerboseLevel(0)
00030 {
00031
00032
00033 fBesEmcGeometry = besEMCGeometry;
00034 fVerboseLevel = verboseLevel;
00035 fStartID = startID;
00036 fAllCrystals = thetaAllCrystals;
00037 fCrystalID = 0;
00038 fFlagLeft = true;
00039 if (startID>endID||endID>thetaAllCrystals||startID<1)
00040 {
00041 G4Exception("BesCrystalParameterisation construction: ID of crystal>No avaible!");
00042 }
00043
00044 }
00045
00046
00047
00048 BesCrystalParameterisation::~BesCrystalParameterisation()
00049 {}
00050
00051
00052
00053 void BesCrystalParameterisation::ComputeTransformation
00054 (const G4int copyNo, G4VPhysicalVolume* physVol) const
00055 {
00056
00057
00058 ComputeIDAndSide(physVol);
00059
00060 if(fVerboseLevel>3)
00061 {
00062 G4cout<<"*BesCrystalParameterisation::ComputeTransformation()*"<<G4endl;
00063 G4cout << "copyNo(transfered)=" << copyNo << G4endl
00064 << "copyNo(gotten) =" << physVol->GetCopyNo() << G4endl
00065 << "fStartID =" << fStartID << G4endl
00066 << "fCrystalID =" << fCrystalID << G4endl;
00067 G4cout << "point of fBesEmcGeometry=" << fBesEmcGeometry << G4endl;
00068 }
00069
00070 G4double xPosition= fBesEmcGeometry->GetXPosition(fCrystalID);
00071 G4double yPosition= fBesEmcGeometry->GetYPosition(fCrystalID);
00072 G4double zPosition= fBesEmcGeometry->GetZPosition(fCrystalID);
00073
00074
00075 if(fFlagLeft) zPosition=-zPosition;
00076 G4ThreeVector origin(xPosition,yPosition,zPosition);
00077 physVol->SetTranslation(origin);
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 if(fVerboseLevel>5)
00096 {
00097 G4cout << "The crystals are at the position:" << G4endl
00098 << origin/cm <<"(cm)" << G4endl;
00099
00100
00101
00102
00103 }
00104
00105
00106 }
00107
00108
00109
00110 void BesCrystalParameterisation::ComputeDimensions
00111 (G4Trap& trackerChamber, const G4int copyNo,
00112 const G4VPhysicalVolume* physVol) const
00113 {
00114
00115
00116 ComputeIDAndSide(physVol);
00117
00118 G4double zHalfLength = fBesEmcGeometry->GetZHalfLength(fCrystalID);
00119 G4double thetaAxis = fBesEmcGeometry->GetThetaAxis(fCrystalID);
00120 G4double phiAxis = fBesEmcGeometry->GetPhiAxis(fCrystalID);
00121 G4double yHalfLength1 = fBesEmcGeometry->GetYHalfLength1(fCrystalID);
00122 G4double xHalfLength1 = fBesEmcGeometry->GetXHalfLength1(fCrystalID);
00123 G4double xHalfLength2 = fBesEmcGeometry->GetXHalfLength2(fCrystalID);
00124 G4double tanAlpha1 = fBesEmcGeometry->GetTanAlpha1(fCrystalID);
00125 G4double yHalfLength2 = fBesEmcGeometry->GetYHalfLength2(fCrystalID);
00126 G4double xHalfLength3 = fBesEmcGeometry->GetXHalfLength3(fCrystalID);
00127 G4double xHalfLength4 = fBesEmcGeometry->GetXHalfLength4(fCrystalID);
00128 G4double tanAlpha2 = fBesEmcGeometry->GetTanAlpha2(fCrystalID);
00129
00130 if(!fFlagLeft)
00131 {
00132 phiAxis=-phiAxis;
00133 tanAlpha1=-tanAlpha1;
00134 tanAlpha2=-tanAlpha2;
00135 G4double tmp;
00136 tmp=xHalfLength1;
00137 xHalfLength1=xHalfLength2;
00138 xHalfLength2=tmp;
00139 tmp=xHalfLength3;
00140 xHalfLength3=xHalfLength4;
00141 xHalfLength4=tmp;
00142 }
00143 if(fVerboseLevel>5)
00144 G4cout << "The size of No." << copyNo << " crystal(placed) are:" << G4endl
00145 << "zHalfLength =" << zHalfLength/cm << "(cm), " << G4endl
00146 << "thetaAxis =" << thetaAxis/deg << "(degree), " << G4endl
00147 << "phiAxis =" << phiAxis/deg << "(degree), " << G4endl
00148 << "yHalfLength1=" << yHalfLength1/cm << "(cm), " << G4endl
00149 << "xHalfLength1=" << xHalfLength1/cm << "(cm), " << G4endl
00150 << "xHalfLength2=" << xHalfLength2/cm << "(cm), " << G4endl
00151 << "tanAlpha1 =" << tanAlpha1 << "(), " << G4endl
00152 << "yHalfLength2=" << yHalfLength2/cm << "(cm), " << G4endl
00153 << "xHalfLength3=" << xHalfLength3/cm << "(cm), " << G4endl
00154 << "xHalfLength4=" << xHalfLength4/cm << "(cm)." << G4endl
00155 << "tanAlpha2 =" << tanAlpha2 << "(), " << G4endl
00156 << "(x4-x3)*y1/(x2-x1)/y2="
00157 << (xHalfLength4-xHalfLength3)*yHalfLength1/(xHalfLength2-xHalfLength1)/yHalfLength2 << G4endl
00158 << "tanAlpha2/tanAlpha1=" << tanAlpha2/tanAlpha1 <<G4endl;
00159
00160
00161 trackerChamber.SetAllParameters(
00162 zHalfLength,
00163 thetaAxis,
00164 phiAxis,
00165 yHalfLength1,
00166 xHalfLength1,
00167 xHalfLength2,
00168 tanAlpha1,
00169 yHalfLength2,
00170 xHalfLength3,
00171 xHalfLength4,
00172 tanAlpha2);
00173
00174 }
00175
00176
00177 G4VSolid* BesCrystalParameterisation::ComputeSolid(const G4int copyNo,
00178 G4VPhysicalVolume *pPhysicalVol)
00179 {
00180 if(0) G4cout<<copyNo<<G4endl;
00181 ComputeIDAndSide(pPhysicalVol);
00182 return pPhysicalVol->GetLogicalVolume()->GetSolid();
00183 }
00184
00185 G4Material* BesCrystalParameterisation::ComputeMaterial(const G4int copyNo,
00186 G4VPhysicalVolume *pPhysicalVol, const G4VTouchable *parentTouch)
00187 {
00188 if(0) G4cout<<copyNo<<parentTouch<<G4endl;
00189 ComputeIDAndSide(pPhysicalVol);
00190 G4int nBSCTheta=fBesEmcGeometry->GetBSCNbTheta();
00191
00192
00193
00194
00195
00196 if(pPhysicalVol->GetCopyNo()>2*nBSCTheta)
00197 return BesEmcConstruction::GetBesEmcConstruction()->GetCasingMaterial();
00198 else
00199 return BesEmcConstruction::GetBesEmcConstruction()->GetCrystalMaterial();
00200 }
00201
00202 void BesCrystalParameterisation::ComputeIDAndSide(
00203 const G4VPhysicalVolume* pPhyVol)const
00204 {
00205
00206
00207 G4int* pCrystalID=const_cast<G4int*>(&fCrystalID);
00208 G4bool* pFlagLeft=const_cast<G4bool*>(&fFlagLeft);
00209 G4int* pVerboseLevel=const_cast<G4int*>(&fVerboseLevel);
00210
00211 *pVerboseLevel=
00212 BesEmcConstruction::GetBesEmcConstruction()->GetVerboseLevel();
00213
00214
00215 *pCrystalID=-1;
00216 for(G4int i=fStartID;i<=fAllCrystals;i++)
00217 {
00218
00219
00220 if(fBesEmcGeometry->GetPhysiBSCCrystal(i)==pPhyVol)
00221 {
00222 *pCrystalID=i;
00223 }
00224 }
00225 if(*pCrystalID==-1)
00226 G4Exception("The point of PhysicCrystal error!!!!!!!!!!!");
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237 if(fCrystalID>fAllCrystals/2)
00238 {
00239 *pFlagLeft=false;
00240 *pCrystalID=fCrystalID-fAllCrystals/2;
00241 }
00242 else
00243 {
00244 *pFlagLeft=true;
00245 *pCrystalID=fAllCrystals/2-fCrystalID+1;
00246 }
00247 *pCrystalID=*pCrystalID-1;
00248 }