BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
ValidRecMdcKalTrackAlg.cxx
Go to the documentation of this file.
1#include "ValidRecMdcKalTrack/ValidRecMdcKalTrackAlg.h"
2#include "GaudiKernel/MsgStream.h"
3#include "GaudiKernel/SmartDataPtr.h"
4#include "GaudiKernel/IHistogramSvc.h"
5#include "MdcRecEvent/RecMdcKalTrack.h"
6#include "Identifier/MdcID.h"
7using namespace std;
8
9
10ValidRecMdcKalTrackAlg::ValidRecMdcKalTrackAlg(const std::string& name, ISvcLocator* pSvcLocator) : Algorithm(name, pSvcLocator),_ntuple(1),m_nt1(0) {
11
12 declareProperty("ntuple",_ntuple=1);
13
14}
15
16
18 if(_ntuple) {
19 NTuplePtr nt1(ntupleSvc(),"FILE_KalValid/n101");
20 StatusCode status;
21 if ( nt1 ) m_nt1 = nt1;
22 else {
23 m_nt1= ntupleSvc()->book("FILE_KalValid/n101",CLID_ColumnWiseTuple,"KalFitValid");
24 if ( m_nt1 ) {
25 status = m_nt1->addItem("stat",5,2,m_stat);
26 status = m_nt1->addItem("ndf",5,2,m_ndf);
27 status = m_nt1->addItem("chisq",5,2,m_chisq);
28 status = m_nt1->addItem("length",5,m_length);
29 status = m_nt1->addItem("tof",5,m_tof);
30 status = m_nt1->addItem("nhits",5,m_nhits);
31 status = m_nt1->addItem("zhelix",5,m_zhelix);
32 status = m_nt1->addItem("zhelixe",5,m_zhelixe);
33 status = m_nt1->addItem("zhelixmu",5,m_zhelixmu);
34 status = m_nt1->addItem("zhelixk",5,m_zhelixk);
35 status = m_nt1->addItem("zhelixp",5,m_zhelixp);
36 status = m_nt1->addItem("zptot",m_zptot);
37 status = m_nt1->addItem("zptote",m_zptote);
38 status = m_nt1->addItem("zptotmu",m_zptotmu);
39 status = m_nt1->addItem("zptotk",m_zptotk);
40 status = m_nt1->addItem("zptotp",m_zptotp);
41
42 status = m_nt1->addItem("zpt",m_zpt);
43 status = m_nt1->addItem("zpte",m_zpte);
44 status = m_nt1->addItem("zptmu",m_zptmu);
45 status = m_nt1->addItem("zptk",m_zptk);
46 status = m_nt1->addItem("zptp",m_zptp);
47
48 status = m_nt1->addItem("fptot",m_fptot);
49 status = m_nt1->addItem("fptote",m_fptote);
50 status = m_nt1->addItem("fptotmu",m_fptotmu);
51 status = m_nt1->addItem("fptotk",m_fptotk);
52 status = m_nt1->addItem("fptotp",m_fptotp);
53 status = m_nt1->addItem("fpt",m_fpt);
54 status = m_nt1->addItem("fpte",m_fpte);
55 status = m_nt1->addItem("fptmu",m_fptmu);
56
57 status = m_nt1->addItem("fptk",m_fptk);
58 status = m_nt1->addItem("fptp",m_fptp);
59 status = m_nt1->addItem("lptot",m_lptot);
60 status = m_nt1->addItem("lptote",m_lptote);
61 status = m_nt1->addItem("lptotmu",m_lptotmu);
62 status = m_nt1->addItem("lptotk",m_lptotk);
63 status = m_nt1->addItem("lptotp",m_lptotp);
64 status = m_nt1->addItem("lpt",m_lpt);
65 status = m_nt1->addItem("lpte",m_lpte);
66 status = m_nt1->addItem("lptmu",m_lptmu);
67 status = m_nt1->addItem("lptk",m_lptk);
68 status = m_nt1->addItem("lptp",m_lptp);
69
70 status = m_nt1->addItem("zsigp",m_zsigp);
71 status = m_nt1->addItem("zsigpe",m_zsigpe);
72 status = m_nt1->addItem("zsigpmu",m_zsigpmu);
73 status = m_nt1->addItem("zsigpk",m_zsigpk);
74 status = m_nt1->addItem("zsigpp",m_zsigpp);
75 status = m_nt1->addItem("fhelix",5,m_fhelix);
76 status = m_nt1->addItem("fhelixe",5,m_fhelixe);
77 status = m_nt1->addItem("fhelixmu",5,m_fhelixmu);
78 status = m_nt1->addItem("fhelixk",5,m_fhelixk);
79 status = m_nt1->addItem("fhelixp",5,m_fhelixp);
80 status = m_nt1->addItem("lhelix",5,m_lhelix);
81 status = m_nt1->addItem("lhelixe",5,m_lhelixe);
82 status = m_nt1->addItem("lhelixmu",5,m_lhelixmu);
83 status = m_nt1->addItem("lhelixk",5,m_lhelixk);
84 status = m_nt1->addItem("lhelixp",5,m_lhelixp);
85
86 status = m_nt1->addItem("zerror",15,m_zerror);
87 status = m_nt1->addItem("zerrore",15,m_zerrore);
88 status = m_nt1->addItem("zerrormu",15,m_zerrormu);
89 status = m_nt1->addItem("zerrork",15,m_zerrork);
90 status = m_nt1->addItem("zerrorp",15,m_zerrorp);
91 status = m_nt1->addItem("ferror",15,m_ferror);
92 status = m_nt1->addItem("ferrore",15,m_ferrore);
93 status = m_nt1->addItem("ferrormu",15,m_ferrormu);
94 status = m_nt1->addItem("ferrork",15,m_ferrork);
95 status = m_nt1->addItem("ferrorp",15,m_ferrorp);
96 status = m_nt1->addItem("lerror",15,m_lerror);
97 status = m_nt1->addItem("lerrore",15,m_lerrore);
98 status = m_nt1->addItem("lerrormu",15,m_lerrormu);
99 status = m_nt1->addItem("lerrork",15,m_lerrork);
100 status = m_nt1->addItem("lerrorp",15,m_lerrorp);
101
102 if( status.isFailure() ) cout<<"Ntuple m_nt1 add item failed!"<<endl;
103 }
104 }
105
106
107 NTuplePtr nt2(ntupleSvc(),"FILE_KalValid/n102");
108 StatusCode status2;
109 if ( nt2 ) m_nt2 = nt2;
110 else {
111 m_nt2= ntupleSvc()->book("FILE_KalValid/n102",CLID_ColumnWiseTuple,"KalFitValid");
112 if ( m_nt2 ) {
113 if( status2.isFailure() ) cout<<"Ntuple2 add item failed!"<<endl;
114 }
115 }
116 }
117}
118
119
121
122 MsgStream log( msgSvc(), name() );
123 log << MSG::INFO << "Booking Histograms" << endreq;
124
125 histDef();
126
127 log << MSG::INFO << "Finished booking Histograms" << endreq;
128 return StatusCode::SUCCESS;
129}
130
131
133 MsgStream log(msgSvc(), name());
134 SmartDataPtr<RecMdcKalTrackCol> mdcKalTrkCol(eventSvc(),"/Event/Recon/RecMdcKalTrackCol");
135 if( ! mdcKalTrkCol )
136 {
137 log << MSG::ERROR << "Unable to retrieve mdcKalTrackCol" << endreq;
138 return StatusCode::FAILURE;
139 } else {
140 for(RecMdcKalTrackCol::iterator iter_trk=mdcKalTrkCol->begin(); iter_trk!=mdcKalTrkCol->end(); iter_trk++) {
141 for( int jj=0, iii=0; jj<5; jj++){
142 m_nhits[jj] = (*iter_trk)->getNhits(jj);
143 m_zhelix[jj] = (*iter_trk)->getZHelix()[jj];
144 m_zhelixe[jj] = (*iter_trk)->getZHelixE()[jj];
145 m_zhelixmu[jj] = (*iter_trk)->getZHelixMu()[jj];
146 m_zhelixk[jj] = (*iter_trk)->getZHelixK()[jj];
147 m_zhelixp[jj] = (*iter_trk)->getZHelixP()[jj];
148 m_fhelix[jj] = (*iter_trk)->getFHelix()[jj];
149 m_fhelixe[jj] = (*iter_trk)->getFHelixE()[jj];
150 m_fhelixmu[jj] = (*iter_trk)->getFHelixMu()[jj];
151 m_fhelixk[jj] = (*iter_trk)->getFHelixK()[jj];
152 m_fhelixp[jj] = (*iter_trk)->getFHelixP()[jj];
153 m_lhelix[jj] = (*iter_trk)->getLHelix()[jj];
154 m_lhelixe[jj] = (*iter_trk)->getLHelixE()[jj];
155 m_lhelixmu[jj] = (*iter_trk)->getLHelixMu()[jj];
156 m_lhelixk[jj] = (*iter_trk)->getLHelixK()[jj];
157 m_lhelixp[jj] = (*iter_trk)->getLHelixP()[jj];
158
159
160 for(int kk=0; kk<=jj; kk++,iii++) {
161 m_zerror[iii] = (*iter_trk)->getZError()[jj][kk];
162 m_zerrore[iii] = (*iter_trk)->getZErrorE()[jj][kk];
163 m_zerrormu[iii] = (*iter_trk)->getZErrorMu()[jj][kk];
164 m_zerrork[iii] = (*iter_trk)->getZErrorK()[jj][kk];
165 m_zerrorp[iii] = (*iter_trk)->getZErrorP()[jj][kk];
166 m_ferror[iii] = (*iter_trk)->getFError()[jj][kk];
167 m_ferrore[iii] = (*iter_trk)->getFErrorE()[jj][kk];
168 m_ferrormu[iii] = (*iter_trk)->getFErrorMu()[jj][kk];
169 m_ferrork[iii] = (*iter_trk)->getFErrorK()[jj][kk];
170 m_ferrorp[iii] = (*iter_trk)->getFErrorP()[jj][kk];
171 m_lerror[iii] = (*iter_trk)->getLError()[jj][kk];
172 m_lerrore[iii] = (*iter_trk)->getLErrorE()[jj][kk];
173 m_lerrormu[iii] = (*iter_trk)->getLErrorMu()[jj][kk];
174 m_lerrork[iii] = (*iter_trk)->getLErrorK()[jj][kk];
175 m_lerrorp[iii] = (*iter_trk)->getLErrorP()[jj][kk];
176 }
177 }
178
179
180 m_ndf[0][0] = (*iter_trk)->getNdf(0,0);
181 m_ndf[1][0] = (*iter_trk)->getNdf(0,1);
182 m_ndf[2][0] = (*iter_trk)->getNdf(0,2);
183 m_ndf[3][0] = (*iter_trk)->getNdf(0,3);
184 m_ndf[4][0] = (*iter_trk)->getNdf(0,4);
185 m_ndf[0][1] = (*iter_trk)->getNdf(1,0);
186 m_ndf[1][1] = (*iter_trk)->getNdf(1,1);
187 m_ndf[2][1] = (*iter_trk)->getNdf(1,2);
188 m_ndf[3][1] = (*iter_trk)->getNdf(1,3);
189 m_ndf[4][1] = (*iter_trk)->getNdf(1,4);
190
191 m_stat[0][0] = (*iter_trk)->getStat(0,0);
192 m_stat[1][0] = (*iter_trk)->getStat(0,1);
193 m_stat[2][0] = (*iter_trk)->getStat(0,2);
194 m_stat[3][0] = (*iter_trk)->getStat(0,3);
195 m_stat[4][0] = (*iter_trk)->getStat(0,4);
196 m_stat[0][1] = (*iter_trk)->getStat(1,0);
197 m_stat[1][1] = (*iter_trk)->getStat(1,1);
198 m_stat[2][1] = (*iter_trk)->getStat(1,2);
199 m_stat[3][1] = (*iter_trk)->getStat(1,3);
200 m_stat[4][1] = (*iter_trk)->getStat(1,4);
201
202
203 m_fptot = sqrt(1+pow(m_fhelix[4],2))/m_fhelix[2];
204 m_fptote = sqrt(1+pow(m_fhelixe[4],2))/m_fhelixe[2];
205 m_fptotmu = sqrt(1+pow(m_fhelixmu[4],2))/m_fhelixmu[2];
206 m_fptotk = sqrt(1+pow(m_fhelixk[4],2))/m_fhelixk[2];
207 m_fptotp = sqrt(1+pow(m_fhelixp[4],2))/m_fhelixp[2];
208
209 m_zpt = 1/m_zhelix[2];
210 m_zpte = 1/m_zhelixe[2];
211 m_zptmu = 1/m_zhelixmu[2];
212 m_zptk = 1/m_zhelixk[2];
213 m_zptp = 1/m_zhelixp[2];
214
215 m_fpt = 1/m_fhelix[2];
216 m_fpte = 1/m_fhelixe[2];
217 m_fptmu = 1/m_fhelixmu[2];
218 m_fptk = 1/m_fhelixk[2];
219 m_fptp = 1/m_fhelixp[2];
220
221 m_lpt = 1/m_lhelix[2];
222 m_lpte = 1/m_lhelixe[2];
223 m_lptmu = 1/m_lhelixmu[2];
224 m_lptk = 1/m_lhelixk[2];
225 m_lptp = 1/m_lhelixp[2];
226
227 m_lptot = sqrt(1+pow(m_lhelix[4],2))/m_lhelix[2];
228 m_lptote = sqrt(1+pow(m_lhelixe[4],2))/m_lhelixe[2];
229 m_lptotmu = sqrt(1+pow(m_lhelixmu[4],2))/m_lhelixmu[2];
230 m_lptotk = sqrt(1+pow(m_lhelixk[4],2))/m_lhelixk[2];
231 m_lptotp = sqrt(1+pow(m_lhelixp[4],2))/m_lhelixp[2];
232
233 m_zptot = sqrt(1+pow(m_zhelix[4],2))/m_zhelix[2];
234 m_zptote = sqrt(1+pow(m_zhelixe[4],2))/m_zhelixe[2];
235 m_zptotmu = sqrt(1+pow(m_zhelixmu[4],2))/m_zhelixmu[2];
236 m_zptotk = sqrt(1+pow(m_zhelixk[4],2))/m_zhelixk[2];
237 m_zptotp = sqrt(1+pow(m_zhelixp[4],2))/m_zhelixp[2];
238
239 StatusCode sc1 = m_nt1->write();
240 if( sc1.isFailure() ) cout<<"Ntuple1 filling failed!"<<endl;
241 }
242 }
243 return StatusCode::SUCCESS;
244}
245
246
248
249 MsgStream log(msgSvc(), name());
250 log << MSG::INFO << "Finalizing..." << endreq;
251 return StatusCode::SUCCESS;
252}
253
254
255
ValidRecMdcKalTrackAlg(const std::string &name, ISvcLocator *pSvcLocator)