source: trunk/MagicSoft/Mars/macros/calibration.C@ 3742

Last change on this file since 3742 was 3742, checked in by gaug, 21 years ago
*** empty log message ***
File size: 5.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): Markus Gaug, 11/2003 <mailto:markus@ifae.es>
19!
20! Copyright: MAGIC Software Development, 2000-2004
21!
22!
23\* ======================================================================== */
24//const TString inpath = "/home/rootdata/Calib/2004_04_08/";
25const TString inpath = "/home/rootdata/BlindPixel/";
26const Int_t pedrun = 20491;
27const Int_t calrun = 20494;
28
29void calibration(const Int_t prun=pedrun, const Int_t crun=calrun)
30{
31
32 MRunIter pruns;
33 MRunIter cruns;
34
35 pruns.AddRun(prun,inpath);
36 cruns.AddRun(crun,inpath);
37
38 MCalibrationCam::PulserColor_t color;
39
40 if (crun < 20000)
41 color = MCalibrationCam::kCT1;
42 else
43 color = FindColor((MDirIter*)&cruns);
44
45 if (color == MCalibrationCam::kNONE)
46 return;
47
48 MCalibrationQECam qecam;
49 MBadPixelsCam badcam;
50 badcam.AsciiRead("badpixels.dat");
51
52 for (Int_t i=0;i<badcam.GetSize();i++)
53 if (badcam[i].IsBad())
54 cout << "Bad Pixel: " << i << endl;
55
56 MStatusDisplay *display = new MStatusDisplay;
57 display->SetUpdateTime(3000);
58 display->Resize(850,700);
59
60 /************************************/
61 /* FIRST LOOP: PEDESTAL COMPUTATION */
62 /************************************/
63
64 MJPedestal pedloop;
65 pedloop.SetInput(&pruns);
66 pedloop.SetDisplay(display);
67 pedloop.SetBadPixels(badcam);
68
69 if (!pedloop.Process())
70 return;
71
72 //
73 // Create a empty Parameter List and an empty Task List
74 // The tasklist is identified in the eventloop by its name
75 //
76 MParList plist0;
77 MTaskList tlist0;
78 plist0.AddToList(&tlist0);
79
80 //
81 // Now setup the tasks and tasklist for the pedestals:
82 // ---------------------------------------------------
83 //
84 MReadMarsFile read("Events");
85 read.DisableAutoScheme();
86 static_cast<MRead&>(read).AddFiles(pruns);
87
88 MJCalibration calloop;
89 calloop.SetColor(color);
90
91 //
92 // If you want only the most necessary plots, choose:
93 // calloop.SetDataCheck();
94 //
95 // For everything, you ever dreamed of, choose:
96 // calloop.SetFullDisplay();
97
98 //
99 // If you want to calibrate the times as well, choose:
100 // calloop.SetRelTimeCalibration();
101 calloop.SetInput(&cruns);
102 calloop.SetDisplay(display);
103 calloop.SetQECam(qecam);
104 calloop.SetBadPixels(pedloop.GetBadPixels());
105 if (!calloop.Process(pedloop.GetPedestalCam()))
106 return;
107
108}
109
110MCalibrationCam::PulserColor_t FindColor(MDirIter* run)
111{
112
113 MCalibrationCam::PulserColor_t col = MCalibrationCam::kNONE;
114
115 TString filenames;
116
117 while (!(filenames=run->Next()).IsNull())
118 {
119
120 filenames.ToLower();
121
122 if (filenames.Contains("green"))
123 if (col == MCalibrationCam::kNONE)
124 {
125 cout << "Found colour: Green in " << filenames << endl;
126 col = MCalibrationCam::kGREEN;
127 }
128 else if (col != MCalibrationCam::kGREEN)
129 {
130 cout << "Different colour found in " << filenames << "... abort" << endl;
131 return MCalibrationCam::kNONE;
132 }
133
134 if (filenames.Contains("blue"))
135 if (col == MCalibrationCam::kNONE)
136 {
137 cout << "Found colour: Blue in " << filenames << endl;
138 col = MCalibrationCam::kBLUE;
139 }
140 else if (col != MCalibrationCam::kBLUE)
141 {
142 cout << "Different colour found in " << filenames << "... abort" << endl;
143 return MCalibrationCam::kNONE;
144 }
145
146 if (filenames.Contains("uv"))
147 if (col == MCalibrationCam::kNONE)
148 {
149 cout << "Found colour: Uv in " << filenames << endl;
150 col = MCalibrationCam::kUV;
151 }
152 else if (col != MCalibrationCam::kUV)
153 {
154 cout << "Different colour found in " << filenames << "... abort" << endl;
155 return MCalibrationCam::kNONE;
156 }
157
158 if (filenames.Contains("ct1"))
159 if (col == MCalibrationCam::kNONE)
160 {
161 cout << "Found colour: Ct1 in " << filenames << endl;
162 col = MCalibrationCam::kCT1;
163 }
164 else if (col != MCalibrationCam::kCT1)
165 {
166 cout << "Different colour found in " << filenames << "... abort" << endl;
167 return MCalibrationCam::kNONE;
168 }
169
170 }
171
172
173
174 if (col == MCalibrationCam::kNONE)
175 cout << "No colour found in filenames of runs: " << ((MRunIter*)run)->GetRunsAsString()
176 << "... abort" << endl;
177
178 return col;
179}
Note: See TracBrowser for help on using the repository browser.