]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONPayloadTrigger.cxx
bc4c1efe8fd9863a4b63d61000b4e2b5bdcfe895
[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 ///////////////////////////////////////////////////////////////////////////////
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
38 ClassImp(AliMUONPayloadTrigger)
39
40 AliMUONPayloadTrigger::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 //_________________________________________________________________
57 AliMUONPayloadTrigger::AliMUONPayloadTrigger(const AliMUONPayloadTrigger& stream) :
58   TObject(stream)
59 {
60   //
61   // copy ctor
62   //
63   AliFatal("copy constructor not implemented");
64 }
65
66 //______________________________________________________________________
67 AliMUONPayloadTrigger& AliMUONPayloadTrigger::operator = (const AliMUONPayloadTrigger& 
68                                               /* stream */)
69
70   // 
71   // assignment operator
72   //
73   AliFatal("assignment operator not implemented");
74   return *this;
75 }
76
77 //___________________________________
78 AliMUONPayloadTrigger::~AliMUONPayloadTrigger()
79 {
80   //
81   // clean up
82   //
83   delete fDDLTrigger;
84   delete fLocalStruct;
85   delete fRegHeader;
86 }
87
88
89 //______________________________________________________
90 Bool_t AliMUONPayloadTrigger::Decode(UInt_t *buffer)
91 {
92   // reading tracker DDL
93   // store buspatch info into Array
94   // store only non-empty structures (buspatch info with datalength !=0)
95
96  // reading DDL for trigger
97
98   AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
99
100   Int_t kDarcHeaderSize = darcHeader->GetHeaderLength(); 
101   Int_t kRegHeaderSize  = fRegHeader->GetHeaderLength() ;
102   Bool_t scalerEvent    = kFALSE;
103   
104   Int_t index = 0;
105   darcHeader->SetWord(buffer[index++]);
106
107   if(darcHeader->GetEventType() == 2) {
108     scalerEvent = kTRUE;
109   } else
110     scalerEvent = kFALSE;
111
112   if(scalerEvent) {
113     // 6 DARC scaler words
114     memcpy(darcHeader->GetDarcScalers(), &buffer[index], darcHeader->GetDarcScalerLength()*4);
115     index += darcHeader->GetDarcScalerLength();
116   }
117
118   if (buffer[index++] != darcHeader->GetEndOfDarc())
119     AliWarning(Form("Wrong end of Darc word %x instead of %x\n",buffer[index-1], darcHeader->GetEndOfDarc())); 
120
121   // 4 words of global board input + Global board output
122   memcpy(darcHeader->GetGlobalInput(), &buffer[index], (kDarcHeaderSize-1)*4); 
123   index += kDarcHeaderSize- 1; // kind tricky cos scaler info in-between Darc header
124
125   if(scalerEvent) {
126     // 10 Global scaler words
127     memcpy(darcHeader->GetGlobalScalers(), &buffer[index], darcHeader->GetGlobalScalerLength()*4);
128     index += darcHeader->GetGlobalScalerLength();
129   }
130
131   if (buffer[index++] != darcHeader->GetEndOfGlobal())
132     AliWarning(Form("Wrong end of Global word %d instead of %d\n",buffer[index-1], darcHeader->GetEndOfGlobal()));
133     
134   // 8 regional boards
135   for (Int_t iReg = 0; iReg < fMaxReg; iReg++) {           //loop over regeonal card
136
137     memcpy(fRegHeader->GetHeader(), &buffer[index], kRegHeaderSize*4);
138     index += kRegHeaderSize;
139
140     fDDLTrigger->AddRegHeader(*fRegHeader);
141     // 11 regional scaler word
142     if(scalerEvent) {
143       memcpy(fRegHeader->GetScalers(), &buffer[index], fRegHeader->GetScalerLength()*4);
144       index += fRegHeader->GetScalerLength();
145     }
146
147     if (buffer[index++] != fRegHeader->GetEndOfReg())
148       AliWarning(Form("Wrong end of Reg word %x instead of %x\n",buffer[index-1], fRegHeader->GetEndOfReg()));
149
150     // 16 local cards per regional board
151     for (Int_t iLoc = 0; iLoc < fMaxLoc; iLoc++) {         //loop over local card
152           
153       Int_t dataSize = fLocalStruct->GetLength();;
154
155       // 5 word trigger information
156       memcpy(fLocalStruct->GetData(), &buffer[index], dataSize*4); 
157       index += dataSize;         
158
159       // 45 regional scaler word
160       if(scalerEvent) {
161         memcpy(fLocalStruct->GetScalers(), &buffer[index], fLocalStruct->GetScalerLength()*4);
162         index += fLocalStruct->GetScalerLength();
163       }
164
165       if (buffer[index++] != fLocalStruct->GetEndOfLocal())
166         AliWarning(Form("Wrong end of local word %x instead of %x\n",buffer[index-1], fLocalStruct->GetEndOfLocal()));
167           
168       fDDLTrigger->AddLocStruct(*fLocalStruct, iReg);
169
170     } // local card loop
171         
172   } // regional card loop
173       
174
175   return kTRUE;
176 }
177
178 //______________________________________________________
179 void AliMUONPayloadTrigger::ResetDDL()
180 {
181   // reseting TClonesArray
182   // after each DDL
183   //
184   AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
185   darcHeader->GetRegHeaderArray()->Delete();
186 }
187
188 //______________________________________________________
189 void AliMUONPayloadTrigger::SetMaxReg(Int_t reg) 
190 {
191   // set regional card number
192   if (reg > 8) reg = 8;
193   fMaxReg = reg;
194 }
195
196 //______________________________________________________
197 void AliMUONPayloadTrigger::SetMaxLoc(Int_t loc) 
198 {
199   // set local card number
200   if (loc > 16) loc = 16;
201   fMaxLoc = loc;
202 }