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