New class AliESDEvent, backward compatibility with the old AliESD (Christian)
[u/mrichter/AliRoot.git] / MUON / AliMUONRawStreamTrigger.cxx
CommitLineData
972432c1 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 $ */
972432c1 17
18///////////////////////////////////////////////////////////////////////////////
19///
c4ee792d 20/// \class AliMUONRawStreamTrigger
972432c1 21/// This class provides access to MUON digits in raw data.
22///
23/// It loops over all MUON digits in the raw data given by the AliRawReader.
24/// The Next method goes to the next digit. If there are no digits left
25/// it returns kFALSE(under develpment).
26/// It can loop also over DDL and store the decoded rawdata in TClonesArrays
313a427d 27/// in payload class.
972432c1 28///
29/// First version implement for Trigger
c4ee792d 30/// \author Christian Finck
972432c1 31///
32///////////////////////////////////////////////////////////////////////////////
33
34#include "AliMUONRawStreamTrigger.h"
35
36#include "AliRawReader.h"
37#include "AliRawDataHeader.h"
9e378ff4 38#include "AliDAQ.h"
972432c1 39#include "AliLog.h"
40
00e86732 41/// \cond CLASSIMP
972432c1 42ClassImp(AliMUONRawStreamTrigger)
00e86732 43/// \endcond
972432c1 44
45AliMUONRawStreamTrigger::AliMUONRawStreamTrigger()
46 : TObject(),
47 fRawReader(0x0),
9f5dcca3 48 fPayload(new AliMUONPayloadTrigger()),
972432c1 49 fDDL(0),
50 fSubEntries(0),
51 fNextDDL(kTRUE),
3c7f5307 52 fMaxDDL(2),
53 fEnableErrorLogger(kFALSE)
972432c1 54{
00e86732 55 ///
56 /// create an object to read MUON raw digits
57 /// Default ctor for monitoring purposes
58 ///
972432c1 59
972432c1 60
61}
62
63//_________________________________________________________________
64AliMUONRawStreamTrigger::AliMUONRawStreamTrigger(AliRawReader* rawReader)
65 : TObject(),
9f5dcca3 66 fRawReader(rawReader),
67 fPayload(new AliMUONPayloadTrigger()),
972432c1 68 fDDL(0),
69 fSubEntries(0),
70 fNextDDL(kTRUE),
3c7f5307 71 fMaxDDL(2),
72 fEnableErrorLogger(kFALSE)
972432c1 73{
00e86732 74 ///
75 /// ctor with AliRawReader as argument
76 /// for reconstruction purpose
77 ///
972432c1 78
972432c1 79}
80
81//___________________________________
82AliMUONRawStreamTrigger::~AliMUONRawStreamTrigger()
83{
00e86732 84 ///
85 /// clean up
86 ///
313a427d 87 delete fPayload;
972432c1 88}
89
90//_____________________________________________________________
91Bool_t AliMUONRawStreamTrigger::Next()
92{
00e86732 93/// read the next raw digit (buspatch structure)
94/// returns kFALSE if there is no digit left
972432c1 95
96// if (fNextDDL){
97// if(!NextDDL()) return kFALSE;
98// }
99// Int_t nEntries = fDDLTrigger->GetBusPatchEntries();
100
101// if (fSubEntries < nEntries) {
102// fLocalStruct = (AliMUONLocalStruct*)fDDLTrigger->GetBusPatchEntry(fSubEntries);
103// fSubEntries++;
104// fNextDDL = kFALSE;
105// return kTRUE;
106// } else {
107// fDDLTrigger->GetBusPatchArray()->Delete();
108// fSubEntries = 0;
109// fNextDDL = kTRUE;
110// return Next();
111// }
112
113 return kFALSE;
114}
115
116//______________________________________________________
117Bool_t AliMUONRawStreamTrigger::NextDDL()
118{
00e86732 119 /// reading tracker DDL
120 /// store buspatch info into Array
121 /// store only non-empty structures (buspatch info with datalength !=0)
972432c1 122
972432c1 123 // reset TClones
313a427d 124 fPayload->ResetDDL();
125
972432c1 126
127 // loop over the two ddl's
128 if (fDDL >= fMaxDDL) {
129 fDDL = 0;
130 return kFALSE;
131 }
9e378ff4 132
972432c1 133 fRawReader->Reset();
362c9d61 134 fRawReader->Select("MUONTRG", fDDL, fDDL); //Select the DDL file to be read
972432c1 135
d6ac560d 136 if (!fRawReader->ReadHeader()) return kFALSE;
972432c1 137
138 Int_t totalDataWord = fRawReader->GetDataSize(); // in bytes
139 UInt_t *buffer = new UInt_t[totalDataWord/4];
140
d6ac560d 141 // check not necessary yet, but for future developments
142 if (!fRawReader->ReadNext((UChar_t*)buffer, totalDataWord)) return kFALSE;
972432c1 143
313a427d 144 fPayload->Decode(buffer);
3c7f5307 145 if (fEnableErrorLogger) AddErrorMessage();
972432c1 146
313a427d 147 fDDL++;
972432c1 148
972432c1 149 delete [] buffer;
150
ea59383d 151
972432c1 152 return kTRUE;
153}
154
972432c1 155
156//______________________________________________________
157void AliMUONRawStreamTrigger::SetMaxDDL(Int_t ddl)
158{
00e86732 159 /// set DDL number
972432c1 160 if (ddl > 2) ddl = 2;
161 fMaxDDL = ddl;
162}
163
164//______________________________________________________
165void AliMUONRawStreamTrigger::SetMaxReg(Int_t reg)
166{
00e86732 167 /// set regional card number
313a427d 168 fPayload->SetMaxReg(reg);
972432c1 169}
170
171//______________________________________________________
172void AliMUONRawStreamTrigger::SetMaxLoc(Int_t loc)
173{
00e86732 174 /// set local card number
313a427d 175 fPayload->SetMaxLoc(loc);
972432c1 176}
ea59383d 177
178//______________________________________________________
179void AliMUONRawStreamTrigger::AddErrorMessage()
180{
181/// add message into logger of AliRawReader per event
182
183 for (Int_t i = 0; i < fPayload->GetDarcEoWErrors(); ++i)
184 fRawReader->AddMajorErrorLog(kDarcEoWErr, "Wrong end of Darc word structure");
185
186 for (Int_t i = 0; i < fPayload->GetGlobalEoWErrors(); ++i)
187 fRawReader->AddMajorErrorLog(kGlobalEoWErr, "Wrong end of Global word structure");
188
189 for (Int_t i = 0; i < fPayload->GetRegEoWErrors(); ++i)
190 fRawReader->AddMajorErrorLog(kRegEoWErr, "Wrong end of Regional word structure");
191
192 for (Int_t i = 0; i < fPayload->GetLocalEoWErrors(); ++i)
193 fRawReader->AddMajorErrorLog(kLocalEoWErr, "Wrong end of Local word structure");
194
195}