]>
Commit | Line | Data |
---|---|---|
9f5fafa6 | 1 | /* |
2 | ||
3 | Version 1 for MUONTRGda MUON trigger | |
4 | Working version for reading back raw data | |
5 | (Ch. Finck) | |
6 | ||
7 | */ | |
8 | extern "C" { | |
9 | #include <daqDA.h> | |
10 | } | |
11 | ||
12 | #include "event.h" | |
13 | #include "monitor.h" | |
14 | ||
15 | #include <Riostream.h> | |
16 | #include <stdio.h> | |
17 | #include <stdlib.h> | |
18 | ||
19 | //AliRoot | |
20 | #include "AliMUONRawStreamTrigger.h" | |
21 | #include "AliMUONDarcHeader.h" | |
22 | #include "AliMUONRegHeader.h" | |
23 | #include "AliMUONLocalStruct.h" | |
24 | #include "AliMUONDDLTrigger.h" | |
25 | // #include "AliMUONVStore.h" | |
26 | // #include "AliMUON2DMap.h" | |
27 | // #include "AliMUONCalibParamNF.h" | |
28 | // #include "AliMpDDLStore.h" | |
29 | // #include "AliMpIntPair.h" | |
30 | #include "AliMpConstants.h" | |
31 | #include "AliRawReaderDate.h" | |
32 | ||
33 | ||
34 | //ROOT | |
35 | ||
36 | #include "TString.h" | |
37 | #include "TStopwatch.h" | |
38 | #include "TMath.h" | |
39 | #include "TTimeStamp.h" | |
40 | #include "TROOT.h" | |
41 | #include "TPluginManager.h" | |
42 | ||
43 | ||
44 | // global variables | |
45 | TString command("pat"); | |
46 | UInt_t runNumber = 0; | |
47 | Int_t nEvents = 0; | |
48 | ||
49 | ||
50 | //*************************************************************// | |
51 | ||
52 | // main routine | |
53 | int main(Int_t argc, Char_t **argv) | |
54 | { | |
55 | ||
56 | // needed for streamer application | |
57 | gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", | |
58 | "*", | |
59 | "TStreamerInfo", | |
60 | "RIO", | |
61 | "TStreamerInfo()"); | |
62 | ||
63 | ||
64 | Int_t printLevel = 0; // Global variable defined as extern in the others .cxx files | |
65 | Int_t skipEvents = 0; | |
66 | Int_t maxEvents = 1000000; | |
67 | Char_t inputFile[256]; | |
68 | TString flatOutputFile; | |
69 | TString configFile; | |
70 | ||
71 | // option handler | |
72 | ||
73 | // decode the input line | |
74 | for (Int_t i = 1; i < argc; i++) // argument 0 is the executable name | |
75 | { | |
76 | Char_t* arg; | |
77 | ||
78 | arg = argv[i]; | |
79 | if (arg[0] != '-') continue; | |
80 | switch (arg[1]) | |
81 | { | |
82 | case 'f' : | |
83 | i++; | |
84 | sprintf(inputFile,argv[i]); | |
85 | break; | |
86 | case 'a' : | |
87 | i++; | |
88 | flatOutputFile = argv[i]; | |
89 | break; | |
90 | case 'c' : | |
91 | i++; | |
92 | configFile = argv[i]; | |
93 | break; | |
94 | case 'e' : | |
95 | i++; | |
96 | command = argv[i]; | |
97 | break; | |
98 | case 'd' : | |
99 | i++; | |
100 | printLevel=atoi(argv[i]); | |
101 | break; | |
102 | case 's' : | |
103 | i++; | |
104 | skipEvents=atoi(argv[i]); | |
105 | break; | |
106 | case 'n' : | |
107 | i++; | |
108 | sscanf(argv[i],"%d",&maxEvents); | |
109 | break; | |
110 | case 'h' : | |
111 | i++; | |
112 | printf("\n******************* %s usage **********************",argv[0]); | |
113 | printf("\n%s -options, the available options are :",argv[0]); | |
114 | printf("\n-h help (this screen)"); | |
115 | printf("\n"); | |
116 | printf("\n Input"); | |
117 | printf("\n-f <raw data file> (default = %s)",inputFile); | |
118 | printf("\n"); | |
119 | printf("\n Output"); | |
120 | printf("\n-a <Flat ASCII file> (default = %s)",flatOutputFile.Data()); | |
121 | printf("\n"); | |
122 | printf("\n Options"); | |
123 | printf("\n-d <print level> (default = %d)",printLevel); | |
124 | printf("\n-s <skip events> (default = %d)",skipEvents); | |
125 | printf("\n-n <max events> (default = %d)",maxEvents); | |
126 | printf("\n-e <execute pattern/scaler> (default = %s)",command.Data()); | |
127 | ||
128 | printf("\n\n"); | |
129 | exit(-1); | |
130 | default : | |
131 | printf("%s : bad argument %s (please check %s -h)\n",argv[0],argv[i],argv[0]); | |
132 | argc = 2; exit(-1); // exit if error | |
133 | } // end of switch | |
134 | } // end of for i | |
135 | ||
136 | // set command to lower case | |
137 | command.ToLower(); | |
138 | ||
139 | // decoding the events | |
140 | ||
141 | Int_t status; | |
142 | Int_t nDateEvents = 0; | |
143 | ||
144 | void* event; | |
145 | ||
146 | // containers | |
147 | AliMUONDDLTrigger* ddlTrigger = 0x0; | |
148 | AliMUONDarcHeader* darcHeader = 0x0; | |
149 | AliMUONRegHeader* regHeader = 0x0; | |
150 | AliMUONLocalStruct* localStruct = 0x0; | |
151 | ||
152 | TStopwatch timers; | |
153 | ||
154 | timers.Start(kTRUE); | |
155 | ||
156 | // once we have a configuration file in db | |
157 | // copy locally a file from daq detector config db | |
158 | // The current detector is identified by detector code in variable | |
159 | // DATE_DETECTOR_CODE. It must be defined. | |
160 | // If environment variable DAQDA_TEST_DIR is defined, files are copied from DAQDA_TEST_DIR | |
161 | // instead of the database. The usual environment variables are not needed. | |
162 | if (!configFile.IsNull()) { | |
163 | status = daqDA_DB_getFile("myconfig", configFile.Data()); | |
164 | if (status) { | |
165 | printf("Failed to get config file : %d\n",status); | |
166 | return -1; | |
167 | } | |
168 | } | |
169 | ||
170 | ||
171 | status = monitorSetDataSource(inputFile); | |
172 | if (status) { | |
173 | cerr << "ERROR : monitorSetDataSource status (hex) = " << hex << status | |
174 | << " " << monitorDecodeError(status) << endl; | |
175 | return -1; | |
176 | } | |
177 | status = monitorDeclareMp("MUON Tracking monitoring"); | |
178 | if (status) { | |
179 | cerr << "ERROR : monitorDeclareMp status (hex) = " << hex << status | |
180 | << " " << monitorDecodeError(status) << endl; | |
181 | return -1; | |
182 | } | |
183 | ||
184 | cout << "MUONTRKda : Reading data from file " << inputFile <<endl; | |
185 | ||
186 | while(1) | |
187 | { | |
188 | if (nEvents >= maxEvents) break; | |
189 | if (nEvents && nEvents % 100 == 0) | |
190 | cout<<"Cumulated events " << nEvents << endl; | |
191 | ||
192 | // check shutdown condition | |
193 | if (daqDA_checkShutdown()) | |
194 | break; | |
195 | ||
196 | // Skip Events if needed | |
197 | while (skipEvents) { | |
198 | status = monitorGetEventDynamic(&event); | |
199 | skipEvents--; | |
200 | } | |
201 | ||
202 | // starts reading | |
203 | status = monitorGetEventDynamic(&event); | |
204 | if (status < 0) { | |
205 | cout<<"EOF found"<<endl; | |
206 | break; | |
207 | } | |
208 | ||
209 | nDateEvents++; | |
210 | ||
211 | // decoding rawdata headers | |
212 | AliRawReader *rawReader = new AliRawReaderDate(event); | |
213 | ||
214 | Int_t eventType = rawReader->GetType(); | |
215 | runNumber = rawReader->GetRunNumber(); | |
216 | ||
217 | ||
218 | if (eventType != PHYSICS_EVENT) | |
219 | continue; // for the moment | |
220 | ||
221 | nEvents++; | |
222 | if (printLevel) printf("\nEvent # %d\n",nEvents); | |
223 | ||
224 | // decoding MUON payload | |
225 | AliMUONRawStreamTrigger* rawStream = new AliMUONRawStreamTrigger(rawReader); | |
226 | //rawStream->SetMaxReg(1); | |
227 | ||
228 | // loops over DDL | |
229 | while((status = rawStream->NextDDL())) { | |
230 | ||
231 | if (printLevel) printf("iDDL %d\n", rawStream->GetDDL()); | |
232 | ||
233 | ddlTrigger = rawStream->GetDDLTrigger(); | |
234 | darcHeader = ddlTrigger->GetDarcHeader(); | |
235 | ||
236 | if (printLevel) printf("Global output %x\n", (Int_t)darcHeader->GetGlobalOutput()); | |
237 | ||
238 | // loop over regional structures | |
239 | Int_t nReg = darcHeader->GetRegHeaderEntries(); | |
240 | for(Int_t iReg = 0; iReg < nReg; ++iReg){ //REG loop | |
241 | ||
242 | if (printLevel) printf("RegionalId %d\n", iReg); | |
243 | ||
244 | regHeader = darcHeader->GetRegHeaderEntry(iReg); | |
245 | ||
246 | // loop over local structures | |
247 | Int_t nLocal = regHeader->GetLocalEntries(); | |
248 | for(Int_t iLocal = 0; iLocal < nLocal; ++iLocal) { | |
249 | ||
250 | localStruct = regHeader->GetLocalEntry(iLocal); | |
251 | ||
252 | Int_t loStripX = (Int_t)localStruct->GetXPos(); | |
253 | Int_t loStripY = (Int_t)localStruct->GetYPos(); | |
254 | Int_t loDev = (Int_t)localStruct->GetXDev(); | |
255 | ||
256 | if (printLevel) printf("Index %d, XPos: %d, YPos: %d Dev: %d\n", | |
257 | localStruct->GetId(), loStripX, loStripY, loDev); | |
258 | ||
259 | if (printLevel) printf("X pattern %x %x %x %x, Y pattern %x %x %x %x\n", | |
260 | localStruct->GetX1(), localStruct->GetX2(),localStruct->GetX3(),localStruct->GetX4(), | |
261 | localStruct->GetY1(), localStruct->GetY2(),localStruct->GetY3(),localStruct->GetY4()); | |
262 | ||
263 | } // iLocal | |
264 | } // iReg | |
265 | } // NextDDL | |
266 | ||
267 | delete rawReader; | |
268 | delete rawStream; | |
269 | ||
270 | } // while (1) | |
271 | ||
272 | ||
273 | timers.Stop(); | |
274 | ||
275 | cout << "MUONTRKda : Run number : " << runNumber << endl; | |
276 | cout << "MUONTRKda : Flat ASCII file generated : " << flatOutputFile << endl; | |
277 | // cout << "MUONTRKda : Histo file generated : " << histoFileName << endl; | |
278 | cout << "MUONTRKda : Nb of DATE events = " << nDateEvents << endl; | |
279 | cout << "MUONTRKda : Nb of events used = " << nEvents << endl; | |
280 | ||
281 | printf("Execution time : R:%7.2fs C:%7.2fs\n", timers.RealTime(), timers.CpuTime()); | |
282 | ||
283 | return status; | |
284 | } |