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
30 #include "AliRawReader.h"
31 #include "AliRawReaderDate.h"
32 #include "AliPHOSCalibHistoProducer.h"
33 #include "AliPHOSRawDecoder.h"
34 #include "AliCaloAltroMapping.h"
39 1- monitoring data source
41 int main(int argc, char **argv) {
46 printf("Wrong number of arguments\n");
51 /* open result file */
53 fp=fopen("./result.txt","a");
55 printf("Failed to open file\n");
59 /* Open mapping files */
60 AliAltroMapping *mapping[4];
61 TString path = gSystem->Getenv("ALICE_ROOT");
62 path += "/PHOS/mapping/RCU";
64 for(Int_t i = 0; i < 4; i++) {
68 mapping[i] = new AliCaloAltroMapping(path2.Data());
72 /* define data source : this is argument 1 */
73 status=monitorSetDataSource( argv[1] );
75 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
80 /* declare monitoring program */
81 status=monitorDeclareMp( __FILE__ );
83 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
88 /* define wait event timeout - 1s max */
90 monitorSetNoWaitNetworkTimeout(1000);
93 /* log start of process */
94 printf("DA example case2 monitoring program started\n");
97 /* init some counters */
98 int nevents_physics=0;
101 AliRawReader *rawReader = NULL;
103 AliPHOSCalibHistoProducer hp(200,0.,200.);
104 hp.SetOldRCUFormat(kTRUE);
105 hp.SetUpdatingRate(200000);
107 /* main loop (infinite) */
109 struct eventHeaderStruct *event;
110 eventTypeType eventT;
112 /* check shutdown condition */
113 if (daqDA_checkShutdown()) {break;}
115 /* get next event (blocking call until timeout) */
116 status=monitorGetEventDynamic((void **)&event);
117 if (status==MON_ERR_EOF) {
118 printf ("End of File detected\n");
119 break; /* end of monitoring file has been reached */
123 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
127 /* retry if got no event */
133 /* use event - here, just write event id to result file */
134 eventT=event->eventType;
136 if (eventT==PHYSICS_EVENT) {
137 fprintf(fp,"Run #%lu, event size: %lu, BC:%u, Orbit:%u, Period:%u\n",
138 (unsigned long)event->eventRunNb,
139 (unsigned long)event->eventSize,
140 EVENT_ID_GET_BUNCH_CROSSING(event->eventId),
141 EVENT_ID_GET_ORBIT(event->eventId),
142 EVENT_ID_GET_PERIOD(event->eventId)
145 rawReader = new AliRawReaderDate((void*)event);
146 AliPHOSRawDecoder dc(rawReader,mapping);
147 dc.SubtractPedestals(kTRUE);
148 hp.SetRawDecoder(&dc);
160 /* exit when last event received, no need to wait for TERM signal */
161 if (eventT==END_OF_RUN) {
162 printf("EOR event detected\n");
167 for(Int_t i = 0; i < 4; i++) delete mapping[i];
170 fprintf(fp,"Run #%s, received %d physics events out of %d\n",getenv("DATE_RUN_NUMBER"),nevents_physics,nevents_total);
172 /* close result file */