BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
BesTofTrig.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/BesTofTrig.h"
14#include <algorithm>
15#include <iostream>
16
19#include "GaudiKernel/ISvcLocator.h"
20#include "GaudiKernel/Bootstrap.h"
21#include "GaudiKernel/IDataProviderSvc.h"
22
23#include <map>
24using namespace std;
25
27{
28 m_TofHitCount = TofHitCount::get_Tof();
29}
31{
32}
34{
35
36 ISvcLocator* svcLocator = Gaudi::svcLocator();
37 StatusCode sc = svcLocator->service("BesGlobalTrigSvc", m_tmpSvc);
38 m_pIBGT = dynamic_cast<BesGlobalTrigSvc* >(m_tmpSvc);
39
40 //reset hit counter
41 int barHitCount = 0;
42 int endHitCount = 0;
43
44 NBTOF1 = false;
45 NBTOF2 = false;
46 NETOF1 = false;
47 NETOF2 = false;
48 NTOF1 = false;
49
50 TBB = false;
51 ETBB = false;
52
53 bHitpos.clear();
54 ecapHitpos.clear();
55 wcapHitpos.clear();
56
57 if(!m_TofHitCount) std::cerr<<"can not get TofHitCount pointer"<<std::endl;
58
59 std::vector<int> barHitmap;
60 std::vector<int> endHitmap;
61 std::vector<int> barHitId1;
62 std::vector<int> barHitId2;
63 std::vector<int> ecapHitId;
64 std::vector<int> wcapHitId;
65 std::vector<int>::iterator iter;
66
67 barHitmap.clear();
68 endHitmap.clear();
69 barHitId1.clear();
70 barHitId2.clear();
71 ecapHitId.clear();
72 wcapHitId.clear();
73
74 barHitId1 = m_TofHitCount->GetbarrelHit1();
75 barHitId2 = m_TofHitCount->GetbarrelHit2();
76 ecapHitId = m_TofHitCount->GetecapHit();
77 wcapHitId = m_TofHitCount->GetwcapHit();
78
79 for(unsigned int btofId = 0; btofId < barHitId1.size(); btofId++) barHitmap.push_back(barHitId1[btofId]);
80 for(unsigned int btofId = 0; btofId < barHitId2.size(); btofId++) barHitmap.push_back(88+barHitId2[btofId]);
81 for(unsigned int etofId = 0; etofId < ecapHitId.size(); etofId++) endHitmap.push_back(ecapHitId[etofId]);
82 for(unsigned int etofId = 0; etofId < wcapHitId.size(); etofId++) endHitmap.push_back(48+wcapHitId[etofId]);
83 //two layer tof in barrel is "or" logic
84 // -------------------------
85 // ... | | |j+1| j | ... outer layer
86 // -------------------------
87 // ---------------------------
88 // ... | | | i | | ... inner layer
89 // ---------------------------
90 // M_i = M_i || M_j || M_j+1
91 int scinNo;
92 for(int btofId = 0; btofId < 88; btofId++) {
93 if(m_pIBGT->getTofLayerControl() == 1) {
94 if((find(barHitId1.begin(),barHitId1.end(),btofId)!=barHitId1.end()) ) {
95 bHitpos.push_back(btofId);
96 }
97 }
98 if(m_pIBGT->getTofLayerControl() == 2) {
99 if(btofId != 87) {
100 if((find(barHitId1.begin(),barHitId1.end(),btofId)!=barHitId1.end()) ||
101 (find(barHitId2.begin(),barHitId2.end(),btofId)!=barHitId2.end()) ||
102 (find(barHitId2.begin(),barHitId2.end(),btofId+1)!=barHitId2.end()) ) {
103 bHitpos.push_back(btofId);
104 }
105 }
106 if(btofId == 87) {
107 if((find(barHitId1.begin(),barHitId1.end(),btofId)!=barHitId1.end()) ||
108 (find(barHitId2.begin(),barHitId2.end(),btofId)!=barHitId2.end()) ||
109 (find(barHitId2.begin(),barHitId2.end(),0)!=barHitId2.end()) ) {
110 bHitpos.push_back(btofId);
111 }
112 }
113 }
114 }
115 //hit position in end caps
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 {
121 ecapHitpos.push_back(scinNo);
122 }
123 }
124
125 for(iter=wcapHitId.begin();iter!=wcapHitId.end();iter++)
126 {
127 scinNo = (int)*iter/2;
128 if(find(wcapHitpos.begin(),wcapHitpos.end(),scinNo)==wcapHitpos.end())
129 {
130 wcapHitpos.push_back(scinNo);
131 }
132 }
133
134 //Counting the hit number only for NBTOF1, NBTOF2, NETOF1, NETOF1 trigger conditions. Combine contiguous hits as one hit
135 //barrel
136 for(int btofId = 0; btofId < 88; btofId++) {
137 if(btofId == 0) {
138 if((find(bHitpos.begin(),bHitpos.end(),btofId) != bHitpos.end()) &&
139 (find(bHitpos.begin(),bHitpos.end(),87) == bHitpos.end())) {
140 barHitCount++;
141 }
142 }
143 else {
144 if((find(bHitpos.begin(),bHitpos.end(),btofId) != bHitpos.end()) &&
145 (find(bHitpos.begin(),bHitpos.end(),btofId-1) == bHitpos.end())) {
146 barHitCount++;
147 }
148 }
149 }
150 //endcaps
151 for(int etofId = 0; etofId < 48; etofId++) {
152 if(etofId == 0) {
153 if((find(wcapHitId.begin(),wcapHitId.end(),etofId) != wcapHitId.end()) &&
154 (find(wcapHitId.begin(),wcapHitId.end(),47) == wcapHitId.end())) {
155 endHitCount++;
156 }
157 if((find(ecapHitId.begin(),ecapHitId.end(),etofId) != ecapHitId.end()) &&
158 (find(ecapHitId.begin(),ecapHitId.end(),47) == ecapHitId.end())) {
159 endHitCount++;
160 }
161 }
162 else {
163 if((find(wcapHitId.begin(),wcapHitId.end(),etofId) != wcapHitId.end()) &&
164 (find(wcapHitId.begin(),wcapHitId.end(),etofId-1) == wcapHitId.end())) {
165 endHitCount++;
166 }
167 if((find(ecapHitId.begin(),ecapHitId.end(),etofId) != ecapHitId.end()) &&
168 (find(ecapHitId.begin(),ecapHitId.end(),etofId-1) == ecapHitId.end())) {
169 endHitCount++;
170 }
171 }
172 }
173
174 if(barHitCount>=1) NBTOF1 = true;
175 if(barHitCount>=2) NBTOF2 = true;
176 if(endHitCount>=1) NETOF1 = true;
177 if(endHitCount>=2) NETOF2 = true;
178 if((NBTOF1 == true) || (NETOF1 == true)) NTOF1 = true;
179
180 for(iter=bHitpos.begin();iter!=bHitpos.end();iter++)
181 {
182 scinNo = *iter;
183 for(int i=0;i<13;i++)
184 {
185 if(scinNo+38+i<88)
186 {
187 if(find(bHitpos.begin(),bHitpos.end(),scinNo+38+i)!=bHitpos.end()) TBB = true;
188 }
189 if(scinNo+38+i>=88)
190 {
191 if(find(bHitpos.begin(),bHitpos.end(),scinNo+38+i-88)!=bHitpos.end()) TBB = true;
192 }
193 }
194 }
195 for(iter=wcapHitId.begin();iter!=wcapHitId.end();iter++)
196 {
197 scinNo = *iter;
198 for(int i=0;i<9;i++)
199 {
200 if(scinNo+20+i<48)
201 {
202 if(find(ecapHitId.begin(),ecapHitId.end(),scinNo+20+i)!=ecapHitId.end()) ETBB = true;
203 }
204 if(scinNo+20+i>=48)
205 {
206 if(find(ecapHitId.begin(),ecapHitId.end(),scinNo+20+i-48)!=ecapHitId.end()) ETBB = true;
207 }
208 }
209 }
210 map<int,vector<int>,greater<int> > mHitId;
211 mHitId.clear();
212 typedef pair<int, vector<int> > vpair;
213/*
214 std::vector<int> bhitmap;
215 bhitmap.clear();
216 for(int id = 0; id < barHitId1.size(); id++) {
217 bhitmap.push_back(barHitId1[id]);
218 }
219 for(int id = 0; id < barHitId2.size(); id++) {
220 bhitmap.push_back(88+barHitId2[id]);
221 }
222*/
223 mHitId.insert(vpair(0,ecapHitpos));
224 mHitId.insert(vpair(1,bHitpos));
225 mHitId.insert(vpair(2,wcapHitpos));
226
227 m_pIBGT->setNBTof1(NBTOF1);
228 m_pIBGT->setNBTof2(NBTOF2);
229 m_pIBGT->setNETof1(NETOF1);
230 m_pIBGT->setNETof2(NETOF2);
231 m_pIBGT->setNTof1(NTOF1);
232 m_pIBGT->setBTofBB(TBB);
233 m_pIBGT->setETofBB(ETBB);
234 m_pIBGT->setTofHitPos(mHitId);
235 m_pIBGT->setBTofHitMap(barHitmap);
236 m_pIBGT->setETofHitMap(endHitmap);
237}
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
void setNETof2(bool i)
void setNETof1(bool i)
void setETofBB(bool i)
void setETofHitMap(vector< int > i)
void setNBTof1(bool i)
void setBTofBB(bool i)
void setNBTof2(bool i)
void setBTofHitMap(vector< int > i)
void setTofHitPos(map< int, vector< int >, greater< int > > i)
void setNTof1(bool i)
void startTofTrig()
Definition: BesTofTrig.cxx:33
std::vector< int > & GetwcapHit()
Definition: TofHitCount.h:15
static TofHitCount * get_Tof(void)
Definition: TofHitCount.cxx:26
std::vector< int > & GetecapHit()
Definition: TofHitCount.h:14
std::vector< int > & GetbarrelHit1()
Definition: TofHitCount.h:12
std::vector< int > & GetbarrelHit2()
Definition: TofHitCount.h:13