1 #include "AliFMDMultCuts.h"
2 #include "AliForwardCorrectionManager.h"
3 #include "AliFMDCorrELossFit.h"
4 #include "AliForwardUtil.h"
8 #include <TParameter.h>
13 ClassImp(AliFMDMultCuts)
15 ; // This is for Emacs
18 //____________________________________________________________________
19 AliFMDMultCuts::AliFMDMultCuts()
28 //____________________________________________________________________
29 AliFMDMultCuts::AliFMDMultCuts(EMethod method,
41 Set(method, cut1, cut2, cut3, cut4, cut5);
44 //____________________________________________________________________
45 AliFMDMultCuts::AliFMDMultCuts(const AliFMDMultCuts& o)
47 fMPVFraction(o.fMPVFraction),
49 fIncludeSigma(o.fIncludeSigma),
50 fProbability(o.fProbability)
52 for (Int_t i = 0; i < 5; i++) fMultCuts[i] = o.fMultCuts[i];
54 //____________________________________________________________________
56 AliFMDMultCuts::operator=(const AliFMDMultCuts& o)
58 if (&o == this) return *this;
59 fMPVFraction = o.fMPVFraction;
61 fIncludeSigma = o.fIncludeSigma;
62 fProbability = o.fProbability;
63 for (Int_t i = 0; i < 5; i++) fMultCuts[i] = o.fMultCuts[i];
66 //____________________________________________________________________
68 AliFMDMultCuts::Reset()
70 for (Int_t i = 0; i < 5; i++) fMultCuts[i] = -1;
73 fIncludeSigma = false;
76 //____________________________________________________________________
78 AliFMDMultCuts::Set(EMethod method,
88 // Then switch on method
91 if (cut2 < 0) SetMultCuts(cut1, cut1, cut1*1.2, cut1*1.2, cut1);
92 else SetMultCuts(cut1, cut2, cut3, cut4, cut5);
101 SetIncludeSigma(cut2 > 0);
104 SetProbability(cut1);
110 //____________________________________________________________________
112 AliFMDMultCuts::GetFixedCut(UShort_t d, Char_t r) const
114 // Int_t idx = (d == 1 ? 0 : 2*(d - 2) + 1 + ((r=='I' || r=='i') ? 0 : 1));
117 case 1: idx = 0; break;
118 case 2: idx = 1 + ((r == 'I' || r == 'i') ? 0 : 1); break;
119 case 3: idx = 3 + ((r == 'I' || r == 'i') ? 0 : 1); break;
121 if (idx < 0) return -1024;
122 return fMultCuts[idx];
125 //____________________________________________________________________
127 AliFMDMultCuts::SetMultCuts(Double_t fmd1i,
133 fMultCuts[0] = fmd1i;
134 fMultCuts[1] = fmd2i >= 0 ? fmd2i : fmd1i;
135 fMultCuts[2] = fmd2o >= 0 ? fmd2o : fmd1i;
136 fMultCuts[3] = fmd3i >= 0 ? fmd3i : fmd1i;
137 fMultCuts[4] = fmd3o >= 0 ? fmd3o : fmd1i;
141 //____________________________________________________________________
143 AliFMDMultCuts::GetMultCut(UShort_t d, Char_t r, Int_t ieta,
147 // Get the multiplicity cut. If the user has set fMultCut (via
148 // SetMultCut) then that value is used. If not, then the lower
149 // value of the fit range for the enery loss fits is returned.
152 // Lower cut on multiplicity
154 UShort_t meth = GetMethod();
155 DGUARD(fDebug, 5, "Get mult cut for FMD%d%c (method %d) @ etabin=%d",
157 Double_t rcut = -1024;
158 if (meth == kFixed) rcut = GetFixedCut(d, r);
161 // Get the energy loss fits
162 AliForwardCorrectionManager& fcm =
163 AliForwardCorrectionManager::Instance();
164 const AliFMDCorrELossFit* fits = fcm.GetELossFit();
168 // Return fMPVFraction * mpv
169 rcut = fits->GetLowerBound(d, r, ieta, fMPVFraction); break;
171 // Return MPV - fNXi * xi
172 rcut = fits->GetLowerBound(d, r, ieta, fNXi, errors,fIncludeSigma);
175 // Return probability cut
176 rcut = fits->GetLowerBound(d, r, ieta, fProbability, true); break;
178 // Return lower fit boundary
179 rcut = fits->GetLowCut(); break;
183 Warning("GetMultCut", "No energy loss fits obtained from manager");
185 DMSG(fDebug, 5, "-> %8.4f", rcut);
190 //____________________________________________________________________
192 AliFMDMultCuts::GetMultCut(UShort_t d, Char_t r, Double_t eta,
196 // Get the multiplicity cut. If the user has set fMultCut (via
197 // SetMultCut) then that value is used. If not, then the lower
198 // value of the fit range for the enery loss fits is returned.
201 // Lower cut on multiplicity
203 DGUARD(fDebug, 5, "Get mult cut for FMD%d%c @ eta=%8.4f",
205 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
206 const AliFMDCorrELossFit* fits = fcm.GetELossFit();
207 Int_t iEta = fits ? fits->FindEtaBin(eta) : 1;
208 DMSG(fDebug, 5, "bin=%4d", iEta);
209 return GetMultCut(d, r, iEta, errors);
211 //____________________________________________________________________
213 AliFMDMultCuts::GetMethod() const
215 return (fMultCuts[0] >= 0 ? kFixed : // Fixed
216 fMPVFraction > 0 ? kMPVFraction : // Fraction MPV
217 fNXi > 0 ? kLandauWidth : // Width
218 fProbability > 0 ? kProbability :
219 kFitRange); // Fit range
221 //____________________________________________________________________
223 AliFMDMultCuts::GetMethodString() const
225 switch (GetMethod()) {
226 case kFixed: return "fixed value";
227 case kMPVFraction: return "fraction of MPV";
228 case kFitRange: return "fit range";
229 case kLandauWidth: return "landau width";
230 case kProbability: return "probability";
235 //____________________________________________________________________
237 AliFMDMultCuts::FillHistogram(TH2* h) const
239 DGUARD(fDebug, 5, "Fill Histogram %s with cuts", h->GetName());
240 AliInfoF("Caching multiplicity cuts (%s)", h->GetName());
241 TAxis* yAxis = h->GetYaxis();
242 for (Int_t iy = 1; iy <= yAxis->GetNbins(); iy++) {
243 TString lab(yAxis->GetBinLabel(iy));
245 UShort_t det = lab.Atoi();
247 // Printf("Filling for FMD%d%c (bin # %d) %s", det, rng, iy, lab.Data());
248 AliInfoF("FMD%d%c", det, rng);
249 for (Int_t ix = 1; ix <= h->GetNbinsX(); ix++) {
250 Double_t eta = h->GetXaxis()->GetBinCenter(ix);
251 Double_t c = GetMultCut(det, rng, eta, false);
252 DMSG(fDebug, 5, "FMD%s bin=%4d -> eta=%8.4f -> %8.4f",
253 lab.Data(), ix, eta, c);
254 // Double_t c = GetMultCut(det, rng, ix, false);
255 if (c > 0) h->SetBinContent(ix, iy, c);
260 //____________________________________________________________________
262 AliFMDMultCuts::Output(TList* l, const char* name) const
265 if (name && name[0] != '\0') {
273 ll->Add(AliForwardUtil::MakeParameter("nXi", fNXi));
274 ll->Add(AliForwardUtil::MakeParameter("frac", fMPVFraction));
275 ll->Add(AliForwardUtil::MakeParameter("sigma", fIncludeSigma));
276 ll->Add(AliForwardUtil::MakeParameter("probability", fProbability));
277 ll->Add(AliForwardUtil::MakeParameter("method", GetMethod()));
279 //____________________________________________________________________
281 AliFMDMultCuts::Input(TList* l, const char* name)
283 if (!l) return false;
285 if (name && name[0] != '\0') {
286 ll = static_cast<TList*>(l->FindObject(name));
288 if (!ll) return false;
290 TObject* nXi = ll->FindObject("nXi");
291 TObject* frac = ll->FindObject("frac");
292 TObject* sigma = ll->FindObject("sigma");
293 TObject* prob = ll->FindObject("probability");
294 if (!nXi || !frac || !sigma) return false;
295 AliForwardUtil::GetParameter(nXi, fNXi);
296 AliForwardUtil::GetParameter(frac, fMPVFraction);
297 AliForwardUtil::GetParameter(sigma, fIncludeSigma);
298 AliForwardUtil::GetParameter(prob, fProbability);
302 #define PF(N,V,...) \
303 AliForwardUtil::PrintField(N,V, ## __VA_ARGS__)
304 #define PFB(N,FLAG) \
306 AliForwardUtil::PrintName(N); \
307 std::cout << std::boolalpha << (FLAG) << std::noboolalpha << std::endl; \
309 #define PFV(N,VALUE) \
311 AliForwardUtil::PrintName(N); \
312 std::cout << (VALUE) << std::endl; } while(false)
314 //____________________________________________________________________
316 AliFMDMultCuts::Print(Option_t*) const
318 gROOT->IncreaseDirLevel();
319 PFV("Method used", GetMethodString());
321 gROOT->IncreaseDirLevel();
322 PFV("FMD1i", GetFixedCut(1,'I'));
323 PFV("FMD2i", GetFixedCut(2,'I'));
324 PFV("FMD2o", GetFixedCut(2,'O'));
325 PFV("FMD3i", GetFixedCut(3,'I'));
326 PFV("FMD3o", GetFixedCut(3,'O'));
327 gROOT->DecreaseDirLevel();
328 PFV("N xi factor", fNXi);
329 PFB("Include sigma in cut", fIncludeSigma);
330 PFV("MPV fraction", fMPVFraction);
331 PFV("Probability", fProbability);
332 gROOT->DecreaseDirLevel();
334 //____________________________________________________________________