TrackSegmentCamAtNu Class Reference

#include <TrackSegmentCamAtNu.h>

List of all members.

Public Member Functions

 TrackSegmentCamAtNu (ClusterCamAtNu *clustm, ClusterCamAtNu *clust0, ClusterCamAtNu *clustp)
virtual ~TrackSegmentCamAtNu ()
void AddCluster (ClusterCamAtNu *clust)
bool ContainsCluster (ClusterCamAtNu *clust)
ClusterCamAtNuGetCluster (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 (TrackSegmentCamAtNu *segment)
bool IsAssoc (TrackSegmentCamAtNu *segment)
void AddAssocSegToBeg (TrackSegmentCamAtNu *seg)
void AddAssocSegToEnd (TrackSegmentCamAtNu *seg)
TrackSegmentCamAtNuGetAssocSegBeg (unsigned int i)
TrackSegmentCamAtNuGetAssocSegEnd (unsigned int i)
unsigned int GetNAssocSegBeg () const
unsigned int GetNAssocSegEnd () const
void AddPrefSegToBeg (TrackSegmentCamAtNu *seg)
void AddPrefSegToEnd (TrackSegmentCamAtNu *seg)
TrackSegmentCamAtNuGetPrefSegBeg (unsigned int i)
TrackSegmentCamAtNuGetPrefSegEnd (unsigned int i)
unsigned int GetNPrefSegBeg () const
unsigned int GetNPrefSegEnd () const
void AddMatchSegToBeg (TrackSegmentCamAtNu *seg)
void AddMatchSegToEnd (TrackSegmentCamAtNu *seg)
TrackSegmentCamAtNuGetMatchSegBeg (unsigned int i)
TrackSegmentCamAtNuGetMatchSegEnd (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 (TrackSegmentCamAtNu *segment)
TrackSegmentCamAtNuGetSeedSegment ()
void SetNPlanes (int nplanes)
int GetNPlanes () const
double GetScore (vector< TrackSegmentCamAtNu * > *BegSegBank=0, vector< TrackSegmentCamAtNu * > *EndSegBank=0)
double GetBegTime () const
double GetEndTime () const
void SetPartner (TrackSegmentCamAtNu *segment)
TrackSegmentCamAtNuGetPartner ()

Private Attributes

vector< ClusterCamAtNu * > ClustersInSegment
vector< TrackSegmentCamAtNu * > fBegAssociatedSegList
vector< TrackSegmentCamAtNu * > fEndAssociatedSegList
vector< TrackSegmentCamAtNu * > fBegPreferredSegList
vector< TrackSegmentCamAtNu * > fEndPreferredSegList
vector< TrackSegmentCamAtNu * > fBegMatchedSegList
vector< TrackSegmentCamAtNu * > fEndMatchedSegList
TrackSegmentCamAtNufSeedSegment
TrackSegmentCamAtNufPartner
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 TrackSegmentCamAtNu.h.


Constructor & Destructor Documentation

TrackSegmentCamAtNu::TrackSegmentCamAtNu ( ClusterCamAtNu clustm,
ClusterCamAtNu clust0,
ClusterCamAtNu clustp 
)

Definition at line 20 of file TrackSegmentCamAtNu.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 }

TrackSegmentCamAtNu::~TrackSegmentCamAtNu (  )  [virtual]

Member Function Documentation

void TrackSegmentCamAtNu::AddAssocSegToBeg ( TrackSegmentCamAtNu seg  ) 

Definition at line 370 of file TrackSegmentCamAtNu.cxx.

References fBegAssociatedSegList.

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

void TrackSegmentCamAtNu::AddAssocSegToEnd ( TrackSegmentCamAtNu seg  ) 

Definition at line 379 of file TrackSegmentCamAtNu.cxx.

References fEndAssociatedSegList.

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

void TrackSegmentCamAtNu::AddCluster ( ClusterCamAtNu clust  ) 

Definition at line 49 of file TrackSegmentCamAtNu.cxx.

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

Referenced by AddSegment(), and AlgAtmosShowerList::FormDummyTracks().

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 TrackSegmentCamAtNu::AddMatchSegToBeg ( TrackSegmentCamAtNu seg  ) 

Definition at line 442 of file TrackSegmentCamAtNu.cxx.

References fBegMatchedSegList.

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

void TrackSegmentCamAtNu::AddMatchSegToEnd ( TrackSegmentCamAtNu seg  ) 

Definition at line 451 of file TrackSegmentCamAtNu.cxx.

References fEndMatchedSegList.

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

void TrackSegmentCamAtNu::AddPrefSegToBeg ( TrackSegmentCamAtNu seg  ) 

Definition at line 406 of file TrackSegmentCamAtNu.cxx.

References fBegPreferredSegList.

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

void TrackSegmentCamAtNu::AddPrefSegToEnd ( TrackSegmentCamAtNu seg  ) 

Definition at line 415 of file TrackSegmentCamAtNu.cxx.

References fEndPreferredSegList.

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

void TrackSegmentCamAtNu::AddSegment ( TrackSegmentCamAtNu segment  ) 

Definition at line 91 of file TrackSegmentCamAtNu.cxx.

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

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

bool TrackSegmentCamAtNu::ContainsCluster ( ClusterCamAtNu clust  ) 

Definition at line 69 of file TrackSegmentCamAtNu.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 }

TrackSegmentCamAtNu * TrackSegmentCamAtNu::GetAssocSegBeg ( unsigned int  i  ) 

Definition at line 388 of file TrackSegmentCamAtNu.cxx.

References fBegAssociatedSegList.

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

TrackSegmentCamAtNu * TrackSegmentCamAtNu::GetAssocSegEnd ( unsigned int  i  ) 

Definition at line 397 of file TrackSegmentCamAtNu.cxx.

References fEndAssociatedSegList.

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

double TrackSegmentCamAtNu::GetBegDir (  ) 

Definition at line 285 of file TrackSegmentCamAtNu.cxx.

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

Referenced by 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   HitCamAtNu* 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   if((swx*swx-sw*swx2)!=0) {return (swx*swy-sw*swyx)/(swx*swx-sw*swx2);}
00313   else return 0;
00314 }

int TrackSegmentCamAtNu::GetBegPlane (  )  const

Definition at line 111 of file TrackSegmentCamAtNu.cxx.

References fBegPlane.

Referenced by GetScore(), and IsAssoc().

00112 {
00113   return fBegPlane;
00114 }

double TrackSegmentCamAtNu::GetBegTime (  )  const [inline]

Definition at line 85 of file TrackSegmentCamAtNu.h.

References fBegTime.

00085 { return fBegTime; };

double TrackSegmentCamAtNu::GetBegTPos (  ) 

Definition at line 219 of file TrackSegmentCamAtNu.cxx.

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

Referenced by GetScore(), and IsAssoc().

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   HitCamAtNu* 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 TrackSegmentCamAtNu::GetBegZPos (  )  const

Definition at line 354 of file TrackSegmentCamAtNu.cxx.

References fBegVtxZ.

Referenced by IsAssoc().

00355 {
00356   return fBegVtxZ;
00357 }

ClusterCamAtNu * TrackSegmentCamAtNu::GetCluster ( unsigned int  i  ) 

Definition at line 81 of file TrackSegmentCamAtNu.cxx.

References ClustersInSegment.

Referenced by AddSegment(), GetScore(), IsAssoc(), and AlgAtmosShowerList::MatchShowers().

00082 {
00083   if(i<ClustersInSegment.size()) {return ClustersInSegment[i];}
00084   
00085   else {return 0;}
00086 }

double TrackSegmentCamAtNu::GetEndDir (  ) 

Definition at line 319 of file TrackSegmentCamAtNu.cxx.

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

Referenced by IsAssoc().

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

int TrackSegmentCamAtNu::GetEndPlane (  )  const

Definition at line 119 of file TrackSegmentCamAtNu.cxx.

References fEndPlane.

Referenced by GetScore(), and IsAssoc().

00120 {
00121   return fEndPlane;
00122 }

double TrackSegmentCamAtNu::GetEndTime (  )  const [inline]

Definition at line 86 of file TrackSegmentCamAtNu.h.

References fEndTime.

00086 { return fEndTime; };

double TrackSegmentCamAtNu::GetEndTPos (  ) 

Definition at line 252 of file TrackSegmentCamAtNu.cxx.

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

Referenced by GetScore(), and IsAssoc().

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   HitCamAtNu* 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 TrackSegmentCamAtNu::GetEndZPos (  )  const

Definition at line 362 of file TrackSegmentCamAtNu.cxx.

References fEndVtxZ.

Referenced by IsAssoc().

00363 {
00364   return fEndVtxZ;
00365 }

unsigned int TrackSegmentCamAtNu::GetEntries (  )  const

Definition at line 103 of file TrackSegmentCamAtNu.cxx.

References ClustersInSegment.

Referenced by AddSegment(), GetBegDir(), GetBegTPos(), GetEndDir(), GetEndTPos(), GetScore(), IsAssoc(), and AlgAtmosShowerList::MatchShowers().

00104 {
00105   return ClustersInSegment.size();
00106 }

TrackSegmentCamAtNu * TrackSegmentCamAtNu::GetMatchSegBeg ( unsigned int  i  ) 

Definition at line 460 of file TrackSegmentCamAtNu.cxx.

References fBegMatchedSegList.

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

TrackSegmentCamAtNu * TrackSegmentCamAtNu::GetMatchSegEnd ( unsigned int  i  ) 

Definition at line 469 of file TrackSegmentCamAtNu.cxx.

References fEndMatchedSegList.

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

unsigned int TrackSegmentCamAtNu::GetNAssocSegBeg (  )  const [inline]

Definition at line 48 of file TrackSegmentCamAtNu.h.

References fBegAssociatedSegList.

00048 {return fBegAssociatedSegList.size();};  

unsigned int TrackSegmentCamAtNu::GetNAssocSegEnd (  )  const [inline]

Definition at line 49 of file TrackSegmentCamAtNu.h.

References fEndAssociatedSegList.

00049 {return fEndAssociatedSegList.size();};  

unsigned int TrackSegmentCamAtNu::GetNMatchSegBeg (  )  const [inline]

Definition at line 64 of file TrackSegmentCamAtNu.h.

References fBegMatchedSegList.

00064 {return fBegMatchedSegList.size();};

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

Definition at line 65 of file TrackSegmentCamAtNu.h.

References fEndMatchedSegList.

00065 {return fEndMatchedSegList.size();};

int TrackSegmentCamAtNu::GetNPlanes (  )  const [inline]

Definition at line 81 of file TrackSegmentCamAtNu.h.

References fNPlanes.

00081 { return fNPlanes; };

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

Definition at line 56 of file TrackSegmentCamAtNu.h.

References fBegPreferredSegList.

00056 {return fBegPreferredSegList.size();};

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

Definition at line 57 of file TrackSegmentCamAtNu.h.

References fEndPreferredSegList.

00057 {return fEndPreferredSegList.size();};

TrackSegmentCamAtNu* TrackSegmentCamAtNu::GetPartner (  )  [inline]

Definition at line 89 of file TrackSegmentCamAtNu.h.

References fPartner.

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

int TrackSegmentCamAtNu::GetPlaneView (  )  const

Definition at line 478 of file TrackSegmentCamAtNu.cxx.

References fPlaneView.

00479 {
00480   return fPlaneView;
00481 }

TrackSegmentCamAtNu * TrackSegmentCamAtNu::GetPrefSegBeg ( unsigned int  i  ) 

Definition at line 424 of file TrackSegmentCamAtNu.cxx.

References fBegPreferredSegList.

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

TrackSegmentCamAtNu * TrackSegmentCamAtNu::GetPrefSegEnd ( unsigned int  i  ) 

Definition at line 433 of file TrackSegmentCamAtNu.cxx.

References fEndPreferredSegList.

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

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

Definition at line 486 of file TrackSegmentCamAtNu.cxx.

References MuELoss::e, GetBegPlane(), GetBegTPos(), HitCamAtNu::GetCharge(), GetCluster(), GetEndPlane(), GetEndTPos(), GetEntries(), ClusterCamAtNu::GetEntries(), ClusterCamAtNu::GetHit(), ClusterCamAtNu::GetPlane(), HitCamAtNu::GetTPos(), HitCamAtNu::GetZPos(), Munits::km, Msg::kVerbose, Munits::m, MSG, and MinosMaterial::Z().

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

TrackSegmentCamAtNu* TrackSegmentCamAtNu::GetSeedSegment (  )  [inline]

Definition at line 78 of file TrackSegmentCamAtNu.h.

References fSeedSegment.

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

int TrackSegmentCamAtNu::GetTmpTrkFlag (  )  const [inline]

Definition at line 69 of file TrackSegmentCamAtNu.h.

References fTmpTrkFlag.

00069 { return fTmpTrkFlag; };

int TrackSegmentCamAtNu::GetTrkFlag (  )  const [inline]

Definition at line 75 of file TrackSegmentCamAtNu.h.

References fTrkFlag.

00075 { return fTrkFlag; };

int TrackSegmentCamAtNu::GetUID (  )  const [inline]

Definition at line 72 of file TrackSegmentCamAtNu.h.

References fUID.

00072 { return fUID; };

bool TrackSegmentCamAtNu::IsAssoc ( TrackSegmentCamAtNu segment  ) 

Definition at line 127 of file TrackSegmentCamAtNu.cxx.

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

00128 {
00129   unsigned int i;
00130   bool assoc=false;
00131   bool flag=false; 
00132   TrackSegmentCamAtNu* Seg1 = this;
00133   TrackSegmentCamAtNu* 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       ClusterCamAtNu* 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           ClusterCamAtNu* 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       ClusterCamAtNu* 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     ClusterCamAtNu* clrb = Seg2->GetCluster(idb); ClusterCamAtNu* 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       ClusterCamAtNu* 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     ClusterCamAtNu* clre = Seg1->GetCluster(ide); ClusterCamAtNu* 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 TrackSegmentCamAtNu::SetNPlanes ( int  nplanes  )  [inline]

Definition at line 80 of file TrackSegmentCamAtNu.h.

References fNPlanes.

00080 { fNPlanes=nplanes; };

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

Definition at line 88 of file TrackSegmentCamAtNu.h.

References fPartner.

00088 {fPartner = segment;};

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

Definition at line 77 of file TrackSegmentCamAtNu.h.

References fSeedSegment.

00077 {fSeedSegment = segment;};

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

Definition at line 68 of file TrackSegmentCamAtNu.h.

References fTmpTrkFlag.

00068 { fTmpTrkFlag=flag; };

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

Definition at line 74 of file TrackSegmentCamAtNu.h.

References fTrkFlag.

00074 { fTrkFlag=flag; };

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

Definition at line 71 of file TrackSegmentCamAtNu.h.

References fUID.

00071 { fUID=uid; };


Member Data Documentation

Definition at line 106 of file TrackSegmentCamAtNu.h.

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

Definition at line 114 of file TrackSegmentCamAtNu.h.

Referenced by AddCluster(), and GetBegTime().

Definition at line 108 of file TrackSegmentCamAtNu.h.

Referenced by AddCluster(), and GetBegZPos().

Definition at line 107 of file TrackSegmentCamAtNu.h.

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

Definition at line 115 of file TrackSegmentCamAtNu.h.

Referenced by AddCluster(), and GetEndTime().

Definition at line 109 of file TrackSegmentCamAtNu.h.

Referenced by AddCluster(), and GetEndZPos().

Definition at line 113 of file TrackSegmentCamAtNu.h.

Referenced by GetNPlanes(), and SetNPlanes().

Definition at line 103 of file TrackSegmentCamAtNu.h.

Referenced by GetPartner(), and SetPartner().

Definition at line 112 of file TrackSegmentCamAtNu.h.

Referenced by GetPlaneView().

Definition at line 101 of file TrackSegmentCamAtNu.h.

Referenced by GetSeedSegment(), and SetSeedSegment().

Definition at line 111 of file TrackSegmentCamAtNu.h.

Referenced by GetTmpTrkFlag(), and SetTmpTrkFlag().

Definition at line 110 of file TrackSegmentCamAtNu.h.

Referenced by GetTrkFlag(), and SetTrkFlag().

Definition at line 105 of file TrackSegmentCamAtNu.h.

Referenced by GetUID(), and SetUID().

const double TrackSegmentCamAtNu::StripWidth [private]

Definition at line 116 of file TrackSegmentCamAtNu.h.

Referenced by IsAssoc().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1