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