]>
Commit | Line | Data |
---|---|---|
d687eb80 | 1 | /// \file UnitTest.C |
2 | /// | |
3 | /// Unit test for some functions classes used in the $ALICE_ROOT/TPC/Base directory: | |
4 | /// | |
5 | /// ~~~{.cpp} | |
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"); | |
7 | /// | |
8 | /// .L $ALICE_ROOT/TPC/Base/test/UnitTest.C+ | |
9 | /// UnitTestAliTPCCalPadTree(); | |
10 | /// TestCorrection_AliTPCCorrection_AddCorrectionCompact(); | |
11 | /// ~~~ | |
7b83b139 | 12 | |
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" | |
69d03c4d | 25 | #include "AliTPCCorrection.h" |
26 | #include "AliTPCComposedCorrection.h" | |
27 | #include "AliTPCExBTwist.h" | |
28 | #include "AliTPCFCVoltError3D.h" | |
e7463b27 | 29 | #include "AliTPCROCVoltError3D.h" |
954a5d1b | 30 | #include "AliTPCBoundaryVoltError.h" |
653c697d | 31 | #include "AliTPCCalibGlobalMisalignment.h" |
32 | #include "AliCDBEntry.h" | |
33 | #include "TStopwatch.h" | |
34 | #include "TGeoMatrix.h" | |
c534975a | 35 | #include "TGeoGlobalMagField.h" |
36 | #include "AliMagF.h" | |
92e31745 | 37 | // PARAMETERS to set from outside: |
69d03c4d | 38 | TString baseDir="/hera/alice/wiechula/calib/guiTrees"; // TO FIX specification of inout data |
7b83b139 | 39 | // |
40 | // | |
41 | ||
653c697d | 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(); | |
820dad02 | 49 | Bool_t TestCorrection_AliTPCComposedCorrectionAddCorrectionCompact_TPCCalibCorrection(Bool_t fast=kFALSE); |
7b83b139 | 50 | |
51 | void UnitTestAliTPCCalPadTree(){ | |
d687eb80 | 52 | /// Make a UnitTest of the AliTPCCalPad |
53 | /// a.) TTree functionaility | |
54 | /// b.) MedianFilterFunctionality | |
55 | /// c.) LTMFilterFunctionality | |
56 | ||
7b83b139 | 57 | TObjArray *fArray = new TObjArray(100); |
58 | TTree * treePad=AliTPCcalibDButil::ConnectGainTrees(baseDir); | |
92e31745 | 59 | for (Int_t i=0; i<5; i+=2){ |
69d03c4d | 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); | |
7b83b139 | 68 | if (i>0) { |
69 | padLx->MedianFilter(i,2*i); | |
70 | padLy->MedianFilter(i,2*i); | |
92e31745 | 71 | padLLx->LTMFilter(i,2*i,1.00, 0); |
72 | padLLy->LTMFilter(i,2*i,1.00, 0); | |
7b83b139 | 73 | padMax->MedianFilter(i,2*i); |
74 | padMean->MedianFilter(i,2*i); | |
92e31745 | 75 | padMaxL->LTMFilter(i,2*i,0.8,0); |
76 | padMeanL->LTMFilter(i,2*i,0.8,0); | |
7b83b139 | 77 | } |
92e31745 | 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()); | |
7b83b139 | 82 | padMax->SetName(TString::Format("QMax%d",i).Data()); |
83 | padMean->SetName(TString::Format("QTot%d",i).Data()); | |
92e31745 | 84 | padMaxL->SetName(TString::Format("QMaxL%d",i).Data()); |
85 | padMeanL->SetName(TString::Format("QTotL%d",i).Data()); | |
7b83b139 | 86 | fArray->AddLast(padLx); |
87 | fArray->AddLast(padLy); | |
92e31745 | 88 | fArray->AddLast(padLLx); |
89 | fArray->AddLast(padLLy); | |
7b83b139 | 90 | fArray->AddLast(padMax); |
91 | fArray->AddLast(padMean); | |
92e31745 | 92 | fArray->AddLast(padMaxL); |
93 | fArray->AddLast(padMeanL); | |
7b83b139 | 94 | } |
95 | AliTPCCalibViewer::MakeTree("QAtest.root", fArray,0); | |
96 | // | |
92e31745 | 97 | // 2.) Check invariants |
98 | // | |
7b83b139 | 99 | TFile*fout= TFile::Open("QAtest.root"); |
100 | TTree * tree = (TTree*)fout->Get("calPads"); | |
92e31745 | 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"); | |
7b83b139 | 112 | } |
69d03c4d | 113 | |
114 | ||
115 | Bool_t TestCorrection_AliTPCExBTwistAddCorrectionCompact(){ | |
d687eb80 | 116 | /// 1.) Test ExB twist AddCorrectionCompact |
117 | ||
e7463b27 | 118 | Bool_t isOK[10]={kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE}; |
69d03c4d | 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 | |
653c697d | 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); | |
e7463b27 | 128 | isOK[0]&=compCorrTwist->AddCorrectionCompact(twistY,-1); |
129 | isOK[0]&=compCorrTwist->AddCorrectionCompact(twistX,-1); | |
130 | isOK[1]=compCorrTwist->GetCorrections()->GetEntries()==1; | |
653c697d | 131 | |
69d03c4d | 132 | AliTPCExBTwist *twistRes=0; |
e7463b27 | 133 | if (isOK[1]==kFALSE){ |
134 | isOK[2]=kFALSE; | |
135 | isOK[3]=kFALSE; | |
136 | isOK[4]=kFALSE; | |
69d03c4d | 137 | }else{ |
138 | twistRes= dynamic_cast<AliTPCExBTwist *>(compCorrTwist->GetSubCorrection(0)); | |
139 | if (twistRes==NULL){ | |
e7463b27 | 140 | isOK[2]=kFALSE; |
141 | isOK[3]=kFALSE; | |
142 | isOK[4]=kFALSE; | |
69d03c4d | 143 | }else{ |
e7463b27 | 144 | isOK[3] &= (twistRes->GetXTwist()==0); |
145 | isOK[4] &= (twistRes->GetYTwist()==0); | |
69d03c4d | 146 | } |
147 | } | |
148 | Bool_t res=kTRUE; | |
e7463b27 | 149 | for (Int_t i=0; i<5; i++) res&=isOK[i]; |
69d03c4d | 150 | { |
e7463b27 | 151 | if (isOK[0]==kFALSE){ |
69d03c4d | 152 | ::Error("TestCorrection_AddCorrectionCompact","AliTPCExBTwist -ADD FAILED"); |
153 | }else{ | |
154 | ::Info("TestCorrection_AddCorrectionCompact","AliTPCExBTwist -ADD OK"); | |
155 | } | |
e7463b27 | 156 | if (isOK[1]==kFALSE){ |
69d03c4d | 157 | ::Error("TestCorrection_AddCorrectionCompact","AliTPCExBTwist - wrong entries FAILED"); |
158 | }else{ | |
159 | ::Info("TestCorrection_AddCorrectionCompact","AliTPCExBTwist - entries OK"); | |
160 | } | |
e7463b27 | 161 | if (isOK[2]==kFALSE || isOK[3]==kFALSE ||isOK[4]==kFALSE ){ |
69d03c4d | 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 | ||
171 | Bool_t TestCorrection_AliTPCFCVoltError3DAddCorrectionCompact(){ | |
d687eb80 | 172 | /// TestCorrection_AliTPCFCVoltError3DAddCorrectionCompact |
173 | ||
e7463b27 | 174 | const Float_t kEpsilon=0.000001; |
69d03c4d | 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); | |
186 | } | |
187 | // | |
653c697d | 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); | |
69d03c4d | 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 | } | |
e7463b27 | 236 | |
237 | ||
238 | ||
239 | Bool_t TestCorrection_AliTPCRocVoltError3DAddCorrectionCompact(){ | |
d687eb80 | 240 | /// AliTPCRocVoltError3DAddCorrectionCompact |
241 | ||
e7463b27 | 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; | |
252 | } | |
253 | corr0->SetROCData(&matrixDz); | |
254 | matrixDz*=0.5; | |
255 | corr1->SetROCData(&matrixDz); | |
256 | // | |
653c697d | 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); | |
e7463b27 | 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 | } | |
954a5d1b | 300 | |
301 | ||
302 | ||
303 | ||
304 | ||
305 | Bool_t TestCorrection_AliTPCBoundaryVoltErrorAddCorrectionCompact(){ | |
d687eb80 | 306 | /// AliTPCBoundaryVoltErrorAddCorrectionCompact |
307 | ||
954a5d1b | 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; | |
316 | } | |
317 | corr0->SetBoundariesA(boundaries); | |
318 | corr1->SetBoundariesA(boundaries); | |
319 | // | |
653c697d | 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); | |
954a5d1b | 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 | } | |
653c697d | 366 | |
367 | ||
368 | ||
369 | ||
370 | ||
371 | Bool_t TestCorrection_AliTPCCalibGlobalMisalignmentAddCorrectionCompact(){ | |
d687eb80 | 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 | |
376 | ||
653c697d | 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(); | |
382 | AliTPCCalibGlobalMisalignment *corr0 = new AliTPCCalibGlobalMisalignment; | |
383 | AliTPCCalibGlobalMisalignment *corr1 = new AliTPCCalibGlobalMisalignment; | |
384 | AliTPCCalibGlobalMisalignment *corr2 = new AliTPCCalibGlobalMisalignment; | |
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(§orAlign); | |
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; | |
415 | AliTPCCalibGlobalMisalignment *corrRes=0; | |
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 | ||
460 | Bool_t TestCorrection_AliTPCCorrection_AddCorrectionCompact(){ | |
d687eb80 | 461 | /// |
462 | ||
653c697d | 463 | TestCorrection_AliTPCExBTwistAddCorrectionCompact(); |
464 | TestCorrection_AliTPCFCVoltError3DAddCorrectionCompact(); | |
465 | TestCorrection_AliTPCRocVoltError3DAddCorrectionCompact(); | |
466 | TestCorrection_AliTPCBoundaryVoltErrorAddCorrectionCompact(); | |
467 | TestCorrection_AliTPCCalibGlobalMisalignmentAddCorrectionCompact(); | |
468 | } | |
469 | ||
820dad02 | 470 | Bool_t TestCorrection_AliTPCComposedCorrectionAddCorrectionCompact_TPCCalibCorrection(Bool_t fast){ |
d687eb80 | 471 | /// Test the |
472 | ||
c534975a | 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); | |
483 | AliTPCComposedCorrection *compInputFast = new AliTPCComposedCorrection; | |
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(); | |
820dad02 | 491 | if (fast){ // skip slow correction |
492 | if ( clName.Contains("AliTPCFCVoltError3D"))continue; | |
493 | if ( clName.Contains("AliTPCROCVoltError3D"))continue; | |
494 | } | |
c534975a | 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()); | |
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); | |
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 | ||
653c697d | 539 | |
540 | Bool_t TestCorrection_AliTPCComposedCorrectionAddCorrectionCompact(){ | |
d687eb80 | 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) | |
544 | /// | |
545 | /// 2.) Make compact for of the Composed correction. Test correction checking invariant inverse x orig | |
546 | ||
653c697d | 547 | const Int_t npointsTest=10000; |
548 | const Float_t kEpsilon=0.0001; // using Floating point precission | |
653c697d | 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(); | |
c534975a | 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)); | |
565 | } | |
566 | compInputFast->SetCorrections(&arrayInputFast); | |
567 | ||
568 | ||
569 | ||
653c697d | 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) | |
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; | |
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(); | |
c534975a | 611 | compOutInverseCompact->AddCorrectionCompact(compInputFast,1); |
612 | compOutInverseCompact->AddCorrectionCompact(compInputFast,-1); | |
653c697d | 613 | compOutInverseCompact->SetOmegaTauT1T2(0,1,1); |
c534975a | 614 | compInputFast->SetOmegaTauT1T2(0,1,1); |
653c697d | 615 | compOutInverseCompact->AddVisualCorrection(compOutInverseCompact,10); |
c534975a | 616 | compInputFast->AddVisualCorrection(compInput,3); |
653c697d | 617 | TStopwatch timer; |
618 | // | |
619 | TF1 fcomp("fcomp","AliTPCCorrection::GetCorrXYZ(x,x,100,0,10)",85,245); | |
c534975a | 620 | TF1 forig("forig","-AliTPCCorrection::GetCorrXYZ(x,x,100,0,3)",85,245); |
653c697d | 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 | } |