make the update of the period level QA safe (by running in a temp location and only...
[u/mrichter/AliRoot.git] / TPC / AliTPCDisplayDigits.C
CommitLineData
c2b0eaa4 1/****************************************************************************
2 * Origin: I.Belikov, CERN, Jouri.Belikov@cern.ch *
3 ****************************************************************************/
4
5#ifndef __CINT__
ddae8318 6#include <Riostream.h>
c2b0eaa4 7#include <TFile.h>
8#include <TTree.h>
9#include <TCanvas.h>
10#include <TStyle.h>
11#include <TH2.h>
12
13#include "AliTPCParam.h"
14#include "AliSimDigits.h"
15#endif
16
a1d53143 17Int_t AliTPCDisplayDigits(Int_t eventn, int sec, int row, int lab=-1,
cc80f89e 18 int max_t_chan=500, float min_t=0., float max_t=500.,
19 int max_p_chan=150, float min_p=0., float max_p=150.)
20{
73042f01 21 cerr<<"Displaying digits...\n";
cc80f89e 22
23// Connect the Root Galice file containing Geometry, Kine and Hits
106ea0fc 24 TFile *f = TFile::Open("rfio:galice.root");
73042f01 25 if (!f->IsOpen()) {cerr<<"Can't open galice.root !\n"; return 1;}
cc80f89e 26
a1d53143 27
28
c2b0eaa4 29 AliTPCParam *par=(AliTPCParam *)f->Get("75x40_100x60_150x60");
30 if (!par) { cerr<<"TPC parameters have not been found !\n"; return 2; }
cc80f89e 31
c2b0eaa4 32 Char_t s[80];
cc80f89e 33 sprintf(s,"Sector %d Row %d\n",sec,row);
34 TH2F *h = new TH2F("h",s,max_t_chan,min_t,max_t,max_p_chan,min_p,max_p);
a1d53143 35
c2b0eaa4 36 Char_t name[100];
37 sprintf(name,"TreeD_75x40_100x60_150x60_%d",eventn);
cc80f89e 38
a1d53143 39 TTree *t=(TTree*)f->Get(name);
c2b0eaa4 40 if (!t) { cerr<<"TPC digits have not been found !\n"; return 3; }
cc80f89e 41 AliSimDigits dummy, *digit=&dummy;
42 t->GetBranch("Segment")->SetAddress(&digit);
c2b0eaa4 43 Int_t sbr=(Int_t)t->GetEntries();
44 for (Int_t i=0; i<sbr; i++) {
45 if (!t->GetEvent(i)) continue;
46 Int_t s,r;
47 par->AdjustSectorRow(digit->GetID(),s,r);
48 if (s==sec && r==row) goto ok;
cc80f89e 49 }
c2b0eaa4 50 return 4;
51
cc80f89e 52ok:
c2b0eaa4 53
54 Int_t imax=0, jmax=0, qmax=0;
cc80f89e 55 digit->First();
56 do {
c2b0eaa4 57 //Short_t dig=digit->CurrentDigit();
58 Int_t i=digit->CurrentRow(), j=digit->CurrentColumn();
59 Short_t dig=digit->GetDigit(i,j);
cc80f89e 60 if (lab >= 0) {
c2b0eaa4 61 Int_t lab0=digit->GetTrackID(i,j,0);
62 Int_t lab1=digit->GetTrackID(i,j,1);
63 Int_t lab2=digit->GetTrackID(i,j,2);
cc80f89e 64 if (lab0!=lab) if (lab1!=lab) if (lab2!=lab) continue;
65 if (dig>qmax) {imax=i; jmax=j; qmax=dig;}
66 cerr<<lab0<<' '<<lab1<<' '<<lab2<<endl;
67 }
68 h->Fill(i,j,dig);
69 } while (digit->Next());
73042f01 70 if (qmax>0){cerr<<"Peak (time,pad,q) : "<<imax<<' '<<jmax<<' '<<qmax<<endl;}
cc80f89e 71
72 h->SetMaximum(100);
73 gStyle->SetOptStat(0);
73042f01 74 TCanvas *c1=new TCanvas("ddisplay","TPC digits display",0,0,1110,680);
cc80f89e 75 TPad *p1=new TPad("p1","",0,0,1,0.5);
76 p1->Draw();
77 TPad *p2=new TPad("p2","",0,0.5,1,1);
78 p2->Draw();
79 p2->cd();
73042f01 80 h->DrawCopy("lego");
cc80f89e 81 p1->cd();
73042f01 82 h->DrawCopy("colz");
83
84 c1->Modified(); c1->Update();
85
86 f->Close();
87 return 0;
cc80f89e 88}
89