T0 DAs + enable optimization for ITS
[u/mrichter/AliRoot.git] / ITS / AliITSDigitPlot.C
CommitLineData
97835629 1//
2
3#if !defined(__CINT__) || defined(__MAKECINT__)
4 #include <Riostream.h>
5 #include <TClassTable.h>
6 //#include <fstream.h>
7
8 #include "TH2.h"
9 #include "TFile.h"
10 #include "TKey.h"
11 #include "TObjArray.h"
12 #include "TStyle.h"
13 #include "TCanvas.h"
14 #include "TLine.h"
15 #include "TText.h"
16 #include "TParticle.h"
17 #include "TStopwatch.h"
18 #include "TPDGCode.h"
19
20 #include "AliRun.h"
21 #include "AliESD.h"
22 #include "AliCascadeVertex.h"
23
24 #include "AliMC.h"
25 #include "AliHeader.h"
26 #include "AliConfig.h"
27 #include "AliRunLoader.h"
28 #include "AliITSLoader.h"
29 #include "AliITS.h"
30 #include "AliITSdigit.h"
31 #include "AliITSgeom.h"
32#endif
33
34 const Int_t ndets=5;
35 TH2I *BeamSpot[ndets];
36//----------------------------------------------------------------------
37void SetUPHistograms(){
38 // Define the histograms to be filled
39 Int_t i;
40 Char_t name[10],title[50];
41
42 for(i=0;i<ndets;i++){
43 sprintf(name,"BeamSpot%d",i);
44 sprintf(title,"Beam Spot for SPD %d detectors row-column values",i);
45 BeamSpot[i] = new TH2I(name,title,256,0.,256.,160,0.,160.);
46 } // end for i
47}
48//----------------------------------------------------------------------
49void FillHistograms(Int_t module,Int_t row,Int_t colm,Int_t signal){
50 // Fill the histograms
51
52 if(module<0 || module>=ndets) return;
53 BeamSpot[module]->Fill((Double_t) row,(Double_t) colm,(Double_t) signal);
54}
55//----------------------------------------------------------------------
56void DisplayHistograms(){
57 // Display the histograms
58
59 TCanvas *c0 = new TCanvas("c0","SPD Digits",400,10,600,700);
60 BeamSpot[2]->Draw();
61}
62//----------------------------------------------------------------------
63void AliITSDigitPlot(Int_t istart=0,Int_t iend=-1,
64 const char *filename="galice.root"){
65 // Macro to plot digits from many events
66 // Inputs:
67 // Int_t istart Starting event number
68 // Int_t iend Last event number, =-1 all
69 // Outputs:
70 // none.
71 // Return:
72 // none.
73 if (gClassTable->GetID("AliRun") < 0) {
74 gROOT->ProcessLine(".x $(ALICE_ROOT)/macros/loadlibs.C");
75 }
76 if(gAlice){
33c3c91a 77 delete AliRunLoader::Instance();
97835629 78 delete gAlice;
79 gAlice=0;
80 } // end if gAlice
81
82 Int_t nevents=0,nmodules=0,retval=0;
83 Int_t i,j,module,dig,ndig,row,column,signal,det;
84 AliITS *its = 0;
85 AliITSgeom *gm = 0;
86 AliRunLoader *rl = 0;
87 AliITSLoader *ld = 0;
88 TTree *treeD = 0;
89 TBranch *br = 0;
90 TClonesArray *digits = 0;
91 AliITSdigit *d = 0;
92 TObjArray *digDet = 0;
93 Char_t *branchname[3] = {"ITSDigitsSPD","ITSDigitsSDD","ITSDigitsSSD"};
94 //
95 rl = AliRunLoader::Open(filename);
96 if(!rl){
97 cerr<<"Error, can not open file "<<filename<<endl;
98 return;
99 } // end if !rl
100 retval = rl->LoadgAlice();
101 if (retval){
102 cerr<<"Error, LoadgAlice returned error"<<endl;
103 return;
104 }
105 gAlice = rl->GetAliRun();
106 retval = rl->LoadHeader();
107 if (retval){
108 cerr<<"Error, LoadHeader returned error"<<endl;
109 return;
110 } // end if
111 ld = (AliITSLoader*) rl->GetLoader("ITSLoader");
112 if(!ld){
113 cerr<<"Error, ITS loader not found"<<endl;
114 return;
115 } // end if
116 its = (AliITS*) gAlice->GetModule("ITS");
117 if(!its){
118 cerr <<"Error, No AliDetector ITS found on file"<<endl;
119 return;
120 } // end if
121 gm = its->GetITSgeom();
122 if(!gm){
123 cerr <<"Error, AliITSgeom not initilized in module ITS"<<endl;
124 return;
125 } // end if
126 nevents = rl->GetNumberOfEvents();
127 if(iend>nevents) iend = nevents;
128 if(iend<0) iend = nevents;
129 if(iend<=istart){delete rl; return;}
130 nmodules = gm->GetIndexMax();
131 ld->GetDigitsDataLoader()->Load("read");
132 treeD = ld->TreeD();
133 if(!treeD){
134 cerr <<"Error, could not get TreeD="<<treeD << endl;
135 return;
136 } // end if !treeD
137 digDet = new TObjArray(3);
7d62fb64 138 its->SetDefaults();
97835629 139 for(det=0;det<3;det++){
7d62fb64 140 digDet->AddAt(new TClonesArray(its->GetDetTypeSim()->
141 GetDigitClassName(det),1000),det);
97835629 142 br = treeD->GetBranch(branchname[det]);
143 br->SetAddress(&((*digDet)[det]));
144 } // end for det
145
146 //
147 SetUPHistograms();
148 //
149 for(i=istart;i<iend;i++){
150 rl->GetEvent(i);
151 treeD = ld->TreeD();
152 for(det=0;det<3;det++){
153 ((TClonesArray*)(digDet->At(det)))->Clear();
154 br = treeD->GetBranch(branchname[det]);
155 br->SetAddress(&((*digDet)[det]));
156 } // end for det
157 for(module=0;module<nmodules;module++){
158 for(j=0;j<3;j++) ((TClonesArray*)(digDet->At(j)))->Clear();
159 treeD->GetEvent(module);
160 digits = (TClonesArray*) (digDet->At(0)); // SPD only.
161 ndig = digits->GetEntriesFast();
162 for(dig=0;dig<ndig;dig++){
163 d = (AliITSdigit*) digits->At(dig);
164 row = d->GetCoord1();
165 column = d->GetCoord1();
166 signal = d->GetSignal();
167 //cout <<"event="<<i<< " ndig="<< ndig<< " mod="
168 //<<module<<" row="<<row<<" col="<<column<< " sig="
169 //<<signal<<endl;
170 FillHistograms(module,row,column,signal);
171 } // end for mod
172 } // end for module
173 } // end for i
174 DisplayHistograms();
175 delete digits;
176 return;
177}