Bastian's Task for Jet Fragmentation, to be merged with other FF tasks
[u/mrichter/AliRoot.git] / TPC / AliTPCComposedCorrection.cxx
CommitLineData
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>
60
0116859c 61
62#include "AliTPCComposedCorrection.h"
63
64
65AliTPCComposedCorrection::AliTPCComposedCorrection()
66 : AliTPCCorrection("composed_correction",
67 "composition of corrections"),
68 fCorrections(0),
69 fMode(kParallel)
70{
71 //
72 // default constructor
73 //
74}
75
76AliTPCComposedCorrection::AliTPCComposedCorrection(TCollection *corrections,
77 AliTPCComposedCorrection::CompositionType mode)
78 : AliTPCCorrection("composed_correction",
79 "composition of corrections"),
80 fCorrections(corrections),
81 fMode(mode)
82{
83 //
84 // Constructor that defines the set of corrections, this one is composed of.
85 //
86}
87
88AliTPCComposedCorrection::~AliTPCComposedCorrection() {
89 //
90 // virtual destructor
91 //
92}
93
94
95void AliTPCComposedCorrection::GetCorrection(const Float_t x[],const Short_t roc,Float_t dx[]) {
96 //
97 // This applies all correction and the specified manner (see general
98 // class description for details).
99 //
100 TIterator *i=fCorrections->MakeIterator();
101 AliTPCCorrection *c;
102 switch (fMode) {
103 case kParallel:
104 Float_t dxi[3];
105 for (int j=0;j<3;++j) dx[j]=0.;
106 while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next()))) {
107 c->GetCorrection(x,roc,dxi);
108 for (Int_t j=0;j<3;++j) dx[j]+=dxi[j];
109 }
110 break;
111 case kQueue:
112 Float_t xi[3];
113 for (Int_t j=0;j<3;++j) xi[j]=x[j];
114 while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next()))) {
115 c->GetCorrection(xi,roc,dx);
116 for (Int_t j=0;j<3;++j) xi[j]+=dx[j];
117 }
118 for (Int_t j=0;j<3;++j) dx[j]=xi[j]-x[j];
119 break;
120 }
121 delete i;
122}
123
124void AliTPCComposedCorrection::GetDistortion(const Float_t x[],const Short_t roc,Float_t dx[]) {
125 //
126 // This applies all distortions and the specified manner (see general
127 // class descxiption for details).
128 //
129
130 TIterator *i=fCorrections->MakeReverseIterator();
131 AliTPCCorrection *c;
132 switch (fMode) {
133 case kParallel:
134 Float_t dxi[3];
135 for (int j=0;j<3;++j) dx[j]=0.;
136 while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next()))) {
137 c->GetDistortion(x,roc,dxi);
138 for (Int_t j=0;j<3;++j) dx[j]+=dxi[j];
139 }
140 break;
141 case kQueue:
142 Float_t xi[3];
143 for (Int_t j=0;j<3;++j) xi[j]=x[j];
144 while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next()))) {
145 c->GetDistortion(xi,roc,dx);
146 for (Int_t j=0;j<3;++j) xi[j]+=dx[j];
147 }
148 for (Int_t j=0;j<3;++j) dx[j]=xi[j]-x[j];
149 break;
150 }
151 delete i;
152}
153
154
155void AliTPCComposedCorrection::Print(Option_t* option) const {
156 //
157 // Print function to check which correction classes are used
158 // option=="d" prints details regarding the setted magnitude
159 // option=="a" prints the C0 and C1 coefficents for calibration purposes
160 //
161
162 printf("Composed TPC spacepoint correction \"%s\" -- composed of:\n",GetTitle());
163 TString opt = option; opt.ToLower();
164 Int_t in=1;
165 TIterator *i=fCorrections->MakeIterator();
166 AliTPCCorrection *c;
167 while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next()))) {
168 if (opt.Contains("d")) {
169 printf("%d. ",in);
170 c->Print(option);
171 } else {
172 printf("%d. %s\n",in,c->GetTitle());
173 }
174 ++in;
175 }
e527a1b9 176 if (in==1) printf(" Info: The correction compound is empty: No corrections set\n");
0116859c 177 delete i;
178}
179
180
e527a1b9 181void AliTPCComposedCorrection::Init() {
182 //
183 // Initialization funtion (not used at the moment)
184 //
185
186 TIterator *i=fCorrections->MakeIterator();
187 AliTPCCorrection *c;
188 while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next())))
189 c->Init();
190 delete i;
191
192}
193
194void AliTPCComposedCorrection::Update(const TTimeStamp &timeStamp) {
195 //
196 // Update function
197 //
198
199 TIterator *i=fCorrections->MakeIterator();
200 AliTPCCorrection *c;
201 while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next())))
202 c->Update(timeStamp);
203 delete i;
204
205}
206
207
208
0116859c 209void AliTPCComposedCorrection::SetOmegaTauT1T2(Float_t omegaTau,Float_t t1,Float_t t2) {
210 //
211 // Gives the possibility to set the OmegaTau plus Tensor corrections T1 and T2 (effective omega Tau)
212 // to each subcorrection (since they might become event specific due to changing drift velocity)
213 //
214 // The omegaTau comes idealy from the Database, since it is a function of drift velocity, B and E field
215 // e.g. omegaTau = -10.0 * Bz * vdrift / Ez ; // with Bz in kG and Ez in V/cm
216 // omegaTau = -0.325 for Bz=5kG, Ez=400V/cm and vdrift = 2.6cm/muSec
217 // The T1 and T2 tensors were measured in a dedicated calibration run
218 //
219 // Note: overwrites previously set values!
220 //
221
222 TIterator *i=fCorrections->MakeIterator();
223 AliTPCCorrection *c;
224 while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next()))) {
225 c->SetOmegaTauT1T2(omegaTau,t1,t2);
226 }
227 delete i;
228}
229
230ClassImp(AliTPCComposedCorrection)