]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/FORWARD/analysis2/AliFMDMultCuts.cxx
merging trunk to TPCdev
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / AliFMDMultCuts.cxx
1 #include "AliFMDMultCuts.h"
2 #include "AliForwardCorrectionManager.h"
3 #include "AliFMDCorrELossFit.h"
4 #include "AliForwardUtil.h"
5 #include <iostream>
6 #include <TROOT.h>
7 #include <TParameter.h>
8
9 ClassImp(AliFMDMultCuts)
10 #if 0
11 ; // This is for Emacs
12 #endif
13
14 //____________________________________________________________________
15 AliFMDMultCuts::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 //____________________________________________________________________
24 AliFMDMultCuts::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 //____________________________________________________________________
33 AliFMDMultCuts&
34 AliFMDMultCuts::operator=(const AliFMDMultCuts& o)
35 {
36   if (&o == this) return *this; 
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 //____________________________________________________________________
45 Double_t
46 AliFMDMultCuts::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;
52   case 2: idx = 1 + ((r == 'I' || r == 'i') ? 0 : 1); break;
53   case 3: idx = 3 + ((r == 'I' || r == 'i') ? 0 : 1); break;
54   }
55   if (idx < 0) return -1024;
56   return fMultCuts[idx];
57 }
58
59 //____________________________________________________________________
60 void
61 AliFMDMultCuts::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 //____________________________________________________________________
76 Double_t
77 AliFMDMultCuts::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);
89  
90   if (rcut > 0) return rcut;
91
92   AliForwardCorrectionManager&  fcm = AliForwardCorrectionManager::Instance();
93   const 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 //____________________________________________________________________
103 Double_t
104 AliFMDMultCuts::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   const AliFMDCorrELossFit*     fits = fcm.GetELossFit();
117   Int_t                         iEta = fits ? fits->FindEtaBin(eta) : 1;
118   
119   return GetMultCut(d, r, iEta, errors);
120 }
121 //____________________________________________________________________
122 UShort_t
123 AliFMDMultCuts::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 //____________________________________________________________________
131 const char*
132 AliFMDMultCuts::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
143 //____________________________________________________________________
144 void
145 AliFMDMultCuts::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     
155
156   ll->Add(AliForwardUtil::MakeParameter("nXi", fNXi));
157   ll->Add(AliForwardUtil::MakeParameter("frac", fMPVFraction));
158   ll->Add(AliForwardUtil::MakeParameter("sigma", fIncludeSigma));
159   ll->Add(AliForwardUtil::MakeParameter("method", GetMethod()));
160 }
161 //____________________________________________________________________
162 Bool_t
163 AliFMDMultCuts::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;
181 }
182   
183 //____________________________________________________________________
184 void
185 AliFMDMultCuts::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 
191             << ind << "  Method used:           " << GetMethodString() << '\n'
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 //