]>
Commit | Line | Data |
---|---|---|
69355034 | 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 | ClassImp(AliTOFFEEDump) | |
34 | ||
35 | //_______________________________________________________________ | |
36 | ||
37 | AliTOFFEEDump::AliTOFFEEDump() : | |
38 | TObject(), | |
39 | fSize(0), | |
40 | fData(NULL) | |
41 | { | |
42 | /* default constructor */ | |
43 | } | |
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 | { | |
83 | /* default destructor */ | |
84 | ||
85 | if (fData) delete [] fData; | |
86 | } | |
87 | ||
88 | //_______________________________________________________________ | |
89 | ||
90 | Bool_t | |
91 | AliTOFFEEDump::operator!=(const AliTOFFEEDump &source) | |
92 | { | |
93 | /* operator!= */ | |
94 | ||
95 | /* check size */ | |
96 | if (fSize != source.fSize) return kTRUE; | |
97 | ||
98 | /* check data */ | |
99 | if (memcmp(fData, source.fData, fSize) != 0) return kTRUE; | |
100 | ||
101 | return kFALSE; | |
102 | } | |
103 | ||
104 | //_______________________________________________________________ | |
105 | ||
106 | Bool_t | |
107 | AliTOFFEEDump::ReadFromFile(const Char_t *filename) | |
108 | { | |
109 | /* read from file */ | |
110 | ||
111 | /* open file */ | |
112 | Char_t *expandedFileName = gSystem->ExpandPathName(filename); | |
113 | std::ifstream is; | |
114 | is.open(expandedFileName, std::ios::binary); | |
115 | if (!is.is_open()) { | |
116 | AliError(Form("error while opening TOF FEE dump file: %s", filename)); | |
117 | return kFALSE; | |
118 | } | |
119 | AliInfo(Form("TOF FEE dump file opened: %s", filename)); | |
120 | ||
121 | /* get file size */ | |
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 */ | |
127 | if (size <= 0) { | |
128 | AliError(Form("error while getting TOF FEE dump file size: %d", size)); | |
129 | return kFALSE; | |
130 | } | |
131 | AliInfo(Form("got TOF FEE dump file size: %d", size)); | |
132 | ||
133 | /* check previous allocation */ | |
134 | if (fData) { | |
135 | AliWarning("data already allocated, old data will be overwritten"); | |
136 | delete [] fData; | |
137 | } | |
138 | ||
139 | /* allocate and read data */ | |
140 | fSize = size; | |
141 | fData = new UChar_t[fSize]; | |
142 | is.read((Char_t *)fData, fSize); | |
143 | AliInfo(Form("TOF FEE dump file stored")); | |
144 | ||
145 | /* close file */ | |
146 | is.close(); | |
147 | ||
148 | return kTRUE; | |
149 | } | |
150 | ||
151 | //_______________________________________________________________ | |
152 | ||
153 | void | |
154 | AliTOFFEEDump::DumpData() { | |
155 | /* dump data */ | |
156 | ||
157 | printf("*** TOF FEE dump data ***\n"); | |
158 | printf("data size = %d bytes\n", fSize); | |
159 | printf("*************************\n"); | |
fba402a9 | 160 | Int_t nwords = fSize / 4; |
69355034 | 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]); | |
165 | } | |
166 | printf("\n*************************\n"); | |
167 | ||
168 | } |