1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 author: Roberto Preghenella (preghenella@bo.infn.it)
19 ///////////////////////////////////////////////////////////////
21 // This classes provide the object to store the full dump //
22 // of TOF FEE configuration database. //
24 ///////////////////////////////////////////////////////////////
26 #include "AliTOFFEEDump.h"
33 ClassImp(AliTOFFEEDump)
35 //_______________________________________________________________
37 AliTOFFEEDump::AliTOFFEEDump() :
42 /* default constructor */
46 //_______________________________________________________________
48 AliTOFFEEDump::AliTOFFEEDump(const AliTOFFEEDump &source) :
53 /* copy constructor */
56 if (fSize == 0) return;
58 /* allocate and copy data */
59 fData = new UChar_t[fSize];
60 memcpy(fData, source.fData, fSize);
63 //_______________________________________________________________
66 AliTOFFEEDump::operator=(const AliTOFFEEDump &source)
70 /* check source and destination size */
71 if (source.fSize == 0 || fSize != source.fSize) return *this;
74 memcpy(fData, source.fData, fSize);
79 //_______________________________________________________________
81 AliTOFFEEDump::~AliTOFFEEDump()
83 /* default destructor */
85 if (fData) delete [] fData;
88 //_______________________________________________________________
91 AliTOFFEEDump::operator!=(const AliTOFFEEDump &source)
96 if (fSize != source.fSize) return kTRUE;
99 if (memcmp(fData, source.fData, fSize) != 0) return kTRUE;
104 //_______________________________________________________________
107 AliTOFFEEDump::ReadFromFile(const Char_t *filename)
112 Char_t *expandedFileName = gSystem->ExpandPathName(filename);
114 is.open(expandedFileName, std::ios::binary);
116 AliError(Form("error while opening TOF FEE dump file: %s", filename));
119 AliInfo(Form("TOF FEE dump file opened: %s", filename));
122 Int_t begin = is.tellg();
123 is.seekg(0, std::ios::end); /* end */
124 Int_t end = is.tellg();
125 Int_t size = end - begin;
126 is.seekg(0, std::ios::beg); /* rewind file */
128 AliError(Form("error while getting TOF FEE dump file size: %d", size));
131 AliInfo(Form("got TOF FEE dump file size: %d", size));
133 /* check previous allocation */
135 AliWarning("data already allocated, old data will be overwritten");
139 /* allocate and read data */
141 fData = new UChar_t[fSize];
142 is.read((Char_t *)fData, fSize);
143 AliInfo(Form("TOF FEE dump file stored"));
151 //_______________________________________________________________
154 AliTOFFEEDump::DumpData() {
157 printf("*** TOF FEE dump data ***\n");
158 printf("data size = %d bytes\n", fSize);
159 printf("*************************\n");
160 Int_t nwords = fSize / 4;
161 UInt_t *data = (UInt_t *)fData;
162 for (Int_t iword = 0; iword < nwords; iword++) {
163 if (iword != 0 && iword % 4 == 0) printf("\n");
164 printf("%08x ", data[iword]);
166 printf("\n*************************\n");