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
26 #include "AliRawReader.h"
27 #include "AliRawReaderDate.h"
28 #include "AliPHOSCalibHistoProducer.h"
33 1- monitoring data source
35 int main(int argc, char **argv) {
40 printf("Wrong number of arguments\n");
45 /* open result file */
47 fp=fopen("./result.txt","a");
49 printf("Failed to open file\n");
54 /* define data source : this is argument 1 */
55 status=monitorSetDataSource( argv[1] );
57 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
62 /* declare monitoring program */
63 status=monitorDeclareMp( __FILE__ );
65 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
70 /* define wait event timeout - 1s max */
72 monitorSetNoWaitNetworkTimeout(1000);
75 /* log start of process */
76 printf("DA example case2 monitoring program started\n");
79 /* init some counters */
80 int nevents_physics=0;
83 AliPHOSCalibHistoProducer hp;
84 hp.SetOldRCUFormat(kTRUE);
85 hp.SetUpdatingRate(500);
87 /* main loop (infinite) */
89 struct eventHeaderStruct *event;
92 /* check shutdown condition */
93 if (daqDA_checkShutdown()) {break;}
95 /* get next event (blocking call until timeout) */
96 status=monitorGetEventDynamic((void **)&event);
97 if (status==MON_ERR_EOF) {
98 printf ("End of File detected\n");
99 break; /* end of monitoring file has been reached */
103 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
107 /* retry if got no event */
113 /* use event - here, just write event id to result file */
114 eventT=event->eventType;
116 if (eventT==PHYSICS_EVENT) {
117 fprintf(fp,"Run #%lu, event size: %lu, BC:%u, Orbit:%u, Period:%u\n",
118 (unsigned long)event->eventRunNb,
119 (unsigned long)event->eventSize,
120 EVENT_ID_GET_BUNCH_CROSSING(event->eventId),
121 EVENT_ID_GET_ORBIT(event->eventId),
122 EVENT_ID_GET_PERIOD(event->eventId)
125 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
127 hp.SetRawReader(rawReader);
138 /* exit when last event received, no need to wait for TERM signal */
139 if (eventT==END_OF_RUN) {
140 printf("EOR event detected\n");
147 fprintf(fp,"Run #%s, received %d physics events out of %d\n",getenv("DATE_RUN_NUMBER"),nevents_physics,nevents_total);
149 /* close result file */