source: branches/Mars_McMismatchStudy/macros/tutorials/pedvsevent.C@ 19116

Last change on this file since 19116 was 7159, checked in by tbretz, 19 years ago
*** empty log message ***
File size: 5.7 KB
Line 
1
2/////////////////////////////////////////////////////////////////////////////
3// //
4// Author(s): S.C. Commichau, Javier Rico, 12/2003 //
5// //
6// Macro to generate pedestal vs time (event) plot for a single pixel //
7// //
8/////////////////////////////////////////////////////////////////////////////
9
10
11const Int_t default_pixel = 1 ;
12
13void pedvsevent(Int_t pixel = default_pixel,
14 TString pname = "/disc02/Data/rootdata/Miscellaneous/2003_11_29/20031128_03118_P_Park-camera-closed_E.root")
15{
16
17 TH1F* Pedestal = new TH1F("Pedestal","Pedestals",100,0,20);
18 TH1F* PedestalRMS = new TH1F("PedestalRMS","Pedestal RMS",100,0,10);
19
20 //Create an empty parameter list and an empty task list
21 //the tasklist is identified in the eventloop by ist name
22 MParList plist;
23 MTaskList tlist;
24
25 //Creates a MPedestalPix object for each pixel, i.e. it is a
26 //storage container for all Pedestal information in the camera
27 MPedestalCam cam;
28
29 plist.AddToList(&cam);
30
31 //MHCamEvent hist;
32 //hist.SetType(1);
33 //plist.AddToList(&hist);
34
35 plist.AddToList(&tlist);
36
37 //Setup task and tasklist for the pedestals
38 MReadMarsFile read("Events", pname);
39 read.DisableAutoScheme();
40
41 //Apply the geometry to geometry dependant containers.
42 //MGeomApply changes the size of the arrays in the containers to a size
43 //matching the number of pixels, eg: MPedestalCam, MBlindPixels
44 //Default geometry is MGeomCamMagic
45 MGeomApply geomapl;
46
47 //Task to calculate pedestals
48 MPedCalcPedRun ped;
49
50 tlist.AddToList(&read);
51 tlist.AddToList(&geomapl);
52 tlist.AddToList(&ped);
53
54 //ped.SetPixel(pixel);
55 //ped.Draw();
56
57 //Create and setup the 1st Eventloop
58 MEvtLoop evtloop;
59 evtloop.SetParList(&plist);
60
61 //Execute first analysis, pedestals...
62 if (!tlist.PreProcess(&plist))
63 return;
64
65 const Int_t nevents = read.GetEntries();
66
67 Float_t x[nevents], rms[nevents], mean[nevents];
68
69
70 Int_t i = 0;
71 while (tlist.Process())
72 {
73 mean[i] = cam[pixel].GetPedestal();
74 rms[i] = cam[pixel].GetPedestalRms();
75 x[i] = i;
76 i++;
77 }
78
79 TGraphErrors* pedgraph = new TGraphErrors(nevents,x,mean,NULL,NULL);
80 TGraphErrors* rmsgraph = new TGraphErrors(nevents,x,rms,NULL,NULL);
81
82 //plist.FindObject("MPedestalCam")->Print();
83
84 tlist.PostProcess();
85 //if (!evtloop.Eventloop())
86 // return;
87
88 Float_t finalmean = cam[pixel].GetPedestal();
89 Float_t finalrms = cam[pixel].GetPedestalRms();
90
91 TLine* pedline = new TLine(0,finalmean,nevents,finalmean);
92 TLine* rmsline = new TLine(0,finalrms,nevents,finalrms);
93
94 //The draw area
95
96
97
98 gROOT->Reset();
99 gStyle->SetOptStat(0);
100 // Set statistics options, 1111111
101 // |||||||
102 // ||||||histogram name
103 // |||||number of entries
104 // ||||mean value
105 // |||RMS
106 // ||underflows
107 // |overflows
108 // sum of bins
109
110 // Set gPad options
111 gStyle->SetFrameBorderMode(0);
112 gStyle->SetPalette(1);
113 // Delete Frames of subCanvas' does not work, hook it Mr. gPad!
114 gStyle->SetFrameBorderSize(0);
115 gStyle->SetCanvasColor(0);
116 gStyle->SetFrameFillColor(0);
117 gStyle->SetTitleFont(102);
118 gStyle->SetTitleFillColor(0);
119 gStyle->SetTitleBorderSize(0);
120 gStyle->SetStatColor(0);
121 gStyle->SetStatBorderSize(0);
122
123 // Set Canvas options
124 TCanvas *MyC1 = new TCanvas("MyC","Pedestal vs Event", 0, 100, 900, 500);
125 MyC->SetBorderMode(0); // Delete the Canvas' border line
126
127 MyC->cd();
128 gPad->SetBorderMode(0);
129
130 // TLine* pedline = new TLine(0,finalmean,nevents,finalmean);
131 //TLine* rmsline = new TLine(0,finalrms,nevents,finalrms);
132
133 tlist.PrintStatistics();
134 //plist.FindObject("MPedestalCam")->Print();
135 Size_t pos = pname.Last('/')+10;
136 TString iRun = TString(pname(pos,5));
137
138 char str[64];
139
140 sprintf(str,"Run %s Pixel %d",iRun.Data(),pixel);
141
142 pedgraph->SetMaximum(30);
143 pedgraph->SetMinimum(0);
144 pedgraph->SetMarkerStyle(24);
145 pedgraph->SetMarkerSize(.5);
146 pedgraph->GetXaxis()->SetTitleFont(102);
147 pedgraph->GetYaxis()->SetTitleFont(102);
148 pedgraph->GetXaxis()->SetLabelFont(102);
149 pedgraph->GetYaxis()->SetLabelFont(102);
150 pedgraph->SetTitle(str);
151// pedgraph->SetTitleFont(102);
152 pedgraph->GetYaxis()->SetTitleFont(102);
153 pedgraph->GetXaxis()->SetTitle("Event");
154 pedgraph->GetYaxis()->SetTitle("[FADC Counts]");
155 pedgraph->GetXaxis()->SetLimits(0,nevents-1);
156
157 rmsgraph->SetMarkerStyle(25);
158 rmsgraph->SetMarkerSize(.5);
159 rmsgraph->SetMarkerColor(8);
160
161 pedline->SetLineColor(2);
162 rmsline->SetLineColor(4);
163 pedline->SetLineWidth(2);
164 rmsline->SetLineWidth(2);
165
166 pedgraph->Draw("AP");
167 rmsgraph->Draw("P");
168
169 pedline->Draw("same");
170 rmsline->Draw("same");
171
172 TLegend* leg = new TLegend(.14,.68,.39,.88);
173 leg->SetHeader("");
174 leg->AddEntry(pedgraph,"Event based Pedestal","P");
175 leg->AddEntry(pedline,"Run based Pedestal","L");
176 leg->AddEntry(rmsgraph,"Event based RMS","P");
177 leg->AddEntry(rmsline,"Run based RMS","L");
178 leg->SetFillColor(0);
179 leg->SetLineColor(1);
180 leg->SetBorderSize(1);
181
182
183 leg->Draw("same");
184}
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
Note: See TracBrowser for help on using the repository browser.