1 /*************************************************************************
2 * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 ///////////////////////////////////////////////////////////////////////////
17 // Dielectron SignalBase //
21 Base class for signal extraction from a histogram or an array of histograms
22 The histogram is assumed to be an inv. mass spectrum,
23 the array of histograms is assumed to be an array with inv. mass histograms
24 resulting from single and mixed events, as defined in AliDielectron.cxx
28 ///////////////////////////////////////////////////////////////////////////
32 #include <TPaveText.h>
34 #include "AliDielectronSignalBase.h"
36 ClassImp(AliDielectronSignalBase)
38 AliDielectronSignalBase::AliDielectronSignalBase() :
60 // Default Constructor
64 //______________________________________________
65 AliDielectronSignalBase::AliDielectronSignalBase(const char* name, const char* title) :
91 //______________________________________________
92 AliDielectronSignalBase::~AliDielectronSignalBase()
97 if(fHistSignal) delete fHistSignal;
98 if(fHistBackground) delete fHistBackground;
99 if (fHistDataPP) delete fHistDataPP;
100 if (fHistDataPM) delete fHistDataPM;
101 if (fHistDataMM) delete fHistDataMM;
102 if (fHistDataME) delete fHistDataME;
106 //______________________________________________
107 TPaveText* AliDielectronSignalBase::DrawStats(Double_t x1/*=0.*/, Double_t y1/*=0.*/, Double_t x2/*=0.*/, Double_t y2/*=0.*/)
110 // Draw extracted values in a TPaveText
111 // with the corners x1,y2,x2,y2
113 if (TMath::Abs(x1)<1e-20&&TMath::Abs(x2)<1e-20){
119 TPaveText *t=new TPaveText(x1,y1,x2,y2,"brNDC");
120 t->SetFillColor(kWhite);
123 t->AddText(Form("Range : %.2f - %.2f GeV/c^{2}", fIntMin, fIntMax));
124 t->AddText(Form("Signal : %.1f #pm %.1f", fValues(0), fErrors(0)));
125 t->AddText(Form("Backgnd: %.1f #pm %.1f", fValues(1), fErrors(1)));
126 t->AddText(Form("Signif.: %.2f #pm %.2f", fValues(2), fErrors(2)));
127 t->AddText(Form("S/B : %.2f #pm %.2f", fValues(3), fErrors(3)));
129 t->AddText(Form("Mass: %.2f #pm %.2f GeV/c^{2}", fValues(4), fErrors(4)));
130 t->AddText(Form("Mass res.: %.1f #pm %.1f MeV/c^{2}", 1000*fValues(5), 1000*fErrors(5)));
137 //______________________________________________
138 void AliDielectronSignalBase::Print(Option_t */*option*/) const
141 // Print the statistics
143 printf("Signal : %.5g #pm %.5g\n",fValues(0), fErrors(0));
144 printf("Backgnd: %.5g #pm %.5g\n",fValues(1), fErrors(1));
145 printf("Signif.: %.5g #pm %.5g\n",fValues(2), fErrors(2));
146 printf("SoB : %.5g #pm %.5g\n",fValues(3), fErrors(3));
148 printf("Mass: %.5g #pm %.5g\n", fValues(4), fErrors(4));
149 printf("Mass res.: %.5g #pm %.5g\n", fValues(5), fErrors(5));
153 //______________________________________________
154 Double_t AliDielectronSignalBase::ScaleHistograms(TH1* histRaw, TH1* histBackground, Double_t intMin, Double_t intMax)
157 // scale histBackground to match the integral of histRaw in the interval intMin, intMax
160 //protect using over and underflow bins in normalisation calculation
161 if (intMin<histRaw->GetXaxis()->GetXmin()) intMin=histRaw->GetXaxis()->GetXmin();
162 if (intMin<histBackground->GetXaxis()->GetXmin()) intMin=histBackground->GetXaxis()->GetXmin();
164 if (intMax>histRaw->GetXaxis()->GetXmax())
165 intMax=histRaw->GetXaxis()->GetXmax()-histRaw->GetBinWidth(histRaw->GetNbinsX())/2.;
166 if (intMax>histBackground->GetXaxis()->GetXmax())
167 intMax=histBackground->GetXaxis()->GetXmax()-histBackground->GetBinWidth(histBackground->GetNbinsX())/2.;
169 Double_t intRaw = histRaw->Integral(histRaw->FindBin(intMin),histRaw->FindBin(intMax));
170 Double_t intBack = histBackground->Integral(histBackground->FindBin(intMin),histBackground->FindBin(intMax));
171 Double_t scaleFactor=intBack>0?intRaw/intBack:0.;
173 histBackground->Sumw2();
174 histBackground->Scale(scaleFactor);