]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGDQ/dielectron/AliDielectronSignalBase.h
update from pr task : sjena
[u/mrichter/AliRoot.git] / PWGDQ / 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
bc75eeb5 23
572b0139 24#include <TNamed.h>
25#include <TVectorT.h>
26#include <TMath.h>
37a6f270 27#include <TH1F.h>
28#include <TF1.h>
572b0139 29
30class TObjArray;
31class TPaveText;
572b0139 32
33class AliDielectronSignalBase : public TNamed {
34public:
bc75eeb5 35 enum EBackgroundMethod {
5720c765 36 kFittedMC = 0,
ac390e40 37 kFitted,
bc75eeb5 38 kLikeSign,
45b2b1b8 39 kLikeSignArithm,
b9d223bb 40 kLikeSignRcorr,
41 kLikeSignArithmRcorr,
37a6f270 42 kLikeSignFit,
2a14a7b1 43 kEventMixing,
37a6f270 44 kEventMixingFit,
2a14a7b1 45 kRotation
bc75eeb5 46 };
47
37a6f270 48 enum ESignalExtractionMethod {
49 kBinCounting = 0,
50 kMCScaledMax,
51 kMCScaledInt,
52 kMCFitted,
53 kCrystalBall,
54 kGaus
55 };
56
572b0139 57 AliDielectronSignalBase();
58 AliDielectronSignalBase(const char*name, const char* title);
bc75eeb5 59
572b0139 60 virtual ~AliDielectronSignalBase();
37a6f270 61
62 void SetMCSignalShape(TH1F* hist) { fgHistSimPM=hist; }
63 void SetParticleOfInterest(Int_t pdgcode) { fPOIpdg=pdgcode; }
572b0139 64 void SetIntegralRange(Double_t min, Double_t max) {fIntMin=min;fIntMax=max;}
bc75eeb5 65 void SetFitRange(Double_t min, Double_t max) {fFitMin=min; fFitMax=max;}
66 void SetRebin(Int_t factor) {fRebin = factor;}
67 void SetMethod(EBackgroundMethod method) {fMethod = method;}
b9d223bb 68 Int_t GetMethod() const { return (Int_t)fMethod; }
37a6f270 69 void SetExtractionMethod(ESignalExtractionMethod method) {fPeakMethod = method;}
70 Int_t GetExtractionMethod() const { return (Int_t)fPeakMethod; }
bc75eeb5 71
572b0139 72 const TVectorD& GetValues() const {return fValues;}
73 const TVectorD& GetErrors() const {return fErrors;}
74
bc75eeb5 75 Double_t GetIntegralMin() const { return fIntMin; }
76 Double_t GetIntegralMax() const { return fIntMax; }
77 Double_t GetSignal() const { return fValues(0);}
78 Double_t GetSignalError() const { return fErrors(0);}
79 Double_t GetBackground() const { return fValues(1);}
80 Double_t GetBackgroundError() const { return fErrors(1);}
81 Double_t GetSignificance() const { return fValues(2);}
82 Double_t GetSignificanceError() const { return fErrors(2);}
83 Double_t GetSB() const { return fValues(3);}
84 Double_t GetSBError() const { return fErrors(3);}
85 Double_t GetMass() const { return fValues(4);}
86 Double_t GetMassError() const { return fErrors(4);}
87 Double_t GetMassWidth() const { return fValues(5);}
88 Double_t GetMassWidthError() const { return fErrors(5);}
37a6f270 89 static const char* GetValueName(Int_t i) { return (i>=0&&i<6)?fgkValueNames[i]:""; }
90
2a14a7b1 91 TH1* GetSignalHistogram() const {return fHistSignal;}
92 TH1* GetBackgroundHistogram() const {return fHistBackground;}
93 TH1* GetUnlikeSignHistogram() const {return fHistDataPM;}
ac390e40 94 TH1* GetRfactorHistogram() const {return fHistRfactor;}
37a6f270 95 TObject* GetPeakShape() const {return fgPeakShape;}
ac390e40 96
554e40f8 97 void SetScaleRawToBackground(Double_t intMin, Double_t intMax) { fScaleMin=intMin; fScaleMax=intMax; }
fd6ebd85 98 void SetScaleRawToBackground(Double_t intMin, Double_t intMax, Double_t intMin2, Double_t intMax2) { fScaleMin=intMin; fScaleMax=intMax; fScaleMin2=intMin2; fScaleMax2=intMax2; }
37a6f270 99 Double_t GetScaleMin() const { return fScaleMin; }
100 Double_t GetScaleMax() const { return fScaleMax; }
101 Double_t GetScaleMin2() const { return fScaleMin2; }
102 Double_t GetScaleMax2() const { return fScaleMax2; }
103 Double_t GetScaleFactor() const { return fScaleFactor; }
104 Int_t GetParticleOfInterest() const { return fPOIpdg; }
ac390e40 105
106 void SetMixingCorrection(Bool_t mixcorr=kTRUE) { fMixingCorr=mixcorr; }
2a14a7b1 107
554e40f8 108 static Double_t ScaleHistograms(TH1* histRaw, TH1* histBackground, Double_t intMin, Double_t intMax);
fd6ebd85 109 static Double_t ScaleHistograms(TH1* histRaw, TH1* histBackground, Double_t intMin, Double_t intMax, Double_t intMin2, Double_t intMax2);
2a14a7b1 110
bc75eeb5 111 virtual void Print(Option_t *option="") const;
572b0139 112
113 /**
114 This function needs to be implemented by the signal extraction classes.
bc75eeb5 115 Here all the work should be done.
572b0139 116
117 The signal extraction is done on the mass spectra.
118 The TObjArray should contain the Inv. Mass spectra of the 10 possible combinations
119 for single and mixed events defined in AliDielectron.cxx
572b0139 120 */
121 virtual void Process(TObjArray * const /*arrhist*/) = 0;
37a6f270 122 TObject* DescribePeakShape(ESignalExtractionMethod method, Bool_t replaceValErr=kFALSE, TH1F *mcShape=0x0);
123
bc75eeb5 124protected:
572b0139 125
2a14a7b1 126 TH1 *fHistSignal; // histogram of pure signal
127 TH1 *fHistBackground; // histogram of background (fitted=0, like-sign=1, event mixing=2)
128 TH1 *fHistDataPM; // histogram of selected +- pair candidates
129 TH1 *fHistDataPP; // histogram of selected ++ pair candidates
130 TH1 *fHistDataMM; // histogram of selected -- pair candidates
5720c765 131 TH1 *fHistDataME; // histogram of selected +- pair candidates from mixed event
ac390e40 132 TH1 *fHistRfactor; // histogram of R factors
37a6f270 133
5720c765 134 TVectorD fValues; // values
135 TVectorD fErrors; // value errors
bc75eeb5 136
5720c765 137 Double_t fIntMin; // signal extraction range min
138 Double_t fIntMax; // signal extraction range max
139 Double_t fFitMin; // fit range lowest inv. mass
140 Double_t fFitMax; // fit range highest inv. mass
bc75eeb5 141
5720c765 142 Int_t fRebin; // histogram rebin factor
143 EBackgroundMethod fMethod; // method for background substraction
144 Double_t fScaleMin; // min for scaling of raw and background histogram
145 Double_t fScaleMax; // max for scaling of raw and background histogram
fd6ebd85 146 Double_t fScaleMin2; // min for scaling of raw and background histogram
147 Double_t fScaleMax2; // max for scaling of raw and background histogram
5720c765 148 Double_t fScaleFactor; // scale factor of raw to background histogram scaling
ac390e40 149 Bool_t fMixingCorr; // switch for bin by bin correction with R factor
37a6f270 150
151 ESignalExtractionMethod fPeakMethod; // method for peak description and signal extraction
152 static TObject *fgPeakShape; // histogram or function used to describe the extracted signal
153
5720c765 154 Bool_t fProcessed; // flag
37a6f270 155 Int_t fPOIpdg; // pdg code particle of interest
156 static TH1F* fgHistSimPM; // simulated peak shape
157
5720c765 158 void SetSignificanceAndSOB(); // calculate the significance and S/B
37a6f270 159 void SetFWHM(); // calculate the fwhm
160 static const char* fgkValueNames[6]; //value names
161
572b0139 162 TPaveText* DrawStats(Double_t x1=0., Double_t y1=0., Double_t x2=0., Double_t y2=0.);
bc75eeb5 163
572b0139 164 AliDielectronSignalBase(const AliDielectronSignalBase &c);
165 AliDielectronSignalBase &operator=(const AliDielectronSignalBase &c);
166
37a6f270 167 ClassDef(AliDielectronSignalBase,4) // base and abstract class for signal extraction
572b0139 168};
169
572b0139 170inline void AliDielectronSignalBase::SetSignificanceAndSOB()
171{
172 //
bc75eeb5 173 // Calculate S/B and significance
572b0139 174 //
bc75eeb5 175 // Signal/Background
176 fValues(3) = (fValues(1)>0 ? fValues(0)/fValues(1) : 0);
177 Float_t epsSig = (fValues(0)>0 ? fErrors(0)/fValues(0) : 0);
178 Float_t epsBknd = (fValues(1)>0 ? fErrors(1)/fValues(1) : 0);
179 fErrors(3) = fValues(3)*TMath::Sqrt(epsSig*epsSig + epsBknd*epsBknd);
180 // Significance
181 fValues(2) = ((fValues(0)+fValues(1))>0 ? fValues(0)/TMath::Sqrt(fValues(0)+fValues(1)) : 0);
e4339752 182 Float_t s = (fValues(0)>0?fValues(0):0); Float_t b = fValues(1);
37a6f270 183 Float_t se = fErrors(0); Float_t be = fErrors(1);
184 // fErrors(2) = ((s+b)>0 ? TMath::Sqrt((s*(s+2*b)*(s+2*b)+b*s*s)/(4*TMath::Power(s+b,3))) : 0); // old implementation
185 fErrors(2) = ((s+b)>0 ? fValues(2)*TMath::Sqrt(be*be + TMath::Power(se*(s+2*b)/s, 2)) / 2 / (s+b) : 0);
186}
187
188inline void AliDielectronSignalBase::SetFWHM()
189{
190 // calculate the fwhm
191 if(!fgPeakShape) return;
192
193 // case for TF1
194 if(fgPeakShape->IsA() == TF1::Class()) {
195 TF1* fit = (TF1*) fgPeakShape->Clone("fit");
196 TF1* pfit = (TF1*) fit->Clone("pfit");
197 TF1* mfit = (TF1*) fit->Clone("mfit");
198 for (Int_t i=0; i<fit->GetNpar(); i++) {
199 pfit->SetParameter(i,fit->GetParameter(i) + fit->GetParError(i));
200 mfit->SetParameter(i,fit->GetParameter(i) - fit->GetParError(i));
201 }
202 Double_t maxX = fit->GetMaximumX();
203 Double_t maxY = fit->GetHistogram()->GetMaximum();
204 Double_t xAxMin = fit->GetXmin();
205 Double_t xAxMax = fit->GetXmax();
206 // fwhms
207 Double_t fwhmMin = fit->GetX(.5*maxY, xAxMin, maxX);
208 Double_t fwhmMax = fit->GetX(.5*maxY, maxX, xAxMax);
209 Double_t pfwhmMin = pfit->GetX(.5*maxY, xAxMin, maxX);
210 Double_t pfwhmMax = pfit->GetX(.5*maxY, maxX, xAxMax);
211 Double_t mfwhmMin = mfit->GetX(.5*maxY, xAxMin, maxX);
212 Double_t mfwhmMax = mfit->GetX(.5*maxY, maxX, xAxMax);
213 Double_t pError = TMath::Abs( (fwhmMax-fwhmMin) - (pfwhmMax-pfwhmMin) );
214 Double_t mError = TMath::Abs( (fwhmMax-fwhmMin) - (mfwhmMax-mfwhmMin) );
215 fValues(5) = (fwhmMax-fwhmMin);
216 fErrors(5) = (pError>=mError ? pError : mError);
217 delete fit;
218 delete pfit;
219 delete mfit;
220 }
221 else if(fgPeakShape->IsA() == TH1F::Class()) {
222 // th1 calculation
223 TH1F *hist = (TH1F*) fgPeakShape->Clone("hist");
224 Int_t bin1 = hist->FindFirstBinAbove(hist->GetMaximum()/2);
225 Int_t bin2 = hist->FindLastBinAbove(hist->GetMaximum()/2);
226 fValues(5) = hist->GetBinCenter(bin2) - hist->GetBinCenter(bin1);
227 fErrors(5) = 0.0; // not defined
228 delete hist;
229 }
230
572b0139 231}
232
233#endif