]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/FORWARD/analysis2/corrs/MakeELossFitsFromFile.C
Various fixes and more automation
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / corrs / MakeELossFitsFromFile.C
1 /**
2  * @file   MakeELossFitsFromFile.C
3  * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
4  * @date   Thu Jul  7 11:23:50 2011
5  * 
6  * @brief This script takes the output list from a file and applies
7  * the energy fitter directly. In principle this should be done by the
8  * train via AliFMDEnergyFitterTask::Terminate but if this fails or
9  * impatience takes over this script can help...
10  *
11  * @ingroup pwglf_forward_scripts_corr
12  */
13 /** 
14  * 
15  * 
16  * @param filename 
17  * @param sys 
18  * @param sNN 
19  * @param field 
20  * @param mc 
21  *
22  * @ingroup pwglf_forward_scripts_corr
23  */
24 void MakeELossFitsFromFile(const Char_t* filename="forward.root",
25                            UShort_t sys=1, UShort_t sNN=900, Short_t field=5, 
26                            Bool_t mc=false) 
27 {
28   
29   gROOT->Macro("$ALICE_ROOT/PWGLF/FORWARD/analysis2/scripts/LoadLibs.C");
30   
31   TFile::Open(filename);
32   TList* list = (TList*)gFile->Get("Forward");
33   
34   AliForwardCorrectionManager::Instance().Init(sys, sNN, field, mc, 0);
35   
36   AliFMDEnergyFitter fitter("Fitter");
37   // Set the eta axis to use - note, this overrides whatever is used
38   // by the rest of the algorithms - but only for the energy fitter
39   // algorithm. 
40   fitter.SetEtaAxis(200, -4, 6);
41   // Set maximum energy loss to consider 
42   fitter.SetMaxE(15); 
43   // Set number of energy loss bins 
44   fitter.SetNEbins(450);
45   // Set whether to use increasing bin sizes 
46   fitter.SetUseIncreasingBins(true);
47   // Set whether to do fit the energy distributions 
48   fitter.SetDoFits(kTRUE);
49   // Set whether to make the correction object 
50   fitter.SetDoMakeObject(kTRUE);
51   // Set the low cut used for energy
52   fitter.SetLowCut(0.4);
53   // Set the number of bins to subtract from maximum of distributions
54   // to get the lower bound of the fit range
55   fitter.SetFitRangeBinWidth(4);
56   // Set the maximum number of landaus to try to fit (max 5)
57   fitter.SetNParticles(5);
58   // Set the minimum number of entries in the distribution before
59   // trying to fit to the data
60   fitter.SetMinEntries(1000);
61   fitter.SetMaxRelativeParameterError(0.12);
62   fitter.SetMaxChi2PerNDF(20);
63   fitter.SetMinWeight(1e-5);
64   // --- Set limits on fits the energy -------------------------------
65   // Maximum relative error on parameters 
66   AliFMDCorrELossFit::ELossFit::fgMaxRelError = .12;
67   // Least weight to use 
68   AliFMDCorrELossFit::ELossFit::fgLeastWeight = 1e-5;
69   // Maximum value of reduced chi^2 
70   AliFMDCorrELossFit::ELossFit::fgMaxChi2nu   = 20;
71
72   TList* dummy = new TList;
73   fitter.DefineOutput(dummy);
74   TAxis a(200, -4, 6); // ignored, but needed
75   fitter.Init(a); 
76
77   fitter.Fit(list);
78
79   list->ls();
80   TDirectory* savdir = gDirectory;
81   TFile* tmp = TFile::Open("elossfits.root", "RECREATE");
82   list->Write(list->GetName(), TObject::kSingleKey);
83   dummy->Write("dummy",  TObject::kSingleKey);
84   tmp->Write();
85   tmp->Close();
86   savdir->cd();
87 }
88 //
89 // EOF
90 //