00001 00002 // 00003 // Utility class: mMuiTriggerEmulator: 00004 // Author: S.Kelly 00005 // Date: 00006 // Description: 00007 // 00009 00010 // MUIOO/MUTOO headers 00011 // 00012 #include <mMuiTriggerEmulator.h> 00013 #include <mMuiTriggerEmulatorPar.h> 00014 #include <TMutNode.h> 00015 #include <PHException.h> 00016 #include <MUTOO.h> 00017 #include <PHTimer.h> 00018 #include <TMuiHitMapO.h> 00019 00020 // PHENIX headers 00021 // 00022 00025 // STL/BOOST 00026 // 00027 #include <iostream> 00028 #include <string> 00029 #include <list> 00030 #include <boost/array.hpp> 00031 00032 mMuiTriggerEmulator::mMuiTriggerEmulator() : _timer("mMuiTriggerEmulator") 00033 { 00034 name = "mMuiTriggerEmulator"; 00035 MUTOO::TRACE("initializing module " + std::string(name.getString())); 00036 00037 for(int i=0; i<8;++i) _deep_mask.set(i); 00038 for(int i=0; i<6;++i) _shallow_mask.set(i); 00039 } 00040 00041 // Destructor 00042 00043 mMuiTriggerEmulator::~mMuiTriggerEmulator() { } 00044 00045 // Event method. 00046 00047 PHBoolean mMuiTriggerEmulator::event(PHCompositeNode* top_node) 00048 { 00049 00050 _timer.restart(); 00051 00052 try { 00053 00054 // Reset IOC pointers 00055 // 00056 set_interface_ptrs(top_node); 00057 00058 // Clear all lists, bitmasks and trigger booleans 00059 // 00060 clear_state_variables(); 00061 00062 // Populate quadrant lists 00063 // 00064 fill_quadrant_list(); 00065 00066 // Set plane bitset 00067 // 00068 set_plane_bitset(); 00069 00070 // Set trigger status 00071 // 00072 set_trigger_status(); 00073 00074 } catch(std::exception& e) { 00075 MUTOO::TRACE(e.what()); 00076 return False; 00077 } 00078 00079 // Timer 00080 // 00081 _timer.print(); 00082 return True; 00083 } 00084 00086 void 00087 mMuiTriggerEmulator::set_interface_ptrs(PHCompositeNode* top_node){ 00088 // module runtime parameters 00089 // 00090 _mod_par = TMutNode<mMuiTriggerEmulatorPar>::find_node(top_node,"mMuiTriggerEmulatorPar"); 00091 _hit_map = TMutNode<TMuiHitMapO>::find_node(top_node,"TMuiHitMapO"); 00092 } 00093 00094 void 00095 mMuiTriggerEmulator::clear_state_variables() 00096 { 00097 _deep_deep = false; 00098 _deep_shallow = false; 00099 for(size_t i=0;i<_quad_hit_list.size();++i){ 00100 _quad_hit_list[i].clear(); 00101 _quad_bitset[i].reset(); 00102 } 00103 } 00104 00105 void 00106 mMuiTriggerEmulator::fill_quadrant_list() 00107 { 00108 // Loop over all hits in the MUID. Store hit point in 00109 // lists by quadrant. Note small panel hits contribute 00110 // a hit to 2 quadrants. 00111 // 00112 TMuiHitMapO::const_iterator hit_iter = _hit_map->range(); 00113 while(TMuiHitMapO::const_pointer hit_ptr = hit_iter.next()){ 00114 UShort_t panel = hit_ptr->get()->get_panel(); 00115 // plane 1 (small panel) contributes to quadrant 0 and 1 00116 // plane 4 (small panel) contributes to quadrant 2 and 3 00117 if(panel == 0 || panel == 1) { 00118 _quad_hit_list[0].push_back(*hit_ptr); 00119 } 00120 if(panel == 1 || panel == 2) { 00121 _quad_hit_list[1].push_back(*hit_ptr); 00122 } 00123 if(panel == 3 || panel == 4) { 00124 _quad_hit_list[2].push_back(*hit_ptr); 00125 } 00126 if(panel == 4 || panel == 5) { 00127 _quad_hit_list[3].push_back(*hit_ptr); 00128 } 00129 } 00130 } 00131 00132 00133 void 00134 mMuiTriggerEmulator::set_plane_bitset() 00135 { 00136 for(size_t quad=0;quad<_quad_hit_list.size();++quad) { 00137 // Loop over all hits in quadrant hit list 00138 // 00139 hit_list::iterator hit_iter = _quad_hit_list[quad].begin(); 00140 for(;hit_iter!= _quad_hit_list[quad].begin();++hit_iter){ 00141 // Set the plane bit 00142 // 00143 UShort_t plane = hit_iter->get()->get_plane(); 00144 _quad_bitset[quad].set(plane); 00145 } 00146 } 00147 } 00148 00149 void 00150 mMuiTriggerEmulator::set_trigger_status() 00151 { 00152 // The BLT deep deep trigger is 7/8 in the first 8 planes, 00153 // the BLT deep shallow trigger is 5/6 in the first 6 planes. 00154 // 00155 UShort_t ndeep=0, nshallow=0; 00156 for(size_t quad=0;quad<_quad_bitset.size();++quad) { 00157 // Deep is 7 of 8 00158 // 00159 if ((_quad_bitset[quad] & _deep_mask).count() >= 7) ++ndeep; 00160 // Shallow is 5 of 6 00161 // 00162 if ((_quad_bitset[quad] & _shallow_mask).count() >= 5) ++nshallow; 00163 } 00164 if(ndeep>=2) _deep_deep = true; 00165 if(ndeep>=1 && nshallow>=1) _deep_shallow = true; 00166 } 00167 00168 00169 00170 00171