BOSS 7.1.2
BESIII Offline Software System
Loading...
Searching...
No Matches
getConstants.cxx
Go to the documentation of this file.
2 gROOT->Reset();
3 gROOT->SetStyle("Plain");
4 gStyle->SetOptStat(00000);
5
6 const unsigned int barScin = 176;
7 const unsigned int endScin = 96;
8 const unsigned int barEnd = 2;
9
10 const unsigned int crateNum = 2;
11 const unsigned int crate[crateNum] = { 64, 65 };
12 const unsigned int boardNum = 14;
13 unsigned int board[boardNum];
14 for( unsigned int i=0; i<boardNum; i++ ) {
15 board[i] = i+1;
16 }
17 const unsigned int channelNum = 16;
18 const unsigned int paramNum = 8;
19 double param[crateNum][boardNum][channelNum][paramNum];
20
21 unsigned int ifee[crateNum][boardNum][channelNum];
22 unsigned int icrate[crateNum][boardNum][channelNum];
23 unsigned int iboard[crateNum][boardNum][channelNum];
24 unsigned int ichannel[crateNum][boardNum][channelNum];
25 ifstream inData[crateNum][boardNum];
26 char inFile[crateNum][boardNum][1000];
27
28 char kind[10]=".txt";
29 // char kind[100]="-Curve.txt";
30
31 ofstream outData1, outData2, outData3;
32 char outFile1[800], outFile2[800], outFile3[800];
33 sprintf( outFile1, "ElecBarEast%s", kind );
34 sprintf( outFile2, "ElecBarWest%s", kind );
35 sprintf( outFile3, "ElecEndcap%s", kind );
36
37
38 for( unsigned int i=0; i<crateNum; i++ ) {
39 for( unsigned int j=0; j<boardNum; j++ ) {
40
41 sprintf( inFile[i][j], "/ihepbatch/besd09/sunss/Electronics/09summer/Data/Crate%i/Board%i/Crate%i-Board%i%s", crate[i], board[j], crate[i], board[j],kind );
42 cout << inFile[i][j] << endl;
43 inData[i][j].open( inFile[i][j] );
44 for( unsigned int k=0; k<channelNum; k++ ) {
45 inData[i][j] >> ifee[i][j][k] >> icrate[i][j][k] >> iboard[i][j][k] >> ichannel[i][j][k];
46 for( unsigned int l=0; l<paramNum; l++ ) {
47 inData[i][j] >> param[i][j][k][l];
48 }
49 }
50 inData[i][j].close();
51 }
52 }
53
54 int be[crateNum][boardNum][channelNum];
55 int counter[crateNum][boardNum][channelNum];
56 int end[crateNum][boardNum][channelNum];
57 for( unsigned int i=0; i<crateNum; i++ ) {
58 for( unsigned int j=0; j<boardNum; j++ ) {
59 for( unsigned int k=0; k<channelNum; k++ ) {
60 if( j<3 ) {
61 be[i][j][k] = 0;
62 end[i][j][k] = 0;
63 if( i==0 ) {
64 if( j==0 ) {
65 counter[i][j][k] = k;
66 }
67 else if( j==1 ) {
68 if( k<channelNum/2 ) { // 8
69 counter[i][j][k] = k+channelNum; // 16
70 }
71 else {
72 counter[i][j][k] = k-channelNum/2+48; // 8
73 }
74 }
75 else if( j==2 ) {
76 counter[i][j][k] = k+channelNum/2+48; // 8
77 }
78 }
79 else if( i==1 ) {
80 if( j==0 ) {
81 counter[i][j][k] = k+channelNum+channelNum/2; // 24
82 }
83 else if( j==1 ) {
84 if( k<channelNum/2 ) { // 8
85 counter[i][j][k] = k+channelNum*2+channelNum/2; // 40
86 }
87 else {
88 counter[i][j][k] = k+channelNum+48; // 16
89 }
90 }
91 else if( j==2 ) {
92 counter[i][j][k] = k+channelNum*2+48; // 32
93 }
94 }
95 }
96 else {
97 be[i][j][k] = 1;
98 if( (k%2)==0 ) {
99 end[i][j][k] = 0; // east
100 }
101 else {
102 end[i][j][k] = 1; // west
103 }
104 if( i==0 ) {
105 if( (k%4)<2 ) {
106 counter[i][j][k] = (j-3)*channelNum/4+k/4; // (j-3)*4+1/4
107 }
108 else {
109 counter[i][j][k] = (j-3)*channelNum/4+k/4+88; // (j-3)*4+1/4
110 }
111 }
112 else if( i==1 ) {
113 if( (k%4)<2 ) {
114 counter[i][j][k] = (boardNum-3+j-3)*channelNum/4+k/4;
115 }
116 else {
117 counter[i][j][k] = (boardNum-3+j-3)*channelNum/4+k/4+88;
118 }
119 }
120 }
121 // cout << i << " " << j << " " << k << " " << be[i][j][k] << " " << counter[i][j][k] << " " << end[i][j][k] << endl;
122 }
123 }
124 }
125
126 for( unsigned int i=0; i<crateNum; i++ ) {
127 for( unsigned int j=0; j<boardNum; j++ ) {
128 for( unsigned int k=0; k<channelNum; k++ ) {
129 if( be[i][j][k] == 0 ) {
130 counter[i][j][k] = counter[i][j][k] - 12;
131 if( counter[i][j][k]<0 || ( counter[i][j][k]>=36 && counter[i][j][k]<48 ) ) {
132 counter[i][j][k] = counter[i][j][k] + 48;
133 }
134 }
135 else {
136 counter[i][j][k] = counter[i][j][k] - 11;
137 if( counter[i][j][k]<0 || ( counter[i][j][k]>=77 && counter[i][j][k]<88 ) ) {
138 counter[i][j][k] = counter[i][j][k] + 88;
139 }
140 }
141 // cout << i << " " << j << " " << k << " " << be[i][j][k] << " " << counter[i][j][k] << " " << end[i][j][k] << endl;
142 }
143 }
144 }
145
146
147 for( unsigned int i=0; i<crateNum; i++ ) {
148 for( unsigned int j=0; j<boardNum; j++ ) {
149 for( unsigned int k=0; k<channelNum; k++ ) {
150 if( i==0 ) {
151 icrate[i][j][k] = 64;
152 }
153 else {
154 icrate[i][j][k] = 65;
155 }
156 iboard[i][j][k] = j+1;
157 ichannel[i][j][k] = k+1;
158 }
159 }
160 }
161
162 unsigned int Fee[barScin][barEnd], ecFee[endScin];
163 unsigned int Crate[barScin][barEnd], ecCrate[endScin];
164 unsigned int Board[barScin][barEnd], ecBoard[endScin];
165 unsigned int Channel[barScin][barEnd], ecChannel[endScin];
166 double pbeast[barScin][paramNum], pbwest[barScin][paramNum];
167 double pendcap[endScin][paramNum],;
168 for( unsigned int i=0; i<crateNum; i++ ) {
169 for( unsigned int j=0; j<boardNum; j++ ) {
170 for( unsigned int k=0; k<channelNum; k++ ) {
171 if( be[i][j][k]==1 ) {
172 if( end[i][j][k]==0 ) {
173 Fee[counter[i][j][k]][0] = ifee[i][j][k];
174 Crate[counter[i][j][k]][0] = icrate[i][j][k];
175 Board[counter[i][j][k]][0] = iboard[i][j][k];
176 Channel[counter[i][j][k]][0] = ichannel[i][j][k];
177 for( unsigned int l=0; l<paramNum; l++ ) {
178 pbeast[counter[i][j][k]][l] = param[i][j][k][l];
179 }
180 }
181 else{
182 Fee[counter[i][j][k]][1] = ifee[i][j][k];
183 Crate[counter[i][j][k]][1] = icrate[i][j][k];
184 Board[counter[i][j][k]][1] = iboard[i][j][k];
185 Channel[counter[i][j][k]][1] = ichannel[i][j][k];
186 for( unsigned int l=0; l<paramNum; l++ ) {
187 pbwest[counter[i][j][k]][l] = param[i][j][k][l];
188 }
189 }
190 }
191 else {
192 ecFee[counter[i][j][k]] = ifee[i][j][k];
193 ecCrate[counter[i][j][k]] = icrate[i][j][k];
194 ecBoard[counter[i][j][k]] = iboard[i][j][k];
195 ecChannel[counter[i][j][k]] = ichannel[i][j][k];
196 for( unsigned int l=0; l<paramNum; l++ ) {
197 pendcap[counter[i][j][k]][l] = param[i][j][k][l];
198 }
199 }
200 }
201 }
202 }
203
204 double bRatio[2][barScin], eRatio[endScin];
205 ifstream inRatio1, inRatio2, inRatio3;
206 inRatio1.open( "BEastRatio.txt" );
207 inRatio2.open( "BWestRatio.txt" );
208 for( unsigned int i=0; i<barScin; i++ ) {
209 inRatio1 >> bRatio[0][i];
210 inRatio2 >> bRatio[1][i];
211 }
212 inRatio1.close();
213 inRatio2.close();
214 inRatio3.open( "EndRatio.txt" );
215 for( unsigned int i=0; i<endScin; i++ ) {
216 inRatio3 >> eRatio[i];
217 }
218 inRatio3.close();
219
220 outData1.open( outFile1 );
221 outData2.open( outFile2 );
222 for( unsigned int i=0; i<barScin; i++ ) {
223 if( paramNum == 8 ) {
224 outData1 << Fee[i][0] << " " << Crate[i][0] << " " << Board[i][0] << " " << Channel[i][0] << " ";
225 outData2 << Fee[i][1] << " " << Crate[i][1] << " " << Board[i][1] << " " << Channel[i][1] << " ";
226 }
227 outData1 << bRatio[0][i];
228 outData2 << bRatio[1][i];
229 for( unsigned int l=0; l<paramNum; l++ ) {
230 outData1 << " " << pbeast[i][l];
231 outData2 << " " << pbwest[i][l];
232 }
233 outData1 << endl;
234 outData2 << endl;
235 }
236 outData1.close();
237 outData2.close();
238
239 outData3.open( outFile3 );
240 for( unsigned int i=0; i<endScin; i++ ) {
241 if( paramNum == 8 ) {
242 outData3 << ecFee[i] << " " << ecCrate[i] << " " << ecBoard[i] << " " << ecChannel[i] << " ";
243 }
244 outData3 << eRatio[i];
245 for( unsigned int l=0; l<paramNum; l++ ) {
246 outData3 << " " << pendcap[i][l];
247 }
248 outData3 << endl;
249 }
250 outData3.close();
251
252 return;
253}
sprintf(cut,"kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)
void getConstants()