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