562f777bfc49a23b443714a682006ee35821c967
[u/mrichter/AliRoot.git] / TPC / AliTPCDisplayDigits3Dnew.C
1 #ifndef __CINT__
2   #include "alles.h"
3   #include "AliTPCtracker.h"
4   #include "TView.h"
5   #include "TPolyMarker3D.h"
6   #include "AliSimDigits.h"
7 #endif
8
9 //  
10 //  display 3D digits
11 //  input parameter is event number  - threshol to the noise
12 //  if sdigits=kTRUE it will display Sdigits - otherwise it display digits
13 //  signal event is displayed with yellow color
14
15 Int_t AliTPCDisplayDigits3D(Int_t eventn=0, Int_t noiseth=15, Bool_t sdigits=kFALSE) {
16    cerr<<"Displaying digits...\n";
17
18    TFile *file=TFile::Open("galice.root");
19    if (!file->IsOpen()) {cerr<<"Can't open galice.root !\n"; return 1;}
20
21    TFile *cf=TFile::Open("galice.root");
22    // if (!cf->IsOpen()){cerr<<"Can't open AliTPCclusters.root !\n"; return 3;}
23
24    AliTPCParam *param=(AliTPCParam *)cf->Get("75x40_100x60");
25    if (!param) {cerr<<"TPC parameters have not been found !\n"; return 2;}
26
27    TCanvas *c1=new TCanvas("ddisplay", "Digits display",0,0,700,730);
28    TView *v=new TView(1);
29    v->SetRange(-430,-560,-430,430,560,1710);
30    c1->Clear();
31    c1->SetFillColor(1);
32    c1->SetTheta(90.);
33    c1->SetPhi(0.);
34
35    AliTPCDigitsArray *digarr=new AliTPCDigitsArray;
36    digarr->Setup(param);
37    
38    char  cname[100];
39    if (!sdigits)
40      sprintf(cname,"TreeD_75x40_100x60_%d",eventn);
41    else
42      sprintf(cname,"TreeS_75x40_100x60_%d",eventn);
43
44 // some "constants"
45    Int_t markerColorSignal = 5;
46    Int_t markerColorBgr = 2;
47    Int_t MASK = 10000000;
48
49    digarr->ConnectTree(cname);
50    Int_t nrows=Int_t(digarr->GetTree()->GetEntries());
51    Int_t all0=0;
52    for (Int_t n=0; n<nrows; n++) {
53        AliSimDigits *s=(AliSimDigits*)digarr->LoadEntry(n);
54        Int_t sec,row;
55        param->AdjustSectorRow(s->GetID(),sec,row);
56        Int_t npads, sign;
57        {
58          const Int_t kNIS=param->GetNInnerSector(), kNOS=param->GetNOuterSector();
59          if (sec < kNIS) {
60            npads = param->GetNPadsLow(row);
61            sign = (sec < kNIS/2) ? 1 : -1;
62          } else {
63            npads = param->GetNPadsUp(row);
64            sign = ((sec-kNIS) < kNOS/2) ? 1 : -1;
65          }
66        }
67
68        AliSimDigits *digrow = (AliSimDigits*)digarr->GetRow(sec,row);
69        Int_t ncl=0;
70        if (digrow->First()){
71          while(digrow->Next()) ncl++;
72          ncl++;
73        }
74        TPolyMarker3D *pm=new TPolyMarker3D(ncl);
75        TPolyMarker3D *pmSignal=new TPolyMarker3D(ncl); // polymarker for signal
76        Int_t imarBgr=0;
77        Int_t imarSignal=0;
78        if (digrow->First()) do {
79          Short_t dig=digrow->CurrentDigit();
80          Double_t y = (digrow->CurrentColumn()- 0.5 - 0.5*npads)*param->GetPadPitchWidth(sec);
81          Double_t z = sign*(param->GetZLength()-param->GetZWidth()*digrow->CurrentRow());        
82          Double_t x=param->GetPadRowRadii(sec,row);
83          if (dig<noiseth) continue;     
84          Int_t trackId = digrow->GetTrackID(digrow->CurrentRow(),digrow->CurrentColumn(),0);    
85          Float_t cs, sn, tmp;
86          param->AdjustCosSin(sec,cs,sn);
87          tmp = x*cs-y*sn; y= x*sn+y*cs; x=tmp;
88          if (trackId<0) continue;  //if signal from croostalk - we don't have track ID information
89          if (trackId < MASK-1) {
90            pmSignal->SetPoint(imarSignal,x,y,z);
91            imarSignal++;
92          } else {
93            pm->SetPoint(imarBgr,x,y,z);
94            imarBgr++;
95          }
96        } while (digrow->Next());
97
98 // change color for signal
99        digarr->ClearRow(sec,row);
100        pm->SetMarkerSize(1); 
101        pm->SetMarkerColor(markerColorBgr);
102        pm->SetMarkerStyle(1);
103        pm->Draw();
104
105        pmSignal->SetMarkerSize(1); 
106        pmSignal->SetMarkerColor(markerColorSignal);
107        pmSignal->SetMarkerStyle(1);
108        pmSignal->Draw();
109        all0+=imarSignal;
110    }
111    printf("%d\n",all0);
112    
113
114    delete digarr;
115    cf->Close();
116    //draw TPC skeleton
117    TGeometry *geom=(TGeometry*)file->Get("AliceGeom");
118    TNode * main = (TNode*)((geom->GetListOfNodes())->First());
119    TIter next(main->GetListOfNodes());
120    TNode  *module=0;
121    while((module = (TNode*)next())) {
122      char ch[100];
123      sprintf(ch,"%s\n",module->GetTitle());
124      //printf("%s\n",module->GetTitle());
125      if (ch[0]=='T'&&ch[1]=='P' && ch[2]=='C')  //if TPC draw
126        module->SetVisibility(3);
127      else
128        module->SetVisibility(-1);
129    }
130      
131    
132    geom->Draw("same");
133    //v->Draw();
134    c1->Modified(); c1->Update(); 
135
136    file->Close();
137    return 0;
138 }
139