BOSS 7.0.6
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcTSF.cxx
Go to the documentation of this file.
1//---------------------------------------------------------------------------//
2//// BOOST --- BESIII Object_Oriented Simulation Tool /
3////
4////---------------------------------------------------------------------------/
5////
6////Description:
7////Author: Caogf
8////Created: Feb, 2006
9////Modified:
10////Comment:
11////
12//
13#include "Trigger/MdcTSF.h"
14
16#include "Identifier/MdcID.h"
17
19#include "RawEvent/DigiEvent.h"
20
21#include <TString.h>
22#include <fstream>
23#include <vector>
24
25using namespace std;
26
27MdcTSF* MdcTSF::mdc_Pointer=0;
29 if(!mdc_Pointer) mdc_Pointer = new MdcTSF();
30 return mdc_Pointer;
31}
32
34{
35 ReadLut();
36 //Dump();
37}
39{
40}
41void MdcTSF::setMdcDigi(std::vector<int>& vmdcHit)
42{
43 std::vector<int> vtmp;
44 vtmp.clear();
45 digiId.clear();
46
47 for(std::vector<int>::iterator iter = vmdcHit.begin(); iter != vmdcHit.end(); iter += 2)
48 {
49 int layer = *iter;
50 int wire = *(iter + 1);
51 if(layer<=19) { vtmp.push_back(layer); vtmp.push_back(wire); }
52 if(layer>=36&&layer<=39)
53 {
54 wire = int(wire/2);//combine neighbor two cells
55 vtmp.push_back(layer);
56 vtmp.push_back(wire);
57 }
58 }
59
60 //remove the same layer, same cell, because of combine in 10 super layer;
61 for(std::vector<int>::iterator iter = vtmp.begin(); iter != vtmp.end(); iter += 2) {
62 bool ifsamelem = false;
63 int layerId = *(iter);
64 int cellId = *(iter+1);
65 for(std::vector<int>::iterator iter_tmp = iter; iter_tmp != vtmp.end(); iter_tmp += 2) {
66 if((iter_tmp+2) != vtmp.end()) {
67 int layerId_tmp = *(iter_tmp+2);
68 int cellId_tmp = *(iter_tmp+3);
69 if((layerId == layerId_tmp) && (cellId == cellId_tmp)) ifsamelem = true;
70 }
71 }
72 if(ifsamelem == false) {
73 digiId.push_back(layerId);
74 digiId.push_back(cellId);
75 // std::cout<<"layer: "<<layerId<<" "<<"wire: "<<cellId<<std::endl;
76 }
77 }
78
79}
81{
82//============================reset each array======================================
83 // super layer one
84 for(int i=0;i<48;i++)
85 {
86 SL1PivotCellHit[i] = 0;
87 SL1TSF[i] = 0;
88 for(int j=0;j<8;j++)
89 {
90 SL1HitCount[i][j] = 0;
91 }
92 }
93 // super layer two
94 for(int i=0;i<80;i++)
95 {
96 SL2PivotCellHit[i] = 0;
97 SL2TSF[i] = 0;
98 for(int j=0;j<12;j++)
99 {
100 SL2HitCount[i][j] = 0;
101 }
102 }
103 // super layer three
104 for(int i=0;i<88;i++)
105 {
106 SL3PivotCellHit[i] = 0;
107 SL3TSF[i] = 0;
108 for(int j=0;j<16;j++)
109 {
110 SL3HitCount[i][j] = 0;
111 }
112 }
113 // super layer four
114 for(int i=0;i<112;i++)
115 {
116 SL4PivotCellHit[i] = 0;
117 SL4TSF[i] = 0;
118 for(int j=0;j<22;j++)
119 {
120 SL4HitCount[i][j] = 0;
121 }
122 }
123 // super layer five
124 for(int i=0;i<128;i++)
125 {
126 SL5PivotCellHit[i] = 0;
127 SL5TSF[i] = 0;
128 for(int j=0;j<31;j++)
129 {
130 SL5HitCount[i][j] = 0;
131 }
132 }
133 // super layer ten
134 for(int i=0;i<128;i++)
135 {
136 SL10PivotCellHit[i] = 0;
137 SL10TSF[i] = 0;
138 for(int j=0;j<81;j++)
139 {
140 SL10HitCount[i][j] = 0;
141 }
142 }
143//=================================== end reset value ===================================
144
145//============ counting the hit number in each super layer for each combination ========
146 int layer,cell,superlayer,ln;
147
148 for(std::vector<int>::iterator iter=digiId.begin();iter!=digiId.end();iter+=2)
149 {
150 layer = *iter;
151 cell = *(iter+1);
152 if(layer<=19)
153 {
154 superlayer = (int) layer/4+1;
155 ln = layer%4;
156 if(superlayer == 1)
157 {
158 if(ln==2) SL1PivotCellHit[cell] = 1;
159 for(unsigned int i = 0;i < SL1.size(); i++)
160 {
161 for(unsigned int j = 0; j < SL1[i].size()/4; j++) {
162 if(SL1[i][3-ln+j*4] == cell+1) SL1HitCount[i][j] += 1;
163 }
164 }
165 } //end super layer1
166
167 if(superlayer == 2)
168 {
169 if(ln==2) SL2PivotCellHit[cell] = 1;
170 for(unsigned int i = 0;i < SL2.size(); i++)
171 {
172 for(unsigned int j = 0; j < SL2[i].size()/4; j++) {
173 if(SL2[i][3-ln+j*4] == cell+1) SL2HitCount[i][j] += 1;
174 }
175 }
176 } //end super layer2
177
178 if(superlayer==3)
179 {
180 if(ln==2) SL3PivotCellHit[cell] = 1;
181 for(unsigned int i = 0;i < SL3.size(); i++)
182 {
183 for(unsigned int j = 0; j < SL3[i].size()/4; j++) {
184 if(SL3[i][3-ln+j*4] == cell+1) SL3HitCount[i][j] += 1;
185 }
186 }
187 } //end super layer3
188
189 if(superlayer==4)
190 {
191 if(ln==2) SL4PivotCellHit[cell] = 1;
192 for(unsigned int i = 0;i < SL4.size(); i++)
193 {
194 for(unsigned int j = 0; j < SL4[i].size()/4; j++) {
195 if(SL4[i][3-ln+j*4] == cell+1) SL4HitCount[i][j] += 1;
196 }
197 }
198 } //end super layer4
199
200 if(superlayer==5)
201 {
202 if(ln==1) SL5PivotCellHit[cell] = 1;
203 for(unsigned int i = 0;i < SL5.size(); i++)
204 {
205 for(unsigned int j = 0; j < SL5[i].size()/4; j++) {
206 if(SL5[i][3-ln+j*4] == cell+1) SL5HitCount[i][j] += 1;
207 }
208 }
209 } //end super layer5
210 }
211 else
212 {
213 superlayer = (int) layer/4+1;
214 ln = layer%4;
215 if(ln==1) SL10PivotCellHit[cell] = 1;
216 for(unsigned int i = 0;i < SL10.size(); i++)
217 {
218 for(unsigned int j = 0; j < SL10[i].size()/4; j++) {
219 if(SL10[i][3-ln+j*4] == cell+1) SL10HitCount[i][j] += 1;
220 }
221 }
222 } //end super layer10
223 }
224}
226{
227 CountTS();
228 // find TSF in each super layer
229 for(int i=0; i<48; i++)
230 for(int j=0; j<8; j++)
231 {
232 if(SL1HitCount[i][j] >= 3) { SL1TSF[i] = 1; break; } //cout<<"SL1 cell id : "<<i<<endl; break; }
233 }
234
235 for(int i=0; i<80; i++)
236 for(int j=0; j<12; j++)
237 {
238 if(SL2HitCount[i][j] >= 3) { SL2TSF[i] = 1; break; } //cout<<"SL2 cell id : "<<i<<endl; break; }
239 }
240
241 for(int i = 0; i < 88; i++)
242 for(int j = 0; j < 16; j++)
243 {
244 if(SL3HitCount[i][j] >= 3) { SL3TSF[i] = 1; break; } //cout<<"SL3: "<<i<<endl; break; }
245 }
246
247 for(int i = 0; i < 112; i++)
248 for(int j = 0; j < 22; j++)
249 {
250 if(SL4HitCount[i][j] >= 3) { SL4TSF[i] = 1; break; } //cout<<"SL4: "<<i<<endl; break; }
251 }
252
253 for(int i = 0; i < 128; i++)
254 for(int j = 0; j < 31; j++)
255 {
256 if(SL5HitCount[i][j] >= 3) { SL5TSF[i] = 1; break; } //cout<<"SL5: "<<i<<endl; break; }
257 }
258
259 for(int i = 0; i < 128; i++)
260 for(int j = 0; j < 81; j++)
261 {
262 if(SL10HitCount[i][j] >= 3) { SL10TSF[i] = 1; break; } //cout<<"SL10 : "<<i<<endl; break; }
263 }
264
265 // combine the continuous TSF
266
267
268
269}
270
272{
273 fstream readin;
274 int ncell=0,pl=0;
275 int a,b,l4,l3,l2,l1;
276 SL1.clear();
277 SL2.clear();
278 SL3.clear();
279 SL4.clear();
280 SL5.clear();
281 SL10.clear();
282 for(int n=1;n<6;n++)
283 {
284 if(n==1) { ncell=48; pl=3; }
285 if(n==2) { ncell=80; pl=7; }
286 if(n==3) { ncell=88; pl=11; }
287 if(n==4) { ncell=112; pl=15; }
288 if(n==5) { ncell=128; pl=18; }
289
290 for(int i=1;i<(ncell+1);i++)
291 {
292 std::vector<int> tmp;
293 tmp.clear();
294 int num=0;
295 TString filename = TString(getenv( "TRIGGERROOT" ));
296 filename+="/data/tsf";
297 filename+=n;
298 filename+="/TSF-SL";
299 filename+=n;
300 filename+="-L";
301 filename+=pl;
302 filename+="-C";
303 filename+=i;
304 filename+=".pat";
305 readin.clear();
306 readin.open(filename,ios_base::in);
307 if(!readin) cerr<<"can not open the file "<<filename<<endl;
308 while(readin.good())
309 {
310 readin>>a>>b>>l4>>l3>>l2>>l1;
311 num++;
312 }
313 readin.close();
314 readin.clear();
315 readin.open(filename,ios_base::in);
316 if(!readin) cerr<<"can not open the file again "<<filename<<endl;
317 for(int j=0;j<(num-1);j++)
318 {
319 readin>>a>>b>>l4>>l3>>l2>>l1;
320 tmp.push_back(l4);
321 tmp.push_back(l3);
322 tmp.push_back(l2);
323 tmp.push_back(l1);
324 }
325 readin.close();
326 if(n==1) SL1.push_back(tmp);
327 if(n==2) SL2.push_back(tmp);
328 if(n==3) SL3.push_back(tmp);
329 if(n==4) SL4.push_back(tmp);
330 if(n==5) SL5.push_back(tmp);
331 }
332 }
333 for(int i=1;i<129;i++)
334 {
335 std::vector<int> tmp1;
336 tmp1.clear();
337 int num=0;
338 //TString filename = "/ihepbatch/bes/caogf/data/tsf/tsf10C/TSF-SL10C-L38-C";
339 TString filename = TString(getenv( "TRIGGERROOT" ));
340 filename+="/data/tsf10C/TSF-SL10C-L38-C";
341 filename+=i;
342 filename+=".pat";
343 readin.clear();
344 readin.open(filename,ios_base::in);
345 if(!readin) cerr<<"can not open the file "<<filename<<endl;
346 while(readin.good())
347 {
348 readin>>a>>b>>l4>>l3>>l2>>l1;
349 num++;
350 }
351 readin.close();
352 readin.clear();
353 readin.open(filename,ios_base::in);
354 if(!readin) cerr<<"can not open the file again "<<filename<<endl;
355
356 for(int j=0;j<(num-1);j++)
357 {
358 readin>>a>>b>>l4>>l3>>l2>>l1;
359 tmp1.push_back(l4);
360 tmp1.push_back(l3);
361 tmp1.push_back(l2);
362 tmp1.push_back(l1);
363 }
364 readin.close();
365 SL10.push_back(tmp1);
366 }
367}
369{
370 std::vector<int> combine_size;
371 cout<<endl;
372 cout<<" ***************check data file tsf: ***************** "<<endl;
373 cout<<"*--------------------------BEGIN-------------------------------*"<<endl;
374 cout<<endl;
375
376 cout<<" -------------------SL1---------------------- "<<endl;
377 combine_size.clear();
378 for(unsigned int i=0; i<SL1.size(); i++) {
379 cout<<"Cell ID --> "<<i<<endl;
380 combine_size.push_back(SL1[i].size());
381 for(unsigned int j=0; j<SL1[i].size(); j++) {
382 cout<<SL1[i][j]<<" ";
383 if((j+1)%4==0) cout<<endl;
384 }
385 cout<<endl;
386 }
387 sort(combine_size.begin(),combine_size.end());
388 cout<<"The Max Number of Combination is "<<combine_size[combine_size.size()-1]/4<<endl;
389 cout<<endl;
390
391 cout<<" -------------------SL2---------------------- "<<endl;
392 combine_size.clear();
393 for(unsigned int i=0; i<SL2.size(); i++) {
394 cout<<"Cell ID --> "<<i<<endl;
395 combine_size.push_back(SL2[i].size());
396 for(unsigned int j=0; j<SL2[i].size(); j++) {
397 cout<<SL2[i][j]<<" ";
398 if((j+1)%4==0) cout<<endl;
399 }
400 cout<<endl;
401 }
402 sort(combine_size.begin(),combine_size.end());
403 cout<<"The Max Number of Combination is "<<combine_size[combine_size.size()-1]/4<<endl;
404 cout<<endl;
405
406 cout<<" -------------------SL3---------------------- "<<endl;
407 combine_size.clear();
408 for(unsigned int i=0; i<SL3.size(); i++) {
409 cout<<"Cell ID --> "<<i<<endl;
410 combine_size.push_back(SL3[i].size());
411 for(unsigned int j=0; j<SL3[i].size(); j++) {
412 cout<<SL3[i][j]<<" ";
413 if((j+1)%4==0) cout<<endl;
414 }
415 cout<<endl;
416 }
417 sort(combine_size.begin(),combine_size.end());
418 cout<<"The Max Number of Combination is "<<combine_size[combine_size.size()-1]/4<<endl;
419 cout<<endl;
420
421 cout<<" -------------------SL4---------------------- "<<endl;
422 combine_size.clear();
423 for(unsigned int i=0; i<SL4.size(); i++) {
424 cout<<"Cell ID --> "<<i<<endl;
425 combine_size.push_back(SL4[i].size());
426 for(unsigned int j=0; j<SL4[i].size(); j++) {
427 cout<<SL4[i][j]<<" ";
428 if((j+1)%4==0) cout<<endl;
429 }
430 cout<<endl;
431 }
432 sort(combine_size.begin(),combine_size.end());
433 cout<<"The Max Number of Combination is "<<combine_size[combine_size.size()-1]/4<<endl;
434 cout<<endl;
435
436 cout<<" -------------------SL5---------------------- "<<endl;
437 combine_size.clear();
438 for(unsigned int i=0; i<SL5.size(); i++) {
439 cout<<"Cell ID --> "<<i<<endl;
440 combine_size.push_back(SL5[i].size());
441 for(unsigned int j=0; j<SL5[i].size(); j++) {
442 cout<<SL5[i][j]<<" ";
443 if((j+1)%4==0) cout<<endl;
444 }
445 cout<<endl;
446 }
447 sort(combine_size.begin(),combine_size.end());
448 cout<<"The Max Number of Combination is "<<combine_size[combine_size.size()-1]/4<<endl;
449 cout<<endl;
450
451 cout<<" -------------------SL10---------------------- "<<endl;
452 combine_size.clear();
453 for(unsigned int i=0; i<SL10.size(); i++) {
454 cout<<"Cell ID --> "<<i<<endl;
455 combine_size.push_back(SL10[i].size());
456 for(unsigned int j=0; j<SL10[i].size(); j++) {
457 cout<<SL10[i][j]<<" ";
458 if((j+1)%4==0) cout<<endl;
459 }
460 cout<<endl;
461 }
462 sort(combine_size.begin(),combine_size.end());
463 cout<<"The Max Number of Combination is "<<combine_size[combine_size.size()-1]/4<<endl;
464 cout<<endl;
465
466 cout<<"*---------------------------END------------------------------*"<<endl;
467}
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
Definition: MdcTSF.h:6
void CountTS()
Definition: MdcTSF.cxx:80
MdcTSF()
Definition: MdcTSF.cxx:33
void GetTS()
Definition: MdcTSF.cxx:225
static MdcTSF * get_Mdc(void)
Definition: MdcTSF.cxx:28
void setMdcDigi(std::vector< int > &vmdcHit)
Definition: MdcTSF.cxx:41
~MdcTSF()
Definition: MdcTSF.cxx:38
void Dump()
Definition: MdcTSF.cxx:368
void ReadLut()
Definition: MdcTSF.cxx:271
const double b
Definition: slope.cxx:9