Fixes for building of DA (Anshul)
[u/mrichter/AliRoot.git] / TPC / AliTPCMonitorDateFormat.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 $Log$
18 Revision 1.3  2007/10/12 13:36:27  cvetan
19 Coding convention fixes from Stefan
20
21 Revision 1.2  2007/09/17 16:34:54  cvetan
22 The package was overwriting the rootcint flags. This was fixed by applying the necessary changes in the DATE-dependent parts of the code
23
24 Revision 1.1  2007/09/17 10:23:31  cvetan
25 New TPC monitoring package from Stefan Kniege. The monitoring package can be started by running TPCMonitor.C macro located in macros folder.
26
27 */ 
28
29
30 ////////////////////////////////////////////////////////////////////////
31 ////
32 //// AliTPCMonitorDateFormat class
33 ////
34 //// Class for decoding raw data headers in DATE format
35 ////
36 //// Reads event and subevent header informations form DATE files
37 //// 
38 //// Authors: Roland Bramm, 
39 ////          Stefan Kniege, IKF, Frankfurt
40 ////       
41 /////////////////////////////////////////////////////////////////////////
42
43 #include "AliTPCMonitorDateFormat.h"
44 #include "event.h"
45 #include <iostream>
46 ClassImp(AliTPCMonitorDateFormat)
47 //____________________________________________________________________________
48 AliTPCMonitorDateFormat::AliTPCMonitorDateFormat(Char_t* data): 
49   fdataPtr(data),
50   fsubEventPtr(data),
51   fcurrentPtr(data),
52   fevent((struct eventHeaderStruct*) fdataPtr),
53   fsubEvent(0),
54   fequipment(0)
55 {
56   // Constructor
57 }
58
59
60 //____________________________________________________________________________
61 AliTPCMonitorDateFormat::AliTPCMonitorDateFormat(const AliTPCMonitorDateFormat &dateformat) :
62   TNamed(dateformat.GetName(),dateformat.GetTitle()),
63   fdataPtr(dateformat.fdataPtr),
64   fsubEventPtr(dateformat.fsubEventPtr),
65   fcurrentPtr(dateformat.fcurrentPtr),
66   fevent((struct eventHeaderStruct*)dateformat.fdataPtr),
67   fsubEvent(dateformat.fsubEvent),
68   fequipment(dateformat.fequipment)
69 {
70   // copy constructor
71 }
72
73 //____________________________________________________________________________
74 AliTPCMonitorDateFormat &AliTPCMonitorDateFormat:: operator= (const AliTPCMonitorDateFormat& dateformat)
75 {
76
77   // assignment operator 
78   if(this!=&dateformat)
79     {
80       fdataPtr=dateformat.fdataPtr;
81       fsubEventPtr=dateformat.fsubEventPtr;
82       fcurrentPtr=dateformat.fcurrentPtr;
83       fevent=dateformat.fevent;
84       fsubEvent=dateformat.fsubEvent;
85       fequipment=dateformat.fequipment;
86     }
87   return *this;
88 }
89
90 //____________________________________________________________________________
91 AliTPCMonitorDateFormat::~AliTPCMonitorDateFormat()
92 {
93   // Destructor
94 }
95
96 //____________________________________________________________________________
97 Int_t AliTPCMonitorDateFormat::GetEventSize()const
98 {
99   // Return event size
100   return (Int_t)fevent->eventSize;
101 }
102
103 //____________________________________________________________________________
104 Int_t AliTPCMonitorDateFormat::GetEventHeaderSize()const
105 {
106   // Return event header size
107   return (Int_t)fevent->eventHeadSize;
108 }
109
110 //____________________________________________________________________________
111 Int_t AliTPCMonitorDateFormat::GetEventHeaderBaseSize()const
112 {
113   // Return event header base size
114         return (Int_t)EVENT_HEAD_BASE_SIZE;
115 }
116
117 //____________________________________________________________________________
118 Int_t AliTPCMonitorDateFormat::GetEventID()const
119 {
120   // Return event ID
121   return (Int_t)EVENT_ID_GET_NB_IN_RUN(fevent->eventId);
122 }
123
124 //____________________________________________________________________________
125 Int_t AliTPCMonitorDateFormat::GetEventLDC()const
126 {
127   // Return event LDC
128   return (Int_t)fevent->eventLdcId;
129 }
130
131 //____________________________________________________________________________
132 Int_t AliTPCMonitorDateFormat::GetEventGDC()const
133 {
134   // return event GDC
135   return (Int_t)fevent->eventGdcId;
136 }
137
138 //____________________________________________________________________________
139 Int_t AliTPCMonitorDateFormat::GetEventRunID()const
140 {
141   // Return run ID
142   return (Int_t)fevent->eventRunNb;
143 }
144
145 //____________________________________________________________________________
146 Int_t AliTPCMonitorDateFormat::GetEventVersion()const
147 {
148   // Return event version
149   return (Int_t)fevent->eventVersion; 
150 }
151
152 //____________________________________________________________________________
153 Int_t AliTPCMonitorDateFormat::GetEventVersionMajor()const
154 {
155   // retrun event version (16-32 bit)
156   return (Int_t)(GetEventVersion()>>16);
157 }
158
159 //____________________________________________________________________________
160 Int_t AliTPCMonitorDateFormat::GetEventVersionMinor()const
161 {
162   // return event version (0-15 bit)
163   return (Int_t)(GetEventVersion()&0x0000ffff);
164 }
165
166 //____________________________________________________________________________
167 Bool_t AliTPCMonitorDateFormat::IsEventSuperEvent()const
168 {
169   // Check if event ist super event
170   Bool_t retval;
171   if(TEST_SYSTEM_ATTRIBUTE( fevent->eventTypeAttribute, ATTR_SUPER_EVENT ) == 1)
172     retval = true;
173   else
174     retval = false;
175   return retval;
176 }
177
178 //____________________________________________________________________________
179 Bool_t AliTPCMonitorDateFormat::IsEventStartOfRun()const
180 {
181   // Check if event ist Start of Run
182   Bool_t retval;
183   if(fevent->eventType == START_OF_RUN)
184     retval = true;
185   else
186     retval = false;
187   return retval;
188 }
189
190 //____________________________________________________________________________
191 Bool_t AliTPCMonitorDateFormat::IsEventEndOfRun()const
192 {
193   // Check if event is End of Run
194   Bool_t retval;
195   if(fevent->eventType == END_OF_RUN)
196     retval = true;
197   else
198     retval = false;
199   return retval;
200 }
201
202 //____________________________________________________________________________
203 Bool_t AliTPCMonitorDateFormat::IsEventPhysicsEvent()const
204 {
205   // Check if event is Physics event
206   Bool_t retval;
207   if(fevent->eventType == PHYSICS_EVENT)
208     retval = true;
209   else
210     retval = false;
211   return retval;
212 }
213
214 //____________________________________________________________________________
215 Bool_t AliTPCMonitorDateFormat::IsEventSwapped()const
216 {
217   // Check if event is swapped
218   Bool_t retval;
219   if(TEST_SYSTEM_ATTRIBUTE( fevent->eventTypeAttribute, ATTR_EVENT_SWAPPED ) == 1)
220     retval = true;
221   else
222     retval = false;
223   return retval;
224 }
225
226 //____________________________________________________________________________
227 Bool_t AliTPCMonitorDateFormat::IsEventWrongEndian()const
228 {
229   // Check endian  
230   Bool_t retval;
231   if(EVENT_MAGIC_NUMBER == fevent->eventMagic)
232     retval = false;
233   else
234     retval = true;
235   return retval;
236 }
237
238
239 //____________________________________________________________________________
240 void AliTPCMonitorDateFormat::GotoSubEventHeader()
241 {
242   // Set subevent Pointer to sub event
243   if(IsEventSuperEvent() ==true){
244     fsubEventPtr = fdataPtr+GetEventHeaderSize();
245     fsubEvent = (struct eventHeaderStruct*) (fsubEventPtr);
246   }else{
247     fsubEventPtr = fdataPtr;
248                 fsubEvent = (struct eventHeaderStruct*) (fsubEventPtr);
249   }
250 }
251
252 //____________________________________________________________________________
253 void AliTPCMonitorDateFormat::GotoNextSubEventHeader()
254 {
255   // set subevent pointer to next  sub event 
256   fsubEventPtr += GetSubEventSize();
257   fsubEvent = (struct eventHeaderStruct*) (fsubEventPtr);
258 }
259
260 //____________________________________________________________________________
261 Bool_t AliTPCMonitorDateFormat::IsLastSubEventHeader()const
262 {
263   // Check if sub event is last sub event
264   Bool_t retval;
265   Int_t position;
266   if(IsEventSuperEvent() ==true){
267     position = fsubEventPtr - fdataPtr;
268     if( (position+GetSubEventSize()) < GetEventSize() )
269                         retval = false;
270     else
271       retval = true;
272   }else{
273     position = fsubEventPtr - fdataPtr;
274     if( (position+GetSubEventSize()) < GetEventSize() )
275                         retval = false;
276     else
277       retval = true;
278   }
279   return retval;
280 }
281
282 //____________________________________________________________________________
283 Int_t AliTPCMonitorDateFormat::GetSubEventSize()const
284 {
285   // Return sub event size
286   return (Int_t)fsubEvent->eventSize;
287 }
288
289 //____________________________________________________________________________
290 Int_t AliTPCMonitorDateFormat::GetSubEventHeaderSize()const
291 {
292   // Return sub event header size
293   return (Int_t)fsubEvent->eventHeadSize;
294 }
295
296 //____________________________________________________________________________
297 Int_t AliTPCMonitorDateFormat::GetSubEventLDC()const
298 {
299   // Return sub event LDC
300   return (Int_t)fsubEvent->eventLdcId;
301 }
302
303 //____________________________________________________________________________
304 Int_t AliTPCMonitorDateFormat::GetSubEventGDC()const
305 {
306   // return sub event GDC
307         return (Int_t)fsubEvent->eventGdcId;
308 }
309
310
311 //____________________________________________________________________________
312 Bool_t AliTPCMonitorDateFormat::IsSubEventSuperEvent()
313 {
314   // Check if sub event is super event
315         Bool_t retval;
316         if(TEST_SYSTEM_ATTRIBUTE( fsubEvent->eventTypeAttribute, ATTR_SUPER_EVENT ) == 1)
317                 retval = true;
318         else
319                 retval = false;
320         return retval;
321 }
322
323 //____________________________________________________________________________
324 Bool_t AliTPCMonitorDateFormat::IsSubEventStartOfRun()const
325
326   // Check if sub event is start of run
327   Bool_t retval;
328   if(fsubEvent->eventType == START_OF_RUN)
329     retval = true;
330   else
331     retval = false;
332   return retval;
333 }
334
335 //____________________________________________________________________________
336 Bool_t AliTPCMonitorDateFormat::IsSubEventEndOfRun()const
337 {
338   // Check if sub event is end of run
339   Bool_t retval;
340   if(fsubEvent->eventType == END_OF_RUN)
341     retval = true;
342   else
343     retval = false;
344   return retval;
345 }
346
347 //____________________________________________________________________________
348 Bool_t AliTPCMonitorDateFormat::IsSubEventPhysicsEvent()const
349 {
350   // Check if sub event is physics event
351   Bool_t retval;
352   if(fsubEvent->eventType == PHYSICS_EVENT)
353     retval = true;
354   else
355     retval = false;
356   return retval;
357 }
358
359 //____________________________________________________________________________
360 void AliTPCMonitorDateFormat::GotoFirstEquipment()
361 {
362   // Set current pointer to first equipment
363   fcurrentPtr = fsubEventPtr + GetSubEventHeaderSize();
364   fequipment = (struct equipmentHeaderStruct*) (fcurrentPtr);
365 }
366
367 //____________________________________________________________________________
368 void AliTPCMonitorDateFormat::GotoNextEquipment()
369 {
370   // Set current pointer to next equipment
371   fcurrentPtr += GetEquipmentSize();
372   fequipment = (struct equipmentHeaderStruct*) (fcurrentPtr);
373 }
374
375 //____________________________________________________________________________
376 Bool_t AliTPCMonitorDateFormat::IsLastEquipment() const
377 {
378   // Check if equipment is last equipment
379   Bool_t retval;
380   Int_t position; 
381   position = fcurrentPtr - fsubEventPtr;
382   if( (position+GetEquipmentSize()) < GetSubEventSize() )
383                   retval = false;
384   else
385     retval = true;
386   return retval; 
387 }
388
389 //____________________________________________________________________________
390 Int_t AliTPCMonitorDateFormat::GetEquipmentSize() const
391 {
392   // Return equipment size
393   return (Int_t)fequipment->equipmentSize;
394 }
395
396 //____________________________________________________________________________
397 Int_t AliTPCMonitorDateFormat::GetPayloadSize() const
398 {
399   // Return payload slze
400   Int_t retval = 0;
401   if(GetEventVersion() < 196610){
402     retval = (Int_t)fequipment->equipmentSize;
403   }else{
404     retval = (Int_t)fequipment->equipmentSize - GetEquipmentHeaderSize();
405   }
406   return retval;
407 }
408
409 //____________________________________________________________________________
410 Int_t AliTPCMonitorDateFormat::GetEquipmentType() const
411 {
412   // Return equipment type
413   return (Int_t)fequipment->equipmentType;
414 }
415
416 //____________________________________________________________________________
417 Int_t AliTPCMonitorDateFormat::GetEquipmentID() const
418 {
419   // Return equipment ID
420   return (Int_t)fequipment->equipmentId;
421 }
422
423 //____________________________________________________________________________
424 Int_t* AliTPCMonitorDateFormat::GetEquipmentTypeAttribute()
425 {
426   // Return equipment type attribute
427   return (Int_t*)fequipment->equipmentTypeAttribute;
428 }
429
430 //____________________________________________________________________________
431 Int_t AliTPCMonitorDateFormat::GetEquipmentBasicSize() const
432 {
433   // Return equipment basic size
434   return (Int_t)fequipment->equipmentBasicElementSize;
435 }
436
437 //____________________________________________________________________________
438 Int_t AliTPCMonitorDateFormat::GetEquipmentHeaderSize() const
439 {
440   // Return equipment header size
441   return sizeof(struct equipmentHeaderStruct);
442 }
443
444
445 //____________________________________________________________________________
446 Char_t *AliTPCMonitorDateFormat::GetFirstDataPointer() 
447 {
448   // Return data pointer (after equipment header)
449   Char_t *datapointer;
450   if(GetEventVersion() < 196610){
451     fcurrentPtr += GetEquipmentHeaderSize();
452     datapointer = fcurrentPtr;
453   }else{
454     datapointer = fcurrentPtr + GetEquipmentHeaderSize();
455   }
456   return datapointer;
457  
458 }
459
460 //____________________________________________________________________________
461 Int_t AliTPCMonitorDateFormat::GetPosition() const
462 {
463   // Return current position relative to start of event
464   Int_t retval = (Int_t) (fcurrentPtr - fdataPtr);
465   return retval;
466 }
467
468 //____________________________________________________________________________
469 Int_t AliTPCMonitorDateFormat::GetPositionSubEvent() const
470 {
471   // Return subevent position  relative to start of event
472   Int_t retval = (Int_t) (fsubEventPtr - fdataPtr);
473   return retval;
474 }
475