#include <RawTOFDigit.h>
Public Member Functions | |
RawTOFDigit () | |
RawTOFDigit (const Int_t *&p, const RawDigitCrateStatus *cstat) | |
virtual | ~RawTOFDigit () |
Int_t | GetNumberOfEntries () const |
Int_t | GetTdcEventCounter () const |
Bool_t | IsStructureOk () const |
Short_t | GetTdcChannel (Int_t indx) const |
Short_t | GetTdcValue (Int_t indx) const |
Bool_t | IsTdcValid (Int_t indx) const |
Bool_t | IsTdcUnderThreshold (Int_t indx) const |
Bool_t | IsTdcOverflow (Int_t indx) const |
Int_t | GetTdcArraySize () const |
const Int_t * | GetTdcArray () const |
virtual void | Print (Option_t *option="") const |
Protected Attributes | |
const Int_t * | fTDCArray |
Friends | |
std::ostream & | operator<< (std::ostream &os, const RawTOFDigit &r) |
Definition at line 17 of file RawTOFDigit.h.
RawTOFDigit::RawTOFDigit | ( | ) |
Definition at line 57 of file RawTOFDigit.cxx.
RawTOFDigit::RawTOFDigit | ( | const Int_t *& | p, | |
const RawDigitCrateStatus * | cstat | |||
) |
Definition at line 63 of file RawTOFDigit.cxx.
References fTDCArray, and GetTdcArraySize().
00064 : RawVaDigit(p,cstat) 00065 { 00066 // a RawTOFDigit looks like a RawVaDigit with extra words tacked 00067 // onto the end. 00068 00069 // use fTDCArray just to reference back to real data in mother block 00070 // don't make any copy of the data 00071 fTDCArray = p; 00072 // advance pointer beyond entries 00073 int nskip = GetTdcArraySize(); 00074 p += nskip; 00075 }
RawTOFDigit::~RawTOFDigit | ( | ) | [virtual] |
Definition at line 78 of file RawTOFDigit.cxx.
Int_t RawTOFDigit::GetNumberOfEntries | ( | ) | const |
Definition at line 84 of file RawTOFDigit.cxx.
References RawDigit::fDigitCrateStatus, fTDCArray, RawBlockId::GetMinor(), RawCrateStatus::GetRawBlockId(), Msg::kWarning, and MSG.
Referenced by GetTdcArraySize(), GetTdcChannel(), GetTdcEventCounter(), GetTdcValue(), IsStructureOk(), IsTdcOverflow(), IsTdcUnderThreshold(), IsTdcValid(), and Print().
00085 { 00086 // number of TDC channels read out per TOF "hit" 00087 // is dependent on the minor version id of the block 00088 // but for most cases actual count comes from header word 00089 00090 const int cntMask = 0x3f; 00091 const int cntShift = 8; 00092 00093 static int nmsg = 5; 00094 00095 // we can get this from the CrateStatus 00096 Int_t minor = fDigitCrateStatus->GetRawBlockId().GetMinor(); 00097 switch (minor) { 00098 case 0: 00099 // pull count size of block from header word 00100 return (fTDCArray[0]>>cntShift)&cntMask; 00101 break; 00102 default: 00103 if (nmsg > 0) { 00104 MSG("RawData",Msg::kWarning) 00105 << "RawTOFDigit::GetNumberOfEntries() unknown minor version " 00106 << minor << ", assume std TDC header format" << endl; 00107 nmsg--; 00108 if (nmsg==0) 00109 MSG("RawData",Msg::kWarning) 00110 << " ... last warning" << endl; 00111 } 00112 // pull count size of block from header word 00113 return (fTDCArray[0]>>cntShift)&cntMask; 00114 break; 00115 } 00116 00117 }
const Int_t* RawTOFDigit::GetTdcArray | ( | ) | const [inline] |
Definition at line 40 of file RawTOFDigit.h.
References fTDCArray.
Referenced by Print().
00040 { return fTDCArray; }
Int_t RawTOFDigit::GetTdcArraySize | ( | ) | const |
Definition at line 120 of file RawTOFDigit.cxx.
References RawDigit::fDigitCrateStatus, RawBlockId::GetMinor(), GetNumberOfEntries(), RawCrateStatus::GetRawBlockId(), Msg::kWarning, and MSG.
Referenced by Print(), and RawTOFDigit().
00121 { 00122 // the size of the Tdc array is dependent on the minor 00123 // version id of the block but for most cases actual count 00124 // comes from header word plus one each for the header and trailer 00125 00126 static int nmsg = 5; 00127 00128 Int_t minor = fDigitCrateStatus->GetRawBlockId().GetMinor(); 00129 switch (minor) { 00130 case 0: 00131 return 2+GetNumberOfEntries(); 00132 break; 00133 default: 00134 if (nmsg > 0) { 00135 MSG("RawData",Msg::kWarning) 00136 << "RawTOFDigit::GetTdcArraySize() unknown minor version " 00137 << minor << ", assume std TDC header format" << endl; 00138 nmsg--; 00139 if (nmsg==0) 00140 MSG("RawData",Msg::kWarning) 00141 << " ... last warning" << endl; 00142 } 00143 return 2+GetNumberOfEntries(); 00144 break; 00145 } 00146 00147 }
Short_t RawTOFDigit::GetTdcChannel | ( | Int_t | indx | ) | const |
Definition at line 192 of file RawTOFDigit.cxx.
References fTDCArray, and GetNumberOfEntries().
Referenced by Print(), and AlgCalDetSI::RunAlg().
00193 { 00194 // pull the "channel" field from the data word "indx" 00195 // simply assume that minorid>0 00196 00197 if (indx<0 || indx>=GetNumberOfEntries()) return -1; 00198 00199 const int chanMask = 0x3f; 00200 const int chanShift = 16; 00201 // index past header word 00202 return (fTDCArray[indx+1]>>chanShift)&chanMask; 00203 00204 }
Int_t RawTOFDigit::GetTdcEventCounter | ( | ) | const |
Definition at line 150 of file RawTOFDigit.cxx.
References fTDCArray, and GetNumberOfEntries().
Referenced by Print().
00151 { 00152 // pull the "event counter" field from the trailer word 00153 // simply assume that minorid>0 00154 00155 // skip past header + data words 00156 int indx = GetNumberOfEntries() + 1; 00157 00158 return fTDCArray[indx]&0x00ffffff; 00159 }
Short_t RawTOFDigit::GetTdcValue | ( | Int_t | indx | ) | const |
Definition at line 207 of file RawTOFDigit.cxx.
References fTDCArray, and GetNumberOfEntries().
Referenced by Print(), and AlgCalDetSI::RunAlg().
00208 { 00209 // pull the "adc" field from the data word "indx" 00210 // simply assume that minorid>0 00211 00212 if (indx<0 || indx>=GetNumberOfEntries()) return -1; 00213 00214 const int adcMask = 0x0fff; 00215 00216 // index past header word 00217 return fTDCArray[indx+1]&adcMask; 00218 00219 }
Bool_t RawTOFDigit::IsStructureOk | ( | ) | const |
Definition at line 162 of file RawTOFDigit.cxx.
References fTDCArray, GetNumberOfEntries(), and n.
Referenced by Print(), and AlgCalDetSI::RunAlg().
00163 { 00164 // verify that flag bits are all in the right places in the TDC block 00165 // simply assume minorid>0 00166 00167 // 3 2 1 00168 // 10987654321098765432109876543210 00169 // header: ggggg010cccccccc00nnnnnn-------- 00170 // data: ggggg00000cccccc-vuoaaaaaaaaaaaa 00171 // trailer: ggggg100eeeeeeeeeeeeeeeeeeeeeeee 00172 00173 bool isokay = true; 00174 00175 const Int_t *p = fTDCArray; 00176 00177 if ((*p&0x0700c000) != 0x02000000) isokay = false; 00178 p++; 00179 00180 int n = GetNumberOfEntries(); 00181 for (int i=0; i<n; i++) { 00182 if ((*p&0x07c00000) != 0x00000000) isokay = false; 00183 p++; 00184 } 00185 00186 if ((*p&0x07000000) != 0x04000000) isokay = false; 00187 00188 return isokay; 00189 }
Bool_t RawTOFDigit::IsTdcOverflow | ( | Int_t | indx | ) | const |
Definition at line 252 of file RawTOFDigit.cxx.
References fTDCArray, and GetNumberOfEntries().
Referenced by Print().
00253 { 00254 // pull the "overflow" field from the data word "indx" 00255 // simply assume that minorid>0 00256 00257 if (indx<0 || indx>=GetNumberOfEntries()) return true; 00258 00259 const int overMask = BIT(12); 00260 00261 // index past header word 00262 return fTDCArray[indx+1]&overMask; 00263 00264 }
Bool_t RawTOFDigit::IsTdcUnderThreshold | ( | Int_t | indx | ) | const |
Definition at line 237 of file RawTOFDigit.cxx.
References fTDCArray, and GetNumberOfEntries().
Referenced by Print().
00238 { 00239 // pull the "underthreshold" field from the data word "indx" 00240 // simply assume that minorid>0 00241 00242 if (indx<0 || indx>=GetNumberOfEntries()) return true; 00243 00244 const int underMask = BIT(13); 00245 00246 // index past header word 00247 return fTDCArray[indx+1]&underMask; 00248 00249 }
Bool_t RawTOFDigit::IsTdcValid | ( | Int_t | indx | ) | const |
Definition at line 222 of file RawTOFDigit.cxx.
References fTDCArray, and GetNumberOfEntries().
Referenced by Print().
00223 { 00224 // pull the "valid" field from the data word "indx" 00225 // simply assume that minorid>0 00226 00227 if (indx<0 || indx>=GetNumberOfEntries()) return false; 00228 00229 const int validMask = BIT(14); 00230 00231 // index past header word 00232 return fTDCArray[indx+1]&validMask; 00233 00234 }
void RawTOFDigit::Print | ( | Option_t * | option = "" |
) | const [virtual] |
Reimplemented from RawDigit.
Definition at line 267 of file RawTOFDigit.cxx.
References GetNumberOfEntries(), GetTdcArray(), GetTdcArraySize(), GetTdcChannel(), GetTdcEventCounter(), GetTdcValue(), IsStructureOk(), IsTdcOverflow(), IsTdcUnderThreshold(), and IsTdcValid().
Referenced by RawTOFBlock::FillRawTOFDigits().
00268 { 00269 // print out the digit 00270 RawVaDigit::Print(option); 00271 00272 int nvalues = GetNumberOfEntries(); 00273 int evtcntr = GetTdcEventCounter(); 00274 bool isok = IsStructureOk(); 00275 cout << " has " << nvalues << " values (" 00276 << "evtcntr: " << evtcntr << "," 00277 << ((isok) ? "isok" : "badbits") << ")" << endl; 00278 if (nvalues) 00279 cout << " indx chan value valid thrsh overflow" << endl; 00280 for (int i=0; i<nvalues; i++) { 00281 cout << " [" << setw(3) << i << "]" 00282 << " " << setw(4) << GetTdcChannel(i) 00283 << " " << setw(5) << GetTdcValue(i) 00284 << ((IsTdcValid(i)) ? " yes" : " no") 00285 << ((IsTdcUnderThreshold(i)) ? " under" : " above") 00286 << ((IsTdcOverflow(i)) ? " yes" : " no") 00287 << endl; 00288 } 00289 00290 #ifdef TOOVERBOSE 00291 int arraysize = GetTdcArraySize(); 00292 const Int_t* array = GetTdcArray(); 00293 for (int i=0; i<arraysize; i++) { 00294 cout << " 0x" << setfill('0') << hex << setw(8) 00295 << array[i] << setfill(' ') << dec; 00296 } 00297 cout << endl; 00298 #endif 00299 00300 }
std::ostream& operator<< | ( | std::ostream & | os, | |
const RawTOFDigit & | r | |||
) | [friend] |
Reimplemented from RawDigit.
const Int_t* RawTOFDigit::fTDCArray [protected] |
Definition at line 46 of file RawTOFDigit.h.
Referenced by GetNumberOfEntries(), GetTdcArray(), GetTdcChannel(), GetTdcEventCounter(), GetTdcValue(), IsStructureOk(), IsTdcOverflow(), IsTdcUnderThreshold(), IsTdcValid(), and RawTOFDigit().