]>
Commit | Line | Data |
---|---|---|
2e9f335b | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2003, 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 | **************************************************************************/ | |
30c1018e | 15 | /* $Id$ */ |
a79660fb | 16 | |
3f1ed77a | 17 | |
a79660fb | 18 | //This class conteins all the methods to create raw data |
19 | //as par a given DDL. | |
20 | //It produces DDL with both compressed and uncompressed format. | |
21 | //For compression we use the optimized table wich needs | |
22 | //to be provided. | |
23 | ||
b62e2a95 | 24 | #include <TObjArray.h> |
0d08c0d0 | 25 | #include <TString.h> |
26 | #include <TSystem.h> | |
b62e2a95 | 27 | #include <Riostream.h> |
2e9f335b | 28 | #include <stdio.h> |
29 | #include <stdlib.h> | |
b47ae838 | 30 | //#include "AliAltroBuffer.h" |
31 | #include "AliAltroBufferV3.h" | |
0d08c0d0 | 32 | #include "AliTPCAltroMapping.h" |
2e9f335b | 33 | #include "AliTPCDDLRawData.h" |
362c9d61 | 34 | #include "AliDAQ.h" |
2e9f335b | 35 | |
36 | ClassImp(AliTPCDDLRawData) | |
37 | //////////////////////////////////////////////////////////////////////////////////////// | |
38 | ||
0b3c7dfc | 39 | AliTPCDDLRawData::AliTPCDDLRawData(const AliTPCDDLRawData &source): |
179c6296 | 40 | TObject(source), |
41 | fVerbose(0) | |
0b3c7dfc | 42 | { |
2e9f335b | 43 | // Copy Constructor |
9f992f70 | 44 | fVerbose=source.fVerbose; |
2e9f335b | 45 | return; |
46 | } | |
47 | ||
48 | AliTPCDDLRawData& AliTPCDDLRawData::operator=(const AliTPCDDLRawData &source){ | |
49 | //Assigment operator | |
04420071 | 50 | if (this == &source) return (*this); |
9f992f70 | 51 | fVerbose=source.fVerbose; |
2e9f335b | 52 | return *this; |
53 | } | |
54 | ||
55 | ||
56 | //////////////////////////////////////////////////////////////////////////// | |
0421c3d1 | 57 | void AliTPCDDLRawData::RawData(const char* inputFileName){ |
58 | //Raw data generation | |
2e9f335b | 59 | //Number of DDL=2*36+4*36=216 |
60 | //2 DDL for each inner sector | |
61 | //4 DDL for each outer sector | |
2e9f335b | 62 | ifstream f; |
30c1018e | 63 | #ifndef __DECCXX |
0421c3d1 | 64 | f.open(inputFileName,ios::binary); |
30c1018e | 65 | #else |
0421c3d1 | 66 | f.open(inputFileName); |
30c1018e | 67 | #endif |
0421c3d1 | 68 | if(!f){Error("RawData", "File doesn't exist !!");return;} |
2e9f335b | 69 | struct DataPad{ |
70 | Int_t Sec; | |
71 | Int_t SubSec; | |
72 | Int_t Row; | |
73 | Int_t Pad; | |
74 | Int_t Dig; | |
75 | Int_t Time; | |
76 | }; | |
77 | DataPad data; | |
78 | ||
ba42285c | 79 | //AliAltroBuffer is used in write mode to generate raw data file |
c57f81bf | 80 | char filename[101]; |
0421c3d1 | 81 | Int_t ddlNumber=0; |
ba42285c | 82 | AliAltroBuffer *buffer=NULL; |
a79660fb | 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 | |
88 | Int_t bunchLength=0; | |
2e9f335b | 89 | Int_t nwords=0; |
0b3c7dfc | 90 | UInt_t numPackets=0; |
0421c3d1 | 91 | |
0d08c0d0 | 92 | TString path = gSystem->Getenv("ALICE_ROOT"); |
93 | path += "/TPC/mapping/Patch"; | |
94 | TString path2; | |
95 | AliTPCAltroMapping *mapping[6]; | |
96 | for(Int_t i = 0; i < 6; i++) { | |
97 | path2 = path; | |
98 | path2 += i; | |
99 | path2 += ".data"; | |
100 | mapping[i] = new AliTPCAltroMapping(path2.Data()); | |
101 | } | |
102 | ||
103 | ||
2e9f335b | 104 | while (f.read((char*)(&data),sizeof(data))){ |
a79660fb | 105 | if (pPadNumber==-1){ |
106 | pSecNumber=data.Sec; | |
107 | pRowNumber=data.Row; | |
108 | pPadNumber=data.Pad; | |
109 | pTimeBin=data.Time; | |
110 | pSubSector=data.SubSec; | |
0421c3d1 | 111 | |
112 | if(data.Sec<36) | |
113 | ddlNumber=data.Sec*2+data.SubSec; | |
114 | else | |
115 | ddlNumber=72+(data.Sec-36)*4+data.SubSec; | |
ed742999 | 116 | strncpy(filename,AliDAQ::DdlFileName("TPC",ddlNumber),100); |
0d08c0d0 | 117 | Int_t patchIndex = data.SubSec; |
118 | if(data.Sec>=36) patchIndex += 2; | |
b47ae838 | 119 | //buffer=new AliAltroBuffer(filename,mapping[patchIndex]); |
120 | buffer=new AliAltroBufferV3(filename,mapping[patchIndex]); | |
2e9f335b | 121 | //size magic word sector number sub-sector number 0 for TPC 0 for uncompressed |
0421c3d1 | 122 | buffer->WriteDataHeader(kTRUE,kFALSE);//Dummy; |
a79660fb | 123 | bunchLength=1; |
b27ca38e | 124 | buffer->FillBuffer(data.Dig); |
2e9f335b | 125 | nwords++; |
126 | }//end if | |
127 | else{ | |
a79660fb | 128 | if ( (data.Time==(pTimeBin+1)) && |
129 | (pPadNumber==data.Pad) && | |
130 | (pRowNumber==data.Row) && | |
8e6b0387 | 131 | (pSecNumber==data.Sec) && |
132 | (pSubSector==data.SubSec)){ | |
a79660fb | 133 | bunchLength++; |
2e9f335b | 134 | }//end if |
135 | else{ | |
a79660fb | 136 | buffer->FillBuffer(pTimeBin); |
137 | buffer->FillBuffer(bunchLength+2); | |
2e9f335b | 138 | nwords+=2; |
8e6b0387 | 139 | if ((pPadNumber!=data.Pad)||(pRowNumber!=data.Row)||(pSecNumber!=data.Sec)||(pSubSector!=data.SubSec)){ |
2e9f335b | 140 | //Trailer is formatted and inserted!! |
a79660fb | 141 | buffer->WriteTrailer(nwords,pPadNumber,pRowNumber,pSecNumber); |
2e9f335b | 142 | numPackets++; |
143 | nwords=0; | |
144 | ||
8e6b0387 | 145 | if(pSecNumber!=data.Sec || pSubSector!=data.SubSec){ |
0421c3d1 | 146 | //size magic word sector number sub-sector number 0 for TPC 0 for uncompressed |
147 | buffer->Flush(); | |
148 | buffer->WriteDataHeader(kFALSE,kFALSE); | |
149 | //cout<<"Data header for DDL:"<<PSecNumber<<" Sub-sec:"<<PSubSector<<endl; | |
150 | delete buffer; | |
151 | ||
152 | if(data.Sec<36) | |
153 | ddlNumber=data.Sec*2+data.SubSec; | |
154 | else | |
155 | ddlNumber=72+(data.Sec-36)*4+data.SubSec; | |
4af75575 | 156 | strncpy(filename,AliDAQ::DdlFileName("TPC",ddlNumber),100); |
0d08c0d0 | 157 | Int_t patchIndex = data.SubSec; |
158 | if(data.Sec>=36) patchIndex += 2; | |
b47ae838 | 159 | // buffer=new AliAltroBuffer(filename,mapping[patchIndex]); |
160 | buffer=new AliAltroBufferV3(filename,mapping[patchIndex]); | |
0421c3d1 | 161 | buffer->WriteDataHeader(kTRUE,kFALSE);//Dummy; |
a79660fb | 162 | pSubSector=data.SubSec; |
2e9f335b | 163 | }//end if |
2e9f335b | 164 | }//end if |
165 | ||
a79660fb | 166 | bunchLength=1; |
167 | pPadNumber=data.Pad; | |
168 | pRowNumber=data.Row; | |
169 | pSecNumber=data.Sec; | |
2e9f335b | 170 | }//end else |
a79660fb | 171 | pTimeBin=data.Time; |
b27ca38e | 172 | buffer->FillBuffer(data.Dig); |
2e9f335b | 173 | nwords++; |
174 | }//end else | |
175 | }//end while | |
0421c3d1 | 176 | if (buffer) { |
177 | buffer->FillBuffer(pTimeBin); | |
178 | buffer->FillBuffer(bunchLength+2); | |
179 | nwords+=2; | |
180 | buffer->WriteTrailer(nwords,pPadNumber,pRowNumber,pSecNumber); | |
181 | //write the D.H. | |
182 | buffer->Flush(); | |
183 | buffer->WriteDataHeader(kFALSE,kFALSE); | |
184 | //cout<<"Data header for D D L:"<<pSecNumber<<" Sub-sec:"<<pSubSector<<endl; | |
185 | delete buffer; | |
186 | } | |
0d08c0d0 | 187 | |
188 | for(Int_t i = 0; i < 6; i++) delete mapping[i]; | |
189 | ||
2e9f335b | 190 | f.close(); |
191 | return; | |
192 | } |