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