TGraphAligned.h
1 #ifndef _TGRAPH_ALIGNED_H
2 #define _TGRAPH_ALIGNED_H
3 
4 #include "TGraph.h"
5 
18 class TGraphAligned : public TGraph {
19 
20 
22 #define TGRAPH_ALIGNED_ALIGNMENT 32
23  typedef Double_t * aligned_double_v __attribute__((aligned (TGRAPH_ALIGNED_ALIGNMENT)));
24  //Have to reimplement all interesting constructors, unfortunately, since we
25  //unfortunately cannot call the TGraph constructor and have it call our
26  //implementation of CtorAllocate
27 
28  public:
30  TGraphAligned();
31 
33  TGraphAligned(Int_t n);
34  TGraphAligned & operator=(const TGraphAligned&);
36  TGraphAligned(Int_t n, const Double_t * x, const Double_t * y);
37 
40  TGraphAligned(const TGraph &);
41 
42 
43  double * getMoments(int i, double origin, double * moments = 0) const;
44 
45  void dBize(double mindB=-200);
46  void undBize();
47 
48 
49  void zeroMean();
50 
51  /* just copies the numbers from g*/
52  void adopt(const TGraphAligned * g);
53 
54 
55 
56  //Shift the values by a number of samples.
57  //by default will set any new values to zero, unless wrap is true
58  void shift(int nsamples, bool zero = true);
59 
60  void getMeanAndRMS(Double_t * mean, Double_t * rms, Int_t istart = 0, Int_t iend = -1) const;
61  Double_t getSumV2(Int_t istart = 0, Int_t iend = -1) const;
62 
63  Double_t peakVal(Int_t * location = 0, Int_t istart= 0, Int_t iend = -1, bool abs = false) const;
64  Double_t pk2pk(Int_t nthMax = 0, Int_t nthMin = 0,Int_t * location_max = 0, Int_t * location_min = 0, Int_t istart= 0, Int_t iend = -1) const;
65 
67  TH1 * valueHist(int nbins = 100, const double * weights =0, TH1 * out = 0 ) const;
68 
69  void setPlottingLimits(double mult = 1.1, bool sym = true, double dt_from_peak =-1);
70 
71  aligned_double_v GetX() const { return fX; }
72  aligned_double_v GetY() const { return fY; }
73 
74  void setBelow(double val, bool abso=true, double to=0);
75 
77  virtual ~TGraphAligned();
78 
79  protected:
80 
81  virtual Double_t **AllocateAlignedArrays(Int_t Narrays, Int_t arraySize);
82  inline Double_t **Allocate(Int_t newsize) { return AllocateAlignedArrays(2, newsize); }
83  virtual Bool_t CtorAllocate (void);
84 
85  //needs to be reimplement to avoid delete[] on memalign-allocated pointer, which Valgrind will perhaps unjustly complain about
86  virtual void CopyAndRelease(Double_t ** newarrays, Int_t ibegin, Int_t iend, Int_t obegin);
87 
88  ClassDef(TGraphAligned,1);
89 
90 };
91 
92 
93 #endif
94 
95 
96 
97 
virtual ~TGraphAligned()
TH1 * valueHist(int nbins=100, const double *weights=0, TH1 *out=0) const