]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG/FLOW/Tasks/AliJetFlowTools.h
merge centrality bins on input level
[u/mrichter/AliRoot.git] / PWG / FLOW / Tasks / AliJetFlowTools.h
index f220cef544871e379f74af0a96b3f54f7221feb4..a85f4cc4c9a83393525f67f4f3e2a026e69a7f85 100644 (file)
@@ -13,7 +13,6 @@ class TF1;
 class TH1D;
 class TH2D;
 class TCanvas;
-class TLegend;
 class TString;
 class TArrayD;
 class TGraph;
@@ -29,6 +28,8 @@ class AliUnfolding;
 #include "TFile.h"
 #include "TProfile.h"
 #include "TVirtualPad.h"
+#include "TPaveText.h"
+#include "TLegend.h"
 //_____________________________________________________________________________
 class AliJetFlowTools {
     public: 
@@ -46,14 +47,18 @@ class AliJetFlowTools {
             kNone };                    // no unfolding
         enum prior {                    // prior that is used for unfolding
             kPriorChi2,                 // prior from chi^2 method
-            kPriorMeasured };           // use measured spectrum as prior
+            kPriorMeasured,             // use measured spectrum as prior
+            kPriorPythia };             // use pythia spectrum as prior
         enum histoType {                // histogram identifier, only used internally
-            kInPlaneSpectrum,
+            kInPlaneSpectrum,           // default style for spectrum
             kOutPlaneSpectrum,
             kUnfoldedSpectrum,
             kFoldedSpectrum,
             kMeasuredSpectrum,
-            kEmpty };
+            kBar,                       // default style for bar histogram
+            kRatio,                     // default style for ratio
+            kV2,                        // default style for v2
+            kEmpty };                   // default style
         // setters, interface to the class
         void            SetSaveFull(Bool_t b)           {fSaveFull              = b;}
         void            SetInputList(TList* list)       {
@@ -74,6 +79,10 @@ class AliJetFlowTools {
             fActiveDir->cd();
         }
         void            SetCentralityBin(Int_t bin)             {fCentralityBin         = bin;}
+        void            SetCentralityBin(TArrayI* bins)         {
+            fCentralityArray = bins;
+            fCentralityBin = fCentralityArray->At(0);
+        }
         void            SetDetectorResponse(TH2D* dr)           {fDetectorResponse      = dr;}
         void            SetJetFindingEfficiency(TH1D* e)        {fJetFindingEff         = e;}
         void            SetBinsTrue(TArrayD* bins)              {fBinsTrue              = bins;}
@@ -92,6 +101,7 @@ class AliJetFlowTools {
         void            SetAvoidRoundingError(Bool_t r)         {fAvoidRoundingError    = r;}
         void            SetUnfoldingAlgorithm(unfoldingAlgorithm ua)    {fUnfoldingAlgorithm                    = ua;}
         void            SetPrior(prior p)                       {fPrior                 = p;}
+        void            SetPrior(prior p, TH1D* spectrum)       {fPrior                 = p; fPriorUser         = spectrum;}
         void            SetNormalizeSpectra(Bool_t b)           {fNormalizeSpectra      = b;}
         void            SetNormalizeSpectra(Int_t e)            { // use to normalize to this no of events
             fEventCount         = e;
@@ -109,8 +119,13 @@ class AliJetFlowTools {
         void            SetUseDetectorResponse(Bool_t r)        {fUseDetectorResponse   = r;}
         void            SetUseDptResponse(Bool_t r)             {fUseDptResponse        = r;}
         void            SetTrainPowerFit(Bool_t t)              {fTrainPower            = t;}
-        void            SetUnfoldInOutPlane(Bool_t i)           {fInOutUnfolding        = i;}
+        void            SetDphiUnfolding(Bool_t i)              {fDphiUnfolding         = i;}
+        void            SetDphiDptUnfolding(Bool_t i)           {fDphiDptUnfolding      = i;}
+        void            SetExLJDpt(Bool_t i)                    {fExLJDpt               = i;}
+        void            SetWeightFunction(TF1* w)               {fResponseMaker->SetRMMergeWeightFunction(w);}
+        void            SetTreatCorrErrAsUncorrErr(Bool_t b)    {fSetTreatCorrErrAsUncorrErr = b;}
         void            Make();
+        void            MakeAU();       // test function, use with caution (09012014)
         void            Finish() {
             fOutputFile->cd();
             if(fRMSSpectrumIn)  fRMSSpectrumIn->Write();
@@ -119,9 +134,45 @@ class AliJetFlowTools {
             fOutputFile->Close();}
         void            PostProcess(
                 TString def,
+                Int_t columns = 4,
+                Float_t rangeLow = 20,
+                Float_t rangeUp = 80,
+                TString in = "UnfoldedSpectra.root", 
+                TString out = "ProcessedSpectra.root") const;
+        void            GetNominalValues(
+                TH1D*& ratio,
+                TGraphErrors*& v2,
+                TArrayI* in,
+                TArrayI* out,
+                TString inFile = "UnfoldedSpectra.root",
+                TString outFile = "Nominal.root") const;
+        void            GetCorrelatedUncertainty(
+                TGraphAsymmErrors*& corrRatio,
+                TGraphAsymmErrors*& corrV2,
+                TArrayI* variationsIn,
+                TArrayI* variationsOut,
+                TArrayI* variantions2ndIn,
+                TArrayI* variantions2ndOut,
+                TString type = "",
+                Int_t columns = 4,
+                Float_t rangeLow = 20,
+                Float_t rangeUp = 80,
+                TString in = "UnfoldedSpectra.root", 
+                TString out = "CorrelatedUncertainty.root") const;
+        void            GetShapeUncertainty(
+                TGraphAsymmErrors*& shapeRatio,
+                TGraphAsymmErrors*& shapeV2,
+                TArrayI* regularizationIn,
+                TArrayI* regularizationOut,
+                TArrayI* trueBinIn = 0x0,
+                TArrayI* trueBinOut = 0x0,
+                TArrayI* recBinIn = 0x0,
+                TArrayI* recBinOut = 0x0,
+                Int_t columns = 4,
+                Float_t rangeLow = 20,
+                Float_t rangeUp = 80,
                 TString in = "UnfoldedSpectra.root", 
-                TString out = "ProcessedSpectra.root", 
-                Int_t columns = 4) const;
+                TString out = "ShapeUncertainty.root") const;
         Bool_t          SetRawInput (
                 TH2D* detectorResponse, // detector response matrix
                 TH1D* jetPtIn,          // in plane jet spectrum
@@ -138,20 +189,49 @@ class AliJetFlowTools {
         static TH2D*    MatrixMultiplication(TH2D* a, TH2D* b, TString name = "CombinedResponse");
         static TH1D*    NormalizeTH1D(TH1D* histo, Double_t scale = 1.);
         static TGraphErrors*    GetRatio(TH1 *h1 = 0x0, TH1* h2 = 0x0, TString name = "", Bool_t appendFit = kFALSE, Int_t xmax = -1);
-        static TGraphErrors*    GetV2(TH1* h1 = 0x0, TH1* h2 = 0x0, Double_t r = .7, TString name = "");
+        static TGraphErrors*    GetV2(TH1* h1 = 0x0, TH1* h2 = 0x0, Double_t r = 0., TString name = "");
+        TGraphAsymmErrors*      GetV2WithSystematicErrors(
+                TH1* h1, TH1* h2, Double_t r, TString name, 
+                TH1* relativeErrorInUp,
+                TH1* relativeErrorInLow,
+                TH1* relativeErrorOutUp,
+                TH1* relativeErrorOutLow,
+                Float_t rho = 0.) const;
         static void     WriteObject(TObject* object, TString suffix = "", Bool_t kill = kTRUE);
         static TH2D*    ConstructDPtResponseFromTH1D(TH1D* dpt, Bool_t AvoidRoundingError);
         static TH2D*    GetUnityResponse(TArrayD* binsTrue, TArrayD* binsRec, TString suffix = "");
         void            SaveConfiguration(Bool_t convergedIn, Bool_t convergedOut) const;
         static TMatrixD*        CalculatePearsonCoefficients(TMatrixD* covmat);
         static TH1D*    SmoothenPrior(TH1D* spectrum, TF1* function, Double_t min, Double_t max, Double_t start, Bool_t kill = kTRUE, Bool_t counts = kTRUE);
-        // set styles
+        // set style
+        void            SetTitleFontSize(Double_t s)    {fTitleFontSize = s;}
+        static void     Style();
         static void     Style(TCanvas* c, TString style = "PEARSON");
         static void     Style(TVirtualPad* c, TString style = "SPECTRUM");
         static void     Style(TLegend* l);
         static void     Style(TH1* h, EColor col = kBlue, histoType = kEmpty);
         static void     Style(TGraph* h, EColor col = kBlue, histoType = kEmpty);
-        static TLegend* AddLegend(TVirtualPad* p)       {return p->BuildLegend(.27, .61, .88, .88);}
+        static TLegend* AddLegend(TVirtualPad* p, Bool_t style = kFALSE) {
+            if(!style) return p->BuildLegend(.565, .663, .882, .883);
+            else {
+                TLegend* l = AddLegend(p, kFALSE);
+                Style(l);
+                return l;
+            }
+        }
+        static TPaveText*       AddTPaveText(TString text, Int_t r = 2) {
+            TPaveText* t(new TPaveText(.35, .27, .76, .33,"NDC"));
+//            t->SetFillStyle(0);
+            t->SetFillColor(0);            
+            t->SetBorderSize(0);
+            t->AddText(0.,0.,text.Data());
+            t->AddText(0., 0., Form("#it{R} = 0.%i #it{k}_{T} charged jets", r));
+            t->SetTextColor(kBlack);
+//            t->SetTextSize(0.03);
+            t->SetTextFont(42);
+            t->Draw("same");
+            return t;
+        } 
         static void     SavePadToPDF(TVirtualPad* pad)  {pad->SaveAs(Form("%s.pdf", pad->GetName()));}
         // interface to AliUnfolding, not necessary but nice to have all parameters in one place
         static void     SetMinuitStepSize(Float_t s)    {AliUnfolding::SetMinuitStepSize(s);}
@@ -161,12 +241,19 @@ class AliJetFlowTools {
         static void     SetDebug(Int_t d)               {AliUnfolding::SetDebug(d);}
     private:
         Bool_t          PrepareForUnfolding(); 
+        Bool_t          PrepareForUnfolding(Int_t low, Int_t up);
         TH1D*           GetPrior(                       const TH1D* measuredJetSpectrum,
                                                         const TH2D* resizedResponse,
                                                         const TH1D* kinematicEfficiency,
                                                         const TH1D* measuredJetSpectrumTrueBins,
                                                         const TString suffix,
                                                         const TH1D* jetFindingEfficiency);
+        TH1D*           UnfoldWrapper(                  const TH1D* measuredJetSpectrum, 
+                                                        const TH2D* resizedResponse,
+                                                        const TH1D* kinematicEfficiency,
+                                                        const TH1D* measuredJetSpectrumTrueBins,
+                                                        const TString suffix,
+                                                        const TH1D* jetFindingEfficiency = 0x0);
         TH1D*           UnfoldSpectrumChi2(             const TH1D* measuredJetSpectrum, 
                                                         const TH2D* resizedResponse,
                                                         const TH1D* kinematicEfficiency,
@@ -191,13 +278,30 @@ class AliJetFlowTools {
                                                         const TH1D* measuredJetSpectrumTrueBins,
                                                         const TString suffix,
                                                         const TH1D* jetFindingEfficiency = 0x0);
+        void            DoIntermediateSystematics(
+                TArrayI* variationsIn,
+                TArrayI* variationsOut,
+                TH1D*& relativeErrorInUp,
+                TH1D*& relativeErrorInLow,
+                TH1D*& relativeErrorOutUp,
+                TH1D*& relativeErrorOutLow,
+                TH1D*& relativeSystematicIn,
+                TH1D*& relativeSystematicOut,
+                TH1D*& nominal,
+                TH1D*& nominalIn,
+                TH1D*& nominalOut,
+                Int_t columns,
+                Float_t rangeLow,
+                Float_t rangeUp,
+                TFile* readMe, 
+                TString source = "") const;
         static void     ResetAliUnfolding();
         // give object a unique name via the 'protect heap' functions. 
         // may seem redundant, but some internal functions of root (e.g.
         // ProjectionY()) check for existing objects by name and re-use them
-        TH1D*           ProtectHeap(TH1D* protect, Bool_t kill = kTRUE, TString suffix = "");
-        TH2D*           ProtectHeap(TH2D* protect, Bool_t kill = kTRUE, TString suffix = "");
-        TGraphErrors*   ProtectHeap(TGraphErrors* protect, Bool_t kill = kTRUE, TString suffix = "");
+        TH1D*           ProtectHeap(TH1D* protect, Bool_t kill = kTRUE, TString suffix = "") const;
+        TH2D*           ProtectHeap(TH2D* protect, Bool_t kill = kTRUE, TString suffix = "") const;
+        TGraphErrors*   ProtectHeap(TGraphErrors* protect, Bool_t kill = kTRUE, TString suffix = "") const;
         // members, accessible via setters
         AliAnaChargedJetResponseMaker*  fResponseMaker; // utility object
         TF1*                    fPower;                 // smoothening fit
@@ -209,6 +313,7 @@ class AliJetFlowTools {
         TString                 fOutputFileName;        // output file name
         TFile*                  fOutputFile;            // output file
         Int_t                   fCentralityBin;         // centrality bin
+        TArrayI*                fCentralityArray;       // array of bins that are merged
         TH2D*                   fDetectorResponse;      // detector response
         TH1D*                   fJetFindingEff;         // jet finding efficiency
         Double_t                fBetaIn;                // regularization strength, in plane unfolding
@@ -220,6 +325,7 @@ class AliJetFlowTools {
         Bool_t                  fAvoidRoundingError;    // set dpt to zero for small values far from the diagonal
         unfoldingAlgorithm      fUnfoldingAlgorithm;    // algorithm used for unfolding
         prior                   fPrior;                 // prior for unfolding
+        TH1D*                   fPriorUser;             // user supplied prior (e.g. pythia spectrum)
         TArrayD*                fBinsTrue;              // pt true bins
         TArrayD*                fBinsRec;               // pt rec bins
         TArrayD*                fBinsTruePrior;         // holds true bins for the chi2 prior for SVD. setting this is optional
@@ -236,15 +342,18 @@ class AliJetFlowTools {
         Float_t                 fFitStart;              // from this value, use smoothening
         Bool_t                  fSmoothenCounts;        // fill smoothened spectrum with counts
         Bool_t                  fTestMode;              // unfold with unity response for testing
-        Bool_t                  fNoDphi;                // no dphi dependence in unfolding
         Bool_t                  fRawInputProvided;      // input histograms provided, not read from file
         Double_t                fEventPlaneRes;         // event plane resolution for current centrality
         Bool_t                  fUseDetectorResponse;   // add detector response to unfolding
         Bool_t                  fUseDptResponse;        // add dpt response to unfolding
         Bool_t                  fTrainPower;            // don't clear the params of fPower for call to Make
-                                                        // might give more stable results, but also introduces
+                                                        // might give more stable results, but possibly introduces
                                                         // a bias / dependency on previous iterations
-        Bool_t                  fInOutUnfolding;        // do the unfolding in in and out of plane orientation
+        Bool_t                  fDphiUnfolding;         // do the unfolding in in and out of plane orientation
+        Bool_t                  fDphiDptUnfolding;      // do the unfolding in dphi and dpt bins (to fit v2)
+        Bool_t                  fExLJDpt;               // exclude randon cones with leading jet
+        Bool_t                  fSetTreatCorrErrAsUncorrErr;    // treat the correlated error as uncorrelated
+        Double_t                fTitleFontSize;         // title font size
         // members, set internally
         TProfile*               fRMSSpectrumIn;         // rms of in plane spectra of converged unfoldings
         TProfile*               fRMSSpectrumOut;        // rms of out of plane spectra of converged unfoldings