simple-tof-analysis
 All Classes Namespaces Functions Variables Groups Pages
TSPOTMgr.h
1 /*
2  * TSPOTMgr.h
3  *
4  * Created on: Nov 8, 2014
5  * Author: Silvestro di Luise
6  * Silvestro.Di.Luise@cern.ch
7  *
8  */
9 
10 #ifndef TSPOTMGR_H_
11 #define TSPOTMGR_H_
12 
13 #include <TMath.h>
14 
15 #include "StringUtils.h"
16 
17 #include "MessageMgr.h"
18 
19 #include "TSNamed.h"
20 
21 
22 /*
23  *
24  */
25 
26 class TSPOTMgr: public TSNamed {
27 
28 public:
29  TSPOTMgr() { Init(); }
30  virtual ~TSPOTMgr(){};
31 
32  double GetNativePOTD() const;
33  double GetPOTD() const;
34  float GetPOT() const {return fPOT;}
35  float GetNativePOT() const {return fPOTnative;}
36  float GetNativePOTPower() const {return fPOTnative_pow;}
37  float GetPOTPower() const {return fPOTpower;}
38  float GetPOTScaling() const {return fPOTscaling;}
39  TString GetPOTLabel() const {return fPOTlabel;}
40  TString GetNativePOTLabel() const {return fPOTNativeLabel;}
41 
42  void Init();
43 
44  void SetNativePOT(float POT, float Power=20);
45  void SetPOT(float POT, float Power=20);
46  void Restore();
47 
48 private:
49 
50  float fPOT;
51  float fPOTnative;
52  float fPOTpower;
53  float fPOTnative_pow;
54  float fPOTscaling;
55 
56  TString fPOTlabel;
57  TString fPOTNativeLabel;
58 
59  inline void fBuildPOTNames();
60 };
61 
62 
63 
64 inline double TSPOTMgr::GetPOTD() const
65 {
66 
67  double P = fPOT*TMath::Power(10,fPOTpower);
68 
69  return P;
70 }
71 
72 
73 inline double TSPOTMgr::GetNativePOTD() const
74 {
75 
76  double P = fPOTnative*TMath::Power(10,fPOTnative_pow);
77 
78  return P;
79 }
80 
81 inline void TSPOTMgr::Init()
82 {
83 
84 
85  SetNativePOT(1,20);//1e20
86 
87  fBuildPOTNames();
88 }
89 
90 inline void TSPOTMgr::SetNativePOT(float POT, float Power)
91 {
98  if(POT <= 0 || Power<=0 ){
99  MSG::ERROR(__FILE__,"::",__FUNCTION__," Invalid inputs ");
100  MSG::ERROR("POT: ",POT,"e^",Power);
101  return;
102  }
103 
104  fPOTscaling = 1;
105 
106  fPOTnative = POT;
107  fPOT = POT;
108 
109  fPOTpower = Power;
110  fPOTnative_pow = fPOTpower;
111 
112  fBuildPOTNames();
113 
114 }
115 
116 
117 
118 inline void TSPOTMgr::Restore(){
119 
120  SetNativePOT( GetNativePOT(), GetNativePOTPower() );
121 
122 }
123 
124 
125 inline void TSPOTMgr::SetPOT(float POT, float Power)
126 {
127 
128 
129  if(POT <= 0 || Power <= 0 ){
130  MSG::ERROR(__FILE__,"::",__FUNCTION__," Invalid inputs");
131  return;
132  }
133 
134  //scaling factor w.r.t. current normalization
135 
136  fPOTscaling = (POT/fPOT)*TMath::Power(10,Power-fPOTpower);
137 
138  fPOT = POT;
139  fPOTpower = Power;
140 
141  fBuildPOTNames();
142 
143 }
144 
145 
146 
147 inline void TSPOTMgr::fBuildPOTNames()
148 {
149 
150 
151  fPOTNativeLabel = "Native POT: ";
152  fPOTNativeLabel += StringUtils::ToString(fPOTnative);
153  fPOTNativeLabel +="x10^{"; fPOTNativeLabel+=fPOTpower; fPOTNativeLabel+="}";
154 
155 
156  fPOTlabel = "POT: ";
157  fPOTlabel += StringUtils::ToString(fPOT);
158  fPOTlabel +="x10^{"; fPOTlabel+=fPOTpower; fPOTlabel+="}";
159 
160 
161 }
162 
163 #endif /* TSPOTMGR_H_ */
void SetNativePOT(float POT, float Power=20)
Definition: TSPOTMgr.h:90
Definition: TSNamed.h:38
Definition: TSPOTMgr.h:26