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"
40 #include "TPluginManager.h"
46 1- monitoring data source
48 int main(int argc, char **argv) {
50 /* magic line from Rene */
51 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
58 AliPMDCalibPedestal calibped;
59 AliPMDCalibGain calibgain;
61 TTree *ped = new TTree("ped","PMD Pedestal tree");
62 TTree *gain = new TTree("gain","PMD Gain tree");
64 TH1F::AddDirectory(0);
67 // decoding the events
72 printf("Wrong number of arguments\n");
76 /* open result file */
78 fp=fopen("./result.txt","a");
80 printf("Failed to open file\n");
84 /* define data source : this is argument 1 */
85 status=monitorSetDataSource( argv[1] );
87 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
91 /* declare monitoring program */
92 status=monitorDeclareMp( __FILE__ );
94 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
98 /* define wait event timeout - 1s max */
100 monitorSetNoWaitNetworkTimeout(1000);
102 /* log start of process */
103 printf("DA example case2 monitoring program started\n");
105 /* init some counters */
106 int nevents_physics=0;
109 struct eventHeaderStruct *event;
110 eventTypeType eventT;
113 /* main loop (infinite) */
116 /* check shutdown condition */
117 if (daqDA_checkShutdown()) {break;}
119 /* get next event (blocking call until timeout) */
120 status=monitorGetEventDynamic((void **)&event);
121 if (status==MON_ERR_EOF) {
122 printf ("End of File detected\n");
123 break; /* end of monitoring file has been reached */
127 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
131 /* retry if got no event */
138 /* use event - here, just write event id to result file */
139 eventT=event->eventType;
140 switch (event->eventType){
145 /* END START OF RUN */
152 printf(" event number = %i \n",iev);
153 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
154 calibped.ProcessEvent(rawReader);
156 calibgain.ProcessEvent(rawReader);
166 /* exit when last event received, no need to wait for TERM signal */
167 if (eventT==END_OF_RUN) {
168 printf("EOR event detected\n");
169 calibped.Analyse(ped);
170 calibgain.Analyse(gain);
176 //write the Run level file
177 TFile * fileRun = new TFile ("outPMDdaRun.root","RECREATE");
178 TBenchmark *bench = new TBenchmark();
185 fprintf(fp,"Run #%s, received %d physics events out of %d\n",getenv("DATE_RUN_NUMBER"),nevents_physics,nevents_total);
188 TFile * pedRun = new TFile ("pmd_ped.root","RECREATE");
192 TFile * gainRun = new TFile ("pmd_calib.root","RECREATE");
198 /* close result file */