source: tags/Mars-V0.9.2/macros/PedCalcFromData.C

Last change on this file was 4356, checked in by jflix, 21 years ago
*** empty log message ***
File size: 4.9 KB
Line 
1
2/////////////////////////////////////////////////////////////////////////////
3// //
4// Description: Macro that uses MPedCalcFromData to evaluate Pedestals from//
5// Data Runs. //
6// Author: Josep Flix (jflix@ifae.es) //
7// Date: 25/06/2004 //
8// //
9/////////////////////////////////////////////////////////////////////////////
10
11void PedCalcFromData()
12{
13
14 gROOT->Reset();
15 gStyle->SetCanvasColor(0);
16 gStyle->SetCanvasBorderMode(0);
17 gStyle->SetPadBorderMode(0);
18 gStyle->SetFrameBorderMode(0);
19 gStyle->SetOptStat(0000000);
20 gStyle->SetPalette(1);
21
22 TString pedfile("20040422_23229_P_Mrk421_E.root");
23 TString datafile("20040422_23230_D_Mrk421_E.root");
24
25 gStyle->SetOptFit(0);
26 gStyle->SetOptStat(0000);
27
28 MParList plist;
29 MTaskList tlist;
30
31 MPedestalCam cam;
32 plist.AddToList(&cam);
33
34 plist.AddToList(&tlist);
35
36 MReadMarsFile read("Events", "/home/pepe/DATA_REAL/Mkn421/"+pedfile);
37 read.DisableAutoScheme();
38 MGeomApply geomapl;
39 MExtractFixedWindow extractor;
40 extractor.SetRange(2,14,4,14);
41
42 MPedCalcPedRun ped;
43 ped.SetWindowSize(12);
44 ped.SetRange(2,14);
45
46 tlist.AddToList(&read);
47 tlist.AddToList(&geomapl);
48 tlist.AddToList(&ped);
49
50 MEvtLoop evtloop;
51
52 if (!tlist.PreProcess(&plist))
53 return;
54
55 while (tlist.Process())
56 {
57 }
58 tlist.PostProcess();
59
60
61 // ---------------------------------------------------------------
62 // 2nd evt loop
63 // ---------------------------------------------------------------
64
65 c1 = new TCanvas("c1","c1",0,0,600,300);
66 c1->Divide(2,1);
67 c1->SetBorderMode(0);
68
69 TH2D *plot1 = new TH2D("","",1,0.1,175000,1,8,15);
70 TH2D *plot2 = new TH2D("","",1,0.1,175000,1,1,40);
71 c1->cd(1);
72 plot1->Draw();
73 c1->cd(2);
74 plot2->Draw();
75
76 Int_t COUNT=0;
77
78 for (int j = 0; j < 6 ; j++){
79
80 if (j == 1)
81 TString datafile("20040422_23231_D_Mrk421_E.root");
82 if (j == 2)
83 TString datafile("20040422_23233_D_Mrk421_E.root");
84 if (j == 3)
85 TString datafile("20040422_23234_D_Mrk421_E.root");
86 if (j == 4)
87 TString datafile("20040422_23236_D_Mrk421_E.root");
88 if (j == 5)
89 TString datafile("20040422_23237_D_Mrk421_E.root");
90
91 MParList plist2;
92 MTaskList tlist2;
93 plist2.AddToList(&tlist2);
94 plist2.AddToList(&cam);
95
96 MGeomCam *geomcam = (MGeomCam*)plist->FindObject("MGeomCam");
97
98 MReadMarsFile read2("Events");
99 read2.DisableAutoScheme();
100
101 read2.AddFile("/home/pepe/DATA_REAL/Mkn421/"+datafile);
102 MGeomApply apply2;
103
104 MPedCalcFromData ped2;
105 ped2.SetDumpEvents(500);
106 ped2.SetLoRange(2,14);
107 ped2.SetHighGainThreshold(50);
108
109 tlist2.AddToList(&read2);
110 tlist2.AddToList(&apply2);
111 tlist2.AddToList(&ped2);
112
113 MEvtLoop evtloop2;
114 evtloop2.SetParList(&plist2);
115
116 if (!tlist2.PreProcess(&plist2))
117 return;
118
119 TArrayD PedMean[577];
120 TArrayD PedRms[577];
121 for (int i = 0; i < 577 ; i++){
122 PedMean[i].Set(20001);
123 PedRms[i].Set(20001);
124 };
125 Double_t x[20001];
126 Double_t y[20001];
127 Int_t Cont = 0;
128 Int_t HOT = 0;
129
130 while (tlist2.Process())
131 {
132
133 COUNT++;
134
135 if (read2.GetNumExecutions()==1 || read2.GetNumExecutions()%500==0){
136
137 x[Cont] = COUNT;
138 for (int i = 1; i < 577; i++){
139
140 PedMean[i](Cont) = cam[i]->GetPedestal();
141 PedRms[i](Cont) = cam[i]->GetPedestalRms();
142
143 };
144 Cont++;
145 };
146// if (read2.GetNumExecutions() == 5000) break;
147 }
148
149 tlist2.PostProcess();
150 cout << "EXEC = " << read2.GetNumExecutions() << '\t' << HOT << endl;
151
152 for (int i = 1; i < 577; i++){
153
154 if ( i == 8 || i ==146 || i ==200 || i ==269 || i==279 || i==400 || i==26 || i==439 || i==490 || i==39){
155
156 for (int k = 0 ; k < 20000; k++)
157 y[k] = PedMean[i](k);
158
159 c1->cd(1);
160
161 TGraph *graph1 = new TGraph(Cont,x,y);
162 graph1->SetLineColor((int)i/3);
163 graph1->SetMarkerColor((int)i/3);
164 graph1->SetMarkerSize(.4);
165 graph1->SetMarkerStyle(20);
166 graph1->Draw("PL");
167
168 c1->cd(2);
169 for (int k = 0 ; k < 20000; k++)
170 y[k] = PedRms[i](k);
171
172 TGraph *graph2 = new TGraph(Cont,x,y);
173 graph2->SetMarkerSize(.4);
174 graph2->SetLineColor((int)i/3);
175 graph2->SetMarkerStyle(20);
176 graph2->SetMarkerColor((int)i/3);
177 graph2->Draw("PL");
178
179 Char_t tit[100];
180 sprintf(tit,"Pixel %i",i);
181 TLatex *pix = new TLatex(20000.,38.-1.*HOT,tit);
182 pix->SetTextColor((int)i/3);
183 pix->SetTextSize(.03);
184 pix->Draw("");
185 HOT++;
186 };
187
188 };
189
190 TLine *line2 = new TLine(x[Cont-1],1.,x[Cont-1],40.);
191 line2->SetLineStyle(2);
192 TLine *line1 = new TLine(x[Cont-1],8.,x[Cont-1],15.);
193 line1->SetLineStyle(2);
194 c1->cd(1);
195 line1->Draw("");
196 c1->cd(2);
197 line2->Draw("");
198
199 };
200}
Note: See TracBrowser for help on using the repository browser.