source: trunk/MagicSoft/Mars/macros/tutorials/extendcam.C@ 7155

Last change on this file since 7155 was 7155, checked in by tbretz, 19 years ago
*** empty log message ***
File size: 6.0 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
67MCerPhotEvt *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 = (MCerPhotEvt*)plist->FindObject("MCerPhotEvt");
84 if (!evt)
85 {
86 cout << "Fehler: MCerPhotEvt" << 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(*(MCerPhotEvt*)cl1->GetClone());
138 d2->SetCamContent(*(MCerPhotEvt*)cl2->GetClone());
139 d3->SetCamContent(*fFreq2);
140 d4->SetCamContent(*(MCerPhotEvt*)cl4->GetClone());
141 d5->SetCamContent(*(MCerPhotEvt*)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/kolodziejski/Diplomarbeit/marsdata/mcdata/*.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("MCerPhotEvt", "Clone1");
187 MClone clone2("MCerPhotEvt", "Clone2");
188 MClone clone3("MCerPhotEvt", "Clone3");
189 MClone clone4("MCerPhotEvt", "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(26, 18);
205 clean1.SetMethod(MImgCleanStd::kAbsolute);
206 clean1.SetNameGeomCam("MGeomCamMagicXT");
207
208 MImgCleanStd clean2(26, 18);
209 clean2.SetMethod(MImgCleanStd::kAbsolute);
210 clean2.SetNameGeomCam("MGeomCamMagicXT");
211
212 // Setup your tasklist
213 tlist.AddToList(&read);
214 tlist.AddToList(&apply);
215 tlist.AddToList(&clone1);
216 tlist.AddToList(&enhance);
217 tlist.AddToList(&clone2);
218 tlist.AddToList(&clean1);
219 tlist.AddToList(&clone3);
220 tlist.AddToList(&ftcalc);
221 tlist.AddToList(&clone4);
222 tlist.AddToList(&clean2);
223 tlist.AddToList(&mytask);
224
225 // Run your analysis
226 MEvtLoop evtloop;
227 evtloop.SetParList(&plist);
228
229 if (!evtloop.Eventloop())
230 return;
231
232 // Print statistics information about your loop
233 tlist.PrintStatistics();
234}
235
Note: See TracBrowser for help on using the repository browser.