1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 // (invariant) differential yield
17 // author: Eulogio Serradilla <eulogio.serradilla@cern.ch>
19 #include <Riostream.h>
24 #include <TGraphErrors.h>
27 #include "AliLnSpectra.h"
30 ClassImp(AliLnSpectra)
32 AliLnSpectra::AliLnSpectra(const TString& particle, const TString& ptFilename, const TString& tag, const TString& outputFilename, const TString& otag)
35 , fPtFilename(ptFilename)
37 , fOutputFilename(outputFilename)
48 AliLnSpectra::~AliLnSpectra()
55 Int_t AliLnSpectra::Exec()
58 // (invariant) differential yield projection in pt for |y| < ymax-ymin
62 TFile* finput = new TFile(fPtFilename.Data(), "read");
63 if(finput->IsZombie()) exit(1);
65 // pt and number of events
67 TH1D* hPt = FindObj<TH1D>(finput, fParticle + "_Pt");
68 TH1D* hStats = FindObj<TH1D>(finput, fParticle + "_Stats");
70 Double_t nEvent = hStats->Integral(3,3);
71 if(fINEL) nEvent = hStats->Integral(4,4);
75 TFile* foutput = new TFile(fOutputFilename.Data(),"recreate");
77 foutput->mkdir(fOutputTag.Data());
78 foutput->cd(fOutputTag.Data());
82 TGraphErrors* grDYieldPt = this->GetDiffYieldPt(hPt, nEvent, fParticle + "_DiffYield_Pt");
85 // invariant differential yield
87 TGraphErrors* grInvDYieldPt = this->GetInvDiffYieldPt(grDYieldPt, fParticle + "_InvDiffYield_Pt");
88 grInvDYieldPt->Write();
101 TGraphErrors* AliLnSpectra::GetDiffYieldPt(const TH1D* hPt, Int_t nEvent, const TString& name) const
104 // projection of the differential yield in pt
105 // only statistical error of N is taken into account
107 TGraphErrors* grDYieldPt = new TGraphErrors();
108 grDYieldPt->SetName(name.Data());
110 Double_t dy = fYMax - fYMin;
112 TAxis* xaxis = hPt->GetXaxis();
114 for(Int_t i=1, j=0; i < xaxis->GetNbins()+1; ++i)
116 Double_t pt = xaxis->GetBinCenter(i);
117 Double_t dpt = xaxis->GetBinWidth(i);
119 Double_t n = hPt->GetBinContent(i);
120 Double_t eN = hPt->GetBinError(i);
124 Double_t yield = n/(nEvent*dpt*dy);
125 Double_t yError = yield*eN/n;
127 grDYieldPt->SetPoint(j, pt, yield);
128 grDYieldPt->SetPointError(j++, dpt/2., yError);
134 TGraphErrors* AliLnSpectra::GetInvDiffYieldPt(const TGraphErrors* grDYieldPt, const TString& name) const
137 // projection of the invariant differential yield in pt
138 // only statistical error of N is taken into account
140 TGraphErrors* grInvDYieldPt = new TGraphErrors();
141 grInvDYieldPt->SetName(name.Data());
143 for(Int_t i=0; i < grDYieldPt->GetN(); ++i)
146 grDYieldPt->GetPoint(i,pt,y);
148 Double_t errpt = grDYieldPt->GetErrorX(i);
149 Double_t erry = grDYieldPt->GetErrorY(i);
151 y = y/(2.*TMath::Pi()*pt);
152 erry = erry / (2.*TMath::Pi()*pt);
154 grInvDYieldPt->SetPoint(i, pt, y);
155 grInvDYieldPt->SetPointError(i, errpt, erry);
158 return grInvDYieldPt;
161 TGraphErrors* AliLnSpectra::GetInvDiffYieldPt(const TH1D* hPt, Int_t nEvent, const TString& name) const
164 // projection of the invariant differential yield in pt
165 // only statistical error of N is taken into account
167 TGraphErrors* grDYieldPt = this->GetDiffYieldPt(hPt, nEvent, "_tmp_diff_yield_");
168 TGraphErrors* grInvDYieldPt = this->GetInvDiffYieldPt(grDYieldPt, name);
171 return grInvDYieldPt;