LCOV - code coverage report
Current view: top level - TOF/TOFbase - AliTOFFEEDump.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 49 2.0 %
Date: 2016-06-14 17:26:59 Functions: 1 9 11.1 %

          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             : /*
      17             :   author: Roberto Preghenella (preghenella@bo.infn.it)
      18             : */
      19             : ///////////////////////////////////////////////////////////////
      20             : //                                                           //
      21             : //   This classes provide the object to store the full dump  //
      22             : //   of TOF FEE configuration database.                      //
      23             : //                                                           //
      24             : ///////////////////////////////////////////////////////////////
      25             : 
      26             : #include "AliTOFFEEDump.h"
      27             : #include <string.h>
      28             : #include <iostream>
      29             : #include <fstream>
      30             : #include "TSystem.h"
      31             : #include "AliLog.h"
      32             : 
      33          26 : ClassImp(AliTOFFEEDump)
      34             : 
      35             : //_______________________________________________________________
      36             : 
      37             : AliTOFFEEDump::AliTOFFEEDump() :
      38           0 :   TObject(),
      39           0 :   fSize(0),
      40           0 :   fData(NULL)
      41           0 : {
      42             :   /* default constructor */
      43           0 : }
      44             : 
      45             : #if 0
      46             : //_______________________________________________________________
      47             : 
      48             : AliTOFFEEDump::AliTOFFEEDump(const AliTOFFEEDump &source) :
      49             :   TObject(source),
      50             :   fSize(source.fSize),
      51             :   fData(NULL)
      52             : {
      53             :   /* copy constructor */
      54             :   
      55             :   /* check size */
      56             :   if (fSize == 0) return;
      57             : 
      58             :   /* allocate and copy data */
      59             :   fData = new UChar_t[fSize];
      60             :   memcpy(fData, source.fData, fSize);
      61             : }
      62             : 
      63             : //_______________________________________________________________
      64             : 
      65             : AliTOFFEEDump &
      66             : AliTOFFEEDump::operator=(const AliTOFFEEDump &source)
      67             : {
      68             :   /* operator= */
      69             :   
      70             :   /* check source and destination size */
      71             :   if (source.fSize == 0 || fSize != source.fSize) return *this;
      72             : 
      73             :   /* copy data */
      74             :   memcpy(fData, source.fData, fSize);
      75             :   return *this;
      76             : }
      77             : #endif
      78             : 
      79             : //_______________________________________________________________
      80             : 
      81             : AliTOFFEEDump::~AliTOFFEEDump()
      82           0 : {
      83             :   /* default destructor */
      84             : 
      85           0 :   if (fData) delete [] fData;
      86           0 : }
      87             : 
      88             : //_______________________________________________________________
      89             : 
      90             : Bool_t
      91             : AliTOFFEEDump::operator!=(const AliTOFFEEDump &source)
      92             : {
      93             :   /* operator!= */
      94             :   
      95             :   /* check size */
      96           0 :   if (fSize != source.fSize) return kTRUE;
      97             : 
      98             :   /* check data */
      99           0 :   if (memcmp(fData, source.fData, fSize) != 0) return kTRUE;
     100             : 
     101           0 :   return kFALSE;
     102           0 : }
     103             : 
     104             : //_______________________________________________________________
     105             : 
     106             : Bool_t
     107             : AliTOFFEEDump::ReadFromFile(const Char_t *filename)
     108             : {
     109             :   /* read from file */
     110             : 
     111             :   /* open file */
     112           0 :   Char_t *expandedFileName = gSystem->ExpandPathName(filename);
     113           0 :   std::ifstream is;
     114           0 :   is.open(expandedFileName, std::ios::binary);
     115           0 :   if (!is.is_open()) {
     116           0 :     AliError(Form("error while opening TOF FEE dump file: %s", filename));
     117           0 :     return kFALSE;
     118             :   }
     119           0 :   AliInfo(Form("TOF FEE dump file opened: %s", filename));
     120             : 
     121             :   /* get file size */
     122           0 :   Int_t begin = is.tellg();
     123           0 :   is.seekg(0, std::ios::end); /* end */
     124           0 :   Int_t end = is.tellg();
     125           0 :   Int_t size = end - begin;
     126           0 :   is.seekg(0, std::ios::beg); /* rewind file */
     127           0 :   if (size <= 0) {
     128           0 :     AliError(Form("error while getting TOF FEE dump file size: %d", size));
     129           0 :     return kFALSE;
     130             :   }
     131           0 :   AliInfo(Form("got TOF FEE dump file size: %d", size));
     132             : 
     133             :   /* check previous allocation */
     134           0 :   if (fData) {
     135           0 :     AliWarning("data already allocated, old data will be overwritten");
     136           0 :     delete [] fData;
     137             :   }
     138             : 
     139             :   /* allocate and read data */
     140           0 :   fSize = size;
     141           0 :   fData = new UChar_t[fSize];
     142           0 :   is.read((Char_t *)fData, fSize);
     143           0 :   AliInfo(Form("TOF FEE dump file stored"));
     144             : 
     145             :   /* close file */
     146           0 :   is.close();
     147             : 
     148           0 :   return kTRUE;
     149           0 : }
     150             : 
     151             : //_______________________________________________________________
     152             : 
     153             : void
     154             : AliTOFFEEDump::DumpData() {
     155             :   /* dump data */
     156             : 
     157           0 :   printf("*** TOF FEE dump data ***\n");
     158           0 :   printf("data size = %d bytes\n", fSize);
     159           0 :   printf("*************************\n");
     160           0 :   Int_t nwords = fSize / 4;
     161           0 :   UInt_t *data = (UInt_t *)fData;
     162           0 :   for (Int_t iword = 0; iword < nwords; iword++) {
     163           0 :     if (iword != 0 && iword % 4 == 0) printf("\n");
     164           0 :     printf("%08x ", data[iword]);
     165             :   }
     166           0 :   printf("\n*************************\n");
     167             :   
     168           0 : }

Generated by: LCOV version 1.11