BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
ExtBesCrystalParameterisation.cxx
Go to the documentation of this file.
1//---------------------------------------------------------------------------//
2// BOOST --- BESIII Object_Oreiented Simulation Tool //
3//---------------------------------------------------------------------------//
4// Descpirtion: EMC detector
5// Author: Fu Chengdong
6// Created: Sep 4, 2003
7// Comment:
8//---------------------------------------------------------------------------//
9//
11
13#include "ExtBesEmcGeometry.h"
14// #include "BesDetectorConstruction.hh"
15
16#include "G4LogicalVolume.hh"
17#include "G4SystemOfUnits.hh"
18#include "G4ThreeVector.hh"
19#include "G4Trap.hh"
20#include "G4VPhysicalVolume.hh"
21
22//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
23
25 const G4int startID, const G4int endID, const G4int thetaAllCrystals,
26 ExtBesEmcGeometry* besEMCGeometry, const G4int verboseLevel )
27 : fVerboseLevel( 0 ) {
28 // for debug
29 // G4Exception("ExtBesCrystalParameterisation::ExtBesCrystalParameterisation()
30 // starting........");
31 fBesEmcGeometry = besEMCGeometry;
32 fVerboseLevel = verboseLevel; // if need to debug this class,open it
33 fStartID = startID;
34 fAllCrystals = thetaAllCrystals;
35 fCrystalID = 0;
36 fFlagLeft = true;
37 if ( startID > endID || endID > thetaAllCrystals || startID < 1 )
38 {
39 G4cout << "ExtBesCrystalParameterisation construction: ID of crystal>No avaible!"
40 << G4endl;
41 exit( -1 );
42 }
43}
44
45//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
46
48
49//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
50
52 G4VPhysicalVolume* physVol ) const {
53 // for debug
54 // G4Exception("ExtBesCrystalParameterisation::ComputeTransformation() starting........");
55 ComputeIDAndSide( physVol );
56
57 if ( fVerboseLevel > 3 )
58 {
59 G4cout << "*ExtBesCrystalParameterisation::ComputeTransformation()*" << G4endl;
60 G4cout << "copyNo(transfered)=" << copyNo << G4endl
61 << "copyNo(gotten) =" << physVol->GetCopyNo() << G4endl
62 << "fStartID =" << fStartID << G4endl
63 << "fCrystalID =" << fCrystalID << G4endl;
64 G4cout << "point of fBesEmcGeometry=" << fBesEmcGeometry << G4endl;
65 }
66
67 G4double xPosition = fBesEmcGeometry->GetXPosition( fCrystalID );
68 G4double yPosition = fBesEmcGeometry->GetYPosition( fCrystalID );
69 G4double zPosition = fBesEmcGeometry->GetZPosition( fCrystalID );
70 // G4Exception("ExtBesCrystalParameterisation::ComputeTransformation() running........");
71 // G4double xPosition=0,yPosition=0,zPosition=0;
72 if ( fFlagLeft ) zPosition = -zPosition;
73 G4ThreeVector origin( xPosition, yPosition, zPosition );
74 physVol->SetTranslation( origin );
75
76 // G4double thetaPosition=fBesEmcGeometry->GetThetaPosition(fCrystalID);
77 // G4RotationMatrix *rotateMatrix;
78 // rotateMatrix = new G4RotationMatrix();
79 // if(fFlagLeft)
80 // {
81 // rotateMatrix->rotateZ(-90*deg);
82 // rotateMatrix->rotateX(-180*deg+thetaPosition);
83 // }
84 // else
85 // {
86 // rotateMatrix->rotateZ(-90*deg);
87 // rotateMatrix->rotateX(-thetaPosition);
88 // }
89 // G4double delta = 0*deg;
90 // G4ThreeVector axis = G4ThreeVector(0,0,0);
91 // rotateMatrix->getAngleAxis(delta, axis);
92 if ( fVerboseLevel > 5 )
93 {
94 G4cout << "The crystals are at the position:" << G4endl << origin / cm << "(cm)" << G4endl;
95 // G4cout << thetaPosition/deg <<"(deg)." << G4endl
96 //<< "The axis of crystals in the world system is: " << G4endl
97 //<< delta/deg << "(deg)(delta) " << G4endl
98 //<< axis << "(Z axis)" << G4endl;
99 }
100 // physVol->SetRotation(rotateMatrix);
101}
102
103//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
104
106 G4Trap& trackerChamber, const G4int copyNo, const G4VPhysicalVolume* physVol ) const {
107 // for debug
108 // G4Exception("ExtBesCrystalParameterisation::ComputeDimensions() starting........");
109 ComputeIDAndSide( physVol );
110
111 G4double zHalfLength = fBesEmcGeometry->GetZHalfLength( fCrystalID );
112 G4double thetaAxis = fBesEmcGeometry->GetThetaAxis( fCrystalID );
113 G4double phiAxis = fBesEmcGeometry->GetPhiAxis( fCrystalID );
114 G4double yHalfLength1 = fBesEmcGeometry->GetYHalfLength1( fCrystalID );
115 G4double xHalfLength1 = fBesEmcGeometry->GetXHalfLength1( fCrystalID );
116 G4double xHalfLength2 = fBesEmcGeometry->GetXHalfLength2( fCrystalID );
117 G4double tanAlpha1 = fBesEmcGeometry->GetTanAlpha1( fCrystalID );
118 G4double yHalfLength2 = fBesEmcGeometry->GetYHalfLength2( fCrystalID );
119 G4double xHalfLength3 = fBesEmcGeometry->GetXHalfLength3( fCrystalID );
120 G4double xHalfLength4 = fBesEmcGeometry->GetXHalfLength4( fCrystalID );
121 G4double tanAlpha2 = fBesEmcGeometry->GetTanAlpha2( fCrystalID );
122
123 if ( !fFlagLeft )
124 {
125 phiAxis = -phiAxis;
126 tanAlpha1 = -tanAlpha1;
127 tanAlpha2 = -tanAlpha2;
128 G4double tmp;
129 tmp = xHalfLength1;
130 xHalfLength1 = xHalfLength2;
131 xHalfLength2 = tmp;
132 tmp = xHalfLength3;
133 xHalfLength3 = xHalfLength4;
134 xHalfLength4 = tmp;
135 }
136 if ( fVerboseLevel > 5 )
137 G4cout << "The size of No." << copyNo << " crystal(placed) are:" << G4endl
138 << "zHalfLength =" << zHalfLength / cm << "(cm), " << G4endl
139 << "thetaAxis =" << thetaAxis / deg << "(degree), " << G4endl
140 << "phiAxis =" << phiAxis / deg << "(degree), " << G4endl
141 << "yHalfLength1=" << yHalfLength1 / cm << "(cm), " << G4endl
142 << "xHalfLength1=" << xHalfLength1 / cm << "(cm), " << G4endl
143 << "xHalfLength2=" << xHalfLength2 / cm << "(cm), " << G4endl
144 << "tanAlpha1 =" << tanAlpha1 << "(), " << G4endl
145 << "yHalfLength2=" << yHalfLength2 / cm << "(cm), " << G4endl
146 << "xHalfLength3=" << xHalfLength3 / cm << "(cm), " << G4endl
147 << "xHalfLength4=" << xHalfLength4 / cm << "(cm)." << G4endl
148 << "tanAlpha2 =" << tanAlpha2 << "(), " << G4endl << "(x4-x3)*y1/(x2-x1)/y2="
149 << ( xHalfLength4 - xHalfLength3 ) * yHalfLength1 /
150 ( xHalfLength2 - xHalfLength1 ) / yHalfLength2
151 << G4endl << "tanAlpha2/tanAlpha1=" << tanAlpha2 / tanAlpha1 << G4endl;
152 // G4cout << fStartID << "-->This is an output sentence for debug." << G4endl;
153
154 trackerChamber.SetAllParameters( zHalfLength, thetaAxis, phiAxis, yHalfLength1, xHalfLength1,
155 xHalfLength2, tanAlpha1, yHalfLength2, xHalfLength3,
156 xHalfLength4, tanAlpha2 );
157}
158
159//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
161 G4VPhysicalVolume* pPhysicalVol ) {
162 ComputeIDAndSide( pPhysicalVol );
163 return pPhysicalVol->GetLogicalVolume()->GetSolid();
164}
165
167 G4VPhysicalVolume* pPhysicalVol ) {
168 ComputeIDAndSide( pPhysicalVol );
169 G4int nBSCTheta = fBesEmcGeometry->GetBSCNbTheta();
170 // if(fVerboseLevel>5)
171 // G4cout <<"******ExtBesCrystalParameterisation::ComputeMaterial******"<<G4endl
172 // <<"Number of all crystals=" << nBSCTheta << G4endl
173 // <<"No of current crystal =" << pPhysicalVol->GetCopyNo() << G4endl
174 // <<"*******************************************************"<<G4endl;
175 if ( pPhysicalVol->GetCopyNo() > 2 * nBSCTheta )
178}
179
181 const G4VPhysicalVolume* pPhyVol ) const {
182 // for debug
183 // G4Exception("ExtBesCrystalParameterisation::ComputeIDAndSide() starting......");
184 G4int* pCrystalID = const_cast<G4int*>( &fCrystalID );
185 G4bool* pFlagLeft = const_cast<G4bool*>( &fFlagLeft );
186 G4int* pVerboseLevel = const_cast<G4int*>( &fVerboseLevel );
187
189
190 //*pCrystalID=pPhyVol->GetMotherPhysical()->GetCopyNo();
191 *pCrystalID = -1;
192 for ( G4int i = fStartID; i <= fAllCrystals; i++ )
193 {
194 // G4cout << fBesEmcGeometry->GetPhysiBSCCrystal(i) << ".vs."
195 // << pPhyVol << G4endl;
196 if ( fBesEmcGeometry->GetPhysiBSCCrystal( i ) == pPhyVol ) { *pCrystalID = i; }
197 }
198 if ( *pCrystalID == -1 )
199 {
200 G4cout << "The point of PhysicCrystal error!!!!!!!!!!!" << G4endl;
201 exit( -1 );
202 }
203
204 //*pCrystalID=pPhyVol->GetCopyNo();
205 // if(fVerboseLevel>6)
206 // G4cout<<"******ExtBesCrystalParameterisation::ComputeIDAndSide******"<<G4endl
207 // <<"point of pPhyVol =" << pPhyVol << G4endl
208 // <<"point of mother =" << pPhyVol->GetMother() << G4endl
209 // <<"CopyNo of pPhyVol=" << pPhyVol->GetCopyNo() << G4endl
210 // <<"CopyNo of mother =" << pPhyVol->GetMother()->GetCopyNo() << G4endl
211 // <<"********************************************************"<<G4endl;
212
213 if ( fCrystalID > fAllCrystals / 2 )
214 {
215 *pFlagLeft = false;
216 *pCrystalID = fCrystalID - fAllCrystals / 2;
217 }
218 else
219 {
220 *pFlagLeft = true;
221 *pCrystalID = fAllCrystals / 2 - fCrystalID + 1;
222 }
223 *pCrystalID = *pCrystalID - 1;
224}
const DifPoint origin
ExtBesCrystalParameterisation(const G4int, const G4int, const G4int, ExtBesEmcGeometry *, const G4int)
G4Material * ComputeMaterial(const G4int, G4VPhysicalVolume *)
G4VSolid * ComputeSolid(const G4int, G4VPhysicalVolume *)
void ComputeTransformation(const G4int, G4VPhysicalVolume *) const
void ComputeDimensions(G4Trap &, const G4int, const G4VPhysicalVolume *) const
void ComputeIDAndSide(const G4VPhysicalVolume *) const
static ExtBesEmcConstruction * GetBesEmcConstruction()