Add member in initialization list
[u/mrichter/AliRoot.git] / MUON / AliMUONPayloadTrigger.cxx
CommitLineData
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
00e86732 17/// \class AliMUONPayloadTrigger
939ae4b2 18/// Class Payload
19///
20/// Decodes rawdata from buffer and stores in TClonesArray.
21///
22/// First version implement for Trigger
23///
00e86732 24/// \author Christian Finck
939ae4b2 25
26#include "AliMUONPayloadTrigger.h"
27
939ae4b2 28#include "AliMUONDarcHeader.h"
29#include "AliMUONRegHeader.h"
30#include "AliMUONLocalStruct.h"
31#include "AliMUONDDLTrigger.h"
32
1ed3c5c2 33#include "AliLog.h"
34
00e86732 35/// \cond CLASSIMP
939ae4b2 36ClassImp(AliMUONPayloadTrigger)
00e86732 37/// \endcond
939ae4b2 38
39AliMUONPayloadTrigger::AliMUONPayloadTrigger()
40 : TObject(),
41 fMaxReg(8),
9f5dcca3 42 fMaxLoc(16),
43 fDDLTrigger(new AliMUONDDLTrigger()),
44 fRegHeader(new AliMUONRegHeader()),
45 fLocalStruct(new AliMUONLocalStruct())
939ae4b2 46{
00e86732 47 ///
48 /// create an object to read MUON raw digits
49 /// Default ctor for monitoring purposes
50 ///
939ae4b2 51
939ae4b2 52}
53
54//___________________________________
55AliMUONPayloadTrigger::~AliMUONPayloadTrigger()
56{
00e86732 57 ///
58 /// clean up
59 ///
939ae4b2 60 delete fDDLTrigger;
61 delete fLocalStruct;
62 delete fRegHeader;
63}
64
65
66//______________________________________________________
67Bool_t AliMUONPayloadTrigger::Decode(UInt_t *buffer)
68{
00e86732 69 /// decode trigger DDL
5a92f8e6 70 /// store only notified cards
939ae4b2 71
72 // reading DDL for trigger
73
74 AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
75
18d3ded7 76 static Int_t kGlobalHeaderSize = darcHeader->GetGlobalHeaderLength();
77 static Int_t kDarcHeaderSize = darcHeader->GetDarcHeaderLength();
78 static Int_t kRegHeaderSize = fRegHeader->GetHeaderLength();
79
80 Bool_t scalerEvent = kFALSE;
939ae4b2 81
82 Int_t index = 0;
18d3ded7 83
84 memcpy(darcHeader->GetHeader(), &buffer[index], (kDarcHeaderSize)*4);
85 index += kDarcHeaderSize;
939ae4b2 86
d622a0ec 87 if(darcHeader->GetEventType() == 0) {
939ae4b2 88 scalerEvent = kTRUE;
89 } else
90 scalerEvent = kFALSE;
91
92 if(scalerEvent) {
93 // 6 DARC scaler words
94 memcpy(darcHeader->GetDarcScalers(), &buffer[index], darcHeader->GetDarcScalerLength()*4);
95 index += darcHeader->GetDarcScalerLength();
96 }
97
98 if (buffer[index++] != darcHeader->GetEndOfDarc())
1ed3c5c2 99
ea59383d 100 AliWarning(Form("Wrong end of Darc word %x instead of %x\n",
1ed3c5c2 101 buffer[index-1], darcHeader->GetEndOfDarc()));
102
939ae4b2 103
104 // 4 words of global board input + Global board output
18d3ded7 105 memcpy(darcHeader->GetGlobalInput(), &buffer[index], (kGlobalHeaderSize)*4);
106 index += kGlobalHeaderSize;
939ae4b2 107
108 if(scalerEvent) {
109 // 10 Global scaler words
110 memcpy(darcHeader->GetGlobalScalers(), &buffer[index], darcHeader->GetGlobalScalerLength()*4);
111 index += darcHeader->GetGlobalScalerLength();
112 }
113
114 if (buffer[index++] != darcHeader->GetEndOfGlobal())
1ed3c5c2 115
ea59383d 116 AliWarning(Form("Wrong end of Global word %x instead of %x\n",
1ed3c5c2 117 buffer[index-1], darcHeader->GetEndOfGlobal()));
118
77a606e8 119
939ae4b2 120 // 8 regional boards
121 for (Int_t iReg = 0; iReg < fMaxReg; iReg++) { //loop over regeonal card
122
123 memcpy(fRegHeader->GetHeader(), &buffer[index], kRegHeaderSize*4);
124 index += kRegHeaderSize;
125
126 fDDLTrigger->AddRegHeader(*fRegHeader);
127 // 11 regional scaler word
128 if(scalerEvent) {
129 memcpy(fRegHeader->GetScalers(), &buffer[index], fRegHeader->GetScalerLength()*4);
130 index += fRegHeader->GetScalerLength();
131 }
132
133 if (buffer[index++] != fRegHeader->GetEndOfReg())
1ed3c5c2 134
ea59383d 135 AliWarning(Form("Wrong end of Reg word %x instead of %x\n",
1ed3c5c2 136 buffer[index-1], fRegHeader->GetEndOfReg()));
137
939ae4b2 138
139 // 16 local cards per regional board
140 for (Int_t iLoc = 0; iLoc < fMaxLoc; iLoc++) { //loop over local card
141
142 Int_t dataSize = fLocalStruct->GetLength();;
143
144 // 5 word trigger information
145 memcpy(fLocalStruct->GetData(), &buffer[index], dataSize*4);
146 index += dataSize;
147
148 // 45 regional scaler word
149 if(scalerEvent) {
150 memcpy(fLocalStruct->GetScalers(), &buffer[index], fLocalStruct->GetScalerLength()*4);
151 index += fLocalStruct->GetScalerLength();
152 }
153
154 if (buffer[index++] != fLocalStruct->GetEndOfLocal())
1ed3c5c2 155
ea59383d 156 AliWarning(Form("Wrong end of local word %x instead of %x\n",
1ed3c5c2 157 buffer[index-1], fLocalStruct->GetEndOfLocal()));
158
5a92f8e6 159 // fill only if card notified
160 if (fLocalStruct->GetData(0) == fLocalStruct->GetDisableWord())
161 continue;
162
939ae4b2 163 fDDLTrigger->AddLocStruct(*fLocalStruct, iReg);
164
165 } // local card loop
166
167 } // regional card loop
168
169
170 return kTRUE;
171}
172
173//______________________________________________________
174void AliMUONPayloadTrigger::ResetDDL()
175{
00e86732 176 /// reseting TClonesArray
177 /// after each DDL
178 ///
939ae4b2 179 AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
180 darcHeader->GetRegHeaderArray()->Delete();
181}
182
183//______________________________________________________
184void AliMUONPayloadTrigger::SetMaxReg(Int_t reg)
185{
00e86732 186 /// set regional card number
939ae4b2 187 if (reg > 8) reg = 8;
188 fMaxReg = reg;
189}
190
191//______________________________________________________
192void AliMUONPayloadTrigger::SetMaxLoc(Int_t loc)
193{
00e86732 194 /// set local card number
939ae4b2 195 if (loc > 16) loc = 16;
196 fMaxLoc = loc;
197}