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"
35 #include "TTreePlayer.h"
38 int main(int argc, char **argv){
42 /* log start of process */
43 printf("HMPID DA program started\n");
45 /* check that we got some arguments = list of files */
47 printf("Wrong number of arguments\n");
51 /* copy locally a file from daq detector config db
52 status=daqDA_DB_getFile("myconfig","./myconfig.txt");
54 printf("Failed to get config file : %d\n",status);
57 and possibly use it */
60 daqDA_progressReport(10);
63 /* init the pedestal calculation */
64 AliHMPIDCalib *pCal=new AliHMPIDCalib();
65 //pCal->Init(); //Init the pedestal calculation
67 /* init event counter */
71 for (n=1;n<argc;n++) {
73 status=monitorSetDataSource( argv[n] );
75 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
80 /* in this example, indexed on the number of files */
81 daqDA_progressReport(10+80*n/argc);
83 for(;;) { // infinite loop
84 struct eventHeaderStruct *event;
88 status=monitorGetEventDynamic((void **)&event);
89 if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */
91 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
95 /* retry if got no event */
100 /* use event - here, just write event id to result file */
101 eventT=event->eventType;
103 if (eventT==PHYSICS_EVENT) { //we use PHYSICS_EVENT for pedestal not CALIBRATION_EVENT
107 AliRawReader *reader = new AliRawReaderDate((void*)event);
109 // Temporary there. Shall be removed as soon as the equipment ID is set correctly
110 // For the moment ddl.map file contains one line which maps
111 // the observed eqID=225 to the first HMPID DDL with ID=1536
112 // reader->LoadEquipmentIdsMap("ddl.map");
114 AliHMPIDRawStream stream(reader);
116 while(stream.Next()) {
117 Int_t ddl=stream.GetDDLNumber();
118 for(Int_t row = 1; row <=AliHMPIDRawStream::kNRows; row++){
119 for(Int_t dil = 1; dil <=AliHMPIDRawStream::kNDILOGICAdd; dil++){
120 for(Int_t pad = 0; pad < AliHMPIDRawStream::kNPadAdd; pad++){
121 pCal->FillPedestal(ddl,row,dil,pad,stream.GetCharge(ddl,row,dil,pad));
129 }// if CALIBRATION_EVENT
131 /* exit when last event received, no need to wait for TERM signal */
132 if (eventT==END_OF_RUN) {
133 printf("EOR event detected\n");
144 printf("Run #%s, received %d calibration events\n",getenv("DATE_RUN_NUMBER"),iEvtNcal);
147 printf("No calibration events have been read. Exiting\n");
151 /* report progress */
152 daqDA_progressReport(90);
154 for(Int_t ddl=0; ddl < 14; ddl++) {
156 /* Calculate pedestal for the given ddl, if there is no ddl go t next */
157 if(!pCal->CalcPedestal(ddl,Form("./HmpidPedDdl%02i.txt",ddl))) continue;
159 /* store the result file on FES */
160 status=daqDA_FES_storeFile(Form("./HmpidPedDdl%02i.txt",ddl),Form("HMPID_DA_Pedestals_ddl=%02i",ddl));
162 printf("Failed to export file : %d\n",status);
167 /* report progress */
168 daqDA_progressReport(100);