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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // this program prints the mini headers in a raw data file //
22 // type "printMiniHeader -?" to get a description of the arguments //
24 ///////////////////////////////////////////////////////////////////////////////
30 #include "AliMiniHeader.h"
33 //_____________________________________________________________________________
34 int main(int argc, char** argv)
36 if ((argc < 2) || (argc > 2) || (strcmp(argv[1], "-?") == 0) ||
37 (strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0)) {
38 printf("\nUsage: printMiniHeader fileName\n\n");
39 printf(" fileName : name of the raw data file\n\n");
43 // open the raw data file
44 FILE* file = fopen(argv[1], "rb");
46 ::Fatal("readMiniHeader", "could not open file %s", argv[1]);
48 fseek(file, 0, SEEK_END);
49 Int_t size = ftell(file);
50 fseek(file, 0, SEEK_SET);
52 // read the mini headers
55 if (!fread(&header, sizeof(header), 1, file)) {
57 ::Error("readMiniHeader", "could not read mini header at position %d",
63 // check the magic word
64 if ((header.fMagicWord[2] != 0x12) ||
65 (header.fMagicWord[1] != 0x34) ||
66 (header.fMagicWord[0] != 0x56)) {
67 ::Error("readMiniHeader", "the magic word is wrong %2x%2x%2x",
68 header.fMagicWord[2], header.fMagicWord[1],
69 header.fMagicWord[0]);
74 Int_t bytesLeft = size-ftell(file);
75 if ((Int_t)header.fSize > bytesLeft) {
76 ::Error("readMiniHeader",
77 "the raw data size exceeds the file size by %d bytes",
78 header.fSize - bytesLeft);
81 // print the header information
82 printf("size : %d\n", header.fSize);
83 printf("detector ID : %d\n", header.fDetectorID);
84 printf("DDL ID : %d\n", header.fDDLID);
85 printf("compressed : %d\n", header.fCompressionFlag);
86 printf("version : %d\n", header.fVersion);
89 // go to next mini header
90 if ((Int_t)header.fSize > bytesLeft) break;
91 fseek(file, header.fSize, SEEK_CUR);