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