BOSS 7.1.2
BESIII Offline Software System
Loading...
Searching...
No Matches
TagParser3 Class Reference

#include <TagParser3.h>

+ Inheritance diagram for TagParser3:

Public Member Functions

 TagParser3 ()
 
 ~TagParser3 ()
 
StatusCode getVEntry (vector< int > &)
 
int getDstDataType ()
 
unsigned int getTagData0 ()
 
unsigned int getTagData1 ()
 
unsigned int getTagData2 ()
 
unsigned int getTagData3 ()
 
unsigned int getTagData4 ()
 
unsigned int getTagData5 ()
 
unsigned int getTagData6 ()
 
unsigned int getTagData7 ()
 
unsigned int getTagData8 ()
 
unsigned int getTagData9 ()
 
void setDstDataType (int t)
 
void setTagData0 (unsigned int t)
 
void setTagData1 (unsigned int t)
 
void setTagData2 (unsigned int t)
 
void setTagData3 (unsigned int t)
 
void setTagData4 (unsigned int t)
 
void setTagData5 (unsigned int t)
 
void setTagData6 (unsigned int t)
 
void setTagData7 (unsigned int t)
 
void setTagData8 (unsigned int t)
 
void setTagData9 (unsigned int t)
 
void setFileName (string name)
 
void setCriteria (vector< string > name)
 
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)
 
- Public Member Functions inherited from ITagParser
 ITagParser ()
 
 ~ITagParser ()
 

Detailed Description

Definition at line 15 of file TagParser3.h.

Constructor & Destructor Documentation

◆ TagParser3()

TagParser3::TagParser3 ( )

Definition at line 27 of file TagParser3.cxx.

27 {
28}

◆ ~TagParser3()

TagParser3::~TagParser3 ( )

Definition at line 30 of file TagParser3.cxx.

30 {
31}

Member Function Documentation

◆ getDstDataType()

int TagParser3::getDstDataType ( )
inlinevirtual

Implements ITagParser.

Definition at line 23 of file TagParser3.h.

23{ return m_dstDataType; }

◆ getTagData0()

unsigned int TagParser3::getTagData0 ( )
inlinevirtual

Implements ITagParser.

Definition at line 24 of file TagParser3.h.

24{ return m_tagData0; }

◆ getTagData1()

unsigned int TagParser3::getTagData1 ( )
inlinevirtual

Implements ITagParser.

Definition at line 25 of file TagParser3.h.

25{ return m_tagData1; }

◆ getTagData2()

unsigned int TagParser3::getTagData2 ( )
inlinevirtual

Implements ITagParser.

Definition at line 26 of file TagParser3.h.

26{ return m_tagData2; }

◆ getTagData3()

unsigned int TagParser3::getTagData3 ( )
inlinevirtual

Implements ITagParser.

Definition at line 27 of file TagParser3.h.

27{ return m_tagData3; }

◆ getTagData4()

unsigned int TagParser3::getTagData4 ( )
inlinevirtual

Implements ITagParser.

Definition at line 28 of file TagParser3.h.

28{ return m_tagData4; }

◆ getTagData5()

unsigned int TagParser3::getTagData5 ( )
inlinevirtual

Implements ITagParser.

Definition at line 29 of file TagParser3.h.

29{ return m_tagData5; }

◆ getTagData6()

unsigned int TagParser3::getTagData6 ( )
inlinevirtual

Implements ITagParser.

Definition at line 30 of file TagParser3.h.

30{ return m_tagData6; }

◆ getTagData7()

unsigned int TagParser3::getTagData7 ( )
inlinevirtual

Implements ITagParser.

Definition at line 31 of file TagParser3.h.

31{ return m_tagData7; }

◆ getTagData8()

unsigned int TagParser3::getTagData8 ( )
inlinevirtual

Implements ITagParser.

Definition at line 32 of file TagParser3.h.

32{ return m_tagData8; }

◆ getTagData9()

unsigned int TagParser3::getTagData9 ( )
inlinevirtual

Implements ITagParser.

Definition at line 33 of file TagParser3.h.

33{ return m_tagData9; }

◆ getVEntry()

StatusCode TagParser3::getVEntry ( std::vector< int > & ventry)
virtual

Implements ITagParser.

Definition at line 33 of file TagParser3.cxx.

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 }
366 flag++;
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();
377 delete file;
378 return StatusCode::SUCCESS;
379}
char * file
Definition DQA_TO_DB.cxx:15
void Tag1ToInt(unsigned int res, int &val1, int &val2, int &val3, int &val4)
vector< int > split(string str, string pattern, bool &all, bool &type)
void Tag2ToInt(unsigned int res, int &val1, int &val2, int &val3, int &val4, int &val5, int &val6)
char * c_str(Index i)

◆ setCriteria()

void TagParser3::setCriteria ( vector< string > name)
inlinevirtual

Implements ITagParser.

Definition at line 48 of file TagParser3.h.

48{m_criteria = name;}

◆ setDstDataType()

void TagParser3::setDstDataType ( int t)
inlinevirtual

Implements ITagParser.

Definition at line 35 of file TagParser3.h.

35{ m_dstDataType = t; }
TTree * t
Definition binning.cxx:23

◆ setFileName()

void TagParser3::setFileName ( string name)
inlinevirtual

Implements ITagParser.

Definition at line 47 of file TagParser3.h.

47{m_fileName = name; std::cout<<"filename is "<<m_fileName<<std::endl;}

◆ setTagData0()

void TagParser3::setTagData0 ( unsigned int t)
inlinevirtual

Implements ITagParser.

Definition at line 36 of file TagParser3.h.

36{ m_tagData0 = t; }

◆ setTagData1()

void TagParser3::setTagData1 ( unsigned int t)
inlinevirtual

Implements ITagParser.

Definition at line 37 of file TagParser3.h.

37{ m_tagData1 = t; }

◆ setTagData2()

void TagParser3::setTagData2 ( unsigned int t)
inlinevirtual

Implements ITagParser.

Definition at line 38 of file TagParser3.h.

38{ m_tagData2 = t; }

◆ setTagData3()

void TagParser3::setTagData3 ( unsigned int t)
inlinevirtual

Implements ITagParser.

Definition at line 39 of file TagParser3.h.

39{ m_tagData3 = t; }

◆ setTagData4()

void TagParser3::setTagData4 ( unsigned int t)
inlinevirtual

Implements ITagParser.

Definition at line 40 of file TagParser3.h.

40{ m_tagData4 = t; }

◆ setTagData5()

void TagParser3::setTagData5 ( unsigned int t)
inlinevirtual

Implements ITagParser.

Definition at line 41 of file TagParser3.h.

41{ m_tagData5 = t; }

◆ setTagData6()

void TagParser3::setTagData6 ( unsigned int t)
inlinevirtual

Implements ITagParser.

Definition at line 42 of file TagParser3.h.

42{ m_tagData6 = t; }

◆ setTagData7()

void TagParser3::setTagData7 ( unsigned int t)
inlinevirtual

Implements ITagParser.

Definition at line 43 of file TagParser3.h.

43{ m_tagData7 = t; }

◆ setTagData8()

void TagParser3::setTagData8 ( unsigned int t)
inlinevirtual

Implements ITagParser.

Definition at line 44 of file TagParser3.h.

44{ m_tagData8 = t; }

◆ setTagData9()

void TagParser3::setTagData9 ( unsigned int t)
inlinevirtual

Implements ITagParser.

Definition at line 45 of file TagParser3.h.

45{ m_tagData9 = t; }

◆ split()

vector< int > TagParser3::split ( string str,
string pattern,
bool & all,
bool & type )

Definition at line 398 of file TagParser3.cxx.

399{
400 vector<int> result;
401 unsigned int pos;
402 type = true;
403 all = false;
404 str += pattern;
405
406 for (unsigned int i = 0; i<str.size(); i++) {
407 pos = str.find(pattern, i);
408 if (pos<str.size()) {
409 string val = str.substr(i, pos-i);
410 if (val=="all") {
411 all=true;
412 } else if (val=="type0") {
413 type=false;
414 } else {
415 result.push_back(atoi(val.c_str()));
416 }
417 i = pos + pattern.size() - 1;
418 }
419 }
420 return result;
421}

Referenced by getVEntry().

◆ Tag1ToInt()

void TagParser3::Tag1ToInt ( unsigned int res,
int & val1,
int & val2,
int & val3,
int & val4 )

Definition at line 380 of file TagParser3.cxx.

381{
382 val1 = (res>>24) & 0xFF;
383 val2 = (res>>16) & 0xFF;
384 val3 = (res>>8) & 0xFF;
385 val4 = res & 0xFF;
386 return;
387}

Referenced by getVEntry().

◆ Tag2ToInt()

void TagParser3::Tag2ToInt ( unsigned int res,
int & val1,
int & val2,
int & val3,
int & val4,
int & val5,
int & val6 )

Definition at line 388 of file TagParser3.cxx.

389{
390 val1=(res>>26) & 0x3F;
391 val2=(res>>20) & 0x3F;
392 val3=(res>>15) & 0x1F;
393 val4=(res>>10) & 0x1F;
394 val5=(res>>5) & 0x1F;
395 val6 =res & 0x1F;
396 return;
397}

Referenced by getVEntry().


The documentation for this class was generated from the following files: