/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Reconstruction/MdcFastTrkAlg/MdcFastTrkAlg-00-04-09/src/FTSegment.cxx

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     MdcFastTrkAlg
00004 // Module:      FTSegment
00005 // 
00006 // Description:  segment class for MdcFastTrkAlg
00007 //
00008 
00009 #include <math.h>
00010 #include "MdcFastTrkAlg/FTSegment.h"
00011 #include "MdcFastTrkAlg/FTTrack.h"
00012 #include "MdcFastTrkAlg/FTWire.h"
00013 #include "MdcFastTrkAlg/FTSuperLayer.h"
00014 #include "MdcFastTrkAlg/MdcFastTrkAlg.h"
00015 #include "MdcFastTrkAlg/MdcParameter.h"
00016 MdcParameter* FTSegment::param = MdcParameter::instance();
00017 
00018 
00019 int
00020 FTSegment::examine(){
00021   int stat = -1;
00022   FTList<FTWire *> wireHitsByLocalLayer[4] = {4,4,4,4};
00023 
00024   register FTWire ** hptr = _wireHits.firstPtr();
00025   FTWire ** const last = _wireHits.lastPtr();
00026   do{
00027     wireHitsByLocalLayer[(**hptr).layer().localLayerId()].append(*hptr);
00028   }while((hptr++)!=last);
00029   float length_phi = 0.;
00030   int innerBoundId = 0;
00031   int outerBoundId = 0;
00032   int AlreadyFound = 0;
00033   //int LocalLayerLength; 
00034   //int HalfLocalLayerLength;
00035   const int nLayer = _superLayer.nLayer();
00036   // to look for the innerBound and outBand of the hits
00037   for (int i = 0; i^nLayer; i++){
00038     int N_wireHits = wireHitsByLocalLayer[i].length();
00039     if(N_wireHits){
00040       float localPhi_max = 0.;
00041       float localPhi_min = 7.;
00042       for (int j = 0; j^N_wireHits; j++){
00043         float localPhi = wireHitsByLocalLayer[i][j]->phi();
00044         //LocalLayerLength = wireHitsByLocalLayer[i][j]->layer().NWire();
00045         //HalfLocalLayerLength = LocalLayerLength >> 1;     
00046         if (localPhi > localPhi_max) localPhi_max = localPhi;
00047         if (localPhi < localPhi_min) localPhi_min = localPhi;
00048       }
00049       float local_length_phi = localPhi_max - localPhi_min;
00050       if (local_length_phi > M_PI)
00051         local_length_phi = 2*M_PI - local_length_phi;
00052       if ( local_length_phi > length_phi ) length_phi = local_length_phi;
00053       outerBoundId = i;
00054       AlreadyFound = 1;
00055     } else if(!AlreadyFound){
00056       innerBoundId++;
00057     } else {
00058       break;
00059     }
00060   }
00061   //length_phi needed to decide more carefully 
00062   //  if (length_phi>0.09){
00063   //  cout<<length_phi<<" : "<<FTSuperLayer::_maxDphi[_superLayer.superLayerId()]*2*M_PI/180<<endl;
00064   if (length_phi>FTSuperLayer::_maxDphi[_superLayer.superLayerId()]*2*M_PI/180){ //by X.-R. Lu
00065     stat = 3;                   // to be divided
00066   }else{
00067     if (innerBoundId > 0){
00068       stat = 2;                 // outer short
00069     }else{
00070       if (outerBoundId < nLayer - 1){
00071         stat = 1;               // inner short
00072       }else{
00073         stat = 0;               // long simple
00074       }
00075     }
00076   }
00077   _innerBoundHits.append(wireHitsByLocalLayer[innerBoundId]);
00078   _outerBoundHits.append(wireHitsByLocalLayer[outerBoundId]);
00079   return stat;
00080 }
00081 
00082 void
00083 FTSegment::update(void){
00084   //static const float alpha(333.564095);
00085   //float N_kappa;
00086   int n = _innerBoundHits.length();
00087   int m = _outerBoundHits.length();
00088 
00089   if (n^1) {
00090     _incoming_x = 0.5*(_innerBoundHits[0]->x()+_innerBoundHits[1]->x());
00091     _incoming_y = 0.5*(_innerBoundHits[0]->y()+_innerBoundHits[1]->y());
00092   } else {
00093     _incoming_x = _innerBoundHits[0]->x();
00094     _incoming_y = _innerBoundHits[0]->y();
00095   }
00096   if (m^1) {
00097     _outgoing_x = 0.5*(_outerBoundHits[0]->x()+_outerBoundHits[1]->x());
00098     _outgoing_y = 0.5*(_outerBoundHits[0]->y()+_outerBoundHits[1]->y());
00099   } else {
00100     _outgoing_x = _outerBoundHits[0]->x();
00101     _outgoing_y = _outerBoundHits[0]->y();
00102   }
00103   float in_r = _innerBoundHits.first()->layer().r();
00104   float out_r = _outerBoundHits.first()->layer().r();
00105   float sbX = _incoming_x - _outgoing_x;
00106   float sbY = _incoming_y - _outgoing_y;
00107   // kappa = -2. * alpha * ((Vin X Vout)_z / |Vin|*|Vout|) / |Vin-Vout|
00108   _kappa = 2.*(-1. / 2.99792458 /m_pmgnIMF->getReferField())*(_outgoing_x*_incoming_y - _outgoing_y*_incoming_x) /
00109     (in_r*out_r*sqrt(sbX*sbX+sbY*sbY));
00110   _r = 0.5*(in_r + out_r);
00111 }
00112 
00113 
00114 int
00115 FTSegment::update3D(const FTTrack * track){
00116   IMessageSvc *msgSvc;
00117   Gaudi::svcLocator()->service("MessageSvc", msgSvc);
00118   
00119   MsgStream log(msgSvc, "FTFinder");
00120   
00121   /*if (_superLayer.superLayerId() > 
00122     track->axial_segments().first()->superLayer().superLayerId() + 4) return 0;*/
00123   if (!_sList){
00124     int n = _innerBoundHits.length();
00125     int m = _outerBoundHits.length();
00126 
00127     _incoming_x = (n^1) 
00128       ? 0.5*(_innerBoundHits[0]->x()+_innerBoundHits[1]->x()) 
00129       : _innerBoundHits[0]->x();
00130     _incoming_y = (n^1) 
00131       ? 0.5*(_innerBoundHits[0]->y()+_innerBoundHits[1]->y()) 
00132       : _innerBoundHits[0]->y();
00133     _outgoing_x = (m^1) 
00134       ? 0.5*(_outerBoundHits[0]->x()+_outerBoundHits[1]->x()) 
00135       : _outerBoundHits[0]->x();
00136     _outgoing_y = (m^1) 
00137       ? 0.5*(_outerBoundHits[0]->y()+_outerBoundHits[1]->y()) 
00138       : _outerBoundHits[0]->y();
00139     _sList = new FTList<float>(5);
00140     _zList = new FTList<float>(5);
00141     _trackList = new FTList<FTTrack *>(5);
00142   }
00143   const Lpav & la = track->lpav();
00144   double d;
00145   double inS;
00146   const FTLayer * bound = &_innerBoundHits.first()->layer();
00147   log<<MSG::DEBUG<<"started inS calculation with layer limit "<< (double)bound->limit()<<endreq;
00148   if (!(la.sd((double)bound->r(),(double)_incoming_x,
00149               (double)_incoming_y,(double)bound->limit(),  // multiplied with an factor due to bad rphi fit
00150               inS,d))) return 0;
00151   double inZ = bound->z(d);
00152   double outS; 
00153   bound = &_outerBoundHits.first()->layer();
00154   log<<MSG::DEBUG<<"started outS calculation with layer limit "<< (double)bound->limit()<<endreq;
00155   if (!(la.sd((double)bound->r(),(double)_outgoing_x,
00156               (double)_outgoing_y,(double)bound->limit(),  // multiplied with an factor due to bad rphi fit
00157               outS,d))) return 0;
00158   double outZ = bound->z(d);
00159   _sList->append(inS+outS);
00160   _zList->append(inZ+outZ);
00161   _trackList->append((FTTrack *)track);
00162   log<<MSG::DEBUG<<"-----> coupled! DONE! "<<endreq;
00163   return 1;
00164 }
00165 
00166 void
00167 FTSegment::linkStereoSegments(void){
00168   float min_D_z = 9999.;
00169   float S = 0.;
00170   float Z = 0.;
00171   FTTrack * selected = NULL;
00172   int m = _trackList->length();
00173   for (int j = 0; j^m; j++){
00174     FTTrack * t = (*_trackList)[j];
00175     float z_tmp = (*_zList)[j];
00176     float s_tmp = (*_sList)[j];
00177     float D_z = fabs(t->d_z(s_tmp,z_tmp));
00178     if (D_z < min_D_z){
00179       selected = t;
00180       min_D_z = D_z;
00181       S = s_tmp;
00182       Z = z_tmp;
00183     }
00184   }
00185   if (selected){
00186     selected->append_stereo(this,S,Z); 
00187     
00188   }
00189 }
00190 
00191 #ifndef OnlineMode
00192 void 
00193 FTSegment::printout(void){
00194   
00195   IMessageSvc *msgSvc;
00196   Gaudi::svcLocator()->service("MessageSvc", msgSvc);
00197   
00198   MsgStream log(msgSvc, "FTSegment");
00199   log << MSG::DEBUG << "pintout of one segment:" << endreq;  
00200   int n=_wireHits.length();
00201   for(int i=0; i^n; i++){
00202     FTWire &h = *_wireHits[i];
00203      log << MSG::DEBUG << "hit: layer " << h.layer().layerId() << " phi "<< h.phi() << endreq;
00204   }
00205 }
00206 #endif

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