]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCTestClustering.C
Clean-up bug in Centered() corrected.
[u/mrichter/AliRoot.git] / TPC / AliTPCTestClustering.C
1 void AliTPCTestClustering() {
2    const char *pname="75x40_100x60";
3    const char *tname="TreeD_75x40_100x60";
4
5 // Dynamically link some shared libs
6
7    if (gClassTable->GetID("AliRun") < 0) {
8       gROOT->LoadMacro("loadlibs.C");
9       loadlibs();
10    } else {
11       delete gAlice;
12       gAlice=0;
13    }
14
15 // Connect the Root Galice file containing Geometry, Kine and Hits
16    TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
17    if (!file) file = new TFile("galice.root");
18    //if (!file) file = TFile::Open("rfio:galice.root");
19
20 // Get AliRun object from file or create it if not on file
21    if (!gAlice) {
22       gAlice = (AliRun*)file->Get("gAlice");
23       if (gAlice) printf("AliRun object found on file\n");
24       if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
25    }
26
27    gAlice->GetEvent(0);
28
29    AliTPC *TPC = (AliTPC*)gAlice->GetDetector("TPC");
30    int ver=TPC->IsVersion(); 
31    cerr<<"TPC version "<<ver<<" has been found !\n";
32
33    AliTPCParam *dig=(AliTPCParam *)file->Get(pname);
34    if (dig!=0) TPC->SetParam(dig);
35    else cerr<<"Warning: default TPC parameters will be used !\n";
36
37    switch (ver) {
38    case 1:
39       cerr<<"Making clusters...\n";
40       TPC->Hits2Clusters();
41       break;
42    case 2:
43       cerr<<"Looking for clusters...\n";
44       TPC->Digits2Clusters();
45       break;
46    default:
47       cerr<<"Invalid TPC version !\n";
48       return;
49    }
50    TClonesArray *c=TPC->Clusters();
51    int n=c->GetEntriesFast();
52    cerr<<"Number of clusters "<<n<<"                            \n";
53
54    Float_t x[3];
55    TPolyMarker3D *pm=new TPolyMarker3D(n);
56    for (int i=0; i<n; i++) {
57        AliTPCcluster *cl=(AliTPCcluster *)c->UncheckedAt(i);
58        cl->GetXYZ(x,dig);
59        Double_t xx=x[0], yy=x[1], zz=x[2];
60        pm->SetPoint(i,xx,yy,zz);
61    }
62
63    c1=new TCanvas("c1", "Cluster display",0,0,700,730);
64    TView *v=new TView(1);
65    v->SetRange(-430,-560,-430,430,560,1710);
66
67    c1->Clear();
68    c1->SetFillColor(1);
69    c1->SetTheta(90.);
70    c1->SetPhi(0.);
71
72    pm->SetMarkerSize(1);
73    pm->SetMarkerColor(2);
74    pm->SetMarkerStyle(1);
75    pm->Draw();
76
77    gAlice->GetGeometry()->Draw("same");
78 }