00001
00002
00003
00004
00006
00007
00008
00009 #include <mMuiEvalFramework.h>
00010 #include <mMuiEvalFrameworkPar.h>
00011 #include <TMutNode.h>
00012 #include <TMuiHitMapO.h>
00013 #include <TMuiClusterMapO.h>
00014 #include <PHException.h>
00015 #include <MUIOO.h>
00016 #include <PHTimer.h>
00017
00018
00019
00020 #include<dMuiRawWrapper.h>
00021
00022
00023
00024
00025
00026
00027
00028 #include <iostream>
00029 #include <string>
00030
00031
00032 mMuiEvalFramework::mMuiEvalFramework() :
00033 _timer(PHTimeServer::get()->insert_new("mMuiEvalFramework") )
00034 {
00035 name = "mMuiEvalFramework";
00036 MUIOO::TRACE("initializing module " + std::string(name.getString()));
00037 }
00038
00039
00040 mMuiEvalFramework::~mMuiEvalFramework() { }
00041
00042
00043
00044 PHBoolean
00045 mMuiEvalFramework::event(PHCompositeNode* top_node)
00046 {
00047 _timer.get()->restart();
00048
00049 try {
00050
00051 set_interface_ptrs(top_node);
00052 if (_mod_par->get_eval_unpack()) eval_unpacker();
00053 if (_mod_par->get_eval_cluster()) eval_cluster();
00054 if (_mod_par->get_eval_findroad()) eval_findroad();
00055 }
00056 catch (std::exception& e) {
00057 MUIOO::TRACE(e.what());
00058 return False;
00059 }
00060
00061
00062 _timer.get()->stop();
00063 _timer.get()->print();
00064 return True;
00065 }
00066
00067 void
00068 mMuiEvalFramework::set_interface_ptrs(PHCompositeNode* top_node){
00069
00070
00071
00072 _mod_par = TMutNode<mMuiEvalFrameworkPar>::find_node(top_node,"mMuiEvalFrameworkPar");
00073
00074
00075
00076 _hit_map = TMutNode<TMuiHitMapO>::find_node(top_node,"TMuiHitMapO");
00077
00078
00079
00080 _cluster_map = TMutNode<TMuiClusterMapO>::find_node(top_node,"TMuiClusterMapO");
00081
00082
00083
00084 if(_mod_par->get_eval_unpack()) {
00085 _hit_table = TMutNode<dMuiRawWrapper>::find_io_node(top_node,"dMuiRaw");
00086 }
00087
00088
00089 if(_mod_par->get_eval_cluster()){
00090 _cluster_table = TMutNode<dMuiClustersWrapper>::find_io_node(top_node,"dMuiClusters");
00091 }
00092
00093
00094 if(_mod_par->get_eval_findroad()){
00095 _road_table = TMutNode<dMuiRoadsWrapper>::find_io_node(top_node,"dMuiRoads");
00096 }
00097 }
00098
00099
00100 void
00101 mMuiEvalFramework::eval_unpacker()
00102 {
00103
00104
00105 TABLE_HEAD_ST dMuiRaw_h = _hit_table->TableHeader();
00106 DMUIRAW_ST* dMuiRaw = _hit_table->TableData();
00107
00108 MUIOO::PRINT(std::cout, "MUI unpack summary statistics");
00109 std::cout << "TMuiHitMapO: total hits = " << _hit_map->size() << std::endl;
00110 std::cout << "dMuiRaw: total hits = " << dMuiRaw_h.nok << std::endl;
00111 MUIOO::PRINT(std::cout, "**");
00112
00113 for(int i=0;i<dMuiRaw_h.nok;i++){
00114 unsigned short arm = dMuiRaw[i].arm;
00115 unsigned short plane = dMuiRaw[i].plane;
00116 unsigned short panel = dMuiRaw[i].panel;
00117 unsigned short orientation = dMuiRaw[i].orientation;
00118 unsigned short twopack = dMuiRaw[i].twopack;
00119 TMuiHitMapO::const_iterator hit_iter = _hit_map->get(arm,
00120 plane,
00121 panel,
00122 orientation,
00123 twopack);
00124 bool found_match = false;
00125 if (hit_iter.count() == 0) found_match = true;
00126 if(!found_match){
00127 std::cout << "TMuiHitMapO/dMuiRaw mismatch" << std::endl;
00128 }
00129 }
00130 }
00131
00132 void mMuiEvalFramework::eval_cluster(){
00133
00134
00135
00136 TABLE_HEAD_ST dMuiClusters_h = _cluster_table->TableHeader();
00137 DMUICLUSTERS_ST* dMuiClusters = _cluster_table->TableData();
00138
00139 int nmatch=0;
00140 const double max_diff_match = 10.;
00141
00142 for(int i=0; i<dMuiClusters_h.nok;i++){
00143
00144 unsigned short arm = dMuiClusters[i].arm;
00145 unsigned short plane = dMuiClusters[i].plane;
00146 unsigned short panel = dMuiClusters[i].panel;
00147 unsigned short orient = dMuiClusters[i].orientation;
00148
00149 float cpos_staf[3];
00150 for (int j = 0; j<3; j++) {
00151 cpos_staf[j] = dMuiClusters[i].CentroidPos[j];;
00152 }
00153
00154 TMuiClusterMapO::const_iterator cluster_iter = _cluster_map->get(arm,
00155 plane,
00156 panel,
00157 orient);
00158 bool found_match = false;
00159 while(TMuiClusterMapO::const_pointer cluster_ptr = cluster_iter.next()){
00160
00161 PHPoint cpos_oo = cluster_ptr->get()->get_centroidpos();
00162 double diffX = cpos_oo.getX() - cpos_staf[0];
00163 double diffY = cpos_oo.getY() - cpos_staf[1];
00164 double diffZ = cpos_oo.getZ() - cpos_staf[2];
00165 double diff = sqrt(diffX*diffX + diffY*diffY + diffZ*diffZ);
00166 if (diff < max_diff_match) {
00167 found_match = true;
00168 }
00169 }
00170 if(!found_match){
00171 MUIOO::PRINT(std::cout,"No matching cluster found");
00172 print_cluster(&dMuiClusters[i]);
00173 MUIOO::PRINT(std::cout,"**");
00174 }
00175 else {
00176 nmatch++;
00177 }
00178 }
00179 MUIOO::PRINT(std::cout,"Summary Comparison");
00180 std::cout << " ntot " << dMuiClusters_h.nok
00181 << " nmatch " << nmatch << std::endl;
00182 MUIOO::PRINT(std::cout,"**");
00183 }
00184
00185 void
00186 mMuiEvalFramework::eval_findroad()
00187 {
00188
00189 return;
00190 }
00191
00192 void
00193 mMuiEvalFramework::print_raw(const DMUIRAW_ST* raw_ptr)
00194 {
00195
00196 return;
00197 }
00198
00199 void
00200 mMuiEvalFramework::print_cluster(const DMUICLUSTERS_ST* clus_ptr)
00201 {
00202 MUIOO::PRINT(std::cout,"dMuiClusters");
00203 std::cout << " arm: " << clus_ptr->arm << std::endl;
00204 std::cout << " plane: " << clus_ptr->plane << std::endl;
00205 std::cout << " panel: " << clus_ptr->panel << std::endl;
00206 std::cout << " orientation: " << clus_ptr->orientation << std::endl;
00207 std::cout << " size: " << clus_ptr->size << std::endl;
00208 std::cout << " index: " << clus_ptr->dMuiClusterIndex << std::endl;
00209 MUIOO::PRINT(std::cout,"**");
00210 }
00211
00212 void
00213 mMuiEvalFramework::print_road(const DMUIROADS_ST* raw_ptr)
00214 {
00215
00216 return;
00217 }