/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Reconstruction/KalFitAlg/KalFitAlg-00-07-55-p03/src/KalFitAlg2.cxx

Go to the documentation of this file.
00001 #include "KalFitAlg/KalFitAlg.h"
00002 #include "KalFitAlg/KalFitTrack.h"
00003 #include "GaudiKernel/MsgStream.h"
00004 #include "GaudiKernel/AlgFactory.h"
00005 #include "GaudiKernel/ISvcLocator.h"
00006 #include "GaudiKernel/SmartDataPtr.h"
00007 #include "GaudiKernel/IDataProviderSvc.h"
00008 #include "GaudiKernel/PropertyMgr.h"
00009 #include "MdcGeomSvc/IMdcGeomSvc.h"
00010 #include <fstream>
00011 
00012 
00013 
00014  IMdcGeomSvc* KalFitAlg::imdcGeomSvc_ = 0;
00015 
00016 /*void KalFitAlg::setInitMatrix(HepSymMatrix m)
00017  {
00018  initMatrix_ = m;
00019 
00020  }*/
00021 
00022  /*
00023  void KalFitAlg::setMaterial_Mdc(void)
00024 {
00025   if(debug_ == 4) cout << " Mdc cylinder material file :\n";
00026   //  string  fn("$HOME/geomdc_material.dat");
00027   if(debug_ == 4) cout << " "  << matfile_ << std::endl;
00028   ifstream fin(matfile_.c_str() ); 
00029   if(!fin){
00030     perror(matfile_.c_str());
00031     cout<<"KalFitAlg::setMaterial.......file reading error"<<endl;
00032     exit(1);
00033   }
00034 
00035   double z, a, i, rho, x0;
00036 
00037   for (int j = 0; j < 6 &&
00038          fin >> z >> a >> i >> rho >> x0; j++){
00039      KalFitMaterial  mat(z, a, i, rho, x0);
00040      _BesKalmanFitMaterials.push_back(mat);
00041   };
00042   fin.close();
00043 }
00044 */
00045 
00046 
00047 /*
00048 void KalFitAlg::setCylinder_Mdc(void)
00049 {
00050   double radius, thick, length , z0;
00051 
00053   radius = _BesKalmanFitTubs[0].GetInnerRadius()/(cm);
00054   thick  = _BesKalmanFitTubs[0].GetOuterRadius()/(cm) - _BesKalmanFitTubs[0].GetInnerRadius()/(cm);
00055   length = 2.0*_BesKalmanFitTubs[0].GetZHalfLength()/(cm); 
00056   z0     = 0.0;
00057   std::cout<<"innerwall: "<<" radius: "<<radius<<" thick:"<<thick<<" length: "<<length<<std::endl;
00058   KalFitCylinder innerwallCylinder(&(_BesKalmanFitMaterials[1]), radius, thick, length , z0);
00059   _BesKalmanFitWalls.push_back(innerwallCylinder);
00060   
00061   
00063   radius = _BesKalmanFitTubs[2].GetOuterRadius()/(cm);
00064   thick  = _BesKalmanFitTubs[0].GetInnerRadius()/(cm) - _BesKalmanFitTubs[2].GetOuterRadius()/(cm);
00065   length = 2.0*_BesKalmanFitTubs[0].GetZHalfLength()/(cm);
00066   z0     = 0.0;
00067   std::cout<<"outer air: "<<" radius: "<<radius<<" thick:"<<thick<<" length: "<<length<<std::endl;
00068   KalFitCylinder outerAirCylinder(&(_BesKalmanFitMaterials[4]), radius, thick, length , z0);
00069   _BesKalmanFitWalls.push_back(outerAirCylinder);
00070            
00071  
00073   radius = _BesKalmanFitTubs[2].GetInnerRadius()/(cm);
00074   thick  = _BesKalmanFitTubs[2].GetOuterRadius()/(cm) - _BesKalmanFitTubs[2].GetInnerRadius()/(cm);
00075   length = 2.0*_BesKalmanFitTubs[2].GetZHalfLength()/(cm);
00076   z0     = 0.0;
00077   std::cout<<"outer Be: "<<" radius: "<<radius<<" thick:"<<thick<<" length: "<<length<<std::endl;
00078   KalFitCylinder outerBeCylinder(&(_BesKalmanFitMaterials[2]), radius, thick, length , z0);
00079   _BesKalmanFitWalls.push_back(outerBeCylinder);
00080   
00081 
00083   radius = _BesKalmanFitTubs[3].GetInnerRadius()/(cm);
00084   thick  = _BesKalmanFitTubs[3].GetOuterRadius()/(cm) - _BesKalmanFitTubs[3].GetInnerRadius()/(cm);
00085   length = 2.0*_BesKalmanFitTubs[3].GetZHalfLength()/(cm);
00086   z0     = 0.0;
00087   std::cout<<"He gas: "<<" radius: "<<radius<<" thick:"<<thick<<" length: "<<length<<std::endl;
00088   KalFitCylinder heCylinder(&(_BesKalmanFitMaterials[3]), radius, thick, length , z0);
00089   _BesKalmanFitWalls.push_back(heCylinder);
00090 
00091     
00093   radius = _BesKalmanFitTubs[4].GetInnerRadius()/(cm);
00094   thick  = _BesKalmanFitTubs[4].GetOuterRadius()/(cm) - _BesKalmanFitTubs[4].GetInnerRadius()/(cm);
00095   length = 2.0*_BesKalmanFitTubs[4].GetZHalfLength()/(cm);
00096   z0     = 0.0;
00097   std::cout<<"inner Be: "<<" radius: "<<radius<<" thick:"<<thick<<" length: "<<length<<std::endl;
00098   KalFitCylinder innerBeCylinder(&(_BesKalmanFitMaterials[2]), radius, thick, length , z0);
00099   _BesKalmanFitWalls.push_back(innerBeCylinder);
00100 
00102   radius = 0.;
00103   thick  = _BesKalmanFitTubs[4].GetInnerRadius()/(cm);
00104   length = 2.0*_BesKalmanFitTubs[4].GetZHalfLength()/(cm);
00105   z0     = 0.0;
00106   std::cout<<"inner air: "<<" radius: "<<radius<<" thick:"<<thick<<" length: "<<length<<std::endl;
00107   KalFitCylinder innerAirCylinder(&(_BesKalmanFitMaterials[4]), radius, thick, length , z0);
00108   _BesKalmanFitWalls.push_back(innerAirCylinder);
00109   
00110 }
00111 */
00112 
00113 
00114 void KalFitAlg::set_Mdc(void)
00115 {
00116    MdcGeomSvc * mdcGeomSvc = dynamic_cast<MdcGeomSvc* >(imdcGeomSvc_);
00117   if(! mdcGeomSvc) {
00118        std::cout<<"ERROR OCCUR when dynamic_cast in KalFitAlg2.cxx ..!!"<<std::endl;
00119    }
00120 
00121   if(debug_ == 4)  {
00122      cout << "KalFitAlg:: MDC initialisation " << std::endl;
00123    }
00124   _wire = NULL;
00125   _layer = NULL; 
00126   _superLayer = NULL;
00127 
00128   const int Nwire = mdcGeomSvc->getWireSize();
00129   const int Nlyr =  mdcGeomSvc->getLayerSize();
00130   const int Nsup =  mdcGeomSvc->getSuperLayerSize();
00131 
00132   if (!Nwire || !Nlyr || !Nsup){
00133     cout << ".....MdcGeom Objects are missing !! " << std::endl;
00134     exit(-1); 
00135   }
00136       
00137   if (!_wire) 
00138     _wire = (KalFitWire *) malloc((Nwire+1) * sizeof(KalFitWire));
00139   if (!_layer) 
00140     _layer = (KalFitLayer_Mdc *) malloc(Nlyr * sizeof(KalFitLayer_Mdc));
00141   if (!_superLayer) 
00142     _superLayer = (KalFitSuper_Mdc *) malloc(Nsup * sizeof(KalFitSuper_Mdc));
00143 
00144   if (!_wire || !_layer || !_superLayer){  
00145     std::cerr << "KalFitAlg::Cannot allocate geometries" << std::endl;
00146     std::cerr << "JOB will stop" << std::endl;
00147     exit(-1);
00148   }
00149    
00150   int superLayerID = 0;
00151   int layerID = 0;
00152   int localLayerID = 0;
00153   int localWireID = 0; 
00154   int localID = 0;
00155   int wireID;
00156 
00157   MdcGeoLayer * layer_back = NULL;
00158   MdcGeoSuper * superLayer_back = NULL;
00159   int k = 0;
00160   int Nlayer[12];
00161   int Nlocal[12];
00162   int NlocalWireID[43];
00163 
00164   for (wireID = 0;wireID <= Nwire; wireID++) {
00165     MdcGeoLayer * layer = (wireID==Nwire) ? NULL : mdcGeomSvc->Wire(wireID)->Lyr();
00166     if (layer != layer_back) {
00167       layer_back = layer;
00168       MdcGeoSuper * superLayer = (wireID==Nwire) ? NULL : mdcGeomSvc->Layer(layerID)->Sup();
00169       if (superLayer != superLayer_back) {
00170         superLayer_back = superLayer;
00171         Nlayer[k] = localLayerID;
00172         Nlocal[k] = localID;
00173         localLayerID = 0;
00174         k++;
00175       }
00176       NlocalWireID[layerID] = localWireID;
00177       localID = 0;
00178       localWireID = 0;
00179       layerID++;
00180       localLayerID++;
00181     }
00182     localID++;
00183     localWireID++;
00184   }
00185 
00186   superLayerID = -1;
00187   layerID = -1;
00188   localLayerID = 0;
00189   localID = 0;
00190   layer_back = NULL;
00191   superLayer_back = NULL;
00192   for (wireID = 0;wireID < Nwire; wireID++) {
00193     MdcGeoLayer * layer = (wireID==Nwire) ? 
00194                           NULL : mdcGeomSvc->Wire(wireID)->Lyr();
00195     if (layer != layer_back){
00196       layer_back = layer;
00197       MdcGeoSuper * superLayer = (wireID==Nwire) ? 
00198                                  NULL : mdcGeomSvc->Layer(layerID+1)->Sup();
00199       if (superLayer != superLayer_back){
00200         superLayer_back = superLayer;
00201         // initialize super-layer
00202         superLayerID++;
00203         new(_superLayer+superLayerID) KalFitSuper_Mdc(wireID,
00204                                                    Nlocal[superLayerID+1],
00205                                                    layerID+1,
00206                                                    Nlayer[superLayerID+1],
00207                                                    superLayerID);
00208         localLayerID=0;
00209       }
00210       // initialize layer
00211       layerID++;
00212       double slantWithSymbol = (mdcGeomSvc->Layer(layerID)->Slant())
00213                               *(mdcGeomSvc->Layer(layerID)->Sup()->Type());
00214       new(_layer+layerID) KalFitLayer_Mdc(_superLayer[superLayerID],
00215                                   0.1*layer->Radius(), (layer->Slant())*(layer->Sup()->Type()),
00216                                   0.1*(layer->Length()/2), 
00217                                   0.1*(-layer->Length()/2), layer->Offset(),
00218                                   layerID, localLayerID++ );
00219       localID = 0;
00220     }
00221     // initialize wire
00222 
00223     const MdcGeoWire * wire = (wireID==Nwire) ? NULL : mdcGeomSvc->Wire(wireID); 
00224     HepPoint3D fwd(0.1*wire->Backward());
00225     HepPoint3D bck(0.1*wire->Forward());
00226 
00227     if (superLayerID == 2 || superLayerID == 3  ||
00228         superLayerID == 4 || superLayerID == 9 ||
00229         superLayerID == 10) {     // axial wire
00230       new(_wire+wireID) KalFitWire(localID++,_layer[layerID],
00231                                    fwd,bck, _wire+Nwire,wire->Id(),0);
00232                               
00233     } else {                      // stereo wire
00234       new(_wire+wireID) KalFitWire(localID++,_layer[layerID],
00235                                    fwd,bck, _wire+Nwire,wire->Id(),1);
00236     }
00237   }
00238  
00239   // make virtual wire object for the pointer of boundary's neighbor
00240   new(_wire+Nwire) KalFitWire();
00241 
00242   if (debug_ == 4) cout << "MDC geometry reading done" << std::endl;  
00243 
00244   return;
00245 }
00246 
00247 void KalFitAlg::setCalibSvc_init()
00248  {
00249   IMdcCalibFunSvc* imdcCalibSvc; 
00250   MsgStream log(msgSvc(), name());
00251   StatusCode sc = service ("MdcCalibFunSvc", imdcCalibSvc);
00252   m_mdcCalibFunSvc_ = dynamic_cast<MdcCalibFunSvc*>(imdcCalibSvc);
00253   if ( sc.isFailure() ){
00254     log << MSG::FATAL << "Could not load MdcCalibFunSvc!" << endreq;
00255   }
00256  KalFitTrack::setMdcCalibFunSvc( m_mdcCalibFunSvc_);
00257  }
00258 
00259 void KalFitAlg::setGeomSvc_init()
00260  {
00261   IMdcGeomSvc*  imdcGeomSvc;
00262   MsgStream log(msgSvc(), name());
00263   StatusCode sc = service ("MdcGeomSvc", imdcGeomSvc);
00264 //  m_mdcGeomSvc_ = dynamic_cast<MdcGeomSvc*>(imdcGeomSvc);
00265   if ( sc.isFailure() ){
00266     log << MSG::FATAL << "Could not load MdcGeomSvc!" << endreq;
00267   }
00268  imdcGeomSvc_ = imdcGeomSvc;
00269 
00270  KalFitTrack::setIMdcGeomSvc( imdcGeomSvc);
00271  }
00272 
00273  /*void KalFitAlg::getEventStarTime()
00274  {
00275  double t0=0.;
00276   MsgStream log(msgSvc(), name());
00277  // t_t0 = -1;
00278  // t_t0Stat = -1;
00279   SmartDataPtr<EvTimeCol> evtimeCol(eventSvc(),"/Event/Recon/EvTimeCol");
00280   if (evtimeCol) {
00281     EvTimeCol::iterator iter_evt = evtimeCol->begin();
00282     t0 =  (*iter_evt)->getTest()*1.e-9;
00283  // t_t0 = (*iter_evt)->getTest();
00284  // t_t0Stat = (*iter_evt)->getStat();
00285   }else{
00286     log << MSG::WARNING << "Could not find EvTimeCol" << endreq;
00287   }
00288 
00289  KalFitTrack::setT0(t0);
00290 
00291  }
00292 */

Generated on Tue Nov 29 23:13:24 2016 for BOSS_7.0.2 by  doxygen 1.4.7