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