]>
Commit | Line | Data |
---|---|---|
7b83b139 | 1 | /* |
e7463b27 | 2 | Unit test for some functions classes used in the $ALICE_ROOT/TPC/Base directory: |
7b83b139 | 3 | gSystem->SetIncludePath("-I$ROOTSYS/include -I$ALICE_ROOT/ -I$ALICE_ROOT/include -I$ALICE_ROOT/STEER\ |
4 | -I$ALICE_ROOT/TPC -I$ALICE_ROOT/ITS -I$ALICE_ROOT/TRD -I$ALICE_ROOT/TOF -I$ALICE_ROOT/RAW -I$ALICE_ROOT/PWG1 -I$ALICE_ROOT/STAT -I$ALICE_ROOT/TPC/Base -I$ALICE_ROOT/TPC/Calib"); | |
5 | ||
6 | .L $ALICE_ROOT/TPC/Base/test/UnitTest.C+ | |
92e31745 | 7 | UnitTestAliTPCCalPadTree(); |
69d03c4d | 8 | TestCorrection_AliTPCExBTwistAddCorrectionCompact(); |
e7463b27 | 9 | TestCorrection_AliTPCFCVoltError3DAddCorrectionCompact(); |
10 | TestCorrection_AliTPCRocVoltError3DAddCorrectionCompact(); | |
954a5d1b | 11 | TestCorrection_AliTPCBoundaryVoltErrorAddCorrectionCompact(); |
92e31745 | 12 | |
7b83b139 | 13 | */ |
14 | ||
15 | #include "TF1.h" | |
16 | #include "TMath.h" | |
17 | #include "TLinearFitter.h" | |
18 | #include "TFile.h" | |
19 | #include "AliSysInfo.h" | |
20 | #include "TTree.h" | |
21 | #include "AliLog.h" | |
22 | #include "THn.h" | |
23 | #include "TRandom.h" | |
24 | #include "AliTPCCalPad.h" | |
25 | #include "AliTPCCalibViewer.h" | |
26 | #include "AliTPCcalibDButil.h" | |
69d03c4d | 27 | #include "AliTPCCorrection.h" |
28 | #include "AliTPCComposedCorrection.h" | |
29 | #include "AliTPCExBTwist.h" | |
30 | #include "AliTPCFCVoltError3D.h" | |
e7463b27 | 31 | #include "AliTPCROCVoltError3D.h" |
954a5d1b | 32 | #include "AliTPCBoundaryVoltError.h" |
33 | ||
7b83b139 | 34 | // |
92e31745 | 35 | // PARAMETERS to set from outside: |
7b83b139 | 36 | // |
69d03c4d | 37 | TString baseDir="/hera/alice/wiechula/calib/guiTrees"; // TO FIX specification of inout data |
7b83b139 | 38 | // |
39 | // | |
40 | ||
41 | ||
42 | void UnitTestAliTPCCalPadTree(){ | |
43 | // | |
92e31745 | 44 | // Make a UnitTest of the AliTPCCalPad |
45 | // a.) TTree functionaility | |
46 | // b.) MedianFilterFunctionality | |
47 | // c.) LTMFilterFunctionality | |
48 | // | |
7b83b139 | 49 | TObjArray *fArray = new TObjArray(100); |
50 | TTree * treePad=AliTPCcalibDButil::ConnectGainTrees(baseDir); | |
92e31745 | 51 | for (Int_t i=0; i<5; i+=2){ |
69d03c4d | 52 | AliTPCCalPad * padLx = AliTPCCalPad::MakePadFromTree(treePad,"lx.fElements","Lx",kTRUE); |
53 | AliTPCCalPad * padLy = AliTPCCalPad::MakePadFromTree(treePad,"ly.fElements","Ly",kTRUE); | |
54 | AliTPCCalPad * padLLx = AliTPCCalPad::MakePadFromTree(treePad,"lx.fElements","LLx",kTRUE); | |
55 | AliTPCCalPad * padLLy = AliTPCCalPad::MakePadFromTree(treePad,"ly.fElements","LLy",kTRUE); | |
56 | AliTPCCalPad * padMax = AliTPCCalPad::MakePadFromTree(treePad,"QA.2010.LHC10d.MaxCharge.fElements","QMax",kTRUE); | |
57 | AliTPCCalPad * padMean = AliTPCCalPad::MakePadFromTree(treePad,"QA.2010.LHC10d.MeanCharge.fElements","QTot",kTRUE); | |
58 | AliTPCCalPad * padMaxL = AliTPCCalPad::MakePadFromTree(treePad,"QA.2010.LHC10d.MaxCharge.fElements","QMax",kTRUE); | |
59 | AliTPCCalPad * padMeanL = AliTPCCalPad::MakePadFromTree(treePad,"QA.2010.LHC10d.MeanCharge.fElements","QTot",kTRUE); | |
7b83b139 | 60 | if (i>0) { |
61 | padLx->MedianFilter(i,2*i); | |
62 | padLy->MedianFilter(i,2*i); | |
92e31745 | 63 | padLLx->LTMFilter(i,2*i,1.00, 0); |
64 | padLLy->LTMFilter(i,2*i,1.00, 0); | |
7b83b139 | 65 | padMax->MedianFilter(i,2*i); |
66 | padMean->MedianFilter(i,2*i); | |
92e31745 | 67 | padMaxL->LTMFilter(i,2*i,0.8,0); |
68 | padMeanL->LTMFilter(i,2*i,0.8,0); | |
7b83b139 | 69 | } |
92e31745 | 70 | padLx->SetName(TString::Format("Lx%d",i).Data()); |
71 | padLy->SetName(TString::Format("Ly%d",i).Data()); | |
72 | padLLx->SetName(TString::Format("LLx%d",i).Data()); | |
73 | padLLy->SetName(TString::Format("LLy%d",i).Data()); | |
7b83b139 | 74 | padMax->SetName(TString::Format("QMax%d",i).Data()); |
75 | padMean->SetName(TString::Format("QTot%d",i).Data()); | |
92e31745 | 76 | padMaxL->SetName(TString::Format("QMaxL%d",i).Data()); |
77 | padMeanL->SetName(TString::Format("QTotL%d",i).Data()); | |
7b83b139 | 78 | fArray->AddLast(padLx); |
79 | fArray->AddLast(padLy); | |
92e31745 | 80 | fArray->AddLast(padLLx); |
81 | fArray->AddLast(padLLy); | |
7b83b139 | 82 | fArray->AddLast(padMax); |
83 | fArray->AddLast(padMean); | |
92e31745 | 84 | fArray->AddLast(padMaxL); |
85 | fArray->AddLast(padMeanL); | |
7b83b139 | 86 | } |
87 | AliTPCCalibViewer::MakeTree("QAtest.root", fArray,0); | |
88 | // | |
92e31745 | 89 | // 2.) Check invariants |
90 | // | |
7b83b139 | 91 | TFile*fout= TFile::Open("QAtest.root"); |
92 | TTree * tree = (TTree*)fout->Get("calPads"); | |
92e31745 | 93 | Int_t isOutM0 = tree->Draw("(Ly2.fElements-Ly0.fElements)>>his0(100,-10,10)","abs((Ly2.fElements-Ly0.fElements))>2","goff"); |
94 | Int_t isOutM1=tree->Draw("(Lx2.fElements-Lx0.fElements)/0.75>>his1(100,-10,10)","abs((Lx2.fElements-Lx0.fElements))>0","goff"); | |
95 | printf("IsOut=%d\t%d\n",isOutM0,isOutM1); | |
96 | if ((isOutM0+isOutM1)==0) ::Info("UnitTestAliTPCCalPadTree","MedianTest OK"); | |
97 | if (isOutM0||isOutM1) ::Fatal("UnitTestAliTPCCalPadTree","MedianTest FAILED"); | |
98 | // | |
99 | Int_t isOutL0 = tree->Draw("(LLy2.fElements-Ly0.fElements)>>his0(100,-10,10)","abs((LLy2.fElements-LLy0.fElements))>0","goff"); | |
100 | Int_t isOutL1=tree->Draw("(LLx2.fElements-Lx0.fElements)/0.75>>his1(100,-10,10)","abs((LLx2.fElements-LLx0.fElements))>0","goff"); | |
101 | printf("IsOut=%d\t%d\n",isOutL0,isOutL1); | |
102 | if ((isOutL0+isOutL1)==0) ::Info("UnitTestAliTPCCalPadTree","LTMTest OK"); | |
103 | if (isOutL0||isOutL1) ::Fatal("UnitTestAliTPCCalPadTree","LTMTest FAILED"); | |
7b83b139 | 104 | } |
69d03c4d | 105 | |
106 | ||
107 | Bool_t TestCorrection_AliTPCExBTwistAddCorrectionCompact(){ | |
108 | // | |
109 | // | |
69d03c4d | 110 | // 1.) Test ExB twist AddCorrectionCompact |
111 | // | |
e7463b27 | 112 | Bool_t isOK[10]={kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE}; |
69d03c4d | 113 | AliTPCComposedCorrection *compCorrTwist = new AliTPCComposedCorrection(); |
114 | AliTPCExBTwist *twistX = new AliTPCExBTwist; | |
115 | AliTPCExBTwist *twistY = new AliTPCExBTwist; | |
116 | twistX->SetXTwist(0.001); // 1 mrad twist in x | |
117 | twistY->SetYTwist(0.001); // 1 mrad twist in x | |
e7463b27 | 118 | isOK[0]&=compCorrTwist->AddCorrectionCompact(twistX,1); |
119 | isOK[0]&=compCorrTwist->AddCorrectionCompact(twistY,1); | |
120 | isOK[0]&=compCorrTwist->AddCorrectionCompact(twistY,-1); | |
121 | isOK[0]&=compCorrTwist->AddCorrectionCompact(twistX,-1); | |
122 | isOK[1]=compCorrTwist->GetCorrections()->GetEntries()==1; | |
69d03c4d | 123 | AliTPCExBTwist *twistRes=0; |
e7463b27 | 124 | if (isOK[1]==kFALSE){ |
125 | isOK[2]=kFALSE; | |
126 | isOK[3]=kFALSE; | |
127 | isOK[4]=kFALSE; | |
69d03c4d | 128 | }else{ |
129 | twistRes= dynamic_cast<AliTPCExBTwist *>(compCorrTwist->GetSubCorrection(0)); | |
130 | if (twistRes==NULL){ | |
e7463b27 | 131 | isOK[2]=kFALSE; |
132 | isOK[3]=kFALSE; | |
133 | isOK[4]=kFALSE; | |
69d03c4d | 134 | }else{ |
e7463b27 | 135 | isOK[3] &= (twistRes->GetXTwist()==0); |
136 | isOK[4] &= (twistRes->GetYTwist()==0); | |
69d03c4d | 137 | } |
138 | } | |
139 | Bool_t res=kTRUE; | |
e7463b27 | 140 | for (Int_t i=0; i<5; i++) res&=isOK[i]; |
69d03c4d | 141 | { |
e7463b27 | 142 | if (isOK[0]==kFALSE){ |
69d03c4d | 143 | ::Error("TestCorrection_AddCorrectionCompact","AliTPCExBTwist -ADD FAILED"); |
144 | }else{ | |
145 | ::Info("TestCorrection_AddCorrectionCompact","AliTPCExBTwist -ADD OK"); | |
146 | } | |
e7463b27 | 147 | if (isOK[1]==kFALSE){ |
69d03c4d | 148 | ::Error("TestCorrection_AddCorrectionCompact","AliTPCExBTwist - wrong entries FAILED"); |
149 | }else{ | |
150 | ::Info("TestCorrection_AddCorrectionCompact","AliTPCExBTwist - entries OK"); | |
151 | } | |
e7463b27 | 152 | if (isOK[2]==kFALSE || isOK[3]==kFALSE ||isOK[4]==kFALSE ){ |
69d03c4d | 153 | ::Error("TestCorrection_AddCorrectionCompact","AliTPCExBTwist - inconsitent entries FAILED"); |
154 | }else{ | |
155 | ::Info("TestCorrection_AddCorrectionCompact","AliTPCExBTwist - consistent entries OK"); | |
156 | } | |
157 | } | |
158 | return res; | |
159 | } | |
160 | ||
161 | ||
162 | Bool_t TestCorrection_AliTPCFCVoltError3DAddCorrectionCompact(){ | |
69d03c4d | 163 | // |
e7463b27 | 164 | // TestCorrection_AliTPCFCVoltError3DAddCorrectionCompact |
69d03c4d | 165 | // |
e7463b27 | 166 | const Float_t kEpsilon=0.000001; |
69d03c4d | 167 | Bool_t isOK[10]={kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE}; |
168 | AliTPCComposedCorrection *compCorrComp = new AliTPCComposedCorrection(); | |
169 | AliTPCFCVoltError3D *corr0 = new AliTPCFCVoltError3D; | |
170 | AliTPCFCVoltError3D *corr1 = new AliTPCFCVoltError3D; | |
171 | for (Int_t isec=0; isec<36; isec++){ | |
172 | corr0->SetRodVoltShiftA(isec,TMath::Cos(TMath::Pi()*isec/36),kFALSE); | |
173 | corr0->SetRodVoltShiftC(isec,TMath::Cos(TMath::Pi()*isec/36),kFALSE); | |
174 | corr1->SetRodVoltShiftA(isec,TMath::Sin(TMath::Pi()*isec/36),kFALSE); | |
175 | corr1->SetRodVoltShiftC(isec,TMath::Sin(TMath::Pi()*isec/36),kFALSE); | |
176 | corr1->SetCopperRodShiftA(isec,TMath::Sin(TMath::Pi()*isec/36),kFALSE); | |
177 | corr1->SetCopperRodShiftC(isec,TMath::Sin(TMath::Pi()*isec/36),kFALSE); | |
178 | } | |
179 | // | |
180 | isOK[0]&=compCorrComp->AddCorrectionCompact(corr0,1); | |
181 | isOK[0]&=compCorrComp->AddCorrectionCompact(corr1,1); | |
182 | isOK[0]&=compCorrComp->AddCorrectionCompact(corr1,-1); | |
183 | isOK[0]&=compCorrComp->AddCorrectionCompact(corr0,-1); | |
184 | isOK[1]=compCorrComp->GetCorrections()->GetEntries()==1; | |
185 | AliTPCFCVoltError3D *corrRes=0; | |
186 | if (isOK[1]==kFALSE){ | |
187 | isOK[2]=kFALSE; | |
188 | isOK[3]=kFALSE; | |
189 | isOK[4]=kFALSE; | |
190 | }else{ | |
191 | corrRes= dynamic_cast<AliTPCFCVoltError3D *>(compCorrComp->GetSubCorrection(0)); | |
192 | if (corrRes==NULL){ | |
193 | isOK[2]=kFALSE; | |
194 | isOK[3]=kFALSE; | |
195 | isOK[4]=kFALSE; | |
196 | }else{ | |
197 | for (Int_t isec=0; isec<36; isec++){ | |
198 | isOK[3] &=( TMath::Abs(corrRes->GetRodVoltShiftA(isec))<kEpsilon); | |
199 | isOK[4] &=( TMath::Abs(corrRes->GetRodVoltShiftC(isec))<kEpsilon); | |
200 | isOK[5] &=( TMath::Abs(corrRes->GetCopperRodShiftA(isec))<kEpsilon); | |
201 | isOK[6] &=( TMath::Abs(corrRes->GetCopperRodShiftC(isec))<kEpsilon); | |
202 | } | |
203 | } | |
204 | } | |
205 | Bool_t res=kTRUE; | |
206 | for (Int_t i=0; i<5; i++) res&=isOK[i]; | |
207 | { | |
208 | if (isOK[0]==kFALSE){ | |
209 | ::Error("TestCorrection_AddCorrectionCompact","AliTPCFCVoltError3D -ADD FAILED"); | |
210 | }else{ | |
211 | ::Info("TestCorrection_AddCorrectionCompact","AliTPCFCVoltError3D -ADD OK"); | |
212 | } | |
213 | if (isOK[1]==kFALSE){ | |
214 | ::Error("TestCorrection_AddCorrectionCompact","AliTPCFCVoltError3D - wrong entries FAILED"); | |
215 | }else{ | |
216 | ::Info("TestCorrection_AddCorrectionCompact","AliTPCFCVoltError3D - entries OK"); | |
217 | } | |
218 | if (isOK[2]==kFALSE || isOK[3]==kFALSE ||isOK[4]==kFALSE ){ | |
219 | ::Error("TestCorrection_AddCorrectionCompact","AliTPCFCVoltError3D - inconsitent entries FAILED"); | |
220 | }else{ | |
221 | ::Info("TestCorrection_AddCorrectionCompact","AliTPCFCVoltError3D - consistent entries OK"); | |
222 | } | |
223 | } | |
224 | return res; | |
225 | } | |
e7463b27 | 226 | |
227 | ||
228 | ||
229 | Bool_t TestCorrection_AliTPCRocVoltError3DAddCorrectionCompact(){ | |
230 | // | |
231 | // AliTPCRocVoltError3DAddCorrectionCompact | |
232 | // | |
233 | const Float_t kEpsilon=0.00000001; | |
234 | Bool_t isOK[10]={kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE}; | |
235 | AliTPCComposedCorrection *compCorrROCVoltError3D = new AliTPCComposedCorrection(); | |
236 | AliTPCROCVoltError3D *corr0 = new AliTPCROCVoltError3D; | |
237 | AliTPCROCVoltError3D *corr1 = new AliTPCROCVoltError3D; | |
238 | TMatrixD matrixDz(72,3); | |
239 | for (Int_t isec=0; isec<72; isec++){ | |
240 | matrixDz(isec,0)=gRandom->Rndm()*0.1; | |
241 | matrixDz(isec,1)=gRandom->Rndm()*0.001; | |
242 | matrixDz(isec,2)=gRandom->Rndm()*0.001; | |
243 | } | |
244 | corr0->SetROCData(&matrixDz); | |
245 | matrixDz*=0.5; | |
246 | corr1->SetROCData(&matrixDz); | |
247 | // | |
248 | isOK[0]&=compCorrROCVoltError3D->AddCorrectionCompact(corr0,1); | |
249 | isOK[0]&=compCorrROCVoltError3D->AddCorrectionCompact(corr1,1); | |
250 | isOK[0]&=compCorrROCVoltError3D->AddCorrectionCompact(corr1,-1); | |
251 | isOK[0]&=compCorrROCVoltError3D->AddCorrectionCompact(corr0,-1); | |
252 | isOK[1]=compCorrROCVoltError3D->GetCorrections()->GetEntries()==1; | |
253 | AliTPCROCVoltError3D *corrRes=0; | |
254 | if (isOK[1]==kFALSE){ | |
255 | isOK[2]=kFALSE; | |
256 | isOK[3]=kFALSE; | |
257 | isOK[4]=kFALSE; | |
258 | }else{ | |
259 | corrRes= dynamic_cast<AliTPCROCVoltError3D *>(compCorrROCVoltError3D->GetSubCorrection(0)); | |
260 | if (corrRes==NULL){ | |
261 | isOK[2]=kFALSE; | |
262 | isOK[3]=kFALSE; | |
263 | isOK[4]=kFALSE; | |
264 | }else{ | |
265 | isOK[3]=TMath::Abs(corrRes->GetMatrix()->Sum())<kEpsilon; | |
266 | } | |
267 | } | |
268 | Bool_t res=kTRUE; | |
269 | for (Int_t i=0; i<5; i++) res&=isOK[i]; | |
270 | { | |
271 | if (isOK[0]==kFALSE){ | |
272 | ::Error("TestCorrection_AddCorrectionCompact","AliTPCROCVoltError3D -ADD FAILED"); | |
273 | }else{ | |
274 | ::Info("TestCorrection_AddCorrectionCompact","AliTPCROCVoltError3D -ADD OK"); | |
275 | } | |
276 | if (isOK[1]==kFALSE){ | |
277 | ::Error("TestCorrection_AddCorrectionCompact","AliTPCROCVoltError3D - wrong entries FAILED"); | |
278 | }else{ | |
279 | ::Info("TestCorrection_AddCorrectionCompact","AliTPCROCVoltError3D - entries OK"); | |
280 | } | |
281 | if (isOK[2]==kFALSE || isOK[3]==kFALSE ||isOK[4]==kFALSE ){ | |
282 | ::Error("TestCorrection_AddCorrectionCompact","AliTPCROCVoltError3D - inconsitent entries FAILED"); | |
283 | }else{ | |
284 | ::Info("TestCorrection_AddCorrectionCompact","AliTPCROCVoltError3D - consistent entries OK"); | |
285 | } | |
286 | } | |
287 | return res; | |
288 | } | |
954a5d1b | 289 | |
290 | ||
291 | ||
292 | ||
293 | ||
294 | Bool_t TestCorrection_AliTPCBoundaryVoltErrorAddCorrectionCompact(){ | |
295 | // | |
296 | // AliTPCBoundaryVoltErrorAddCorrectionCompact | |
297 | // | |
298 | const Float_t kEpsilon=0.00000001; | |
299 | Bool_t isOK[10]={kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE}; | |
300 | AliTPCComposedCorrection *compCorrBoundaryVoltError = new AliTPCComposedCorrection(); | |
301 | AliTPCBoundaryVoltError *corr0 = new AliTPCBoundaryVoltError; | |
302 | AliTPCBoundaryVoltError *corr1 = new AliTPCBoundaryVoltError; | |
303 | Float_t boundaries[8]; | |
304 | for (Int_t ibound=0; ibound<8; ibound++){ | |
305 | boundaries[ibound]=gRandom->Rndm()-0.5; | |
306 | } | |
307 | corr0->SetBoundariesA(boundaries); | |
308 | corr1->SetBoundariesA(boundaries); | |
309 | // | |
310 | isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr0,1); | |
311 | isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr1,1); | |
312 | isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr1,-1); | |
313 | isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr0,-1); | |
314 | isOK[1]=compCorrBoundaryVoltError->GetCorrections()->GetEntries()==1; | |
315 | AliTPCBoundaryVoltError *corrRes=0; | |
316 | if (isOK[1]==kFALSE){ | |
317 | isOK[2]=kFALSE; | |
318 | isOK[3]=kFALSE; | |
319 | isOK[4]=kFALSE; | |
320 | }else{ | |
321 | corrRes= dynamic_cast<AliTPCBoundaryVoltError *>(compCorrBoundaryVoltError->GetSubCorrection(0)); | |
322 | if (corrRes==NULL){ | |
323 | isOK[2]=kFALSE; | |
324 | isOK[3]=kFALSE; | |
325 | isOK[4]=kFALSE; | |
326 | }else{ | |
327 | for (Int_t ibound=0; ibound<8; ibound++){ | |
328 | isOK[3]&=TMath::Abs(corrRes->GetBoundariesA(ibound))<kEpsilon; | |
329 | isOK[3]&=TMath::Abs(corrRes->GetBoundariesC(ibound))<kEpsilon; | |
330 | } | |
331 | } | |
332 | } | |
333 | Bool_t res=kTRUE; | |
334 | for (Int_t i=0; i<5; i++) res&=isOK[i]; | |
335 | { | |
336 | if (isOK[0]==kFALSE){ | |
337 | ::Error("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError -ADD FAILED"); | |
338 | }else{ | |
339 | ::Info("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError -ADD OK"); | |
340 | } | |
341 | if (isOK[1]==kFALSE){ | |
342 | ::Error("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError - wrong entries FAILED"); | |
343 | }else{ | |
344 | ::Info("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError - entries OK"); | |
345 | } | |
346 | if (isOK[2]==kFALSE || isOK[3]==kFALSE ||isOK[4]==kFALSE ){ | |
347 | ::Error("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError - inconsitent entries FAILED"); | |
348 | }else{ | |
349 | ::Info("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError - consistent entries OK"); | |
350 | } | |
351 | } | |
352 | return res; | |
353 | } |