5 This program connects to the DAQ data source passed as argument
6 and populates local "./result.txt" file with the ids of events received
9 The program exits when being asked to shut down (daqDA_checkshutdown)
12 Messages on stdout are exported to DAQ log system.
14 contact: alice-datesupport@cern.ch
28 #include "AliRawReader.h"
29 #include "AliRawReaderDate.h"
30 #include "AliPHOSCalibHistoProducer.h"
35 1- monitoring data source
37 int main(int argc, char **argv) {
42 printf("Wrong number of arguments\n");
47 /* open result file */
49 fp=fopen("./result.txt","a");
51 printf("Failed to open file\n");
56 /* define data source : this is argument 1 */
57 status=monitorSetDataSource( argv[1] );
59 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
64 /* declare monitoring program */
65 status=monitorDeclareMp( __FILE__ );
67 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
72 /* define wait event timeout - 1s max */
74 monitorSetNoWaitNetworkTimeout(1000);
77 /* log start of process */
78 printf("DA example case2 monitoring program started\n");
81 /* init some counters */
82 int nevents_physics=0;
85 AliPHOSCalibHistoProducer hp;
86 hp.SetOldRCUFormat(kTRUE);
87 hp.SetUpdatingRate(500);
89 /* main loop (infinite) */
91 struct eventHeaderStruct *event;
94 /* check shutdown condition */
95 if (daqDA_checkShutdown()) {break;}
97 /* get next event (blocking call until timeout) */
98 status=monitorGetEventDynamic((void **)&event);
99 if (status==MON_ERR_EOF) {
100 printf ("End of File detected\n");
101 break; /* end of monitoring file has been reached */
105 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
109 /* retry if got no event */
115 /* use event - here, just write event id to result file */
116 eventT=event->eventType;
118 if (eventT==PHYSICS_EVENT) {
119 fprintf(fp,"Run #%lu, event size: %lu, BC:%u, Orbit:%u, Period:%u\n",
120 (unsigned long)event->eventRunNb,
121 (unsigned long)event->eventSize,
122 EVENT_ID_GET_BUNCH_CROSSING(event->eventId),
123 EVENT_ID_GET_ORBIT(event->eventId),
124 EVENT_ID_GET_PERIOD(event->eventId)
127 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
129 hp.SetRawReader(rawReader);
140 /* exit when last event received, no need to wait for TERM signal */
141 if (eventT==END_OF_RUN) {
142 printf("EOR event detected\n");
149 fprintf(fp,"Run #%s, received %d physics events out of %d\n",getenv("DATE_RUN_NUMBER"),nevents_physics,nevents_total);
151 /* close result file */