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