166 const unsigned long*
buffer = (
reinterpret_cast<const unsigned long*
>(fedData.
data()));
167 int fedLenght = fedData.
size();
170 if (fedLenght != (nWordsPerEvent * 4)) {
171 edm::LogError(
"CamacTBDataFormatter") <<
"CamacTBData has size " << fedLenght <<
" Bytes as opposed to expected " 172 << (nWordsPerEvent * 4) <<
". Returning.";
180 for (
int wordNumber = 0; wordNumber < nWordsPerEvent; wordNumber++) {
181 statusWords[wordNumber] =
true;
199 a = buffer[wordCounter];
201 LogDebug(
"CamacTBDataFormatter") <<
"\n\nword:\t" <<
a;
203 b = (a & 0xff000000);
205 LogDebug(
"CamacTBDataFormatter") <<
"format ver:\t" <<
b;
209 LogDebug(
"CamacTBDataFormatter") <<
"major:\t" <<
b;
213 LogDebug(
"CamacTBDataFormatter") <<
"minor:\t" <<
b;
215 LogDebug(
"CamacTBDataFormatter") <<
"\n\n word:\t" <<
a;
216 LogDebug(
"CamacTBDataFormatter") <<
"time stamp secs: " <<
a;
218 LogDebug(
"CamacTBDataFormatter") <<
"\n\n word:\t" <<
a;
219 LogDebug(
"CamacTBDataFormatter") <<
"time stamp musecs: " <<
a;
221 a = buffer[wordCounter];
223 LogDebug(
"CamacTBDataFormatter") <<
"\n\n word:\t" <<
a;
225 LogDebug(
"CamacTBDataFormatter") <<
"LV1A: " <<
b;
228 a = buffer[wordCounter];
230 LogDebug(
"CamacTBDataFormatter") <<
"\n\n word:\t" <<
a;
231 b = (a & 0xffff0000);
233 LogDebug(
"CamacTBDataFormatter") <<
"run number: " <<
b;
236 LogDebug(
"CamacTBDataFormatter") <<
"spill number: " <<
b;
239 a = buffer[wordCounter];
242 LogDebug(
"CamacTBDataFormatter") <<
"event number in spill: " <<
b;
244 a = buffer[wordCounter];
247 LogDebug(
"CamacTBDataFormatter") <<
"internal event number: " <<
b;
249 a = buffer[wordCounter];
251 LogDebug(
"CamacTBDataFormatter") <<
"\n\n word:\t" <<
a;
252 b = (a & 0xffff0000);
254 LogDebug(
"CamacTBDataFormatter") <<
"vme errors: " <<
b;
256 LogDebug(
"CamacTBDataFormatter") <<
"camac errors: " <<
b;
258 a = buffer[wordCounter];
260 LogDebug(
"CamacTBDataFormatter") <<
"\n\n word:\t" <<
a;
262 LogDebug(
"CamacTBDataFormatter") <<
"extended (32 bits) run number: " <<
b;
272 unsigned long bufferHodo[16];
273 bool hodoAreGood =
true;
274 for (
int hodo = 0; hodo < 16; hodo++) {
275 hodoAreGood = hodoAreGood && checkStatus(buffer[wordCounter], wordCounter);
277 a = buffer[wordCounter];
278 bufferHodo[hodo] = buffer[wordCounter];
281 LogDebug(
"CamacTBDataFormatter") <<
"hodo: " << hodo <<
"\t: " <<
b;
287 for (
int iplane = 0; iplane < nHodoPlanes; iplane++) {
290 for (
int fiber = 0; fiber < nHodoFibers; fiber++) {
291 hodoHits[iplane][fiber] = 0;
297 for (
int j = 0;
j < hodoRawLen;
j++) {
298 int word = bufferHodo[
j + iplane * hodoRawLen] & 0xffff;
299 for (
int i = 1;
i < 0x10000;
i <<= 1) {
302 hodoHits[iplane][hodoFiberMap[detType][ch].
nfiber - 1]++;
310 hodoRaw.
setPlanes((
unsigned int)nHodoPlanes);
311 for (
int ipl = 0; ipl < nHodoPlanes; ipl++) {
313 theHodoPlane.
setChannels((
unsigned int)nHodoFibers);
314 for (
int fib = 0; fib < nHodoFibers; fib++) {
315 theHodoPlane.
setHit((
unsigned int)fib, (
bool)hodoHits[ipl][fib]);
317 hodoRaw.
setPlane((
unsigned int)ipl, theHodoPlane);
321 <<
"hodoscope block has hardware problems or is partly unused at LV1: " << lv1 <<
" spill: " << spill
322 <<
"run: " << run <<
". Skipping digi.";
332 scalers_.reserve(36);
334 bool scalersAreGood =
true;
335 for (
int scaler = 0; scaler < 72; scaler++) {
336 scalersAreGood = scalersAreGood && checkStatus(buffer[wordCounter], wordCounter);
338 a = buffer[wordCounter];
341 LogDebug(
"CamacTBDataFormatter") <<
"scaler: " << scaler <<
"\t: " <<
b;
344 if ((scaler % 2) == 0)
345 scalers_.push_back(b);
347 if (scalersAreGood) {
351 <<
"scalers block has hardware problems or is partly unused at LV1: " << lv1 <<
" spill: " << spill
359 LogDebug(
"CamacTBDataFormatter") <<
"\n";
360 bool fingersAreGood =
true;
361 for (
int finger = 0; finger < 2; finger++) {
362 fingersAreGood = fingersAreGood && checkStatus(buffer[wordCounter], wordCounter);
364 a = buffer[wordCounter];
367 LogDebug(
"CamacTBDataFormatter") <<
"finger: " << finger <<
"\t: " <<
b;
369 if (fingersAreGood) {
373 <<
"fingers block has hardware problems or is partly unused at LV1: " << lv1 <<
" spill: " << spill
381 a = buffer[wordCounter];
383 LogDebug(
"CamacTBDataFormatter") <<
"\n\n word:\t" <<
a;
384 b = (a & 0x000000ff);
385 LogDebug(
"CamacTBDataFormatter") <<
"number of words used in multi stop TDC words: " <<
b;
387 int numberTDCwords = 16;
388 bool multiStopTDCIsGood =
true;
389 for (
int tdc = 0; tdc < numberTDCwords; tdc++) {
390 multiStopTDCIsGood = multiStopTDCIsGood && checkStatus(buffer[wordCounter], wordCounter);
392 a = buffer[wordCounter];
395 LogDebug(
"CamacTBDataFormatter") <<
"tdc: " << tdc <<
"\t: " <<
b;
397 if (multiStopTDCIsGood) {
401 <<
"multi stop TDC block has hardware problems or is partly unused at LV1: " << lv1 <<
" spill: " << spill
406 wordCounter += (16 - numberTDCwords);
411 a = buffer[wordCounter];
413 b = (a & 0x00000001);
416 LogDebug(
"CamacTBDataFormatter") <<
" table is in position.";
417 tableIsMoving =
false;
419 LogDebug(
"CamacTBDataFormatter") <<
" table is moving.";
420 tableIsMoving =
true;
431 bool ADCIsGood =
true;
432 a = buffer[wordCounter];
434 b = (a & 0x00ffffff);
435 LogDebug(
"CamacTBDataFormatter") <<
"ADC word1: " << a <<
"\t ADC2: " << b <<
" word is: " << (wordCounter - 1);
438 ADCIsGood = checkStatus(buffer[wordCounter], wordCounter);
439 a = buffer[wordCounter];
442 LogDebug(
"CamacTBDataFormatter") <<
"ADC word2, adc channel 11, ampli S6: " << a <<
"\t ADC2: " <<
b;
453 ADCIsGood&& checkStatus(buffer[wordCounter], wordCounter);
454 a = buffer[wordCounter];
457 LogDebug(
"CamacTBDataFormatter") <<
"TDC word1: " << a <<
"\t TDC2: " <<
b;
458 ADCIsGood&& checkStatus(buffer[wordCounter], wordCounter);
459 a = buffer[wordCounter];
462 LogDebug(
"CamacTBDataFormatter") <<
"TDC word2: (ext_val_trig - LHC_clock) " << a
463 <<
"\t (ext_val_trig - LHC_clock): " <<
b;
466 int sampleNumber = 1;
470 a = buffer[wordCounter];
472 LogDebug(
"CamacTBDataFormatter") <<
"\n\n word:\t" <<
a;
474 LogDebug(
"CamacTBDataFormatter") <<
"last word of event: " <<
b;
480 if (wordNumber < 1 || wordNumber > nWordsPerEvent) {
482 <<
"checking word number: " << wordNumber <<
" which is out of allowed range (" << nWordsPerEvent <<
")";
488 if (word & 0x80000000)
490 edm::LogWarning(
"CamacTBDataFormatter::checkStatus") <<
"daq item not used at word: " << wordNumber;
491 statusWords[wordNumber - 1] =
false;
495 if (word & 0x40000000)
497 edm::LogWarning(
"CamacTBDataFormatter::checkStatus") <<
"vme error on word: " << wordNumber;
498 statusWords[wordNumber - 1] =
false;
502 if (word & 0x20000000)
504 edm::LogWarning(
"CamacTBDataFormatter::checkStatus") <<
"vme status error at word: " << wordNumber;
505 statusWords[wordNumber - 1] =
false;
509 if (word & 0x10000000)
511 edm::LogWarning(
"CamacTBDataFormatter::checkStatus") <<
"camac error (no X) at word: " << wordNumber;
512 statusWords[wordNumber - 1] =
false;
516 if (word & 0x08000000)
518 edm::LogWarning(
"CamacTBDataFormatter::checkStatus") <<
"camac error (no Q) at word: " << wordNumber;
519 statusWords[wordNumber - 1] =
false;
void setHit(unsigned int i, bool status)
void setPlane(unsigned int i, const EcalTBHodoscopePlaneRawHits &planeHit)
size_t size() const
Lenght of the data buffer in bytes.
void setChannels(unsigned int size)
Set methods.
void setSample(unsigned int i, const EcalTBTDCSample &sam)
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
void setSize(unsigned int size)
Set methods.
void setPlanes(unsigned int size)
Set methods.