BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
ExtBesEmcParameter.cxx
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: ExtBesEmcParameter.cxx
11
12#include "ExtBesEmcParameter.h"
13#include "SimUtil/ReadBoostRoot.hh"
14#include <assert.h>
15#include <fstream>
16#include <strstream>
17
18using namespace std;
19
20// Initialize static data member
21ExtBesEmcParameter* ExtBesEmcParameter::fpInstance = 0;
22
24
26
27// static method
28// Access to an instance
30 if ( !Exist() )
31 {
32 fpInstance = new ExtBesEmcParameter;
33 fpInstance->ReadData();
34 }
35 return *fpInstance;
36}
37
38bool ExtBesEmcParameter::Exist() { return fpInstance != 0; }
39
41 if ( Exist() )
42 {
43 delete fpInstance;
44 fpInstance = 0;
45 }
46}
47
49 // G4String ParaPath = ReadBoostRoot::GetBoostRoot();
50 G4String ParaPath = getenv( "SIMUTILDATAROOT" );
51
52 if ( !ParaPath )
53 {
54 G4cout << "BOOST environment not set!" << G4endl;
55 exit( -1 );
56 }
57 ParaPath += "/dat/BesEmc.txt";
58 G4cout << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" << G4endl;
59 G4cout << ParaPath << G4endl;
60 ifstream fin;
61 fin.open( ParaPath );
62 assert( fin );
63
64 const int maxCharOfOneLine = 255;
65 char temp[maxCharOfOneLine], *p;
66 int lineNo = 0, inputNo = 0;
67
68 while ( fin.peek() != EOF )
69 {
70 fin.getline( temp, maxCharOfOneLine );
71 p = temp;
72 lineNo++;
73 while ( *p != '\0' )
74 {
75 if ( *p == '#' )
76 {
77 *p = '\0'; // delete the comments.
78 break;
79 }
80 p++;
81 }
82 p = temp; // reset the pointer to the beginning of the string.
83 while ( *p == ' ' || *p == '\t' ) p++;
84 if ( *p == '\0' ) continue;
85 inputNo++;
86 switch ( inputNo )
87 {
88 case 1:
89 istrstream( p ) >> array_size >> m_tau >> m_highRange >> m_midRange >> m_lowRange >>
90 m_sampleTime >> m_bitNb >> m_photonsPerMeV >> m_nonuniformity >> m_peakTime >>
91 m_timeOffset;
92 break;
93 case 2:
94 istrstream( p ) >> WorldRmin1 >> WorldRmax1 >> WorldRmin2 >> WorldRmax2 >> WorldDz >>
95 WorldZPosition >> CrystalLength;
96 break;
97 case 3:
98 istrstream( p ) >> cryNumInOneLayer[0] >> cryNumInOneLayer[1] >> cryNumInOneLayer[2] >>
99 cryNumInOneLayer[3] >> cryNumInOneLayer[4] >> cryNumInOneLayer[5];
100 break;
101 case 4:
102 istrstream( p ) >> pentaInOneSector[0] >> pentaInOneSector[1] >> pentaInOneSector[2] >>
103 pentaInOneSector[3] >> pentaInOneSector[4];
104 break;
105 case 5: istrstream( p ) >> fTyvekThickness >> fAlThickness >> fMylarThickness; break;
106 case 6:
107 istrstream( p ) >> BSCRmin >> BSCDz >> BSCRmin1 >> BSCRmax1 >> BSCRmin2 >> BSCRmax2 >>
108 BSCDz1;
109 break;
110 case 7: istrstream( p ) >> BSCAngleRotat >> BSCNbPhi >> BSCNbTheta; break;
111 case 8:
112 istrstream( p ) >> BSCYFront0 >> BSCYFront >> BSCYFront1 >> BSCPosition0 >> BSCPosition1;
113 break;
114 case 9:
115 istrstream( p ) >> TaperRingDz >> TaperRingThickness1 >> TaperRingThickness2 >>
116 TaperRingThickness3 >> TaperRingTheta >> TaperRingInnerLength >>
117 TaperRingOuterLength;
118 case 10:
119 istrstream( p ) >> rearBoxLength >> rearBoxDz >> HangingPlateDz >> OCGirderAngle >>
120 rearCasingThickness;
121 case 11:
122 istrstream( p ) >> orgGlassLengthX >> orgGlassLengthY >> orgGlassLengthZ >> PDLengthX >>
123 PDLengthY >> PDLengthZ >> AlPlateDz >> PABoxDz >> PABoxThickness;
124 case 12:
125 istrstream( p ) >> cableDr >> waterPipeDr >> waterPipeThickness >> SPBarThickness >>
126 SPBarThickness1 >> SPBarwidth >> EndRingDz >> EndRingDr >> EndRingRmin;
127 default:;
128 }
129 }
130}
static ExtBesEmcParameter & GetInstance()