1 /**************************************************************************
2 * Copyright(c) 1998-2003, 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 //This class conteins all the methods to create raw data
20 //It produces DDL with both compressed and uncompressed format.
21 //For compression we use the optimized table wich needs
24 #include <TObjArray.h>
27 #include <Riostream.h>
30 //#include "AliAltroBuffer.h"
31 #include "AliAltroBufferV3.h"
32 #include "AliTPCAltroMapping.h"
33 #include "AliTPCDDLRawData.h"
36 ClassImp(AliTPCDDLRawData)
37 ////////////////////////////////////////////////////////////////////////////////////////
39 AliTPCDDLRawData::AliTPCDDLRawData(const AliTPCDDLRawData &source):
44 fVerbose=source.fVerbose;
48 AliTPCDDLRawData& AliTPCDDLRawData::operator=(const AliTPCDDLRawData &source){
50 if (this == &source) return (*this);
51 fVerbose=source.fVerbose;
56 ////////////////////////////////////////////////////////////////////////////
57 void AliTPCDDLRawData::RawData(const char* inputFileName){
59 //Number of DDL=2*36+4*36=216
60 //2 DDL for each inner sector
61 //4 DDL for each outer sector
64 f.open(inputFileName,ios::binary);
66 f.open(inputFileName);
68 if(!f){Error("RawData", "File doesn't exist !!");return;}
79 //AliAltroBuffer is used in write mode to generate raw data file
82 AliAltroBuffer *buffer=NULL;
83 Int_t pSecNumber=-1; //Previous Sector number
84 Int_t pRowNumber=-1; //Previous Row number
85 Int_t pPadNumber=-1; //Previous Pad number
86 Int_t pTimeBin=-1; //Previous Time-Bin
87 Int_t pSubSector=-1; //Previous Sub Sector
92 TString path = gSystem->Getenv("ALICE_ROOT");
93 path += "/TPC/mapping/Patch";
95 AliTPCAltroMapping *mapping[6];
96 for(Int_t i = 0; i < 6; i++) {
100 mapping[i] = new AliTPCAltroMapping(path2.Data());
104 while (f.read((char*)(&data),sizeof(data))){
110 pSubSector=data.SubSec;
113 ddlNumber=data.Sec*2+data.SubSec;
115 ddlNumber=72+(data.Sec-36)*4+data.SubSec;
116 strncpy(filename,AliDAQ::DdlFileName("TPC",ddlNumber),100);
117 Int_t patchIndex = data.SubSec;
118 if(data.Sec>=36) patchIndex += 2;
119 //buffer=new AliAltroBuffer(filename,mapping[patchIndex]);
120 buffer=new AliAltroBufferV3(filename,mapping[patchIndex]);
121 //size magic word sector number sub-sector number 0 for TPC 0 for uncompressed
122 buffer->WriteDataHeader(kTRUE,kFALSE);//Dummy;
124 buffer->FillBuffer(data.Dig);
128 if ( (data.Time==(pTimeBin+1)) &&
129 (pPadNumber==data.Pad) &&
130 (pRowNumber==data.Row) &&
131 (pSecNumber==data.Sec) &&
132 (pSubSector==data.SubSec)){
136 buffer->FillBuffer(pTimeBin);
137 buffer->FillBuffer(bunchLength+2);
139 if ((pPadNumber!=data.Pad)||(pRowNumber!=data.Row)||(pSecNumber!=data.Sec)||(pSubSector!=data.SubSec)){
140 //Trailer is formatted and inserted!!
141 buffer->WriteTrailer(nwords,pPadNumber,pRowNumber,pSecNumber);
145 if(pSecNumber!=data.Sec || pSubSector!=data.SubSec){
146 //size magic word sector number sub-sector number 0 for TPC 0 for uncompressed
148 buffer->WriteDataHeader(kFALSE,kFALSE);
149 //cout<<"Data header for DDL:"<<PSecNumber<<" Sub-sec:"<<PSubSector<<endl;
153 ddlNumber=data.Sec*2+data.SubSec;
155 ddlNumber=72+(data.Sec-36)*4+data.SubSec;
156 strncpy(filename,AliDAQ::DdlFileName("TPC",ddlNumber),100);
157 Int_t patchIndex = data.SubSec;
158 if(data.Sec>=36) patchIndex += 2;
159 // buffer=new AliAltroBuffer(filename,mapping[patchIndex]);
160 buffer=new AliAltroBufferV3(filename,mapping[patchIndex]);
161 buffer->WriteDataHeader(kTRUE,kFALSE);//Dummy;
162 pSubSector=data.SubSec;
172 buffer->FillBuffer(data.Dig);
177 buffer->FillBuffer(pTimeBin);
178 buffer->FillBuffer(bunchLength+2);
180 buffer->WriteTrailer(nwords,pPadNumber,pRowNumber,pSecNumber);
183 buffer->WriteDataHeader(kFALSE,kFALSE);
184 //cout<<"Data header for D D L:"<<pSecNumber<<" Sub-sec:"<<pSubSector<<endl;
188 for(Int_t i = 0; i < 6; i++) delete mapping[i];