BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
KalFitAlg2.cxx
Go to the documentation of this file.
1#include "GaudiKernel/IDataProviderSvc.h"
2#include "GaudiKernel/ISvcLocator.h"
3#include "GaudiKernel/MsgStream.h"
4#include "GaudiKernel/PropertyMgr.h"
5#include "GaudiKernel/SmartDataPtr.h"
6#include "KalFitAlg.h"
7#include "KalFitAlg/KalFitTrack.h"
8#include "MdcGeomSvc/IMdcGeomSvc.h"
9#include <fstream>
10
11IMdcGeomSvc* KalFitAlg::imdcGeomSvc_ = 0;
12
13/*void KalFitAlg::setInitMatrix(HepSymMatrix m)
14 {
15 initMatrix_ = m;
16
17 }*/
18
19/*
20void KalFitAlg::setMaterial_Mdc(void)
21{
22 if(debug_ == 4) cout << " Mdc cylinder material file :\n";
23 // string fn("$HOME/geomdc_material.dat");
24 if(debug_ == 4) cout << " " << matfile_ << std::endl;
25 ifstream fin(matfile_.c_str() );
26 if(!fin){
27 perror(matfile_.c_str());
28 cout<<"KalFitAlg::setMaterial.......file reading error"<<endl;
29 exit(1);
30 }
31
32 double z, a, i, rho, x0;
33
34 for (int j = 0; j < 6 &&
35 fin >> z >> a >> i >> rho >> x0; j++){
36 KalFitMaterial mat(z, a, i, rho, x0);
37 _BesKalmanFitMaterials.push_back(mat);
38 };
39 fin.close();
40}
41*/
42
43/*
44void KalFitAlg::setCylinder_Mdc(void)
45{
46 double radius, thick, length , z0;
47
48 /// innerwall of inner drift chamber
49 radius = _BesKalmanFitTubs[0].GetInnerRadius()/(cm);
50 thick = _BesKalmanFitTubs[0].GetOuterRadius()/(cm) -
51_BesKalmanFitTubs[0].GetInnerRadius()/(cm); length
52= 2.0*_BesKalmanFitTubs[0].GetZHalfLength()/(cm); z0 = 0.0; std::cout<<"innerwall: "<<"
53radius: "<<radius<<" thick:"<<thick<<" length: "<<length<<std::endl; KalFitCylinder
54innerwallCylinder(&(_BesKalmanFitMaterials[1]), radius, thick, length , z0);
55 _BesKalmanFitWalls.push_back(innerwallCylinder);
56
57
58 /// outer air, be attention the calculation of the radius and thick of the air cylinder is
59special radius = _BesKalmanFitTubs[2].GetOuterRadius()/(cm); thick =
60_BesKalmanFitTubs[0].GetInnerRadius()/(cm) - _BesKalmanFitTubs[2].GetOuterRadius()/(cm); length
61= 2.0*_BesKalmanFitTubs[0].GetZHalfLength()/(cm); z0 = 0.0; std::cout<<"outer air: "<<"
62radius: "<<radius<<" thick:"<<thick<<" length: "<<length<<std::endl; KalFitCylinder
63outerAirCylinder(&(_BesKalmanFitMaterials[4]), radius, thick, length , z0);
64 _BesKalmanFitWalls.push_back(outerAirCylinder);
65
66
67 /// outer beryllium layer
68 radius = _BesKalmanFitTubs[2].GetInnerRadius()/(cm);
69 thick = _BesKalmanFitTubs[2].GetOuterRadius()/(cm) -
70_BesKalmanFitTubs[2].GetInnerRadius()/(cm); length
71= 2.0*_BesKalmanFitTubs[2].GetZHalfLength()/(cm); z0 = 0.0; std::cout<<"outer Be: "<<"
72radius: "<<radius<<" thick:"<<thick<<" length: "<<length<<std::endl; KalFitCylinder
73outerBeCylinder(&(_BesKalmanFitMaterials[2]), radius, thick, length , z0);
74 _BesKalmanFitWalls.push_back(outerBeCylinder);
75
76
77 /// helium gas
78 radius = _BesKalmanFitTubs[3].GetInnerRadius()/(cm);
79 thick = _BesKalmanFitTubs[3].GetOuterRadius()/(cm) -
80_BesKalmanFitTubs[3].GetInnerRadius()/(cm); length
81= 2.0*_BesKalmanFitTubs[3].GetZHalfLength()/(cm); z0 = 0.0; std::cout<<"He gas: "<<"
82radius: "<<radius<<" thick:"<<thick<<" length: "<<length<<std::endl; KalFitCylinder
83heCylinder(&(_BesKalmanFitMaterials[3]), radius, thick, length , z0);
84 _BesKalmanFitWalls.push_back(heCylinder);
85
86
87 /// inner beryllium layer
88 radius = _BesKalmanFitTubs[4].GetInnerRadius()/(cm);
89 thick = _BesKalmanFitTubs[4].GetOuterRadius()/(cm) -
90_BesKalmanFitTubs[4].GetInnerRadius()/(cm); length
91= 2.0*_BesKalmanFitTubs[4].GetZHalfLength()/(cm); z0 = 0.0; std::cout<<"inner Be: "<<"
92radius: "<<radius<<" thick:"<<thick<<" length: "<<length<<std::endl; KalFitCylinder
93innerBeCylinder(&(_BesKalmanFitMaterials[2]), radius, thick, length , z0);
94 _BesKalmanFitWalls.push_back(innerBeCylinder);
95
96 /// inner air
97 radius = 0.;
98 thick = _BesKalmanFitTubs[4].GetInnerRadius()/(cm);
99 length = 2.0*_BesKalmanFitTubs[4].GetZHalfLength()/(cm);
100 z0 = 0.0;
101 std::cout<<"inner air: "<<" radius: "<<radius<<" thick:"<<thick<<" length:
102"<<length<<std::endl; KalFitCylinder innerAirCylinder(&(_BesKalmanFitMaterials[4]), radius,
103thick, length , z0); _BesKalmanFitWalls.push_back(innerAirCylinder);
104
105}
106*/
107
108void KalFitAlg::set_Mdc( void ) {
109 IMdcGeomSvc* mdcGeomSvc = imdcGeomSvc_;
110 if ( !mdcGeomSvc )
111 { std::cout << "ERROR OCCUR when dynamic_cast in KalFitAlg2.cxx ..!!" << std::endl; }
112
113 if ( debug_ == 4 ) { cout << "KalFitAlg:: MDC initialisation " << std::endl; }
114 _wire = NULL;
115 _layer = NULL;
116 _superLayer = NULL;
117
118 const int Nwire = mdcGeomSvc->getWireSize();
119 const int Nlyr = mdcGeomSvc->getLayerSize();
120 const int Nsup = mdcGeomSvc->getSuperLayerSize();
121
122 if ( !Nwire || !Nlyr || !Nsup )
123 {
124 cout << ".....MdcGeom Objects are missing !! " << std::endl;
125 exit( -1 );
126 }
127
128 if ( !_wire ) _wire = (KalFitWire*)malloc( ( Nwire + 1 ) * sizeof( KalFitWire ) );
129 if ( !_layer ) _layer = (KalFitLayer_Mdc*)malloc( Nlyr * sizeof( KalFitLayer_Mdc ) );
130 if ( !_superLayer )
131 _superLayer = (KalFitSuper_Mdc*)malloc( Nsup * sizeof( KalFitSuper_Mdc ) );
132
133 if ( !_wire || !_layer || !_superLayer )
134 {
135 std::cerr << "KalFitAlg::Cannot allocate geometries" << std::endl;
136 std::cerr << "JOB will stop" << std::endl;
137 exit( -1 );
138 }
139
140 int superLayerID = 0;
141 int layerID = 0;
142 int localLayerID = 0;
143 int localWireID = 0;
144 int localID = 0;
145 int wireID;
146
147 MdcGeoLayer* layer_back = NULL;
148 MdcGeoSuper* superLayer_back = NULL;
149 int k = 0;
150 int Nlayer[12];
151 int Nlocal[12];
152 int NlocalWireID[43];
153
154 for ( wireID = 0; wireID <= Nwire; wireID++ )
155 {
156 MdcGeoLayer* layer = ( wireID == Nwire ) ? NULL : mdcGeomSvc->Wire( wireID )->Lyr();
157 if ( layer != layer_back )
158 {
159 layer_back = layer;
160 MdcGeoSuper* superLayer =
161 ( wireID == Nwire ) ? NULL : mdcGeomSvc->Layer( layerID )->Sup();
162 if ( superLayer != superLayer_back )
163 {
164 superLayer_back = superLayer;
165 Nlayer[k] = localLayerID;
166 Nlocal[k] = localID;
167 localLayerID = 0;
168 k++;
169 }
170 NlocalWireID[layerID] = localWireID;
171 localID = 0;
172 localWireID = 0;
173 layerID++;
174 localLayerID++;
175 }
176 localID++;
177 localWireID++;
178 }
179
180 superLayerID = -1;
181 layerID = -1;
182 localLayerID = 0;
183 localID = 0;
184 layer_back = NULL;
185 superLayer_back = NULL;
186 for ( wireID = 0; wireID < Nwire; wireID++ )
187 {
188 MdcGeoLayer* layer = ( wireID == Nwire ) ? NULL : mdcGeomSvc->Wire( wireID )->Lyr();
189 if ( layer != layer_back )
190 {
191 layer_back = layer;
192 MdcGeoSuper* superLayer =
193 ( wireID == Nwire ) ? NULL : mdcGeomSvc->Layer( layerID + 1 )->Sup();
194 if ( superLayer != superLayer_back )
195 {
196 superLayer_back = superLayer;
197 // initialize super-layer
198 superLayerID++;
199 new ( _superLayer + superLayerID )
200 KalFitSuper_Mdc( wireID, Nlocal[superLayerID + 1], layerID + 1,
201 Nlayer[superLayerID + 1], superLayerID );
202 localLayerID = 0;
203 }
204 // initialize layer
205 layerID++;
206 double slantWithSymbol = ( mdcGeomSvc->Layer( layerID )->Slant() ) *
207 ( mdcGeomSvc->Layer( layerID )->Sup()->Type() );
208 new ( _layer + layerID ) KalFitLayer_Mdc(
209 _superLayer[superLayerID], 0.1 * layer->Radius(),
210 ( layer->Slant() ) * ( layer->Sup()->Type() ), 0.1 * ( layer->Length() / 2 ),
211 0.1 * ( -layer->Length() / 2 ), layer->Offset(), layerID, localLayerID++ );
212 localID = 0;
213 }
214 // initialize wire
215
216 const MdcGeoWire* wire = ( wireID == Nwire ) ? NULL : mdcGeomSvc->Wire( wireID );
217 HepPoint3D fwd( 0.1 * wire->Backward() );
218 HepPoint3D bck( 0.1 * wire->Forward() );
219
220 if ( superLayerID == 2 || superLayerID == 3 || superLayerID == 4 || superLayerID == 9 ||
221 superLayerID == 10 )
222 { // axial wire
223 new ( _wire + wireID )
224 KalFitWire( localID++, _layer[layerID], fwd, bck, _wire + Nwire, wire->Id(), 0 );
225 }
226 else
227 { // stereo wire
228 new ( _wire + wireID )
229 KalFitWire( localID++, _layer[layerID], fwd, bck, _wire + Nwire, wire->Id(), 1 );
230 }
231 }
232
233 // make virtual wire object for the pointer of boundary's neighbor
234 new ( _wire + Nwire ) KalFitWire();
235
236 if ( debug_ == 4 ) cout << "MDC geometry reading done" << std::endl;
237
238 return;
239}
240
242 MsgStream log( msgSvc(), name() );
243 StatusCode sc = service( "MdcCalibFunSvc", m_mdcCalibFunSvc_ );
244 if ( sc.isFailure() ) { log << MSG::FATAL << "Could not load MdcCalibFunSvc!" << endmsg; }
245 KalFitTrack::setMdcCalibFunSvc( m_mdcCalibFunSvc_ );
246}
247
249 IMdcGeomSvc* imdcGeomSvc;
250 MsgStream log( msgSvc(), name() );
251 StatusCode sc = service( "MdcGeomSvc", imdcGeomSvc );
252 // m_mdcGeomSvc_ = dynamic_cast<MdcGeomSvc*>(imdcGeomSvc);
253 if ( sc.isFailure() ) { log << MSG::FATAL << "Could not load MdcGeomSvc!" << endmsg; }
254 imdcGeomSvc_ = imdcGeomSvc;
255
256 KalFitTrack::setIMdcGeomSvc( imdcGeomSvc );
257}
258
259/*void KalFitAlg::getEventStarTime()
260{
261double t0=0.;
262 MsgStream log(msgSvc(), name());
263// t_t0 = -1;
264// t_t0Stat = -1;
265 SmartDataPtr<EvTimeCol> evtimeCol(eventSvc(),"/Event/Recon/EvTimeCol");
266 if (evtimeCol) {
267 EvTimeCol::iterator iter_evt = evtimeCol->begin();
268 t0 = (*iter_evt)->getTest()*1.e-9;
269// t_t0 = (*iter_evt)->getTest();
270// t_t0Stat = (*iter_evt)->getStat();
271 }else{
272 log << MSG::WARNING << "Could not find EvTimeCol" << endmsg;
273 }
274
275KalFitTrack::setT0(t0);
276
277}
278*/
HepGeom::Point3D< double > HepPoint3D
Definition KalFitAlg.h:50
IMessageSvc * msgSvc()
virtual const int getLayerSize()=0
virtual const MdcGeoLayer *const Layer(unsigned id)=0
virtual const MdcGeoWire *const Wire(unsigned id)=0
virtual const int getWireSize()=0
virtual const int getSuperLayerSize()=0
void setCalibSvc_init(void)
initialize for the services
int debug_
Debug flag for the track finder part.
Definition KalFitAlg.h:207
void setGeomSvc_init(void)
void set_Mdc(void)
Set up the wires, layers and superlayers...
static void setMdcCalibFunSvc(const IMdcCalibFunSvc *calibsvc)
static void setIMdcGeomSvc(IMdcGeomSvc *igeomsvc)