BOSS 7.1.1
BESIII Offline Software System
Loading...
Searching...
No Matches
BesEmcTrig.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/BesEmcTrig.h"
14#include "Trigger/EmcESum.h"
15#include "Trigger/EmcCCount.h"
16#include "Trigger/TrigPara.h"
17
20#include "GaudiKernel/ISvcLocator.h"
21#include "GaudiKernel/Bootstrap.h"
22#include "GaudiKernel/IDataProviderSvc.h"
23#include "CLHEP/Random/RandGauss.h"
24using namespace CLHEP;
25using namespace TrigConf;
26using namespace std;
27
29{
30 m_EmcESum = new EmcESum();
31 m_EmcCCount = new EmcCCount();
32// cout<<"BesEmcTrig output "<<endl;
33}
35{
36 if(m_EmcESum) delete m_EmcESum;
37 if(m_EmcCCount) delete m_EmcCCount;
38}
40{
41 m_EmcESum->getESum();
42 m_EmcCCount->getClusterId();
43 //reset values
44 NClus1 = false;
45 NClus2 = false;
46 NBClus1 = false;
47 NEClus1 = false;
48
49 BClus_Phi = false;
50 EClus_Phi = false;
51 EClusBB = false;
52 BClusBB = false;
53 Clus_Z = false;
54 BL_BBLK = false;
55
56 Etot_L = false;
57 Etot_M = false;
58 BEtot_H = false;
59 EEtot_H = false;
60
61 BL_Z = false;
62 Diff_E = false;
63 Diff_B = false;
64 //BL_BEMC = false; //not used
65 BL_EBLK = false;
66
67 ISvcLocator* svcLocator = Gaudi::svcLocator();
68 StatusCode sc = svcLocator->service("BesGlobalTrigSvc", m_tmpSvc);
69 m_pIBGT = dynamic_cast<BesGlobalTrigSvc* >(m_tmpSvc);
70
71 //set cluster number trigger conditions including barrel and endcaps
72 int nbcluster = 0, necluster = 0;
73 nbcluster = m_pIBGT->getEmcNbCluster();
74 necluster = m_pIBGT->getEmcNweCluster() + m_pIBGT->getEmcNeeCluster();
75 if((nbcluster + necluster)>=1) NClus1 = true;
76 if((nbcluster + necluster)>=2) NClus2 = true;
77 if(nbcluster >= 1) NBClus1 = true;
78 if(necluster >= 1) NEClus1 = true;
79
80 double L1ETOT_L = double (m_pIBGT->getL1ETOT_L());
81 double L1ETOT_M = double (m_pIBGT->getL1ETOT_M());
82 double L1EDIFF_BR = double (m_pIBGT->getL1EDIFF_BR());
83 double L1EDIFF_EC = double (m_pIBGT->getL1EDIFF_EC());
84 //middle energy threshold neut_a used
85 /*for(int i = 0; ; i++) {
86 double theshold = RandGauss::shoot(m_pIBGT->getL1ETOT_M_Peak(),m_pIBGT->getL1ETOT_M_Sigma());
87 if(theshold < m_pIBGT->getL1ETOT_M_Peak()) {
88 L1ETOT_M = theshold;
89 break;
90 }
91 }
92 for(int i = 0; ; i++) {
93 double theshold = RandGauss::shoot(m_pIBGT->getL1ETOT_L_Peak(),m_pIBGT->getL1ETOT_L_Sigma());
94 if(theshold < m_pIBGT->getL1ETOT_L_Peak()) {
95 L1ETOT_L = theshold;
96 break;
97 }
98 }*/
99
100 if((m_EmcESum->getTotE() > L1ETOT_M) ) Etot_M = true;
101 //low energy threshold(charge channel used)
102 if((m_EmcESum->getTotE() > L1ETOT_L) ) Etot_L = true;
103 //energy balance check for reserved in barrel
104 if((std::abs(m_EmcESum->getLBTotE() - m_EmcESum->getRBTotE())<L1EDIFF_BR))
105 Diff_B = true;
106 //energy balance check for babar of endcap
107 if((std::abs(m_EmcESum->getWETotE() - m_EmcESum->getEETotE())<L1EDIFF_EC))
108 Diff_E = true;
109 //High energy threshold in barrel
110 double L1ETOT_BR = double (m_pIBGT->getL1ETOT_BR());
111 double L1ETOT_EC = double (m_pIBGT->getL1ETOT_EC());
112 /*for(int i = 0; ; i++) {
113 double theshold = RandGauss::shoot(m_pIBGT->getL1ETOT_BR_Peak(),m_pIBGT->getL1ETOT_BR_Sigma());
114 if( theshold < m_pIBGT->getL1ETOT_BR_Peak()) {
115 L1ETOT_BR = theshold;
116 break;
117 }
118 }
119 for(int i = 0; ; i++) {
120 double theshold = RandGauss::shoot(m_pIBGT->getL1ETOT_EC_Peak(),m_pIBGT->getL1ETOT_EC_Sigma());
121 if(theshold < m_pIBGT->getL1ETOT_EC_Peak()) {
122 L1ETOT_EC = theshold;
123 break;
124 }
125 }*/
126 if((m_EmcESum->getBTotE()>L1ETOT_BR)) BEtot_H = true;
127 //High energy threshold(for babar trigger condition)
128 if((m_EmcESum->getETotE()>L1ETOT_EC)) EEtot_H = true;
129 //energy balance check for reserved in barrel
130 //double L1EBL_BR = m_pIBGT->getL1EBL_BR();
131 //if(m_EmcESum->GetLBTotE() > L1EBL_BR && m_EmcESum->GetRBTotE() > L1EBL_BR)
132 //BL_BEMC = true;
133 //energy balance check for babar of endcap
134 double L1EBL_EC = double (m_pIBGT->getL1EBL_EC());
135 if((m_EmcESum->getWETotE()>L1EBL_EC && m_EmcESum->getEETotE()>L1EBL_EC))
136 BL_EBLK = true;
137
138 //check balance condition of block energy for babar trigger
139 double energy0 = m_EmcESum->getBBLKE(0);
140 double energy1 = m_EmcESum->getBBLKE(1);
141 double energy2 = m_EmcESum->getBBLKE(2);
142 double energy3 = m_EmcESum->getBBLKE(3);
143 double energy4 = m_EmcESum->getBBLKE(4);
144 double energy5 = m_EmcESum->getBBLKE(5);
145 double energy9 = m_EmcESum->getBBLKE(9);
146 double energy10 = m_EmcESum->getBBLKE(10);
147 double energy6 = m_EmcESum->getBBLKE(6);
148 double energy11 = m_EmcESum->getBBLKE(11);
149 double energy7 = m_EmcESum->getBBLKE(7);
150 double energy8 = m_EmcESum->getBBLKE(8);
151 double L1BLK_GATE = double (m_pIBGT->getL1BLK_GATE());
152 if((energy0+energy1)>L1BLK_GATE && (energy9+energy10)>L1BLK_GATE)
153 BL_BBLK = true;
154 if((energy1+energy2)>L1BLK_GATE && (energy10+energy11)>L1BLK_GATE)
155 BL_BBLK = true;
156 if((energy2+energy3)>L1BLK_GATE && (energy11+energy6)>L1BLK_GATE)
157 BL_BBLK = true;
158 if((energy3+energy4)>L1BLK_GATE && (energy6+energy7)>L1BLK_GATE)
159 BL_BBLK = true;
160 if((energy4+energy5)>L1BLK_GATE && (energy7+energy8)>L1BLK_GATE)
161 BL_BBLK = true;
162 if((energy5+energy0)>L1BLK_GATE && (energy8+energy9)>L1BLK_GATE)
163 BL_BBLK = true;
164 //double WEenergy1 = m_EmcESum->getWEBLKE(0);
165 //double WEenergy2 = m_EmcESum->getWEBLKE(1);
166 //double EEenergy1 = m_EmcESum->getEEBLKE(0);
167 //double EEenergy2 = m_EmcESum->getEEBLKE(1);
168 //if(((WEenergy1>L1BLK_GATE || WEenergy2>L1BLK_GATE) && (EEenergy1>L1BLK_GATE || EEenergy2>L1BLK_GATE)) ) BL_BBLK = true;
169
170 //check cluster balance in phi of barral
171 for(int j =0;j<TrigConf::TCPHINO_B;j++)
172 {
173 int bphi = m_EmcCCount->getBClusterPhi(j);
174 if(bphi==0) continue;
175 if(bphi==1)
176 {
177 int NCluster = 0;
178 for(int k =0;k<15;k++)
179 {
180 if((8+k+j)<TrigConf::TCPHINO_B)
181 NCluster+=m_EmcCCount->getBClusterPhi(8+k+j);
182 else
183 NCluster+=m_EmcCCount->getBClusterPhi(8+k+j-TrigConf::TCPHINO_B);
184 if(NCluster>=1)
185 {
186 BClus_Phi = true;
187 break;
188 }
189 }
190 if(BClus_Phi == true)
191 break;
192 }
193 }
194
195 //check cluster balance in phi of endcap.
196 for(int j = 0;j<TrigConf::TCPHINO_E/2;j++)
197 {
198 int wephi = m_EmcCCount->getWEClusterPhi(j);
199 if(wephi == 0) continue;
200 if(wephi == 1)
201 {
202 int NCluster = 0;
203 for(int k=0;k<7;k++)
204 {
205 if((j+5+k)<TrigConf::TCPHINO_E/2)
206 NCluster+= m_EmcCCount->getEEClusterPhi(j+5+k);
207 else
208 NCluster+= m_EmcCCount->getEEClusterPhi(j+5+k-TrigConf::TCPHINO_E/2);
209 if(NCluster>=1)
210 {
211 EClus_Phi = true;
212 break;
213 }
214 }
215 if(EClus_Phi == true)
216 break;
217 }
218 }
219
220 //check barrel cluster balance in theta and phi for babar trigger
221 for(int i=0;i<TrigConf::TCTHETANO_B;i++)
222 for(int j=0;j<TrigConf::TCPHINO_B;j++)
223 {
224 int BClusId = m_EmcCCount->getBClusterId(i,j);
225 int NCluster = 0;
226 if(BClusId==0) continue;
227 else
228 {
229 if(i>0&&i<(TrigConf::TCTHETANO_B-1))
230 {
231 for(int k=0;k<5;k++)
232 {
233 if(j+13+k<TrigConf::TCPHINO_B)
234 {
235 NCluster+= m_EmcCCount->getBClusterId((TrigConf::TCTHETANO_B-1)-i,j+13+k);
236 NCluster+= m_EmcCCount->getBClusterId((TrigConf::TCTHETANO_B-1)-i+1,j+13+k);
237 NCluster+= m_EmcCCount->getBClusterId((TrigConf::TCTHETANO_B-1)-i-1,j+13+k);
238 }
239 else
240 {
241 NCluster+= m_EmcCCount->getBClusterId((TrigConf::TCTHETANO_B-1)-i,j+13+k-TrigConf::TCPHINO_B);
242 NCluster+= m_EmcCCount->getBClusterId((TrigConf::TCTHETANO_B-1)-i+1,j+13+k-TrigConf::TCPHINO_B);
243 NCluster+= m_EmcCCount->getBClusterId((TrigConf::TCTHETANO_B-1)-i-1,j+13+k-TrigConf::TCPHINO_B);
244 }
245 }
246 if(NCluster>0) { BClusBB = true; break; }
247 }
248 if(i==0)
249 {
250 for(int k=0;k<5;k++)
251 {
252 if(j+13+k<TrigConf::TCPHINO_B)
253 {
254 NCluster+= m_EmcCCount->getBClusterId((TrigConf::TCTHETANO_B-1),j+13+k);
255 NCluster+= m_EmcCCount->getBClusterId((TrigConf::TCTHETANO_B-2),j+13+k);
256 }
257 else
258 {
259 NCluster+= m_EmcCCount->getBClusterId((TrigConf::TCTHETANO_B-2),j+13+k-TrigConf::TCPHINO_B);
260 NCluster+= m_EmcCCount->getBClusterId((TrigConf::TCTHETANO_B-1),j+13+k-TrigConf::TCPHINO_B);
261 }
262 }
263 if(NCluster>0) { BClusBB = true; break; }
264 }
265 if(i==(TrigConf::TCTHETANO_B-1))
266 {
267 for(int k=0;k<5;k++)
268 {
269 if(j+13+k<TrigConf::TCPHINO_B)
270 {
271 NCluster+= m_EmcCCount->getBClusterId(0,j+13+k);
272 NCluster+= m_EmcCCount->getBClusterId(1,j+13+k);
273 }
274 else
275 {
276 NCluster+= m_EmcCCount->getBClusterId(0,j+13+k-TrigConf::TCPHINO_B);
277 NCluster+= m_EmcCCount->getBClusterId(1,j+13+k-TrigConf::TCPHINO_B);
278 }
279 }
280 if(NCluster>0) { BClusBB = true; break; }
281 }
282 }
283 }
284 //check endcap cluster balance in phi for babar trigger
285 for(int j = 0;j<TrigConf::TCPHINO_E/2;j++)
286 {
287 int NCluster = 0;
288 int EClusId = m_EmcCCount->getWEClusterPhi(j);
289
290 if(EClusId == 0) continue;
291 else
292 {
293
294 for(int k=0;k<3;k++)
295 {
296 if((j+7+k)<TrigConf::TCPHINO_E/2)
297 NCluster+= m_EmcCCount->getEEClusterPhi(j+7+k);
298 else
299 NCluster+= m_EmcCCount->getEEClusterPhi(j+7+k-TrigConf::TCPHINO_E/2);
300 if(NCluster>=1)
301 {
302 EClusBB = true;
303 break;
304 }
305 }
306 if(EClusBB == true)
307 break;
308 }
309 }
310 //z energy balance (B+E)
311 double L1EBL_Z = double (m_pIBGT->getL1EBL_Z());
312 /*for(int i = 0; ; i++) {
313 double theshold = RandGauss::shoot(m_pIBGT->getL1EBL_Z_Peak(),m_pIBGT->getL1EBL_Z_Sigma());
314 if(theshold < m_pIBGT->getL1EBL_Z_Peak()) {
315 L1EBL_Z = theshold;
316 break;
317 }
318 }*/
319 if((m_EmcESum->getRTotE()>=L1EBL_Z && m_EmcESum->getLTotE()>=L1EBL_Z))
320 BL_Z = true;
321// cout<<"RTotE and LTotE are "<<m_EmcESum->GetRTotE()<<" "<<m_EmcESum->GetLTotE()<<endl;
322//
323 //z cluster balance (if one cluster is found in each side ,return true)
324 if(m_EmcCCount->getEClus_Z()&&m_EmcCCount->getWClus_Z())
325 Clus_Z = true;
326
327 //set trigger conditions in service
328
329 m_pIBGT->setNClus1(NClus1);
330 m_pIBGT->setNClus2(NClus2);
331 m_pIBGT->setNBClus1(NBClus1);
332 m_pIBGT->setNEClus1(NEClus1);
333
334 m_pIBGT->setBClusBB(BClusBB);
335 m_pIBGT->setEClusBB(EClusBB);
336 m_pIBGT->setClus_Z(Clus_Z);
337 m_pIBGT->setBClus_PHI(BClus_Phi);
338 m_pIBGT->setEClus_PHI(EClus_Phi);
339 m_pIBGT->setBEtot_H(BEtot_H);
340 m_pIBGT->setEEtot_H(EEtot_H);
341 m_pIBGT->setEtot_L(Etot_L);
342 m_pIBGT->setEtot_M(Etot_M);
343 m_pIBGT->setBL_Z(BL_Z);
344 m_pIBGT->setDiff_B(Diff_B);
345 m_pIBGT->setDiff_E(Diff_E);
346 m_pIBGT->setBL_BBLK(BL_BBLK);
347 m_pIBGT->setBL_EBLK(BL_EBLK);
348}
void startEmcTrig()
void setBL_BBLK(bool i)
void setBEtot_H(bool i)
void setDiff_B(bool i)
void setBL_EBLK(bool i)
void setNClus1(bool i)
void setEClus_PHI(bool i)
void setEClusBB(bool i)
void setEEtot_H(bool i)
void setNClus2(bool i)
void setBClus_PHI(bool i)
void setDiff_E(bool i)
void setNBClus1(bool i)
void setEtot_M(bool i)
void setEtot_L(bool i)
void setClus_Z(bool i)
void setBClusBB(bool i)
void setNEClus1(bool i)
int getBClusterId(int i, int j)
Definition EmcCCount.h:21
bool getEClus_Z()
Definition EmcCCount.h:24
void getClusterId()
Definition EmcCCount.cxx:36
int getBClusterPhi(int i)
Definition EmcCCount.h:18
int getEEClusterPhi(int i)
Definition EmcCCount.h:20
bool getWClus_Z()
Definition EmcCCount.h:25
int getWEClusterPhi(int i)
Definition EmcCCount.h:19
double getLTotE()
Definition EmcESum.h:15
double getETotE()
Definition EmcESum.h:18
double getLBTotE()
Definition EmcESum.h:19
double getWETotE()
Definition EmcESum.h:21
double getBBLKE(int i)
Definition EmcESum.h:23
double getEETotE()
Definition EmcESum.h:22
void getESum()
Definition EmcESum.cxx:36
double getTotE()
Definition EmcESum.h:14
double getRBTotE()
Definition EmcESum.h:20
double getBTotE()
Definition EmcESum.h:17
double getRTotE()
Definition EmcESum.h:16