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
10 Input Files: PMD_PED.root, Configfile
11 Output Files: PMDGAINS.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 Int_t filestatus = -1, totevt = -1;
58 // Reads the pedestal file and keep the values in memory for subtraction
60 AliPMDCalibGain calibgain;
61 Int_t pstatus = calibgain.ExtractPedestal();
63 if(pstatus == -3) return -3;
69 fp1 = fopen("Configfile","r");
73 printf("**** Configfile doesn't exist, creating the file ****\n");
74 fp1 = fopen("Configfile","w");
78 fprintf(fp1,"%d %d %d\n",filestatus, totevt,maxevt);
82 fscanf(fp1,"%d %d %d\n",&filestatus, &totevt,&maxevt);
83 //printf("%d %d %d\n",filestatus, totevt, maxevt);
89 calibgain.ReadIntermediateFile();
92 // decoding the events
97 printf("Wrong number of arguments\n");
102 /* define data source : this is argument 1 */
103 status=monitorSetDataSource( argv[1] );
105 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
109 /* declare monitoring program */
110 status=monitorDeclareMp( __FILE__ );
112 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
116 /* define wait event timeout - 1s max */
118 monitorSetNoWaitNetworkTimeout(1000);
120 /* log start of process */
121 printf("PMD GAIN DA - strted generating the gain of a cell\n");
123 /* init some counters */
124 int nevents_physics=0;
127 struct eventHeaderStruct *event;
128 eventTypeType eventT = 0;
132 /* main loop (infinite) */
135 /* check shutdown condition */
136 if (daqDA_checkShutdown()) {break;}
138 /* get next event (blocking call until timeout) */
139 status=monitorGetEventDynamic((void **)&event);
140 if (status==MON_ERR_EOF) {
141 printf ("End of File detected\n");
142 break; /* end of monitoring file has been reached */
146 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
150 /* retry if got no event */
157 /* use event - here, just write event id to result file */
159 eventT=event->eventType;
160 switch (event->eventType){
165 /* END START OF RUN */
173 //if(nevents_physics%100 == 0)printf("Physis Events = %d\n",nevents_physics);
174 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
175 TObjArray *pmdddlcont = new TObjArray();
176 calibgain.ProcessEvent(rawReader, pmdddlcont);
190 /* exit when last event received, no need to wait for TERM signal */
192 ic = new TTree("ic","PMD Gain tree");
194 totevt += nevents_physics++;
196 fp1 = fopen("Configfile","w+");
200 printf("Required Number of Events not reached\n");
201 printf("Number of Events processed = %d\n",totevt);
202 printf("Writing the intermediate ASCII file\n");
203 calibgain.WriteIntermediateFile();
206 fprintf(fp1,"%d %d %d\n",filestatus,totevt,maxevt);
208 else if (totevt >= maxevt)
210 printf("Required Number of Events reached = %d\n",totevt);
211 calibgain.Analyse(ic);
213 TFile * gainRun = new TFile ("PMDGAINS.root","RECREATE");
219 fprintf(fp1,"%d %d %d\n",filestatus,totevt,maxevt);
227 /* store the result file on FES */
231 printf("root file is created and getting exported\n");
232 status = daqDA_FES_storeFile("PMDGAINS.root","gaincalib");