Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

TMuiRoadOGroup Class Reference

To Group roads by checking their hit sharing, projection at station 3 road direction, etc and then mark the "golden" road in a group. More...

#include <TMuiRoadOGroup.h>

List of all members.

Public Methods

 TMuiRoadOGroup (const short &arm, const float &z, const float &MutrWin, const float &MuidWin)
 Constructor. More...

 TMuiRoadOGroup (const TMuiRoadOGroup &source)
 Copy constructor. More...

 ~TMuiRoadOGroup ()
 Destructor. More...

void SetGroup (const short &Group)
 set the group index for this road. More...

void AttachRoad (TMuiRoadMapO::pointer road)
 Attach the given road to this group. More...

void MergeGroup (TMuiRoadOGroup *sourceGroup)
 Merge roads from another group to this group. More...

void RemoveRoad (TMuiRoadMapO::pointer road)
 Remove the given road from this group. More...

void TMuiRoadOGroup::Clear ()
size_t GoldenIndex () const
 Get the road index for "Golden" road in this group. More...

short Group () const
 unique index of of this group. More...

short TotalRoads () const
 How many roads in all does this group contain? More...

TMuiRoadMapO::pointer Road (int roadIndex) const
 Pointer to the Nth road of this group. More...

bool IsGroup (TMuiRoadMapO::pointer road)
 Does the road belong to this group. More...

PHPoint ProjectToZ (TMutFitPar fit_par, double ZPlane)
 Project a TMutFitPar object to the the specified ZPlane. More...


Public Attributes

vector< TMuiRoadMapO::pointer > f_pRoads

Private Methods

void MarkGolden ()
 Mark the "Golden" road in this group. More...


Private Attributes

float fZPlane
float fMutrWin
float fMuidWin
short fGroup
size_t fGoldenIndex
float fChi2DOF
short fArm
short fTotalRoads


Detailed Description

To Group roads by checking their hit sharing, projection at station 3 road direction, etc and then mark the "golden" road in a group.

Author:
Jason Newby \URL{mailto:rjnewby@utk.edu}

Definition at line 19 of file TMuiRoadOGroup.h.


Constructor & Destructor Documentation

TMuiRoadOGroup const short &    arm,
const float &    z,
const float &    MutrWin,
const float &    MuidWin
 

Constructor.

Definition at line 17 of file TMuiRoadOGroup.cxx.

00019   : fZPlane(z),fMutrWin(MutrWin),fMuidWin(MuidWin),
00020     fGroup(-1),fGoldenIndex(0),fChi2DOF(100000.0),
00021     fArm(arm),fTotalRoads(0),f_pRoads(0)
00022 {}

TMuiRoadOGroup const TMuiRoadOGroup &    source
 

Copy constructor.

Definition at line 25 of file TMuiRoadOGroup.cxx.

00026   : fZPlane(source.fZPlane),fMutrWin(source.fMutrWin),
00027     fMuidWin(source.fMuidWin),
00028     fGroup(source.fGroup),fGoldenIndex(source.fGoldenIndex),
00029     fChi2DOF(source.fChi2DOF),fArm(source.fArm), 
00030     fTotalRoads(source.fTotalRoads),f_pRoads(source.f_pRoads)
00031 {}

~TMuiRoadOGroup  
 

Destructor.

Definition at line 34 of file TMuiRoadOGroup.cxx.

00034 {}


Member Function Documentation

void AttachRoad TMuiRoadMapO::pointer    road
 

Attach the given road to this group.

Definition at line 75 of file TMuiRoadOGroup.cxx.

References f_pRoads, and fTotalRoads.

Referenced by mMuiRoadFinder1::flag_golden, and MergeGroup.

00076 {
00077   // Attach the road to the group.
00078   f_pRoads.push_back(road);
00079   fTotalRoads = f_pRoads.size();
00080 }

size_t GoldenIndex   const
 

Get the road index for "Golden" road in this group.

Definition at line 57 of file TMuiRoadOGroup.cxx.

References fGoldenIndex.

00058 {
00059   return fGoldenIndex;
00060 }

short Group   const
 

unique index of of this group.

Definition at line 65 of file TMuiRoadOGroup.cxx.

References fGroup.

Referenced by SetGroup.

00066 {
00067   return fGroup;
00068 }

bool IsGroup TMuiRoadMapO::pointer    road
 

Does the road belong to this group.

Definition at line 220 of file TMuiRoadOGroup.cxx.

References f_pRoads, fArm, fMutrWin, fZPlane, and ProjectToZ.

00221 {
00222   vector<TMuiRoadMapO::pointer>::iterator i;
00223   short arm = road->get()->get_arm();
00224 
00225   // Is the given road in the same arm as the group?
00226   if ( arm != fArm  ) {
00227     return false;
00228   }
00229 
00230   //
00231   if(f_pRoads.size()>=1500)
00232   {
00233     return false;
00234   }
00235     
00236   // Grouping roads with following criteria:
00237   // 1. Project roads to MuTR Station 3, if they are in a certain window
00238   // 2. If pass 1, if all associated hits are in a certain window in each gap
00239     
00240   // compare the given road with each road within this group
00241   bool St3IsGroup = false;
00242   PHPoint roadX = ProjectToZ(road->get()->get_fit_par(),fZPlane);
00243   for (i = f_pRoads.begin(); i != f_pRoads.end(); i++) {
00244     // Does the road already exist in the group?
00245     if( (*i)->get()->get_key() == road->get()->get_key() ){
00246       return false;
00247     }
00248     PHPoint iX = ProjectToZ((*i)->get()->get_fit_par(),fZPlane);
00249     if ( (fabs(iX.getX()- roadX.getX()) < fMutrWin) && (fabs(iX.getY()- roadX.getY()) < fMutrWin)){
00250       St3IsGroup=true;
00251       break;
00252     }
00253   } 
00254   if(St3IsGroup == false)
00255   {
00256     return false;
00257   }
00258   // check associated clusters in each MuID gap
00259   int MatchingVHits = 0;
00260   int MatchingHHits = 0;
00261   int MinMatchHits = 1;
00262 
00263   for (i = f_pRoads.begin(); i != f_pRoads.end(); i++)
00264   {
00265     //Loop over clusters and check for matches within window
00266     TMuiClusterMapO::const_key_iterator iclust1
00267       =road->get()->get_associated<TMuiClusterO>();
00268     TMuiClusterMapO::const_key_iterator iclust2
00269       =(*i)->get()->get_associated<TMuiClusterO>();
00270 
00271     while(TMuiClusterMapO::const_pointer clust1 = iclust1.next())
00272     {
00273       iclust2 = (*i)->get()->get_associated<TMuiClusterO>();
00274       while(TMuiClusterMapO::const_pointer clust2 = iclust2.next())
00275       {
00276         if(clust1->get()->get_key()==clust2->get()->get_key())
00277         {
00278           if(clust1->get()->get_orientation()==0)
00279           {
00280             MatchingHHits++;
00281           }else{
00282             MatchingVHits++;
00283           }
00284         }
00285       }
00286     }
00287     
00288     
00289   }
00290 
00291   if(MatchingVHits>=MinMatchHits && MatchingHHits>=MinMatchHits && St3IsGroup)
00292   {
00293     return true;
00294   }
00295 
00296   return false;
00297 
00298 }

void MarkGolden   [private]
 

Mark the "Golden" road in this group.

Definition at line 136 of file TMuiRoadOGroup.cxx.

References f_pRoads, fZPlane, and ProjectToZ.

Referenced by SetGroup.

00137 {
00138   // Mark the "golden" road in the group.
00139   // Lets sort the roads by their projections to station 3 of the MuTr
00140   // and choose the median.  We may want to weight by Chi2.
00141   if(f_pRoads.size()>=1500)
00142   {
00143     cout<<"Road Group reached maximum entries: 1500\n";
00144     return;
00145   }
00146   double st3x, st3y;
00147   double st3xlist[1500];
00148   double st3ylist[1500];
00149   double Rst3xlist[1500];
00150   double Rst3ylist[1500];
00151   TMuiRoadMapO::pointer Rlist[1500];
00152   int xycount=0;
00153 
00154   short Golden = 0;
00155   vector<TMuiRoadMapO::pointer>::iterator i;
00156   TMuiRoadMapO::pointer road = NULL;
00157   PHPoint st3p;
00158   for (i=f_pRoads.begin(); i != f_pRoads.end(); i++){
00159     road=(*i);
00160     st3p = ProjectToZ(road->get()->get_fit_par(),fZPlane);
00161     st3xlist[xycount] = st3p.getX();
00162     st3ylist[xycount] = st3p.getY();
00163     Rst3xlist[xycount] = st3p.getX();
00164     Rst3ylist[xycount] = st3p.getY();
00165     Rlist[xycount] = road;
00166     xycount++;
00167   }
00168   // Now lets calculate the median
00169   gsl_sort(st3xlist,1,xycount);
00170   gsl_sort(st3ylist,1,xycount);
00171   st3x = gsl_stats_median_from_sorted_data(st3xlist,1,xycount);
00172   st3y = gsl_stats_median_from_sorted_data(st3ylist,1,xycount);
00173   // Lets find the road the minimum distance from this
00174   double MinDist = 1E10;
00175   double ThisDist = 0.0;
00176   int med_id = 0;
00177   for (int rid = 0; rid < xycount; rid++)
00178   { 
00179     ThisDist = sqrt((st3x-Rst3xlist[rid])*(st3x-Rst3xlist[rid])+(st3y-Rst3ylist[rid])*(st3y-Rst3ylist[rid]));
00180     if(ThisDist < MinDist)
00181     {
00182       MinDist = ThisDist;
00183       road = Rlist[rid];
00184       med_id = rid;
00185     }
00186   }
00187   //Now lets set this road as golden
00188   for (i=f_pRoads.begin(); i != f_pRoads.end(); i++){
00189     if( (*i) == road){
00190       Golden = 1;
00191       (*i)->get()->set_golden(Golden);
00192     }else{
00193       (*i)->get()->set_golden(0);
00194     }
00195   }
00196 }

void MergeGroup TMuiRoadOGroup *    sourceGroup
 

Merge roads from another group to this group.

Definition at line 85 of file TMuiRoadOGroup.cxx.

References AttachRoad, Road, and TotalRoads.

Referenced by mMuiRoadFinder1::flag_golden.

00086 {
00087   if(sourceGroup==NULL)
00088   {
00089     return;
00090   }
00091   int roadIndex = 0;
00092   while(roadIndex < sourceGroup->TotalRoads())
00093   {
00094     AttachRoad(sourceGroup->Road(roadIndex));
00095     roadIndex++;
00096   }
00097 }

PHPoint ProjectToZ TMutFitPar    fit_par,
double    ZPlane
 

Project a TMutFitPar object to the the specified ZPlane.

Definition at line 207 of file TMuiRoadOGroup.cxx.

References fZPlane.

Referenced by IsGroup, and MarkGolden.

00208 {
00209   PHPoint z_intersect;
00210   PHGeometry::intersectionLinePlane(
00211                         PHLine(fit_par.get_point(),fit_par.get_tangent()),
00212                         PHPlane(PHPoint(0,0,fZPlane),PHVector(0,0,1)),
00213                         z_intersect
00214                         );
00215   return z_intersect;
00216 }

void RemoveRoad TMuiRoadMapO::pointer    road
 

Remove the given road from this group.

Definition at line 120 of file TMuiRoadOGroup.cxx.

References f_pRoads, and fTotalRoads.

00121 {
00122   // Remove the road from the group.
00123   vector<TMuiRoadMapO::pointer>::iterator i;
00124   for (i=f_pRoads.begin(); i != f_pRoads.end(); i++){
00125     if((*i) == road){
00126       f_pRoads.erase(i);
00127       break;
00128     }
00129   }
00130   fTotalRoads = f_pRoads.size();
00131 }

TMuiRoadMapO::pointer Road int    roadIndex const
 

Pointer to the Nth road of this group.

Definition at line 101 of file TMuiRoadOGroup.cxx.

References f_pRoads.

Referenced by MergeGroup.

00102 {
00103   if((unsigned int)roadIndex < f_pRoads.size())
00104   {
00105     return f_pRoads[roadIndex];
00106   }
00107   return NULL;
00108 }

void SetGroup const short &    Group
 

set the group index for this road.

Definition at line 41 of file TMuiRoadOGroup.cxx.

References f_pRoads, fGroup, Group, and MarkGolden.

Referenced by mMuiRoadFinder1::flag_golden.

00042 {
00043   if (Group < 0) {
00044    return;
00045   }
00046   fGroup = Group;
00047   vector<TMuiRoadMapO::pointer>::iterator i;
00048   for (i=f_pRoads.begin(); i != f_pRoads.end(); i++){
00049     (*i)->get()->set_group(fGroup);
00050   }
00051   MarkGolden();
00052 }

void TMuiRoadOGroup::Clear  
 

short TotalRoads   const
 

How many roads in all does this group contain?

Definition at line 203 of file TMuiRoadOGroup.cxx.

References fTotalRoads.

Referenced by MergeGroup.

00203 {return fTotalRoads;}


Member Data Documentation

vector<TMuiRoadMapO::pointer> f_pRoads
 

Definition at line 88 of file TMuiRoadOGroup.h.

Referenced by AttachRoad, IsGroup, MarkGolden, RemoveRoad, Road, and SetGroup.

short fArm [private]
 

Definition at line 85 of file TMuiRoadOGroup.h.

Referenced by IsGroup.

float fChi2DOF [private]
 

Definition at line 84 of file TMuiRoadOGroup.h.

size_t fGoldenIndex [private]
 

Definition at line 83 of file TMuiRoadOGroup.h.

Referenced by GoldenIndex.

short fGroup [private]
 

Definition at line 82 of file TMuiRoadOGroup.h.

Referenced by Group, and SetGroup.

float fMuidWin [private]
 

Definition at line 80 of file TMuiRoadOGroup.h.

float fMutrWin [private]
 

Definition at line 79 of file TMuiRoadOGroup.h.

Referenced by IsGroup.

short fTotalRoads [private]
 

Definition at line 86 of file TMuiRoadOGroup.h.

Referenced by AttachRoad, RemoveRoad, and TotalRoads.

float fZPlane [private]
 

Definition at line 78 of file TMuiRoadOGroup.h.

Referenced by IsGroup, MarkGolden, and ProjectToZ.


The documentation for this class was generated from the following files:
MUIOO: PHENIX Muon Identifier Analysis Framework. Documentation by doxygen
Last modified: