AliPhysics  9c66e61 (9c66e61)
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 
28 ClassImp(AliDJetTHnReader);
30 
36  fFileNameInput(),
37  fDirName(),
38  fListName(),
39  fObjectName(),
40  fFileInput(nullptr)
41 {
42 }
43 
49  AliDJetVReader(source),
51  fDirName(source.fDirName),
52  fListName(source.fListName),
53  fObjectName(source.fObjectName),
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(fJetzBinEdges[0], fJetzBinEdges[fnJetzbins]);
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  if (fMassRebin != 1) fMassPlot->Rebin(fMassRebin);
102 
103  return kTRUE;
104 }
105 
110 {
111  std::cout << "Extracting input mass plot: " << fpTmin << " to " << fpTmax << std::endl;
112 
113  double jetmin = 5, jetmax = 30;
114 
115  TDirectoryFile* dir = dynamic_cast<TDirectoryFile*>(fFileInput->Get(fDirName.Data()));
116 
117  TList *histList = dynamic_cast<TList*>(dir->Get(Form("%s0", fListName.Data())));
118  THnSparseF *sparse = dynamic_cast<THnSparseF*>(histList->FindObject(fObjectName.Data()));
119  sparse->GetAxis(0)->SetRangeUser(fJetzBinEdges[0], fJetzBinEdges[fnJetzbins]);
120  sparse->GetAxis(1)->SetRangeUser(jetmin, jetmax);
121  sparse->GetAxis(2)->SetRangeUser(fpTmin, fpTmax);
122 
123  fMassPlot = sparse->Projection(3);
124  fMassPlot->SetName("inputSpectrum");
125  if (fMassRebin != 1) fMassPlot->Rebin(fMassRebin);
126  fMassVsJetPtPlot = sparse->Projection(3, 1);
127  fMassVsJetPtPlot->SetName("hInvMassJetPt");
128 
129  return kTRUE;
130 }
virtual ~AliDJetTHnReader()
Bool_t ExtractInputMassPlotSideband()
Double_t fpTmax
pT upper edge of mass plot to evaluate variations of yields
Declaration of class AliDJetTHnReader.
Double_t * fJetzBinEdges
Jet z bin edges to be used for spectrum.
TString fListName
Name of input list.
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...
Int_t fnJetzbins
Number of jet z bins to be used for spectrum.
TH1D * fMassPlot
!Mass spectra to be fitted
Double_t * fDEffValues
D-meson efficiency values.
Definition: External.C:252
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.
UInt_t fMassRebin
Rebin the mass histogram axis.
TFile * fFileInput
!File containing the task output
TH2D * fMassVsJetPtPlot
!Mass vs jet pt (SB method)
bool Bool_t
Definition: External.C:53
TDirectoryFile * dir
TString fFileNameInput
Name of input file.