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