]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/SPECTRA/Nuclei/B2/AliLnDriver.cxx
Added support for He3 and BA
[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 "AliLnDriver.h"
34 #include "B2.h"
35
36
37 ClassImp(AliLnDriver)
38
39 AliLnDriver::AliLnDriver()
40 : TObject()
41 , fSpecies("Deuteron")
42 , fOutputTag("test")
43 , fOutputCorTag("")
44 , fIsOnlyGen(0)
45 , fINEL(1)
46 , fMakeCorr(1)
47 , fMakePt(1)
48 , fMakeRatio(1)
49 , fMakeSpectra(1)
50 , fMakeStats(1)
51 , fPtMin(3)
52 , fPtMax(15)
53 , fPid(0.4)
54 , fPidPt(1.)
55 , fSecondaries(1)
56 , fSecProc(AliLnSecondaries::kTFractionFitter)
57 , fMatDCAxyMod(AliLnSecondaries::kGeantDCAxy)
58 , fANucTemplate(0)
59 , fNbin(1)
60 , fYMin(-0.5)
61 , fYMax(0.5)
62 , fMinDCAxy(-1.5)
63 , fMaxDCAxy(1.5)
64 , fBkgMin(2.2)
65 , fBkgMax(5.)
66 , fIntMin(2.)
67 , fIntMax(6.5)
68 , fEfficiency(1)
69 , fG3Fluka(0)
70 , fScMat(1)
71 , fScFd(1)
72 , fInputData()
73 , fInputSimu()
74 , fInputSimuFix()
75 , fOutputPtCorr()
76 , fOutputPt()
77 , fOutputRatio()
78 , fOutputSpectra()
79 , fOutputPtCorrDebug()
80 , fOutputPtDebug()
81 , fFitFrac(0)
82 , fFdwnCorr(1)
83 , fSameFdwn(0)
84 , fMCtoINEL(0)
85 , fAddFakeTracks(1)
86 , fPidProc(AliLnPt::kMassSquared)
87 , fPidEff(1)
88 , fDebugLevel(0)
89 {
90 //
91 // constructor
92 //
93         for(Int_t i=0; i<3; ++i)
94         {
95                 fTrigEff[i] = 1;
96         }
97         
98         gErrorIgnoreLevel = kWarning;
99         // gErrorIgnoreLevel = kPrint, kInfo, kWarning, kError, kBreak, kSysError, kFatal;
100 }
101
102 AliLnDriver::~AliLnDriver()
103 {
104 //
105 // destructor
106 //
107 }
108
109 void AliLnDriver::SetInputFilenames(const TString& data, const TString& simu, const TString& simuFix, const TString& ptcorr)
110 {
111 //
112 // input filenames to get the pt
113 //
114         fInputData = data;
115         fInputSimu = simu;
116         fInputSimuFix = simuFix;
117         fOutputPtCorr = ptcorr;
118         
119         fOutputPtCorrDebug = ptcorr;
120         fOutputPtCorrDebug.Replace(ptcorr.Length()-5,5,"-debug.root");
121 }
122
123 void AliLnDriver::SetOutputFilenames(const TString& pt, const TString& ratio, const TString& spectra)
124 {
125 //
126 // output filenames
127 //
128         fOutputPt = pt;
129         fOutputRatio=ratio;
130         fOutputSpectra=spectra;
131         
132         fOutputPtDebug = pt;
133         fOutputPtDebug.Replace(pt.Length()-5,5,"-debug.root");
134 }
135
136 void AliLnDriver::SetTriggerEfficiency(Double_t eff[3])
137 {
138 //
139 // set trigger efficiency
140 //
141         for(Int_t i=0; i<3; ++i) fTrigEff[i] = eff[i];
142 }
143
144 Int_t AliLnDriver::Run() const
145 {
146 //
147 // run script
148 //
149         using namespace std;
150         
151         if(!fIsOnlyGen && fMakeCorr)
152         {
153                 if(fDebugLevel > 0 )
154                 {
155                         cout << endl;
156                         cout << "********* Rebuild corrections ***********" << endl;
157                         cout << "Species               : " << fSpecies << endl;
158                         cout << "Simulation file       : " << fInputSimu << endl;
159                         cout << "Simulation file (fix) : " << fInputSimuFix << endl;
160                         cout << "Output file           : " << fOutputPtCorr << endl;
161                         cout << "Output file (debug)   : " << fOutputPtCorrDebug << endl;
162                         cout << endl;
163                 }
164                 
165                 this->MakePtCorr();
166         }
167         
168         if(fMakePt)
169         {
170                 if(fDebugLevel > 0 )
171                 {
172                         cout << endl;
173                         cout << "********* Make pt ***********" << endl;
174                         cout << "Species             : " << fSpecies << endl;
175                         cout << "pt interval (GeV/c) : (" << fPtMin << ", " << fPtMax << ")" << endl;
176                         cout << "pid pt (GeV/c)      : " << fPidPt <<  endl;
177                         cout << "Input file          : " << fInputData << endl;
178                         cout << "Correction file     : " << fOutputPtCorr << endl;
179                         cout << "Output file         : " << fOutputPt << endl;
180                         cout << "Output file (debug) : " << fOutputPtDebug << endl;
181                         cout << endl;
182                 }
183                 
184                 this->MakePt();
185         }
186         
187         if(fMakeRatio)
188         {
189                 if(fDebugLevel > 0 )
190                 {
191                         cout << endl;
192                         cout << "********* Make ratio ***********" << endl;
193                         cout << "Species             : " << fSpecies << endl;
194                         cout << "Input file          : " << fOutputPt << endl;
195                         cout << "Output file         : " << fOutputRatio << endl;
196                         cout << endl;
197                 }
198                 
199                 this->MakeRatio();
200         }
201         
202         if(fMakeSpectra)
203         {
204                 if(fDebugLevel > 0 )
205                 {
206                         cout << endl;
207                         cout << "********* Make spectra ***********" << endl;
208                         cout << "Species             : " << fSpecies << endl;
209                         cout << "INEL extrapolation  : " << fINEL << endl;
210                         cout << "Rapidity interval   : (" << fYMin << ", " << fYMax << ")" << endl;
211                         cout << "Input file          : " << fOutputPt << endl;
212                         cout << "Output file         : " << fOutputSpectra << endl;
213                         cout << endl;
214                 }
215                 
216                 this->MakeSpectra();
217         }
218         
219         return 0;
220 }
221
222 void AliLnDriver::MakePtCorr() const
223 {
224 //
225 // make pt correction file
226 //
227         const Int_t kNpart = 2;
228         const TString kParticle[kNpart] = {fSpecies, Form("Anti%s",fSpecies.Data())};
229         
230         TFileMerger m1, m2;
231         
232         for(Int_t i=0; i<kNpart; ++i)
233         {
234                 TString outputfile1 = kParticle[i] + "-corrections.root";
235                 TString outputfile2 = Form("debug-%s", outputfile1.Data());
236                 
237                 AliLnCorr lncorr(kParticle[i], fInputData, fInputSimu, fInputSimuFix, outputfile1, fOutputCorTag);
238                 
239                 lncorr.GetLnSecondaries()->SetCorBins(fPtMin, fPtMax);
240                 lncorr.GetLnSecondaries()->SetProcedure(fSecProc);
241                 lncorr.GetLnSecondaries()->SetMatDCAxyModel(fMatDCAxyMod);
242                 lncorr.GetLnSecondaries()->SetAntiNucleusAsTemplate(fANucTemplate);
243                 lncorr.GetLnSecondaries()->SetDCAxyInterval(fMinDCAxy, fMaxDCAxy);
244                 lncorr.GetLnSecondaries()->SetNBin(fNbin);
245                 lncorr.GetLnSecondaries()->SetScalingFactors(fScMat, fScFd);
246                 lncorr.GetLnSecondaries()->SetAddFakeTracks(fAddFakeTracks);
247                 
248                 lncorr.GetLnEfficiency()->SetG3Fluka(fG3Fluka);
249                 lncorr.GetLnEfficiency()->SetAddFakeTracks(fAddFakeTracks);
250                 
251                 lncorr.Exec();
252                 
253                 m1.AddFile(outputfile1.Data(),0);
254                 m2.AddFile(outputfile2.Data(),0);
255         }
256         
257         // merge and remove tmp files
258         
259         m1.OutputFile(fOutputPtCorr.Data());
260         m1.Merge();
261         
262         gSystem->Exec(Form("rm -f %s-corrections.root Anti%s-corrections.root", fSpecies.Data(), fSpecies.Data()));
263         
264         m2.OutputFile(fOutputPtCorrDebug.Data());
265         m2.Merge();
266         
267         gSystem->Exec(Form("rm -f debug-%s-corrections.root debug-Anti%s-corrections.root", fSpecies.Data(), fSpecies.Data()));
268 }
269
270 void AliLnDriver::MakePt() const
271 {
272 //
273 // make pt from data and correction file
274 //
275         const Int_t kNpart = 2;
276         
277         const TString kParticle[kNpart] = { fSpecies, Form("Anti%s",fSpecies.Data())};
278         
279         TFileMerger m, m2;
280         
281         for(Int_t i=0; i<kNpart; ++i)
282         {
283                 TString ptfile   = kParticle[i] + "-Pt.root";
284                 
285                 AliLnPt lnpt(kParticle[i], fTrigEff[0], fInputData, ptfile, fOutputTag, fOutputPtCorr, fOutputCorTag);
286                 
287                 lnpt.SetOnlyGeneration(fIsOnlyGen);
288                 
289                 lnpt.SetPtInterval(fPtMin, fPtMax);
290                 lnpt.SetPid(fPid);
291                 lnpt.SetPidProcedure(fPidProc);
292                 lnpt.SetPidPt(fPidPt);
293                 lnpt.SetBkgInterval(fBkgMin, fBkgMax);
294                 lnpt.SetPidInterval(fIntMin, fIntMax);
295                 lnpt.SetSecondaries(fSecondaries);
296                 lnpt.SetEfficiency(fEfficiency);
297                 lnpt.SetMakeStats(fMakeStats);
298                 lnpt.SetMCtoINEL(fMCtoINEL);
299                 lnpt.SetFitFractionCorr(fFitFrac);
300                 lnpt.SetFeedDownCorr(fFdwnCorr);
301                 lnpt.SetSameFeedDownCorr(fSameFdwn);
302                 lnpt.SetPidEfficiency(fPidEff);
303                 lnpt.SetDebugLevel(fDebugLevel);
304                 
305                 lnpt.Exec();
306                 
307                 m.AddFile(ptfile.Data(),0);
308                 if(!fIsOnlyGen) m2.AddFile(Form("debug-%s",ptfile.Data()),0);
309         }
310         
311         // merge and remove tmp files
312         
313         m.OutputFile(fOutputPt.Data());
314         m.Merge();
315         
316         gSystem->Exec(Form("rm -f %s-Pt.root Anti%s-Pt.root", fSpecies.Data(), fSpecies.Data()));
317         
318         if(!fIsOnlyGen)
319         {
320                 m2.OutputFile(fOutputPtDebug.Data());
321                 m2.Merge();
322                 
323                 gSystem->Exec(Form("rm -f debug-%s-Pt.root debug-Anti%s-Pt.root", fSpecies.Data(),fSpecies.Data()));
324         }
325 }
326
327 void AliLnDriver::MakeRatio() const
328 {
329 //
330 // make antiparticle/particle ratio
331 //
332         AliLnRatio lnr(fSpecies, fOutputPt, fOutputTag, fOutputRatio, fOutputTag);
333         
334         lnr.Exec();
335 }
336
337 void AliLnDriver::MakeSpectra() const
338 {
339 //
340 // make differential yields
341 //
342         TFileMerger m;
343         
344         const TString kParticle[2] = { fSpecies, Form("Anti%s",fSpecies.Data())};
345         
346         for(Int_t i=0; i<2; ++i)
347         {
348                 TString spectrafile = kParticle[i] + "-Spectra.root";
349                 
350                 AliLnSpectra lnspectra(kParticle[i], fOutputPt, fOutputTag, spectrafile, fOutputTag);
351                 
352                 lnspectra.SetRapidityInterval(fYMin, fYMax);
353                 lnspectra.SetExtrapolateToINEL(fINEL);
354                 
355                 lnspectra.Exec();
356                 
357                 m.AddFile(spectrafile.Data(),0);
358         }
359         
360         // merge and remove tmp files
361         
362         m.OutputFile(fOutputSpectra.Data());
363         m.Merge();
364         
365         gSystem->Exec(Form("rm -f %s-Spectra.root Anti%s-Spectra.root", fSpecies.Data(), fSpecies.Data()));
366 }