]>
Commit | Line | Data |
---|---|---|
b7f06c9d | 1 | /* |
2 | ||
3 | ACORDE DA for online calibration | |
4 | ||
5 | Contact: Pedro.Gonzalez.Zamora@cern.ch | |
ce0d3dc0 | 6 | Link: missing |
7 | Reference Run: missing | |
b7f06c9d | 8 | Run Type: PHYSICS |
ce0d3dc0 | 9 | DA Type: LDC |
b7f06c9d | 10 | Number of events needed: depending on the run, being run-level |
11 | Input Files: ACORDEDa.root | |
ce0d3dc0 | 12 | Output Files: ACORDEHistos.root to be exported to the DAQ FXS |
b7f06c9d | 13 | Trigger types used: PHYSICS_EVENT |
14 | ||
15 | */ | |
16 | ||
17 | #define FILE_TOTAL "ACORDEHistos.root" | |
18 | // DATE | |
19 | #include "event.h" | |
20 | #include "monitor.h" | |
21 | #include "daqDA.h" | |
22 | ||
23 | //AliRoot | |
24 | #include "AliACORDERawStream.h" | |
25 | #include "AliRawReaderDate.h" | |
b7f06c9d | 26 | |
27 | //ROOT | |
28 | #include "TROOT.h" | |
29 | #include "TPluginManager.h" | |
30 | #include <TFile.h> | |
31 | #include <TH1F.h> | |
32 | #include <TMath.h> | |
33 | ||
34 | ||
35 | #include <stdio.h> | |
36 | #include <stdlib.h> | |
37 | ||
38 | ||
39 | ||
40 | /* Main routine | |
41 | Arguments: list of DATE raw data files | |
42 | */ | |
43 | int main(int argc, char **argv) { | |
44 | ||
ce0d3dc0 | 45 | gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", |
46 | "*", | |
47 | "TStreamerInfo", | |
48 | "RIO", | |
49 | "TStreamerInfo()"); | |
50 | ||
b7f06c9d | 51 | int status; |
52 | ||
53 | // AliACORDERawStream reader; | |
54 | ||
55 | bool fHitMap[60]; | |
56 | bool fMultMap[60]; | |
57 | int eventHits=0; | |
58 | int multHits=0; | |
59 | ||
b7f06c9d | 60 | UInt_t word; |
61 | int kModules=60; | |
62 | ||
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); | |
67 | ||
68 | ||
69 | ||
70 | ||
71 | ||
72 | ||
73 | /* log start of process */ | |
74 | printf("ACORDE DA program started\n"); | |
75 | ||
76 | ||
77 | /* check that we got some arguments = list of files */ | |
78 | if (argc<2) | |
79 | { | |
80 | printf("Wrong number of arguments\n"); | |
81 | return -1; | |
82 | } | |
83 | ||
84 | /* open log */ | |
85 | ||
86 | FILE *fp=NULL; | |
87 | fp=fopen("./da.log","a"); | |
88 | if (fp==NULL) { | |
89 | printf("Failed to open file\n"); | |
90 | return -1; | |
91 | } | |
92 | ||
93 | ||
94 | ||
95 | /* report progress */ | |
96 | daqDA_progressReport(10); | |
97 | ||
98 | ||
99 | /* init some counters */ | |
100 | int nevents_physics=0; | |
101 | int nevents_total=0; | |
102 | ||
103 | ||
104 | /* read the data files */ | |
105 | int n; | |
106 | for (n=1;n<argc;n++) { | |
107 | ||
108 | status=monitorSetDataSource( argv[n] ); | |
109 | if (status!=0) { | |
110 | printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status)); | |
111 | return -1; | |
112 | } | |
113 | ||
114 | /* report progress */ | |
115 | daqDA_progressReport(10+80*n/argc); | |
116 | ||
117 | /* read the file */ | |
118 | for(;;) { | |
119 | struct eventHeaderStruct *event; | |
120 | eventTypeType eventT; | |
121 | ||
122 | /* get next event */ | |
123 | status=monitorGetEventDynamic((void **)&event); | |
124 | ||
125 | if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */ | |
126 | ||
127 | if (status!=0) | |
128 | { | |
129 | printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status)); | |
130 | return -1; | |
131 | } | |
132 | ||
133 | /* retry if got no event */ | |
134 | if (event==NULL) | |
135 | { | |
136 | break; | |
137 | } | |
138 | ||
139 | /* use event - here, just write event id to result file */ | |
140 | eventT=event->eventType; | |
141 | ||
142 | switch (event->eventType) | |
143 | { | |
144 | ||
ce0d3dc0 | 145 | case START_OF_RUN: |
146 | break; | |
147 | case END_OF_RUN: | |
148 | break; | |
149 | case PHYSICS_EVENT: | |
b7f06c9d | 150 | nevents_physics++; |
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)); | |
157 | ||
158 | AliRawReader *rawReader = new AliRawReaderDate((void*)event); | |
159 | ||
160 | AliACORDERawStream* rawStream = new AliACORDERawStream(rawReader); | |
161 | ||
162 | rawStream->Reset(); | |
163 | ||
164 | rawStream->Next(); | |
165 | ||
166 | word = rawStream->GetWord(0); | |
167 | for(int i=0;i<30;i++){ | |
168 | fHitMap[i]=word & 1; | |
169 | word>>=1; | |
170 | } | |
171 | ||
172 | word = rawStream->GetWord(1); | |
173 | for(int i=30;i<60;i++){ | |
174 | fHitMap[i]=word & 1; | |
175 | word>>=1; | |
176 | } | |
177 | ||
178 | word = rawStream->GetWord(2); | |
179 | for(int i=0;i<30;i++){ | |
180 | fMultMap[i]=word & 1; | |
181 | word>>=1; | |
182 | } | |
183 | ||
184 | word = rawStream->GetWord(3); | |
185 | for(int i=30;i<60;i++){ | |
186 | fMultMap[i]=word & 1; | |
187 | word>>=1; | |
188 | } | |
189 | ||
190 | for(int i=0; i<kModules; ++i){ | |
191 | if(fHitMap[i]){ | |
192 | fH1->Fill(i); | |
193 | ++eventHits; | |
194 | } | |
195 | if(fMultMap[i]){ | |
196 | fH3->Fill(i); | |
197 | ++multHits; | |
198 | } | |
199 | } | |
200 | fH2->Fill(eventHits); | |
201 | fH4->Fill(multHits); | |
202 | ||
203 | delete rawStream; | |
204 | rawStream = 0x0; | |
205 | delete rawReader; | |
206 | rawReader = 0x0; | |
207 | } //End Swicht | |
208 | ||
209 | ||
210 | ||
211 | ||
212 | ||
213 | nevents_total++; | |
214 | ||
215 | /* free resources */ | |
216 | free(event); | |
217 | } | |
218 | ||
219 | } | |
220 | ||
221 | ||
222 | //write root file | |
223 | ||
224 | ||
225 | TObjArray Hlist(0); | |
226 | Hlist.Add(fH1); | |
227 | Hlist.Add(fH2); | |
228 | Hlist.Add(fH3); | |
229 | Hlist.Add(fH4); | |
230 | ||
231 | TFile *histoFile = new TFile(FILE_TOTAL,"recreate"); | |
232 | Hlist.Write(); | |
233 | histoFile->Close(); | |
234 | delete histoFile; | |
235 | ||
236 | ||
237 | ||
238 | /* write report */ | |
239 | fprintf(fp,"Run #%s, received %d physics events out of %d\n",getenv("DATE_RUN_NUMBER"),nevents_physics,nevents_total); | |
240 | ||
241 | ||
242 | /* close result file */ | |
243 | fclose(fp); | |
244 | ||
245 | ||
246 | /* report progress */ | |
247 | daqDA_progressReport(90); | |
248 | ||
249 | ||
250 | /* store the result file on FES */ | |
251 | status=daqDA_FES_storeFile(FILE_TOTAL,"CALIB"); | |
252 | if (status) { | |
253 | printf("Failed to export file : %d\n",status); | |
254 | return -1; | |
255 | } | |
256 | ||
257 | ||
258 | /* report progress */ | |
259 | daqDA_progressReport(100); | |
260 | ||
261 | ||
262 | return status; | |
263 | } |