AliPhysics  6f1d526 (6f1d526)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliDJetTHnReader.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2016, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
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  **************************************************************************/
15 
16 #include <TFile.h>
17 #include <TDirectoryFile.h>
18 #include <TList.h>
19 #include <TH1D.h>
20 #include <TH2D.h>
21 #include <TH3D.h>
22 #include <THnSparse.h>
23 #include <Riostream.h>
24 
25 #include "AliDJetTHnReader.h"
26 
30 
36  fFileNameInput(),
37  fDirName(),
38  fListName(),
39  fObjectName(),
40  fFileInput(nullptr)
41 {
42 }
43 
49  AliDJetVReader(source),
50  fFileNameInput(source.fFileNameInput),
51  fDirName(source.fDirName),
52  fListName(source.fListName),
53  fObjectName(source.fObjectName),
54  fFileInput(nullptr)
55 {
56 }
57 
62 {
63 }
64 
69 {
70  std::cout << "Extracting input mass plot: " << fpTmin << " to " << fpTmax << std::endl;
71 
72  TDirectoryFile* dir = dynamic_cast<TDirectoryFile*>(fFileInput->Get(fDirName.Data()));
73 
74  TList *histList = dynamic_cast<TList*>(dir->Get(Form("%s0", fListName.Data())));
75  THnSparseF *sparse = dynamic_cast<THnSparseF*>(histList->FindObject(fObjectName.Data()));
76  sparse->GetAxis(0)->SetRangeUser(fzmin, fzmax);
77  TH3D* hInvMassptD = static_cast<TH3D*>(sparse->Projection(3, 1, 2));
78  hInvMassptD->SetName("hInvMassptD");
79 
80  if (!hInvMassptD) return kFALSE;
81 
82  TH1D* hmassjet[fnDbins];
83  TH1D* hmassjet_scale[fnDbins];
84  for (int i = 0; i < fnDbins; i++) {
85  hmassjet[i] = nullptr;
86  hmassjet_scale[i] = nullptr;
87  }
88  TH1D *hmass = nullptr;
89 
90  for (int j = 0; j < fnDbins; j++) {
91  hmassjet[j] = hInvMassptD->ProjectionX(Form("hmassjet%d",j), hInvMassptD->GetYaxis()->FindBin(fpTmin), hInvMassptD->GetYaxis()->FindBin(fpTmax)-1, hInvMassptD->GetZaxis()->FindBin(fDbinpTedges[j]), hInvMassptD->GetZaxis()->FindBin(fDbinpTedges[j + 1]) - 1);
92 
93  hmassjet_scale[j] = static_cast<TH1D*>(hmassjet[j]->Clone(Form("hmassjet%d_scale", j)));
94  hmassjet_scale[j]->Scale(1. / fDEffValues[j]);
95 
96  if (!j) hmass = static_cast<TH1D*>(hmassjet_scale[j]->Clone("hmass"));
97  else hmass->Add(hmassjet_scale[j]);
98  }
99 
100  fMassPlot = static_cast<TH1D*>(hmass->Clone("inputSpectrum"));
101 
102  return kTRUE;
103 }
104 
109 {
110  std::cout << "Extracting input mass plot: " << fpTmin << " to " << fpTmax << std::endl;
111 
112  double jetmin = 5, jetmax = 30;
113 
114  TDirectoryFile* dir = dynamic_cast<TDirectoryFile*>(fFileInput->Get(fDirName.Data()));
115 
116  TList *histList = dynamic_cast<TList*>(dir->Get(Form("%s0", fListName.Data())));
117  THnSparseF *sparse = dynamic_cast<THnSparseF*>(histList->FindObject(fObjectName.Data()));
118  sparse->GetAxis(0)->SetRangeUser(fzmin, fzmax);
119  sparse->GetAxis(1)->SetRangeUser(jetmin, jetmax);
120  sparse->GetAxis(2)->SetRangeUser(fpTmin, fpTmax);
121 
122  fMassPlot = sparse->Projection(3);
123  fMassPlot->SetName("inputSpectrum");
124  fMassVsJetPtPlot = sparse->Projection(3, 1);
125  fMassVsJetPtPlot->SetName("hInvMassJetPt");
126 
127  return kTRUE;
128 }
virtual ~AliDJetTHnReader()
Bool_t ExtractInputMassPlotSideband()
Double_t fpTmax
pT upper edge of mass plot to evaluate variations of yields
Declaration of class AliDJetTHnReader.
TString fListName
Name of input list.
Double_t fzmax
z maximum value to extract jet pT spectrum
Double_t * fDbinpTedges
D-meson pt bin edges values.
Bool_t ExtractInputMassPlotEffScale()
Implementation of an abstract class to read the invariant mass histograms used to extract the raw yie...
Implementation of an abstract class to read the invariant mass histograms used to extract the raw yie...
TH1D * fMassPlot
!Mass spectra to be fitted
Double_t * fDEffValues
D-meson efficiency values.
Definition: External.C:252
Double_t fzmin
z minimum value to extract jet pT spectrum
TString fDirName
Name of input directory in the root file.
Definition: External.C:212
Int_t fnDbins
Number of D-meson pT bins (for eff scaling)
Double_t fpTmin
pT lower edge of mass plot to evaluate variations of yields
TString fObjectName
Name of input container to extract the mass plot.
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
TFile * fFileInput
!File containing the task output
TH2D * fMassVsJetPtPlot
!Mass vs jet pt (SB method)
bool Bool_t
Definition: External.C:53