3 /// Unit test for some functions classes used in the $ALICE_ROOT/TPC/Base directory:
6 /// gSystem->SetIncludePath("-I$ROOTSYS/include -I$ALICE_ROOT/ -I$ALICE_ROOT/install/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");
8 /// .L $ALICE_ROOT/TPC/Base/test/UnitTest.C+
9 /// UnitTestAliTPCCalPadTree();
10 /// 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"
35 #include "TGeoGlobalMagField.h"
37 // PARAMETERS to set from outside:
38 TString baseDir="/hera/alice/wiechula/calib/guiTrees"; // TO FIX specification of inout data
42 Bool_t TestCorrection_AliTPCCorrection_AddCorrectionCompact();
43 Bool_t TestCorrection_AliTPCExBTwistAddCorrectionCompact();
44 Bool_t TestCorrection_AliTPCFCVoltError3DAddCorrectionCompact();
45 Bool_t TestCorrection_AliTPCRocVoltError3DAddCorrectionCompact();
46 Bool_t TestCorrection_AliTPCBoundaryVoltErrorAddCorrectionCompact();
47 Bool_t TestCorrection_AliTPCCalibGlobalMisalignmentAddCorrectionCompact();
48 Bool_t TestCorrection_AliTPCComposedCorrectionAddCorrectionCompact();
49 Bool_t TestCorrection_AliTPCComposedCorrectionAddCorrectionCompact_TPCCalibCorrection(Bool_t fast=kFALSE);
51 void UnitTestAliTPCCalPadTree(){
52 /// Make a UnitTest of the AliTPCCalPad
53 /// a.) TTree functionaility
54 /// b.) MedianFilterFunctionality
55 /// c.) LTMFilterFunctionality
57 TObjArray *fArray = new TObjArray(100);
58 TTree * treePad=AliTPCcalibDButil::ConnectGainTrees(baseDir);
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);
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);
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);
95 AliTPCCalibViewer::MakeTree("QAtest.root", fArray,0);
97 // 2.) Check invariants
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");
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");
115 Bool_t TestCorrection_AliTPCExBTwistAddCorrectionCompact(){
116 /// 1.) Test ExB twist AddCorrectionCompact
118 Bool_t isOK[10]={kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE};
119 AliTPCComposedCorrection *compCorrTwist = new AliTPCComposedCorrection();
120 AliTPCExBTwist *twistX = new AliTPCExBTwist;
121 AliTPCExBTwist *twistY = new AliTPCExBTwist;
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;
132 AliTPCExBTwist *twistRes=0;
133 if (isOK[1]==kFALSE){
138 twistRes= dynamic_cast<AliTPCExBTwist *>(compCorrTwist->GetSubCorrection(0));
144 isOK[3] &= (twistRes->GetXTwist()==0);
145 isOK[4] &= (twistRes->GetYTwist()==0);
149 for (Int_t i=0; i<5; i++) res&=isOK[i];
151 if (isOK[0]==kFALSE){
152 ::Error("TestCorrection_AddCorrectionCompact","AliTPCExBTwist -ADD FAILED");
154 ::Info("TestCorrection_AddCorrectionCompact","AliTPCExBTwist -ADD OK");
156 if (isOK[1]==kFALSE){
157 ::Error("TestCorrection_AddCorrectionCompact","AliTPCExBTwist - wrong entries FAILED");
159 ::Info("TestCorrection_AddCorrectionCompact","AliTPCExBTwist - entries OK");
161 if (isOK[2]==kFALSE || isOK[3]==kFALSE ||isOK[4]==kFALSE ){
162 ::Error("TestCorrection_AddCorrectionCompact","AliTPCExBTwist - inconsitent entries FAILED");
164 ::Info("TestCorrection_AddCorrectionCompact","AliTPCExBTwist - consistent entries OK");
171 Bool_t TestCorrection_AliTPCFCVoltError3DAddCorrectionCompact(){
172 /// TestCorrection_AliTPCFCVoltError3DAddCorrectionCompact
174 const Float_t kEpsilon=0.000001;
175 Bool_t isOK[10]={kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE};
176 AliTPCComposedCorrection *compCorrComp = new AliTPCComposedCorrection();
177 AliTPCFCVoltError3D *corr0 = new AliTPCFCVoltError3D;
178 AliTPCFCVoltError3D *corr1 = new AliTPCFCVoltError3D;
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);
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){
201 corrRes= dynamic_cast<AliTPCFCVoltError3D *>(compCorrComp->GetSubCorrection(0));
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);
216 for (Int_t i=0; i<5; i++) res&=isOK[i];
218 if (isOK[0]==kFALSE){
219 ::Error("TestCorrection_AddCorrectionCompact","AliTPCFCVoltError3D -ADD FAILED");
221 ::Info("TestCorrection_AddCorrectionCompact","AliTPCFCVoltError3D -ADD OK");
223 if (isOK[1]==kFALSE){
224 ::Error("TestCorrection_AddCorrectionCompact","AliTPCFCVoltError3D - wrong entries FAILED");
226 ::Info("TestCorrection_AddCorrectionCompact","AliTPCFCVoltError3D - entries OK");
228 if (isOK[2]==kFALSE || isOK[3]==kFALSE ||isOK[4]==kFALSE ){
229 ::Error("TestCorrection_AddCorrectionCompact","AliTPCFCVoltError3D - inconsitent entries FAILED");
231 ::Info("TestCorrection_AddCorrectionCompact","AliTPCFCVoltError3D - consistent entries OK");
239 Bool_t TestCorrection_AliTPCRocVoltError3DAddCorrectionCompact(){
240 /// AliTPCRocVoltError3DAddCorrectionCompact
242 const Float_t kEpsilon=0.00000001;
243 Bool_t isOK[10]={kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE};
244 AliTPCComposedCorrection *compCorrROCVoltError3D = new AliTPCComposedCorrection();
245 AliTPCROCVoltError3D *corr0 = new AliTPCROCVoltError3D;
246 AliTPCROCVoltError3D *corr1 = new AliTPCROCVoltError3D;
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;
253 corr0->SetROCData(&matrixDz);
255 corr1->SetROCData(&matrixDz);
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){
270 corrRes= dynamic_cast<AliTPCROCVoltError3D *>(compCorrROCVoltError3D->GetSubCorrection(0));
276 isOK[3]=TMath::Abs(corrRes->GetMatrix()->Sum())<kEpsilon;
280 for (Int_t i=0; i<5; i++) res&=isOK[i];
282 if (isOK[0]==kFALSE){
283 ::Error("TestCorrection_AddCorrectionCompact","AliTPCROCVoltError3D -ADD FAILED");
285 ::Info("TestCorrection_AddCorrectionCompact","AliTPCROCVoltError3D -ADD OK");
287 if (isOK[1]==kFALSE){
288 ::Error("TestCorrection_AddCorrectionCompact","AliTPCROCVoltError3D - wrong entries FAILED");
290 ::Info("TestCorrection_AddCorrectionCompact","AliTPCROCVoltError3D - entries OK");
292 if (isOK[2]==kFALSE || isOK[3]==kFALSE ||isOK[4]==kFALSE ){
293 ::Error("TestCorrection_AddCorrectionCompact","AliTPCROCVoltError3D - inconsitent entries FAILED");
295 ::Info("TestCorrection_AddCorrectionCompact","AliTPCROCVoltError3D - consistent entries OK");
305 Bool_t TestCorrection_AliTPCBoundaryVoltErrorAddCorrectionCompact(){
306 /// AliTPCBoundaryVoltErrorAddCorrectionCompact
308 const Float_t kEpsilon=0.00000001;
309 Bool_t isOK[10]={kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE};
310 AliTPCComposedCorrection *compCorrBoundaryVoltError = new AliTPCComposedCorrection();
311 AliTPCBoundaryVoltError *corr0 = new AliTPCBoundaryVoltError;
312 AliTPCBoundaryVoltError *corr1 = new AliTPCBoundaryVoltError;
313 Float_t boundaries[8];
314 for (Int_t ibound=0; ibound<8; ibound++){
315 boundaries[ibound]=gRandom->Rndm()-0.5;
317 corr0->SetBoundariesA(boundaries);
318 corr1->SetBoundariesA(boundaries);
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){
333 corrRes= dynamic_cast<AliTPCBoundaryVoltError *>(compCorrBoundaryVoltError->GetSubCorrection(0));
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;
346 for (Int_t i=0; i<5; i++) res&=isOK[i];
348 if (isOK[0]==kFALSE){
349 ::Error("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError -ADD FAILED");
351 ::Info("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError -ADD OK");
353 if (isOK[1]==kFALSE){
354 ::Error("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError - wrong entries FAILED");
356 ::Info("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError - entries OK");
358 if (isOK[2]==kFALSE || isOK[3]==kFALSE ||isOK[4]==kFALSE ){
359 ::Error("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError - inconsitent entries FAILED");
361 ::Info("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError - consistent entries OK");
371 Bool_t TestCorrection_AliTPCCalibGlobalMisalignmentAddCorrectionCompact(){
372 /// AliTPCCalibGlobalMisalignmentAddCorrectionCompact
373 /// Invariant used in test is not exact it is only approximate - as matrix multiplication is not comulative
374 /// !!!! BUG FOUND ????
375 /// hmatrix1->GetTranslation()[idelta]=xxx; // does not work as expected Translation is set, visible in Print but not used later
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};
381 AliTPCComposedCorrection *compCorrBoundaryVoltError = new AliTPCComposedCorrection();
382 AliTPCCalibGlobalMisalignment *corr0 = new AliTPCCalibGlobalMisalignment;
383 AliTPCCalibGlobalMisalignment *corr1 = new AliTPCCalibGlobalMisalignment;
384 AliTPCCalibGlobalMisalignment *corr2 = new AliTPCCalibGlobalMisalignment;
385 TObjArray sectorAlign(72);
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);
397 corr0->SetAlignGlobal(hmatrix0);
398 corr1->SetAlignGlobal(hmatrix1);
399 corr0->SetAlignGlobalDelta(hmatrix1);
400 corr1->SetAlignGlobalDelta(hmatrix0);
401 corr2->SetAlignSectors(§orAlign);
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);
410 isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr2,1);
411 isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr2,-1);
414 isOK[1]=compCorrBoundaryVoltError->GetCorrections()->GetEntries()==1;
415 AliTPCCalibGlobalMisalignment *corrRes=0;
416 if (isOK[1]==kFALSE){
421 corrRes= dynamic_cast<AliTPCCalibGlobalMisalignment *>(compCorrBoundaryVoltError->GetSubCorrection(0));
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;
433 corrRes->GetAlignGlobal()->Print();
434 corrRes->GetAlignSectors()->At(0)->Print();
435 corrRes->GetAlignSectors()->At(1)->Print();
439 for (Int_t i=0; i<5; i++) res&=isOK[i];
441 if (isOK[0]==kFALSE){
442 ::Error("TestCorrection_AddCorrectionCompact","AliTPCCalibGlobalMisalignment -ADD FAILED");
444 ::Info("TestCorrection_AddCorrectionCompact","AliTPCCalibGlobalMisalignment -ADD OK");
446 if (isOK[1]==kFALSE){
447 ::Error("TestCorrection_AddCorrectionCompact","AliTPCCalibGlobalMisalignment - wrong entries FAILED");
449 ::Info("TestCorrection_AddCorrectionCompact","AliTPCCalibGlobalMisalignment - entries OK");
451 if (isOK[2]==kFALSE || isOK[3]==kFALSE ||isOK[4]==kFALSE ){
452 ::Error("TestCorrection_AddCorrectionCompact","AliTPCCalibGlobalMisalignment - inconsitent entries FAILED");
454 ::Info("TestCorrection_AddCorrectionCompact","AliTPCCalibGlobalMisalignment - consistent entries OK");
460 Bool_t TestCorrection_AliTPCCorrection_AddCorrectionCompact(){
463 TestCorrection_AliTPCExBTwistAddCorrectionCompact();
464 TestCorrection_AliTPCFCVoltError3DAddCorrectionCompact();
465 TestCorrection_AliTPCRocVoltError3DAddCorrectionCompact();
466 TestCorrection_AliTPCBoundaryVoltErrorAddCorrectionCompact();
467 TestCorrection_AliTPCCalibGlobalMisalignmentAddCorrectionCompact();
470 Bool_t TestCorrection_AliTPCComposedCorrectionAddCorrectionCompact_TPCCalibCorrection(Bool_t fast){
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));
477 // 0.) Read an input OCDB entry
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);
483 AliTPCComposedCorrection *compInputFast = new AliTPCComposedCorrection;
484 Int_t ncorrs = compInput->GetCorrections()->GetEntries();
485 TObjArray arrayInputFast(ncorrs);
487 // 1.) Test each individual correction
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;
495 // if ( clName.Contains("AliTPCExBBShape"))continue;
496 AliTPCCorrection *corrInput=compInput->GetSubCorrection(icorr);
498 ::Info("TestCorrection_AliTPCComposedCorrectionAddCorrectionCompact_TPCCalibCorrection",TString::Format("%s\t%s",corrInput->IsA()->GetName(),corrInput->GetName()).Data());
499 AliTPCComposedCorrection *compTest0= new AliTPCComposedCorrection;
500 AliTPCComposedCorrection *compTest1= new AliTPCComposedCorrection;
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);
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());
528 ::Info("TestCorrection_AliTPCComposedCorrectionAddCorrectionCompact_TPCCalibCorrection",TString::Format("Test0:\t%s\t%3.5f\t%3.5f OK",clName.Data(),mean0,rms0).Data());
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());
533 ::Info("TestCorrection_AliTPCComposedCorrectionAddCorrectionCompact_TPCCalibCorrection",TString::Format("Test1:\t%s\t%3.5f\t%3.5f OK",clName.Data(),mean1,rms1).Data());
540 Bool_t TestCorrection_AliTPCComposedCorrectionAddCorrectionCompact(){
541 /// Tests of AliTPCComposedCorrection
542 /// 1.) Make linear combination correction example using weights.
543 /// Test correction checking invariant inverse x orig (there are simpler way to do inversion using AliTPCInverseCorrection)
545 /// 2.) Make compact for of the Composed correction. Test correction checking invariant inverse x orig
547 const Int_t npointsTest=10000;
548 const Float_t kEpsilon=0.0001; // using Floating point precission
550 // 0.) Read an input OCDB entry
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);
556 AliTPCComposedCorrection *compInputFast = new AliTPCComposedCorrection;
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));
566 compInputFast->SetCorrections(&arrayInputFast);
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)
573 AliTPCComposedCorrection *compInverse = new AliTPCComposedCorrection();
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;
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);
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);
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;
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());
605 ::Info("TestCorrection_AddCorrectionCompact","AliTPCComposedCorrection - Test1 OK");
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);
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);