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