]>
Commit | Line | Data |
---|---|---|
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" | |
32 | #include "AliLog.h" | |
33 | #ifdef ALI_DATE | |
34 | #include "event.h" | |
35 | #include "monitor.h" | |
36 | #endif | |
37 | ||
38 | ClassImp(AliRawReaderDateOnline) | |
39 | ||
40 | AliRawReaderDateOnline::AliRawReaderDateOnline( | |
41 | #ifdef ALI_DATE | |
42 | const char* filename | |
43 | #else | |
44 | const char* /* filename */ | |
45 | #endif | |
46 | ) : | |
47 | AliRawReaderDate((void*)NULL) | |
48 | { | |
49 | ||
50 | // Constructor | |
51 | // Initialize the DATE monitoring libs | |
52 | ||
53 | #ifdef ALI_DATE | |
54 | ||
55 | ||
56 | // Removal of the selection of physics events | |
57 | // Requested by Filimon and FMD experts | |
58 | // fSelectEventType = PHYSICS_EVENT; | |
59 | ||
60 | int status; | |
61 | ||
62 | /* define data source : this is argument 1 */ | |
63 | status=monitorSetDataSource( (char* )filename ); | |
64 | if (status!=0) { | |
65 | AliFatal(Form("monitorSetDataSource() failed : %s",monitorDecodeError(status))); | |
66 | } | |
67 | ||
68 | /* declare monitoring program */ | |
69 | status=monitorDeclareMp( __FILE__ ); | |
70 | if (status!=0) { | |
71 | AliFatal(Form("monitorDeclareMp() failed : %s",monitorDecodeError(status))); | |
72 | } | |
73 | ||
74 | /* define wait event timeout - 1s max */ | |
75 | monitorSetNowait(); | |
76 | monitorSetNoWaitNetworkTimeout(1000); | |
77 | ||
78 | #else | |
79 | Fatal("AliRawReaderDateOnline", "this class was compiled without DATE"); | |
80 | #endif | |
81 | } | |
82 | ||
83 | Bool_t AliRawReaderDateOnline::NextEvent() | |
84 | { | |
85 | // wait and get the next event | |
86 | // from shared memory | |
87 | ||
88 | #ifdef ALI_DATE | |
89 | ||
90 | // Event already loaded no need take a new one | |
91 | if (AliRawReaderDate::NextEvent()) return kTRUE; | |
92 | ||
93 | if (fEvent) free(fEvent); | |
94 | fEvent = NULL; | |
95 | ||
96 | while (1) { | |
97 | /* get next event (blocking call until timeout) */ | |
98 | int status=monitorGetEventDynamic((void**)&fEvent); | |
99 | ||
100 | if (status==MON_ERR_EOF) { | |
101 | AliInfo("End of File detected"); | |
102 | Reset(); | |
103 | fEvent = NULL; | |
104 | return kFALSE; /* end of monitoring file has been reached */ | |
105 | } | |
106 | ||
107 | if (status!=0) { | |
108 | AliError(Form("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status))); | |
109 | Reset(); | |
110 | fEvent = NULL; | |
111 | return kFALSE; | |
112 | } | |
113 | ||
114 | /* retry if got no event */ | |
115 | if (fEvent==NULL) { | |
116 | continue; | |
117 | } | |
118 | ||
119 | eventTypeType eventT=fEvent->eventType; | |
120 | /* exit when last event received, no need to wait for TERM signal */ | |
121 | if (eventT==END_OF_RUN) { | |
122 | AliInfo("EOR event detected"); | |
123 | Reset(); | |
124 | free(fEvent); | |
125 | fEvent = NULL; | |
126 | return kFALSE; | |
127 | } | |
128 | ||
129 | if (!IsEventSelected()) { | |
130 | free(fEvent); | |
131 | continue; | |
132 | } | |
133 | ||
134 | AliInfo(Form("Run #%lu, event size: %lu, BC:0x%x, Orbit:0x%x, Period:0x%x", | |
135 | (unsigned long)fEvent->eventRunNb, | |
136 | (unsigned long)fEvent->eventSize, | |
137 | EVENT_ID_GET_BUNCH_CROSSING(fEvent->eventId), | |
138 | EVENT_ID_GET_ORBIT(fEvent->eventId), | |
139 | EVENT_ID_GET_PERIOD(fEvent->eventId) | |
140 | )); | |
141 | break; | |
142 | } | |
143 | ||
144 | fEventNumber++; | |
145 | Reset(); | |
146 | ||
147 | return kTRUE; | |
148 | ||
149 | } | |
150 | ||
151 | #else | |
152 | return kFALSE; | |
153 | } | |
154 | #endif | |
155 | ||
156 | AliRawReaderDateOnline::~AliRawReaderDateOnline() | |
157 | { | |
158 | // Destructor | |
159 | // Free the last event in shared memory | |
160 | ||
161 | #ifdef ALI_DATE | |
162 | if (fEvent) free(fEvent); | |
163 | #endif | |
164 | } | |
165 | ||
166 | void AliRawReaderDateOnline::SelectEvents(Int_t type, | |
167 | ULong64_t triggerMask, | |
168 | const char *triggerExpr) | |
169 | { | |
170 | // Select event by using DATE monitoring | |
171 | // library | |
172 | #ifdef ALI_DATE | |
173 | const Char_t* table[] = {"ALL", "no", "*", "*", | |
174 | "PHY", "all","*", "*", | |
175 | NULL, NULL, NULL, NULL}; | |
176 | TString trSelection; | |
177 | for (Int_t i = 0; i < 50; i++) { | |
178 | if (triggerMask & (1ull << i)) { | |
179 | if (!trSelection.IsNull()) trSelection += "&"; | |
180 | trSelection += Form("%d",i+1); | |
181 | } | |
182 | } | |
183 | table[7] = trSelection.Data(); | |
184 | ||
185 | monitorDeclareTableExtended(const_cast<char**>(table)); | |
186 | ||
187 | #endif | |
188 | AliRawReader::SelectEvents(type,triggerMask,triggerExpr); | |
189 | } |