]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/CalibMacros/RegisterCorrection.C
AliTPCcalibTimeGain.cxx - Adding the Gamma conversion selected electorns
[u/mrichter/AliRoot.git] / TPC / CalibMacros / RegisterCorrection.C
1 /*
2   marian.ivanov@cern.ch
3   //
4   Register primitive corrections: base functions for minimization:
5   Id numbers are assoctied to given primitive corrections.
6   See comments in the function headers. 
7   Used only for residuals minimization not in the reconstruction.
8   File with all primitives expected to be in the current directory
9   filename =  TPCCorrectionPrimitives.root
10   //
11
12   RegisterCorrection();                         - Reserved id's  0 -999
13   //
14   RegisterAliTPCFCVoltError3D();                - Reserved id's  0 -99
15   RegisterAliTPCBoundaryVoltError();            - Reserved id's  100-199
16   RegisterAliTPCCalibGlobalMisalignment();      - Reserved id's  200-499
17   RegisterAliTPCExBBShape();                    - Reserved id's  500-600
18   RegisterAliTPCExBTwist();                     - Reserved id's  600-700
19   RegisterAliTPCROCVoltError3D()                - Reserved id's  700-800
20   RegisterAliTPCROCVoltError3DSector()          - Reserved id's  800-900
21   .x ~/rootlogon.C
22   .L $ALICE_ROOT/TPC/CalibMacros/RegisterCorrection.C+
23   RegisterCorrection();
24
25 */
26 #if !defined(__CINT__) || defined(__MAKECINT__)
27 #include "TFile.h"
28 #include "TObjArray.h"
29 #include "TTreeStream.h"
30 #include "TMath.h" 
31 #include "TGraph.h" 
32 #include "TRandom.h"
33 #include "TTree.h"
34 #include "TF1.h"
35 #include "TH2F.h"
36 #include "TH3F.h"
37 #include "TAxis.h"
38 #include "TPad.h"
39 #include "TCanvas.h"
40 #include "TStyle.h"
41 #include "AliTPCParamSR.h"
42 #include "TDatabasePDG.h"
43 #include "AliTPCCorrection.h"
44 #include "AliTPCFCVoltError3D.h"
45 #include "AliTPCROCVoltError3D.h"
46 #include "AliTPCComposedCorrection.h"
47 #include "AliTPCBoundaryVoltError.h"
48 #include "AliTPCCalibGlobalMisalignment.h"
49 #include "AliTPCExBBShape.h"
50 #include "AliTPCExBTwist.h"
51 #include "AliMagF.h"
52 #include "AliCDBEntry.h"
53 #include "AliTPCROC.h"
54 #include <TStatToolkit.h>
55 #include "TCut.h"
56 #include "TGraphErrors.h"
57 #include  "AliTrackerBase.h"
58 #include  "TGeoGlobalMagField.h"
59 #include  "TROOT.h"
60 #endif
61
62
63
64
65 TFile *fCorrections=0;       //file with corrections
66 //
67 //models E field distortion   AliTPCFCVoltError3D
68 //
69 AliTPCFCVoltError3D *rotOFC  =0;     // fit models
70 AliTPCFCVoltError3D *rodOFC1 =0;
71 AliTPCFCVoltError3D *rodOFC2 =0;
72 AliTPCFCVoltError3D *rotIFC  =0;
73 AliTPCFCVoltError3D *rodIFC1 =0;
74 AliTPCFCVoltError3D *rodIFC2 =0;
75 AliTPCFCVoltError3D *rodIFCShift=0;     //common IFC shift
76 AliTPCFCVoltError3D *rodOFCShift=0;     //common OFC shift
77 AliTPCFCVoltError3D *rodIFCSin=0;       //common IFC shift -sinus
78 AliTPCFCVoltError3D *rodOFCSin=0;       //common OFC shift -sinus
79 AliTPCFCVoltError3D *rodIFCCos=0;       //common IFC shift -cos
80 AliTPCFCVoltError3D *rodOFCCos=0;       //common OFC shift -cos
81
82 AliTPCROCVoltError3D *rocRotgXA=0;     // roc rotation A side - inclination in X
83 AliTPCROCVoltError3D *rocRotgYA=0;     // roc rotation A side - inclination in Y
84 AliTPCROCVoltError3D *rocRotgXC=0;     // roc rotation C side - inclination in X
85 AliTPCROCVoltError3D *rocRotgYC=0;     // roc rotation C side - inclination in Y
86 AliTPCROCVoltError3D *rocDzIROCA=0;      // roc shift A side - in Z
87 AliTPCROCVoltError3D *rocDzIROCC=0;      // roc shift C side - in Z
88 AliTPCROCVoltError3D *rocRotIROCA=0;      // roc rotation A side - in Z
89 AliTPCROCVoltError3D *rocRotIROCC=0;      // roc rotation C side - in Z
90 //
91 AliTPCROCVoltError3D *rocShiftIROCA0=0;      // IROC shift A0 side
92 AliTPCROCVoltError3D *rocRotIROCA0=0;        // IROC rot   A0 side
93 AliTPCROCVoltError3D *rocShiftOROCA0=0;      // OROC shift A0 side
94 AliTPCROCVoltError3D *rocRotOROCA0=0;        // OROC rot   A0 side
95 AliTPCROCVoltError3D *rocShiftIROCC0=0;      // IROC shift C0 side
96 AliTPCROCVoltError3D *rocRotIROCC0=0;        // IROC rot   C0 side
97 AliTPCROCVoltError3D *rocShiftOROCC0=0;      // OROC shift C0 side
98 AliTPCROCVoltError3D *rocRotOROCC0=0;        // OROC rot   C0 side
99 //
100 //
101 //
102 AliTPCBoundaryVoltError *boundaryVoltErrorA[8];  // boundary voltage error A side
103 AliTPCBoundaryVoltError *boundaryVoltErrorC[8];  // boundary voltage error C side
104 AliTPCExBBShape *exbShape     = 0;               // nominal correctin
105 AliTPCExBBShape *exbShapeT1X  = 0;               // nominal +deltaT1=0.1
106 AliTPCExBBShape *exbShapeT2X  = 0;               // nominal +deltaT2=0.1
107 AliTPCExBTwist  *twistX    = 0;
108 AliTPCExBTwist  *twistY    = 0;
109 //
110 AliTPCCalibGlobalMisalignment *alignRot0=0;
111 AliTPCCalibGlobalMisalignment *alignRot1=0;
112 AliTPCCalibGlobalMisalignment *alignRot2=0;
113 AliTPCCalibGlobalMisalignment *alignTrans0=0;
114 AliTPCCalibGlobalMisalignment *alignTrans1=0;
115 AliTPCCalibGlobalMisalignment *alignTrans2=0;
116
117
118
119 //
120 void RegisterAliTPCFCVoltError3D();
121 void RegisterAliTPCCalibGlobalMisalignment();
122 void RegisterAliTPCBoundaryVoltError();
123 void RegisterAliTPCExBShape();
124 void RegisterAliTPCExBTwist();
125 void RegisterAliTPCROCVoltError3D();
126 void RegisterAliTPCROCVoltError3DSector();
127 //
128
129 void RegisterCorrection(Int_t type=0){
130   //
131   //
132   //
133   // check the presence of corrections in file
134   //
135   gROOT->Macro("ConfigCalibTrain.C(119037)");
136   //
137   //
138   if (type==1) return RegisterAliTPCROCVoltError3D();
139   if (type==2) return RegisterAliTPCROCVoltError3DSector();
140   fCorrections = new TFile("TPCCorrectionPrimitives.root");
141   AliTPCComposedCorrection *corrField3D = (AliTPCComposedCorrection*) fCorrections->Get("TPCFCVoltError3D");
142   // if not make new file
143   if (!corrField3D) fCorrections = new TFile("TPCCorrectionPrimitives.root","update");
144   if (type==0) {
145     RegisterAliTPCROCVoltError3D();
146     RegisterAliTPCROCVoltError3DSector();
147   }
148   RegisterAliTPCCalibGlobalMisalignment();
149   RegisterAliTPCBoundaryVoltError();
150   RegisterAliTPCFCVoltError3D();
151   RegisterAliTPCExBShape();
152   RegisterAliTPCExBTwist();
153   if (fCorrections) fCorrections->Close();
154   //
155 }
156
157
158
159 void RegisterAliTPCFCVoltError3D(){
160   //
161   // Load the models from the file
162   // Or create it
163   // Register functions with following IDs:
164   // IMPORTANT: The nominal shift is in mm 
165   //
166   //  rotOFC  - 0 
167   //  rodOFC1 - 1
168   //  rodOFC2 - 2 
169   //  rotIFC  - 3 
170   //  rodIFC1 - 4 
171   //  rodIFC2 - 5 
172   //  rodIFCShift - 6 
173   //  rodIFCSin   - 7 
174   //  rodIFCCos   - 8 
175   //  rodOFCShift - 9 
176   //  rodOFCSin   - 10 
177   //  rodOFCCos   - 11 
178   //
179   printf("RegisterAliTPCFCVoltError3D()");
180   Int_t volt = 40; // 40 V ~  1mm
181   AliTPCComposedCorrection *corrField3D = (AliTPCComposedCorrection*) fCorrections->Get("TPCFCVoltError3D");    
182   if (corrField3D) { // load form file
183     corrField3D->Print();
184     TCollection *iter = corrField3D->GetCorrections();    
185     rotOFC = (AliTPCFCVoltError3D*)iter->FindObject("rotOFC");
186     rodOFC1 = (AliTPCFCVoltError3D*)iter->FindObject("rodOFC1");
187     rodOFC2 = (AliTPCFCVoltError3D*)iter->FindObject("rodOFC2");
188     rotIFC = (AliTPCFCVoltError3D*)iter->FindObject("rotIFC");
189     rodIFC1 = (AliTPCFCVoltError3D*)iter->FindObject("rodIFC1");
190     rodIFC2 = (AliTPCFCVoltError3D*)iter->FindObject("rodIFC2");
191     //
192     rodIFCShift = (AliTPCFCVoltError3D*)iter->FindObject("rodIFCShift");
193     rodOFCShift = (AliTPCFCVoltError3D*)iter->FindObject("rodOFCShift");
194     rodIFCSin = (AliTPCFCVoltError3D*)iter->FindObject("rodIFCSin");
195     rodOFCSin = (AliTPCFCVoltError3D*)iter->FindObject("rodOFCSin");
196     rodIFCCos = (AliTPCFCVoltError3D*)iter->FindObject("rodIFCCos");
197     rodOFCCos = (AliTPCFCVoltError3D*)iter->FindObject("rodOFCCos");
198   } else {    
199     // OFC 
200     rotOFC = new AliTPCFCVoltError3D();
201     rotOFC->SetOmegaTauT1T2(0,1,1);
202     rotOFC->SetRotatedClipVoltA(1,volt);
203     rotOFC->SetRotatedClipVoltC(1,volt);
204     //
205     rodOFC1 = new AliTPCFCVoltError3D();
206     rodOFC1->SetOmegaTauT1T2(0,1,1);
207     rodOFC1->SetRodVoltShiftA(18,volt);
208     rodOFC1->SetRodVoltShiftC(18,volt);
209     //
210     rodOFC2 = new AliTPCFCVoltError3D();
211     rodOFC2->SetOmegaTauT1T2(0,1,1);
212     rodOFC2->SetCopperRodShiftA(18,volt);
213     rodOFC2->SetCopperRodShiftC(18,volt);    
214     // IFC     
215     rotIFC = new AliTPCFCVoltError3D();
216     rotIFC->SetOmegaTauT1T2(0,1,1);
217     rotIFC->SetRotatedClipVoltA(0,volt);
218     rotIFC->SetRotatedClipVoltC(0,volt);
219     //
220     rodIFC1 = new AliTPCFCVoltError3D();
221     rodIFC1->SetOmegaTauT1T2(0,1,1);
222     rodIFC1->SetRodVoltShiftA(0,volt);
223     rodIFC1->SetRodVoltShiftC(0,volt);
224     //
225     rodIFC2 = new AliTPCFCVoltError3D();
226     rodIFC2->SetOmegaTauT1T2(0,1,1);
227     rodIFC2->SetCopperRodShiftA(0,volt);
228     rodIFC2->SetCopperRodShiftC(0,volt);
229     //
230     rodIFCShift = new AliTPCFCVoltError3D();
231     rodIFCSin = new AliTPCFCVoltError3D();
232     rodIFCCos = new AliTPCFCVoltError3D();
233     rodOFCShift = new AliTPCFCVoltError3D();
234     rodOFCSin = new AliTPCFCVoltError3D();
235     rodOFCCos = new AliTPCFCVoltError3D();
236     for (Int_t isec=0; isec<18; isec++){
237       Double_t phi=TMath::Pi()*isec/9.;
238       rodIFCShift->SetOmegaTauT1T2(0,1,1);
239       rodIFCShift->SetRodVoltShiftA(isec,volt);
240       rodIFCShift->SetRodVoltShiftC(isec,volt);
241       rodIFCSin->SetOmegaTauT1T2(0,1,1);
242       rodIFCSin->SetRodVoltShiftA(isec,volt*TMath::Sin(phi));
243       rodIFCSin->SetRodVoltShiftC(isec,volt*TMath::Sin(phi));
244       rodIFCCos->SetOmegaTauT1T2(0,1,1);
245       rodIFCCos->SetRodVoltShiftA(isec,volt*TMath::Cos(phi));
246       rodIFCCos->SetRodVoltShiftC(isec,volt*TMath::Cos(phi));
247       //
248       rodOFCShift->SetOmegaTauT1T2(0,1,1);
249       rodOFCShift->SetRodVoltShiftA(18+isec,volt);
250       rodOFCShift->SetRodVoltShiftC(18+isec,volt);
251       rodOFCSin->SetOmegaTauT1T2(0,1,1);
252       rodOFCSin->SetRodVoltShiftA(18+isec,volt*TMath::Sin(phi));
253       rodOFCSin->SetRodVoltShiftC(18+isec,volt*TMath::Sin(phi));
254       rodOFCCos->SetOmegaTauT1T2(0,1,1);
255       rodOFCCos->SetRodVoltShiftA(18+isec,volt*TMath::Cos(phi));
256       rodOFCCos->SetRodVoltShiftC(18+isec,volt*TMath::Cos(phi));
257     }
258     //
259     //
260     // Initialization of the lookup tables
261     //
262     printf(" ------- OFC rotated clip:\n"); rotOFC->InitFCVoltError3D();
263     printf(" ------- OFC rod & strip:\n");  rodOFC1->InitFCVoltError3D();
264     printf(" ------- OFC copper rod:\n");   rodOFC2->InitFCVoltError3D();
265     printf(" ------- IFC rotated clip:\n"); rotIFC->InitFCVoltError3D();
266     printf(" ------- IFC rod & strip:\n");  rodIFC1->InitFCVoltError3D();
267     printf(" ------- IFC copper rod:\n");   rodIFC2->InitFCVoltError3D();
268
269     printf(" ------- IFC rod & strip shift:\n");  rodIFCShift->InitFCVoltError3D();
270     printf(" ------- IFC rod & strip sin:\n");    rodIFCSin->InitFCVoltError3D();
271     printf(" ------- IFC rod & strip cos:\n");    rodIFCCos->InitFCVoltError3D();
272     printf(" ------- OFC rod & strip shift:\n");  rodOFCShift->InitFCVoltError3D();
273     printf(" ------- OFC rod & strip sin:\n");    rodOFCSin->InitFCVoltError3D();
274     printf(" ------- OFC rod & strip cos:\n");    rodOFCCos->InitFCVoltError3D();
275
276     // give names
277     rotOFC->SetName("rotOFC");rotOFC->SetTitle("rotOFC");
278     rodOFC1->SetName("rodOFC1");rodOFC1->SetTitle("rodOFC1");
279     rodOFC2->SetName("rodOFC2");rodOFC2->SetTitle("rodOFC2");
280     rotIFC->SetName("rotIFC");rotIFC->SetTitle("rotIFC");
281     rodIFC1->SetName("rodIFC1");rodIFC1->SetTitle("rodIFC1");
282     rodIFC2->SetName("rodIFC2");rodIFC2->SetTitle("rodIFC2");
283     //
284     rodIFCShift->SetName("rodIFCShift");rodIFCShift->SetTitle("rodIFCShift");
285     rodIFCSin->SetName("rodIFCSin");rodIFCSin->SetTitle("rodIFCSin");
286     rodIFCCos->SetName("rodIFCCos");rodIFCCos->SetTitle("rodIFCCos");
287     //
288     rodOFCShift->SetName("rodOFCShift");rodOFCShift->SetTitle("rodOFCShift");
289     rodOFCSin->SetName("rodOFCSin");rodOFCSin->SetTitle("rodOFCSin");
290     rodOFCCos->SetName("rodOFCCos");rodOFCCos->SetTitle("rodOFCCos");
291     //
292     // save in file
293     corrField3D = new AliTPCComposedCorrection();
294     TObjArray *cs = new TObjArray();
295     cs->Add(rotIFC); cs->Add(rotOFC);
296     cs->Add(rodIFC1); cs->Add(rodOFC1);
297     cs->Add(rodIFC2); cs->Add(rodOFC2);
298     cs->Add(rodIFCShift);    cs->Add(rodIFCSin);    cs->Add(rodIFCCos);
299     cs->Add(rodOFCShift);    cs->Add(rodOFCSin);    cs->Add(rodOFCCos);
300     //
301     corrField3D->SetCorrections(cs);
302     corrField3D->SetOmegaTauT1T2(0,1.,1.);
303     corrField3D->Print();    
304     fCorrections->cd();
305     corrField3D->Write("TPCFCVoltError3D");
306   }
307   //
308   AliTPCCorrection::AddVisualCorrection(rotOFC,0); 
309   AliTPCCorrection::AddVisualCorrection(rodOFC1,1); 
310   AliTPCCorrection::AddVisualCorrection(rodOFC2,2); 
311   AliTPCCorrection::AddVisualCorrection(rotIFC,3); 
312   AliTPCCorrection::AddVisualCorrection(rodIFC1,4); 
313   AliTPCCorrection::AddVisualCorrection(rodIFC2,5); 
314   // common corrections
315   //
316   AliTPCCorrection::AddVisualCorrection(rodIFCShift,6); 
317   AliTPCCorrection::AddVisualCorrection(rodIFCSin,7); 
318   AliTPCCorrection::AddVisualCorrection(rodIFCCos,8); 
319   //
320   AliTPCCorrection::AddVisualCorrection(rodIFCShift,9); 
321   AliTPCCorrection::AddVisualCorrection(rodIFCSin,10); 
322   AliTPCCorrection::AddVisualCorrection(rodIFCCos,11); 
323 }
324
325
326 void RegisterAliTPCCalibGlobalMisalignment(){
327   //
328   // Register primitive alignment components.
329   // Linear conbination of primitev forulas used for fit
330   // The nominal delta 1 mm in shift and 1 mrad in rotation
331   // Primitive formulas registeren in AliTPCCoreection::AddvisualCorrection
332   // 20 - deltaX 
333   // 21 - deltaY
334   // 22 - deltaZ
335   // 23 - rot0 (phi)
336   // 24 - rot1 (theta)
337   // 25 - rot2 
338   //
339   printf("RegisterAliTPCCalibGlobalMisalignment()\n");
340   TGeoHMatrix matrixX;
341   TGeoHMatrix matrixY;
342   TGeoHMatrix matrixZ;
343   TGeoRotation rot0;
344   TGeoRotation rot1;
345   TGeoRotation rot2;  //transformation matrices
346   TGeoRotation rot90;  //transformation matrices
347   matrixX.SetDx(0.1); matrixY.SetDy(0.1); matrixZ.SetDz(0.1); //1 mm translation
348   rot0.SetAngles(0.001*TMath::RadToDeg(),0,0);
349   rot1.SetAngles(0,0.001*TMath::RadToDeg(),0);
350   rot2.SetAngles(0,0,0.001*TMath::RadToDeg());
351   //how to get rot02 ?
352   rot90.SetAngles(0,90,0);
353   rot2.MultiplyBy(&rot90,kTRUE);
354   rot90.SetAngles(0,-90,0);
355   rot2.MultiplyBy(&rot90,kFALSE);
356   alignRot0  =new  AliTPCCalibGlobalMisalignment;
357   alignRot0->SetAlignGlobal(&rot0);
358   alignRot0->SetName("alignRot0");
359   alignRot1=new  AliTPCCalibGlobalMisalignment;
360   alignRot1->SetAlignGlobal(&rot1);
361   alignRot1->SetName("alignRot1");
362   alignRot2=new  AliTPCCalibGlobalMisalignment;
363   alignRot2->SetAlignGlobal(&rot2);
364   alignRot2->SetName("alignRot2");
365   //
366   alignTrans0  =new  AliTPCCalibGlobalMisalignment;
367   alignTrans0->SetAlignGlobal(&matrixX);
368   alignTrans0->SetName("alignTrans0");
369   alignTrans1=new  AliTPCCalibGlobalMisalignment;
370   alignTrans1->SetAlignGlobal(&matrixY);
371   alignTrans1->SetName("alignTrans1");
372   alignTrans2=new  AliTPCCalibGlobalMisalignment;
373   alignTrans2->SetAlignGlobal(&matrixZ);
374   alignTrans2->SetName("alignTrans2");
375   //
376   AliTPCCorrection::AddVisualCorrection(alignTrans0  ,200);
377   AliTPCCorrection::AddVisualCorrection(alignTrans1  ,201);
378   AliTPCCorrection::AddVisualCorrection(alignTrans2  ,202);
379   AliTPCCorrection::AddVisualCorrection(alignRot0    ,203);
380   AliTPCCorrection::AddVisualCorrection(alignRot1    ,204);
381   AliTPCCorrection::AddVisualCorrection(alignRot2    ,205);
382   //
383   TObjArray arrAlign(6);
384   arrAlign.AddAt(alignTrans0->Clone(),0);
385   arrAlign.AddAt(alignTrans1->Clone(),1);
386   arrAlign.AddAt(alignTrans2->Clone(),2);
387   arrAlign.AddAt(alignRot0->Clone(),3);
388   arrAlign.AddAt(alignRot1->Clone(),4);
389   arrAlign.AddAt(alignRot2->Clone(),5);
390   //combAlign.SetCorrections((TObjArray*)arrAlign.Clone());
391 }
392
393
394 void RegisterAliTPCBoundaryVoltError(){
395   //
396   // Register phi symetric E filed distortions
397   // 100-108 - A side 0 Field  
398   // 110-118 - C side 0 Field  
399   // 120-128 - A side +0.5 Field  
400   // 130-138 - C side +0.5 Field  
401   // 140-148 - A side -0.5 Field  
402   // 150-158 - C side -0.5 Field  
403   //
404   Double_t vdrift = 2.64; // [cm/us]   // to be updated: per second (ideally)
405   Double_t ezField = 400; // [V/cm]   // to be updated: never (hopefully)
406   Double_t T1 = 1.0;
407   Double_t T2 = 1.0;
408   Double_t wtP = -10.0 * (0.5*10) * vdrift /  ezField ; 
409   Double_t wtM = -10.0 * (0.5*10) * vdrift / -ezField ; 
410
411   printf("RegisterAliTPCBoundaryVoltError()\n");
412   AliTPCComposedCorrection *corrField2D = (AliTPCComposedCorrection*) fCorrections->Get("TPCFCVoltError2D");    
413   //
414   if (!corrField2D){
415     TObjArray *array=new TObjArray(16);
416     Double_t val = 40.; // 1mm
417     Float_t bound0[8] = { 0, 0,0,0,0,0,0,0};
418     Float_t boundAi[8] = { 0, 0,0,0,0,0,0,0};
419     Float_t boundCi[8] = { 0, 0,0,0,0,0,0,0};    
420     for (Int_t ipar=0; ipar<8; ipar++){
421       //
422       boundaryVoltErrorA[ipar] = new AliTPCBoundaryVoltError;
423       boundaryVoltErrorC[ipar] = new AliTPCBoundaryVoltError;
424       boundaryVoltErrorA[ipar]->SetName(Form("BoundaryVoltErrorAsidePar%d",ipar));
425       boundaryVoltErrorA[ipar]->SetTitle(Form("BoundaryVoltErrorAsidePar%d",ipar));
426       boundaryVoltErrorC[ipar]->SetName(Form("BoundaryVoltErrorCsidePar%d",ipar));
427       boundaryVoltErrorC[ipar]->SetTitle(Form("BoundaryVoltErrorCsidePar%d",ipar));
428       for (Int_t jpar=0; jpar<8; jpar++) if (ipar!=jpar){
429         boundAi[jpar]=0;
430         boundCi[jpar]=0;
431       }
432       boundAi[ipar]=val;
433       boundCi[ipar]=val;
434       //
435       boundaryVoltErrorA[ipar]->SetBoundariesA(boundAi);
436       boundaryVoltErrorA[ipar]->SetBoundariesC(bound0);
437       boundaryVoltErrorA[ipar]->InitBoundaryVoltErrorDistortion();  
438       boundaryVoltErrorA[ipar]->SetOmegaTauT1T2(0.,1,1); 
439       //
440       Float_t tempboundAi[8] = { 0, 0,0,0,0,0,-boundCi[6],-boundCi[7]};
441       boundaryVoltErrorC[ipar]->SetBoundariesA(tempboundAi);
442       boundaryVoltErrorC[ipar]->SetBoundariesC(boundCi);
443     
444       boundaryVoltErrorC[ipar]->InitBoundaryVoltErrorDistortion();  
445       boundaryVoltErrorC[ipar]->SetOmegaTauT1T2(0.,1,1); 
446       array->AddAt(boundaryVoltErrorA[ipar],ipar);
447       array->AddAt(boundaryVoltErrorC[ipar],ipar+8);
448       boundaryVoltErrorA[ipar]->Print();
449       boundaryVoltErrorC[ipar]->Print();
450       AliTPCCorrection::AddVisualCorrection(boundaryVoltErrorA[ipar], 100+ipar); 
451       AliTPCCorrection::AddVisualCorrection(boundaryVoltErrorC[ipar], 150+ipar);     
452     }
453     corrField2D = new AliTPCComposedCorrection;
454     corrField2D->SetCorrections(array);
455     corrField2D->SetOmegaTauT1T2(0,1.,1.);
456     corrField2D->Print();    
457     fCorrections->cd();
458     corrField2D->SetName("TPCFCVoltError2D");
459     corrField2D->SetTitle("TPCFCVoltError2D");
460     corrField2D->Write("TPCFCVoltError2D");
461   }else{
462     TObjArray *array = (TObjArray*)corrField2D->GetCorrections();
463     for (Int_t ipar=0; ipar<8; ipar++){
464       boundaryVoltErrorA[ipar] = (AliTPCBoundaryVoltError*) array->At(ipar);
465       boundaryVoltErrorC[ipar] = (AliTPCBoundaryVoltError*) array->At(ipar+8);      
466     }
467   }
468   //
469   // Register correction
470   for (Int_t ipar=0; ipar<8; ipar++){
471     AliTPCCorrection::AddVisualCorrection(boundaryVoltErrorA[ipar], 100+ipar); 
472     AliTPCCorrection::AddVisualCorrection(boundaryVoltErrorC[ipar], 110+ipar);     
473     //
474     // correction for +-0.5 T setting
475     AliTPCCorrection *corrField =0; 
476     corrField=(AliTPCCorrection *)boundaryVoltErrorA[ipar]->Clone();
477     corrField->SetOmegaTauT1T2(wtP,T1,T2);
478     AliTPCCorrection::AddVisualCorrection(corrField,120+ipar);
479
480     corrField=(AliTPCCorrection *)boundaryVoltErrorC[ipar]->Clone();
481     corrField->SetOmegaTauT1T2(wtP,T1,T2);
482     AliTPCCorrection::AddVisualCorrection(corrField,130+ipar);
483
484     corrField=(AliTPCCorrection *)boundaryVoltErrorA[ipar]->Clone();
485     corrField->SetOmegaTauT1T2(wtM,T1,T2);
486     AliTPCCorrection::AddVisualCorrection(corrField,140+ipar);
487
488     corrField=(AliTPCCorrection *)boundaryVoltErrorC[ipar]->Clone();
489     corrField->SetOmegaTauT1T2(wtM,T1,T2);
490     AliTPCCorrection::AddVisualCorrection(corrField,150+ipar);
491   }
492   
493 }
494
495
496
497 void RegisterAliTPCExBShape(){
498   //
499   //
500   // 
501   AliMagF *magF = new AliMagF("mag","mag");
502
503   exbShape             = new AliTPCExBBShape;
504   exbShape->SetBField(magF);
505   exbShape->SetName("TPCExBShape");
506   exbShape->SetTitle("TPCExBShape");
507   exbShape->SetOmegaTauT1T2(0,1.,1.);
508   exbShape->Print();   
509   AliTPCCorrection::AddVisualCorrection(exbShape,500); 
510   exbShapeT1X             = new AliTPCExBBShape;
511   exbShapeT1X->SetBField(magF);
512   exbShapeT1X->SetName("TPCExbShapeT1X");
513   exbShapeT1X->SetTitle("TPCExbShapeT1X");
514   exbShapeT1X->SetOmegaTauT1T2(0,1.2,1.);
515   exbShapeT1X->Print();   
516   AliTPCCorrection::AddVisualCorrection(exbShapeT1X,501); 
517   exbShapeT2X             = new AliTPCExBBShape;
518   exbShapeT2X->SetBField(magF);
519   exbShapeT2X->SetName("TPCExbShapeT2X");
520   exbShapeT2X->SetTitle("TPCExbShapeT2X");
521   exbShapeT2X->SetOmegaTauT1T2(0,1.0,1.2);
522   exbShapeT2X->Print();   
523   AliTPCCorrection::AddVisualCorrection(exbShapeT2X,502); 
524 }
525
526
527 void RegisterAliTPCExBTwist(){
528   //
529   //
530   //
531   twistX    = new  AliTPCExBTwist;
532   twistY    = new  AliTPCExBTwist;
533   twistX->SetXTwist(0.001);  // 1 mrad twist in x
534   twistX->SetName("ExBTwistX");
535   twistX->SetTitle("ExBTwistX");
536   twistY->SetYTwist(0.001);  // 1 mrad twist in y
537   twistY->SetName("ExBTwistY");
538   twistY->SetTitle("ExBTwistY");
539   twistX->SetOmegaTauT1T2(0,1.,1.);
540   twistY->SetOmegaTauT1T2(0,1.,1.);      
541   AliTPCCorrection::AddVisualCorrection(twistX,600); 
542   AliTPCCorrection::AddVisualCorrection(twistY,601); 
543 }
544
545
546 void RegisterAliTPCROCVoltError3D(){
547   //
548   // ROC rotation transformation
549   //       700 -709 - 0 field
550   //       710 -719 - +0.5 field
551   //       720 -729 - -0.5 field
552   Double_t vdrift = 2.64; // [cm/us]   // to be updated: per second (ideally)
553   Double_t ezField = 400; // [V/cm]   // to be updated: never (hopefully)
554   Double_t T1 = 1.0;
555   Double_t T2 = 1.0;
556   Double_t wtP = -10.0 * (0.5*10) * vdrift /  ezField ; 
557   Double_t wtM = -10.0 * (0.5*10) * vdrift / -ezField ; 
558
559   //
560   rocRotgXA=0;     // roc rotation A side - inclination in X
561   rocRotgYA=0;     // roc rotation A side - inclination in Y
562   rocRotgXC=0;     // roc rotation C side - inclination in X
563   rocRotgYC=0;     // roc rotation C side - inclination in Y
564   rocDzIROCA=0;      // roc shift A side - in Z
565   rocDzIROCC=0;      // roc shift C side - in Z
566   rocRotIROCA=0;      // roc rot IROC A side - in Z
567   rocRotIROCC=0;      // roc rot OROC C side - in Z
568  //
569   printf("RegisterAliTPCROCVoltError3D()");
570   Double_t kAngle=0.001;
571   // reference in lx
572   AliTPCROC * rocInfo = AliTPCROC::Instance();
573   Double_t lxRef  = (rocInfo->GetPadRowRadii(0,62)+rocInfo->GetPadRowRadii(36,0))/2;
574   //
575   TMatrixD matrix(72,3);
576  
577   AliTPCComposedCorrection *corrField3D = 0;
578   TFile *fCorrectionsROC=0;
579   fCorrectionsROC = new TFile("TPCCorrectionPrimitivesROC.root");
580   corrField3D = ( AliTPCComposedCorrection *)fCorrectionsROC->Get("TPCROCVoltError3DRotationgXgY");
581   //
582   if (!corrField3D){
583     fCorrectionsROC = new TFile("TPCCorrectionPrimitivesROC.root","recreate");
584   }  
585   if (corrField3D) { // load from file
586     corrField3D->Print();
587     TCollection *iter = corrField3D->GetCorrections();
588    
589     rocRotgXA=(AliTPCROCVoltError3D*)iter->FindObject("rocRotgXA");    
590    
591     rocRotgYA=(AliTPCROCVoltError3D*)iter->FindObject("rocRotgYA");  
592    
593     rocRotgXC=(AliTPCROCVoltError3D*)iter->FindObject("rocRotgXC");  
594    
595     rocRotgYC=(AliTPCROCVoltError3D*)iter->FindObject("rocRotgYC");  
596     
597     rocDzIROCA=(AliTPCROCVoltError3D*)iter->FindObject("rocDzIROCA");  
598    
599     rocDzIROCC=(AliTPCROCVoltError3D*)iter->FindObject("rocDzIROCC");  
600
601     rocRotIROCA=(AliTPCROCVoltError3D*)iter->FindObject("rocRotIROCA");  
602    
603     rocRotIROCC=(AliTPCROCVoltError3D*)iter->FindObject("rocRotIROCC");  
604      
605   } else {
606     corrField3D = new AliTPCComposedCorrection;
607     rocRotgXA=new AliTPCROCVoltError3D;    
608     rocRotgYA=new AliTPCROCVoltError3D;  
609     rocRotgXC=new AliTPCROCVoltError3D;  
610     rocRotgYC=new AliTPCROCVoltError3D;  
611     rocDzIROCA=new AliTPCROCVoltError3D;  
612     rocDzIROCC=new AliTPCROCVoltError3D;  
613     rocRotIROCA=new AliTPCROCVoltError3D;  
614     rocRotIROCC=new AliTPCROCVoltError3D;  
615     //
616     for (Int_t isec=0; isec<72; isec++){
617       Double_t secAlpha = TMath::DegToRad()*(10.+20.*(((Int_t)isec)%18));
618       matrix(isec,0)=0; matrix(isec,1)=0; matrix(isec,2)=0;
619       if (isec%36<18){
620         matrix(isec,0) = kAngle*TMath::Cos(secAlpha)*lxRef;
621         matrix(isec,1) = kAngle*TMath::Cos(secAlpha);
622         matrix(isec,2) = -kAngle*TMath::Sin(secAlpha);
623       }
624     }
625     rocRotgXA->SetROCData(&matrix);
626     //
627     for (Int_t isec=0; isec<72; isec++){
628       Double_t secAlpha = TMath::DegToRad()*(10.+20.*(((Int_t)isec)%18));
629       matrix(isec,0)=0; matrix(isec,1)=0; matrix(isec,2)=0;
630       if (isec%36<18){
631         matrix(isec,0) = kAngle*TMath::Sin(secAlpha)*lxRef;
632         matrix(isec,1) = kAngle*TMath::Sin(secAlpha);
633         matrix(isec,2) = kAngle*TMath::Cos(secAlpha);
634       }
635     }
636     rocRotgYA->SetROCData(&matrix);
637     //
638     for (Int_t isec=0; isec<72; isec++){
639      Double_t secAlpha = TMath::DegToRad()*(10.+20.*(((Int_t)isec)%18));
640       matrix(isec,0)=0; matrix(isec,1)=0; matrix(isec,2)=0;
641       if (isec%36>=18){
642         matrix(isec,0) = kAngle*TMath::Cos(secAlpha)*lxRef;
643         matrix(isec,1) = kAngle*TMath::Cos(secAlpha);
644         matrix(isec,2) = -kAngle*TMath::Sin(secAlpha);
645       }
646     }
647     rocRotgXC->SetROCData(&matrix);
648     //
649     for (Int_t isec=0; isec<72; isec++){
650       Double_t secAlpha = TMath::DegToRad()*(10.+20.*(((Int_t)isec)%18));
651       matrix(isec,0)=0; matrix(isec,1)=0; matrix(isec,2)=0;
652       if (isec%36>=18){
653         matrix(isec,0) = kAngle*TMath::Sin(secAlpha)*lxRef;
654         matrix(isec,1) = kAngle*TMath::Sin(secAlpha);
655         matrix(isec,2) = kAngle*TMath::Cos(secAlpha);
656       }
657     }
658     rocRotgYC->SetROCData(&matrix);
659
660     //
661     //
662     for (Int_t isec=0; isec<72; isec++){
663       matrix(isec,0)=0; matrix(isec,1)=0; matrix(isec,2)=0;
664       if (isec<18){
665         matrix(isec,0) = 0.1;  // 1 mm 
666         matrix(isec,1) = 0;
667         matrix(isec,2) = 0;
668       }
669     }
670     rocDzIROCA->SetROCData(&matrix);
671     //
672     for (Int_t isec=0; isec<72; isec++){
673       matrix(isec,0)=0; matrix(isec,1)=0; matrix(isec,2)=0;
674       if (isec>=18 && isec<36){
675         matrix(isec,0) = 0.1;  // 1 mm 
676         matrix(isec,1) = 0;
677         matrix(isec,2) = 0;
678       }
679     }
680     rocDzIROCC->SetROCData(&matrix);
681     //
682     //
683     for (Int_t isec=0; isec<72; isec++){
684       matrix(isec,0)=0; matrix(isec,1)=0; matrix(isec,2)=0;
685       if (isec<18){
686         matrix(isec,0) = 0;   
687         matrix(isec,1) = kAngle;
688         matrix(isec,2) = 0;
689       }
690     }
691     rocRotIROCA->SetROCData(&matrix);
692     //
693     for (Int_t isec=0; isec<72; isec++){
694       matrix(isec,0)=0; matrix(isec,1)=0; matrix(isec,2)=0;
695       if (isec>=18 && isec<36){
696         matrix(isec,0) = 0;
697         matrix(isec,1) = kAngle;
698         matrix(isec,2) = 0;
699       }
700     }
701     rocRotIROCC->SetROCData(&matrix);
702
703
704     //
705     rocRotgXA->SetElectronArrivalCorrection(kFALSE);
706     rocRotgYA->SetElectronArrivalCorrection(kFALSE);
707     rocRotgXC->SetElectronArrivalCorrection(kFALSE);
708     rocRotgYC->SetElectronArrivalCorrection(kFALSE);
709     rocDzIROCA->SetElectronArrivalCorrection(kFALSE);
710     rocDzIROCC->SetElectronArrivalCorrection(kFALSE);
711     rocRotIROCA->SetElectronArrivalCorrection(kFALSE);
712     rocRotIROCC->SetElectronArrivalCorrection(kFALSE);
713
714     /* // verification plots
715     rocRotgXA.CreateHistoOfZAlignment(0,500,500)->Draw("surf2"); 
716     rocRotgYA.CreateHistoOfZAlignment(0,500,500)->Draw("surf2"); 
717     rocRotgXC.CreateHistoOfZAlignment(1,500,500)->Draw("surf2"); 
718     rocRotgYC.CreateHistoOfZAlignment(1,500,500)->Draw("surf2"); 
719     */
720
721     //
722     rocRotgXA->SetName("rocRotgXA");rocRotgXA->SetTitle("rocRotgXA");
723     rocRotgYA->SetName("rocRotgYA");rocRotgYA->SetTitle("rocRotgYA");
724     rocRotgXC->SetName("rocRotgXC");rocRotgXC->SetTitle("rocRotgXC");
725     rocRotgYC->SetName("rocRotgYC");rocRotgYC->SetTitle("rocRotgYC");
726     rocDzIROCA->SetName("rocDzIROCA");rocDzIROCA->SetTitle("rocDzIROCA");
727     rocDzIROCC->SetName("rocDzIROCC");rocDzIROCC->SetTitle("rocDzIROCC");
728     rocRotIROCA->SetName("rocRotIROCA");rocRotIROCA->SetTitle("rocRotIROCA");
729     rocRotIROCC->SetName("rocRotIROCC");rocRotIROCC->SetTitle("rocRotIROCC");
730     //
731     //
732     TObjArray *cs = new TObjArray();
733     cs->Add(rocRotgXA);
734     cs->Add(rocRotgYA);
735     cs->Add(rocRotgXC);
736     cs->Add(rocRotgYC);
737     cs->Add(rocDzIROCA);
738     cs->Add(rocDzIROCC);
739     cs->Add(rocRotIROCA);
740     cs->Add(rocRotIROCC);
741     corrField3D->SetCorrections(cs);
742     corrField3D->SetOmegaTauT1T2(0,1.,1.);
743     corrField3D->Print();
744     fCorrectionsROC->cd();
745     corrField3D->Init();
746     corrField3D->Print("da");
747     fCorrectionsROC->cd();
748     corrField3D->Write("TPCROCVoltError3DRotationgXgY");
749     //     rocRotgXA->Write();       
750     //     rocRotgYA->Write(); 
751     //     rocRotgXC->Write(); 
752     //     rocRotgYC->Write(); 
753     //     rocDzIROCA->Write(); 
754     //     rocDzIROCC->Write(); 
755   }
756   AliTPCCorrection::AddVisualCorrection(rocRotgXA,701); 
757   AliTPCCorrection::AddVisualCorrection(rocRotgYA,702); 
758   AliTPCCorrection::AddVisualCorrection(rocRotgXC,703); 
759   AliTPCCorrection::AddVisualCorrection(rocRotgYC,704); 
760   AliTPCCorrection::AddVisualCorrection(rocDzIROCA,705); 
761   AliTPCCorrection::AddVisualCorrection(rocDzIROCC,706); 
762   AliTPCCorrection::AddVisualCorrection(rocRotIROCA,707); 
763   AliTPCCorrection::AddVisualCorrection(rocRotIROCC,708); 
764
765   AliTPCCorrection *corrPlus =0; 
766   //
767   corrPlus=(AliTPCCorrection *)rocRotgXA->Clone();
768   corrPlus->SetOmegaTauT1T2(wtP,T1,T2);
769   AliTPCCorrection::AddVisualCorrection(corrPlus,711);
770   //
771   corrPlus=(AliTPCCorrection *)rocRotgYA->Clone();
772   corrPlus->SetOmegaTauT1T2(wtP,T1,T2);
773   AliTPCCorrection::AddVisualCorrection(corrPlus,712);
774   //
775   corrPlus=(AliTPCCorrection *)rocRotgXC->Clone();
776   corrPlus->SetOmegaTauT1T2(wtP,T1,T2);
777   AliTPCCorrection::AddVisualCorrection(corrPlus,713);
778   //
779   corrPlus=(AliTPCCorrection *)rocRotgYC->Clone();
780   corrPlus->SetOmegaTauT1T2(wtP,T1,T2);
781   AliTPCCorrection::AddVisualCorrection(corrPlus,714);
782   //
783   corrPlus=(AliTPCCorrection *)rocDzIROCA->Clone();
784   corrPlus->SetOmegaTauT1T2(wtP,T1,T2);
785   AliTPCCorrection::AddVisualCorrection(corrPlus,715);
786   //
787   corrPlus=(AliTPCCorrection *)rocDzIROCC->Clone();
788   corrPlus->SetOmegaTauT1T2(wtP,T1,T2);
789   AliTPCCorrection::AddVisualCorrection(corrPlus,716);
790   //
791   corrPlus=(AliTPCCorrection *)rocRotIROCA->Clone();
792   corrPlus->SetOmegaTauT1T2(wtP,T1,T2);
793   AliTPCCorrection::AddVisualCorrection(corrPlus,717);
794   //
795   corrPlus=(AliTPCCorrection *)rocDzIROCC->Clone();
796   corrPlus->SetOmegaTauT1T2(wtP,T1,T2);
797   AliTPCCorrection::AddVisualCorrection(corrPlus,718);
798   //
799   //
800   AliTPCCorrection *corrMinus =0; 
801   //
802   corrMinus=(AliTPCCorrection *)rocRotgXA->Clone();
803   corrMinus->SetOmegaTauT1T2(wtM,T1,T2);
804   AliTPCCorrection::AddVisualCorrection(corrMinus,721);
805   //
806   corrMinus=(AliTPCCorrection *)rocRotgYA->Clone();
807   corrMinus->SetOmegaTauT1T2(wtM,T1,T2);
808   AliTPCCorrection::AddVisualCorrection(corrMinus,722);
809   //
810   corrMinus=(AliTPCCorrection *)rocRotgXC->Clone();
811   corrMinus->SetOmegaTauT1T2(wtM,T1,T2);
812   AliTPCCorrection::AddVisualCorrection(corrMinus,723);
813   //
814   corrMinus=(AliTPCCorrection *)rocRotgYC->Clone();
815   corrMinus->SetOmegaTauT1T2(wtM,T1,T2);
816   AliTPCCorrection::AddVisualCorrection(corrMinus,724);
817   //
818   corrMinus=(AliTPCCorrection *)rocDzIROCA->Clone();
819   corrMinus->SetOmegaTauT1T2(wtM,T1,T2);
820   AliTPCCorrection::AddVisualCorrection(corrMinus,725);
821   //
822   corrMinus=(AliTPCCorrection *)rocDzIROCC->Clone();
823   corrMinus->SetOmegaTauT1T2(wtM,T1,T2);
824   AliTPCCorrection::AddVisualCorrection(corrMinus,726);
825   //
826   corrMinus=(AliTPCCorrection *)rocRotIROCA->Clone();
827   corrMinus->SetOmegaTauT1T2(wtM,T1,T2);
828   AliTPCCorrection::AddVisualCorrection(corrMinus,727);
829   //
830   corrMinus=(AliTPCCorrection *)rocDzIROCC->Clone();
831   corrMinus->SetOmegaTauT1T2(wtM,T1,T2);
832   AliTPCCorrection::AddVisualCorrection(corrMinus,728);
833   //
834
835   fCorrectionsROC->Close();
836   delete fCorrectionsROC;
837 }
838
839
840 void RegisterAliTPCROCVoltError3DSector(){
841   //
842   // ROC rotation and shift transformation
843   // 800-819 -   0.0 Field
844   // 820-839 -  +0.5 Field
845   // 840-859 -  +0.5 Field
846
847   rocShiftIROCA0=0;      // IROC shift A0 side
848   rocRotIROCA0=0;        // IROC rot   A0 side
849   rocShiftOROCA0=0;      // OROC shift A0 side
850   rocRotOROCA0=0;        // OROC rot   A0 side
851   rocShiftIROCC0=0;      // IROC shift C0 side
852   rocRotIROCC0=0;        // IROC rot   C0 side
853   rocShiftOROCC0=0;      // OROC shift C0 side
854   rocRotOROCC0=0;        // OROC rot   C0 side
855   Double_t vdrift = 2.64; // [cm/us]   // to be updated: per second (ideally)
856   Double_t ezField = 400; // [V/cm]   // to be updated: never (hopefully)
857   Double_t T1 = 1.0;
858   Double_t T2 = 1.0;
859
860   //  Double_t wt = -10.0 * (bzField*10) * vdrift / ezField ; 
861
862   //
863   //
864   printf("RegisterAliTPCROCVoltError3DSector()");
865   Double_t kAngle=0.001;
866   Double_t kDz=0.1;
867   // reference in lx
868   //
869   TMatrixD matrix(72,3);
870  
871   AliTPCComposedCorrection *corrField3DSector = 0;
872   TFile *fCorrectionsROC=0;
873   fCorrectionsROC = new TFile("TPCCorrectionPrimitivesSector.root");
874   corrField3DSector = ( AliTPCComposedCorrection *)fCorrectionsROC->Get("TPCROCVoltError3DSector");
875   //
876   if (!corrField3DSector){
877     fCorrectionsROC = new TFile("TPCCorrectionPrimitivesSector.root","recreate");
878   }  
879   if (corrField3DSector) { // load from file
880     corrField3DSector->Print();
881     TCollection *iter = corrField3DSector->GetCorrections();
882     //
883     rocShiftIROCA0=(AliTPCROCVoltError3D*)iter->FindObject("rocShiftIROCA0");   // IROC shift A0 side
884     rocRotIROCA0=(AliTPCROCVoltError3D*)iter->FindObject("rocRotIROCA0");       // IROC rot   A0 side
885     rocShiftOROCA0=(AliTPCROCVoltError3D*)iter->FindObject("rocShiftOROCA0");   // OROC shift A0 side
886     rocRotOROCA0=(AliTPCROCVoltError3D*)iter->FindObject("rocRotOROCA0");       // OROC rot   A0 side
887     rocShiftIROCC0=(AliTPCROCVoltError3D*)iter->FindObject("rocShiftIROCC0");   // IROC shift C0 side
888     rocRotIROCC0=(AliTPCROCVoltError3D*)iter->FindObject("rocRotIROCC0");       // IROC rot   C0 side
889     rocShiftOROCC0=(AliTPCROCVoltError3D*)iter->FindObject("rocShiftOROCC0");   // OROC shift C0 side
890     rocRotOROCC0=(AliTPCROCVoltError3D*)iter->FindObject("rocRotOROCC0");       // OROC rot   C0 side
891      
892   } else {
893     corrField3DSector = new AliTPCComposedCorrection;
894     rocShiftIROCA0=new AliTPCROCVoltError3D;      // IROC shift A0 side
895     rocRotIROCA0=new AliTPCROCVoltError3D;        // IROC rot   A0 side
896     rocShiftOROCA0=new AliTPCROCVoltError3D;      // OROC shift A0 side
897     rocRotOROCA0=new AliTPCROCVoltError3D;        // OROC rot   A0 side
898     rocShiftIROCC0=new AliTPCROCVoltError3D;      // IROC shift C0 side
899     rocRotIROCC0=new AliTPCROCVoltError3D;        // IROC rot   C0 side
900     rocShiftOROCC0=new AliTPCROCVoltError3D;      // OROC shift C0 side
901     rocRotOROCC0=new AliTPCROCVoltError3D;        // OROC rot   C0 side
902     //
903     matrix.Zero(); matrix(0,0)=kDz; 
904     rocShiftIROCA0->SetROCData(&matrix);
905     matrix.Zero(); matrix(0,1)=kAngle; 
906     rocRotIROCA0->SetROCData(&matrix);
907     matrix.Zero(); matrix(36,0)=kDz; 
908     rocShiftOROCA0->SetROCData(&matrix);
909     matrix.Zero(); matrix(36,1)=kAngle; 
910     rocRotOROCA0->SetROCData(&matrix);
911
912     matrix.Zero(); matrix(18,0)=kDz; 
913     rocShiftIROCC0->SetROCData(&matrix);
914     matrix.Zero(); matrix(18,1)=kAngle; 
915     rocRotIROCC0->SetROCData(&matrix);
916     matrix.Zero(); matrix(36+18,0)=kDz; 
917     rocShiftOROCC0->SetROCData(&matrix);
918     matrix.Zero(); matrix(36+18,1)=kAngle; 
919     rocRotOROCC0->SetROCData(&matrix);
920     //
921     rocShiftIROCA0->SetElectronArrivalCorrection(kFALSE);     // IROC shift A0 side
922     rocRotIROCA0->SetElectronArrivalCorrection(kFALSE);        // IROC rot   A0 side
923     rocShiftOROCA0->SetElectronArrivalCorrection(kFALSE);      // OROC shift A0 side
924     rocRotOROCA0->SetElectronArrivalCorrection(kFALSE);        // OROC rot   A0 side
925     rocShiftIROCC0->SetElectronArrivalCorrection(kFALSE);      // IROC shift C0 side
926     rocRotIROCC0->SetElectronArrivalCorrection(kFALSE);        // IROC rot   C0 side
927     rocShiftOROCC0->SetElectronArrivalCorrection(kFALSE);      // OROC shift C0 side
928     rocRotOROCC0->SetElectronArrivalCorrection(kFALSE);        // OROC rot   C0 side
929
930     /* // verification plots
931     */
932     //
933     rocShiftIROCA0->SetName("rocShiftIROCA0");rocShiftIROCA0->SetTitle("rocShiftIROCA0");
934     rocRotIROCA0->SetName("rocRotIROCA0");rocRotIROCA0->SetTitle("rocRotIROCA0");
935     rocShiftOROCA0->SetName("rocShiftOROCA0"); rocShiftOROCA0->SetTitle("rocShiftOROCA0");
936     rocRotOROCA0->SetName("rocRotOROCA0");rocRotOROCA0->SetTitle("rocRotOROCA0");
937     //
938     rocShiftIROCC0->SetName("rocShiftIROCC0");rocShiftIROCC0->SetTitle("rocShiftIROCC0");
939     rocRotIROCC0->SetName("rocRotIROCC0");rocRotIROCC0->SetTitle("rocRotIROCC0");
940     rocShiftOROCC0->SetName("rocShiftOROCC0");rocShiftOROCC0->SetTitle("rocShiftOROCC0");
941     rocRotOROCC0->SetName("rocRotOROCC0");rocRotOROCC0->SetTitle("rocRotOROCC0");
942     //
943     //
944     TObjArray *cs = new TObjArray();
945     cs->Add(rocShiftIROCA0);      // IROC shift A0 side
946     cs->Add(rocRotIROCA0);        // IROC rot   A0 side
947     cs->Add(rocShiftOROCA0);      // OROC shift A0 side
948     cs->Add(rocRotOROCA0);        // OROC rot   A0 side
949     cs->Add(rocShiftIROCC0);      // IROC shift C0 side
950     cs->Add(rocRotIROCC0);        // IROC rot   C0 side
951     cs->Add(rocShiftOROCC0);      // OROC shift C0 side
952     cs->Add(rocRotOROCC0);        // OROC rot   C0 side
953     //
954     corrField3DSector->SetCorrections(cs);
955     corrField3DSector->SetOmegaTauT1T2(0,T1,T2);
956     corrField3DSector->Print();
957     //
958
959     fCorrectionsROC->cd();
960     corrField3DSector->Init();
961     corrField3DSector->Print("da");
962     fCorrectionsROC->cd();
963     corrField3DSector->Write("TPCROCVoltError3DSector");
964   }
965   AliTPCCorrection::AddVisualCorrection(rocShiftIROCA0,800);      // IROC shift A0 side
966   AliTPCCorrection::AddVisualCorrection(rocRotIROCA0,801);        // IROC rot   A0 side
967   AliTPCCorrection::AddVisualCorrection(rocShiftOROCA0,802);      // OROC shift A0 side
968   AliTPCCorrection::AddVisualCorrection(rocRotOROCA0,803);        // OROC rot   A0 side
969   AliTPCCorrection::AddVisualCorrection(rocShiftIROCC0,804);      // IROC shift C0 side
970   AliTPCCorrection::AddVisualCorrection(rocRotIROCC0,805);        // IROC rot   C0 side
971   AliTPCCorrection::AddVisualCorrection(rocShiftOROCC0,806);      // OROC shift C0 side
972   AliTPCCorrection::AddVisualCorrection(rocRotOROCC0,807);        // OROC rot   C0 side 
973   //
974   // Register correction for plus setting
975   AliTPCCorrection *corr =0; 
976   Double_t wtp = -10.0 * (0.5*10) * vdrift / ezField ; 
977   Double_t wtm = -10.0 * (0.5*10) * vdrift / -ezField ; 
978
979   corr=(AliTPCCorrection *)rocShiftIROCA0->Clone();
980   corr->SetOmegaTauT1T2(wtp,T1,T2);
981   AliTPCCorrection::AddVisualCorrection(corr,820);           // IROC shift A0 side + Plus field
982   //
983   corr=(AliTPCCorrection *)rocRotIROCA0->Clone();
984   corr->SetOmegaTauT1T2(wtp,T1,T2);
985   AliTPCCorrection::AddVisualCorrection(corr,821);           // IROC rot   A0 side
986   //
987   corr=(AliTPCCorrection *)rocShiftOROCA0->Clone();
988   corr->SetOmegaTauT1T2(wtp,T1,T2);
989   AliTPCCorrection::AddVisualCorrection(corr,822);            // OROC shift   A0 side
990   //
991   corr=(AliTPCCorrection *)rocRotOROCA0->Clone();
992   corr->SetOmegaTauT1T2(wtp,T1,T2);
993   AliTPCCorrection::AddVisualCorrection(corr,823);            // OROC rot   A0 side
994   corr=(AliTPCCorrection *)rocShiftIROCC0->Clone();
995   corr->SetOmegaTauT1T2(wtp,T1,T2);
996   AliTPCCorrection::AddVisualCorrection(corr,824);           // IROC shift C0 side + Plus field
997   //
998   corr=(AliTPCCorrection *)rocRotIROCC0->Clone();
999   corr->SetOmegaTauT1T2(wtp,T1,T2);
1000   AliTPCCorrection::AddVisualCorrection(corr,825);           // IROC rot   C0 side
1001   //
1002   corr=(AliTPCCorrection *)rocShiftOROCC0->Clone();
1003   corr->SetOmegaTauT1T2(wtp,T1,T2);
1004   AliTPCCorrection::AddVisualCorrection(corr,826);            // OROC shift   C0 side
1005   //
1006   corr=(AliTPCCorrection *)rocRotOROCC0->Clone();
1007   corr->SetOmegaTauT1T2(wtp,T1,T2);
1008   AliTPCCorrection::AddVisualCorrection(corr,827);            // OROC rot   C0 side
1009   //
1010   corr=(AliTPCCorrection *)rocShiftIROCA0->Clone();
1011   corr->SetOmegaTauT1T2(wtm,T1,T2);
1012   AliTPCCorrection::AddVisualCorrection(corr,840);           // IROC shift A0 side + Plus field
1013   //
1014   corr=(AliTPCCorrection *)rocRotIROCA0->Clone();
1015   corr->SetOmegaTauT1T2(wtm,T1,T2);
1016   AliTPCCorrection::AddVisualCorrection(corr,841);           // IROC rot   A0 side
1017   //
1018   corr=(AliTPCCorrection *)rocShiftOROCA0->Clone();
1019   corr->SetOmegaTauT1T2(wtm,T1,T2);
1020   AliTPCCorrection::AddVisualCorrection(corr,842);            // OROC shift   A0 side
1021   //
1022   corr=(AliTPCCorrection *)rocRotOROCA0->Clone();
1023   corr->SetOmegaTauT1T2(wtm,T1,T2);
1024   AliTPCCorrection::AddVisualCorrection(corr,843);            // OROC rot   A0 side
1025   corr=(AliTPCCorrection *)rocShiftIROCC0->Clone();
1026   corr->SetOmegaTauT1T2(wtm,T1,T2);
1027   AliTPCCorrection::AddVisualCorrection(corr,844);           // IROC shift C0 side + Plus field
1028   //
1029   corr=(AliTPCCorrection *)rocRotIROCC0->Clone();
1030   corr->SetOmegaTauT1T2(wtm,T1,T2);
1031   AliTPCCorrection::AddVisualCorrection(corr,845);           // IROC rot   C0 side
1032   //
1033   corr=(AliTPCCorrection *)rocShiftOROCC0->Clone();
1034   corr->SetOmegaTauT1T2(wtm,T1,T2);
1035   AliTPCCorrection::AddVisualCorrection(corr,846);            // OROC shift   C0 side
1036   //
1037   corr=(AliTPCCorrection *)rocRotOROCC0->Clone();
1038   corr->SetOmegaTauT1T2(wtm,T1,T2);
1039   AliTPCCorrection::AddVisualCorrection(corr,847);            // OROC rot   C0 side
1040   //
1041   fCorrectionsROC->Close();
1042   delete fCorrectionsROC;
1043 }
1044
1045
1046
1047
1048
1049 AliTPCComposedCorrection * MakeComposedCorrectionExB(){
1050   //
1051   // make composed corection for ExB scanning
1052   //
1053   RegisterCorrection();
1054   //
1055   //Double_t bzField=AliTrackerBase::GetBz();    
1056   //  AliMagF* magF= (AliMagF*)(TGeoGlobalMagField::Instance()->GetField());
1057   //Double_t vdrift = 2.6; // [cm/us]   // to be updated: per second (ideally)
1058   //Double_t ezField = 400; // [V/cm]   // to be updated: never (hopefully)
1059   //  Double_t wt = -10.0 * (bzField*10) * vdrift / ezField ; 
1060   //Double_t T1 = 1.0;
1061   //Double_t T2 = 1.0;
1062   //
1063   TObjArray * corr = new TObjArray;
1064   corr->AddLast(twistX);
1065   corr->AddLast(twistY);
1066   for (Int_t i=0; i<8; i++){
1067     corr->AddLast(boundaryVoltErrorA[i]);
1068     corr->AddLast(boundaryVoltErrorC[i]);
1069   }
1070   corr->AddLast(alignTrans0);
1071   corr->AddLast(alignTrans1);
1072   corr->AddLast(alignTrans2);
1073   corr->AddLast(alignRot0);
1074   corr->AddLast(alignRot1);
1075   corr->AddLast(alignRot2);
1076   corr->AddLast(rocRotgXA);
1077   corr->AddLast(rocRotgYA);
1078   corr->AddLast(rocRotgXC);
1079   corr->AddLast(rocRotgYC);
1080   corr->AddLast(exbShape);
1081   corr->AddLast(exbShapeT1X);
1082   corr->AddLast(exbShapeT2X);
1083   corr->AddLast(rocRotgXA);
1084   corr->AddLast(rocRotgYA);
1085   corr->AddLast(rocRotgXC);
1086   corr->AddLast(rocRotgYC);
1087   corr->AddLast(rocDzIROCA);
1088   corr->AddLast(rocDzIROCC);
1089   AliTPCComposedCorrection *cc= new AliTPCComposedCorrection ;
1090   cc->SetCorrections((TObjArray*)(corr));
1091   //cc->SetOmegaTauT1T2(wt,T1,T2);  
1092   //exbShapeT1X->SetOmegaTauT1T2(0,1.2,1.0);
1093   //exbShapeT2X->SetOmegaTauT1T2(0,1.0,1.2);
1094   //cc->Init();
1095   cc->Print("DA"); // Print used correction classes
1096   cc->SetName("ComposedExB");
1097   TFile fexb("RegisterCorrectionExB.root","recreate");
1098   cc->Write("ComposedExB");
1099   fexb.Close();
1100   return cc;
1101 }