LCOV - code coverage report
Current view: top level - ITS/ITSbase - AliITSFOSignalsSPD.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 26 43 60.5 %
Date: 2016-06-14 17:26:59 Functions: 13 15 86.7 %

          Line data    Source code
       1             : /////////////////////////////////////////////////////////////////////
       2             : // Author: Henrik Tydesjo                                          //
       3             : //                                                                 //
       4             : // This class is used to store information on generated Fast-OR    //
       5             : // signals. 1200 bits, one per pixel chip.                         //
       6             : //                                                                 //
       7             : /////////////////////////////////////////////////////////////////////
       8             : 
       9             : #include "AliITSFOSignalsSPD.h"
      10             : 
      11         118 : ClassImp(AliITSFOSignalsSPD)
      12             : 
      13             : AliITSFOSignalsSPD::AliITSFOSignalsSPD() :
      14          66 :   TObject(), fSignals(1200)
      15         165 : {
      16             :   // default constructor
      17          66 : }
      18             : //______________________________________________________________________
      19         196 : AliITSFOSignalsSPD::~AliITSFOSignalsSPD() {}
      20             : //______________________________________________________________________
      21             : AliITSFOSignalsSPD::AliITSFOSignalsSPD(const AliITSFOSignalsSPD& fo):
      22           8 :   TObject(), fSignals(fo.fSignals)
      23          20 : {
      24             :   // copy constructor
      25           8 : }
      26             : //______________________________________________________________________
      27             : AliITSFOSignalsSPD& AliITSFOSignalsSPD::operator=(const AliITSFOSignalsSPD& fo) {
      28             :   // assignment operator
      29           0 :   if (this!=&fo) {
      30           0 :     fSignals = fo.fSignals;
      31           0 :   }
      32           0 :   return *this;
      33             : }
      34             : //______________________________________________________________________
      35             : void AliITSFOSignalsSPD::SetSignal(UInt_t eq, UInt_t hs, UInt_t chip, Bool_t setVal) {
      36             :   // Set 0 or 1 for a specific chip
      37         148 :   fSignals.SetBitNumber(GetChipKey(eq,hs,chip),setVal);
      38         148 : }
      39             : //______________________________________________________________________
      40             : Bool_t AliITSFOSignalsSPD::GetSignal(UInt_t eq, UInt_t hs, UInt_t chip) const {
      41             :   // check if a specific chip has a signal
      42       19200 :   return fSignals.TestBitNumber(GetChipKey(eq,hs,chip));
      43             : }
      44             : //______________________________________________________________________
      45             : Bool_t AliITSFOSignalsSPD::GetNextSignal(Int_t& eq, Int_t& hs, Int_t& chip) const {
      46             :   // Returns true if a signal was found (start looking after the bit number
      47             :   // corresponding to the input parameters eq,hs,chip).
      48             :   // If either of eq,hs,chip < 0 , start from beginning of TBits array.
      49             :   // See example of usage in DumpSignals method.
      50             :   UInt_t searchIndex;
      51         616 :   if (eq<0 || hs<0 || chip<0) searchIndex = 0;
      52         148 :   else searchIndex = GetChipKey(eq, hs, chip) + 1;
      53         156 :   UInt_t nextIndex = fSignals.FirstSetBit(searchIndex);
      54         164 :   if (nextIndex==1200) return kFALSE;
      55         148 :   GetChipFromKey(nextIndex, eq, hs, chip);
      56         148 :   return kTRUE;
      57         156 : }
      58             : //__________________________________________________________________________________
      59             : void AliITSFOSignalsSPD::DumpSignals() {
      60             :   // print a list of the chips which have a signal
      61           0 :   printf("These chips (given in eq,hs,chip) have a signal:\n");
      62             :   UInt_t nrSignals=0;
      63           0 :   Int_t eq   = -1;
      64           0 :   Int_t hs   = -1;
      65           0 :   Int_t chip = -1;
      66           0 :   while (GetNextSignal(eq,hs,chip)) {
      67           0 :     printf("%d,%d,%d\n",eq,hs,chip);
      68           0 :     nrSignals++;
      69             :   }
      70           0 :   printf("In total %d signals.\n",nrSignals);
      71           0 : }
      72             : //______________________________________________________________________
      73             : UInt_t AliITSFOSignalsSPD::GetChipKey(Int_t eq, Int_t hs, Int_t chip) const {
      74             :   // translates eq,hs,chip numbers into one integer key (0-1199)
      75       19792 :   if (eq>=20 || eq<0 || hs>=6 || hs<0 || chip>=10 || chip<0) {
      76           0 :     Error("AliITSFOSignalsSPD::GetChipKey", "eq,hs,chip = %d,%d,%d out of range",eq,hs,chip);
      77           0 :     return 0;
      78             :   }
      79        9896 :   return eq*60 + hs*10 + chip;
      80        9896 : }
      81             : //__________________________________________________________________________________
      82             : void AliITSFOSignalsSPD::GetChipFromKey(UInt_t key, Int_t& eq, Int_t& hs, Int_t& chip) const {
      83             :   // translates a chip key back into eq,hs,chip numbers
      84         296 :   if (key>=1200) {
      85           0 :     Error("AliITSFOSignalsSPD::GetChipFromKey", "key = %d out of range", key);
      86           0 :     return;
      87             :   }
      88         148 :   eq   = key/60;
      89         148 :   hs   = (key%60)/10;
      90         148 :   chip = key%10;
      91         296 : }

Generated by: LCOV version 1.11