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()
25 //____________________________________________________________________
26 AliFMDMultCuts::AliFMDMultCuts(EMethod method,
35 Set(method, cut1, cut2, cut3, cut4, cut5);
38 //____________________________________________________________________
39 AliFMDMultCuts::AliFMDMultCuts(const AliFMDMultCuts& o)
43 for (Int_t i = 0; i < 5; i++) fCuts[i] = o.fCuts[i];
45 //____________________________________________________________________
47 AliFMDMultCuts::operator=(const AliFMDMultCuts& o)
49 if (&o == this) return *this;
51 for (Int_t i = 0; i < 5; i++) fCuts[i] = o.fCuts[i];
54 //____________________________________________________________________
56 AliFMDMultCuts::Reset()
59 for (Int_t i = 0; i < 5; i++) fCuts[i] = -1;
61 //____________________________________________________________________
63 AliFMDMultCuts::Set(EMethod method,
74 if (fMethod == kFixed) oFac = 1.2;
75 else if (fMethod == kMPVFraction) oFac = 1.1;
77 fCuts[1] = fmd2i >= 0 ? fmd2i : fmd1i;
78 fCuts[2] = fmd2o >= 0 ? fmd2o : fmd1i * oFac;
79 fCuts[3] = fmd3i >= 0 ? fmd3i : fmd1i;
80 fCuts[4] = fmd3o >= 0 ? fmd3o : fmd1i * oFac;
82 //____________________________________________________________________
84 AliFMDMultCuts::DepSet(const char* what,
92 Warning(what, "*** DEPRECATED - use AliFMDMultCuts::Set instead ***");
93 Set(method, fmd1i, fmd2i, fmd2o, fmd3i, fmd3o);
96 //____________________________________________________________________
98 AliFMDMultCuts::SetIncludeSigma(Bool_t in)
100 Warning("SetIncludeSigma",
101 "*** DEPRECATED - use AliFMDMultCuts::Set instead ***");
103 if (fMethod == kLandauWidth) fMethod = kLandauSigmaWidth;
106 if (fMethod == kLandauSigmaWidth) fMethod = kLandauWidth;
110 //____________________________________________________________________
112 AliFMDMultCuts::GetCutParam(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 -kBad;
125 //____________________________________________________________________
127 AliFMDMultCuts::GetMultCut(UShort_t d, Char_t r, Int_t ieta,
131 // Get the multiplicity cut. If the user has set fMultCut (via
132 // SetMultCut) then that value is used. If not, then the lower
133 // value of the fit range for the enery loss fits is returned.
136 // Lower cut on multiplicity
138 DGUARD(fDebug, 5, "Get mult cut for FMD%d%c (method %d) @ etabin=%d",
139 d, r, fMethod, ieta);
140 Double_t param = GetCutParam(d, r);
142 Warning("GetMultCut", "Got bad cut parameter for FMD%d%c ieta=%d",
147 // If we're using a fixed cut, just return
148 if (fMethod == kFixed) {
149 DMSG(fDebug, 5, "-> %8.4f", param);
154 Double_t rcut = -kBad;
156 // Get the energy loss fits
157 AliForwardCorrectionManager& fcm =
158 AliForwardCorrectionManager::Instance();
159 const AliFMDCorrELossFit* fits = fcm.GetELossFit();
163 // Return fMPVFraction * mpv
164 rcut = fits->GetLowerBound(d, r, ieta, param); break;
166 // Return MPV - fNXi * xi
167 rcut = fits->GetLowerBound(d, r, ieta, param, errors,false);
169 case kLandauSigmaWidth:
170 // Return MPV - fNXi * xi
171 rcut = fits->GetLowerBound(d, r, ieta, param, errors,true);
174 // Return probability cut
175 rcut = fits->GetLowerBound(d, r, ieta, param, true); break;
177 // Return lower fit boundary
178 rcut = fits->GetLowCut(); break;
182 Warning("GetMultCut", "No energy loss fits obtained from manager");
184 DMSG(fDebug, 5, "-> %8.4f", rcut);
189 //____________________________________________________________________
191 AliFMDMultCuts::GetMultCut(UShort_t d, Char_t r, Double_t eta,
195 // Get the multiplicity cut. If the user has set fMultCut (via
196 // SetMultCut) then that value is used. If not, then the lower
197 // value of the fit range for the enery loss fits is returned.
200 // Lower cut on multiplicity
202 DGUARD(fDebug, 5, "Get mult cut for FMD%d%c @ eta=%8.4f",
204 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
205 const AliFMDCorrELossFit* fits = fcm.GetELossFit();
206 Int_t iEta = fits ? fits->FindEtaBin(eta) : 1;
207 DMSG(fDebug, 5, "bin=%4d", iEta);
208 return GetMultCut(d, r, iEta, errors);
210 //____________________________________________________________________
212 AliFMDMultCuts::GetMethodString(Bool_t latex) const
214 return Method2String(fMethod, latex);
217 //____________________________________________________________________
219 AliFMDMultCuts::Method2String(EMethod method, Bool_t latex)
223 return latex ? "c=X" : "fixed value";
225 return latex ? "c=X#times#Delta_{p}":"fraction of MPV";
227 return latex ? "range" : "c: lower fit bound";
229 return latex ? "c=#Delta_{p}-X#times#xi" : "landau width";
230 case kLandauSigmaWidth:
231 return latex ? "c=#Delta_{p}-X#times(#xi+#sigma)" : "landau+sigma width";
233 return latex ? "c:P(#Delta<c)<X" : "probability";
235 return latex ? "c:?" : "unknown";
237 //____________________________________________________________________
238 AliFMDMultCuts::EMethod
239 AliFMDMultCuts::String2Method(const char* str)
242 if (m.EqualTo("fixed value") || m.Contains("fix"))
244 else if (m.EqualTo("fraction of mpv") || m.Contains("mpv"))
246 else if (m.EqualTo("fit range") || m.Contains("fit"))
248 else if (m.EqualTo("landau width") || m.Contains("xi") ||
249 m.Contains("width")) return kLandauWidth;
250 else if (m.EqualTo("landau+sigma width") || m.Contains("sig"))
251 return kLandauSigmaWidth;
252 else if (m.EqualTo("probability") || m.Contains("prob"))
257 //____________________________________________________________________
259 AliFMDMultCuts::FillHistogram(TH2* h) const
261 DGUARD(fDebug, 5, "Fill Histogram %s with cuts", h->GetName());
262 // AliInfoF("Caching multiplicity cuts (%s)", h->GetName());
263 TAxis* yAxis = h->GetYaxis();
264 for (Int_t iy = 1; iy <= yAxis->GetNbins(); iy++) {
265 TString lab(yAxis->GetBinLabel(iy));
267 UShort_t det = lab.Atoi();
269 // Printf("Filling for FMD%d%c (bin # %d) %s", det, rng, iy, lab.Data());
270 DMSG(fDebug, 5, "FMD%d%c", det, rng);
271 // AliInfoF("FMD%d%c", det, rng);
272 for (Int_t ix = 1; ix <= h->GetNbinsX(); ix++) {
273 Double_t eta = h->GetXaxis()->GetBinCenter(ix);
274 Double_t c = GetMultCut(det, rng, eta, false);
275 DMSG(fDebug, 10, "FMD%s bin=%4d -> eta=%8.4f -> %8.4f",
276 lab.Data(), ix, eta, c);
277 // Double_t c = GetMultCut(det, rng, ix, false);
278 if (c > 0) h->SetBinContent(ix, iy, c);
283 //____________________________________________________________________
285 AliFMDMultCuts::Output(TList* l, const char* name) const
288 if (name && name[0] != '\0') {
296 ll->Add(AliForwardUtil::MakeParameter("method", UShort_t(fMethod)));
297 ll->Add(AliForwardUtil::MakeParameter("fmd1i", fCuts[0]));
298 ll->Add(AliForwardUtil::MakeParameter("fmd2i", fCuts[1]));
299 ll->Add(AliForwardUtil::MakeParameter("fmd2o", fCuts[2]));
300 ll->Add(AliForwardUtil::MakeParameter("fmd3i", fCuts[3]));
301 ll->Add(AliForwardUtil::MakeParameter("fmd3o", fCuts[4]));
303 //____________________________________________________________________
305 AliFMDMultCuts::Input(TList* l, const char* name)
307 if (!l) return false;
309 if (name && name[0] != '\0') {
310 ll = static_cast<TList*>(l->FindObject(name));
312 if (!ll) return false;
314 TObject* meth = ll->FindObject("method");
315 TObject* fmd1i = ll->FindObject("fmd1i");
316 TObject* fmd2i = ll->FindObject("fmd2i");
317 TObject* fmd2o = ll->FindObject("fmd2o");
318 TObject* fmd3i = ll->FindObject("fmd3i");
319 TObject* fmd3o = ll->FindObject("fmd3o");
321 UShort_t methNum = 0;
323 AliForwardUtil::GetParameter(meth, methNum);
325 case 0: fMethod = kFixed; break;
326 case 1: fMethod = kMPVFraction; break;
327 case 2: fMethod = kFitRange; break;
328 case 3: fMethod = kLandauWidth; break;
329 case 4: fMethod = kLandauSigmaWidth; break;
330 case 5: fMethod = kProbability; break;
333 AliForwardUtil::GetParameter(fmd1i, fCuts[0]);
334 AliForwardUtil::GetParameter(fmd2i, fCuts[1]);
335 AliForwardUtil::GetParameter(fmd2o, fCuts[2]);
336 AliForwardUtil::GetParameter(fmd3i, fCuts[3]);
337 AliForwardUtil::GetParameter(fmd3o, fCuts[4]);
341 #define PF(N,V,...) \
342 AliForwardUtil::PrintField(N,V, ## __VA_ARGS__)
343 #define PFB(N,FLAG) \
345 AliForwardUtil::PrintName(N); \
346 std::cout << std::boolalpha << (FLAG) << std::noboolalpha << std::endl; \
348 #define PFV(N,VALUE) \
350 AliForwardUtil::PrintName(N); \
351 std::cout << (VALUE) << std::endl; } while(false)
353 //____________________________________________________________________
355 AliFMDMultCuts::Print(Option_t*) const
357 gROOT->IncreaseDirLevel();
358 PFV("Method used", GetMethodString());
359 gROOT->IncreaseDirLevel();
360 PFV("FMD1i", GetCutParam(1,'I'));
361 PFV("FMD2i", GetCutParam(2,'I'));
362 PFV("FMD2o", GetCutParam(2,'O'));
363 PFV("FMD3i", GetCutParam(3,'I'));
364 PFV("FMD3o", GetCutParam(3,'O'));
365 gROOT->DecreaseDirLevel();
366 gROOT->DecreaseDirLevel();
368 //____________________________________________________________________