B2 analysis code
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / Nuclei / B2 / macros / Config_Proton_TPCTOF_LHC10x.C
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 // LHC10x config for protons and antiprotons
17 // author: Eulogio Serradilla <eulogio.serradilla@cern.ch>
18
19 #include <Riostream.h>
20 #include <TSystem.h>
21 #include <TString.h>
22 #include <TFileMerger.h>
23
24 #include "AliLnDriver.h"
25 #include "Config.h"
26
27 Int_t Config_Proton_TPCTOF_LHC10x(const TString& inputDir   = "~/alice/input",
28                                   const TString& outputDir  = "~/alice/output",
29                                   const TString& period     = "lhc10d",
30                                   const TString& outputTag  = "lhc10d",
31                                   const TString& multTag    = "",
32                                   const TString& multCorTag = "",
33                                   Bool_t normToInel         = 1,  // for mult
34                                   Bool_t drawOutput         = 1)  // for batch
35 {
36 //
37 // lhc10b, lhc10c, lhc10d, lhc10e config for protons and antiprotons
38 // (combine TPC and TOF)
39 //
40         const TString  kSpecies      = "Proton";
41         
42         const TString  kTrkSelTPC    = "its_tpc_dca_spd-bayes";
43         const TString  kTrkSelTOF    = "its_tpc_tof_dca_spd-bayes";
44         
45         const TString  kOutputTagTPC = outputTag + "-tpc";
46         const TString  kOutputTagTOF = outputTag + "-tof";
47         
48         const Int_t    kJointBin     = 11;
49         const Int_t    kHiPtBin      = 36;
50         
51         const TString  kTrigName     = "mbor";
52         const Bool_t   kVtxCorr      = 0;
53         const Double_t kVtxCorrVal   = GetVertexCorrection(period);
54         
55         const Bool_t   kUnfolding    = 0;
56         const Bool_t   kFakeTracks   = 0;
57         const Bool_t   kSecondaries  = 1;
58         const Int_t    kSecProd      = 0; // 0 tff, 1 roofit, 2 mc
59         const Int_t    kMatDCAxyMod  = 1; // 0 geant, 1 flat
60         const Int_t    kNbin         = 10;
61         const Double_t kDCAxy[2]     = {-1.,1.};
62         const Bool_t   kEfficiency   = 1;
63         const Bool_t   kG3Fluka      = 0;
64         const Double_t kMatScaling   = 1.9;
65         const Double_t kFdwnScaling  = 1.9;
66         const Bool_t   kFitFrac      = 0;
67         const Bool_t   kSameFdwn     = 1;
68         
69         const Double_t kSysErr[2]    = {0.08, 0.08} ;
70         
71         Double_t xsec[3];
72         GetInelXSection(xsec, period);
73         
74         Double_t trigEff[3];
75         GetTriggerEfficiency(trigEff, kTrigName, period);
76         
77         // common options
78         
79         AliLnDriver driver;
80         
81         driver.SetSpecies(kSpecies);
82         
83         driver.SetTriggerEfficiency(trigEff);
84         driver.SetInelXSection(xsec);
85         driver.SetNormalizeToINEL(normToInel);
86         driver.SetVertexCorrection(kVtxCorr, kVtxCorrVal);
87         
88         driver.SetPidM2(0);
89         driver.SetUnfolding(kUnfolding);
90         driver.SetFakeTracks(kFakeTracks);
91         driver.SetSecondaries(kSecondaries);
92         driver.SetSecProd(kSecProd);
93         driver.SetMatDCAxyModel(kMatDCAxyMod);
94         driver.SetNBin(kNbin);
95         driver.SetDCAxyInterval(kDCAxy[0], kDCAxy[1]);
96         driver.SetEfficiency(kEfficiency,kG3Fluka);
97         driver.SetScalingFactors(kMatScaling, kFdwnScaling);
98         driver.SetFitFractionCorr(kFitFrac);
99         driver.SetSameFeedDownCorr(kSameFdwn);
100         
101         driver.SetSysErr(kSysErr[0],kSysErr[1]);
102         
103         // get the pt with TPC up to kJointBin
104         
105         TString inputDataTPC     = inputDir + "/" + period + "/"
106                                  + MakeInputName(kSpecies, period, kTrkSelTPC+multTag) + ".root";
107         
108         TString inputSimuTPC     = inputDir + "/" + period + "/"
109                                  + MakeSimuName(kSpecies, period, kTrkSelTPC+multCorTag) + ".root";
110         
111         TString inputSimuFixTPC  = inputDir + "/" + period + "/"
112                                  + MakeSimuFixName(kSpecies, period, kTrkSelTPC+multCorTag, kG3Fluka) + ".root";
113         
114         TString inputCorrTPC     = inputDir + "/" + period + "/"
115                                  + MakeInputName(kSpecies, period, kTrkSelTPC+multTag) + "-corr.root";
116         
117         TString outputPtTPC      = outputDir + "/" + MakeOutputName(kSpecies, kOutputTagTPC) + "-Pt.root";
118         TString outputRatioTPC   = outputDir + "/" + MakeOutputName(kSpecies, kOutputTagTPC) + "-Ratio.root";
119         TString outputSpectraTPC = outputDir + "/" + MakeOutputName(kSpecies, kOutputTagTPC) + "-Spectra.root";
120         
121         
122         driver.SetInputFilenames(inputDataTPC, inputSimuTPC, inputSimuFixTPC, inputCorrTPC);
123         driver.SetOutputFilenames(outputPtTPC, outputRatioTPC, outputSpectraTPC);
124         
125         driver.SetOutputTag(kOutputTagTPC);
126         
127         driver.SetMakeStats(0);
128         driver.SetMakeCorrections(1);
129         driver.SetMakePt(1);
130         driver.SetMakeRatio(0);
131         driver.SetMakeSpectra(0);
132         
133         driver.SetPtBinInterval(5, kJointBin);
134         
135         TString outputCorrDebugTPC = driver.GetPtCorrDebugFilename();
136         TString outputPtDebugTPC   = driver.GetPtDebugFilename();
137         
138         driver.Run();
139         
140         // get the pt with TOF from kJointBin to kHiPtBin
141         
142         TString inputDataTOF     = inputDir + "/" + period + "/"
143                                  + MakeInputName(kSpecies, period, kTrkSelTOF+multTag) + ".root";
144         
145         TString inputSimuTOF     = inputDir + "/" + period + "/"
146                                  + MakeSimuName(kSpecies, period, kTrkSelTOF+multCorTag) + ".root";
147         
148         TString inputSimuFixTOF  = inputDir + "/" + period + "/"
149                                  + MakeSimuFixName(kSpecies, period, kTrkSelTOF+multCorTag) + ".root";
150         
151         TString inputCorrTOF     = inputDir + "/" + period + "/"
152                                  + MakeInputName(kSpecies, period, kTrkSelTOF+multTag) + "-corr.root";
153         
154         TString outputPtTOF      = outputDir + "/" + MakeOutputName(kSpecies, kOutputTagTOF) + "-Pt.root";
155         TString outputRatioTOF   = outputDir + "/" + MakeOutputName(kSpecies, kOutputTagTOF) + "-Ratio.root";
156         TString outputSpectraTOF = outputDir + "/" + MakeOutputName(kSpecies, kOutputTagTOF) + "-Spectra.root";
157         
158         
159         driver.SetInputFilenames(inputDataTOF, inputSimuTOF, inputSimuFixTOF, inputCorrTOF);
160         driver.SetOutputFilenames(outputPtTOF, outputRatioTOF, outputSpectraTOF);
161         
162         driver.SetOutputTag(kOutputTagTOF);
163         
164         driver.SetMakeStats(1);
165         driver.SetMakeCorrections(1);
166         driver.SetMakePt(1);
167         driver.SetMakeRatio(0);
168         driver.SetMakeSpectra(0);
169         
170         driver.SetPtBinInterval(kJointBin, kHiPtBin);
171         driver.SetUnfolding(0);
172         driver.SetEfficiency(kEfficiency,0);
173         
174         TString outputCorrDebugTOF = driver.GetPtCorrDebugFilename();
175         TString outputPtDebugTOF   = driver.GetPtDebugFilename();
176         
177         driver.Run();
178         
179         // combine TPC and TOF pt
180         
181         TString outputPt      = outputDir + "/" + MakeOutputName(kSpecies, outputTag) + "-Pt.root";
182         TString outputRatio   = outputDir + "/" + MakeOutputName(kSpecies, outputTag) + "-Ratio.root";
183         TString outputSpectra = outputDir + "/" + MakeOutputName(kSpecies, outputTag) + "-Spectra.root";
184         
185         TFileMerger m;
186         
187         m.AddFile(outputPtTPC.Data(),0);
188         m.AddFile(outputPtTOF.Data(),0);
189         
190         m.OutputFile(outputPt.Data());
191         
192         m.Merge();
193         
194         // make ratio and spectra
195         
196         driver.SetOutputFilenames(outputPt, outputRatio, outputSpectra);
197         
198         driver.SetOutputTag(outputTag);
199         
200         driver.SetMakeCorrections(0);
201         driver.SetMakePt(0);
202         driver.SetMakeRatio(1);
203         driver.SetMakeSpectra(1);
204         
205         driver.Run();
206         
207         // delete tmp files
208         
209         gSystem->Exec(Form("rm -f %s %s %s %s", inputCorrTPC.Data(), outputPtTPC.Data(), outputCorrDebugTPC.Data(), outputPtDebugTPC.Data()));
210         gSystem->Exec(Form("rm -f %s %s %s %s", inputCorrTOF.Data(), outputPtTOF.Data(), outputCorrDebugTOF.Data(), outputPtDebugTOF.Data()));
211         
212         // draw output
213         
214         if(!drawOutput) return 0;
215         
216         TStyle* st = GetDrawingStyle();
217         st->cd();
218         gROOT->ForceStyle();
219         
220         DrawOutputRatio(outputRatio, outputTag, kSpecies);
221         DrawOutputSpectra(outputSpectra, outputTag, kSpecies);
222         
223         return 0;
224 }