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