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