source: branches/Corsika7405Compatibility/melectronics/MDigitalSignal.cc@ 20055

Last change on this file since 20055 was 9347, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 3.6 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of CheObs, the Modular Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appears in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Thomas Bretz, 1/2009 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: CheObs Software Development, 2000-2009
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26//
27// MDigitalSignal
28//
29// A digital signal with a start time and length.
30//
31//////////////////////////////////////////////////////////////////////////////
32#include "MDigitalSignal.h"
33
34#include <TMath.h>
35
36#include "MLog.h"
37#include "MLogManip.h"
38
39ClassImp(MDigitalSignal);
40
41using namespace std;
42
43// ------------------------------------------------------------------------
44//
45// Initialize a new signal with a coincidence (and) of the two given
46// signals.
47//
48MDigitalSignal::MDigitalSignal(const MDigitalSignal &ttl1, const MDigitalSignal &ttl2) : fIndex(-1)
49{
50 const Double_t new0 = TMath::Max(ttl1.fStart, ttl2.fStart);
51 const Double_t new1 = TMath::Min(ttl1.fStart+ttl1.fLength, ttl2.fStart+ttl2.fLength);
52
53 fStart = new0;
54 fLength = new1-new0;
55}
56
57// ------------------------------------------------------------------------
58//
59// Compare the start time of two signal.
60//
61// Returns:
62// 0) Both signals have identical start time
63// 1) the argument starts earlier than this
64// -1) The argument starts later than this
65//
66Int_t MDigitalSignal::Compare(const TObject *obj) const
67{
68 const MDigitalSignal &ttl = *static_cast<const MDigitalSignal*>(obj);
69
70 if (ttl.fStart>fStart)
71 return -1;
72
73 if (ttl.fStart<fStart)
74 return 1;
75
76 return 0;
77}
78
79// ------------------------------------------------------------------------
80//
81// Return whether two signals overlap.
82//
83Bool_t MDigitalSignal::Overlap(const TObject &obj) const
84{
85 const MDigitalSignal &ttl = static_cast<const MDigitalSignal&>(obj);
86
87 return fStart<=ttl.fStart+ttl.fLength && ttl.fStart<=fStart+fLength;
88}
89
90// ------------------------------------------------------------------------
91//
92// Combine a new (overlapping) signal with this signal to one signal.
93// If they don't overlap kFALSE is returned, kTRUE otherwise.
94//
95Bool_t MDigitalSignal::Combine(const TObject &obj)
96{
97 if (!Overlap(obj))
98 return kFALSE;
99
100 const MDigitalSignal &ttl = static_cast<const MDigitalSignal&>(obj);
101
102 const Double_t new0 = TMath::Min(fStart, ttl.fStart);
103 const Double_t new1 = TMath::Max(fStart+fLength, ttl.fStart+ttl.fLength);
104
105 fStart = new0;
106 fLength = new1-new0;
107
108 return kTRUE;
109}
110
111/*
112Bool_t Overlay(const TObject &obj)
113{
114 const TTL &ttl = static_cast<const TTL&>(obj);
115
116 const Double_t new0 = TMath::Max(fStart, ttl.fStart);
117 const Double_t new1 = TMath::Min(fStart+fLength, ttl.fStart+ttl.fLength);
118
119 fStart = new0;
120 fLength = new1-new0;
121
122 return IsValid();
123}*/
124
125
126void MDigitalSignal::Print(Option_t *o) const
127{
128 gLog << all << Form("%.2f,%.2f ", fStart, fStart+fLength) << endl;
129}
Note: See TracBrowser for help on using the repository browser.