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
25 #include <Riostream.h>
30 #include "AliRawReaderDate.h"
31 #include "AliPMDCalibPedestal.h"
32 #include "AliPMDCalibGain.h"
37 #include "TBenchmark.h"
42 1- monitoring data source
44 int main(int argc, char **argv) {
46 AliPMDCalibPedestal calibped;
47 AliPMDCalibGain calibgain;
49 TTree *ped = new TTree("ped","PMD Pedestal tree");
50 TTree *gain = new TTree("gain","PMD Gain tree");
52 TH1F::AddDirectory(0);
55 // decoding the events
60 printf("Wrong number of arguments\n");
64 /* open result file */
66 fp=fopen("./result.txt","a");
68 printf("Failed to open file\n");
72 /* define data source : this is argument 1 */
73 status=monitorSetDataSource( argv[1] );
75 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
79 /* declare monitoring program */
80 status=monitorDeclareMp( __FILE__ );
82 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
86 /* define wait event timeout - 1s max */
88 monitorSetNoWaitNetworkTimeout(1000);
90 /* log start of process */
91 printf("DA example case2 monitoring program started\n");
93 /* init some counters */
94 int nevents_physics=0;
97 struct eventHeaderStruct *event;
101 /* main loop (infinite) */
104 /* check shutdown condition */
105 if (daqDA_checkShutdown()) {break;}
107 /* get next event (blocking call until timeout) */
108 status=monitorGetEventDynamic((void **)&event);
109 if (status==MON_ERR_EOF) {
110 printf ("End of File detected\n");
111 break; /* end of monitoring file has been reached */
115 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
119 /* retry if got no event */
126 /* use event - here, just write event id to result file */
127 eventT=event->eventType;
128 switch (event->eventType){
133 /* END START OF RUN */
140 printf(" event number = %i \n",iev);
141 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
142 calibped.ProcessEvent(rawReader);
144 calibgain.ProcessEvent(rawReader);
154 /* exit when last event received, no need to wait for TERM signal */
155 if (eventT==END_OF_RUN) {
156 printf("EOR event detected\n");
157 calibped.Analyse(ped);
158 calibgain.Analyse(gain);
164 //write the Run level file
165 TFile * fileRun = new TFile ("outPMDdaRun.root","RECREATE");
166 TBenchmark *bench = new TBenchmark();
173 fprintf(fp,"Run #%s, received %d physics events out of %d\n",getenv("DATE_RUN_NUMBER"),nevents_physics,nevents_total);
176 TFile * pedRun = new TFile ("pmd_ped.root","RECREATE");
180 TFile * gainRun = new TFile ("pmd_calib.root","RECREATE");
186 /* close result file */