GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BaseCalib.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2006 by Christophe Theisen & Olivier Stezowski *
3  * christophe.theisen(AT)cea.fr, stezow(AT)ipnl.in2p3.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
23 #ifndef GW_BASECALIB_H
24 #define GW_BASECALIB_H
25 
26 //#include<stdio>
27 #include<fstream>
28 #include<iostream>
29 #include<iomanip>
30 using namespace std;
31 
32 #ifndef ROOT_TH1_H
33 #include "TH1.h"
34 #endif
35 #ifndef ROOT_TGRAPHERRORS_H
36 #include "TGraphErrors.h"
37 #endif
38 #ifndef ROOT_TF1_H
39 #include "TF1.h"
40 #endif
41 #ifndef GW_H1CALIBRATOR_H
42 #include "H1Calibrator.h"
43 #endif
44 
45 namespace Gw {
46 
56 class BaseCalib {
57 
58 public:
59  BaseCalib();
60  virtual ~BaseCalib();
61 
63  void AlignMax(TH1 *histo, TF1 *function, const Double_t AlignValue,
64  const Bool_t invert=false, const Double_t xmin=0, const Double_t xmax=0);
65 
67  void AlignMax(TH1 *histo, TF1 *function, const Double_t AlignValue,
68  const Double_t ProportionalCoef, const Bool_t invert=false, const Double_t xmin=0, const Double_t xmax=0);
69 
70  void SetPoint(const Int_t index, const Double_t channel, const Double_t energy) { fTabulated[index] = energy; fRaw[index] = channel; }
71  void AddPoint(const Double_t channel, const Double_t energy);
72 
74  void SetEnergy(const Int_t index, const Double_t energy) { fTabulated[index] = energy; }
75  void SetChannel(const Int_t index, const Double_t channel) { fRaw[index] = channel; }
76 
77  Double_t GetEnergy(const Int_t index) const { return fTabulated[index]; }
78  Double_t GetChannel(const Int_t index) const { return fRaw[index]; }
79 
80  void Calibrate(TF1 *function) const;
81  void Calibrate(const char* filename, TF1 *function);
82  void Calibrate(TF1 *function, const Int_t nbpoints, const Double_t *raw, const Double_t *tabulated);
83  void Calibrate(Int_t dimension);
84 
85  void DrawResults(const TF1 *function) const;
86 
87  static void CheckCalibration(TH1 *histo, const Double_t value, Double_t xmin=-1111, Double_t xmax=-1111, const Int_t color=2);
88  static void CheckCalibration(TH1 *histo, const Int_t nbvalue, const Double_t *values, Double_t xmin=-1111, Double_t xmax=-1111, const Int_t color=2);
89  static void CheckCalibration(TH1 *histo, const char *SourceName, Double_t xmin=-1111, Double_t xmax=-1111, const Int_t color=2);
90 protected:
91 
92  TArrayD fTabulated;
93  TArrayD fRaw;
94 
96 
98  ClassDef(BaseCalib,0); // a BaseCalib
99 
100 };
101 
102 }
103 
104 #endif
void SetPoint(const Int_t index, const Double_t channel, const Double_t energy)
Definition: BaseCalib.h:70
Double_t GetEnergy(const Int_t index) const
Definition: BaseCalib.h:77
TArrayD fTabulated
Definition: BaseCalib.h:92
Double_t GetChannel(const Int_t index) const
Definition: BaseCalib.h:78
UInt_t value[MaxValue]
Definition: ReadDaqAlone.C:29
TH1F * histo[MaxValue]
Definition: ReadDaqAlone.C:31
BaseCalib is a tool class.
Definition: BaseCalib.h:56
TArrayD fRaw
Definition: BaseCalib.h:93
void SetChannel(const Int_t index, const Double_t channel)
Definition: BaseCalib.h:75
H1Calibrator fCalibrator
Definition: BaseCalib.h:95
H1Calibrator is a service class in order to calibrate a TH1 The raw histogram must never be changed T...
Definition: H1Calibrator.h:58
void SetEnergy(const Int_t index, const Double_t energy)
Get/Set energy/channel.
Definition: BaseCalib.h:74
header file for the calibration facility