]>
Commit | Line | Data |
---|---|---|
939ae4b2 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, 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 | **************************************************************************/ | |
15 | ||
16 | ||
17 | /////////////////////////////////////////////////////////////////////////////// | |
18 | /// | |
19 | /// Class Payload | |
20 | /// | |
21 | /// Decodes rawdata from buffer and stores in TClonesArray. | |
22 | /// | |
23 | /// First version implement for Tracker | |
24 | /// | |
25 | /////////////////////////////////////////////////////////////////////////////// | |
26 | ||
27 | #include "AliMUONPayloadTracker.h" | |
28 | ||
29 | #include "AliRawReader.h" | |
30 | #include "AliRawDataHeader.h" | |
31 | #include "AliLog.h" | |
32 | ||
33 | #include "AliMUONDspHeader.h" | |
34 | #include "AliMUONBlockHeader.h" | |
35 | #include "AliMUONBusStruct.h" | |
36 | #include "AliMUONDDLTracker.h" | |
37 | ||
38 | ClassImp(AliMUONPayloadTracker) | |
39 | ||
40 | AliMUONPayloadTracker::AliMUONPayloadTracker() | |
41 | : TObject(), | |
42 | fMaxBlock(2), | |
43 | fMaxDsp(5), | |
44 | fMaxBus(5) | |
45 | { | |
46 | // | |
84ceeb06 | 47 | // create an object to decode MUON payload |
939ae4b2 | 48 | // |
939ae4b2 | 49 | |
50 | fDDLTracker = new AliMUONDDLTracker(); | |
51 | fBusStruct = new AliMUONBusStruct(); | |
52 | fBlockHeader = new AliMUONBlockHeader(); | |
53 | fDspHeader = new AliMUONDspHeader(); | |
54 | } | |
55 | ||
56 | //_________________________________________________________________ | |
57 | AliMUONPayloadTracker::AliMUONPayloadTracker(const AliMUONPayloadTracker& stream) : | |
58 | TObject(stream) | |
59 | { | |
60 | // | |
61 | // copy ctor | |
62 | // | |
63 | AliFatal("copy constructor not implemented"); | |
64 | } | |
65 | ||
66 | //______________________________________________________________________ | |
67 | AliMUONPayloadTracker& AliMUONPayloadTracker::operator = (const AliMUONPayloadTracker& | |
68 | /* stream */) | |
69 | { | |
70 | // | |
71 | // assignment operator | |
72 | // | |
73 | AliFatal("assignment operator not implemented"); | |
74 | return *this; | |
75 | } | |
76 | ||
77 | ||
78 | //___________________________________ | |
79 | AliMUONPayloadTracker::~AliMUONPayloadTracker() | |
80 | { | |
81 | // | |
82 | // clean up | |
83 | // | |
939ae4b2 | 84 | delete fDDLTracker; |
85 | delete fBusStruct; | |
86 | delete fBlockHeader; | |
87 | delete fDspHeader; | |
88 | } | |
89 | ||
90 | //______________________________________________________ | |
84ceeb06 | 91 | Bool_t AliMUONPayloadTracker::Decode(UInt_t* buffer, Int_t totalDDLSize) |
939ae4b2 | 92 | { |
84ceeb06 | 93 | |
94 | // Each DDL is made with 2 Blocks each of which consists of 5 DSP's at most | |
95 | // and each of DSP has at most 5 buspatches. | |
96 | // The different structures, Block (CRT), DSP (FRT) and Buspatch, | |
97 | // are identified by a key word 0xFC0000FC, 0xF000000F and 0xB000000B respectively. | |
98 | // (fBusPatchManager no more needed !) | |
939ae4b2 | 99 | |
100 | ||
101 | //Read Header Size of DDL,Block,DSP and BusPatch | |
8ecc5cf0 | 102 | static Int_t kBlockHeaderSize = fBlockHeader->GetHeaderLength(); |
103 | static Int_t kDspHeaderSize = fDspHeader->GetHeaderLength(); | |
104 | static Int_t kBusPatchHeaderSize = fBusStruct->GetHeaderLength(); | |
939ae4b2 | 105 | |
84ceeb06 | 106 | // size structures |
939ae4b2 | 107 | Int_t totalBlockSize; |
108 | Int_t totalDspSize; | |
109 | Int_t totalBusPatchSize; | |
110 | Int_t dataSize; | |
84ceeb06 | 111 | Int_t bufSize; |
939ae4b2 | 112 | |
84ceeb06 | 113 | // indexes |
114 | Int_t indexBlk; | |
115 | Int_t indexDsp; | |
116 | Int_t indexBusPatch; | |
117 | Int_t index = 0; | |
118 | Int_t iBlock = 0; | |
939ae4b2 | 119 | |
84ceeb06 | 120 | // CROCUS CRT |
121 | while (buffer[index] == fBlockHeader->GetDefaultDataKey()) { | |
939ae4b2 | 122 | |
84ceeb06 | 123 | if (iBlock > fMaxBlock) break; |
124 | ||
125 | // copy within padding words | |
126 | memcpy(fBlockHeader->GetHeader(),&buffer[index], (kBlockHeaderSize)*4); | |
939ae4b2 | 127 | |
84ceeb06 | 128 | totalBlockSize = fBlockHeader->GetTotalLength(); |
939ae4b2 | 129 | |
84ceeb06 | 130 | indexBlk = index; |
131 | index += kBlockHeaderSize; | |
939ae4b2 | 132 | |
84ceeb06 | 133 | // copy in TClonesArray |
134 | fDDLTracker->AddBlkHeader(*fBlockHeader); | |
939ae4b2 | 135 | |
84ceeb06 | 136 | // Crocus FRT |
137 | Int_t iDsp = 0; | |
138 | while (buffer[index] == fDspHeader->GetDefaultDataKey()) { | |
939ae4b2 | 139 | |
84ceeb06 | 140 | if (iDsp > fMaxDsp) break; // if ever... |
141 | ||
142 | memcpy(fDspHeader->GetHeader(),&buffer[index], kDspHeaderSize*4); | |
939ae4b2 | 143 | |
84ceeb06 | 144 | totalDspSize = fDspHeader->GetTotalLength(); |
145 | indexDsp = index; | |
146 | index += kDspHeaderSize; | |
939ae4b2 | 147 | |
84ceeb06 | 148 | if (fDspHeader->GetPaddingWord() != fDspHeader->GetDefaultPaddingWord()) { |
149 | // copy the field of Padding word into ErrorWord field | |
150 | fDspHeader->SetErrorWord(fDspHeader->GetPaddingWord()); | |
151 | index--; | |
152 | } | |
939ae4b2 | 153 | |
84ceeb06 | 154 | // copy in TClonesArray |
155 | fDDLTracker->AddDspHeader(*fDspHeader, iBlock); | |
939ae4b2 | 156 | |
84ceeb06 | 157 | // buspatch structure |
158 | Int_t iBusPatch = 0; | |
159 | while (buffer[index] == fBusStruct->GetDefaultDataKey()) { | |
939ae4b2 | 160 | |
84ceeb06 | 161 | if (iBusPatch > fMaxBus) break; // if ever |
162 | ||
163 | //copy buffer into header structure | |
164 | memcpy(fBusStruct->GetHeader(), &buffer[index], kBusPatchHeaderSize*4); | |
939ae4b2 | 165 | |
84ceeb06 | 166 | totalBusPatchSize = fBusStruct->GetTotalLength(); |
167 | indexBusPatch = index; | |
939ae4b2 | 168 | |
84ceeb06 | 169 | //Check Buspatch header, not empty events |
170 | if(totalBusPatchSize > kBusPatchHeaderSize) { | |
171 | ||
172 | index += kBusPatchHeaderSize; | |
173 | dataSize = fBusStruct->GetLength(); | |
174 | bufSize = fBusStruct->GetBufSize(); | |
175 | ||
176 | if(dataSize > 0) { // check data present | |
177 | if (dataSize > bufSize) // check buffer size | |
178 | fBusStruct->SetAlloc(dataSize); | |
179 | ||
180 | //copy buffer into data structure | |
181 | memcpy(fBusStruct->GetData(), &buffer[index], dataSize*4); | |
182 | fBusStruct->SetBlockId(iBlock); // could be usefull in future applications ? | |
183 | fBusStruct->SetDspId(iDsp); | |
184 | ||
185 | // copy in TClonesArray | |
186 | fDDLTracker->AddBusPatch(*fBusStruct, iBlock, iDsp); | |
187 | ||
188 | } // dataSize test | |
189 | ||
190 | } // testing buspatch | |
191 | ||
192 | index = indexBusPatch + totalBusPatchSize; | |
193 | if (index >= totalDDLSize) {// check the end of DDL | |
194 | index = totalDDLSize - 1; // point to the last element of buffer | |
195 | break; | |
196 | } | |
197 | iBusPatch++; | |
198 | } // buspatch loop | |
939ae4b2 | 199 | |
84ceeb06 | 200 | index = indexDsp + totalDspSize; |
201 | if (index >= totalDDLSize) { | |
202 | index = totalDDLSize - 1; | |
203 | break; | |
204 | } | |
205 | iDsp++; | |
206 | } // dsp loop | |
207 | ||
208 | index = indexBlk + totalBlockSize; | |
209 | if (index >= totalDDLSize) { | |
210 | index = totalDDLSize - 1; | |
211 | break; | |
212 | } | |
213 | iBlock++; | |
214 | } // block loop | |
939ae4b2 | 215 | |
216 | return kTRUE; | |
217 | } | |
218 | ||
219 | //______________________________________________________ | |
220 | void AliMUONPayloadTracker::ResetDDL() | |
221 | { | |
222 | // reseting TClonesArray | |
223 | // after each DDL | |
224 | // | |
225 | fDDLTracker->GetBlkHeaderArray()->Delete(); | |
226 | } | |
227 | ||
228 | //______________________________________________________ | |
229 | void AliMUONPayloadTracker::SetMaxBlock(Int_t blk) | |
230 | { | |
231 | // set regional card number | |
232 | if (blk > 2) blk = 2; | |
233 | fMaxBlock = blk; | |
234 | } |