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 vector<string> name_cut;
135 vector<int> CutDs, CutD0, CutD;
140 bool allDs=
false, allD0=
false, allD=
false, typeDs=
true, typeD0=
true, typeD=
true;
143 int nPos_1, nPos_2, nPos_3;
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(
"=");
152 name = m_criteria[i].substr(0,nPos_3);
153 name_cut.push_back(name);
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);
161 std::cout<<
"pls check your tag criterias"<<std::endl;
162 return StatusCode::SUCCESS;
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;
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());
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);
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;
194 for (
int i=0;i<t3->GetEntries();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);
202 unsigned int flag = 0;
205 for (
unsigned int j=0; j<name_cut.size(); j++ ) {
206 if (name_cut[j]==
"tagDs") {
208 if ( !(tagData5&(1<<31)) && typeDs )
break;
211 for (
unsigned int k=0; k<CutDs.size(); k++) {
212 if ( tagData5&(1<<Ds_modeTag[CutDs[k]]) ) {
223 else if (name_cut[j]==
"tagD0") {
225 if ( !(tagData6&(1<<31)) && typeD0 )
break;
228 for (
unsigned int k=0; k<CutD0.size(); k++) {
229 if ( tagData6&(1<<D0_modeTag[CutD0[k]]) ) {
240 else if (name_cut[j]==
"tagD") {
242 if ( !(tagData7&(1<<31)) && typeD )
break;
245 for (
unsigned int k=0; k<CutD.size(); k++) {
246 if ( tagData7&(1<<Dp_modeTag[CutD[k]]) ) {
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;}
282 cout <<
"pls check the name of your criteria !" << endl;
285 if ( tagvalue>=Cut2[name_cut[j]] || tagvalue<=Cut1[name_cut[j]] )
break;
289 if (
flag==name_cut.size()) {
298 return StatusCode::SUCCESS;
302 val1 = (res>>24) & 0xFF;
303 val2 = (res>>16) & 0xFF;
304 val3 = (res>>8) & 0xFF;
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;
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);
332 }
else if (val==
"type0") {
335 result.push_back(atoi(val.c_str()));
337 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)