]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONPayloadTrigger.cxx
Puting a pre-compilator flag for online purpose (if AliLog not present) (Christian)
[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
32 #ifndef DATE_SYS
33 #include "AliLog.h"
34 #endif
35
36 #include "AliMUONDarcHeader.h"
37 #include "AliMUONRegHeader.h"
38 #include "AliMUONLocalStruct.h"
39 #include "AliMUONDDLTrigger.h"
40
41 ClassImp(AliMUONPayloadTrigger)
42
43 AliMUONPayloadTrigger::AliMUONPayloadTrigger()
44   : TObject(),
45     fMaxReg(8),
46     fMaxLoc(16),
47     fDDLTrigger(new AliMUONDDLTrigger()),
48     fRegHeader(new AliMUONRegHeader()), 
49     fLocalStruct(new AliMUONLocalStruct())
50 {
51   //
52   // create an object to read MUON raw digits
53   // Default ctor for monitoring purposes
54   //
55
56 }
57
58 //___________________________________
59 AliMUONPayloadTrigger::~AliMUONPayloadTrigger()
60 {
61   //
62   // clean up
63   //
64   delete fDDLTrigger;
65   delete fLocalStruct;
66   delete fRegHeader;
67 }
68
69
70 //______________________________________________________
71 Bool_t AliMUONPayloadTrigger::Decode(UInt_t *buffer)
72 {
73   // decode trigger DDL
74   // store only non-empty structures (TrigY ==0)
75
76  // reading DDL for trigger
77
78   AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
79
80   static Int_t kGlobalHeaderSize = darcHeader->GetGlobalHeaderLength(); 
81   static Int_t kDarcHeaderSize   = darcHeader->GetDarcHeaderLength(); 
82   static Int_t kRegHeaderSize    = fRegHeader->GetHeaderLength();
83
84   Bool_t scalerEvent = kFALSE;
85   
86   Int_t index = 0;
87
88   memcpy(darcHeader->GetHeader(), &buffer[index], (kDarcHeaderSize)*4); 
89   index += kDarcHeaderSize;
90
91   if(darcHeader->GetEventType() == 0) {
92     scalerEvent = kTRUE;
93   } else
94     scalerEvent = kFALSE;
95
96   if(scalerEvent) {
97     // 6 DARC scaler words
98     memcpy(darcHeader->GetDarcScalers(), &buffer[index], darcHeader->GetDarcScalerLength()*4);
99     index += darcHeader->GetDarcScalerLength();
100   }
101
102   if (buffer[index++] != darcHeader->GetEndOfDarc())
103 #ifndef DATE_SYS
104     AliWarning(Form("Wrong end of Darc word %x instead of %x\n",buffer[index-1], darcHeader->GetEndOfDarc()));
105 #else 
106   printf("Wrong end of Darc word %x instead of %x\n",buffer[index-1], darcHeader->GetEndOfDarc());
107 #endif
108
109   // 4 words of global board input + Global board output
110   memcpy(darcHeader->GetGlobalInput(), &buffer[index], (kGlobalHeaderSize)*4); 
111   index += kGlobalHeaderSize; 
112
113   if(scalerEvent) {
114     // 10 Global scaler words
115     memcpy(darcHeader->GetGlobalScalers(), &buffer[index], darcHeader->GetGlobalScalerLength()*4);
116     index += darcHeader->GetGlobalScalerLength();
117   }
118
119   if (buffer[index++] != darcHeader->GetEndOfGlobal())
120 #ifndef DATE_SYS
121     AliWarning(Form("Wrong end of Global word %x instead of %x\n",buffer[index-1], darcHeader->GetEndOfGlobal()));
122 #else 
123   printf("Wrong end of Global word %x instead of %x\n",buffer[index-1], darcHeader->GetEndOfGlobal());
124 #endif
125  
126   // 8 regional boards
127   for (Int_t iReg = 0; iReg < fMaxReg; iReg++) {           //loop over regeonal card
128
129     memcpy(fRegHeader->GetHeader(), &buffer[index], kRegHeaderSize*4);
130     index += kRegHeaderSize;
131
132     fDDLTrigger->AddRegHeader(*fRegHeader);
133     // 11 regional scaler word
134     if(scalerEvent) {
135       memcpy(fRegHeader->GetScalers(), &buffer[index], fRegHeader->GetScalerLength()*4);
136       index += fRegHeader->GetScalerLength();
137     }
138
139     if (buffer[index++] != fRegHeader->GetEndOfReg())
140 #ifndef DATE_SYS
141       AliWarning(Form("Wrong end of Reg word %x instead of %x\n",buffer[index-1], fRegHeader->GetEndOfReg()));
142 #else
143       printf("Wrong end of Reg word %x instead of %x\n",buffer[index-1], fRegHeader->GetEndOfReg());
144 #endif
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 #ifndef DATE_SYS
163         AliWarning(Form("Wrong end of local word %x instead of %x\n",buffer[index-1], fLocalStruct->GetEndOfLocal()));
164 #else
165       printf("Wrong end of local word %x instead of %x\n",buffer[index-1], fLocalStruct->GetEndOfLocal());
166 #endif
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 }