Add method as parameter output
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / AliFMDMultCuts.cxx
CommitLineData
bfcbb65a 1#include "AliFMDMultCuts.h"
2#include "AliForwardCorrectionManager.h"
3#include "AliFMDCorrELossFit.h"
241cca4d 4#include "AliForwardUtil.h"
bfcbb65a 5#include <iostream>
6#include <TROOT.h>
7#include <TParameter.h>
8
9ClassImp(AliFMDMultCuts)
10#if 0
11; // This is for Emacs
12#endif
13
14//____________________________________________________________________
15AliFMDMultCuts::AliFMDMultCuts()
16 : TObject(),
17 fMPVFraction(0),
18 fNXi(0),
19 fIncludeSigma(true)
20{
21 for (Int_t i = 0; i < 5; i++) fMultCuts[i] = 0;
22}
23//____________________________________________________________________
24AliFMDMultCuts::AliFMDMultCuts(const AliFMDMultCuts& o)
25 : TObject(o),
26 fMPVFraction(o.fMPVFraction),
27 fNXi(o.fNXi),
28 fIncludeSigma(o.fIncludeSigma)
29{
30 for (Int_t i = 0; i < 5; i++) fMultCuts[i] = o.fMultCuts[i];
31}
32//____________________________________________________________________
33AliFMDMultCuts&
34AliFMDMultCuts::operator=(const AliFMDMultCuts& o)
35{
d015ecfe 36 if (&o == this) return *this;
bfcbb65a 37 fMPVFraction = o.fMPVFraction;
38 fNXi = o.fNXi;
39 fIncludeSigma = o.fIncludeSigma;
40 for (Int_t i = 0; i < 5; i++) fMultCuts[i] = o.fMultCuts[i];
41 return *this;
42}
43
44//____________________________________________________________________
45Double_t
46AliFMDMultCuts::GetFixedCut(UShort_t d, Char_t r) const
47{
48 // Int_t idx = (d == 1 ? 0 : 2*(d - 2) + 1 + ((r=='I' || r=='i') ? 0 : 1));
49 Int_t idx = -1;
50 switch (d) {
51 case 1: idx = 0; break;
b63fc7df 52 case 2: idx = 1 + ((r == 'I' || r == 'i') ? 0 : 1); break;
53 case 3: idx = 3 + ((r == 'I' || r == 'i') ? 0 : 1); break;
bfcbb65a 54 }
55 if (idx < 0) return 1024;
56 return fMultCuts[idx];
57}
58
59//____________________________________________________________________
60void
61AliFMDMultCuts::SetMultCuts(Double_t fmd1i,
62 Double_t fmd2i,
63 Double_t fmd2o,
64 Double_t fmd3i,
65 Double_t fmd3o)
66{
67 fMultCuts[0] = fmd1i;
68 fMultCuts[1] = fmd2i >= 0 ? fmd2i : fmd1i;
69 fMultCuts[2] = fmd2o >= 0 ? fmd2o : fmd1i;
70 fMultCuts[3] = fmd3i >= 0 ? fmd3i : fmd1i;
71 fMultCuts[4] = fmd3o >= 0 ? fmd3o : fmd1i;
72}
73
74
75//____________________________________________________________________
76Double_t
77AliFMDMultCuts::GetMultCut(UShort_t d, Char_t r, Int_t ieta,
78 Bool_t errors) const
79{
80 //
81 // Get the multiplicity cut. If the user has set fMultCut (via
82 // SetMultCut) then that value is used. If not, then the lower
83 // value of the fit range for the enery loss fits is returned.
84 //
85 // Return:
86 // Lower cut on multiplicity
87 //
88 Double_t rcut = GetFixedCut(d, r);
4077f3e8 89
bfcbb65a 90 if (rcut > 0) return rcut;
91
92 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
93 AliFMDCorrELossFit* fits = fcm.GetELossFit();
94 if (fMPVFraction > 0)
95 return fits->GetLowerBound(d, r, ieta, fMPVFraction);
96
97 if (fNXi < 0) return fits->GetLowCut();
98
99 return fits->GetLowerBound(d, r, ieta, fNXi, errors, fIncludeSigma);
100}
101
102//____________________________________________________________________
103Double_t
104AliFMDMultCuts::GetMultCut(UShort_t d, Char_t r, Double_t eta,
105 Bool_t errors) const
106{
107 //
108 // Get the multiplicity cut. If the user has set fMultCut (via
109 // SetMultCut) then that value is used. If not, then the lower
110 // value of the fit range for the enery loss fits is returned.
111 //
112 // Return:
113 // Lower cut on multiplicity
114 //
115 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
116 AliFMDCorrELossFit* fits = fcm.GetELossFit();
e441e255 117 Int_t iEta = fits ? fits->FindEtaBin(eta) : 1;
bfcbb65a 118
119 return GetMultCut(d, r, iEta, errors);
120}
c514a160 121//____________________________________________________________________
122UShort_t
123AliFMDMultCuts::GetMethod() const
124{
125 return (fMultCuts[0] >= 0 ? kFixed : // Fixed
126 fMPVFraction > 0 ? kMPVFraction : // Fraction MPV
127 fNXi < 0 ? kFitRange : // Fit range
128 kLandauWidth);
129}
130//____________________________________________________________________
131const char*
132AliFMDMultCuts::GetMethodString() const
133{
134 switch (GetMethod()) {
135 case kFixed: return "fixed value";
136 case kMPVFraction: return "fraction of MPV";
137 case kFitRange: return "fit range";
138 case kLandauWidth: return "landau width";
139 }
140 return "unknown";
141}
142
bfcbb65a 143//____________________________________________________________________
144void
145AliFMDMultCuts::Output(TList* l, const char* name) const
146{
147 TList* ll = l;
148 if (name && name[0] != '\0') {
149 ll = new TList;
150 ll->SetName(name);
151 ll->SetOwner();
152 l->Add(ll);
153 }
154
c514a160 155
241cca4d 156 ll->Add(AliForwardUtil::MakeParameter("nXi", fNXi));
157 ll->Add(AliForwardUtil::MakeParameter("frac", fMPVFraction));
158 ll->Add(AliForwardUtil::MakeParameter("sigma", fIncludeSigma));
c514a160 159 ll->Add(AliForwardUtil::MakeParameter("method", GetMethod()));
241cca4d 160}
161//____________________________________________________________________
162Bool_t
163AliFMDMultCuts::Input(TList* l, const char* name)
164{
165 if (!l) return false;
166 TList* ll = l;
167 if (name && name[0] != '\0') {
168 ll = static_cast<TList*>(l->FindObject(name));
169 }
170 if (!ll) return false;
171
172 TObject* nXi = ll->FindObject("nXi");
173 TObject* frac = ll->FindObject("frac");
174 TObject* sigma = ll->FindObject("sigma");
175 if (!nXi || !frac || !sigma) return false;
176 AliForwardUtil::GetParameter(nXi, fNXi);
177 AliForwardUtil::GetParameter(frac, fMPVFraction);
178 AliForwardUtil::GetParameter(sigma, fIncludeSigma);
179
180 return true;
bfcbb65a 181}
182
183//____________________________________________________________________
184void
185AliFMDMultCuts::Print(Option_t*) const
186{
187 char ind[gROOT->GetDirLevel()+1];
188 for (Int_t i = 0; i < gROOT->GetDirLevel(); i++) ind[i] = ' ';
189 ind[gROOT->GetDirLevel()] = '\0';
190 std::cout << std::boolalpha
c514a160 191 << ind << " Method used: " << GetMethodString() << '\n'
bfcbb65a 192 << ind << " Fixed cuts: "
193 << "FMD1i=" << GetFixedCut(1,'I') << " "
194 << "FMD2i=" << GetFixedCut(2,'I') << " "
195 << "FMD2o=" << GetFixedCut(2,'O') << " "
196 << "FMD3i=" << GetFixedCut(3,'I') << " "
197 << "FMD3o=" << GetFixedCut(3,'O') << "\n"
198 << ind << " N xi factor: " << fNXi << '\n'
199 << ind << " Include sigma in cut: " << fIncludeSigma << '\n'
200 << ind << " MPV fraction: " << fMPVFraction
201 << std::noboolalpha << std::endl;
202}
203//____________________________________________________________________
204//
205// EOF
206//