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 "AliTPCAltroMapping.h"
32 #include "AliTPCDDLRawData.h"
33 #include "AliRawDataHeader.h"
35 ClassImp(AliTPCDDLRawData)
36 ////////////////////////////////////////////////////////////////////////////////////////
38 AliTPCDDLRawData::AliTPCDDLRawData(const AliTPCDDLRawData &source):
42 fVerbose=source.fVerbose;
46 AliTPCDDLRawData& AliTPCDDLRawData::operator=(const AliTPCDDLRawData &source){
48 fVerbose=source.fVerbose;
53 ////////////////////////////////////////////////////////////////////////////
54 void AliTPCDDLRawData::RawData(const char* inputFileName){
56 //Number of DDL=2*36+4*36=216
57 //2 DDL for each inner sector
58 //4 DDL for each outer sector
61 f.open(inputFileName,ios::binary);
63 f.open(inputFileName);
65 if(!f){Error("RawData", "File doesn't exist !!");return;}
76 //AliAltroBuffer is used in write mode to generate raw data file
79 AliAltroBuffer *buffer=NULL;
80 Int_t pSecNumber=-1; //Previous Sector number
81 Int_t pRowNumber=-1; //Previous Row number
82 Int_t pPadNumber=-1; //Previous Pad number
83 Int_t pTimeBin=-1; //Previous Time-Bin
84 Int_t pSubSector=-1; //Previous Sub Sector
89 TString path = gSystem->Getenv("ALICE_ROOT");
90 path += "/TPC/mapping/Patch";
92 AliTPCAltroMapping *mapping[6];
93 for(Int_t i = 0; i < 6; i++) {
97 mapping[i] = new AliTPCAltroMapping(path2.Data());
101 while (f.read((char*)(&data),sizeof(data))){
107 pSubSector=data.SubSec;
110 ddlNumber=data.Sec*2+data.SubSec;
112 ddlNumber=72+(data.Sec-36)*4+data.SubSec;
113 sprintf(filename,"TPC_%d.ddl",ddlNumber+kDDLOffset);
114 Int_t patchIndex = data.SubSec;
115 if(data.Sec>=36) patchIndex += 2;
116 buffer=new AliAltroBuffer(filename,mapping[patchIndex]);
117 //size magic word sector number sub-sector number 0 for TPC 0 for uncompressed
118 buffer->WriteDataHeader(kTRUE,kFALSE);//Dummy;
120 buffer->FillBuffer(data.Dig);
124 if ( (data.Time==(pTimeBin+1)) &&
125 (pPadNumber==data.Pad) &&
126 (pRowNumber==data.Row) &&
127 (pSecNumber==data.Sec)){
131 buffer->FillBuffer(pTimeBin);
132 buffer->FillBuffer(bunchLength+2);
134 if ((pPadNumber!=data.Pad)||(pRowNumber!=data.Row)||(pSecNumber!=data.Sec)){
135 //Trailer is formatted and inserted!!
136 buffer->WriteTrailer(nwords,pPadNumber,pRowNumber,pSecNumber);
140 if(pSubSector!=data.SubSec){
141 //size magic word sector number sub-sector number 0 for TPC 0 for uncompressed
143 buffer->WriteDataHeader(kFALSE,kFALSE);
144 //cout<<"Data header for DDL:"<<PSecNumber<<" Sub-sec:"<<PSubSector<<endl;
148 ddlNumber=data.Sec*2+data.SubSec;
150 ddlNumber=72+(data.Sec-36)*4+data.SubSec;
151 sprintf(filename,"TPC_%d.ddl",ddlNumber+kDDLOffset);
152 Int_t patchIndex = data.SubSec;
153 if(data.Sec>=36) patchIndex += 2;
154 buffer=new AliAltroBuffer(filename,mapping[patchIndex]);
155 buffer->WriteDataHeader(kTRUE,kFALSE);//Dummy;
156 pSubSector=data.SubSec;
166 buffer->FillBuffer(data.Dig);
171 buffer->FillBuffer(pTimeBin);
172 buffer->FillBuffer(bunchLength+2);
174 buffer->WriteTrailer(nwords,pPadNumber,pRowNumber,pSecNumber);
177 buffer->WriteDataHeader(kFALSE,kFALSE);
178 //cout<<"Data header for D D L:"<<pSecNumber<<" Sub-sec:"<<pSubSector<<endl;
182 for(Int_t i = 0; i < 6; i++) delete mapping[i];