BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
TagParser1.cxx
Go to the documentation of this file.
1#include "GaudiKernel/IAppMgrUI.h"
2#include "GaudiKernel/IDataProviderSvc.h"
3#include "GaudiKernel/IInterface.h"
4#include "GaudiKernel/IProperty.h"
5#include "GaudiKernel/ISvcLocator.h"
6#include "GaudiKernel/MsgStream.h"
7#include "GaudiKernel/PropertyMgr.h"
8#include "GaudiKernel/SmartDataPtr.h"
9#include "GaudiKernel/SmartIF.h"
10#include "GaudiKernel/StatusCode.h"
11
12#include "GaudiKernel/Bootstrap.h"
13#include "GaudiKernel/IIncidentListener.h"
14#include "GaudiKernel/IIncidentSvc.h"
15#include "GaudiKernel/ISvcLocator.h"
16#include "GaudiKernel/Incident.h"
17
18#include "TFile.h"
19#include "TFormula.h"
20#include "TTree.h"
21#include "TagParser1.h"
22#include <fstream>
23#include <iostream>
24#include <map>
25
27
29
30StatusCode TagParser1::getVEntry( std::vector<int>& ventry ) {
31
32 int NumCriteria = m_criteria.size();
33 if ( NumCriteria > 23 )
34 {
35 std::cout << "the number of criterias too much!!" << std::endl;
36 return StatusCode::SUCCESS;
37 }
38 if ( m_criteria[0].find( "<NumOfGoodCh<" ) == std::string::npos )
39 {
40 std::cout << "pls ensure your first criterias is NumOfCharged" << std::endl;
41 return StatusCode::SUCCESS;
42 }
43 // string criteria="";
44 vector<string> criteria;
45 map<string, int> Cut1;
46 map<string, int> Cut2;
47 for ( int i = 0; i < NumCriteria; i++ )
48 {
49 int nPos_1 = m_criteria[i].find_first_of( "<" );
50 int nPos_2 = m_criteria[i].find_last_of( "<" );
51 if ( nPos_1 == nPos_2 || nPos_1 == -1 || nPos_2 == -1 )
52 {
53 std::cout << "pls check your criterias" << std::endl;
54 return StatusCode::SUCCESS;
55 }
56 string name_cut = m_criteria[i].substr( nPos_1 + 1, nPos_2 - nPos_1 - 1 );
57 Cut1[name_cut] = atoi( m_criteria[i].substr( 0 ).c_str() );
58 Cut2[name_cut] = atoi( m_criteria[i].substr( nPos_2 + 1 ).c_str() );
59 criteria.push_back( name_cut );
60 std::cout << "criteria is " << criteria[i] << std::endl;
61 std::cout << "nCTrkCut1: " << Cut1[criteria[i]] << " nCTrkCut2: " << Cut2[criteria[i]]
62 << std::endl;
63 }
64
65 // if ( criteria.find("<NumOfCharged<") != std::string::npos ) {
66 // nCTrkCut1 = atoi( criteria.substr(0).c_str() );
67 // nCTrkCut2 = atoi( criteria.substr(15).c_str() );
68 // std::cout<<"nCTrkCut1: "<<nCTrkCut1<<" nCTrkCut2: "<<nCTrkCut2<<std::endl;
69 // }
70
71 std::vector<int> ventry_temp;
72
73 TFile* file = TFile::Open( m_fileName.c_str() );
74 TTree* t0 = (TTree*)file->Get( "Metadata" );
75 Int_t mode, begin, end;
76 t0->SetBranchAddress( "mode", &mode );
77 t0->SetBranchAddress( "begin", &begin );
78 t0->SetBranchAddress( "end", &end );
79
80 for ( int i = 0; i < t0->GetEntries(); ++i )
81 {
82 t0->GetEntry( i );
83 std::cout << "t0 entry: " << i << std::endl;
84 if ( ( mode != -1 ) && ( mode > Cut1["NumOfGoodCh"] && mode < Cut2["NumOfGoodCh"] ) )
85 {
86 for ( int i = begin; i < end; ++i )
87 {
88 ventry_temp.push_back( i );
89 // ventry.push_back(i);
90 // std::cout<<"ventry_temp push back: "<<i<<std::endl;
91 }
92 }
93 }
94
95 TTree* t3 = (TTree*)file->Get( "Entries" );
96 UInt_t tagData0, tagData1, tagData2, tagData3, tagData4;
97 t3->SetBranchAddress( "tagData0", &tagData0 );
98 t3->SetBranchAddress( "tagData1", &tagData1 );
99 t3->SetBranchAddress( "tagData2", &tagData2 );
100 t3->SetBranchAddress( "tagData3", &tagData3 );
101 t3->SetBranchAddress( "tagData4", &tagData4 );
102
103 Int_t npip, npim, nkp, nkm, nlambda, nalambda;
104 Int_t npp, npm, nep, nem, nmup, nmum, neta, npi0, ngamma, nks;
105 Int_t nCharged, nGoodChargedp, nGoodChargedm, totCharged, nNeutrk, nTottrk;
106 for ( int i = 0; i < ventry_temp.size(); i++ )
107 {
108 t3->GetEntry( ventry_temp[i] );
109 Tag1ToInt( tagData1, nNeutrk, nTottrk, ngamma, npi0 );
110 Tag2ToInt( tagData2, npip, npim, nkp, nkm, npp, npm );
111 Tag2ToInt( tagData3, nlambda, nalambda, nep, nem, nmup, nmum );
112 Tag2ToInt( tagData4, nks, neta, nCharged, nGoodChargedp, nGoodChargedm, totCharged );
113
114 // std::cout<<"npip = "<<npip<<", npim = "<<npim<<std::endl;
115 // std::cout<<"nctk = "<<tagData0<<std::endl;
116
117 if ( Cut2["NumOfNeutrk"] != 0 &&
118 ( nNeutrk >= Cut2["NumOfNeutrk"] || nNeutrk <= Cut1["NumOfNeutrk"] ) )
119 continue;
120 if ( Cut2["NumOfTottrk"] != 0 &&
121 ( nTottrk >= Cut2["NumOfTottrk"] || nTottrk <= Cut1["NumOfTottrk"] ) )
122 continue;
123 if ( Cut2["NumOfGamma"] != 0 &&
124 ( ngamma >= Cut2["NumOfGamma"] || ngamma <= Cut1["NumOfGamma"] ) )
125 continue;
126 if ( Cut2["NumOfPion0"] != 0 &&
127 ( npi0 >= Cut2["NumOfPion0"] || npi0 <= Cut1["NumOfPion0"] ) )
128 continue;
129 if ( Cut2["NumOfPionp"] != 0 &&
130 ( npip >= Cut2["NumOfPionp"] || npip <= Cut1["NumOfPionp"] ) )
131 continue;
132 if ( Cut2["NumOfPionm"] != 0 &&
133 ( npim >= Cut2["NumOfPionm"] || npim <= Cut1["NumOfPionm"] ) )
134 continue;
135 if ( Cut2["NumOfKaonp"] != 0 &&
136 ( nkp >= Cut2["NumOfKaonp"] || nkp <= Cut1["NumOfKaonp"] ) )
137 continue;
138 if ( Cut2["NumOfKaonm"] != 0 &&
139 ( nkm >= Cut2["NumOfKaonm"] || nkm <= Cut1["NumOfKaonm"] ) )
140 continue;
141 if ( Cut2["NumOfProtonp"] != 0 &&
142 ( npp >= Cut2["NumOfProtonp"] || npp <= Cut1["NumOfProtonp"] ) )
143 continue;
144 if ( Cut2["NumOfProtonm"] != 0 &&
145 ( npm >= Cut2["NumOfProtonm"] || npp <= Cut1["NumOfProtonm"] ) )
146 continue;
147 if ( Cut2["NumOfLambda"] != 0 &&
148 ( nlambda >= Cut2["NumOfLambda"] || nlambda <= Cut1["NumOfLambda"] ) )
149 continue;
150 if ( Cut2["NumOfALambda"] != 0 &&
151 ( nalambda >= Cut2["NumOfALambda"] || nalambda <= Cut1["NumOfALambda"] ) )
152 continue;
153 if ( Cut2["NumOfElectronp"] != 0 &&
154 ( nep >= Cut2["NumOfElectronp"] || nep <= Cut1["NumOfElectronp"] ) )
155 continue;
156 if ( Cut2["NumOfElectronm"] != 0 &&
157 ( nem >= Cut2["NumOfElectronm"] || nem <= Cut1["NumOfElectronm"] ) )
158 continue;
159 if ( Cut2["NumOfMuonp"] != 0 &&
160 ( nmup >= Cut2["NumOfMuonp"] || nmup <= Cut1["NumOfMuonp"] ) )
161 continue;
162 if ( Cut2["NumOfMuonm"] != 0 &&
163 ( nmum >= Cut2["NumOfMuonm"] || nmum <= Cut1["NumOfMuonm"] ) )
164 continue;
165 if ( Cut2["NumOfKs"] != 0 && ( nks >= Cut2["NumOfKs"] || nks <= Cut1["NumOfKs"] ) )
166 continue;
167 if ( Cut2["NumOfEta"] != 0 && ( neta >= Cut2["NumOfEta"] || neta <= Cut1["NumOfEta"] ) )
168 continue;
169 if ( Cut2["NumOfCharged"] != 0 &&
170 ( nCharged >= Cut2["NumOfCharged"] || nCharged <= Cut1["NumOfCharged"] ) )
171 continue;
172 if ( Cut2["NumOfGoodChp"] != 0 &&
173 ( nGoodChargedp >= Cut2["NumOfGoodChp"] || nGoodChargedp <= Cut1["NumOfGoodChp"] ) )
174 continue;
175 if ( Cut2["NumOfGoodChm"] != 0 &&
176 ( nGoodChargedm >= Cut2["NumOfGoodChm"] || nGoodChargedm <= Cut1["NumOfGoodChm"] ) )
177 continue;
178 if ( Cut2["TotCharged"] != 0 &&
179 ( totCharged >= Cut2["TotCharged"] || totCharged <= Cut1["TotCharged"] ) )
180 continue;
181 ventry.push_back( ventry_temp[i] );
182 // std::cout<<"ventry push back: "<<i<<std::endl;
183 }
184 delete file;
185
186 return StatusCode::SUCCESS;
187}
188void TagParser1::Tag1ToInt( unsigned int res, int& val1, int& val2, int& val3, int& val4 ) {
189 val1 = ( res >> 24 ) & 0xFF;
190 val2 = ( res >> 16 ) & 0xFF;
191 val3 = ( res >> 8 ) & 0xFF;
192 val4 = res & 0xFF;
193 return;
194}
195void TagParser1::Tag2ToInt( unsigned int res, int& val1, int& val2, int& val3, int& val4,
196 int& val5, int& val6 ) {
197 val1 = ( res >> 26 ) & 0x3F;
198 val2 = ( res >> 20 ) & 0x3F;
199 val3 = ( res >> 15 ) & 0x1F;
200 val4 = ( res >> 10 ) & 0x1F;
201 val5 = ( res >> 5 ) & 0x1F;
202 val6 = res & 0x1F;
203 return;
204}
205
206/*int* TagParser1::IntToChar(int val)
207 {
208 int *ch;
209 ch = new int[4];
210 ch[0]=(val>>24) & 0xFF;
211 ch[1]=(val>>16) & 0xFF;
212 ch[2]=(val>>8) & 0xFF;
213 ch[3]=val & 0xFF;
214 return ch;
215
216 }*/
char * file
Definition DQA_TO_DB.cxx:16
void Tag2ToInt(unsigned int res, int &val1, int &val2, int &val3, int &val4, int &val5, int &val6)
void Tag1ToInt(unsigned int res, int &val1, int &val2, int &val3, int &val4)
StatusCode getVEntry(vector< int > &)