BOSS 7.0.7
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 ()
 
virtual StatusCode getVEntry (vector< int > &)=0
 
virtual int getDstDataType ()=0
 
virtual unsigned int getTagData0 ()=0
 
virtual unsigned int getTagData1 ()=0
 
virtual unsigned int getTagData2 ()=0
 
virtual unsigned int getTagData3 ()=0
 
virtual unsigned int getTagData4 ()=0
 
virtual unsigned int getTagData5 ()=0
 
virtual unsigned int getTagData6 ()=0
 
virtual unsigned int getTagData7 ()=0
 
virtual unsigned int getTagData8 ()=0
 
virtual unsigned int getTagData9 ()=0
 
virtual void setDstDataType (int t)=0
 
virtual void setTagData0 (unsigned int t)=0
 
virtual void setTagData1 (unsigned int t)=0
 
virtual void setTagData2 (unsigned int t)=0
 
virtual void setTagData3 (unsigned int t)=0
 
virtual void setTagData4 (unsigned int t)=0
 
virtual void setTagData5 (unsigned int t)=0
 
virtual void setTagData6 (unsigned int t)=0
 
virtual void setTagData7 (unsigned int t)=0
 
virtual void setTagData8 (unsigned int t)=0
 
virtual void setTagData9 (unsigned int t)=0
 
virtual void setFileName (string name)=0
 
virtual void setCriteria (vector< string > name)=0
 

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 ( vector< int > &  )
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[50] = 6;
94 D0_modeTag[51] = 7;
95 D0_modeTag[100] = 8;
96 D0_modeTag[101] = 9;
97 D0_modeTag[102] = 10;
98 D0_modeTag[103] = 11;
99 D0_modeTag[104] = 12;
100 D0_modeTag[105] = 13;
101 D0_modeTag[106] = 14;
102 D0_modeTag[107] = 15;
103 D0_modeTag[108] = 16;
104 D0_modeTag[109] = 17;
105 D0_modeTag[110] = 18;
106 D0_modeTag[111] = 19;
107 D0_modeTag[112] = 20;
108 D0_modeTag[113] = 21;
109 D0_modeTag[114] = 22;
110 D0_modeTag[115] = 23;
111 D0_modeTag[116] = 24;
112 D0_modeTag[117] = 25;
113 D0_modeTag[118] = 26;
114 D0_modeTag[119] = 27;
115 D0_modeTag[120] = 28;
116 D0_modeTag[121] = 29;
117 D0_modeTag[122] = 30;
118 D0_modeTag[123] = 30;
119 D0_modeTag[124] = 30;
120 D0_modeTag[125] = 30;
121 D0_modeTag[126] = 30;
122
123 Dp_modeTag[200] = 0;
124 Dp_modeTag[201] = 1;
125 Dp_modeTag[202] = 2;
126 Dp_modeTag[203] = 3;
127 Dp_modeTag[204] = 4;
128 Dp_modeTag[205] = 5;
129 Dp_modeTag[206] = 6;
130 Dp_modeTag[207] = 7;
131 Dp_modeTag[208] = 8;
132 Dp_modeTag[209] = 9;
133 Dp_modeTag[210] = 10;
134 Dp_modeTag[211] = 11;
135 Dp_modeTag[212] = 12;
136 Dp_modeTag[213] = 13;
137 Dp_modeTag[214] = 14;
138 Dp_modeTag[215] = 15;
139 Dp_modeTag[216] = 16;
140 Dp_modeTag[217] = 17;
141 Dp_modeTag[218] = 18;
142 Dp_modeTag[219] = 19;
143 Dp_modeTag[220] = 20;
144 Dp_modeTag[221] = 21;
145 Dp_modeTag[222] = 22;
146
147 int NumCriteria = m_criteria.size();
148 if (NumCriteria>27) {
149 std::cout<<"the number of criterias too much !"<<std::endl;
150 return StatusCode::SUCCESS;
151 }
152
153 vector<string> name_cut;
154 vector<int> CutLc, CutDs, CutD0, CutD;
155 CutLc.clear();
156 CutDs.clear();
157 CutD0.clear();
158 CutD.clear();
159 name_cut.clear();
160 bool allLc=false, allDs=false, allD0=false, allD=false, typeLc=true, typeDs=true, typeD0=true, typeD=true;
161
162 string name;
163 int nPos_1, nPos_2, nPos_3;
164 string pat=",";
165 map<string, int> Cut1, Cut2;
166 for (int i=0; i<NumCriteria; i++) {
167 std::cout<<"TagFilterSvc::criteria " << i << " : " << m_criteria[i] << endl;
168 nPos_1 = m_criteria[i].find_first_of("<");
169 nPos_2 = m_criteria[i].find_last_of("<");
170 nPos_3 = m_criteria[i].find_first_of("=");
171 if (nPos_3!=-1) {
172 name = m_criteria[i].substr(0,nPos_3);
173 name_cut.push_back(name);
174 if (name=="tagLc") {
175 CutLc = split(m_criteria[i].substr(nPos_3+1),pat, allLc, typeLc);
176 } else if (name=="tagDs") {
177 CutDs = split(m_criteria[i].substr(nPos_3+1),pat, allDs, typeDs);
178 } else if (name=="tagD0") {
179 CutD0 = split(m_criteria[i].substr(nPos_3+1),pat, allD0, typeD0);
180 } else if (name=="tagD") {
181 CutD = split(m_criteria[i].substr(nPos_3+1),pat, allD, typeD);
182 } else {
183 std::cout<<"pls check your tag criterias"<<std::endl;
184 return StatusCode::SUCCESS;
185 }
186 }
187 else if (nPos_1==-1 || nPos_2==-1 || nPos_1==nPos_2) {
188 std::cout<<"pls check your criterias"<<std::endl;
189 return StatusCode::SUCCESS;
190 }
191 else {
192 name = m_criteria[i].substr(nPos_1+1,nPos_2-nPos_1-1);
193 name_cut.push_back(name);
194 Cut1[name] = atoi(m_criteria[i].substr(0).c_str());
195 Cut2[name] = atoi(m_criteria[i].substr(nPos_2+1).c_str());
196 }
197 }
198
199 TFile* file = TFile::Open( m_fileName.c_str() );
200 TTree* t3 = (TTree*)file->Get("Entries");
201 UInt_t tagData0, tagData1, tagData2, tagData3, tagData4;
202 UInt_t tagData5, tagData6, tagData7, tagData8;
203 t3->SetBranchAddress("tagData0", &tagData0);
204 t3->SetBranchAddress("tagData1", &tagData1);
205 t3->SetBranchAddress("tagData2", &tagData2);
206 t3->SetBranchAddress("tagData3", &tagData3);
207 t3->SetBranchAddress("tagData4", &tagData4);
208 t3->SetBranchAddress("tagData5", &tagData5);
209 t3->SetBranchAddress("tagData6", &tagData6);
210 t3->SetBranchAddress("tagData7", &tagData7);
211 t3->SetBranchAddress("tagData8", &tagData8);
212
213 Int_t npip, npim, nkp, nkm, nlambda, nalambda;
214 Int_t npp, npm, nep, nem, nmup, nmum, neta, npi0, ngamma, nks;
215 Int_t nGoodCharged, nCharged, nGoodChargedp, nGoodChargedm, totCharged, nNeutrk, nTottrk;
216
217 for (int i=0;i<t3->GetEntries();i++ ) {
218 t3->GetEntry(i);
219 nGoodCharged = tagData0;
220 Tag1ToInt(tagData1, nNeutrk, nTottrk, ngamma, npi0);
221 Tag2ToInt(tagData2, npip, npim, nkp, nkm, npp, npm);
222 Tag2ToInt(tagData3, nlambda, nalambda, nep, nem, nmup, nmum);
223 Tag2ToInt(tagData4, nks, neta, nCharged, nGoodChargedp, nGoodChargedm, totCharged);
224
225 unsigned int flag = 0;
226 bool isTag = false;
227 int tagvalue=-1;
228 for (unsigned int j=0; j<name_cut.size(); j++ ) {
229 if (name_cut[j]=="tagLc") {
230 if (tagData5>0) {
231 if ( !(tagData5&(1<<31)) && typeLc ) break;
232 if ( !allLc ) {
233 isTag = false;
234 for (unsigned int k=0; k<CutLc.size(); k++) {
235 if ( tagData5&(1<<Lc_modeTag[CutLc[k]]) ) {
236 isTag = true;
237 break;
238 }
239 }
240 if (!isTag) break;
241 }
242 } else {
243 break;
244 }
245 }
246 else if (name_cut[j]=="tagDs") {
247 if (tagData6>0) {
248 if ( !(tagData6&(1<<31)) && typeDs ) break;
249 if ( !allDs ) {
250 isTag = false;
251 for (unsigned int k=0; k<CutDs.size(); k++) {
252 if ( tagData6&(1<<Ds_modeTag[CutDs[k]]) ) {
253 isTag = true;
254 break;
255 }
256 }
257 if (!isTag) break;
258 }
259 } else {
260 break;
261 }
262 }
263 else if (name_cut[j]=="tagD0") {
264 if (tagData7>0) {
265 if ( !(tagData7&(1<<31)) && typeD0 ) break;
266 if ( !allD0 ) {
267 isTag = false;
268 for (unsigned int k=0; k<CutD0.size(); k++) {
269 if ( tagData7&(1<<D0_modeTag[CutD0[k]]) ) {
270 isTag = true;
271 break;
272 }
273 }
274 if (!isTag) break;
275 }
276 } else {
277 break;
278 }
279 }
280 else if (name_cut[j]=="tagD") {
281 if (tagData8>0) {
282 if ( !(tagData8&(1<<31)) && typeD ) break;
283 if ( !allD ) {
284 isTag = false;
285 for (unsigned int k=0; k<CutD.size(); k++) {
286 if ( tagData8&(1<<Dp_modeTag[CutD[k]]) ) {
287 isTag = true;
288 break;
289 }
290 }
291 if (!isTag) break;
292 }
293 } else {
294 break;
295 }
296 }
297 else {
298 if (name_cut[j]=="NumOfGoodCh") {tagvalue = nGoodCharged;}
299 else if (name_cut[j]=="NumOfNeutrk") {tagvalue = nNeutrk;}
300 else if (name_cut[j]=="NumOfTottrk") {tagvalue = nTottrk;}
301 else if (name_cut[j]=="NumOfGamma") {tagvalue = ngamma;}
302 else if (name_cut[j]=="NumOfPion0") {tagvalue = npi0;}
303 else if (name_cut[j]=="NumOfPionp") {tagvalue = npip;}
304 else if (name_cut[j]=="NumOfPionm") {tagvalue = npim;}
305 else if (name_cut[j]=="NumOfKaonp") {tagvalue = nkp;}
306 else if (name_cut[j]=="NumOfKaonm") {tagvalue = nkm;}
307 else if (name_cut[j]=="NumOfProtonp") {tagvalue = npp;}
308 else if (name_cut[j]=="NumOfProtonm") {tagvalue = npm;}
309 else if (name_cut[j]=="NumOfLambda") {tagvalue = nlambda;}
310 else if (name_cut[j]=="NumOfALambda" ) {tagvalue = nalambda;}
311 else if (name_cut[j]=="NumOfElectronp") {tagvalue = nep;}
312 else if (name_cut[j]=="NumOfElectronm") {tagvalue = nem;}
313 else if (name_cut[j]=="NumOfMuonp") {tagvalue = nmup;}
314 else if (name_cut[j]=="NumOfMuonm") {tagvalue = nmum;}
315 else if (name_cut[j]=="NumOfKs") {tagvalue = nks;}
316 else if (name_cut[j]=="NumOfEta") {tagvalue = neta;}
317 else if (name_cut[j]=="NumOfCharged") {tagvalue = nCharged;}
318 else if (name_cut[j]=="NumOfGoodChp") {tagvalue = nGoodChargedp;}
319 else if (name_cut[j]=="NumOfGoodChm") {tagvalue = nGoodChargedm;}
320 else if (name_cut[j]=="TotCharged") {tagvalue = totCharged;}
321 else {
322 cout << "pls check the name of your criteria !" << endl;
323 break;
324 }
325 if ( tagvalue>=Cut2[name_cut[j]] || tagvalue<=Cut1[name_cut[j]] ) break;
326 }
327 flag++;
328 }
329 if (flag==name_cut.size()) {
330 ventry.push_back(i);
331 }
332 }
333 CutLc.clear();
334 CutDs.clear();
335 CutD0.clear();
336 CutD.clear();
337 name_cut.clear();
338 delete file;
339 return StatusCode::SUCCESS;
340}
char * file
Definition: DQA_TO_DB.cxx:15
void Tag1ToInt(unsigned int res, int &val1, int &val2, int &val3, int &val4)
Definition: TagParser3.cxx:341
vector< int > split(string str, string pattern, bool &all, bool &type)
Definition: TagParser3.cxx:359
void Tag2ToInt(unsigned int res, int &val1, int &val2, int &val3, int &val4, int &val5, int &val6)
Definition: TagParser3.cxx:349
char * c_str(Index i)
Definition: EvtCyclic3.cc:252

◆ 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 359 of file TagParser3.cxx.

360{
361 vector<int> result;
362 unsigned int pos;
363 type = true;
364 all = false;
365 str += pattern;
366
367 for (unsigned int i = 0; i<str.size(); i++) {
368 pos = str.find(pattern, i);
369 if (pos<str.size()) {
370 string val = str.substr(i, pos-i);
371 if (val=="all") {
372 all=true;
373 } else if (val=="type0") {
374 type=false;
375 } else {
376 result.push_back(atoi(val.c_str()));
377 }
378 i = pos + pattern.size() - 1;
379 }
380 }
381 return result;
382}

Referenced by getVEntry().

◆ Tag1ToInt()

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

Definition at line 341 of file TagParser3.cxx.

342{
343 val1 = (res>>24) & 0xFF;
344 val2 = (res>>16) & 0xFF;
345 val3 = (res>>8) & 0xFF;
346 val4 = res & 0xFF;
347 return;
348}

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 349 of file TagParser3.cxx.

350{
351 val1=(res>>26) & 0x3F;
352 val2=(res>>20) & 0x3F;
353 val3=(res>>15) & 0x1F;
354 val4=(res>>10) & 0x1F;
355 val5=(res>>5) & 0x1F;
356 val6 =res & 0x1F;
357 return;
358}

Referenced by getVEntry().


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