BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcFastTrkAlg.cxx
Go to the documentation of this file.
1#include "MdcFastTrkAlg.h"
2#include "FTFinder.h"
3
4#include "GaudiKernel/IDataProviderSvc.h"
5#include "GaudiKernel/ISvcLocator.h"
6#include "GaudiKernel/MsgStream.h"
7#include "GaudiKernel/PropertyMgr.h"
8#include "GaudiKernel/SmartDataPtr.h"
9
10#include "EventModel/Event.h"
11#include "EventModel/EventHeader.h"
12#include "MdcGeomSvc/IMdcGeomSvc.h"
13#include "MdcGeomSvc/MdcGeoLayer.h"
14#include "MdcGeomSvc/MdcGeoWire.h"
15#include "MdcRawEvent/MdcDigi.h"
16
17#include <fstream>
18
19#ifndef OnlineMode
20# include "McTruth/McKine.h"
21# include "ntupleItem.h"
22#endif
23
24#include "MdcRecEvent/RecMdcTrack.h"
25
26#include <iostream>
27#include <vector>
28
29using namespace std;
30
31//...Globals...
32
33#ifndef OnlineMode
34// MCTruth
35
38
39extern NTuple::Item<long> g_ntrkMC, g_eventNo;
40extern NTuple::Array<float> g_theta0MC, g_phi0MC;
41extern NTuple::Array<float> g_pxMC, g_pyMC, g_pzMC, g_ptMC;
42
43// recon
44extern NTuple::Item<long> g_ntrk;
45extern NTuple::Item<float> g_eventtime;
46extern NTuple::Array<float> g_px, g_py, g_pz, g_pt, g_p;
47extern NTuple::Array<float> g_phi, g_theta;
48extern NTuple::Array<float> g_vx, g_vy, g_vz;
49extern NTuple::Array<float> g_dr, g_phi0, g_kappa, g_dz, g_tanl;
50extern NTuple::Item<float> g_estime;
51
52extern IHistogram1D* g_sigmaxy;
53extern IHistogram1D* g_sigmaz;
54extern IHistogram1D* g_chi2xy;
55extern IHistogram1D* g_chi2sz;
56extern IHistogram1D* g_ncellMC;
57extern IHistogram1D* g_ncell;
58extern IHistogram1D* g_naxialhit;
59extern IHistogram1D* g_nstereohit;
60extern IHistogram1D* g_nhit;
61extern IHistogram2D* g_hitmap[20];
62#endif
63
64/////////////////////////////////////////////////////////////////////////////
66MdcFastTrkAlg::MdcFastTrkAlg( const std::string& name, ISvcLocator* pSvcLocator )
67 : Algorithm( name, pSvcLocator ) {
68 // Declare the properties
69 declareProperty( "bunchtime", m_bunchtime_MC = 8.0 );
70 declareProperty( "T0cal", m_mdc_tcal = 200.0 );
71 m_ftFinder = 0;
72}
73
74// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
76
77 MsgStream log( msgSvc(), name() );
78 log << MSG::INFO << "in initialize()" << endmsg;
79
80#ifndef OnlineMode
81 NTuplePtr nt( ntupleSvc(), "FILE102/n1" );
82 if ( nt ) m_tuple = nt;
83 else
84 {
85 m_tuple = ntupleSvc()->book( "FILE102/n1", CLID_ColumnWiseTuple, "MdcRecEvent" );
86 if ( m_tuple )
87 {
88 m_tuple->addItem( "eventNo", g_eventNo );
89 m_tuple->addItem( "NtrackMC", g_ntrkMC, 0, 50 );
90 m_tuple->addItem( "MCtheta0", g_ntrkMC, g_theta0MC );
91 m_tuple->addItem( "MCphi0", g_ntrkMC, g_phi0MC );
92 m_tuple->addItem( "pxMC", g_ntrkMC, g_pxMC );
93 m_tuple->addItem( "pyMC", g_ntrkMC, g_pyMC );
94 m_tuple->addItem( "pzMC", g_ntrkMC, g_pzMC );
95 m_tuple->addItem( "ptMC", g_ntrkMC, g_ptMC );
96 m_tuple->addItem( "Ntrack", g_ntrk, 0, 50 );
97 m_tuple->addItem( "px", g_ntrk, g_px );
98 m_tuple->addItem( "py", g_ntrk, g_py );
99 m_tuple->addItem( "pz", g_ntrk, g_pz );
100 m_tuple->addItem( "pt", g_ntrk, g_pt );
101 m_tuple->addItem( "p", g_ntrk, g_p );
102 m_tuple->addItem( "phi", g_ntrk, g_phi );
103 m_tuple->addItem( "theta", g_ntrk, g_theta );
104 m_tuple->addItem( "vx", g_ntrk, g_vx );
105 m_tuple->addItem( "vy", g_ntrk, g_vy );
106 m_tuple->addItem( "vz", g_ntrk, g_vz );
107 m_tuple->addItem( "dr", g_ntrk, g_dr );
108 m_tuple->addItem( "phi0", g_ntrk, g_phi0 );
109 m_tuple->addItem( "kappa", g_ntrk, g_kappa );
110 m_tuple->addItem( "dz", g_ntrk, g_dz );
111 m_tuple->addItem( "tanl", g_ntrk, g_tanl );
112 m_tuple->addItem( "eventtime", g_eventtime );
113 m_tuple->addItem( "Testime", g_estime );
114 }
115 else
116 { // did not manage to book the N tuple....
117 log << MSG::ERROR << "Cannot book N-tuple:" << long( m_tuple ) << endmsg;
118 return StatusCode::FAILURE;
119 }
120 }
121
122 g_sigmaxy = histoSvc()->book( "sigmaxy", "1D sigmaxy", 100, -0.2, 0.2 );
123 g_sigmaz = histoSvc()->book( "sigmaz", "1D sigmaz", 100, -3.5, 3.5 );
124 g_chi2xy = histoSvc()->book( "chi2xy", "1D chi2xy", 100, -0.01, 0.01 );
125 g_chi2sz = histoSvc()->book( "chi2sz", "1D chi2sz", 100, -8.0, 8. );
126 g_ncellMC = histoSvc()->book( "ncellmc", "1D ncellMC", 100, 0.0, 7000. );
127 g_ncell = histoSvc()->book( "ncell", "1D ncell", 100, 0.0, 7000. );
128 g_naxialhit = histoSvc()->book( "naxialhit", "2D axial hit", 30, 0.0, 30. );
129 g_nstereohit = histoSvc()->book( "nstereohit", "2D stereo hit", 30, 0.0, 30. );
130 g_nhit = histoSvc()->book( "nhit", "2D hit", 50, 0.0, 50. );
131 g_hitmap[0] = histoSvc()->book( "hm0", "2d hitmap1", 80, -80., 80., 80, -80., 80. );
132 g_hitmap[1] = histoSvc()->book( "hm1", "2d hitmap2", 80, -80., 80., 80, -80., 80. );
133 g_hitmap[2] = histoSvc()->book( "hm2", "2d hitmap3", 80, -80., 80., 80, -80., 80. );
134 g_hitmap[3] = histoSvc()->book( "hm3", "2d hitmap4", 80, -80., 80., 80, -80., 80. );
135 g_hitmap[4] = histoSvc()->book( "hm4", "2d hitmap5", 80, -80., 80., 80, -80., 80. );
136 g_hitmap[5] = histoSvc()->book( "hm5", "2d hitmap6", 80, -80., 80., 80, -80., 80. );
137 g_hitmap[6] = histoSvc()->book( "hm6", "2d hitmap7", 80, -80., 80., 80, -80., 80. );
138 g_hitmap[7] = histoSvc()->book( "hm7", "2d hitmap8", 80, -80., 80., 80, -80., 80. );
139 g_hitmap[8] = histoSvc()->book( "hm8", "2d hitmap9", 80, -80., 80., 80, -80., 80. );
140 g_hitmap[9] = histoSvc()->book( "hm9", "2d hitmap10", 80, -80., 80., 80, -80., 80. );
141 g_hitmap[10] = histoSvc()->book( "hm10", "2d hitmap11", 80, -80., 80., 80, -80., 80. );
142
143 num_2Dtrk = 0;
144 num_3Dtrk = 0;
145 num_finaltrk = 0;
146#endif
147
148 m_ftFinder = new FTFinder();
149 m_ftFinder->init();
150 m_ftFinder->setBunchtime( m_bunchtime_MC );
151 m_ftFinder->setT0cal( m_mdc_tcal );
152 m_ftFinder->setAlgorithmPointer( this );
153
154#ifndef OnlineMode
155 StatusCode sc = service( "BesTimerSvc", m_timersvc );
156 if ( sc.isFailure() )
157 {
158 log << MSG::WARNING << name() << ": Unable to locate BesTimer Service" << endmsg;
159 return StatusCode::FAILURE;
160 }
161
162 m_timer[1] = m_timersvc->addItem( "Execution" );
163 m_timer[1]->propName( "nExecution" );
164#endif
165
166 return StatusCode::SUCCESS;
167}
168
169// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
171 if ( !m_beginRun )
172 {
173 StatusCode sc = beginRun();
174 if ( sc.isFailure() )
175 {
176 error() << "beginRun failed" << endmsg;
177 return StatusCode::FAILURE;
178 }
179 m_beginRun = true;
180 }
181
182 MsgStream log( msgSvc(), name() );
183 log << MSG::INFO << "in execute()" << endmsg;
184
185#ifndef OnlineMode
186 m_timer[1]->start();
187#endif
188
189 m_ftFinder->event();
190
191#ifndef OnlineMode
192 m_timer[1]->stop();
193
194 g_eventtime = m_timer[1]->elapsed();
195
196 if ( m_tuple )
197 {
198 StatusCode status = m_tuple->write();
199 if ( !status.isSuccess() ) { log << MSG::ERROR << "Can't fill ntuple!" << endmsg; }
200 }
201#endif
202
203 return StatusCode::SUCCESS;
204}
205
206// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
208
209 MsgStream log( msgSvc(), name() );
210 log << MSG::INFO << "in finalize()" << endmsg;
211
212 m_ftFinder->term();
213#ifndef OnlineMode
214 log << MSG::DEBUG << "num_2Dtrk: " << num_2Dtrk << " num_3Dtrk: " << num_3Dtrk
215 << " num_finaltrk: " << num_finaltrk << endmsg;
216 m_timersvc->print();
217#endif
218
219 return StatusCode::SUCCESS;
220}
221
222// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
224 info() << "in beginRun()" << endmsg;
225 m_ftFinder->begin_run();
226
227 return StatusCode::SUCCESS;
228}
DECLARE_COMPONENT(BesBdkRc)
IHistogram1D * g_nstereohit
Definition ntupleItem.h:42
NTuple::Array< float > g_pz
Definition FTFinder.cxx:68
NTuple::Array< float > g_theta
Definition FTFinder.cxx:69
int num_3Dtrk
Definition FTFinder.cxx:81
NTuple::Array< float > g_pxMC
Definition ntupleItem.h:23
NTuple::Array< float > g_pzMC
Definition FTFinder.cxx:63
IHistogram1D * g_ncellMC
Definition ntupleItem.h:39
int num_2Dtrk
NTuple::Array< float > g_pyMC
Definition FTFinder.cxx:63
NTuple::Array< float > g_dr
Definition ntupleItem.h:32
IHistogram2D * g_hitmap[20]
Definition ntupleItem.h:44
NTuple::Array< float > g_kappa
Definition FTFinder.cxx:71
NTuple::Array< float > g_ptMC
Definition FTFinder.cxx:63
NTuple::Item< float > g_estime
Definition ntupleItem.h:33
NTuple::Array< float > g_dz
Definition FTFinder.cxx:71
NTuple::Array< float > g_tanl
Definition FTFinder.cxx:71
NTuple::Item< long > g_ntrk
Definition ntupleItem.h:27
NTuple::Item< long > g_ntrkMC
Definition ntupleItem.h:21
NTuple::Array< float > g_phi0MC
Definition FTFinder.cxx:62
int num_finaltrk
Definition FTFinder.cxx:81
NTuple::Array< float > g_py
Definition FTFinder.cxx:68
NTuple::Array< float > g_px
Definition ntupleItem.h:29
IHistogram1D * g_ncell
Definition ntupleItem.h:40
NTuple::Array< float > g_pt
Definition FTFinder.cxx:68
IHistogram1D * g_nhit
Definition ntupleItem.h:43
NTuple::Array< float > g_p
Definition FTFinder.cxx:68
NTuple::Array< float > g_phi0
Definition FTFinder.cxx:71
NTuple::Array< float > g_vx
Definition ntupleItem.h:31
IHistogram1D * g_naxialhit
Definition ntupleItem.h:41
NTuple::Array< float > g_vy
Definition FTFinder.cxx:70
NTuple::Array< float > g_theta0MC
Definition ntupleItem.h:22
NTuple::Array< float > g_vz
Definition FTFinder.cxx:70
NTuple::Array< float > g_phi
Definition ntupleItem.h:30
AIDA::IHistogram1D * g_sigmaz
Definition ntupleItem.h:36
AIDA::IHistogram1D * g_chi2xy
Definition ntupleItem.h:37
AIDA::IHistogram1D * g_sigmaxy
Definition ntupleItem.h:35
AIDA::IHistogram1D * g_chi2sz
Definition ntupleItem.h:38
int g_eventNo
Definition FTFinder.cxx:61
NTuple::Item< float > g_eventtime
Definition ntupleItem.h:28
INTupleSvc * ntupleSvc()
IHistogramSvc * histoSvc()
IMessageSvc * msgSvc()
StatusCode execute()
StatusCode finalize()
MdcFastTrkAlg(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode beginRun()
StatusCode initialize()