source: trunk/Mars/melectronics/MDigitalSignal.h@ 13344

Last change on this file since 13344 was 9347, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 1.7 KB
Line 
1#ifndef MARS_MDigitalSignal
2#define MARS_MDigitalSignal
3
4#ifndef ROOT_TObject
5#include <TObject.h>
6#endif
7
8//#include <climits>
9
10class MDigitalSignal : public TObject
11{
12 Double_t fStart;
13 Double_t fLength;
14
15 Int_t fIndex;
16
17public:
18 MDigitalSignal(Double_t start=0, Double_t len=1e12/*FLT_MAX*/) : fStart(start), fLength(len), fIndex(-1)
19 {
20 }
21
22 MDigitalSignal(const MDigitalSignal &ttl) : TObject(ttl), fStart(ttl.fStart), fLength(ttl.fLength), fIndex(ttl.fIndex)
23 {
24 }
25
26 MDigitalSignal(const MDigitalSignal &ttl1, const MDigitalSignal &ttl2);
27
28 // Setter
29 void SetIndex(Int_t idx=-1) { fIndex=idx; }
30
31 // Getter
32 Bool_t IsValid() const { return fLength>0; }
33
34 Double_t GetStart() const { return fStart; }
35 Double_t GetEnd() const { return fStart+fLength; }
36 Double_t GetLength() const { return fLength; }
37
38 Int_t GetIndex() const { return fIndex; }
39 Bool_t IsConnected() const { return fIndex>=0; }
40
41 // TObject
42 Bool_t IsSortable() const { return kTRUE; }
43 Int_t Compare(const TObject *obj) const;
44 void Print(Option_t *o="") const;
45
46 // MDigitalSignal
47 Bool_t Overlap(const TObject &obj) const;
48 Bool_t Combine(const TObject &obj);
49
50 MDigitalSignal GetCoincidence(const MDigitalSignal &ttl) const
51 {
52 return MDigitalSignal(*this, ttl);
53 }
54
55 const MDigitalSignal operator&&(const MDigitalSignal &ttl) const
56 {
57 return GetCoincidence(ttl);
58 }
59 const MDigitalSignal operator||(const MDigitalSignal &ttl) const
60 {
61 MDigitalSignal cpy(ttl);
62 return !cpy.Combine(*this) ? MDigitalSignal(0, -1) : cpy;
63 }
64
65 ClassDef(MDigitalSignal, 1) // A digital signal with a start time and a length
66};
67
68#endif
Note: See TracBrowser for help on using the repository browser.