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