2 PMD DA for online calibration
4 contact: basanta@phy.iitb.ac.in
5 Link:http://www.veccal.ernet.in/~pmd/
9 Number of events needed: 1 million for PB+PB, 200 milion for p+p
11 Output Files: pmd_calib.root, to be exported to the DAQ FXS
12 Trigger types used: PHYSICS_EVENT
23 #include <Riostream.h>
28 #include "AliRawReaderDate.h"
29 #include "AliPMDCalibPedestal.h"
30 #include "AliPMDCalibGain.h"
35 #include "TBenchmark.h"
38 #include "TPluginManager.h"
44 1- monitoring data source
46 int main(int argc, char **argv) {
48 /* magic line from Rene */
49 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
55 AliPMDCalibGain calibgain;
59 //TH1F::AddDirectory(0);
62 // decoding the events
67 printf("Wrong number of arguments\n");
71 /* open result file */
73 fp=fopen("./result.txt","a");
75 printf("Failed to open file\n");
79 /* define data source : this is argument 1 */
80 status=monitorSetDataSource( argv[1] );
82 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
86 /* declare monitoring program */
87 status=monitorDeclareMp( __FILE__ );
89 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
93 /* define wait event timeout - 1s max */
95 monitorSetNoWaitNetworkTimeout(1000);
97 /* log start of process */
98 printf("DA example case2 monitoring program started\n");
100 /* init some counters */
101 int nevents_physics=0;
104 struct eventHeaderStruct *event;
105 eventTypeType eventT = 0;
109 /* main loop (infinite) */
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 */
134 /* use event - here, just write event id to result file */
136 eventT=event->eventType;
137 switch (event->eventType){
142 /* END START OF RUN */
150 if(nevents_physics%100 == 0)printf("Physis Events = %d\n",nevents_physics);
151 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
152 TObjArray *pmdddlcont = new TObjArray();
153 calibgain.ProcessEvent(rawReader, pmdddlcont);
167 /* exit when last event received, no need to wait for TERM signal */
168 if (eventT==END_OF_RUN) {
169 printf("EOR event detected\n");
171 ic = new TTree("ic","PMD Gain tree");
172 calibgain.Analyse(ic);
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 * gainRun = new TFile ("PMDGAINS.root","RECREATE");
196 /* close result file */