]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONPayloadTrigger.cxx
bugfix: AliTPCCalibPulser.h dependency and protection corrected
[u/mrichter/AliRoot.git] / MUON / AliMUONPayloadTrigger.cxx
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 // $Id$
17
18 //-----------------------------------------------------------------------------
19 /// \class AliMUONPayloadTrigger
20 /// Class Payload
21 ///
22 /// Decodes rawdata from buffer and stores in TClonesArray.
23 /// 
24 /// First version implement for Trigger
25 ///
26 /// \author Christian Finck
27 //-----------------------------------------------------------------------------
28
29 #include "AliMUONPayloadTrigger.h"
30
31 #include "AliMUONDarcHeader.h"
32 #include "AliMUONRegHeader.h"
33 #include "AliMUONLocalStruct.h"
34 #include "AliMUONDDLTrigger.h"
35
36 #include "AliLog.h"
37
38 /// \cond CLASSIMP
39 ClassImp(AliMUONPayloadTrigger)
40 /// \endcond
41
42 AliMUONPayloadTrigger::AliMUONPayloadTrigger()
43   : TObject(),
44     fMaxReg(8),
45     fMaxLoc(16),
46     fDDLTrigger(new AliMUONDDLTrigger()),
47     fRegHeader(new AliMUONRegHeader()), 
48     fLocalStruct(new AliMUONLocalStruct()),
49     fDarcEoWErrors(0),
50     fGlobalEoWErrors(0),
51     fRegEoWErrors(0),
52     fLocalEoWErrors(0)
53 {
54   ///
55   /// create an object to read MUON raw digits
56   /// Default ctor for monitoring purposes
57   ///
58
59 }
60
61 //___________________________________
62 AliMUONPayloadTrigger::~AliMUONPayloadTrigger()
63 {
64   ///
65   /// clean up
66   ///
67   delete fDDLTrigger;
68   delete fLocalStruct;
69   delete fRegHeader;
70 }
71
72
73 //______________________________________________________
74 Bool_t AliMUONPayloadTrigger::Decode(UInt_t *buffer)
75 {
76   /// decode trigger DDL
77   /// store only notified cards
78
79  // reading DDL for trigger
80
81   AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
82
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;
88   
89   Int_t index = 0;
90
91   memcpy(darcHeader->GetHeader(), &buffer[index], (kDarcHeaderSize)*4); 
92   index += kDarcHeaderSize;
93
94   if(darcHeader->GetEventType() == 0) {
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
105   if (buffer[index++] != darcHeader->GetEndOfDarc()) {
106
107       AliWarning(Form("Wrong end of Darc word %x instead of %x\n",
108                     buffer[index-1], darcHeader->GetEndOfDarc()));
109       fDarcEoWErrors++;
110   }
111   // 4 words of global board input + Global board output
112   memcpy(darcHeader->GetGlobalInput(), &buffer[index], (kGlobalHeaderSize)*4); 
113   index += kGlobalHeaderSize; 
114
115   if(scalerEvent) {
116     // 10 Global scaler words
117     memcpy(darcHeader->GetGlobalScalers(), &buffer[index], darcHeader->GetGlobalScalerLength()*4);
118     index += darcHeader->GetGlobalScalerLength();
119   }
120
121   if (buffer[index++] != darcHeader->GetEndOfGlobal()) {
122
123       AliWarning(Form("Wrong end of Global word %x instead of %x\n",
124                       buffer[index-1], darcHeader->GetEndOfGlobal()));
125       fGlobalEoWErrors++;
126   }
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
140     if (buffer[index++] != fRegHeader->GetEndOfReg()) {
141
142       AliWarning(Form("Wrong end of Reg word %x instead of %x\n",
143                     buffer[index-1], fRegHeader->GetEndOfReg()));
144       fRegEoWErrors++;
145     }
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
161       if (buffer[index++] != fLocalStruct->GetEndOfLocal()) {
162
163         AliWarning(Form("Wrong end of local word %x instead of %x\n",
164                         buffer[index-1], fLocalStruct->GetEndOfLocal()));
165         fLocalEoWErrors++;
166       }
167       // fill only if card notified
168       if (fLocalStruct->GetData(0) == fLocalStruct->GetDisableWord())
169           continue;
170
171       fDDLTrigger->AddLocStruct(*fLocalStruct, iReg);
172
173     } // local card loop
174         
175   } // regional card loop
176       
177
178   return kTRUE;
179 }
180
181 //______________________________________________________
182 void AliMUONPayloadTrigger::ResetDDL()
183 {
184   /// reseting TClonesArray
185   /// after each DDL
186   ///
187   AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
188   darcHeader->GetRegHeaderArray()->Delete();
189   fDarcEoWErrors   = 0;
190   fGlobalEoWErrors = 0;
191   fRegEoWErrors    = 0;
192   fLocalEoWErrors  = 0;
193 }
194
195 //______________________________________________________
196 void AliMUONPayloadTrigger::SetMaxReg(Int_t reg) 
197 {
198   /// set regional card number
199   if (reg > 8) reg = 8;
200   fMaxReg = reg;
201 }
202
203 //______________________________________________________
204 void AliMUONPayloadTrigger::SetMaxLoc(Int_t loc) 
205 {
206   /// set local card number
207   if (loc > 16) loc = 16;
208   fMaxLoc = loc;
209 }