]>
Commit | Line | Data |
---|---|---|
5e89474d | 1 | /* |
2 | ||
3 | DAcase1.c | |
4 | ||
5 | This program reads the DAQ data files passed as argument using the monitoring library. | |
6 | ||
7 | It computes the average event size and populates local "./result.txt" file with the | |
8 | result. | |
9 | ||
10 | The program reports about its processing progress. | |
11 | ||
12 | Messages on stdout are exported to DAQ log system. | |
13 | ||
14 | contact: alice-datesupport@cern.ch | |
15 | ||
16 | */ | |
17 | ||
18 | extern "C" { | |
19 | #include "daqDA.h" | |
20 | } | |
21 | ||
22 | #include "event.h" | |
23 | #include "monitor.h" | |
24 | ||
25 | #include <stdio.h> | |
26 | #include <stdlib.h> | |
27 | ||
28 | // ROOT includes | |
29 | #include <TFile.h> | |
30 | #include <TH1F.h> | |
31 | #include <TH2F.h> | |
32 | ||
33 | // AliRoot includes | |
34 | #include "AliRawReaderDate.h" | |
35 | #include "AliITSOnlineSDDTP.h" | |
36 | #include "AliITSRawStreamSDD.h" | |
37 | /* Main routine | |
38 | Arguments: list of DATE raw data files | |
39 | */ | |
40 | int main(int argc, char **argv) { | |
41 | ||
42 | int status = 0; | |
43 | ||
44 | ||
45 | /* log start of process */ | |
46 | printf("ITS SDD TP algorithm program started\n"); | |
47 | ||
48 | ||
49 | /* check that we got some arguments = list of files */ | |
50 | if (argc<2) { | |
51 | printf("Wrong number of arguments\n"); | |
52 | return -1; | |
53 | } | |
54 | ||
55 | // Loop over modules has to be added | |
56 | AliITSOnlineSDDTP *left=new AliITSOnlineSDDTP(12,1,411.); | |
57 | TH2F* histo = new TH2F("histo","",256,-0.5,255.5,256,-0.5,255.5); | |
58 | ||
59 | /* report progress */ | |
60 | daqDA_progressReport(10); | |
61 | ||
62 | ||
63 | /* init some counters */ | |
64 | Int_t iev=0; | |
65 | ||
66 | ||
67 | /* read the data files */ | |
68 | int n; | |
69 | for (n=1;n<argc;n++) { | |
70 | ||
71 | status=monitorSetDataSource( argv[n] ); | |
72 | if (status!=0) { | |
73 | printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status)); | |
74 | return -1; | |
75 | } | |
76 | ||
77 | /* report progress */ | |
78 | /* in this example, indexed on the number of files */ | |
79 | // Progress report inside the event loop as well? | |
80 | daqDA_progressReport(10+80*n/argc); | |
81 | ||
82 | /* read the file */ | |
83 | for(;;) { | |
84 | struct eventHeaderStruct *event; | |
85 | eventTypeType eventT; | |
86 | ||
87 | /* get next event */ | |
88 | status=monitorGetEventDynamic((void **)&event); | |
89 | if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */ | |
90 | if (status!=0) { | |
91 | printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status)); | |
92 | return -1; | |
93 | } | |
94 | ||
95 | /* retry if got no event */ | |
96 | if (event==NULL) { | |
97 | break; | |
98 | } | |
99 | ||
100 | iev++; | |
101 | ||
102 | /* use event - here, just write event id to result file */ | |
103 | eventT=event->eventType; | |
104 | switch (event->eventType){ | |
105 | ||
106 | /* START OF RUN */ | |
107 | case START_OF_RUN: | |
108 | break; | |
109 | ||
110 | /* END OF RUN */ | |
111 | case END_OF_RUN: | |
112 | break; | |
113 | ||
114 | case PHYSICS_EVENT: | |
115 | break; | |
116 | ||
117 | case CALIBRATION_EVENT: | |
118 | // for test raw data | |
119 | // case PHYSICS_EVENT: | |
120 | printf(" event number = %i \n",iev); | |
121 | AliRawReader *rawReader = new AliRawReaderDate((void*)event); | |
122 | rawReader->RequireHeader(kFALSE); | |
123 | ||
124 | // temp for test raw data | |
125 | rawReader->SelectEquipment(17,101,101); | |
126 | ||
127 | Int_t evtyp=0; | |
128 | while(rawReader->ReadHeader()){ | |
129 | const UInt_t *subev = rawReader->GetSubEventAttributes(); | |
130 | if(subev[0]==0 && subev[1]==0 && subev[2]==0) evtyp=1; | |
131 | } | |
132 | ||
133 | rawReader->Reset(); | |
134 | histo->Reset(); | |
135 | AliITSRawStreamSDD s(rawReader); | |
136 | // temp for test raw data | |
137 | rawReader->SelectEquipment(17,101,101); | |
138 | ||
139 | while(s.Next()){ | |
140 | // calculation of module etc. | |
141 | if(s.GetCarlosId()==1&&s.GetChannel()==0){ | |
142 | histo->Fill(s.GetCoord2(),s.GetCoord1(),s.GetSignal()); | |
143 | } | |
144 | } | |
145 | delete rawReader; | |
146 | left->AddEvent(histo); | |
147 | } | |
148 | ||
149 | /* free resources */ | |
150 | free(event); | |
151 | } | |
152 | ||
153 | } | |
154 | ||
155 | ||
156 | /* write report */ | |
157 | printf("Run #%s, received %d calibration events\n",getenv("DATE_RUN_NUMBER"),iev); | |
158 | ||
159 | /* report progress */ | |
160 | daqDA_progressReport(90); | |
161 | ||
162 | ||
163 | TH1F *hval=new TH1F("hval","",256,-0.5,255.5); | |
164 | TH1F *hgain=new TH1F("hgain","",256,-0.5,255.5); | |
165 | ||
166 | for(Int_t ian=0;ian<256;ian++){ | |
167 | hgain->SetBinContent(ian+1,left->GetChannelGain(ian)); | |
168 | hval->SetBinContent(ian+1,float(left->IsAnodeGood(ian))); | |
169 | printf("Anode: %d, valid=%d, gain=%f\n",ian,left->IsAnodeGood(ian),left->GetChannelGain(ian)); | |
170 | } | |
171 | ||
172 | hgain->SetMaximum(10); | |
173 | ||
174 | hgain->GetXaxis()->SetTitle("Anode number"); | |
175 | hgain->GetYaxis()->SetTitle("Gain (ADC counts/DAC units)"); | |
176 | ||
177 | left->ValidateAnodes(); | |
178 | printf("Anodes validated"); | |
179 | left->WriteToFXS(); | |
180 | ||
181 | // Example how to store the output file ot DAQ FXS | |
182 | // status=daqDA_FES_storeFile("./result.txt","DAcase1_results"); | |
183 | ||
184 | /* report progress */ | |
185 | daqDA_progressReport(100); | |
186 | ||
187 | // temp for debug purposes | |
188 | TFile fh("histos.root","RECREATE"); | |
189 | histo->Write(); | |
190 | hgain->Write(); | |
191 | hval->Write(); | |
192 | fh.Close(); | |
193 | ||
194 | return status; | |
195 | } |