BOSS 7.1.1
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 G4cout<<"BOOST environment not set!"<<G4endl;
60 exit(-1);
61 }
62
63 G4String ParaPath1 = ParaPath;
64
65 ParaPath += "/dat/BesEmc.txt";
66 ifstream fin;
67 fin.open(ParaPath);
68 assert(fin);
69
70 const int maxCharOfOneLine=255;
71 char temp[maxCharOfOneLine],*p;
72 int lineNo=0,inputNo=0;
73
74 while(fin.peek()!=EOF)
75 {
76 fin.getline(temp,maxCharOfOneLine);
77 p=temp;
78 lineNo++;
79 while(*p!='\0')
80 {
81 if(*p=='#')
82 {
83 *p='\0'; //delete the comments.
84 break;
85 }
86 p++;
87 }
88 p=temp; //reset the pointer to the beginning of the string.
89 while(*p==' '||*p=='\t')p++;
90 if(*p=='\0')continue;
91 inputNo++;
92 switch(inputNo)
93 {
94 case 1:
95 istrstream(p)>>array_size>>m_tau>>m_highRange>>m_midRange>>m_lowRange>>m_sampleTime>>m_bitNb>>m_photonsPerMeV>>m_nonuniformity>>m_peakTime>>m_timeOffset;
96 break;
97 case 2:
98 istrstream(p)>>WorldRmin1>>WorldRmax1>>WorldRmin2>>WorldRmax2>>WorldDz>>WorldZPosition>>CrystalLength>>CrystalLength1;
99 break;
100 case 3:
101 istrstream(p)>>cryNumInOneLayer[0]>>cryNumInOneLayer[1]>>cryNumInOneLayer[2]>>cryNumInOneLayer[3]>>cryNumInOneLayer[4]>>cryNumInOneLayer[5];
102 break;
103 case 4:
104 istrstream(p)>>pentaInOneSector[0]>>pentaInOneSector[1]>>pentaInOneSector[2]>>pentaInOneSector[3]>>pentaInOneSector[4];
105 break;
106 case 5:
107 istrstream(p)>>fTyvekThickness>>fAlThickness>>fMylarThickness;
108 break;
109 case 6:
110 istrstream(p)>>BSCRmin>>BSCDz>>BSCRmin1>>BSCRmax1>>BSCRmin2>>BSCRmax2>>BSCDz1;
111 break;
112 case 7:
113 istrstream(p)>>BSCAngleRotat>>BSCNbPhi>>BSCNbTheta;
114 break;
115 case 8:
116 istrstream(p)>>BSCYFront0>>BSCYFront>>BSCYFront1>>BSCPosition0>>BSCPosition1;
117 break;
118 case 9:
119 istrstream(p)>>TaperRingDz>>TaperRingThickness1>>TaperRingThickness2>>TaperRingThickness3
120 >>TaperRingTheta>>TaperRingInnerLength>>TaperRingOuterLength;
121 case 10:
122 istrstream(p)>>rearBoxLength>>rearBoxDz>>HangingPlateDz>>OCGirderAngle>>rearCasingThickness;
123 case 11:
124 istrstream(p)>>orgGlassLengthX>>orgGlassLengthY>>orgGlassLengthZ
125 >>PDLengthX>>PDLengthY>>PDLengthZ>>AlPlateDz>>PABoxDz>>PABoxThickness;
126 case 12:
127 istrstream(p)>>cableDr>>waterPipeDr>>waterPipeThickness
128 >>SPBarThickness>>SPBarThickness1>>SPBarwidth>>EndRingDz>>EndRingDr>>EndRingRmin;
129 default:
130 ;
131 }
132 }
133 fin.close();
134
135 ifstream fin1;
136 ParaPath1 += "/dat/EmcLightOutput.dat";
137 fin1.open(ParaPath1);
138 assert(fin1);
139 for(G4int i=0;i<6240;i++) {
140 fin1>>lightOutput[i];
141 }
142 fin1.close();
143}
144
145G4double BesEmcParameter::GetLightOutput(G4int partId, G4int theta, G4int phi)
146{
147 EmcStructure struc;
148 struc.setEmcStruc();
149 G4int index = struc.getGeomIndex(partId,theta,phi);
150 if(index>=0&&index<6240) {
151 return lightOutput[index];
152 } else {
153 return 1.;
154 }
155}
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