source: JEM-EUSO/esaf_lal/tags/v1_r0/esaf/packages/simulation/detector/electronics/include/BoolAlgebra.hh @ 117

Last change on this file since 117 was 117, checked in by moretto, 11 years ago

ESAF version compilable on mac OS

File size: 2.2 KB
Line 
1// ESAF : Euso Simulation and Analysis Framework
2// $Id: BoolAlgebra.hh 1799 2005-05-02 10:11:11Z pesce $
3// M. Pallavicini - created Mar,  3 2004
4// Boolean algebra classes used by Chip Tracking
5
6#ifndef __BOOLALGEBRA_HH_
7#define __BOOLALGEBRA_HH_
8
9#include <exception>
10#include "euso.hh"
11
12class BoolMatrix;
13
14class BoolVector {
15public:
16
17    // empty ctor
18    BoolVector();
19 
20    // ctor
21    BoolVector(Int_t);
22
23    // dtor
24    virtual ~BoolVector();
25
26    // get / set
27    inline Int_t Size() const { return fSize;}
28   
29    inline Bool_t operator()(Int_t i) const { return fVector[i]; }
30
31    inline Bool_t& operator()(Int_t i) {return fVector[i]; }
32
33    inline void Zero() {for(Int_t i=0; i<fSize; i++) fVector[i]=kFALSE;}
34
35    // return the logic OR of all elements
36    Bool_t OR() const;
37
38    // return the logic AND of all elements
39    Bool_t AND() const;
40
41    // assignement operator
42    BoolVector& operator = (const BoolVector& );
43
44    // left multiplication with a matrix
45    BoolVector& operator *= (const BoolMatrix&);
46
47    // bitwise AND
48    BoolVector& operator &= (const BoolVector&);
49
50private:
51    Int_t fSize;
52    Bool_t fVector[256];
53   
54    ClassDef(BoolVector,0)
55
56    friend Bool_t operator % (const BoolVector& v1, const BoolVector &v2);
57    friend class BoolMatrix;
58};
59
60// boolean scalar product
61inline Bool_t operator%(const BoolVector& v1, const BoolVector &v2) {
62    Bool_t res = kFALSE;
63    for(Int_t i=0; i < v1.fSize; i++)
64        res |= v1(i)&v2(i);
65    return res;
66}
67
68// very simple matrix with boolean elements
69class BoolMatrix {
70public:
71    // ctor
72    BoolMatrix(Int_t);
73
74    // dtor
75    virtual ~BoolMatrix();
76
77    // get / set operator
78    inline Bool_t operator()(Int_t i,Int_t j) const { return fMatrix[i][j]; }
79
80        // access to elements
81    Bool_t& operator()(Int_t i,Int_t j) {return fMatrix[i][j]; }
82   
83        // assignment operator
84        BoolMatrix & operator = (const BoolMatrix&);
85
86        // left multiplication with another matrix
87        BoolMatrix & operator *= (const BoolMatrix&);
88
89    // set to a neighbors matrix
90    void SetNeighborsMatrix();
91
92private:
93       
94    void Zero();
95    Int_t fSize;
96    Bool_t fMatrix[256][256];
97        friend class BoolVector;
98
99    ClassDef(BoolMatrix,0)
100};
101
102
103#endif  /* __BOOLALGEBRA_HH_ */
104
Note: See TracBrowser for help on using the repository browser.