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