Add a protection againts runs with missing DCS information in the OCDB
[u/mrichter/AliRoot.git] / TRD / AliTRDdEdxBaseUtils.h
CommitLineData
6951a056 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15//
16//
17//
18// Xianguo Lu
19// lu@physi.uni-heidelberg.de
20// Xianguo.Lu@cern.ch
21//
22/*
23grep " AliTRDdEdxBaseUtils::" AliTRDdEdxBaseUtils.cxx | grep "=" -v | grep -v "[6]" | grep -v printf |wc
24grep "(" AliTRDdEdxBaseUtils.h | grep ";" | grep -v grep | grep -v ClassDef | grep -v "{" | grep -v typedef | wc
25*/
26
27
28#ifndef ALITRDDEDXBASEUTILS_H
29#define ALITRDDEDXBASEUTILS_H
30
31#ifndef TVECTORD_H
32#include "TVectorD.h"
33#endif
34
35#ifndef THNSPARSE_H
36#include "THnBase.h"
37#endif
38
39#ifndef TTREESTREAM_H
40#include "TTreeStream.h"
41#endif
42
43class TH1D;
44class TH2D;
45class TObjArray;
46
47class AliESDEvent;
48class AliESDtrack;
49class AliTRDcluster;
50class AliTRDtrackV1;
51class AliTRDseedV1;
52
53class AliTRDdEdxBaseUtils
54{
55 public:
56 //===================================================================================
57 // Math and Histogram
58 //===================================================================================
59 static void GetCDFCuts(const TH1D *hh, const Int_t ncut, Double_t cuts[], const Double_t cdfs[], const Double_t thres);
60 static Double_t GetMeanRMS(const Double_t nn, const Double_t sum, const Double_t w2s, Double_t * grms=0x0, Double_t * gerr=0x0);
61 static Double_t TruncatedMean(const Int_t nx, const Double_t xdata[], const Double_t lowfrac, const Double_t highfrac, Double_t * grms=0x0, Double_t * gerr=0x0, Double_t *wws=0x0);
62 static Double_t TruncatedMean(const TH1 *hh, const Double_t lowfrac, const Double_t highfrac, Double_t * grms=0x0, Double_t * gerr=0x0);
63 static void FitSlicesY(const TH2D *hh, TH1D *&hnor, TH1D *&hmpv, TH1D *&hwid, TH1D *&hres, const Double_t thres, const Double_t lowfrac, const Double_t highfrac);
64
65 //===================================================================================
66 // TRD Analysis Fast Tool
67 //===================================================================================
68 static Int_t GetNtracklet(const AliESDEvent *esd);
69 static AliTRDtrackV1 * GetTRDtrackV1(const AliESDtrack * esdtrack);
70 static Bool_t IsInSameStack(const AliTRDtrackV1 *trdtrack);
71 static Bool_t GetFirstSectorStackMomentum(const AliTRDtrackV1 *trdtrack, Int_t & isec, Int_t & istk, Double_t & mom);
72
73 //===================================================================================
74 // Detector, Data and Control Constant
75 //===================================================================================
76
77 static Int_t NTRDchamber(){return 18*5*6;} //540
78 static Int_t NTRDtimebin(){return NTRDchamber()*31;} //16740
79 static Int_t ToDetector(const Int_t gtb);
80 static Int_t ToTimeBin(const Int_t gtb);
81 static Int_t ToSector(const Int_t gtb);
82 static Int_t ToStack(const Int_t gtb);
83 static Int_t ToLayer(const Int_t gtb);
84
85 static TString GetRunType(const Int_t run);
86
87 static void SetQ0Frac(const Double_t q0){ fgQ0Frac = q0; }
88 static void SetQ1Frac(const Double_t q1){ fgQ1Frac = q1; }
89 static void SetTimeBinCountCut(const Double_t tbc){ fgTimeBinCountCut = tbc; }
90 static void SetCalibTPCnclsCut(const Int_t tpc){ fgCalibTPCnclsCut = tpc; }
91 static void SetExBOn(const Bool_t kon){ fgExBOn = kon; }
92 static void SetPadGainOn(const Bool_t kon){ fgPadGainOn = kon; }
93 static void SetQScale(const Double_t scale){ fgQScale = scale; }
94
95 static Double_t Q0Frac(){return fgQ0Frac;}
96 static Double_t Q1Frac(){return fgQ1Frac;}
97 static Double_t TimeBinCountCut(){return fgTimeBinCountCut;}
98 static Int_t CalibTPCnclsCut(){return fgCalibTPCnclsCut;}
99 static Bool_t IsExBOn(){return fgExBOn;}
100 static Bool_t IsPadGainOn(){return fgPadGainOn;}
101 static Double_t QScale(){return fgQScale;}
102
103 static void PrintControl();
104
105 //===================================================================================
106 // dEdx Parameterization
107 //===================================================================================
108
109 static Double_t MeandEdx(const Double_t * xx, const Double_t * par);
110 static Double_t MeanTR(const Double_t * xx, const Double_t * par);
111 static Double_t MeandEdxTR(const Double_t * xx, const Double_t * par);
112
113 static Double_t QMeanTPC(const Double_t bg);
114 static Double_t Q0MeanTRDpp(const Double_t bg);
115 static Double_t Q1MeanTRDpp(const Double_t bg);
116 static Double_t Q0MeanTRDPbPb(const Double_t bg);
117 static Double_t Q1MeanTRDPbPb(const Double_t bg);
118
119 typedef Double_t (*FFunc)(const Double_t *xx, const Double_t *par);
120
121 static Double_t MeandEdxLogx(const Double_t * xx, const Double_t * par){return ToLogx(MeandEdx, xx, par);}
122 static Double_t MeanTRLogx(const Double_t * xx, const Double_t * par){return ToLogx(MeanTR, xx, par);}
123 static Double_t MeandEdxTRLogx(const Double_t * xx, const Double_t * par){return ToLogx(MeandEdxTR, xx, par);}
124
125 private:
126 //dEdx Parameterization
127 static Double_t ToLogx(FFunc func, const Double_t * xx, const Double_t * par);
128
129 //Control Constant
130 static Double_t fgQ0Frac; //q0frac
131 static Double_t fgQ1Frac; //q1frac
132 static Double_t fgTimeBinCountCut; //tbcut
133 static Int_t fgCalibTPCnclsCut; //tpccut
134 static Bool_t fgExBOn; //exbon
135 static Bool_t fgPadGainOn; //pad gain
136 static Double_t fgQScale; //Qscale
137
138};
139
140#endif