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

#include <TagParser2.h>

+ Inheritance diagram for TagParser2:

Public Member Functions

 TagParser2 ()
 
 ~TagParser2 ()
 
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 TagParser2.h.

Constructor & Destructor Documentation

◆ TagParser2()

TagParser2::TagParser2 ( )

Definition at line 27 of file TagParser2.cxx.

27 {
28}

◆ ~TagParser2()

TagParser2::~TagParser2 ( )

Definition at line 30 of file TagParser2.cxx.

30 {
31}

Member Function Documentation

◆ getDstDataType()

int TagParser2::getDstDataType ( )
inlinevirtual

Implements ITagParser.

Definition at line 23 of file TagParser2.h.

23{ return m_dstDataType; }

◆ getTagData0()

unsigned int TagParser2::getTagData0 ( )
inlinevirtual

Implements ITagParser.

Definition at line 24 of file TagParser2.h.

24{ return m_tagData0; }

◆ getTagData1()

unsigned int TagParser2::getTagData1 ( )
inlinevirtual

Implements ITagParser.

Definition at line 25 of file TagParser2.h.

25{ return m_tagData1; }

◆ getTagData2()

unsigned int TagParser2::getTagData2 ( )
inlinevirtual

Implements ITagParser.

Definition at line 26 of file TagParser2.h.

26{ return m_tagData2; }

◆ getTagData3()

unsigned int TagParser2::getTagData3 ( )
inlinevirtual

Implements ITagParser.

Definition at line 27 of file TagParser2.h.

27{ return m_tagData3; }

◆ getTagData4()

unsigned int TagParser2::getTagData4 ( )
inlinevirtual

Implements ITagParser.

Definition at line 28 of file TagParser2.h.

28{ return m_tagData4; }

◆ getTagData5()

unsigned int TagParser2::getTagData5 ( )
inlinevirtual

Implements ITagParser.

Definition at line 29 of file TagParser2.h.

29{ return m_tagData5; }

◆ getTagData6()

unsigned int TagParser2::getTagData6 ( )
inlinevirtual

Implements ITagParser.

Definition at line 30 of file TagParser2.h.

30{ return m_tagData6; }

◆ getTagData7()

unsigned int TagParser2::getTagData7 ( )
inlinevirtual

Implements ITagParser.

Definition at line 31 of file TagParser2.h.

31{ return m_tagData7; }

◆ getTagData8()

unsigned int TagParser2::getTagData8 ( )
inlinevirtual

Implements ITagParser.

Definition at line 32 of file TagParser2.h.

32{ return m_tagData8; }

◆ getTagData9()

unsigned int TagParser2::getTagData9 ( )
inlinevirtual

Implements ITagParser.

Definition at line 33 of file TagParser2.h.

33{ return m_tagData9; }

◆ getVEntry()

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

Implements ITagParser.

Definition at line 33 of file TagParser2.cxx.

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;
243 unsigned int flag;
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
321 flag = 0;
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;
352 flag++;
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();
362 delete file;
363 return StatusCode::SUCCESS;
364}
char * file
Definition DQA_TO_DB.cxx:15
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)
char * c_str(Index i)

◆ setCriteria()

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

Implements ITagParser.

Definition at line 48 of file TagParser2.h.

48{m_criteria = name;}

◆ setDstDataType()

void TagParser2::setDstDataType ( int t)
inlinevirtual

Implements ITagParser.

Definition at line 35 of file TagParser2.h.

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

◆ setFileName()

void TagParser2::setFileName ( string name)
inlinevirtual

Implements ITagParser.

Definition at line 47 of file TagParser2.h.

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

◆ setTagData0()

void TagParser2::setTagData0 ( unsigned int t)
inlinevirtual

Implements ITagParser.

Definition at line 36 of file TagParser2.h.

36{ m_tagData0 = t; }

◆ setTagData1()

void TagParser2::setTagData1 ( unsigned int t)
inlinevirtual

Implements ITagParser.

Definition at line 37 of file TagParser2.h.

37{ m_tagData1 = t; }

◆ setTagData2()

void TagParser2::setTagData2 ( unsigned int t)
inlinevirtual

Implements ITagParser.

Definition at line 38 of file TagParser2.h.

38{ m_tagData2 = t; }

◆ setTagData3()

void TagParser2::setTagData3 ( unsigned int t)
inlinevirtual

Implements ITagParser.

Definition at line 39 of file TagParser2.h.

39{ m_tagData3 = t; }

◆ setTagData4()

void TagParser2::setTagData4 ( unsigned int t)
inlinevirtual

Implements ITagParser.

Definition at line 40 of file TagParser2.h.

40{ m_tagData4 = t; }

◆ setTagData5()

void TagParser2::setTagData5 ( unsigned int t)
inlinevirtual

Implements ITagParser.

Definition at line 41 of file TagParser2.h.

41{ m_tagData5 = t; }

◆ setTagData6()

void TagParser2::setTagData6 ( unsigned int t)
inlinevirtual

Implements ITagParser.

Definition at line 42 of file TagParser2.h.

42{ m_tagData6 = t; }

◆ setTagData7()

void TagParser2::setTagData7 ( unsigned int t)
inlinevirtual

Implements ITagParser.

Definition at line 43 of file TagParser2.h.

43{ m_tagData7 = t; }

◆ setTagData8()

void TagParser2::setTagData8 ( unsigned int t)
inlinevirtual

Implements ITagParser.

Definition at line 44 of file TagParser2.h.

44{ m_tagData8 = t; }

◆ setTagData9()

void TagParser2::setTagData9 ( unsigned int t)
inlinevirtual

Implements ITagParser.

Definition at line 45 of file TagParser2.h.

45{ m_tagData9 = t; }

◆ split()

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

Definition at line 383 of file TagParser2.cxx.

384{
385 vector<int> result;
386 unsigned int pos;
387 type = true;
388 all = false;
389 str += pattern;
390
391 for (unsigned int i = 0; i<str.size(); i++) {
392 pos = str.find(pattern, i);
393 if (pos<str.size()) {
394 string val = str.substr(i, pos-i);
395 if (val=="all") {
396 all=true;
397 } else if (val=="type0") {
398 type=false;
399 } else {
400 result.push_back(atoi(val.c_str()));
401 }
402 i = pos + pattern.size() - 1;
403 }
404 }
405 return result;
406}

Referenced by getVEntry().

◆ Tag1ToInt()

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

Definition at line 365 of file TagParser2.cxx.

366{
367 val1 = (res>>24) & 0xFF;
368 val2 = (res>>16) & 0xFF;
369 val3 = (res>>8) & 0xFF;
370 val4 = res & 0xFF;
371 return;
372}

Referenced by getVEntry().

◆ Tag2ToInt()

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

Definition at line 373 of file TagParser2.cxx.

374{
375 val1=(res>>26) & 0x3F;
376 val2=(res>>20) & 0x3F;
377 val3=(res>>15) & 0x1F;
378 val4=(res>>10) & 0x1F;
379 val5=(res>>5) & 0x1F;
380 val6 =res & 0x1F;
381 return;
382}

Referenced by getVEntry().


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