]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG3/dielectron/AliDielectronSignalBase.h
framework update; new classes for track rotation (for background), cuts grouping...
[u/mrichter/AliRoot.git] / PWG3 / dielectron / AliDielectronSignalBase.h
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
24 #include <TNamed.h>
25 #include <TVectorT.h>
26 #include <TMath.h>
27
28 class TObjArray;
29 class TPaveText;
30 class TH1F;
31
32 class AliDielectronSignalBase : public TNamed {
33 public:
34   enum EBackgroundMethod {
35     kFitted = 0,
36     kLikeSign,
37     kEventMixing,
38     kRotation
39   };
40
41   AliDielectronSignalBase();
42   AliDielectronSignalBase(const char*name, const char* title);
43   
44   virtual ~AliDielectronSignalBase();
45   
46   void SetIntegralRange(Double_t min, Double_t max) {fIntMin=min;fIntMax=max;}
47   void SetFitRange(Double_t min, Double_t max) {fFitMin=min; fFitMax=max;}
48   void SetRebin(Int_t factor) {fRebin = factor;}
49   void SetMethod(EBackgroundMethod method) {fMethod = method;}
50
51   const TVectorD& GetValues() const {return fValues;}
52   const TVectorD& GetErrors() const {return fErrors;}
53
54   Double_t GetIntegralMin()          const { return fIntMin; }
55   Double_t GetIntegralMax()          const { return fIntMax; }
56   Double_t GetSignal()               const { return fValues(0);}
57   Double_t GetSignalError()          const { return fErrors(0);}
58   Double_t GetBackground()           const { return fValues(1);}
59   Double_t GetBackgroundError()      const { return fErrors(1);}
60   Double_t GetSignificance()         const { return fValues(2);}
61   Double_t GetSignificanceError()    const { return fErrors(2);}
62   Double_t GetSB()                   const { return fValues(3);}
63   Double_t GetSBError()              const { return fErrors(3);}
64   Double_t GetMass()                 const { return fValues(4);}
65   Double_t GetMassError()            const { return fErrors(4);}
66   Double_t GetMassWidth()            const { return fValues(5);}
67   Double_t GetMassWidthError()       const { return fErrors(5);}
68
69   TH1* GetSignalHistogram()      const {return fHistSignal;}
70   TH1* GetBackgroundHistogram()  const {return fHistBackground;}
71   TH1* GetUnlikeSignHistogram()  const {return fHistDataPM;}
72   
73   static void ScaleHistograms(TH1* histRaw, TH1* histBackground, Double_t intMin, Double_t intMax);
74   
75   virtual void Print(Option_t *option="") const;
76
77   /**
78   This function needs to be implemented by the signal extraction classes.
79   Here all the work should be done.
80   
81   The signal extraction is done on the mass spectra.
82   The TObjArray should contain the Inv. Mass spectra of the 10 possible combinations
83      for single and mixed events defined in AliDielectron.cxx
84   */
85   virtual void Process(TObjArray * const /*arrhist*/) = 0;
86     
87 protected: 
88
89   TH1 *fHistSignal;                  // histogram of pure signal
90   TH1 *fHistBackground;              // histogram of background (fitted=0, like-sign=1, event mixing=2)
91   TH1 *fHistDataPM;                  // histogram of selected +- pair candidates
92   TH1 *fHistDataPP;                  // histogram of selected ++ pair candidates
93   TH1 *fHistDataMM;                  // histogram of selected -- pair candidates
94
95   TVectorD fValues;                   // values
96   TVectorD fErrors;                   // value errors
97
98   Double_t fIntMin;                   // signal extraction range min
99   Double_t fIntMax;                   // signal extraction range max
100   Double_t fFitMin;                   // fit range lowest inv. mass
101   Double_t fFitMax;                   // fit range highest inv. mass
102
103   Int_t fRebin;                       // histogram rebin factor
104   EBackgroundMethod fMethod;          // method for background substraction
105
106   Bool_t fProcessed;                  // flag
107
108   void SetSignificanceAndSOB();       // calculate the significance and S/B
109   TPaveText* DrawStats(Double_t x1=0., Double_t y1=0., Double_t x2=0., Double_t y2=0.);
110
111   AliDielectronSignalBase(const AliDielectronSignalBase &c);
112   AliDielectronSignalBase &operator=(const AliDielectronSignalBase &c);
113
114   ClassDef(AliDielectronSignalBase,3) // Dielectron SignalBase
115 };
116
117 inline void AliDielectronSignalBase::SetSignificanceAndSOB()
118 {
119   //
120   // Calculate S/B and significance
121   //
122   // Signal/Background
123   fValues(3) = (fValues(1)>0 ? fValues(0)/fValues(1) : 0);
124   Float_t epsSig = (fValues(0)>0 ? fErrors(0)/fValues(0) : 0);
125   Float_t epsBknd = (fValues(1)>0 ? fErrors(1)/fValues(1) : 0);
126   fErrors(3) = fValues(3)*TMath::Sqrt(epsSig*epsSig + epsBknd*epsBknd);
127   // Significance
128   fValues(2) = ((fValues(0)+fValues(1))>0 ? fValues(0)/TMath::Sqrt(fValues(0)+fValues(1)) : 0);
129   Float_t s = fValues(0); Float_t b = fValues(1);
130   fErrors(2) = ((s+b)>0 ? TMath::Sqrt((s*(s+2*b)*(s+2*b)+b*s*s)/(4*TMath::Power(s+b,3))) : 0);
131 }
132
133 #endif