AlcapDAQ  1
TOctalFADCIsland.h
Go to the documentation of this file.
1 #ifndef TOctalFADCIsland_h
2 #define TOctalFADCIsland_h
3 
4 #include <vector>
5 
13 class TOctalFADCIsland {
14  public:
15 
16  TOctalFADCIsland(int timestamp, const std::vector<int>& samples, int channel)
17  : fTime(timestamp), fData(samples), fChannel(channel){fmaxGauss = -1; fmaxbinGauss = -1; fchiSqrRed = -1;fPulseQuality = -1;}
18 
19  int GetTime() const { return fTime; }
20  int GetNSamples() const { return fData.size(); }
21  int GetSample(int i) const { return fData[i]; }
22  int GetFADCChannel() const { return fChannel; }
23 
24 
25 
26  std::vector<int>& GetSampleVector() { return fData; }
27 
28  int GetMax(int first = 0) const { return GetMax(first,fData.size()-1); } //Make these two steps so you only need one implementation. Giving no argument just finds the maximum. Still, you can ask for the max between "first" and "last" sample
29  int GetMax(int first, int last) const;
30  int GetMaxBin(int first = 0) const { return GetMaxBin(first, fData.size()-1);}
31  int GetMaxBin(int first, int last) const;
32  int GetMaxBinBlockTime(int first = 0) const {return GetMaxBinBlockTime(first, fData.size()-1);}
33  int GetMaxBinBlockTime(int first, int last) const;
34 
35 
36  double GetTimeNs() const; //Returns fTime in ns This time is used in the event display
37 
38 
39 
40 
41 //Added by Frederik, oct/nov 2011. Written in function of the Ge and NaI analysis, still can be used more general
42 
43  double GetAverageMax(int nAv, int first = 0) const { return GetAverageMax(nAv,first,fData.size()-1); } //First argument is number of point around the maximum you want to average "0" should give the same result as the GetMax method, "2" averages the maximum with the sample left and right of it, i.e. an average of 3 points
44  double GetAverageMax(int nAv, int first, int last) const;
45  bool GoodPulse(int shapTime, double clockPeriod, int level) ; // check if it is a "good" FADC pulse. The level indicates how many of the conditions will be checked
46  bool GoodPulse(int shapTime, double clockPeriod, int pedestal, int runnr, int level, int channel) ; // custom for weird overshoot samples of the Ge detector
47  int GetCFBlockTime(int first = 0) const {return GetCFBlockTime(first, fData.size()-1);}
48  int GetCFBlockTime(int first, int last) const;
49  int GetCFBin(int first = 0) const {return GetCFBin(first, fData.size()-1);}
50  int GetCFBin(int first, int last) const;
51 
52  double GetAverage(int first = 0) const {return GetAverage(first, fData.size()-1);}
53  double GetAverage(int first,int last) const; //Give the average value between two boundaries. It is the user responsibility to make sure that "first" and "last" are ok. Use GetNSamples for that. The function will return -1 for arguments out of range
54  double GetIntegral(int first = 0) const {return GetIntegral(first, fData.size()-1);}
55  double GetIntegral(int first,int last) const;
56 
57  int FitGauss(int left, int right, int shapTime, double clockPeriod, int pedestal);//Call this function first to do the fits before asking for the max etc ...
58  double GetMaxGauss() const {return fmaxGauss;}
59  double GetMaxBinGauss() const {return fmaxbinGauss;}
60  double GetChiSqrRed() const {return fchiSqrRed;}
61 
62  void SetMaxGauss(double value) {fmaxGauss = value;}
64  void SetChiSqrRed(double value) {fchiSqrRed = value;}
65 
67  int GetPulseQuality() const {return fPulseQuality;}
68 
69 
70  struct TimeSortFADCIslands {
71  bool operator()(const TOctalFADCIsland& i1, const TOctalFADCIsland& i2) {
72  int t1 = i1.GetTime();
73  int t2 = i2.GetTime();
74  return t1 < t2;
75  }
76  };
77 
79  bool operator() (const TOctalFADCIsland& a, double time) {
80  return a.GetTimeNs() < time;
81  }
82  bool operator() (double time,const TOctalFADCIsland& b) {
83  return time < b.GetTimeNs();
84  }
85  };
86 
87  private:
89  int fPulseQuality; // -1 is an unchecked pulse, 0 is an accepted pulse, 1,2,.... represent the level at which the pulse/island is rejected
90  std::vector<int> fData;
92  //TH1I* island;
93 };
94 
95 #endif