33 {
34
35 std::map<int, unsigned int> Lc_modeTag, Ds_modeTag, D0_modeTag, Dp_modeTag;
36
37 Lc_modeTag[1000] = 0;
38 Lc_modeTag[1001] = 1;
39 Lc_modeTag[1002] = 2;
40 Lc_modeTag[1003] = 3;
41 Lc_modeTag[1004] = 4;
42 Lc_modeTag[1005] = 5;
43 Lc_modeTag[1030] = 6;
44 Lc_modeTag[1031] = 7;
45 Lc_modeTag[1032] = 8;
46 Lc_modeTag[1033] = 9;
47 Lc_modeTag[1034] = 10;
48 Lc_modeTag[1060] = 11;
49 Lc_modeTag[1061] = 12;
50 Lc_modeTag[1062] = 13;
51 Lc_modeTag[1063] = 14;
52 Lc_modeTag[1064] = 15;
53 Lc_modeTag[1065] = 16;
54
55 Ds_modeTag[400] = 1;
56 Ds_modeTag[401] = 0;
57 Ds_modeTag[402] = 2;
58 Ds_modeTag[403] = 13;
59 Ds_modeTag[404] = 3;
60 Ds_modeTag[405] = 4;
61 Ds_modeTag[406] = 5;
62 Ds_modeTag[407] = 14;
63 Ds_modeTag[420] = 28;
64 Ds_modeTag[421] = 6;
65 Ds_modeTag[422] = 24;
66 Ds_modeTag[423] = 25;
67 Ds_modeTag[424] = 26;
68 Ds_modeTag[425] = 27;
69 Ds_modeTag[440] = 7;
70 Ds_modeTag[441] = 8;
71 Ds_modeTag[442] = 20;
72 Ds_modeTag[450] = 21;
73 Ds_modeTag[451] = 22;
74 Ds_modeTag[452] = 23;
75 Ds_modeTag[460] = 9;
76 Ds_modeTag[461] = 15;
77 Ds_modeTag[470] = 16;
78 Ds_modeTag[471] = 17;
79 Ds_modeTag[480] = 10;
80 Ds_modeTag[481] = 11;
81 Ds_modeTag[500] = 29;
82 Ds_modeTag[501] = 18;
83 Ds_modeTag[502] = 12;
84 Ds_modeTag[503] = 19;
85 Ds_modeTag[504] = 30;
86
87 D0_modeTag[0] = 0;
88 D0_modeTag[1] = 1;
89 D0_modeTag[2] = 2;
90 D0_modeTag[3] = 3;
91 D0_modeTag[4] = 4;
92 D0_modeTag[5] = 5;
93 D0_modeTag[6] = 6;
94 D0_modeTag[7] = 7;
95 D0_modeTag[8] = 8;
96 D0_modeTag[9] = 8;
97 D0_modeTag[10] = 9;
98 D0_modeTag[50] = 10;
99 D0_modeTag[51] = 11;
100 D0_modeTag[100] = 12;
101 D0_modeTag[101] = 13;
102 D0_modeTag[102] = 14;
103 D0_modeTag[103] = 15;
104 D0_modeTag[104] = 16;
105 D0_modeTag[105] = 16;
106 D0_modeTag[106] = 17;
107 D0_modeTag[107] = 16;
108 D0_modeTag[108] = 16;
109 D0_modeTag[109] = 18;
110 D0_modeTag[110] = 19;
111 D0_modeTag[111] = 20;
112 D0_modeTag[112] = 16;
113 D0_modeTag[113] = 21;
114 D0_modeTag[114] = 22;
115 D0_modeTag[115] = 23;
116 D0_modeTag[116] = 24;
117 D0_modeTag[117] = 25;
118 D0_modeTag[118] = 26;
119 D0_modeTag[119] = 27;
120 D0_modeTag[120] = 28;
121 D0_modeTag[121] = 29;
122 D0_modeTag[122] = 30;
123 D0_modeTag[123] = 30;
124 D0_modeTag[124] = 30;
125 D0_modeTag[125] = 30;
126 D0_modeTag[126] = 30;
127 D0_modeTag[127] = 30;
128 D0_modeTag[128] = 30;
129 D0_modeTag[129] = 30;
130 D0_modeTag[130] = 30;
131 D0_modeTag[131] = 30;
132 D0_modeTag[132] = 30;
133 D0_modeTag[133] = 30;
134 D0_modeTag[134] = 30;
135 D0_modeTag[135] = 30;
136
137 Dp_modeTag[200] = 0;
138 Dp_modeTag[201] = 1;
139 Dp_modeTag[202] = 2;
140 Dp_modeTag[203] = 3;
141 Dp_modeTag[204] = 4;
142 Dp_modeTag[205] = 5;
143 Dp_modeTag[206] = 6;
144 Dp_modeTag[207] = 7;
145 Dp_modeTag[208] = 8;
146 Dp_modeTag[209] = 9;
147 Dp_modeTag[210] = 10;
148 Dp_modeTag[211] = 11;
149 Dp_modeTag[212] = 12;
150 Dp_modeTag[213] = 13;
151 Dp_modeTag[214] = 14;
152 Dp_modeTag[215] = 15;
153 Dp_modeTag[216] = 16;
154 Dp_modeTag[217] = 17;
155 Dp_modeTag[218] = 18;
156 Dp_modeTag[219] = 19;
157 Dp_modeTag[220] = 20;
158 Dp_modeTag[221] = 21;
159 Dp_modeTag[222] = 22;
160 Dp_modeTag[223] = 23;
161 Dp_modeTag[224] = 24;
162 Dp_modeTag[225] = 24;
163 Dp_modeTag[226] = 25;
164 Dp_modeTag[227] = 25;
165 Dp_modeTag[228] = 26;
166 Dp_modeTag[229] = 27;
167 Dp_modeTag[230] = 28;
168 Dp_modeTag[231] = 29;
169 Dp_modeTag[232] = 29;
170 Dp_modeTag[233] = 29;
171 Dp_modeTag[234] = 29;
172 Dp_modeTag[235] = 29;
173 Dp_modeTag[236] = 29;
174 Dp_modeTag[237] = 29;
175 Dp_modeTag[238] = 29;
176 Dp_modeTag[239] = 29;
177 Dp_modeTag[240] = 29;
178 Dp_modeTag[241] = 29;
179 Dp_modeTag[242] = 29;
180 Dp_modeTag[290] = 30;
181 Dp_modeTag[291] = 30;
182 Dp_modeTag[292] = 30;
183 Dp_modeTag[293] = 30;
184 Dp_modeTag[294] = 30;
185
186 int NumCriteria = m_criteria.size();
187 if (NumCriteria>27) {
188 std::cout<<"the number of criterias too much !"<<std::endl;
189 return StatusCode::SUCCESS;
190 }
191
192 vector<string> name_cut;
193 vector<int> CutLc, CutDs, CutD0, CutD;
194 CutLc.clear();
195 CutDs.clear();
196 CutD0.clear();
197 CutD.clear();
198 name_cut.clear();
199 bool allLc=false, allDs=false, allD0=false, allD=false, typeLc=true, typeDs=true, typeD0=true, typeD=true;
200
201 string name;
202 int nPos_1, nPos_2, nPos_3;
203 string pat=",";
204 map<string, int> Cut1, Cut2;
205 for (int i=0; i<NumCriteria; i++) {
206 std::cout<<"TagFilterSvc::criteria " << i << " : " << m_criteria[i] << endl;
207 nPos_1 = m_criteria[i].find_first_of("<");
208 nPos_2 = m_criteria[i].find_last_of("<");
209 nPos_3 = m_criteria[i].find_first_of("=");
210 if (nPos_3!=-1) {
211 name = m_criteria[i].substr(0,nPos_3);
212 name_cut.push_back(name);
213 if (name=="tagLc") {
214 CutLc =
split(m_criteria[i].substr(nPos_3+1),pat, allLc, typeLc);
215 } else if (name=="tagDs") {
216 CutDs =
split(m_criteria[i].substr(nPos_3+1),pat, allDs, typeDs);
217 } else if (name=="tagD0") {
218 CutD0 =
split(m_criteria[i].substr(nPos_3+1),pat, allD0, typeD0);
219 } else if (name=="tagD") {
220 CutD =
split(m_criteria[i].substr(nPos_3+1),pat, allD, typeD);
221 } else {
222 std::cout<<"pls check your tag criterias"<<std::endl;
223 return StatusCode::SUCCESS;
224 }
225 }
226 else if (nPos_1==-1 || nPos_2==-1 || nPos_1==nPos_2) {
227 std::cout<<"pls check your criterias"<<std::endl;
228 return StatusCode::SUCCESS;
229 }
230 else {
231 name = m_criteria[i].substr(nPos_1+1,nPos_2-nPos_1-1);
232 name_cut.push_back(name);
233 Cut1[name] = atoi(m_criteria[i].substr(0).
c_str());
234 Cut2[name] = atoi(m_criteria[i].substr(nPos_2+1).
c_str());
235 }
236 }
237
238 TFile*
file = TFile::Open( m_fileName.c_str() );
239 TTree* t3 = (TTree*)
file->Get(
"Entries");
240 UInt_t tagData0, tagData1, tagData2, tagData3, tagData4;
241 UInt_t tagData5, tagData6, tagData7, tagData8;
242 t3->SetBranchAddress("tagData0", &tagData0);
243 t3->SetBranchAddress("tagData1", &tagData1);
244 t3->SetBranchAddress("tagData2", &tagData2);
245 t3->SetBranchAddress("tagData3", &tagData3);
246 t3->SetBranchAddress("tagData4", &tagData4);
247 t3->SetBranchAddress("tagData5", &tagData5);
248 t3->SetBranchAddress("tagData6", &tagData6);
249 t3->SetBranchAddress("tagData7", &tagData7);
250 t3->SetBranchAddress("tagData8", &tagData8);
251
252 Int_t npip, npim, nkp, nkm, nlambda, nalambda;
253 Int_t npp, npm, nep, nem, nmup, nmum, neta, npi0, ngamma, nks;
254 Int_t nGoodCharged, nCharged, nGoodChargedp, nGoodChargedm, totCharged, nNeutrk, nTottrk;
255
256 for (int i=0;i<t3->GetEntries();i++ ) {
257 t3->GetEntry(i);
258 nGoodCharged = tagData0;
259 Tag1ToInt(tagData1, nNeutrk, nTottrk, ngamma, npi0);
260 Tag2ToInt(tagData2, npip, npim, nkp, nkm, npp, npm);
261 Tag2ToInt(tagData3, nlambda, nalambda, nep, nem, nmup, nmum);
262 Tag2ToInt(tagData4, nks, neta, nCharged, nGoodChargedp, nGoodChargedm, totCharged);
263
264 unsigned int flag = 0;
265 bool isTag = false;
266 int tagvalue=-1;
267 for (unsigned int j=0; j<name_cut.size(); j++ ) {
268 if (name_cut[j]=="tagLc") {
269 if (tagData5>0) {
270 if ( !(tagData5&(1<<31)) && typeLc ) break;
271 if ( !allLc ) {
272 isTag = false;
273 for (unsigned int k=0; k<CutLc.size(); k++) {
274 if ( tagData5&(1<<Lc_modeTag[CutLc[k]]) ) {
275 isTag = true;
276 break;
277 }
278 }
279 if (!isTag) break;
280 }
281 } else {
282 break;
283 }
284 }
285 else if (name_cut[j]=="tagDs") {
286 if (tagData6>0) {
287 if ( !(tagData6&(1<<31)) && typeDs ) break;
288 if ( !allDs ) {
289 isTag = false;
290 for (unsigned int k=0; k<CutDs.size(); k++) {
291 if ( tagData6&(1<<Ds_modeTag[CutDs[k]]) ) {
292 isTag = true;
293 break;
294 }
295 }
296 if (!isTag) break;
297 }
298 } else {
299 break;
300 }
301 }
302 else if (name_cut[j]=="tagD0") {
303 if (tagData7>0) {
304 if ( !(tagData7&(1<<31)) && typeD0 ) break;
305 if ( !allD0 ) {
306 isTag = false;
307 for (unsigned int k=0; k<CutD0.size(); k++) {
308 if ( tagData7&(1<<D0_modeTag[CutD0[k]]) ) {
309 isTag = true;
310 break;
311 }
312 }
313 if (!isTag) break;
314 }
315 } else {
316 break;
317 }
318 }
319 else if (name_cut[j]=="tagD") {
320 if (tagData8>0) {
321 if ( !(tagData8&(1<<31)) && typeD ) break;
322 if ( !allD ) {
323 isTag = false;
324 for (unsigned int k=0; k<CutD.size(); k++) {
325 if ( tagData8&(1<<Dp_modeTag[CutD[k]]) ) {
326 isTag = true;
327 break;
328 }
329 }
330 if (!isTag) break;
331 }
332 } else {
333 break;
334 }
335 }
336 else {
337 if (name_cut[j]=="NumOfGoodCh") {tagvalue = nGoodCharged;}
338 else if (name_cut[j]=="NumOfNeutrk") {tagvalue = nNeutrk;}
339 else if (name_cut[j]=="NumOfTottrk") {tagvalue = nTottrk;}
340 else if (name_cut[j]=="NumOfGamma") {tagvalue = ngamma;}
341 else if (name_cut[j]=="NumOfPion0") {tagvalue = npi0;}
342 else if (name_cut[j]=="NumOfPionp") {tagvalue = npip;}
343 else if (name_cut[j]=="NumOfPionm") {tagvalue = npim;}
344 else if (name_cut[j]=="NumOfKaonp") {tagvalue = nkp;}
345 else if (name_cut[j]=="NumOfKaonm") {tagvalue = nkm;}
346 else if (name_cut[j]=="NumOfProtonp") {tagvalue = npp;}
347 else if (name_cut[j]=="NumOfProtonm") {tagvalue = npm;}
348 else if (name_cut[j]=="NumOfLambda") {tagvalue = nlambda;}
349 else if (name_cut[j]=="NumOfALambda" ) {tagvalue = nalambda;}
350 else if (name_cut[j]=="NumOfElectronp") {tagvalue = nep;}
351 else if (name_cut[j]=="NumOfElectronm") {tagvalue = nem;}
352 else if (name_cut[j]=="NumOfMuonp") {tagvalue = nmup;}
353 else if (name_cut[j]=="NumOfMuonm") {tagvalue = nmum;}
354 else if (name_cut[j]=="NumOfKs") {tagvalue = nks;}
355 else if (name_cut[j]=="NumOfEta") {tagvalue = neta;}
356 else if (name_cut[j]=="NumOfCharged") {tagvalue = nCharged;}
357 else if (name_cut[j]=="NumOfGoodChp") {tagvalue = nGoodChargedp;}
358 else if (name_cut[j]=="NumOfGoodChm") {tagvalue = nGoodChargedm;}
359 else if (name_cut[j]=="TotCharged") {tagvalue = totCharged;}
360 else {
361 cout << "pls check the name of your criteria !" << endl;
362 break;
363 }
364 if ( tagvalue>=Cut2[name_cut[j]] || tagvalue<=Cut1[name_cut[j]] ) break;
365 }
367 }
368 if (
flag==name_cut.size()) {
369 ventry.push_back(i);
370 }
371 }
372 CutLc.clear();
373 CutDs.clear();
374 CutD0.clear();
375 CutD.clear();
376 name_cut.clear();
378 return StatusCode::SUCCESS;
379}
void Tag2ToInt(unsigned int res, int &val1, int &val2, int &val3, int &val4, int &val5, int &val6)
vector< int > split(string str, string pattern, bool &all, bool &type)
void Tag1ToInt(unsigned int res, int &val1, int &val2, int &val3, int &val4)