]>
Commit | Line | Data |
---|---|---|
ad7f2bfa | 1 | //////////////////////////////////////////////////////////////////////////////////// |
2 | // Author: Henrik Tydesjo // | |
3 | // // | |
4 | // Implementation of conditions data from Pixel Trigger (PIT) // | |
5 | // // | |
6 | // The information is propagated from pixel trigger system to DCS file exchange // | |
7 | // server (text file format). The ReadFromTextFile method will populate this // | |
8 | // object with the values from the text file. Via a Preprocessor, this object // | |
9 | // can be stored in OCDB. // | |
10 | // // | |
11 | // One can also manually create conditions data that may be interesting for // | |
12 | // simulation. // | |
13 | // // | |
14 | //////////////////////////////////////////////////////////////////////////////////// | |
15 | ||
16 | #include "AliITSTriggerConditions.h" | |
17 | #include "AliITSTriggerAlgorithmConditions.h" | |
18 | #include <TError.h> | |
19 | #include <fstream> | |
20 | ||
21 | ClassImp(AliITSTriggerConditions) | |
22 | ||
23 | //__________________________________________________________________________________ | |
24 | AliITSTriggerConditions::AliITSTriggerConditions() : | |
25 | TObject(), | |
26 | fRunNumber(0), | |
27 | fFirmWareVersion(0), | |
28 | fGlobalDescription("n/a"), | |
29 | fVersionRegister(0), | |
30 | fInputConditionsVersion(0), | |
31 | fParametersVersion(0), | |
32 | fInActiveChips(1200), | |
33 | fNumAlgo(0), | |
34 | fAlgoList(TObjArray(10)) | |
35 | { | |
36 | // default constructor | |
37 | fAlgoList.SetOwner(kTRUE); | |
38 | } | |
39 | //__________________________________________________________________________________ | |
40 | AliITSTriggerConditions::AliITSTriggerConditions(const AliITSTriggerConditions& cond) : | |
41 | TObject(), | |
42 | fRunNumber(cond.fRunNumber), | |
43 | fFirmWareVersion(cond.fFirmWareVersion), | |
44 | fGlobalDescription(cond.fGlobalDescription), | |
45 | fVersionRegister(cond.fVersionRegister), | |
46 | fInputConditionsVersion(cond.fInputConditionsVersion), | |
47 | fParametersVersion(cond.fParametersVersion), | |
48 | fInActiveChips(cond.fInActiveChips), | |
49 | fNumAlgo(cond.fNumAlgo), | |
50 | fAlgoList(cond.fAlgoList) | |
51 | { | |
52 | // copy constructor | |
53 | fAlgoList.SetOwner(kTRUE); | |
54 | } | |
55 | //__________________________________________________________________________________ | |
56 | AliITSTriggerConditions::~AliITSTriggerConditions() | |
57 | { | |
58 | // destructor | |
59 | ClearAlgorithms(); | |
60 | } | |
61 | //______________________________________________________________________ | |
62 | AliITSTriggerConditions& AliITSTriggerConditions::operator=(const AliITSTriggerConditions& cond) { | |
63 | // assignment operator | |
64 | if (this!=&cond) { | |
65 | fRunNumber = cond.fRunNumber; | |
66 | fFirmWareVersion = cond.fFirmWareVersion; | |
67 | fGlobalDescription = cond.fGlobalDescription; | |
68 | fVersionRegister = cond.fVersionRegister; | |
69 | fInputConditionsVersion = cond.fInputConditionsVersion; | |
70 | fParametersVersion = cond.fParametersVersion; | |
71 | fInActiveChips = cond.fInActiveChips; | |
72 | fNumAlgo = cond.fNumAlgo; | |
73 | fAlgoList = cond.fAlgoList; | |
74 | } | |
75 | return *this; | |
76 | } | |
77 | //__________________________________________________________________________________ | |
78 | void AliITSTriggerConditions::DumpAll() const { | |
79 | // Dumps all conditions data | |
80 | ||
81 | printf("[Header]\n"); | |
82 | printf("RUN_NUMBER = %d\n",fRunNumber); | |
83 | printf("PROCESSING_FIRMWARE_VERSION = %d\n",fFirmWareVersion); | |
84 | printf("GLOBAL_DESCRIPTION = %s\n",fGlobalDescription.Data()); | |
85 | printf("VERSION_REGISTER_VALUE = %d\n",fVersionRegister); | |
86 | printf("INPUT_CONDITIONS_VERSION = %d\n",fInputConditionsVersion); | |
87 | printf("PARAMETERS_VERSION = %d\n",fParametersVersion); | |
88 | printf("\n"); | |
89 | ||
90 | printf("[Outputs]\n"); | |
91 | for (UInt_t i=0; i<fNumAlgo; i++) { | |
92 | printf("%d = '%s', '%s'\n", GetAlgoIDI(i), GetAlgoLabelI(i), GetAlgoDescriptionI(i)); | |
93 | } | |
94 | printf("\n"); | |
95 | ||
96 | printf("[Output_parameters]\n"); | |
97 | for (UInt_t i=0; i<fNumAlgo; i++) { | |
98 | printf("%d =", GetAlgoIDI(i)); | |
99 | for (Short_t p=0; p<GetNumAlgoParamI(i); p++) { | |
100 | printf(" '%s', %d;", GetAlgoParamNameII(i,p), GetAlgoParamValueII(i,p)); | |
101 | } | |
102 | printf("\n"); | |
103 | } | |
104 | printf("\n"); | |
105 | ||
106 | printf("[Active_chips]\n"); | |
107 | for (UInt_t eq=0; eq<20; eq++) { | |
108 | for (UInt_t hs=0; hs<6; hs++) { | |
109 | UInt_t nActiveOnHs = 0; | |
110 | TString inactiveStr = ""; | |
111 | for (UInt_t chip=0; chip<10; chip++) { | |
112 | Bool_t isChipActive = IsChipActive(eq,hs,chip); | |
113 | inactiveStr.Append(Form("%d",isChipActive)); | |
114 | nActiveOnHs+=isChipActive; | |
115 | } | |
116 | if (nActiveOnHs<10) { | |
117 | printf("%d,%c,%d=%s\n", eq%10, eq<10 ? 'A' : 'C', hs, inactiveStr.Data()); | |
118 | } | |
119 | } | |
120 | } | |
121 | ||
122 | } | |
123 | //__________________________________________________________________________________ | |
124 | void AliITSTriggerConditions::ResetAll() { | |
125 | // clear all data, and put default values | |
126 | fRunNumber=0; | |
127 | fFirmWareVersion=0; | |
128 | fGlobalDescription="n/a"; | |
129 | fVersionRegister=0; | |
130 | fInputConditionsVersion=0; | |
131 | fParametersVersion=0; | |
132 | ResetInActiveChips(); | |
133 | ClearAlgorithms(); | |
134 | } | |
135 | //__________________________________________________________________________________ | |
136 | void AliITSTriggerConditions::ClearAlgorithms() { | |
137 | // clears the list of algorithms | |
138 | fAlgoList.Clear(); | |
139 | fNumAlgo=0; | |
140 | } | |
141 | //__________________________________________________________________________________ | |
142 | void AliITSTriggerConditions::ClearAlgoParamsI(UShort_t aIndex) { | |
143 | // clears the list of parameters for algorithm with index aIndex | |
144 | if (aIndex>=fNumAlgo) { | |
145 | Error("AliITSTriggerConditions::ClearAlgoParamsI", "index %d out of range", aIndex); | |
146 | return; | |
147 | } | |
148 | ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(aIndex))->ClearParams(); | |
149 | } | |
150 | //__________________________________________________________________________________ | |
151 | void AliITSTriggerConditions::ClearAlgoParamsL(const Char_t* aLabel) { | |
152 | // clears the list of parameters for algorithm with label aLabel | |
153 | UShort_t findIndex=fNumAlgo; | |
154 | for (UInt_t i=0; i<fNumAlgo; i++) { | |
155 | if (strcmp(((AliITSTriggerAlgorithmConditions*)fAlgoList.At(i))->GetLabel(),aLabel) == 0) { | |
156 | findIndex = i; | |
157 | break; | |
158 | } | |
159 | } | |
160 | if (findIndex==fNumAlgo) { | |
161 | Error("AliITSTriggerConditions::ClearAlgoParamsL", "label %s not found", aLabel); | |
162 | } | |
163 | ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(findIndex))->ClearParams(); | |
164 | } | |
165 | //__________________________________________________________________________________ | |
166 | void AliITSTriggerConditions::AddAlgo(UShort_t id, const Char_t* aLabel, const Char_t* aDescr) { | |
167 | // adds a new algorithm with id 'id', label aLabel, and description aDescr | |
168 | // if the id or label is already used in the list of algorithms, the old entry will be over-written | |
169 | UShort_t findIndex=fNumAlgo; | |
170 | for (UInt_t i=0; i<fNumAlgo; i++) { | |
171 | if (strcmp(((AliITSTriggerAlgorithmConditions*)fAlgoList.At(i))->GetLabel(), aLabel) == 0 || | |
172 | ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(i))->GetID() == id ) { | |
173 | findIndex = i; | |
174 | break; | |
175 | } | |
176 | } | |
177 | if (findIndex<fNumAlgo) { | |
178 | delete fAlgoList.At(findIndex); | |
179 | fAlgoList.AddAt(new AliITSTriggerAlgorithmConditions(id,aLabel,aDescr),findIndex); | |
180 | } | |
181 | else { | |
182 | fAlgoList.AddAtAndExpand(new AliITSTriggerAlgorithmConditions(id,aLabel,aDescr),fNumAlgo); | |
183 | fNumAlgo++; | |
184 | } | |
185 | } | |
186 | //__________________________________________________________________________________ | |
187 | void AliITSTriggerConditions::AddAlgoParam(UShort_t id, const Char_t* name, Int_t value) { | |
188 | // adds a new parameter with name 'name' and value 'value', for the algorithm with id 'id' | |
189 | UShort_t findIndex=fNumAlgo; | |
190 | for (UInt_t i=0; i<fNumAlgo; i++) { | |
191 | if (((AliITSTriggerAlgorithmConditions*)fAlgoList.At(i))->GetID() == id) { | |
192 | findIndex = i; | |
193 | break; | |
194 | } | |
195 | } | |
196 | if (findIndex==fNumAlgo) { | |
197 | Error("AliITSTriggerConditions::AddAlgoParam", "id %d not found", id); | |
198 | return; | |
199 | } | |
200 | ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(findIndex))->AddParam(name, value); | |
201 | } | |
202 | //__________________________________________________________________________________ | |
203 | Short_t AliITSTriggerConditions::GetAlgoIndexL(const Char_t* aLabel) const { | |
204 | // returns the index for the algorithm with label aLabel | |
205 | UShort_t findIndex=fNumAlgo; | |
206 | for (UInt_t i=0; i<fNumAlgo; i++) { | |
207 | if (strcmp(((AliITSTriggerAlgorithmConditions*)fAlgoList.At(i))->GetLabel(), aLabel) == 0) { | |
208 | findIndex = i; | |
209 | break; | |
210 | } | |
211 | } | |
212 | if (findIndex==fNumAlgo) { | |
213 | Error("AliITSTriggerConditions::GetAlgoIndexL", "label %s not found", aLabel); | |
214 | return -1; | |
215 | } | |
216 | return findIndex; | |
217 | } | |
218 | //__________________________________________________________________________________ | |
219 | Short_t AliITSTriggerConditions::GetAlgoIDI(UShort_t aIndex) const { | |
220 | // returns the ID for the algorithm with index aIndex (in real life, could be 1-10) | |
221 | if (aIndex>=fNumAlgo) { | |
222 | Error("AliITSTriggerConditions::GetAlgoIDI", "index %d out of range", aIndex); | |
223 | return -1; | |
224 | } | |
225 | return ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(aIndex))->GetID(); | |
226 | } | |
227 | //__________________________________________________________________________________ | |
228 | const Char_t* AliITSTriggerConditions::GetAlgoLabelI(UShort_t aIndex) const { | |
229 | // returns the label for the algorithm with index aIndex | |
230 | if (aIndex>=fNumAlgo) { | |
231 | Error("AliITSTriggerConditions::GetAlgoLabelI", "index %d out of range", aIndex); | |
232 | return ""; | |
233 | } | |
234 | return ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(aIndex))->GetLabel(); | |
235 | } | |
236 | //__________________________________________________________________________________ | |
237 | const Char_t* AliITSTriggerConditions::GetAlgoDescriptionI(UShort_t aIndex) const { | |
238 | // returns the description for the algorithm with index aIndex | |
239 | if (aIndex>=fNumAlgo) { | |
240 | Error("AliITSTriggerConditions::GetAlgoDescriptionI", "index %d out of range", aIndex); | |
241 | return ""; | |
242 | } | |
243 | return ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(aIndex))->GetDescription(); | |
244 | } | |
245 | //__________________________________________________________________________________ | |
246 | Short_t AliITSTriggerConditions::GetNumAlgoParamI(UShort_t aIndex) const { | |
247 | // returns the number of parameters, corresponding to the algorithm with index aIndex | |
248 | if (aIndex>=fNumAlgo) { | |
249 | Error("AliITSTriggerConditions::GetNumAlgoParamI", "index %d out of range", aIndex); | |
250 | return -1; | |
251 | } | |
252 | return ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(aIndex))->GetNumParam(); | |
253 | } | |
254 | //__________________________________________________________________________________ | |
255 | const Char_t* AliITSTriggerConditions::GetAlgoParamNameII(UShort_t aIndex, UShort_t pIndex) const { | |
256 | // returns the parameter name for the parameter with index pIndex, corresponding to the algorithm with index aIndex | |
257 | if (aIndex>=fNumAlgo) { | |
258 | Error("AliITSTriggerConditions::GetAlgoParamNameII", "index %d out of range", aIndex); | |
259 | return ""; | |
260 | } | |
261 | return ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(aIndex))->GetParamNameI(pIndex); | |
262 | } | |
263 | //__________________________________________________________________________________ | |
264 | Int_t AliITSTriggerConditions::GetAlgoParamValueII(UShort_t aIndex, UShort_t pIndex) const { | |
265 | // returns the parameter value for the parameter with index pIndex, corresponding to the algorithm with index aIndex | |
266 | if (aIndex>=fNumAlgo) { | |
267 | Error("AliITSTriggerConditions::GetAlgoParamValueII", "index %d out of range", aIndex); | |
268 | return -1; | |
269 | } | |
270 | return ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(aIndex))->GetParamValueI(pIndex); | |
271 | } | |
272 | //__________________________________________________________________________________ | |
273 | Int_t AliITSTriggerConditions::GetAlgoParamValueIN(UShort_t aIndex, const Char_t* pName) const { | |
274 | // returns parameter value for the parameter named pName, corresponding to the algorithm with index aIndex | |
275 | if (aIndex>=fNumAlgo) { | |
276 | Error("AliITSTriggerConditions::GetAlgoParamValueIN", "index %d out of range", aIndex); | |
277 | return -1; | |
278 | } | |
279 | return ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(aIndex))->GetParamValueN(pName); | |
280 | } | |
281 | //__________________________________________________________________________________ | |
282 | Short_t AliITSTriggerConditions::GetNumAlgoParamL(const Char_t* aLabel) const { | |
283 | // returns the number of parameters, corresponding to the algorithm with label aLabel | |
284 | UShort_t findIndex=fNumAlgo; | |
285 | for (UInt_t i=0; i<fNumAlgo; i++) { | |
286 | if (strcmp(((AliITSTriggerAlgorithmConditions*)fAlgoList.At(i))->GetLabel(), aLabel) == 0) { | |
287 | findIndex = i; | |
288 | break; | |
289 | } | |
290 | } | |
291 | if (findIndex==fNumAlgo) { | |
292 | Error("AliITSTriggerConditions::GetNumAlgoParamL", "label %s not found", aLabel); | |
293 | return -1; | |
294 | } | |
295 | return ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(findIndex))->GetNumParam(); | |
296 | } | |
297 | //__________________________________________________________________________________ | |
298 | const Char_t* AliITSTriggerConditions::GetAlgoParamNameLI(const Char_t* aLabel, UShort_t pIndex) const { | |
299 | // returns parameter name for the parameter with index pIndex, corresponding to the algorithm with label aLabel | |
300 | UShort_t findIndex=fNumAlgo; | |
301 | for (UInt_t i=0; i<fNumAlgo; i++) { | |
302 | if (strcmp(((AliITSTriggerAlgorithmConditions*)fAlgoList.At(i))->GetLabel(), aLabel) == 0) { | |
303 | findIndex = i; | |
304 | break; | |
305 | } | |
306 | } | |
307 | if (findIndex==fNumAlgo) { | |
308 | Error("AliITSTriggerConditions::GetAlgoParamNameLI", "label %s not found", aLabel); | |
309 | return ""; | |
310 | } | |
311 | return ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(findIndex))->GetParamNameI(pIndex); | |
312 | } | |
313 | //__________________________________________________________________________________ | |
314 | Int_t AliITSTriggerConditions::GetAlgoParamValueLI(const Char_t* aLabel, UShort_t pIndex) const { | |
315 | // returns parameter value for the parameter with index pIndex, corresponding to the algorithm with label aLabel | |
316 | UShort_t findIndex=fNumAlgo; | |
317 | for (UInt_t i=0; i<fNumAlgo; i++) { | |
318 | if (strcmp(((AliITSTriggerAlgorithmConditions*)fAlgoList.At(i))->GetLabel(), aLabel) == 0) { | |
319 | findIndex = i; | |
320 | break; | |
321 | } | |
322 | } | |
323 | if (findIndex==fNumAlgo) { | |
324 | Error("AliITSTriggerConditions::GetAlgoParamValueLI", "label %s not found", aLabel); | |
325 | return -1; | |
326 | } | |
327 | return ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(findIndex))->GetParamValueI(pIndex); | |
328 | } | |
329 | //__________________________________________________________________________________ | |
330 | Int_t AliITSTriggerConditions::GetAlgoParamValueLN(const Char_t* aLabel, const Char_t* pName) const { | |
331 | // returns parameter value for the parameter named pName, corresponding to the algorithm with label aLabel | |
332 | UShort_t findIndex=fNumAlgo; | |
333 | for (UInt_t i=0; i<fNumAlgo; i++) { | |
334 | if (strcmp(((AliITSTriggerAlgorithmConditions*)fAlgoList.At(i))->GetLabel(), aLabel) == 0) { | |
335 | findIndex = i; | |
336 | break; | |
337 | } | |
338 | } | |
339 | if (findIndex==fNumAlgo) { | |
340 | Error("AliITSTriggerConditions::GetAlgoParamValueLN", "label %s not found", aLabel); | |
341 | return -1; | |
342 | } | |
343 | return ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(findIndex))->GetParamValueN(pName); | |
344 | } | |
345 | //__________________________________________________________________________________ | |
346 | UInt_t AliITSTriggerConditions::GetChipKey(Int_t eq, Int_t hs, Int_t chip) const { | |
347 | // translates eq,hs,chip numbers into one integer key (0-1199) | |
348 | if (eq<0 || eq>=20 || hs<0 || hs>=6 || chip<0 || chip>=10) { | |
349 | Error("AliITSTriggerConditions::GetChipKey", "eq,hs,chip = %d,%d,%d out of range",eq,hs,chip); | |
350 | return 0; | |
351 | } | |
352 | return eq*60 + hs*10 + chip; | |
353 | } | |
354 | //__________________________________________________________________________________ | |
355 | void AliITSTriggerConditions::GetChipFromKey(UInt_t key, Int_t& eq, Int_t& hs, Int_t& chip) const { | |
356 | // translates a chip key back into eq,hs,chip numbers | |
357 | if (key>=1200) { | |
358 | Error("AliITSTriggerConditions::GetChipFromKey", "key = %d out of range", key); | |
359 | return; | |
360 | } | |
361 | eq = key/60; | |
362 | hs = (key%60)/10; | |
363 | chip = key%10; | |
364 | } | |
365 | //__________________________________________________________________________________ | |
366 | Bool_t AliITSTriggerConditions::GetNextInActiveChip(Int_t& eq, Int_t& hs, Int_t& chip) const { | |
367 | // Returns true if an in-active chip was found (start looking after the bit number | |
368 | // corresponding to the input parameters eq,hs,chip). | |
369 | // If either of eq,hs,chip < 0 , start from beginning of TBits array. | |
370 | // See example of usage in AliITSDetTypeRec::RemoveFastOrFiredInActive. | |
371 | UInt_t searchIndex; | |
372 | if (eq<0 || hs<0 || chip<0) searchIndex = 0; | |
373 | else searchIndex = GetChipKey(eq, hs, chip) + 1; | |
374 | UInt_t nextIndex = fInActiveChips.FirstSetBit(searchIndex); | |
375 | if (nextIndex==1200) return kFALSE; | |
376 | GetChipFromKey(nextIndex, eq, hs, chip); | |
377 | return kTRUE; | |
378 | } | |
379 | //__________________________________________________________________________________ | |
380 | void AliITSTriggerConditions::DumpInActiveChips() const { | |
381 | // Prints a list of all inactive chips | |
382 | UInt_t startBit=0; | |
383 | UInt_t occ=0; | |
384 | while (startBit<1200) { | |
385 | startBit = fInActiveChips.FirstSetBit(startBit); | |
386 | if (startBit<1200) { | |
387 | occ++; | |
388 | Int_t eq,hs,chip; | |
389 | GetChipFromKey(startBit,eq,hs,chip); | |
390 | printf("%3d: %d,%d,%d\n",occ,eq,hs,chip); | |
391 | startBit++; | |
392 | } | |
393 | } | |
394 | } | |
395 | //__________________________________________________________________________________ | |
396 | void AliITSTriggerConditions::ReadFromTextFile(const Char_t* fileName) { | |
397 | // Reads conditions from text file (file format is used online by PIT system) | |
398 | ||
399 | ResetAll(); | |
400 | ||
401 | const Int_t maxS = 500; | |
402 | enum headers {HEAD, OUTPUT, PARAM, ACTIVECHIP}; | |
403 | ||
404 | ifstream file; | |
405 | file.open(fileName, ifstream::in); | |
406 | if (file.fail()) { | |
407 | Error("AliITSTriggerConditions::ReadFromTextFile","No file (%s) present.",fileName); | |
408 | return; | |
409 | } | |
410 | ||
411 | Int_t headType = -1; // no header read from start | |
412 | UInt_t nl = 0; | |
413 | Char_t cline[maxS]; | |
414 | while(!file.eof()) { | |
415 | // *** get line | |
416 | nl++; | |
417 | file.getline(cline,maxS); | |
418 | TString line(cline); | |
419 | ||
420 | // *** remove comments from line | |
421 | Int_t skipPos = line.First('#'); | |
422 | if (skipPos>=0) { | |
423 | line.Remove(skipPos,maxS); | |
424 | } | |
425 | ||
426 | // *** check what type of information the line has (header or not...) | |
427 | Int_t brackPos1 = line.First('['); | |
428 | Int_t brackPos2 = line.First(']'); | |
429 | if (brackPos1==0 && brackPos2-1>brackPos1) { | |
430 | // *** parse header line (header has to come first on the line) | |
431 | TString headword = line(brackPos1+1,brackPos2-1-brackPos1); | |
432 | if (headword.CompareTo("Header", TString::kIgnoreCase) == 0) headType = HEAD; | |
433 | else if (headword.CompareTo("Outputs", TString::kIgnoreCase) == 0) headType = OUTPUT; | |
434 | else if (headword.CompareTo("Output_parameters",TString::kIgnoreCase) == 0) headType = PARAM; | |
435 | else if (headword.CompareTo("Active_chips", TString::kIgnoreCase) == 0) headType = ACTIVECHIP; | |
436 | } | |
437 | else { | |
438 | // *** parse non-header line | |
439 | ||
440 | // HEAD data | |
441 | if (headType==HEAD) { | |
442 | TString descrWord, valueWord; | |
443 | if (! SplitStringIn2(line,descrWord,valueWord,'=')) continue; | |
444 | descrWord.ReplaceAll(" ",""); | |
445 | valueWord.Remove(TString::kBoth,' '); | |
446 | ||
447 | if (descrWord.CompareTo("RUN_NUMBER",TString::kIgnoreCase) == 0 && valueWord.IsDigit()) { | |
448 | SetRunNumber(valueWord.Atoi()); | |
449 | } | |
450 | else if (descrWord.CompareTo("PROCESSING_FIRMWARE_VERSION",TString::kIgnoreCase) == 0 && valueWord.IsDigit()) { | |
451 | SetFirmWareVersion(valueWord.Atoi()); | |
452 | } | |
453 | else if (descrWord.CompareTo("GLOBAL_DESCRIPTION",TString::kIgnoreCase) == 0) { | |
454 | SetGlobalDescription(valueWord.Data()); | |
455 | } | |
456 | else if (descrWord.CompareTo("VERSION_REGISTER_VALUE",TString::kIgnoreCase) == 0 && valueWord.IsDigit()) { | |
457 | SetVersionRegister(valueWord.Atoi()); | |
458 | } | |
459 | else if (descrWord.CompareTo("INPUT_CONDITIONS_VERSION",TString::kIgnoreCase) == 0 && valueWord.IsDigit()) { | |
460 | SetInputConditionsVersion(valueWord.Atoi()); | |
461 | } | |
462 | else if (descrWord.CompareTo("PARAMETERS_VERSION",TString::kIgnoreCase) == 0 && valueWord.IsDigit()) { | |
463 | SetParametersVersion(valueWord.Atoi()); | |
464 | } | |
465 | } | |
466 | // OUTPUT data | |
467 | else if (headType==OUTPUT) { | |
468 | TString idWord, labelWord, descrWord, restWord; | |
469 | if (! SplitStringIn2(line,idWord,restWord,'=')) continue; | |
470 | if (! idWord.IsDigit()) continue; | |
471 | if (! SplitStringIn2(restWord,labelWord,descrWord,',')) continue; | |
472 | labelWord = GetStringBetween(labelWord,'\'','\''); | |
473 | descrWord = GetStringBetween(descrWord,'\'','\''); | |
474 | if (labelWord.Length()==0 || descrWord.Length()==0) continue; | |
475 | // printf("id: %d , label '%s' , descr '%s'\n", idWord.Atoi(),labelWord.Data(),descrWord.Data()); | |
476 | AddAlgo(idWord.Atoi(),labelWord.Data(),descrWord.Data()); | |
477 | } | |
478 | // PARAM data | |
479 | else if (headType==PARAM) { | |
480 | TString idWord, restWord; | |
481 | if (! SplitStringIn2(line,idWord,restWord,'=')) continue; | |
482 | if (! idWord.IsDigit()) continue; | |
483 | while (restWord.Length()>0) { | |
484 | TString parWord, nameWord, valWord; | |
485 | SplitStringIn2(restWord,parWord,restWord,';'); | |
486 | if (! SplitStringIn2(parWord,nameWord,valWord,',')) break; | |
487 | nameWord = GetStringBetween(nameWord,'\'','\''); | |
488 | if (nameWord.Length()==0 || valWord.Length()==0 || ! valWord.IsDigit()) break; | |
489 | // printf("id %d , param %s , value %d\n",idWord.Atoi(),nameWord.Data(),valWord.Atoi()); | |
490 | AddAlgoParam(idWord.Atoi(),nameWord.Data(),valWord.Atoi()); | |
491 | } | |
492 | } | |
493 | // ACTIVECHIP data | |
494 | if (headType==ACTIVECHIP) { | |
495 | TString eqWord, sideWord, hsWord, chipWord, restWord; | |
496 | if (! SplitStringIn2(line,eqWord,restWord,',')) continue; | |
497 | if (! eqWord.IsDigit()) continue; | |
498 | UInt_t eq = eqWord.Atoi(); | |
499 | if (eq>=20) continue; | |
500 | if (! SplitStringIn2(restWord,sideWord,restWord,',')) continue; | |
501 | sideWord.ReplaceAll(" ",""); | |
502 | if (sideWord.CompareTo("A",TString::kIgnoreCase) == 0) {} | |
503 | else if (sideWord.CompareTo("C",TString::kIgnoreCase) == 0) eq+=10; | |
504 | else continue; | |
505 | if (! SplitStringIn2(restWord,hsWord,chipWord,'=')) continue; | |
506 | if (! hsWord.IsDigit()) continue; | |
507 | UInt_t hs = hsWord.Atoi(); | |
508 | if (hs>=6) continue; | |
509 | chipWord.ReplaceAll(" ",""); | |
510 | if (chipWord.Length()!=10) continue; | |
511 | for (UInt_t chip=0; chip<10; chip++) { | |
512 | if (chipWord[9-chip]=='0') { | |
513 | // printf("Chip %d,%d,%d inactive\n",eq,hs,chip); | |
514 | SetInActiveChip(eq,hs,chip); | |
515 | } | |
516 | } | |
517 | } | |
518 | ||
519 | } | |
520 | } | |
521 | file.close(); | |
522 | } | |
523 | //__________________________________________________________________________________ | |
524 | Bool_t AliITSTriggerConditions::SplitStringIn2(TString orig, TString& word1, TString& word2, Char_t sep) { | |
525 | // splits a string in two parts (one before separator character and one after) | |
526 | Int_t sepPos = orig.First(sep); | |
527 | if (sepPos<0) sepPos = orig.Length(); | |
528 | word1 = orig(0,sepPos); | |
529 | word2 = orig(sepPos+1,orig.Length()); | |
530 | return (word1.Length()>0 && word2.Length()>0); | |
531 | } | |
532 | //__________________________________________________________________________________ | |
533 | TString AliITSTriggerConditions::GetStringBetween(TString orig, Char_t sep1, Char_t sep2) { | |
534 | // returns string between separator character 1 and separator character 2 | |
535 | Int_t pos1 = orig.First(sep1); | |
536 | if (pos1<0) return ""; | |
537 | TString ret = orig(pos1+1,orig.Length()); | |
538 | Int_t pos2 = ret.First(sep2); | |
539 | if (pos2<0) return ""; | |
540 | ret = ret(0,pos2); | |
541 | return ret; | |
542 | } | |
543 | //__________________________________________________________________________________ | |
544 | Bool_t AliITSTriggerConditions::IsEqualTo(AliITSTriggerConditions *cond) const { | |
545 | // checks if this object contains the same information as the input cond object | |
546 | if (fRunNumber != cond->GetRunNumber()) return kFALSE; | |
547 | if (fFirmWareVersion != cond->GetFirmWareVersion()) return kFALSE; | |
548 | if (fGlobalDescription.CompareTo(cond->GetGlobalDescription()) !=0) return kFALSE; | |
549 | if (fVersionRegister != cond->GetVersionRegister()) return kFALSE; | |
550 | if (fInputConditionsVersion != cond->GetInputConditionsVersion()) return kFALSE; | |
551 | if (fParametersVersion != cond->GetParametersVersion()) return kFALSE; | |
552 | ||
553 | for (UInt_t eq=0; eq<20; eq++) { | |
554 | for (UInt_t hs=0; hs<6; hs++) { | |
555 | for (UInt_t chip=0; chip<10; chip++) { | |
556 | if (IsChipActive(eq,hs,chip) != cond->IsChipActive(eq,hs,chip)) return kFALSE; | |
557 | } | |
558 | } | |
559 | } | |
560 | ||
561 | if (fNumAlgo != cond->GetNumAlgo()) return kFALSE; | |
562 | for (Short_t alg1=0; alg1<fNumAlgo; alg1++) { | |
563 | Short_t alg2 = cond->GetAlgoIndexL(GetAlgoLabelI(alg1)); | |
564 | if (alg2<0) return kFALSE; | |
565 | if (GetAlgoIDI(alg1) != cond->GetAlgoIDI(alg2)) return kFALSE; | |
566 | if (strcmp(GetAlgoDescriptionI(alg1), cond->GetAlgoDescriptionI(alg2)) != 0) return kFALSE; | |
567 | if (GetNumAlgoParamI(alg1) != cond->GetNumAlgoParamI(alg2)) return kFALSE; | |
568 | for (Short_t par1=0; par1<GetNumAlgoParamI(alg1); par1++) { | |
569 | const Char_t* paramName = GetAlgoParamNameII(alg1,par1); | |
570 | if (GetAlgoParamValueIN(alg1,paramName) != cond->GetAlgoParamValueIN(alg2,paramName)) return kFALSE; | |
571 | } | |
572 | } | |
573 | ||
574 | return kTRUE; | |
575 | } |