First version of the parallel TPC tracking (M.Ivanov)
[u/mrichter/AliRoot.git] / TPC / AliTPCCompareClusters.C
CommitLineData
1c53abe2 1/****************************************************************************
2 * Origin: M.Ivanov, CERN, Marian.Ivanov@cern.ch *
3 ****************************************************************************/
4
5
6
d6a97186 7#ifndef __CINT__
8#include "alles.h"
9#include "AliComplexCluster.h"
10#endif
11
12Int_t AliTPCCompareClusters(Int_t eventn) {
13 cerr<<"Comparing clusters...\n";
14
15 TFile *file=TFile::Open("galice.root");
16 if (!file->IsOpen()) {cerr<<"Can't open galice.root !\n"; return 1;}
17
18 // TFile *cf=TFile::Open("AliTPCclusters.root");
19 TFile *cf=TFile::Open("AliTPCclusters.root");
20 if (!cf->IsOpen()){cerr<<"Can't open AliTPCclusters.root !\n"; return 3;}
21
22 AliTPCParam *dig=(AliTPCParam *)cf->Get("75x40_100x60");
23 if (!dig) {cerr<<"TPC parameters have not been found !\n"; return 2;}
24
25 TFile *fout=TFile::Open("AliTPCClustersDif.root","new");
26 if (!fout->IsOpen()) fout=TFile::Open("AliTPCClustersDif.root","recreate");
27
28 //connect exact clusters
29 file->cd();
30 AliTPCClustersArray *ce=new AliTPCClustersArray;
31 ce->Setup(dig);
32 ce->SetClusterType("AliComplexCluster");
33 char cname[100];
34 sprintf(cname,"TreeCExact_%d",eventn);
35 ce->ConnectTree(cname);
36 //connect reconstructed clusters
37 cf->cd();
38 AliTPCClustersArray *cr=new AliTPCClustersArray;
39 cr->Setup(dig);
40 cr->SetClusterType("AliTPCcluster");
41 sprintf(cname,"TreeC_TPC_%d",eventn);
42 cr->ConnectTree(cname);
43
44 //create differantial clusters
45 fout->cd();
46 AliTPCClustersArray carray;
47 carray.Setup(dig);
48 carray.SetClusterType("AliDifCluster");
49 carray.MakeTree();
50
51 Int_t nrows=Int_t(cr->GetTree()->GetEntries());
52 for (Int_t n=0; n<nrows; n++) {
53 AliSegmentID *sr=cr->LoadEntry(n);
54 Int_t sec,row;
55 dig->AdjustSectorRow(sr->GetID(),sec,row);
56 ce->LoadRow(sec,row);
57 cr->LoadRow(sec,row);
58 AliTPCClustersRow* clrowe = ce->GetRow(sec,row);
59 AliTPCClustersRow* clrowr = cr->GetRow(sec,row);
60 AliTPCClustersRow* clrowdiff = carray.CreateRow(sec,row);
61
62 Int_t ncl=clrowe->GetArray()->GetEntriesFast();
63 const Int_t kNIS=dig->GetNInnerSector(), kNOS=dig->GetNOuterSector();
64 Int_t npads, sign;
65 if (sec < kNIS) {
66 npads = dig->GetNPadsLow(row);
67 sign = (sec < kNIS/2) ? 1 : -1;
68 } else {
69 npads = dig->GetNPadsUp(row);
70 sign = ((sec-kNIS) < kNOS/2) ? 1 : -1;
71 }
72
73 while (ncl--) {
74 // AliTPCcluster *cl=(AliTPCcluster*)clrow[ncl];
75 AliComplexCluster *cl=(AliComplexCluster*)(clrowe->GetArray()->At(ncl));
76 AliDifCluster * cldif = new(clrowdiff->Append()) AliDifCluster;
77
78 Double_t x=dig->GetPadRowRadii(sec,row);
79 Double_t y=cl->fY;
80 y = ( y + 0.5 - 0.5*npads) *dig->GetPadPitchWidth(sec);
81 Double_t z=cl->fX*dig->GetZWidth();
82 z = sign*(dig->GetZLength() - z);
83 Float_t cs, sn, tmp;
84 dig->AdjustCosSin(sec,cs,sn);
85 Int_t ncr = clrowr->GetArray()->GetEntriesFast();
86 AliTPCcluster *clrec =0;
87 while (ncr--) {
88 clrec = (AliTPCcluster*)(clrowr->GetArray()->At(ncr));
89 if (clrec->GetLabel(0) == cl->fTracks[0]){
90 //cout<<cl->fTracks[0]<<"\n";
91 cldif->fTracks[0]= cl->fTracks[0];
92 cldif->fTracks[1]= clrec->GetLabel(1);
93 cldif->fTracks[2]= clrec->GetLabel(2);
94
95 cldif->fX = clrec->GetZ();
96 cldif->fY = clrec->GetY();
97 cldif->fQ = clrec->GetQ();
98 cldif->fOrigQ = cl->fQ;
99 cldif->fDx = cldif->fX - z;
100 cldif->fAngleX= cl->fSigmaX2;
101 cldif->fAngleY= cl->fSigmaY2;
102 cldif->fDy = cldif->fY - y;
103 }
104
105 }
106 //tmp = x*cs-y*sn; y= x*sn+y*cs; x=tmp;
107
108 // pm->SetPoint(ncl,x,y,z);
109 }
110 cr->ClearRow(sec,row);
111 ce->ClearRow(sec,row);
112 carray.StoreRow(sec,row);
113 carray.ClearRow(sec,row);
114 }
115 delete ce;
116 delete cr;
117 carray.GetTree()->Write("Diff");
118 cf->Close();
119 fout->Close();
120 file->Close();
121 return 0;
122}