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