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