Additional protection for the raw-data reading. Getter to the raw-data payload (Chris...
[u/mrichter/AliRoot.git] / MUON / AliMUONRawStreamTracker.cxx
CommitLineData
c0751163 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
c4ee792d 16/* $Id $ */
17
c0751163 18
19///////////////////////////////////////////////////////////////////////////////
20///
c4ee792d 21/// \class AliMUONRawStreamTracker
c0751163 22/// This class provides access to MUON digits in raw data.
23///
24/// It loops over all MUON digits in the raw data given by the AliRawReader.
25/// The Next method goes to the next digit. If there are no digits left
26/// it returns kFALSE (under develpment)
313a427d 27/// It can loop also over DDL and store the decoded rawdata in TClonesArray
28/// in Payload class.
c0751163 29///
30/// First version implement for Tracker
31///
c4ee792d 32/// \author Christian Finck
c0751163 33///////////////////////////////////////////////////////////////////////////////
34
35#include "AliMUONRawStreamTracker.h"
36
37#include "AliRawReader.h"
38#include "AliRawDataHeader.h"
9e378ff4 39#include "AliDAQ.h"
c0751163 40#include "AliLog.h"
41
00e86732 42/// \cond CLASSIMP
c0751163 43ClassImp(AliMUONRawStreamTracker)
00e86732 44/// \endcond
c0751163 45
46AliMUONRawStreamTracker::AliMUONRawStreamTracker()
47 : TObject(),
48 fRawReader(0x0),
49 fDDL(0),
50 fBusPatchId(0),
51 fDspId(0),
52 fBlkId(0),
53 fNextDDL(kTRUE),
9f5dcca3 54 fMaxDDL(20),
55 fPayload(new AliMUONPayloadTracker())
c0751163 56{
00e86732 57 ///
58 /// create an object to read MUON raw digits
59 /// Default ctor for monitoring purposes
60 ///
c0751163 61
313a427d 62
c0751163 63}
64
65//_________________________________________________________________
66AliMUONRawStreamTracker::AliMUONRawStreamTracker(AliRawReader* rawReader)
67 : TObject(),
9f5dcca3 68 fRawReader(rawReader),
c0751163 69 fDDL(0),
70 fBusPatchId(0),
71 fDspId(0),
72 fBlkId(0),
73 fNextDDL(kTRUE),
9f5dcca3 74 fMaxDDL(20),
75 fPayload(new AliMUONPayloadTracker())
76
c0751163 77{
00e86732 78 ///
79 /// ctor with AliRawReader as argument
80 /// for reconstruction purpose
81 ///
c0751163 82
c0751163 83
c0751163 84}
85
c0751163 86//___________________________________
87AliMUONRawStreamTracker::~AliMUONRawStreamTracker()
88{
00e86732 89 ///
90 /// clean up
91 ///
313a427d 92 delete fPayload;
93
c0751163 94}
95
96//_____________________________________________________________
97Bool_t AliMUONRawStreamTracker::Next()
98{
00e86732 99 ///
100 /// read the next raw digit (buspatch structure)
101 /// returns kFALSE if there is no digit left
102 /// (under development)
c0751163 103
313a427d 104// AliMUONDDLTracker* ddlTracker = 0x0;
105// AliMUONBlockHeader* blkHeader = 0x0;
106// AliMUONDspHeader* dspHeader = 0x0;
107// Int_t nBusPatch;
108// Int_t nDsp;
109// Int_t nBlock;
110
111// next:
112// if (fNextDDL){
113// printf("iDDL %d\n", fDDL+1);
114// fBlkId = 0;
115// fDspId = 0;
116// fBusPatchId = 0;
117// if(!NextDDL())
118// return kFALSE;
119// }
120// fNextDDL = kFALSE;
121
122// ddlTracker = GetDDLTracker();
123
124// nBlock = ddlTracker->GetBlkHeaderEntries();
125// if (fBlkId < nBlock) {
126
127// blkHeader = ddlTracker->GetBlkHeaderEntry(fBlkId);
128// nDsp = blkHeader->GetDspHeaderEntries();
129
130// if( fDspId < nDsp) {
131// dspHeader = blkHeader->GetDspHeaderEntry(fDspId);
132// nBusPatch = dspHeader->GetBusPatchEntries();
133
134// if (fBusPatchId < nBusPatch) {
135// fBusStructPtr = dspHeader->GetBusPatchEntry(fBusPatchId++);
136// return kTRUE;
137
138// } else {// iBusPatch
139// fDspId++;
140// fBusPatchId = 0;
141// goto next;
142// // Next();
143// }
144
145// } else {// iDsp
146// fBlkId++;
147// fDspId = 0;
148// fBusPatchId = 0;
149// goto next;
150// // Next();
151// }
152
153// } else {// iBlock
154// fBlkId = 0;
155// fDspId = 0;
156// fBusPatchId = 0;
157// fNextDDL = kTRUE;
158// //return kTRUE;
159// goto next;
160// }
c0751163 161
162 return kFALSE;
163}
164
165//______________________________________________________
166Bool_t AliMUONRawStreamTracker::NextDDL()
167{
00e86732 168 /// reading tracker DDL
c0751163 169
313a427d 170 fPayload->ResetDDL();
c0751163 171
172
c0751163 173 if (fDDL >= 20) {
174 fDDL = 0;
175 return kFALSE;
176 }
177 AliDebug(3, Form("DDL Number %d\n", fDDL ));
178
c0751163 179 fRawReader->Reset();
362c9d61 180 fRawReader->Select("MUONTRK", fDDL, fDDL); //Select the DDL file to be read
c0751163 181
54e01c1c 182 if(!fRawReader->ReadHeader()) return kFALSE;
c0751163 183
313a427d 184 Int_t totalDataWord = fRawReader->GetDataSize(); // in bytes
c0751163 185
313a427d 186 UInt_t *buffer = new UInt_t[totalDataWord/4];
c0751163 187
54e01c1c 188 if(!fRawReader->ReadNext((UChar_t*)buffer, totalDataWord)) return kFALSE;
c0751163 189
84ceeb06 190 fPayload->Decode(buffer, totalDataWord/4);
c0751163 191
313a427d 192 delete[] buffer;
c0751163 193
194 fDDL++;
195
196 return kTRUE;
197}
c0751163 198
199//______________________________________________________
200void AliMUONRawStreamTracker::SetMaxDDL(Int_t ddl)
201{
00e86732 202 /// set DDL number
c0751163 203 if (ddl > 20) ddl = 20;
204 fMaxDDL = ddl;
313a427d 205
c0751163 206}
207
208//______________________________________________________
209void AliMUONRawStreamTracker::SetMaxBlock(Int_t blk)
210{
00e86732 211 /// set regional card number
313a427d 212 fPayload->SetMaxBlock(blk);
c0751163 213}