| 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, 1/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 19 | ! Author(s): Markus Gaug, 4/2004 <mailto:markus@ifae.es>
|
|---|
| 20 | !
|
|---|
| 21 | ! Copyright: MAGIC Software Development, 2000-2004
|
|---|
| 22 | !
|
|---|
| 23 | !
|
|---|
| 24 | \* ======================================================================== */
|
|---|
| 25 |
|
|---|
| 26 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 27 | //
|
|---|
| 28 | // MJPedestal
|
|---|
| 29 | //
|
|---|
| 30 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 31 | #include "MJPedestal.h"
|
|---|
| 32 |
|
|---|
| 33 | // root classes
|
|---|
| 34 | #include <TF1.h>
|
|---|
| 35 | #include <TEnv.h>
|
|---|
| 36 | #include <TFile.h>
|
|---|
| 37 | #include <TLine.h>
|
|---|
| 38 | #include <TLatex.h>
|
|---|
| 39 | #include <TString.h>
|
|---|
| 40 | #include <TCanvas.h>
|
|---|
| 41 | #include <TSystem.h>
|
|---|
| 42 | #include <TLegend.h>
|
|---|
| 43 | #include <TPad.h>
|
|---|
| 44 |
|
|---|
| 45 | // mars core
|
|---|
| 46 | #include "MLog.h"
|
|---|
| 47 | #include "MLogManip.h"
|
|---|
| 48 |
|
|---|
| 49 | #include "MTaskEnv.h"
|
|---|
| 50 | #include "MSequence.h"
|
|---|
| 51 | #include "MRunIter.h"
|
|---|
| 52 | #include "MParList.h"
|
|---|
| 53 | #include "MTaskList.h"
|
|---|
| 54 | #include "MEvtLoop.h"
|
|---|
| 55 |
|
|---|
| 56 | #include "MStatusDisplay.h"
|
|---|
| 57 |
|
|---|
| 58 | // Other basic classes
|
|---|
| 59 | #include "MExtractor.h"
|
|---|
| 60 |
|
|---|
| 61 | // parameter containers
|
|---|
| 62 | #include "MGeomCam.h"
|
|---|
| 63 | #include "MHCamera.h"
|
|---|
| 64 | #include "MPedestalCam.h"
|
|---|
| 65 | #include "MPedestalPix.h"
|
|---|
| 66 | #include "MBadPixelsCam.h"
|
|---|
| 67 |
|
|---|
| 68 | #include "MCalibrationPedCam.h"
|
|---|
| 69 | #include "MCalibrationPix.h"
|
|---|
| 70 | #include "MHPedestalCam.h"
|
|---|
| 71 | #include "MHPedestalPix.h"
|
|---|
| 72 |
|
|---|
| 73 | // tasks
|
|---|
| 74 | #include "MReadMarsFile.h"
|
|---|
| 75 | #include "MRawFileRead.h"
|
|---|
| 76 | #include "MGeomApply.h"
|
|---|
| 77 | #include "MBadPixelsMerge.h"
|
|---|
| 78 | #include "MFillH.h"
|
|---|
| 79 | #include "MPedCalcPedRun.h"
|
|---|
| 80 | #include "MPedCalcFromLoGain.h"
|
|---|
| 81 |
|
|---|
| 82 | ClassImp(MJPedestal);
|
|---|
| 83 |
|
|---|
| 84 | using namespace std;
|
|---|
| 85 |
|
|---|
| 86 | const Double_t MJPedestal::fgPedestalMin = 4.;
|
|---|
| 87 | const Double_t MJPedestal::fgPedestalMax = 16.;
|
|---|
| 88 | const Double_t MJPedestal::fgPedRmsMin = 0.;
|
|---|
| 89 | const Double_t MJPedestal::fgPedRmsMax = 20.;
|
|---|
| 90 |
|
|---|
| 91 | const Float_t MJPedestal::fgRefPedClosedLids = 9.635;
|
|---|
| 92 | const Float_t MJPedestal::fgRefPedExtraGalactic = 9.93;
|
|---|
| 93 | const Float_t MJPedestal::fgRefPedGalactic = 10.03;
|
|---|
| 94 | const Float_t MJPedestal::fgRefPedRmsClosedLidsInner = 1.7;
|
|---|
| 95 | const Float_t MJPedestal::fgRefPedRmsExtraGalacticInner = 5.6;
|
|---|
| 96 | const Float_t MJPedestal::fgRefPedRmsGalacticInner = 6.92;
|
|---|
| 97 | const Float_t MJPedestal::fgRefPedRmsClosedLidsOuter = 1.7;
|
|---|
| 98 | const Float_t MJPedestal::fgRefPedRmsExtraGalacticOuter = 3.35;
|
|---|
| 99 | const Float_t MJPedestal::fgRefPedRmsGalacticOuter = 4.2;
|
|---|
| 100 |
|
|---|
| 101 | // --------------------------------------------------------------------------
|
|---|
| 102 | //
|
|---|
| 103 | // Default constructor.
|
|---|
| 104 | //
|
|---|
| 105 | // Sets:
|
|---|
| 106 | // - fRuns to 0,
|
|---|
| 107 | // - fExtractor to NULL,
|
|---|
| 108 | // - fDataCheck to kFALSE,
|
|---|
| 109 | // - fExtractType to kUsePedRun
|
|---|
| 110 | // - fStorage to Normal Storage
|
|---|
| 111 | // - fExtractorResolution to kFALSE
|
|---|
| 112 | //
|
|---|
| 113 | MJPedestal::MJPedestal(const char *name, const char *title)
|
|---|
| 114 | : fRuns(0), fExtractor(NULL), fDisplayType(kNormalDisplay),
|
|---|
| 115 | fDataCheck(kFALSE), fExtractType(kUsePedRun)
|
|---|
| 116 | {
|
|---|
| 117 | fName = name ? name : "MJPedestal";
|
|---|
| 118 | fTitle = title ? title : "Tool to create a pedestal file (MPedestalCam)";
|
|---|
| 119 |
|
|---|
| 120 | SetNormalStorage();
|
|---|
| 121 | SetUsePedRun();
|
|---|
| 122 | SetPathIn("");
|
|---|
| 123 | SetExtractorResolution(kFALSE);
|
|---|
| 124 | }
|
|---|
| 125 |
|
|---|
| 126 | MJPedestal::~MJPedestal()
|
|---|
| 127 | {
|
|---|
| 128 | if (fExtractor)
|
|---|
| 129 | delete fExtractor;
|
|---|
| 130 | }
|
|---|
| 131 |
|
|---|
| 132 | const char* MJPedestal::GetOutputFile() const
|
|---|
| 133 | {
|
|---|
| 134 | if (fSequence.IsValid())
|
|---|
| 135 | return Form("%s/pedest%06d.root", (const char*)fPathOut, fSequence.GetSequence());
|
|---|
| 136 |
|
|---|
| 137 | if (!fRuns)
|
|---|
| 138 | return "";
|
|---|
| 139 |
|
|---|
| 140 | return Form("%s/%s-F0.root", (const char*)fPathOut, (const char*)fRuns->GetRunsAsFileName());
|
|---|
| 141 | }
|
|---|
| 142 |
|
|---|
| 143 | //---------------------------------------------------------------------------------
|
|---|
| 144 | //
|
|---|
| 145 | // Try to read an existing MPedestalCam from a previously created output file.
|
|---|
| 146 | // If found, also an MBadPixelsCam and the corresponding display is read.
|
|---|
| 147 | //
|
|---|
| 148 | // In case of Storage type "kNoStorage" or if the file is not found or the
|
|---|
| 149 | // MPedestalCam cannot be read, return kFALSE, otherwise kTRUE.
|
|---|
| 150 | //
|
|---|
| 151 | Bool_t MJPedestal::ReadPedestalCam()
|
|---|
| 152 | {
|
|---|
| 153 | const TString fname = GetOutputFile();
|
|---|
| 154 |
|
|---|
| 155 | *fLog << inf << "Reading pedestals from file: " << fname << endl;
|
|---|
| 156 |
|
|---|
| 157 | TFile file(fname, "READ");
|
|---|
| 158 | if (fPedestalCamIn.Read()<=0)
|
|---|
| 159 | {
|
|---|
| 160 | *fLog << err << "Unable to read incoming MPedestalCam from " << fname << endl;
|
|---|
| 161 | return kFALSE;
|
|---|
| 162 | }
|
|---|
| 163 |
|
|---|
| 164 | if (fPedestalCamOut.Read()<=0)
|
|---|
| 165 | {
|
|---|
| 166 | *fLog << err << "Unable to read outgoing MPedestalCam from " << fname << endl;
|
|---|
| 167 | return kFALSE;
|
|---|
| 168 | }
|
|---|
| 169 |
|
|---|
| 170 | if (file.FindKey("MBadPixelsCam"))
|
|---|
| 171 | {
|
|---|
| 172 | MBadPixelsCam bad;
|
|---|
| 173 | if (bad.Read()<=0)
|
|---|
| 174 | {
|
|---|
| 175 | *fLog << err << "Unable to read MBadPixelsCam from " << fname << endl;
|
|---|
| 176 | return kFALSE;
|
|---|
| 177 | }
|
|---|
| 178 | fBadPixels.Merge(bad);
|
|---|
| 179 | }
|
|---|
| 180 |
|
|---|
| 181 | if (fDisplay && !fDisplay->GetCanvas("Pedestals"))
|
|---|
| 182 | fDisplay->Read();
|
|---|
| 183 |
|
|---|
| 184 | return kTRUE;
|
|---|
| 185 | }
|
|---|
| 186 |
|
|---|
| 187 | MExtractor *MJPedestal::ReadCalibration() const
|
|---|
| 188 | {
|
|---|
| 189 | const TString fname = Form("%s/calib%06d.root",fPathIn.Data(), fSequence.GetSequence());
|
|---|
| 190 |
|
|---|
| 191 | *fLog << inf << "Reading extractor from file: " << fname << endl;
|
|---|
| 192 |
|
|---|
| 193 | TFile file(fname, "READ");
|
|---|
| 194 | if (!file.IsOpen())
|
|---|
| 195 | {
|
|---|
| 196 | *fLog << err << dbginf << "ERROR - Could not open file " << fname << endl;
|
|---|
| 197 | return NULL;
|
|---|
| 198 | }
|
|---|
| 199 |
|
|---|
| 200 | TObject *o = file.Get("ExtractSignal");
|
|---|
| 201 | if (o && !o->InheritsFrom(MExtractor::Class()))
|
|---|
| 202 | {
|
|---|
| 203 | *fLog << err << dbginf << "ERROR - ExtractSignal read from " << fname << " doesn't inherit from MExtractor!" << endl;
|
|---|
| 204 | return NULL;
|
|---|
| 205 | }
|
|---|
| 206 |
|
|---|
| 207 | return o ? (MExtractor*)o->Clone("ExtractSignal") : NULL;
|
|---|
| 208 | }
|
|---|
| 209 |
|
|---|
| 210 | //---------------------------------------------------------------------------------
|
|---|
| 211 | //
|
|---|
| 212 | // Display the results.
|
|---|
| 213 | // If Display type "kDataCheck" was chosen, also the reference lines are displayed.
|
|---|
| 214 | //
|
|---|
| 215 | void MJPedestal::DisplayResult(MParList &plist)
|
|---|
| 216 | {
|
|---|
| 217 | if (!fDisplay)
|
|---|
| 218 | return;
|
|---|
| 219 |
|
|---|
| 220 | //
|
|---|
| 221 | // Update display
|
|---|
| 222 | //
|
|---|
| 223 | TString title = fDisplay->GetTitle();
|
|---|
| 224 | title += "-- Pedestal ";
|
|---|
| 225 | if (fSequence.IsValid())
|
|---|
| 226 | title += fSequence.GetName();
|
|---|
| 227 | else
|
|---|
| 228 | if (fRuns) // FIXME: What to do if an environmentfile was used?
|
|---|
| 229 | title += fRuns->GetRunsAsString();
|
|---|
| 230 | title += " --";
|
|---|
| 231 | fDisplay->SetTitle(title);
|
|---|
| 232 |
|
|---|
| 233 | //
|
|---|
| 234 | // Get container from list
|
|---|
| 235 | //
|
|---|
| 236 | MGeomCam &geomcam = *(MGeomCam*)plist.FindObject("MGeomCam");
|
|---|
| 237 | MCalibrationPedCam &calpedcam = *(MCalibrationPedCam*)plist.FindObject("MCalibrationPedCam");
|
|---|
| 238 |
|
|---|
| 239 | //
|
|---|
| 240 | // Create container to display
|
|---|
| 241 | //
|
|---|
| 242 | MHCamera disp0 (geomcam, "MPedestalCam;ped", "Mean Pedestal");
|
|---|
| 243 | MHCamera disp1 (geomcam, "MPedestalCam;RMS", "Pedestal RMS");
|
|---|
| 244 | MHCamera disp2 (geomcam, "MCalibPedCam;histmean", "Mean Pedestal (Hist.)");
|
|---|
| 245 | MHCamera disp3 (geomcam, "MCalibPedCam;histsigma", "Pedestal RMS (Hist.)");
|
|---|
| 246 | MHCamera disp4 (geomcam, "MCalibPedCam;ped", "Mean Pedestal");
|
|---|
| 247 | MHCamera disp5 (geomcam, "MCalibPedCam;RMS", "Pedestal RMS");
|
|---|
| 248 | MHCamera disp6 (geomcam, "MCalibDiffCam;ped", "Diff. Mean Pedestal (Hist.)");
|
|---|
| 249 | MHCamera disp7 (geomcam, "MCalibDiffCam;RMS", "Diff. Pedestal RMS (Hist.)");
|
|---|
| 250 | MHCamera disp8 (geomcam, "MCalibDiffCam;ped", "Diff. Mean Pedestal");
|
|---|
| 251 | MHCamera disp9 (geomcam, "MCalibDiffCam;AbsRMS", "Diff. Abs. Pedestal RMS");
|
|---|
| 252 | MHCamera disp10(geomcam, "MCalibDiffCam;RelRMS", "Diff. Rel. Pedestal RMS");
|
|---|
| 253 |
|
|---|
| 254 | disp0.SetCamContent(fPedestalCamOut, 0);
|
|---|
| 255 | disp0.SetCamError (fPedestalCamOut, 1);
|
|---|
| 256 |
|
|---|
| 257 | disp1.SetCamContent(fPedestalCamOut, 2);
|
|---|
| 258 | disp1.SetCamError (fPedestalCamOut, 3);
|
|---|
| 259 |
|
|---|
| 260 | if (fExtractType == kUseHists)
|
|---|
| 261 | {
|
|---|
| 262 | disp2.SetCamContent(calpedcam, 0);
|
|---|
| 263 | disp2.SetCamError (calpedcam, 1);
|
|---|
| 264 |
|
|---|
| 265 | disp3.SetCamContent(calpedcam, 2);
|
|---|
| 266 | disp3.SetCamError (calpedcam, 3);
|
|---|
| 267 |
|
|---|
| 268 | disp4.SetCamContent(calpedcam, 5);
|
|---|
| 269 | disp4.SetCamError (calpedcam, 6);
|
|---|
| 270 |
|
|---|
| 271 | disp5.SetCamContent(calpedcam, 7);
|
|---|
| 272 | disp5.SetCamError (calpedcam, 8);
|
|---|
| 273 |
|
|---|
| 274 | for (UInt_t i=0;i<geomcam.GetNumPixels();i++)
|
|---|
| 275 | {
|
|---|
| 276 |
|
|---|
| 277 | MPedestalPix &ped = fPedestalCamOut[i];
|
|---|
| 278 | MCalibrationPix &hist = calpedcam [i];
|
|---|
| 279 | MBadPixelsPix &bad = fBadPixels[i];
|
|---|
| 280 |
|
|---|
| 281 | if (bad.IsUnsuitable())
|
|---|
| 282 | continue;
|
|---|
| 283 |
|
|---|
| 284 | disp6.Fill(i,ped.GetPedestal()-hist.GetHiGainMean());
|
|---|
| 285 | disp6.SetUsed(i);
|
|---|
| 286 |
|
|---|
| 287 | disp7.Fill(i,hist.GetHiGainSigma()-ped.GetPedestalRms());
|
|---|
| 288 | if (TMath::Abs(ped.GetPedestalRms()-hist.GetHiGainSigma()) < 4.0)
|
|---|
| 289 | disp7.SetUsed(i);
|
|---|
| 290 |
|
|---|
| 291 | disp8.Fill(i,ped.GetPedestal()-hist.GetLoGainMean());
|
|---|
| 292 | disp8.SetUsed(i);
|
|---|
| 293 |
|
|---|
| 294 | disp9.Fill(i,hist.GetLoGainSigma()-ped.GetPedestalRms());
|
|---|
| 295 | if (TMath::Abs(hist.GetLoGainSigma() - ped.GetPedestalRms()) < 4.0)
|
|---|
| 296 | disp9.SetUsed(i);
|
|---|
| 297 | }
|
|---|
| 298 | }
|
|---|
| 299 |
|
|---|
| 300 | if (fExtractorResolution)
|
|---|
| 301 | {
|
|---|
| 302 | for (UInt_t i=0;i<geomcam.GetNumPixels();i++)
|
|---|
| 303 | {
|
|---|
| 304 |
|
|---|
| 305 | MPedestalPix &pedo = fPedestalCamOut[i];
|
|---|
| 306 | MPedestalPix &pedi = fPedestalCamIn[i];
|
|---|
| 307 | MBadPixelsPix &bad = fBadPixels[i];
|
|---|
| 308 |
|
|---|
| 309 | if (bad.IsUnsuitable())
|
|---|
| 310 | continue;
|
|---|
| 311 |
|
|---|
| 312 | const Float_t diff = pedo.GetPedestalRms()-pedi.GetPedestalRms();
|
|---|
| 313 | const Float_t sum = 0.5*(pedo.GetPedestalRms()+pedi.GetPedestalRms());
|
|---|
| 314 |
|
|---|
| 315 | disp9.Fill(i,pedo.GetPedestalRms()-pedi.GetPedestalRms());
|
|---|
| 316 | if (pedo.IsValid() && pedi.IsValid())
|
|---|
| 317 | disp9.SetUsed(i);
|
|---|
| 318 |
|
|---|
| 319 | disp10.Fill(i,sum == 0. ? 0. : diff/sum);
|
|---|
| 320 | if (pedo.IsValid() && pedi.IsValid() && sum != 0.)
|
|---|
| 321 | disp10.SetUsed(i);
|
|---|
| 322 | }
|
|---|
| 323 | }
|
|---|
| 324 |
|
|---|
| 325 | disp0.SetYTitle("P [cts/slice]");
|
|---|
| 326 | disp1.SetYTitle("P_{rms} [cts/slice]");
|
|---|
| 327 | disp2.SetYTitle("Hist. Mean [cts/slice]");
|
|---|
| 328 | disp3.SetYTitle("Hist. Sigma [cts/slice]");
|
|---|
| 329 | disp4.SetYTitle("Calc. Mean [cts/slice]");
|
|---|
| 330 | disp5.SetYTitle("Calc. RMS [cts/slice]");
|
|---|
| 331 | disp6.SetYTitle("Diff. Mean [cts/slice]");
|
|---|
| 332 | disp7.SetYTitle("Diff. RMS [cts/slice]");
|
|---|
| 333 | disp8.SetYTitle("Diff. Mean [cts/slice]");
|
|---|
| 334 | disp9.SetYTitle("Abs.Diff.RMS [cts/slice]");
|
|---|
| 335 | disp10.SetYTitle("Rel.Diff.RMS [1]");
|
|---|
| 336 |
|
|---|
| 337 | //
|
|---|
| 338 | // Display data
|
|---|
| 339 | //
|
|---|
| 340 | if (fDisplayType != kDataCheckDisplay && fExtractType != kUseHists && !fExtractorResolution)
|
|---|
| 341 | {
|
|---|
| 342 | TCanvas &c3 = fDisplay->AddTab("Pedestals");
|
|---|
| 343 | c3.Divide(2,3);
|
|---|
| 344 |
|
|---|
| 345 | disp0.CamDraw(c3, 1, 2, 1);
|
|---|
| 346 | disp1.CamDraw(c3, 2, 2, 6);
|
|---|
| 347 | return;
|
|---|
| 348 | }
|
|---|
| 349 |
|
|---|
| 350 | if (fExtractType == kUseHists)
|
|---|
| 351 | {
|
|---|
| 352 |
|
|---|
| 353 | TCanvas &c3 = fDisplay->AddTab("Extractor Hist.");
|
|---|
| 354 | c3.Divide(2,3);
|
|---|
| 355 |
|
|---|
| 356 | disp2.CamDraw(c3, 1, 2, 1);
|
|---|
| 357 | disp3.CamDraw(c3, 2, 2, 5);
|
|---|
| 358 |
|
|---|
| 359 | TCanvas &c4 = fDisplay->AddTab("Extractor Calc.");
|
|---|
| 360 | c4.Divide(2,3);
|
|---|
| 361 |
|
|---|
| 362 | disp4.CamDraw(c4, 1, 2, 1);
|
|---|
| 363 | disp5.CamDraw(c4, 2, 2, 5);
|
|---|
| 364 |
|
|---|
| 365 |
|
|---|
| 366 | TCanvas &c5 = fDisplay->AddTab("Difference Hist.");
|
|---|
| 367 | c5.Divide(2,3);
|
|---|
| 368 |
|
|---|
| 369 | disp6.CamDraw(c5, 1, 2, 1);
|
|---|
| 370 | disp7.CamDraw(c5, 2, 2, 5);
|
|---|
| 371 |
|
|---|
| 372 | TCanvas &c6 = fDisplay->AddTab("Difference Calc.");
|
|---|
| 373 | c6.Divide(2,3);
|
|---|
| 374 |
|
|---|
| 375 | disp8.CamDraw(c6, 1, 2, 1);
|
|---|
| 376 | disp9.CamDraw(c6, 2, 2, 5);
|
|---|
| 377 | return;
|
|---|
| 378 | }
|
|---|
| 379 |
|
|---|
| 380 | if (fDisplayType == kDataCheckDisplay)
|
|---|
| 381 | {
|
|---|
| 382 |
|
|---|
| 383 | TCanvas &c3 = fDisplay->AddTab(fExtractorResolution ? "PedExtrd" : "Ped");
|
|---|
| 384 | c3.Divide(2,3);
|
|---|
| 385 |
|
|---|
| 386 | c3.cd(1);
|
|---|
| 387 | gPad->SetBorderMode(0);
|
|---|
| 388 | gPad->SetTicks();
|
|---|
| 389 | MHCamera *obj1=(MHCamera*)disp0.DrawCopy("hist");
|
|---|
| 390 | //
|
|---|
| 391 | // for the datacheck, fix the ranges!!
|
|---|
| 392 | //
|
|---|
| 393 | if (!fExtractorResolution)
|
|---|
| 394 | {
|
|---|
| 395 | obj1->SetMinimum(fgPedestalMin);
|
|---|
| 396 | obj1->SetMaximum(fgPedestalMax);
|
|---|
| 397 | //
|
|---|
| 398 | // Set the datacheck sizes:
|
|---|
| 399 | //
|
|---|
| 400 | FixDataCheckHist((TH1D*)obj1);
|
|---|
| 401 | //
|
|---|
| 402 | // set reference lines
|
|---|
| 403 | //
|
|---|
| 404 | DisplayReferenceLines(obj1,0);
|
|---|
| 405 | }
|
|---|
| 406 |
|
|---|
| 407 | //
|
|---|
| 408 | // end reference lines
|
|---|
| 409 | //
|
|---|
| 410 | c3.cd(3);
|
|---|
| 411 | gPad->SetBorderMode(0);
|
|---|
| 412 | obj1->SetPrettyPalette();
|
|---|
| 413 | obj1->Draw();
|
|---|
| 414 |
|
|---|
| 415 | c3.cd(5);
|
|---|
| 416 | gPad->SetBorderMode(0);
|
|---|
| 417 | gPad->SetTicks();
|
|---|
| 418 | TH1D *obj2 = (TH1D*)obj1->Projection(obj1->GetName());
|
|---|
| 419 | obj2->Draw();
|
|---|
| 420 | obj2->SetBit(kCanDelete);
|
|---|
| 421 | obj2->Fit("gaus","Q");
|
|---|
| 422 | obj2->GetFunction("gaus")->SetLineColor(kYellow);
|
|---|
| 423 | //
|
|---|
| 424 | // Set the datacheck sizes:
|
|---|
| 425 | //
|
|---|
| 426 | FixDataCheckHist(obj2);
|
|---|
| 427 | obj2->SetStats(1);
|
|---|
| 428 |
|
|---|
| 429 | c3.cd(2);
|
|---|
| 430 | gPad->SetBorderMode(0);
|
|---|
| 431 | gPad->SetTicks();
|
|---|
| 432 | MHCamera *obj3=(MHCamera*)disp1.DrawCopy("hist");
|
|---|
| 433 | //
|
|---|
| 434 | // for the datacheck, fix the ranges!!
|
|---|
| 435 | //
|
|---|
| 436 | obj3->SetMinimum(fgPedRmsMin);
|
|---|
| 437 | obj3->SetMaximum(fgPedRmsMax);
|
|---|
| 438 | //
|
|---|
| 439 | // Set the datacheck sizes:
|
|---|
| 440 | //
|
|---|
| 441 | FixDataCheckHist((TH1D*)obj3);
|
|---|
| 442 | //
|
|---|
| 443 | // set reference lines
|
|---|
| 444 | //
|
|---|
| 445 | DisplayReferenceLines(obj3,1);
|
|---|
| 446 |
|
|---|
| 447 | c3.cd(4);
|
|---|
| 448 | gPad->SetBorderMode(0);
|
|---|
| 449 | obj3->SetPrettyPalette();
|
|---|
| 450 | obj3->Draw();
|
|---|
| 451 |
|
|---|
| 452 | c3.cd(6);
|
|---|
| 453 | gPad->SetBorderMode(0);
|
|---|
| 454 |
|
|---|
| 455 | if (geomcam.InheritsFrom("MGeomCamMagic"))
|
|---|
| 456 | {
|
|---|
| 457 | TArrayI inner(1);
|
|---|
| 458 | inner[0] = 0;
|
|---|
| 459 |
|
|---|
| 460 | TArrayI outer(1);
|
|---|
| 461 | outer[0] = 1;
|
|---|
| 462 |
|
|---|
| 463 | TArrayI s0(6);
|
|---|
| 464 | s0[0] = 6;
|
|---|
| 465 | s0[1] = 1;
|
|---|
| 466 | s0[2] = 2;
|
|---|
| 467 | s0[3] = 3;
|
|---|
| 468 | s0[4] = 4;
|
|---|
| 469 | s0[5] = 5;
|
|---|
| 470 |
|
|---|
| 471 | TArrayI s1(3);
|
|---|
| 472 | s1[0] = 6;
|
|---|
| 473 | s1[1] = 1;
|
|---|
| 474 | s1[2] = 2;
|
|---|
| 475 |
|
|---|
| 476 | TArrayI s2(3);
|
|---|
| 477 | s2[0] = 3;
|
|---|
| 478 | s2[1] = 4;
|
|---|
| 479 | s2[2] = 5;
|
|---|
| 480 |
|
|---|
| 481 | TVirtualPad *pad = gPad;
|
|---|
| 482 | pad->Divide(2,1);
|
|---|
| 483 |
|
|---|
| 484 | TH1D *inout[2];
|
|---|
| 485 | inout[0] = disp1.ProjectionS(s0, inner, "Inner");
|
|---|
| 486 | inout[1] = disp1.ProjectionS(s0, outer, "Outer");
|
|---|
| 487 | FixDataCheckHist(inout[0]);
|
|---|
| 488 | FixDataCheckHist(inout[1]);
|
|---|
| 489 |
|
|---|
| 490 | inout[0]->SetTitle(Form("%s %s",disp1.GetTitle(),"Inner"));
|
|---|
| 491 | inout[1]->SetTitle(Form("%s %s",disp1.GetTitle(),"Outer"));
|
|---|
| 492 |
|
|---|
| 493 |
|
|---|
| 494 | for (int i=0; i<2; i++)
|
|---|
| 495 | {
|
|---|
| 496 | pad->cd(i+1);
|
|---|
| 497 | gPad->SetBorderMode(0);
|
|---|
| 498 | gPad->SetTicks();
|
|---|
| 499 |
|
|---|
| 500 | inout[i]->SetDirectory(NULL);
|
|---|
| 501 | inout[i]->SetLineColor(kRed+i);
|
|---|
| 502 | inout[i]->SetBit(kCanDelete);
|
|---|
| 503 | inout[i]->Draw();
|
|---|
| 504 | inout[i]->Fit("gaus", "Q");
|
|---|
| 505 |
|
|---|
| 506 | TLegend *leg2 = new TLegend(0.6,0.2,0.9,0.55);
|
|---|
| 507 | leg2->SetHeader(inout[i]->GetName());
|
|---|
| 508 | leg2->AddEntry(inout[i], inout[i]->GetName(), "l");
|
|---|
| 509 |
|
|---|
| 510 | //
|
|---|
| 511 | // Display the outliers as dead and noisy pixels
|
|---|
| 512 | //
|
|---|
| 513 | DisplayOutliers(inout[i]);
|
|---|
| 514 |
|
|---|
| 515 | //
|
|---|
| 516 | // Display the two half of the camera separately
|
|---|
| 517 | //
|
|---|
| 518 | TH1D *half[2];
|
|---|
| 519 | half[0] = disp1.ProjectionS(s1, i==0 ? inner : outer , "Sector 6-1-2");
|
|---|
| 520 | half[1] = disp1.ProjectionS(s2, i==0 ? inner : outer , "Sector 3-4-5");
|
|---|
| 521 |
|
|---|
| 522 | for (int j=0; j<2; j++)
|
|---|
| 523 | {
|
|---|
| 524 | half[j]->SetLineColor(kRed+i+2*j+1);
|
|---|
| 525 | half[j]->SetDirectory(NULL);
|
|---|
| 526 | half[j]->SetBit(kCanDelete);
|
|---|
| 527 | half[j]->Draw("same");
|
|---|
| 528 | leg2->AddEntry(half[j], half[j]->GetName(), "l");
|
|---|
| 529 | }
|
|---|
| 530 | leg2->Draw();
|
|---|
| 531 | delete leg2;
|
|---|
| 532 | }
|
|---|
| 533 | return;
|
|---|
| 534 | }
|
|---|
| 535 | }
|
|---|
| 536 |
|
|---|
| 537 | if (fExtractorResolution)
|
|---|
| 538 | {
|
|---|
| 539 |
|
|---|
| 540 | TCanvas &c3 = fDisplay->AddTab("PedExtrd");
|
|---|
| 541 | c3.Divide(2,3);
|
|---|
| 542 |
|
|---|
| 543 | disp0.CamDraw(c3, 1, 2, 1);
|
|---|
| 544 | disp1.CamDraw(c3, 2, 2, 6);
|
|---|
| 545 |
|
|---|
| 546 | TCanvas &c13 = fDisplay->AddTab("PedDiff");
|
|---|
| 547 | c13.Divide(2,3);
|
|---|
| 548 |
|
|---|
| 549 | disp9.CamDraw(c13, 1, 2, 5);
|
|---|
| 550 | disp10.CamDraw(c13, 2, 2, 5);
|
|---|
| 551 | return;
|
|---|
| 552 | }
|
|---|
| 553 | }
|
|---|
| 554 |
|
|---|
| 555 |
|
|---|
| 556 | void MJPedestal::DisplayReferenceLines(MHCamera *cam, const Int_t what) const
|
|---|
| 557 | {
|
|---|
| 558 |
|
|---|
| 559 | Double_t x = cam->GetNbinsX();
|
|---|
| 560 |
|
|---|
| 561 | const MGeomCam *geom = cam->GetGeometry();
|
|---|
| 562 |
|
|---|
| 563 | if (geom->InheritsFrom("MGeomCamMagic"))
|
|---|
| 564 | x = what ? 397 : cam->GetNbinsX();
|
|---|
| 565 |
|
|---|
| 566 | TLine line;
|
|---|
| 567 | line.SetLineStyle(kDashed);
|
|---|
| 568 | line.SetLineWidth(3);
|
|---|
| 569 |
|
|---|
| 570 | line.SetLineColor(kBlue);
|
|---|
| 571 | TLine *l1 = line.DrawLine(0, what ? fgRefPedRmsGalacticInner : fgRefPedGalactic,
|
|---|
| 572 | x, what ? fgRefPedRmsGalacticInner : fgRefPedGalactic);
|
|---|
| 573 |
|
|---|
| 574 | line.SetLineColor(kYellow);
|
|---|
| 575 | TLine *l2 = line.DrawLine(0, what ? fgRefPedRmsExtraGalacticInner : fgRefPedExtraGalactic,
|
|---|
| 576 | x, what ? fgRefPedRmsExtraGalacticInner : fgRefPedExtraGalactic);
|
|---|
| 577 |
|
|---|
| 578 | line.SetLineColor(kMagenta);
|
|---|
| 579 | TLine *l3 = line.DrawLine(0, what ? fgRefPedRmsClosedLidsInner : fgRefPedClosedLids,
|
|---|
| 580 | x, what ? fgRefPedRmsClosedLidsInner : fgRefPedClosedLids);
|
|---|
| 581 |
|
|---|
| 582 | if (geom->InheritsFrom("MGeomCamMagic"))
|
|---|
| 583 | if (what)
|
|---|
| 584 | {
|
|---|
| 585 | const Double_t x2 = cam->GetNbinsX();
|
|---|
| 586 |
|
|---|
| 587 | line.SetLineColor(kBlue);
|
|---|
| 588 | line.DrawLine(398, fgRefPedRmsGalacticOuter,
|
|---|
| 589 | x2, fgRefPedRmsGalacticOuter);
|
|---|
| 590 |
|
|---|
| 591 | line.SetLineColor(kYellow);
|
|---|
| 592 | line.DrawLine(398, fgRefPedRmsExtraGalacticOuter,
|
|---|
| 593 | x2, fgRefPedRmsExtraGalacticOuter);
|
|---|
| 594 |
|
|---|
| 595 | line.SetLineColor(kMagenta);
|
|---|
| 596 | line.DrawLine(398, fgRefPedRmsClosedLidsOuter,
|
|---|
| 597 | x2, fgRefPedRmsClosedLidsOuter);
|
|---|
| 598 | }
|
|---|
| 599 |
|
|---|
| 600 |
|
|---|
| 601 | TLegend *leg = new TLegend(0.4,0.75,0.7,0.99);
|
|---|
| 602 | leg->SetBit(kCanDelete);
|
|---|
| 603 | leg->AddEntry(l1, "Galactic Source","l");
|
|---|
| 604 | leg->AddEntry(l2, "Extra-Galactic Source","l");
|
|---|
| 605 | leg->AddEntry(l3, "Closed Lids","l");
|
|---|
| 606 | leg->Draw();
|
|---|
| 607 | }
|
|---|
| 608 |
|
|---|
| 609 | void MJPedestal::DisplayOutliers(TH1D *hist) const
|
|---|
| 610 | {
|
|---|
| 611 | const Float_t mean = hist->GetFunction("gaus")->GetParameter(1);
|
|---|
| 612 | const Float_t lolim = mean - 3.5*hist->GetFunction("gaus")->GetParameter(2);
|
|---|
| 613 | const Float_t uplim = mean + 3.5*hist->GetFunction("gaus")->GetParameter(2);
|
|---|
| 614 | const Stat_t dead = hist->Integral(0,hist->FindBin(lolim)-1);
|
|---|
| 615 | const Stat_t noisy = hist->Integral(hist->FindBin(uplim)+1,hist->GetNbinsX()+1);
|
|---|
| 616 |
|
|---|
| 617 | TLatex deadtex;
|
|---|
| 618 | deadtex.SetTextSize(0.06);
|
|---|
| 619 | deadtex.DrawLatex(0.1,hist->GetBinContent(hist->GetMaximumBin())/1.1,Form("%3i dead pixels",(Int_t)dead));
|
|---|
| 620 |
|
|---|
| 621 | TLatex noisytex;
|
|---|
| 622 | noisytex.SetTextSize(0.06);
|
|---|
| 623 | noisytex.DrawLatex(0.1,hist->GetBinContent(hist->GetMaximumBin())/1.2,Form("%3i noisy pixels",(Int_t)noisy));
|
|---|
| 624 | }
|
|---|
| 625 |
|
|---|
| 626 | void MJPedestal::FixDataCheckHist(TH1D *hist) const
|
|---|
| 627 | {
|
|---|
| 628 | hist->SetDirectory(NULL);
|
|---|
| 629 | hist->SetStats(0);
|
|---|
| 630 |
|
|---|
| 631 | //
|
|---|
| 632 | // set the labels bigger
|
|---|
| 633 | //
|
|---|
| 634 | TAxis *xaxe = hist->GetXaxis();
|
|---|
| 635 | TAxis *yaxe = hist->GetYaxis();
|
|---|
| 636 |
|
|---|
| 637 | xaxe->CenterTitle();
|
|---|
| 638 | yaxe->CenterTitle();
|
|---|
| 639 | xaxe->SetTitleSize(0.06);
|
|---|
| 640 | yaxe->SetTitleSize(0.06);
|
|---|
| 641 | xaxe->SetTitleOffset(0.8);
|
|---|
| 642 | yaxe->SetTitleOffset(0.5);
|
|---|
| 643 | xaxe->SetLabelSize(0.05);
|
|---|
| 644 | yaxe->SetLabelSize(0.05);
|
|---|
| 645 | }
|
|---|
| 646 |
|
|---|
| 647 | /*
|
|---|
| 648 | Bool_t MJPedestal::WriteEventloop(MEvtLoop &evtloop) const
|
|---|
| 649 | {
|
|---|
| 650 | if (fOutputPath.IsNull())
|
|---|
| 651 | return kTRUE;
|
|---|
| 652 |
|
|---|
| 653 | const TString oname(GetOutputFile());
|
|---|
| 654 |
|
|---|
| 655 | *fLog << inf << "Writing to file: " << oname << endl;
|
|---|
| 656 |
|
|---|
| 657 | TFile file(oname, fOverwrite?"RECREATE":"NEW", "File created by MJPedestal", 9);
|
|---|
| 658 | if (!file.IsOpen())
|
|---|
| 659 | {
|
|---|
| 660 | *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
|
|---|
| 661 | return kFALSE;
|
|---|
| 662 | }
|
|---|
| 663 |
|
|---|
| 664 | if (evtloop.Write(fName)<=0)
|
|---|
| 665 | {
|
|---|
| 666 | *fLog << err << "Unable to write MEvtloop to " << oname << endl;
|
|---|
| 667 | return kFALSE;
|
|---|
| 668 | }
|
|---|
| 669 |
|
|---|
| 670 | return kTRUE;
|
|---|
| 671 | }
|
|---|
| 672 | */
|
|---|
| 673 |
|
|---|
| 674 | void MJPedestal::SetExtractor(MExtractor* ext)
|
|---|
| 675 | {
|
|---|
| 676 | if (fExtractor)
|
|---|
| 677 | delete fExtractor;
|
|---|
| 678 | fExtractor = ext ? (MExtractor*)ext->Clone(ext->GetName()) : NULL;
|
|---|
| 679 | }
|
|---|
| 680 |
|
|---|
| 681 | // --------------------------------------------------------------------------
|
|---|
| 682 | //
|
|---|
| 683 | // The following resource options are available:
|
|---|
| 684 | //
|
|---|
| 685 | // Do a datacheck run (read raw-data and enable display)
|
|---|
| 686 | // Prefix.DataCheck: Yes, No <default>
|
|---|
| 687 | //
|
|---|
| 688 | // Show data check display
|
|---|
| 689 | // Prefix.DataCheckDisplay: Yes, No <default>
|
|---|
| 690 | //
|
|---|
| 691 | // Use cosmic data instead of pedestal data (DatRuns)
|
|---|
| 692 | // Prefix.UseData: Yes, No <default>
|
|---|
| 693 | //
|
|---|
| 694 | // Write an output file with pedestals and status-display
|
|---|
| 695 | // Prefix.DisableOutput: Yes, No <default>
|
|---|
| 696 | //
|
|---|
| 697 | Bool_t MJPedestal::CheckEnvLocal()
|
|---|
| 698 | {
|
|---|
| 699 | SetDataCheck(GetEnv("DataCheck", fDataCheck));
|
|---|
| 700 |
|
|---|
| 701 | if (HasEnv("DataCheckDisplay"))
|
|---|
| 702 | fDisplayType = GetEnv("DataCheckDisplay", kFALSE) ? kDataCheckDisplay : kNormalDisplay;
|
|---|
| 703 |
|
|---|
| 704 | if (HasEnv("UseData"))
|
|---|
| 705 | fExtractType = GetEnv("UseData",kFALSE) ? kUseData : kUsePedRun;
|
|---|
| 706 |
|
|---|
| 707 | if (HasEnv("UseHists"))
|
|---|
| 708 | if (GetEnv("UseHists",kFALSE))
|
|---|
| 709 | fExtractType = kUseHists;
|
|---|
| 710 |
|
|---|
| 711 | SetExtractorResolution(GetEnv("ExtractorResolution", fExtractorResolution));
|
|---|
| 712 |
|
|---|
| 713 | SetNoStorage(GetEnv("DisableOutput", IsNoStorage()));
|
|---|
| 714 |
|
|---|
| 715 | MTaskEnv tenv("ExtractSignal");
|
|---|
| 716 | tenv.SetDefault(fExtractor);
|
|---|
| 717 |
|
|---|
| 718 | if (tenv.ReadEnv(*GetEnv(), GetEnvPrefix()+".ExtractSignal", GetEnvDebug())==kERROR)
|
|---|
| 719 | return kFALSE;
|
|---|
| 720 |
|
|---|
| 721 | if (fExtractor==tenv.GetTask())
|
|---|
| 722 | return kTRUE;
|
|---|
| 723 |
|
|---|
| 724 | if (!tenv.GetTask()->InheritsFrom(MExtractor::Class()))
|
|---|
| 725 | {
|
|---|
| 726 | *fLog << err << "ERROR: ExtractSignal from resource file doesn't inherit from MExtractor.... abort." << endl;
|
|---|
| 727 | return kFALSE;
|
|---|
| 728 | }
|
|---|
| 729 |
|
|---|
| 730 | SetExtractor((MExtractor*)tenv.GetTask());
|
|---|
| 731 |
|
|---|
| 732 | return kTRUE;
|
|---|
| 733 | }
|
|---|
| 734 |
|
|---|
| 735 | //---------------------------------------------------------------------------------
|
|---|
| 736 | //
|
|---|
| 737 | // Try to write the created MPedestalCam in the output file.
|
|---|
| 738 | // If possible, also an MBadPixelsCam and the corresponding display is written.
|
|---|
| 739 | //
|
|---|
| 740 | // In case of Storage type "kNoStorage" or if any of the containers
|
|---|
| 741 | // cannot be written, return kFALSE, otherwise kTRUE.
|
|---|
| 742 | //
|
|---|
| 743 | Bool_t MJPedestal::WriteResult()
|
|---|
| 744 | {
|
|---|
| 745 | if (IsNoStorage())
|
|---|
| 746 | return kTRUE;
|
|---|
| 747 |
|
|---|
| 748 | if (fPathOut.IsNull())
|
|---|
| 749 | return kTRUE;
|
|---|
| 750 |
|
|---|
| 751 | const TString oname(GetOutputFile());
|
|---|
| 752 |
|
|---|
| 753 | *fLog << inf << "Writing to file: " << oname << endl;
|
|---|
| 754 |
|
|---|
| 755 | TFile file(oname, "UPDATE", "File created by MJPedestal", 9);
|
|---|
| 756 | if (!file.IsOpen())
|
|---|
| 757 | {
|
|---|
| 758 | *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
|
|---|
| 759 | return kFALSE;
|
|---|
| 760 | }
|
|---|
| 761 |
|
|---|
| 762 | TObjArray cont;
|
|---|
| 763 |
|
|---|
| 764 | if (fDisplay)
|
|---|
| 765 | cont.Add(fDisplay);
|
|---|
| 766 |
|
|---|
| 767 | cont.Add(&fPedestalCamOut);
|
|---|
| 768 | cont.Add(&fBadPixels);
|
|---|
| 769 |
|
|---|
| 770 | return WriteContainer(cont);
|
|---|
| 771 | }
|
|---|
| 772 |
|
|---|
| 773 | Bool_t MJPedestal::Process()
|
|---|
| 774 | {
|
|---|
| 775 | if (!ReadPedestalCam())
|
|---|
| 776 | return ProcessFile();
|
|---|
| 777 |
|
|---|
| 778 | return kTRUE;
|
|---|
| 779 | }
|
|---|
| 780 |
|
|---|
| 781 | Bool_t MJPedestal::SetupExtractor(MParList &plist, MExtractPedestal &extped)
|
|---|
| 782 | {
|
|---|
| 783 | if (!fExtractor)
|
|---|
| 784 | return kTRUE;
|
|---|
| 785 |
|
|---|
| 786 | if (!fExtractorResolution || !fExtractor->InheritsFrom("MExtractTimeAndCharge"))
|
|---|
| 787 | return kFALSE;
|
|---|
| 788 |
|
|---|
| 789 | extped.SetPedestalsIn(&fPedestalCamIn);
|
|---|
| 790 | extped.SetExtractor((MExtractTimeAndCharge*)fExtractor);
|
|---|
| 791 |
|
|---|
| 792 | return kTRUE;
|
|---|
| 793 | }
|
|---|
| 794 |
|
|---|
| 795 | Bool_t MJPedestal::ProcessFile()
|
|---|
| 796 | {
|
|---|
| 797 | if (!fSequence.IsValid())
|
|---|
| 798 | {
|
|---|
| 799 | if (!fRuns)
|
|---|
| 800 | {
|
|---|
| 801 | *fLog << err << "Neither AddRuns nor SetSequence nor SetEnv was called... abort." << endl;
|
|---|
| 802 | return kFALSE;
|
|---|
| 803 | }
|
|---|
| 804 | if (fRuns && fRuns->GetNumRuns() != fRuns->GetNumEntries())
|
|---|
| 805 | {
|
|---|
| 806 | *fLog << err << "Number of files found doesn't match number of runs... abort." << endl;
|
|---|
| 807 | return kFALSE;
|
|---|
| 808 | }
|
|---|
| 809 | }
|
|---|
| 810 |
|
|---|
| 811 | if (!CheckEnv())
|
|---|
| 812 | return kFALSE;
|
|---|
| 813 |
|
|---|
| 814 | // --------------------------------------------------------------------------------
|
|---|
| 815 |
|
|---|
| 816 | const TString type = IsUseData() ? "data" : "pedestal";
|
|---|
| 817 |
|
|---|
| 818 | *fLog << inf;
|
|---|
| 819 | fLog->Separator(GetDescriptor());
|
|---|
| 820 | *fLog << "Calculate MPedestalCam from " << type << "-runs ";
|
|---|
| 821 | if (fSequence.IsValid())
|
|---|
| 822 | *fLog << fSequence.GetName() << endl;
|
|---|
| 823 | else
|
|---|
| 824 | if (fRuns)
|
|---|
| 825 | *fLog << fRuns->GetRunsAsString() << endl;
|
|---|
| 826 | else
|
|---|
| 827 | *fLog << "in Resource File." << endl;
|
|---|
| 828 | *fLog << endl;
|
|---|
| 829 |
|
|---|
| 830 | // --------------------------------------------------------------------------------
|
|---|
| 831 |
|
|---|
| 832 | MParList plist;
|
|---|
| 833 | MTaskList tlist;
|
|---|
| 834 | plist.AddToList(&tlist);
|
|---|
| 835 | plist.AddToList(this); // take care of fDisplay!
|
|---|
| 836 |
|
|---|
| 837 | MReadMarsFile read("Events");
|
|---|
| 838 | MRawFileRead rawread(NULL);
|
|---|
| 839 |
|
|---|
| 840 | MDirIter iter;
|
|---|
| 841 | if (fSequence.IsValid())
|
|---|
| 842 | {
|
|---|
| 843 | const Int_t n0 = IsUseData() ? fSequence.SetupDatRuns(iter, fPathData, "D", fDataCheck) : fSequence.SetupPedRuns(iter, fPathData, "P", fDataCheck);
|
|---|
| 844 | const Int_t n1 = IsUseData() ? fSequence.GetNumDatRuns() : fSequence.GetNumPedRuns();
|
|---|
| 845 | if (n0==0)
|
|---|
| 846 | {
|
|---|
| 847 | *fLog << err << "ERROR - No " << type << " input files of sequence found in " << (fPathData.IsNull()?"<defaul>":fPathData.Data()) << endl;
|
|---|
| 848 | return kFALSE;
|
|---|
| 849 | }
|
|---|
| 850 | if (n0!=n1)
|
|---|
| 851 | {
|
|---|
| 852 | *fLog << err << "ERROR - Number of " << type << " files found (" << n0 << ") in " << (fPathData.IsNull()?"<defaul>":fPathData.Data()) << " doesn't match number of files in sequence (" << n1 << ")" << endl;
|
|---|
| 853 | return kFALSE;
|
|---|
| 854 | }
|
|---|
| 855 | }
|
|---|
| 856 |
|
|---|
| 857 | if (fDataCheck)
|
|---|
| 858 | {
|
|---|
| 859 | if (fRuns || fSequence.IsValid())
|
|---|
| 860 | rawread.AddFiles(fSequence.IsValid() ? iter : *fRuns);
|
|---|
| 861 | tlist.AddToList(&rawread);
|
|---|
| 862 | }
|
|---|
| 863 | else
|
|---|
| 864 | {
|
|---|
| 865 | read.DisableAutoScheme();
|
|---|
| 866 | if (fRuns || fSequence.IsValid())
|
|---|
| 867 | read.AddFiles(fSequence.IsValid() ? iter : *fRuns);
|
|---|
| 868 | tlist.AddToList(&read);
|
|---|
| 869 | }
|
|---|
| 870 |
|
|---|
| 871 | // Setup Tasklist
|
|---|
| 872 | plist.AddToList(&fPedestalCamOut);
|
|---|
| 873 | plist.AddToList(&fBadPixels);
|
|---|
| 874 |
|
|---|
| 875 | MGeomApply geomapl;
|
|---|
| 876 | MBadPixelsMerge merge(&fBadPixels);
|
|---|
| 877 |
|
|---|
| 878 | MPedCalcPedRun pedcalc;
|
|---|
| 879 | pedcalc.SetPedestalUpdate(kFALSE);
|
|---|
| 880 |
|
|---|
| 881 | MPedCalcFromLoGain pedlogain;
|
|---|
| 882 | pedlogain.SetPedestalUpdate(kFALSE);
|
|---|
| 883 |
|
|---|
| 884 | MHPedestalCam hpedcam;
|
|---|
| 885 | hpedcam.SetRenorm(kTRUE);
|
|---|
| 886 |
|
|---|
| 887 | MFillH fillped(&hpedcam, "MExtractedSignalCam", "FillPedestalCam");
|
|---|
| 888 | fillped.SetBit(MFillH::kDoNotDisplay);
|
|---|
| 889 |
|
|---|
| 890 | tlist.AddToList(&geomapl);
|
|---|
| 891 | tlist.AddToList(&merge);
|
|---|
| 892 |
|
|---|
| 893 | if (!fPathIn.IsNull())
|
|---|
| 894 | {
|
|---|
| 895 | fExtractor = ReadCalibration();
|
|---|
| 896 | if (!fExtractor)
|
|---|
| 897 | return kFALSE;
|
|---|
| 898 |
|
|---|
| 899 | *fLog << all;
|
|---|
| 900 | *fLog << underline << "Signal Extractor found in calibration file:" << endl;
|
|---|
| 901 | fExtractor->Print();
|
|---|
| 902 | *fLog << endl;
|
|---|
| 903 | }
|
|---|
| 904 |
|
|---|
| 905 | MTaskEnv taskenv("ExtractPedestal");
|
|---|
| 906 | switch (fExtractType)
|
|---|
| 907 | {
|
|---|
| 908 | case kUseData:
|
|---|
| 909 | taskenv.SetDefault(&pedlogain);
|
|---|
| 910 | tlist.AddToList(&taskenv);
|
|---|
| 911 |
|
|---|
| 912 | if (!SetupExtractor(plist, pedlogain))
|
|---|
| 913 | pedlogain.SetExtractWindow(15, (Int_t)TMath::Nint(fExtractor->GetNumHiGainSamples()));
|
|---|
| 914 | break;
|
|---|
| 915 |
|
|---|
| 916 | case kUsePedRun:
|
|---|
| 917 | taskenv.SetDefault(&pedcalc);
|
|---|
| 918 | tlist.AddToList(&taskenv);
|
|---|
| 919 |
|
|---|
| 920 | if (!SetupExtractor(plist, pedcalc))
|
|---|
| 921 | pedcalc.SetExtractWindow(fExtractor->GetHiGainFirst(), TMath::Nint(fExtractor->GetNumHiGainSamples()));
|
|---|
| 922 | break;
|
|---|
| 923 |
|
|---|
| 924 | case kUseHists:
|
|---|
| 925 | if (!fExtractor)
|
|---|
| 926 | {
|
|---|
| 927 | *fLog << err << GetDescriptor() << " - ERROR: ";
|
|---|
| 928 | *fLog << "Extraction Type is kUseHists, but no extractor was set" << endl;
|
|---|
| 929 | return kFALSE;
|
|---|
| 930 | }
|
|---|
| 931 |
|
|---|
| 932 | tlist.AddToList(fExtractor);
|
|---|
| 933 | tlist.AddToList(&fillped);
|
|---|
| 934 | break;
|
|---|
| 935 | }
|
|---|
| 936 |
|
|---|
| 937 | /*
|
|---|
| 938 | if (!fPathIn.IsNull())
|
|---|
| 939 | {
|
|---|
| 940 | delete fExtractor;
|
|---|
| 941 | fExtractor = 0;
|
|---|
| 942 | }
|
|---|
| 943 | */
|
|---|
| 944 | //
|
|---|
| 945 | // Execute the eventloop
|
|---|
| 946 | //
|
|---|
| 947 | MEvtLoop evtloop(fName);
|
|---|
| 948 | evtloop.SetParList(&plist);
|
|---|
| 949 | evtloop.SetDisplay(fDisplay);
|
|---|
| 950 | evtloop.SetLogStream(fLog);
|
|---|
| 951 | if (!SetupEnv(evtloop))
|
|---|
| 952 | return kFALSE;
|
|---|
| 953 |
|
|---|
| 954 | // if (!WriteEventloop(evtloop))
|
|---|
| 955 | // return kFALSE;
|
|---|
| 956 |
|
|---|
| 957 | // Execute first analysis
|
|---|
| 958 | if (!evtloop.Eventloop(fMaxEvents))
|
|---|
| 959 | {
|
|---|
| 960 | *fLog << err << GetDescriptor() << ": Failed." << endl;
|
|---|
| 961 | return kFALSE;
|
|---|
| 962 | }
|
|---|
| 963 |
|
|---|
| 964 | tlist.PrintStatistics();
|
|---|
| 965 |
|
|---|
| 966 | DisplayResult(plist);
|
|---|
| 967 |
|
|---|
| 968 | if (!WriteResult())
|
|---|
| 969 | return kFALSE;
|
|---|
| 970 |
|
|---|
| 971 | *fLog << all << GetDescriptor() << ": Done." << endl;
|
|---|
| 972 | *fLog << endl << endl;
|
|---|
| 973 |
|
|---|
| 974 | return kTRUE;
|
|---|
| 975 | }
|
|---|