/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Electronics.cc
Go to the documentation of this file.
00001 #include "Conventions/Electronics.h"
00002 
00003 DayaBay::ElecChannelId::ElecChannelId(int board, int connector,
00004                                   Site::Site_t site,
00005                                   DetectorId::DetectorId_t det)
00006   : Detector(site,det)
00007 {
00008   m_data += (0x000000ff & connector) | (0x000000ff & board)<<8;
00009 }
00010 
00011 
00012 DayaBay::ElecChannelId::~ElecChannelId() {}
00013 
00014 
00015 int DayaBay::ElecChannelId::board() const
00016 {
00017   return (m_data & 0x0000ff00)>>8;
00018 }
00019 
00020 int DayaBay::ElecChannelId::connector() const
00021 {
00022   return (m_data & 0x000000ff);
00023 }
00024 
00025 bool DayaBay::ElecChannelId::bogus() const
00026 {
00027   if (this->Detector::bogus()) return true;
00028   // require nonzero ID
00029   return ! (m_data & 0x0000ffff);
00030 }
00031 
00032 DayaBay::FeeChannelId::~FeeChannelId()
00033 {
00034 }
00035 
00036 DayaBay::FeeChannelId DayaBay::FeeChannelId::boardId() const
00037 {
00038   return DayaBay::FeeChannelId(m_data & 0xffffff00);
00039 }
00040 
00041 bool DayaBay::FeeChannelId::bogus() const
00042 {
00043   return this->ElecChannelId::bogus();
00044 
00045   // FIXME: fill in FEE-specific bogosity testing
00046 
00047 }
00048 
00049 DayaBay::FadcChannelId::~FadcChannelId()
00050 {
00051 }
00052 
00053 DayaBay::FadcChannelId DayaBay::FadcChannelId::boardId() const
00054 {
00055   return DayaBay::FeeChannelId(m_data & 0xffffff00);
00056 }
00057 
00058 
00059 int  DayaBay::FadcChannelId::outputId() const
00060 {
00061     if (connector()>16) return 0;
00062     int board = m_data & 0xffffff00;
00063     int connector = m_data & 0x000000ff;
00064     return ( board | ( 16 + (connector+1)/2) );
00065 }
00066 
00067 int  DayaBay::FadcChannelId::firstInputId() const
00068 {
00069     if (connector()<=16) return 0;
00070     int board = m_data & 0xffffff00;
00071     int connector = m_data & 0x000000ff;
00072     return ( board | ((connector-16)*2-1) );
00073 }
00074 
00075 int  DayaBay::FadcChannelId::secondInputId() const
00076 {
00077     if (connector()<=16) return 0;
00078     int board = m_data & 0xffffff00;
00079     int connector = m_data & 0x000000ff;
00080     return ( board | ((connector-16)*2) );
00081 }
00082 
00083 bool DayaBay::FadcChannelId::bogus() const
00084 {
00085   return this->ElecChannelId::bogus();
00086 
00087   // FIXME: fill in FADC-specific bogosity testing
00088 
00089 }
00090 
00091 DayaBay::FecChannelId::~FecChannelId()
00092 {
00093 }
00094 
00095 DayaBay::FecChannelId DayaBay::FecChannelId::boardId() const
00096 {
00097   return DayaBay::FecChannelId(m_data & 0xffffff00);
00098 }
00099 
00100 unsigned int DayaBay::FecChannelId::cfId() const
00101 {
00102     return convertToCfId((0xff00 & m_data) >> 8);
00103 }
00104 
00105 unsigned int DayaBay::FecChannelId::fecId() const
00106 {
00107     return convertToFecId((0xff00 & m_data)>>8);
00108 }
00109 
00110 unsigned int DayaBay::FecChannelId::rtmCfId() const
00111 {
00112     return cfId() >> 1;
00113 }
00114 
00115 unsigned int DayaBay::FecChannelId::rtmRotId() const
00116 {
00117     return cfId() & 1;
00118 }
00119 
00120 unsigned int DayaBay::FecChannelId::fecHit() const
00121 {
00122     return 1<<(0xff & m_data);
00123 }
00124 
00125 int DayaBay::FecChannelId::convertToBoard(unsigned int cfId, unsigned int fecId) const
00126 {
00127   return ((0x07 & cfId) << 4) | (0x0f &fecId);
00128 }
00129 
00130 unsigned int DayaBay::FecChannelId::convertToCfId(int board) const
00131 {
00132   return (0x70 & board) >> 4;
00133 }
00134 
00135 unsigned int DayaBay::FecChannelId::convertToFecId(int board) const
00136 {
00137   return (0x0f & board);
00138 }
00139 
00140 std::ostream& DayaBay::operator<<(std::ostream& str,
00141                                   const DayaBay::ElecChannelId& elecChannelId)
00142 {
00143     return str
00144       << "[" << (void*)elecChannelId.fullPackedData() << "] "
00145       << Site::AsString(elecChannelId.site())
00146       << DetectorId::AsString(elecChannelId.detectorId())
00147       << "("<<elecChannelId.board()
00148       <<","<<elecChannelId.connector()<<")";
00149 }
00150 
00151 bool DayaBay::FecChannelId::bogus() const
00152 {
00153     if (this->Detector::bogus()) return true;
00154 
00155     if ((m_data & 0x000000ff) > 32) // too many connectors
00156         return true;
00157 
00158     Site::Site_t siteid = site();
00159     int cfid = (m_data & 0x0000f000) >> 12;
00160     int fecid = (m_data & 0x00000f00) >> 8;
00161 
00162     if (siteid == Site::kFar && cfid > 5) // too many CFs
00163         return true;
00164 
00165     if (siteid == Site::kDayaBay && cfid > 3) // too many CFs
00166         return true;
00167 
00168     if (siteid == Site::kLingAo && cfid > 3) // too many CFs
00169         return true;
00170 
00171     if (fecid > 14)
00172       return true;
00173   // FIXME: add FEC-channel bogosity testing
00174     return false;
00175 }
00176 
00177 // Local Variables: **
00178 // c-basic-offset:2 **
00179 // End: **
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:56:19 for Conventions by doxygen 1.7.4