| 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-2003
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | void calibration(TString pedname="./20031102_02399_P_Unavailable_E.root",
|
|---|
| 26 | TString calname="./20031102_02400_D_Flip500Hz_E.root")
|
|---|
| 27 | {
|
|---|
| 28 |
|
|---|
| 29 | //
|
|---|
| 30 | // Create a empty Parameter List and an empty Task List
|
|---|
| 31 | // The tasklist is identified in the eventloop by its name
|
|---|
| 32 | //
|
|---|
| 33 | MParList plist;
|
|---|
| 34 |
|
|---|
| 35 | MTaskList tlist;
|
|---|
| 36 | plist.AddToList(&tlist);
|
|---|
| 37 |
|
|---|
| 38 | //
|
|---|
| 39 | // Now setup the tasks and tasklist for the pedestals:
|
|---|
| 40 | // ---------------------------------------------------
|
|---|
| 41 | //
|
|---|
| 42 |
|
|---|
| 43 | MReadMarsFile read("Events", pedname);
|
|---|
| 44 | read.DisableAutoScheme();
|
|---|
| 45 |
|
|---|
| 46 | MGeomApply geomapl;
|
|---|
| 47 | MGeomCamMagic geomcam;
|
|---|
| 48 | MGeomCam geom;
|
|---|
| 49 | MPedCalcPedRun pedcalc;
|
|---|
| 50 | MPedestalCam pedcam;
|
|---|
| 51 |
|
|---|
| 52 | tlist.AddToList(&read);
|
|---|
| 53 | tlist.AddToList(&geomapl);
|
|---|
| 54 | tlist.AddToList(&pedcalc);
|
|---|
| 55 |
|
|---|
| 56 | plist.AddToList(&pedcam);
|
|---|
| 57 |
|
|---|
| 58 | MHCamEvent hist("Pedestal");
|
|---|
| 59 | hist.SetType(1);
|
|---|
| 60 | plist.AddToList(&hist);
|
|---|
| 61 | MFillH fill(&hist, "MPedestalCam");
|
|---|
| 62 |
|
|---|
| 63 | tlist.AddToList(&fill);
|
|---|
| 64 |
|
|---|
| 65 | //
|
|---|
| 66 | // Update frequency by default = 1Hz
|
|---|
| 67 | //
|
|---|
| 68 | MStatusDisplay *d = new MStatusDisplay;
|
|---|
| 69 |
|
|---|
| 70 | // Set update time to 3s
|
|---|
| 71 | d->SetUpdateTime(3000);
|
|---|
| 72 |
|
|---|
| 73 | //
|
|---|
| 74 | // Create and setup the eventloop
|
|---|
| 75 | //
|
|---|
| 76 | MEvtLoop evtloop;
|
|---|
| 77 | evtloop.SetParList(&plist);
|
|---|
| 78 | evtloop.SetDisplay(d);
|
|---|
| 79 |
|
|---|
| 80 | //
|
|---|
| 81 | // Execute first analysis
|
|---|
| 82 | //
|
|---|
| 83 | if (!evtloop.Eventloop())
|
|---|
| 84 | return;
|
|---|
| 85 |
|
|---|
| 86 | tlist.PrintStatistics();
|
|---|
| 87 |
|
|---|
| 88 | //
|
|---|
| 89 | // Create a empty Parameter List and an empty Task List
|
|---|
| 90 | //
|
|---|
| 91 | MParList plist2;
|
|---|
| 92 |
|
|---|
| 93 | MTaskList tlist2;
|
|---|
| 94 | plist2.AddToList(&tlist2);
|
|---|
| 95 |
|
|---|
| 96 | plist2.AddToList((MPedestalCam*)plist.FindObject("MPedestalCam"));
|
|---|
| 97 |
|
|---|
| 98 | MGeomApply geomapl2;
|
|---|
| 99 | tlist2.AddToList(&geomapl);
|
|---|
| 100 |
|
|---|
| 101 | //
|
|---|
| 102 | // Now setup the new tasks and tasklist for the calibration
|
|---|
| 103 | // ---------------------------------------------------
|
|---|
| 104 | //
|
|---|
| 105 |
|
|---|
| 106 | MReadMarsFile read2("Events", calname);
|
|---|
| 107 | read2.DisableAutoScheme();
|
|---|
| 108 |
|
|---|
| 109 | MCalibrationCalc calcalc;
|
|---|
| 110 | calcalc.SetSkipTFits();
|
|---|
| 111 |
|
|---|
| 112 | plist2.AddToList(&geomcam);
|
|---|
| 113 |
|
|---|
| 114 | //
|
|---|
| 115 | // As long, as we don't have digital modules,
|
|---|
| 116 | // we have to set the color by hand
|
|---|
| 117 | //
|
|---|
| 118 | calcalc.SetPulserColor(MCalibrationCalc::kEBlue);
|
|---|
| 119 |
|
|---|
| 120 | tlist2.AddToList(&read2);
|
|---|
| 121 | tlist2.AddToList(&calcalc);
|
|---|
| 122 |
|
|---|
| 123 | MHCamEvent hist2;
|
|---|
| 124 | hist2.SetType(0);
|
|---|
| 125 | plist2.AddToList(&hist2);
|
|---|
| 126 | MFillH fill2("MHCamEvent", "MCalibrationCam");
|
|---|
| 127 | tlist2.AddToList(&fill2);
|
|---|
| 128 |
|
|---|
| 129 | //
|
|---|
| 130 | // Create and setup the eventloop
|
|---|
| 131 | //
|
|---|
| 132 | MEvtLoop evtloop2;
|
|---|
| 133 | evtloop2.SetParList(&plist2);
|
|---|
| 134 |
|
|---|
| 135 | //
|
|---|
| 136 | // Execute second analysis
|
|---|
| 137 | //
|
|---|
| 138 | if (!evtloop2.Eventloop())
|
|---|
| 139 | return;
|
|---|
| 140 |
|
|---|
| 141 | tlist2.PrintStatistics();
|
|---|
| 142 |
|
|---|
| 143 | // plist2.FindObject("MCalibrationCam")->Print();
|
|---|
| 144 |
|
|---|
| 145 | //
|
|---|
| 146 | // just one example how to get the plots of individual pixels
|
|---|
| 147 | //
|
|---|
| 148 | MCalibrationCam *cam = plist2.FindObject("MCalibrationCam");
|
|---|
| 149 | MCalibrationPix *pix = cam->GetCalibrationPix(523);
|
|---|
| 150 | pix->Draw();
|
|---|
| 151 |
|
|---|
| 152 | TCanvas *c1 = MH::MakeDefCanvas("Calibration1","Plots of FADC Charges",700,900);
|
|---|
| 153 | c1->Divide(5, 2);
|
|---|
| 154 |
|
|---|
| 155 | MHCamEvent &h = *(MHCamEvent*)plist2->FindObject("MHCamEvent");
|
|---|
| 156 | MHCamera *disp0 = h.GetHistByName();
|
|---|
| 157 | MHCamera *disp1 = new MHCamera(geomcam, "MCalibrationCam;q", "Fitted Mean Charges");
|
|---|
| 158 | MHCamera *disp2 = new MHCamera(geomcam, "MCalibrationCam;errq", "Error of Fitted Mean Charges");
|
|---|
| 159 | MHCamera *disp3 = new MHCamera(geomcam, "MCalibrationCam;sigmaq", "Sigma of Fitted Mean Charges");
|
|---|
| 160 | MHCamera *disp4 = new MHCamera(geomcam, "MCalibrationCam;errsigmaq", "Error of Sigma of Fitted Mean Charges");
|
|---|
| 161 | MHCamera *disp5 = new MHCamera(geomcam, "MCalibrationCam;probq", "Probability of Fit");
|
|---|
| 162 | MHCamera *disp6 = new MHCamera(geomcam, "MCalibrationCam;t", "Arrival Times");
|
|---|
| 163 | MHCamera *disp7 = new MHCamera(geomcam, "MCalibrationCam;sigmat", "Sigma of Arrival Times");
|
|---|
| 164 | MHCamera *disp8 = new MHCamera(geomcam, "MCalibrationCam;probt", "Probability of Time Fit");
|
|---|
| 165 | MHCamera *disp9 = new MHCamera(geomcam, "MCalibrationCam;ped", "Pedestals");
|
|---|
| 166 | MHCamera *disp10 = new MHCamera(geomcam, "MCalibrationCam;pedrms", "Pedestal RMS");
|
|---|
| 167 | MHCamera *disp11 = new MHCamera(geomcam, "MCalibrationCam;rq", "Reduced Charges");
|
|---|
| 168 | MHCamera *disp12 = new MHCamera(geomcam, "MCalibrationCam;errrq", "Error of Reduced Charges");
|
|---|
| 169 |
|
|---|
| 170 | disp1->SetBit(kCanDelete);
|
|---|
| 171 | disp2->SetBit(kCanDelete);
|
|---|
| 172 | disp3->SetBit(kCanDelete);
|
|---|
| 173 | disp4->SetBit(kCanDelete);
|
|---|
| 174 | disp5->SetBit(kCanDelete);
|
|---|
| 175 | disp6->SetBit(kCanDelete);
|
|---|
| 176 | disp7->SetBit(kCanDelete);
|
|---|
| 177 | disp8->SetBit(kCanDelete);
|
|---|
| 178 | disp9->SetBit(kCanDelete);
|
|---|
| 179 | disp10->SetBit(kCanDelete);
|
|---|
| 180 | disp11->SetBit(kCanDelete);
|
|---|
| 181 | disp12->SetBit(kCanDelete);
|
|---|
| 182 |
|
|---|
| 183 | disp1->SetCamContent(*cam, 0);
|
|---|
| 184 | disp2->SetCamContent(*cam, 1);
|
|---|
| 185 | disp3->SetCamContent(*cam, 2);
|
|---|
| 186 | disp4->SetCamContent(*cam, 3);
|
|---|
| 187 | disp5->SetCamContent(*cam, 4);
|
|---|
| 188 | disp6->SetCamContent(*cam, 5);
|
|---|
| 189 | disp7->SetCamContent(*cam, 6);
|
|---|
| 190 | disp8->SetCamContent(*cam, 7);
|
|---|
| 191 | disp9->SetCamContent(*cam, 8);
|
|---|
| 192 | disp10->SetCamContent(*cam, 9);
|
|---|
| 193 | disp11->SetCamContent(*cam, 10);
|
|---|
| 194 | disp12->SetCamContent(*cam, 11);
|
|---|
| 195 |
|
|---|
| 196 | disp1->SetYTitle("Q [FADC counts]");
|
|---|
| 197 | disp2->SetYTitle("\\Delta_{Q} [FADC counts]");
|
|---|
| 198 | disp3->SetYTitle("\\sigma_{Q} [FADC counts]");
|
|---|
| 199 | disp4->SetYTitle("\\Delta_{\\sigma_{Q}} [FADC counts]");
|
|---|
| 200 | disp5->SetYTitle("P [au]");
|
|---|
| 201 | disp6->SetYTitle("T [FADC slices]");
|
|---|
| 202 | disp7->SetYTitle("\\Delta_{T} [FADC slices]");
|
|---|
| 203 | disp8->SetYTitle("P [au]");
|
|---|
| 204 | disp9->SetYTitle("P [FADC counts/ slice ]");
|
|---|
| 205 | disp10->SetYTitle("RMS_{P} [FADC counts / slice ]");
|
|---|
| 206 | disp11->SetYTitle("Q [FADC counts]");
|
|---|
| 207 | disp12->SetYTitle("\\Delta_{Q} [FADC counts]");
|
|---|
| 208 |
|
|---|
| 209 | // TText text(0.1, 0.5, &fname[fname.Last('/')+1]);
|
|---|
| 210 | // text.SetTextSize(0.015);
|
|---|
| 211 | // text.DrawClone();
|
|---|
| 212 |
|
|---|
| 213 | c1->cd(1);
|
|---|
| 214 | gStyle->SetOptStat(1111);
|
|---|
| 215 | disp1->Draw("hist");
|
|---|
| 216 | gPad->Update();
|
|---|
| 217 |
|
|---|
| 218 | c1->cd(2);
|
|---|
| 219 | gStyle->SetOptStat(1101);
|
|---|
| 220 | disp2->Draw("hist");
|
|---|
| 221 | gPad->Update();
|
|---|
| 222 |
|
|---|
| 223 | c1->cd(3);
|
|---|
| 224 | gStyle->SetOptStat(1101);
|
|---|
| 225 | disp3->Draw("hist");
|
|---|
| 226 | gPad->Update();
|
|---|
| 227 |
|
|---|
| 228 | c1->cd(4);
|
|---|
| 229 | gStyle->SetOptStat(1101);
|
|---|
| 230 | disp4->Draw("hist");
|
|---|
| 231 | gPad->Update();
|
|---|
| 232 |
|
|---|
| 233 | c1->cd(5);
|
|---|
| 234 | gStyle->SetOptStat(1101);
|
|---|
| 235 | disp5->Draw("hist");
|
|---|
| 236 | gPad->Update();
|
|---|
| 237 |
|
|---|
| 238 | c1->cd(6);
|
|---|
| 239 | gPad->SetBorderMode(0);
|
|---|
| 240 | gPad->Divide(1,1);
|
|---|
| 241 | gPad->cd(1);
|
|---|
| 242 | disp1->Draw();
|
|---|
| 243 |
|
|---|
| 244 | c1->cd(7);
|
|---|
| 245 | gPad->SetBorderMode(0);
|
|---|
| 246 | gPad->Divide(1,1);
|
|---|
| 247 | gPad->cd(1);
|
|---|
| 248 | disp2->Draw();
|
|---|
| 249 |
|
|---|
| 250 | c1->cd(8);
|
|---|
| 251 | gPad->SetBorderMode(0);
|
|---|
| 252 | gPad->Divide(1,1);
|
|---|
| 253 | gPad->cd(1);
|
|---|
| 254 | disp3->Draw();
|
|---|
| 255 |
|
|---|
| 256 | c1->cd(9);
|
|---|
| 257 | gPad->SetBorderMode(0);
|
|---|
| 258 | gPad->Divide(1,1);
|
|---|
| 259 | gPad->cd(1);
|
|---|
| 260 | disp4->Draw();
|
|---|
| 261 |
|
|---|
| 262 | c1->cd(10);
|
|---|
| 263 | gPad->SetBorderMode(0);
|
|---|
| 264 | gPad->Divide(1,1);
|
|---|
| 265 | gPad->cd(1);
|
|---|
| 266 | disp5->Draw();
|
|---|
| 267 |
|
|---|
| 268 | TCanvas *c2 = MH::MakeDefCanvas("Calibration2","Plots of Arrival Times",700,900);
|
|---|
| 269 | c2->Divide(3, 2);
|
|---|
| 270 |
|
|---|
| 271 | c2->cd(1);
|
|---|
| 272 | gStyle->SetOptStat(1111);
|
|---|
| 273 | disp6->Draw("hist");
|
|---|
| 274 | gPad->Update();
|
|---|
| 275 |
|
|---|
| 276 | c2->cd(2);
|
|---|
| 277 | gStyle->SetOptStat(1101);
|
|---|
| 278 | disp7->Draw("hist");
|
|---|
| 279 | gPad->Update();
|
|---|
| 280 |
|
|---|
| 281 | c2->cd(3);
|
|---|
| 282 | gStyle->SetOptStat(1101);
|
|---|
| 283 | disp8->Draw("hist");
|
|---|
| 284 | gPad->Update();
|
|---|
| 285 |
|
|---|
| 286 | c2->cd(4);
|
|---|
| 287 | gPad->SetBorderMode(0);
|
|---|
| 288 | gPad->Divide(1,1);
|
|---|
| 289 | gPad->cd(1);
|
|---|
| 290 | disp6->Draw();
|
|---|
| 291 |
|
|---|
| 292 | c2->cd(5);
|
|---|
| 293 | gPad->SetBorderMode(0);
|
|---|
| 294 | gPad->Divide(1,1);
|
|---|
| 295 | gPad->cd(1);
|
|---|
| 296 | disp7->Draw();
|
|---|
| 297 |
|
|---|
| 298 | c2->cd(6);
|
|---|
| 299 | gPad->SetBorderMode(0);
|
|---|
| 300 | gPad->Divide(1,1);
|
|---|
| 301 | gPad->cd(1);
|
|---|
| 302 | disp8->Draw();
|
|---|
| 303 |
|
|---|
| 304 |
|
|---|
| 305 | TCanvas *c3 = MH::MakeDefCanvas("Calibration3","Plots of Pedestals",700,900);
|
|---|
| 306 | c3->Divide(2, 2);
|
|---|
| 307 |
|
|---|
| 308 | c3->cd(1);
|
|---|
| 309 | gStyle->SetOptStat(1111);
|
|---|
| 310 | disp9->Draw("hist");
|
|---|
| 311 | gPad->Update();
|
|---|
| 312 |
|
|---|
| 313 | c3->cd(2);
|
|---|
| 314 | gStyle->SetOptStat(1101);
|
|---|
| 315 | disp10->Draw("hist");
|
|---|
| 316 | gPad->Update();
|
|---|
| 317 |
|
|---|
| 318 | c3->cd(3);
|
|---|
| 319 | gPad->SetBorderMode(0);
|
|---|
| 320 | gPad->Divide(1,1);
|
|---|
| 321 | gPad->cd(1);
|
|---|
| 322 | disp9->Draw();
|
|---|
| 323 |
|
|---|
| 324 | c3->cd(4);
|
|---|
| 325 | gPad->SetBorderMode(0);
|
|---|
| 326 | gPad->Divide(1,1);
|
|---|
| 327 | gPad->cd(1);
|
|---|
| 328 | disp10->Draw();
|
|---|
| 329 |
|
|---|
| 330 | TCanvas *c4 = MH::MakeDefCanvas("Calibration4","Plots of Reduced Charges",700,900);
|
|---|
| 331 | c3->Divide(2, 2);
|
|---|
| 332 |
|
|---|
| 333 | c4->cd(1);
|
|---|
| 334 | gStyle->SetOptStat(1111);
|
|---|
| 335 | disp11->Draw("hist");
|
|---|
| 336 | gPad->Update();
|
|---|
| 337 |
|
|---|
| 338 | c4->cd(2);
|
|---|
| 339 | gStyle->SetOptStat(1101);
|
|---|
| 340 | disp12->Draw("hist");
|
|---|
| 341 | gPad->Update();
|
|---|
| 342 |
|
|---|
| 343 | c4->cd(3);
|
|---|
| 344 | gPad->SetBorderMode(0);
|
|---|
| 345 | gPad->Divide(1,1);
|
|---|
| 346 | gPad->cd(1);
|
|---|
| 347 | disp11->Draw();
|
|---|
| 348 |
|
|---|
| 349 | c4->cd(4);
|
|---|
| 350 | gPad->SetBorderMode(0);
|
|---|
| 351 | gPad->Divide(1,1);
|
|---|
| 352 | gPad->cd(1);
|
|---|
| 353 | disp12->Draw();
|
|---|
| 354 |
|
|---|
| 355 |
|
|---|
| 356 |
|
|---|
| 357 | // c->SaveAs(fname(0, fname.Last('.')+1) + "ps");
|
|---|
| 358 | //c->SaveAs(fname(0, fname.Last('.')+1) + "root");
|
|---|
| 359 |
|
|---|
| 360 | }
|
|---|
| 361 |
|
|---|