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

◆ 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 318 of file TagParser2.cxx.

319{
320 vector<int> result;
321 unsigned int pos;
322 type = true;
323 all = false;
324 str += pattern;
325
326 for (unsigned int i = 0; i<str.size(); i++) {
327 pos = str.find(pattern, i);
328 if (pos<str.size()) {
329 string val = str.substr(i, pos-i);
330 if (val=="all") {
331 all=true;
332 } else if (val=="type0") {
333 type=false;
334 } else {
335 result.push_back(atoi(val.c_str()));
336 }
337 i = pos + pattern.size() - 1;
338 }
339 }
340 return result;
341}

Referenced by getVEntry().

◆ Tag1ToInt()

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

Definition at line 300 of file TagParser2.cxx.

301{
302 val1 = (res>>24) & 0xFF;
303 val2 = (res>>16) & 0xFF;
304 val3 = (res>>8) & 0xFF;
305 val4 = res & 0xFF;
306 return;
307}

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 308 of file TagParser2.cxx.

309{
310 val1=(res>>26) & 0x3F;
311 val2=(res>>20) & 0x3F;
312 val3=(res>>15) & 0x1F;
313 val4=(res>>10) & 0x1F;
314 val5=(res>>5) & 0x1F;
315 val6 =res & 0x1F;
316 return;
317}

Referenced by getVEntry().


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