BOSS 7.1.0
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 unsigned int Ncut_oth=0;
135 vector<string> name_tag, name_oth;
136 vector<int> CutDs, CutD0, CutD;
137 CutDs.clear();
138 CutD0.clear();
139 CutD.clear();
140 name_tag.clear();
141 name_oth.clear();
142 bool allDs=false, allD0=false, allD=false, typeDs=true, typeD0=true, typeD=true, QC=false;
143
144 string name;
145 int nPos_1, nPos_2, nPos_3, nPos_4;
146 string pat=",";
147 map<string, int> Cut1, Cut2;
148 for (int i=0; i<NumCriteria; i++) {
149 std::cout<<"TagFilterSvc::criteria " << i << " : " << m_criteria[i];
150 nPos_1 = m_criteria[i].find_first_of("<");
151 nPos_2 = m_criteria[i].find_last_of("<");
152 nPos_3 = m_criteria[i].find_first_of("=");
153 nPos_4 = m_criteria[i].find("QCon");
154 if (nPos_4!=-1) {
155 QC=true;
156 cout << " -> Turn on QC";
157 }
158 else if (nPos_3!=-1) {
159 name = m_criteria[i].substr(0,nPos_3);
160 name_tag.push_back(name);
161 if (name=="tagDs") {
162 CutDs = split(m_criteria[i].substr(nPos_3+1),pat, allDs, typeDs);
163 } else if (name=="tagD0") {
164 CutD0 = split(m_criteria[i].substr(nPos_3+1),pat, allD0, typeD0);
165 } else if (name=="tagD") {
166 CutD = split(m_criteria[i].substr(nPos_3+1),pat, allD, typeD);
167 } else {
168 std::cout<<"pls check your tag criterias"<<std::endl;
169 return StatusCode::SUCCESS;
170 }
171 }
172 else if (nPos_1==-1 || nPos_2==-1 || nPos_1==nPos_2) {
173 std::cout<<"pls check your criterias"<<std::endl;
174 return StatusCode::SUCCESS;
175 }
176 else {
177 name = m_criteria[i].substr(nPos_1+1,nPos_2-nPos_1-1);
178 name_oth.push_back(name);
179 Ncut_oth++;
180 Cut1[name] = atoi(m_criteria[i].substr(0).c_str());
181 Cut2[name] = atoi(m_criteria[i].substr(nPos_2+1).c_str());
182 }
183 std::cout<<std::endl;
184 }
185
186 TFile* file = TFile::Open( m_fileName.c_str() );
187 TTree* t3 = (TTree*)file->Get("Entries");
188 UInt_t tagData0, tagData1, tagData2, tagData3, tagData4;
189 UInt_t tagData5, tagData6, tagData7, tagData8;
190 t3->SetBranchAddress("tagData0", &tagData0);
191 t3->SetBranchAddress("tagData1", &tagData1);
192 t3->SetBranchAddress("tagData2", &tagData2);
193 t3->SetBranchAddress("tagData3", &tagData3);
194 t3->SetBranchAddress("tagData4", &tagData4);
195 t3->SetBranchAddress("tagData5", &tagData5);
196 t3->SetBranchAddress("tagData6", &tagData6);
197 t3->SetBranchAddress("tagData7", &tagData7);
198 t3->SetBranchAddress("tagData8", &tagData8);
199
200 Int_t npip, npim, nkp, nkm, nlambda, nalambda;
201 Int_t npp, npm, nep, nem, nmup, nmum, neta, npi0, ngamma, nks;
202 Int_t nGoodCharged, nCharged, nGoodChargedp, nGoodChargedm, totCharged, nNeutrk, nTottrk;
203 bool isTag, isPID;
204 unsigned int flag;
205
206 for (int i=0;i<t3->GetEntries();i++ ) {
207 t3->GetEntry(i);
208 nGoodCharged = tagData0;
209 Tag1ToInt(tagData1, nNeutrk, nTottrk, ngamma, npi0);
210 Tag2ToInt(tagData2, npip, npim, nkp, nkm, npp, npm);
211 Tag2ToInt(tagData3, nlambda, nalambda, nep, nem, nmup, nmum);
212 Tag2ToInt(tagData4, nks, neta, nCharged, nGoodChargedp, nGoodChargedm, totCharged);
213
214 if ( QC && tagData8==0 ) continue;
215 if ( name_tag.size()==0 && Ncut_oth==0 ) {
216 ventry.push_back(i);
217 continue;
218 }
219 isTag = false;
220 for (unsigned int j=0; j<name_tag.size(); j++ ) {
221 if (name_tag[j]=="tagD0") {
222 if (tagData6>0) {
223 isPID = true;
224 if ( !(tagData6&(1<<31)) && typeD0 ) isPID = false;
225 if ( isPID ) {
226 if ( !allD0 ) {
227 for (unsigned int k=0; k<CutD0.size(); k++) {
228 if ( tagData6&(1<<D0_modeTag[CutD0[k]]) ) {
229 isTag = true;
230 break;
231 }
232 }
233 } else {
234 isTag = true;
235 }
236 }
237 }
238 }
239 else if (name_tag[j]=="tagD") {
240 if (tagData7>0) {
241 isPID = true;
242 if ( !(tagData7&(1<<31)) && typeD ) isPID = false;
243 if ( isPID ) {
244 if ( !allD ) {
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 } else {
252 isTag = true;
253 }
254 }
255 }
256 }
257 else if (name_tag[j]=="tagDs") {
258 if (tagData5>0) {
259 isPID = true;
260 if ( !(tagData5&(1<<31)) && typeDs ) isPID = false;
261 if ( isPID ) {
262 if ( !allDs ) {
263 for (unsigned int k=0; k<CutDs.size(); k++) {
264 if ( tagData5&(1<<Ds_modeTag[CutDs[k]]) ) {
265 isTag = true;
266 break;
267 }
268 }
269 } else {
270 isTag = true;
271 }
272 }
273 }
274 }
275 if (isTag) break;
276 }
277 if (isTag) {
278 ventry.push_back(i);
279 continue;
280 }
281
282 flag = 0;
283 int tagvalue=-1;
284 for (unsigned int j=0; j<name_oth.size(); j++ ) {
285 if (name_oth[j]=="NumOfGoodCh") {tagvalue = nGoodCharged;}
286 else if (name_oth[j]=="NumOfNeutrk") {tagvalue = nNeutrk;}
287 else if (name_oth[j]=="NumOfTottrk") {tagvalue = nTottrk;}
288 else if (name_oth[j]=="NumOfGamma") {tagvalue = ngamma;}
289 else if (name_oth[j]=="NumOfPion0") {tagvalue = npi0;}
290 else if (name_oth[j]=="NumOfPionp") {tagvalue = npip;}
291 else if (name_oth[j]=="NumOfPionm") {tagvalue = npim;}
292 else if (name_oth[j]=="NumOfKaonp") {tagvalue = nkp;}
293 else if (name_oth[j]=="NumOfKaonm") {tagvalue = nkm;}
294 else if (name_oth[j]=="NumOfProtonp") {tagvalue = npp;}
295 else if (name_oth[j]=="NumOfProtonm") {tagvalue = npm;}
296 else if (name_oth[j]=="NumOfLambda") {tagvalue = nlambda;}
297 else if (name_oth[j]=="NumOfALambda" ) {tagvalue = nalambda;}
298 else if (name_oth[j]=="NumOfElectronp") {tagvalue = nep;}
299 else if (name_oth[j]=="NumOfElectronm") {tagvalue = nem;}
300 else if (name_oth[j]=="NumOfMuonp") {tagvalue = nmup;}
301 else if (name_oth[j]=="NumOfMuonm") {tagvalue = nmum;}
302 else if (name_oth[j]=="NumOfKs") {tagvalue = nks;}
303 else if (name_oth[j]=="NumOfEta") {tagvalue = neta;}
304 else if (name_oth[j]=="NumOfCharged") {tagvalue = nCharged;}
305 else if (name_oth[j]=="NumOfGoodChp") {tagvalue = nGoodChargedp;}
306 else if (name_oth[j]=="NumOfGoodChm") {tagvalue = nGoodChargedm;}
307 else if (name_oth[j]=="TotCharged") {tagvalue = totCharged;}
308 else {
309 cout << "pls check the name of your criteria !" << endl;
310 break;
311 }
312 if ( tagvalue>=Cut2[name_oth[j]] || tagvalue<=Cut1[name_oth[j]] ) break;
313 flag++;
314 }
315 if (Ncut_oth>0&&Ncut_oth==flag) ventry.push_back(i);
316 }
317 cout << "TagFilterSvc::" << ventry.size() << " out of " << t3->GetEntries() << " events selected" << endl;
318 CutDs.clear();
319 CutD0.clear();
320 CutD.clear();
321 name_tag.clear();
322 name_oth.clear();
323 delete file;
324 return StatusCode::SUCCESS;
325}
char * file
Definition: DQA_TO_DB.cxx:15
void Tag1ToInt(unsigned int res, int &val1, int &val2, int &val3, int &val4)
Definition: TagParser2.cxx:326
void Tag2ToInt(unsigned int res, int &val1, int &val2, int &val3, int &val4, int &val5, int &val6)
Definition: TagParser2.cxx:334
vector< int > split(string str, string pattern, bool &all, bool &type)
Definition: TagParser2.cxx:344
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 344 of file TagParser2.cxx.

345{
346 vector<int> result;
347 unsigned int pos;
348 type = true;
349 all = false;
350 str += pattern;
351
352 for (unsigned int i = 0; i<str.size(); i++) {
353 pos = str.find(pattern, i);
354 if (pos<str.size()) {
355 string val = str.substr(i, pos-i);
356 if (val=="all") {
357 all=true;
358 } else if (val=="type0") {
359 type=false;
360 } else {
361 result.push_back(atoi(val.c_str()));
362 }
363 i = pos + pattern.size() - 1;
364 }
365 }
366 return result;
367}

Referenced by getVEntry().

◆ Tag1ToInt()

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

Definition at line 326 of file TagParser2.cxx.

327{
328 val1 = (res>>24) & 0xFF;
329 val2 = (res>>16) & 0xFF;
330 val3 = (res>>8) & 0xFF;
331 val4 = res & 0xFF;
332 return;
333}

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

335{
336 val1=(res>>26) & 0x3F;
337 val2=(res>>20) & 0x3F;
338 val3=(res>>15) & 0x1F;
339 val4=(res>>10) & 0x1F;
340 val5=(res>>5) & 0x1F;
341 val6 =res & 0x1F;
342 return;
343}

Referenced by getVEntry().


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