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> Ds_modeTag, D0_modeTag, Dp_modeTag;
100 D0_modeTag[124] = 30;
101 D0_modeTag[125] = 30;
102 D0_modeTag[126] = 30;
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;
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;
134 unsigned int Ncut_oth=0;
135 vector<string> name_tag, name_oth;
136 vector<int> CutDs, CutD0, CutD;
142 bool allDs=
false, allD0=
false, allD=
false, typeDs=
true, typeD0=
true, typeD=
true, QC=
false;
145 int nPos_1, nPos_2, nPos_3, nPos_4;
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");
156 cout <<
" -> Turn on QC";
158 else if (nPos_3!=-1) {
159 name = m_criteria[i].substr(0,nPos_3);
160 name_tag.push_back(name);
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);
168 std::cout<<
"pls check your tag criterias"<<std::endl;
169 return StatusCode::SUCCESS;
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;
177 name = m_criteria[i].substr(nPos_1+1,nPos_2-nPos_1-1);
178 name_oth.push_back(name);
180 Cut1[name] = atoi(m_criteria[i].substr(0).c_str());
181 Cut2[name] = atoi(m_criteria[i].substr(nPos_2+1).c_str());
183 std::cout<<std::endl;
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);
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;
206 for (
int i=0;i<t3->GetEntries();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);
214 if ( QC && tagData8==0 )
continue;
215 if ( name_tag.size()==0 && Ncut_oth==0 ) {
220 for (
unsigned int j=0; j<name_tag.size(); j++ ) {
221 if (name_tag[j]==
"tagD0") {
224 if ( !(tagData6&(1<<31)) && typeD0 ) isPID =
false;
227 for (
unsigned int k=0; k<CutD0.size(); k++) {
228 if ( tagData6&(1<<D0_modeTag[CutD0[k]]) ) {
239 else if (name_tag[j]==
"tagD") {
242 if ( !(tagData7&(1<<31)) && typeD ) isPID =
false;
245 for (
unsigned int k=0; k<CutD.size(); k++) {
246 if ( tagData7&(1<<Dp_modeTag[CutD[k]]) ) {
257 else if (name_tag[j]==
"tagDs") {
260 if ( !(tagData5&(1<<31)) && typeDs ) isPID =
false;
263 for (
unsigned int k=0; k<CutDs.size(); k++) {
264 if ( tagData5&(1<<Ds_modeTag[CutDs[k]]) ) {
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;}
309 cout <<
"pls check the name of your criteria !" << endl;
312 if ( tagvalue>=Cut2[name_oth[j]] || tagvalue<=Cut1[name_oth[j]] )
break;
315 if (Ncut_oth>0&&Ncut_oth==
flag) ventry.push_back(i);
317 cout <<
"TagFilterSvc::" << ventry.size() <<
" out of " << t3->GetEntries() <<
" events selected" << endl;
324 return StatusCode::SUCCESS;
328 val1 = (res>>24) & 0xFF;
329 val2 = (res>>16) & 0xFF;
330 val3 = (res>>8) & 0xFF;
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;
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);
358 }
else if (val==
"type0") {
361 result.push_back(atoi(val.c_str()));
363 i = pos + pattern.size() - 1;
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)
StatusCode getVEntry(vector< int > &)
vector< int > split(string str, string pattern, bool &all, bool &type)