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