1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
20 macro to compare TClonesArray hits with interpolated hits
25 #include "AliObjectArray.h"
26 #include "AliTPCTrackHits.h"
27 #include "AliArrayBranch.h"
28 #include "TestTPCTrackHits.h"
32 void CompareHits(TClonesArray * arr, AliTPCTrackHits * myhits, Bool_t debug, TClonesArray *arrd=0);
33 AliTPCTrackHits * MakeTrack(TClonesArray * arr, TClonesArray * arrp, AliTPCTrackHits *myhits);
35 void ConvertHits(const char * benchmark, Bool_t debug)
38 //convert - not parametrised hits stored in Clones array
42 TFile f("galice.root","update");
43 TClonesArray *arr = new TClonesArray("AliTPChit",100);
44 TTree * treeCl =(TTree*)f.Get("TreeH0");
45 TBranch *branch = treeCl->GetBranch("TPC");
46 AliTPCTrackHits * myhits = new AliTPCTrackHits;
47 branch->SetAddress(&arr);
49 TTree * treeP = (TTree*)f.Get("TreeK0");
50 TBranch *branchP = treeP->GetBranch("Particles");
51 TClonesArray *arrp = new TClonesArray("TParticle",100);
52 branchP->SetAddress(&arrp);
55 TFile f2("treeh.root","recreate");
56 f2.SetCompressionLevel(10);
57 TTree * treeh2 = new TTree("TreeTPCH","TreeTPCH");
58 //treeh2->AliBranch("TPC","AliTPCTrackHits", &myhits,4096);
59 treeh2->GetListOfBranches()->Add(new AliObjectBranch("TPC","AliTPCTrackHits",
60 &myhits,treeh2,4096,1));
62 TFile f3("treehcl.root","recreate");
63 f3.SetCompressionLevel(2);
64 TTree * treeh3 = new TTree("TreeTPCH","TreeTPCH");
65 treeh3->Branch("TPC", &arr,64000,100);
67 gBenchmark->Start(benchmark);
68 Int_t trsize = (Int_t)treeCl->GetEntries();
69 for (Int_t i=0;i<300;i++){
71 Int_t size = branch->GetEvent(i);
73 if ((size>0)&& arr->GetEntriesFast()>0) {
76 myhits =MakeTrack(arr,arrp,myhits);
77 CompareHits(arr,myhits,debug);
82 if ((i%10)==0) cout<<i<<"\n";
92 gBenchmark->Stop(benchmark);
93 gBenchmark->Show(benchmark);
98 void CompareHits(const char * benchmark, Bool_t debug)
100 //compare persistent hits
101 TFile f2("treeh.root");
102 TTree * treeh2 = (TTree*)f2.Get("TreeTPCH");
103 AliTPCTrackHits * myhits = new AliTPCTrackHits ;
104 AliObjectBranch *mybranch = (AliObjectBranch*)treeh2->GetBranch("TPC");
105 mybranch->SetAddress(&myhits);
108 TClonesArray *arr = new TClonesArray("AliTPChit",100);
109 TFile f3("treehcl.root");
110 TTree * treeh3 = (TTree*)f3.Get("TreeTPCH");
111 TBranch *branch = treeh3->GetBranch("TPC");
112 branch->SetAddress(&arr);
115 gBenchmark->Start(benchmark);
116 Int_t trsize = (Int_t)treeh3->GetEntries();
117 for (Int_t i=0;i<300;i++){
118 Int_t size = branch->GetEvent(i);
119 mybranch->GetEvent(i);
121 if ((arr->GetEntriesFast()>0) && size>0) {
122 CompareHits(arr,myhits,debug);
123 if ((i%10)==0) cout<<i<<"\n";
126 gBenchmark->Stop(benchmark);
127 gBenchmark->Show(benchmark);
131 void CompareHitsG(const char * benchmark, Bool_t debug)
133 //compare persistent hits
134 TFile f2("galice.root");
135 TTree * treeh2 = (TTree*)f2.Get("TreeH0");
136 AliTPCTrackHits * myhits = new AliTPCTrackHits ;
137 AliObjectBranch *mybranch = (AliObjectBranch*)treeh2->GetBranch("TPC2");
138 mybranch->SetAddress(&myhits);
141 TClonesArray *arr = new TClonesArray("AliTPChit",100);
142 //TFile f3("treehcl.root");
143 //TTree * treeh3 = (TTree*)f3.Get("TreeTPCH");
144 TBranch *branch = treeh2->GetBranch("TPC");
145 branch->SetAddress(&arr);
147 TFile f3("treehdelta.root","recreate");
148 f3.SetCompressionLevel(2);
149 TTree * treeh3 = new TTree("DelataH","DeltaH");
150 TClonesArray *arrd = new TClonesArray("AliTPChitD",100);
151 treeh3->Branch("TPC", &arrd,64000,100);
154 gBenchmark->Start(benchmark);
155 Int_t trsize = treeh2->GetEntries();
156 for (Int_t i=0;i<trsize;i++){
157 Int_t size = branch->GetEvent(i);
158 mybranch->GetEvent(i);
160 if ((arr->GetEntriesFast()>0) && size>0) {
161 CompareHits(arr,myhits,debug,arrd);
163 if ((i%10)==0) cout<<i<<"\n";
168 gBenchmark->Stop(benchmark);
169 gBenchmark->Show(benchmark);
175 AliTPCTrackHits * MakeTrack(TClonesArray * arr, TClonesArray * arrp, AliTPCTrackHits *myhits)
178 //make track wit hits according
180 // AliTPCTrackHits * myhits= new AliTPCTrackHits;
181 myhits->SetHitPrecision(0.002);
182 myhits->SetStepPrecision(0.003);
183 myhits->SetMaxDistance(100);
184 myhits->FlushHitStack(kTRUE);
185 for (Int_t i=0;i<arr->GetEntriesFast();i++){
186 hit = (AliTPChit*)arr->At(i);
188 TParticle *p = (TParticle*)arrp->At(hit->GetTrack());
189 Float_t momentum = TMath::Sqrt(p->Px()*p->Px()+p->Py()*p->Py());
190 Float_t ran= 100.*gRandom->Rndm();
191 if (ran<1.) myhits->FlushHitStack(kTRUE);
192 if (momentum<0.01) {//if small momentum - not precise
193 myhits->SetHitPrecision(0.05);
194 myhits->AddHitKartez(hit->fSector,hit->GetTrack(), hit->X(), hit->Y(),
195 hit->Z(), hit->fQ+1000);
198 myhits->SetHitPrecision(0.002);
199 myhits->AddHitKartez(hit->fSector,hit->GetTrack(), hit->X(), hit->Y(),
204 myhits->FlushHitStack();
210 void CompareHits(TClonesArray * arr, AliTPCTrackHits * myhits, Bool_t debug, TClonesArray *arrd)
213 // if debug option kTRUE
214 // compare hits and write result to the stdoutput
215 AliTPChit * hit, *hit2;
216 if (arrd) arrd->Clear();
218 for (Int_t i=0;i<arr->GetEntriesFast();i++){
219 hit = (AliTPChit*)arr->At(i);
221 if (i==0) myhits->First();
223 hit2 = myhits->GetHit();
226 if (hit) cout<<"Error _ hits "<<i<<"didn't find\n";
232 AliTrackHitsParam *param= myhits->GetParam();
233 AliHitInfo * info = myhits->GetHitInfo();
236 TClonesArray &larrd = *arrd;
237 AliTPChitD * h = new(larrd[i]) AliTPChitD;
241 h->SetTrack(hit->GetTrack());
243 h->fSector = hit->fSector;
244 AliTPChit * hitd = h->GetDelta();
245 hitd->SetX(hit->X()-hit2->X());
246 hitd->SetY(hit->Y()-hit2->Y());
247 hitd->SetZ(hit->Z()-hit2->Z());
248 hitd->SetTrack(hit->GetTrack()-hit2->GetTrack());
249 hitd->fQ = hit->fQ-hit2->fQ;
250 hitd->fSector = hit->fSector-hit2->fSector;
256 (hit->X()-hit2->X())*(hit->X()-hit2->X())+
257 (hit->Y()-hit2->Y())*(hit->Y()-hit2->Y())+
258 (hit->Z()-hit2->Z())*(hit->Z()-hit2->Z()));
259 printf("C1\t%d\t%d\t%d\t%d\t",
260 hit->fSector,hit2->fSector,hit->GetTrack(),hit2->GetTrack());
261 printf("%3.6f\t%3.6f\t%3.6f\t%3.6f\t%3.6f\t%3.6f\t",
262 hit->X(),hit2->X(), hit->Y(),hit2->Y(),hit->Z(),hit2->Z());
263 printf("%3.6f\t%3.6f\t%3.6f\t%3.6f\t%3.6f\t%3.6f\t%3.6f\t",
264 dd, param->fR,param->fZ,param->fFi,param->fAn,
265 param->fAd,param->fTheta);
266 printf("%d\t%d\t%d\n",
267 (Int_t)info->fHitDistance, (Int_t)hit->fQ, (Int_t)hit2->fQ);
277 //Filter for paw visualisation of results
280 //sed '/*/d' dd.txt | sed '/C/d'| cat -n > out.txt
281 // sed -n '/C2/p' dd.txt | sed 's/C1//' | cat -n >out2.txt
282 // sed -n '/C3/p' dd.txt | sed 's/C2//' | cat -n >out3.txt
285 //myfilter C1 dd.txt >out1.txt
286 //myfilter C2 dd.txt >out2.txt
287 //myfilter C3 dd.txt >out3.txt
289 // sed -n 1,50000p dd.txt | myfilter C1 | sed -n 1,50000p >out1.txt
291 //myfilter C1 dd.txt | sed -n 1,50000p >out1.txt
292 //myfilter C2 dd.txt | sed -n 1,50000p >out2.txt
293 //myfilter C3 dd.txt | sed -n 1,50000p >out3.txt
296 Nt/Create 1 'Test of Match' 21 ! ! event v1 v2 t1 t2 x1 x2 y1 y2 z1 z2 dd r z fi an ad theta dist q1 q2
299 Nt/Create 2 'Test of Match2' 13 ! ! event stacksize i r z fi alfa theta dr1 ddr ddz ddrfi dd
302 Nt/Create 3 'Test of Match2' 2 ! ! event stacksize
306 void Fit2(Double_t fSumY, Double_t fSumYX, Double_t fSumYX2,
307 Double_t fSumX, Double_t fSumX2, Double_t fSumX3,
308 Double_t fSumX4, Int_t n,
309 Double_t &a, Double_t &b, Double_t &c)
312 //recalc parameters not fixing origin point
314 n* (fSumX2*fSumX4-fSumX3*fSumX3) -
315 fSumX* (fSumX*fSumX4-fSumX3*fSumX2)+
316 fSumX2* (fSumX*fSumX3-fSumX2*fSumX2);
318 if (TMath::Abs(det)>0){
320 (fSumY * (fSumX2*fSumX4-fSumX3*fSumX3)-
321 fSumX *(fSumYX*fSumX4-fSumYX2*fSumX3)+
322 fSumX2*(fSumYX*fSumX3-fSumYX2*fSumX2))/det;
324 (n*(fSumYX*fSumX4-fSumX3*fSumYX2)-
325 fSumY*(fSumX*fSumX4-fSumX3*fSumX2)+
326 fSumX2*(fSumX*fSumYX2-fSumYX*fSumX2))/det;
328 (n*(fSumX2*fSumYX2-fSumYX*fSumX3)-
329 fSumX*(fSumX*fSumYX2-fSumYX*fSumX2)+
330 fSumY*(fSumX*fSumX3-fSumX2*fSumX2))/det;
331 cout<<a<<"\t"<<b<<"\t"<<c<<"\n";
335 void TestFit(Float_t a, Float_t b, Float_t c, Int_t n)
337 Double_t fSumY,fSumYX,fSumYX2,fSumX, fSumX2,fSumX3, fSumX4;
338 fSumY = fSumYX = fSumYX2 = fSumX = fSumX2 = fSumX3 = fSumX4 =0;
340 for (Int_t i=0;i<n; i++){
341 Float_t x = gRandom->Rndm();
342 Float_t y = a+b*x+c*x*x;
351 Fit2(fSumY,fSumYX,fSumYX2, fSumX,fSumX2,fSumX3,fSumX4,n,a2,b2,c2);