#include <TMuiRoadFinder.h>
| Public Types | |
| typedef std::set< TMuiClusterMapO::value_type, cluster_less_ftor > | cluster_list | 
| typedef std::vector< PHPoint > | point_list | 
| Public Methods | |
| Road (TMuiRoadFinder *finder, const TMuiClusterMapO::pointer cluster_ptr, bool use_window, const road_window &theta_window, const road_window &phi_window) | |
| Road (TMuiRoadFinder *finder, const TMuiClusterMapO::pointer cluster_ptr) | |
| const TMutFitPar & | get_fit_par () const | 
| size_t | get_n_cluster () const | 
| size_t | get_n_point () const | 
| bool | add_cluster (TMuiClusterMapO::pointer cluster_ptr) | 
| bool | bifurcate (TMuiClusterMapO::pointer cluster_ptr) | 
| UShort_t | get_arm () const | 
| cluster_list & | get_cluster_list () | 
| point_list & | get_point_list () | 
| road_window | get_theta_window () const | 
| road_window | get_phi_window () const | 
| double | get_r_at_z (double z) const | 
| double | get_theta () const | 
| double | get_phi () const | 
| bool | is_complete () const | 
| void | set_complete (bool complete) | 
| bool | get_status () const | 
| void | set_status (bool status) | 
| bool | check_theta_window (const road_window &theta_window) const | 
| bool | check_phi_window (const road_window &theta_window) const | 
| void | print () const | 
| Static Public Methods | |
| void | set_dca_cut (double dca_cut) | 
| void | set_prox_cut (double prox_cut) | 
| void | set_orient_z_dist (double orient_z_dist) | 
| void | set_tube_width (double tube_width) | 
| void | set_verbose (bool verbose) | 
| void | initialize_evaluation () | 
| void | finish_evaluation () | 
| Private Methods | |
| PHPoint | make_point (const TMuiClusterMapO::pointer) const | 
| void | update_road (TMuiClusterMapO::pointer) | 
| void | update_road (TMuiClusterMapO::pointer, const PHPoint &point) | 
| bool | test_window (const PHPoint &) const | 
| bool | check_parallel (const TMuiClusterMapO::pointer) const | 
| PHPoint | project (double z) const | 
| bool | check_proximity (TMuiClusterMapO::pointer cluster_ptr) const | 
| bool | check_dca (const TMuiClusterMapO::pointer cluster_ptr, const PHPoint &) const | 
| bool | check_slope () const | 
| bool | unique_check (TMuiClusterMapO::pointer cluster_ptr) const | 
| bool | has_window () const | 
| Private Attributes | |
| TMuiRoadFinder * | _finder | 
| UShort_t | _arm | 
| road_window | _theta_window | 
| road_window | _phi_window | 
| bool | _has_window | 
| bool | _complete | 
| bool | _status | 
| cluster_list | _clusters | 
| point_list | _points | 
| TMutFitPar | _fit_par | 
| Static Private Attributes | |
| double | _dca_cut = 4.0 | 
| double | _prox_cut = 4.0 | 
| bool | _use_slope_cuts = false | 
| double | _orient_z_dist = 2.0 | 
| double | _tube_width = 8.35 | 
| bool | _verbose = false | 
| bool | _evaluation = false | 
| TFile * | _file = 0 | 
| TNtuple * | _ntuple = 0 | 
| boost::array< float, 20 > | _eval_data | 
Definition at line 180 of file TMuiRoadFinder.h.
| 
 | 
| 
 Definition at line 199 of file TMuiRoadFinder.h. Referenced by TMuiRoadFinder::evaluate, and get_cluster_list. | 
| 
 | 
| 
 Definition at line 200 of file TMuiRoadFinder.h. Referenced by get_point_list. | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 202 of file TMuiRoadFinder.h. References _arm, _clusters, _complete, _finder, _has_window, _phi_window, _status, _theta_window, and get_arm. 
 00206 : 00207 _finder(finder), 00208 _arm(cluster_ptr->get()->get_arm()), 00209 _theta_window(theta_window), 00210 _phi_window(phi_window), 00211 _has_window(use_window), 00212 _complete(false), 00213 _status(true) 00214 { 00215 _clusters.insert(*cluster_ptr); 00216 } | 
| 
 | ||||||||||||
| 
 Definition at line 218 of file TMuiRoadFinder.h. References _arm, _clusters, _complete, _finder, _has_window, _phi_window, _status, _theta_window, and get_arm. 
 00218 : 00219 _finder(finder), 00220 _arm(cluster_ptr->get()->get_arm()), 00221 _theta_window(std::make_pair(0,0)), 00222 _phi_window(std::make_pair(0,0)), 00223 _has_window(false), 00224 _complete(false), 00225 _status(true) 00226 { 00227 _clusters.insert(*cluster_ptr); 00228 } | 
| 
 | 
| 
 Definition at line 275 of file TMuiRoadFinder.cxx. References _arm, _clusters, _eval_data, _ntuple, _points, bifurcate, check_dca, check_parallel, check_proximity, check_slope, has_window, make_point, project, test_window, unique_check, and update_road. Referenced by bifurcate. 
 00276 {
00277   bool was_added=false;
00278   if(_evaluation) _eval_data.assign(0);
00279 
00280   // If road has a cluster in this plane and orientation and has a least 2 clusters 
00281   // already then call bifurcate
00282   //
00283   if(!unique_check(cluster_ptr)) {
00284     if(_clusters.size()>1) {
00285       was_added = bifurcate(cluster_ptr);
00286       return was_added;
00287     } else {
00288       return false; // too small to add to
00289     }
00290   } 
00291   
00292   // If we made it until here, it means that this cluster is the first in this plane 
00293   // and orientation and could add to our information on the road (if it fits in)
00294 
00295   // if Road has point [
00296   //  project point to z of cluster
00297   //  test theta, phi window of projected point
00298   //  test projected point - cluster DCA
00299   //  if added update road parameters
00300   // ] else [ 
00301   //  if can make point with this cluster [
00302   //    test theta, phi window of point
00303   //    if added update road parameters
00304   //  ] else [
00305   //    test proximity of cluster with existing cluster
00306   //  ]
00307   // ]  
00308   
00309   if(_points.size() != 0){
00310 
00311     PHPoint point = project(cluster_ptr->get()->get_centroidpos().getZ());
00312     if(test_window(point) && 
00313        check_dca(cluster_ptr,point) &&
00314        check_proximity(cluster_ptr)){
00315       update_road(cluster_ptr);
00316       was_added = true;
00317     }
00318     
00319   } 
00320   else {
00321     // Check if this cluster is parallel to existing cluster
00322     //
00323     if(!check_parallel(cluster_ptr)) {
00324       // Not parallel (and the right panel/plane) so it will intersect
00325       // with an existing cluster in this road - update&add
00326       if (has_window()) {
00327         PHPoint point = make_point(cluster_ptr);
00328         // If point is in window then add coord and point to stub
00329         //
00330         if(test_window(point)){
00331           update_road(cluster_ptr);
00332           was_added = true;
00333         }
00334       }
00335       else {
00336         update_road(cluster_ptr);
00337         was_added = true;
00338       } 
00339     }
00340     else {
00341       // Prior and current cluster are parallel, check proximity and add
00342       // cluster to road if proximity cut is satisfied.
00343       //
00344       if (check_proximity(cluster_ptr)) {
00345         update_road(cluster_ptr);
00346         was_added = true;
00347       }
00348     }
00349   }  
00350 
00351   if(_clusters.size() >= 3){
00352     check_slope();
00353   }
00354   if(_evaluation) {
00355     _eval_data[0] = _arm;
00356     _eval_data[1] = cluster_ptr->get()->get_plane();
00357     _eval_data[2] = cluster_ptr->get()->get_panel();
00358     _eval_data[3] = cluster_ptr->get()->get_orientation();
00359     _eval_data[4] = _clusters.size(); 
00360     _eval_data[5] = was_added ? 1 : 0; 
00361     _ntuple->Fill(&(_eval_data[0]));
00362   }
00363   return was_added;
00364 }
 | 
| 
 | 
| 
 Definition at line 463 of file TMuiRoadFinder.cxx. References _clusters, _finder, _has_window, _phi_window, TMuiRoadFinder::_road_list, _theta_window, TMuiRoadFinder::abort_new_road, add_cluster, TMuiRoadFinder::start_new_road, and update_road. Referenced by add_cluster. 
 00464 {
00465   // Sanity check
00466   //
00467   if(_finder->_road_list.size() > 500) {
00468     throw std::runtime_error(DESCRIPTION("bifurcate: too many roads"));
00469   }
00470 
00471   // New road pointer with null initialization
00472   //
00473   TMuiRoadFinder::Road* new_road_ptr = 0;
00474   
00475   // Loop over cluster list; copy clusters from old road that are not in the 
00476   // same plane as cluster_ptr
00477   //
00478   cluster_list::iterator cluster_iter = _clusters.begin();
00479   for(;cluster_iter!=_clusters.end();++cluster_iter){
00480     if(cluster_ptr->get()->get_plane() != cluster_iter->get()->get_plane()) {      
00481       // Old cluster
00482       //
00483       TMuiClusterMapO::value_type old_cluster = *cluster_iter;
00484 
00485       // First time start the new road -- subsequent times update road with old cluster
00486       //
00487       if(!new_road_ptr) {
00488         new_road_ptr = _finder->start_new_road(&old_cluster, _has_window, _theta_window, _phi_window);
00489       } else {
00490         new_road_ptr->update_road(&old_cluster);
00491       }
00492     }
00493   }
00494 
00495   // If cluster_ptr is the first then return here
00496   //
00497   if(!new_road_ptr) {
00498     _finder->start_new_road(cluster_ptr, _has_window, _theta_window, _phi_window);
00499     return true;
00500   }
00501   
00502   // Now we have a road that is guarenteed *not* to have a cluster in the same plane
00503   // as cluster_ptr.  Here we invoke a fancy (obtuse) piece of recursion by calling
00504   // add_cluster using the new road pointer. This will ensure that exactly the same
00505   // criteria is applied for adding clusters to roads in both the original and
00506   // new (bifurcated) road.
00507   //
00508   bool was_added = new_road_ptr->add_cluster(cluster_ptr);
00509   if(was_added) {
00510     return true;
00511   } else {
00512     _finder->abort_new_road();
00513     return false;
00514   }
00515 }
 | 
| 
 | ||||||||||||
| 
 Definition at line 433 of file TMuiRoadFinder.cxx. Referenced by add_cluster. 
 00435 {
00436   // get the line info for the cluster
00437   PHLine line = cluster_ptr->get()->get_coord();
00438   double distance = PHGeometry::distanceLinePoint(line, point);
00439   // normalize distance to something 
00440   // width is from the narrow dimension of the tube
00441   if (_tube_width > 0) distance /= _tube_width; 
00442   else return false;
00443        
00444   if(_evaluation) {
00445     _eval_data[8] = distance; 
00446   }
00447  
00448   if(distance < _dca_cut) {
00449     // since the line distance calculation assumes an infinite line, 
00450     // it is possible to get an acceptable distance even when the line is
00451     // offset from the point. Use centroidpos, which should not be more
00452     // than half the length away from any point, for this
00453     double projdist = PHGeometry::distancePointToPoint(cluster_ptr->get()->get_centroidpos(), point);
00454     double halflength = 0.5*line.length();
00455     if (projdist < halflength) {
00456       return true;
00457     }
00458   }
00459   return false;
00460 }
 | 
| 
 | 
| 
 Definition at line 367 of file TMuiRoadFinder.cxx. References _clusters. Referenced by add_cluster. 
 00368 {  
00369   // Loop over clusters in road cluster list and check for non-parallel cluster
00370   // in the same plane, panel
00371   cluster_list::const_iterator cluster_iter = _clusters.begin();
00372   for(;cluster_iter!=_clusters.end();++cluster_iter){
00373     if ( (cluster_iter->get()->get_plane() == cluster_ptr->get()->get_plane()) && 
00374          (cluster_iter->get()->get_panel() == cluster_ptr->get()->get_panel()) && 
00375          (cluster_iter->get()->get_orientation() != cluster_ptr->get()->get_orientation()) ) {
00376       return false;
00377     }
00378   }
00379   return true;
00380 }
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 Definition at line 519 of file TMuiRoadFinder.cxx. References _clusters, _eval_data, _prox_cut, and _tube_width. Referenced by add_cluster. 
 00520 {
00521   // This method is called only when we don't have any points found yet, and
00522   // not any non-parallell clusters to this new one, in the same plane and panel.
00523   // If the new one is close enough, we'll add it to our cluster list.
00524   //
00525   // Idiot check
00526   //
00527   if(!_clusters.size()) throw std::logic_error(DESCRIPTION("attempted comparison with null entry"));
00528 
00529   PHPoint point1 = cluster_ptr->get()->get_centroidpos();
00530 
00531   // Loop over clusters in road cluster list and get the closest (in Z) parallel cluster
00532   double distance = DBL_MAX;
00533   cluster_list::const_iterator best_iter;
00534   cluster_list::const_iterator cluster_iter = _clusters.begin();
00535   for(;cluster_iter!=_clusters.end();++cluster_iter){
00536     if (cluster_iter->get()->get_orientation() == cluster_ptr->get()->get_orientation()) {
00537       PHPoint point2 = cluster_iter->get()->get_centroidpos();
00538       double thisdistance = std::fabs(point2.getZ() - point1.getZ());
00539       if (thisdistance < distance) {
00540         distance = thisdistance;
00541         best_iter = cluster_iter;
00542       }
00543     }
00544   }
00545 
00546   if (distance == DBL_MAX) { 
00547     // nothing found to compare with
00548     return false;
00549   }
00550 
00551   PHPoint point2 = best_iter->get()->get_centroidpos();
00552   point1.setZ(0);
00553   point2.setZ(0);
00554   distance = PHGeometry::distancePointToPoint(point1,point2);
00555 
00556   if (_tube_width > 0) distance /= _tube_width; 
00557   else return false;
00558 
00559   if(_evaluation) {
00560     _eval_data[9] = distance; 
00561   }
00562 
00563   if(distance < _prox_cut) {
00564     return true;
00565   }
00566   return false;
00567 }
 | 
| 
 | 
| 
 Definition at line 383 of file TMuiRoadFinder.cxx. Referenced by add_cluster. 
 00384 {
00385   return true;
00386 }
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 Definition at line 835 of file TMuiRoadFinder.cxx. References _evaluation, and _ntuple. 
 00836 {  
00837   if(_ntuple) delete _ntuple;
00838   _evaluation = false;
00839 }
 | 
| 
 | 
| 
 Definition at line 238 of file TMuiRoadFinder.h. References _arm. Referenced by Road. 
 00238 {return _arm;}
 | 
| 
 | 
| 
 Definition at line 242 of file TMuiRoadFinder.h. References _clusters, and cluster_list. 
 00242 { return _clusters; }
 | 
| 
 | 
| 
 Definition at line 230 of file TMuiRoadFinder.h. References _fit_par. 
 00230 {return _fit_par;}
 | 
| 
 | 
| 
 Definition at line 232 of file TMuiRoadFinder.h. References _clusters. 
 00232 {return _clusters.size();}    
 | 
| 
 | 
| 
 Definition at line 233 of file TMuiRoadFinder.h. References _points. 
 00233 {return _points.size();}    
 | 
| 
 | 
| 
 Definition at line 260 of file TMuiRoadFinder.h. References _fit_par. 
 | 
| 
 | 
| 
 Definition at line 245 of file TMuiRoadFinder.h. References _phi_window. 
 00245 { return _phi_window; }
 | 
| 
 | 
| 
 Definition at line 243 of file TMuiRoadFinder.h. References _points, and point_list. 
 00243 { return _points; }
 | 
| 
 | 
| 
 Definition at line 249 of file TMuiRoadFinder.h. References _fit_par, and MUIOO::SQUARE. 
 00249                                       {
00250       PHPoint p = TMutTrackUtil::linear_track_model(&_fit_par,z);
00251       return std::sqrt(MUIOO::SQUARE(p.getX()) + MUIOO::SQUARE(p.getY()));
00252     }
 | 
| 
 | 
| 
 Definition at line 286 of file TMuiRoadFinder.h. References _status. 
 00286 {return _status; }
 | 
| 
 | 
| 
 Definition at line 254 of file TMuiRoadFinder.h. References _fit_par, and MUIOO::SQUARE. 
 00254                              {
00255       double r = std::sqrt(MUIOO::SQUARE(_fit_par.get_x()) +
00256                            MUIOO::SQUARE(_fit_par.get_y()));
00257       return atan2(r,std::fabs(_fit_par.get_z()));
00258     }
 | 
| 
 | 
| 
 Definition at line 244 of file TMuiRoadFinder.h. References _theta_window. 
 00244 { return _theta_window; }
 | 
| 
 | 
| 
 Definition at line 344 of file TMuiRoadFinder.h. References _has_window. Referenced by add_cluster, and test_window. 
 00344 { return _has_window; }
 | 
| 
 | 
| 
 Definition at line 815 of file TMuiRoadFinder.cxx. References _evaluation, _file, _ntuple, and MUIOO::TRACE. 
 00816 { 
00817   if(_evaluation) return;
00818 
00819   _file = (TFile*)gROOT->GetListOfFiles()->FindObject("muioo_eval_ntuple.root");
00820   if (_file) {
00821     MUIOO::TRACE("TMuiRoadFinder::Road::initialize_evaluation, creating eval root file");
00822     _file = new TFile("muioo_eval_ntuple.root", "RECREATE");
00823   }
00824 
00825   // Fields for stub finder algorithm during add cluster stage
00826   //
00827   _ntuple = new TNtuple("road_cluster","road_cluster","arm:plane:panel:orientation:ncoord:added:phi_check:theta_check:dca_dist:prox_dist:x:y:z:phi1:phi2:theta1:theta2");
00828   cout << " TMuiRoadFinder::Road::initialize_evaluation() ntuple created" << endl; 
00829   
00830   _evaluation = true;
00831   
00832   return;
00833 }
 | 
| 
 | 
| 
 Definition at line 284 of file TMuiRoadFinder.h. References _complete. 
 00284 { return _complete; }
 | 
| 
 | 
| 
 Definition at line 738 of file TMuiRoadFinder.cxx. References _clusters, and _orient_z_dist. Referenced by add_cluster. 
 00739 {  
00740   // get the line info for the cluster
00741   PHLine line1 = cluster_ptr->get()->get_coord();
00742   // Loop over clusters in road cluster list and check for non-parallel cluster
00743   // in the same plane, panel
00744   cluster_list::const_iterator cluster_iter = _clusters.begin();
00745   for(;cluster_iter!=_clusters.end();++cluster_iter){
00746     if ( (cluster_iter->get()->get_plane() == cluster_ptr->get()->get_plane()) && 
00747          (cluster_iter->get()->get_panel() == cluster_ptr->get()->get_panel()) && 
00748          (cluster_iter->get()->get_orientation() != cluster_ptr->get()->get_orientation()) ) { 
00749       // there should only be one candidate in the list, so we should have it now
00750       PHLine line2 = cluster_iter->get()->get_coord();
00751       // check possible intersection of line1 and line2
00752       double distance = PHGeometry::distanceLineLine(line1, line2);
00753         
00754       if (distance <= _orient_z_dist) // we had an intersection
00755         {
00756           PHPoint point = PHGeometry::closestApproachLineLine(line1, line2);
00757           return point;
00758         }
00759     }
00760   }
00761   return PHPoint();
00762 }
 | 
| 
 | 
| 
 Definition at line 292 of file TMuiRoadFinder.h. References _clusters, and _points. 
 00292                        { 
00293       std::cout << "road: " ;
00294       // clusters
00295       cluster_list::const_iterator iter = _clusters.begin();
00296       std::cout << " nclusters " << _clusters.size() << std::endl;
00297       for(;iter!=_clusters.end();++iter){
00298         std::cout << " clusterkey " << iter->get()->get_key().get_obj_key() 
00299                   << std::endl;
00300         iter->get()->print();
00301       }
00302       // points
00303       point_list::const_iterator piter = _points.begin();
00304       std::cout << " npoints " << _points.size() << std::endl;
00305       for(;piter!=_points.end();++piter){
00306         std::cout << " point " << *piter
00307                   << std::endl;
00308         piter->print();
00309       }
00310       std::cout << std::endl;
00311     }
 | 
| 
 | 
| 
 Definition at line 732 of file TMuiRoadFinder.cxx. References _fit_par. Referenced by add_cluster. 
 00733 {
00734   return TMutTrackUtil::linear_track_model(&_fit_par,z);
00735 }
 | 
| 
 | 
| 
 Definition at line 285 of file TMuiRoadFinder.h. References _complete. 
 00285 { _complete = complete; }
 | 
| 
 | 
| 
 Definition at line 264 of file TMuiRoadFinder.h. References _dca_cut. 
 00264                                            {
00265       _dca_cut = dca_cut;
00266     }
 | 
| 
 | 
| 
 Definition at line 272 of file TMuiRoadFinder.h. References _orient_z_dist. 
 00272                                                         { 
00273       _orient_z_dist = orient_z_dist;
00274     }
 | 
| 
 | 
| 
 Definition at line 268 of file TMuiRoadFinder.h. References _prox_cut. 
 00268                                              {
00269       _prox_cut = prox_cut;
00270     }
 | 
| 
 | 
| 
 Definition at line 287 of file TMuiRoadFinder.h. References _status. 
 00287 {_status = status;}
 | 
| 
 | 
| 
 Definition at line 276 of file TMuiRoadFinder.h. References _tube_width. 
 00276                                                   { 
00277       _tube_width = tube_width;
00278     }
 | 
| 
 | 
| 
 Definition at line 280 of file TMuiRoadFinder.h. References _verbose. 
 00280                                          {
00281       _verbose = verbose;
00282     }
 | 
| 
 | 
| 
 Definition at line 389 of file TMuiRoadFinder.cxx. References _eval_data, _phi_window, _points, _theta_window, TMuiRoadFinder::check_phi_window, TMuiRoadFinder::check_theta_window, has_window, TMuiRoadFinder::IN_WINDOW, and TMuiRoadFinder::WindowEnum. Referenced by add_cluster. 
 00390 {
00391   // If there is no window defined for this road then  
00392   // we can say that the new cluster falls within the window..
00393   //
00394   if (!has_window()) {
00395     return true;
00396   }
00397   
00398   // If we haven't got any points, we don't have a well-defined/centered
00399   // window yet
00400   //
00401   if (_points.size() == 0) {
00402     return true;
00403   }
00404 
00405   TMuiRoadFinder::WindowEnum phi_check = 
00406     TMuiRoadFinder::check_phi_window(point,_phi_window);
00407 
00408   TMuiRoadFinder::WindowEnum theta_check = 
00409     TMuiRoadFinder::check_theta_window(point,_theta_window);
00410 
00411   if(_evaluation) {
00412     _eval_data[6] = phi_check; 
00413     _eval_data[7] = theta_check; 
00414     _eval_data[10] = point.getX(); 
00415     _eval_data[11] = point.getY();
00416     _eval_data[12] = point.getZ();  
00417     _eval_data[13] = _phi_window.first;  
00418     _eval_data[14] = _phi_window.second;  
00419     _eval_data[15] = _theta_window.first;  
00420     _eval_data[16] = _theta_window.second;  
00421   }
00422 
00423   if(phi_check == TMuiRoadFinder::IN_WINDOW && 
00424      theta_check == TMuiRoadFinder::IN_WINDOW) {
00425     return true;
00426   } 
00427   else {
00428     return false;
00429   }
00430 }
 | 
| 
 | 
| 
 Definition at line 765 of file TMuiRoadFinder.cxx. References _clusters. Referenced by add_cluster. 
 00766 {
00767   // Loop over clusters and punt if the road already has a cluster in
00768   // this plane and orientation. (no panel check here)
00769   //
00770   cluster_list::const_iterator cluster_iter = _clusters.begin();
00771   for(;cluster_iter!=_clusters.end();++cluster_iter){
00772     
00773    if(cluster_ptr->get()->get_plane() == cluster_iter->get()->get_plane() &&
00774       cluster_ptr->get()->get_orientation() == cluster_iter->get()->get_orientation()) {
00775      return false;
00776    }
00777   }
00778   return true;
00779 }
 | 
| 
 | ||||||||||||
| 
 | 
| 
 | 
| 
 Definition at line 570 of file TMuiRoadFinder.cxx. References _arm, _clusters, _fit_par, _orient_z_dist, _phi_window, _points, _status, and _theta_window. Referenced by add_cluster, and bifurcate. 
 00571 {
00572   // Push cluster onto cluster list
00573   //
00574   _clusters.insert(*cluster_ptr);
00575   
00576   // Regenerate points list with new cluster -- repetitive but
00577   // makes the code simple.
00578   //
00579   _points.clear();
00580 
00581   // Loop over all unique combinations of clusters in this road,
00582   // attempt to make points out of cluster that share a common
00583   // plane.
00584   cluster_list::const_iterator iter1 = _clusters.begin();
00585   for(;iter1!=_clusters.end();++iter1){
00586 
00587     PHLine line1 = iter1->get()->get_coord();
00588     cluster_list::const_iterator iter2 = iter1;
00589     ++iter2;
00590     
00591     for(;iter2!=_clusters.end();++iter2){
00592      
00593       if(iter1->get()->get_plane() == iter2->get()->get_plane() &&
00594          iter1->get()->get_panel() == iter2->get()->get_panel() &&
00595          iter1->get()->get_orientation() != iter2->get()->get_orientation() ){
00596 
00597         PHLine line2 = iter2->get()->get_coord();
00598 
00599         // check possible intersection of line1 and line2
00600         double distance = PHGeometry::distanceLineLine(line1, line2);
00601         
00602         if (distance <= _orient_z_dist) // we had an intersection
00603           {
00604             PHPoint point = PHGeometry::closestApproachLineLine(line1, line2);
00605             _points.push_back(point);
00606           }
00607       }
00608     }
00609   }
00610 
00611   // update fit parameters
00612   //  std::cout << " number of points " << _points.size() << endl;
00613   if(_points.size()==0){
00614 
00615     // If we have 0 points then just initialize the fit_par with the 
00616     // center of the first cluster
00617     //
00618     iter1 = _clusters.begin();
00619     PHPoint mid_point = iter1->get()->get_centroidpos();
00620     // One point, take the point with 0 angles (dx/ydz)
00621     //
00622     _fit_par.set_x(mid_point.getX());
00623     _fit_par.set_y(mid_point.getY());
00624     _fit_par.set_z(mid_point.getZ());
00625     _fit_par.set_dxdz(0);
00626     _fit_par.set_dydz(0);    
00627   } 
00628   else if(_points.size()==1){
00629     
00630     // One point, take the point with 0 angles (dx/ydz)
00631     //
00632     _fit_par.set_x(_points.begin()->getX());
00633     _fit_par.set_y(_points.begin()->getY());
00634     _fit_par.set_z(_points.begin()->getZ());
00635     _fit_par.set_dxdz(0);
00636     _fit_par.set_dydz(0);
00637 
00638     // center the phi/theta windows around the found point
00639     PHSphPoint spherepoint;
00640     PHGeometry::cartesianToSpherical(_points[0], spherepoint);
00641     double half_phi_window_size = 0.5*(_phi_window.second - _phi_window.first);
00642     double half_theta_window_size = 0.5*(_theta_window.second - _theta_window.first);
00643 
00644     _phi_window.first = static_cast<double>(spherepoint.getPhi())
00645       - half_phi_window_size; 
00646     _phi_window.second = static_cast<double>(spherepoint.getPhi())
00647       + half_phi_window_size; 
00648     _theta_window.first = static_cast<double>(spherepoint.getTheta())
00649       - half_theta_window_size;  
00650     _theta_window.second = static_cast<double>(spherepoint.getTheta())
00651       + half_theta_window_size; 
00652   } 
00653   else if(_points.size()>1) {
00654 
00655     // More than one point, do a linear fit
00656     //
00657     // The second argument is the array dimension
00658     boost::array<double,MUIOO::MAX_PLANE> x = {{0}}; 
00659     boost::array<double,MUIOO::MAX_PLANE> y = {{0}}; 
00660     boost::array<double,MUIOO::MAX_PLANE> z = {{0}}; 
00661       
00662     double z0 = _points[0].getZ();
00663     size_t n_data = _points.size();
00664 
00665     // use constants from float.h to really init min/max properly
00666     double z_max = -DBL_MAX; 
00667     double z_min = DBL_MAX;
00668 
00669     PHSphPoint spherepoint;
00670     double phi_sum = 0.0;
00671     double theta_sum = 0.0;
00672     double half_phi_window_size = 0.5*(_phi_window.second - _phi_window.first);
00673     double half_theta_window_size = 0.5*(_theta_window.second - _theta_window.first);
00674 
00675     for(size_t i=0;i<n_data;++i){
00676       PHGeometry::cartesianToSpherical(_points[i], spherepoint);
00677       phi_sum += spherepoint.getPhi();
00678       theta_sum += spherepoint.getTheta();
00679       x.at(i) = _points[i].getX();
00680       y.at(i) = _points[i].getY();
00681       z.at(i) = _points[i].getZ() - z0;
00682       z_min = std::min(z_min,_points[i].getZ());
00683       z_max = std::max(z_max,_points[i].getZ());
00684     }
00685 
00686     phi_sum /= n_data;
00687     theta_sum /= n_data;
00688     _phi_window.first = phi_sum - half_phi_window_size; 
00689     _phi_window.second = phi_sum + half_phi_window_size; 
00690     _theta_window.first = theta_sum - half_theta_window_size;  
00691     _theta_window.second = theta_sum + half_theta_window_size;  
00692 
00693     double x0=0,m_x=0, y0=0, m_y=0;
00694     double cov00=0, cov11=0, cov22=0,chi2x=0,chi2y=0;
00695       
00696     // Fit x: method from gsl_fit.h
00697     //
00698     gsl_fit_linear(z.begin(),1,x.begin(),1,n_data,
00699                    &x0,&m_x,&cov00,&cov11,&cov22,&chi2x);
00700       
00701     // Fit y
00702     //
00703     gsl_fit_linear(z.begin(),1,y.begin(),1,n_data,
00704                    &y0,&m_y,&cov00,&cov11,&cov22,&chi2y);
00705 
00706     // Sanity check (dx/dz dy/dz cut)
00707     //
00708     if(std::fabs(m_x) > 10 || std::fabs(m_y) > 10) {
00709       _status = false;
00710       return;
00711     }
00712 
00713     _fit_par.set_x(x0);
00714     _fit_par.set_y(y0);
00715     _fit_par.set_z(z0);
00716     _fit_par.set_dxdz(m_x);
00717     _fit_par.set_dydz(m_y);
00718     
00719     // "begin" is closest to interaction region
00720     //
00721     if(_arm == MUIOO::South) {
00722       _fit_par.set_z_begin(z_max) ;
00723       _fit_par.set_z_end(z_min);
00724     } else {
00725       _fit_par.set_z_begin(z_min) ;
00726       _fit_par.set_z_end(z_max);
00727     }
00728   }
00729 }
 | 
| 
 | 
| 
 Definition at line 337 of file TMuiRoadFinder.h. Referenced by add_cluster, get_arm, Road, and update_road. | 
| 
 | 
| 
 Definition at line 367 of file TMuiRoadFinder.h. Referenced by add_cluster, bifurcate, check_parallel, check_proximity, get_cluster_list, get_n_cluster, make_point, print, Road, unique_check, and update_road. | 
| 
 | 
| 
 Definition at line 348 of file TMuiRoadFinder.h. Referenced by is_complete, Road, and set_complete. | 
| 
 | 
| 
 Definition at line 30 of file TMuiRoadFinder.cxx. Referenced by set_dca_cut. | 
| 
 | 
| 
 Definition at line 41 of file TMuiRoadFinder.cxx. Referenced by add_cluster, check_proximity, and test_window. | 
| 
 | 
| 
 Definition at line 37 of file TMuiRoadFinder.cxx. Referenced by finish_evaluation, and initialize_evaluation. | 
| 
 | 
| 
 Definition at line 39 of file TMuiRoadFinder.cxx. Referenced by initialize_evaluation. | 
| 
 | 
| 
 Definition at line 333 of file TMuiRoadFinder.h. | 
| 
 | 
| 
 Definition at line 375 of file TMuiRoadFinder.h. Referenced by get_fit_par, get_phi, get_r_at_z, get_theta, project, and update_road. | 
| 
 | 
| 
 Definition at line 343 of file TMuiRoadFinder.h. Referenced by bifurcate, has_window, and Road. | 
| 
 | 
| 
 Definition at line 40 of file TMuiRoadFinder.cxx. Referenced by add_cluster, finish_evaluation, and initialize_evaluation. | 
| 
 | 
| 
 Definition at line 34 of file TMuiRoadFinder.cxx. Referenced by make_point, set_orient_z_dist, and update_road. | 
| 
 | 
| 
 Definition at line 342 of file TMuiRoadFinder.h. Referenced by bifurcate, get_phi_window, Road, test_window, and update_road. | 
| 
 | 
| 
 Definition at line 371 of file TMuiRoadFinder.h. Referenced by add_cluster, get_n_point, get_point_list, print, test_window, and update_road. | 
| 
 | 
| 
 Definition at line 31 of file TMuiRoadFinder.cxx. Referenced by check_proximity, and set_prox_cut. | 
| 
 | 
| 
 Definition at line 349 of file TMuiRoadFinder.h. Referenced by get_status, Road, set_status, and update_road. | 
| 
 | 
| 
 Definition at line 341 of file TMuiRoadFinder.h. Referenced by bifurcate, get_theta_window, Road, test_window, and update_road. | 
| 
 | 
| 
 Definition at line 35 of file TMuiRoadFinder.cxx. Referenced by check_proximity, and set_tube_width. | 
| 
 | 
| 
 Definition at line 38 of file TMuiRoadFinder.cxx. | 
| 
 | 
| 
 Definition at line 28 of file TMuiRoadFinder.cxx. Referenced by set_verbose. | 
