2 PMD DA for online calibration
4 contact: basanta@phy.iitb.ac.in
6 Reference Run:/afs/cern.ch/user/b/bnandi/public/pedestaldata/run37820.raw
9 Number of events needed: 1000
11 Output Files: pmd_ped.root, to be exported to the DAQ FXS, pedestal230*.ped
12 Trigger types used: PHYSICS_EVENT
23 #include <Riostream.h>
28 #include "AliRawReaderDate.h"
29 #include "AliPMDCalibPedestal.h"
34 #include "TBenchmark.h"
37 #include "TPluginManager.h"
41 1- monitoring data source
43 int main(int argc, char **argv) {
45 /* magic line from Rene */
46 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
53 AliPMDCalibPedestal calibped;
57 // TH1F::AddDirectory(0);
60 // decoding the events
65 printf("Wrong number of arguments\n");
70 /* define data source : this is argument 1 */
71 status=monitorSetDataSource( argv[1] );
73 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
77 /* declare monitoring program */
78 status=monitorDeclareMp( __FILE__ );
80 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
84 /* define wait event timeout - 1s max */
86 monitorSetNoWaitNetworkTimeout(1000);
88 /* log start of process */
89 printf("PMD PED DA - started generating mean and rms of each channel\n");
91 /* init some counters */
94 struct eventHeaderStruct *event;
95 eventTypeType eventT = 0;
98 /* main loop (infinite) */
101 /* check shutdown condition */
102 if (daqDA_checkShutdown()) {break;}
104 /* get next event (blocking call until timeout) */
105 status=monitorGetEventDynamic((void **)&event);
106 if (status==MON_ERR_EOF) {
107 printf ("End of File detected\n");
108 break; /* end of monitoring file has been reached */
112 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
116 /* retry if got no event */
123 /* use event - here, just write event id to result file */
124 eventT=event->eventType;
125 switch (event->eventType){
130 /* END START OF RUN */
138 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
139 TObjArray *pmdddlcont = new TObjArray();
140 calibped.ProcessEvent(rawReader,pmdddlcont);
151 /* exit when last event received, no need to wait for TERM signal */
153 // either END_OF_RUN or 1000 events
157 printf("-- 1000 pedestal events processed : terminating --\n");
158 printf("-- eventT is set to END_OF_RUN --\n");
165 printf(" Total number of events processed = %i \n",iev);
167 ped = new TTree("ped","PMD Pedestal tree");
169 if (eventT==END_OF_RUN) {
170 printf("EOR event detected\n");
171 calibped.Analyse(ped);
174 TFile * pedRun = new TFile ("PMD_PED.root","RECREATE");
181 /* store the pedestal file in database */
183 status = daqDA_DB_storeFile("PMD_PED.root","PMD_PED.root");
187 printf("--- PEDESTAL root FILE IS IN THE DAQ DATABASE\n");
191 printf("--- Storing the root file into the database failed\n");
194 /* store the pedestal file on FES */
196 status = daqDA_FES_storeFile("PMD_PED.root","PMD_PED.root");