source: trunk/MagicSoft/Mars/macros/ScanPulseABPed.C@ 6439

Last change on this file since 6439 was 4404, checked in by fgoebel, 20 years ago
*** empty log message ***
File size: 4.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): Thomas Bretz 12/2000 <mailto:tbretz@uni-sw.gwdg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2001
21!
22!
23\* ======================================================================== */
24
25
26Bool_t HandleInput()
27{
28 TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
29 while (1)
30 {
31 //
32 // While reading the input process gui events asynchronously
33 //
34 timer.TurnOn();
35 TString input = Getline("Type 'q' to exit, <return> to go on: ");
36 timer.TurnOff();
37
38 if (input=="q\n")
39 return kFALSE;
40
41 if (input=="\n")
42 return kTRUE;
43 };
44
45 return kFALSE;
46}
47
48const TString defname = "/.magic/magicserv01/MAGIC/rootdata2/2004_04_22/20040422_23211_D_Mrk421_E.root";
49const TString defpedname = "/.magic/magicserv01/MAGIC/rootdata2/2004_04_22/20040422_23209_P_Mrk421_E.root";
50
51void ScanPulseABPed(Int_t ipix = 1, const TString fname = defname, const TString pedname = defpedname) {
52
53 MParList plist_ped;
54
55 MTaskList tlist_ped;
56 plist_ped.AddToList(&tlist_ped);
57
58 MPedestalCam pedcam;
59 plist_ped.AddToList(&pedcam);
60
61 MReadMarsFile read("Events", pedname);
62 read.DisableAutoScheme();
63 tlist_ped.AddToList(&read);
64
65 MGeomApply geomapl_ped;
66 MGeomCamMagic geomcam;
67 tlist_ped.AddToList(&geomapl_ped);
68
69
70 MPedCalcFromLoGain pedcalc_ped;
71 pedcalc_ped.SetMaxHiGainVar(20);
72 pedcalc_ped.SetRange(0, 11, 1, 14);
73 pedcalc_ped.SetWindowSize(12,14);
74 pedcalc_ped.SetPedestalUpdate(kFALSE);
75 tlist_ped.AddToList(&pedcalc_ped);
76
77 MEvtLoop evtloop_ped;
78 evtloop_ped.SetParList(&plist_ped);
79
80 if (!evtloop_ped.Eventloop())
81 return;
82
83 tlist_ped.PrintStatistics();
84
85
86 // now the event loop for the signal reconstruction with pedestals subtracted
87
88
89 MParList plist;
90 MTaskList tlist;
91 // MPedestalCam pedcam;
92 plist.AddToList(&pedcam);
93
94 MRawRunHeader runheader;
95 plist.AddToList(&runheader);
96
97 MRawEvtData evtdata;
98 plist.AddToList(&evtdata);
99
100 plist.AddToList(&tlist);
101
102 MReadMarsFile read("Events", fname);
103 read.DisableAutoScheme();
104
105 MGeomApply geomapl;
106
107 tlist.AddToList(&read);
108 tlist.AddToList(&geomapl);
109
110 MEvtLoop evtloop;
111 evtloop.SetParList(&plist);
112
113 if (!evtloop.PreProcess())
114 return;
115
116 TString title = "Pulse in pixel: ";
117 title += ipix;
118 TCanvas c("Events", title, 600, 600);
119 c.SetBorderMode(0);
120 c.Divide(1,1);
121 c.cd(1);
122 gPad->cd(1);
123
124 Int_t First = 1;
125
126 while (tlist.Process()) {
127
128 if (First) {
129 First = 0;
130
131 const Int_t nh = runheader.GetNumSamplesHiGain();
132 const Int_t nl = runheader.GetNumSamplesLoGain();
133 const Int_t nt = nh+nl;
134
135 TH1D *hpulse_corr = new TH1D("hpulse_corr", title, nt, -0.5, nt+0.5);
136 hpulse_corr->SetMaximum(255);
137 hpulse_corr->SetMinimum(-10);
138 hpulse_corr->SetLineColor(2);
139 // hpulse_corr->SetLineWidth(3);
140
141 hpulse_corr->Draw();
142
143 TH1D *hpulse = new TH1D("hpulse", title, nt, -0.5, nt+0.5);
144 hpulse->Draw("same");
145 }
146
147 MRawEvtPixelIter pixel(&evtdata);
148 pixel.Jump(ipix);
149
150 Bool_t ABFlag = pixel.HasABFlag();
151
152 cout << "Event: " << read.GetNumEntry() << " ABFlag: " << (Int_t)ABFlag << endl;
153
154 const Byte_t *higains = pixel.GetHiGainSamples();
155 const Byte_t *logains = pixel.GetLoGainSamples();
156
157 const Float_t ped_mean = pedcam[ipix].GetPedestal();
158 const Float_t ABoffs = pedcam[ipix].GetPedestalABoffset();
159
160 Float_t PedMean[2];
161 PedMean[0] = ped_mean + ABoffs;
162 PedMean[1] = ped_mean - ABoffs;
163
164 for (int slice=0; slice<nh; slice++) {
165 hpulse_corr->SetBinContent(slice+1, higains[slice]-PedMean[(slice+ABFlag)&0x1]);
166 hpulse->SetBinContent(slice+1, higains[slice]);
167 }
168 for (int slice=0; slice<nl; slice++) {
169 hpulse_corr->SetBinContent(slice+nh+1, logains[slice]-PedMean[(nh+slice+ABFlag)&0x1]);
170 hpulse->SetBinContent(slice+nh+1, logains[slice]);
171 }
172
173 c.GetPad(1)->Modified();
174 c.GetPad(1)->Update();
175
176 if (!HandleInput())
177 break;
178 }
179
180 evtloop.PostProcess();
181
182}
183
184
185
186
187
188
189
Note: See TracBrowser for help on using the repository browser.