2 PMD DA for online calibration
4 contact: basanta@iitb.ac.in, Satyajit.Jena@cern.ch
5 Link: https://twiki.cern.ch/twiki/bin/view/ALICE/DA
6 Reference Run:/afs/cern.ch/user/s/sjena/public/run83496.raw
9 Number of events needed: 1000
10 Input Files: PMD/Calib/Mapping/Run0_999999999_v0_s0.root
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 = new AliPMDCalibPedestal();
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;
103 if (getenv("DATE_RUN_NUMBER")==0) {
104 printf("DATE_RUN_NUMBER not properly set.\n");
106 printf("Run Number is set to Zero \n");
110 runNr = atoi(getenv("DATE_RUN_NUMBER"));
113 if (gSystem->AccessPathName("localOCDB/PMD/Calib/Mapping",kFileExists))
115 if (gSystem->mkdir("localOCDB/PMD/Calib/Mapping",kTRUE) != 0)
117 printf("Failed to create directory: localOCDB/PMD/Calib/Mapping");
121 status = daqDA_DB_getFile("PMD/Calib/Mapping/Run0_999999999_v0_s0.root","localOCDB/PMD/Calib/Mapping/Run0_999999999_v0_s0.root");
124 printf("Failed to get PMD-Mapping file (PMD/Calib/Mapping/Run0_999999999_v0_s0.root) from DAQdetDB, status=%d\n", status);
128 // Global initializations
129 AliLog::SetGlobalLogLevel(AliLog::kError);
130 AliCDBManager *man = AliCDBManager::Instance();
131 man->SetDefaultStorage("local://localOCDB");
135 /* main loop (infinite) */
138 /* check shutdown condition */
139 if (daqDA_checkShutdown()) {break;}
141 /* get next event (blocking call until timeout) */
142 status=monitorGetEventDynamic((void **)&event);
143 if (status==MON_ERR_EOF) {
144 printf ("End of File detected\n");
145 break; /* end of monitoring file has been reached */
149 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
153 /* retry if got no event */
160 /* use event - here, just write event id to result file */
161 eventT=event->eventType;
162 switch (event->eventType){
167 /* END START OF RUN */
175 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
176 TObjArray *pmdddlcont = new TObjArray();
177 calibped->ProcessEvent(rawReader,pmdddlcont);
188 /* exit when last event received, no need to wait for TERM signal */
190 // either END_OF_RUN or 1000 events
194 printf("-- 1000 pedestal events processed : terminating --\n");
195 printf("-- eventT is set to END_OF_RUN --\n");
202 printf(" Total number of events processed = %i \n",iev);
204 ped = new TTree("ped","PMD Pedestal tree");
206 if (eventT==END_OF_RUN) {
207 printf("EOR event detected\n");
208 calibped->Analyse(ped);
211 TFile * pedRun = new TFile ("PMD_PED.root","RECREATE");
220 /* store the pedestal file in database */
222 status = daqDA_DB_storeFile("PMD_PED.root","PMD_PED.root");
226 printf("--- PEDESTAL root FILE IS IN THE DAQ DATABASE\n");
230 printf("--- Storing the root file into the database failed\n");
233 /* store the pedestal file on FES */
235 status = daqDA_FES_storeFile("PMD_PED.root","PMD_PED.root");