LCOV - code coverage report
Current view: top level - ITS/ITSbase - AliITSTriggerConditions.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 49 393 12.5 %
Date: 2016-06-14 17:26:59 Functions: 13 37 35.1 %

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

Generated by: LCOV version 1.11