FairRoot/PandaRoot
PndMdtWaveform.cxx
Go to the documentation of this file.
1 //=====================================================================
2 // PndMdtWaveform.cxx
3 //
4 // Class to hold waveforms created from Mdt Digis
5 //
6 // Software developed for the BaBar Detector at the SLAC B-Factory.
7 // Adapted for the PANDA experiment at GSI
8 //
9 // Jifeng Hu, hu@to.infn.it, Torino University
10 //-----------------------
11 
12 
13 
14 //---------------
15 // C++ Headers --
16 //---------------
17 
18 #include "PndMdtWaveform.h"
19 #include <iostream>
20 #include <algorithm>
21 #include "assert.h"
22 
23 using std::cout;
24 using std::endl;
25 
26 
27 //----------------
28 // Constructors --
29 //----------------
31  FairTimeStamp()
32  ,fTrackId(-1)
33  ,fDetectorId(-1)
34  ,fSignal(40,0.)
35 { }
36 
37 
38 
39 
40 PndMdtWaveform::PndMdtWaveform(Int_t trackId, Int_t detId, Double_t time, Bool_t isWire) :
41  fTrackId(trackId)
42  ,fDetectorId(detId)
43  ,fIsWireSig(isWire)
44  ,fSignal(40,0.)
45 {
46  SetTimeStamp(time);
47 }
48 
49 PndMdtWaveform::PndMdtWaveform(const PndMdtWaveform& copy):FairTimeStamp(copy),
50  fTrackId(copy.fTrackId)
51  ,fDetectorId ( copy.fDetectorId)
52  ,fIsWireSig(copy.fIsWireSig)
53  ,fSignal(copy.fSignal)
54 {
55  SetTimeStamp(copy.GetTimeStamp());
56  SetTimeStampError(copy.GetTimeStampError());
57 }
58 
60  if(this != &copy){
61  fTrackId = copy.fTrackId;
62  fDetectorId = copy.fDetectorId;
63  fSignal = copy.fSignal;
64  SetTimeStamp(copy.GetTimeStamp());
65  SetTimeStampError(copy.GetTimeStampError());
66  }
67  return *this;
68 }
69 
70 //--------------
71 // Destructor --
72 //--------------
73 
75 {
76  fSignal.clear();
77 }
78 
79 
80 //-------------
81 // Selectors --
82 //-------------
83 bool PndMdtWaveform::operator < (const PndMdtWaveform& otherWave) const
84 {
85  if(GetDetectorID() < otherWave.GetDetectorID())
86  return true;
87  if(GetDetectorID() > otherWave.GetDetectorID())
88  return false;
89  if(GetTimeStamp() < otherWave.GetTimeStamp())
90  return GetActiveTime() < otherWave.GetTimeStamp();
91  return false;
92 }
94  if(this != &otherWave)
95  {
96  Int_t k =0;
97  Int_t IDX = 0;
98  for(; (IDX < GetWaveformLength()) && (k < otherWave.GetWaveformLength()); ++ IDX){
99  if((GetTimeStamp() + IDX*10.) < otherWave.GetTimeStamp()){
100  continue;
101  }
102  fSignal[IDX] += otherWave.fSignal[k];
103  ++k;
104  }
105  if(k < otherWave.GetWaveformLength()){
106  fSignal.reserve( GetWaveformLength() + otherWave.GetWaveformLength() - (k+1));
107  for(; IDX < GetWaveformLength(); ++IDX, ++k){
108  fSignal.push_back(otherWave.fSignal[k]);
109  }
110  }
111  }
112  return *this;
113 }
114 
115 TGraphErrors* PndMdtWaveform::ToTGraph() const
116 {
117  //free this object outside
118  TGraphErrors* g = new TGraphErrors(fSignal.size());
119  for(size_t i = 0; i< fSignal.size(); ++i){
120  g->SetPoint(i, i*10, fSignal[i]);//every 10 nano seconds
121  g->SetPointError(i, 0, 0);
122  }
123  return g;
124 }
126 {
127  std::vector<Double_t>::const_iterator it = fSignal.begin();
128  std::vector<Double_t>::const_iterator it_end = fSignal.end();
129  cout<<"PndMdtWaveform::"<<fSignal.size()<<" :[";
130  for(; it != it_end; ++it)
131  out<<*it<<", ";
132  out<<"]"<<endl;
133  return out;
134 }
135 bool PndMdtWaveform::equal(FairTimeStamp* data) const
136 {
137  PndMdtWaveform* other = (PndMdtWaveform*)(data);
138  if(GetDetectorID() == other->GetDetectorID()) return true;
139  return false;
140 }
141 bool PndMdtWaveform::equal(FairTimeStamp* data)
142 {
143  PndMdtWaveform* other = (PndMdtWaveform*)(data);
144  if(GetDetectorID() == other->GetDetectorID()) return true;
145  return false;
146 }
147 
virtual std::ostream & Print(std::ostream &out=std::cout) const
Double_t GetActiveTime() const
PndMdtWaveform & operator+=(const PndMdtWaveform &otherWave)
Int_t i
Definition: run_full.C:25
Int_t GetDetectorID() const
Long_t GetWaveformLength() const
TFile * g
TGraphErrors * ToTGraph() const
std::vector< Double_t > fSignal
virtual bool operator<(const PndMdtWaveform &otherWave) const
Double_t
virtual bool equal(FairTimeStamp *data) const
TF1 * fSignal
TFile * out
Definition: reco_muo.C:20
virtual ~PndMdtWaveform()
virtual PndMdtWaveform & operator=(const PndMdtWaveform &copy)
ClassImp(PndAnaContFact)