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 **************************************************************************/
22 macro to compare TClonesArray hits with interpolated hits
27 #include "AliObjectArray.h"
28 #include "AliTPCTrackHits.h"
29 #include "AliArrayBranch.h"
30 #include "TestTPCTrackHits.h"
34 void CompareHits(TClonesArray * arr, AliTPCTrackHits * myhits, Bool_t debug, TClonesArray *arrd=0);
35 AliTPCTrackHits * MakeTrack(TClonesArray * arr, TClonesArray * arrp, AliTPCTrackHits *myhits);
37 void ConvertHits(const char * benchmark, Bool_t debug)
40 //convert - not parametrised hits stored in Clones array
44 TFile f("galice.root","update");
45 TClonesArray *arr = new TClonesArray("AliTPChit",100);
46 TTree * treeCl =(TTree*)f.Get("TreeH0");
47 TBranch *branch = treeCl->GetBranch("TPC");
48 AliTPCTrackHits * myhits = new AliTPCTrackHits;
49 branch->SetAddress(&arr);
51 TTree * treeP = (TTree*)f.Get("TreeK0");
52 TBranch *branchP = treeP->GetBranch("Particles");
53 TClonesArray *arrp = new TClonesArray("TParticle",100);
54 branchP->SetAddress(&arrp);
57 TFile f2("treeh.root","recreate");
58 f2.SetCompressionLevel(10);
59 TTree * treeh2 = new TTree("TreeTPCH","TreeTPCH");
60 //treeh2->AliBranch("TPC","AliTPCTrackHits", &myhits,4096);
61 treeh2->GetListOfBranches()->Add(new AliObjectBranch("TPC","AliTPCTrackHits",
62 &myhits,treeh2,4096,1));
64 TFile f3("treehcl.root","recreate");
65 f3.SetCompressionLevel(2);
66 TTree * treeh3 = new TTree("TreeTPCH","TreeTPCH");
67 treeh3->Branch("TPC", &arr,64000,2);
69 gBenchmark->Start(benchmark);
70 Int_t trsize = (Int_t)treeCl->GetEntries();
71 for (Int_t i=0;i<300;i++){
73 Int_t size = branch->GetEvent(i);
75 if ((size>0)&& arr->GetEntriesFast()>0) {
78 myhits =MakeTrack(arr,arrp,myhits);
79 CompareHits(arr,myhits,debug);
84 if ((i%10)==0) cout<<i<<"\n";
94 gBenchmark->Stop(benchmark);
95 gBenchmark->Show(benchmark);
100 void CompareHits(const char * benchmark, Bool_t debug)
102 //compare persistent hits
103 TFile f2("treeh.root");
104 TTree * treeh2 = (TTree*)f2.Get("TreeTPCH");
105 AliTPCTrackHits * myhits = new AliTPCTrackHits ;
106 AliObjectBranch *mybranch = (AliObjectBranch*)treeh2->GetBranch("TPC");
107 mybranch->SetAddress(&myhits);
110 TClonesArray *arr = new TClonesArray("AliTPChit",100);
111 TFile f3("treehcl.root");
112 TTree * treeh3 = (TTree*)f3.Get("TreeTPCH");
113 TBranch *branch = treeh3->GetBranch("TPC");
114 branch->SetAddress(&arr);
117 gBenchmark->Start(benchmark);
118 Int_t trsize = (Int_t)treeh3->GetEntries();
119 for (Int_t i=0;i<300;i++){
120 Int_t size = branch->GetEvent(i);
121 mybranch->GetEvent(i);
123 if ((arr->GetEntriesFast()>0) && size>0) {
124 CompareHits(arr,myhits,debug);
125 if ((i%10)==0) cout<<i<<"\n";
128 gBenchmark->Stop(benchmark);
129 gBenchmark->Show(benchmark);
133 void CompareHitsG(const char * benchmark, Bool_t debug)
135 //compare persistent hits
136 TFile f2("galice.root");
137 TTree * treeh2 = (TTree*)f2.Get("TreeH0");
138 AliTPCTrackHits * myhits = new AliTPCTrackHits ;
139 AliObjectBranch *mybranch = (AliObjectBranch*)treeh2->GetBranch("TPC2");
140 mybranch->SetAddress(&myhits);
143 TClonesArray *arr = new TClonesArray("AliTPChit",100);
144 //TFile f3("treehcl.root");
145 //TTree * treeh3 = (TTree*)f3.Get("TreeTPCH");
146 TBranch *branch = treeh2->GetBranch("TPC");
147 branch->SetAddress(&arr);
149 TFile f3("treehdelta.root","recreate");
150 f3.SetCompressionLevel(2);
151 TTree * treeh3 = new TTree("DelataH","DeltaH");
152 TClonesArray *arrd = new TClonesArray("AliTPChitD",100);
153 treeh3->Branch("TPC", &arrd,64000,2);
156 gBenchmark->Start(benchmark);
157 Int_t trsize = treeh2->GetEntries();
158 for (Int_t i=0;i<trsize;i++){
159 Int_t size = branch->GetEvent(i);
160 mybranch->GetEvent(i);
162 if ((arr->GetEntriesFast()>0) && size>0) {
163 CompareHits(arr,myhits,debug,arrd);
165 if ((i%10)==0) cout<<i<<"\n";
170 gBenchmark->Stop(benchmark);
171 gBenchmark->Show(benchmark);
177 AliTPCTrackHits * MakeTrack(TClonesArray * arr, TClonesArray * arrp, AliTPCTrackHits *myhits)
180 //make track wit hits according
182 // AliTPCTrackHits * myhits= new AliTPCTrackHits;
183 myhits->SetHitPrecision(0.002);
184 myhits->SetStepPrecision(0.003);
185 myhits->SetMaxDistance(100);
186 myhits->FlushHitStack(kTRUE);
187 for (Int_t i=0;i<arr->GetEntriesFast();i++){
188 hit = (AliTPChit*)arr->At(i);
190 TParticle *p = (TParticle*)arrp->At(hit->GetTrack());
191 Float_t momentum = TMath::Sqrt(p->Px()*p->Px()+p->Py()*p->Py());
192 Float_t ran= 100.*gRandom->Rndm();
193 if (ran<1.) myhits->FlushHitStack(kTRUE);
194 if (momentum<0.01) {//if small momentum - not precise
195 myhits->SetHitPrecision(0.05);
196 myhits->AddHitKartez(hit->fSector,hit->GetTrack(), hit->X(), hit->Y(),
197 hit->Z(), hit->fQ+1000);
200 myhits->SetHitPrecision(0.002);
201 myhits->AddHitKartez(hit->fSector,hit->GetTrack(), hit->X(), hit->Y(),
206 myhits->FlushHitStack();
212 void CompareHits(TClonesArray * arr, AliTPCTrackHits * myhits, Bool_t debug, TClonesArray *arrd)
215 // if debug option kTRUE
216 // compare hits and write result to the stdoutput
217 AliTPChit * hit, *hit2;
218 if (arrd) arrd->Clear();
220 for (Int_t i=0;i<arr->GetEntriesFast();i++){
221 hit = (AliTPChit*)arr->At(i);
223 if (i==0) myhits->First();
225 hit2 = myhits->GetHit();
228 if (hit) cout<<"Error _ hits "<<i<<"didn't find\n";
234 AliTrackHitsParam *param= myhits->GetParam();
235 AliHitInfo * info = myhits->GetHitInfo();
238 TClonesArray &larrd = *arrd;
239 AliTPChitD * h = new(larrd[i]) AliTPChitD;
243 h->SetTrack(hit->GetTrack());
245 h->fSector = hit->fSector;
246 AliTPChit * hitd = h->GetDelta();
247 hitd->SetX(hit->X()-hit2->X());
248 hitd->SetY(hit->Y()-hit2->Y());
249 hitd->SetZ(hit->Z()-hit2->Z());
250 hitd->SetTrack(hit->GetTrack()-hit2->GetTrack());
251 hitd->fQ = hit->fQ-hit2->fQ;
252 hitd->fSector = hit->fSector-hit2->fSector;
258 (hit->X()-hit2->X())*(hit->X()-hit2->X())+
259 (hit->Y()-hit2->Y())*(hit->Y()-hit2->Y())+
260 (hit->Z()-hit2->Z())*(hit->Z()-hit2->Z()));
261 printf("C1\t%d\t%d\t%d\t%d\t",
262 hit->fSector,hit2->fSector,hit->GetTrack(),hit2->GetTrack());
263 printf("%3.6f\t%3.6f\t%3.6f\t%3.6f\t%3.6f\t%3.6f\t",
264 hit->X(),hit2->X(), hit->Y(),hit2->Y(),hit->Z(),hit2->Z());
265 printf("%3.6f\t%3.6f\t%3.6f\t%3.6f\t%3.6f\t%3.6f\t%3.6f\t",
266 dd, param->fR,param->fZ,param->fFi,param->fAn,
267 param->fAd,param->fTheta);
268 printf("%d\t%d\t%d\n",
269 (Int_t)info->fHitDistance, (Int_t)hit->fQ, (Int_t)hit2->fQ);
279 //Filter for paw visualisation of results
282 //sed '/*/d' dd.txt | sed '/C/d'| cat -n > out.txt
283 // sed -n '/C2/p' dd.txt | sed 's/C1//' | cat -n >out2.txt
284 // sed -n '/C3/p' dd.txt | sed 's/C2//' | cat -n >out3.txt
287 //myfilter C1 dd.txt >out1.txt
288 //myfilter C2 dd.txt >out2.txt
289 //myfilter C3 dd.txt >out3.txt
291 // sed -n 1,50000p dd.txt | myfilter C1 | sed -n 1,50000p >out1.txt
293 //myfilter C1 dd.txt | sed -n 1,50000p >out1.txt
294 //myfilter C2 dd.txt | sed -n 1,50000p >out2.txt
295 //myfilter C3 dd.txt | sed -n 1,50000p >out3.txt
298 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
301 Nt/Create 2 'Test of Match2' 13 ! ! event stacksize i r z fi alfa theta dr1 ddr ddz ddrfi dd
304 Nt/Create 3 'Test of Match2' 2 ! ! event stacksize
308 void Fit2(Double_t fSumY, Double_t fSumYX, Double_t fSumYX2,
309 Double_t fSumX, Double_t fSumX2, Double_t fSumX3,
310 Double_t fSumX4, Int_t n,
311 Double_t &a, Double_t &b, Double_t &c)
314 //recalc parameters not fixing origin point
316 n* (fSumX2*fSumX4-fSumX3*fSumX3) -
317 fSumX* (fSumX*fSumX4-fSumX3*fSumX2)+
318 fSumX2* (fSumX*fSumX3-fSumX2*fSumX2);
320 if (TMath::Abs(det)>0){
322 (fSumY * (fSumX2*fSumX4-fSumX3*fSumX3)-
323 fSumX *(fSumYX*fSumX4-fSumYX2*fSumX3)+
324 fSumX2*(fSumYX*fSumX3-fSumYX2*fSumX2))/det;
326 (n*(fSumYX*fSumX4-fSumX3*fSumYX2)-
327 fSumY*(fSumX*fSumX4-fSumX3*fSumX2)+
328 fSumX2*(fSumX*fSumYX2-fSumYX*fSumX2))/det;
330 (n*(fSumX2*fSumYX2-fSumYX*fSumX3)-
331 fSumX*(fSumX*fSumYX2-fSumYX*fSumX2)+
332 fSumY*(fSumX*fSumX3-fSumX2*fSumX2))/det;
333 cout<<a<<"\t"<<b<<"\t"<<c<<"\n";
337 void TestFit(Float_t a, Float_t b, Float_t c, Int_t n)
339 Double_t fSumY,fSumYX,fSumYX2,fSumX, fSumX2,fSumX3, fSumX4;
340 fSumY = fSumYX = fSumYX2 = fSumX = fSumX2 = fSumX3 = fSumX4 =0;
342 for (Int_t i=0;i<n; i++){
343 Float_t x = gRandom->Rndm();
344 Float_t y = a+b*x+c*x*x;
353 Fit2(fSumY,fSumYX,fSumYX2, fSumX,fSumX2,fSumX3,fSumX4,n,a2,b2,c2);