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