]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RAW/AliRawReaderDateOnline.cxx
Typo corrected.
[u/mrichter/AliRoot.git] / RAW / AliRawReaderDateOnline.cxx
CommitLineData
3b98a4d4 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/// This is a class for reading raw data from a date monitoring libraries.
19/// It supports two modes - event taken from shared memory via DATE monitoring
20/// libs, or an emulation mode when the events are taken from a DATE file using
21/// the same monitoring libs.
22/// The constructor requires an argument:
23///
24/// : - events are taken from shared memory
25/// or
26/// <DATE_filename> - events are taken from date file
27///
28/// Cvetan Cheshkov 1/04/2008
29///////////////////////////////////////////////////////////////////////////////
30
31#include "AliRawReaderDateOnline.h"
36a7d3c6 32#include "AliLog.h"
33#ifdef ALI_DATE
34#include "event.h"
35#include "monitor.h"
36#endif
3b98a4d4 37
38ClassImp(AliRawReaderDateOnline)
39
36a7d3c6 40AliRawReaderDateOnline::AliRawReaderDateOnline(
3b98a4d4 41#ifdef ALI_DATE
42 const char* filename
43#else
44 const char* /* filename */
45#endif
46 ) :
36a7d3c6 47 AliRawReaderDate((void*)NULL)
3b98a4d4 48{
49
50// Constructor
51// Initialize the DATE monitoring libs
52
53#ifdef ALI_DATE
54
00665a00 55 fSelectEventType = PHYSICS_EVENT;
56
3b98a4d4 57 int status;
58
59 /* define data source : this is argument 1 */
36a7d3c6 60 status=monitorSetDataSource( (char* )filename );
3b98a4d4 61 if (status!=0) {
62 AliFatal(Form("monitorSetDataSource() failed : %s",monitorDecodeError(status)));
63 }
64
65 /* declare monitoring program */
66 status=monitorDeclareMp( __FILE__ );
67 if (status!=0) {
68 AliFatal(Form("monitorDeclareMp() failed : %s",monitorDecodeError(status)));
69 }
70
71 /* define wait event timeout - 1s max */
72 monitorSetNowait();
73 monitorSetNoWaitNetworkTimeout(1000);
74
75#else
76 Fatal("AliRawReaderDateOnline", "this class was compiled without DATE");
77#endif
78}
79
36a7d3c6 80Bool_t AliRawReaderDateOnline::NextEvent()
3b98a4d4 81{
82// wait and get the next event
83// from shared memory
84
85#ifdef ALI_DATE
86
36a7d3c6 87 // Event already loaded no need take a new one
88 if (AliRawReaderDate::NextEvent()) return kTRUE;
89
3b98a4d4 90 if (fEvent) free(fEvent);
36a7d3c6 91 fEvent = NULL;
3b98a4d4 92
93 while (1) {
94 /* get next event (blocking call until timeout) */
36a7d3c6 95 int status=monitorGetEventDynamic((void**)&fEvent);
3b98a4d4 96
00665a00 97 if (status==MON_ERR_EOF) {
3b98a4d4 98 AliInfo("End of File detected");
36a7d3c6 99 Reset();
100 fEvent = NULL;
3b98a4d4 101 return kFALSE; /* end of monitoring file has been reached */
102 }
103
104 if (status!=0) {
105 AliError(Form("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status)));
36a7d3c6 106 Reset();
107 fEvent = NULL;
3b98a4d4 108 return kFALSE;
109 }
110
111 /* retry if got no event */
36a7d3c6 112 if (fEvent==NULL) {
3b98a4d4 113 continue;
114 }
36a7d3c6 115
116 eventTypeType eventT=fEvent->eventType;
3b98a4d4 117 /* exit when last event received, no need to wait for TERM signal */
118 if (eventT==END_OF_RUN) {
119 AliInfo("EOR event detected");
36a7d3c6 120 Reset();
121 fEvent = NULL;
3b98a4d4 122 return kFALSE;
123 }
36a7d3c6 124
00665a00 125 if (!IsEventSelected()) {
3b98a4d4 126 continue;
127 }
128
00665a00 129 AliInfo(Form("Run #%lu, event size: %lu, BC:0x%x, Orbit:0x%x, Period:0x%x",
36a7d3c6 130 (unsigned long)fEvent->eventRunNb,
131 (unsigned long)fEvent->eventSize,
132 EVENT_ID_GET_BUNCH_CROSSING(fEvent->eventId),
133 EVENT_ID_GET_ORBIT(fEvent->eventId),
134 EVENT_ID_GET_PERIOD(fEvent->eventId)
3b98a4d4 135 ));
36a7d3c6 136 break;
3b98a4d4 137 }
138
36a7d3c6 139 fEventNumber++;
140 Reset();
3b98a4d4 141
36a7d3c6 142 return kTRUE;
3b98a4d4 143
36a7d3c6 144}
145
146#else
3b98a4d4 147 return kFALSE;
148}
36a7d3c6 149#endif
3b98a4d4 150
36a7d3c6 151AliRawReaderDateOnline::~AliRawReaderDateOnline()
152{
153// Destructor
154// Free the last event in shared memory
3b98a4d4 155
36a7d3c6 156#ifdef ALI_DATE
157 if (fEvent) free(fEvent);
158#endif
159}