source: trunk/Mars/macros/tutorials/extendcam.C@ 18679

Last change on this file since 18679 was 7208, checked in by tbretz, 19 years ago
*** empty log message ***
File size: 6.1 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/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2004-2005
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26//
27// extendcam.C
28//
29// This macro demonstrates how to extend the magic camera and performes
30// a fourier transformation on it
31//
32/////////////////////////////////////////////////////////////////////////////////
33
34Bool_t HandleInput()
35{
36 // This must be there to get accesss to the GUI while the macro
37 // is still running!
38
39 TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
40 while (1)
41 {
42 //
43 // While reading the input process gui events asynchronously
44 //
45 timer.TurnOn();
46 TString input = Getline("Type 'q' to exit, <return> to go on: ");
47 timer.TurnOff();
48
49 if (input=="q\n")
50 return kFALSE;
51
52 if (input=="\n")
53 return kTRUE;
54 };
55
56 return kFALSE;
57}
58
59TCanvas *c;
60MHCamera *d1=new MHCamera(MGeomCamMagic());
61MHCamera *d2=new MHCamera;
62MHCamera *d3=new MHCamera;
63MHCamera *d4=new MHCamera;
64MHCamera *d5=new MHCamera;
65MHCamera *d6=new MHCamera(MGeomCamMagicXT());
66
67MSignalCam *evt=0;
68MMcEvt *mc;
69
70MHexagonFreqSpace *fFreq1;
71MHexagonFreqSpace *fFreq2;
72
73Int_t PreProcess(MParList *plist)
74{
75 fFreq1 = (MHexagonFreqSpace*)plist->FindObject("MHexagonFreqSpace1");
76 if (!fFreq1)
77 return kFALSE;
78 fFreq2 = (MHexagonFreqSpace*)plist->FindObject("MHexagonFreqSpace2");
79 if (!fFreq2)
80 return kFALSE;
81
82 //Für Real-Raum
83 evt = (MSignalCam*)plist->FindObject("MSignalCam");
84 if (!evt)
85 {
86 cout << "Fehler: MSignalCam" << endl;
87 return kFALSE;
88 }
89
90 mc = (MMcEvt*)plist->FindObject("MMcEvt");
91 if (!mc)
92 {
93 cout << "Fehler: MMcEvt" << endl;
94 return kFALSE;
95 }
96
97 c = new TCanvas("Events", "Real Events", 900, 600);
98 c->SetBorderMode(0);
99 c->Divide(3,2);
100
101 MGeomCam *geomfreq=fFreq1->NewGeomCam();
102 geomfreq->SetName("FreqSpace");
103
104 c->cd(1);
105 d1->SetPrettyPalette();
106 d1->Draw();
107 c->cd(2);
108 d2->SetGeometry(MGeomCamMagicXT());
109 d2->SetPrettyPalette();
110 d2->Draw();
111 c->cd(4);
112 d3->SetGeometry(*geomfreq);
113 d3->SetPrettyPalette();
114 d3->Draw();
115 c->cd(5);
116 d4->SetGeometry(MGeomCamMagicXT());
117 d4->SetPrettyPalette();
118 d4->Draw();
119 c->cd(3);
120 d5->SetGeometry(MGeomCamMagicXT());
121 d5->SetPrettyPalette();
122 d5->Draw();
123 c->cd(6);
124 //d6->SetGeometry(MGeomCamMagicXT());
125 d6->SetPrettyPalette();
126 d6->Draw();
127 return kTRUE;
128}
129
130MClone *cl1;
131MClone *cl2;
132MClone *cl3;
133MClone *cl4;
134
135Int_t Process()
136{
137 d1->SetCamContent(*(MSignalCam*)cl1->GetClone());
138 d2->SetCamContent(*(MSignalCam*)cl2->GetClone());
139 d3->SetCamContent(*fFreq2);
140 d4->SetCamContent(*(MSignalCam*)cl4->GetClone());
141 d5->SetCamContent(*(MSignalCam*)cl3->GetClone());
142 d6->SetCamContent(*evt);
143
144 d2->SetMaximum(-1111);
145 d4->SetMaximum(-1111);
146 d2->SetMinimum(0);
147 d4->SetMinimum(0);
148 d2->SetMaximum(TMath::Max(d2->GetMaximum(), d4->GetMaximum()));
149 d4->SetMaximum(d2->GetMaximum());
150
151 for (int i=1; i<7; i++)
152 {
153 c->GetPad(i)->GetPad(1)->Modified();
154 c->GetPad(i)->GetPad(1)->Update();
155 }
156
157 c->Modified();
158 c->Update();
159
160
161 return HandleInput();
162}
163
164void extendcam()
165{
166 MParList plist;
167 MTaskList tlist;
168
169 MGeomCamMagicXT geom("MGeomCamMagicXT");
170 plist.AddToList(&geom);
171
172 plist.AddToList(&tlist);
173
174 MReadMarsFile read("Events");
175 read.DisableAutoScheme();
176 read.AddFile("/home/tbretz/Software/mcwobble/lza/cal/19*.root");
177 //read.AddFile("/home/hoehne/data/mcdata/gammas/calib/calib_gamma_zbin0.root");
178 //read.AddFile("/home/hoehne/data/mcdata/hadrons/calib/calib_proton_zbin0.root");
179
180
181 // Setup intercative task calling the functions defined above
182 MGeomApply apply; //necessary for evt
183 MGeomCamMagicEnhance enhance;
184 // enhance.SetNameCerPhotEvtOut("MCerPhotEvt2");
185
186 MClone clone1("MSignalCam", "Clone1");
187 MClone clone2("MSignalCam", "Clone2");
188 MClone clone3("MSignalCam", "Clone3");
189 MClone clone4("MSignalCam", "Clone4");
190
191 cl1 = &clone1;
192 cl2 = &clone2;
193 cl3 = &clone3;
194 cl4 = &clone4;
195
196 MHexagonalFTCalc ftcalc;
197 ftcalc.SetNameGeomCam("MGeomCamMagicXT");
198 // ftcalc.SetNameCerPhotEvt("MCerPhotEvt2");
199
200 MTaskInteractive mytask;
201 mytask.SetPreProcess(PreProcess);
202 mytask.SetProcess(Process);
203
204 MImgCleanStd clean1(8, 4.5);
205 clean1.SetMethod(MImgCleanStd::kAbsolute);
206 clean1.SetNameGeomCam("MGeomCamMagicXT");
207 clean1.SetNamePedPhotCam("MPedPhotFromExtractorRndm");
208
209 MImgCleanStd clean2(8, 4.5);
210 clean2.SetMethod(MImgCleanStd::kAbsolute);
211 clean2.SetNameGeomCam("MGeomCamMagicXT");
212 clean2.SetNamePedPhotCam("MPedPhotFromExtractorRndm");
213
214 // Setup your tasklist
215 tlist.AddToList(&read);
216 tlist.AddToList(&apply);
217 tlist.AddToList(&clone1);
218 tlist.AddToList(&enhance);
219 tlist.AddToList(&clone2);
220 tlist.AddToList(&clean1);
221 tlist.AddToList(&clone3);
222 tlist.AddToList(&ftcalc);
223 tlist.AddToList(&clone4);
224 tlist.AddToList(&clean2);
225 tlist.AddToList(&mytask);
226
227 // Run your analysis
228 MEvtLoop evtloop;
229 evtloop.SetParList(&plist);
230
231 if (!evtloop.Eventloop())
232 return;
233
234 // Print statistics information about your loop
235 tlist.PrintStatistics();
236}
237
Note: See TracBrowser for help on using the repository browser.