3 ACORDE DA for online calibration
5 Contact: Pedro.Gonzalez.Zamora@cern.ch
10 Number of events needed: depending on the run, being run-level
11 Input Files: ACORDEDa.root
12 Output Files: ACORDEHistos.root to be exported to the DAQ FXS
13 Trigger types used: PHYSICS_EVENT
17 #define FILE_TOTAL "ACORDEHistos.root"
24 #include "AliACORDERawStream.h"
25 #include "AliRawReaderDate.h"
29 #include "TPluginManager.h"
41 Arguments: list of DATE raw data files
43 int main(int argc, char **argv) {
45 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
53 // AliACORDERawStream reader;
63 TH1D *fH1=new TH1D("fHist1", "Single MUON Hits", kModules+1, 0, kModules);
64 TH1D *fH2=new TH1D("fHist2", "Total MUON Hits ", 10, 0, 9);
65 TH1D *fH3=new TH1D("fHist3", "Hit Multiplicity (Mult words)", kModules+1, 0, kModules);
66 TH1D *fH4=new TH1D("fHist4", "Total Hit Multiplicity (Mult words)", 10, 0, 9);
73 /* log start of process */
74 printf("ACORDE DA program started\n");
77 /* check that we got some arguments = list of files */
80 printf("Wrong number of arguments\n");
87 fp=fopen("./da.log","a");
89 printf("Failed to open file\n");
96 daqDA_progressReport(10);
99 /* init some counters */
100 int nevents_physics=0;
104 /* read the data files */
106 for (n=1;n<argc;n++) {
108 status=monitorSetDataSource( argv[n] );
110 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
114 /* report progress */
115 daqDA_progressReport(10+80*n/argc);
119 struct eventHeaderStruct *event;
120 eventTypeType eventT;
123 status=monitorGetEventDynamic((void **)&event);
125 if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */
129 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
133 /* retry if got no event */
139 /* use event - here, just write event id to result file */
140 eventT=event->eventType;
142 switch (event->eventType)
151 fprintf(fp,"Run #%lu, event size: %lu, BC:%u, Orbit:%u, Period:%u\n",
152 (unsigned long)event->eventRunNb,
153 (unsigned long)event->eventSize,
154 EVENT_ID_GET_BUNCH_CROSSING(event->eventId),
155 EVENT_ID_GET_ORBIT(event->eventId),
156 EVENT_ID_GET_PERIOD(event->eventId));
158 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
160 AliACORDERawStream* rawStream = new AliACORDERawStream(rawReader);
166 word = rawStream->GetWord(0);
167 for(int i=0;i<30;i++){
172 word = rawStream->GetWord(1);
173 for(int i=30;i<60;i++){
178 word = rawStream->GetWord(2);
179 for(int i=0;i<30;i++){
180 fMultMap[i]=word & 1;
184 word = rawStream->GetWord(3);
185 for(int i=30;i<60;i++){
186 fMultMap[i]=word & 1;
190 for(int i=0; i<kModules; ++i){
200 fH2->Fill(eventHits);
231 TFile *histoFile = new TFile(FILE_TOTAL,"recreate");
239 fprintf(fp,"Run #%s, received %d physics events out of %d\n",getenv("DATE_RUN_NUMBER"),nevents_physics,nevents_total);
242 /* close result file */
246 /* report progress */
247 daqDA_progressReport(90);
250 /* store the result file on FES */
251 status=daqDA_FES_storeFile(FILE_TOTAL,"CALIB");
253 printf("Failed to export file : %d\n",status);
258 /* report progress */
259 daqDA_progressReport(100);