/[PAMELA software]/calo/flight/CaloViewer/src/CaloViewer.cpp
ViewVC logotype

Contents of /calo/flight/CaloViewer/src/CaloViewer.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Fri Jun 12 14:03:50 2009 UTC (15 years, 5 months ago) by mocchiut
Branch: CaloViewer, MAIN
CVS Tags: start, v1r00, HEAD
Changes since 1.1: +0 -0 lines
Porting of CaloMatra to a library for the EV

1 #include <CaloViewer.h>
2
3 //--------------------------------------
4 /**
5 * Default constructor
6 */
7 CaloViewer::CaloViewer(){
8 Clear();
9 };
10
11 CaloViewer::CaloViewer(PamLevel2 *l2p){
12 //
13 Clear();
14 //
15 L2 = l2p;
16 debug = false;
17 //
18 };
19
20 void CaloViewer::Clear(){
21 //
22 };
23
24 void CaloViewer::Print(){
25 //
26 };
27
28 void CaloViewer::Delete(){
29 Clear();
30 };
31
32 void ColorMIP(Float_t mip, int& colo){
33 // printf("mip = %f \n",mip);
34 if ( colo > 0 ){
35 colo = 10;
36 if ( mip > 0.7 ) colo = 38;
37 if ( mip > 2. ) colo = 4;
38 if ( mip > 10. ) colo = 3;
39 if ( mip > 100. ) colo = 2;
40 if ( mip > 500. ) colo = 6;
41 } else {
42 colo = 10;
43 if ( mip > 0.7 ) colo = 17;
44 if ( mip > 2. ) colo = 15;
45 if ( mip > 10. ) colo = 14;
46 if ( mip > 100. ) colo = 13;
47 if ( mip > 500. ) colo = 12;
48 };
49 }
50
51 void CaloViewer::Draw(TString type){
52 //
53 //
54 gStyle->SetLabelSize(0.04);
55 gStyle->SetNdivisions(510,"XY");
56 //
57 TCanvas *cview = 0;
58 cview = dynamic_cast<TCanvas*>(gDirectory->FindObject("cview"));
59 if ( !cview ){
60 cview = new TCanvas("Calorimeter viewer","Calorimeter viewer",850,950);
61 cview->SetFillColor(10);
62 cview->Range(0,0,100,100);
63 };
64 //
65 if ( debug ) printf(" Processing event \n");
66 //
67 Clear();
68 //
69 cview->Clear();
70 gPad->SetFrameBorderMode(0);
71 //
72 stringstream xview;
73 stringstream yview;
74 //
75 // figures:
76 //
77 Float_t paddim = 0.88;
78 Int_t bgcolor = 10;
79 xview.str("");
80 xview << "cv x-view event ";
81 yview.str("");
82 yview << "cv y-view event ";
83 gDirectory->Delete(xview.str().c_str());
84 gDirectory->Delete(yview.str().c_str());
85 TH2F *Xview = new TH2F(xview.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
86 TH2F *Yview = new TH2F(yview.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
87 //
88 if ( !strcmp(type.Data(),"lego") ){
89 paddim = 0.98;
90 } else {
91 paddim = 0.88;
92 };
93 gDirectory->Delete("cvpd1");
94 gDirectory->Delete("cvpd2");
95 gDirectory->Delete("cvpalette");
96 TPad *pd1 = new TPad("cvpd1","This is pad1",0.02,0.05,paddim,0.49,bgcolor);
97 TPad *pd2 = new TPad("cvpd2","This is pad2",0.02,0.51,paddim,0.95,bgcolor);
98 TPad *palette = 0;
99 cview->cd();
100 pd1->Range(0,0,100,100);
101 pd2->Range(0,0,100,100);
102 pd1->SetTicks();
103 pd2->SetTicks();
104 pd1->Draw();
105 pd2->Draw();
106 if ( !strcmp(type.Data(),"box") ){
107 palette = new TPad("cvpalette","This is palette",0.90,0.05,0.98,0.9,bgcolor);
108 cview->cd();
109 if ( dynamic_cast<TLatex*>(gDirectory->FindObject("t")) ) dynamic_cast<TLatex*>(gDirectory->FindObject("t"))->Delete();
110 TLatex *t=new TLatex();
111 t->SetTextFont(32);
112 t->SetTextColor(1);
113 t->SetTextSize(0.03);
114 t->SetTextAlign(12);
115 t->DrawLatex(92.,92.5,"MIP");
116 palette->Range(0,0,100,100);
117 palette->Draw();
118 palette->cd();
119 // palette
120 if ( dynamic_cast<TPaveLabel*>(gDirectory->FindObject("box1")) ) dynamic_cast<TPaveLabel*>(gDirectory->FindObject("box1"))->Delete();
121 TPaveLabel *box1 = new TPaveLabel(2,2,98,16.3,"0","");
122 box1->SetTextFont(32);
123 box1->SetTextColor(1);
124 box1->SetTextSize(0.25);
125 box1->SetFillColor(10);
126 box1->Draw();
127 if ( dynamic_cast<TPaveLabel*>(gDirectory->FindObject("box2")) ) dynamic_cast<TPaveLabel*>(gDirectory->FindObject("box2"))->Delete();
128 TPaveLabel *box2 = new TPaveLabel(2,18.3,98,32.66,"0-2","");
129 box2->SetTextFont(32);
130 box2->SetTextColor(1);
131 box2->SetTextSize(0.25);
132 box2->SetFillColor(38);
133 box2->Draw();
134 if ( dynamic_cast<TPaveLabel*>(gDirectory->FindObject("box3")) ) dynamic_cast<TPaveLabel*>(gDirectory->FindObject("box3"))->Delete();
135 TPaveLabel *box3 = new TPaveLabel(2,34.66,98,48.96,"2-10","");
136 box3->SetTextFont(32);
137 box3->SetTextColor(1);
138 box3->SetTextSize(0.25);
139 box3->SetFillColor(4);
140 box3->Draw();
141 if ( dynamic_cast<TPaveLabel*>(gDirectory->FindObject("box4")) ) dynamic_cast<TPaveLabel*>(gDirectory->FindObject("box4"))->Delete();
142 TPaveLabel *box4 = new TPaveLabel(2,50.96,98,65.26,"10-100","");
143 box4->SetTextFont(32);
144 box4->SetTextColor(1);
145 box4->SetTextSize(0.25);
146 box4->SetFillColor(3);
147 box4->Draw();
148 if ( dynamic_cast<TPaveLabel*>(gDirectory->FindObject("box5")) ) dynamic_cast<TPaveLabel*>(gDirectory->FindObject("box5"))->Delete();
149 TPaveLabel *box5 = new TPaveLabel(2,67.26,98,81.56,"100-500","");
150 box5->SetTextFont(32);
151 box5->SetTextColor(1);
152 box5->SetTextSize(0.2);
153 box5->SetFillColor(2);
154 box5->Draw();
155 if ( dynamic_cast<TPaveLabel*>(gDirectory->FindObject("box6")) ) dynamic_cast<TPaveLabel*>(gDirectory->FindObject("box6"))->Delete();
156 TPaveLabel *box6 = new TPaveLabel(2,83.56,98,97.86,">500","");
157 box6->SetTextFont(32);
158 box6->SetTextColor(1);
159 box6->SetTextSize(0.25);
160 box6->SetFillColor(6);
161 box6->Draw();
162 };
163 cview->cd();
164 if ( type == "box" ) {
165 pd2->cd();
166 gStyle->SetOptStat(0);
167 Xview->SetXTitle("strip");
168 Xview->SetYTitle("X - plane");
169 Xview->GetYaxis()->SetTitleOffset(0.5);
170 Xview->SetFillColor(bgcolor);
171 Xview->Fill(1.,1.,1.);
172 Xview->Draw(type);
173 pd2->Update();
174 pd1->cd();
175 gStyle->SetOptStat(0);
176 Yview->SetXTitle("strip");
177 Yview->SetYTitle("Y - plane");
178 Yview->GetYaxis()->SetTitleOffset(0.5);
179 Yview->SetFillColor(bgcolor);
180 Yview->Fill(1.,1.,1.);
181 Yview->Draw(type);
182 pd1->Update();
183 };
184 //
185 // run over views and planes
186 //
187 Int_t m = 0;
188 Int_t l = 0;
189 Int_t n = 0;
190 Float_t mip = 0.;
191 for (Int_t i=0; i<L2->GetCaloLevel1()->istrip; i++){
192 mip = L2->GetCaloLevel1()->DecodeEstrip(i,l,m,n);
193 if ( l == 1 ) n = 95-n;
194 m = 21-m;
195 //
196 // OK, now in estrip we have the energy deposit in MIP of all the strips for this event (at the end of loops of course)
197 //
198 if ( type == "box" ){
199 xview.str("");
200 xview << "cv x-view event " << n;
201 xview << " " << m;
202 xview << " " << l;
203 yview.str("");
204 yview << "cv y-view event " << n;
205 yview << " " << m;
206 yview << " " << l;
207 gDirectory->Delete(xview.str().c_str());
208 gDirectory->Delete(yview.str().c_str());
209 TH2F *Xview = new TH2F(xview.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
210 TH2F *Yview = new TH2F(yview.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
211 // TH2F *Yview = new TH2F(yview.str().c_str(),"",96,-0.5,95.5,22,21.5,-0.5);
212 Int_t colo;
213 ColorMIP(mip,colo);
214 Xview->SetFillColor(colo);
215 Yview->SetFillColor(colo);
216 if ( l == 0 ) {
217 Xview->Fill(n,m,1.);
218 pd2->cd();
219 Xview->Draw("box same");
220 };
221 if ( l == 1 ) {
222 Yview->Fill(n,m,1.);
223 pd1->cd();
224 Yview->Draw("box same");
225 };
226 } else {
227 if ( l == 0 ) Xview->Fill(n,m,mip);
228 if ( l == 1 ) Yview->Fill(n,m,mip);
229 };
230 };
231 //
232 if ( type == "lego" ){
233 pd2->cd();
234 gStyle->SetOptStat(0);
235 Xview->SetXTitle("strip");
236 Xview->SetYTitle("X - plane");
237 Xview->GetXaxis()->SetTitleOffset(1.5);
238 Xview->GetYaxis()->SetTitleOffset(1.5);
239 Xview->SetZTitle("MIP");
240 Xview->Draw(type);
241 pd2->Update();
242 pd1->cd();
243 gStyle->SetOptStat(0);
244 Yview->SetXTitle("strip");
245 Yview->SetYTitle("Y - plane");
246 Yview->GetXaxis()->SetTitleOffset(1.5);
247 Yview->GetYaxis()->SetTitleOffset(1.5);
248 Yview->SetZTitle("MIP");
249 Yview->Draw(type);
250 pd1->Update();
251 };
252 pd2->Update();
253 pd1->Update();
254 cview->cd();
255 cview->Update();
256 //
257 //
258 gStyle->SetLabelSize(0);
259 gStyle->SetNdivisions(1,"XY");
260 //
261 //
262 };

  ViewVC Help
Powered by ViewVC 1.1.23