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