]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG3/dielectron/AliDielectronSignalBase.h
Updates and additions: Classes for signal and spectrum extraction; saving of
[u/mrichter/AliRoot.git] / PWG3 / dielectron / AliDielectronSignalBase.h
CommitLineData
572b0139 1#ifndef ALIDIELECTRONSIGNALBASE_H
2#define ALIDIELECTRONSIGNALBASE_H
3
4/* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
6
7//#############################################################
8//# #
9//# Class AliDielectronSignalBase #
10//# Manage Cuts on the legs of the pair #
11//# #
12//# Authors: #
13//# Anton Andronic, GSI / A.Andronic@gsi.de #
14//# Ionut C. Arsene, GSI / I.C.Arsene@gsi.de #
15//# Julian Book, Uni Ffm / Julian.Book@cern.ch #
16//# Frederick Kramer, Uni Ffm, / Frederick.Kramer@cern.ch #
17//# Magnus Mager, CERN / Magnus.Mager@cern.ch #
18//# WooJin J. Park, GSI / W.J.Park@gsi.de #
19//# Jens Wiechula, Uni HD / Jens.Wiechula@cern.ch #
20//# #
21//#############################################################
22
23#include <TNamed.h>
24#include <TVectorT.h>
25#include <TMath.h>
26
27class TObjArray;
28class TPaveText;
29class TH1;
30
31class AliDielectronSignalBase : public TNamed {
32public:
33 AliDielectronSignalBase();
34 AliDielectronSignalBase(const char*name, const char* title);
35
36 virtual ~AliDielectronSignalBase();
37
38
39 void SetIntegralRange(Double_t min, Double_t max) {fIntMin=min;fIntMax=max;}
40
41 void SetSignal(Double_t val, Double_t valErr) {fValues(0)=val; fErrors(0)=valErr;}
42 void SetBackground(Double_t val, Double_t valErr) {fValues(1)=val; fErrors(1)=valErr;}
43 void SetSignificance(Double_t val, Double_t valErr) {fValues(2)=val; fErrors(2)=valErr;}
44 void SetSignalOverBackground(Double_t val, Double_t valErr) {fValues(3)=val; fErrors(3)=valErr;}
45
46 const TVectorD& GetValues() const {return fValues;}
47 const TVectorD& GetErrors() const {return fErrors;}
48
49 Double_t GetIntegralMin() const { return fIntMin; }
50 Double_t GetIntegralMax() const { return fIntMax; }
51
52 Double_t GetSignal() {return fValues(0);}
53 Double_t GetBackground() {return fValues(1);}
54 Double_t GetSignificance() {return fValues(2);}
55 Double_t GetSignalOverBackground() {return fValues(3);}
56
57 Double_t GetSignalError() {return fErrors(0);}
58 Double_t GetBackgroundError() {return fErrors(1);}
59 Double_t GetSignificanceError() {return fErrors(2);}
60 Double_t GetSignalOverBackgroundError() {return fErrors(3);}
61
62 void GetSignal(Double_t &val, Double_t &valErr) {val=fValues(0); valErr=fErrors(0);}
63 void GetBackground(Double_t &val, Double_t &valErr) {val=fValues(1); valErr=fErrors(1);}
64 void GetSignificance(Double_t &val, Double_t &valErr) {val=fValues(2); valErr=fErrors(2);}
65 void GetSignalOverBackground(Double_t &val, Double_t &valErr) {val=fValues(3); valErr=fErrors(3);}
66
67 /**
68 This function needs to be implemented by the signal extraction classes.
69
70 The signal extraction is done on the mass spectra.
71 The TObjArray should contain the Inv. Mass spectra of the 10 possible combinations
72 for single and mixed events defined in AliDielectron.cxx
73 In the referece TVectorDs the values and value errors of the result should be stored:
74 Parameter - 0: Signal entries
75 1: Background entries
76 2: Significance ( S/sqr(S+B) )
77 3: Signal/Background
78
79 It is enough to calculate the signal and background and then call
80 SetSignificanceAndSOB(TVectorD &values, TVectorD &errors)
81 Please also read the description there!!!
82 */
83 virtual void Process(TObjArray * const /*arrhist*/) = 0;
84
85protected:
86
87 void SetSignificanceAndSOB();
88 TPaveText* DrawStats(Double_t x1=0., Double_t y1=0., Double_t x2=0., Double_t y2=0.);
89 void Reset() {fValues.Zero(); fErrors.Zero();}
90
91private:
92 TVectorD fValues; // values
93 TVectorD fErrors; // value errors
94
95 Double_t fIntMin; // signal extraction range min
96 Double_t fIntMax; // signal extraction range max
97
98 AliDielectronSignalBase(const AliDielectronSignalBase &c);
99 AliDielectronSignalBase &operator=(const AliDielectronSignalBase &c);
100
101 ClassDef(AliDielectronSignalBase,2) // Dielectron SignalBase
102};
103
104//
105// Inline functions
106//
107
108inline void AliDielectronSignalBase::SetSignificanceAndSOB()
109{
110 //
111 // calculate significance and signal over background from values
112 // it is expected that:
113 // - 'values' and 'errors' have the size 4
114 // - Parameters 0 are given: signal and signal error
115 // - Parameters 1 are given: background and background error
116 // - Optionally parameter 2 can be given: signal+background and its error
117 //
118 // The calculated significance and S/B and the corresponding errors
119 // are written in parameters 2 and 3, the first two parameters (signal and background)
120 // stay untouched
121
122 Double_t signal=fValues(0), signal_err=fErrors(0);
123 Double_t background=fValues(1), background_err=fErrors(1);
124 Double_t sigPlusBack=fValues(2), sigPlusBack_err=fErrors(2);
125 Double_t significance=0, significance_err=0;
126 Double_t sob=0, sob_err=0;
127
128 if (sigPlusBack<1e-20){
129 //calculate signal plus background
130 sigPlusBack=signal+background;
131 sigPlusBack_err=TMath::Sqrt( signal_err*signal_err + background_err*background_err );
132 }
133
134 if (sigPlusBack>1e-30){
135
136 significance=signal/TMath::Sqrt(sigPlusBack);
137
138 significance_err=TMath::Sqrt((signal_err/signal)*(signal_err/signal)+
139 (0.5*sigPlusBack_err/sigPlusBack)*(0.5*sigPlusBack_err/sigPlusBack)
140 )*significance;
141
142 }
143
144 if (background>1e-30){
145 sob=signal/background;
146 sob_err=TMath::Sqrt((signal_err/signal)*(signal_err/signal)+
147 (background_err/background)*(background_err/background))*sob;
148 }
149
150 fValues(2)=significance;
151 fErrors(2)=significance_err;
152
153 fValues(3)=sob;
154 fErrors(3)=sob_err;
155}
156
157#endif