]>
Commit | Line | Data |
---|---|---|
0116859c | 1 | |
2 | /************************************************************************** | |
3 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
4 | * * | |
5 | * Author: The ALICE Off-line Project. * | |
6 | * Contributors are mentioned in the code where appropriate. * | |
7 | * * | |
8 | * Permission to use, copy, modify and distribute this software and its * | |
9 | * documentation strictly for non-commercial purposes is hereby granted * | |
10 | * without fee, provided that the above copyright notice appears in all * | |
11 | * copies and that both the copyright notice and this permission notice * | |
12 | * appear in the supporting documentation. The authors make no claims * | |
13 | * about the suitability of this software for any purpose. It is * | |
14 | * provided "as is" without express or implied warranty. * | |
15 | **************************************************************************/ | |
16 | ||
17 | //////////////////////////////////////////////////////////////////////////////// | |
18 | // // | |
19 | // AliTPCComposedCorrection class // | |
20 | // // | |
21 | // This class is creating a correction that is composed out of smaller // | |
22 | // corrections. // | |
23 | // There are two ways the sub-corrections can be combined into this one: // | |
24 | // 1. kParallel: All corrections are applied at the given position x and // | |
25 | // the dx terms are summed up (this commutes). // | |
26 | // 2. kQueue: The corrections are called in order. The first one at the // | |
27 | // given position x resulting in dx1, the second one is called at // | |
28 | // the corrected position (x+dx1) resulting in dx2, the third one // | |
29 | // is then called at position (x+dx1+dx2) and so forth. dx=dx1+dx2+... // | |
30 | // is returned. // | |
31 | // For the inverse of the correction this is taken into account by reversing // | |
32 | // the order the corrections are applied in the kQueue case (no issue for // | |
33 | // kParallel). // | |
34 | // // | |
35 | // date: 27/04/2010 // | |
36 | // Authors: Magnus Mager, Stefan Rossegger, Jim Thomas // | |
37 | // // | |
38 | // Example usage: // | |
39 | // // | |
40 | // AliMagF mag("mag","mag"); // | |
41 | // AliTPCExBBShape exb; // B field shape distortions // | |
42 | // exb.SetBField(&mag); // | |
43 | // // | |
44 | // AliTPCExBTwist twist; // ExB Twist distortions // | |
45 | // twist.SetXTwist(0.001); // | |
46 | // // | |
47 | // TObjArray cs; cs.Add(&exb); cs.Add(&twist); // | |
48 | // // | |
49 | // AliTPCComposedCorrection cc; // | |
50 | // cc.SetCorrections(&cs); // | |
51 | // cc.SetOmegaTauT1T2(wt,T1,T2); // | |
52 | // cc.Print("DA"); // | |
53 | // cc.CreateHistoDRPhiinZR(0,100,100)->Draw("surf2"); // | |
54 | //////////////////////////////////////////////////////////////////////////////// | |
55 | ||
56 | ||
57 | #include <TCollection.h> | |
e527a1b9 | 58 | #include <TTimeStamp.h> |
b1f0a2a5 | 59 | #include <TIterator.h> |
c9cbd2f2 | 60 | #include "AliLog.h" |
0116859c | 61 | |
62 | #include "AliTPCComposedCorrection.h" | |
63 | ||
64 | ||
65 | AliTPCComposedCorrection::AliTPCComposedCorrection() | |
66 | : AliTPCCorrection("composed_correction", | |
67 | "composition of corrections"), | |
68 | fCorrections(0), | |
cfe2c39a | 69 | fMode(kParallel), |
70 | fWeights(0) // weights of corrections | |
0116859c | 71 | { |
72 | // | |
73 | // default constructor | |
74 | // | |
75 | } | |
76 | ||
77 | AliTPCComposedCorrection::AliTPCComposedCorrection(TCollection *corrections, | |
78 | AliTPCComposedCorrection::CompositionType mode) | |
79 | : AliTPCCorrection("composed_correction", | |
80 | "composition of corrections"), | |
81 | fCorrections(corrections), | |
cfe2c39a | 82 | fMode(mode), |
83 | fWeights(0) //weights of correction | |
0116859c | 84 | { |
85 | // | |
86 | // Constructor that defines the set of corrections, this one is composed of. | |
87 | // | |
88 | } | |
89 | ||
90 | AliTPCComposedCorrection::~AliTPCComposedCorrection() { | |
91 | // | |
c9cbd2f2 | 92 | // destructor |
0116859c | 93 | // |
c9cbd2f2 | 94 | if (!fCorrections) { |
95 | AliInfo("No Correction-models were set: can not delete them"); | |
96 | } else { | |
97 | TIterator *i=fCorrections->MakeIterator(); | |
98 | AliTPCCorrection *c; | |
99 | while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next()))) { | |
100 | delete c; | |
101 | } | |
102 | delete i; | |
103 | } | |
cfe2c39a | 104 | if (fWeights) delete fWeights; |
0116859c | 105 | } |
106 | ||
72bb0bb7 | 107 | AliTPCCorrection * AliTPCComposedCorrection::GetSubCorrection(Int_t ipos){ |
108 | // | |
109 | // | |
110 | // | |
111 | TObjArray *arr = (TObjArray*)fCorrections; | |
112 | return (AliTPCCorrection *)arr->At(ipos); | |
113 | } | |
114 | ||
115 | AliTPCCorrection * AliTPCComposedCorrection::GetSubCorrection(const char *cname){ | |
116 | // | |
117 | // | |
118 | // | |
119 | TCollection *arr = fCorrections; | |
120 | return (AliTPCCorrection *)arr->FindObject(cname); | |
121 | } | |
122 | ||
123 | ||
0116859c | 124 | |
125 | void AliTPCComposedCorrection::GetCorrection(const Float_t x[],const Short_t roc,Float_t dx[]) { | |
126 | // | |
127 | // This applies all correction and the specified manner (see general | |
128 | // class description for details). | |
129 | // | |
c9cbd2f2 | 130 | |
131 | if (!fCorrections) { | |
132 | AliInfo("No Corrections-models were set: can not calculate distortions"); | |
133 | return; | |
134 | } | |
cfe2c39a | 135 | TIterator *i=fCorrections->MakeIterator(); |
0116859c | 136 | AliTPCCorrection *c; |
cfe2c39a | 137 | Int_t weightIndex=0; |
0116859c | 138 | switch (fMode) { |
139 | case kParallel: | |
140 | Float_t dxi[3]; | |
141 | for (int j=0;j<3;++j) dx[j]=0.; | |
142 | while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next()))) { | |
143 | c->GetCorrection(x,roc,dxi); | |
cfe2c39a | 144 | Double_t w=1; |
145 | if (fWeights) w=(*fWeights)[weightIndex++]; | |
146 | for (Int_t j=0;j<3;++j) dx[j]+=w*dxi[j]; | |
0116859c | 147 | } |
148 | break; | |
149 | case kQueue: | |
150 | Float_t xi[3]; | |
151 | for (Int_t j=0;j<3;++j) xi[j]=x[j]; | |
152 | while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next()))) { | |
153 | c->GetCorrection(xi,roc,dx); | |
cfe2c39a | 154 | Double_t w=1; |
155 | if (fWeights) w=(*fWeights)[weightIndex++]; | |
156 | for (Int_t j=0;j<3;++j) xi[j]+=w*dx[j]; | |
0116859c | 157 | } |
158 | for (Int_t j=0;j<3;++j) dx[j]=xi[j]-x[j]; | |
159 | break; | |
160 | } | |
161 | delete i; | |
162 | } | |
163 | ||
164 | void AliTPCComposedCorrection::GetDistortion(const Float_t x[],const Short_t roc,Float_t dx[]) { | |
165 | // | |
166 | // This applies all distortions and the specified manner (see general | |
167 | // class descxiption for details). | |
168 | // | |
169 | ||
c9cbd2f2 | 170 | if (!fCorrections) { |
171 | AliInfo("No Corrections-models were set: can not calculate distortions"); | |
172 | return; | |
173 | } | |
0116859c | 174 | TIterator *i=fCorrections->MakeReverseIterator(); |
175 | AliTPCCorrection *c; | |
cfe2c39a | 176 | Int_t weightIndex=0; |
0116859c | 177 | switch (fMode) { |
178 | case kParallel: | |
179 | Float_t dxi[3]; | |
180 | for (int j=0;j<3;++j) dx[j]=0.; | |
181 | while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next()))) { | |
182 | c->GetDistortion(x,roc,dxi); | |
cfe2c39a | 183 | Double_t w=1; |
184 | if (fWeights) w=(*fWeights)[weightIndex++]; | |
185 | for (Int_t j=0;j<3;++j) dx[j]+=w*dxi[j]; | |
0116859c | 186 | } |
187 | break; | |
188 | case kQueue: | |
189 | Float_t xi[3]; | |
190 | for (Int_t j=0;j<3;++j) xi[j]=x[j]; | |
191 | while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next()))) { | |
192 | c->GetDistortion(xi,roc,dx); | |
cfe2c39a | 193 | Double_t w=1; |
194 | if (fWeights) w=(*fWeights)[weightIndex++]; | |
195 | for (Int_t j=0;j<3;++j) xi[j]+=w*dx[j]; | |
0116859c | 196 | } |
197 | for (Int_t j=0;j<3;++j) dx[j]=xi[j]-x[j]; | |
198 | break; | |
199 | } | |
200 | delete i; | |
201 | } | |
202 | ||
203 | ||
204 | void AliTPCComposedCorrection::Print(Option_t* option) const { | |
205 | // | |
206 | // Print function to check which correction classes are used | |
207 | // option=="d" prints details regarding the setted magnitude | |
208 | // option=="a" prints the C0 and C1 coefficents for calibration purposes | |
209 | // | |
210 | ||
211 | printf("Composed TPC spacepoint correction \"%s\" -- composed of:\n",GetTitle()); | |
212 | TString opt = option; opt.ToLower(); | |
213 | Int_t in=1; | |
c9cbd2f2 | 214 | if (!fCorrections) { |
215 | printf(" - composed correction is empty!\n"); | |
216 | return; | |
217 | } | |
0116859c | 218 | TIterator *i=fCorrections->MakeIterator(); |
219 | AliTPCCorrection *c; | |
220 | while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next()))) { | |
221 | if (opt.Contains("d")) { | |
0b736a46 | 222 | printf("\n"); |
223 | printf("%d. %s\t%s\n",in,c->GetTitle(), c->GetName()); | |
0116859c | 224 | c->Print(option); |
225 | } else { | |
0b736a46 | 226 | printf("%d. %s\t%s\n",in,c->GetTitle(), c->GetName()); |
0116859c | 227 | } |
228 | ++in; | |
229 | } | |
e527a1b9 | 230 | if (in==1) printf(" Info: The correction compound is empty: No corrections set\n"); |
0116859c | 231 | delete i; |
232 | } | |
233 | ||
234 | ||
e527a1b9 | 235 | void AliTPCComposedCorrection::Init() { |
236 | // | |
237 | // Initialization funtion (not used at the moment) | |
238 | // | |
c9cbd2f2 | 239 | if (!fCorrections) { |
240 | AliInfo("No Correction-models were set"); | |
241 | return; | |
242 | } | |
e527a1b9 | 243 | TIterator *i=fCorrections->MakeIterator(); |
244 | AliTPCCorrection *c; | |
245 | while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next()))) | |
246 | c->Init(); | |
247 | delete i; | |
248 | ||
249 | } | |
250 | ||
251 | void AliTPCComposedCorrection::Update(const TTimeStamp &timeStamp) { | |
252 | // | |
253 | // Update function | |
254 | // | |
c9cbd2f2 | 255 | if (!fCorrections) { |
256 | AliInfo("No Correction-models were set"); | |
257 | return; | |
258 | } | |
e527a1b9 | 259 | |
260 | TIterator *i=fCorrections->MakeIterator(); | |
261 | AliTPCCorrection *c; | |
262 | while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next()))) | |
263 | c->Update(timeStamp); | |
264 | delete i; | |
265 | ||
266 | } | |
267 | ||
268 | ||
269 | ||
0116859c | 270 | void AliTPCComposedCorrection::SetOmegaTauT1T2(Float_t omegaTau,Float_t t1,Float_t t2) { |
271 | // | |
272 | // Gives the possibility to set the OmegaTau plus Tensor corrections T1 and T2 (effective omega Tau) | |
273 | // to each subcorrection (since they might become event specific due to changing drift velocity) | |
274 | // | |
275 | // The omegaTau comes idealy from the Database, since it is a function of drift velocity, B and E field | |
276 | // e.g. omegaTau = -10.0 * Bz * vdrift / Ez ; // with Bz in kG and Ez in V/cm | |
277 | // omegaTau = -0.325 for Bz=5kG, Ez=400V/cm and vdrift = 2.6cm/muSec | |
278 | // The T1 and T2 tensors were measured in a dedicated calibration run | |
279 | // | |
280 | // Note: overwrites previously set values! | |
281 | // | |
282 | ||
c9cbd2f2 | 283 | if (!fCorrections) { |
284 | AliInfo("No Correction-models were set"); | |
285 | return; | |
286 | } | |
287 | ||
0116859c | 288 | TIterator *i=fCorrections->MakeIterator(); |
289 | AliTPCCorrection *c; | |
290 | while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next()))) { | |
291 | c->SetOmegaTauT1T2(omegaTau,t1,t2); | |
292 | } | |
293 | delete i; | |
294 | } | |
295 | ||
296 | ClassImp(AliTPCComposedCorrection) |