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 PMD DA for online calibration
16 contact: basanta@phy.iitb.ac.in
17 Run Type: PHYSICS for calibration
18 : PEDESTAL_RUN for Pedestal
20 Number of events needed: 1 million for PB+PB, 200 milion for p+p
21 Input Files: outPMDdaRun.root, to be updated if existing
22 Output Files: pmd_calib.root, pmd_ped.root, both to be exported to the DAQ FXS
23 Trigger types used: PHYSICS_EVENT
34 #include <Riostream.h>
39 #include "AliRawReaderDate.h"
40 #include "AliPMDCalibPedestal.h"
41 #include "AliPMDCalibGain.h"
46 #include "TBenchmark.h"
49 #include "TPluginManager.h"
55 1- monitoring data source
57 int main(int argc, char **argv) {
59 /* magic line from Rene */
60 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
67 AliPMDCalibPedestal calibped;
68 AliPMDCalibGain calibgain;
70 TTree *ped = new TTree("ped","PMD Pedestal tree");
71 TTree *gain = new TTree("gain","PMD Gain tree");
73 TH1F::AddDirectory(0);
76 // decoding the events
81 printf("Wrong number of arguments\n");
85 /* open result file */
87 fp=fopen("./result.txt","a");
89 printf("Failed to open file\n");
93 /* define data source : this is argument 1 */
94 status=monitorSetDataSource( argv[1] );
96 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
100 /* declare monitoring program */
101 status=monitorDeclareMp( __FILE__ );
103 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
107 /* define wait event timeout - 1s max */
109 monitorSetNoWaitNetworkTimeout(1000);
111 /* log start of process */
112 printf("DA example case2 monitoring program started\n");
114 /* init some counters */
115 int nevents_physics=0;
118 struct eventHeaderStruct *event;
119 eventTypeType eventT;
122 /* main loop (infinite) */
125 /* check shutdown condition */
126 if (daqDA_checkShutdown()) {break;}
128 /* get next event (blocking call until timeout) */
129 status=monitorGetEventDynamic((void **)&event);
130 if (status==MON_ERR_EOF) {
131 printf ("End of File detected\n");
132 break; /* end of monitoring file has been reached */
136 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
140 /* retry if got no event */
147 /* use event - here, just write event id to result file */
148 eventT=event->eventType;
149 switch (event->eventType){
154 /* END START OF RUN */
161 printf(" event number = %i \n",iev);
162 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
163 calibped.ProcessEvent(rawReader);
165 calibgain.ProcessEvent(rawReader);
175 /* exit when last event received, no need to wait for TERM signal */
176 if (eventT==END_OF_RUN) {
177 printf("EOR event detected\n");
178 calibped.Analyse(ped);
179 calibgain.Analyse(gain);
185 //write the Run level file
186 TFile * fileRun = new TFile ("outPMDdaRun.root","RECREATE");
187 TBenchmark *bench = new TBenchmark();
194 fprintf(fp,"Run #%s, received %d physics events out of %d\n",getenv("DATE_RUN_NUMBER"),nevents_physics,nevents_total);
197 TFile * pedRun = new TFile ("pmd_ped.root","RECREATE");
201 TFile * gainRun = new TFile ("pmd_calib.root","RECREATE");
207 /* close result file */