AliRoot Core  edcc906 (edcc906)
UnitTest.C
Go to the documentation of this file.
1 
13 #include "TF1.h"
14 #include "TMath.h"
15 #include "TLinearFitter.h"
16 #include "TFile.h"
17 #include "AliSysInfo.h"
18 #include "TTree.h"
19 #include "AliLog.h"
20 #include "THn.h"
21 #include "TRandom.h"
22 #include "AliTPCCalPad.h"
23 #include "AliTPCCalibViewer.h"
24 #include "AliTPCcalibDButil.h"
25 #include "AliTPCCorrection.h"
27 #include "AliTPCExBTwist.h"
28 #include "AliTPCFCVoltError3D.h"
29 #include "AliTPCROCVoltError3D.h"
32 #include "AliCDBEntry.h"
33 #include "TStopwatch.h"
34 #include "TGeoMatrix.h"
35 #include "TGeoGlobalMagField.h"
36 #include "AliMagF.h"
37 // PARAMETERS to set from outside:
38 TString baseDir="/hera/alice/wiechula/calib/guiTrees"; // TO FIX specification of inout data
39 //
40 //
41 
50 
56 
57  TObjArray *fArray = new TObjArray(100);
59  for (Int_t i=0; i<5; i+=2){
60  AliTPCCalPad * padLx = AliTPCCalPad::MakePadFromTree(treePad,"lx.fElements","Lx",kTRUE);
61  AliTPCCalPad * padLy = AliTPCCalPad::MakePadFromTree(treePad,"ly.fElements","Ly",kTRUE);
62  AliTPCCalPad * padLLx = AliTPCCalPad::MakePadFromTree(treePad,"lx.fElements","LLx",kTRUE);
63  AliTPCCalPad * padLLy = AliTPCCalPad::MakePadFromTree(treePad,"ly.fElements","LLy",kTRUE);
64  AliTPCCalPad * padMax = AliTPCCalPad::MakePadFromTree(treePad,"QA.2010.LHC10d.MaxCharge.fElements","QMax",kTRUE);
65  AliTPCCalPad * padMean = AliTPCCalPad::MakePadFromTree(treePad,"QA.2010.LHC10d.MeanCharge.fElements","QTot",kTRUE);
66  AliTPCCalPad * padMaxL = AliTPCCalPad::MakePadFromTree(treePad,"QA.2010.LHC10d.MaxCharge.fElements","QMax",kTRUE);
67  AliTPCCalPad * padMeanL = AliTPCCalPad::MakePadFromTree(treePad,"QA.2010.LHC10d.MeanCharge.fElements","QTot",kTRUE);
68  if (i>0) {
69  padLx->MedianFilter(i,2*i);
70  padLy->MedianFilter(i,2*i);
71  padLLx->LTMFilter(i,2*i,1.00, 0);
72  padLLy->LTMFilter(i,2*i,1.00, 0);
73  padMax->MedianFilter(i,2*i);
74  padMean->MedianFilter(i,2*i);
75  padMaxL->LTMFilter(i,2*i,0.8,0);
76  padMeanL->LTMFilter(i,2*i,0.8,0);
77  }
78  padLx->SetName(TString::Format("Lx%d",i).Data());
79  padLy->SetName(TString::Format("Ly%d",i).Data());
80  padLLx->SetName(TString::Format("LLx%d",i).Data());
81  padLLy->SetName(TString::Format("LLy%d",i).Data());
82  padMax->SetName(TString::Format("QMax%d",i).Data());
83  padMean->SetName(TString::Format("QTot%d",i).Data());
84  padMaxL->SetName(TString::Format("QMaxL%d",i).Data());
85  padMeanL->SetName(TString::Format("QTotL%d",i).Data());
86  fArray->AddLast(padLx);
87  fArray->AddLast(padLy);
88  fArray->AddLast(padLLx);
89  fArray->AddLast(padLLy);
90  fArray->AddLast(padMax);
91  fArray->AddLast(padMean);
92  fArray->AddLast(padMaxL);
93  fArray->AddLast(padMeanL);
94  }
95  AliTPCCalibViewer::MakeTree("QAtest.root", fArray,0);
96  //
97  // 2.) Check invariants
98  //
99  TFile*fout= TFile::Open("QAtest.root");
100  TTree * tree = (TTree*)fout->Get("calPads");
101  Int_t isOutM0 = tree->Draw("(Ly2.fElements-Ly0.fElements)>>his0(100,-10,10)","abs((Ly2.fElements-Ly0.fElements))>2","goff");
102  Int_t isOutM1=tree->Draw("(Lx2.fElements-Lx0.fElements)/0.75>>his1(100,-10,10)","abs((Lx2.fElements-Lx0.fElements))>0","goff");
103  printf("IsOut=%d\t%d\n",isOutM0,isOutM1);
104  if ((isOutM0+isOutM1)==0) ::Info("UnitTestAliTPCCalPadTree","MedianTest OK");
105  if (isOutM0||isOutM1) ::Fatal("UnitTestAliTPCCalPadTree","MedianTest FAILED");
106  //
107  Int_t isOutL0 = tree->Draw("(LLy2.fElements-Ly0.fElements)>>his0(100,-10,10)","abs((LLy2.fElements-LLy0.fElements))>0","goff");
108  Int_t isOutL1=tree->Draw("(LLx2.fElements-Lx0.fElements)/0.75>>his1(100,-10,10)","abs((LLx2.fElements-LLx0.fElements))>0","goff");
109  printf("IsOut=%d\t%d\n",isOutL0,isOutL1);
110  if ((isOutL0+isOutL1)==0) ::Info("UnitTestAliTPCCalPadTree","LTMTest OK");
111  if (isOutL0||isOutL1) ::Fatal("UnitTestAliTPCCalPadTree","LTMTest FAILED");
112 }
113 
114 
117 
118  Bool_t isOK[10]={kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE};
119  AliTPCComposedCorrection *compCorrTwist = new AliTPCComposedCorrection();
122  twistX->SetXTwist(0.001); // 1 mrad twist in x
123  twistY->SetYTwist(0.001); // 1 mrad twist in x
124  isOK[0]&=compCorrTwist->AddCorrectionCompact(twistX,0.5);
125  isOK[0]&=compCorrTwist->AddCorrectionCompact(twistY,0.5);
126  isOK[0]&=compCorrTwist->AddCorrectionCompact(twistX,0.5);
127  isOK[0]&=compCorrTwist->AddCorrectionCompact(twistY,0.5);
128  isOK[0]&=compCorrTwist->AddCorrectionCompact(twistY,-1);
129  isOK[0]&=compCorrTwist->AddCorrectionCompact(twistX,-1);
130  isOK[1]=compCorrTwist->GetCorrections()->GetEntries()==1;
131 
132  AliTPCExBTwist *twistRes=0;
133  if (isOK[1]==kFALSE){
134  isOK[2]=kFALSE;
135  isOK[3]=kFALSE;
136  isOK[4]=kFALSE;
137  }else{
138  twistRes= dynamic_cast<AliTPCExBTwist *>(compCorrTwist->GetSubCorrection(0));
139  if (twistRes==NULL){
140  isOK[2]=kFALSE;
141  isOK[3]=kFALSE;
142  isOK[4]=kFALSE;
143  }else{
144  isOK[3] &= (twistRes->GetXTwist()==0);
145  isOK[4] &= (twistRes->GetYTwist()==0);
146  }
147  }
148  Bool_t res=kTRUE;
149  for (Int_t i=0; i<5; i++) res&=isOK[i];
150  {
151  if (isOK[0]==kFALSE){
152  ::Error("TestCorrection_AddCorrectionCompact","AliTPCExBTwist -ADD FAILED");
153  }else{
154  ::Info("TestCorrection_AddCorrectionCompact","AliTPCExBTwist -ADD OK");
155  }
156  if (isOK[1]==kFALSE){
157  ::Error("TestCorrection_AddCorrectionCompact","AliTPCExBTwist - wrong entries FAILED");
158  }else{
159  ::Info("TestCorrection_AddCorrectionCompact","AliTPCExBTwist - entries OK");
160  }
161  if (isOK[2]==kFALSE || isOK[3]==kFALSE ||isOK[4]==kFALSE ){
162  ::Error("TestCorrection_AddCorrectionCompact","AliTPCExBTwist - inconsitent entries FAILED");
163  }else{
164  ::Info("TestCorrection_AddCorrectionCompact","AliTPCExBTwist - consistent entries OK");
165  }
166  }
167  return res;
168 }
169 
170 
173 
174  const Float_t kEpsilon=0.000001;
175  Bool_t isOK[10]={kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE};
179  for (Int_t isec=0; isec<36; isec++){
180  corr0->SetRodVoltShiftA(isec,TMath::Cos(TMath::Pi()*isec/36),kFALSE);
181  corr0->SetRodVoltShiftC(isec,TMath::Cos(TMath::Pi()*isec/36),kFALSE);
182  corr1->SetRodVoltShiftA(isec,TMath::Sin(TMath::Pi()*isec/36),kFALSE);
183  corr1->SetRodVoltShiftC(isec,TMath::Sin(TMath::Pi()*isec/36),kFALSE);
184  corr1->SetCopperRodShiftA(isec,TMath::Sin(TMath::Pi()*isec/36),kFALSE);
185  corr1->SetCopperRodShiftC(isec,TMath::Sin(TMath::Pi()*isec/36),kFALSE);
186  }
187  //
188  isOK[0]&=compCorrComp->AddCorrectionCompact(corr0,0.5);
189  isOK[0]&=compCorrComp->AddCorrectionCompact(corr1,0.5);
190  isOK[0]&=compCorrComp->AddCorrectionCompact(corr0,0.5);
191  isOK[0]&=compCorrComp->AddCorrectionCompact(corr1,0.5);
192  isOK[0]&=compCorrComp->AddCorrectionCompact(corr1,-1);
193  isOK[0]&=compCorrComp->AddCorrectionCompact(corr0,-1);
194  isOK[1]=compCorrComp->GetCorrections()->GetEntries()==1;
195  AliTPCFCVoltError3D *corrRes=0;
196  if (isOK[1]==kFALSE){
197  isOK[2]=kFALSE;
198  isOK[3]=kFALSE;
199  isOK[4]=kFALSE;
200  }else{
201  corrRes= dynamic_cast<AliTPCFCVoltError3D *>(compCorrComp->GetSubCorrection(0));
202  if (corrRes==NULL){
203  isOK[2]=kFALSE;
204  isOK[3]=kFALSE;
205  isOK[4]=kFALSE;
206  }else{
207  for (Int_t isec=0; isec<36; isec++){
208  isOK[3] &=( TMath::Abs(corrRes->GetRodVoltShiftA(isec))<kEpsilon);
209  isOK[4] &=( TMath::Abs(corrRes->GetRodVoltShiftC(isec))<kEpsilon);
210  isOK[5] &=( TMath::Abs(corrRes->GetCopperRodShiftA(isec))<kEpsilon);
211  isOK[6] &=( TMath::Abs(corrRes->GetCopperRodShiftC(isec))<kEpsilon);
212  }
213  }
214  }
215  Bool_t res=kTRUE;
216  for (Int_t i=0; i<5; i++) res&=isOK[i];
217  {
218  if (isOK[0]==kFALSE){
219  ::Error("TestCorrection_AddCorrectionCompact","AliTPCFCVoltError3D -ADD FAILED");
220  }else{
221  ::Info("TestCorrection_AddCorrectionCompact","AliTPCFCVoltError3D -ADD OK");
222  }
223  if (isOK[1]==kFALSE){
224  ::Error("TestCorrection_AddCorrectionCompact","AliTPCFCVoltError3D - wrong entries FAILED");
225  }else{
226  ::Info("TestCorrection_AddCorrectionCompact","AliTPCFCVoltError3D - entries OK");
227  }
228  if (isOK[2]==kFALSE || isOK[3]==kFALSE ||isOK[4]==kFALSE ){
229  ::Error("TestCorrection_AddCorrectionCompact","AliTPCFCVoltError3D - inconsitent entries FAILED");
230  }else{
231  ::Info("TestCorrection_AddCorrectionCompact","AliTPCFCVoltError3D - consistent entries OK");
232  }
233  }
234  return res;
235 }
236 
237 
238 
241 
242  const Float_t kEpsilon=0.00000001;
243  Bool_t isOK[10]={kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE};
244  AliTPCComposedCorrection *compCorrROCVoltError3D = new AliTPCComposedCorrection();
247  TMatrixD matrixDz(72,3);
248  for (Int_t isec=0; isec<72; isec++){
249  matrixDz(isec,0)=gRandom->Rndm()*0.1;
250  matrixDz(isec,1)=gRandom->Rndm()*0.001;
251  matrixDz(isec,2)=gRandom->Rndm()*0.001;
252  }
253  corr0->SetROCData(&matrixDz);
254  matrixDz*=0.5;
255  corr1->SetROCData(&matrixDz);
256  //
257  isOK[0]&=compCorrROCVoltError3D->AddCorrectionCompact(corr0,0.5);
258  isOK[0]&=compCorrROCVoltError3D->AddCorrectionCompact(corr1,0.5);
259  isOK[0]&=compCorrROCVoltError3D->AddCorrectionCompact(corr0,0.5);
260  isOK[0]&=compCorrROCVoltError3D->AddCorrectionCompact(corr1,0.5);
261  isOK[0]&=compCorrROCVoltError3D->AddCorrectionCompact(corr1,-1);
262  isOK[0]&=compCorrROCVoltError3D->AddCorrectionCompact(corr0,-1);
263  isOK[1]=compCorrROCVoltError3D->GetCorrections()->GetEntries()==1;
264  AliTPCROCVoltError3D *corrRes=0;
265  if (isOK[1]==kFALSE){
266  isOK[2]=kFALSE;
267  isOK[3]=kFALSE;
268  isOK[4]=kFALSE;
269  }else{
270  corrRes= dynamic_cast<AliTPCROCVoltError3D *>(compCorrROCVoltError3D->GetSubCorrection(0));
271  if (corrRes==NULL){
272  isOK[2]=kFALSE;
273  isOK[3]=kFALSE;
274  isOK[4]=kFALSE;
275  }else{
276  isOK[3]=TMath::Abs(corrRes->GetMatrix()->Sum())<kEpsilon;
277  }
278  }
279  Bool_t res=kTRUE;
280  for (Int_t i=0; i<5; i++) res&=isOK[i];
281  {
282  if (isOK[0]==kFALSE){
283  ::Error("TestCorrection_AddCorrectionCompact","AliTPCROCVoltError3D -ADD FAILED");
284  }else{
285  ::Info("TestCorrection_AddCorrectionCompact","AliTPCROCVoltError3D -ADD OK");
286  }
287  if (isOK[1]==kFALSE){
288  ::Error("TestCorrection_AddCorrectionCompact","AliTPCROCVoltError3D - wrong entries FAILED");
289  }else{
290  ::Info("TestCorrection_AddCorrectionCompact","AliTPCROCVoltError3D - entries OK");
291  }
292  if (isOK[2]==kFALSE || isOK[3]==kFALSE ||isOK[4]==kFALSE ){
293  ::Error("TestCorrection_AddCorrectionCompact","AliTPCROCVoltError3D - inconsitent entries FAILED");
294  }else{
295  ::Info("TestCorrection_AddCorrectionCompact","AliTPCROCVoltError3D - consistent entries OK");
296  }
297  }
298  return res;
299 }
300 
301 
302 
303 
304 
307 
308  const Float_t kEpsilon=0.00000001;
309  Bool_t isOK[10]={kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE};
310  AliTPCComposedCorrection *compCorrBoundaryVoltError = new AliTPCComposedCorrection();
313  Float_t boundaries[8];
314  for (Int_t ibound=0; ibound<8; ibound++){
315  boundaries[ibound]=gRandom->Rndm()-0.5;
316  }
317  corr0->SetBoundariesA(boundaries);
318  corr1->SetBoundariesA(boundaries);
319  //
320  isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr0,0.5);
321  isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr1,0.5);
322  isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr0,0.5);
323  isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr1,0.5);
324  isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr1,-1);
325  isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr0,-1);
326  isOK[1]=compCorrBoundaryVoltError->GetCorrections()->GetEntries()==1;
327  AliTPCBoundaryVoltError *corrRes=0;
328  if (isOK[1]==kFALSE){
329  isOK[2]=kFALSE;
330  isOK[3]=kFALSE;
331  isOK[4]=kFALSE;
332  }else{
333  corrRes= dynamic_cast<AliTPCBoundaryVoltError *>(compCorrBoundaryVoltError->GetSubCorrection(0));
334  if (corrRes==NULL){
335  isOK[2]=kFALSE;
336  isOK[3]=kFALSE;
337  isOK[4]=kFALSE;
338  }else{
339  for (Int_t ibound=0; ibound<8; ibound++){
340  isOK[3]&=TMath::Abs(corrRes->GetBoundariesA(ibound))<kEpsilon;
341  isOK[3]&=TMath::Abs(corrRes->GetBoundariesC(ibound))<kEpsilon;
342  }
343  }
344  }
345  Bool_t res=kTRUE;
346  for (Int_t i=0; i<5; i++) res&=isOK[i];
347  {
348  if (isOK[0]==kFALSE){
349  ::Error("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError -ADD FAILED");
350  }else{
351  ::Info("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError -ADD OK");
352  }
353  if (isOK[1]==kFALSE){
354  ::Error("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError - wrong entries FAILED");
355  }else{
356  ::Info("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError - entries OK");
357  }
358  if (isOK[2]==kFALSE || isOK[3]==kFALSE ||isOK[4]==kFALSE ){
359  ::Error("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError - inconsitent entries FAILED");
360  }else{
361  ::Info("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError - consistent entries OK");
362  }
363  }
364  return res;
365 }
366 
367 
368 
369 
370 
376 
377  const Float_t kEpsilon=0.0001;
378  Bool_t isOK[10]={kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE};
379  Double_t delta[3]={0.01,0.02,0.03};
380 
381  AliTPCComposedCorrection *compCorrBoundaryVoltError = new AliTPCComposedCorrection();
385  TObjArray sectorAlign(72);
386 
387  TGeoHMatrix *hmatrix0 = new TGeoHMatrix;
388  TGeoHMatrix *hmatrix1 = new TGeoHMatrix;
389  hmatrix0->RotateX(TMath::RadToDeg()*0.0001);
390  hmatrix0->RotateY(TMath::RadToDeg()*0.0002);
391  hmatrix0->RotateZ(TMath::RadToDeg()*0.0003);
392  hmatrix1->SetTranslation(delta);
393  for (Int_t isec=0; isec<72; isec++){
394  if ((isec%2)==0) sectorAlign.AddAt(hmatrix0,isec);
395  if ((isec%2)==1) sectorAlign.AddAt(hmatrix1,isec);
396  }
397  corr0->SetAlignGlobal(hmatrix0);
398  corr1->SetAlignGlobal(hmatrix1);
399  corr0->SetAlignGlobalDelta(hmatrix1);
400  corr1->SetAlignGlobalDelta(hmatrix0);
401  corr2->SetAlignSectors(&sectorAlign);
402  //
403  isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr0,0.5);
404  isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr1,0.5);
405  isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr0,0.5);
406  isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr1,0.5);
407  isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr0,-1);
408  isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr1,-1);
409  //
410  isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr2,1);
411  isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr2,-1);
412  //
413  //
414  isOK[1]=compCorrBoundaryVoltError->GetCorrections()->GetEntries()==1;
416  if (isOK[1]==kFALSE){
417  isOK[2]=kFALSE;
418  isOK[3]=kFALSE;
419  isOK[4]=kFALSE;
420  }else{
421  corrRes= dynamic_cast<AliTPCCalibGlobalMisalignment *>(compCorrBoundaryVoltError->GetSubCorrection(0));
422  if (corrRes==NULL){
423  isOK[2]=kFALSE;
424  isOK[3]=kFALSE;
425  isOK[4]=kFALSE;
426  }else{
427  for (Int_t itrans=0; itrans<3; itrans++){
428  isOK[2+itrans]&=TMath::Abs(corrRes->GetAlignGlobal()->GetTranslation()[itrans])<kEpsilon;
429  for (Int_t isec=0; isec<72; isec++){
430  isOK[2+itrans]&=TMath::Abs(((TGeoHMatrix*)(corrRes->GetAlignSectors()->At(isec)))->GetTranslation()[itrans])<kEpsilon;
431  }
432  }
433  corrRes->GetAlignGlobal()->Print();
434  corrRes->GetAlignSectors()->At(0)->Print();
435  corrRes->GetAlignSectors()->At(1)->Print();
436  }
437  }
438  Bool_t res=kTRUE;
439  for (Int_t i=0; i<5; i++) res&=isOK[i];
440  {
441  if (isOK[0]==kFALSE){
442  ::Error("TestCorrection_AddCorrectionCompact","AliTPCCalibGlobalMisalignment -ADD FAILED");
443  }else{
444  ::Info("TestCorrection_AddCorrectionCompact","AliTPCCalibGlobalMisalignment -ADD OK");
445  }
446  if (isOK[1]==kFALSE){
447  ::Error("TestCorrection_AddCorrectionCompact","AliTPCCalibGlobalMisalignment - wrong entries FAILED");
448  }else{
449  ::Info("TestCorrection_AddCorrectionCompact","AliTPCCalibGlobalMisalignment - entries OK");
450  }
451  if (isOK[2]==kFALSE || isOK[3]==kFALSE ||isOK[4]==kFALSE ){
452  ::Error("TestCorrection_AddCorrectionCompact","AliTPCCalibGlobalMisalignment - inconsitent entries FAILED");
453  }else{
454  ::Info("TestCorrection_AddCorrectionCompact","AliTPCCalibGlobalMisalignment - consistent entries OK");
455  }
456  }
457  return res;
458 }
459 
462 
468 }
469 
472 
473  const Int_t npointsTest=10000;
474  const Float_t kEpsilon=0.001; //10 microns
475  TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", -1., -1., AliMagF::k5kG));
476  //
477  // 0.) Read an input OCDB entry
478  //
479  TFile * f = TFile::Open("$ALICE_OCDB/alice/data/2010/OCDB/TPC/Calib/Correction/Run0_999999999_v8_s0.root");
480  AliCDBEntry * entry=(AliCDBEntry*)f->Get("AliCDBEntry");
481  TObjArray * corrArray = (TObjArray *)entry->GetObject();
482  AliTPCComposedCorrection *compInput = (AliTPCComposedCorrection *)corrArray->At(0);
484  Int_t ncorrs = compInput->GetCorrections()->GetEntries();
485  TObjArray arrayInputFast(ncorrs);
486  //
487  // 1.) Test each individual correction
488  //
489  for (Int_t icorr=0; icorr<ncorrs; icorr++){
490  TString clName=compInput->GetSubCorrection(icorr)->IsA()->GetName();
491  if (fast){ // skip slow correction
492  if ( clName.Contains("AliTPCFCVoltError3D"))continue;
493  if ( clName.Contains("AliTPCROCVoltError3D"))continue;
494  }
495  // if ( clName.Contains("AliTPCExBBShape"))continue;
496  AliTPCCorrection *corrInput=compInput->GetSubCorrection(icorr);
497  //
498  ::Info("TestCorrection_AliTPCComposedCorrectionAddCorrectionCompact_TPCCalibCorrection",TString::Format("%s\t%s",corrInput->IsA()->GetName(),corrInput->GetName()).Data());
501  compTest0->AddCorrectionCompact(corrInput,0.5);
502  compTest0->AddCorrectionCompact(corrInput,0.5);
503  compTest1->AddCorrectionCompact(corrInput,1);
504  compTest1->AddCorrectionCompact(corrInput,-1);
505  corrInput->AddVisualCorrection(corrInput,10);
506  compTest0->AddVisualCorrection(compTest0,11);
507  compTest1->AddVisualCorrection(compTest1,12);
508  compTest0->SetOmegaTauT1T2(0.35,1,1);
509  compTest1->SetOmegaTauT1T2(0.35,1,1);
510  corrInput->SetOmegaTauT1T2(0.35,1,1);
511  for (Int_t icoord=0; icoord<3; icoord++){
512  TVectorD dvecTest0(npointsTest);
513  TVectorD dvecTest1(npointsTest);
514  for (Int_t ipoint=0; ipoint<npointsTest; ipoint++){
515  Double_t r= 85.+gRandom->Rndm()*150;
516  Double_t phi= gRandom->Rndm()*TMath::TwoPi();
517  Double_t z=500*(gRandom->Rndm()-0.5);
518  dvecTest0[ipoint]=AliTPCCorrection::GetCorrXYZ(r*TMath::Cos(phi),r*TMath::Sin(phi),z, icoord, 11)-AliTPCCorrection::GetCorrXYZ(r*TMath::Cos(phi),r*TMath::Sin(phi),z, icoord, 10);
519  dvecTest1[ipoint]=AliTPCCorrection::GetCorrXYZ(r*TMath::Cos(phi),r*TMath::Sin(phi),z, icoord, 12);
520  }
521  Double_t mean0 = TMath::Mean(npointsTest, dvecTest0.GetMatrixArray());
522  Double_t rms0 = TMath::RMS(npointsTest, dvecTest0.GetMatrixArray());
523  Double_t mean1 = TMath::Mean(npointsTest, dvecTest1.GetMatrixArray());
524  Double_t rms1 = TMath::RMS(npointsTest, dvecTest1.GetMatrixArray());
525  if (TMath::Abs(rms0)>kEpsilon){
526  ::Error("TestCorrection_AliTPCComposedCorrectionAddCorrectionCompact_TPCCalibCorrection",TString::Format("Test0:\t%s\t%3.5f\t%3.5f FAILED",clName.Data(),mean0,rms0).Data());
527  }else{
528  ::Info("TestCorrection_AliTPCComposedCorrectionAddCorrectionCompact_TPCCalibCorrection",TString::Format("Test0:\t%s\t%3.5f\t%3.5f OK",clName.Data(),mean0,rms0).Data());
529  }
530  if (TMath::Abs(rms1)>kEpsilon){
531  ::Error("TestCorrection_AliTPCComposedCorrectionAddCorrectionCompact_TPCCalibCorrection",TString::Format("Test1:\t%s\t%3.5f\t%3.5f FAILED",clName.Data(),mean1,rms1).Data());
532  }else{
533  ::Info("TestCorrection_AliTPCComposedCorrectionAddCorrectionCompact_TPCCalibCorrection",TString::Format("Test1:\t%s\t%3.5f\t%3.5f OK",clName.Data(),mean1,rms1).Data());
534  }
535  }
536  }
537 }
538 
539 
546 
547  const Int_t npointsTest=10000;
548  const Float_t kEpsilon=0.0001; // using Floating point precission
549  //
550  // 0.) Read an input OCDB entry
551  //
552  TFile * f = TFile::Open("$ALICE_OCDB/alice/data/2010/OCDB/TPC/Calib/Correction/Run0_999999999_v8_s0.root");
553  AliCDBEntry * entry=(AliCDBEntry*)f->Get("AliCDBEntry");
554  TObjArray * corrArray = (TObjArray *)entry->GetObject();
555  AliTPCComposedCorrection *compInput = (AliTPCComposedCorrection *)corrArray->At(0);
557  Int_t ncorrs = compInput->GetCorrections()->GetEntries();
558  TObjArray arrayInputFast(ncorrs);
559  for (Int_t icorr=0; icorr<ncorrs; icorr++){
560  TString clName=compInput->GetSubCorrection(icorr)->IsA()->GetName();
561  if ( clName.Contains("AliTPCFCVoltError3D"))continue;
562  if ( clName.Contains("AliTPCROCVoltError3D"))continue;
563  if ( clName.Contains("AliTPCExBBShape"))continue;
564  arrayInputFast.AddLast(compInput->GetSubCorrection(icorr));
565  }
566  compInputFast->SetCorrections(&arrayInputFast);
567 
568 
569 
570  //
571  // 1.) Make linear combination correction example using weights.
572  // Test correction checking invariant inverse x orig (there are simpler way to do inversion using AliTPCInverseCorrection)
574  Bool_t isOK1[10]={kTRUE};
575  TObjArray * collection= dynamic_cast<TObjArray*>(compInput->GetCorrections());
576  Int_t entries = collection->GetEntries();
577  TVectorD weights(entries+1);
578  for (Int_t i=0; i<entries+1; i++) weights[i]=-1.0;
579  weights[0]=1.;
580  TObjArray * arrayInvariant = new TObjArray(entries+1);
581  arrayInvariant->AddLast(compInput);
582  for (Int_t i=0; i<entries; i++) arrayInvariant->AddLast( collection->At(i));
583  compInverse->SetCorrections( arrayInvariant);
584  compInverse->SetWeights(&weights);
585  compInverse->AddVisualCorrection(compInverse,1);
586  compInput->AddVisualCorrection(compInput,2);
587  TF1 finv1("finv1","AliTPCCorrection::GetCorrXYZ(x,x,100,0,1)",85,245);
588  //
589  TVectorD vecCompInverse(npointsTest);
590  for (Int_t icoord=0; icoord<3; icoord++){
591  for (Int_t ipoint=0; ipoint<npointsTest; ipoint++){
592  Double_t r= 85.+gRandom->Rndm()*150;
593  Double_t phi= gRandom->Rndm()*TMath::TwoPi();
594  Double_t z=500*(gRandom->Rndm()-0.5);
595  vecCompInverse[ipoint]=AliTPCCorrection::GetCorrXYZ(r*TMath::Cos(phi),r*TMath::Sin(phi),z, icoord, 1);
596  }
597  Double_t rms=TMath::RMS(npointsTest,vecCompInverse.GetMatrixArray());
598  Double_t mean=TMath::Mean(npointsTest,vecCompInverse.GetMatrixArray());
599  isOK1[icoord]=TMath::Abs(rms)<kEpsilon;
600  isOK1[icoord]&=TMath::Abs(mean)<kEpsilon;
601  }
602  if (isOK1[0]==kFALSE || isOK1[1]==kFALSE ||isOK1[2]==kFALSE ){
603  ::Error("TestCorrection_AddCorrectionCompact",TString::Format("AliTPCComposedCorrection - Test1 (%d,%d,%d) FAILED",isOK1[0], isOK1[1],isOK1[2]).Data());
604  }else{
605  ::Info("TestCorrection_AddCorrectionCompact","AliTPCComposedCorrection - Test1 OK");
606  }
607  //
608  // 2.) Make compact for of the Composed correction. Test correction checking invariant inverse x orig
609  // This take time - dostortion has to be recalculated
610  AliTPCComposedCorrection *compOutInverseCompact = new AliTPCComposedCorrection();
611  compOutInverseCompact->AddCorrectionCompact(compInputFast,1);
612  compOutInverseCompact->AddCorrectionCompact(compInputFast,-1);
613  compOutInverseCompact->SetOmegaTauT1T2(0,1,1);
614  compInputFast->SetOmegaTauT1T2(0,1,1);
615  compOutInverseCompact->AddVisualCorrection(compOutInverseCompact,10);
616  compInputFast->AddVisualCorrection(compInput,3);
617  TStopwatch timer;
618  //
619  TF1 fcomp("fcomp","AliTPCCorrection::GetCorrXYZ(x,x,100,0,10)",85,245);
620  TF1 forig("forig","-AliTPCCorrection::GetCorrXYZ(x,x,100,0,3)",85,245);
621  TF1 fdiff("fdiff","AliTPCCorrection::GetCorrXYZ(x,x,100,0,10)+AliTPCCorrection::GetCorrXYZ(x,x,100,0,2)",85,245);
622  timer.Print();
623 
624 
625  return kTRUE;
626 }
virtual Bool_t AddCorrectionCompact(AliTPCCorrection *corr, Double_t weight)
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
const Double_t kEpsilon
TFile * Open(const char *filename, Long64_t &nevents)
Bool_t TestCorrection_AliTPCCalibGlobalMisalignmentAddCorrectionCompact()
Definition: UnitTest.C:371
void UnitTestAliTPCCalPadTree()
Definition: UnitTest.C:51
void SetCopperRodShiftA(Int_t rod, Float_t voltOffset, Bool_t doInit=kTRUE)
Float_t GetCopperRodShiftA(Int_t i) const
#define TObjArray
AliTPCFCVoltError3D class.
Bool_t TestCorrection_AliTPCComposedCorrectionAddCorrectionCompact()
Definition: UnitTest.C:540
Float_t GetXTwist() const
TStopwatch timer
Definition: kNNSpeed.C:15
TMatrixD * GetMatrix() const
virtual void SetOmegaTauT1T2(Float_t omegaTau, Float_t t1, Float_t t2)
Bool_t TestCorrection_AliTPCExBTwistAddCorrectionCompact()
Definition: UnitTest.C:115
void SetOmegaTauT1T2(Float_t omegaTau, Float_t t1, Float_t t2)
Float_t GetRodVoltShiftC(Int_t i) const
static Double_t GetCorrXYZ(Double_t gx, Double_t gy, Double_t gz, Int_t axisType, Int_t corrType=0)
TTree * tree
The class calculates the space point distortions due to z offsets of the.
AliTPCExBTwist class.
static AliTPCCalPad * MakePadFromTree(TTree *tree, const char *query, const char *name=0, Bool_t doFast=kFALSE)
void SetRodVoltShiftC(Int_t rod, Float_t voltOffset, Bool_t doInit=kTRUE)
AliTPCCorrection class.
void SetAlignSectors(const TObjArray *arraySector)
void SetCopperRodShiftC(Int_t rod, Float_t voltOffset, Bool_t doInit=kTRUE)
TObject * GetObject()
Definition: AliCDBEntry.h:56
void SetYTwist(Float_t yTwist)
void SetBoundariesA(Float_t boundariesA[8])
AliTPCComposedCorrection class.
AliTPCExBTwist * twistX
Float_t GetYTwist() const
Bool_t MedianFilter(Int_t deltaRow, Int_t deltaPad, AliTPCCalPad *outlierPad=0, Bool_t doEdge=kTRUE)
void SetXTwist(Float_t xTwist)
void SetCorrections(const TCollection *corrections)
Bool_t TestCorrection_AliTPCBoundaryVoltErrorAddCorrectionCompact()
Definition: UnitTest.C:305
AliTPCExBTwist * twistY
TFile * fout
Definition: PlotSys.C:39
Float_t GetBoundariesC(Int_t i) const
TString baseDir
Definition: UnitTest.C:38
void SetROCData(TMatrixD *matrix)
static void MakeTree(const char *fileName, TObjArray *array, const char *mapFileName=0, AliTPCCalPad *const outlierPad=0, Float_t ltmFraction=0.9)
Definition: AliCDBEntry.h:18
void SetAlignGlobalDelta(const TGeoMatrix *matrixGlobalDelta)
TF1 * f
Definition: interpolTest.C:21
static void AddVisualCorrection(AliTPCCorrection *corr, Int_t position)
TCollection * GetCorrections() const
virtual AliTPCCorrection * GetSubCorrection(Int_t ipos)
Bool_t TestCorrection_AliTPCFCVoltError3DAddCorrectionCompact()
Definition: UnitTest.C:171
Bool_t TestCorrection_AliTPCCorrection_AddCorrectionCompact()
Definition: UnitTest.C:460
void SetAlignGlobal(const TGeoMatrix *matrixGlobal)
void SetRodVoltShiftA(Int_t rod, Float_t voltOffset, Bool_t doInit=kTRUE)
static TTree * ConnectGainTrees(TString baseDir)
Bool_t LTMFilter(Int_t deltaRow, Int_t deltaPad, Float_t fraction, Int_t type, AliTPCCalPad *outlierPad=0, Bool_t doEdge=kTRUE)
void SetWeights(TVectorD *weights)
Bool_t TestCorrection_AliTPCRocVoltError3DAddCorrectionCompact()
Definition: UnitTest.C:239
Float_t GetBoundariesA(Int_t i) const
class TVectorT< Double_t > TVectorD
void res(Char_t i)
Definition: Resolution.C:2
Float_t GetRodVoltShiftA(Int_t i) const
Bool_t TestCorrection_AliTPCComposedCorrectionAddCorrectionCompact_TPCCalibCorrection(Bool_t fast=kFALSE)
Definition: UnitTest.C:470
class TMatrixT< Double_t > TMatrixD
Float_t GetCopperRodShiftC(Int_t i) const