source: trunk/MagicSoft/Mars/mtemp/mifae/macros/mmcCleaning.C@ 5138

Last change on this file since 5138 was 4822, checked in by rico, 20 years ago
*** empty log message ***
File size: 6.3 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):
19 !
20 ! Copyright: MAGIC Software Development, 2000-2004
21 !
22 !
23 \* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// mmcCleaning - study different cleaning levels with mc
28//
29//
30/////////////////////////////////////////////////////////////////////////////
31
32
33void mmcCleaning()
34{
35 //
36 // This is a demonstration program which reads in MC camera files
37 // and produces and output with calibrated events (signal in photons
38 // for all pixels, in MCerPhotEvt containers).
39 //
40
41 // ------------- user change -----------------
42 Char_t* NonoiseFilename = "/local_disk/jrico/mc/Gamma_zbin12_0_7_1250to1259_w0_nonoise.root"; // File to be used for the calibration (must be a camera file without added noise)
43 Char_t* NoiseFilename = "/local_disk/jrico/mc/Gamma_zbin12_0_7_1250to1259_w0.root"; // File to be analyzed
44
45 Char_t* NonoiseOutFilename = "/local_disk/jrico/mc/Gamma_zbin12_0_7_1250to1259_w0_cleaned_nonoise.root"; // Output file name
46 Char_t* NoiseOutFilename = "/local_disk/jrico/mc/Gamma_zbin12_0_7_1250to1259_w0_cleaned_6045.root"; // Output file name
47
48
49 MExtractSignal sigextract;
50 // (other extraction methods can be used)
51
52 sigextract.SetSaturationLimit(240);
53 // Defines when to switch to low gain
54
55 // Define FADC slices to be integrated in high and low gain:
56 sigextract.SetRange(1, 14, 3, 14);
57
58 // ---------------------------------------------------------------------
59 //
60 // Create a empty Parameter List and an empty Task List
61 // The tasklist is identified in the eventloop by its name
62 //
63 MParList plist;
64 MTaskList tlist;
65 plist.AddToList(&tlist);
66
67 MPedestalCam pedcam;
68 MGeomCamMagic geomcam;
69 MCerPhotEvt nphot;
70
71 plist.AddToList(&pedcam);
72 plist.AddToList(&geomcam);
73 plist.AddToList(&nphot);
74
75 //
76 // Now setup the tasks and tasklist:
77 // ---------------------------------
78 //
79 MReadMarsFile read("Events");
80 read.AddFile(NonoiseFilename);
81 read.DisableAutoScheme();
82
83 MGeomApply geom;
84 // Reads in geometry from MC file and sets the right sizes for
85 // several parameter containers.
86
87 MMcPedestalCopy pcopy;
88 // Copies pedestal data from the MC file run fadc header to the
89 // MPedestalCam container.
90
91 MDisplay display(&nphot,&geomcam);
92 MHillasDisplay display2(&nphot,&geomcam);
93
94 MPointingPosCalc pointcalc;
95 // Creates MPointingPos object and fill it with the telescope orientation
96 // information taken from MMcEvt.
97
98 MMcCalibrationUpdate mccalibupdate;
99
100 MCalibrate calib;
101 // MCalibrate transforms signals from ADC counts into photons. In the first
102 // loop it applies a "dummy" calibration supplied by MMcCalibrationUpdate, just
103 // to equalize inner and outer pixels. At the end of the first loop, in the
104 // PostProcess of MMcCalibrationCalc (see below) the true calibration constants
105 // are calculated.
106
107 calib.SetCalibrationMode(MCalibrate::kFfactor);
108
109 MImgCleanStd clean(6.0,4.5);
110 clean.SetRemoveSingle(kFALSE);
111 //
112 // Applies tail cuts to image. Since the calibration is performed on
113 // noiseless camera files, the precise values of the cleaning levels
114 // are unimportant (in any case, only pixels without any C-photon will
115 // be rejected).
116 //
117
118 MHillasCalc hcalc; // Calculates Hillas parameters not dependent on source position.
119 MHillasSrcCalc hsrccalc;
120
121 MMcCalibrationCalc mccalibcalc;
122 // Calculates calibration constants to convert from ADC counts to photons.
123
124 MWriteRootFile write(NonoiseOutFilename); // Writes output
125 write.AddContainer("MRawRunHeader", "Events");
126 write.AddContainer("MMcEvt", "Events");
127 write.AddContainer("MRawEvtHeader", "Events");
128 write.AddContainer("MCerPhotEvt", "Events");
129 write.AddContainer("MHillas", "Events");
130 write.AddContainer("MHillasSrc", "Events");
131
132 tlist.AddToList(&read);
133 tlist.AddToList(&geom);
134 tlist.AddToList(&pcopy);
135 tlist.AddToList(&pointcalc);
136 tlist.AddToList(&sigextract);
137 tlist.AddToList(&mccalibupdate);
138 tlist.AddToList(&calib);
139 tlist.AddToList(&clean);
140 tlist.AddToList(&hcalc);
141 tlist.AddToList(&hsrccalc);
142 // tlist.AddToList(&display2);
143 tlist.AddToList(&mccalibcalc);
144 tlist.AddToList(&write);
145
146 //
147 // First loop: No noise
148 //
149
150 MProgressBar bar;
151 bar.SetWindowName("No noise...");
152
153 MEvtLoop evtloop;
154 evtloop.SetProgressBar(&bar);
155 evtloop.SetParList(&plist);
156
157 if (!evtloop.Eventloop())
158 return;
159 mccalibcalc.GetHistADC2PhotEl()->Write();
160 mccalibcalc.GetHistPhot2PhotEl()->Write();
161 // Writes out the histograms used for calibration.
162
163
164 //
165 // Second loop: process file with noise
166 //
167 MReadMarsFile read2("Events");
168 read2.AddFile(NoiseFilename);
169 read2.DisableAutoScheme();
170 tlist.AddToListBefore(&read2, &read, "All");
171 tlist.RemoveFromList(&read);
172
173 MWriteRootFile write2(NoiseOutFilename); // Writes output
174 write2.AddContainer("MRawRunHeader", "Events");
175 write2.AddContainer("MMcEvt", "Events");
176 write2.AddContainer("MRawEvtHeader", "Events");
177 write2.AddContainer("MCerPhotEvt", "Events");
178 write2.AddContainer("MHillas", "Events");
179 write2.AddContainer("MHillasSrc", "Events");
180
181 // tlist.AddToListBefore(&display2,&clean, "All");
182 tlist.AddToListBefore(&write2, &write, "All");
183 tlist.RemoveFromList(&write);
184
185
186
187 bar.SetWindowName("Cleaning 3015...");
188 clean.SetRemoveSingle();
189
190 // tlist.RemoveFromList(&clean);
191 // tlist.RemoveFromList(&hcalc);
192 tlist.RemoveFromList(&mccalibcalc);
193
194 if (!evtloop.Eventloop())
195 return;
196
197 tlist.PrintStatistics();
198}
Note: See TracBrowser for help on using the repository browser.