New START corrected for coding conventions
[u/mrichter/AliRoot.git] / START / readDigits.C
CommitLineData
ef51244a 1void readDigits(Int_t evNumber=1)
2{
3
4 // Dynamically link some shared libs
5 if (gClassTable->GetID("AliRun") < 0) {
6 gROOT->LoadMacro("loadlibs.C");
7 loadlibs();
8 }
9
10 // Connect the Root Galice file containing Geometry, Kine and Hits
11 TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
12 //TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
13 if (!file) file = new TFile("galice.root","UPDATE");
14
15 // Get AliRun object from file or create it if not on file
16 if (!gAlice) {
17 gAlice = (AliRun*)file->Get("gAlice");
18 if (gAlice) printf("AliRun object found on file\n");
19 if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
20 }
21 char nameTD[8],nameTR[8];
22
23 TH1F *hTimediff = new TH1F("hTimediff","Time difference",100,0,256);
24 TH1F *hTimePs = new TH1F("hTimePs","Time in Ps",100,-2000,2000);
25
26 digits = new AliSTARTdigit();
27 TBranch *bd;
28
29
30 // Event ------------------------- LOOP
31 for (j=0; j<evNumber; j++){
32 sprintf(nameTD,"TreeD%d",j);
33 printf("%s\n",nameTD);
34 TTree *TD = (TTree*)gDirectory->Get(nameTD);
35 bd = TD->GetBranch("START");
36 bd->SetAddress(&digits);
37 bd->GetEvent(0);
38 // printf(" Digits: %d \n ",digits->GetTime());
39
40 printf("time %d\n",digits->GetTime());
41
42 if(digits->GetTime()!=999999){
43 Int_t timediff = digits->GetTime();
44 Double_t timePs=(timediff-128)*10.; // time in Ps channel_width =10ps
45 // cout<<"timediff "<<timediff<<" timePs "<<timePs<<endl;
46 hTimediff->Fill(timediff);
47 hTimePs->Fill(timePs);
48 }
49 }
50
51 Hfile = new TFile("figs.root","UPDATE","Histograms for STASRT digits");
52 printf("Writting histograms to root file \n");
53 Hfile->cd();
54//Create a canvas, set the view range, show histograms
55 gStyle->SetOptStat(111111);
56 TCanvas *c1 = new TCanvas("c1","Alice START Time ",400,10,600,600);
57 hTimePs->SetXTitle("arriving time, ps");
58 hTimePs->SetYTitle("number of events");
59 hTimePs->Write();
60
61
62
63} // end of macro
64
65
66
67