Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

FTFinder Class Reference

#include <FTFinder.h>

List of all members.

Public Member Functions

void begin_run ()
 begin run function(reads constants)
void begin_run ()
 begin run function(reads constants)
void event ()
 track finder core
void event ()
 track finder core
 FTFinder ()
 Constructors and destructor.
 FTFinder ()
 Constructors and destructor.
int getWireId (FTWire *) const
 returns wire ID for given FTWire object
int getWireId (FTWire *) const
 returns wire ID for given FTWire object
void init ()
 initializer(creates geometry)
void init ()
 initializer(creates geometry)
void setAlgorithmPointer (Algorithm *)
 returns FTFinder pointer
void setAlgorithmPointer (Algorithm *)
 returns FTFinder pointer
FTSuperLayersuperLayer (int id) const
 returns superlayer
FTSuperLayersuperLayer (int id) const
 returns superlayer
float t2x (const FTLayer &l, const float t) const
 convert t to x
float t2x (const FTLayer &l, const float t) const
 convert t to x
void term ()
 terminator
void term ()
 terminator
FTList< FTTrack * > & tracks (void) const
 returns track list
FTList< FTTrack * > & tracks (void) const
 returns track list
CLHEP::Hep3Vector vertex (void) const
 returns event primary vertex
CLHEP::Hep3Vector vertex (void) const
 returns event primary vertex
float x2t (const FTLayer &l, const float x) const
 convert x to t
float x2t (const FTLayer &l, const float x) const
 convert x to t

Public Attributes

int eventNo
float evtTiming
int expflag
int i_rPhiFit
const HepPoint3D pivot
int runNo
float t0Estime
int tEstFlag
FTList< float > tEstime [10]
FTList< float > tEstime [10]
float Testime
float tOffSet

Private Member Functions

void clear (void)
 clear object
void clear (void)
 clear object
int CorrectEvtTiming (void)
 corrects event timing after 2nd r-phi fit and returns event timing
int CorrectEvtTiming (void)
 corrects event timing after 2nd r-phi fit and returns event timing
int findBestVertex (void)
 find vertex closest to IP
int findBestVertex (void)
 find vertex closest to IP
int getTestime (void)
 get event start time from segment linear fit
int getTestime (void)
 get event start time from segment linear fit
FTTracklinkAxialSegments (FTSegment **inner, FTSegment **outer)
 link axial segments to make track
FTTracklinkAxialSegments (FTSegment **inner, FTSegment **outer)
 link axial segments to make track
void linkAxialSegments_step (FTList< FTSegment * > &InnerSegments, FTList< FTSegment * > &OuterSegments, FTList< FTSegment * > &Connected, float maxDphi, float maxChi2)
void linkAxialSegments_step (FTList< FTSegment * > &InnerSegments, FTList< FTSegment * > &OuterSegments, FTList< FTSegment * > &Connected, float maxDphi, float maxChi2)
void linkAxialSuperLayer234 (FTList< FTSegment * > &inner_segments)
void linkAxialSuperLayer234 (FTList< FTSegment * > &inner_segments)
void linkAxialSuperLayer910 (FTList< FTSegment * > &outer_segments)
void linkAxialSuperLayer910 (FTList< FTSegment * > &outer_segments)
void makeMdst (void)
 make Mdst_charged/trk/trk_fit table from reconstruted tracks
void makeMdst (void)
 make Mdst_charged/trk/trk_fit table from reconstruted tracks
StatusCode makeTds (void)
 output tracking results into TDS
StatusCode makeTds (void)
 output tracking results into TDS
void mkTrack3D (void)
 create 3D track list
void mkTrack3D (void)
 create 3D track list
void mkTrackList (void)
 create track list
void mkTrackList (void)
 create track list
StatusCode registT0 (void)
StatusCode registT0 (void)
int updateMdc (void)
 unpack RAWCDC and create wire-hit
int updateMdc (void)
 unpack RAWCDC and create wire-hit
int VertexFit (int z_flag)
 finds event primary vertex
int VertexFit (int z_flag)
 finds event primary vertex
int VertexFit2D ()
 finds event primary vertex from 2D tracks
int VertexFit2D ()
 finds event primary vertex from 2D tracks

Private Attributes

FTList< FTSegment * > _axialSegCollect
FTList< FTSegment * > _axialSegCollect
int _ExpNo
FTLayer_layer
FTLayer_layer
FTList< FTSegment * > * _linkedSegments
FTList< FTSegment * > * _linkedSegments
int _RunNo
FTSuperLayer_superLayer
FTSuperLayer_superLayer
FTList< FTTrack * > & _tracks
FTList< FTTrack * > & _tracks
double _vx
double _vy
double _vz
int _widbase [43]
FTWire_wire
FTWire_wire
Algorithm * m_algorithm
Algorithm * m_algorithm
HepPDT::ParticleDataTable * m_particleTable
HepPDT::ParticleDataTable * m_particleTable
IRawDataProviderSvcm_rawDataProviderSvc
IRawDataProviderSvcm_rawDataProviderSvc
int m_total_trk

Static Private Attributes

MdcParameterparam
MdcParameterparam = MdcParameter::instance()


Constructor & Destructor Documentation

FTFinder::FTFinder  ) 
 

Constructors and destructor.

00122   :// findEventVertex(1),
00123   // evtTimeCorr(1),
00124   
00125   //  minPt(0.07),
00126   // minDr(7.5),
00127   // tOffSet(0.),
00128   // xtCoEff(0.0344),
00129   // doIt(1),
00130 #ifndef OnlineMode
00131   // mkMdst(true),
00132 #endif
00133   // mkTds(true),
00134   tOffSet(0.),
00135   t0Estime(-999.),
00136   tEstFlag(0),
00137   
00138   _wire(NULL),
00139   _layer(NULL),
00140   _superLayer(NULL),
00141   _tracks(*(new FTList<FTTrack *>(20))),
00142   _linkedSegments(new FTList<FTSegment *>(6)),
00143   _axialSegCollect(10),
00144   _vx(0.),
00145   _vy(0.),
00146   _vz(0.),
00147   _ExpNo(0),
00148   _RunNo(0),
00149   m_total_trk(0),
00150   pivot(0,0,0)
00151 {
00152   
00153 }

FTFinder::FTFinder  ) 
 

Constructors and destructor.


Member Function Documentation

void FTFinder::begin_run  ) 
 

begin run function(reads constants)

void FTFinder::begin_run  ) 
 

begin run function(reads constants)

00328                    {
00329 
00330   eventNo = 0;
00331   runNo=0;
00332   expflag=0;
00333   if (!param->_doIt) return;
00334   _ExpNo = 0;
00335   _RunNo = 0;
00336 
00337   IMdcGeomSvc* mdcGeomSvc;
00338   StatusCode sc = Gaudi::svcLocator()->service("MdcGeomSvc", mdcGeomSvc);
00339 
00340   if (sc ==  StatusCode::SUCCESS) {
00341    //mdcGeomSvc->Dump();
00342    
00343   } else {
00344     return ;
00345   }
00346   
00347   const int Nwire = mdcGeomSvc->getWireSize();
00348   const int Nlyr =  mdcGeomSvc->getLayerSize();
00349   const int Nsup =  mdcGeomSvc->getSuperLayerSize();
00350 
00351   if(!Nwire || !Nlyr){
00352     std::cerr << "FTFINDER::GEOCDC not found (please put cdctable before l4)" << std::endl;
00353     std::cerr << "JOB will stop" << std::endl;
00354     exit(-1);
00355   }
00356  
00357   if (!_wire) _wire = (FTWire *) malloc((Nwire+1) * sizeof(FTWire));
00358   if (!_layer) _layer = (FTLayer *) malloc(Nlyr * sizeof(FTLayer));
00359   if (!_superLayer) _superLayer =
00360                       (FTSuperLayer *) malloc(Nsup * sizeof(FTSuperLayer));
00361  
00362   if (!_wire || !_layer || !_superLayer){
00363     std::cerr << "FTFINDER::Cannot allocate geometries" << std::endl;
00364     std::cerr << "JOB will stop" << std::endl;
00365     exit(-1);
00366   }
00367 
00368   int superLayerID = 0;
00369   int layerID = 0;
00370   int localLayerID = 0;
00371   int localWireID = 0;
00372   int localID = 0;
00373   int wireID;
00374   MdcGeoLayer * layer_back = NULL;
00375   MdcGeoSuper * superLayer_back = NULL;
00376   int k = 0;
00377   int Nlayer[12];
00378   int Nlocal[12];
00379   int NlocalWireID[44];
00380 
00381   for (wireID = 0;wireID <= Nwire; wireID++){
00382     MdcGeoLayer * layer = (wireID==Nwire) ? NULL : mdcGeomSvc->Wire(wireID)->Lyr();
00383     if (layer != layer_back){
00384       layer_back = layer;
00385       MdcGeoSuper * superLayer = (wireID==Nwire) ? NULL : mdcGeomSvc->Layer(layerID)->Sup();
00386       if (superLayer != superLayer_back){
00387         superLayer_back = superLayer;
00388         Nlayer[k] = localLayerID;
00389         Nlocal[k] = localID;
00390         localLayerID = 0;
00391         k++;
00392       }
00393       NlocalWireID[layerID] = localWireID;
00394       localID = 0;
00395       localWireID = 0;
00396       layerID++;
00397       localLayerID++;
00398     }
00399     localID++;
00400     localWireID++;
00401   }
00402 
00403 
00404   superLayerID = -1;
00405   layerID = -1;
00406   localLayerID = 0;
00407   localID = 0;
00408   layer_back = NULL;
00409   superLayer_back = NULL;
00410   for (wireID = 0;wireID < Nwire; wireID++){
00411     MdcGeoLayer * layer = mdcGeomSvc->Wire(wireID)->Lyr();
00412     if (layer != layer_back){
00413       layer_back = layer;
00414       MdcGeoSuper * superLayer = mdcGeomSvc->Layer(layerID+1)->Sup();
00415       if (superLayer != superLayer_back){
00416         superLayer_back = superLayer;
00417         // initialize super-layer
00418         superLayerID++;
00419         new(_superLayer+superLayerID) FTSuperLayer(wireID,
00420                                                    Nlocal[superLayerID+1],
00421                                                    layerID+1,
00422                                                    Nlayer[superLayerID+1],
00423                                                    superLayerID);
00424         localLayerID=0;
00425       }
00426       // initialize layer
00427       layerID++;
00428       double slantWithSymbol = (mdcGeomSvc->Layer(layerID)->Slant())*(mdcGeomSvc->Layer(layerID)->Sup()->Type());
00429       // slant in new MdcGeomSvc include  symbol 
00430        new(_layer+layerID) FTLayer(0.1*layer->Radius(), layer->Slant(),
00431                                   0.1*(+layer->Length()/2), 0.1*(-layer->Length()/2), 0.1*layer->Offset(),
00432                                   layerID, localLayerID++, NlocalWireID[layerID+1],
00433                                   _superLayer[superLayerID]);
00434       localID = 0;
00435     }
00436     // initialize wire
00437     const MdcGeoWire * wire = mdcGeomSvc->Wire(wireID); 
00438     if (superLayerID == 2 || superLayerID == 3  ||
00439         superLayerID == 4 || superLayerID == 9 ||
00440         superLayerID == 10){     // axial wire
00441       new(_wire+wireID) FTWire(0.1*(float)0.5*(wire->Backward().x()+wire->Forward().x()),
00442                                0.1*(float)0.5*(wire->Backward().y()+wire->Forward().y()),
00443                                0.,0.,
00444                                _layer[layerID], localID++, _wire+Nwire);
00445                               
00446     }else{                      // stereo wire
00447       new(_wire+wireID) FTWire(0.1*(float)wire->Backward().x(),
00448                                0.1*(float)wire->Backward().y(),
00449                                0.1*(float)wire->Forward().x() - 0.1*(float)wire->Backward().x(),
00450                                0.1*(float)wire->Forward().y() - 0.1*(float)wire->Backward().y(),
00451                                _layer[layerID], localID++, _wire+Nwire);
00452     }
00453   }
00454  
00455   // make virtual wire object for the pointer of boundary's neighbor
00456   new(_wire+Nwire) FTWire();
00457 
00458   for (int i = 0; i < Nwire; i++){
00459     (*(_wire+i)).initNeighbor(); 
00460   }
00461   
00462   _widbase[0] = 0;
00463   for (int k = 1; k < 43; k++){
00464     _widbase[k] = _widbase[k-1] + (*(_layer+k-1)).NWire();
00465   }
00466 }

void FTFinder::clear void   )  [private]
 

clear object

void FTFinder::clear void   )  [private]
 

clear object

00840                    {
00841   evtTiming = 0;
00842   
00843   if ( _superLayer ) {
00844      for (int i = 0; i^11; i++) (*(_superLayer+i)).clear();
00845   }
00846   _tracks.deleteAll();
00847   _axialSegCollect.deleteAll();
00848   _vx = -99999.;
00849   _vy = -99999.;
00850   _vz = -99999.;
00851   for (int i = 0; i < 10; i++) {
00852     tEstime[i].clear();
00853   }
00854 }

int FTFinder::CorrectEvtTiming void   )  [private]
 

corrects event timing after 2nd r-phi fit and returns event timing

int FTFinder::CorrectEvtTiming void   )  [private]
 

corrects event timing after 2nd r-phi fit and returns event timing

01642 {
01643   int nTrks = _tracks.length();
01644   float weight_sum = 0.;
01645   float dt_sum2 = 0.;
01646   for (int i = 0; i^nTrks; i++){
01647     float dt_sum = 0.;
01648     float dtt_sum = 0.;
01649     int nHits = 0;
01650     const Lpav & la = _tracks[i]->lpav();
01651     FTList<FTSegment *>& axial_sgmnts = _tracks[i]->axial_segments();
01652     int m = axial_sgmnts.length();
01653     for (int j = 0; j^m; j++){
01654       FTList<FTWire *>& hits = axial_sgmnts[j]->wireHits();
01655       int l = hits.length();
01656       for (int k = 0; k^l; k++){
01657         FTWire & h = * hits[k];
01658         const float x = h.x();
01659         const float y = h.y();
01660         double d0 = fabs(la.d((double)x,(double)y));
01661         if (d0 >= 0.47f*h.layer().csize()) continue;
01662         nHits++;
01663         float dt = x2t(h.layer(), d0) - h.time();
01664         //   float dt = d0/(40*0.0001) - h.time();
01665         dt_sum += dt;
01666         dtt_sum += (dt*dt);
01667       }
01668     }
01669     if (!nHits) continue;
01670     float weight_t = exp(-(dtt_sum - (dt_sum*dt_sum/nHits))/(nHits*1600));
01671     weight_sum += (nHits*weight_t);
01672     dt_sum2 += (dt_sum*weight_t);
01673   }
01674   //  cout<<"event correction time: "<< int(dt_sum2/weight_sum)<<endl;
01675   return int(dt_sum2/weight_sum);
01676 
01677 }

void FTFinder::event  ) 
 

track finder core

void FTFinder::event  ) 
 

track finder core

-- vertex(r-phi) fit and event timing correction

-- 2D track re-fitting

00469                 {
00470   IMessageSvc *msgSvc;
00471   Gaudi::svcLocator()->service("MessageSvc", msgSvc);
00472 
00473   MsgStream log(msgSvc, "FTFinder");
00474 
00475   IDataProviderSvc* eventSvc = NULL;
00476   Gaudi::svcLocator()->service("EventDataSvc", eventSvc);
00477   
00478   if (!param->_doIt) return;
00479   //--
00480   // clear old information
00481   //--
00482   clear();
00483 
00484   //check whether  Recon  already registered
00485   DataObject *aReconEvent;
00486   eventSvc->findObject("/Event/Recon",aReconEvent);
00487   if(!aReconEvent) {
00488     // register ReconEvent Data Object to TDS;
00489     ReconEvent* recevt = new ReconEvent;
00490     StatusCode sc = eventSvc->registerObject("/Event/Recon",recevt );
00491     if(sc!=StatusCode::SUCCESS) {
00492       log << MSG::FATAL << "Could not register ReconEvent" <<endreq;
00493       return;
00494     }
00495   }
00496   //register Event start time
00497   IDataManagerSvc *dataManSvc = dynamic_cast<IDataManagerSvc*> (eventSvc);
00498   DataObject *aEsTimeEvent;
00499   eventSvc->findObject("/Event/Recon/RecEsTimeCol",aEsTimeEvent);
00500   if(aEsTimeEvent != NULL) {
00501     dataManSvc->clearSubTree("/Event/Recon/RecEsTimeCol");
00502     eventSvc->unregisterObject("/Event/Recon/RecEsTimeCol");
00503   }
00504 
00505   RecEsTimeCol *aRecEsTimeCol = new RecEsTimeCol;
00506   StatusCode est;
00507   est = eventSvc->registerObject("/Event/Recon/RecEsTimeCol",aRecEsTimeCol);
00508   if( est.isFailure() ) {
00509       log << MSG::FATAL << "Could not register RecEsTimeCol" << endreq;
00510       return;
00511    }
00512   log << MSG::DEBUG << "RecEsTimeCol registered successfully!" <<endreq; 
00513   //--
00514   // update wirehit information
00515   //--
00516   updateMdc();
00517 
00518   //--
00519   // segment finding
00520   //--
00521   for (int i =  0; i^11; i++){
00522     (*(_superLayer+i)).mkSegmentList();
00523   }
00524 
00525   //--
00526   // reduce noise and get start time from segment fit
00527   for(int j=0;j<10;j++){
00528     (*(_superLayer+j)).reduce_noise(tEstime);
00529   }
00530 
00531   getTestime();
00532   
00533   //--
00534   // register t0Estime to TDS
00535   //--
00536   //if(t0Estime!=-999&&t0Estime<24) registT0();
00537 
00538   //--
00539   // axial segment linking
00540   //--
00541   mkTrackList();
00542 
00543   //--
00544   // 2D track fitting
00545   //--
00546   //(*_superLayer).reAppendSalvage();
00547 
00548   int n = _tracks.length();
00549   log << MSG::DEBUG << "number of 2D tracks: " << n <<endreq;
00550 #ifndef OnlineMode
00551   num_2Dtrk+=n;
00552 #endif
00553   for (int i = 0; i^n; i++){
00554     if (!_tracks[i]->r_phiFit()){
00555       delete _tracks[i];
00556       log<<MSG::DEBUG<<"===========>deleted 2D track :  "<< i+1 <<endreq;
00557       n = _tracks.remove(i);
00558     }
00559   }
00560 
00561   if(t0Estime!=-999){
00562     //begin to make Event start time
00563     RecEsTime *arecestime = new RecEsTime;
00564     arecestime -> setTest(t0Estime);
00565     arecestime -> setStat(tEstFlag);
00566     aRecEsTimeCol->push_back(arecestime);
00567   }
00568   if (!n){
00569     makeTds();
00570     return;
00571   }
00572 
00575   //--
00576   int vtx_flag = VertexFit(0);
00577   evtTiming = (param->_evtTimeCorr) ? CorrectEvtTiming() : 0;
00578 
00581   //--
00582   if(param->_hitscut==1){
00583     for (int i = 0; i^n; i++){
00584       _tracks[i]->r_phiReFit(_vx, _vy, vtx_flag);
00585     }
00586   }
00587 
00588   //--
00589   //cut bad hits from 2D track re-fitting
00590   if(param->_hitscut==2){
00591     for (int i = 0; i^n; i++){
00592       for(int j = 0; j<2; j++){
00593         i_rPhiFit= _tracks[i]->r_phi2Fit(_vx, _vy, vtx_flag);
00594         if(i_rPhiFit!=-99) _tracks[i]->r_phi3Fit(i_rPhiFit,_vx, _vy, vtx_flag);
00595       }
00596       _tracks[i]->r_phi4Fit(_vx, _vy, vtx_flag);
00597     }
00598   }
00599 
00600   //--
00601   // stereo segment linking
00602   //--
00603   mkTrack3D();
00604 
00605   //--
00606   // final track fittng
00607   //--
00608   n = _tracks.length();
00609   log<< MSG::DEBUG <<"number of 3D tracks: " << n << endreq;
00610 
00611 #ifndef OnlineMode
00612   num_3Dtrk+=n;
00613 #endif
00614 
00615   for (int i = 0; i^n; i++) {
00616 
00617 #ifndef OnlineMode
00618     log<<MSG::DEBUG<<"=======>3D track: "<<i<<endreq;
00619     _tracks[i]->printout();
00620 #endif
00621 
00622     if (_tracks[i]->get_nhits() < 18) {
00623       delete _tracks[i];
00624       log<< MSG::DEBUG <<"================>deleted 3D track :  "<< i+1 <<endreq;
00625       n = _tracks.remove(i);
00626     }
00627   }
00628   
00629   if (!n){
00630     makeTds();
00631     return;
00632   }
00633 
00634   for (int i = 0; i^n; i++){
00635     _tracks[i]->s_zFit();
00636   }
00637 
00638   //--
00639   // find primary event vertex
00640   //--
00641   if (param->_findEventVertex){
00642     VertexFit(1);
00643   }
00644   
00645   n = _tracks.length();
00646   log<<MSG::DEBUG<<"final number of tracks: " << n << endreq;
00647 
00648 #ifndef OnlineMode
00649   num_finaltrk+=n;
00650   if (param->_mkMdst) makeMdst();
00651 #endif
00652 
00653   //--
00654   // output tracking result into TDS
00655   // by wangdy
00656   //--
00657   if (param->_mkTds) makeTds();
00658 
00659 }

int FTFinder::findBestVertex void   )  [private]
 

find vertex closest to IP

int FTFinder::findBestVertex void   )  [private]
 

find vertex closest to IP

01613 {
01614   int nTrks = _tracks.length();
01615   if (nTrks < 2){
01616     _vx = -9999.;
01617     _vy = -9999.;
01618     _vz = -9999.;
01619     return 0;
01620   }
01621   float min_dr = 9999.;
01622   float phi0 = 9999.;
01623   for (int i = 0; i < nTrks; i++){
01624     HepVector a = _tracks[i]->lpav().Hpar(pivot);
01625     if (fabs(a(1)) < fabs(min_dr)){
01626       min_dr = a(1);
01627       phi0 = a(2);
01628     }
01629   }
01630   _vx = min_dr*cos(phi0);
01631   _vy = min_dr*sin(phi0);
01632   return 1;
01633 }

int FTFinder::getTestime void   )  [private]
 

get event start time from segment linear fit

int FTFinder::getTestime void   )  [private]
 

get event start time from segment linear fit

00858 {
00859   IMessageSvc *msgSvc;
00860   Gaudi::svcLocator()->service("MessageSvc", msgSvc);
00861 
00862   MsgStream log(msgSvc, "FTFinder");
00863 
00864   IDataProviderSvc* eventSvc = NULL;
00865   Gaudi::svcLocator()->service("EventDataSvc", eventSvc);
00866 
00867    float sumT=0,estime=0;
00868    int n=0;
00869    t0Estime=-999;
00870    // for(int i=0;i<4;i++){
00871    for(int i=0;i<10;i++){
00872     for(int j=0;j<tEstime[i].length();j++){
00873       if(tEstime[i][j]!=0){
00874         sumT+=tEstime[i][j];
00875         n++;
00876       }
00877     }
00878    }
00879    if(n!=0){
00880      estime=sumT/n;
00881      if(estime>-1){  // && estime<50){
00882        //if(m_nbunch==3){
00883        if(expflag==0){      
00884          int nbunch=((int)(estime-tOffSet))/8;
00885          if(((int)(estime-tOffSet))%8>4) nbunch=nbunch+1;
00886          t0Estime=nbunch*8+tOffSet+200;
00887        }
00888        else{
00889          t0Estime=estime+200;
00890        }
00891        //if(m_nbunch==6){
00892        /* int nbunch=((int)(estime-tOffSet))/4;
00893           if(((int)(estime-tOffSet))%4>2) nbunch=nbunch+1;
00894           t0Estime=nbunch*4+tOffSet;
00895        */
00896        // if(t0Estime>-1 && t0Estime<24)  FTTrack::Testime=t0Estime;
00897        int trigtimming=0;
00898        // Retrieve trigger timming information
00899        // timing system: TOF:1,  MDC:2, EMC:3, NONE:0
00900        SmartDataPtr<TrigData> trigData(eventSvc,"/Event/Trig/TrigData");
00901        if (trigData) {
00902          trigtimming=trigData->getTimingType();
00903          log << MSG::INFO <<"Timing type: "<< trigData->getTimingType() << endreq;
00904        }
00905        if(trigtimming==1)  tEstFlag=117;
00906        if(trigtimming==2)  tEstFlag=127;
00907        if(trigtimming==3)  tEstFlag=137;
00908        if(trigtimming==0)  tEstFlag=107;
00909 #ifndef OnlineMode
00910        g_estime=estime;
00911 #endif
00912      }
00913    }
00914 }

int FTFinder::getWireId FTWire  )  const
 

returns wire ID for given FTWire object

int FTFinder::getWireId FTWire  )  const [inline]
 

returns wire ID for given FTWire object

00198                                     {
00199   return ((int)w - (int)_wire)/sizeof(FTWire);
00200 }

void FTFinder::init  ) 
 

initializer(creates geometry)

void FTFinder::init  ) 
 

initializer(creates geometry)

00157 {
00158   if (!param->_doIt) return;
00159 
00160 
00161   // Get the Particle Properties Service
00162   IPartPropSvc* p_PartPropSvc;
00163   static const bool CREATEIFNOTTHERE(true);
00164   StatusCode PartPropStatus = Gaudi::svcLocator()->service("PartPropSvc", p_PartPropSvc, CREATEIFNOTTHERE);
00165   if (!PartPropStatus.isSuccess() || 0 == p_PartPropSvc) {
00166     // log << MSG::ERROR << " Could not initialize Particle Properties Service" << endreq;
00167     std::cerr << "Could not initialize Particle Properties Service" << std::endl;  
00168     //  return PartPropStatus;
00169     return;
00170   }
00171   m_particleTable = p_PartPropSvc->PDT();
00172   
00173   // IRawDataProviderSvc* m_rawDataProviderSvc;
00174   StatusCode RawData = Gaudi::svcLocator()-> service ("RawDataProviderSvc", m_rawDataProviderSvc, CREATEIFNOTTHERE);
00175   if ( !RawData.isSuccess() ){
00176     std::cerr  << "Could not load RawDataProviderSvc!" << m_rawDataProviderSvc << endreq;
00177     return;
00178   }
00179  
00180 //  IMdcGeomSvc* mdcGeomSvc;
00181 //  StatusCode sc = Gaudi::svcLocator()->service("MdcGeomSvc", mdcGeomSvc);
00182 //
00183 //  if (sc ==  StatusCode::SUCCESS) {
00184 //   //mdcGeomSvc->Dump();
00185 //   
00186 //  } else {
00187 //    return ;
00188 //  }
00189 //  
00190 //  const int Nwire = mdcGeomSvc->getWireSize();
00191 //  const int Nlyr =  mdcGeomSvc->getLayerSize();
00192 //  const int Nsup =  mdcGeomSvc->getSuperLayerSize();
00193 //
00194 //  if(!Nwire || !Nlyr){
00195 //    std::cerr << "FTFINDER::GEOCDC not found (please put cdctable before l4)" << std::endl;
00196 //    std::cerr << "JOB will stop" << std::endl;
00197 //    exit(-1);
00198 //  }
00199 // 
00200 //  if (!_wire) _wire = (FTWire *) malloc((Nwire+1) * sizeof(FTWire));
00201 //  if (!_layer) _layer = (FTLayer *) malloc(Nlyr * sizeof(FTLayer));
00202 //  if (!_superLayer) _superLayer =
00203 //                      (FTSuperLayer *) malloc(Nsup * sizeof(FTSuperLayer));
00204 // 
00205 //  if (!_wire || !_layer || !_superLayer){
00206 //    std::cerr << "FTFINDER::Cannot allocate geometries" << std::endl;
00207 //    std::cerr << "JOB will stop" << std::endl;
00208 //    exit(-1);
00209 //  }
00210 //
00211 //  int superLayerID = 0;
00212 //  int layerID = 0;
00213 //  int localLayerID = 0;
00214 //  int localWireID = 0;
00215 //  int localID = 0;
00216 //  int wireID;
00217 //  MdcGeoLayer * layer_back = NULL;
00218 //  MdcGeoSuper * superLayer_back = NULL;
00219 //  int k = 0;
00220 //  int Nlayer[12];
00221 //  int Nlocal[12];
00222 //  int NlocalWireID[44];
00223 //
00224 //  for (wireID = 0;wireID <= Nwire; wireID++){
00225 //    MdcGeoLayer * layer = (wireID==Nwire) ? NULL : mdcGeomSvc->Wire(wireID)->Lyr();
00226 //    if (layer != layer_back){
00227 //      layer_back = layer;
00228 //      MdcGeoSuper * superLayer = (wireID==Nwire) ? NULL : mdcGeomSvc->Layer(layerID)->Sup();
00229 //      if (superLayer != superLayer_back){
00230 //        superLayer_back = superLayer;
00231 //        Nlayer[k] = localLayerID;
00232 //        Nlocal[k] = localID;
00233 //        localLayerID = 0;
00234 //        k++;
00235 //      }
00236 //      NlocalWireID[layerID] = localWireID;
00237 //      localID = 0;
00238 //      localWireID = 0;
00239 //      layerID++;
00240 //      localLayerID++;
00241 //    }
00242 //    localID++;
00243 //    localWireID++;
00244 //  }
00245 //
00246 //
00247 //  superLayerID = -1;
00248 //  layerID = -1;
00249 //  localLayerID = 0;
00250 //  localID = 0;
00251 //  layer_back = NULL;
00252 //  superLayer_back = NULL;
00253 //  for (wireID = 0;wireID < Nwire; wireID++){
00254 //    MdcGeoLayer * layer = mdcGeomSvc->Wire(wireID)->Lyr();
00255 //    if (layer != layer_back){
00256 //      layer_back = layer;
00257 //      MdcGeoSuper * superLayer = mdcGeomSvc->Layer(layerID+1)->Sup();
00258 //      if (superLayer != superLayer_back){
00259 //        superLayer_back = superLayer;
00260 //        // initialize super-layer
00261 //        superLayerID++;
00262 //        new(_superLayer+superLayerID) FTSuperLayer(wireID,
00263 //                                                   Nlocal[superLayerID+1],
00264 //                                                   layerID+1,
00265 //                                                   Nlayer[superLayerID+1],
00266 //                                                   superLayerID);
00267 //        localLayerID=0;
00268 //      }
00269 //      // initialize layer
00270 //      layerID++;
00271 //      double slantWithSymbol = (mdcGeomSvc->Layer(layerID)->Slant())*(mdcGeomSvc->Layer(layerID)->Sup()->Type());
00272 //      // slant in new MdcGeomSvc include  symbol 
00273 //       new(_layer+layerID) FTLayer(0.1*layer->Radius(), layer->Slant(),
00274 //                                  0.1*(+layer->Length()/2), 0.1*(-layer->Length()/2), 0.1*layer->Offset(),
00275 //                                  layerID, localLayerID++, NlocalWireID[layerID+1],
00276 //                                  _superLayer[superLayerID]);
00277 //      localID = 0;
00278 //    }
00279 //    // initialize wire
00280 //    const MdcGeoWire * wire = mdcGeomSvc->Wire(wireID); 
00281 //    if (superLayerID == 2 || superLayerID == 3  ||
00282 //        superLayerID == 4 || superLayerID == 9 ||
00283 //        superLayerID == 10){     // axial wire
00284 //      new(_wire+wireID) FTWire(0.1*(float)0.5*(wire->Backward().x()+wire->Forward().x()),
00285 //                               0.1*(float)0.5*(wire->Backward().y()+wire->Forward().y()),
00286 //                               0.,0.,
00287 //                               _layer[layerID], localID++, _wire+Nwire);
00288 //                            
00289 //    }else{                      // stereo wire
00290 //      new(_wire+wireID) FTWire(0.1*(float)wire->Backward().x(),
00291 //                               0.1*(float)wire->Backward().y(),
00292 //                               0.1*(float)wire->Forward().x() - 0.1*(float)wire->Backward().x(),
00293 //                               0.1*(float)wire->Forward().y() - 0.1*(float)wire->Backward().y(),
00294 //                               _layer[layerID], localID++, _wire+Nwire);
00295 //    }
00296 //  }
00297 // 
00298 //  // make virtual wire object for the pointer of boundary's neighbor
00299 //  new(_wire+Nwire) FTWire();
00300 //
00301 //  for (int i = 0; i < Nwire; i++){
00302 //    (*(_wire+i)).initNeighbor(); 
00303 //  }
00304 //  
00305 //  _widbase[0] = 0;
00306 //  for (int k = 1; k < 43; k++){
00307 //    _widbase[k] = _widbase[k-1] + (*(_layer+k-1)).NWire();
00308 //  }
00309 
00310   //minPt = (float)param->_minPt;
00311   //minDr = (float)param->_minDr;
00312   //xtCoEff = param->_xtCoEff;
00313 }

FTTrack* FTFinder::linkAxialSegments FTSegment **  inner,
FTSegment **  outer
[private]
 

link axial segments to make track

FTTrack * FTFinder::linkAxialSegments FTSegment **  inner,
FTSegment **  outer
[private]
 

link axial segments to make track

01077 {
01078   float chi2_kappa = param->_chi2_kappa;
01079   _linkedSegments->clear();
01080   if(!outer) {
01081       // allow only 2, 3, 4,  axial segments in one track
01082       int n = (*inner)->wireHits().length();
01083       _linkedSegments->append(*inner);
01084       if(n >= 7) return (new FTTrack(*_linkedSegments, (*inner)->kappa(), chi2_kappa));
01085       else return NULL;
01086   }
01087   int n = _linkedSegments->append(*outer);
01088   float SigmaK = (*outer)->kappa();
01089   float SigmaRR = (*outer)->r();
01090   SigmaRR *= SigmaRR;
01091   float SigmaKRR = SigmaK*SigmaRR;
01092   float SigmaKKRR = SigmaK*SigmaKRR;
01093   FTSegment & s = * (*_linkedSegments)[n-1];
01094   FTSegment * innerSegment = NULL;
01095   float SigmaK_cache, SigmaRR_cache, SigmaKRR_cache, SigmaKKRR_cache;
01096 
01097   float Min_chi2 = param->_Min_chi2;
01098   float inX = s.incomingX();
01099   float inY = s.incomingY();
01100   //const FTWire & innerBoundHit = * s.innerBoundHits().first();
01101   //float in_r = innerBoundHit.layer().r();
01102   //float incomingPhi = innerBoundHit.phi();
01103   float in_r = s.innerBoundHits().first()->layer().r();
01104   float incomingPhi = s.incomingPhi();
01105 
01106   FTSegment* next = *inner;
01107   const FTWire & NextOuterBoundHit = * next->outerBoundHits().first();
01108     
01109   //float deltaPhi =fabs(incomingPhi - next->outgoingPhi());
01110   //if (deltaPhi > param->_deltaPhi  && deltaPhi < (2*M_PI-param->_deltaPhi)) return NULL;   
01111   float outX = next->outgoingX();
01112   float outY = next->outgoingY();
01113 
01115   float _trk_d = -2*(param->_alpha)/s.kappa();
01116   float _angle1 = asin(NextOuterBoundHit.layer().r()/_trk_d);
01117   float _angle2 = asin(s.outerBoundHits().first()->layer().r()/_trk_d);
01118   float _ang_diff = _angle2 - _angle1;
01119   float _diff = s.outgoingPhi() - next->outgoingPhi();
01120   _diff = _diff - (int(_diff/M_PI))*2*M_PI;
01121   float _require = _ang_diff - _diff;
01122   //cut of connecting inner and outer segments
01123   if (_require < -0.10 || _require > 0.11) return NULL;
01124 
01125   float SegK = next->kappa();
01126   float SegRR = next->r();
01127   SegRR *= SegRR;
01128   const float out_r = NextOuterBoundHit.layer().r();
01129   // kappa = -2. * alpha * ((Vout X Vin)_z / |Vin|*|Vout|) / |Vin-Vout|
01130   float GapK = 2.*(param->_alpha)*(inX*outY-inY*outX) /
01131           (in_r*out_r*sqrt((inX-outX)*(inX-outX)+(inY-outY)*(inY-outY)));
01132   //float GapRR = (currentLayer==j+1||currentLayer==j+2) ? 0.5*(in_r+out_r) : in_r+out_r;
01133   float GapRR = 0.5*(in_r+out_r);
01134   GapRR*=GapRR;
01135   float SigmaK_tmp = (SigmaK + SegK + GapK);
01136   float SigmaRR_tmp = SigmaRR + SegRR + GapRR;
01137   float SigmaKRR_tmp = SigmaKRR + SegK*SegRR + GapK*GapRR;
01138   float SigmaKKRR_tmp = SigmaKKRR + SegK*SegK*SegRR + GapK*GapK*GapRR;
01139   float MuK_tmp = SigmaK_tmp/(2*n+1);
01140   float chi2 = (MuK_tmp*MuK_tmp*SigmaRR_tmp
01141           - 2.*MuK_tmp*SigmaKRR_tmp + SigmaKKRR_tmp)/(2*n+1);
01142   if ((chi2-chi2_kappa) < Min_chi2){
01143     Min_chi2 = chi2;
01144     innerSegment = next;
01145     SigmaK_cache = SigmaK_tmp;
01146     SigmaRR_cache = SigmaRR_tmp;
01147     SigmaKRR_cache = SigmaKRR_tmp;
01148     SigmaKKRR_cache = SigmaKKRR_tmp;
01149   }
01150   if (innerSegment){
01151     n = _linkedSegments->append(*inner);
01152     SigmaK = SigmaK_cache;
01153     SigmaRR = SigmaRR_cache;
01154     SigmaKRR = SigmaKRR_cache;
01155     SigmaKKRR = SigmaKKRR_cache;
01156     chi2_kappa = Min_chi2;
01157     
01158     if (n > 1) return (new FTTrack(*_linkedSegments,SigmaK/(2*n-1),chi2_kappa));
01159   }else{
01160     // allow only 3, 4, 5 axial segments in one track
01161     /*n = (*inner)->wireHits().length();
01162       _linkedSegments->clear();
01163       _linkedSegments->append(*inner);
01164       if(n > 10) return (new FTTrack(*_linkedSegments, SegK, Min_chi2));*/
01165     return NULL;
01166   }
01167   //if (fabs(SigmaK/(2*n-1)) > 1.2/minPt) return NULL;
01168   return NULL;
01169   
01170 }

void FTFinder::linkAxialSegments_step FTList< FTSegment * > &  InnerSegments,
FTList< FTSegment * > &  OuterSegments,
FTList< FTSegment * > &  Connected,
float  maxDphi,
float  maxChi2
[private]
 

void FTFinder::linkAxialSegments_step FTList< FTSegment * > &  InnerSegments,
FTList< FTSegment * > &  OuterSegments,
FTList< FTSegment * > &  Connected,
float  maxDphi,
float  maxChi2
[private]
 

01251 {
01252   IMessageSvc *msgSvc;
01253   Gaudi::svcLocator()->service("MessageSvc", msgSvc);
01254   MsgStream log(msgSvc, "FTFinder");
01255 
01256   int n = InnerSegments.length();
01257   int m = OuterSegments.length();
01258   for (int i = 0; i^n; i++){
01259      FTSegment * inner = InnerSegments[i];
01260 #ifndef OnlineMode
01261      //     log<<MSG::DEBUG<<"linking: "<<endreq;
01262      //     inner->printout();
01263 #endif
01264      const FTLayer & in_outerBound = inner->outerBoundHits().first()->layer();
01265      float in_outerPhi = inner->outgoingPhi();
01266      float min_Dphi = M_PI/2;
01267      int   min_Dphi_index = -1;
01268      for (int j = 0; j^m; j++) {
01269        FTSegment * outer = OuterSegments[j];
01270 #ifndef OnlineMode
01271        //       log<<MSG::DEBUG<<"segment: "<<j<<endreq;
01272        //       outer->printout();
01273 #endif
01274        float D_phi = fabs(in_outerPhi - outer->incomingPhi());
01275        if (D_phi > M_PI) D_phi = 2*M_PI - D_phi;
01276        if (D_phi > min_Dphi) continue;
01277        float inX   = inner->incomingX();
01278        float inY   = inner->incomingY();
01279        float outX  = outer->outgoingX();
01280        float outY  = outer->outgoingY();
01281        float in_r  = inner->innerBoundHits().first()->layer().r();
01282        float out_r = outer->outerBoundHits().first()->layer().r();
01283        float allK = 2.*(param->_alpha)*(inY*outX-inX*outY) /
01284          (in_r*out_r*sqrt((inX-outX)*(inX-outX)+(inY-outY)*(inY-outY)));
01285        //float cache_in  = ((inner->kappa() + outer->kappa() + allK)/3.0 - inner->kappa())/in_r;
01286        float cache_in  = ((outer->kappa() + allK)/3.0 - inner->kappa()*2/3.0)/in_r;
01287        float cache_out = ((inner->kappa() + allK)/3.0 - outer->kappa()*2/3.0)/out_r;
01288        float cache_all = ((inner->kappa()+outer->kappa())/3.0-allK*2/3.0)*2.0/(in_r+out_r);
01289        float chi2_z = cache_in*cache_in + cache_out*cache_out + cache_all*cache_all;
01290        log<<MSG::DEBUG<<"D_phi: "<< D_phi <<" chi2_z: "<< chi2_z <<" maxChi2: " <<maxChi2 <<endreq;
01291        if (chi2_z > maxChi2) continue;
01292        min_Dphi = D_phi;
01293        min_Dphi_index = j;
01294      }
01295      if (min_Dphi_index < 0) continue;
01296      log<<MSG::DEBUG<<"min_Dphi: "<< min_Dphi <<endreq;
01297      FTSegment * outer = OuterSegments[min_Dphi_index];
01298      const FTLayer & out_innerBound = outer->innerBoundHits().first()->layer();
01299      switch (out_innerBound.layerId() - in_outerBound.layerId()) {
01300        case 1:
01301          if (min_Dphi > maxDphi) continue;
01302          break;
01303        case 2:
01304          if (min_Dphi > maxDphi*1.5) continue;
01305          break;
01306        case 3:
01307          if (min_Dphi > maxDphi*2.25) continue;
01308          break;
01309        default:
01310          continue;
01311      }
01312      inner->connect_outer(outer->wireHits(), outer->outerBoundHits());
01313      inner->update();
01314      Connected.append(inner);
01315      n = InnerSegments.remove(i);
01316      delete outer;
01317      m = OuterSegments.remove(min_Dphi_index);
01318      log<<MSG::DEBUG<<"DONE!!"<<endreq;
01319   }
01320   return;
01321 }

void FTFinder::linkAxialSuperLayer234 FTList< FTSegment * > &  inner_segments  )  [private]
 

void FTFinder::linkAxialSuperLayer234 FTList< FTSegment * > &  inner_segments  )  [private]
 

01174 {
01175   FTList<FTSegment *>  _segments34(10);
01176   FTList<FTSegment *>& SuperLayer3Segments = _superLayer[3].segments();
01177   FTList<FTSegment *>& SuperLayer4Segments = _superLayer[4].segments();
01178   linkAxialSegments_step(SuperLayer3Segments, SuperLayer4Segments,
01179                          _segments34, param->_D_phi2, param->_chi2_2);
01180   _segments34.append(SuperLayer3Segments);
01181   SuperLayer3Segments.clear();
01182 
01183   FTList<FTSegment *>& SuperLayer2Segments = _superLayer[2].segments();
01184   linkAxialSegments_step(SuperLayer2Segments, _segments34,
01185                          inner_segments, param->_D_phi1, param->_chi2_1);
01186   inner_segments.append(_segments34);
01187 
01188   //zoujh: connect the 2&4 superlayers leap over 3
01189   int n = SuperLayer2Segments.length();
01190   int m = SuperLayer4Segments.length();
01191   for (int i = 0; i^n; i++) {
01192     FTSegment * inner = SuperLayer2Segments[i];
01193     //inner->printout();
01194     float in_outerPhi = inner->outgoingPhi();
01195     for (int j = 0; j^m; j++) {
01196       FTSegment * outer = SuperLayer4Segments[j];
01197       //      outer->printout();
01198       float out_innerPhi = outer->incomingPhi();
01199       float D_phi = fabs(in_outerPhi - out_innerPhi);
01200       if (D_phi > M_PI) D_phi = 2*M_PI - D_phi;
01202       if (D_phi > M_PI/12.5) continue;
01203       float inX   = inner->outgoingX();
01204       float inY   = inner->outgoingY();
01205       float outX  = outer->incomingX();
01206       float outY  = outer->incomingY();
01207       float in_r  = inner->outerBoundHits().first()->layer().r();
01208       float out_r = outer->innerBoundHits().first()->layer().r();
01209       float GapK = 2.*(param->_alpha)*(inY*outX-inX*outY) /
01210           (in_r*out_r*sqrt((inX-outX)*(inX-outX)+(inY-outY)*(inY-outY)));
01211       //float cache_in = ((inner->kappa()+outer->kappa()+GapK)/3.0 - inner->kappa())/in_r;
01212       float cache_in  = ((outer->kappa()+GapK)/3.0 - inner->kappa()*2.0/3.0)/in_r;
01213       float cache_out = ((inner->kappa()+GapK)/3.0 - outer->kappa()*2.0/3.0)/out_r;
01214       float cache_gap = ((inner->kappa()+outer->kappa())/3.0-GapK*2.0/3.0)*2.0/(in_r+out_r);
01215       float chi2_z = cache_in*cache_in + cache_out*cache_out + cache_gap*cache_gap;
01216       if (chi2_z > param->_D_phi1) continue;
01218       inner->connect_outer(outer->wireHits(),outer->outerBoundHits());
01219       inner->update();
01220       inner_segments.append(inner);
01221       n = SuperLayer2Segments.remove(i);
01222       m = SuperLayer4Segments.remove(j);
01223       delete outer;
01224       break;
01225     }
01226   }
01227   inner_segments.append(SuperLayer2Segments);
01228   SuperLayer2Segments.clear();
01229   inner_segments.append(SuperLayer4Segments);
01230   SuperLayer4Segments.clear();
01231 }

void FTFinder::linkAxialSuperLayer910 FTList< FTSegment * > &  outer_segments  )  [private]
 

void FTFinder::linkAxialSuperLayer910 FTList< FTSegment * > &  outer_segments  )  [private]
 

01235 {
01236   FTList<FTSegment *>& SuperLayer9Segments = _superLayer[9].segments();
01237   FTList<FTSegment *>& SuperLayer10Segments = _superLayer[10].segments();
01238   linkAxialSegments_step(SuperLayer9Segments, SuperLayer10Segments,
01239                          outer_segments, param->_D_phi3, param->_chi2_3);
01240   outer_segments.append(SuperLayer9Segments);
01241   SuperLayer9Segments.clear();
01242   outer_segments.append(SuperLayer10Segments);
01243   SuperLayer10Segments.clear();
01244 }

void FTFinder::makeMdst void   )  [private]
 

make Mdst_charged/trk/trk_fit table from reconstruted tracks

void FTFinder::makeMdst void   )  [private]
 

make Mdst_charged/trk/trk_fit table from reconstruted tracks

01682 {
01683   //  static const double pi_mass(0.13956995);
01684   const int nTrks = _tracks.length();
01685   int Ntable(0);
01686   
01687   for (int i = 0; i<nTrks; i++){
01688 
01689     const FTTrack & trk = * _tracks[i];
01690     FTList<FTSegment *> &axialSegments = trk.axial_segments(); 
01691     FTList<FTSegment *> &stereoSegments = trk.stereo_segments(); 
01692     int axialSegmentsN = axialSegments.length();  
01693     int stereoSegmentsN = stereoSegments.length();  
01694     for (int i = 0; i < axialSegmentsN ; i++) {
01695         //FTSuperLayer& superLayer= axialSegments[i]->superLayer();
01696         FTList<FTWire *> &wires = axialSegments[i]->wireHits();   
01697         int wiresN = wires.length();
01698         for (int j=0; j < wiresN; j++) {
01699             //int id = wires[j]->localId();
01700             g_ncell->fill(wires[j]->getWireId());
01701         }
01702     }
01703 
01704     for (int i = 0; i < stereoSegmentsN ; i++) {
01705         //FTSuperLayer& superLayer = stereoSegments[i]->superLayer();
01706         FTList<FTWire *> &wires = stereoSegments[i]->wireHits();
01707         int wiresN = wires.length();
01708         for (int j=0; j < wiresN; j++) {
01709             //int id = wires[j]->localId();
01710             g_ncell->fill(wires[j]->getWireId());
01711         }
01712     }
01713       
01714     const Helix& h = * trk.helix();
01715     if (h.tanl() < -9000.) continue;
01716 
01717     Ntable++;
01718     Hep3Vector p(h.momentum());
01719     HepPoint3D v(h.x());    
01720     //float m_charge = (h.kappa() > 0) ? 1. : -1.;
01721     float m_px = p.x();
01722     g_px[Ntable-1] = p.x();
01723     float m_py = p.y();
01724     g_py[Ntable-1] = p.y();
01725     float m_pz = p.z();
01726     g_pz[Ntable-1] = p.z();
01727     g_p[Ntable-1] = p.mag();
01728     g_phi[Ntable-1] = atan2(m_py, m_px);
01729 
01730     g_dr[Ntable-1] = h.dr();
01731     g_phi0[Ntable-1] = h.phi0();
01732     g_kappa[Ntable-1] = h.kappa();
01733     g_pt[Ntable-1] = 1/fabs(h.kappa());
01734     g_dz[Ntable-1] = h.dz();
01735     g_tanl[Ntable-1] = h.tanl();
01736     g_theta[Ntable-1] = atan2(1/fabs(h.kappa()),(double)(m_pz));
01737     g_vx[Ntable-1] = v(0);
01738     g_vy[Ntable-1] = v(1);
01739     g_vz[Ntable-1] = v(2);
01740   }  
01741   g_ntrk = Ntable;
01742 
01743 }

StatusCode FTFinder::makeTds void   )  [private]
 

output tracking results into TDS

StatusCode FTFinder::makeTds void   )  [private]
 

output tracking results into TDS

01754 {
01755   IMessageSvc *msgSvc;
01756   Gaudi::svcLocator()->service("MessageSvc", msgSvc);
01757   MsgStream log(msgSvc, "FTFinder");
01758 
01759   IDataProviderSvc* eventSvc = NULL;
01760   Gaudi::svcLocator()->service("EventDataSvc", eventSvc);
01761 
01762   if (eventSvc) {
01763      //log << MSG::DEBUG << "makeTds:event Svc has been found" << endreq;
01764   } else {
01765      log << MSG::FATAL << "makeTds:Could not find eventSvc" << endreq;
01766     return StatusCode::FAILURE ;
01767   }
01768 
01769   RecMdcTrackCol* trkcol = new RecMdcTrackCol;   
01770   RecMdcHitCol* hitcol = new RecMdcHitCol;
01771 
01772   //make RecMdcTrackCol
01773 #ifndef OnlineMode
01774   log << MSG::DEBUG << "beginning to make RecMdcTrackCol" <<endreq; 
01775 #endif
01776   int ntrk = tracks().length(); 
01777   int trkid=0;   
01778   for (int i =0; i < ntrk; i++) {
01779     RecMdcTrack* trk = new RecMdcTrack;
01780     FTTrack* fttrk = tracks()[i];
01781 
01782 #ifndef OnlineMode    
01783     //    fttrk->printout();
01784 #endif
01785 
01786     if (fttrk->helix()->tanl() < -9000.){
01787       log << MSG::DEBUG << "deleted trackId = " << i+1 << " due to tanl = " << fttrk->helix()->tanl() << endreq;   
01788       delete trk;       
01789       continue;
01790     }
01791     //    int trackindex = i;
01792     HepPoint3D pos = fttrk->helix()->pivot();
01793     int charge = -1;
01794     HepVector m_a(5,0);
01795     m_a = fttrk->helix()->a();
01796     m_a[2]=-m_a[2];
01797     HepSymMatrix m_ea = fttrk->helix()->Ea();
01798     float fiterm = fttrk->lpav().phi(77.0);
01799     float chi2lpav =  fttrk->lpav().chisq();
01800     float chi2zav = fttrk->Zav().chisq();
01801      
01802 // note: this alg itself can not provide error matrix,so m_ea above is empty;
01803 //       the following error matrix values are based on BESII results      
01804 //       the values of online Bhabha events are multiplied by factor 10 
01805 //                          wangdy 20050418
01806      m_ea[0][0] = 0.0085;
01807      m_ea[1][1] = 0.000011;
01808      m_ea[2][2] = 0.0018;
01809      m_ea[3][3] = 1.2;
01810      m_ea[4][4] = 0.00026;
01811      m_ea[1][0] = m_ea[0][1] = -0.00029;
01812      m_ea[2][0] = m_ea[0][2] = charge*0.004;
01813      m_ea[2][1] = m_ea[1][2] = charge*0.00012;
01814      m_ea[3][0] = m_ea[0][3] = -0.017;
01815      m_ea[3][1] = m_ea[1][3] = 0.0;
01816      m_ea[3][2] = m_ea[2][3] = 0.0;
01817      m_ea[4][0] = m_ea[0][4] = 0.0;
01818      m_ea[4][1] = m_ea[1][4] = 0.0;
01819      m_ea[4][2] = m_ea[2][4] = 0.0;
01820      m_ea[4][3] = m_ea[3][4] = -0.018;
01821      
01822     trk->setTrackId(trkid);
01823     trk->setHelix(m_a);
01824     trk->setPivot(pos);
01825     trk->setError(m_ea);
01826     trk->setFiTerm(fiterm);
01827     trk->setChi2(chi2lpav+chi2zav);
01828 #ifndef OnlineMode
01829     log <<MSG::DEBUG << " trackId = " << i  << endreq;   
01830     log <<MSG::DEBUG <<"fast-tracking  kappa "<<m_a[2]
01831         <<"   fast-tracking tanl "<<m_a[4]
01832         <<endreq;
01833     log <<MSG::DEBUG <<"push_backed kappa "<<trk->helix(2)
01834         <<"   push_backed tanl "<< trk->helix(4)
01835         <<endreq;
01836 
01837     log << MSG::DEBUG << "beginning to make hitlist and RecMdcHitCol " <<endreq;
01838 #endif
01839 
01840     HitRefVec  hitrefvec;
01841 
01842     int hitindex = 0;    
01843 
01844     //axial segments part
01845     FTList<FTSegment *>&  seglist_ax = fttrk->axial_segments();
01846     int nseg_ax = seglist_ax.length();
01847     int ntrackhits = 0;
01848     for (int iseg_ax = 0; iseg_ax < nseg_ax; iseg_ax++) {
01849       FTList<FTWire *>& hitlist_ax = seglist_ax[iseg_ax]->wireHits();
01850       int nhitlist_ax = hitlist_ax.length();
01851       ntrackhits += nhitlist_ax;
01852       for( int ihit_ax = 0; ihit_ax < nhitlist_ax; ihit_ax++,hitindex++) {
01853         FTWire wire_ax = *(hitlist_ax[ihit_ax]);
01854         double  dd = wire_ax.distance();
01855         double  adc = RawDataUtil::MdcChargeChannel(wire_ax.getAdc());
01856         double  tdc = wire_ax.time();
01857         double  chi2 = wire_ax.getChi2();
01858         const Identifier mdcid = MdcID::wire_id(wire_ax.layer().layerId(),wire_ax.localId());
01859 
01860         RecMdcHit*  hit = new RecMdcHit;
01861         hit->setId(hitindex);
01862         hit->setDriftDistLeft( dd );
01863         hit->setDriftDistRight( dd );
01864         hit->setAdc( adc );
01865         hit->setTdc( tdc );
01866         hit->setMdcId( mdcid );
01867         hit->setChisqAdd( chi2 );
01868 #ifndef OnlineMode
01869         log << MSG::DEBUG << "Hit DriftDistLeft " << hit->getDriftDistLeft() << endreq;     
01870         log << MSG::DEBUG << "MDC Hit ADC " << hit->getAdc() << endreq;
01871         log << MSG::DEBUG << "Hit MDC  Identifier " << hit->getMdcId() << endreq;     
01872         log << MSG::DEBUG << "Hit Chisq " << hit->getChisqAdd() << endreq;     
01873 #endif
01874         hitcol->push_back(hit);
01875         SmartRef<RecMdcHit> refhit(hit);
01876         hitrefvec.push_back(refhit);
01877       }
01878     }
01879 
01880     //stereo segments part
01881     FTList<FTSegment *>&  seglist_st = fttrk->stereo_segments();
01882     int nseg_st = seglist_st.length();
01883     int ntrackster = 0;
01884     
01885     for (int iseg_st = 0; iseg_st < nseg_st; iseg_st++) {
01886       FTList<FTWire *>& hitlist_st = seglist_st[iseg_st]->wireHits();
01887       int nhitlist_st = hitlist_st.length();
01888       ntrackhits += nhitlist_st;
01889       ntrackster += nhitlist_st;
01890       for( int ihit_st = 0; ihit_st < nhitlist_st; ihit_st++,hitindex++) {
01891         FTWire wire_st = *(hitlist_st[ihit_st]);
01892         double  dd = wire_st.distance();
01893         //double  adc = wire_st.getAdc();
01894         double  adc = RawDataUtil::MdcChargeChannel(wire_st.getAdc());
01895         double  tdc = wire_st.time();    
01896         double  chi2 = wire_st.getChi2();
01897         const Identifier mdcid = MdcID::wire_id(wire_st.layer().layerId(),wire_st.localId());
01898 
01899         RecMdcHit*  hit = new RecMdcHit;
01900         hit->setId(hitindex);
01901         hit->setDriftDistLeft( dd );
01902         hit->setDriftDistRight( dd );
01903         hit->setAdc( adc );
01904         hit->setTdc( tdc); 
01905         hit->setMdcId( mdcid );
01906         hit->setChisqAdd( chi2 );
01907 #ifndef OnlineMode
01908         log << MSG::DEBUG << "Z Hit DriftDistLeft " << hit->getDriftDistLeft() << endreq;     
01909         log << MSG::DEBUG << "Z MDC Hit ADC " << hit->getAdc() << endreq;
01910         log << MSG::DEBUG << "Z Hit MDC  Identifier " << hit->getMdcId() << endreq;     
01911         log << MSG::DEBUG << "Z Hit Chisq " << hit->getChisqAdd() << endreq;     
01912 #endif
01913         hitcol->push_back(hit);
01914         SmartRef<RecMdcHit> refhit(hit);
01915         hitrefvec.push_back(refhit);
01916       } 
01917     }
01918     trk->setNhits(ntrackhits);
01919     trk->setNster(ntrackster);
01920     trk->setVecHits(hitrefvec);   
01921     trkcol->push_back(trk);
01922     trkid++;
01923 #ifndef OnlineMode
01924     g_naxialhit->fill((float)(ntrackhits-ntrackster), 1.0);
01925     g_nstereohit->fill((float)ntrackster, 1.0);
01926     g_nhit->fill((float)ntrackhits, 1.0);
01927 #endif
01928   } 
01929 
01930   IDataManagerSvc *dataManSvc = dynamic_cast<IDataManagerSvc*> (eventSvc); 
01931   DataObject *aTrackCol;
01932   eventSvc->findObject("/Event/Recon/RecMdcTrackCol",aTrackCol);
01933   if(aTrackCol != NULL) {
01934     dataManSvc->clearSubTree("/Event/Recon/RecMdcTrackCol");
01935     eventSvc->unregisterObject("/Event/Recon/RecMdcTrackCol");
01936   }
01937   DataObject *aRecHitCol;
01938   eventSvc->findObject("/Event/Recon/RecMdcHitCol",aRecHitCol);
01939   if(aRecHitCol != NULL) {
01940     dataManSvc->clearSubTree("/Event/Recon/RecMdcHitCol");
01941     eventSvc->unregisterObject("/Event/Recon/RecMdcHitCol");
01942   }
01943 
01944   //register RecMdcHitCol
01945   StatusCode hitsc;
01946   hitsc = eventSvc->registerObject("/Event/Recon/RecMdcHitCol", hitcol);
01947   if( hitsc.isFailure() ) {
01948     log << MSG::FATAL << "Could not register RecMdcHitCol" << endreq;
01949     return hitsc;
01950   }
01951 #ifndef OnlineMode
01952   log << MSG::DEBUG << "RecMdcHitCol registered successfully!" <<endreq;
01953 
01954   RecMdcTrackCol::iterator bef = trkcol->begin();
01955   for( ; bef != trkcol->end(); bef++) {
01956     log <<MSG::DEBUG <<" registered kappa"<<(*bef)->helix(2)
01957         <<"   registered tanl"<< (*bef)->helix(4)
01958         <<endreq;    
01959   }
01960 #endif
01961 
01962   //register RecMdcTrackCol
01963   StatusCode trksc;
01964   trksc = eventSvc->registerObject("/Event/Recon/RecMdcTrackCol", trkcol);
01965   if( trksc.isFailure() ) {
01966     log << MSG::FATAL << "Could not register RecMdcHit" << endreq;
01967     return trksc; 
01968   }
01969 #ifndef OnlineMode
01970   log << MSG::DEBUG << "RecMdcTrackCol registered successfully!" <<endreq;
01971   
01972   //check the result:RecMdcHitCol   
01973   SmartDataPtr<RecMdcHitCol> newhitCol(eventSvc,"/Event/Recon/RecMdcHitCol");
01974   if (!newhitCol) {
01975     log << MSG::FATAL << "Could not find RecMdcHit" << endreq;
01976     return( StatusCode::FAILURE);
01977   }
01978   log << MSG::DEBUG << "Begin to check RecMdcHitCol"<<endreq;
01979   RecMdcHitCol::iterator iter_hit = newhitCol->begin();
01980   for( ; iter_hit != newhitCol->end(); iter_hit++){ 
01981     log << MSG::DEBUG << "retrieved MDC Hit:"
01982         << "   DDL " <<(*iter_hit)->getDriftDistLeft()
01983         << "   DDR " <<(*iter_hit)->getDriftDistRight()
01984         << "   ADC " <<(*iter_hit)->getAdc() << endreq;
01985   }
01986   
01987   //check the result:RecMdcTrackCol   
01988   SmartDataPtr<RecMdcTrackCol> newtrkCol(eventSvc,"/Event/Recon/RecMdcTrackCol");
01989   if (!newtrkCol) { 
01990     log << MSG::FATAL << "Could not find RecMdcTrackCol" << endreq;
01991     return( StatusCode::FAILURE);
01992   }
01993   log << MSG::DEBUG << "Begin to check RecMdcTrackCol"<<endreq; 
01994   RecMdcTrackCol::iterator iter_trk = newtrkCol->begin();
01995    for( ; iter_trk != newtrkCol->end(); iter_trk++){
01996      log << MSG::DEBUG << "retrieved MDC track:"
01997          << "Track Id: " << (*iter_trk)->trackId()
01998          << "   Pivot: " << (*iter_trk)->poca()[0] << " "
01999          << (*iter_trk)->poca()[1] << " " << (*iter_trk)->poca()[2] 
02000          << endreq ;
02001      
02002      /*<< "Phi0: " << (*iter_trk)->getFi0() << "   Error of Phi0 "
02003        << (*iter_trk)->getError()(2,2) << endreq
02004        /<< "kappa: " << (*iter_trk)->getCpa() << "   Error of kappa "
02005        << (*iter_trk)->getError()(3,3) << endreq
02006           << "Tanl: " << (*iter_trk)->getTanl() << "   Error of Tanl "
02007           << (*iter_trk)->getError()(5,5) << endreq      
02008           << "Chisq of fit: "<< (*iter_trk)->getChisq()
02009           << "   Phi terminal: "<< (*iter_trk)->getFiTerm()
02010           << endreq
02011           << "Number of hits: "<< (*iter_trk)->getNhits()
02012           << "   Number of stereo hits " << (*iter_trk)->getNster()
02013           << endreq;*/
02014      
02015      log << MSG::DEBUG << "hitList of this  track:" << endreq;
02016      HitRefVec gothits = (*iter_trk)->getVecHits();
02017      HitRefVec::iterator it_gothit = gothits.begin();
02018      for( ; it_gothit != gothits.end(); it_gothit++){
02019        log << MSG::DEBUG << "hits Id: "<<(*it_gothit)->getId()
02020            << "   hits DDL&DDR " <<(*it_gothit)->getDriftDistLeft()
02021            << "   hits MDC IDentifier " <<(*it_gothit)->getMdcId()
02022            << endreq     
02023            << "   hits TDC " <<(*it_gothit)->getTdc()  
02024            << "   hits ADC " <<(*it_gothit)->getAdc() << endreq;
02025      } 
02026      
02027    }
02028 #endif
02029    
02030    return StatusCode::SUCCESS;
02031 }

void FTFinder::mkTrack3D void   )  [private]
 

create 3D track list

void FTFinder::mkTrack3D void   )  [private]
 

create 3D track list

01324                        {
01325   IMessageSvc *msgSvc;
01326   Gaudi::svcLocator()->service("MessageSvc", msgSvc);
01327   MsgStream log(msgSvc, "FTFinder");
01328   
01329   int n = _tracks.length();
01330   // select segment candidate and cache sz
01331   FTList<FTSegment *> multi_trk_cand(20);
01332   for (int i=8; i>=0 ; i-- ){
01333     //if (i==2 || i==3 || i==4) continue;
01334     if (i == 4) i -= 3;
01335     FTList<FTSegment *> & segments = _superLayer[i].segments();
01336     int m = segments.length();
01337     for (int j = 0; j^m; j++){
01338       FTSegment * s = segments[j];
01339 #ifndef OnlineMode
01340         s->printout();
01341 #endif
01342       int nTrack = 0;
01343       FTTrack * t;
01344       for (int k = 0; k^n; k++){
01345 #ifndef OnlineMode
01346         log<<MSG::DEBUG<<"coupling to track: " << k <<endreq;
01347         //_tracks[k]->printout();
01348 #endif
01349         if (s->update3D(_tracks[k])){ // calculate s and z
01350           t = _tracks[k];
01351           nTrack++;
01352         }
01353       }
01354       switch(nTrack){
01355       case 0:
01356         continue;
01357       case 1:
01358         t->append_stereo_cache(s);
01359         break;
01360       default:
01361         multi_trk_cand.append(s);
01362         break;
01363       }
01364     }
01365     // whose relation between this is unique
01366     for (int j = 0; j^n; j++) _tracks[j]->updateSZ();
01367   }
01368   // link segments by tanLambda & dz
01369   for (int i = 0; i^n; i++) _tracks[i]->linkStereoSegments(); 
01370   n = multi_trk_cand.length();
01371   for (int i = 0; i^n; i++) multi_trk_cand[i]->linkStereoSegments();
01372 }

void FTFinder::mkTrackList void   )  [private]
 

create track list

void FTFinder::mkTrackList void   )  [private]
 

create track list

00918 {
00919 
00920   IMessageSvc *msgSvc;
00921   Gaudi::svcLocator()->service("MessageSvc", msgSvc);
00922 
00923   MsgStream log(msgSvc, "FTFinder");
00924 
00925   FTTrack ** tracks = (FTTrack **)malloc( 6 * sizeof(FTTrack *));
00926   int * Nsame = (int *)malloc( 6 * sizeof(int));
00927   int ntrack_cand = 0;
00928   int i,j,k,l;
00929 
00930   //for (int i =0; i < tracks().lenght(); i++) {
00931   //  FTTrack* fttrk = tracks()[i];
00932   //  fttrk->setFTFinder(this);
00933   //}
00934 
00935   FTList<FTSegment *> inner_segments(10);
00936   FTList<FTSegment *> outer_segments(10);
00937 
00938   linkAxialSuperLayer234(inner_segments);
00939   linkAxialSuperLayer910(outer_segments);
00940 
00941   _axialSegCollect.append(inner_segments);
00942   _axialSegCollect.append(outer_segments);
00943 
00944   int innerN = inner_segments.length();
00945   int outerN = outer_segments.length();
00946 
00947   log << MSG::DEBUG << innerN <<" segments in inner axial layers!"<<endreq;
00948   log << MSG::DEBUG << outerN <<" segments in outer axial layers!"<<endreq;
00949 
00950   for (l = 0; l^innerN; l++){
00951     if (inner_segments[l]->track()) continue;
00952     FTSegment *inner = inner_segments[l];
00953     FTTrack *track_cand = NULL;
00954 
00955 #ifndef OnlineMode
00956     inner->printout();
00957 #endif
00958     
00959     if(outerN==0){ 
00960       track_cand = linkAxialSegments(&inner, NULL);
00961       if(!track_cand) continue;
00962       _linkedSegments = new FTList<FTSegment *>(5);
00963       //      track_cand->printout();
00964       // append this to _tracks
00965       FTList<FTSegment *>& segments = track_cand->axial_segments();
00966       int n=segments.length();
00967       for (i = 0; i < n; i++){
00968         segments[i]->track(track_cand);
00969       }
00970       _tracks.append(track_cand);
00971       track_cand->setFTFinder(this);
00972       ntrack_cand++;
00973       continue;
00974     }
00975     
00976     for(k = 0; k^outerN; k++) {
00977       if (outer_segments[k]->track()) { //already used
00978         if(k==outerN-1) {  //if the last outer segment
00979           if (inner_segments[l]->track()) continue;   //inner segment never used
00980           track_cand = linkAxialSegments(&inner, NULL);
00981           if(!track_cand) continue;
00982           _linkedSegments = new FTList<FTSegment *>(5);
00983           // append this to _tracks
00984           FTList<FTSegment *>& segments = track_cand->axial_segments();
00985           int n=segments.length();
00986           for (i = 0; i < n; i++){
00987             segments[i]->track(track_cand);
00988           }
00989           _tracks.append(track_cand);
00990           track_cand->setFTFinder(this);
00991           ntrack_cand++;
00992         }
00993         continue;
00994       }
00995 
00996       FTSegment *outer = outer_segments[k];      
00997       track_cand = linkAxialSegments(&inner, &outer);
00998 
00999       if (!track_cand ){  // link failed
01000         if( k == outerN-1 ) { //if the last outer segment
01001           if (inner_segments[l]->track()) continue;  //inner segment never used
01002           track_cand = linkAxialSegments(&inner, NULL);
01003         }
01004         if(!track_cand) continue;
01005       }
01006       //  else {
01007       //    innerN = inner_segments.remove(l);
01008       //    outerN = outer_segments.remove(k);
01009       //  }
01010       //track_cand->printout();      
01011 
01012       ntrack_cand++;
01013       _linkedSegments = new FTList<FTSegment *>(5);
01014       
01015       //compair this to appended track candidate
01016       
01017       FTList<FTSegment *>& segments = track_cand->axial_segments();
01018       int n = segments.length();
01019       
01020       //compare this to the appended track candidate
01021       if(inner_segments[l]->track()) { //already used
01022         FTTrack * trk_tmp = inner_segments[l]->track();
01023         int nTrks = _tracks.length();
01024         int cache_i=0;
01025         for (i = 0; i^nTrks; i++){
01026           if (_tracks[i] == trk_tmp){
01027             cache_i = i;
01028             break;
01029           }
01030         }
01031         FTList<FTSegment *> & segments2 = trk_tmp->axial_segments();
01032         int n2 = segments2.length();
01033         if(n >= n2 && track_cand->chi2_kappa_tmp() < trk_tmp->chi2_kappa_tmp()){
01034           // swap this and appended one
01035           for (i = 0; i < n2; i++){
01036             segments2[i]->track(NULL);
01037           }        
01038           for (i = 0; i < n; i++){
01039             segments[i]->track(track_cand);
01040           }
01041           _tracks.replace(cache_i,track_cand);
01042           track_cand->setFTFinder(this);
01043           delete trk_tmp;
01044         }else{
01045           delete track_cand;
01046         }
01047       }else{
01048         // append this
01049         for (i = 0; i < n; i++){
01050           segments[i]->track(track_cand);
01051         }
01052         _tracks.append(track_cand);
01053         track_cand->setFTFinder(this);
01054       }
01055     } // end of loop of outerN
01056   } //end of loop innerN
01057   
01058   free(tracks);
01059   free(Nsame);
01060 
01061 #ifndef OnlineMode
01062   int n=_tracks.length();
01063   for(int i=0; i<n; i++){
01064     FTList<FTSegment *> & segments = _tracks[i]->axial_segments(); 
01065     log << MSG::DEBUG <<" loop connected axial track: " << i <<endreq;  
01066     int l=segments.length();    
01067     for(int j=0; j<l; j++){
01068       segments[j]->printout();
01069     }
01070   }
01071 #endif
01072 
01073 }

StatusCode FTFinder::registT0 void   )  [private]
 

StatusCode FTFinder::registT0 void   )  [private]
 

void FTFinder::setAlgorithmPointer Algorithm *   ) 
 

returns FTFinder pointer

void FTFinder::setAlgorithmPointer Algorithm *   )  [inline]
 

returns FTFinder pointer

00223                                            {
00224   m_algorithm = alg;
00225 }

FTSuperLayer* FTFinder::superLayer int  id  )  const
 

returns superlayer

FTSuperLayer * FTFinder::superLayer int  id  )  const [inline]
 

returns superlayer

00186                                 {
00187   return _superLayer + id;
00188 }

float FTFinder::t2x const FTLayer l,
const float  t
const
 

convert t to x

float FTFinder::t2x const FTLayer l,
const float  t
const [inline]
 

convert t to x

00212 {
00213   float x = (t>0.0f) ?((param->_xtCoEff))*sqrt(t*l.csize()) : 0.0f;
00214   if ( x > 0.47f*l.csize() ){
00215     x = 0.0004f*t + 0.47f*l.csize()*(1.0f-0.0004f*0.47f/((param->_xtCoEff)*(param->_xtCoEff)));
00216   }
00217 
00218   return x;
00219 }

void FTFinder::term  ) 
 

terminator

void FTFinder::term  ) 
 

terminator

00317 {
00318   if (param->_doIt) clear();
00319   delete &_tracks;
00320   delete _linkedSegments;
00321   if (!param->_doIt) return;
00322   free(_wire);
00323   free(_layer);
00324   free(_superLayer);
00325 }

FTList<FTTrack *>& FTFinder::tracks void   )  const
 

returns track list

FTList< FTTrack * > & FTFinder::tracks void   )  const [inline]
 

returns track list

00192                           {
00193   return _tracks;
00194 }

int FTFinder::updateMdc void   )  [private]
 

unpack RAWCDC and create wire-hit

int FTFinder::updateMdc void   )  [private]
 

unpack RAWCDC and create wire-hit

00662                        {
00663   IMessageSvc *msgSvc;
00664   Gaudi::svcLocator()->service("MessageSvc", msgSvc);
00665 
00666   MsgStream log(msgSvc, "FTFinder");
00667 
00668   IDataProviderSvc* eventSvc = NULL;
00669   Gaudi::svcLocator()->service("EventDataSvc", eventSvc);
00670 
00671 
00672   if (eventSvc) {
00673      //log << MSG::INFO << "Could find event Svc" << endreq;
00674   } else {
00675      log << MSG::FATAL << "Could not find Event Header" << endreq;
00676     return 0;
00677   }
00678 
00679 
00680   // Part 1: Get the event header, print out event and run number
00681 
00682   SmartDataPtr<Event::EventHeader> eventHeader(eventSvc,"/Event/EventHeader");
00683   if (!eventHeader) {
00684     log << MSG::FATAL << "Could not find Event Header" << endreq;
00685     return( StatusCode::FAILURE);
00686   }
00687   log << MSG::DEBUG << "MdcFastTrkAlg: retrieved event: " << eventHeader->eventNumber()  << "  run: " <<  eventHeader->runNumber() << endreq;
00688   eventNo = eventHeader->eventNumber();
00689   runNo = eventHeader->runNumber();
00690   if(runNo>0) expflag=1;
00691   else  expflag=0;
00692   int digiId;
00693 
00694 #ifndef OnlineMode
00695   g_eventNo = eventHeader->eventNumber();
00696 
00697   // Part 2: Retrieve MC truth
00698    SmartDataPtr<McParticleCol> mcParticleCol(eventSvc,"/Event/MC/McParticleCol");
00699    if (!mcParticleCol) {
00700     log << MSG::WARNING << "Could not find McParticle" << endreq;
00701    // return( StatusCode::FAILURE);
00702    }
00703    else{
00704      McParticleCol ::iterator iter_mc = mcParticleCol->begin();
00705      digiId = 0;
00706      int ntrkMC = 0;
00707      int charge = 0;
00708      for (;iter_mc != mcParticleCol->end(); iter_mc++, digiId++) {
00709        log << MSG::DEBUG << "MDC digit No: " << digiId << endreq;
00710        log << MSG::DEBUG
00711            << " particleId = " << (*iter_mc)->particleProperty ()
00712            << endreq;
00713        int  statusFlags = (*iter_mc)->statusFlags();
00714        int  pid = (*iter_mc)->particleProperty();
00715        if(pid >0) {
00716          if(m_particleTable->particle( pid )){ 
00717            charge = (int)m_particleTable->particle( pid )->charge();
00718          }
00719        } else if ( pid <0 ) {
00720          if(m_particleTable->particle( -pid )){
00721            charge = (int)m_particleTable->particle( -pid )->charge();
00722            charge *= -1;
00723          }
00724        } else {
00725          log << MSG::WARNING << "wrong particle id, please check data" <<endreq;
00726        }
00727        
00728        if(charge==0 || abs(cos((*iter_mc)->initialFourMomentum().theta()))>0.93) continue; 
00729        
00730        g_theta0MC[ntrkMC] = (*iter_mc)->initialFourMomentum().theta();
00731        g_phi0MC[ntrkMC] = (*iter_mc)->initialFourMomentum().phi();
00732        g_pxMC[ntrkMC] = (*iter_mc)->initialFourMomentum().px();
00733        g_pyMC[ntrkMC] = (*iter_mc)->initialFourMomentum().py();
00734        g_pzMC[ntrkMC] = (*iter_mc)->initialFourMomentum().pz();
00735        g_ptMC[ntrkMC] = 0.001 * sqrt(g_pxMC[ntrkMC]*g_pxMC[ntrkMC] + g_pyMC[ntrkMC]*g_pyMC[ntrkMC]);
00736        ntrkMC++;
00737      }
00738      g_ntrkMC = ntrkMC;
00739    }
00740 #endif
00741 
00742 #ifdef MultiThread
00743    //Part 3: Retrieve MDC digi
00744     SmartDataPtr<MdcDigiCol> mdcDigiVec(eventSvc,"/Event/Digi/MdcDigiCol");
00745     if (!mdcDigiVec) {
00746      log << MSG::FATAL << "Could not find MDC digi" << endreq;
00747      return( StatusCode::FAILURE);
00748     }
00749    MdcDigiCol::iterator iter1 = mdcDigiVec->begin();
00750    digiId = 0;
00751    Identifier mdcId;
00752    int layerId;
00753    int wireId;
00754    for (;iter1 != mdcDigiVec->end(); iter1++, digiId++) {
00755 #else
00756    //--use RawDataProvider to get MdcDigi
00757    //  bool m_dropRecHits=true;//or false 
00758    MdcDigiVec mdcDigiVec = m_rawDataProviderSvc->getMdcDigiVec();
00759    MdcDigiVec::iterator iter1 = mdcDigiVec.begin();
00760    digiId = 0;
00761    Identifier mdcId;
00762    int layerId;
00763    int wireId;
00764    for (;iter1 != mdcDigiVec.end(); iter1++, digiId++) {
00765 #endif
00766      mdcId = (*iter1)->identify();
00767      layerId = MdcID::layer(mdcId);
00768      wireId = MdcID::wire(mdcId);
00769 #ifndef OnlineMode
00770      log << MSG::DEBUG << "MDC digit No: " << digiId << endreq;
00771      log << MSG::DEBUG
00772          << " time_channel = " << RawDataUtil::MdcTime((*iter1)->getTimeChannel())
00773          << " charge_channel = " << RawDataUtil::MdcCharge((*iter1)->getChargeChannel())
00774          << " layerId = " << layerId 
00775          << " wireId = " << wireId
00776          << endreq;
00777 #endif
00778 
00779         const int localwid = wireId; 
00780         const int wid = localwid + _widbase[layerId];
00781 
00782 #ifndef OnlineMode
00783        g_ncellMC->fill((float)wid, 1.0);
00784 #endif
00785         //... skip invalid wireID's
00786         if (wid < 0 || wid > 6795) continue;
00787         FTWire & w = *(_wire + wid);
00788         float tdc =  RawDataUtil::MdcTime((*iter1)->getTimeChannel());
00789         float adc =  RawDataUtil::MdcCharge((*iter1)->getChargeChannel());
00790 
00791 #ifndef OnlineMode
00792         if (eventNo == 466)  {
00793              g_hitmap[0]->fill(w.x(), w.y());
00794         }
00795 
00796         if (eventNo == 538)  {
00797              g_hitmap[1]->fill(w.x(), w.y());
00798         }
00799 
00800         if (eventNo == 408)  {
00801              g_hitmap[2]->fill(w.x(), w.y());
00802         }
00803 
00804         if (eventNo == 499)  {
00805              g_hitmap[3]->fill(w.x(), w.y());
00806         }
00807 
00808         if (eventNo == 603)  {
00809              g_hitmap[4]->fill(w.x(), w.y());
00810         }
00811 
00812         if (eventNo == 938)  {
00813              g_hitmap[5]->fill(w.x(), w.y());
00814         }
00815 #endif
00816         // tdc/adc calibration
00817         //new tdc include drift time and flight time
00818         float time = tdc-sqrt(w.x()*w.x()+w.y()*w.y())/30;
00819         w.time(time);
00820         w.wireId(wid);
00821         w.setAdc(adc); 
00822  
00823         //... check adc validation
00824         const FTLayer & lyr = w.layer();
00825 
00826         //... save to the array
00827         //w.distance(time*40*0.0001);  //original
00828         w.distance(0.0); //by X.-R. Lu
00829         w.setChi2(999);
00830         w.state(FTWireHit);
00831         FTSuperLayer & sup = (FTSuperLayer &) lyr.superLayer();
00832         sup.appendHit(&w);
00833    }
00834    
00835    return 1;
00836 }

CLHEP::Hep3Vector FTFinder::vertex void   )  const
 

returns event primary vertex

Hep3Vector FTFinder::vertex void   )  const
 

returns event primary vertex

01636                           {
01637   return Hep3Vector(_vx,_vy,_vz);
01638 }

int FTFinder::VertexFit int  z_flag  )  [private]
 

finds event primary vertex

int FTFinder::VertexFit int  z_flag  )  [private]
 

finds event primary vertex

01465 {
01466   _vx = 0.;
01467   _vy = 0.;
01468   _vz = 0.;
01469   if (!z_flag){
01470     return VertexFit2D();
01471   }
01472   int n = _tracks.length();
01473   if (n < 2){
01474     _vx = -99999.;
01475     _vy = -99999.;
01476     _vz = -99999.;
01477     return 0;
01478   }
01479   FTList<float> px(10);
01480   FTList<float> py(10);
01481   FTList<float> pz(10);
01482   FTList<float> dx(10);
01483   FTList<float> dy(10);
01484   FTList<float> dz(10);
01485   FTList<float> pmag2(10);
01486   FTList<float> weight(10);
01487   FTList<float> weight_z(10);
01488   FTList<float> sigma2_r(10);
01489   FTList<float> sigma2_z(10);
01490   
01491   for (int i = 0; i < n; i++){
01492     const Lpav & la = _tracks[i]->lpav();
01493     if (la.nc() <= 3) continue;
01494     const zav & za = _tracks[i]->Zav();
01495     if(za.nc() > 2 && za.b() > -900){
01496       pmag2.append(1+za.b()*za.b());
01497       pz.append(za.a());
01498       dz.append(za.b());
01499       sigma2_z.append(za.chisq()/(za.nc()-2));
01500       weight_z.append(exp(-(za.chisq()/(za.nc()-2))));
01501     }else{
01502       continue;
01503     }     
01504 
01505     HepVector a = la.Hpar(pivot);
01506     
01507     const float dr_i = a(1);
01508     const float px_i = - std::sin(a(2));
01509     const float py_i = std::cos(a(2));
01510 
01511     px.append(px_i);
01512     py.append(py_i);
01513     dx.append(dr_i*py_i);
01514     dy.append(-dr_i*px_i);
01515     sigma2_r.append(std::sqrt(la.chisq())/(la.nc()-3));
01516     weight.append(exp(-(std::sqrt(la.chisq())/(la.nc()-3))));
01517   }
01518   
01519   n = dx.length();
01520   if (n < 2){
01521     _vx = -9999.;
01522     _vy = -9999.;
01523     _vz = -9999.;
01524     return 0;
01525   }
01526 
01527   FTList<float> vtx_x(20);
01528   FTList<float> vtx_y(20);
01529   FTList<float> vtx_z(20);
01530   FTList<float> weight2(20);
01531   FTList<float> weight2_z(20);
01532   FTList<float> vtx_chi2(20);
01533   unsigned n_vtx(0);
01534   for (int i = n - 1; i; i--){
01535     for (int j = 0; j < i; j++){
01536       // min. chi2 fit w/ line approximation
01537       const float pij_x = py[i]*pz[j]-pz[i]*py[j];
01538       const float pij_y = pz[i]*px[j]-px[i]*pz[j];
01539       const float pij_z = px[i]*py[j]-py[i]*px[j];
01540 
01541       if (pij_x == 0.0f && pij_y == 0.0f && pij_z == 0.0f ) continue;
01542 
01543       const float sr = sigma2_r[i]+sigma2_r[j]; 
01544       const float sz = sigma2_z[i]+sigma2_z[j];
01545 
01546       const float ddx = dx[i]-dx[j];
01547       const float ddy = dy[i]-dy[j];
01548       const float ddz = dz[i]-dz[j];
01549 
01550       const float pij_mag2 = pij_x*pij_x/(sr*sz)+pij_y*pij_y/(sr*sz)+pij_z*pij_z/(sr*sr);
01551 
01552       const float d_i = (pij_x*(py[j]*ddz-pz[j]*ddy)/(sr*sz)+
01553                          pij_y*(pz[j]*ddx-px[j]*ddz)/(sr*sz)+
01554                          pij_z*(px[j]*ddy-py[j]*ddx)/(sr*sr))/pij_mag2;
01555 
01556       const float d_j = (pij_x*(py[i]*ddz-pz[i]*ddy)/(sr*sz)+
01557                          pij_y*(pz[i]*ddx-px[i]*ddz)/(sr*sz)+
01558                          pij_z*(px[i]*ddy-py[i]*ddx)/(sr*sr))/pij_mag2;
01559 
01560       const float vtx_x_i = dx[i] + px[i]*d_i;
01561       const float vtx_y_i = dy[i] + py[i]*d_i;
01562       const float vtx_z_i = dz[i] + pz[i]*d_i;
01563 
01564       const float vtx_x_j = dx[j] + px[j]*d_j;
01565       const float vtx_y_j = dy[j] + py[j]*d_j;
01566       const float vtx_z_j = dz[j] + pz[j]*d_j;
01567 
01568       const float weight_ij = weight[i]+weight[j];
01569       vtx_x.append((weight[j]*vtx_x_i + weight[i]*vtx_x_j)/weight_ij);
01570       vtx_y.append((weight[j]*vtx_y_i + weight[i]*vtx_y_j)/weight_ij);
01571       vtx_z.append((weight_z[j]*vtx_z_i + weight_z[i]*vtx_z_j)/(weight_z[i]+weight_z[j]));
01572       
01573       weight2.append(exp(-sr));
01574       weight2_z.append(exp(-sz));
01575       vtx_chi2.append(((vtx_x_i-vtx_x_j)*(vtx_x_i-vtx_x_j)+(vtx_y_i-vtx_y_j)*(vtx_y_i-vtx_y_j))/sr +
01576                       (vtx_z_i-vtx_z_j)*(vtx_z_i-vtx_z_j)/sz);
01577       n_vtx++;
01578     }
01579   }
01580   n = vtx_chi2.length();
01581   float S_weight(0.0f);
01582   float S_weight_z(0.0f);
01583   for (int i = 0; i != n; i++){
01584     if (vtx_chi2[i] > 10.) continue;
01585     float w(std::exp(-vtx_chi2[i]));
01586     _vx += vtx_x[i]*weight2[i]*w;
01587     _vy += vtx_y[i]*weight2[i]*w;
01588     _vz += vtx_z[i]*weight2_z[i]*w;
01589     S_weight += weight2[i]*w;
01590     S_weight_z += weight2_z[i]*w;
01591   }
01592   int rtn_flag = 0;
01593   if (S_weight <= 0.){
01594     _vx = -9999.;
01595     _vy = -9999.;
01596   }else{
01597     _vx /= S_weight;
01598     _vy /= S_weight;
01599     rtn_flag = 1;
01600   }
01601   if (!z_flag) return rtn_flag;
01602   if (S_weight_z <= 0.){
01603     _vz = -9999.;
01604   }else{
01605     _vz /= S_weight_z;
01606     rtn_flag++;
01607   }
01608   return rtn_flag;
01609 }

int FTFinder::VertexFit2D  )  [private]
 

finds event primary vertex from 2D tracks

int FTFinder::VertexFit2D  )  [private]
 

finds event primary vertex from 2D tracks

01376 {
01377   int nTrks = _tracks.length();
01378   if (nTrks < 2){
01379     _vx = -99999.;
01380     _vy = -99999.;
01381     _vz = -99999.;
01382     return 0;
01383   }
01384   FTList<float> px(10);
01385   FTList<float> py(10);
01386   FTList<float> dx(10);
01387   FTList<float> dy(10);
01388   FTList<double> weight(10);
01389   for (int i = 0; i < nTrks; i++){
01390     const Lpav & la = _tracks[i]->lpav();
01391     HepVector a = la.Hpar(pivot);
01392     
01393     const float dr_i = a(1);
01394     if (fabs(a(1)) > 1.5) continue;
01395     const float px_i = - sin(a(2));
01396     const float py_i = cos(a(2));
01397 
01398     //const float dx_i = dr_i*py_i;
01399     //const float dy_i = -dr_i*px_i;
01400 
01401     float weight_i = la.chisq()/(la.nc()*0.02);
01402 
01403     px.append(px_i);
01404     py.append(py_i);
01405     dx.append(dr_i*py_i);
01406     dy.append(-dr_i*px_i);
01407     weight.append(exp(-weight_i*weight_i));
01408   }
01409   if (dx.length() < 2){
01410     _vx = -99999.;
01411     _vy = -99999.;
01412     _vz = -99999.;
01413     return 0;
01414   }
01415   double S_weight = 0.;
01416   for (int i = dx.length() - 1; i; i--){
01417     const float px_i = px[i];
01418     const float py_i = py[i];
01419     const float dx_i = dx[i];
01420     const float dy_i = dy[i];
01421     const float weight_i = weight[i];
01422     for (int j = 0; j < i; j++){
01423       const float px_j = px[j];
01424       const float py_j = py[j];
01425       //const float weight_j = weight[j];
01426       
01427       const float ddx = dx[j] - dx_i;
01428       const float ddy = dx[j] - dy_i;
01429     
01430       const float tmp_par = px_i*py_j - px_j*py_i;
01431       const float par = (py_j*ddx-px_j*ddy)/tmp_par;
01432 
01433       double weight_ij = weight_i*weight[j];
01434       S_weight += weight_i*weight[j];
01435       if (tmp_par==0 ||
01436           par < -0.5 || (py_i*ddx-px_i*ddy)/tmp_par < -0.5 ||
01437           fabs((px_i*px_j + py_i*py_j)/
01438                sqrt((px_i*px_i+py_i*py_i)*(px_j*px_j+py_j*py_j)))>0.86){
01439         _vx += (dx_i+0.5*ddx)*weight_ij;
01440         _vy += (dy_i+0.5*ddy)*weight_ij;
01441       }else{
01442         _vx += (dx_i+par*px_i)*weight_ij;
01443         _vy += (dy_i+par*py_i)*weight_ij;
01444       }
01445     }
01446   }
01447 
01448   int rtn_flag = 0;
01449   if (S_weight == 0.){
01450     _vx = -99999.;
01451     _vy = -99999.;
01452     _vz = -99999.;
01453   }else{
01454     _vx /= S_weight;
01455     _vy /= S_weight;
01456     _vz = -99999.;
01457     rtn_flag = 1;
01458   }
01459   return rtn_flag;
01460 
01461 }

float FTFinder::x2t const FTLayer l,
const float  x
const
 

convert x to t

float FTFinder::x2t const FTLayer l,
const float  x
const [inline]
 

convert x to t

00205 {
00206   return (x*x) / (param->_xtCoEff * param->_xtCoEff *l.csize());
00207 }


Member Data Documentation

FTList<FTSegment *> FTFinder::_axialSegCollect [private]
 

FTList<FTSegment *> FTFinder::_axialSegCollect [private]
 

int FTFinder::_ExpNo [private]
 

FTLayer* FTFinder::_layer [private]
 

FTLayer* FTFinder::_layer [private]
 

FTList<FTSegment *>* FTFinder::_linkedSegments [private]
 

FTList<FTSegment *>* FTFinder::_linkedSegments [private]
 

int FTFinder::_RunNo [private]
 

FTSuperLayer* FTFinder::_superLayer [private]
 

FTSuperLayer* FTFinder::_superLayer [private]
 

FTList<FTTrack *>& FTFinder::_tracks [private]
 

FTList<FTTrack *>& FTFinder::_tracks [private]
 

double FTFinder::_vx [private]
 

double FTFinder::_vy [private]
 

double FTFinder::_vz [private]
 

int FTFinder::_widbase [private]
 

FTWire* FTFinder::_wire [private]
 

FTWire* FTFinder::_wire [private]
 

int FTFinder::eventNo
 

float FTFinder::evtTiming
 

int FTFinder::expflag
 

int FTFinder::i_rPhiFit
 

Algorithm* FTFinder::m_algorithm [private]
 

Algorithm* FTFinder::m_algorithm [private]
 

HepPDT::ParticleDataTable* FTFinder::m_particleTable [private]
 

HepPDT::ParticleDataTable* FTFinder::m_particleTable [private]
 

IRawDataProviderSvc* FTFinder::m_rawDataProviderSvc [private]
 

IRawDataProviderSvc* FTFinder::m_rawDataProviderSvc [private]
 

int FTFinder::m_total_trk [private]
 

MdcParameter* FTFinder::param [static, private]
 

MdcParameter * FTFinder::param = MdcParameter::instance() [static, private]
 

const HepPoint3D FTFinder::pivot
 

int FTFinder::runNo
 

float FTFinder::t0Estime
 

int FTFinder::tEstFlag
 

FTList<float> FTFinder::tEstime[10]
 

FTList<float> FTFinder::tEstime[10]
 

float FTFinder::Testime
 

float FTFinder::tOffSet
 


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 16:15:25 2011 for BOSS6.5.5 by  doxygen 1.3.9.1