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