1 | // pedrmsonoff.C
|
---|
2 | // compare pedestal rms for two different sets
|
---|
3 | //
|
---|
4 |
|
---|
5 | #include "MParList.h"
|
---|
6 | #include "MTaskList.h"
|
---|
7 | #include "MPedestalCam.h"
|
---|
8 | #include "MReadMarsFile.h"
|
---|
9 | #include "MGeomApply.h"
|
---|
10 | #include "MPedCalcPedRun.h"
|
---|
11 | #include "MEvtLoop.h"
|
---|
12 | #include "MPedestalPix.h"
|
---|
13 | #include "MHCamera.h"
|
---|
14 |
|
---|
15 | #include "TTimer.h"
|
---|
16 | #include "TString.h"
|
---|
17 | #include "TCanvas.h"
|
---|
18 | #include "TFile.h"
|
---|
19 | #include "TGraphErrors.h"
|
---|
20 | #include "TMultiGraph.h"
|
---|
21 | #include "TLegend.h"
|
---|
22 | #include "TPaveStats.h"
|
---|
23 | #include "TH1F.h"
|
---|
24 | #include "TStyle.h"
|
---|
25 | #include "TROOT.h"
|
---|
26 |
|
---|
27 | #include <iostream>
|
---|
28 |
|
---|
29 | using namespace std;
|
---|
30 |
|
---|
31 | void compare(TCanvas* canvas,TString onfname, TString offfname,TString descon, TString descoff, UInt_t index=-1);
|
---|
32 |
|
---|
33 | void pedrmsonoff()
|
---|
34 | //int main()
|
---|
35 | {
|
---|
36 | // general settings
|
---|
37 | gROOT->Reset();
|
---|
38 | gStyle->SetCanvasColor(0);
|
---|
39 | gStyle->SetStatColor(0);
|
---|
40 | gStyle->SetStatBorderSize(1);
|
---|
41 | gStyle->SetOptStat(111111);
|
---|
42 | gStyle->SetStatW(0.2);
|
---|
43 | gStyle->SetStatH(0.1);
|
---|
44 | gStyle->SetStatX(0.9);
|
---|
45 | gStyle->SetStatY(0.9);
|
---|
46 |
|
---|
47 | // create canvas
|
---|
48 | TCanvas* canvas = new TCanvas("canvas","On/Off crab pedestal rms", 0, 100, 800, 500);
|
---|
49 | canvas->SetBorderMode(0); // Delete the Canvas' border line
|
---|
50 | canvas->cd();
|
---|
51 |
|
---|
52 | #ifdef TEMPLATE
|
---|
53 | // define input files/parameters
|
---|
54 | const UInt_t ncomp = 9;
|
---|
55 |
|
---|
56 | // const TString onfile ="/mnt/disc02/Data/rootdata/CrabNebula/2004_01_26/20040125_10412_P_Crab-On_E.root";
|
---|
57 | TString onfile[ncomp] = {
|
---|
58 | "/local_disk/jrico/rootdata/20040126_12149_P_Cab-On_E.root",
|
---|
59 | "/local_disk/jrico/rootdata/20040125_10412_P_Crab-On_E.root",
|
---|
60 | "/local_disk/jrico/rootdata/20040125_10412_P_Crab-On_E.root",
|
---|
61 | "/local_disk/jrico/rootdata/20040119_04642_P_Crab-On_E.root",
|
---|
62 | "/local_disk/jrico/rootdata/20040128_1342*_P_ClosedLidsHVoff_E.root",
|
---|
63 | "/local_disk/jrico/rootdata/20040128_1342*_P_ClosedLidsLVoff_E.root",
|
---|
64 | "/local_disk/jrico/rootdata/20040128_1343*_P_ReciversOff_E.root",
|
---|
65 | "/local_disk/jrico/rootdata/20040126_12386_P_Cab-On_E.root",
|
---|
66 | "/local_disk/jrico/rootdata/20040126_12543_P_OffCrab-1_E.root"};
|
---|
67 |
|
---|
68 |
|
---|
69 | TString ondesc[ncomp] = {"Run 12149 Jan 27th, Crab On, #theta 28 deg",
|
---|
70 | "Run 10412 Jan 26th, Crab On, #theta 12.5 deg",
|
---|
71 | "Run 10412 Jan 26th, Crab On, #theta 12.5 deg",
|
---|
72 | "Run 4642 Jan 20th, Crab On, #theta 14.1 deg",
|
---|
73 | "Runs 13426-7 Jan 29th, Closed lids HV off",
|
---|
74 | "Runs 13428-9 Jan 29th, Closed lids LV off",
|
---|
75 | "Runs 13430-1 Jan 29th, Recivers Off",
|
---|
76 | "Run 12386 Jan 27th, Crab On #theta 37.1 deg",
|
---|
77 | "Run 12543 Jan 27th, Crab Off #theta 8.6 deg"};
|
---|
78 |
|
---|
79 |
|
---|
80 | TString offfile[ncomp] = {
|
---|
81 | "/local_disk/jrico/rootdata/20040121_06773_P_OffCrab1_E.root",
|
---|
82 | "/local_disk/jrico/rootdata/20040125_11477_P_OffCrab1_E.root",
|
---|
83 | "/local_disk/jrico/rootdata/20040125_10415_P_Crab-On_E.root",
|
---|
84 | "/local_disk/jrico/rootdata/20040125_10415_P_Crab-On_E.root",
|
---|
85 | "/local_disk/jrico/rootdata/20040128_13425_P_ClosedLidsHVon_E.root",
|
---|
86 | "/local_disk/jrico/rootdata/20040128_13425_P_ClosedLidsHVon_E.root",
|
---|
87 | "/local_disk/jrico/rootdata/20040128_13425_P_ClosedLidsHVon_E.root",
|
---|
88 | "/local_disk/jrico/rootdata/20040128_13425_P_ClosedLidsHVon_E.root",
|
---|
89 | "/local_disk/jrico/rootdata/20040128_13425_P_ClosedLidsHVon_E.root"};
|
---|
90 |
|
---|
91 |
|
---|
92 | TString offdesc[ncomp] = {"Run 6773 Jan 22nd, Crab Off #theta 28 deg",
|
---|
93 | "Run 11477 Jan 26th, Crab Off #theta 9.2 deg",
|
---|
94 | "Run 10415 Jan 26th, Crab On, #theta 13.8 deg",
|
---|
95 | "Run 10415 Jan 26th, Crab On, #theta 13.8 deg",
|
---|
96 | "Run 13425 Jan 29th, Closed lids HV on",
|
---|
97 | "Run 13425 Jan 29th, Closed lids HV on",
|
---|
98 | "Run 13425 Jan 29th, Closed lids HV on",
|
---|
99 | "Run 13425 Jan 29th, Closed lids HV on",
|
---|
100 | "Run 13425 Jan 29th, Closed lids HV on"};
|
---|
101 | #endif
|
---|
102 |
|
---|
103 | // define input files/parameters
|
---|
104 | const UInt_t ncomp = 1;
|
---|
105 |
|
---|
106 | TString onfile[ncomp] = {"/local_disk/jrico/rootdata/pedestals/20040619_*_P_OffPSR1957-1_E.root"};
|
---|
107 | TString ondesc[ncomp] = {"Off-PSR1957"};
|
---|
108 | TString offfile[ncomp] = {"/local_disk/jrico/mc/empty_disc00.root"};
|
---|
109 | TString offdesc[ncomp] = {"MC (Vela)"};
|
---|
110 |
|
---|
111 | canvas->Print("pedrmsonoff.ps[");
|
---|
112 | for(UInt_t i=0;i<ncomp;i++)
|
---|
113 | compare(canvas,onfile[i],offfile[i],ondesc[i],offdesc[i],i);
|
---|
114 | canvas->Print("pedrmsonoff.ps]");
|
---|
115 | }
|
---|
116 |
|
---|
117 |
|
---|
118 | void compare(TCanvas* canvas,TString onfname, TString offfname,TString descon, TString descoff,UInt_t index)
|
---|
119 | {
|
---|
120 | /*************************/
|
---|
121 | /* FIRST LOOP: ON DATA */
|
---|
122 | /*************************/
|
---|
123 |
|
---|
124 | // basic lists
|
---|
125 | MParList plist;
|
---|
126 | MTaskList tlist;
|
---|
127 | plist.AddToList(&tlist);
|
---|
128 |
|
---|
129 | // containers
|
---|
130 | MPedestalCam onpedcam;
|
---|
131 | plist.AddToList(&onpedcam);
|
---|
132 |
|
---|
133 | //tasks
|
---|
134 | MReadMarsFile read("Events", onfname);
|
---|
135 | MGeomApply geomapl;
|
---|
136 | MPedCalcPedRun pedcalc;
|
---|
137 |
|
---|
138 | read.DisableAutoScheme();
|
---|
139 |
|
---|
140 | tlist.AddToList(&read);
|
---|
141 | tlist.AddToList(&geomapl);
|
---|
142 | tlist.AddToList(&pedcalc);
|
---|
143 |
|
---|
144 | // Create and execute the event looper
|
---|
145 | MEvtLoop evtloop;
|
---|
146 | evtloop.SetParList(&plist);
|
---|
147 |
|
---|
148 | cout << "*********************" << endl;
|
---|
149 | cout << "** RUNNING ON DATA **" << endl;
|
---|
150 | cout << "*********************" << endl;
|
---|
151 |
|
---|
152 | if (!evtloop.Eventloop())
|
---|
153 | return;
|
---|
154 |
|
---|
155 | tlist.PrintStatistics();
|
---|
156 |
|
---|
157 | /**************************/
|
---|
158 | /* SECOND LOOP: OFF DATA */
|
---|
159 | /**************************/
|
---|
160 | MReadMarsFile read2("Events",offfname);
|
---|
161 | read2.DisableAutoScheme();
|
---|
162 | tlist.AddToListBefore(&read2, &read, "All");
|
---|
163 | tlist.RemoveFromList(&read);
|
---|
164 |
|
---|
165 | // containers
|
---|
166 | MPedestalCam offpedcam;
|
---|
167 | plist.Remove(&onpedcam);
|
---|
168 | plist.AddToList(&offpedcam);
|
---|
169 |
|
---|
170 | // Execute the event looper
|
---|
171 | cout << "**********************" << endl;
|
---|
172 | cout << "** RUNNING OFF DATA **" << endl;
|
---|
173 | cout << "**********************" << endl;
|
---|
174 |
|
---|
175 | if (!evtloop.Eventloop())
|
---|
176 | return;
|
---|
177 |
|
---|
178 | tlist.PrintStatistics();
|
---|
179 |
|
---|
180 | /*******************/
|
---|
181 | /* FILL HISTOGRAMS */
|
---|
182 | /*******************/
|
---|
183 | const UInt_t npix = 577;
|
---|
184 | const UInt_t ninner = 397;
|
---|
185 | const UInt_t imin = 0;
|
---|
186 | const UInt_t imax = 20;
|
---|
187 | const UInt_t itot = 50;
|
---|
188 |
|
---|
189 | TH1F* honinpedrms = new TH1F(descon+TString(" Inner"),"Pedestal RMS" ,itot,imin,imax);
|
---|
190 | TH1F* hoffinpedrms = new TH1F(descoff+TString(" Inner"),"Pedestal RMS",itot,imin,imax);
|
---|
191 | TH1F* honoutpedrms = new TH1F(descon+TString(" Outer"),"Pedestal RMS" ,itot,imin,imax);
|
---|
192 | TH1F* hoffoutpedrms = new TH1F(descoff+TString(" Outer"),"Pedestal RMS",itot,imin,imax);
|
---|
193 |
|
---|
194 | for(UInt_t i=0;i<npix;i++)
|
---|
195 | {
|
---|
196 | const Float_t onpedrms = onpedcam[i].GetPedestalRms();
|
---|
197 | const Float_t offpedrms = offpedcam[i].GetPedestalRms();
|
---|
198 |
|
---|
199 | if(i<ninner)
|
---|
200 | {
|
---|
201 | honinpedrms->Fill(onpedrms);
|
---|
202 | hoffinpedrms->Fill(offpedrms);
|
---|
203 | }
|
---|
204 | else
|
---|
205 | {
|
---|
206 | honoutpedrms->Fill(onpedrms);
|
---|
207 | hoffoutpedrms->Fill(offpedrms);
|
---|
208 | }
|
---|
209 | }
|
---|
210 |
|
---|
211 | /*******************/
|
---|
212 | /* DRAW HISTOGRAMS */
|
---|
213 | /*******************/
|
---|
214 |
|
---|
215 | // draw pedestal histos
|
---|
216 | honinpedrms->GetXaxis()->SetTitle("Pedestal RMS (ADC cnts)");
|
---|
217 | honinpedrms->GetYaxis()->SetTitle("# pixels");
|
---|
218 | honinpedrms->SetFillStyle(3004);
|
---|
219 | honinpedrms->SetFillColor(1);
|
---|
220 |
|
---|
221 | hoffinpedrms->GetXaxis()->SetTitle("Pedestal RMS (ADC cnts)");
|
---|
222 | hoffinpedrms->GetYaxis()->SetTitle("# pixels");
|
---|
223 | hoffinpedrms->SetFillStyle(3005);
|
---|
224 | hoffinpedrms->SetFillColor(2);
|
---|
225 | hoffinpedrms->SetLineColor(2);
|
---|
226 |
|
---|
227 | honoutpedrms->GetXaxis()->SetTitle("Pedestal RMS (ADC cnts)");
|
---|
228 | honoutpedrms->GetYaxis()->SetTitle("# pixels");
|
---|
229 | honoutpedrms->SetFillStyle(3017);
|
---|
230 | honoutpedrms->SetFillColor(1);
|
---|
231 |
|
---|
232 | hoffoutpedrms->GetXaxis()->SetTitle("Pedestal RMS (ADC cnts)");
|
---|
233 | hoffoutpedrms->GetYaxis()->SetTitle("# pixels");
|
---|
234 | hoffoutpedrms->SetFillStyle(3018);
|
---|
235 | hoffoutpedrms->SetFillColor(2);
|
---|
236 | hoffoutpedrms->SetLineColor(2);
|
---|
237 |
|
---|
238 | hoffinpedrms->Draw();
|
---|
239 | hoffoutpedrms->Draw("sames");
|
---|
240 | honinpedrms->Draw("sames");
|
---|
241 | honoutpedrms->Draw("sames");
|
---|
242 |
|
---|
243 | // move stat boxes to make them all visible
|
---|
244 | gPad->Update();
|
---|
245 | TPaveStats* onoutpavstat = (TPaveStats*) honoutpedrms->GetListOfFunctions()->FindObject("stats");
|
---|
246 | TPaveStats* offinpavstat = (TPaveStats*) hoffinpedrms->GetListOfFunctions()->FindObject("stats");
|
---|
247 | TPaveStats* offoutpavstat = (TPaveStats*) hoffoutpedrms->GetListOfFunctions()->FindObject("stats");
|
---|
248 | Float_t shifty = offinpavstat->GetY2NDC()-offinpavstat->GetY1NDC();
|
---|
249 | Float_t shiftx = onoutpavstat->GetX2NDC()-onoutpavstat->GetX1NDC();
|
---|
250 |
|
---|
251 | onoutpavstat->SetX1NDC(onoutpavstat->GetX1NDC()-shiftx);
|
---|
252 | onoutpavstat->SetX2NDC(onoutpavstat->GetX2NDC()-shiftx);
|
---|
253 |
|
---|
254 | offinpavstat->SetY1NDC(offinpavstat->GetY1NDC()-shifty);
|
---|
255 | offinpavstat->SetY2NDC(offinpavstat->GetY2NDC()-shifty);
|
---|
256 |
|
---|
257 | offoutpavstat->SetX1NDC(offoutpavstat->GetX1NDC()-shiftx);
|
---|
258 | offoutpavstat->SetX2NDC(offoutpavstat->GetX2NDC()-shiftx);
|
---|
259 | offoutpavstat->SetY1NDC(offoutpavstat->GetY1NDC()-shifty);
|
---|
260 | offoutpavstat->SetY2NDC(offoutpavstat->GetY2NDC()-shifty);
|
---|
261 |
|
---|
262 | // include legend
|
---|
263 | TLegend* leg1 = new TLegend(.52,.25,.88,.45);
|
---|
264 | leg1->SetHeader("");
|
---|
265 | leg1->AddEntry(honinpedrms,descon+TString(" (Inner)"),"f");
|
---|
266 | leg1->AddEntry(hoffinpedrms,descoff+TString(" (Inner)"),"f");
|
---|
267 | leg1->AddEntry(honoutpedrms,descon+TString(" (Outer)"),"f");
|
---|
268 | leg1->AddEntry(hoffoutpedrms,descoff+TString(" (Outer)"),"f");
|
---|
269 | leg1->SetFillColor(0);
|
---|
270 | leg1->SetLineColor(0);
|
---|
271 | leg1->SetBorderSize(0);
|
---|
272 | leg1->Draw();
|
---|
273 |
|
---|
274 | if(index>=0)
|
---|
275 | {
|
---|
276 | char fname[100];
|
---|
277 | sprintf(fname,"pedrmsonoff%02d.eps",index);
|
---|
278 | canvas->Print(fname);
|
---|
279 | }
|
---|
280 | canvas->Print("pedrmsonoff.ps");
|
---|
281 |
|
---|
282 | return;
|
---|
283 |
|
---|
284 | }
|
---|