28 {
29
30 ISvcLocator* svcLocator = Gaudi::svcLocator();
31 StatusCode sc = svcLocator->service( "BesGlobalTrigSvc", m_tmpSvc );
32 m_pIBGT = dynamic_cast<BesGlobalTrigSvc*>( m_tmpSvc );
33
34
35 int barHitCount = 0;
36 int endHitCount = 0;
37
38 NBTOF1 = false;
39 NBTOF2 = false;
40 NETOF1 = false;
41 NETOF2 = false;
42 NTOF1 = false;
43
44 TBB = false;
45 ETBB = false;
46
47 bHitpos.clear();
48 ecapHitpos.clear();
49 wcapHitpos.clear();
50
51 if ( !m_TofHitCount ) std::cerr << "can not get TofHitCount pointer" << std::endl;
52
53 std::vector<int> barHitmap;
54 std::vector<int> endHitmap;
55 std::vector<int> barHitId1;
56 std::vector<int> barHitId2;
57 std::vector<int> ecapHitId;
58 std::vector<int> wcapHitId;
59 std::vector<int>::iterator
iter;
60
61 barHitmap.clear();
62 endHitmap.clear();
63 barHitId1.clear();
64 barHitId2.clear();
65 ecapHitId.clear();
66 wcapHitId.clear();
67
68 barHitId1 = m_TofHitCount->GetbarrelHit1();
69 barHitId2 = m_TofHitCount->GetbarrelHit2();
70 ecapHitId = m_TofHitCount->GetecapHit();
71 wcapHitId = m_TofHitCount->GetwcapHit();
72
73 for ( unsigned int btofId = 0; btofId < barHitId1.size(); btofId++ )
74 barHitmap.push_back( barHitId1[btofId] );
75 for ( unsigned int btofId = 0; btofId < barHitId2.size(); btofId++ )
76 barHitmap.push_back( 88 + barHitId2[btofId] );
77 for ( unsigned int etofId = 0; etofId < ecapHitId.size(); etofId++ )
78 endHitmap.push_back( ecapHitId[etofId] );
79 for ( unsigned int etofId = 0; etofId < wcapHitId.size(); etofId++ )
80 endHitmap.push_back( 48 + wcapHitId[etofId] );
81
82
83
84
85
86
87
88
89 int scinNo;
90 for ( int btofId = 0; btofId < 88; btofId++ )
91 {
92 if ( m_pIBGT->getTofLayerControl() == 1 )
93 {
94 if ( ( find( barHitId1.begin(), barHitId1.end(), btofId ) != barHitId1.end() ) )
95 { bHitpos.push_back( btofId ); }
96 }
97 if ( m_pIBGT->getTofLayerControl() == 2 )
98 {
99 if ( btofId != 87 )
100 {
101 if ( ( find( barHitId1.begin(), barHitId1.end(), btofId ) != barHitId1.end() ) ||
102 ( find( barHitId2.begin(), barHitId2.end(), btofId ) != barHitId2.end() ) ||
103 ( find( barHitId2.begin(), barHitId2.end(), btofId + 1 ) != barHitId2.end() ) )
104 { bHitpos.push_back( btofId ); }
105 }
106 if ( btofId == 87 )
107 {
108 if ( ( find( barHitId1.begin(), barHitId1.end(), btofId ) != barHitId1.end() ) ||
109 ( find( barHitId2.begin(), barHitId2.end(), btofId ) != barHitId2.end() ) ||
110 ( find( barHitId2.begin(), barHitId2.end(), 0 ) != barHitId2.end() ) )
111 { bHitpos.push_back( btofId ); }
112 }
113 }
114 }
115
116 for (
iter = ecapHitId.begin();
iter != ecapHitId.end();
iter++ )
117 {
118 scinNo = (int)( *
iter ) / 2;
119 if ( find( ecapHitpos.begin(), ecapHitpos.end(), scinNo ) == ecapHitpos.end() )
120 { ecapHitpos.push_back( scinNo ); }
121 }
122
123 for (
iter = wcapHitId.begin();
iter != wcapHitId.end();
iter++ )
124 {
125 scinNo = (int)*
iter / 2;
126 if ( find( wcapHitpos.begin(), wcapHitpos.end(), scinNo ) == wcapHitpos.end() )
127 { wcapHitpos.push_back( scinNo ); }
128 }
129
130
131
132 for ( int btofId = 0; btofId < 88; btofId++ )
133 {
134 if ( btofId == 0 )
135 {
136 if ( ( find( bHitpos.begin(), bHitpos.end(), btofId ) != bHitpos.end() ) &&
137 ( find( bHitpos.begin(), bHitpos.end(), 87 ) == bHitpos.end() ) )
138 { barHitCount++; }
139 }
140 else
141 {
142 if ( ( find( bHitpos.begin(), bHitpos.end(), btofId ) != bHitpos.end() ) &&
143 ( find( bHitpos.begin(), bHitpos.end(), btofId - 1 ) == bHitpos.end() ) )
144 { barHitCount++; }
145 }
146 }
147
148 for ( int etofId = 0; etofId < 48; etofId++ )
149 {
150 if ( etofId == 0 )
151 {
152 if ( ( find( wcapHitId.begin(), wcapHitId.end(), etofId ) != wcapHitId.end() ) &&
153 ( find( wcapHitId.begin(), wcapHitId.end(), 47 ) == wcapHitId.end() ) )
154 { endHitCount++; }
155 if ( ( find( ecapHitId.begin(), ecapHitId.end(), etofId ) != ecapHitId.end() ) &&
156 ( find( ecapHitId.begin(), ecapHitId.end(), 47 ) == ecapHitId.end() ) )
157 { endHitCount++; }
158 }
159 else
160 {
161 if ( ( find( wcapHitId.begin(), wcapHitId.end(), etofId ) != wcapHitId.end() ) &&
162 ( find( wcapHitId.begin(), wcapHitId.end(), etofId - 1 ) == wcapHitId.end() ) )
163 { endHitCount++; }
164 if ( ( find( ecapHitId.begin(), ecapHitId.end(), etofId ) != ecapHitId.end() ) &&
165 ( find( ecapHitId.begin(), ecapHitId.end(), etofId - 1 ) == ecapHitId.end() ) )
166 { endHitCount++; }
167 }
168 }
169
170 if ( barHitCount >= 1 ) NBTOF1 = true;
171 if ( barHitCount >= 2 ) NBTOF2 = true;
172 if ( endHitCount >= 1 ) NETOF1 = true;
173 if ( endHitCount >= 2 ) NETOF2 = true;
174 if ( ( NBTOF1 == true ) || ( NETOF1 == true ) ) NTOF1 = true;
175
176 for (
iter = bHitpos.begin();
iter != bHitpos.end();
iter++ )
177 {
179 for ( int i = 0; i < 13; i++ )
180 {
181 if ( scinNo + 38 + i < 88 )
182 {
183 if ( find( bHitpos.begin(), bHitpos.end(), scinNo + 38 + i ) != bHitpos.end() )
184 TBB = true;
185 }
186 if ( scinNo + 38 + i >= 88 )
187 {
188 if ( find( bHitpos.begin(), bHitpos.end(), scinNo + 38 + i - 88 ) != bHitpos.end() )
189 TBB = true;
190 }
191 }
192 }
193 for (
iter = wcapHitId.begin();
iter != wcapHitId.end();
iter++ )
194 {
196 for ( int i = 0; i < 9; i++ )
197 {
198 if ( scinNo + 20 + i < 48 )
199 {
200 if ( find( ecapHitId.begin(), ecapHitId.end(), scinNo + 20 + i ) != ecapHitId.end() )
201 ETBB = true;
202 }
203 if ( scinNo + 20 + i >= 48 )
204 {
205 if ( find( ecapHitId.begin(), ecapHitId.end(), scinNo + 20 + i - 48 ) !=
206 ecapHitId.end() )
207 ETBB = true;
208 }
209 }
210 }
211 map<int, vector<int>, greater<int>> mHitId;
212 mHitId.clear();
213 typedef pair<int, vector<int>> vpair;
214
215
216
217
218
219
220
221
222
223
224 mHitId.insert( vpair( 0, ecapHitpos ) );
225 mHitId.insert( vpair( 1, bHitpos ) );
226 mHitId.insert( vpair( 2, wcapHitpos ) );
227
228 m_pIBGT->setNBTof1( NBTOF1 );
229 m_pIBGT->setNBTof2( NBTOF2 );
230 m_pIBGT->setNETof1( NETOF1 );
231 m_pIBGT->setNETof2( NETOF2 );
232 m_pIBGT->setNTof1( NTOF1 );
233 m_pIBGT->setBTofBB( TBB );
234 m_pIBGT->setETofBB( ETBB );
235 m_pIBGT->setTofHitPos( mHitId );
236 m_pIBGT->setBTofHitMap( barHitmap );
237 m_pIBGT->setETofHitMap( endHitmap );
238}