BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
BesEmcParameter.cc
Go to the documentation of this file.
1//---------------------------------------------------------------------------//
2// BOOST --- BESIII Object_Oriented Simulation Tool //
3//---------------------------------------------------------------------------//
4/// Description:
5// Author: He Miao
6// Created: Nov,12 2004
7// Modified:
8// Comment:
9//---------------------------------------------------------------------------//
10//$ID: BesEmcParameter.hh
11
12#include "EmcSim/BesEmcParameter.hh"
13#include <fstream>
14#include <strstream>
15// #include "ReadBoostRoot.hh"
16#include "EmcGeneralClass/EmcStructure.h"
17using namespace std;
18
19// Initialize static data member
20BesEmcParameter* BesEmcParameter::fpInstance = 0;
21
23
25
26// static method
27// Access to an instance
29 if ( !Exist() )
30 {
31 fpInstance = new BesEmcParameter;
32 fpInstance->ReadData();
33 }
34 return *fpInstance;
35}
36
37bool BesEmcParameter::Exist() { return fpInstance != 0; }
38
40 if ( Exist() )
41 {
42 delete fpInstance;
43 fpInstance = 0;
44 }
45}
46
48 G4String ParaPath = getenv( "EMCSIMROOT" );
49 if ( !ParaPath )
50 {
51 G4cout << "BOOST environment not set!" << G4endl;
52 exit( -1 );
53 }
54
55 G4String ParaPath1 = ParaPath;
56
57 ParaPath += "/dat/BesEmc.txt";
58 ifstream fin;
59 fin.open( ParaPath );
60 assert( fin );
61
62 const int maxCharOfOneLine = 255;
63 char temp[maxCharOfOneLine], *p;
64 int lineNo = 0, inputNo = 0;
65
66 while ( fin.peek() != EOF )
67 {
68 fin.getline( temp, maxCharOfOneLine );
69 p = temp;
70 lineNo++;
71 while ( *p != '\0' )
72 {
73 if ( *p == '#' )
74 {
75 *p = '\0'; // delete the comments.
76 break;
77 }
78 p++;
79 }
80 p = temp; // reset the pointer to the beginning of the string.
81 while ( *p == ' ' || *p == '\t' ) p++;
82 if ( *p == '\0' ) continue;
83 inputNo++;
84 switch ( inputNo )
85 {
86 case 1:
87 istrstream( p ) >> array_size >> m_tau >> m_highRange >> m_midRange >> m_lowRange >>
88 m_sampleTime >> m_bitNb >> m_photonsPerMeV >> m_nonuniformity >> m_peakTime >>
89 m_timeOffset;
90 break;
91 case 2:
92 istrstream( p ) >> WorldRmin1 >> WorldRmax1 >> WorldRmin2 >> WorldRmax2 >> WorldDz >>
93 WorldZPosition >> CrystalLength >> CrystalLength1;
94 break;
95 case 3:
96 istrstream( p ) >> cryNumInOneLayer[0] >> cryNumInOneLayer[1] >> cryNumInOneLayer[2] >>
97 cryNumInOneLayer[3] >> cryNumInOneLayer[4] >> cryNumInOneLayer[5];
98 break;
99 case 4:
100 istrstream( p ) >> pentaInOneSector[0] >> pentaInOneSector[1] >> pentaInOneSector[2] >>
101 pentaInOneSector[3] >> pentaInOneSector[4];
102 break;
103 case 5: istrstream( p ) >> fTyvekThickness >> fAlThickness >> fMylarThickness; break;
104 case 6:
105 istrstream( p ) >> BSCRmin >> BSCDz >> BSCRmin1 >> BSCRmax1 >> BSCRmin2 >> BSCRmax2 >>
106 BSCDz1;
107 break;
108 case 7: istrstream( p ) >> BSCAngleRotat >> BSCNbPhi >> BSCNbTheta; break;
109 case 8:
110 istrstream( p ) >> BSCYFront0 >> BSCYFront >> BSCYFront1 >> BSCPosition0 >> BSCPosition1;
111 break;
112 case 9:
113 istrstream( p ) >> TaperRingDz >> TaperRingThickness1 >> TaperRingThickness2 >>
114 TaperRingThickness3 >> TaperRingTheta >> TaperRingInnerLength >>
115 TaperRingOuterLength;
116 case 10:
117 istrstream( p ) >> rearBoxLength >> rearBoxDz >> HangingPlateDz >> OCGirderAngle >>
118 rearCasingThickness;
119 case 11:
120 istrstream( p ) >> orgGlassLengthX >> orgGlassLengthY >> orgGlassLengthZ >> PDLengthX >>
121 PDLengthY >> PDLengthZ >> AlPlateDz >> PABoxDz >> PABoxThickness;
122 case 12:
123 istrstream( p ) >> cableDr >> waterPipeDr >> waterPipeThickness >> SPBarThickness >>
124 SPBarThickness1 >> SPBarwidth >> EndRingDz >> EndRingDr >> EndRingRmin;
125 default:;
126 }
127 }
128 fin.close();
129
130 ifstream fin1;
131 ParaPath1 += "/dat/EmcLightOutput.dat";
132 fin1.open( ParaPath1 );
133 assert( fin1 );
134 for ( G4int i = 0; i < 6240; i++ ) { fin1 >> lightOutput[i]; }
135 fin1.close();
136}
137
138G4double BesEmcParameter::GetLightOutput( G4int partId, G4int theta, G4int phi ) {
139 EmcStructure struc;
140 struc.setEmcStruc();
141 G4int index = struc.getGeomIndex( partId, theta, phi );
142 if ( index >= 0 && index < 6240 ) { return lightOutput[index]; }
143 else { return 1.; }
144}
static void Kill()
static BesEmcParameter & GetInstance()
static bool Exist()
int getGeomIndex(unsigned int PartId, unsigned int ThetaIndex, unsigned int PhiIndex) const