PowerSpectrum.hh
Go to the documentation of this file.00001
00009 #ifndef __POWER_SPECTRUM_HH_
00010 #define __POWER_SPECTRUM_HH_
00011
00012
00013 #include <iostream>
00014 #include <iomanip>
00015 #include "rdTXOclass_2.h"
00016 #include <TH1F.h>
00017 #include <TString.h>
00018
00019
00020 #define MAXCHANNELS 2048
00021 using namespace std;
00022
00023 class PowerSpectrum {
00024 protected:
00025
00026 Int_t fNChannels;
00027 Int_t fNPts;
00028
00029 Float_t * fGains;
00030 Float_t fSamplingInterval;
00031 Float_t fADCScale;
00032
00033
00034 Float_t fNyquist;
00035 Float_t fDeltaFreq;
00036
00037
00038 TH1F ** fPS;
00039
00040
00041 TH1F ** fPSfull;
00042
00043
00044 TH1F ** fPulses;
00045
00046
00047 Float_t * fIntegral;
00048
00049
00050 TString fName;
00051
00052
00053 Int_t fMeasNumber;
00054
00055
00056 TString fHeaderFile;
00057
00058
00059 Float_t fAdcChannels;
00060 Float_t fFini;
00061 Float_t fFend;
00062
00064
00066 public:
00067
00068
00069 PowerSpectrum();
00070
00071
00072 PowerSpectrum(char * gainFile);
00073
00074
00075
00076 PowerSpectrum(Int_t nf);
00077
00078
00079 PowerSpectrum (const PowerSpectrum & ps);
00080
00081
00082 virtual ~PowerSpectrum();
00083
00084
00085 void Initialize();
00086
00087
00088 Int_t ReadGainsFromConfFile (char * confFile);
00089
00090
00091
00092
00093
00094 Int_t ReadGainsFromDataFile (char * inFile);
00095
00096
00097 Int_t ReadHeaderFile (char * headFile);
00098
00099
00100
00101 Int_t ReadTassoPS(char * inputFile);
00102
00103
00104
00105 Int_t ReadTassoPulses (char * inputFile);
00106
00107
00108
00109 Int_t ReadROOTPS(char * inputFile);
00110
00111
00112
00113 Int_t ReadROOTPulses (char * inputFile);
00114
00115
00116 Int_t ComputePowerSpectrum();
00117
00118
00119
00120
00121
00122 void Integral (Float_t fini = -1, Float_t fend=-1);
00123
00124
00125
00126
00127
00128
00129 TH1F * GetHistoIntegral (char * histoName, Float_t fini = -1, Float_t fend= -1);
00130
00132
00134
00135 inline TH1F ** GetPS() {return fPS;}
00136 inline TH1F ** GetPSfull() {return fPSfull;}
00137
00138
00139
00140 inline TH1F * GetPS (Int_t i)
00141 {if (i<fNChannels) {if (fPS) return fPS[i]; cout << "Error: Power Spectrum not initialized yet" << endl; return 0;} ; cout << "Error: channel " << i << " out of range " << endl;return 0;}
00142
00143 inline TH1F * GetPSfull (Int_t i)
00144 {if (i<fNChannels) {if (fPSfull) return fPSfull[i]; cout << "Error: Power Spectrum not initialized yet" << endl; return 0;} ; cout << "Error: channel " << i << " out of range " << endl;return 0;}
00145
00146 inline TH1F ** GetPulses() {return fPulses;}
00147
00148
00149 inline TH1F * GetPulse (Int_t i)
00150 {if (i<fNChannels) {if (fPulses) return fPulses[i]; cout << "Error: Pulses not initialized yet" << endl; return 0;} ; cout << "Error: channel " << i << " out of range " << endl; return 0;}
00151
00152 inline Int_t GetNChannels () {return fNChannels;}
00153 inline Int_t GetNPts () {return fNPts;}
00154
00155
00156 inline Float_t GetSamplingInterval () {return fSamplingInterval*1e3;}
00157
00158
00159 inline Float_t GetADCScale () {return fADCScale*1e3;}
00160
00161 inline Float_t GetGain(Int_t i) {if (i<fNChannels) {if (fGains) return fGains[i]; cout << "Error: Gains not initialized yet" << endl; return 0;}; cout << "Error: File " << fName.Data() << " channel " << i << " out of range " << endl;return 0;}
00162 inline Float_t GetIntegral(Int_t i) {if (fIntegral && i<fNChannels) return fIntegral[i]; cout << "Error: File " << fName.Data() << " channel " << i << " not integrated yet" << endl; return 0;}
00163 inline Float_t * GetIntegral() {return fIntegral; }
00164 inline Float_t GetNyquist() {return fNyquist;}
00165 inline Float_t GetFini () {return fFini;};
00166 inline Float_t GetFend () {return fFend;};
00167 inline const char * GetName () {return (fName.Data());};
00168 inline Int_t GetMeasNumber() {return fMeasNumber;};
00169
00171
00173
00174 inline Int_t SetPS (Int_t i, TH1F * histo)
00175 {if (i<fNChannels && i>=0) {fPS[i]=histo; return 0;} cout << "Error: channel " << i << " out of range " << endl;return 0;}
00176
00177 inline Int_t SetPSfull (Int_t i, TH1F * histo)
00178 {if (i<fNChannels && i>=0) {fPSfull[i]=histo; return 0;} cout << "Error: channel " << i << " out of range " << endl;return 0;}
00179
00180
00181 inline Int_t SetPulse (Int_t i, TH1F * histo)
00182 {if (i<fNChannels && i>=0) {fPulses[i]=histo; return 0;} ; cout << "Error: channel " << i << " out of range " << endl; return 0;}
00183
00184
00185 inline void SetSamplingInterval (Float_t s)
00186 {fSamplingInterval = s*1e-3; fNyquist = 0.5/fSamplingInterval;}
00187 inline void SetNPts (Int_t npts) {fNPts=npts; fDeltaFreq=fNyquist/(fNPts/2); if (fNyquist==0) cout << "Warning: Set sampling interval first" << endl;}
00188 inline void SetADCScale (Float_t s)
00189 {fADCScale = s*1e-3;}
00190
00191 inline void SetFini (Float_t f) {fFini = f;};
00192 inline void SetFend (Float_t f) {fFend = f;};
00193 inline void SetMeasNumber(Int_t no) {fMeasNumber = no;};
00194 inline void SetName(char * name) {fName = name;};
00195 inline void SetNChannels (Int_t nch) {fNChannels=nch;}
00196
00197
00198
00199 private:
00200
00201 };
00202
00203 #endif