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