]> git.uio.no Git - u/mrichter/AliRoot.git/blame - test/vmctest/scripts/plotDigits.C
Update master to aliroot
[u/mrichter/AliRoot.git] / test / vmctest / scripts / plotDigits.C
CommitLineData
0866e534 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16// $Id$
17
18// Macro to process the files with histograms generated by
19// digitsDET.C macros for all included detectors and to produce plots
20// with histograms.
21// The histogram files are aerched in the directories,
22// which names are specified in label[] array;
23// the labels will be then used at the histogram titles.
24//
25// By E. Sicking, CERN; I. Hrivnacova, IPN Orsay
26
27void plotDetDigits(string a = "ITS", string b = "")
28{
29 string label[10];
30 string histoName[10];
31 string histoTitle[10];
32 TFile* file[10];
33 Int_t color[10];
34 TH1F* histo[10][10];
35
36 // Fill values by hand
37 //
38 Int_t ndirs = 3;
39 Int_t nhistos = 2;
40
41 // Histogram labels (per directory)
42 label[0] = "g3";
43 label[1] = "g4_sc";
44 label[2] = "g4";
45
46 // Histogram names & title (per histogram)
47 histoName[0] = "hadc";
48 histoName[1] = "hadclog";
49 histoTitle[0] = "Number of ADC in ";
50 histoTitle[1] = "Log_{10}(Number of ADC in ";
51
52 // The histogram colors (per directory)
53 color[0] = kBlack;
54 color[1] = kRed;
55 color[2] = kBlue;
56 //
57 // end hand made definitions
58
59 // generate detname
60 string detname = a;
61 if ( b.size() > 0 ) {
62 detname.append(".");
63 detname.append(b);
64 }
65
66 cout << "Processing " << detname << " ... " << endl;
67
68 // generate filename
69 string filename = "digits.";
70 filename.append(detname);
71 filename.append(".root");
72
73 // label for all histos
74 string labelall;
75 for ( Int_t i=0; i<ndirs; i++ ) {
76 labelall.append(label[i]);
77 if (i<ndirs-1) labelall.append("+");
78 }
79
80 // open files
81 for ( Int_t i=0; i<ndirs; i++ ) {
82 string filepath = label[i];
83 filepath.append("/");
84 filepath.append(filename);
85 file[i] = TFile::Open(filepath.data());
86 if ( ! file[i] ) {
87 cerr << "Cannot open " << file[i] << endl;
88 }
89 }
90
91 double scale=1.5;
92
93 //extract histograms
94 for ( Int_t j=0; j<nhistos; j++ ) {
95 for ( Int_t i=0; i<ndirs; i++ ) {
96 histo[i][j] = (TH1F *)file[i]->Get(histoName[j].data());
97 if ( ! histo[i][j] ) {
98 histo[i][j] = (TH1F *)file[i]->Get("hadcLog");
99 }
100 //histo[i][j]->SetLineWidth(3);
101 //histo[i][j]->SetLineStyle(3+i);
102 histo[i][j]->SetLineColor(color[i]);
103 //histo[i][j]->Sumw2();
104 }
105 }
106
107 // style & legend
108 gROOT->SetStyle("Plain");
109 //gStyle->SetOptStat(0);
110
111 // ???
112 TLegend *legp;
113 TF1 *fun1p;
114 TF1 *fun2p;
115 TF1 *fun3p;
116 legp= new TLegend(0.9,0.75,0.7,0.9);
117 fun1p= new TF1("fun1p","gaus",-5.0,5.0);
118 fun2p= new TF1("fun2p","gaus",-5.0,5.0);
119 fun3p= new TF1("fun3p","gaus",-5.0,5.0);
120 fun1p->SetLineColor(kBlue);
121 fun2p->SetLineColor(kRed);
122 fun2p->SetLineStyle(2);
123 fun3p->SetLineColor(kBlack);
124 fun3p->SetLineStyle(3);
125 legp->SetFillColor(kWhite);
126 legp->AddEntry(fun1p,"Geant3","l");
127 legp->AddEntry(fun2p,"Geant4","l");
128 legp->AddEntry(fun3p,"Fluka","l");
129
130 //Draw
131 TCanvas* c1
132 = new TCanvas (detname.data(), detname.data(), 100, 100, 1000,1560);
133 c1->Divide(nhistos, ndirs+1 );
134
135 // All plots
136 Int_t counter = 0;
137 for ( Int_t j=0; j<nhistos ; ++j ) {
138 c1->cd(++counter);
139 for ( Int_t i=0; i<ndirs; i++ ) {
140 histo[i][j]->SetTitle(labelall.data());
141 string xtitle = histoTitle[j];
142 xtitle.append(detname);
143 histo[i][j]->SetXTitle(xtitle.data());
144 string option("");
145 if ( i>0 ) option = "same";
146 histo[i][j]->Draw(option.data());
147 histo[i][j]->SetMaximum(histo[i][j]->GetMaximum()*scale);
148 //histo[i][j]->Sumw2();
149 gPad->SetLogy();
150 //legp->Draw();
151 }
152 }
153
154 // Plots per case
155 for ( Int_t i=0; i<ndirs; i++ ) {
156 for ( Int_t j=0; j<nhistos ; ++j ) {
157 c1->cd(++counter);
158 // gPad->SetLeftMargin(0.15);
159 // gPad->SetBottomMargin(0.15);
160 histo[i][j]->SetTitle(label[i].data());
161 string xtitle = histoTitle[j];
162 xtitle.append(detname);
163 histo[i][j]->SetXTitle(xtitle.data());
164 histo[i][j]->Draw("");
165 histo[i][j]->SetMaximum(histo[i][j]->GetMaximum()*scale);
166 //histo[i][j]->Sumw2();
167 gPad->SetLogy();
168 //legp->Draw();
169 }
170 }
171
172 string outName = detname;
173 outName += ".gif";
174 c1->SaveAs(outName.data());
175}
176
177void plotDigits() {
178 plotDetDigits("ITS","SDD");
179 plotDetDigits("ITS","SPD");
180 plotDetDigits("ITS","SSD");
181 plotDetDigits("TPC");
182 plotDetDigits("TRD");
183 plotDetDigits("TOF");
184 plotDetDigits("EMCAL");
185 plotDetDigits("HMPID");
186 plotDetDigits("PHOS");
187}