AliPhysics  32b88a8 (32b88a8)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 }
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  case kLandauWidth:
166  // Return MPV - fNXi * xi
167  rcut = fits->GetLowerBound(d, r, ieta, param, errors,false);
168  break;
169  case kLandauSigmaWidth:
170  // Return MPV - fNXi * xi
171  rcut = fits->GetLowerBound(d, r, ieta, param, errors,true);
172  break;
173  case kProbability:
174  // Return probability cut
175  rcut = fits->GetLowerBound(d, r, ieta, param, true); break;
176  default:
177  // Return lower fit boundary
178  rcut = fits->GetLowCut(); break;
179  }
180  }
181  else
182  Warning("GetMultCut", "No energy loss fits obtained from manager");
183 
184  DMSG(fDebug, 5, "-> %8.4f", rcut);
185 
186  return rcut;
187 }
188 
189 //____________________________________________________________________
190 Double_t
192  Bool_t errors) const
193 {
194  //
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.
198  //
199  // Return:
200  // Lower cut on multiplicity
201  //
202  DGUARD(fDebug, 5, "Get mult cut for FMD%d%c @ eta=%8.4f",
203  d, r, eta);
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);
209 }
210 //____________________________________________________________________
211 const char*
213 {
214  return Method2String(fMethod, latex);
215 }
216 
217 //____________________________________________________________________
218 const char*
220 {
221  switch (method) {
222  case kFixed:
223  return latex ? "c=X" : "fixed value";
224  case kMPVFraction:
225  return latex ? "c=X#times#Delta_{p}":"fraction of MPV";
226  case kFitRange:
227  return latex ? "range" : "c: lower fit bound";
228  case kLandauWidth:
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";
232  case kProbability:
233  return latex ? "c:P(#Delta<c)<X" : "probability";
234  }
235  return latex ? "c:?" : "unknown";
236 }
237 //____________________________________________________________________
240 {
241  TString m(str);
242  if (m.EqualTo("fixed value") || m.Contains("fix"))
243  return kFixed;
244  else if (m.EqualTo("fraction of mpv") || m.Contains("mpv"))
245  return kMPVFraction;
246  else if (m.EqualTo("fit range") || m.Contains("fit"))
247  return kFitRange;
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"))
253  return kProbability;
254  return kFixed;
255  }
256 
257 //____________________________________________________________________
258 void
260 {
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));
266  lab.Remove(0,3);
267  UShort_t det = lab.Atoi();
268  Char_t rng = lab[1];
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);
279  }
280  }
281 }
282 
283 //____________________________________________________________________
284 void
285 AliFMDMultCuts::Output(TList* l, const char* name) const
286 {
287  TList* ll = l;
288  if (name && name[0] != '\0') {
289  ll = new TList;
290  ll->SetName(name);
291  ll->SetOwner();
292  l->Add(ll);
293  }
294 
295 
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]));
302 }
303 //____________________________________________________________________
304 Bool_t
305 AliFMDMultCuts::Input(TList* l, const char* name)
306 {
307  if (!l) return false;
308  TList* ll = l;
309  if (name && name[0] != '\0') {
310  ll = static_cast<TList*>(l->FindObject(name));
311  }
312  if (!ll) return false;
313 
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");
320 
321  UShort_t methNum = 0;
322 
323  AliForwardUtil::GetParameter(meth, methNum);
324  switch (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;
331  }
332 
338 
339  return true;
340 }
341 #define PF(N,V,...) \
342  AliForwardUtil::PrintField(N,V, ## __VA_ARGS__)
343 #define PFB(N,FLAG) \
344  do { \
345  AliForwardUtil::PrintName(N); \
346  std::cout << std::boolalpha << (FLAG) << std::noboolalpha << std::endl; \
347  } while(false)
348 #define PFV(N,VALUE) \
349  do { \
350  AliForwardUtil::PrintName(N); \
351  std::cout << (VALUE) << std::endl; } while(false)
352 
353 //____________________________________________________________________
354 void
356 {
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();
367 }
368 //____________________________________________________________________
369 //
370 // EOF
371 //
void Print(Option_t *option="") const
return jsonbuilder str().c_str()
static EMethod String2Method(const char *str)
double Double_t
Definition: External.C:58
ClassImp(AliFMDMultCuts) AliFMDMultCuts
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)
Double_t GetLowerBound(UShort_t d, Char_t r, Int_t etaBin, Double_t f) const
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.
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)
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
const char Option_t
Definition: External.C:48
bool Bool_t
Definition: External.C:53
static AliForwardCorrectionManager & Instance()
Double_t GetLowCut() const