]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/PHOSPHYSda.cxx
Coding convention violations: suppression
[u/mrichter/AliRoot.git] / PHOS / PHOSPHYSda.cxx
CommitLineData
12f6dd57 1/*
2
3PHOSPHYSda.cxx
4
5This program reads the DAQ data files passed as argument using the monitoring library.
6It stores the required event information into an output file.
7Messages on stdout are exported to DAQ log system.
8
9contact: Hisayuki.Torii@cern.ch
10
11*/
12
13#include "event.h"
14#include "monitor.h"
15#include "daqDA.h"
16
17#include <stdio.h>
18#include <stdlib.h>
19
20#include "AliRawReader.h"
21#include "AliRawReaderDate.h"
22#include "AliPHOSRawDecoder.h"
23#include "AliCaloAltroMapping.h"
24#include "AliPHOSDApi0mip.h"
25
26/* Main routine
27 Arguments: list of DATE raw data files
28*/
29int main(int argc, char **argv) {
30
31 int status;
32
33 /* log start of process */
34 printf("PHOSPHYSda program started\n");
35
36 /* Time out counters*/
37 int timeout = 180; // 3mins
38 time_t start_time = time(0);
39
40 /* check that we got some arguments = list of files */
41 if (argc<2) {
42 printf("Wrong number of arguments\n");
43 return -1;
44 }
45
46
47 /* Retrieve mapping files from DAQ DB */
48 const char* mapFiles[4] = {"RCU0.data","RCU1.data","RCU2.data","RCU3.data"};
49 for(Int_t iFile=0; iFile<4; iFile++) {
50 int failed = daqDA_DB_getFile(mapFiles[iFile], mapFiles[iFile]);
51 if(failed) {
52 printf("Cannot retrieve file %s from DAQ DB. Exit.\n",mapFiles[iFile]);
53 return -1;
54 }
55 }
56
57 /* Open mapping files */
58 AliAltroMapping *mapping[4];
59 TString path = "./";
60 path += "RCU";
61 TString path2;
62 for(Int_t i = 0; i < 4; i++) {
63 path2 = path;
64 path2 += i;
65 path2 += ".data";
66 mapping[i] = new AliCaloAltroMapping(path2.Data());
67 }
68
69 /* report progress */
70 daqDA_progressReport(10);
71
72 /* init some counters */
73 int nevents_physics=0;
74 int nevents_total=0;
75
76 /* init PHOS reader*/
77 AliRawReader *rawReader = NULL;
78
79 /* Prepare DA algorithm */
80 int iMod = 0;
81 AliPHOSDApi0mip* dapi0mip = new AliPHOSDApi0mip(iMod);
82
83 /* read the data files */
84 for(int n=1;n<argc;n++) {
85 status=monitorSetDataSource( argv[n] );
86 if (status!=0) {
87 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
88 return -1;
89 }
90
91 /* report progress */
92 /* in this example, indexed on the number of files */
93 daqDA_progressReport(10+80*(n-1)/argc);
94
95 /* read the file */
96 for(;;) {
97 struct eventHeaderStruct *event;
98 eventTypeType eventT;
99
100 /* get next event */
101 status=monitorGetEventDynamic((void **)&event);
102 if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */
103 if (status!=0) {
104 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
105 return -1;
106 }
107
108 /* retry if got no event */
109 if (event==NULL) {
110 break;
111 }
112
113 /* Status report */
114 // This is just for debugging
115 //if( nevents_total%1000 == 0 ){
116 //daqDA_progressReport(10+80*(n-1)/argc+nevents_total/10000);
117 //printf(" DEBUGDEBUG:: next event %d\n",nevents_total);
118 //}
119
120 /* get time stamp */
121 time_t t;
122 t = event->eventTimestamp;
123 dapi0mip->SetTime(t);
124
125 /* Applying into DA algorithm */
126 int ix, iz, igain;
127 eventT=event->eventType;
128 if (eventT==PHYSICS_EVENT || eventT==CALIBRATION_EVENT) {
129 // ---------------------------------------------------------------
130 // User Defined Function
131 // ---------------------------------------------------------------
132 dapi0mip->NewEvent();
133 rawReader = new AliRawReaderDate((void*)event);
134 //AliPHOSRawDecoderv1 dc(rawReader,mapping);
135 AliPHOSRawDecoder dc(rawReader,mapping);
136 dc.SubtractPedestals(false);
137 while(dc.NextDigit()) {
138 //printf(".");
139 ix = dc.GetRow() - 1;
140 iz = dc.GetColumn() - 1;
141 if(dc.IsLowGain()) igain = 0; else igain = 1;
142 if( igain == 1 ){
143 dapi0mip->FillDigit(dc.GetEnergy(),ix,iz);
144 }
145 //dc.GetTime();
146 }
147 delete rawReader;
148 //dapi0mip->FillHist(); // This is not necesarry in this DA algorithm
149 dapi0mip->FillTree();
150 //if( nevents_total%1000 == 0 ){ // Dump for debugging
151 //dapi0mip->Print();
152 //}
153 // ---------------------------------------------------------------
154 nevents_physics++;
155 }
156 nevents_total++;
157
158 /* Check the time out */
159 if( nevents_total%1000 == 0 ){
160 time_t current_time = time(0);
161 if( current_time - start_time > timeout ){
162 free(event);
163 printf(" Warning: Exit due to the processing time exceed the limitation of %d sec\n",timeout);
164 n = argc;
165 break;
166 }
167 }
168
169 /* free resources */
170 free(event);
171 }
172
173 }
174
175 /* report progress */
176 daqDA_progressReport(90);
177
178 /* Delete DA algorithm for saving output into a file */
179 delete dapi0mip;
180
181 /* Store output files to the File Exchange Server */
182 char localfile[1024];
183 char remotefile[1024];
184 sprintf(localfile,"AliPHOSDApi0mip_mod%d.root",iMod);
185 sprintf(remotefile,"PHOSDApi0mip",iMod);
186 daqDA_FES_storeFile(localfile,remotefile);
187
188 /* report progress */
189 daqDA_progressReport(100);
190
191 return status;
192}
193