BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
EmcCCount.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/EmcCCount.h"
14#include <iostream>
15
16#include "Trigger/IBesGlobalTrigSvc.h"
17#include "Trigger/BesGlobalTrigSvc.h"
18#include "GaudiKernel/ISvcLocator.h"
19#include "GaudiKernel/Bootstrap.h"
20#include "GaudiKernel/IDataProviderSvc.h"
21#include "CLHEP/Random/RandGauss.h"
22
23#include <map>
24#include <vector>
25#include <complex>
26
27using namespace std;
28
30{
31 m_EmcTCFinder = EmcTCFinder::get_Emc();
32}
34{
35}
37{
38 //reset values
39 EClus_Z = false;
40 WClus_Z = false;
41 //barrel
42 for(int j=0;j<TrigConf::TCPHINO_B;j++)
43 {
44 BClusterPhi[j] = 0;
45 for(int i=0;i<TrigConf::TCTHETANO_B;i++)
46 {
47 BClusterId[i][j] = 0;
48 }
49 }
50 //endcaps
51 for(int j =0;j<TrigConf::TCPHINO_E/2;j++)
52 {
53 if(j < TrigConf::TCPHINO_E/2) {
54 WEClusterPhi[j] = 0;
55 EEClusterPhi[j] = 0;
56 }
57 for(int i =0;i<TrigConf::TCTHETANO_E;i++)
58 {
59 EEClusterId[i][j] = 0;
60 WEClusterId[i][j] = 0;
61 }
62 }
63
64 std::vector<double> emcClusE;
65 emcClusE.clear();
66
67 for(int i=0;i<TrigConf::TCTHETANO_B;i++)
68 for(int j=0;j<TrigConf::TCPHINO_B;j++)
69 {
70 ///Find cluster position in barral
71 if(findCluster(1,i,j))
72 {
73 BClusterId[i][j] = 1;
74 //check cluster z balance for charge track
75 int block_phi = int (j/5);
76 if(((block_phi%2 == 0) && i > 5) || ((block_phi%2 == 1) && i > 4)) WClus_Z = true;
77 else EClus_Z = true;
78 emcClusE.push_back(m_EmcTCFinder->getBTCEnergy(i,j));
79 }
80 }
81 //Find cluster position in endcap
82 for(int i =0;i<TrigConf::TCTHETANO_E;i++)
83 for(int j =0;j<TrigConf::TCPHINO_E/2;j++)
84 {
85 if(findCluster(0,i,j)) { EEClusterId[i][j] = 1; EClus_Z = true; emcClusE.push_back(m_EmcTCFinder->getEETCEnergy(i,j)); }
86 if(findCluster(2,i,j)) { WEClusterId[i][j] = 1; WClus_Z = true; emcClusE.push_back(m_EmcTCFinder->getWETCEnergy(i,j)); }
87 }
88 //Find phi position of cluster in barrel
89 for(int j = 0;j<TrigConf::TCPHINO_B;j++)
90 for(int i =0;i<TrigConf::TCTHETANO_B;i++)
91 {
92 if(BClusterId[i][j]==1)
93 {
94 BClusterPhi[j] = 1;
95 break;
96 }
97 }
98 //Find phi position of cluster in west endcap
99 for(int j =0;j<TrigConf::TCPHINO_E/2;j++)
100 for(int i =0;i<TrigConf::TCTHETANO_E;i++)
101 {
102 if(WEClusterId[i][j] == 1)
103 {
104 WEClusterPhi[j] = 1;
105 }
106 }
107 //Find phi position of cluster in east endcap
108 for(int j =0;j<TrigConf::TCPHINO_E/2;j++)
109 for(int i =0;i<TrigConf::TCTHETANO_E;i++)
110 {
111 if(EEClusterId[i][j] == 1)
112 {
113 EEClusterPhi[j] = 1;
114 }
115 }
116 // for(int i=0;i<TrigConf::TCPHINO_E/2;i++) cout<<"ClusterId output "<<EEClusterPhi[i]<<" "<<WEClusterPhi[i]<<endl;
117
118 //set number of cluster in barrel and endcaps for service
119 int nbCluster = 0, neeCluster = 0, nweCluster = 0;
120
121 map<int,vector<complex<int> >, greater<int> > mClusId;
122 std::vector<complex<int> > vClusIdBR;
123 std::vector<complex<int> > vClusIdEE;
124 std::vector<complex<int> > vClusIdWE;
125 typedef pair<int, vector<complex<int> > > vpair;
126 vClusIdBR.clear();
127 vClusIdEE.clear();
128 vClusIdWE.clear();
129 mClusId.clear();
130
131 for(int i=0;i<TrigConf::TCTHETANO_B;i++)
132 for(int j=0;j<TrigConf::TCPHINO_B;j++)
133 {
134 int BClusId = BClusterId[i][j];
135 if(BClusId == 1) {
136 nbCluster++;
137 complex<int> clusId(i,j);
138 vClusIdBR.push_back(clusId);
139 }
140 }
141 for(int i=0; i<TrigConf::TCTHETANO_E; i++)
142 for(int j=0; j<TrigConf::TCPHINO_E/2; j++)
143 {
144 if(EEClusterPhi[j]) {
145 neeCluster++;
146 complex<int> clusId(i,j);
147 vClusIdEE.push_back(clusId);
148 }
149 if(WEClusterPhi[j]) {
150 nweCluster++;
151 complex<int> clusId(i,j);
152 vClusIdWE.push_back(clusId);
153 }
154 }
155
156 mClusId.insert(vpair(1,vClusIdBR));
157 mClusId.insert(vpair(0,vClusIdEE));
158 mClusId.insert(vpair(2,vClusIdWE));
159
160 ISvcLocator* svcLocator = Gaudi::svcLocator();
161 StatusCode sc = svcLocator->service("BesGlobalTrigSvc", m_tmpSvc);
162 m_pIBGT = dynamic_cast<BesGlobalTrigSvc* >(m_tmpSvc);
163
164 m_pIBGT->setEmcNbCluster(nbCluster);
165 m_pIBGT->setEmcNweCluster(nweCluster);
166 m_pIBGT->setEmcNeeCluster(neeCluster);
167 m_pIBGT->setEmcClusId(mClusId);
168 m_pIBGT->setEmcClusE(emcClusE);
169}
170
171bool EmcCCount::findCluster(int partId,int TCThetaNb,int TCPhiNb)
172{
173 //double L1TC_THRESH = m_pIBGT->getL1TC_THRESH();
174 /*for(int i = 0; ; i++) {
175 double theshold = RandGauss::shoot(m_pIBGT->getL1TC_THRESH(),3.3);
176 if(theshold < m_pIBGT->getL1TC_THRESH()) {
177 L1TC_THRESH = theshold;
178 break;
179 }
180 }*/
181
182 //double energy0,energy1,energy2,energy3,energy4,energy5,energy6,energy7,energy8;
183 int clus0,clus1,clus3,clus4,clus8;
184 /* if(partId==1)
185 {
186// Cluster Finder Logic
187// Phi--->
188// |---|----|----|
189// | 5 | 1 | 6 |
190// |---|----|----|
191// | 2 | 0 | 3 |
192// |---|----|----| ^
193// | 7 | 4 | 8 | |
194// |---|----|----| Theta
195 energy0 = m_EmcTCFinder->getBTCEnergy(TCThetaNb,TCPhiNb);
196 if(energy0>L1TC_THRESH)
197 {
198 //trigger cell index from 0, not 1, so TrigConf::TCTHETANO_B - 1 or TrigConf::TCPHINO_B - 1 needed
199 if(TCThetaNb!=(TrigConf::TCTHETANO_B-1)) energy1 = m_EmcTCFinder->getBTCEnergy(TCThetaNb+1,TCPhiNb);
200 else energy1 = 0.0;
201
202 if(TCPhiNb!=0) energy2 = m_EmcTCFinder->getBTCEnergy(TCThetaNb,TCPhiNb-1);
203 else energy2 = m_EmcTCFinder->getBTCEnergy(TCThetaNb,TrigConf::TCPHINO_B-1);
204
205 if(TCPhiNb!=(TrigConf::TCPHINO_B-1)) energy3 = m_EmcTCFinder->getBTCEnergy(TCThetaNb,TCPhiNb+1);
206 else energy3 = m_EmcTCFinder->getBTCEnergy(TCThetaNb,0);
207
208 if(TCThetaNb!=0) energy4 = m_EmcTCFinder->getBTCEnergy(TCThetaNb-1,TCPhiNb);
209 else energy4 = 0.0;
210
211 if(TCThetaNb!=(TrigConf::TCTHETANO_B-1)&&TCPhiNb!=0) energy5 = m_EmcTCFinder->getBTCEnergy(TCThetaNb+1,TCPhiNb-1);
212 if(TCThetaNb==(TrigConf::TCTHETANO_B-1)) energy5 = 0.0;
213 if(TCThetaNb!=(TrigConf::TCTHETANO_B-1)&&TCPhiNb==0) energy5 = m_EmcTCFinder->getBTCEnergy(TCThetaNb+1,TrigConf::TCPHINO_B-1);
214
215 if(TCThetaNb!=(TrigConf::TCTHETANO_B-1)&&TCPhiNb!=(TrigConf::TCPHINO_B-1)) energy6 = m_EmcTCFinder->getBTCEnergy(TCThetaNb+1,TCPhiNb+1);
216 if(TCThetaNb==(TrigConf::TCTHETANO_B-1)) energy6 = 0.0;
217 if(TCThetaNb!=(TrigConf::TCTHETANO_B-1)&&TCPhiNb==(TrigConf::TCPHINO_B-1)) energy6 = m_EmcTCFinder->getBTCEnergy(TCThetaNb+1,0);
218
219 if(TCThetaNb!=0&&TCPhiNb!=0) energy7 = m_EmcTCFinder->getBTCEnergy(TCThetaNb-1,TCPhiNb-1);
220 if(TCThetaNb==0) energy7=0;
221 if(TCThetaNb!=0&&TCPhiNb==0) energy7 = m_EmcTCFinder->getBTCEnergy(TCThetaNb-1,TrigConf::TCPHINO_B-1);
222
223 if(TCThetaNb!=0&&TCPhiNb!=(TrigConf::TCPHINO_B-1)) energy8 = m_EmcTCFinder->getBTCEnergy(TCThetaNb-1,TCPhiNb+1);
224 if(TCThetaNb==0) energy8 = 0.0;
225 if(TCThetaNb!=0&&TCPhiNb==(TrigConf::TCPHINO_B-1)) energy8 = m_EmcTCFinder->getBTCEnergy(TCThetaNb-1,0);
226
227 if((energy3>=L1TC_THRESH)||(energy1>=L1TC_THRESH)||((energy4>=L1TC_THRESH)&&(energy8>=L1TC_THRESH)))
228 {
229 return false;
230 }
231 else return true;
232 }
233 else return false;
234 }*/
235 if(partId==1)
236 {
237// Cluster Finder Logic
238// <---Theta
239// |---|----|----|
240// | 5 | 1 | 6 |
241// |---|----|----|
242// | 2 | 0 | 3 | Phi
243// |---|----|----| |
244// | 7 | 4 | 8 | |
245// |---|----|----| ^
246 clus0 = m_EmcTCFinder->getBTC(TCThetaNb,TCPhiNb);
247 if(clus0 > 0)
248 {
249 //trigger cell index from 0, not 1, so TrigConf::TCTHETANO_B - 1 or TrigConf::TCPHINO_B - 1 needed
250 if(TCPhiNb != 0) clus1 = m_EmcTCFinder->getBTC(TCThetaNb,TCPhiNb - 1);
251 else clus1 = m_EmcTCFinder->getBTC(TCThetaNb,TrigConf::TCPHINO_B-1);
252
253// if(TCPhiNb!=0) clus2 = m_EmcTCFinder->getBTC(TCThetaNb,TCPhiNb-1);
254// else clus2 = m_EmcTCFinder->getBTC(TCThetaNb,TrigConf::TCPHINO_B-1);
255
256 if(TCThetaNb!=0) clus3 = m_EmcTCFinder->getBTC(TCThetaNb - 1,TCPhiNb);
257 else clus3 = 0;
258
259 if(TCPhiNb!=(TrigConf::TCPHINO_B-1)) clus4 = m_EmcTCFinder->getBTC(TCThetaNb,TCPhiNb+1);
260 else clus4 = m_EmcTCFinder->getBTC(TCThetaNb,0);
261
262// if(TCThetaNb!=(TrigConf::TCTHETANO_B-1)&&TCPhiNb!=0) clus5 = m_EmcTCFinder->getBTC(TCThetaNb+1,TCPhiNb-1);
263// if(TCThetaNb==(TrigConf::TCTHETANO_B-1)) clus5 = 0;
264// if(TCThetaNb!=(TrigConf::TCTHETANO_B-1)&&TCPhiNb==0) clus5 = m_EmcTCFinder->getBTC(TCThetaNb+1,TrigConf::TCPHINO_B-1);
265
266// if(TCThetaNb!=(TrigConf::TCTHETANO_B-1)&&TCPhiNb!=(TrigConf::TCPHINO_B-1)) clus6 = m_EmcTCFinder->getBTC(TCThetaNb+1,TCPhiNb+1);
267// if(TCThetaNb==(TrigConf::TCTHETANO_B-1)) clus6 = 0;
268// if(TCThetaNb!=(TrigConf::TCTHETANO_B-1)&&TCPhiNb==(TrigConf::TCPHINO_B-1)) clus6 = m_EmcTCFinder->getBTC(TCThetaNb+1,0);
269
270// if(TCThetaNb!=0&&TCPhiNb!=0) clus7 = m_EmcTCFinder->getBTC(TCThetaNb-1,TCPhiNb-1);
271// if(TCThetaNb==0) clus7 = 0;
272// if(TCThetaNb!=0&&TCPhiNb==0) clus7 = m_EmcTCFinder->getBTC(TCThetaNb-1,TrigConf::TCPHINO_B-1);
273
274 if(TCThetaNb!=0&&TCPhiNb!=(TrigConf::TCPHINO_B-1)) clus8 = m_EmcTCFinder->getBTC(TCThetaNb-1,TCPhiNb+1);
275 if(TCThetaNb==0) clus8 = 1;
276 if(TCThetaNb!=0&&TCPhiNb==(TrigConf::TCPHINO_B-1)) clus8 = m_EmcTCFinder->getBTC(TCThetaNb-1,0);
277
278 //if((clus3 > 0)||(clus1 > 0)||((clus4 > 0)&&(clus8 > 0)))
279 if(!((clus3 > 0)||(clus1 > 0)) && !((clus4 > 0)&&(clus8 > 0)))
280 {
281 return true;
282 }
283 else return false;
284 }
285 else return false;
286 }
287 //------------------------------------------------------------------------------------
288/* Cluster Finder Logic (1)
289 <---phi
290 |---|
291 | 1 |
292 |---|---| /|\
293 | 0 | 2 | |
294 |---|---| theta
295 if(partId==0)
296 {
297 if(TCThetaNb==0)
298 {
299 energy0 = m_EmcTCFinder->GetEETCEnergy(TCThetaNb,TCPhiNb);
300 energy1 = m_EmcTCFinder->GetEETCEnergy(TCThetaNb+1,TCPhiNb);
301 if(TCPhiNb!=0) energy2 =m_EmcTCFinder->GetEETCEnergy(TCThetaNb,TCPhiNb-1);
302 else energy2 = m_EmcTCFinder->GetEETCEnergy(TCThetaNb,TrigConf::TCPHINO_E-1);
303 if((energy0>=L1TC_THRESH)&&(energy1<L1TC_THRESH)&&(energy2<L1TC_THRESH)) return true;
304 else return false;
305 }
306 if(TCThetaNb==(TrigConf::TCTHETANO_E-1))
307 {
308 energy0 = m_EmcTCFinder->GetEETCEnergy(TCThetaNb,TCPhiNb);
309 if(TCPhiNb!=0) energy1 = m_EmcTCFinder->GetEETCEnergy(TCThetaNb,TCPhiNb-1);
310 else energy1 = m_EmcTCFinder->GetEETCEnergy(TCThetaNb,TrigConf::TCPHINO_E-1);
311 if((energy0>=L1TC_THRESH)&&(energy1<L1TC_THRESH)) return true;
312 else return false;
313 }
314 }
315 if(partId==2)
316 {
317 if(TCThetaNb==0)
318 {
319 energy0 = m_EmcTCFinder->GetWETCEnergy(TCThetaNb,TCPhiNb);
320 energy1 = m_EmcTCFinder->GetWETCEnergy(TCThetaNb+1,TCPhiNb);
321 if(TCPhiNb!=0) energy2 = m_EmcTCFinder->GetWETCEnergy(TCThetaNb,TCPhiNb-1);
322 else energy2 = m_EmcTCFinder->GetWETCEnergy(TCThetaNb,TrigConf::TCPHINO_E-1);
323 if((energy0>=L1TC_THRESH)&&(energy1<L1TC_THRESH)&&(energy2<L1TC_THRESH)) return true;
324 else return false;
325 }
326 if(TCThetaNb==(TrigConf::TCTHETANO_E-1))
327 {
328 energy0 = m_EmcTCFinder->GetWETCEnergy(TCThetaNb,TCPhiNb);
329 if(TCPhiNb!=0) energy1 = m_EmcTCFinder->GetWETCEnergy(TCThetaNb,TCPhiNb-1);
330 else energy1 = m_EmcTCFinder->GetWETCEnergy(TCThetaNb,TrigConf::TCPHINO_E-1);
331 if((energy0>=L1TC_THRESH)&&(energy1<L1TC_THRESH)) return true;
332 else return false;
333 }
334 }
335*/
336 //------------------------------------------------------------------------------------
337/*Cluster Finder Logic (1)
338 <---phi
339
340 |---|---| /|\
341 | 0 | 1 | |
342 |---|---| theta
343 //if(partId==0)
344 //{
345 // energy0 = m_EmcTCFinder->getEETCEnergy(TCThetaNb,TCPhiNb);
346 // if(TCPhiNb!=0) {
347 // energy1 = m_EmcTCFinder->getEETCEnergy(TCThetaNb,TCPhiNb-1);
348 // }
349 // else {
350 // energy1 = m_EmcTCFinder->getEETCEnergy(TCThetaNb,(TrigConf::TCPHINO_E-1));
351 // }
352 // if((energy0>=L1TC_THRESH)&&(energy1<L1TC_THRESH)) return true;
353 // else return false;
354 //}
355
356 if(partId==0)
357 {
358 clus0 = m_EmcTCFinder->getEETC(TCThetaNb,TCPhiNb);
359 if(TCPhiNb!=0) {
360 clus1 = m_EmcTCFinder->getEETC(TCThetaNb,TCPhiNb-1);
361 }
362 else {
363 clus1 = m_EmcTCFinder->getEETC(TCThetaNb,(TrigConf::TCPHINO_E-1));
364 }
365 if((clus0 > 0)&&(clus1 == 0)) return true;
366 else return false;
367 }
368
369 //if(partId==2)
370 //{
371 // energy0 = m_EmcTCFinder->getWETCEnergy(TCThetaNb,TCPhiNb);
372 // if(TCPhiNb!=0) {
373 // energy1 = m_EmcTCFinder->getWETCEnergy(TCThetaNb,TCPhiNb-1);
374 // }
375 // else {
376 // energy1 = m_EmcTCFinder->getWETCEnergy(TCThetaNb,(TrigConf::TCPHINO_E-1));
377 // }
378 // if((energy0>=L1TC_THRESH)&&(energy1<L1TC_THRESH)) return true;
379 // else return false;
380 //}
381
382 if(partId==2)
383 {
384 clus0 = m_EmcTCFinder->getWETC(TCThetaNb,TCPhiNb);
385 if(TCPhiNb!=0) {
386 clus1 = m_EmcTCFinder->getWETC(TCThetaNb,TCPhiNb-1);
387 }
388 else {
389 clus1 = m_EmcTCFinder->getWETC(TCThetaNb,(TrigConf::TCPHINO_E-1));
390 }
391 if((clus0 > 0)&&(clus1 == 0)) return true;
392 else return false;
393 }
394*/
395
396/*Cluster Finder Logic (2)
397 <---phi
398
399 |---|---| /|\
400 | 0 | 1 | |
401 |---|---| theta
402*/
403 if(partId==0)
404 {
405 int etc1,etc2,etc3,etc4;
406 etc1 = m_EmcTCFinder->getEETC(TCThetaNb,TCPhiNb*2);
407 etc2 = m_EmcTCFinder->getEETC(TCThetaNb,TCPhiNb*2+1);
408 if(etc1 > 0 || etc2 > 0) clus0 = 1;
409 else clus0 = 0;
410
411 if(TCPhiNb!=0) {
412 etc3 = m_EmcTCFinder->getEETC(TCThetaNb,(TCPhiNb-1)*2);
413 etc4 = m_EmcTCFinder->getEETC(TCThetaNb,(TCPhiNb-1)*2+1);
414 if(etc3 > 0 || etc4 > 0) clus1 = 1;
415 else clus1 = 0;
416 }
417 else {
418 etc3 = m_EmcTCFinder->getEETC(TCThetaNb,(TrigConf::TCPHINO_E/2-1)*2);
419 etc4 = m_EmcTCFinder->getEETC(TCThetaNb,(TrigConf::TCPHINO_E/2-1)*2+1);
420 if(etc3 > 0 || etc4 > 0) clus1 = 1;
421 else clus1 = 0;
422 }
423
424 if((clus0 > 0)&&(clus1 == 0)) return true;
425 else return false;
426 }
427
428/*Cluster Finder Logic (2)
429 <---phi
430
431 |---|---| /|\
432 | 1 | 0 | |
433 |---|---| theta
434*/
435 if(partId==2)
436 {
437 int etc1,etc2,etc3,etc4;
438 etc1 = m_EmcTCFinder->getWETC(TCThetaNb,TCPhiNb*2);
439 etc2 = m_EmcTCFinder->getWETC(TCThetaNb,TCPhiNb*2+1);
440 if(etc1 > 0 || etc2 > 0) clus0 = 1;
441 else clus0 = 0;
442
443 if(TCPhiNb!= (TrigConf::TCPHINO_E/2-1)) {
444 etc3 = m_EmcTCFinder->getWETC(TCThetaNb,(TCPhiNb+1)*2);
445 etc4 = m_EmcTCFinder->getWETC(TCThetaNb,(TCPhiNb+1)*2+1);
446 if(etc3 > 0 || etc4 > 0) clus1 = 1;
447 else clus1 = 0;
448 }
449 else {
450 etc3 = m_EmcTCFinder->getWETC(TCThetaNb,0);
451 etc4 = m_EmcTCFinder->getWETC(TCThetaNb,1);
452 if(etc3 > 0 || etc4 > 0) clus1 = 1;
453 else clus1 = 0;
454 }
455
456 if((clus0 > 0)&&(clus1 == 0)) return true;
457 else return false;
458 }
459
460 return false;
461}
void setEmcClusId(map< int, vector< complex< int > >, greater< int > > i)
void getClusterId()
Definition: EmcCCount.cxx:36
bool findCluster(int partId, int TCThetaNb, int TCPhiNb)
Definition: EmcCCount.cxx:171
static EmcTCFinder * get_Emc(void)
Definition: EmcTCFinder.cxx:32