/search.css" rel="stylesheet" type="text/css"/> /search.js">
00001 00009 #ifndef CONVENTIONS_ELECTRONICS_H 00010 #define CONVENTIONS_ELECTRONICS_H 1 00011 00012 #include "Conventions/Detectors.h" 00013 #include "CLHEP/Units/SystemOfUnits.h" 00014 #include <vector> 00015 00019 namespace DayaBay { 00020 00021 typedef std::vector<int> DigitalSignal; 00022 typedef std::vector<double> AnalogSignal; 00023 00027 class ElecChannelId : public Detector { 00028 public: 00030 ElecChannelId() : Detector(0) {} 00031 00033 ElecChannelId(int board, int connector, 00034 Site::Site_t site, 00035 DetectorId::DetectorId_t det); 00036 00038 ElecChannelId(const ElecChannelId& channel) : Detector(channel) {} 00039 00041 ElecChannelId(int data) : Detector(data) {} 00042 virtual ~ElecChannelId(); 00043 00045 ElecChannelId& operator=(const ElecChannelId& id) 00046 { m_data = id.m_data; return *this; } 00047 00049 int board() const; 00050 00053 int connector() const; 00054 00056 virtual bool bogus() const; 00057 }; 00058 00077 class FeeChannelId : public ElecChannelId { 00078 public: 00079 FeeChannelId() : ElecChannelId(0) {} 00080 FeeChannelId(int board, int connector, 00081 Site::Site_t site, DetectorId::DetectorId_t det) : 00082 ElecChannelId(board, connector, site, det) {} 00083 FeeChannelId(const FeeChannelId& channel) : ElecChannelId(channel) {} 00084 FeeChannelId(int data) : ElecChannelId(data) {} 00085 virtual ~FeeChannelId(); 00086 // Assignment Operator 00087 FeeChannelId& operator=(const FeeChannelId& id) 00088 { m_data = id.m_data; return *this; } 00089 00091 FeeChannelId boardId() const; 00092 00094 virtual bool bogus() const; 00095 00096 }; 00097 00104 class FadcChannelId : public ElecChannelId { 00105 public: 00106 FadcChannelId() : ElecChannelId(0) {} 00107 FadcChannelId(int connector, 00108 Site::Site_t site, DetectorId::DetectorId_t det) : 00109 ElecChannelId(20, connector, site, det) {} 00110 FadcChannelId(int board, int connector, 00111 Site::Site_t site, DetectorId::DetectorId_t det) : 00112 ElecChannelId(board, connector, site, det) {} 00113 FadcChannelId(const FeeChannelId& channel) : ElecChannelId(channel) {} 00114 FadcChannelId(int data) : ElecChannelId(data) {} 00115 virtual ~FadcChannelId(); 00116 // Assignment Operator 00117 FadcChannelId& operator=(const FadcChannelId& id) 00118 { m_data = id.m_data; return *this; } 00119 00120 // Return the electronics identifier of the entire board 00121 FadcChannelId boardId() const; 00122 // given an input channel return the channel Id of the output. 00123 int outputId() const; 00124 // given an output channel return the first input channel Id. 00125 int firstInputId() const; 00126 // given an output channel return the second input channel Id. 00127 int secondInputId() const; 00128 00130 virtual bool bogus() const; 00131 }; 00132 00147 class FecChannelId : public ElecChannelId { 00148 public: 00149 FecChannelId() : ElecChannelId(0) {} 00150 FecChannelId(int board, int connector, 00151 Site::Site_t site, DetectorId::DetectorId_t det) : 00152 ElecChannelId(board, connector, site, det) {} 00153 FecChannelId(unsigned int cfId, unsigned int fecId, int connector, 00154 Site::Site_t site, DetectorId::DetectorId_t det) : 00155 ElecChannelId(convertToBoard(cfId, fecId), connector, site, det) {} 00156 FecChannelId(const FecChannelId& channel) : ElecChannelId(channel) {} 00157 FecChannelId(int data) : ElecChannelId(data) {} 00158 virtual ~FecChannelId(); 00159 // Assignment Operator 00160 FecChannelId& operator=(const FecChannelId& id) 00161 { m_data = id.m_data; return *this; } 00162 00164 FecChannelId boardId() const; 00165 00167 unsigned int cfId() const; 00169 unsigned int fecId() const; 00171 unsigned int rtmCfId() const; 00173 unsigned int rtmRotId() const; 00174 00176 unsigned int fecHit() const; 00177 00179 virtual bool bogus() const; 00180 00182 static unsigned int connectorToHit(unsigned int connector) {return 0x1<<connector;} 00183 static unsigned int hitToConnector(unsigned int hit) { 00184 for (int i = 0; i < 32; i++, hit>>=1) 00185 if (0x1&hit) return i; 00186 return 0; 00187 } 00188 00189 00190 private: 00191 int convertToBoard(unsigned int cfId, unsigned int fecId) const; 00192 unsigned int convertToCfId(int board) const; 00193 unsigned int convertToFecId(int board) const; 00194 }; 00195 00202 const int BaseFrequencyHz = int(40 * 1e6); // 40 MHz 00203 // Clock cycles relative to base frequency 00204 const int TdcCycles = 16; 00205 const int AdcCycles = 1; 00206 const int EsumCycles = 4; 00207 const int NhitCycles = 2; 00208 // Convenience Frequencies 00209 const int TdcFrequencyHz = BaseFrequencyHz * TdcCycles; 00210 const int AdcFrequencyHz = BaseFrequencyHz * AdcCycles; 00211 const int EsumFrequencyHz = BaseFrequencyHz * EsumCycles; 00212 const int NhitFrequencyHz = BaseFrequencyHz * NhitCycles; 00213 00214 const int FadcFrequencyHz = int(1 * 1e9); // 1 GHz 00215 00216 // Time tolerances - amount of time to extend ElecHeader time window 00217 // (extending from SimHeader time window) 00218 // preTimeTolerance based on width of ADC widened shaped pulse 00219 // postTimeTolerance based on timing of after pulses 00220 const double preTimeTolerance = 300.0*CLHEP::nanosecond; 00221 const double postTimeTolerance = 10.0*CLHEP::microsecond; 00222 00223 // Number of trigger window cycles - default value 00224 const int TriggerWindowCycles = 8; 00225 00226 namespace FeeGain 00227 { 00228 enum FeeGain_t { 00229 kUnknown = 0, 00230 kHigh, 00231 kLow 00232 }; 00233 00234 // FIXME: Add these functions to Electronics.cc 00235 // Convert type enum back and forth to string. 00236 //const char* AsString(FeeGain_t gain); 00237 //FeeGain_t FromString(const char* str); 00238 } 00239 00240 namespace Threshold 00241 { 00242 enum Threshold_t { 00243 kUnknown = 0, 00244 kCrossing, 00245 kAbove 00246 }; 00247 } 00248 00249 namespace ESumComp 00250 { 00251 enum ESumComp_t { 00252 kUnknown = 0, 00253 kESumLow = 0x01, 00254 kESumHigh = 0x02, 00255 kESumTotal= 0x04, 00256 kESumNone = 0x08, 00257 }; 00258 } 00259 00260 std::ostream& operator<<(std::ostream& str, 00261 const DayaBay::ElecChannelId& elecChannel); 00262 00264 } 00265 00266 #endif // CONVENTIONS_ELECTRONICS_H 00267 00268 // Local Variables: ** 00269 // c-basic-offset:2 ** 00270 // End: **