2 PMD DA for online calibration
4 contact: basanta@phy.iitb.ac.in
6 Reference Run:/afs/cern.ch/user/s/sjena/public/run83496.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
22 #include <Riostream.h>
27 #include "AliRawReaderDate.h"
28 #include "AliPMDCalibPedestal.h"
30 #include "AliCDBManager.h"
35 #include "TBenchmark.h"
38 #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",
55 AliPMDCalibPedestal calibped;
59 // TH1F::AddDirectory(0);
62 // decoding the events
67 printf("Wrong number of arguments\n");
72 /* define data source : this is argument 1 */
73 status=monitorSetDataSource( argv[1] );
75 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
79 /* declare monitoring program */
80 status=monitorDeclareMp( __FILE__ );
82 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
86 /* define wait event timeout - 1s max */
88 monitorSetNoWaitNetworkTimeout(1000);
90 /* log start of process */
91 printf("PMD PED DA - started generating mean and rms of each channel\n");
93 /* init some counters */
96 struct eventHeaderStruct *event;
97 eventTypeType eventT = 0;
102 if (getenv("DATE_RUN_NUMBER")==0) {
103 printf("DATE_RUN_NUMBER not properly set.\n");
106 int runNr = atoi(getenv("DATE_RUN_NUMBER"));
111 if (gSystem->AccessPathName("localOCDB/PMD/Calib/Mapping",kFileExists))
113 if (gSystem->mkdir("localOCDB/PMD/Calib/Mapping",kTRUE) != 0)
115 printf("Failed to create directory: localOCDB/PMD/Calib/Mapping");
119 status = daqDA_DB_getFile("PMD/Calib/Mapping","localOCDB/PMD/Calib/Mapping/Run0_999999999_v0_s0.root");
122 printf("Failed to get PMD-Mapping file (PMD/Calib/Mapping) from DAQdetDB, status=%d\n", status);
126 // Global initializations
127 AliLog::SetGlobalLogLevel(AliLog::kError);
128 AliCDBManager *man = AliCDBManager::Instance();
129 man->SetDefaultStorage("local://localOCDB");
133 /* main loop (infinite) */
136 /* check shutdown condition */
137 if (daqDA_checkShutdown()) {break;}
139 /* get next event (blocking call until timeout) */
140 status=monitorGetEventDynamic((void **)&event);
141 if (status==MON_ERR_EOF) {
142 printf ("End of File detected\n");
143 break; /* end of monitoring file has been reached */
147 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
151 /* retry if got no event */
158 /* use event - here, just write event id to result file */
159 eventT=event->eventType;
160 switch (event->eventType){
165 /* END START OF RUN */
173 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
174 TObjArray *pmdddlcont = new TObjArray();
175 calibped.ProcessEvent(rawReader,pmdddlcont);
186 /* exit when last event received, no need to wait for TERM signal */
188 // either END_OF_RUN or 1000 events
192 printf("-- 1000 pedestal events processed : terminating --\n");
193 printf("-- eventT is set to END_OF_RUN --\n");
200 printf(" Total number of events processed = %i \n",iev);
202 ped = new TTree("ped","PMD Pedestal tree");
204 if (eventT==END_OF_RUN) {
205 printf("EOR event detected\n");
206 calibped.Analyse(ped);
209 TFile * pedRun = new TFile ("PMD_PED.root","RECREATE");
216 /* store the pedestal file in database */
218 status = daqDA_DB_storeFile("PMD_PED.root","PMD_PED.root");
222 printf("--- PEDESTAL root FILE IS IN THE DAQ DATABASE\n");
226 printf("--- Storing the root file into the database failed\n");
229 /* store the pedestal file on FES */
231 status = daqDA_FES_storeFile("PMD_PED.root","PMD_PED.root");