Print removed
[u/mrichter/AliRoot.git] / TPC / AliTPCCompareTracks.C
CommitLineData
1c53abe2 1#ifndef __CINT__
2#include "alles.h"
3#include "AliComplexCluster.h"
4//#include "AliTPCclusterM.h"
5#include "AliTPCtrackerMI.h"
6#include "AliTPCclusterMI.h"
7#endif
8
9
10Int_t AliTPCCompareTracks(Int_t eventn, Bool_t all = kFALSE) {
11 cerr<<"Comparing tracks...\n";
12 //CONNECT FILES
13 TFile *file=TFile::Open("galice.root");
14 if (!file->IsOpen()) {cerr<<"Can't open galice.root !\n"; return 1;}
15 //
16 TFile *ftracks=TFile::Open("AliTPCtracks.root","update");
17 if (!ftracks->IsOpen()){cerr<<"Can't open AliTPCtracks.root !\n"; return 3;}
18 //
19 AliTPCParam *param=(AliTPCParam *)file->Get("75x40_100x60_150x60");
20 if (!param) {cerr<<"TPC parameters have not been found !\n"; return 2;}
21 //
22 TFile *fout=TFile::Open("AliTPCTracksDif.root","new");
23 if (!fout->IsOpen()) fout=TFile::Open("AliTPCClustersDif.root","recreate");
24 //
25 //connect exact clusters
26 file->cd();
27 AliTPCClustersArray *ce=new AliTPCClustersArray;
28 ce->Setup(param);
29 ce->SetClusterType("AliComplexCluster");
30 char cname[100];
31 sprintf(cname,"TreeCExact_%d",eventn);
32 ce->ConnectTree(cname);
33 //
34 //connect reconstructed tracks
35 ftracks->cd();
36 sprintf(cname,"Seeds");
37 TTree * treetracks = (TTree*)ftracks->Get(cname);
38 TBranch * branchtracks = treetracks->GetBranch("seeds");
39 //
40 //load seeds to the memory
41 Int_t trackmap[500000][4]; // map of tracks corresponding to given track number
42 memset(trackmap,0,sizeof(Int_t)*4*500000);
43 Int_t ntracks = treetracks->GetEntries();
44 TObjArray * trackarr= new TObjArray(ntracks);
45 Int_t nproces = TMath::Min(ntracks,4000);
46
47 // for (Int_t itrack =0; itrack<ntracks; itrack++){
48 for (Int_t itrack =0; itrack<nproces; itrack++){
49 AliTPCseed * seed = new AliTPCseed;
50 //
51 seed->fPoints = new TClonesArray("AliTPCTrackPoint",200);
52 branchtracks->SetAddress(&seed);
53 branchtracks->GetEntry(itrack);
54
55 //if (seed->fRemoval>0 && (itrack%4) ) continue;
56 trackarr->AddLast(seed);
57
58 //crete array with exact position information
59 seed->fEPoints = new TClonesArray("AliTPCTrackPointRef",1);
60 seed->fEPoints->ExpandCreateFast(200);
61
62 Int_t label = TMath::Abs(seed->GetLabel());
63 Int_t i;
64 if (label>500000) {
65 //too big track label
66 }else{
67 for (i=0;i<4;i++) {
68 if ( trackmap[label][i]==0)
69 break;
70 }
71 if(i<4) trackmap[label][i]=itrack;
72 }
73 }
74
75 //add information about exact positions
76 Int_t nrows=Int_t(ce->GetTree()->GetEntries());
77
78 for (Int_t n=0; n<nrows; n++) {
79 AliSegmentID *se=ce->LoadEntry(n);
80 Int_t sec,row;
81 param->AdjustSectorRow(se->GetID(),sec,row);
82 //
83 AliTPCClustersRow* clrowe = ce->GetRow(sec,row);
84 //
85 Int_t ncl=clrowe->GetArray()->GetEntriesFast();
86 const Int_t kNIS=param->GetNInnerSector(), kNOS=param->GetNOuterSector();
87 Int_t npads, sign;
88 if (sec < kNIS) {
89 npads = param->GetNPadsLow(row);
90 sign = (sec < kNIS/2) ? 1 : -1;
91 } else {
92 npads = param->GetNPadsUp(row);
93 sign = ((sec-kNIS) < kNOS/2) ? 1 : -1;
94 }
95
96 Int_t trrow = row;
97 if (sec>=param->GetNInnerSector()) trrow += param->GetNRowLow();
98
99 while (ncl--) {
100 AliComplexCluster *cl=(AliComplexCluster*)(clrowe->GetArray()->At(ncl));
101 Double_t x=param->GetPadRowRadii(sec,row);
102 Double_t y=cl->fY;
103 y = ( y + 0.5 - 0.5*npads) *param->GetPadPitchWidth(sec);
104 Double_t z=cl->fX*param->GetZWidth();
105 z = sign*(param->GetZLength() - z);
106 Float_t cs, sn, tmp;
107 param->AdjustCosSin(sec,cs,sn);
108 for (Int_t i=0;i<3;i++){
109 if (cl->fTracks[0]<500000) if (trackmap[cl->fTracks[0]][i]) {
110 AliTPCseed * seed = (AliTPCseed*)trackarr->At(trackmap[cl->fTracks[0]][i]);
111 TClonesArray * clarr = seed->fPoints;
112 if (!clarr){
113 //printf("Seed %d without info",trackmap[cl->fTracks[0]][i]);
114 continue;
115 }
116 AliTPCTrackPoint * trcluster = (AliTPCTrackPoint*)(seed->fPoints->At(trrow));
117 AliTPCTrackPointRef * ecluster = (AliTPCTrackPointRef*)(seed->fEPoints->At(trrow));
118 //
119 ecluster->GetCPoint() = trcluster->GetCPoint();
120 ecluster->GetTPoint() = trcluster->GetTPoint();
121 //
122 AliTPCExactPoint & epoint = ecluster->GetExactPoint();
123 /*
124 trcluster->fEZ = z;
125 trcluster->fEY = y;
126 trcluster->fAngleY = cl->fSigmaY2*param->GetPadPitchLength(sec);
127 trcluster->fAngleZ = cl->fSigmaX2*param->GetPadPitchLength(sec);
128 trcluster->fEAmp = cl->fQ;
129 trcluster->fEPrim = cl->fMax;
130 */
131 epoint.fEZ = z;
132 epoint.fEY = y;
133 epoint.fEAngleY = cl->fSigmaY2*param->GetPadPitchLength(sec);
134 epoint.fEAngleZ = cl->fSigmaX2*param->GetPadPitchLength(sec);
135 epoint.fEAmp = cl->fQ;
136 epoint.fEPrim = cl->fMax;
137 }
138 }
139 }
140 // cr->ClearRow(sec,row);
141 ce->ClearRow(sec,row);
142 }
143
144 // make new tree - with tracks - exact position
145 fout->cd();
146 TTree * treenew = new TTree("Seedref","Seedref");
147 AliTPCseed * ioseed = (AliTPCseed*)trackarr->At(0);
148 TBranch * br = treenew->Branch("seeds","AliTPCseed",&ioseed,32000,99);
149
150 for (Int_t itrack =0; itrack<ntracks; itrack++){
151 ioseed = (AliTPCseed*) trackarr->At(itrack);
152 br->SetAddress(&ioseed);
153 treenew->Fill();
154 }
155
156 treenew->Write();
157 printf("1\n");
158 delete ce;
159 printf("2\n");
160 //delete cr;
161 // carray->GetTree()->Write();
162 printf("3\n");
163 // delete carray;
164 printf("4\n");
165 // cf->Close();
166 printf("5\n");
167 fout->Close();
168 printf("6\n");
169 ftracks->Close();
170 printf("7\n");
171 return 0;
172}