9 m_mdchit_one =
new int*[24];
10 for (
int i = 0; i < 24; i++) m_mdchit_one[i] =
new int[256];
11 m_mdchit_sone =
new int*[24];
12 for (
int i = 0; i < 24; i++) m_mdchit_sone[i] =
new int[256];
13 m_mdchit_pre =
new int*[24];
14 for(
int i=0; i<24; i++) m_mdchit_pre[i] =
new int[256];
15 m_mdchit_aft =
new int*[24];
16 for(
int i=0; i<24; i++) m_mdchit_aft[i] =
new int[256];
17 m_mdchit_win =
new uint32_t*[24];
18 for(
int i=0; i<24; i++) m_mdchit_win[i] =
new uint32_t[256];
20 m_mdctsf_one =
new int*[6];
21 for (
int i=0; i<6; i++) m_mdctsf_one[i] =
new int[256];
22 m_mdctsf_sone =
new int*[6];
23 for (
int i=0; i<6; i++) m_mdctsf_sone[i] =
new int[256];
24 m_mdctsf_pre =
new int*[6];
25 for(
int i=0; i<6; i++) m_mdctsf_pre[i] =
new int[256];
26 m_mdctsf_aft =
new int*[6];
27 for(
int i=0; i<6; i++) m_mdctsf_aft[i] =
new int[256];
28 m_mdctsf_win =
new uint32_t*[6];
29 for(
int i=0; i<6; i++) m_mdctsf_win[i] =
new uint32_t[256];
31 m_mdcltrk_one =
new int[128];
32 m_mdcltrk_sone =
new int[128];
33 m_mdcltrk_pre =
new int[128];
34 m_mdcltrk_aft =
new int[128];
35 m_mdcltrk_win =
new uint32_t[128];
37 m_mdcstrk_one =
new int[128];
38 m_mdcstrk_sone =
new int[128];
39 m_mdcstrk_pre =
new int[128];
40 m_mdcstrk_aft =
new int[128];
41 m_mdcstrk_win =
new uint32_t[128];
43 m_mdcltrkc_one =
new int[132];
44 m_mdcltrkc_sone=
new int[132];
46 m_mdcstrkc_one =
new int[132];
47 m_mdcstrkc_sone =
new int[132];
49 m_mdcTrigCondi =
new int[10];
51 filename = getenv(
"TRIGEVENTROOT");
52 filename +=
"/dat/trig_mdc.txt";
54 inputfile.open(filename.c_str());
56 std::vector<uint32_t> vtmp;
58 for(uint32_t i = 0; i < 6; i++) inputfile >>
data[i];
59 for(uint32_t j = 0; j < 4680; j++) {
60 for(uint32_t k = 0; k < 6; k++) inputfile >>
data[k];
61 if((uint32_t (atoi(
data[0].c_str())) != mark) || j == 4679) {
63 for(
int m = 1; m < 6; m++) vtmp.push_back(atoi(
data[m].c_str()));
65 typedef pair<uint32_t, vector<uint32_t> > vpair;
66 m_datamap.insert(vpair(mark,vtmp));
67 mark = atoi(
data[0].c_str());
70 if((uint32_t (atoi(
data[0].c_str())) == mark) && j != 4679) {
71 for(
int l = 1; l < 6; l++) vtmp.push_back(atoi(
data[l].c_str()));
141 if(datasize%window != 0) cerr<<
"ERROR: The data size is not completed in time windows"<<endl;
142 uint32_t periods = datasize/window;
143 std::map<uint32_t, std::vector<uint32_t> >::iterator
iter=m_datamap.begin();
144 for(;
iter != m_datamap.end();
iter++){
145 if(
iter->first != boardId)
continue;
146 std::vector<uint32_t>::iterator iter1 =
iter->second.begin();
147 for(; iter1 !=
iter->second.end(); iter1+=5){
148 uint32_t byteId = *(iter1+0) -1;
149 uint32_t bitId = *(iter1+1);
150 int layerId = *(iter1+2) -1;
151 int wireId = *(iter1+3) -1;
152 uint32_t data_type = *(iter1+4);
153 int seriesOne = -100;
154 bool firstSOne =
true;
155 bool flag_firstone(
true), flag_lastone(
true);
156 for(uint32_t i=0; i<window; i++){
157 if(layerId < 0 || wireId < 0)
continue;
158 if((
iter->first) >= 226 && (
iter->first) <= 233){
160 if((
data[byteId + i*periods] >> bitId) & 1){
161 if(layerId >= 36 && layerId <= 39 ){
162 if(flag_firstone && (i-seriesOne!=1) && (i!=0)){ m_mdchit_pre[layerId-16][wireId] = i+1; flag_firstone =
false;}
163 if( ((i-seriesOne)!=1) && (m_mdchit_aft[layerId-16][wireId]!=0) ) flag_lastone =
false;
164 if( (flag_firstone==
false) && ((i-seriesOne)==1) && flag_lastone) m_mdchit_aft[layerId-16][wireId]=i+1;
165 if(((i-seriesOne)==1) && firstSOne) m_mdchit_sone[layerId-16][wireId] += 1;
166 if(m_mdchit_sone[layerId-16][wireId] != 0 && (i-seriesOne) != 1) firstSOne =
false;
168 m_mdchit_one[layerId-16][wireId] += 1;
169 m_mdchit_win[layerId-16][wireId] += 1<<i;
172 if(flag_firstone && (i-seriesOne!=1) && (i!=0)){ m_mdchit_pre[layerId][wireId] = i+1; flag_firstone =
false;}
173 if( ((i-seriesOne)!=1) && (m_mdchit_aft[layerId][wireId]!=0) ) flag_lastone =
false;
174 if( (flag_firstone==
false) && ((i-seriesOne)==1) && flag_lastone) m_mdchit_aft[layerId][wireId]=i+1;
175 if(((i-seriesOne) == 1) && firstSOne) m_mdchit_sone[layerId][wireId] += 1;
176 if(m_mdchit_sone[layerId][wireId] != 0 && (i-seriesOne) != 1) firstSOne =
false;
178 m_mdchit_one[layerId][wireId] += 1;
179 m_mdchit_win[layerId][wireId] += 1<<i;
184 if((
data[byteId + i*periods] >> bitId) & 1) {
186 if(flag_firstone && (i-seriesOne!=1) && (i!=0)){ m_mdctsf_pre[2][wireId] = i+1; flag_firstone =
false;}
187 if( ((i-seriesOne)!=1) && (m_mdctsf_aft[2][wireId]!=0) ) flag_lastone =
false;
188 if( (flag_firstone==
false) && ((i-seriesOne)==1) && flag_lastone) m_mdctsf_aft[2][wireId]=i+1;
190 if((i-seriesOne) == 1 && firstSOne) m_mdctsf_sone[2][wireId] += 1;
191 if(m_mdctsf_sone[2][wireId] != 0 && (i-seriesOne) != 1) firstSOne =
false;
193 m_mdctsf_one[2][wireId] += 1;
194 m_mdctsf_win[2][wireId] += 1<<i;
197 if(flag_firstone && (i-seriesOne!=1) && (i!=0)){ m_mdctsf_pre[3][wireId] = i+1; flag_firstone =
false;}
198 if( ((i-seriesOne)!=1) && (m_mdctsf_aft[3][wireId]!=0) ) flag_lastone =
false;
199 if( (flag_firstone==
false) && ((i-seriesOne)==1) && flag_lastone) m_mdctsf_aft[3][wireId]=i+1;
201 if((i-seriesOne) == 1 && firstSOne) m_mdctsf_sone[3][wireId] += 1;
202 if(m_mdctsf_sone[3][wireId] != 0 && (i-seriesOne) != 1) firstSOne =
false;
204 m_mdctsf_one[3][wireId] += 1;
205 m_mdctsf_win[3][wireId] += 1<<i;
208 if(flag_firstone && (i-seriesOne!=1) && (i!=0)){ m_mdctsf_pre[4][wireId] = i+1; flag_firstone =
false;}
209 if( ((i-seriesOne)!=1) && (m_mdctsf_aft[4][wireId]!=0) ) flag_lastone =
false;
210 if( (flag_firstone==
false) && ((i-seriesOne)==1) && flag_lastone) m_mdctsf_aft[4][wireId]=i+1;
212 if((i-seriesOne) == 1 && firstSOne) m_mdctsf_sone[4][wireId] += 1;
213 if(m_mdctsf_sone[4][wireId] != 0 && (i-seriesOne) != 1) firstSOne =
false;
215 m_mdctsf_one[4][wireId] += 1;
216 m_mdctsf_win[4][wireId] += 1<<i;
219 if(flag_firstone && (i-seriesOne!=1) && (i!=0)){ m_mdctsf_pre[5][wireId] = i+1; flag_firstone =
false;}
220 if( ((i-seriesOne)!=1) && (m_mdctsf_aft[5][wireId]!=0) ) flag_lastone =
false;
221 if( (flag_firstone==
false) && ((i-seriesOne)==1) && flag_lastone) m_mdctsf_aft[5][wireId]=i+1;
223 if((i-seriesOne) == 1 && firstSOne) m_mdctsf_sone[5][wireId] += 1;
224 if(m_mdctsf_sone[5][wireId] != 0 && (i-seriesOne) != 1) firstSOne =
false;
226 m_mdctsf_one[5][wireId] += 1;
227 m_mdctsf_win[5][wireId] += 1<<i;
232 if((
data[byteId + i*periods] >> bitId) & 1) {
233 if(flag_firstone && (i-seriesOne!=1) && (i!=0)){ m_mdcltrk_pre[wireId] = i+1; flag_firstone =
false;}
234 if( ((i-seriesOne)!=1) && (m_mdcltrk_aft[wireId]!=0) ) flag_lastone =
false;
235 if( (flag_firstone==
false) && ((i-seriesOne)==1) && flag_lastone) m_mdcltrk_aft[wireId]=i+1;
237 if((i-seriesOne) == 1 && firstSOne) m_mdcltrk_sone[wireId] += 1;
238 if(m_mdcltrk_sone[wireId] != 0 && (i-seriesOne) != 1) firstSOne =
false;
240 m_mdcltrk_one[wireId] += 1;
241 m_mdcltrk_win[wireId] += 1<<i;
245 if((
data[byteId + i*periods] >> bitId) & 1) {
246 if(flag_firstone && (i-seriesOne!=1) && (i!=0)){ m_mdcstrk_pre[wireId] = i+1; flag_firstone =
false;}
247 if( ((i-seriesOne)!=1) && (m_mdcstrk_aft[wireId]!=0) ) flag_lastone =
false;
248 if( (flag_firstone==
false) && ((i-seriesOne)==1) && flag_lastone) m_mdcstrk_aft[wireId]=i+1;
250 if((i-seriesOne) == 1 && firstSOne) m_mdcstrk_sone[wireId] += 1;
251 if(m_mdcstrk_sone[wireId] != 0 && (i-seriesOne) != 1) firstSOne =
false;
253 m_mdcstrk_one[wireId] += 1;
254 m_mdcstrk_win[wireId] += 1<<i;
259 if((
iter->first) == 234) {
261 if((
data[byteId + i*periods] >> bitId) & 1) {
263 if((i - seriesOne) == 1 && firstSOne) m_mdctsf_sone[0][wireId] += 1;
264 if(m_mdctsf_sone[0][wireId] != 0 && (i - seriesOne) != 1) firstSOne =
false;
266 m_mdctsf_one[0][wireId] += 1;
269 if((i - seriesOne) == 1 && firstSOne) m_mdctsf_sone[1][wireId] += 1;
270 if(m_mdctsf_sone[1][wireId] != 0 && (i - seriesOne) != 1) firstSOne =
false;
272 m_mdctsf_one[1][wireId] += 1;
277 if((
data[byteId + i*periods] >> bitId) & 1) {
278 if((i - seriesOne) == 1 && firstSOne) m_mdchit_sone[layerId][wireId] += 1;
279 if(m_mdchit_sone[layerId][wireId] != 0 && (i - seriesOne) != 1) firstSOne =
false;
281 m_mdchit_one[layerId][wireId] += 1;
285 if((
data[byteId + i*periods] >> bitId) & 1) {
286 m_mdcTrigCondi[wireId] = 1;
291 if((
iter->first) == 235 || (
iter->first) == 236) {
293 if((
data[byteId + i*periods] >> bitId) & 1) {
294 if((i - seriesOne) == 1 && firstSOne) m_mdcltrkc_sone[wireId] += 1;
295 if(m_mdcltrkc_sone[wireId] != 0 && (i - seriesOne) != 1) firstSOne =
false;
297 m_mdcltrkc_one[wireId] += 1;
298 if(wireId >= 128) m_mdcTrigCondi[wireId - 126] = 1;
302 if((
data[byteId + i*periods] >> bitId) & 1) {
303 if((i - seriesOne) == 1 && firstSOne) m_mdcstrkc_sone[wireId] += 1;
304 if(m_mdcstrkc_sone[wireId] != 0 && (i - seriesOne) != 1) firstSOne =
false;
306 m_mdcstrkc_one[wireId] += 1;
307 if(wireId >= 128) m_mdcTrigCondi[wireId - 122] = 1;