2 *********************************************************
4 this file provides the detector algorithm for HMPID. *
5 *********************************************************
14 #include <Riostream.h>
19 #include "AliHMPIDRawStream.h"
20 #include "AliHMPIDCalib.h"
21 #include "AliRawReaderDate.h"
22 #include "AliBitPacking.h"
31 #include "TBenchmark.h"
36 int main(int argc, char **argv){
40 /* log start of process */
41 printf("HMPID DA program started\n");
43 /* check that we got some arguments = list of files */
45 printf("Wrong number of arguments\n");
49 /* copy locally a file from daq detector config db
50 status=daqDA_DB_getFile("myconfig","./myconfig.txt");
52 printf("Failed to get config file : %d\n",status);
55 and possibly use it */
58 daqDA_progressReport(10);
61 /* init the pedestal calculation */
62 AliHMPIDCalib *pCal=new AliHMPIDCalib();
64 /* init event counter */
70 for (n=1;n<argc;n++) {
72 status=monitorSetDataSource( argv[n] );
74 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
79 /* in this example, indexed on the number of files */
80 daqDA_progressReport(10+80*n/argc);
82 for(;;) { // infinite loop
83 struct eventHeaderStruct *event;
87 status=monitorGetEventDynamic((void **)&event);
88 if (status==MON_ERR_EOF) /* end of monitoring file has been reached */
90 printf("End of monitoring file has been reached! \n");
96 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
100 /* retry if got no event */
106 /* use event - here, just write event id to result file */
107 eventT=event->eventType;
109 if (eventT==PHYSICS_EVENT) { //we use PHYSICS_EVENT for pedestal not CALIBRATION_EVENT
113 AliRawReader *reader = new AliRawReaderDate((void*)event);
115 // Temporary there. Shall be removed as soon as the equipment ID is set correctly
116 // For the moment ddl.map file contains one line which maps
117 // the observed eqID=225 to the first HMPID DDL with ID=1536
118 // reader->LoadEquipmentIdsMap("ddl.map");
120 AliHMPIDRawStream stream(reader);
122 while(stream.Next()) {
123 Int_t nDDL=stream.GetDDLNumber();
124 for(Int_t row = 1; row <=AliHMPIDRawStream::kNRows; row++){
125 for(Int_t dil = 1; dil <=AliHMPIDRawStream::kNDILOGICAdd; dil++){
126 for(Int_t pad = 0; pad < AliHMPIDRawStream::kNPadAdd; pad++){
127 pCal->FillPedestal(nDDL,row,dil,pad,stream.GetCharge(nDDL,row,dil,pad));
135 }// if CALIBRATION_EVENT
137 /* exit when last event received, no need to wait for TERM signal */
138 if (eventT==END_OF_RUN) {
139 printf("EOR event detected\n");
150 printf("Run #%s, received %d calibration events\n",getenv("DATE_RUN_NUMBER"),iEvtNcal);
153 printf("No calibration events have been read. Exiting\n");
157 /* report progress */
158 daqDA_progressReport(90);
160 for(Int_t nDDL=0; nDDL < AliHMPIDCalib::kNDDL; nDDL++) {
162 /* Calculate pedestal for the given ddl, if there is no ddl go t next */
163 if(!pCal->CalcPedestal(nDDL,Form("./HmpidPedDdl%02i.txt",nDDL),iEvtNcal)) continue;
165 /* store the result file on FES */
167 status=daqDA_FES_storeFile(Form("./HmpidPedDdl%02i.txt",nDDL),Form("HMPID_DA_Pedestals_ddl=%02i",nDDL));
169 printf("Failed to export file : %d\n",status);
175 /* report progress */
176 daqDA_progressReport(100);