AliPhysics  56f1704 (56f1704)
AliFMDMultCuts.cxx
Go to the documentation of this file.
1 #include "AliFMDMultCuts.h"
3 #include "AliFMDCorrELossFit.h"
4 #include "AliForwardUtil.h"
5 #include <AliLog.h>
6 #include <iostream>
7 #include <TROOT.h>
8 #include <TParameter.h>
9 #include <TH2.h>
10 namespace {
11  Int_t fDebug = 1;
12 }
13 ClassImp(AliFMDMultCuts)
14 #if 0
15 ; // This is for Emacs
16 #endif
17 
18 //____________________________________________________________________
20  : TObject(),
21  fMethod(kFixed)
22 {
23  Reset();
24 }
25 //____________________________________________________________________
27  Double_t cut1,
28  Double_t cut2,
29  Double_t cut3,
30  Double_t cut4,
31  Double_t cut5)
32  : TObject(),
33  fMethod(method)
34 {
35  Set(method, cut1, cut2, cut3, cut4, cut5);
36 }
37 
38 //____________________________________________________________________
40  : TObject(o),
41  fMethod(o.fMethod)
42 {
43  for (Int_t i = 0; i < 5; i++) fCuts[i] = o.fCuts[i];
44 }
45 //____________________________________________________________________
48 {
49  if (&o == this) return *this;
50  fMethod = o.fMethod;
51  for (Int_t i = 0; i < 5; i++) fCuts[i] = o.fCuts[i];
52  return *this;
53 }
54 //____________________________________________________________________
55 void
57 {
58  fMethod = kFixed;
59  for (Int_t i = 0; i < 5; i++) fCuts[i] = -1;
60 }
61 //____________________________________________________________________
62 void
64  Double_t fmd1i,
65  Double_t fmd2i,
66  Double_t fmd2o,
67  Double_t fmd3i,
68  Double_t fmd3o)
69 {
70  // First, reset
71  Reset();
72  fMethod = method;
73  Double_t oFac = 1;
74  if (fMethod == kFixed) oFac = 1.2;
75  else if (fMethod == kMPVFraction) oFac = 1.1;
76  fCuts[0] = fmd1i;
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;
81 }
82 //____________________________________________________________________
83 void
84 AliFMDMultCuts::DepSet(const char* what,
85  EMethod method,
86  Double_t fmd1i,
87  Double_t fmd2i,
88  Double_t fmd2o,
89  Double_t fmd3i,
90  Double_t fmd3o)
91 {
92  Warning(what, "*** DEPRECATED - use AliFMDMultCuts::Set instead ***");
93  Set(method, fmd1i, fmd2i, fmd2o, fmd3i, fmd3o);
94 }
95 
96 //____________________________________________________________________
97 void
99 {
100  Warning("SetIncludeSigma",
101  "*** DEPRECATED - use AliFMDMultCuts::Set instead ***");
102  if (in) {
104  }
105  else {
107  }
108 }
109 
110 //____________________________________________________________________
111 Double_t
113 {
114  // Int_t idx = (d == 1 ? 0 : 2*(d - 2) + 1 + ((r=='I' || r=='i') ? 0 : 1));
115  Int_t idx = -1;
116  switch (d) {
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;
120  }
121  if (idx < 0) return -kBad;
122  return fCuts[idx];
123 }
124 
125 //____________________________________________________________________
126 Double_t
128  Bool_t errors) const
129 {
130  //
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.
134  //
135  // Return:
136  // Lower cut on multiplicity
137  //
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);
141  if (param < 0) {
142  Warning("GetMultCut", "Got bad cut parameter for FMD%d%c ieta=%d",
143  d, r, ieta);
144  return -kBad;
145  }
146 
147  // If we're using a fixed cut, just return
148  if (fMethod == kFixed) {
149  DMSG(fDebug, 5, "-> %8.4f", param);
150  return param;
151  }
152 
153  // Bad value
154  Double_t rcut = -kBad;
155 
156  // Get the energy loss fits
159  const AliFMDCorrELossFit* fits = fcm.GetELossFit();
160  if (fits) {
161  switch (fMethod) {
162  case kMPVFraction:
163  // Return fMPVFraction * mpv
164  // rcut = fits->GetLowerBound(d, r, ieta, param); break;
165  rcut = fits->GetMpvCut(d,r,ieta,param); break;
166  case kLandauWidth:
167  // Return MPV - fNXi * xi
168  // rcut = fits->GetLowerBound(d, r, ieta, param, errors,false);
169  rcut = fits->GetXiCut(d, r, ieta, param);
170  break;
171  case kLandauSigmaWidth:
172  // Return MPV - fNXi * (xi+sigma)
173  // rcut = fits->GetLowerBound(d, r, ieta, param, errors,true);
174  rcut = fits->GetXiSigmaCut(d, r, ieta, param);
175  break;
176  case kProbability:
177  // Return probability cut
178  // rcut = fits->GetLowerBound(d, r, ieta, param, true); break;
179  rcut = fits->GetProbabilityCut(d, r, ieta, param); break;
180  case kLandauSigmaAvg:
181  // Return MPV - fNxi*WeightedAverage(xi,sigma)
182  rcut = fits->GetAvgXiSigmaCut(d,r,ieta,param); break;
183  default:
184  // Return lower fit boundary
185  rcut = fits->GetLowCut(); break;
186  }
187  }
188  else
189  Warning("GetMultCut", "No energy loss fits obtained from manager");
190 
191  DMSG(fDebug, 5, "-> %8.4f", rcut);
192 
193  return rcut;
194 }
195 
196 //____________________________________________________________________
197 Double_t
199  Bool_t errors) const
200 {
201  //
202  // Get the multiplicity cut. If the user has set fMultCut (via
203  // SetMultCut) then that value is used. If not, then the lower
204  // value of the fit range for the enery loss fits is returned.
205  //
206  // Return:
207  // Lower cut on multiplicity
208  //
209  DGUARD(fDebug, 5, "Get mult cut for FMD%d%c @ eta=%8.4f",
210  d, r, eta);
212  const AliFMDCorrELossFit* fits = fcm.GetELossFit();
213  Int_t iEta = fits ? fits->FindEtaBin(eta) : 1;
214  DMSG(fDebug, 5, "bin=%4d", iEta);
215  return GetMultCut(d, r, iEta, errors);
216 }
217 //____________________________________________________________________
218 const char*
220 {
221  return Method2String(fMethod, latex);
222 }
223 
224 //____________________________________________________________________
225 const char*
227 {
228  switch (method) {
229  case kFixed:
230  return latex ? "c=X" : "fixed value";
231  case kMPVFraction:
232  return latex ? "c=X#times#Delta_{p}":"fraction of MPV";
233  case kFitRange:
234  return latex ? "range" : "c: lower fit bound";
235  case kLandauWidth:
236  return latex ? "c=#Delta_{p}-X#times#xi" : "landau width";
237  case kLandauSigmaWidth:
238  return latex ? "c=#Delta_{p}-X#times(#xi+#sigma)" : "landau+sigma width";
239  case kProbability:
240  return latex ? "c:P(#Delta<c)<X" : "probability";
241  case kLandauSigmaAvg:
242  return latex ? "x=#Delta_{p}-X#times#bar{#xi+#sigma}" :
243  "landau+sigma avg";
244  }
245  return latex ? "c:?" : "unknown";
246 }
247 //____________________________________________________________________
250 {
251  TString m(str);
252  if (m.EqualTo("fixed value") || m.Contains("fix"))
253  return kFixed;
254  else if (m.EqualTo("fraction of mpv") || m.Contains("mpv"))
255  return kMPVFraction;
256  else if (m.EqualTo("fit range") || m.Contains("fit"))
257  return kFitRange;
258  else if (m.EqualTo("landau width") || m.Contains("xi") ||
259  m.Contains("width")) return kLandauWidth;
260  else if (m.EqualTo("landau+sigma avg") || m.Contains("avg"))
261  return kLandauSigmaAvg;
262  else if (m.EqualTo("landau+sigma width") || m.Contains("sig"))
263  return kLandauSigmaWidth;
264  else if (m.EqualTo("probability") || m.Contains("prob"))
265  return kProbability;
266  return kFixed;
267  }
268 
269 //____________________________________________________________________
270 void
272 {
273  DGUARD(fDebug, 5, "Fill Histogram %s with cuts", h->GetName());
274  // AliInfoF("Caching multiplicity cuts (%s)", h->GetName());
275  TAxis* yAxis = h->GetYaxis();
276  for (Int_t iy = 1; iy <= yAxis->GetNbins(); iy++) {
277  TString lab(yAxis->GetBinLabel(iy));
278  lab.Remove(0,3);
279  UShort_t det = lab.Atoi();
280  Char_t rng = lab[1];
281  // Printf("Filling for FMD%d%c (bin # %d) %s", det, rng, iy, lab.Data());
282  DMSG(fDebug, 5, "FMD%d%c", det, rng);
283  // AliInfoF("FMD%d%c", det, rng);
284  for (Int_t ix = 1; ix <= h->GetNbinsX(); ix++) {
285  Double_t eta = h->GetXaxis()->GetBinCenter(ix);
286  Double_t c = GetMultCut(det, rng, eta, false);
287  DMSG(fDebug, 10, "FMD%s bin=%4d -> eta=%8.4f -> %8.4f",
288  lab.Data(), ix, eta, c);
289  // Double_t c = GetMultCut(det, rng, ix, false);
290  if (c > 0) h->SetBinContent(ix, iy, c);
291  }
292  }
293 }
294 
295 //____________________________________________________________________
296 void
297 AliFMDMultCuts::Output(TList* l, const char* name) const
298 {
299  TList* ll = l;
300  if (name && name[0] != '\0') {
301  ll = new TList;
302  ll->SetName(name);
303  ll->SetOwner();
304  l->Add(ll);
305  }
306 
307 
308  ll->Add(AliForwardUtil::MakeParameter("method", UShort_t(fMethod)));
309  ll->Add(AliForwardUtil::MakeParameter("fmd1i", fCuts[0]));
310  ll->Add(AliForwardUtil::MakeParameter("fmd2i", fCuts[1]));
311  ll->Add(AliForwardUtil::MakeParameter("fmd2o", fCuts[2]));
312  ll->Add(AliForwardUtil::MakeParameter("fmd3i", fCuts[3]));
313  ll->Add(AliForwardUtil::MakeParameter("fmd3o", fCuts[4]));
314 }
315 //____________________________________________________________________
316 Bool_t
317 AliFMDMultCuts::Input(TList* l, const char* name)
318 {
319  if (!l) return false;
320  TList* ll = l;
321  if (name && name[0] != '\0') {
322  ll = static_cast<TList*>(l->FindObject(name));
323  }
324  if (!ll) return false;
325 
326  TObject* meth = ll->FindObject("method");
327  TObject* fmd1i = ll->FindObject("fmd1i");
328  TObject* fmd2i = ll->FindObject("fmd2i");
329  TObject* fmd2o = ll->FindObject("fmd2o");
330  TObject* fmd3i = ll->FindObject("fmd3i");
331  TObject* fmd3o = ll->FindObject("fmd3o");
332 
333  UShort_t methNum = 0;
334 
335  AliForwardUtil::GetParameter(meth, methNum);
336  switch (methNum) {
337  case 0: fMethod = kFixed; break;
338  case 1: fMethod = kMPVFraction; break;
339  case 2: fMethod = kFitRange; break;
340  case 3: fMethod = kLandauWidth; break;
341  case 4: fMethod = kLandauSigmaWidth; break;
342  case 5: fMethod = kProbability; break;
343  }
344 
350 
351  return true;
352 }
353 #define PF(N,V,...) \
354  AliForwardUtil::PrintField(N,V, ## __VA_ARGS__)
355 #define PFB(N,FLAG) \
356  do { \
357  AliForwardUtil::PrintName(N); \
358  std::cout << std::boolalpha << (FLAG) << std::noboolalpha << std::endl; \
359  } while(false)
360 #define PFV(N,VALUE) \
361  do { \
362  AliForwardUtil::PrintName(N); \
363  std::cout << (VALUE) << std::endl; } while(false)
364 
365 //____________________________________________________________________
366 void
368 {
369  gROOT->IncreaseDirLevel();
370  PFV("Method used", GetMethodString());
371  gROOT->IncreaseDirLevel();
372  PFV("FMD1i", GetCutParam(1,'I'));
373  PFV("FMD2i", GetCutParam(2,'I'));
374  PFV("FMD2o", GetCutParam(2,'O'));
375  PFV("FMD3i", GetCutParam(3,'I'));
376  PFV("FMD3o", GetCutParam(3,'O'));
377  gROOT->DecreaseDirLevel();
378  gROOT->DecreaseDirLevel();
379 }
380 //____________________________________________________________________
381 //
382 // EOF
383 //
void Print(Option_t *option="") const
static EMethod String2Method(const char *str)
double Double_t
Definition: External.C:58
Double_t GetXiCut(UShort_t d, Char_t r, Int_t etaBin, Double_t f) const
Double_t fCuts[5]
char Char_t
Definition: External.C:18
Double_t GetCutParam(UShort_t d, Char_t r) const
#define DMSG(L, N, F,...)
TCanvas * c
Definition: TestFitELoss.C:172
void SetIncludeSigma(Bool_t in)
void DepSet(const char *what, EMethod method, Double_t fmd1i, Double_t fmd2i=-1, Double_t fmd2o=-1, Double_t fmd3i=-1, Double_t fmd3o=-1)
Double_t GetMultCut(UShort_t d, Char_t r, Double_t eta, Bool_t errors) const
#define PFV(N, VALUE)
AliFMDMultCuts & operator=(const AliFMDMultCuts &o)
static const char * Method2String(EMethod method, Bool_t latex)
const char * GetMethodString(Bool_t latex=false) const
int Int_t
Definition: External.C:63
void Output(TList *l, const char *name=0) const
Int_t FindEtaBin(Double_t eta) const
Various utilities used in PWGLF/FORWARD.
Int_t method
Double_t GetAvgXiSigmaCut(UShort_t d, Char_t r, Int_t etaBin, Double_t f) const
Double_t GetXiSigmaCut(UShort_t d, Char_t r, Int_t etaBin, Double_t f) const
void Set(EMethod method, Double_t fmd1i, Double_t fmd2i=-1, Double_t fmd2o=-1, Double_t fmd3i=-1, Double_t fmd3o=-1)
static void GetParameter(TObject *o, UShort_t &value)
Double_t GetProbabilityCut(UShort_t d, Char_t r, Int_t etaBin, Double_t f) const
Bool_t Input(TList *l, const char *name)
const AliFMDCorrELossFit * GetELossFit() const
#define DGUARD(L, N, F,...)
static TObject * MakeParameter(const char *name, UShort_t value)
Definition: External.C:220
void FillHistogram(TH2 *h) const
unsigned short UShort_t
Definition: External.C:28
Double_t GetMpvCut(UShort_t d, Char_t r, Int_t etaBin, Double_t f) const
const char Option_t
Definition: External.C:48
bool Bool_t
Definition: External.C:53
static AliForwardCorrectionManager & Instance()
Double_t GetLowCut() const