]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/SPECTRA/Nuclei/B2/AliLnUnfolding.cxx
6dceed72d0320aaabc8e3e85742538c52f2888fb
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / Nuclei / B2 / AliLnUnfolding.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, 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 // unfolding correction for the pt
17 // author: Eulogio Serradilla <eulogio.serradilla@cern.ch>
18
19 //#include <Riostream.h>
20 #include <TFile.h>
21 #include <TSystem.h>
22 #include <TH1D.h>
23 #include <TH2D.h>
24 #include <TString.h>
25 #include <TF1.h>
26
27 #include "AliLnUnfolding.h"
28 #include "B2.h"
29
30 ClassImp(AliLnUnfolding)
31
32 AliLnUnfolding::AliLnUnfolding(const TString& particle, const TString& simuFilename, const TString& outputFilename, const TString& otag)
33 : TObject()
34 , fParticle(particle)
35 , fSimuFilename(simuFilename)
36 , fOutputFilename(outputFilename)
37 , fOutputTag(otag)
38 {
39 //
40 // constructor
41 //
42 }
43
44 AliLnUnfolding::~AliLnUnfolding()
45 {
46 //
47 // destructor
48 //
49 }
50
51 Int_t AliLnUnfolding::Exec()
52 {
53 //
54 // extract the detector response from the simulation for particle/antiparticle
55 //
56         using namespace std;
57         
58         TFile* fsimu = new TFile(fSimuFilename.Data(), "read");
59         if(fsimu->IsZombie()) exit(1);
60         
61         TFile* foutput = new TFile(fOutputFilename.Data(), "recreate");
62         if(fOutputTag != "")
63         {
64                 foutput->mkdir(fOutputTag.Data());
65                 foutput->cd(fOutputTag.Data());
66         }
67         
68         TH2D* hResponseMtx = (TH2D*)FindObj(fsimu, fParticle + "_Prim_Response_Matrix");
69         hResponseMtx->SetName(Form("%s_Response_Matrix",fParticle.Data()));
70         hResponseMtx->Write();
71         
72         TH1D* hMeasuredPt = (TH1D*)FindObj(fsimu, fParticle + "_PID_Pt");
73         hMeasuredPt->SetName(Form("%s_Measured_Pt", fParticle.Data()));
74         hMeasuredPt->Reset();
75         hMeasuredPt->Write();
76         
77         TH1D* hTruePt = (TH1D*)FindObj(fsimu, fParticle + "_Sim_PID_Prim_Pt");
78         hTruePt->SetName(Form("%s_True_Pt", fParticle.Data()));
79         hTruePt->Reset();
80         hTruePt->Write();
81         
82         delete foutput;
83         delete fsimu;
84         
85         return 0;
86 }