2 PMD DA for online calibration
4 contact: basanta@phy.iitb.ac.in
5 Link:/afs/cern.ch/user/b/bnandi/public/
8 Number of events needed: 1 million for PB+PB, 200 milion for p+p
10 Output Files: pmd_calib.root, to be exported to the DAQ FXS
11 Trigger types used: PHYSICS_EVENT
22 #include <Riostream.h>
27 #include "AliRawReaderDate.h"
28 #include "AliPMDCalibPedestal.h"
29 #include "AliPMDCalibGain.h"
34 #include "TBenchmark.h"
37 #include "TPluginManager.h"
43 1- monitoring data source
45 int main(int argc, char **argv) {
47 /* magic line from Rene */
48 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
54 AliPMDCalibGain calibgain;
56 TTree *gain = new TTree("gain","PMD Gain tree");
58 TH1F::AddDirectory(0);
61 // decoding the events
66 printf("Wrong number of arguments\n");
70 /* open result file */
72 fp=fopen("./result.txt","a");
74 printf("Failed to open file\n");
78 /* define data source : this is argument 1 */
79 status=monitorSetDataSource( argv[1] );
81 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
85 /* declare monitoring program */
86 status=monitorDeclareMp( __FILE__ );
88 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
92 /* define wait event timeout - 1s max */
94 monitorSetNoWaitNetworkTimeout(1000);
96 /* log start of process */
97 printf("DA example case2 monitoring program started\n");
99 /* init some counters */
100 int nevents_physics=0;
103 struct eventHeaderStruct *event;
104 eventTypeType eventT;
107 /* main loop (infinite) */
110 /* check shutdown condition */
111 if (daqDA_checkShutdown()) {break;}
113 /* get next event (blocking call until timeout) */
114 status=monitorGetEventDynamic((void **)&event);
115 if (status==MON_ERR_EOF) {
116 printf ("End of File detected\n");
117 break; /* end of monitoring file has been reached */
121 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
125 /* retry if got no event */
132 /* use event - here, just write event id to result file */
134 eventT=event->eventType;
135 switch (event->eventType){
140 /* END START OF RUN */
148 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
149 calibgain.ProcessEvent(rawReader);
159 /* exit when last event received, no need to wait for TERM signal */
160 if (eventT==END_OF_RUN) {
161 printf("EOR event detected\n");
162 calibgain.Analyse(gain);
168 //write the Run level file
169 TFile * fileRun = new TFile ("outPMDdaRun.root","RECREATE");
170 TBenchmark *bench = new TBenchmark();
177 fprintf(fp,"Run #%s, received %d physics events out of %d\n",getenv("DATE_RUN_NUMBER"),nevents_physics,nevents_total);
180 TFile * gainRun = new TFile ("pmd_calib.root","RECREATE");
186 /* close result file */