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