]>
Commit | Line | Data |
---|---|---|
70da6c5a | 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 | // Toolkit containing various usefull things | |
17 | // Usable everywhere in the hfe software package | |
18 | // For more information see the cxx file | |
19 | // | |
20 | // Authors | |
21 | // All authors of the HFE group | |
22 | // | |
23 | #include <TMath.h> | |
24 | #include <TParticle.h> | |
25 | #include "TH1.h" | |
26 | #include "TH2.h" | |
27 | #include "THnSparse.h" | |
28 | #include "TAxis.h" | |
29 | ||
30 | #include "AliAODMCParticle.h" | |
faee3b18 | 31 | #include "AliESDpid.h" |
70da6c5a | 32 | #include "AliLog.h" |
faee3b18 | 33 | #include "AliTOFPIDResponse.h" |
70da6c5a | 34 | |
35 | #include "AliHFEtools.h" | |
36 | ||
37 | ClassImp(AliHFEtools) | |
38 | ||
faee3b18 | 39 | AliESDpid *AliHFEtools::fgDefaultPID = NULL; |
69ac0e6f | 40 | Int_t AliHFEtools::fgLogLevel = 0; |
faee3b18 | 41 | |
70da6c5a | 42 | //__________________________________________ |
43 | AliHFEtools::AliHFEtools(): | |
44 | TObject() | |
45 | { | |
46 | } | |
47 | ||
48 | //__________________________________________ | |
49 | Double_t *AliHFEtools::MakeLinearBinning(Int_t nBins, Double_t ymin, Double_t ymax){ | |
50 | // | |
51 | // Helper function for linearly binned array | |
52 | // | |
53 | Double_t *bins = new Double_t[nBins + 1]; | |
54 | Double_t stepsize = (ymax - ymin) / static_cast<Double_t>(nBins); | |
55 | bins[0] = ymin; | |
56 | for(Int_t ibin = 1; ibin <= nBins; ibin++) | |
57 | bins[ibin] = bins[ibin-1] + stepsize; | |
58 | return bins; | |
59 | } | |
60 | ||
61 | //__________________________________________ | |
62 | Double_t *AliHFEtools::MakeLogarithmicBinning(Int_t nBins, Double_t ymin, Double_t ymax){ | |
63 | // | |
64 | // Helper function for logartimically binned array | |
65 | // | |
66 | Double_t *bins = new Double_t[nBins+1]; | |
67 | bins[0] = ymin; | |
68 | Double_t factor = TMath::Power(ymax/ymin, 1./nBins); | |
69 | for(Int_t ibin = 1; ibin <= nBins; ibin++){ | |
70 | bins[ibin] = factor * bins[ibin-1]; | |
71 | } | |
72 | return bins; | |
73 | } | |
74 | ||
75 | //_________________________________________ | |
76 | Bool_t AliHFEtools::BinLogAxis(TObject *o, Int_t dim){ | |
77 | ||
78 | // | |
79 | // converts the axis (defined by the dimension) of THx or THnSparse | |
80 | // object to Log scale. Number of bins and bin min and bin max are preserved | |
81 | // | |
82 | ||
83 | ||
84 | if(!o){ | |
85 | AliError("Input histogram is null pointer"); | |
86 | return kFALSE; | |
87 | } | |
88 | ||
89 | TAxis *axis = 0x0; | |
90 | if(o->InheritsFrom("TH1")){ | |
91 | axis = (dynamic_cast<TH1F*>(o))->GetXaxis(); | |
92 | } | |
93 | else if(o->InheritsFrom("TH2")){ | |
94 | if(0 == dim){ | |
95 | axis = (dynamic_cast<TH2F*>(o))->GetXaxis(); | |
96 | } | |
97 | else if(1 == dim){ | |
98 | axis = (dynamic_cast<TH2F*>(o))->GetYaxis(); | |
99 | } | |
100 | else{ | |
101 | AliError("Only dim = 0 or 1 possible for TH2F"); | |
102 | } | |
103 | } | |
104 | else if(o->InheritsFrom("THnSparse")){ | |
105 | axis = (dynamic_cast<THnSparse*>(o))->GetAxis(dim); | |
106 | } | |
107 | else{ | |
108 | AliError("Type of input object not recognized, please check your code or update this finction"); | |
109 | return kFALSE; | |
110 | } | |
111 | if(!axis){ | |
112 | AliError(Form("Axis '%d' could not be identified in the object \n", dim)); | |
113 | return kFALSE; | |
114 | } | |
115 | ||
116 | Int_t bins = axis->GetNbins(); | |
117 | ||
118 | Double_t from = axis->GetXmin(); | |
119 | if(from <= 0){ | |
120 | AliError(Form("Log binning not possible for this axis [min = %f]\n", from)); | |
121 | } | |
122 | Double_t to = axis->GetXmax(); | |
123 | Double_t *newBins = new Double_t[bins+1]; | |
124 | newBins[0] = from; | |
125 | Double_t factor = TMath::Power(to/from, 1./bins); | |
126 | for(Int_t i=1; i<=bins; ++i){ | |
127 | newBins[i] = factor * newBins[i-1]; | |
128 | } | |
129 | axis->Set(bins, newBins); | |
e3fc062d | 130 | delete newBins; |
70da6c5a | 131 | |
132 | return kTRUE; | |
133 | } | |
134 | ||
135 | //__________________________________________ | |
136 | Float_t AliHFEtools::GetRapidity(TParticle *part){ | |
137 | // | |
138 | // return rapidity | |
139 | // | |
140 | Float_t rapidity; | |
141 | if(!((part->Energy() - part->Pz())*(part->Energy() + part->Pz())>0)) rapidity=-999; | |
142 | else rapidity = 0.5*(TMath::Log((part->Energy()+part->Pz()) / (part->Energy()-part->Pz()))); | |
143 | return rapidity; | |
144 | } | |
145 | ||
146 | //__________________________________________ | |
147 | Float_t AliHFEtools::GetRapidity(AliAODMCParticle *part){ | |
148 | // return rapidity | |
149 | ||
150 | Float_t rapidity; | |
151 | if(!((part->E() - part->Pz())*(part->E() + part->Pz())>0)) rapidity=-999; | |
152 | else rapidity = 0.5*(TMath::Log((part->E()+part->Pz()) / (part->E()-part->Pz()))); | |
153 | return rapidity; | |
154 | } | |
155 | ||
faee3b18 | 156 | //__________________________________________ |
157 | AliESDpid* AliHFEtools::GetDefaultPID(Bool_t isMC){ | |
158 | // | |
159 | // Get the default PID as singleton instance | |
160 | // | |
161 | if(!fgDefaultPID){ | |
162 | fgDefaultPID = new AliESDpid; | |
163 | Double_t tres = isMC ? 80. : 130.; | |
164 | fgDefaultPID->GetTOFResponse().SetTimeResolution(tres); | |
165 | ||
166 | // TPC Bethe Bloch parameters | |
167 | Double_t alephParameters[5]; | |
168 | if(isMC){ | |
169 | // simulation | |
170 | alephParameters[0] = 2.15898e+00/50.; | |
171 | alephParameters[1] = 1.75295e+01; | |
172 | alephParameters[2] = 3.40030e-09; | |
173 | alephParameters[3] = 1.96178e+00; | |
174 | alephParameters[4] = 3.91720e+00; | |
175 | } else { | |
176 | alephParameters[0] = 0.0283086/0.97; | |
177 | //alephParameters[0] = 0.0283086; | |
178 | alephParameters[1] = 2.63394e+01; | |
179 | alephParameters[2] = 5.04114e-11; | |
180 | alephParameters[3] = 2.12543e+00; | |
181 | alephParameters[4] = 4.88663e+00; | |
182 | } | |
183 | fgDefaultPID->GetTPCResponse().SetBetheBlochParameters(alephParameters[0],alephParameters[1],alephParameters[2], alephParameters[3],alephParameters[4]); | |
67fe7bd0 | 184 | fgDefaultPID->GetTPCResponse().SetSigma(3.79301e-03, 2.21280e+04); |
faee3b18 | 185 | |
186 | } | |
187 | if(fgLogLevel){ | |
67fe7bd0 | 188 | printf("Error - You are using the default PID: You should use the PID coming from the tender\n"); |
189 | printf("Error - Arrrrrrrrr...\n"); | |
190 | printf("Error - Please rethink your program logic. Using default PID is really dangerous\n"); | |
191 | printf("Error - TOF PID is adapted to Monte Carlo\n"); | |
faee3b18 | 192 | } |
193 | return fgDefaultPID; | |
194 | } | |
195 | ||
196 | //__________________________________________ | |
197 | void AliHFEtools::DestroyDefaultPID(){ | |
198 | // | |
199 | // Destroy default PID object if existing | |
200 | // | |
201 | if(fgDefaultPID) delete fgDefaultPID; | |
202 | fgDefaultPID = NULL; | |
203 | } |