source: branches/MarsMoreSimulationTruth/mtemp/mmpi/macros/noise_autocorrelation_AB_all.C

Last change on this file was 6447, checked in by hbartko, 20 years ago
*** empty log message ***
File size: 8.7 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Hendrik Bartko 09/2004 <mailto:hbartko@mppmu.mpg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2001
21!
22!
23\* ======================================================================== */
24
25
26const TString defname = "/.magic/magicserv01/scratch/hbartko/rootdata/2004_09_03/20040903_35698_P_multiplexFADC_E.root";
27const TString defpedname = "/.magic/magicserv01/scratch/hbartko/rootdata/2004_09_03/20040903_35698_P_multiplexFADC_E.root";
28
29// works with one pedestal file to calculate the noise autocorrelation
30
31
32
33
34void noise_autocorrelation_AB_all(const TString fname = defpedname, const TString pedname = defpedname) {
35
36
37 // for (int i=1; i++; i<397){
38
39 TH2F bla;
40 TH2F * hcorr = new TH2F("hcorr","hcorr",15,0,15,15,0,15);
41
42
43 for (int i=1; i<397; i++){
44 bla = noise_autocorrelation_AB_pix(fname,pedname, i);
45
46 hcorr->Add(&bla);
47 }
48
49
50 TCanvas * c_corr = new TCanvas("c_corr","c_corr",600,400);
51 c_corr->SetFillColor(0);
52 c_corr->SetBorderMode(0);
53 c_corr->SetGridx();
54 c_corr->SetGridy();
55 gStyle->SetPalette(1);
56
57 hcorr->Scale(1./396.);
58
59 hcorr->Draw("colz");
60 // }
61
62}
63
64
65
66
67
68TH2F noise_autocorrelation_AB_pix(const TString fname = defpedname, const TString pedname = defpedname, Int_t ipix = 67) {
69
70 MParList plist_ped;
71
72 MTaskList tlist_ped;
73 plist_ped.AddToList(&tlist_ped);
74
75 MPedestalCam pedcam;
76 plist_ped.AddToList(&pedcam);
77
78 MReadMarsFile read("Events", pedname);
79 read.DisableAutoScheme();
80 tlist_ped.AddToList(&read);
81
82 MGeomApply geomapl_ped;
83 MGeomCamMagic geomcam;
84 tlist_ped.AddToList(&geomapl_ped);
85
86
87 MPedCalcFromLoGain pedcalc_ped;
88 //pedcalc_ped.SetMaxHiGainVar(20);
89 //pedcalc_ped.SetRange(0, 11, 1, 14);
90 //pedcalc_ped.SetWindowSize(12,14);
91 pedcalc_ped.SetPedestalUpdate(kFALSE);
92 tlist_ped.AddToList(&pedcalc_ped);
93
94 MEvtLoop evtloop_ped;
95 evtloop_ped.SetParList(&plist_ped);
96
97 if (!evtloop_ped.Eventloop())
98 return;
99
100 tlist_ped.PrintStatistics();
101
102
103 // now the event loop for the signal reconstruction with pedestals subtracted
104
105
106 MParList plist;
107 MTaskList tlist;
108 plist.AddToList(&tlist);
109
110 plist.AddToList(&pedcam);
111
112 MRawRunHeader runheader;
113 plist.AddToList(&runheader);
114
115 MRawEvtData evtdata;
116 plist.AddToList(&evtdata);
117
118 MExtractedSignalCam sigcam;
119 plist.AddToList(&sigcam);
120
121 MArrivalTimeCam timecam;
122 plist.AddToList(&timecam);
123
124
125 MReadMarsFile read("Events", fname);
126 read.DisableAutoScheme();
127
128 MGeomApply geomapl;
129
130 Int_t WindowSize = 6; // size of the chosen integration window for signal and time extraction
131
132 MExtractFixedWindowPeakSearch extractor;
133 extractor.SetRange(0, 14, 0, 14);
134 extractor.SetWindows( WindowSize, WindowSize, 4);
135
136 MExtractTimeHighestIntegral timeext;
137 timeext.SetRange(0, 14, 0, 14);
138 timeext.SetWindowSize(WindowSize,WindowSize);
139
140
141 tlist.AddToList(&read);
142 tlist.AddToList(&geomapl);
143 tlist.AddToList(&extractor);
144 tlist.AddToList(&timeext);
145
146
147 MEvtLoop evtloop;
148 evtloop.SetParList(&plist);
149
150 if (!evtloop.PreProcess())
151 return;
152
153 TString title = "Noise Autocorrelation B_{ij} = <b_{i}*b_{j}> - <b_{i}>*<b_{j}>, Pixel ";
154 title += ipix;
155
156
157 Int_t First = 1;
158
159 TH2F hcorr("hcorr","hcorr",15,0,15,15,0,15);
160
161
162 Float_t B[15][15];
163 Float_t bi[15];
164 Float_t bj[15];
165
166 for (int i=0; i<15; i++){
167 bi[i]=0;
168 bj[i]=0;
169 for (int j=0; j<15; j++){
170 B[i][j]=0;
171 }
172 }
173
174 const Float_t ped_mean = pedcam[ipix].GetPedestal();
175 const Float_t pedRMS = pedcam[ipix].GetPedestalRms();
176
177 cout << " ped_mean " << ped_mean << " pedRMS " << pedRMS << " ABoffs " << pedcam[ipix].GetPedestalABoffset() << endl;
178 int count = 0;
179
180 while (tlist.Process()) {
181
182 if (First) {
183 First = 0;
184
185 const Int_t nh = runheader.GetNumSamplesHiGain();
186 const Int_t nl = runheader.GetNumSamplesLoGain();
187 const Int_t nt = nh+nl;
188
189 }
190
191
192
193 MRawEvtPixelIter pixel(&evtdata);
194 pixel.Jump(ipix);
195
196 Bool_t ABFlag = pixel.HasABFlag();
197
198
199 count++; // couter for the number of events
200
201 const Byte_t *higains = pixel.GetHiGainSamples();
202 const Byte_t *logains = pixel.GetLoGainSamples();
203
204 const Float_t ABoffs = pedcam[ipix].GetPedestalABoffset();
205
206 Float_t PedMean[2];
207 PedMean[0] = ped_mean + ABoffs;
208 PedMean[1] = ped_mean - ABoffs;
209
210
211 // calculate the noise autocorrelation matrix
212 for (int slice=0; slice<nh; slice++) {
213 bi[slice]+= higains[slice]-PedMean[(slice+ABFlag)&0x1];
214 bj[slice]+= higains[slice]-PedMean[(slice+ABFlag)&0x1];
215 for (int ii = 0; ii< nh; ii++){
216 B[slice][ii]+=(higains[slice]-PedMean[(slice+ABFlag)&0x1])*(higains[ii]-PedMean[(ii+ABFlag)&0x1]);
217 }
218 }
219
220
221 // compute the noise signal shape
222
223 Int_t trigger = 0;
224 Double_t charge = 0;
225 Double_t charge_time = 0;
226
227
228
229
230
231
232 } // end eventloop.Process()
233
234 evtloop.PostProcess();
235
236
237 for (int i=0; i<15; i++){
238 for (int j=0; j<15; j++){
239 hcorr->Fill(i,j,B[i][j]/count-bi[i]/count*bj[j]/count);
240 // cout << "i " << i << " j " << j << " B[i][j] " << B[i][j] << " bi[i] " << bi[i] << " bj[j] " << bj[j] << endl;
241 }
242 }
243
244 cout << " pedmean " << ped_mean << " pedRMS " << pedRMS << endl;
245
246
247 return hcorr;
248
249 /*
250
251 TCanvas * c_corr = new TCanvas("c_corr","c_corr",600,400);
252 c_corr->SetFillColor(0);
253 c_corr->SetBorderMode(0);
254 c_corr->SetGridx();
255 c_corr->SetGridy();
256 gStyle->SetPalette(1);
257
258 hcorr->SetStats(0);
259 hcorr->SetTitle(title);
260 hcorr->SetXTitle("slice i");
261 hcorr->SetYTitle("slice j");
262 hcorr->Draw("colz");
263
264
265 TCanvas * c_corr_px = new TCanvas("c_corr_px","c_corr_px",600,400);
266 c_corr_px->SetFillColor(0);
267 c_corr_px->SetBorderMode(0);
268 c_corr_px->SetGridx();
269 c_corr_px->SetGridy();
270
271 TH1F * hcorr_px = (TH1F*)hcorr->ProjectionX("hcorr_px",6,6);
272 hcorr_px->SetLineColor(4);
273 hcorr_px->SetLineWidth(2);
274 hcorr_px->SetStats(0);
275 TString title1 = "Noise Autocorrelation, FADC sample 6, Pixel";
276 title1+=ipix;
277 hcorr_px->SetTitle(title);
278 hcorr_px->SetXTitle("slice i");
279 hcorr_px->SetYTitle("B_{ij} = <b_{i}*b_{j}> - <b_{i}>*<b_{j}> [FADC counts]");
280
281 hcorr_px->Draw();
282
283
284
285 TCanvas * c_shape = new TCanvas("c_shape","c_shape",600,400);
286 c_shape->SetFillColor(0);
287 c_shape->SetBorderMode(0);
288 c_shape->SetGridx();
289 c_shape->SetGridy();
290 shape->SetStats(0);
291 TString title2 = "Noise Signal Shape, Signal #geq 3 FADC counts, Pixel ";
292 title2+=ipix;
293 shape->SetTitle(title2);
294 shape->SetXTitle("FADC sample no.");
295 shape->SetYTitle("signal [FADC counts]");
296 shape->SetMarkerStyle(20);
297 shape->SetMarkerColor(4);
298 shape->SetMarkerSize(0.3);
299 shape->Draw();
300
301
302 TCanvas * c_shape_corr = new TCanvas("c_shape_corr","c_shape_corr",600,400);
303 c_shape_corr->SetFillColor(0);
304 c_shape_corr->SetBorderMode(0);
305 c_shape_corr->SetGridx();
306 c_shape_corr->SetGridy();
307 shape_corr->SetStats(0);
308 TString title3 = "Noise Signal Shape, Signal #geq 3 FADC counts, Pixel ";
309 title3+=ipix;
310 shape_corr->SetTitle(title3);
311 shape_corr->SetXTitle("FADC sample no. + (<t_{arrival}> - t_{arrival}) / T_{ADC}");
312 shape_corr->SetYTitle("signal [FADC counts]");
313 shape_corr->SetMarkerStyle(20);
314 shape_corr->SetMarkerColor(4);
315 shape_corr->SetMarkerSize(0.3);
316 shape_corr->Draw();
317
318
319 TCanvas * c_sig = new TCanvas("c_sig","c_sig",600,400);
320 c_sig->SetFillColor(0);
321 c_sig->SetBorderMode(0);
322 c_sig->SetGridx();
323 c_sig->SetGridy();
324
325 hsig->SetStats(0);
326 TString title4 = "Noise Extracted Charge, MExtractFixedWindowPeakSearch, Pixel ";
327 title4+=ipix;
328 hsig->SetTitle(title4);
329 hsig->SetXTitle("reco charge [FADC counts]");
330 hsig->SetYTitle("events / 2 FADC counts");
331 hsig->SetLineColor(4);
332 hsig->SetLineWidth(2);
333 hsig->Draw();
334
335 TCanvas * c_time = new TCanvas("c_time","c_time",600,400);
336 c_time->SetFillColor(0);
337 c_time->SetBorderMode(0);
338 c_time->SetGridx();
339 c_time->SetGridy();
340
341 htime->SetStats(0);
342 TString title5 = "Noise Arrival Time, MExtractTimeHighestIntegral, Pixel ";
343 title5+=ipix;
344 htime->SetTitle(title5);
345 htime->SetXTitle("arrival time [T_{ADC}]");
346 htime->SetYTitle("events / 0.1 T_{ADC}");
347 htime->SetLineColor(4);
348 htime->SetLineWidth(2);
349 htime->Draw();
350 */
351}
352
353
354
355
356
357
358
Note: See TracBrowser for help on using the repository browser.