00001 #ifndef __MMUIBLTEMULATOR_HH__
00002 #define __MMUIBLTEMULATOR_HH__
00003 
00004 #include<PHModule.h>
00005 #include<PHTimer.h>
00006 #include<TMuiPseudoBLTMapO.h>
00007 #include<TMuiHitMapO.h>
00008 #include<mMuiBLTEmulatorPar.h>
00009 #include<MUIOO.h>
00010 #include "PHIODataNode.h"
00011 #include "PHNodeIterator.h"
00012 #include "PHTypedNodeIterator.h"
00013 #include "Event.h"
00014 
00051 class mMuiBLTEmulator : public PHModule
00052 {
00053  public: 
00054   
00055   enum
00056   {
00057     max_arm =2,
00058     max_quad = 4,
00059     max_plane = 4,
00060     max_orientation = 2,
00061     
00062     DEEP_ROAD = 2,
00063     SHALLOW_ROAD = 1,
00064     
00065     DEEP_DEEP = 16,
00066     DEEP_SHALLOW = 8,
00067     SINGLE_DEEP = 4,
00068     SHALLOW_SHALLOW = 2,
00069     SINGLE_SHALLOW = 1,
00070 
00071     mlu_address_max = 4096,
00072     max_fem = 2,
00073     word_per_fem = 120
00074   };
00075 
00076   mMuiBLTEmulator(); 
00077 
00078   ~mMuiBLTEmulator(); 
00079 
00080   virtual PHBoolean event(PHCompositeNode*);
00081 
00082   
00083   
00084   void initialize(int runno);
00085 
00086   
00087   
00088   bool read_mlu_data(int* mlu_data_d, char* mlu_data_file);
00089 
00090 
00091 
00092  private:  
00093   
00094   
00095   
00096   void get_raw_data();
00097   
00098   
00099   void get_hits();
00100   
00101   
00102   void raw_to_trigpattern();
00103   
00104   
00105   int decision_event(int arm);
00106   
00107   
00108   int decision_mlu(int arm);
00109   
00110   
00111   int quad_fire(int* quad_trig_pattern, int* mlu_data);
00112   
00113   
00114   void set_interface_ptrs(PHCompositeNode* top_node);
00115   
00116   
00117   void fill_map();
00118   
00119   
00120   int get_non_used_plane() { return _non_used_plane;}
00121   
00122   
00123   void set_non_used_plane(int plane ) { _non_used_plane = plane;}
00124 
00125   
00126   
00127   void check_blt();
00128   
00129   
00130   void dump_reco_blt(int arm);
00131   
00132   
00133 #ifndef __CINT__
00134   
00135   
00136   bool is_reco_2D(int arm);
00137   
00138   
00139   bool is_reco_1D1S(int arm);
00140   
00141   
00142   bool is_reco_1D(int arm, int quad);
00143   
00144   
00145   bool is_reco_1S(int arm, int quad);
00146 
00147 
00148 #endif
00149   
00150   
00151   int  get_quad(float x, float y, float z);
00152 
00153 
00154 
00155   
00156   
00157   const mMuiBLTEmulatorPar* _mod_par;           
00158   TMuiHitMapO* _hit_map;
00159   TMuiPseudoBLTMapO* _blt_map;
00160   Event* _event;                             
00161   
00162 
00163   long word[max_arm][max_fem][word_per_fem];
00164   
00165   int mlu_data_s[mlu_address_max];
00166   
00167   int mlu_data_d[mlu_address_max];
00168   
00169   int _non_used_plane;
00170   
00171   int trig_pattern[max_arm][max_quad][max_plane];
00172   
00173   int trig_accept[max_arm][max_quad];
00174   
00175   
00176   
00177   int init_done;
00178   
00179   
00180   
00181   PHTimer _timer;
00182 };
00183 
00184 #endif 
00185 
00186 
00187 
00188 
00189 
00190 
00191 
00192 
00193 
00194 
00195 
00196 
00197 
00198 
00199 
00200 
00201 
00202 
00203 
00204 
00205 
00206