source: trunk/MagicSoft/Mars/mtemp/mifae/programs/pedvsslices.cc@ 6724

Last change on this file since 6724 was 4016, checked in by rico, 21 years ago
*** empty log message ***
File size: 6.8 KB
Line 
1#include "TString.h"
2#include "TMultiGraph.h"
3#include "TGraphErrors.h"
4#include "TStyle.h"
5#include "TCanvas.h"
6#include "TLegend.h"
7
8#include "MParList.h"
9#include "MTaskList.h"
10#include "MReadMarsFile.h"
11#include "MGeomApply.h"
12#include "MEvtLoop.h"
13#include "MPedCalcPedRun.h"
14#include "MPedestalCam.h"
15#include "MPedestalPix.h"
16
17#include <iostream>
18#include <fstream>
19#include <stdlib.h>
20
21using namespace std;
22
23
24const UInt_t nmaxslice = 30;
25const UInt_t step = 2;
26
27void pedvsslices2(TString pedname);
28
29int main()
30//void pedvsslices()
31{
32 pedvsslices2("~markus/Magic/Soft/Mars/20040303_20123_P_NewCalBoxTestLidOpen_E.root");
33}
34
35void pedvsslices2(TString pedname)
36{
37 const Int_t nbad = 22;
38 Int_t bad[nbad]={0,10,47,54,124,125,159,162,222,300,388,395,464,558,559,543,89,510,576,459,550,561};
39
40 static const UInt_t rnmax = (nmaxslice/step)*step;
41 static const UInt_t nslices = rnmax/step;
42 static const UInt_t nloops = rnmax*(rnmax-step+2)/(2*step);
43
44 cout << "nslices = " << nslices << endl;
45
46 // general settings
47 gStyle->SetCanvasColor(0);
48 gStyle->SetStatColor(0);
49 gStyle->SetStatBorderSize(1);
50 gStyle->SetMarkerSize(0.6);
51 gStyle->SetPadBorderMode(0);
52
53 // Define the graphs and their atributes
54 TGraphErrors grmeanIn[nslices];
55 TGraphErrors grrmsIn[nslices];
56 TGraphErrors grmeanOut[nslices];
57 TGraphErrors grrmsOut[nslices];
58
59 // Null graph to adjust plot limits
60 Float_t nullx[rnmax+1];
61 Float_t nullyM[rnmax+1];
62 Float_t nullyR[rnmax+1];
63 for(UInt_t i=0;i<=rnmax;i++)
64 {
65 nullx[i]=(Float_t)i;
66 nullyM[i]=9+2./rnmax*i;
67 nullyR[i]=3.5+5./rnmax*i;
68 }
69 TGraph grnullM(rnmax+1,nullx,nullyM);
70 TGraph grnullR(rnmax+1,nullx,nullyR);
71 grnullM.SetMarkerSize(0);
72 grnullR.SetMarkerSize(0);
73 grnullM.SetMarkerColor(0);
74 grnullR.SetMarkerColor(0);
75 grnullM.GetXaxis()->SetTitle("First used time slice");
76 grnullR.GetXaxis()->SetTitle("First used time slice");
77 grnullM.GetYaxis()->SetTitle("Average Pedestal mean (ADC cnts)");
78 grnullR.GetYaxis()->SetTitle("Average Pedestal rms (ADC cnts)");
79
80 for(UInt_t i=0;i<nslices;i++)
81 {
82 grmeanIn[i].SetMarkerColor(i%9+1);
83 grrmsIn[i].SetMarkerColor(i%9+1);
84 grmeanOut[i].SetMarkerColor(i%9+1);
85 grrmsOut[i].SetMarkerColor(i%9+1);
86
87 grmeanIn[i].SetMarkerStyle(20+i%19+1);
88 grrmsIn[i].SetMarkerStyle(20+i%19+1);
89 grmeanOut[i].SetMarkerStyle(20+i%19+1);
90 grrmsOut[i].SetMarkerStyle(20+i%19+1);
91 }
92
93
94 // Fill the graphs
95 UInt_t islice=0;
96 UInt_t fslice=step-1;
97 for(UInt_t i=0;i<nloops;i++)
98 {
99 MParList plist;
100 MTaskList tlist;
101 MPedestalCam pedcam;
102
103 plist.AddToList(&tlist);
104 plist.AddToList(&pedcam);
105
106 MReadMarsFile read("Events", pedname);
107 read.DisableAutoScheme();
108 MGeomApply geomapl;
109 MPedCalcPedRun pedcalc;
110 cout << "Checking slices from " << islice << " to " << fslice << endl;
111 pedcalc.SetRange(islice,fslice,0,0);
112 pedcalc.SetWindowSize(fslice-islice+1);
113
114 tlist.AddToList(&read);
115 tlist.AddToList(&geomapl);
116 tlist.AddToList(&pedcalc);
117
118 MEvtLoop evtloop;
119 evtloop.SetParList(&plist);
120 if (!evtloop.Eventloop())
121 return;
122
123 // compute the pedestal mean and rms averaged in the camera
124 Float_t meansumIn =0;
125 Float_t meansum2In=0;
126 Float_t rmssumIn =0;
127 Float_t rmssum2In =0;
128 Float_t meansumOut =0;
129 Float_t meansum2Out=0;
130 Float_t rmssumOut =0;
131 Float_t rmssum2Out =0;
132
133 const Int_t ninn = 397;
134 Int_t rninn=0;
135 Int_t rnout=0;
136 for(Int_t j=0;j<pedcam.GetSize();j++)
137 {
138 // skip bad pixels from list above
139 Bool_t isBad=kFALSE;
140 for(Int_t k=0;k<nbad;k++)
141 if(bad[k]==j)
142 {
143 isBad=kTRUE;
144 break;
145 }
146 if(isBad)
147 continue;
148
149 // keep the sum of values and of squares
150 Float_t ped = pedcam[j].GetPedestal();
151 Float_t rms = pedcam[j].GetPedestalRms();
152 if(j<ninn)
153 {
154 meansumIn+= ped;
155 meansum2In+=ped*ped;
156 rmssumIn+=rms;
157 rmssum2In+=rms*rms;
158 rninn++;
159 }
160 else
161 {
162 meansumOut+= ped;
163 meansum2Out+=ped*ped;
164 rmssumOut+=rms;
165 rmssum2Out+=rms*rms;
166 rnout++;
167 }
168 }
169
170 Float_t avmeanIn = meansumIn/rninn;
171 Float_t sigmeanIn = (meansum2In-meansumIn*meansumIn/rninn)/(rninn-1);
172 Float_t avrmsIn = rmssumIn/rninn;
173 Float_t sigrmsIn = (rmssum2In-rmssumIn*rmssumIn/rninn)/(rninn-1);
174
175 Float_t avmeanOut = meansumOut/rnout;
176 Float_t sigmeanOut = (meansum2Out-meansumOut*meansumOut/rnout)/(rnout-1);
177 Float_t avrmsOut = rmssumOut/rnout;
178 Float_t sigrmsOut = (rmssum2Out-rmssumOut*rmssumOut/rnout)/(rnout-1);
179
180 // save the values into the graphs
181 grmeanIn[(fslice-islice+1)/step-1].SetPoint(islice,islice,avmeanIn);
182 grmeanIn[(fslice-islice+1)/step-1].SetPointError(islice,0,sigmeanIn/rninn);
183 grmeanOut[(fslice-islice+1)/step-1].SetPoint(islice,islice,avmeanOut);
184 grmeanOut[(fslice-islice+1)/step-1].SetPointError(islice,0,sigmeanOut/rnout);
185
186 grrmsIn[(fslice-islice+1)/step-1].SetPoint(islice,islice,avrmsIn);
187 grrmsIn[(fslice-islice+1)/step-1].SetPointError(islice,0,sigrmsIn/rninn);
188 grrmsOut[(fslice-islice+1)/step-1].SetPoint(islice,islice,avrmsOut);
189 grrmsOut[(fslice-islice+1)/step-1].SetPointError(islice,0,sigrmsOut/rnout);
190
191 // compute next initial and final slice values
192 islice++;
193 fslice++;
194 if(fslice>=nmaxslice)
195 {
196 fslice=fslice-islice+step;
197 islice=0;
198 }
199 }
200
201 TCanvas* myC = new TCanvas("myC","pedestal studies",900,1250);
202 myC->Divide(2,2);
203
204 TLegend* leg1 = new TLegend(.2,.2,.4,.5);
205 TLegend* leg2 = new TLegend(.44,.2,.88,.5);
206 leg1->SetEntrySeparation(0.1);
207 leg1->SetHeader("");
208 leg2->SetEntrySeparation(0.1);
209 leg2->SetHeader("");
210
211 myC->cd(1);
212 grnullM.SetTitle("Average pedestal mean for inner pixels");
213 grnullM.DrawClone("AP");
214 for(UInt_t i=0;i<nslices;i++)
215 {
216 grmeanIn[i].DrawClone("P");
217 char leglab[100];
218 sprintf(leglab,"%d slices",(i+1)*step);
219 if(i<nslices/2)
220 leg1->AddEntry(&grmeanIn[i],leglab,"p");
221 else
222 leg2->AddEntry(&grmeanIn[i],leglab,"p");
223 }
224 leg1->SetFillColor(0);
225 leg1->SetLineColor(0);
226 leg1->SetBorderSize(0);
227 leg1->Draw();
228 leg2->SetFillColor(0);
229 leg2->SetLineColor(0);
230 leg2->SetBorderSize(0);
231 leg2->Draw();
232
233 myC->cd(2);
234 grnullR.SetTitle("Average pedestal rms for inner pixels");
235 grnullR.DrawClone("AP");
236 for(UInt_t i=0;i<nslices;i++)
237 grrmsIn[i].DrawClone("P");
238
239 myC->cd(3);
240 grnullM.SetTitle("Average pedestal mean for outer pixels");
241 grnullM.DrawClone("AP");
242 for(UInt_t i=0;i<nslices;i++)
243 grmeanOut[i].DrawClone("P");
244
245 myC->cd(4);
246 grnullR.SetTitle("Average pedestal rms for outer pixels");
247 grnullR.DrawClone("AP");
248 for(UInt_t i=0;i<nslices;i++)
249 grrmsOut[i].DrawClone("P");
250
251 myC->Print("pedestaSliceDependence.ps");
252
253}
Note: See TracBrowser for help on using the repository browser.