2 /**************************************************************************
3 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * Author: The ALICE Off-line Project. *
6 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 ////////////////////////////////////////////////////////////////////////////////
19 // AliTPCComposedCorrection class //
21 // This class is creating a correction that is composed out of smaller //
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+... //
31 // 3. kQueueResidual: like kQueue with the exception that in case of //
32 // a positive weight the 'Distortion' is called and in case of a negative //
33 // weight the 'Correction' is called, where the absolute of the weight //
34 // will be applied to the correction
35 // For the inverse of the correction this is taken into account by reversing //
36 // the order the corrections are applied in the kQueue case (no issue for //
39 // date: 27/04/2010 //
40 // Authors: Magnus Mager, Stefan Rossegger, Jim Thomas //
44 // AliMagF mag("mag","mag"); //
45 // AliTPCExBBShape exb; // B field shape distortions //
46 // exb.SetBField(&mag); //
48 // AliTPCExBTwist twist; // ExB Twist distortions //
49 // twist.SetXTwist(0.001); //
51 // TObjArray cs; cs.Add(&exb); cs.Add(&twist); //
53 // AliTPCComposedCorrection cc; //
54 // cc.SetCorrections(&cs); //
55 // cc.SetOmegaTauT1T2(wt,T1,T2); //
57 // cc.CreateHistoDRPhiinZR(0,100,100)->Draw("surf2"); //
58 ////////////////////////////////////////////////////////////////////////////////
61 #include <TCollection.h>
62 #include <TTimeStamp.h>
63 #include <TIterator.h>
67 #include "AliTPCComposedCorrection.h"
70 AliTPCComposedCorrection::AliTPCComposedCorrection()
71 : AliTPCCorrection("composed_correction",
72 "composition of corrections"),
75 fWeights(0) // weights of corrections
78 // default constructor
82 AliTPCComposedCorrection::AliTPCComposedCorrection(TCollection *corrections,
83 AliTPCComposedCorrection::CompositionType mode)
84 : AliTPCCorrection("composed_correction",
85 "composition of corrections"),
86 fCorrections(corrections),
88 fWeights(0) //weights of correction
91 // Constructor that defines the set of corrections, this one is composed of.
95 AliTPCComposedCorrection::~AliTPCComposedCorrection() {
100 AliInfo("No Correction-models were set: can not delete them");
102 TIterator *i=fCorrections->MakeIterator();
104 while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next()))) {
109 if (fWeights) delete fWeights;
112 AliTPCCorrection * AliTPCComposedCorrection::GetSubCorrection(Int_t ipos){
116 TObjArray *arr = (TObjArray*)fCorrections;
117 return (AliTPCCorrection *)arr->At(ipos);
120 AliTPCCorrection * AliTPCComposedCorrection::GetSubCorrection(const char *cname){
124 TCollection *arr = fCorrections;
125 return (AliTPCCorrection *)arr->FindObject(cname);
130 void AliTPCComposedCorrection::GetCorrection(const Float_t x[],const Short_t roc,Float_t dx[]) {
132 // This applies all correction and the specified manner (see general
133 // class description for details).
137 AliInfo("No Corrections-models were set: can not calculate distortions");
140 TIterator *i=fCorrections->MakeIterator();
146 for (int j=0;j<3;++j) dx[j]=0.;
147 while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next()))) {
148 c->GetCorrection(x,roc,dxi);
150 if (fWeights) w=(*fWeights)[weightIndex++];
151 for (Int_t j=0;j<3;++j) dx[j]+=w*dxi[j];
156 for (Int_t j=0;j<3;++j) xi[j]=x[j];
157 while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next()))) {
158 c->GetCorrection(xi,roc,dx);
160 if (fWeights) w=(*fWeights)[weightIndex++];
161 for (Int_t j=0;j<3;++j) xi[j]+=w*dx[j];
163 for (Int_t j=0;j<3;++j) dx[j]=xi[j]-x[j];
166 //TODO: for the moment assume inverse of distortion
167 // check if this is what is desired
168 GetDistortion(x,roc,dx);
169 for (Int_t j=0;j<3;++j) dx[j]*=-1.;
175 void AliTPCComposedCorrection::GetDistortion(const Float_t x[],const Short_t roc,Float_t dx[]) {
177 // This applies all distortions and the specified manner (see general
178 // class descxiption for details).
182 AliInfo("No Corrections-models were set: can not calculate distortions");
186 if (fMode==kQueueResidual && !fWeights) {
187 AliInfo("kQueueResidual mode was selected but no weights were given. Switching to kQueue instead.");
191 TIterator *i=fCorrections->MakeReverseIterator();
197 for (int j=0;j<3;++j) dx[j]=0.;
198 while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next()))) {
199 c->GetDistortion(x,roc,dxi);
201 if (fWeights) w=(*fWeights)[weightIndex++];
202 for (Int_t j=0;j<3;++j) dx[j]+=w*dxi[j];
207 for (Int_t j=0;j<3;++j) xi[j]=x[j];
208 while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next()))) {
209 c->GetDistortion(xi,roc,dx);
211 if (fWeights) w=(*fWeights)[weightIndex++];
212 for (Int_t j=0;j<3;++j) xi[j]+=w*dx[j];
214 for (Int_t j=0;j<3;++j) dx[j]=xi[j]-x[j];
218 for (Int_t j=0;j<3;++j) xi2[j]=x[j];
219 while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next()))) {
220 Double_t w=(*fWeights)[weightIndex++];
221 if (w>0) c->GetDistortion(xi2,roc,dx);
222 else c->GetCorrection(xi2,roc,dx);
223 for (Int_t j=0;j<3;++j) xi2[j]+=TMath::Abs(w)*dx[j];
225 for (Int_t j=0;j<3;++j) dx[j]=xi2[j]-x[j];
232 void AliTPCComposedCorrection::Print(Option_t* option) const {
234 // Print function to check which correction classes are used
235 // option=="d" prints details regarding the setted magnitude
236 // option=="a" prints the C0 and C1 coefficents for calibration purposes
239 printf("Composed TPC spacepoint correction \"%s\" -- composed of:\n",GetTitle());
240 TString opt = option; opt.ToLower();
243 printf(" - composed correction is empty!\n");
246 TIterator *i=fCorrections->MakeIterator();
248 while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next()))) {
249 if (opt.Contains("d")) {
251 printf("%d. %s\t%s\n",in,c->GetTitle(), c->GetName());
254 printf("%d. %s\t%s\n",in,c->GetTitle(), c->GetName());
258 if (in==1) printf(" Info: The correction compound is empty: No corrections set\n");
263 void AliTPCComposedCorrection::Init() {
265 // Initialization funtion (not used at the moment)
268 AliInfo("No Correction-models were set");
271 TIterator *i=fCorrections->MakeIterator();
273 while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next())))
279 void AliTPCComposedCorrection::Update(const TTimeStamp &timeStamp) {
284 AliInfo("No Correction-models were set");
288 TIterator *i=fCorrections->MakeIterator();
290 while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next())))
291 c->Update(timeStamp);
298 void AliTPCComposedCorrection::SetOmegaTauT1T2(Float_t omegaTau,Float_t t1,Float_t t2) {
300 // Gives the possibility to set the OmegaTau plus Tensor corrections T1 and T2 (effective omega Tau)
301 // to each subcorrection (since they might become event specific due to changing drift velocity)
303 // The omegaTau comes idealy from the Database, since it is a function of drift velocity, B and E field
304 // e.g. omegaTau = -10.0 * Bz * vdrift / Ez ; // with Bz in kG and Ez in V/cm
305 // omegaTau = -0.325 for Bz=5kG, Ez=400V/cm and vdrift = 2.6cm/muSec
306 // The T1 and T2 tensors were measured in a dedicated calibration run
308 // Note: overwrites previously set values!
312 AliInfo("No Correction-models were set");
316 TIterator *i=fCorrections->MakeIterator();
318 while (0!=(c=dynamic_cast<AliTPCCorrection*>(i->Next()))) {
319 c->SetOmegaTauT1T2(omegaTau,t1,t2);
324 ClassImp(AliTPCComposedCorrection)