1#include "GaudiKernel/IInterface.h"
2#include "GaudiKernel/StatusCode.h"
3#include "GaudiKernel/SvcFactory.h"
4#include "GaudiKernel/MsgStream.h"
5#include "GaudiKernel/ISvcLocator.h"
6#include "GaudiKernel/SmartDataPtr.h"
7#include "GaudiKernel/IDataProviderSvc.h"
8#include "GaudiKernel/PropertyMgr.h"
9#include "GaudiKernel/SmartIF.h"
10#include "GaudiKernel/IAppMgrUI.h"
11#include "GaudiKernel/IProperty.h"
13#include "GaudiKernel/IIncidentSvc.h"
14#include "GaudiKernel/Incident.h"
15#include "GaudiKernel/IIncidentListener.h"
16#include "GaudiKernel/ISvcLocator.h"
17#include "GaudiKernel/Bootstrap.h"
35 std::map<int, unsigned int> Lc_modeTag, Ds_modeTag, D0_modeTag, Dp_modeTag;
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;
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;
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;
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;
153 vector<string> name_cut;
154 vector<int> CutLc, CutDs, CutD0, CutD;
160 bool allLc=
false, allDs=
false, allD0=
false, allD=
false, typeLc=
true, typeDs=
true, typeD0=
true, typeD=
true;
163 int nPos_1, nPos_2, nPos_3;
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(
"=");
172 name = m_criteria[i].substr(0,nPos_3);
173 name_cut.push_back(name);
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);
183 std::cout<<
"pls check your tag criterias"<<std::endl;
184 return StatusCode::SUCCESS;
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;
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());
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);
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;
217 for (
int i=0;i<t3->GetEntries();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);
225 unsigned int flag = 0;
228 for (
unsigned int j=0; j<name_cut.size(); j++ ) {
229 if (name_cut[j]==
"tagLc") {
231 if ( !(tagData5&(1<<31)) && typeLc )
break;
234 for (
unsigned int k=0; k<CutLc.size(); k++) {
235 if ( tagData5&(1<<Lc_modeTag[CutLc[k]]) ) {
246 else if (name_cut[j]==
"tagDs") {
248 if ( !(tagData6&(1<<31)) && typeDs )
break;
251 for (
unsigned int k=0; k<CutDs.size(); k++) {
252 if ( tagData6&(1<<Ds_modeTag[CutDs[k]]) ) {
263 else if (name_cut[j]==
"tagD0") {
265 if ( !(tagData7&(1<<31)) && typeD0 )
break;
268 for (
unsigned int k=0; k<CutD0.size(); k++) {
269 if ( tagData7&(1<<D0_modeTag[CutD0[k]]) ) {
280 else if (name_cut[j]==
"tagD") {
282 if ( !(tagData8&(1<<31)) && typeD )
break;
285 for (
unsigned int k=0; k<CutD.size(); k++) {
286 if ( tagData8&(1<<Dp_modeTag[CutD[k]]) ) {
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;}
322 cout <<
"pls check the name of your criteria !" << endl;
325 if ( tagvalue>=Cut2[name_cut[j]] || tagvalue<=Cut1[name_cut[j]] )
break;
329 if (
flag==name_cut.size()) {
339 return StatusCode::SUCCESS;
343 val1 = (res>>24) & 0xFF;
344 val2 = (res>>16) & 0xFF;
345 val3 = (res>>8) & 0xFF;
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;
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);
373 }
else if (val==
"type0") {
376 result.push_back(atoi(val.c_str()));
378 i = pos + pattern.size() - 1;
void Tag2ToInt(unsigned int res, int &val1, int &val2, int &val3, int &val4, int &val5, int &val6)
StatusCode getVEntry(vector< int > &)
vector< int > split(string str, string pattern, bool &all, bool &type)
void Tag1ToInt(unsigned int res, int &val1, int &val2, int &val3, int &val4)