#include <TMuiRoadFinder.h>
Public Types | |
| typedef std::list< Road > | road_list |
| typedef std::pair< float, float > | road_window |
| enum | WindowEnum { IN_WINDOW, LOW_WINDOW, HIGH_WINDOW } |
Public Methods | |
| TMuiRoadFinder () | |
| void | find (TMuiClusterMapO *cluster_map) |
| void | find (TMuiClusterMapO *cluster_map, UShort_t arm, bool use_window=false, const road_window &theta_window=std::make_pair(0, 0), const road_window &phi_window=std::make_pair(0, 0)) |
| road_list & | get_road_list () |
| void | clear_road_list () |
| std::list< TMuiClusterMapO::value_type > | TMuiRoadFinder::get_coords_in_window (TMuiClusterMapO *cluster_map, UShort_t arm, const road_window &theta_window, const road_window &phi_window) |
| void | evaluate (PHCompositeNode *top_node) |
Static Public Methods | |
| void | initialize_evaluation () |
| void | finish_evaluation () |
| void | set_verbose (bool verbose) |
| void | set_reversed_algo (bool reverse_algo) |
| 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_min_cluster (UShort_t min_cluster) |
| void | set_max_cluster_share (UShort_t max_cluster_share) |
| void | set_min_point (UShort_t min_point) |
| WindowEnum | check_phi_window (const PHPoint &point, const TMuiRoadFinder::road_window &phi_window) |
| WindowEnum | check_theta_window (const PHPoint &point, const TMuiRoadFinder::road_window &theta_window) |
Private Methods | |
| bool | append_to_road (TMuiClusterMapO::pointer) |
| TMuiRoadFinder::Road * | start_new_road (TMuiClusterMapO::pointer, bool use_window, const road_window &theta_window, const road_window &phi_window) |
| void | abort_new_road () |
| void | set_complete_tag () |
| void | remove_includes () |
| void | print_roads () const |
Private Attributes | |
| road_list | _road_list |
Static Private Attributes | |
| bool | _verbose = false |
| bool | _reverse_algo = false |
| UShort_t | _min_cluster = 4 |
| UShort_t | _min_point = 2 |
| UShort_t | _max_cluster_share = 4 |
| bool | _evaluation = false |
| TFile * | _file = 0 |
| TNtuple * | _ntuple = 0 |
Friends | |
| class | Road |
This class encapsulates the road finding algorithm used by the mMuiRoadFinder module. The algorithm uses an adaptive forward search to associate TMuiClusterO objects with a class scope Road object. Upon completion of the first search the list of TMuiClusterO can be reversed and the algorithm is run again. (w. different seeds) Duplicate Roads (roads with the same hit set) are removed from the internal list as are "includes", ie roads that have hit or point sets that are subsets of other roads. Running the algorithm twice is done to minimize the sensitivity to noise hits added early in the search. The list of class scope road objects held internally by the class is available via an non const member function. This is to allow external modules to splice the internal list. This is quicker than copying but make the class non-const correct.
Definition at line 46 of file TMuiRoadFinder.h.
|
|
Definition at line 51 of file TMuiRoadFinder.h. Referenced by evaluate, and get_road_list. |
|
|
Definition at line 52 of file TMuiRoadFinder.h. Referenced by check_phi_window, check_theta_window, and mMuiFindRoad::find_roads. |
|
|
Definition at line 53 of file TMuiRoadFinder.h. Referenced by TMuiRoadFinder::Road::test_window.
00053 { IN_WINDOW, LOW_WINDOW, HIGH_WINDOW };
|
|
|
Definition at line 55 of file TMuiRoadFinder.h.
00055 {}
|
|
|
Definition at line 252 of file TMuiRoadFinder.cxx. References _road_list. Referenced by TMuiRoadFinder::Road::bifurcate.
00253 {
00254 _road_list.pop_front();
00255 }
|
|
|
Definition at line 217 of file TMuiRoadFinder.cxx. References _road_list. Referenced by find.
00218 {
00219 // Initialize was_appended = false
00220 // Loop over Roads in road list [
00221 // if add_new_cluster successfull [
00222 // set was_appended = true
00223 // ]
00224 // ]
00225 // return was_appended
00226 //
00227 bool sticky_appended = false;
00228 road_list::iterator road_iter = _road_list.begin();
00229 for(;road_iter!=_road_list.end();++road_iter){
00230
00231 // Punt if this road has the complete flag set
00232 //
00233 if(road_iter->is_complete()) continue;
00234
00235 // Attempt to append cluster to current road
00236 //
00237 bool was_appended = road_iter->add_cluster(cluster_ptr);
00238 sticky_appended = (sticky_appended) ? sticky_appended : was_appended;
00239 }
00240 return sticky_appended;
00241 }
|
|
||||||||||||
|
Definition at line 894 of file TMuiRoadFinder.cxx. References HIGH_WINDOW, IN_WINDOW, LOW_WINDOW, and road_window. Referenced by TMuiRoadFinder::Road::test_window.
00896 {
00897 // Convert to spherical coordinates
00898 PHSphPoint spherepoint;
00899 PHGeometry::cartesianToSpherical(point, spherepoint);
00900
00901 // spherepoints phi-coordinate should be in the range between
00902 // the first and second phi-window values.
00903 double thisphi = spherepoint.getPhi();
00904 double dphi_right = phi_window.second - thisphi;
00905 double dphi_left = thisphi - phi_window.first;
00906 // i.e. if both dphi_left/right values are positive, we are within the window
00907
00908 // Some care need to be taken around 2PI
00909 // If the higher limit is above 2PI, and the point is on the positive side
00910 // we subtract 2PI, so the
00911 // same scale is used as for PHSphPoint
00912 // The lower value is always less than 2PI
00913 if (phi_window.second > 2*M_PI && point.getY() > 0) {
00914 dphi_right -= 2*M_PI;
00915 }
00916
00917 //
00918 // 1) within delta window of both indicates inside
00919 // 2) within delta of left but not right indicates left
00920 // 3) within delta of right but not left indicates right
00921 // 4) not within delta of either indicates left or right depending upon
00922 // which is closer
00923 //
00924 if(dphi_left >= 0 && dphi_right >= 0){
00925 return IN_WINDOW;
00926 } else if(dphi_left < 0) {
00927 return LOW_WINDOW;
00928 } else if(dphi_right < 0) {
00929 return HIGH_WINDOW;
00930 } else {
00931 return HIGH_WINDOW; // this should never happen but makes compiler happy
00932 }
00933 }
|
|
||||||||||||
|
Definition at line 936 of file TMuiRoadFinder.cxx. References HIGH_WINDOW, IN_WINDOW, LOW_WINDOW, and road_window. Referenced by TMuiRoadFinder::Road::test_window.
00939 {
00940 // Convert to spherical coordinates
00941 PHSphPoint spherepoint;
00942 PHGeometry::cartesianToSpherical(point, spherepoint);
00943 double theta_p = spherepoint.getTheta();
00944
00945 if(theta_p >= theta_window.first && theta_p <= theta_window.second){
00946 return IN_WINDOW;
00947 } else if(theta_p < theta_window.first) {
00948 return LOW_WINDOW;
00949 } else if(theta_p > theta_window.second) {
00950 return HIGH_WINDOW;
00951 } else {
00952 return HIGH_WINDOW; // this should never happen but makes compiler happy
00953 }
00954 }
|
|
|
Clears the road list. Definition at line 84 of file TMuiRoadFinder.h. References _road_list.
00084 { _road_list.clear(); }
|
|
|
Fill evaluation ntuple from road finders current state Definition at line 985 of file TMuiRoadFinder.cxx. References TMuiRoadFinder::Road::cluster_list, get_road_list, and road_list.
00986 {
00987 TMuiRoadFinder::road_list& road_list = get_road_list();
00988 TMuiRoadFinder::road_list::iterator road_list_iter = road_list.begin();
00989 for(;road_list_iter!=road_list.end();++road_list_iter){
00990 float ntvar[20] = {0};
00991
00992 ntvar[0] = road_list_iter->get_arm();
00993 ntvar[1] = road_list_iter->get_cluster_list().size();
00994
00995 typedef TMuiRoadFinder::Road::cluster_list road_cluster_list;
00996 road_cluster_list& cluster_list = road_list_iter->get_cluster_list();
00997 road_cluster_list::iterator cluster_iter = cluster_list.begin();
00998 for(;cluster_iter!=cluster_list.end();++cluster_iter){
00999 TMuiClusterMapO::const_key_iterator clus_iter = cluster_iter->get()->get_associated<TMuiClusterO>();
01000 if(!clus_iter.at_end()){
01001 TMuiHitMapO::const_key_iterator hit_iter = clus_iter->get()->get_associated<TMuiHitO>();
01002 while(TMuiHitMapO::const_pointer hit_ptr = hit_iter.next()){
01003 TMuiMCHitMapO::const_key_iterator mc_hit_iter = hit_ptr->get()->get_associated<TMuiMCHitO>();
01004 if(!mc_hit_iter.at_end()){
01005 }
01006 }
01007 }
01008 }
01009 }
01010 }
|
|
||||||||||||||||||||||||
|
Find roads at specified location in specified r, theta window. If no windows are specified the algorithm will find all roads at given location. The theta radians [0-PI], the phi interval is a sub interval of the range [0-2PI] in radians. Definition at line 62 of file TMuiRoadFinder.cxx. References _reverse_algo, _road_list, append_to_road, TMuiClusterMapO::get, print_roads, remove_includes, set_complete_tag, and start_new_road.
00067 {
00068 if(_verbose) {
00069 std::cout << " TMuiRoadFinder::find: location: " << " arm: " << arm << std::endl;
00070 }
00071 // Never trust a raw pointer
00072 //
00073 if(!cluster_map) throw std::logic_error(DESCRIPTION("TMuiClusterMapO pointer is null"));
00074
00075 // Local storage for cluster list
00076 //
00077 typedef std::list<TMuiClusterMapO::value_type> local_list_type;
00078 local_list_type local_list;
00079
00080 // Store all clusters in this arm in local list.
00081 //
00082 TMuiClusterMapO::iterator cluster_iter = cluster_map->get(arm);
00083 while(TMuiClusterMapO::pointer cluster_ptr = cluster_iter.next()){
00084 local_list.push_back(*cluster_ptr);
00085 }
00086
00087 // Run the algorithm
00088 //
00089 local_list_type::iterator iter = local_list.begin();
00090 for(;iter!=local_list.end();++iter){
00091 // Attempt to append cluster to existing road. If unsuccessful create new road.
00092 //
00093 bool was_appended = append_to_road(&(*iter));
00094 if(!was_appended){
00095 start_new_road(&(*iter), use_window, theta_window, phi_window);
00096 }
00097 if(_verbose) print_roads();
00098 }
00099
00100 // Before running the reverse algorithm we tag the roads as complete.
00101 // (this is so we don't try to add clusters previously found roads)
00102 //
00103 set_complete_tag();
00104
00105 // Removes roads that are subsets of other roads
00106 //
00107 remove_includes();
00108
00109 // If not in REVERSE mode punt before running reverse algorithm
00110 //
00111 if(!_reverse_algo) return;
00112
00113 // Reverse the list
00114 //
00115 local_list.reverse();
00116
00117 // Run the algorithm again (on the reverse sorted list)
00118 //
00119 iter = local_list.begin();
00120 for(;iter!=local_list.end();++iter){
00121 // Attempt to append cluster to existing road. If unsuccessful create new road.
00122 //
00123 bool was_appended = append_to_road(&(*iter));
00124 if(!was_appended){
00125 start_new_road(&(*iter), use_window, theta_window, phi_window);
00126 }
00127 if(_verbose) print_roads();
00128 }
00129
00130 // Set complete on road found in second pass
00131 //
00132 set_complete_tag();
00133
00134 size_t n_road = _road_list.size();
00135 _road_list.sort(road_less_ftor());
00136 _road_list.unique(road_equal_ftor());
00137
00138 // Removes roads that are subsets of other roads
00139 //
00140 remove_includes();
00141
00142 if(_verbose) {
00143 std::cout << " removed " << n_road - _road_list.size() << " duplicate roads" << std::endl;
00144 }
00145 }
|
|
|
Find roads in both arms with no windows Definition at line 48 of file TMuiRoadFinder.cxx. Referenced by mMuiFindRoad::find_roads.
00049 {
00050 // Never trust a raw pointer
00051 //
00052 if(!cluster_map) throw std::logic_error(DESCRIPTION("TMuiClusterMapO pointer is null"));
00053
00054 for(int arm=0; arm<MUIOO::NumberOfArms;++arm){
00055 find(cluster_map, arm);
00056 }
00057 }
|
|
|
Write evaluation ntuple Definition at line 977 of file TMuiRoadFinder.cxx. References _evaluation, and _ntuple.
00978 {
00979 if(_ntuple) delete _ntuple;
00980 _evaluation=false;
00981 return;
00982 }
|
|
|
Returns a reference to the list of found roads. This needs to be a non-const reference to allow envokers of the algorithm to splice elements from this list. Definition at line 79 of file TMuiRoadFinder.h. References _road_list, and road_list. Referenced by evaluate, and mMuiFindRoad::find_roads.
00079 { return _road_list; }
|
|
|
Initialize evaluation ntuple Definition at line 957 of file TMuiRoadFinder.cxx. References _evaluation, _file, _ntuple, and MUIOO::TRACE.
00958 {
00959 if(_evaluation) return;
00960
00961 _file = (TFile*)gROOT->GetListOfFiles()->FindObject("muioo_eval_ntuple.root");
00962 if (_file) {
00963 MUIOO::TRACE("TMuiRoadFinder::initialize_evaluation, creating eval root file");
00964 _file = new TFile("muioo_eval_ntuple.root", "RECREATE");
00965 }
00966
00967 // Fields for road evaluation after algorithm is complete
00968 //
00969 _ntuple = new TNtuple("road","road",
00970 "arm:iroad:iclust:mc_exist:mc_found:"
00971 "true_hit:bg_hit:th_true:phi_true:th_win:ph_win");
00972
00973 _evaluation = true;
00974 return;
00975 }
|
|
|
Definition at line 244 of file TMuiRoadFinder.cxx. References _road_list, and MUIOO::PRINT. Referenced by find.
00245 {
00246 MUIOO::PRINT(std::cout,"**");
00247 std::for_each(_road_list.begin(), _road_list.end(), road_print_ftor());
00248 MUIOO::PRINT(std::cout,"**");
00249 }
|
|
|
Definition at line 148 of file TMuiRoadFinder.cxx. References _max_cluster_share, and _road_list. Referenced by find.
00149 {
00150 road_list::iterator iter1 = _road_list.begin();
00151 for(;iter1!=_road_list.end();++iter1){
00152 if (!iter1->get_status()) continue; // already marked for removal
00153 road_list::iterator iter2 = iter1;
00154 ++iter2;
00155 for(;iter2!=_road_list.end();++iter2){
00156 if (!iter2->get_status()) continue; // already marked for removal
00157
00158 road_list::iterator big = (iter1->get_n_cluster() >= iter2->get_n_cluster()) ? iter1 : iter2;
00159 road_list::iterator little = (iter1->get_n_cluster() >= iter2->get_n_cluster()) ? iter2 : iter1;
00160
00161 // Mark identical cluster includes for removal
00162 //
00163 if(std::includes(big->get_cluster_list().begin(),
00164 big->get_cluster_list().end(),
00165 little->get_cluster_list().begin(),
00166 little->get_cluster_list().end())) {
00167 little->set_status(false);
00168 }
00169
00170 // Count the number of clusters that are shared
00171 // If it's more than _max_cluster_share, then the little road is deleted
00172 //
00173 UShort_t nshare = 0;
00174
00175 Road::cluster_list::const_iterator big_iter =
00176 big->get_cluster_list().begin();
00177 Road::cluster_list::const_iterator little_iter =
00178 little->get_cluster_list().begin();
00179 for(;big_iter!=big->get_cluster_list().end();++big_iter){
00180 bool match = false;
00181 little_iter = little->get_cluster_list().begin();
00182 for(;little_iter!=little->get_cluster_list().end();++little_iter){
00183 if(big_iter->get()->get_key().get_obj_key()
00184 == little_iter->get()->get_key().get_obj_key()) {
00185 match = true;
00186 }
00187 }
00188 if (match) nshare++;
00189 }
00190 if (nshare > _max_cluster_share) {
00191 little->set_status(false);
00192 }
00193 }
00194 }
00195 // Remove marked roads
00196 //
00197 _road_list.remove_if(road_bad_status_ftor());
00198 }
|
|
|
Definition at line 201 of file TMuiRoadFinder.cxx. References _min_cluster, _min_point, and _road_list. Referenced by find.
00202 {
00203 road_list::iterator road_iter = _road_list.begin();
00204 road_iter = _road_list.begin();
00205 for(;road_iter!=_road_list.end();++road_iter) {
00206 if(road_iter->get_cluster_list().size() < _min_cluster ||
00207 road_iter->get_point_list().size() < _min_point) {
00208 road_iter->set_status(false);
00209 } else {
00210 road_iter->set_complete(true);
00211 }
00212 }
00213 _road_list.remove_if(road_bad_status_ftor());
00214 }
|
|
|
Point project cut applied with road has point. Definition at line 131 of file TMuiRoadFinder.h. Referenced by mMuiFindRoad::find_roads.
00131 {
00132 Road::set_dca_cut(dca_cut);
00133 }
|
|
|
Maximum number of clusters shared beteween two kept roads Definition at line 166 of file TMuiRoadFinder.h. References _max_cluster_share.
00166 {
00167 _max_cluster_share = max_cluster_share;
00168 }
|
|
|
Minimum hits in total (all planes) Definition at line 159 of file TMuiRoadFinder.h. References _min_cluster. Referenced by mMuiFindRoad::find_roads.
00159 {
00160 _min_cluster = min_cluster;
00161 }
|
|
|
Minimum points in total (all planes) Definition at line 173 of file TMuiRoadFinder.h. References _min_point. Referenced by mMuiFindRoad::find_roads.
00173 {
00174 _min_point = min_point;
00175 }
|
|
|
orientations have different z-values: allow for this in reco. Definition at line 145 of file TMuiRoadFinder.h.
00145 {
00146 Road::set_orient_z_dist(orient_z_dist);
00147 }
|
|
|
proximity cut applied when road has no point. Definition at line 138 of file TMuiRoadFinder.h. Referenced by mMuiFindRoad::find_roads.
00138 {
00139 Road::set_prox_cut(prox_cut);
00140 }
|
|
|
Run the road finding algorithm forwards in absolute z, but with reversed seeds, sort and remove duplicates. (Slower but less sensitive to inefficiencies) Definition at line 124 of file TMuiRoadFinder.h. References _reverse_algo. Referenced by mMuiFindRoad::find_roads.
00124 {
00125 _reverse_algo = reverse_algo;
00126 }
|
|
|
width of tube; parameter used when checking distances Definition at line 152 of file TMuiRoadFinder.h.
00152 {
00153 Road::set_tube_width(tube_width);
00154 }
|
|
|
Deluge of info on what the algorithm is doing (DEBUG only) Definition at line 113 of file TMuiRoadFinder.h. References _verbose.
00113 {
00114 _verbose = verbose;
00115 Road::set_verbose(verbose);
00116 }
|
|
||||||||||||||||||||
|
Definition at line 258 of file TMuiRoadFinder.cxx. References _road_list, and Road. Referenced by TMuiRoadFinder::Road::bifurcate, and find.
00262 {
00263 _road_list.push_front(Road(this, cluster_ptr, use_window,
00264 theta_window, phi_window));
00265
00266 // Return a pointer to the newly created Road
00267 //
00268 return &(*_road_list.begin());
00269 }
|
|
||||||||||||||||||||
|
Get a list of coordinates that intersect the given theta/phi window |
|
|
Definition at line 456 of file TMuiRoadFinder.h. Referenced by start_new_road. |
|
|
Definition at line 22 of file TMuiRoadFinder.cxx. Referenced by finish_evaluation, and initialize_evaluation. |
|
|
Definition at line 24 of file TMuiRoadFinder.cxx. Referenced by initialize_evaluation. |
|
|
Definition at line 20 of file TMuiRoadFinder.cxx. Referenced by remove_includes, and set_max_cluster_share. |
|
|
Definition at line 17 of file TMuiRoadFinder.cxx. Referenced by set_complete_tag, and set_min_cluster. |
|
|
Definition at line 18 of file TMuiRoadFinder.cxx. Referenced by set_complete_tag, and set_min_point. |
|
|
Definition at line 23 of file TMuiRoadFinder.cxx. Referenced by finish_evaluation, and initialize_evaluation. |
|
|
Definition at line 15 of file TMuiRoadFinder.cxx. Referenced by find, and set_reversed_algo. |
|
|
Definition at line 474 of file TMuiRoadFinder.h. Referenced by abort_new_road, append_to_road, TMuiRoadFinder::Road::bifurcate, clear_road_list, find, get_road_list, print_roads, remove_includes, set_complete_tag, and start_new_road. |
|
|
Definition at line 14 of file TMuiRoadFinder.cxx. Referenced by set_verbose. |