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