Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

mMuiBLTEmulator Class Reference
[Analysis Modules]

MUID/MUI Blue-Logic Trigger emulator. More...

#include <mMuiBLTEmulator.h>

List of all members.

Public Types

enum  {
  max_arm = 2, max_quad = 4, max_plane = 4, max_orientation = 2,
  DEEP_ROAD = 2, SHALLOW_ROAD = 1, DEEP_DEEP = 16, DEEP_SHALLOW = 8,
  SINGLE_DEEP = 4, SHALLOW_SHALLOW = 2, SINGLE_SHALLOW = 1, mlu_address_max = 4096,
  max_fem = 2, word_per_fem = 120
}

Public Methods

 mMuiBLTEmulator ()
 ~mMuiBLTEmulator ()
virtual PHBoolean event (PHCompositeNode *)
void initialize (int runno)
bool read_mlu_data (int *mlu_data_d, char *mlu_data_file)

Private Methods

void get_raw_data ()
void get_hits ()
void raw_to_trigpattern ()
int decision_event (int arm)
int decision_mlu (int arm)
int quad_fire (int *quad_trig_pattern, int *mlu_data)
void set_interface_ptrs (PHCompositeNode *top_node)
void fill_map ()
int get_non_used_plane ()
void set_non_used_plane (int plane)
void check_blt ()
void dump_reco_blt (int arm)
bool is_reco_2D (int arm)
bool is_reco_1D1S (int arm)
bool is_reco_1D (int arm, int quad)
bool is_reco_1S (int arm, int quad)
int get_quad (float x, float y, float z)

Private Attributes

const mMuiBLTEmulatorPar_mod_par
TMuiHitMapO_hit_map
TMuiPseudoBLTMapO_blt_map
Event * _event
long word [max_arm][max_fem][word_per_fem]
int mlu_data_s [mlu_address_max]
int mlu_data_d [mlu_address_max]
int _non_used_plane
int trig_pattern [max_arm][max_quad][max_plane]
int trig_accept [max_arm][max_quad]
int init_done
PHTimer _timer


Detailed Description

MUID/MUI Blue-Logic Trigger emulator.

Analysis Module Interface Specification

Object Description :: this is a translation from Hiroki's emulator ( offline/packages/mui/mMuiPseudoTrigger), I (chun zhang) am trying to keep it as untouched as possible, ie. do not blame me for anything. Privilege
const mMuiBLTEmulatorPar* Parameter Table immutable
TMuiHitMapO* Parameter Table immutable
TMuiPseudoBLTMapO* Parameter Table immutable

Definition at line 51 of file mMuiBLTEmulator.h.


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
max_arm 
max_quad 
max_plane 
max_orientation 
DEEP_ROAD 
SHALLOW_ROAD 
DEEP_DEEP 
DEEP_SHALLOW 
SINGLE_DEEP 
SHALLOW_SHALLOW 
SINGLE_SHALLOW 
mlu_address_max 
max_fem 
word_per_fem 

Definition at line 55 of file mMuiBLTEmulator.h.

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   };


Constructor & Destructor Documentation

~mMuiBLTEmulator  
 

Definition at line 62 of file mMuiBLTEmulator.cxx.

00062 { }


Member Function Documentation

void check_blt   [private]
 

Definition at line 785 of file mMuiBLTEmulator.cxx.

References _blt_map, _hit_map, dump_reco_blt, TMuiPseudoBLTMapO::get, is_reco_1D1S, and is_reco_2D.

Referenced by event.

00785                                 {
00786   
00787   // define a flag for debug.
00788   //
00789   int check_flag = 0;
00790   for(int iarm = 0; iarm < MUIOO::NumberOfArms; iarm++) {
00791     TMuiPseudoBLTMapO::const_iterator blt_iter = _blt_map->get(iarm);
00792     while(TMuiPseudoBLTMapO::const_pointer blt_ptr = blt_iter.next()){
00793       if(blt_ptr->get()->is_2D_fired()!=is_reco_2D(iarm)) {
00794         check_flag = 1;
00795         std::cout << " 2D trigger shows inconsistent " << std::endl;
00796         dump_reco_blt(iarm);
00797         blt_ptr->get()->print();
00798         _hit_map->print();
00799       } else if(blt_ptr->get()->is_1D1S_fired()!=is_reco_1D1S(iarm)) {
00800         check_flag = 1;
00801         std::cout << " 1D1S trigger shows inconsistent " << std::endl;
00802         dump_reco_blt(iarm);
00803         blt_ptr->get()->print();
00804         _hit_map->print();
00805       } 
00806     }
00807   }
00808 }

int decision_event int    arm [private]
 

Definition at line 284 of file mMuiBLTEmulator.cxx.

References decision_mlu, DEEP_ROAD, max_quad, mlu_data_d, mlu_data_s, quad_fire, SHALLOW_ROAD, trig_accept, and trig_pattern.

Referenced by fill_map.

00284                                        {
00285   
00286   // Copy of Hiroki's code, modification I made is
00287   // having arm as an input to handle both arm 
00288   
00289   int trig_pattern_arm[max_quad][MUIOO::MAX_PLANE-1];
00290   
00291   for(int iquad = 0; iquad < max_quad; iquad++) {
00292     for(int iplane = 0; iplane < MUIOO::MAX_PLANE-1; iplane++) {
00293       trig_pattern_arm[iquad][iplane] = trig_pattern[arm][iquad][iplane];
00294     }
00295   }
00296 
00297   for( int quad = 0; quad<max_quad; quad++ ){
00298     trig_accept[arm][quad] = 0;
00299   }
00300   
00301   for ( int quad = 0; quad<max_quad; quad++ ) {
00302     if ( quad_fire( trig_pattern_arm[quad], mlu_data_d ) == 1 ) {
00303       trig_accept[arm][quad] = DEEP_ROAD;
00304     }
00305     else if ( quad_fire( trig_pattern_arm[quad], mlu_data_s ) == 1 ) {
00306       trig_accept[arm][quad] = SHALLOW_ROAD;
00307     }
00308   } 
00309   return decision_mlu(arm);
00310 }

int decision_mlu int    arm [private]
 

Definition at line 341 of file mMuiBLTEmulator.cxx.

References DEEP_DEEP, DEEP_ROAD, DEEP_SHALLOW, max_quad, SHALLOW_ROAD, SHALLOW_SHALLOW, SINGLE_DEEP, SINGLE_SHALLOW, and trig_accept.

Referenced by decision_event.

00341                                           {
00342 
00343   // copy from hiroki's code, just take out 'cout'
00344   //
00345 
00346   short shallow = 0;
00347   short deep = 0;
00348 
00349   int exclusive_switch = 0;
00350   // if this is 1, all five bits are excusive.
00351 
00352   for( int quad = 0; quad<max_quad; quad++ ) {
00353     if ( trig_accept[arm][quad] > 0 ) {
00354       if ( trig_accept[arm][quad] == DEEP_ROAD ) {
00355         deep++;
00356       } else if ( trig_accept[arm][quad] == SHALLOW_ROAD ) {
00357         shallow++;
00358       }
00359     }
00360   }
00361      
00362   if ( deep >= 2 ) {
00363     if( exclusive_switch == 1 ) {
00364       return DEEP_DEEP;
00365     }
00366     else {
00367       return DEEP_DEEP + DEEP_SHALLOW + SHALLOW_SHALLOW +
00368         SINGLE_DEEP + SINGLE_SHALLOW;
00369     }
00370   } else if ( deep == 1 && shallow >= 1 ) {
00371     if( exclusive_switch == 1 ) {
00372       return DEEP_SHALLOW;
00373     } else {
00374       return DEEP_SHALLOW + SHALLOW_SHALLOW + SINGLE_DEEP + SINGLE_SHALLOW;
00375     }
00376   } else if ( deep == 1 ) {
00377     if( exclusive_switch == 1 ) {
00378       return SINGLE_DEEP;
00379     } else {
00380       return SINGLE_DEEP + SINGLE_SHALLOW;
00381     }
00382   }
00383   else if ( shallow >= 2 ) {
00384     if( exclusive_switch == 1 ) {
00385       return SHALLOW_SHALLOW;
00386     } else {
00387       return SHALLOW_SHALLOW + SINGLE_SHALLOW;
00388     }
00389   }
00390   else if ( shallow == 1 ) {
00391     return SINGLE_SHALLOW;
00392   } else {
00393     return 0;
00394   } 
00395 }

void dump_reco_blt int    arm [private]
 

Definition at line 810 of file mMuiBLTEmulator.cxx.

References is_reco_1D, is_reco_1D1S, is_reco_1S, and is_reco_2D.

Referenced by check_blt.

00810                                            {
00811 
00812   std::cout << " check on arm : " << arm << " :: " <<std::endl;
00813   std::cout << " reco trigger check from mMuiBLTEmulator " << std::endl;
00814   std::cout << " is_reco_2D::                            " << is_reco_2D(arm) << std::endl;
00815   std::cout << " is_reco_1D1S::                          " << is_reco_1D1S(arm) << std::endl;
00816   std::cout << " is_reco_1D quad0::                      " << is_reco_1D(arm, 0) << std::endl;  
00817   std::cout << " is_reco_1D quad1::                      " << is_reco_1D(arm, 1) << std::endl;  
00818   std::cout << " is_reco_1D quad2::                      " << is_reco_1D(arm, 2) << std::endl;  
00819   std::cout << " is_reco_1D quad3::                      " << is_reco_1D(arm, 3) << std::endl;  
00820   std::cout << " is_reco_1S quad0::                      " << is_reco_1S(arm, 0) << std::endl;  
00821   std::cout << " is_reco_1S quad1::                      " << is_reco_1S(arm, 1) << std::endl;  
00822   std::cout << " is_reco_1S quad2::                      " << is_reco_1S(arm, 2) << std::endl;  
00823   std::cout << " is_reco_1S quad3::                      " << is_reco_1S(arm, 3) << std::endl;  
00824 }

PHBoolean event PHCompositeNode *    [virtual]
 

Definition at line 66 of file mMuiBLTEmulator.cxx.

References _mod_par, _timer, check_blt, fill_map, mMuiBLTEmulatorPar::FROMDST, mMuiBLTEmulatorPar::FROMPRDF, mMuiBLTEmulatorPar::get_debug_flag, get_hits, mMuiBLTEmulatorPar::get_mode, get_raw_data, raw_to_trigpattern, and set_interface_ptrs.

00067 {
00068 
00069   _timer.restart(); 
00070   
00071   try { 
00072 
00073     // Reset IOC pointers
00074     //
00075     set_interface_ptrs(top_node);
00076     // do the initialization for first event.
00077     //
00078     // if(!init_done) initialize();
00079 
00080     // collects all the raw hits/hits information.
00081     //
00082     if(_mod_par->get_mode()==mMuiBLTEmulatorPar::FROMPRDF) get_raw_data();
00083     if(_mod_par->get_mode()==mMuiBLTEmulatorPar::FROMDST) get_hits();
00084     // transfer the hit to trigger primary format.
00085     //
00086     raw_to_trigpattern();
00087     // Fill trigger decisions into pseudo-trigger map.
00088     //
00089     fill_map();
00090     // check blt emualtor according to the hit information.
00091     //
00092     if(_mod_par->get_debug_flag()==1) check_blt();
00093   } catch(std::exception& e) {
00094     MUTOO::TRACE(e.what());
00095     return False;
00096   }  
00097 
00098   // Timer
00099   //
00100   _timer.print(); 
00101   return True;
00102 }

void fill_map   [private]
 

Definition at line 398 of file mMuiBLTEmulator.cxx.

References _blt_map, decision_event, DEEP_DEEP, DEEP_ROAD, DEEP_SHALLOW, TMuiPseudoBLTMapO::insert_new, is_reco_1D, is_reco_1D1S, is_reco_1S, is_reco_2D, max_quad, SHALLOW_ROAD, and trig_accept.

Referenced by event.

00398                           {
00399   
00400   // Take the output from emulator, fill pseudo-BLT map.
00401   //
00402   for(int iarm = 0; iarm < MUIOO::NumberOfArms; iarm++) {
00403     TMuiPseudoBLTMapO::iterator blt_iter = _blt_map->insert_new(iarm);
00404     int pseudoblt_bit = decision_event(iarm);
00405     if( (pseudoblt_bit & DEEP_DEEP) != 0 ) blt_iter->get()->fire_2D();
00406     if( (pseudoblt_bit & DEEP_SHALLOW) != 0 ) blt_iter->get()->fire_1D1S();
00407     for(int iquad = 0; iquad < max_quad; iquad++) {
00408       if(trig_accept[iarm][iquad]==DEEP_ROAD) {
00409         blt_iter->get()->fire_1D(iquad);
00410         blt_iter->get()->fire_1S(iquad);
00411       } else if(trig_accept[iarm][iquad]==SHALLOW_ROAD) {
00412         blt_iter->get()->fire_1S(iquad);
00413       }
00414     }
00415     if(is_reco_2D(iarm)) blt_iter->get()->fire_reco_2D();
00416     if(is_reco_1D1S(iarm)) blt_iter->get()->fire_reco_1D1S();
00417     for(int iquad = 0; iquad < max_quad; iquad++) {
00418       if(is_reco_1D(iarm,iquad)) blt_iter->get()->fire_reco_1D(iquad);
00419       if(is_reco_1S(iarm,iquad)) blt_iter->get()->fire_reco_1S(iquad);
00420     }
00421   }
00422 }

void get_hits   [private]
 

Definition at line 127 of file mMuiBLTEmulator.cxx.

References _hit_map, and word.

Referenced by event.

00127                               {
00128   // Loop through mui hit map, fill word array 
00129   // muioo hit is organized by (arm, plane, panel, orientation, twopack),
00130   // but word array is organized by FEM address and every word uses its
00131   // low 16 bits to store 16 twopacks, we need to map muioo hit into 
00132   // low 16 bits of each word in word array. This transform is taken care by
00133   // TMuiChannelId and TMuiAddressTable::Table()->HardwareAddress(TMuiChannelId).
00134   // Here I just call them.
00135   //
00136 
00137   // clear word array for each event.
00138   //
00139   for(int iarm = 0; iarm < MUIOO::NumberOfArms; iarm++){
00140     for(int iorient = 0; iorient < MUIOO::MAX_ORIENTATION; iorient++) {
00141       for(int iword = 0; iword < MUIOO::kWordsPerFEM; iword++) {
00142         word[iarm][iorient][iword] = 0;
00143       }
00144     }
00145   }
00146 
00147   TMuiHitMapO::const_iterator hit_iter = _hit_map->range();
00148   while(TMuiHitMapO::const_pointer hit_ptr = hit_iter.next()){
00149     EOrient_t orientation = kVERT;
00150     if(hit_ptr->get()->get_orientation()==0) orientation = kHORIZ;
00151     
00152     TMuiChannelId muichannel(hit_ptr->get()->get_arm(),
00153                              hit_ptr->get()->get_plane(),
00154                              hit_ptr->get()->get_panel(),
00155                              orientation,
00156                              hit_ptr->get()->get_twopack());
00157     TMuiReadoutID hardware = TMuiAddressTable::Table()->HardwareAddress(muichannel);
00158     int iword = hardware.ROC()*MUIOO::kWordsPerROC+hardware.Word();
00159     int ibit  = hardware.Channel();
00160 
00161     word[hit_ptr->get()->get_arm()][hit_ptr->get()->get_orientation()][iword] |= (0x01<<ibit);  
00162   }
00163 }

int get_non_used_plane   [inline, private]
 

Definition at line 120 of file mMuiBLTEmulator.h.

References _non_used_plane.

Referenced by initialize, and raw_to_trigpattern.

00120 { return _non_used_plane;}

int get_quad float    x,
float    y,
float    z
[private]
 

Definition at line 774 of file mMuiBLTEmulator.cxx.

Referenced by is_reco_1D, and is_reco_1S.

00774                                                        {
00775   
00776   if( x>= 0 && y >= 0 ) return 3;
00777   if( x>= 0 && y <= 0 ) return 1;
00778   if( x<= 0 && y >= 0 ) return 2;
00779   if( x<= 0 && y <= 0 ) return 0;
00780   
00781   // not reached
00782   return -1;
00783 }

void get_raw_data   [private]
 

Definition at line 105 of file mMuiBLTEmulator.cxx.

References _event, max_arm, and word.

Referenced by event.

00105                               {
00106   // get raw data from event_node. then store it into 
00107   // arry word[arm][orientation][iword].
00108   // Tatally there are 120 words per orientation, and the low 16 bits
00109   // in each word represents 16 twopacks. 
00110   //
00111   Packet* p;  
00112   static const int id_base[max_arm] = {12001, 12003}; // for South and North
00113 
00114   for(int iarm = 0; iarm < MUIOO::NumberOfArms; iarm++) {
00115     for(int iorient = 0; iorient < MUIOO::MAX_ORIENTATION; iorient++) {
00116       int pack_id = id_base[iarm] + iorient;
00117       if((p=_event->getPacket(pack_id))!=0) {
00118         for(int iword = 0; iword < MUIOO::kWordsPerFEM; iword++) {
00119           word[iarm][iorient][iword] = p->iValue(iword);
00120         }
00121         delete p;
00122       }
00123     }
00124   }
00125 }

void initialize int    runno
 

Definition at line 444 of file mMuiBLTEmulator.cxx.

References _mod_par, mMuiBLTEmulatorPar::get_mlu_map, get_non_used_plane, init_done, mlu_address_max, mlu_data_d, mlu_data_s, read_mlu_data, and set_non_used_plane.

00444                                              {
00445 
00446   // initialize of non_used_plane
00447   const int nup_max = 3; // non_used_plane
00448   int nup_begin[nup_max];
00449   int nup_end[nup_max];
00450   int nup[nup_max];
00451   
00452   int init_done = 0;
00453 
00454   nup_begin[0] = 35758;
00455   nup[0] = 1;
00456   nup_end[0] = 40655; // end of Run-2
00457   nup_begin[1] = 40656; // It is not certain when it changed?
00458   nup[1] = 2;
00459   nup_end[1] = 71869;  
00460   nup_begin[2] = 71870;  // Nobu
00461   nup[2] = 4;
00462   nup_end[2] = 9999999; // current configuration
00463 
00464   //  int runNumber= 0;
00465   //if(_event) {
00466   //  runNumber = _event->getRunNumber();
00467   //} else {
00468   //  recoConsts* rc = recoConsts::instance();
00469   //  runNumber = rc->get_IntFlag("RUNNUMBER",80312);
00470   //  cout << " mMuiBLTEmulator :: the runNumber we get from this analysis is " << runNumber << endl; 
00471   // }
00472 
00473   int nup_found = 0;
00474   for ( int nup_set = 0; nup_set < nup_max; nup_set++ ) {
00475     if ( runNumber >= nup_begin[nup_set] && 
00476          runNumber <= nup_end[nup_set] ) {
00477       set_non_used_plane(nup[nup_set]);
00478       nup_found = 1;
00479       cout << " mMuiPsedoTrigger Non_Used_Plane was set to "
00480            << get_non_used_plane() << endl;
00481     }
00482   }
00483   if( !nup_found ) {
00484     cout << " mMuiPsedoTrigger Non_Used_Plane was not found for Run "
00485          << runNumber  << endl;
00486     cout << "   Default value " << get_non_used_plane() << " will be used " << endl;
00487   }
00488 
00489   //Let's see if the database contains a time stamp for this run number,
00490   // if so we'll try to get the map from the database.
00491   init_done = -1;
00492   bool db_init_done = false;
00493   RunToTimeObjy runTime;
00494   PHTimeStamp *beginTime = runTime.getBeginTime(runNumber);
00495   if (beginTime)
00496   {
00497     PdbBankManager *bankManager = PdbObjyBankManager::instance();
00498     PdbApplication *application = bankManager->getApplication();  
00499     if (application->startRead()) {
00500       PdbMuiTriggerMLU *achan;
00501       PdbBankID shortbankID("*.calib.mui.muitriggermlu");
00502       shortbankID.setInternalValue(0);  //Shallow MLU will be 0
00503       PdbCalBank* shortBank =
00504         bankManager->fetchBank("PdbMuiTriggerMLUBank",shortbankID,"calib.mui.muitriggermlu",runNumber);
00505        //We are good to go!
00506           //First the shallow
00507       if(shortBank > 0)
00508       {
00509         shortBank->print();
00510           PdbMuiTriggerMLU *achan;
00511           if(shortBank->getLength()<=mlu_address_max){
00512             for(unsigned int wordid = 0; wordid < shortBank->getLength(); wordid++)
00513             {
00514               achan = (PdbMuiTriggerMLU*)&(shortBank->getEntry(wordid));
00515               mlu_data_s[wordid]=achan->MLUword();
00516             }
00517             db_init_done = true;
00518           }
00519           else
00520           {
00521             cout << PHWHERE << "More data in database than expected."<<endl;
00522             db_init_done = false;
00523           }
00524           delete shortBank;
00525       }
00526       else
00527       {
00528         cout << PHWHERE << "Map wasn't found in database."<<endl;
00529       }
00530       PdbBankID deepbankID("*.calib.mui.muitriggermlu");
00531       deepbankID.setInternalValue(1);  //Deep MLU will be 1
00532       PdbCalBank* deepBank =
00533         bankManager->fetchBank("PdbMuiTriggerMLUBank",deepbankID,"calib.mui.muitriggermlu",runNumber);
00534       if(deepBank > 0)
00535       {
00536         deepBank->print();
00537         //Now the deep
00538         if(deepBank->getLength()<=mlu_address_max){
00539           for(unsigned int wordid = 0; wordid < deepBank->getLength(); wordid++)
00540           {
00541             achan = (PdbMuiTriggerMLU*)&(deepBank->getEntry(wordid));
00542             mlu_data_d[wordid]=achan->MLUword();
00543           }
00544           db_init_done = true;
00545           delete deepBank;
00546         }
00547         else
00548         {
00549           cout << PHWHERE << "More data in database than expected."<<endl;
00550           db_init_done = false;
00551         }
00552       }
00553       else
00554       {
00555         cout << PHWHERE << "Map wasn't found in database."<< endl;
00556       }
00557 
00558       application->commit();
00559     }
00560     else
00561     {
00562       cout << PHWHERE << "Failed to start application for update" << endl;
00563     }
00564      delete beginTime;
00565   }
00566   if(db_init_done)
00567   {
00568     init_done = 1;
00569     return ;
00570   }
00571   else
00572   {
00573     cout<< PHWHERE << "Map not found in database will try local files."<< endl;
00574   }
00575 
00576   int map_select = _mod_par->get_mlu_map();
00577   char* mlu_file_d;
00578   char* mlu_file_d1 = "mui_pseudotrigmap_deep_mh1.dat";
00579   char* mlu_file_d2 = "mui_pseudotrigmap_deep_mh2.dat";
00580   // MLU data file for deep roads
00581   char* mlu_file_s = "mui_pseudotrigmap_shallow.dat";
00582   int run_pp_begin = 35758;
00583   int run_change_deep = 38189;
00584   int run_pp_end = 40655;
00585   
00586   if( map_select == 1 || map_select == 0 && ( (runNumber >= run_pp_begin) && (runNumber < run_change_deep) ) )  {
00587     mlu_file_d = mlu_file_d1;
00588   }
00589   else if( (map_select == 2 ) || map_select == 0 && ( (runNumber >= run_change_deep) && (runNumber <= run_pp_end) ) ) {
00590     mlu_file_d = mlu_file_d2;
00591   }
00592   else { 
00593     cout << " mMuiPseudoTrigger: This is not pp Run2 or simulation" << endl;
00594     cout << "   No MLU map was read" << endl;
00595     return;
00596   }
00597 
00598   if( read_mlu_data( mlu_data_d, mlu_file_d ) ) {
00599       cout << "mMuiPsedoTrigger; MLU data for deep roads " 
00600            << mlu_file_d << " was read" << endl;    
00601   }
00602   else {
00603     return;
00604   }
00605 
00606   if( read_mlu_data( mlu_data_s, mlu_file_s ) ) {
00607       cout << "mMuiPsedoTrigger; MLU data for shallow roads " 
00608            << mlu_file_s << " was read" << endl;    
00609   }
00610   else {
00611     return;
00612   } 
00613 
00614    init_done = 1;
00615 }

bool is_reco_1D int    arm,
int    quad
[private]
 

Definition at line 669 of file mMuiBLTEmulator.cxx.

References _hit_map, TMuiHitMapO::get, and get_quad.

Referenced by dump_reco_blt, fill_map, is_reco_1D1S, and is_reco_2D.

00669                                                   {
00670 
00671   int nhit_quad = 0;
00672   
00673   for(int iplane = 0; iplane < MUIOO::MAX_PLANE-1; iplane++) {
00674     for(int iorient = 0; iorient < MUIOO::MAX_ORIENTATION; iorient++){
00675       int find_flag = 0;
00676       for(int ipanel = 0; ipanel < MUIOO::MAX_PANEL; ipanel++) {
00677         TMuiHitMapO::const_iterator mui_hit_iter = _hit_map->get(arm,iplane,ipanel,iorient);
00678         while(TMuiHitMapO::const_pointer mui_hit_ptr = mui_hit_iter.next()){
00679           TMuiMCHitMapO::const_key_iterator mc_hit_iter = mui_hit_ptr->get()->get_associated<TMuiMCHitO>();
00680           while(TMuiMCHitMapO::const_pointer mc_hit_ptr = mc_hit_iter.next()) {
00681             // if the hit is in big panel( 0, 2, 3, 5) we can decide it's quadrant directly,
00682             // if the hit is in small panel(1, 4) and on horizental plane, it contributes to
00683             // both left and right quadrants, if the hit is in small panel and verticle plane,
00684             // we have to relay on mchit x/y position to decide the quadrant.
00685             //
00686             int iquad = -1;
00687 
00688             if(ipanel == 3 ||(ipanel == 4 && iorient == 0) ) {
00689               iquad = 0;
00690               if(quad==iquad) find_flag = 1;
00691             }
00692             if(ipanel == 5 ||(ipanel == 4 && iorient == 0)) {
00693               iquad = 1;
00694               if(quad==iquad) find_flag = 1;
00695             }
00696             if(ipanel == 2 ||(ipanel == 1 && iorient == 0)) {
00697               iquad = 2;
00698               if(quad==iquad) find_flag = 1;
00699             }
00700             if(ipanel == 0 ||(ipanel == 1 && iorient == 0)) {
00701               iquad = 3;
00702               if(quad==iquad) find_flag = 1;
00703             }
00704             if(iorient == 1 && (ipanel==4||ipanel==1)){
00705               iquad = get_quad(mc_hit_ptr->get()->get_x(),
00706                                mc_hit_ptr->get()->get_y(), 
00707                                mc_hit_ptr->get()->get_z());
00708               if(quad==iquad) find_flag = 1; 
00709             }
00710           }
00711         }
00712       }
00713       if(find_flag) nhit_quad++;
00714     }
00715   }
00716   if(nhit_quad >=7 ) return true;
00717   
00718   return false;
00719 }

bool is_reco_1D1S int    arm [private]
 

Definition at line 657 of file mMuiBLTEmulator.cxx.

References is_reco_1D, and is_reco_1S.

Referenced by check_blt, dump_reco_blt, and fill_map.

00657                                           {
00658   for(int iquad1 = 0; iquad1 < 4; iquad1++) {
00659     if(is_reco_1D(arm, iquad1)) {
00660       for(int iquad2=0; iquad2<4; iquad2++) {
00661         if(iquad2==iquad1) continue;
00662         if(is_reco_1D(arm,iquad2) || is_reco_1S(arm,iquad2)) return true;
00663       }
00664     }
00665   }
00666   return false;
00667 }

bool is_reco_1S int    arm,
int    quad
[private]
 

Definition at line 721 of file mMuiBLTEmulator.cxx.

References _hit_map, TMuiHitMapO::get, and get_quad.

Referenced by dump_reco_blt, fill_map, and is_reco_1D1S.

00721                                                   {
00722 
00723   int nhit_quad = 0;
00724   
00725   for(int iplane = 0; iplane < MUIOO::MAX_PLANE-3; iplane++) {
00726     for(int iorient = 0; iorient < MUIOO::MAX_ORIENTATION; iorient++){
00727       int find_flag = 0;
00728       for(int ipanel = 0; ipanel < MUIOO::MAX_PANEL; ipanel++) {
00729         TMuiHitMapO::const_iterator mui_hit_iter = _hit_map->get(arm,iplane,ipanel,iorient);
00730         while(TMuiHitMapO::const_pointer mui_hit_ptr = mui_hit_iter.next()){
00731           TMuiMCHitMapO::const_key_iterator mc_hit_iter = mui_hit_ptr->get()->get_associated<TMuiMCHitO>();
00732           while(TMuiMCHitMapO::const_pointer mc_hit_ptr = mc_hit_iter.next()) {
00733             // if the hit is in big panel( 0, 2, 3, 5) we can decide it's quadrant directly,
00734             // if the hit is in small panel(1, 4) and on horizental plane, it contributes to
00735             // both left and right quadrants, if the hit is in small panel and verticle plane,
00736             // we have to relay on mchit x/y position to decide the quadrant.
00737             //
00738             int iquad = -1;
00739             if(ipanel == 3 ||(ipanel == 4 && iorient == 0) ) {
00740               iquad = 0;
00741               if(quad==iquad) find_flag = 1;
00742             } 
00743             if(ipanel == 5 ||(ipanel == 4 && iorient == 0)) {
00744               iquad = 1;
00745               if(quad==iquad) find_flag = 1;
00746             }
00747             if(ipanel == 2 ||(ipanel == 1 && iorient == 0)) {
00748               iquad = 2;
00749               if(quad==iquad) find_flag = 1;
00750             }
00751             if(ipanel == 0 ||(ipanel == 1 && iorient == 0)) {
00752               iquad = 3;
00753               if(quad==iquad) find_flag = 1;
00754             }
00755             if(iorient == 1 && (ipanel==4||ipanel==1)) {
00756               iquad = get_quad(mc_hit_ptr->get()->get_x(),
00757                                mc_hit_ptr->get()->get_y(), 
00758                                mc_hit_ptr->get()->get_z());
00759               if(quad==iquad) find_flag = 1; 
00760             }
00761           }
00762         }
00763       }
00764       if(find_flag) nhit_quad++;
00765     }
00766   }
00767 
00768   if(nhit_quad >=3 ) return true;
00769   
00770   return false;
00771 }

bool is_reco_2D int    arm [private]
 

Definition at line 644 of file mMuiBLTEmulator.cxx.

References is_reco_1D.

Referenced by check_blt, dump_reco_blt, and fill_map.

00644                                         {
00645 
00646   for(int iquad1 = 0; iquad1 < 4; iquad1++) {
00647     if(is_reco_1D(arm, iquad1)) {
00648       for(int iquad2=0; iquad2<4; iquad2++) {
00649         if(iquad2==iquad1) continue;
00650         if(is_reco_1D(arm,iquad2)) return true;
00651       }
00652     }
00653   }
00654   return false;
00655 }

int quad_fire int *    quad_trig_pattern,
int *    mlu_data
[private]
 

Referenced by decision_event.

void raw_to_trigpattern   [private]
 

Definition at line 165 of file mMuiBLTEmulator.cxx.

References get_non_used_plane, max_quad, trig_pattern, and word.

Referenced by event.

00165                                          {
00166 
00167   // This whole piece is taken directly from Hiroki's code without any changes. Except for
00168   // using three/four dimension array to handle two arm at the same time. I was very careful about 
00169   // this little change.
00170   //
00171 
00172   // convert FEM word[iarm(0-1)][ifem(0-1)][word 0-119](0-0xffff) to trig_pattern[iarm(0-1)][quad(0-3)][plane(0-3)](0-15)
00173 
00174   const int max_sector = 8;
00175   int trig_bit[MUIOO::NumberOfArms][MUIOO::MAX_ORIENTATION][MUIOO::MAX_PLANE-1][max_sector];
00176   for(int iarm = 0; iarm < MUIOO::NumberOfArms; iarm++) {
00177     for ( int iorient = 0; iorient<MUIOO::MAX_ORIENTATION; iorient++ ) {
00178       for ( int iplane = 0; iplane<MUIOO::MAX_PLANE-1; iplane++ ){
00179         for ( int k = 0; k<max_sector; k++ ) {
00180           trig_bit[iarm][iorient][iplane][k] = 0;
00181         }
00182       }
00183     }
00184   }
00185 
00186   // use lower 16 bits of each word
00187   for(int iarm = 0; iarm < MUIOO::NumberOfArms; iarm++) {
00188     for( int iorient = 0; iorient<MUIOO::MAX_ORIENTATION; iorient++ ) {
00189       for ( int iword = 0; iword<MUIOO::kWordsPerFEM; iword++ ) {
00190         word[iarm][iorient][iword] = word[iarm][iorient][iword] & 0xffff;
00191       }
00192     }
00193   }
00194   // word -> trig_bit
00195 
00196   for(int iarm = 0; iarm < MUIOO::NumberOfArms; iarm++) {
00197     int plane_new = 0;
00198     for ( int plane = 0; plane<MUIOO::MAX_PLANE; plane++ ) {
00199       // There are 5 planes int word[][][], but only 4 planes in trig_bit[][][]
00200       if ( plane != get_non_used_plane()) { 
00201         for ( int sector = 0; sector<max_sector; sector++ ) {
00202           if ( sector % 2 == 0 ) {
00203             trig_bit[iarm][ 0 ][ plane_new ][ sector ] = 
00204             word[iarm][ 0 ][ plane*24 + sector*3  + 0 ]
00205             + word[iarm][ 0 ][ plane*24 + sector*3 + 1 ] 
00206             + word[iarm][ 0 ][ plane*24 + sector*3 + 2 ] 
00207             + word[iarm][ 0 ][ plane*24 + sector*3 + 3 ] ;
00208           }
00209           else {
00210             trig_bit[iarm][ 0 ][ plane_new ][ sector ] = 
00211               word[iarm][ 0 ][ plane*24 + (sector-1)*3 + 2 ]
00212               + word[iarm][ 0 ][ plane*24 + (sector-1)*3 + 3 ]
00213               + word[iarm][ 0 ][ plane*24 + (sector-1)*3 + 4 ]
00214               + word[iarm][ 0 ][ plane*24 + (sector-1)*3 + 5 ];
00215           }
00216           for ( int iword = 0; iword<3; iword++ ) {
00217             trig_bit[iarm][ 1 ][ plane_new ][ sector ]
00218               += word[iarm][ 1 ][ plane*24 + sector*3 + iword ]; 
00219           }
00220         }
00221         plane_new++;
00222       }
00223     }
00224   }
00225   // take "OR"
00226   for(int iarm = 0; iarm < MUIOO::NumberOfArms; iarm++) {
00227     for ( int iorient = 0; iorient < MUIOO::MAX_ORIENTATION; iorient++){ // orientation
00228       for ( int iplane = 0; iplane < MUIOO::MAX_PLANE-1; iplane++ ){ // plane
00229         for ( int k = 0; k<max_sector; k++ ) { //sector
00230           if ( trig_bit[iarm][iorient][iplane][k] != 0 ) { 
00231             trig_bit[iarm][iorient][iplane][k] = 1;
00232           }
00233         }
00234       }
00235     }
00236   }
00237   // trig_bit -> trig_pattern
00238   for(int iarm = 0; iarm < MUIOO::NumberOfArms; iarm++) {
00239     for ( int iquad = 0; iquad<max_quad; iquad++ ) {
00240       for ( int iplane = 0; iplane < MUIOO::MAX_PLANE-1; iplane++ ){ // plane
00241         trig_pattern[iarm][iquad][iplane] = 0;
00242       }
00243     }
00244   }
00245  
00246   // Chun :: horizental and vertial planes have different sector configuration.
00247   //         horizental :: sector    6 4 2 0   quadrant 3   1 
00248   //
00249   //
00250   //                                 7 5 3 1            4   2
00251   //
00252   //         vertical   :: sector    1     0   quadrant 3   1
00253   //                                 3     2
00254   //                                 5     4
00255   //                                 7     6            4   2
00256   //
00257   for(int iarm = 0; iarm < MUIOO::NumberOfArms; iarm++) {
00258     for( int plane = 0; plane<MUIOO::MAX_PLANE-1; plane++ ){
00259       trig_pattern[iarm][0][plane] 
00260         += trig_bit[iarm][0][plane][0] * (int)pow( 2.0, 1 )
00261         + trig_bit[iarm][0][plane][2] * (int)pow( 2.0, 0 ) 
00262         + trig_bit[iarm][1][plane][0] * (int)pow( 2.0, 3 )
00263         + trig_bit[iarm][1][plane][2] * (int)pow( 2.0, 2 );
00264       trig_pattern[iarm][1][plane] 
00265         += trig_bit[iarm][0][plane][1] * (int)pow( 2.0, 1 )
00266         + trig_bit[iarm][0][plane][3] * (int)pow( 2.0, 0 ) 
00267         + trig_bit[iarm][1][plane][4] * (int)pow( 2.0, 2 )
00268         + trig_bit[iarm][1][plane][6] * (int)pow( 2.0, 3 );
00269       trig_pattern[iarm][2][plane] 
00270         += trig_bit[iarm][0][plane][4] * (int)pow( 2.0, 0 )
00271         + trig_bit[iarm][0][plane][6] * (int)pow( 2.0, 1 ) 
00272         + trig_bit[iarm][1][plane][1] * (int)pow( 2.0, 3 )
00273         + trig_bit[iarm][1][plane][3] * (int)pow( 2.0, 2 );
00274       trig_pattern[iarm][3][plane] 
00275         += trig_bit[iarm][0][plane][5] * (int)pow( 2.0, 0 )
00276         + trig_bit[iarm][0][plane][7] * (int)pow( 2.0, 1 ) 
00277         + trig_bit[iarm][1][plane][5] * (int)pow( 2.0, 2 )
00278         + trig_bit[iarm][1][plane][7] * (int)pow( 2.0, 3 );
00279     }
00280   }
00281 }

bool read_mlu_data int *    mlu_data_d,
char *    mlu_data_file
 

Definition at line 617 of file mMuiBLTEmulator.cxx.

References mlu_address_max.

Referenced by initialize.

00617                                                                                    {
00618 
00619   for ( int i = 0; i<mlu_address_max; i++ ) {
00620     mlu_word[i] = 0;
00621   }
00622 
00623   FILE* fp;
00624   if ( !( fp = fopen( mlu_data_file, "r" ))) {
00625     printf(" mMuiPseudoTrigger: Input file '%s' can not be opened\n",mlu_data_file);
00626    return False;
00627   }
00628   int scan_data;
00629   for ( int i = 0; i<mlu_address_max; i++ ) {
00630     if ( fscanf( fp, "%x\n", &scan_data ) != EOF ) {
00631       mlu_word[i] = scan_data;
00632     }
00633     else {
00634       printf(" mMuiPseudoTrigger: unable to read %d th line of '%s'\n", i, mlu_data_file);
00635       return False;
00636     }
00637   }
00638   fclose( fp );
00639 
00640   return True;
00641 
00642 }

void set_interface_ptrs PHCompositeNode *    top_node [private]
 

Reset IOC and external interface pointers

Definition at line 426 of file mMuiBLTEmulator.cxx.

References _blt_map, _event, _hit_map, _mod_par, mMuiBLTEmulatorPar::FROMDST, mMuiBLTEmulatorPar::FROMPRDF, and mMuiBLTEmulatorPar::get_mode.

Referenced by event.

00426                                                             {  
00427   // module runtime parameters
00428   //
00429   _mod_par    = TMutNode<mMuiBLTEmulatorPar>::find_node(top_node,"mMuiBLTEmulatorPar");
00430   // interface map 
00431   //
00432   _blt_map    = TMutNode<TMuiPseudoBLTMapO>::find_node(top_node,"TMuiPseudoBLTMapO");
00433 
00434   if(_mod_par->get_mode()==mMuiBLTEmulatorPar::FROMPRDF){
00435     _event = TMutNode<Event>::find_node(top_node,"PRDF");
00436     _hit_map = 0;
00437   }
00438   if(_mod_par->get_mode()==mMuiBLTEmulatorPar::FROMDST){
00439     _event = 0;
00440     _hit_map    = TMutNode<TMuiHitMapO>::find_node(top_node,"TMuiHitMapO");
00441   }
00442 } 

void set_non_used_plane int    plane [inline, private]
 

Definition at line 123 of file mMuiBLTEmulator.h.

References _non_used_plane.

Referenced by initialize.

00123 { _non_used_plane = plane;}


Member Data Documentation

TMuiPseudoBLTMapO* _blt_map [private]
 

Definition at line 159 of file mMuiBLTEmulator.h.

Referenced by check_blt, fill_map, and set_interface_ptrs.

Event* _event [private]
 

Definition at line 160 of file mMuiBLTEmulator.h.

Referenced by get_raw_data, and set_interface_ptrs.

TMuiHitMapO* _hit_map [private]
 

Definition at line 158 of file mMuiBLTEmulator.h.

Referenced by check_blt, get_hits, is_reco_1D, is_reco_1S, and set_interface_ptrs.

const mMuiBLTEmulatorPar* _mod_par [private]
 

Definition at line 157 of file mMuiBLTEmulator.h.

Referenced by event, initialize, and set_interface_ptrs.

int _non_used_plane [private]
 

Definition at line 169 of file mMuiBLTEmulator.h.

Referenced by get_non_used_plane, mMuiBLTEmulator, and set_non_used_plane.

PHTimer _timer [private]
 

Definition at line 181 of file mMuiBLTEmulator.h.

Referenced by event.

int init_done [private]
 

Definition at line 177 of file mMuiBLTEmulator.h.

Referenced by initialize, and mMuiBLTEmulator.

int mlu_data_d[mlu_address_max] [private]
 

Definition at line 167 of file mMuiBLTEmulator.h.

Referenced by decision_event, and initialize.

int mlu_data_s[mlu_address_max] [private]
 

Definition at line 165 of file mMuiBLTEmulator.h.

Referenced by decision_event, and initialize.

int trig_accept[max_arm][max_quad] [private]
 

Definition at line 173 of file mMuiBLTEmulator.h.

Referenced by decision_event, decision_mlu, and fill_map.

int trig_pattern[max_arm][max_quad][max_plane] [private]
 

Definition at line 171 of file mMuiBLTEmulator.h.

Referenced by decision_event, and raw_to_trigpattern.

long word[max_arm][max_fem][word_per_fem] [private]
 

Definition at line 163 of file mMuiBLTEmulator.h.

Referenced by get_hits, get_raw_data, and raw_to_trigpattern.


The documentation for this class was generated from the following files:
MUIOO: PHENIX Muon Identifier Analysis Framework. Documentation by doxygen
Last modified: