]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSFOSignalsSPD.cxx
Fixing a little overlap. Adding flags to perform material budget studies (Mario)
[u/mrichter/AliRoot.git] / ITS / AliITSFOSignalsSPD.cxx
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 ClassImp(AliITSFOSignalsSPD)
12
13 AliITSFOSignalsSPD::AliITSFOSignalsSPD() :
14   TObject(), fSignals(1200)
15 {
16   // default constructor
17 }
18 //______________________________________________________________________
19 AliITSFOSignalsSPD::~AliITSFOSignalsSPD() {}
20 //______________________________________________________________________
21 AliITSFOSignalsSPD::AliITSFOSignalsSPD(const AliITSFOSignalsSPD& fo):
22   TObject(), fSignals(fo.fSignals)
23 {
24   // copy constructor
25 }
26 //______________________________________________________________________
27 AliITSFOSignalsSPD& AliITSFOSignalsSPD::operator=(const AliITSFOSignalsSPD& fo) {
28   // assignment operator
29   if (this!=&fo) {
30     fSignals = fo.fSignals;
31   }
32   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   fSignals.SetBitNumber(GetChipKey(eq,hs,chip),setVal);
38 }
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   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   if (eq<0 || hs<0 || chip<0) searchIndex = 0;
52   else searchIndex = GetChipKey(eq, hs, chip) + 1;
53   UInt_t nextIndex = fSignals.FirstSetBit(searchIndex);
54   if (nextIndex==1200) return kFALSE;
55   GetChipFromKey(nextIndex, eq, hs, chip);
56   return kTRUE;
57 }
58 //__________________________________________________________________________________
59 void AliITSFOSignalsSPD::DumpSignals() {
60   // print a list of the chips which have a signal
61   printf("These chips (given in eq,hs,chip) have a signal:\n");
62   UInt_t nrSignals=0;
63   Int_t eq   = -1;
64   Int_t hs   = -1;
65   Int_t chip = -1;
66   while (GetNextSignal(eq,hs,chip)) {
67     printf("%d,%d,%d\n",eq,hs,chip);
68     nrSignals++;
69   }
70   printf("In total %d signals.\n",nrSignals);
71 }
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   if (eq>=20 || eq<0 || hs>=6 || hs<0 || chip>=10 || chip<0) {
76     Error("AliITSFOSignalsSPD::GetChipKey", "eq,hs,chip = %d,%d,%d out of range",eq,hs,chip);
77     return 0;
78   }
79   return eq*60 + hs*10 + chip;
80 }
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   if (key>=1200) {
85     Error("AliITSFOSignalsSPD::GetChipFromKey", "key = %d out of range", key);
86     return;
87   }
88   eq   = key/60;
89   hs   = (key%60)/10;
90   chip = key%10;
91 }