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 **************************************************************************/
16 // Interface to the Altro format
17 // to read and write digits
18 // To be used in Alice Data Challenges
19 // and in the compression of the RAW data
21 #include "AliAltroBufferV3.h"
22 #include "AliRawDataHeaderSim.h"
24 #include "AliFstream.h"
26 ClassImp(AliAltroBufferV3)
28 //_____________________________________________________________________________
29 AliAltroBufferV3::AliAltroBufferV3(const char* fileName, AliAltroMapping *mapping):
30 AliAltroBuffer(fileName,mapping),
36 //_____________________________________________________________________________
37 AliAltroBufferV3::~AliAltroBufferV3()
41 if (fVerbose) Info("~AliAltroBufferV3", "File Created");
47 //_____________________________________________________________________________
48 AliAltroBufferV3::AliAltroBufferV3(const AliAltroBufferV3& source):
49 AliAltroBuffer(source),
54 Fatal("AliAltroBufferV3", "copy constructor not implemented");
57 //_____________________________________________________________________________
58 AliAltroBufferV3& AliAltroBufferV3::operator = (const AliAltroBufferV3& /*source*/)
62 Fatal("operator =", "assignment operator not implemented");
66 //_____________________________________________________________________________
67 void AliAltroBufferV3::FillBuffer(Int_t val)
69 //Fills the Buffer with 16 ten bits words and write into a file
71 if ((val > 0x3FF) || (val < 0)) {
72 Error("FillBuffer", "Value out of range (10 bits): %d", val);
76 if (fN >= (kMaxWords-1)) {
77 Error("FillBuffer","Altro channel can't have more than 1024 10-bit words!");
84 //_____________________________________________________________________________
85 void AliAltroBufferV3::WriteTrailer(Int_t wordsNumber, Short_t hwAddress)
87 //Writes a trailer (header) of 32 bits using
88 //a given hardware adress
89 UInt_t temp = hwAddress & 0xFFF;
90 temp = (wordsNumber << 16) & 0x3FF;
93 fFile->WriteBuffer((char *)(&temp),sizeof(UInt_t));
98 //_____________________________________________________________________________
99 void AliAltroBufferV3::ReverseAndWrite()
101 // Reverse the altro data order and
102 // write the buffer to the file
105 for(Int_t i = fN; i >= 0; i--) {
106 temp |= (fArray[i] << shift);
109 fFile->WriteBuffer((char *)(&temp),sizeof(UInt_t));
116 fFile->WriteBuffer((char *)(&temp),sizeof(UInt_t));
122 //_____________________________________________________________________________
123 void AliAltroBufferV3::WriteRCUTrailer(Int_t rcuId)
125 // Writes the RCU trailer
126 // rcuId the is serial number of the corresponding
127 // RCU. The basic format of the trailer can be
128 // found in the RCU manual.
129 // This method should be called at the end of
132 UInt_t currentFilePos = fFile->Tellp();
133 UInt_t size = currentFilePos-fDataHeaderPos;
134 size -= sizeof(AliRawDataHeader);
136 if ((size % 5) != 0) {
137 AliFatal(Form("The current raw data payload is not a mutiple of 5 (%d) ! Can not write the RCU trailer !",size));
141 // Now put the size in unit of number of 40bit words
143 fFile->WriteBuffer((char *)(&size),sizeof(UInt_t));
145 // Now several not yet full defined fields
146 // In principle they are supposed to contain
147 // information about the sampling frequency,
148 // L1 phase, list of 'dead' FECs, etc.
150 // fFile->WriteBuffer((char *)(buffer),sizeof(UInt_t)*n);
152 // Now the RCU identifier and size of the trailer
153 // FOr the moment the triler size is 2 32-bit words
154 UInt_t buffer = (2 & 0x7F);
155 buffer |= ((rcuId & 0x1FF) << 7);
156 buffer |= 0xAAAA << 16;
157 fFile->WriteBuffer((char *)(&buffer),sizeof(UInt_t));