]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/SPECTRA/Nuclei/B2/AliLnDriver.cxx
Fix DCA templates for TPC+TOF
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / Nuclei / B2 / AliLnDriver.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 // driver for computing the pt and spectra
17 // author: Eulogio Serradilla <eulogio.serradilla@cern.ch>
18
19 #include <Riostream.h>
20 #include <TObject.h>
21 #include <TSystem.h>
22 #include <TFileMerger.h>
23 #include <TString.h>
24 #include <TFile.h>
25 #include <TError.h>
26
27 #include "AliLnCorr.h"
28 #include "AliLnPt.h"
29 #include "AliLnSecondaries.h"
30 #include "AliLnEfficiency.h"
31 #include "AliLnRatio.h"
32 #include "AliLnSpectra.h"
33 #include "AliLnB2.h"
34 #include "AliLnDriver.h"
35 #include "B2.h"
36
37 ClassImp(AliLnDriver)
38
39 AliLnDriver::AliLnDriver()
40 : TObject()
41 , fSpecies("Deuteron")
42 , fOutputTag("test")
43 , fOutputCorTag("")
44 , fIsOnlyGen(0)
45 , fNormToInel(1)
46 , fMakeCorr(1)
47 , fMakePt(1)
48 , fMakeRatio(1)
49 , fMakeSpectra(1)
50 , fMakeStats(1)
51 , fLowPtBin(3)
52 , fHiPtBin(15)
53 , fLowM2Bin(9)
54 , fHighM2Bin(17)
55 , fUnfolding(0)
56 , fNIter(4)
57 , fFakeTracks(1)
58 , fSecondaries(1)
59 , fSecProd(AliLnSecondaries::kTFractionFitter)
60 , fMatDCAxyMod(AliLnSecondaries::kGeantDCAxy)
61 , fANucTemplate(0)
62 , fNbin(1)
63 , fYMin(-0.5)
64 , fYMax(0.5)
65 , fMinDCAxy(-1.5)
66 , fMaxDCAxy(1.5)
67 , fMinM2Bkg(2.2)
68 , fMaxM2Bkg(5.)
69 , fMinM2tpc(2.)
70 , fMaxM2tpc(6.5)
71 , fEfficiency(1)
72 , fG3Fluka(0)
73 , fScMat(1)
74 , fScFd(1)
75 , fSysPos(1)
76 , fSysNeg(1)
77 , fInputData()
78 , fInputSimu()
79 , fInputSimuFix()
80 , fOutputPtCorr()
81 , fOutputPt()
82 , fOutputRatio()
83 , fOutputSpectra()
84 , fOutputPtCorrDebug()
85 , fOutputPtDebug()
86 , fFitFrac(0)
87 , fFdwnCorr(1)
88 , fSameFdwn(0)
89 , fVtxCorr(0)
90 , fVtxCorrVal(1)
91 {
92 //
93 // constructor
94 //
95         for(Int_t i=0; i<3; ++i)
96         {
97                 fTrigEff[i] = 1;
98                 fXsec[i] = 1;
99         }
100         
101         gErrorIgnoreLevel = kWarning;
102         // gErrorIgnoreLevel = kPrint, kInfo, kWarning, kError, kBreak, kSysError, kFatal;
103 }
104
105 AliLnDriver::~AliLnDriver()
106 {
107 //
108 // destructor
109 //
110 }
111
112 void AliLnDriver::SetInputFilenames(const TString& data, const TString& simu, const TString& simuFix, const TString& ptcorr)
113 {
114 //
115 // input filenames to get the pt
116 //
117         fInputData = data;
118         fInputSimu = simu;
119         fInputSimuFix = simuFix;
120         fOutputPtCorr = ptcorr;
121         
122         fOutputPtCorrDebug = ptcorr;
123         fOutputPtCorrDebug.Replace(ptcorr.Length()-5,5,"-debug.root");
124 }
125
126 void AliLnDriver::SetOutputFilenames(const TString& pt, const TString& ratio, const TString& spectra)
127 {
128 //
129 // output filenames
130 //
131         fOutputPt = pt;
132         fOutputRatio=ratio;
133         fOutputSpectra=spectra;
134         
135         fOutputPtDebug = pt;
136         fOutputPtDebug.Replace(pt.Length()-5,5,"-debug.root");
137 }
138
139 void AliLnDriver::PrintFilenames() const
140 {
141 //
142 // print filenames to stdout
143 //
144         using namespace std;
145         
146         cout << endl;
147         cout << "input data        : " << fInputData << endl;
148         cout << "input simulation  : " << fInputSimu << endl;
149         cout << "input simu. fix   : " << fInputSimuFix << endl;
150         
151         cout << "corrections       : " << fOutputPtCorr << endl;
152         cout << "corrections debug : " << fOutputPtCorrDebug << endl;
153         
154         cout << "output pt         : " << fOutputPt << endl;
155         cout << "output pt debug   : " << fOutputPtDebug << endl;
156         cout << "output ratio      : " << fOutputRatio << endl;
157         cout << "output spectra    : " << fOutputSpectra << endl;
158         cout << endl;
159 }
160
161 void AliLnDriver::SetTriggerEfficiency(Double_t eff[3])
162 {
163 //
164 // set trigger efficiency
165 //
166         for(Int_t i=0; i<3; ++i) fTrigEff[i] = eff[i];
167 }
168
169 void AliLnDriver::SetInelXSection(Double_t xsec[3])
170 {
171 //
172 // set total cross section, stat. and syst. errors
173 //
174         for(Int_t i=0; i<3; ++i) fXsec[i] = xsec[i];
175 }
176
177 Int_t AliLnDriver::Run() const
178 {
179 //
180 // run script
181 //
182         if(!fIsOnlyGen && fMakeCorr) this->MakePtCorr();
183         
184         if(fMakePt) this->MakePt();
185         
186         if(fMakeRatio) this->MakeRatio();
187         
188         if(fMakeSpectra) this->MakeSpectra();
189         
190         return 0;
191 }
192
193 void AliLnDriver::MakePtCorr() const
194 {
195 //
196 // make pt correction file
197 //
198         const Int_t kNpart = 2;
199         const TString kParticle[kNpart] = {fSpecies, Form("Anti%s",fSpecies.Data())};
200         
201         TFileMerger m1, m2;
202         
203         for(Int_t i=0; i<kNpart; ++i)
204         {
205                 TString outputfile1 = kParticle[i] + "-corrections.root";
206                 TString outputfile2 = Form("debug-%s", outputfile1.Data());
207                 
208                 AliLnCorr lncorr(kParticle[i], fInputData, fInputSimu, fInputSimuFix, outputfile1, fOutputCorTag);
209                 
210                 lncorr.GetLnSecondaries()->SetCorBins(fLowPtBin, fHiPtBin);
211                 lncorr.GetLnSecondaries()->SetProcedure(fSecProd);
212                 lncorr.GetLnSecondaries()->SetMatDCAxyModel(fMatDCAxyMod);
213                 lncorr.GetLnSecondaries()->SetAntiNucleusAsTemplate(fANucTemplate);
214                 lncorr.GetLnSecondaries()->SetDCAxyInterval(fMinDCAxy, fMaxDCAxy);
215                 lncorr.GetLnSecondaries()->SetNBin(fNbin);
216                 lncorr.GetLnSecondaries()->SetScalingFactors(fScMat, fScFd);
217                 
218                 lncorr.GetLnEfficiency()->SetG3Fluka(fG3Fluka);
219                 
220                 lncorr.Exec();
221                 
222                 m1.AddFile(outputfile1.Data(),0);
223                 m2.AddFile(outputfile2.Data(),0);
224         }
225         
226         // merge and remove tmp files
227         
228         m1.OutputFile(fOutputPtCorr.Data());
229         m1.Merge();
230         
231         gSystem->Exec(Form("rm -f %s-corrections.root Anti%s-corrections.root", fSpecies.Data(), fSpecies.Data()));
232         
233         m2.OutputFile(fOutputPtCorrDebug.Data());
234         m2.Merge();
235         
236         gSystem->Exec(Form("rm -f debug-%s-corrections.root debug-Anti%s-corrections.root", fSpecies.Data(), fSpecies.Data()));
237 }
238
239 void AliLnDriver::MakePt() const
240 {
241 //
242 // make pt from data and correction file
243 //
244         const Int_t kNpart = 2;
245         
246         const TString kParticle[kNpart] = { fSpecies, Form("Anti%s",fSpecies.Data())};
247         
248         TFileMerger m, m2;
249         
250         for(Int_t i=0; i<kNpart; ++i)
251         {
252                 TString ptfile   = kParticle[i] + "-Pt.root";
253                 
254                 AliLnPt lnpt(kParticle[i], fTrigEff[0], fInputData, ptfile, fOutputTag, fOutputPtCorr, fOutputCorTag);
255                 
256                 lnpt.SetOnlyGeneration(fIsOnlyGen);
257                 lnpt.SetRapidityInterval(fYMin, fYMax);
258                 
259                 lnpt.SetPtBinInterval(fLowPtBin, fHiPtBin);
260                 lnpt.SetM2BinInterval(fLowM2Bin, fHighM2Bin);
261                 lnpt.SetM2BkgInterval(fMinM2Bkg, fMaxM2Bkg);
262                 lnpt.SetM2TPCInterval(fMinM2tpc, fMaxM2tpc);
263                 lnpt.SetPidM2(fPidM2);
264                 lnpt.SetUnfolding(fUnfolding, fNIter);
265                 lnpt.SetFakeTracks(fFakeTracks);
266                 lnpt.SetSecondaries(fSecondaries);
267                 lnpt.SetEfficiency(fEfficiency);
268                 lnpt.SetMakeStats(fMakeStats);
269                 lnpt.SetVertexCorrection(fVtxCorr, fVtxCorrVal);
270                 lnpt.SetFitFractionCorr(fFitFrac);
271                 lnpt.SetFeedDownCorr(fFdwnCorr);
272                 lnpt.SetSameFeedDownCorr(fSameFdwn);
273                 
274                 lnpt.Exec();
275                 
276                 m.AddFile(ptfile.Data(),0);
277                 if(!fIsOnlyGen) m2.AddFile(Form("debug-%s",ptfile.Data()),0);
278         }
279         
280         // merge and remove tmp files
281         
282         m.OutputFile(fOutputPt.Data());
283         m.Merge();
284         
285         gSystem->Exec(Form("rm -f %s-Pt.root Anti%s-Pt.root", fSpecies.Data(), fSpecies.Data()));
286         
287         if(!fIsOnlyGen)
288         {
289                 m2.OutputFile(fOutputPtDebug.Data());
290                 m2.Merge();
291                 
292                 gSystem->Exec(Form("rm -f debug-%s-Pt.root debug-Anti%s-Pt.root", fSpecies.Data(),fSpecies.Data()));
293         }
294 }
295
296 void AliLnDriver::MakeRatio() const
297 {
298 //
299 // make antiparticle/particle ratio
300 //
301         AliLnRatio lnr(fSpecies, fOutputPt, fOutputTag, fOutputRatio, fOutputTag);
302         
303         lnr.Exec();
304 }
305
306 void AliLnDriver::MakeSpectra() const
307 {
308 //
309 // make differential yields
310 //
311         TFileMerger m;
312         
313         const TString kParticle[]  = { fSpecies, Form("Anti%s",fSpecies.Data())};
314         const Double_t kSysErr[] = { fSysPos, fSysNeg };
315         
316         for(Int_t i=0; i<2; ++i)
317         {
318                 TString spectrafile = kParticle[i] + "-Spectra.root";
319                 
320                 AliLnSpectra lnspectra(kParticle[i], fOutputPt, fOutputTag, spectrafile, fOutputTag, fXsec);
321                 
322                 lnspectra.SetRapidityInterval(fYMin, fYMax);
323                 lnspectra.SetNormalizeToINEL(fNormToInel);
324                 lnspectra.SetOnlyGeneration(fIsOnlyGen);
325                 lnspectra.SetScalingFactor(kSysErr[i]);
326                 
327                 lnspectra.Exec();
328                 
329                 m.AddFile(spectrafile.Data(),0);
330         }
331         
332         // merge and remove tmp files
333         
334         m.OutputFile(fOutputSpectra.Data());
335         m.Merge();
336         
337         gSystem->Exec(Form("rm -f %s-Spectra.root Anti%s-Spectra.root", fSpecies.Data(), fSpecies.Data()));
338 }