LCOV - code coverage report
Current view: top level - RAW/RAWDatarec - AliVMERawStream.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 115 0.9 %
Date: 2016-06-14 17:26:59 Functions: 1 7 14.3 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : /* $Id$ */
      17             : 
      18             : ///////////////////////////////////////////////////////////////////////////////
      19             : ///
      20             : /// This class provides access to VME data in test beam raw data.
      21             : ///
      22             : ///////////////////////////////////////////////////////////////////////////////
      23             : 
      24             : #include "AliVMERawStream.h"
      25             : #include "AliRawReader.h"
      26             : 
      27         128 : ClassImp(AliVMERawStream)
      28             : 
      29             : 
      30             : 
      31           0 : AliVMERawStream::AliVMERawStream(AliRawReader* rawReader) :
      32           0 :   fRawReader(rawReader),
      33           0 :   fData(0),
      34           0 :   fNChannels(-1),
      35           0 :   fBlock(0),
      36           0 :   fNumber(0),
      37           0 :   fChannel(0),
      38           0 :   fValue(0),
      39           0 :   fTime(0),
      40           0 :   fTimeMuSec(0)
      41           0 : {
      42             : // create an object to read VME raw digits
      43             : 
      44           0 :   fRawReader = rawReader;
      45             : 
      46           0 :   ReadTDC();
      47           0 :   ReadTime();
      48             : 
      49           0 :   fRawReader->Reset();
      50           0 :   fRawReader->SelectEquipment(551, 38, 38);
      51           0 : }
      52             : 
      53             : Bool_t AliVMERawStream::Next()
      54             : {
      55             : // read the next raw digit
      56             : // returns kFALSE if there is no digit left
      57             : 
      58             :   // V551 string
      59           0 :   if (fNChannels == -1) {
      60           0 :     if (!fRawReader->ReadNextInt(fData)) return kFALSE;
      61           0 :     if (!CheckString("V551")) return kFALSE;
      62           0 :     fNChannels = 0;
      63           0 :   }
      64             : 
      65           0 :   while (fNChannels == 0) {
      66             :     // V550 or v551 string
      67           0 :     if (!fRawReader->ReadNextInt(fData)) {
      68           0 :       Error("Next", "incomplete equipment");
      69           0 :       return kFALSE;
      70             :     }
      71             :     // check for v551 string (end of data)
      72             :     const char* v551 = "v551";
      73           0 :     if (fData == *((UInt_t*) v551)) return kFALSE;
      74           0 :     if (!CheckString("V550")) return kFALSE;
      75             : 
      76             :     // block
      77           0 :     if (!fRawReader->ReadNextShort(fBlock)) {
      78           0 :       Error("Next", "incomplete equipment");
      79           0 :       return kFALSE;
      80             :     }
      81             : 
      82             :     // serial number
      83           0 :     if (!fRawReader->ReadNextShort(fNumber)) {
      84           0 :       Error("Next", "incomplete equipment");
      85           0 :       return kFALSE;
      86             :     }
      87             : 
      88             :     // number of channels
      89           0 :     if (!fRawReader->ReadNextInt((UInt_t&) fNChannels)) {
      90           0 :       Error("Next", "incomplete equipment");
      91           0 :       return kFALSE;
      92             :     }
      93           0 :   }
      94             : 
      95           0 :   if (!fRawReader->ReadNextInt(fData)) {
      96           0 :     Error("Next", "incomplete equipment");
      97           0 :     return kFALSE;
      98             :   }
      99           0 :   fChannel = (fData >> 12) & 0x03ff;
     100           0 :   fValue = fData & 0x0fff;
     101           0 :   fNChannels--;
     102             : 
     103           0 :   return kTRUE;
     104           0 : }
     105             : 
     106             : 
     107             : 
     108             : Bool_t AliVMERawStream::CheckString(const char* str) const
     109             : {
     110             : // check fData to be equal to the given string
     111             : 
     112           0 :   if (fData != *((UInt_t*) str)) {
     113           0 :     char strData[5];
     114           0 :     memcpy(strData, &fData, 4);
     115           0 :     strData[4] = 0;
     116           0 :     Error("CheckString", "invalid %s string (%s)", str, strData);
     117             :     return kFALSE;
     118           0 :   }
     119           0 :   return kTRUE;
     120           0 : }
     121             : 
     122             : Bool_t AliVMERawStream::ReadTDC()
     123             : {
     124             : // read the TDC information
     125             : 
     126           0 :   fRawReader->Reset();
     127           0 :   fRawReader->SelectEquipment(775, 72, 72);
     128             : 
     129             :   // V775 string
     130           0 :   if (!fRawReader->ReadNextInt(fData)) return kFALSE;
     131           0 :   if (!CheckString("V775")) return kFALSE;
     132             : 
     133             :   // header
     134           0 :   if (!fRawReader->ReadNextInt(fData)) {
     135           0 :     Error("ReadTDC", "incomplete TDC equipment");
     136           0 :     return kFALSE;
     137             :   }
     138           0 :   if ((fData & 0x02000000) == 0) {
     139           0 :     Error("ReadTDC", "invalid header: 0x%x", fData);
     140           0 :     return kFALSE;
     141             :   }
     142             : 
     143             :   // check the array size
     144           0 :   Int_t nTDC = fRawReader->GetDataSize() / 4 - 4; // - V775,header,counter,v775
     145           0 :   if ( nTDC != 3 ) {
     146           0 :     Error("ReadTDC", "wrong number of TDC channels: %d", nTDC);
     147           0 :     return kFALSE;
     148             :   }
     149             : 
     150             :   // TDC data
     151           0 :   for (Int_t i = 0; i < fgkNTDC; i++) {
     152           0 :     if (!fRawReader->ReadNextInt(fData)) {
     153           0 :       Error("ReadTDC", "incomplete TDC equipment");
     154           0 :       return kFALSE;
     155             :     }
     156           0 :     if (fData & 0x07000000) {
     157           0 :       Warning("ReadTDC", "bad TDC data: %x", fData);
     158           0 :     }
     159           0 :     if ((fData & 0x00004000) == 0) {
     160           0 :       Warning("ReadTDC", "TDC data not valid: %x", fData);
     161           0 :     }
     162           0 :     if (fData & 0x00002000) {
     163           0 :       Warning("ReadTDC", "TDC data underflow: %x", fData);
     164           0 :     }
     165           0 :     if (fData & 0x00001000) {
     166           0 :       Warning("ReadTDC", "TDC data overflow: %x", fData);
     167           0 :     }
     168           0 :     fTDCChannel[i]  = (fData >> 16) & 0x1f;
     169           0 :     fTDCValue[i] = fData & 0x0fff;
     170             :   }
     171             : 
     172             :   // counter
     173           0 :   if (!fRawReader->ReadNextInt(fData)) {
     174           0 :     Error("ReadTDC", "incomplete TDC equipment");
     175           0 :     return kFALSE;
     176             :   }
     177           0 :   if ((fData & 0x04000000) == 0) {
     178           0 :     Error("ReadTDC", "invalid counter: 0x%x", fData);
     179           0 :     return kFALSE;
     180             :   }
     181             : 
     182             :   // v775 string
     183           0 :   if (!fRawReader->ReadNextInt(fData)) {
     184           0 :     Error("ReadTDC", "incomplete TDC equipment");
     185           0 :     return kFALSE;
     186             :   }
     187           0 :   if (!CheckString("v775")) return kFALSE;
     188             : 
     189           0 :   return kTRUE;
     190           0 : }
     191             : 
     192             : Bool_t AliVMERawStream::ReadTime()
     193             : {
     194             : // read the time information
     195             : 
     196           0 :   fRawReader->Reset();
     197           0 :   fRawReader->SelectEquipment(1970, 0x12345678, 0x12345678);
     198             : 
     199             :   // TIME string
     200           0 :   if (!fRawReader->ReadNextInt(fData)) return kFALSE;
     201           0 :   if (!CheckString("TIME")) return kFALSE;
     202             : 
     203             :   // time value
     204           0 :   if (!fRawReader->ReadNextInt(fTime)) {
     205           0 :     Error("ReadTime", "incomplete time equipment");
     206           0 :     return kFALSE;
     207             :   }
     208             : 
     209             :   // micro seconds value
     210           0 :   if (!fRawReader->ReadNextInt(fTimeMuSec)) {
     211           0 :     Error("ReadTime", "incomplete time equipment");
     212           0 :     return kFALSE;
     213             :   }
     214             : 
     215             :   // time string
     216           0 :   if (!fRawReader->ReadNextInt(fData)) {
     217           0 :     Error("ReadTime", "incomplete time equipment");
     218           0 :     return kFALSE;
     219             :   }
     220           0 :   if (!CheckString("time")) return kFALSE;
     221             : 
     222           0 :   return kTRUE;
     223           0 : }

Generated by: LCOV version 1.11