2 Unit test for some functions classes used in the $ALICE_ROOT/TPC/Base directory:
4 gSystem->SetIncludePath("-I$ROOTSYS/include -I$ALICE_ROOT/ -I$ALICE_ROOT/include -I$ALICE_ROOT/STEER -I$ALICE_ROOT/ITS -I$ALICE_ROOT/TRD -I$ALICE_ROOT/TOF -I$ALICE_ROOT/RAW -I$ALICE_ROOT/STAT -I$ALICE_ROOT/TPC/TPCbase -I$ALICE_ROOT/TPCcalib");
7 .L $ALICE_ROOT/TPC/Base/test/UnitTest.C+
8 G UnitTestAliTPCCalPadTree();
9 TestCorrection_AliTPCCorrection_AddCorrectionCompact();
15 #include "TLinearFitter.h"
17 #include "AliSysInfo.h"
22 #include "AliTPCCalPad.h"
23 #include "AliTPCCalibViewer.h"
24 #include "AliTPCcalibDButil.h"
25 #include "AliTPCCorrection.h"
26 #include "AliTPCComposedCorrection.h"
27 #include "AliTPCExBTwist.h"
28 #include "AliTPCFCVoltError3D.h"
29 #include "AliTPCROCVoltError3D.h"
30 #include "AliTPCBoundaryVoltError.h"
31 #include "AliTPCCalibGlobalMisalignment.h"
32 #include "AliCDBEntry.h"
33 #include "TStopwatch.h"
34 #include "TGeoMatrix.h"
37 // PARAMETERS to set from outside:
39 TString baseDir="/hera/alice/wiechula/calib/guiTrees"; // TO FIX specification of inout data
43 Bool_t TestCorrection_AliTPCCorrection_AddCorrectionCompact();
44 Bool_t TestCorrection_AliTPCExBTwistAddCorrectionCompact();
45 Bool_t TestCorrection_AliTPCFCVoltError3DAddCorrectionCompact();
46 Bool_t TestCorrection_AliTPCRocVoltError3DAddCorrectionCompact();
47 Bool_t TestCorrection_AliTPCBoundaryVoltErrorAddCorrectionCompact();
48 Bool_t TestCorrection_AliTPCCalibGlobalMisalignmentAddCorrectionCompact();
49 Bool_t TestCorrection_AliTPCComposedCorrectionAddCorrectionCompact();
52 void UnitTestAliTPCCalPadTree(){
54 // Make a UnitTest of the AliTPCCalPad
55 // a.) TTree functionaility
56 // b.) MedianFilterFunctionality
57 // c.) LTMFilterFunctionality
59 TObjArray *fArray = new TObjArray(100);
60 TTree * treePad=AliTPCcalibDButil::ConnectGainTrees(baseDir);
61 for (Int_t i=0; i<5; i+=2){
62 AliTPCCalPad * padLx = AliTPCCalPad::MakePadFromTree(treePad,"lx.fElements","Lx",kTRUE);
63 AliTPCCalPad * padLy = AliTPCCalPad::MakePadFromTree(treePad,"ly.fElements","Ly",kTRUE);
64 AliTPCCalPad * padLLx = AliTPCCalPad::MakePadFromTree(treePad,"lx.fElements","LLx",kTRUE);
65 AliTPCCalPad * padLLy = AliTPCCalPad::MakePadFromTree(treePad,"ly.fElements","LLy",kTRUE);
66 AliTPCCalPad * padMax = AliTPCCalPad::MakePadFromTree(treePad,"QA.2010.LHC10d.MaxCharge.fElements","QMax",kTRUE);
67 AliTPCCalPad * padMean = AliTPCCalPad::MakePadFromTree(treePad,"QA.2010.LHC10d.MeanCharge.fElements","QTot",kTRUE);
68 AliTPCCalPad * padMaxL = AliTPCCalPad::MakePadFromTree(treePad,"QA.2010.LHC10d.MaxCharge.fElements","QMax",kTRUE);
69 AliTPCCalPad * padMeanL = AliTPCCalPad::MakePadFromTree(treePad,"QA.2010.LHC10d.MeanCharge.fElements","QTot",kTRUE);
71 padLx->MedianFilter(i,2*i);
72 padLy->MedianFilter(i,2*i);
73 padLLx->LTMFilter(i,2*i,1.00, 0);
74 padLLy->LTMFilter(i,2*i,1.00, 0);
75 padMax->MedianFilter(i,2*i);
76 padMean->MedianFilter(i,2*i);
77 padMaxL->LTMFilter(i,2*i,0.8,0);
78 padMeanL->LTMFilter(i,2*i,0.8,0);
80 padLx->SetName(TString::Format("Lx%d",i).Data());
81 padLy->SetName(TString::Format("Ly%d",i).Data());
82 padLLx->SetName(TString::Format("LLx%d",i).Data());
83 padLLy->SetName(TString::Format("LLy%d",i).Data());
84 padMax->SetName(TString::Format("QMax%d",i).Data());
85 padMean->SetName(TString::Format("QTot%d",i).Data());
86 padMaxL->SetName(TString::Format("QMaxL%d",i).Data());
87 padMeanL->SetName(TString::Format("QTotL%d",i).Data());
88 fArray->AddLast(padLx);
89 fArray->AddLast(padLy);
90 fArray->AddLast(padLLx);
91 fArray->AddLast(padLLy);
92 fArray->AddLast(padMax);
93 fArray->AddLast(padMean);
94 fArray->AddLast(padMaxL);
95 fArray->AddLast(padMeanL);
97 AliTPCCalibViewer::MakeTree("QAtest.root", fArray,0);
99 // 2.) Check invariants
101 TFile*fout= TFile::Open("QAtest.root");
102 TTree * tree = (TTree*)fout->Get("calPads");
103 Int_t isOutM0 = tree->Draw("(Ly2.fElements-Ly0.fElements)>>his0(100,-10,10)","abs((Ly2.fElements-Ly0.fElements))>2","goff");
104 Int_t isOutM1=tree->Draw("(Lx2.fElements-Lx0.fElements)/0.75>>his1(100,-10,10)","abs((Lx2.fElements-Lx0.fElements))>0","goff");
105 printf("IsOut=%d\t%d\n",isOutM0,isOutM1);
106 if ((isOutM0+isOutM1)==0) ::Info("UnitTestAliTPCCalPadTree","MedianTest OK");
107 if (isOutM0||isOutM1) ::Fatal("UnitTestAliTPCCalPadTree","MedianTest FAILED");
109 Int_t isOutL0 = tree->Draw("(LLy2.fElements-Ly0.fElements)>>his0(100,-10,10)","abs((LLy2.fElements-LLy0.fElements))>0","goff");
110 Int_t isOutL1=tree->Draw("(LLx2.fElements-Lx0.fElements)/0.75>>his1(100,-10,10)","abs((LLx2.fElements-LLx0.fElements))>0","goff");
111 printf("IsOut=%d\t%d\n",isOutL0,isOutL1);
112 if ((isOutL0+isOutL1)==0) ::Info("UnitTestAliTPCCalPadTree","LTMTest OK");
113 if (isOutL0||isOutL1) ::Fatal("UnitTestAliTPCCalPadTree","LTMTest FAILED");
117 Bool_t TestCorrection_AliTPCExBTwistAddCorrectionCompact(){
120 // 1.) Test ExB twist AddCorrectionCompact
122 Bool_t isOK[10]={kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE};
123 AliTPCComposedCorrection *compCorrTwist = new AliTPCComposedCorrection();
124 AliTPCExBTwist *twistX = new AliTPCExBTwist;
125 AliTPCExBTwist *twistY = new AliTPCExBTwist;
126 twistX->SetXTwist(0.001); // 1 mrad twist in x
127 twistY->SetYTwist(0.001); // 1 mrad twist in x
128 isOK[0]&=compCorrTwist->AddCorrectionCompact(twistX,0.5);
129 isOK[0]&=compCorrTwist->AddCorrectionCompact(twistY,0.5);
130 isOK[0]&=compCorrTwist->AddCorrectionCompact(twistX,0.5);
131 isOK[0]&=compCorrTwist->AddCorrectionCompact(twistY,0.5);
132 isOK[0]&=compCorrTwist->AddCorrectionCompact(twistY,-1);
133 isOK[0]&=compCorrTwist->AddCorrectionCompact(twistX,-1);
134 isOK[1]=compCorrTwist->GetCorrections()->GetEntries()==1;
136 AliTPCExBTwist *twistRes=0;
137 if (isOK[1]==kFALSE){
142 twistRes= dynamic_cast<AliTPCExBTwist *>(compCorrTwist->GetSubCorrection(0));
148 isOK[3] &= (twistRes->GetXTwist()==0);
149 isOK[4] &= (twistRes->GetYTwist()==0);
153 for (Int_t i=0; i<5; i++) res&=isOK[i];
155 if (isOK[0]==kFALSE){
156 ::Error("TestCorrection_AddCorrectionCompact","AliTPCExBTwist -ADD FAILED");
158 ::Info("TestCorrection_AddCorrectionCompact","AliTPCExBTwist -ADD OK");
160 if (isOK[1]==kFALSE){
161 ::Error("TestCorrection_AddCorrectionCompact","AliTPCExBTwist - wrong entries FAILED");
163 ::Info("TestCorrection_AddCorrectionCompact","AliTPCExBTwist - entries OK");
165 if (isOK[2]==kFALSE || isOK[3]==kFALSE ||isOK[4]==kFALSE ){
166 ::Error("TestCorrection_AddCorrectionCompact","AliTPCExBTwist - inconsitent entries FAILED");
168 ::Info("TestCorrection_AddCorrectionCompact","AliTPCExBTwist - consistent entries OK");
175 Bool_t TestCorrection_AliTPCFCVoltError3DAddCorrectionCompact(){
177 // TestCorrection_AliTPCFCVoltError3DAddCorrectionCompact
179 const Float_t kEpsilon=0.000001;
180 Bool_t isOK[10]={kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE};
181 AliTPCComposedCorrection *compCorrComp = new AliTPCComposedCorrection();
182 AliTPCFCVoltError3D *corr0 = new AliTPCFCVoltError3D;
183 AliTPCFCVoltError3D *corr1 = new AliTPCFCVoltError3D;
184 for (Int_t isec=0; isec<36; isec++){
185 corr0->SetRodVoltShiftA(isec,TMath::Cos(TMath::Pi()*isec/36),kFALSE);
186 corr0->SetRodVoltShiftC(isec,TMath::Cos(TMath::Pi()*isec/36),kFALSE);
187 corr1->SetRodVoltShiftA(isec,TMath::Sin(TMath::Pi()*isec/36),kFALSE);
188 corr1->SetRodVoltShiftC(isec,TMath::Sin(TMath::Pi()*isec/36),kFALSE);
189 corr1->SetCopperRodShiftA(isec,TMath::Sin(TMath::Pi()*isec/36),kFALSE);
190 corr1->SetCopperRodShiftC(isec,TMath::Sin(TMath::Pi()*isec/36),kFALSE);
193 isOK[0]&=compCorrComp->AddCorrectionCompact(corr0,0.5);
194 isOK[0]&=compCorrComp->AddCorrectionCompact(corr1,0.5);
195 isOK[0]&=compCorrComp->AddCorrectionCompact(corr0,0.5);
196 isOK[0]&=compCorrComp->AddCorrectionCompact(corr1,0.5);
197 isOK[0]&=compCorrComp->AddCorrectionCompact(corr1,-1);
198 isOK[0]&=compCorrComp->AddCorrectionCompact(corr0,-1);
199 isOK[1]=compCorrComp->GetCorrections()->GetEntries()==1;
200 AliTPCFCVoltError3D *corrRes=0;
201 if (isOK[1]==kFALSE){
206 corrRes= dynamic_cast<AliTPCFCVoltError3D *>(compCorrComp->GetSubCorrection(0));
212 for (Int_t isec=0; isec<36; isec++){
213 isOK[3] &=( TMath::Abs(corrRes->GetRodVoltShiftA(isec))<kEpsilon);
214 isOK[4] &=( TMath::Abs(corrRes->GetRodVoltShiftC(isec))<kEpsilon);
215 isOK[5] &=( TMath::Abs(corrRes->GetCopperRodShiftA(isec))<kEpsilon);
216 isOK[6] &=( TMath::Abs(corrRes->GetCopperRodShiftC(isec))<kEpsilon);
221 for (Int_t i=0; i<5; i++) res&=isOK[i];
223 if (isOK[0]==kFALSE){
224 ::Error("TestCorrection_AddCorrectionCompact","AliTPCFCVoltError3D -ADD FAILED");
226 ::Info("TestCorrection_AddCorrectionCompact","AliTPCFCVoltError3D -ADD OK");
228 if (isOK[1]==kFALSE){
229 ::Error("TestCorrection_AddCorrectionCompact","AliTPCFCVoltError3D - wrong entries FAILED");
231 ::Info("TestCorrection_AddCorrectionCompact","AliTPCFCVoltError3D - entries OK");
233 if (isOK[2]==kFALSE || isOK[3]==kFALSE ||isOK[4]==kFALSE ){
234 ::Error("TestCorrection_AddCorrectionCompact","AliTPCFCVoltError3D - inconsitent entries FAILED");
236 ::Info("TestCorrection_AddCorrectionCompact","AliTPCFCVoltError3D - consistent entries OK");
244 Bool_t TestCorrection_AliTPCRocVoltError3DAddCorrectionCompact(){
246 // AliTPCRocVoltError3DAddCorrectionCompact
248 const Float_t kEpsilon=0.00000001;
249 Bool_t isOK[10]={kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE};
250 AliTPCComposedCorrection *compCorrROCVoltError3D = new AliTPCComposedCorrection();
251 AliTPCROCVoltError3D *corr0 = new AliTPCROCVoltError3D;
252 AliTPCROCVoltError3D *corr1 = new AliTPCROCVoltError3D;
253 TMatrixD matrixDz(72,3);
254 for (Int_t isec=0; isec<72; isec++){
255 matrixDz(isec,0)=gRandom->Rndm()*0.1;
256 matrixDz(isec,1)=gRandom->Rndm()*0.001;
257 matrixDz(isec,2)=gRandom->Rndm()*0.001;
259 corr0->SetROCData(&matrixDz);
261 corr1->SetROCData(&matrixDz);
263 isOK[0]&=compCorrROCVoltError3D->AddCorrectionCompact(corr0,0.5);
264 isOK[0]&=compCorrROCVoltError3D->AddCorrectionCompact(corr1,0.5);
265 isOK[0]&=compCorrROCVoltError3D->AddCorrectionCompact(corr0,0.5);
266 isOK[0]&=compCorrROCVoltError3D->AddCorrectionCompact(corr1,0.5);
267 isOK[0]&=compCorrROCVoltError3D->AddCorrectionCompact(corr1,-1);
268 isOK[0]&=compCorrROCVoltError3D->AddCorrectionCompact(corr0,-1);
269 isOK[1]=compCorrROCVoltError3D->GetCorrections()->GetEntries()==1;
270 AliTPCROCVoltError3D *corrRes=0;
271 if (isOK[1]==kFALSE){
276 corrRes= dynamic_cast<AliTPCROCVoltError3D *>(compCorrROCVoltError3D->GetSubCorrection(0));
282 isOK[3]=TMath::Abs(corrRes->GetMatrix()->Sum())<kEpsilon;
286 for (Int_t i=0; i<5; i++) res&=isOK[i];
288 if (isOK[0]==kFALSE){
289 ::Error("TestCorrection_AddCorrectionCompact","AliTPCROCVoltError3D -ADD FAILED");
291 ::Info("TestCorrection_AddCorrectionCompact","AliTPCROCVoltError3D -ADD OK");
293 if (isOK[1]==kFALSE){
294 ::Error("TestCorrection_AddCorrectionCompact","AliTPCROCVoltError3D - wrong entries FAILED");
296 ::Info("TestCorrection_AddCorrectionCompact","AliTPCROCVoltError3D - entries OK");
298 if (isOK[2]==kFALSE || isOK[3]==kFALSE ||isOK[4]==kFALSE ){
299 ::Error("TestCorrection_AddCorrectionCompact","AliTPCROCVoltError3D - inconsitent entries FAILED");
301 ::Info("TestCorrection_AddCorrectionCompact","AliTPCROCVoltError3D - consistent entries OK");
311 Bool_t TestCorrection_AliTPCBoundaryVoltErrorAddCorrectionCompact(){
313 // AliTPCBoundaryVoltErrorAddCorrectionCompact
315 const Float_t kEpsilon=0.00000001;
316 Bool_t isOK[10]={kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE};
317 AliTPCComposedCorrection *compCorrBoundaryVoltError = new AliTPCComposedCorrection();
318 AliTPCBoundaryVoltError *corr0 = new AliTPCBoundaryVoltError;
319 AliTPCBoundaryVoltError *corr1 = new AliTPCBoundaryVoltError;
320 Float_t boundaries[8];
321 for (Int_t ibound=0; ibound<8; ibound++){
322 boundaries[ibound]=gRandom->Rndm()-0.5;
324 corr0->SetBoundariesA(boundaries);
325 corr1->SetBoundariesA(boundaries);
327 isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr0,0.5);
328 isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr1,0.5);
329 isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr0,0.5);
330 isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr1,0.5);
331 isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr1,-1);
332 isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr0,-1);
333 isOK[1]=compCorrBoundaryVoltError->GetCorrections()->GetEntries()==1;
334 AliTPCBoundaryVoltError *corrRes=0;
335 if (isOK[1]==kFALSE){
340 corrRes= dynamic_cast<AliTPCBoundaryVoltError *>(compCorrBoundaryVoltError->GetSubCorrection(0));
346 for (Int_t ibound=0; ibound<8; ibound++){
347 isOK[3]&=TMath::Abs(corrRes->GetBoundariesA(ibound))<kEpsilon;
348 isOK[3]&=TMath::Abs(corrRes->GetBoundariesC(ibound))<kEpsilon;
353 for (Int_t i=0; i<5; i++) res&=isOK[i];
355 if (isOK[0]==kFALSE){
356 ::Error("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError -ADD FAILED");
358 ::Info("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError -ADD OK");
360 if (isOK[1]==kFALSE){
361 ::Error("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError - wrong entries FAILED");
363 ::Info("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError - entries OK");
365 if (isOK[2]==kFALSE || isOK[3]==kFALSE ||isOK[4]==kFALSE ){
366 ::Error("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError - inconsitent entries FAILED");
368 ::Info("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError - consistent entries OK");
378 Bool_t TestCorrection_AliTPCCalibGlobalMisalignmentAddCorrectionCompact(){
380 // AliTPCCalibGlobalMisalignmentAddCorrectionCompact
381 // Invariant used in test is not exact it is only approximate - as matrix multiplication is not comulative
382 // !!!! BUG FOUND ????
383 // hmatrix1->GetTranslation()[idelta]=xxx; // does not work as expected Translation is set, visible in Print but not used later
384 const Float_t kEpsilon=0.0001;
385 Bool_t isOK[10]={kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE};
386 Double_t delta[3]={0.01,0.02,0.03};
388 AliTPCComposedCorrection *compCorrBoundaryVoltError = new AliTPCComposedCorrection();
389 AliTPCCalibGlobalMisalignment *corr0 = new AliTPCCalibGlobalMisalignment;
390 AliTPCCalibGlobalMisalignment *corr1 = new AliTPCCalibGlobalMisalignment;
391 AliTPCCalibGlobalMisalignment *corr2 = new AliTPCCalibGlobalMisalignment;
392 TObjArray sectorAlign(72);
394 TGeoHMatrix *hmatrix0 = new TGeoHMatrix;
395 TGeoHMatrix *hmatrix1 = new TGeoHMatrix;
396 hmatrix0->RotateX(TMath::RadToDeg()*0.0001);
397 hmatrix0->RotateY(TMath::RadToDeg()*0.0002);
398 hmatrix0->RotateZ(TMath::RadToDeg()*0.0003);
399 hmatrix1->SetTranslation(delta);
400 for (Int_t isec=0; isec<72; isec++){
401 if ((isec%2)==0) sectorAlign.AddAt(hmatrix0,isec);
402 if ((isec%2)==1) sectorAlign.AddAt(hmatrix1,isec);
404 corr0->SetAlignGlobal(hmatrix0);
405 corr1->SetAlignGlobal(hmatrix1);
406 corr0->SetAlignGlobalDelta(hmatrix1);
407 corr1->SetAlignGlobalDelta(hmatrix0);
408 corr2->SetAlignSectors(§orAlign);
410 isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr0,0.5);
411 isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr1,0.5);
412 isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr0,0.5);
413 isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr1,0.5);
414 isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr0,-1);
415 isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr1,-1);
417 isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr2,1);
418 isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr2,-1);
421 isOK[1]=compCorrBoundaryVoltError->GetCorrections()->GetEntries()==1;
422 AliTPCCalibGlobalMisalignment *corrRes=0;
423 if (isOK[1]==kFALSE){
428 corrRes= dynamic_cast<AliTPCCalibGlobalMisalignment *>(compCorrBoundaryVoltError->GetSubCorrection(0));
434 for (Int_t itrans=0; itrans<3; itrans++){
435 isOK[2+itrans]&=TMath::Abs(corrRes->GetAlignGlobal()->GetTranslation()[itrans])<kEpsilon;
436 for (Int_t isec=0; isec<72; isec++){
437 isOK[2+itrans]&=TMath::Abs(((TGeoHMatrix*)(corrRes->GetAlignSectors()->At(isec)))->GetTranslation()[itrans])<kEpsilon;
440 corrRes->GetAlignGlobal()->Print();
441 corrRes->GetAlignSectors()->At(0)->Print();
442 corrRes->GetAlignSectors()->At(1)->Print();
446 for (Int_t i=0; i<5; i++) res&=isOK[i];
448 if (isOK[0]==kFALSE){
449 ::Error("TestCorrection_AddCorrectionCompact","AliTPCCalibGlobalMisalignment -ADD FAILED");
451 ::Info("TestCorrection_AddCorrectionCompact","AliTPCCalibGlobalMisalignment -ADD OK");
453 if (isOK[1]==kFALSE){
454 ::Error("TestCorrection_AddCorrectionCompact","AliTPCCalibGlobalMisalignment - wrong entries FAILED");
456 ::Info("TestCorrection_AddCorrectionCompact","AliTPCCalibGlobalMisalignment - entries OK");
458 if (isOK[2]==kFALSE || isOK[3]==kFALSE ||isOK[4]==kFALSE ){
459 ::Error("TestCorrection_AddCorrectionCompact","AliTPCCalibGlobalMisalignment - inconsitent entries FAILED");
461 ::Info("TestCorrection_AddCorrectionCompact","AliTPCCalibGlobalMisalignment - consistent entries OK");
467 Bool_t TestCorrection_AliTPCCorrection_AddCorrectionCompact(){
471 TestCorrection_AliTPCExBTwistAddCorrectionCompact();
472 TestCorrection_AliTPCFCVoltError3DAddCorrectionCompact();
473 TestCorrection_AliTPCRocVoltError3DAddCorrectionCompact();
474 TestCorrection_AliTPCBoundaryVoltErrorAddCorrectionCompact();
475 TestCorrection_AliTPCCalibGlobalMisalignmentAddCorrectionCompact();
479 Bool_t TestCorrection_AliTPCComposedCorrectionAddCorrectionCompact(){
481 // Tests of AliTPCComposedCorrection
482 // 1.) Make linear combination correction example using weights.
483 // Test correction checking invariant inverse x orig (there are simpler way to do inversion using AliTPCInverseCorrection)
485 // 2.) Make compact for of the Composed correction. Test correction checking invariant inverse x orig
487 const Int_t npointsTest=10000;
488 const Float_t kEpsilon=0.0001; // using Floating point precission
491 // 0.) Read an input OCDB entry
493 TFile * f = TFile::Open("$ALICE_OCDB/alice/data/2010/OCDB/TPC/Calib/Correction/Run0_999999999_v8_s0.root");
494 AliCDBEntry * entry=(AliCDBEntry*)f->Get("AliCDBEntry");
495 TObjArray * corrArray = (TObjArray *)entry->GetObject();
496 AliTPCComposedCorrection *compInput = (AliTPCComposedCorrection *)corrArray->At(0);
498 // 1.) Make linear combination correction example using weights.
499 // Test correction checking invariant inverse x orig (there are simpler way to do inversion using AliTPCInverseCorrection)
500 AliTPCComposedCorrection *compInverse = new AliTPCComposedCorrection();
501 Bool_t isOK1[10]={kTRUE};
502 TObjArray * collection= dynamic_cast<TObjArray*>(compInput->GetCorrections());
503 Int_t entries = collection->GetEntries();
504 TVectorD weights(entries+1);
505 for (Int_t i=0; i<entries+1; i++) weights[i]=-1.0;
507 TObjArray * arrayInvariant = new TObjArray(entries+1);
508 arrayInvariant->AddLast(compInput);
509 for (Int_t i=0; i<entries; i++) arrayInvariant->AddLast( collection->At(i));
510 compInverse->SetCorrections( arrayInvariant);
511 compInverse->SetWeights(&weights);
512 compInverse->AddVisualCorrection(compInverse,1);
513 compInput->AddVisualCorrection(compInput,2);
514 TF1 finv1("finv1","AliTPCCorrection::GetCorrXYZ(x,x,100,0,1)",85,245);
516 TVectorD vecCompInverse(npointsTest);
517 for (Int_t icoord=0; icoord<3; icoord++){
518 for (Int_t ipoint=0; ipoint<npointsTest; ipoint++){
519 Double_t r= 85.+gRandom->Rndm()*150;
520 Double_t phi= gRandom->Rndm()*TMath::TwoPi();
521 Double_t z=500*(gRandom->Rndm()-0.5);
522 vecCompInverse[ipoint]=AliTPCCorrection::GetCorrXYZ(r*TMath::Cos(phi),r*TMath::Sin(phi),z, icoord, 1);
524 Double_t rms=TMath::RMS(npointsTest,vecCompInverse.GetMatrixArray());
525 Double_t mean=TMath::Mean(npointsTest,vecCompInverse.GetMatrixArray());
526 isOK1[icoord]=TMath::Abs(rms)<kEpsilon;
527 isOK1[icoord]&=TMath::Abs(mean)<kEpsilon;
529 if (isOK1[0]==kFALSE || isOK1[1]==kFALSE ||isOK1[2]==kFALSE ){
530 ::Error("TestCorrection_AddCorrectionCompact",TString::Format("AliTPCComposedCorrection - Test1 (%d,%d,%d) FAILED",isOK1[0], isOK1[1],isOK1[2]).Data());
532 ::Info("TestCorrection_AddCorrectionCompact","AliTPCComposedCorrection - Test1 OK");
535 // 2.) Make compact for of the Composed correction. Test correction checking invariant inverse x orig
536 // This take time - dostortion has to be recalculated
537 AliTPCComposedCorrection *compOutInverseCompact = new AliTPCComposedCorrection();
538 compOutInverseCompact->AddCorrectionCompact(compInput,-1);
539 compOutInverseCompact->AddCorrectionCompact(compInput, 1);
540 compOutInverseCompact->SetOmegaTauT1T2(0,1,1);
541 compInput->SetOmegaTauT1T2(0,1,1);
542 compOutInverseCompact->AddVisualCorrection(compOutInverseCompact,10);
543 compInput->AddVisualCorrection(compInput,2);
546 TF1 fcomp("fcomp","AliTPCCorrection::GetCorrXYZ(x,x,100,0,10)",85,245);
547 TF1 forig("forig","-AliTPCCorrection::GetCorrXYZ(x,x,100,0,2)",85,245);
548 TF1 fdiff("fdiff","AliTPCCorrection::GetCorrXYZ(x,x,100,0,10)+AliTPCCorrection::GetCorrXYZ(x,x,100,0,2)",85,245);