]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG3/dielectron/AliDielectronSignalBase.cxx
major dielectron update (included also the data and plotting macros for paper)
[u/mrichter/AliRoot.git] / PWG3 / dielectron / AliDielectronSignalBase.cxx
index 44adbd31f188604450762fbd0014e91f28450b6e..da3cc998f9507e6268417b898b7c55d70181f1b1 100644 (file)
@@ -28,31 +28,58 @@ resulting from single and mixed events, as defined in AliDielectron.cxx
 ///////////////////////////////////////////////////////////////////////////
 
 
-#include "TPaveText.h"
+#include <TVectorT.h>
+#include <TPaveText.h>
+#include <TH1F.h>
 #include "AliDielectronSignalBase.h"
 
 ClassImp(AliDielectronSignalBase)
 
 AliDielectronSignalBase::AliDielectronSignalBase() :
   TNamed(),
-  fValues(4),
-  fErrors(4),
-  fIntMin(2.99),
-  fIntMax(3.19)
+  fHistSignal(0),
+  fHistBackground(0),
+  fHistDataPM(0),
+  fHistDataPP(0),
+  fHistDataMM(0),
+  fValues(6),
+  fErrors(6),
+  fIntMin(0),
+  fIntMax(0),
+  fFitMin(0),
+  fFitMax(0),
+  fRebin(1),
+  fMethod(kLikeSign),
+  fScaleMin(0.),
+  fScaleMax(0.),
+  fScaleFactor(1.),
+  fProcessed(kFALSE)
 {
   //
   // Default Constructor
   //
-  
 }
 
 //______________________________________________
 AliDielectronSignalBase::AliDielectronSignalBase(const char* name, const char* title) :
   TNamed(name, title),
-  fValues(4),
-  fErrors(4),
-  fIntMin(2.99),
-  fIntMax(3.19)
+  fHistSignal(0),
+  fHistBackground(0),
+  fHistDataPM(0),
+  fHistDataPP(0),
+  fHistDataMM(0),
+  fValues(6),
+  fErrors(6),
+  fIntMin(0),
+  fIntMax(0),
+  fFitMin(0),
+  fFitMax(0),
+  fRebin(1),
+  fMethod(kLikeSign),
+  fScaleMin(0.),
+  fScaleMax(0.),
+  fScaleFactor(1.),
+  fProcessed(kFALSE)
 {
   //
   // Named Constructor
@@ -65,6 +92,11 @@ AliDielectronSignalBase::~AliDielectronSignalBase()
   //
   // Default Destructor
   //
+  if(fHistSignal) delete fHistSignal;
+  if(fHistBackground) delete fHistBackground;
+  if (fHistDataPP) delete fHistDataPP;
+  if (fHistDataPM) delete fHistDataPM;
+  if (fHistDataMM) delete fHistDataMM;
   
 }
 
@@ -85,12 +117,59 @@ TPaveText* AliDielectronSignalBase::DrawStats(Double_t x1/*=0.*/, Double_t y1/*=
   t->SetFillColor(kWhite);
   t->SetBorderSize(1);
   t->SetTextAlign(12);
-  t->AddText(Form("Singal : %.2f #pm %.2f",GetSignal(),GetSignalError()));
-  t->AddText(Form("Backgnd: %.2f #pm %.2f",GetBackground(),GetBackgroundError()));
-  t->AddText(Form("Signif.: %.2f #pm %.2f",GetSignificance(),GetSignificanceError()));
-  t->AddText(Form("SoB    : %.2f #pm %.2f",GetSignalOverBackground(),GetSignalOverBackgroundError()));
+  t->AddText(Form("Range  : %.2f - %.2f GeV/c^{2}", fIntMin, fIntMax));
+  t->AddText(Form("Signal : %.1f #pm %.1f", fValues(0), fErrors(0)));
+  t->AddText(Form("Backgnd: %.1f #pm %.1f", fValues(1), fErrors(1)));
+  t->AddText(Form("Signif.: %.2f #pm %.2f", fValues(2), fErrors(2)));
+  t->AddText(Form("S/B    : %.2f #pm %.2f", fValues(3), fErrors(3)));
+  if(fValues(4)>0) {
+    t->AddText(Form("Mass: %.2f #pm %.2f GeV/c^{2}", fValues(4), fErrors(4)));
+    t->AddText(Form("Mass res.: %.1f #pm %.1f MeV/c^{2}", 1000*fValues(5), 1000*fErrors(5)));
+  }
   t->Draw();
 
   return t;
 }
 
+//______________________________________________
+void AliDielectronSignalBase::Print(Option_t */*option*/) const
+{
+  //
+  // Print the statistics
+  //
+  printf("Signal : %.5g #pm %.5g\n",fValues(0), fErrors(0));
+  printf("Backgnd: %.5g #pm %.5g\n",fValues(1), fErrors(1));
+  printf("Signif.: %.5g #pm %.5g\n",fValues(2), fErrors(2));
+  printf("SoB    : %.5g #pm %.5g\n",fValues(3), fErrors(3));
+  if(fValues(4)>0){
+    printf("Mass: %.5g #pm %.5g\n", fValues(4), fErrors(4));
+    printf("Mass res.: %.5g #pm %.5g\n", fValues(5), fErrors(5));
+  }
+}
+
+//______________________________________________
+Double_t AliDielectronSignalBase::ScaleHistograms(TH1* histRaw, TH1* histBackground, Double_t intMin, Double_t intMax)
+{
+  //
+  // scale histBackground to match the integral of histRaw in the interval intMin, intMax
+  //
+
+  //protect using over and underflow bins in normalisation calculation
+  if (intMin<histRaw->GetXaxis()->GetXmin()) intMin=histRaw->GetXaxis()->GetXmin();
+  if (intMin<histBackground->GetXaxis()->GetXmin()) intMin=histBackground->GetXaxis()->GetXmin();
+  
+  if (intMax>histRaw->GetXaxis()->GetXmax())
+    intMax=histRaw->GetXaxis()->GetXmax()-histRaw->GetBinWidth(histRaw->GetNbinsX())/2.;
+  if (intMax>histBackground->GetXaxis()->GetXmax())
+    intMax=histBackground->GetXaxis()->GetXmax()-histBackground->GetBinWidth(histBackground->GetNbinsX())/2.;
+  
+  Double_t intRaw  = histRaw->Integral(histRaw->FindBin(intMin),histRaw->FindBin(intMax));
+  Double_t intBack = histBackground->Integral(histBackground->FindBin(intMin),histBackground->FindBin(intMax));
+  Double_t scaleFactor=intBack>0?intRaw/intBack:0.;
+  if (intBack>0){
+    histBackground->Sumw2();
+    histBackground->Scale(scaleFactor);
+  }
+
+  return scaleFactor;
+}