#include <EventFilter/EcalTBRawToDigi/src/CamacTBDataFormatter.h>
Public Member Functions | |
CamacTBDataFormatter () | |
void | interpretRawData (const FEDRawData &data, EcalTBEventHeader &tbEventHeader, EcalTBHodoscopeRawInfo &hodoRaw, EcalTBTDCRawInfo &tdcRawInfo) |
virtual | ~CamacTBDataFormatter () |
Private Member Functions | |
bool | checkStatus (ulong word, int wordNumber) |
Private Attributes | |
int | hodoAll [nHodoPlanes *nHodoFibers] |
int | hodoHits [nHodoPlanes][nHodoFibers] |
int | nHodoHits [nHodoPlanes] |
int | nWordsPerEvent |
std::vector< int > | scalers_ |
bool | statusWords [148+4] |
Static Private Attributes | |
static const int | hodoRawLen = 4 |
static const int | nHodoFibers = 64 |
static const int | nHodoPlanes = 4 |
static const int | nHodoscopes = 2 |
Definition at line 28 of file CamacTBDataFormatter.h.
CamacTBDataFormatter::CamacTBDataFormatter | ( | ) |
Definition at line 74 of file CamacTBDataFormatter.cc.
References nWordsPerEvent.
00074 { 00075 nWordsPerEvent = 148; 00076 }
virtual CamacTBDataFormatter::~CamacTBDataFormatter | ( | ) | [inline, virtual] |
Definition at line 33 of file CamacTBDataFormatter.h.
References LogDebug.
00033 {LogDebug("EcalTBRawToDigi") << "@SUB=CamacTBDataFormatter" << "\n"; };
Definition at line 439 of file CamacTBDataFormatter.cc.
References nWordsPerEvent, and statusWords.
Referenced by interpretRawData().
00439 { 00440 00441 00442 if ( wordNumber < 1 || wordNumber > nWordsPerEvent) 00443 { 00444 edm::LogWarning("CamacTBDataFormatter::checkStatus") << "checking word number: " 00445 << wordNumber << " which is out of allowed range (" 00446 << nWordsPerEvent << ")"; 00447 return false; 00448 } 00449 00450 bool isOk = true; 00451 00452 if (word & 0x80000000) // daq item not used 00453 { 00454 edm::LogWarning("CamacTBDataFormatter::checkStatus") << "daq item not used at word: "<< wordNumber; 00455 statusWords[wordNumber -1] = false; 00456 isOk = false; 00457 } 00458 00459 if (word & 0x40000000) // vme error on data 00460 { 00461 edm::LogWarning("CamacTBDataFormatter::checkStatus") << "vme error on word: "<< wordNumber; 00462 statusWords[wordNumber -1] = false; 00463 isOk = false; 00464 } 00465 00466 if (word & 0x20000000) // vme error on status 00467 { 00468 edm::LogWarning("CamacTBDataFormatter::checkStatus") << "vme status error at word: "<< wordNumber; 00469 statusWords[wordNumber -1] = false; 00470 isOk = false; 00471 } 00472 00473 if (word & 0x10000000) // camac error (no X) 00474 { 00475 edm::LogWarning("CamacTBDataFormatter::checkStatus") << "camac error (no X) at word: "<< wordNumber; 00476 statusWords[wordNumber -1] = false; 00477 isOk = false; 00478 } 00479 00480 if (word & 0x08000000) // camac error (no Q) 00481 { 00482 edm::LogWarning("CamacTBDataFormatter::checkStatus") << "camac error (no Q) at word: "<< wordNumber; 00483 statusWords[wordNumber -1] = false; 00484 isOk = false; 00485 } 00486 00487 // camac error check not done on purpose from Aug 8, to speed up Camac communication. This bit status is now ignored. 00488 // if (word & 0x04000000) // no camac check error 00489 // { 00490 //edm::LogWarning("CamacTBDataFormatter::checkStatus") << "no camac check error at word: "<< wordNumber; 00491 //statusWords[wordNumber -1] = false; 00492 //isOk = false; 00493 // } 00494 00495 return isOk; 00496 00497 }
void CamacTBDataFormatter::interpretRawData | ( | const FEDRawData & | data, | |
EcalTBEventHeader & | tbEventHeader, | |||
EcalTBHodoscopeRawInfo & | hodoRaw, | |||
EcalTBTDCRawInfo & | tdcRawInfo | |||
) |
Definition at line 80 of file CamacTBDataFormatter.cc.
References a, b, checkStatus(), FEDRawData::data(), hodoHits, hodoRawLen, i, j, LogDebug, lv1, hodo_fibre_index::nfiber, nHodoFibers, nHodoPlanes, nWordsPerEvent, mergeAndRegister_online::run, scalers_, EcalTBHodoscopePlaneRawHits::setChannels(), EcalTBHodoscopePlaneRawHits::setHit(), EcalTBHodoscopeRawInfo::setPlane(), EcalTBHodoscopeRawInfo::setPlanes(), EcalTBEventHeader::setS6ADC(), EcalTBTDCRawInfo::setSample(), EcalTBEventHeader::setScalers(), EcalTBTDCRawInfo::setSize(), EcalTBEventHeader::setTableIsMoving(), FEDRawData::size(), and statusWords.
Referenced by EcalDCCTB07UnpackingModule::produce(), and EcalDCCTBUnpackingModule::produce().
00084 { 00085 00086 00087 const ulong * buffer = ( reinterpret_cast<ulong*>(const_cast<unsigned char*> ( fedData.data()))); 00088 int fedLenght = fedData.size(); // in Bytes 00089 00090 // check ultimate fed size and strip off fed-header and -trailer 00091 if (fedLenght != (nWordsPerEvent *4) ) 00092 { 00093 edm::LogError("CamacTBDataFormatter") << "CamacTBData has size " << fedLenght 00094 <<" Bytes as opposed to expected " 00095 << (nWordsPerEvent *4) 00096 << ". Returning."; 00097 return; 00098 } 00099 00100 00101 00102 ulong a=1; // used to extract an 8 Bytes word from fed 00103 ulong b=1; // used to manipulate the 8 Bytes word and get what needed 00104 00105 // initializing array of statuses 00106 for (int wordNumber=0; wordNumber<nWordsPerEvent; wordNumber++) 00107 { statusWords[wordNumber ] = true;} 00108 00109 // for (int wordNumber=0; wordNumber<nWordsPerEvent; wordNumber++) 00110 // { checkStatus( buffer[wordNumber], wordNumber);} 00111 00112 // for (int wordNumber=0; wordNumber<nWordsPerEvent; wordNumber++) 00113 // { 00114 // if (! statusWords[wordNumber]) 00115 // { 00116 // edm::LogError("CamacTBDataFormatter") << "bad status in some of the event words; returning;"; 00117 // } 00118 // } 00119 00120 00121 00122 int wordCounter =0; 00123 wordCounter +=4; 00124 00125 00126 // read first word 00127 a = buffer[wordCounter];wordCounter++; 00128 LogDebug("CamacTBDataFormatter") << "\n\nword:\t" << a; 00129 00130 b = (a& 0xff000000); 00131 b = b >> 24; 00132 LogDebug("CamacTBDataFormatter") << "format ver:\t" << b; 00133 00134 b = (a& 0xff0000); 00135 b = b >> 16; 00136 LogDebug("CamacTBDataFormatter") << "major:\t" << b; 00137 00138 b = (a& 0xff00); 00139 b = b >> 8; 00140 LogDebug("CamacTBDataFormatter") << "minor:\t" << b; 00141 00142 a = buffer[wordCounter];wordCounter++; 00143 LogDebug("CamacTBDataFormatter") << "\n\n word:\t" << a; 00144 LogDebug("CamacTBDataFormatter") << "time stamp secs: "<<a; 00145 00146 a = buffer[wordCounter];wordCounter++; 00147 LogDebug("CamacTBDataFormatter") << "\n\n word:\t" << a; 00148 LogDebug("CamacTBDataFormatter") << "time stamp musecs: " <<a; 00149 00150 00151 a = buffer[wordCounter];wordCounter++; 00152 LogDebug("CamacTBDataFormatter") << "\n\n word:\t" << a; 00153 b = (a& 0xffffff); 00154 LogDebug("CamacTBDataFormatter") << "LV1A: "<< b; 00155 int lv1 = b; 00156 00157 a = buffer[wordCounter];wordCounter++; 00158 LogDebug("CamacTBDataFormatter") << "\n\n word:\t" << a; 00159 b = (a& 0xffff0000); 00160 b = b >> 16; 00161 LogDebug("CamacTBDataFormatter") << "run number: "<< b; 00162 int run = b; 00163 b = (a& 0xffff); 00164 LogDebug("CamacTBDataFormatter") << "spill number: "<< b; 00165 int spill = b; 00166 00167 a = buffer[wordCounter];wordCounter++; 00168 b = (a& 0xffff); 00169 LogDebug("CamacTBDataFormatter") << "event number in spill: "<< b; 00170 00171 a = buffer[wordCounter];wordCounter++; 00172 b = (a& 0xffffff); 00173 LogDebug("CamacTBDataFormatter") << "internal event number: "<< b; 00174 00175 a = buffer[wordCounter];wordCounter++; 00176 LogDebug("CamacTBDataFormatter") << "\n\n word:\t" << a; 00177 b = (a& 0xffff0000); 00178 b = b >> 16; 00179 LogDebug("CamacTBDataFormatter") << "vme errors: "<< b; 00180 b = (a& 0xffff); 00181 LogDebug("CamacTBDataFormatter") << "camac errors: "<< b; 00182 00183 a = buffer[wordCounter];wordCounter++; 00184 LogDebug("CamacTBDataFormatter") << "\n\n word:\t" << a; 00185 b = a; 00186 LogDebug("CamacTBDataFormatter") << "extended (32 bits) run number: "<< b; 00187 00188 // skip 1 reserved words 00189 wordCounter +=1; 00190 00191 /********************************** 00192 // acessing the hodoscope block 00193 **********************************/ 00194 00195 // getting 16 words buffer and checking words statuses 00196 ulong bufferHodo[16]; 00197 bool hodoAreGood = true; 00198 for (int hodo=0; hodo<16; hodo++) 00199 { 00200 hodoAreGood = hodoAreGood && checkStatus(buffer[wordCounter], wordCounter); 00201 00202 a = buffer[wordCounter]; 00203 bufferHodo[hodo] = buffer[wordCounter]; 00204 wordCounter++; 00205 00206 b = (a& 0xffffff); 00207 LogDebug("CamacTBDataFormatter") << "hodo: " << hodo << "\t: " << b; 00208 } 00209 00210 hodoRaw.setPlanes(0); 00211 // unpacking the hodo data 00212 if (hodoAreGood){ 00213 for (int iplane=0; iplane<nHodoPlanes; iplane++) 00214 { 00215 int detType = 1; // new mapping for electronics channels 00216 00217 for (int fiber=0; fiber<nHodoFibers; fiber++) { hodoHits[iplane][fiber] = 0; } 00218 00219 int ch=0; 00220 00221 // loop on [4-24bits words] = 1 plane 00222 for(int j=0; j<hodoRawLen; j++) 00223 { 00224 int word= bufferHodo[ j+iplane*hodoRawLen ] &0xffff; 00225 for(int i=1; i<0x10000; i<<=1) 00226 { 00227 if ( word & i ) 00228 { 00229 // map electronics channel to No of fibre 00230 hodoHits[iplane][ hodoFiberMap[detType][ch].nfiber - 1]++; 00231 } 00232 ch ++; 00233 } 00234 } 00235 } 00236 00237 00238 // building the hodo infos (returning decoded hodoscope hits information) 00239 hodoRaw.setPlanes((unsigned int)nHodoPlanes); 00240 for (int ipl = 0; ipl < nHodoPlanes; ipl++) 00241 { 00242 EcalTBHodoscopePlaneRawHits theHodoPlane; 00243 theHodoPlane.setChannels((unsigned int)nHodoFibers); 00244 for (int fib = 0; fib < nHodoFibers; fib++){ theHodoPlane.setHit((unsigned int)fib, (bool)hodoHits[ipl][fib]); } 00245 hodoRaw.setPlane((unsigned int)ipl, theHodoPlane); 00246 } 00247 } 00248 else 00249 { 00250 edm::LogWarning("CamacTBDataFormatter") << "hodoscope block has hardware problems or is partly unused at LV1: " 00251 << lv1 << " spill: " << spill 00252 << "run: " << run 00253 << ". Skipping digi."; 00254 } 00255 00256 00257 00258 00259 00260 /********************************** 00261 // acessing the scalers block 00262 **********************************/ 00263 00264 // getting 72 words buffer and checking words statuses 00265 00266 scalers_.clear(); 00267 scalers_.reserve(36); 00268 00269 bool scalersAreGood = true; 00270 for (int scaler=0; scaler<72; scaler++) 00271 { 00272 scalersAreGood = scalersAreGood && checkStatus(buffer[wordCounter], wordCounter); 00273 00274 a = buffer[wordCounter]; wordCounter++; 00275 b = (a& 0xffffff); 00276 LogDebug("CamacTBDataFormatter") << "scaler: " << scaler << "\t: " << b; 00277 00278 // filling vector container with scalers words 00279 if ( (scaler%2)==0 ) scalers_.push_back(b); 00280 } 00281 if (scalersAreGood){ 00282 tbEventHeader.setScalers (scalers_); 00283 } 00284 else 00285 { 00286 edm::LogWarning("CamacTBDataFormatter") << "scalers block has hardware problems or is partly unused at LV1: " 00287 << lv1 << " spill: " << spill 00288 << "run: " << run; 00289 } 00290 00291 00292 00293 00294 00295 /********************************** 00296 // acessing the fingers block 00297 **********************************/ 00298 00299 LogDebug("CamacTBDataFormatter") <<"\n"; 00300 bool fingersAreGood = true; 00301 for (int finger=0; finger<2; finger++) 00302 { 00303 fingersAreGood = fingersAreGood && checkStatus(buffer[wordCounter], wordCounter); 00304 00305 a = buffer[wordCounter]; wordCounter++; 00306 b = (a& 0xffffff); 00307 LogDebug("CamacTBDataFormatter") << "finger: " << finger << "\t: " << b; 00308 } 00309 if (fingersAreGood){ 00310 ; } 00311 else 00312 { 00313 edm::LogWarning("CamacTBDataFormatter") << "fingers block has hardware problems or is partly unused at LV1: " 00314 << lv1 << " spill: " << spill 00315 << "run: " << run; 00316 } 00317 00318 00319 00320 00321 /********************************** 00322 // acessing the multi stop TDC block 00323 **********************************/ 00324 00325 a = buffer[wordCounter]; wordCounter++; 00326 LogDebug("CamacTBDataFormatter") << "\n\n word:\t" << a; 00327 b = (a& 0x000000ff); 00328 LogDebug("CamacTBDataFormatter") << "number of words used in multi stop TDC words: "<< b; 00329 00330 int numberTDCwords = b; 00331 numberTDCwords = 16; 00332 bool multiStopTDCIsGood = true; 00333 for (int tdc=0; tdc< numberTDCwords ; tdc++) 00334 { 00335 multiStopTDCIsGood = multiStopTDCIsGood && checkStatus(buffer[wordCounter], wordCounter); 00336 00337 a = buffer[wordCounter]; wordCounter++; 00338 b =a; 00339 LogDebug("CamacTBDataFormatter") << "tdc: " << tdc << "\t: " << b; 00340 } 00341 if ( multiStopTDCIsGood ){ 00342 ; } 00343 else 00344 { 00345 edm::LogWarning("CamacTBDataFormatter") << "multi stop TDC block has hardware problems or is partly unused at LV1: " 00346 << lv1 << " spill: " << spill 00347 << "run: " << run; 00348 } 00349 00350 // skip the unused words in multi stop TDC block 00351 wordCounter += (16 - numberTDCwords); 00352 00353 00354 00355 00356 /********************************** 00357 // acessing table in position bit 00358 **********************************/ 00359 a = buffer[wordCounter]; wordCounter++; 00360 b = (a & 0x00000001); //1= table is in position; 0=table is moving 00361 bool tableIsMoving; 00362 if ( b ){ 00363 LogDebug("CamacTBDataFormatter") << " table is in position."; 00364 tableIsMoving = false; 00365 } 00366 else 00367 { 00368 LogDebug("CamacTBDataFormatter") << " table is moving."; 00369 tableIsMoving = true; 00370 } 00371 tbEventHeader.setTableIsMoving( tableIsMoving ); 00372 00373 00374 wordCounter += 3; 00375 00376 00377 00378 /********************************** 00379 // acessing ADC block 00380 **********************************/ 00381 // skip 10 reserved words 00382 wordCounter += 10; 00383 bool ADCIsGood = true; 00384 // ADCIsGood = ADCIsGood && checkStatus(buffer[wordCounter], wordCounter); 00385 ADCIsGood = checkStatus(buffer[wordCounter], wordCounter); 00386 a = buffer[wordCounter]; wordCounter++; // NOT read out 00387 b = (a&0x00ffffff); 00388 LogDebug("CamacTBDataFormatter") << "ADC word1: " << a << "\t ADC2: " << b << " word is: " << (wordCounter-1); 00389 // ADCIsGood = true; 00390 // ADCIsGood = ADCIsGood && checkStatus(buffer[wordCounter], wordCounter); 00391 ADCIsGood = checkStatus(buffer[wordCounter], wordCounter); 00392 a = buffer[wordCounter]; wordCounter++; // read out 00393 b = (a&0xffffff); 00394 LogDebug("CamacTBDataFormatter") << "ADC word2, adc channel 11, ampli S6: " << a << "\t ADC2: " << b; 00395 if (ADCIsGood) tbEventHeader.setS6ADC ( b ) ; 00396 else tbEventHeader.setS6ADC ( -1 ) ; 00397 00398 00399 /********************************** 00400 // acessing TDC block 00401 **********************************/ 00402 // skip 6 reserved words 00403 wordCounter += 6; 00404 bool TDCIsGood = true; 00405 TDCIsGood = ADCIsGood && checkStatus(buffer[wordCounter], wordCounter); 00406 a = buffer[wordCounter]; wordCounter++; 00407 b = (a & 0xfffff); 00408 LogDebug("CamacTBDataFormatter") << "TDC word1: " << a << "\t TDC2: " << b; 00409 TDCIsGood = ADCIsGood && checkStatus(buffer[wordCounter], wordCounter); 00410 a = buffer[wordCounter]; wordCounter++; 00411 b = (a & 0xfffff); 00412 LogDebug("CamacTBDataFormatter") << "TDC word2: (ext_val_trig - LHC_clock) " 00413 << a << "\t (ext_val_trig - LHC_clock): " 00414 << b; 00415 00416 tdcRawInfo.setSize(1); 00417 int sampleNumber =1; 00418 EcalTBTDCSample theTdc(sampleNumber, b); 00419 tdcRawInfo.setSample(0, theTdc); 00420 00421 00422 a = buffer[wordCounter]; wordCounter++; 00423 LogDebug("CamacTBDataFormatter") << "\n\n word:\t" << a; 00424 b = a; 00425 LogDebug("CamacTBDataFormatter") << "last word of event: "<< b; 00426 00427 00428 }
int CamacTBDataFormatter::hodoAll[nHodoPlanes *nHodoFibers] [private] |
Definition at line 60 of file CamacTBDataFormatter.h.
int CamacTBDataFormatter::hodoHits[nHodoPlanes][nHodoFibers] [private] |
const int CamacTBDataFormatter::hodoRawLen = 4 [static, private] |
const int CamacTBDataFormatter::nHodoFibers = 64 [static, private] |
int CamacTBDataFormatter::nHodoHits[nHodoPlanes] [private] |
Definition at line 58 of file CamacTBDataFormatter.h.
const int CamacTBDataFormatter::nHodoPlanes = 4 [static, private] |
const int CamacTBDataFormatter::nHodoscopes = 2 [static, private] |
Definition at line 54 of file CamacTBDataFormatter.h.
int CamacTBDataFormatter::nWordsPerEvent [private] |
Definition at line 51 of file CamacTBDataFormatter.h.
Referenced by CamacTBDataFormatter(), checkStatus(), and interpretRawData().
std::vector<int> CamacTBDataFormatter::scalers_ [private] |
bool CamacTBDataFormatter::statusWords[148+4] [private] |
Definition at line 61 of file CamacTBDataFormatter.h.
Referenced by checkStatus(), and interpretRawData().