TrackSegmentCam Class Reference

#include <TrackSegmentCam.h>

List of all members.

Public Member Functions

 TrackSegmentCam (ClusterCam *clustm, ClusterCam *clust0, ClusterCam *clustp)
virtual ~TrackSegmentCam ()
void AddCluster (ClusterCam *clust)
bool ContainsCluster (ClusterCam *clust)
ClusterCamGetCluster (unsigned int i)
unsigned int GetEntries () const
int GetBegPlane () const
int GetEndPlane () const
int GetPlaneView () const
double GetBegDir ()
double GetBegTPos ()
double GetBegZPos () const
double GetEndDir ()
double GetEndTPos ()
double GetEndZPos () const
void AddSegment (TrackSegmentCam *segment)
bool IsAssoc (TrackSegmentCam *segment)
void AddAssocSegToBeg (TrackSegmentCam *seg)
void AddAssocSegToEnd (TrackSegmentCam *seg)
TrackSegmentCamGetAssocSegBeg (unsigned int i)
TrackSegmentCamGetAssocSegEnd (unsigned int i)
unsigned int GetNAssocSegBeg () const
unsigned int GetNAssocSegEnd () const
void AddPrefSegToBeg (TrackSegmentCam *seg)
void AddPrefSegToEnd (TrackSegmentCam *seg)
TrackSegmentCamGetPrefSegBeg (unsigned int i)
TrackSegmentCamGetPrefSegEnd (unsigned int i)
unsigned int GetNPrefSegBeg () const
unsigned int GetNPrefSegEnd () const
void AddMatchSegToBeg (TrackSegmentCam *seg)
void AddMatchSegToEnd (TrackSegmentCam *seg)
TrackSegmentCamGetMatchSegBeg (unsigned int i)
TrackSegmentCamGetMatchSegEnd (unsigned int i)
unsigned int GetNMatchSegBeg () const
unsigned int GetNMatchSegEnd () const
void SetTmpTrkFlag (int flag)
int GetTmpTrkFlag () const
void SetUID (int uid)
int GetUID () const
void SetTrkFlag (int flag)
int GetTrkFlag () const
void SetSeedSegment (TrackSegmentCam *segment)
TrackSegmentCamGetSeedSegment ()
void SetNPlanes (int nplanes)
int GetNPlanes () const
double GetScore (vector< TrackSegmentCam * > *BegSegBank=0, vector< TrackSegmentCam * > *EndSegBank=0)
double GetBegTime () const
double GetEndTime () const
void SetPartner (TrackSegmentCam *segment)
TrackSegmentCamGetPartner ()

Private Attributes

vector< ClusterCam * > ClustersInSegment
vector< TrackSegmentCam * > fBegAssociatedSegList
vector< TrackSegmentCam * > fEndAssociatedSegList
vector< TrackSegmentCam * > fBegPreferredSegList
vector< TrackSegmentCam * > fEndPreferredSegList
vector< TrackSegmentCam * > fBegMatchedSegList
vector< TrackSegmentCam * > fEndMatchedSegList
TrackSegmentCamfSeedSegment
TrackSegmentCamfPartner
int fUID
int fBegPlane
int fEndPlane
double fBegVtxZ
double fEndVtxZ
int fTrkFlag
int fTmpTrkFlag
int fPlaneView
int fNPlanes
double fBegTime
double fEndTime
const double StripWidth

Detailed Description

Definition at line 18 of file TrackSegmentCam.h.


Constructor & Destructor Documentation

TrackSegmentCam::TrackSegmentCam ( ClusterCam clustm,
ClusterCam clust0,
ClusterCam clustp 
)

Definition at line 20 of file TrackSegmentCam.cxx.

00020                                                                                           :
00021   fSeedSegment(0), fPartner(0), fUID(0), fBegPlane(999), fEndPlane(-999), fBegVtxZ(999.), 
00022   fEndVtxZ(-999.), fTrkFlag(0), fTmpTrkFlag(0), fPlaneView(-1), fNPlanes(0), 
00023   fBegTime(0.), fEndTime(0.), StripWidth(4.108e-2)
00024 {
00025   fPlaneView=clust0->GetPlaneView();
00026   fBegTime=clust0->GetBegTime();
00027   fEndTime=clust0->GetEndTime();
00028 
00029   this->AddCluster(clustm); this->AddCluster(clust0); this->AddCluster(clustp);
00030 }

TrackSegmentCam::~TrackSegmentCam (  )  [virtual]

Member Function Documentation

void TrackSegmentCam::AddAssocSegToBeg ( TrackSegmentCam seg  ) 

Definition at line 371 of file TrackSegmentCam.cxx.

References fBegAssociatedSegList.

Referenced by AlgTrackCamList::NearDetectorTriplets().

00372 {
00373   fBegAssociatedSegList.push_back(seg);
00374   return;
00375 }

void TrackSegmentCam::AddAssocSegToEnd ( TrackSegmentCam seg  ) 

Definition at line 380 of file TrackSegmentCam.cxx.

References fEndAssociatedSegList.

Referenced by AlgTrackCamList::NearDetectorTriplets().

00381 {
00382   fEndAssociatedSegList.push_back(seg);
00383   return;
00384 }

void TrackSegmentCam::AddCluster ( ClusterCam clust  ) 

Definition at line 49 of file TrackSegmentCam.cxx.

References ClustersInSegment, ContainsCluster(), fBegPlane, fBegTime, fBegVtxZ, fEndPlane, fEndTime, fEndVtxZ, ClusterCam::GetBegTime(), ClusterCam::GetEndTime(), ClusterCam::GetPlane(), VHS::GetPlane(), and ClusterCam::GetZPos().

Referenced by AddSegment().

00050 {
00051   if(clust) {
00052     if(this->ContainsCluster(clust)==false) 
00053       {
00054         ClustersInSegment.push_back(clust);
00055         if( fBegPlane > clust->GetPlane()){ fBegPlane = clust->GetPlane(); fBegVtxZ =  clust->GetZPos(); }
00056         if( fEndPlane < clust->GetPlane()){ fEndPlane = clust->GetPlane(); fEndVtxZ =  clust->GetZPos(); }
00057         
00058         if( clust->GetBegTime()<fBegTime ) { fBegTime=clust->GetBegTime(); }
00059         if( clust->GetEndTime()>fEndTime ) { fEndTime=clust->GetEndTime(); }
00060       }
00061   }
00062   
00063   return;
00064 }

void TrackSegmentCam::AddMatchSegToBeg ( TrackSegmentCam seg  ) 

Definition at line 443 of file TrackSegmentCam.cxx.

References fBegMatchedSegList.

Referenced by AlgTrackCamList::FindMatchedJoins(), and AlgTrackCamList::NearDetectorTriplets().

00444 {
00445   fBegMatchedSegList.push_back(seg);
00446   return;
00447 }

void TrackSegmentCam::AddMatchSegToEnd ( TrackSegmentCam seg  ) 

Definition at line 452 of file TrackSegmentCam.cxx.

References fEndMatchedSegList.

Referenced by AlgTrackCamList::FindMatchedJoins(), and AlgTrackCamList::NearDetectorTriplets().

00453 {
00454   fEndMatchedSegList.push_back(seg);
00455   return;
00456 }

void TrackSegmentCam::AddPrefSegToBeg ( TrackSegmentCam seg  ) 

Definition at line 407 of file TrackSegmentCam.cxx.

References fBegPreferredSegList.

Referenced by AlgTrackCamList::FindPreferredJoins().

00408 {
00409   fBegPreferredSegList.push_back(seg);
00410   return;
00411 }

void TrackSegmentCam::AddPrefSegToEnd ( TrackSegmentCam seg  ) 

Definition at line 416 of file TrackSegmentCam.cxx.

References fEndPreferredSegList.

Referenced by AlgTrackCamList::FindPreferredJoins().

00417 {
00418   fEndPreferredSegList.push_back(seg);
00419   return;
00420 }

void TrackSegmentCam::AddSegment ( TrackSegmentCam segment  ) 

Definition at line 91 of file TrackSegmentCam.cxx.

References AddCluster(), GetCluster(), and GetEntries().

Referenced by AlgTrackCamList::FindMatchedJoins(), AlgTrackCamList::Form2DTracks(), AlgTrackCamList::Join2DTracks(), AlgTrackCamList::NearDetectorTriplets(), and AlgTrackCamList::SecondUVComparison().

00092 {
00093   for(unsigned int i=0; i<segment->GetEntries(); ++i) {
00094     this->AddCluster(segment->GetCluster(i));    
00095   }
00096 
00097   return;
00098 }

bool TrackSegmentCam::ContainsCluster ( ClusterCam clust  ) 

Definition at line 69 of file TrackSegmentCam.cxx.

References ClustersInSegment.

Referenced by AddCluster(), and IsAssoc().

00070 {
00071   for(unsigned int i=0; i<ClustersInSegment.size(); ++i) {
00072     if(clust==ClustersInSegment[i]) {return true;}
00073   }
00074 
00075   return false;
00076 }

TrackSegmentCam * TrackSegmentCam::GetAssocSegBeg ( unsigned int  i  ) 

Definition at line 389 of file TrackSegmentCam.cxx.

References fBegAssociatedSegList.

Referenced by AlgTrackCamList::FindAllAssociations(), AlgTrackCamList::FindPreferredJoins(), and AlgTrackCamList::NearDetectorTriplets().

00390 {
00391   if(i<fBegAssociatedSegList.size()) {return fBegAssociatedSegList[i];}
00392   else return 0;
00393 }

TrackSegmentCam * TrackSegmentCam::GetAssocSegEnd ( unsigned int  i  ) 

Definition at line 398 of file TrackSegmentCam.cxx.

References fEndAssociatedSegList.

Referenced by AlgTrackCamList::FindAllAssociations(), AlgTrackCamList::FindPreferredJoins(), and AlgTrackCamList::NearDetectorTriplets().

00399 {
00400   if(i<fEndAssociatedSegList.size()) {return fEndAssociatedSegList[i];}
00401   else return 0;
00402 }

double TrackSegmentCam::GetBegDir (  ) 

Definition at line 285 of file TrackSegmentCam.cxx.

References ClustersInSegment, MuELoss::e, fBegPlane, GetEntries(), VHS::GetPlane(), HitCam::GetTPos(), and HitCam::GetZPos().

Referenced by AlgTrackCamList::FindMatchedJoins(), and IsAssoc().

00286 {
00287   double z=0.0,t=0.0;
00288   double sw=0.0,swx=0.0,swx2=0.0;
00289   double swy=0.0,swyx=0.0;
00290   unsigned int nclusters = this->GetEntries();
00291   unsigned int nhits = 0;
00292   HitCam* hit=0;
00293   for( unsigned int i=0; i<nclusters; ++i)
00294     {//find the clusters on the first plane in the segment
00295       if(ClustersInSegment[i]->GetPlane()<fBegPlane+10)
00296         {
00297           nhits = ClustersInSegment[i]->GetEntries();
00298 
00299           //loop over hits in cluster
00300           for(unsigned int j=0;j<nhits;++j)
00301             {
00302               hit = ClustersInSegment[i]->GetHit(j);
00303               if(hit)
00304                 {
00305                   z=hit->GetZPos(); t=hit->GetTPos();
00306                   sw+=1.0; swx+=z; swx2+=z*z; 
00307                   swy+=t; swyx+=t*z;;
00308                 }
00309             }
00310         }
00311     }
00312   double denom=swx*swx-sw*swx2;
00313   if(fabs(denom)>1.e-10) {return (swx*swy-sw*swyx)/denom;}
00314   else return 0;
00315 }

int TrackSegmentCam::GetBegPlane (  )  const
double TrackSegmentCam::GetBegTime (  )  const [inline]

Definition at line 85 of file TrackSegmentCam.h.

References fBegTime.

Referenced by AlgTrackCamList::SecondUVComparison().

00085 { return fBegTime; };

double TrackSegmentCam::GetBegTPos (  ) 

Definition at line 219 of file TrackSegmentCam.cxx.

References ClustersInSegment, fBegPlane, GetEntries(), VHS::GetPlane(), and HitCam::GetTPos().

Referenced by AlgTrackCamList::FindAllAssociations(), AlgTrackCamList::FindMatchedJoins(), AlgTrackCamList::FindPreferredJoins(), AlgTrackCamList::FirstUVComparison(), AlgTrackCamList::Form2DTracks(), IsAssoc(), AlgTrackCamList::Join2DTracks(), AlgTrackCamList::NearDetectorTriplets(), and AlgTrackCamList::SecondUVComparison().

00220 {
00221   double tot=0.0,begt=0.0;
00222   //Loop over clusters in segment
00223   unsigned int nclusters = this->GetEntries();
00224   unsigned int nhits = 0;
00225   HitCam* hit=0;
00226   for( unsigned int i=0; i<nclusters; ++i)
00227     {//find the clusters on the first plane in the segment
00228       if(ClustersInSegment[i]->GetPlane()==fBegPlane)
00229         {
00230           nhits = ClustersInSegment[i]->GetEntries();
00231 
00232           //loop over hits in cluster
00233           for(unsigned int j=0;j<nhits;++j)
00234             {
00235               hit = ClustersInSegment[i]->GetHit(j);
00236               if(hit)
00237                 {
00238                   begt+=hit->GetTPos();
00239                   tot+=1.0;
00240                 }
00241             }
00242         }
00243     }
00244   if(tot>0) return (begt/tot); 
00245   else return 0;
00246 }

double TrackSegmentCam::GetBegZPos (  )  const

Definition at line 355 of file TrackSegmentCam.cxx.

References fBegVtxZ.

Referenced by AlgTrackCamList::FindMatchedJoins(), IsAssoc(), and AlgTrackCamList::Join2DTracks().

00356 {
00357   return fBegVtxZ;
00358 }

ClusterCam * TrackSegmentCam::GetCluster ( unsigned int  i  ) 
double TrackSegmentCam::GetEndDir (  ) 

Definition at line 320 of file TrackSegmentCam.cxx.

References ClustersInSegment, MuELoss::e, fEndPlane, GetEntries(), VHS::GetPlane(), HitCam::GetTPos(), and HitCam::GetZPos().

Referenced by AlgTrackCamList::FindMatchedJoins(), and IsAssoc().

00321 {
00322   double z=0.0,t=0.0;
00323   double sw=0.0,swx=0.0,swx2=0.0;
00324   double swy=0.0,swyx=0.0;
00325   unsigned int nclusters = this->GetEntries();
00326   unsigned int nhits = 0;
00327   HitCam* hit=0;
00328   for( unsigned int i=0; i<nclusters; ++i)
00329     {//find the clusters on the first plane in the segment
00330       if(ClustersInSegment[i]->GetPlane()>fEndPlane-10)
00331         {
00332           nhits = ClustersInSegment[i]->GetEntries();
00333 
00334           //loop over hits in cluster
00335           for(unsigned int j=0;j<nhits;++j)
00336             {
00337               hit = ClustersInSegment[i]->GetHit(j);
00338               if(hit)
00339                 {
00340                   z=hit->GetZPos(); t=hit->GetTPos();
00341                   sw+=1.0; swx+=z; swx2+=z*z; 
00342                   swy+=t; swyx+=t*z;;
00343                 }
00344             }
00345         }
00346     }
00347   double denom=swx*swx-sw*swx2;
00348   if(fabs(denom)>1.e-10) {return (swx*swy-sw*swyx)/denom;}
00349   else return 0;
00350 }

int TrackSegmentCam::GetEndPlane (  )  const
double TrackSegmentCam::GetEndTime (  )  const [inline]

Definition at line 86 of file TrackSegmentCam.h.

References fEndTime.

Referenced by AlgTrackCamList::SecondUVComparison().

00086 { return fEndTime; };

double TrackSegmentCam::GetEndTPos (  ) 

Definition at line 252 of file TrackSegmentCam.cxx.

References ClustersInSegment, fEndPlane, GetEntries(), VHS::GetPlane(), and HitCam::GetTPos().

Referenced by AlgTrackCamList::FindAllAssociations(), AlgTrackCamList::FindMatchedJoins(), AlgTrackCamList::FindPreferredJoins(), AlgTrackCamList::FirstUVComparison(), AlgTrackCamList::Form2DTracks(), IsAssoc(), AlgTrackCamList::Join2DTracks(), AlgTrackCamList::NearDetectorTriplets(), and AlgTrackCamList::SecondUVComparison().

00253 {
00254   double tot=0.0,endt=0.0;
00255   //Loop over clusters in segment
00256   unsigned int nclusters = this->GetEntries();
00257   unsigned int nhits = 0;
00258   HitCam* hit=0;
00259   for( unsigned int i=0; i<nclusters; ++i)
00260     {//find the clusters on the first plane in the segment
00261       if(ClustersInSegment[i]->GetPlane()==fEndPlane)
00262         {
00263           nhits = ClustersInSegment[i]->GetEntries();
00264 
00265           //loop over hits in cluster
00266           for(unsigned int j=0;j<nhits;++j)
00267             {
00268               hit = ClustersInSegment[i]->GetHit(j);
00269               if(hit)
00270                 {
00271                   endt+=hit->GetTPos();
00272                   tot+=1.0;
00273                 }
00274             }
00275         }
00276     }
00277   if(tot>0) return (endt/tot); 
00278   else return 0;
00279 }

double TrackSegmentCam::GetEndZPos (  )  const

Definition at line 363 of file TrackSegmentCam.cxx.

References fEndVtxZ.

Referenced by AlgTrackCamList::FindMatchedJoins(), IsAssoc(), and AlgTrackCamList::Join2DTracks().

00364 {
00365   return fEndVtxZ;
00366 }

unsigned int TrackSegmentCam::GetEntries (  )  const
TrackSegmentCam * TrackSegmentCam::GetMatchSegBeg ( unsigned int  i  ) 

Definition at line 461 of file TrackSegmentCam.cxx.

References fBegMatchedSegList.

Referenced by AlgTrackCamList::FindMatchedJoins(), and AlgTrackCamList::Form2DTracks().

00462 {
00463   if(i<fBegMatchedSegList.size()) {return fBegMatchedSegList[i];}
00464   else return 0;
00465 }

TrackSegmentCam * TrackSegmentCam::GetMatchSegEnd ( unsigned int  i  ) 

Definition at line 470 of file TrackSegmentCam.cxx.

References fEndMatchedSegList.

Referenced by AlgTrackCamList::FindMatchedJoins(), and AlgTrackCamList::Form2DTracks().

00471 {
00472   if(i<fEndMatchedSegList.size()) {return fEndMatchedSegList[i];}
00473   else return 0;
00474 }

unsigned int TrackSegmentCam::GetNAssocSegBeg (  )  const [inline]
unsigned int TrackSegmentCam::GetNAssocSegEnd (  )  const [inline]
unsigned int TrackSegmentCam::GetNMatchSegBeg (  )  const [inline]

Definition at line 64 of file TrackSegmentCam.h.

References fBegMatchedSegList.

Referenced by AlgTrackCamList::FindMatchedJoins(), and AlgTrackCamList::Form2DTracks().

00064 {return fBegMatchedSegList.size();};

unsigned int TrackSegmentCam::GetNMatchSegEnd (  )  const [inline]

Definition at line 65 of file TrackSegmentCam.h.

References fEndMatchedSegList.

Referenced by AlgTrackCamList::FindMatchedJoins(), and AlgTrackCamList::Form2DTracks().

00065 {return fEndMatchedSegList.size();};

int TrackSegmentCam::GetNPlanes (  )  const [inline]

Definition at line 81 of file TrackSegmentCam.h.

References fNPlanes.

00081 { return fNPlanes; };

unsigned int TrackSegmentCam::GetNPrefSegBeg (  )  const [inline]

Definition at line 56 of file TrackSegmentCam.h.

References fBegPreferredSegList.

Referenced by AlgTrackCamList::FindPreferredJoins().

00056 {return fBegPreferredSegList.size();};

unsigned int TrackSegmentCam::GetNPrefSegEnd (  )  const [inline]

Definition at line 57 of file TrackSegmentCam.h.

References fEndPreferredSegList.

Referenced by AlgTrackCamList::FindMatchedJoins(), and AlgTrackCamList::FindPreferredJoins().

00057 {return fEndPreferredSegList.size();};

TrackSegmentCam* TrackSegmentCam::GetPartner (  )  [inline]

Definition at line 89 of file TrackSegmentCam.h.

References fPartner.

Referenced by AlgTrackCamList::SecondUVComparison().

00089 {return (TrackSegmentCam*)(fPartner);};

int TrackSegmentCam::GetPlaneView (  )  const

Definition at line 479 of file TrackSegmentCam.cxx.

References fPlaneView.

Referenced by AlgTrackCamList::NearDetectorTriplets().

00480 {
00481   return fPlaneView;
00482 }

TrackSegmentCam * TrackSegmentCam::GetPrefSegBeg ( unsigned int  i  ) 

Definition at line 425 of file TrackSegmentCam.cxx.

References fBegPreferredSegList.

Referenced by AlgTrackCamList::FindPreferredJoins().

00426 {
00427   if(i<fBegPreferredSegList.size()) {return fBegPreferredSegList[i];}
00428   else return 0;
00429 }

TrackSegmentCam * TrackSegmentCam::GetPrefSegEnd ( unsigned int  i  ) 

Definition at line 434 of file TrackSegmentCam.cxx.

References fEndPreferredSegList.

Referenced by AlgTrackCamList::FindPreferredJoins().

00435 {
00436   if(i<fEndPreferredSegList.size())  {return fEndPreferredSegList[i];}
00437   else return 0;
00438 }

double TrackSegmentCam::GetScore ( vector< TrackSegmentCam * > *  BegSegBank = 0,
vector< TrackSegmentCam * > *  EndSegBank = 0 
)

Definition at line 487 of file TrackSegmentCam.cxx.

References MuELoss::e, GetBegPlane(), HitCam::GetCharge(), GetCluster(), GetEndPlane(), GetEntries(), ClusterCam::GetEntries(), ClusterCam::GetHit(), ClusterCam::GetPlane(), HitCam::GetTPos(), HitCam::GetZPos(), Munits::km, Munits::m, and MinosMaterial::Z().

Referenced by AlgTrackCamList::Form2DTracks().

00488 {
00489   int begplane2, begplane1, endplane1, endplane2;
00490   int nplane, plane;
00491   
00492   vector<ClusterCam*> TempContainer;
00493   bool IsInTemp;
00494 
00495   
00496   //Store the beginning and end of the segment locally
00497   begplane1=this->GetBegPlane();
00498   endplane1=this->GetEndPlane();
00499   begplane2=this->GetBegPlane();
00500   endplane2=this->GetEndPlane();
00501   //
00502   //  begplane2============begplane1===========endplane1============endplane2
00503   //            BegSegBank             this              EndSegBank
00504   //
00505 
00506   // Store pointers to all clusters
00507   unsigned int nclusters = this->GetEntries();  
00508   for(unsigned int i=0; i<nclusters; ++i) {
00509     TempContainer.push_back(this->GetCluster(i));
00510   }
00511 
00512   unsigned int nsegments;
00513   unsigned int nclustersintemp;
00514   int tempplane;
00515   if(BegSegBank) {
00516     nsegments = (*BegSegBank).size();
00517     for(unsigned int j=0; j<nsegments; ++j) {
00518       //looking for the earliest plane in the Beginning Segments
00519       tempplane = (*BegSegBank)[j]->GetBegPlane();
00520       if(tempplane<begplane2) begplane2=tempplane;
00521       //Loop over clusters in this segment and add any we don't have
00522       nclusters=(*BegSegBank)[j]->GetEntries();
00523       for(unsigned int k=0; k<nclusters; ++k) {
00524         ClusterCam* clust = (*BegSegBank)[j]->GetCluster(k);
00525         
00526         IsInTemp=false;
00527         nclustersintemp = TempContainer.size();
00528         for(unsigned int l=0; l<nclustersintemp; ++l) {
00529           if(TempContainer[l]==clust) {IsInTemp=true; break;}
00530         }
00531         if(IsInTemp==false) {TempContainer.push_back(clust);}
00532       }
00533     }
00534   }
00535 
00536   if(EndSegBank) {
00537     nsegments = (*EndSegBank).size();
00538     for(unsigned int j=0; j<nsegments; ++j) {
00539       //looking for the latest plane in the End Segments
00540       tempplane = (*EndSegBank)[j]->GetEndPlane();
00541       if(tempplane>endplane2) endplane2=tempplane;
00542       //Loop over clusters in this segment and add any we don't have
00543       nclusters = (*EndSegBank)[j]->GetEntries();
00544       for(unsigned int k=0; k<nclusters; ++k) {
00545         ClusterCam* clust = (*EndSegBank)[j]->GetCluster(k);
00546         
00547         IsInTemp=false;
00548         nclustersintemp = TempContainer.size();
00549         for(unsigned int l=0; l<nclustersintemp; ++l) {
00550           if(TempContainer[l]==clust) {IsInTemp=true; break;}
00551         }
00552         if(IsInTemp==false) {TempContainer.push_back(clust);}
00553       }
00554     }
00555   }
00556 
00557   //Convert planes to a single view co-ordinate system where begplane2 = 0;
00558   begplane1-=begplane2; begplane1/=2;
00559   endplane1-=begplane2; endplane1/=2;
00560   endplane2-=begplane2; endplane2/=2;
00561 
00562   //calculate the number of planes we will be considering
00563   nplane=1+endplane2;
00564   double* T = new double[nplane];
00565   double* Z = new double[nplane];
00566   double* W = new double[nplane];
00567   for(int i=0; i<nplane; ++i) {T[i]=0.; Z[i]=0.; W[i]=0.;}
00568 
00569   int km, kp;  
00570   double m,c;
00571   double dt2,sn;
00572   double score, dstraightness, straightness, expected;
00573   double sw, swz, swt, swzt, swzz;
00574   unsigned int nhits;
00575 
00576   nclusters = TempContainer.size();
00577 
00578   for(unsigned int k=0; k<nclusters; ++k) {
00579     ClusterCam* clust = TempContainer[k];
00580     //Convert clust->GetPlane() to a single view co-ordinate system where begplane2 = 0;
00581     plane=(clust->GetPlane()-begplane2)/2;
00582 
00583     if(!(plane<0 || plane>=nplane)) {
00584       sw=0.; swz=0.; swt=0.;
00585       nhits = clust->GetEntries();
00586       for(unsigned int k1=0; k1<nhits; ++k1) {
00587         HitCam* hit = clust->GetHit(k1);
00588         
00589         swz+=hit->GetCharge()*hit->GetZPos();
00590         swt+=hit->GetCharge()*hit->GetTPos();
00591         sw+=hit->GetCharge();
00592       }
00593       
00594       if(sw>0.){
00595         Z[plane]=swz/sw; T[plane]=swt/sw;
00596         // Weight segments on planes spanned by seed segment. 
00597         // Deweight segments on other planes.
00598         if( plane+1>begplane1 && plane-1<endplane1 ) {W[plane]=5.;} 
00599         else {W[plane]=0.5;}
00600       }
00601     }
00602   }
00603     
00604     
00605   score=0.; straightness=0.; expected=0.;
00606   
00607   double w, t, z;
00608 
00609   for(int k=0; k<nplane; ++k) {
00610 
00611     if(W[k]>0.){
00612       swz=0.; swt=0.; swzz=0.; swzt=0.; sw=0.; sn=0.;
00613       dstraightness=0.;
00614 
00615       km=k-5; kp=k+5;
00616             
00617       if(km<0) {km=0;}
00618       if(kp>nplane-1) {kp=nplane-1;}
00619       
00620 
00621       // Fit this section
00622       for(int k1=km; k1<kp+1; ++k1){
00623         if(W[k1]>0.) {
00624           w=W[k1]; t=T[k1]; z=Z[k1];
00625 
00626           swz+=w*z; swt+=w*t; 
00627           swzz+=w*z*z; swzt+=w*z*t; 
00628           sw+=w; sn+=1.;
00629         }
00630       }
00631       
00632       // Calculate deviation from fit at this plane
00633       if(sn>2.){
00634         m=(sw*swzt-swz*swt)/(sw*swzz-swz*swz);
00635         c=(swt*swzz-swz*swzt)/(sw*swzz-swz*swz);
00636 
00637         dt2=pow(T[k]-(m*Z[k]+c),2);
00638 
00639         if(dt2<1.e-5) {straightness+=1;}
00640         else {straightness+=dt2/1.e-5;}
00641         expected+=1;
00642       }
00643     }
00644   }
00645 
00646   // Protect against divide by zero
00647   if(expected==0) {expected=1; straightness=1;}
00648   //  if(expected<4) {expected*=10;}
00649 
00650   score = 1.e4 + double(TempContainer.size()) - pow(straightness/expected,0.5);
00651 
00652   
00653 //   MSG("AlgTrackCamList", Msg::kVerbose) << " nclusters " << double(TempContainer.size()) 
00654 //                                      << " straightness " << pow(straightness/expected,0.5) 
00655 //                                      << " Score " << score 
00656 //                                      << " begplane " << this->GetBegPlane() << " endplane " << this->GetEndPlane()
00657 //                                      << " begtpos " << this->GetBegTPos() << " endtpos " << this->GetEndTPos() << endl;
00658 
00659 //   MSG("AlgTrackCamList", Msg::kVerbose) << "Clusters involved: " << endl;
00660   
00661 //   for(unsigned int i=0; i<TempContainer.size(); ++i) {
00662 //     MSG("AlgTrackCamList", Msg::kVerbose) << "plane " << TempContainer[i]->GetPlane() << " begtpos " << TempContainer[i]->GetBegTPos() 
00663 //                                        << " endtpos " << TempContainer[i]->GetEndTPos() << endl;
00664 //   }
00665 
00666 //   MSG("AlgTrackCamList", Msg::kVerbose) << "----------------------" << endl;
00667 
00668 
00669   if(score<0.) {score=0.;}
00670  
00671   if(T) {delete [] T;}
00672   if(Z) {delete [] Z;}
00673   if(W) {delete [] W;}
00674 
00675   return score;
00676 }

TrackSegmentCam* TrackSegmentCam::GetSeedSegment (  )  [inline]

Definition at line 78 of file TrackSegmentCam.h.

References fSeedSegment.

Referenced by AlgTrackCamList::FindMatchedJoins(), and AlgTrackCamList::NearDetectorTriplets().

00078 {return (TrackSegmentCam*)(fSeedSegment);};

int TrackSegmentCam::GetTmpTrkFlag (  )  const [inline]

Definition at line 69 of file TrackSegmentCam.h.

References fTmpTrkFlag.

Referenced by AlgTrackCamList::FindPreferredJoins(), and AlgTrackCamList::Form2DTracks().

00069 { return fTmpTrkFlag; };

int TrackSegmentCam::GetTrkFlag (  )  const [inline]

Definition at line 75 of file TrackSegmentCam.h.

References fTrkFlag.

00075 { return fTrkFlag; };

int TrackSegmentCam::GetUID (  )  const [inline]
bool TrackSegmentCam::IsAssoc ( TrackSegmentCam segment  ) 

Definition at line 127 of file TrackSegmentCam.cxx.

References ContainsCluster(), GetBegDir(), GetBegPlane(), ClusterCam::GetBegTPos(), GetBegTPos(), GetBegZPos(), GetCluster(), GetEndDir(), GetEndPlane(), ClusterCam::GetEndTPos(), GetEndTPos(), GetEndZPos(), GetEntries(), ClusterCam::GetPlane(), StripWidth, and win.

Referenced by AlgTrackCamList::FindMatchedJoins(), AlgTrackCamList::FindPreferredJoins(), AlgTrackCamList::Join2DTracks(), AlgTrackCamList::NearDetectorTriplets(), and AlgTrackCamList::SecondUVComparison().

00128 {
00129   unsigned int i;
00130   bool assoc=false;
00131   bool flag=false; 
00132   TrackSegmentCam* Seg1 = this;
00133   TrackSegmentCam* Seg2 = segment;
00134 
00135   //If the two clusters overlap at all
00136   if(Seg1->GetEndPlane()>=Seg2->GetBegPlane()){
00137     flag=true;
00138     //All clusters in Seg1 in planes overlapping Seg2 should also be in Seg2
00139     for(i=0;i<Seg1->GetEntries();i++){
00140       ClusterCam* clr = Seg1->GetCluster(i);
00141       if(clr->GetPlane()>=Seg2->GetBegPlane()){ 
00142         if(!(Seg2->ContainsCluster(clr))){
00143           flag=false; 
00144           break; //one mismatch is too many
00145         }
00146       }
00147     }
00148     if(flag)//only bother with 2nd check if 1st was ok
00149       {
00150         //All clusters in Seg2 in planes overlapping Seg1 should also be in Seg1
00151         for(i=0;i<Seg2->GetEntries();i++){
00152           ClusterCam* clr = Seg2->GetCluster(i);
00153           if(clr->GetPlane()<=Seg1->GetEndPlane()){ 
00154             if(!(Seg1->ContainsCluster(clr))){
00155               flag=false; 
00156               break; //one mismatch is too many 
00157             }
00158           }
00159         }
00160       }
00161     //If this is true and they overlap by more than one plane then they are associated
00162     if(Seg1->GetEndPlane()>Seg2->GetBegPlane()){ if(flag) assoc=true; }
00163   }
00164     //If the segments overlap by 1 or fewer planes need to do some more work...    
00165   if(Seg1->GetEndPlane()<=Seg2->GetBegPlane()){
00166     int idb(0),idb0(0);
00167     int bpln=Seg2->GetEndPlane()+1;
00168     //find the first (lowest plane no) two clusters in the second segment
00169     for(i=0;i<Seg2->GetEntries();i++){
00170       ClusterCam* clr = Seg2->GetCluster(i);
00171       if(clr->GetPlane()<bpln && clr->GetPlane()>Seg2->GetBegPlane()) {//+2){
00172         bpln=clr->GetPlane(); idb=i;
00173       }
00174       else{ if(clr->GetPlane()==Seg2->GetBegPlane()) idb0=i; }
00175     }
00176     ClusterCam* clrb = Seg2->GetCluster(idb); ClusterCam* clrb0 = Seg2->GetCluster(idb0);
00177     double bBegTPos = clrb->GetBegTPos(); double bEndTPos = clrb->GetEndTPos();
00178     double b0BegTPos = clrb0->GetBegTPos(); double b0EndTPos = clrb0->GetEndTPos();
00179 
00180     int ide(0),ide0(0);
00181     int epln=Seg1->GetBegPlane()-1;
00182     //find the last (highest plane no) two clusters in the first segment
00183     for(i=0;i<Seg1->GetEntries();i++){
00184       ClusterCam* clr = Seg1->GetCluster(i);
00185       if(clr->GetPlane()>epln && clr->GetPlane()<Seg1->GetEndPlane()) {//-2){
00186         epln=clr->GetPlane(); ide=i;
00187       }
00188       else{ if(clr->GetPlane()==Seg1->GetEndPlane()) ide0=i; }
00189     }
00190     ClusterCam* clre = Seg1->GetCluster(ide); ClusterCam* clre0 = Seg1->GetCluster(ide0);
00191     double eBegTPos = clre->GetBegTPos(); double eEndTPos = clre->GetEndTPos();
00192     double e0BegTPos = clre0->GetBegTPos(); double e0EndTPos = clre0->GetEndTPos();
00193     //Look at how these clusters overlap stripwise    
00194     if( ( bEndTPos-b0BegTPos>-2*StripWidth && b0EndTPos-bBegTPos>-2*StripWidth && eEndTPos-e0BegTPos>-2*StripWidth && e0EndTPos-eBegTPos>-2*StripWidth )
00195         || ( ( bBegTPos-b0BegTPos>-2*StripWidth && e0BegTPos-eBegTPos>-2*StripWidth ) || ( bEndTPos-b0EndTPos>-2*StripWidth && e0EndTPos-eEndTPos>-2*StripWidth ) )
00196         || ( ( bBegTPos-b0BegTPos<2*StripWidth && e0BegTPos-eBegTPos<2*StripWidth ) || ( bEndTPos-b0EndTPos<2*StripWidth && e0EndTPos-eEndTPos<2*StripWidth ) ) 
00197         ) {
00198       //if the segments overlap by 1 plane then we can now say if they are associated or not
00199       if(Seg2->GetBegPlane()==Seg1->GetEndPlane()){ if(flag) assoc=true; }
00200       else{
00201         double z1,z2,t1,t2,dt1,dt2,dir1,dir2,dirtmp,win;
00202         z1=Seg1->GetEndZPos();  z2=Seg2->GetBegZPos();
00203         t1=Seg1->GetEndTPos();  t2=Seg2->GetBegTPos();
00204         dir1=Seg1->GetEndDir(); dt1=t2-t1-dir1*(z2-z1); 
00205         dir2=Seg2->GetBegDir(); dt2=t2-t1-dir2*(z2-z1); 
00206         win=0.1+0.35*(z2-z1);   dirtmp=(1+dir1*dir2)/(sqrt(1+dir1*dir1)*sqrt(1+dir2*dir2));
00207         
00208         if( ( (dt1>-win&&dt1<win)||(dt2>-win&&dt2<win) ) && ( dirtmp>0.65 ) ) assoc=true; 
00209       }
00210     }
00211   }
00212   return assoc;
00213 }

void TrackSegmentCam::SetNPlanes ( int  nplanes  )  [inline]

Definition at line 80 of file TrackSegmentCam.h.

References fNPlanes.

00080 { fNPlanes=nplanes; };

void TrackSegmentCam::SetPartner ( TrackSegmentCam segment  )  [inline]

Definition at line 88 of file TrackSegmentCam.h.

References fPartner.

Referenced by AlgTrackCamList::SecondUVComparison().

00088 {fPartner = segment;};

void TrackSegmentCam::SetSeedSegment ( TrackSegmentCam segment  )  [inline]

Definition at line 77 of file TrackSegmentCam.h.

References fSeedSegment.

Referenced by AlgTrackCamList::NearDetectorTriplets().

00077 {fSeedSegment = segment;};

void TrackSegmentCam::SetTmpTrkFlag ( int  flag  )  [inline]

Definition at line 68 of file TrackSegmentCam.h.

References fTmpTrkFlag.

Referenced by AlgTrackCamList::FindPreferredJoins(), and AlgTrackCamList::Form2DTracks().

00068 { fTmpTrkFlag=flag; };

void TrackSegmentCam::SetTrkFlag ( int  flag  )  [inline]

Definition at line 74 of file TrackSegmentCam.h.

References fTrkFlag.

00074 { fTrkFlag=flag; };

void TrackSegmentCam::SetUID ( int  uid  )  [inline]

Member Data Documentation

Definition at line 106 of file TrackSegmentCam.h.

Referenced by AddCluster(), GetBegDir(), GetBegPlane(), and GetBegTPos().

Definition at line 96 of file TrackSegmentCam.h.

Referenced by AddPrefSegToBeg(), GetNPrefSegBeg(), GetPrefSegBeg(), and ~TrackSegmentCam().

double TrackSegmentCam::fBegTime [private]

Definition at line 114 of file TrackSegmentCam.h.

Referenced by AddCluster(), and GetBegTime().

double TrackSegmentCam::fBegVtxZ [private]

Definition at line 108 of file TrackSegmentCam.h.

Referenced by AddCluster(), and GetBegZPos().

Definition at line 107 of file TrackSegmentCam.h.

Referenced by AddCluster(), GetEndDir(), GetEndPlane(), and GetEndTPos().

Definition at line 97 of file TrackSegmentCam.h.

Referenced by AddPrefSegToEnd(), GetNPrefSegEnd(), GetPrefSegEnd(), and ~TrackSegmentCam().

double TrackSegmentCam::fEndTime [private]

Definition at line 115 of file TrackSegmentCam.h.

Referenced by AddCluster(), and GetEndTime().

double TrackSegmentCam::fEndVtxZ [private]

Definition at line 109 of file TrackSegmentCam.h.

Referenced by AddCluster(), and GetEndZPos().

Definition at line 113 of file TrackSegmentCam.h.

Referenced by GetNPlanes(), and SetNPlanes().

Definition at line 103 of file TrackSegmentCam.h.

Referenced by GetPartner(), and SetPartner().

Definition at line 112 of file TrackSegmentCam.h.

Referenced by GetPlaneView().

Definition at line 101 of file TrackSegmentCam.h.

Referenced by GetSeedSegment(), and SetSeedSegment().

Definition at line 111 of file TrackSegmentCam.h.

Referenced by GetTmpTrkFlag(), and SetTmpTrkFlag().

Definition at line 110 of file TrackSegmentCam.h.

Referenced by GetTrkFlag(), and SetTrkFlag().

int TrackSegmentCam::fUID [private]

Definition at line 105 of file TrackSegmentCam.h.

Referenced by GetUID(), and SetUID().

const double TrackSegmentCam::StripWidth [private]

Definition at line 116 of file TrackSegmentCam.h.

Referenced by IsAssoc().


The documentation for this class was generated from the following files:

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1