| 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 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2004
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | //
|
|---|
| 27 | // MJCalibrateSignal
|
|---|
| 28 | //
|
|---|
| 29 | // This class is reading the output written by callisto. It calibrates
|
|---|
| 30 | // signal and time.
|
|---|
| 31 | //
|
|---|
| 32 | // The signal and time extractors are read from the callisto-output. In
|
|---|
| 33 | // pricipal you could overwrite these default using the resource file,
|
|---|
| 34 | // but this is NOT recommended!
|
|---|
| 35 | //
|
|---|
| 36 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 37 | #include "MJCalibrateSignal.h"
|
|---|
| 38 |
|
|---|
| 39 | #include <TEnv.h>
|
|---|
| 40 | #include <TFile.h>
|
|---|
| 41 |
|
|---|
| 42 | #include "MLog.h"
|
|---|
| 43 | #include "MLogManip.h"
|
|---|
| 44 |
|
|---|
| 45 | #include "MDirIter.h"
|
|---|
| 46 | #include "MRunIter.h"
|
|---|
| 47 | #include "MParList.h"
|
|---|
| 48 | #include "MTaskList.h"
|
|---|
| 49 | #include "MEvtLoop.h"
|
|---|
| 50 |
|
|---|
| 51 | #include "MStatusDisplay.h"
|
|---|
| 52 |
|
|---|
| 53 | #include "MGeomCam.h"
|
|---|
| 54 | #include "MHCamEvent.h"
|
|---|
| 55 | #include "MPedestalCam.h"
|
|---|
| 56 | #include "MBadPixelsCam.h"
|
|---|
| 57 |
|
|---|
| 58 | #include "MCalibrationQECam.h"
|
|---|
| 59 | #include "MCalibrationBlindCam.h"
|
|---|
| 60 | #include "MCalibrationChargeCam.h"
|
|---|
| 61 | #include "MCalibrationRelTimeCam.h"
|
|---|
| 62 | #include "MCalibrationChargePINDiode.h"
|
|---|
| 63 | #include "MCalibrationHiLoCam.h"
|
|---|
| 64 | #include "MCalibrationPatternDecode.h"
|
|---|
| 65 |
|
|---|
| 66 | #include "MCalibrationChargeCalc.h"
|
|---|
| 67 | #include "MCalibrationRelTimeCalc.h"
|
|---|
| 68 |
|
|---|
| 69 | #include "MCalibrationIntensityChargeCam.h"
|
|---|
| 70 | #include "MCalibrationIntensityBlindCam.h"
|
|---|
| 71 | #include "MCalibrationIntensityRelTimeCam.h"
|
|---|
| 72 | #include "MCalibrationIntensityQECam.h"
|
|---|
| 73 | #include "MBadPixelsIntensityCam.h"
|
|---|
| 74 |
|
|---|
| 75 | #include "MHCalibrationChargeCam.h"
|
|---|
| 76 | #include "MHCalibrationChargeBlindCam.h"
|
|---|
| 77 | #include "MHCalibrationChargePINDiode.h"
|
|---|
| 78 | #include "MHCalibrationRelTimeCam.h"
|
|---|
| 79 | #include "MHCamera.h"
|
|---|
| 80 |
|
|---|
| 81 | #include "MCalibCalcFromPast.h"
|
|---|
| 82 |
|
|---|
| 83 | #include "MReadReports.h"
|
|---|
| 84 | #include "MReadMarsFile.h"
|
|---|
| 85 | #include "MRawFileRead.h"
|
|---|
| 86 | #include "MContinue.h"
|
|---|
| 87 | #include "MTriggerPatternDecode.h"
|
|---|
| 88 | #include "MFTriggerPattern.h"
|
|---|
| 89 | #include "MGeomApply.h"
|
|---|
| 90 | #include "MMcPedestalCopy.h"
|
|---|
| 91 | #include "MPointingPosCalc.h"
|
|---|
| 92 | #include "MPointingPosInterpolate.h"
|
|---|
| 93 | #include "MPedCalcFromLoGain.h"
|
|---|
| 94 | #include "MExtractor.h"
|
|---|
| 95 | #include "MExtractTimeAndCharge.h"
|
|---|
| 96 | #include "MExtractPINDiode.h"
|
|---|
| 97 | #include "MExtractBlindPixel.h"
|
|---|
| 98 | #include "MFCosmics.h"
|
|---|
| 99 | #include "MTaskEnv.h"
|
|---|
| 100 | #include "MCalibrateData.h"
|
|---|
| 101 | #include "MCalibrateRelTimes.h"
|
|---|
| 102 | #include "MBadPixelsMerge.h"
|
|---|
| 103 | #include "MBadPixelsCalc.h"
|
|---|
| 104 | #include "MBadPixelsTreat.h"
|
|---|
| 105 | #include "MFillH.h"
|
|---|
| 106 | #include "MWriteRootFile.h"
|
|---|
| 107 |
|
|---|
| 108 | ClassImp(MJCalibrateSignal);
|
|---|
| 109 |
|
|---|
| 110 | using namespace std;
|
|---|
| 111 |
|
|---|
| 112 | // --------------------------------------------------------------------------
|
|---|
| 113 | //
|
|---|
| 114 | // Default constructor.
|
|---|
| 115 | //
|
|---|
| 116 | // Sets:
|
|---|
| 117 | // - fIsInterlaced to kTRUE
|
|---|
| 118 | // - fIsRelTimesUpdate to kFALSE
|
|---|
| 119 | // - fIsHiLoCalibration to kFALSE
|
|---|
| 120 | //
|
|---|
| 121 | MJCalibrateSignal::MJCalibrateSignal(const char *name, const char *title)
|
|---|
| 122 | : fIsInterlaced(kTRUE), fIsRelTimesUpdate(kFALSE), fIsHiLoCalibration(kFALSE)
|
|---|
| 123 | {
|
|---|
| 124 | fName = name ? name : "MJCalibrateSignal";
|
|---|
| 125 | fTitle = title ? title : "Tool to calibrate data";
|
|---|
| 126 |
|
|---|
| 127 | }
|
|---|
| 128 |
|
|---|
| 129 | Bool_t MJCalibrateSignal::WriteResult(TObjArray &cont)
|
|---|
| 130 | {
|
|---|
| 131 | const TString name(Form("signal%08d.root", fSequence.GetSequence()));
|
|---|
| 132 | return WriteContainer(cont, name);
|
|---|
| 133 | }
|
|---|
| 134 |
|
|---|
| 135 | Bool_t MJCalibrateSignal::ReadCalibration(TObjArray &l, MBadPixelsCam &cam, MExtractor* &ext1, MExtractor* &ext2, TString &geom) const
|
|---|
| 136 | {
|
|---|
| 137 | const TString fname = Form("%s/calib%08d.root", fPathIn.Data(), fSequence.GetSequence());
|
|---|
| 138 |
|
|---|
| 139 | *fLog << inf << "Reading from file: " << fname << endl;
|
|---|
| 140 |
|
|---|
| 141 | TFile file(fname, "READ");
|
|---|
| 142 | if (!file.IsOpen())
|
|---|
| 143 | {
|
|---|
| 144 | *fLog << err << dbginf << "ERROR - Could not open file " << fname << endl;
|
|---|
| 145 | return kFALSE;
|
|---|
| 146 | }
|
|---|
| 147 |
|
|---|
| 148 | TObject *o = file.Get("ExtractSignal");
|
|---|
| 149 | if (o && !o->InheritsFrom(MExtractor::Class()))
|
|---|
| 150 | {
|
|---|
| 151 | *fLog << err << dbginf << "ERROR - ExtractSignal read from " << fname << " doesn't inherit from MExtractor!" << endl;
|
|---|
| 152 | return kFALSE;
|
|---|
| 153 | }
|
|---|
| 154 | ext1 = o ? (MExtractor*)o->Clone() : NULL;
|
|---|
| 155 |
|
|---|
| 156 | o = file.Get("ExtractTime");
|
|---|
| 157 | if (o && !o->InheritsFrom(MExtractor::Class()))
|
|---|
| 158 | {
|
|---|
| 159 | *fLog << err << dbginf << "ERROR - ExtractTime read from " << fname << " doesn't inherit from MExtractor!" << endl;
|
|---|
| 160 | return kFALSE;
|
|---|
| 161 | }
|
|---|
| 162 | ext2 = o ? (MExtractor*)o->Clone() : NULL;
|
|---|
| 163 | if (!ext1 && !ext2)
|
|---|
| 164 | {
|
|---|
| 165 | *fLog << err << dbginf << "ERROR - Neither ExtractSignal nor ExrtractTime found in " << fname << "!" << endl;
|
|---|
| 166 | return kFALSE;
|
|---|
| 167 | }
|
|---|
| 168 |
|
|---|
| 169 | o = file.Get("MGeomCam");
|
|---|
| 170 | if (o && !o->InheritsFrom(MGeomCam::Class()))
|
|---|
| 171 | {
|
|---|
| 172 | *fLog << err << dbginf << "ERROR - MGeomCam read from " << fname << " doesn't inherit from MGeomCam!" << endl;
|
|---|
| 173 | return kFALSE;
|
|---|
| 174 | }
|
|---|
| 175 | geom = o ? o->ClassName() : "";
|
|---|
| 176 |
|
|---|
| 177 | TObjArray cont(l);
|
|---|
| 178 | cont.Add(&cam);
|
|---|
| 179 | return ReadContainer(cont);
|
|---|
| 180 | }
|
|---|
| 181 |
|
|---|
| 182 | // --------------------------------------------------------------------------
|
|---|
| 183 | //
|
|---|
| 184 | // MJCalibration allows to setup several option by a resource file:
|
|---|
| 185 | // MJCalibrateSignal.RawData: yes,no
|
|---|
| 186 | //
|
|---|
| 187 | // For more details see the class description and the corresponding Getters
|
|---|
| 188 | //
|
|---|
| 189 | Bool_t MJCalibrateSignal::CheckEnvLocal()
|
|---|
| 190 | {
|
|---|
| 191 |
|
|---|
| 192 | SetInterlaced(GetEnv("Interlaced", fIsInterlaced));
|
|---|
| 193 | SetRelTimesUpdate(GetEnv("RelTimesUpdate", fIsRelTimesUpdate));
|
|---|
| 194 | SetHiLoCalibration(GetEnv("HiLoCalibration", fIsHiLoCalibration));
|
|---|
| 195 |
|
|---|
| 196 | SetUseRootData();
|
|---|
| 197 |
|
|---|
| 198 | if (HasEnv("DataType"))
|
|---|
| 199 | {
|
|---|
| 200 | TString dat = GetEnv("DataType", "");
|
|---|
| 201 | if (dat.BeginsWith("raw", TString::kIgnoreCase))
|
|---|
| 202 | {
|
|---|
| 203 | fDataFlag = 0;
|
|---|
| 204 | SetUseRawData();
|
|---|
| 205 | }
|
|---|
| 206 | if (dat.BeginsWith("root", TString::kIgnoreCase))
|
|---|
| 207 | {
|
|---|
| 208 | fDataFlag = 0;
|
|---|
| 209 | SetUseRootData();
|
|---|
| 210 | }
|
|---|
| 211 | if (dat.BeginsWith("mc", TString::kIgnoreCase))
|
|---|
| 212 | {
|
|---|
| 213 | fDataFlag = 0;
|
|---|
| 214 | SetUseMC();
|
|---|
| 215 | }
|
|---|
| 216 | }
|
|---|
| 217 |
|
|---|
| 218 | return kTRUE;
|
|---|
| 219 | }
|
|---|
| 220 |
|
|---|
| 221 | Bool_t MJCalibrateSignal::ProcessFile(MPedestalCam &pedcamab, MPedestalCam &pedcambias,
|
|---|
| 222 | MPedestalCam &pedcamextr)
|
|---|
| 223 | {
|
|---|
| 224 | if (!fSequence.IsValid())
|
|---|
| 225 | {
|
|---|
| 226 | if (!fRuns)
|
|---|
| 227 | {
|
|---|
| 228 | *fLog << err << "ERROR - Sequence invalid and no runs chosen!" << endl;
|
|---|
| 229 | return kFALSE;
|
|---|
| 230 | }
|
|---|
| 231 |
|
|---|
| 232 | if (fRuns->GetNumRuns() != fRuns->GetNumEntries())
|
|---|
| 233 | {
|
|---|
| 234 | *fLog << err << "Number of files found doesn't match number of runs... abort."
|
|---|
| 235 | << fRuns->GetNumRuns() << " vs. " << fRuns->GetNumEntries() << endl;
|
|---|
| 236 | return kFALSE;
|
|---|
| 237 | }
|
|---|
| 238 | *fLog << "Calibrate data from ";
|
|---|
| 239 | *fLog << "Runs " << fRuns->GetRunsAsString() << endl;
|
|---|
| 240 | *fLog << endl;
|
|---|
| 241 | }
|
|---|
| 242 |
|
|---|
| 243 | //if (!CheckEnv())
|
|---|
| 244 | // return kFALSE;
|
|---|
| 245 |
|
|---|
| 246 | CheckEnv();
|
|---|
| 247 |
|
|---|
| 248 | // --------------------------------------------------------------------------------
|
|---|
| 249 |
|
|---|
| 250 | *fLog << inf;
|
|---|
| 251 | fLog->Separator(GetDescriptor());
|
|---|
| 252 | *fLog << "Calculate calibrated data from runs ";
|
|---|
| 253 | *fLog << fSequence.GetName() << endl;
|
|---|
| 254 | *fLog << endl;
|
|---|
| 255 |
|
|---|
| 256 | // --------------------------------------------------------------------------------
|
|---|
| 257 |
|
|---|
| 258 | MDirIter iter;
|
|---|
| 259 | if (fSequence.IsValid())
|
|---|
| 260 | {
|
|---|
| 261 | const Int_t n0 = fSequence.SetupDatRuns(iter, fPathData, "D", IsUseRawData());
|
|---|
| 262 | const Int_t n1 = fSequence.GetNumDatRuns();
|
|---|
| 263 | if (n0==0)
|
|---|
| 264 | {
|
|---|
| 265 | *fLog << err << "ERROR - No input files of sequence found!" << endl;
|
|---|
| 266 | return kFALSE;
|
|---|
| 267 | }
|
|---|
| 268 | if (n0!=n1)
|
|---|
| 269 | {
|
|---|
| 270 | *fLog << err << "ERROR - Number of files found (" << n0 << ") doesn't match number of files in sequence (" << n1 << ")" << endl;
|
|---|
| 271 | return kFALSE;
|
|---|
| 272 | }
|
|---|
| 273 | }
|
|---|
| 274 |
|
|---|
| 275 | // Read File
|
|---|
| 276 | MCalibrationIntensityChargeCam ichcam;
|
|---|
| 277 | MCalibrationIntensityQECam iqecam;
|
|---|
| 278 | MCalibrationIntensityBlindCam iblcam;
|
|---|
| 279 | MCalibrationIntensityRelTimeCam itmcam;
|
|---|
| 280 | MBadPixelsIntensityCam ibdcam;
|
|---|
| 281 |
|
|---|
| 282 | MHCalibrationChargeCam hchacam;
|
|---|
| 283 | MHCalibrationChargeBlindCam hbndcam;
|
|---|
| 284 | MHCalibrationChargePINDiode hpndiod;
|
|---|
| 285 | MHCalibrationRelTimeCam hrelcam;
|
|---|
| 286 |
|
|---|
| 287 | MCalibrationChargeCam calcam;
|
|---|
| 288 | MCalibrationQECam qecam;
|
|---|
| 289 | MCalibrationBlindCam bndcam;
|
|---|
| 290 | MCalibrationChargePINDiode pind;
|
|---|
| 291 | MCalibrationRelTimeCam tmcam;
|
|---|
| 292 | MCalibrationHiLoCam hilcam;
|
|---|
| 293 |
|
|---|
| 294 | MBadPixelsCam badpix;
|
|---|
| 295 |
|
|---|
| 296 | TObjArray interlacedcont;
|
|---|
| 297 | if (fIsInterlaced)
|
|---|
| 298 | {
|
|---|
| 299 | interlacedcont.Add(&ichcam);
|
|---|
| 300 | interlacedcont.Add(&iqecam);
|
|---|
| 301 | interlacedcont.Add(&iblcam);
|
|---|
| 302 | interlacedcont.Add(&itmcam);
|
|---|
| 303 | interlacedcont.Add(&ibdcam);
|
|---|
| 304 | interlacedcont.Add(&hchacam);
|
|---|
| 305 | interlacedcont.Add(&hbndcam);
|
|---|
| 306 | interlacedcont.Add(&hpndiod);
|
|---|
| 307 | if (fIsRelTimesUpdate)
|
|---|
| 308 | interlacedcont.Add(&hrelcam);
|
|---|
| 309 | if (fIsHiLoCalibration)
|
|---|
| 310 | interlacedcont.Add(&hilcam);
|
|---|
| 311 | }
|
|---|
| 312 |
|
|---|
| 313 | MExtractor *extractor1=0;
|
|---|
| 314 | MExtractor *extractor2=0;
|
|---|
| 315 | MExtractor *extractor3=0;
|
|---|
| 316 | TString geom;
|
|---|
| 317 |
|
|---|
| 318 | TObjArray calibcont;
|
|---|
| 319 | calibcont.Add(&calcam);
|
|---|
| 320 | calibcont.Add(&qecam);
|
|---|
| 321 | calibcont.Add(&bndcam);
|
|---|
| 322 | calibcont.Add(&pind);
|
|---|
| 323 | calibcont.Add(&tmcam);
|
|---|
| 324 |
|
|---|
| 325 | if (!ReadCalibration(calibcont, badpix, extractor1, extractor2, geom))
|
|---|
| 326 | return kFALSE;
|
|---|
| 327 |
|
|---|
| 328 | *fLog << all;
|
|---|
| 329 | if (extractor1)
|
|---|
| 330 | {
|
|---|
| 331 | *fLog << underline << "Signal Extractor found in calibration file" << endl;
|
|---|
| 332 | extractor1->Print();
|
|---|
| 333 | *fLog << endl;
|
|---|
| 334 | extractor3 = (MExtractor*)extractor1->Clone();
|
|---|
| 335 | }
|
|---|
| 336 | else
|
|---|
| 337 | *fLog << inf << "No Signal Extractor: ExtractSignal in file." << endl;
|
|---|
| 338 |
|
|---|
| 339 | if (extractor2)
|
|---|
| 340 | {
|
|---|
| 341 | *fLog << underline << "Time Extractor found in calibration file" << endl;
|
|---|
| 342 | extractor2->Print();
|
|---|
| 343 | *fLog << endl;
|
|---|
| 344 | }
|
|---|
| 345 | else
|
|---|
| 346 | *fLog << inf << "No Time Extractor: ExtractTime in file." << endl;
|
|---|
| 347 |
|
|---|
| 348 | if (!geom.IsNull())
|
|---|
| 349 | *fLog << inf << "Camera geometry found in file: " << geom << endl;
|
|---|
| 350 | else
|
|---|
| 351 | *fLog << inf << "No Camera geometry found using default <MGeomCamMagic>" << endl;
|
|---|
| 352 |
|
|---|
| 353 | // This is necessary for the case in which it is not in the files
|
|---|
| 354 | MBadPixelsCam badcam;
|
|---|
| 355 |
|
|---|
| 356 | // Setup Parlist
|
|---|
| 357 | MParList plist;
|
|---|
| 358 | plist.AddToList(this); // take care of fDisplay!
|
|---|
| 359 | plist.AddToList(&badcam);
|
|---|
| 360 | plist.AddToList(&hilcam);
|
|---|
| 361 | plist.AddToList(&calibcont); // Using AddToList(TObjArray *)
|
|---|
| 362 | plist.AddToList(&interlacedcont); // Using AddToList(TObjArray *)
|
|---|
| 363 |
|
|---|
| 364 | // Setup Tasklist
|
|---|
| 365 | MTaskList tlist;
|
|---|
| 366 | plist.AddToList(&tlist);
|
|---|
| 367 |
|
|---|
| 368 | MReadReports readreal;
|
|---|
| 369 | readreal.AddTree("Events", "MTime.", kTRUE);
|
|---|
| 370 | readreal.AddTree("Trigger");
|
|---|
| 371 | readreal.AddTree("Camera");
|
|---|
| 372 | readreal.AddTree("Drive");
|
|---|
| 373 | readreal.AddTree("CC");
|
|---|
| 374 | readreal.AddTree("Currents");
|
|---|
| 375 |
|
|---|
| 376 | //MReadMarsFile read("Events");
|
|---|
| 377 | //read.DisableAutoScheme();
|
|---|
| 378 | MRawFileRead rawread(NULL);
|
|---|
| 379 | if (IsUseRawData())
|
|---|
| 380 | rawread.AddFiles(fSequence.IsValid() ? iter : *fRuns);
|
|---|
| 381 | else
|
|---|
| 382 | readreal.AddFiles(fSequence.IsValid() ? iter : *fRuns);
|
|---|
| 383 |
|
|---|
| 384 | MPointingPosInterpolate pextr;
|
|---|
| 385 | pextr.AddFiles(&iter);
|
|---|
| 386 |
|
|---|
| 387 | MGeomApply apply; // Only necessary to create geometry
|
|---|
| 388 | if (!geom.IsNull())
|
|---|
| 389 | apply.SetGeometry(geom);
|
|---|
| 390 | MBadPixelsMerge merge(&badpix);
|
|---|
| 391 |
|
|---|
| 392 | // Make sure that pedcamab has the correct name
|
|---|
| 393 | pedcamab.SetName("MPedestalFundamental");
|
|---|
| 394 | pedcamextr.SetName("MPedestalFromExtractorRndm");
|
|---|
| 395 | pedcambias.SetName("MPedestalFromExtractor");
|
|---|
| 396 | plist.AddToList(&pedcamextr);
|
|---|
| 397 | plist.AddToList(&pedcambias);
|
|---|
| 398 | plist.AddToList(&pedcamab);
|
|---|
| 399 |
|
|---|
| 400 | // Check for interleaved events
|
|---|
| 401 | MCalibrationPatternDecode caldec;
|
|---|
| 402 | MTriggerPatternDecode decode;
|
|---|
| 403 |
|
|---|
| 404 | MFTriggerPattern ftp;
|
|---|
| 405 | // ftp.RequireCalibration();
|
|---|
| 406 | ftp.DenyCalibration();
|
|---|
| 407 | ftp.DenyPedestal();
|
|---|
| 408 | // ftp.DenyPinDiode();
|
|---|
| 409 | ftp.SetInverted();
|
|---|
| 410 | MContinue conttp(&ftp, "ContTrigPattern");
|
|---|
| 411 | // --> tlist2
|
|---|
| 412 |
|
|---|
| 413 | // Do signal and pedestal calculation
|
|---|
| 414 | MPedCalcFromLoGain pedlo1("MPedCalcFundamental");
|
|---|
| 415 | pedlo1.SetPedestalUpdate(kTRUE);
|
|---|
| 416 | pedlo1.SetNamePedestalCamOut("MPedestalFundamental");
|
|---|
| 417 |
|
|---|
| 418 | MPedCalcFromLoGain pedlo2("MPedCalcWithExtractorRndm");
|
|---|
| 419 | pedlo2.SetPedestalUpdate(kTRUE);
|
|---|
| 420 | pedlo2.SetRandomCalculation(kTRUE);
|
|---|
| 421 | pedlo2.SetNamePedestalCamIn("MPedestalFundamental");
|
|---|
| 422 | pedlo2.SetNamePedestalCamOut("MPedestalFromExtractorRndm");
|
|---|
| 423 |
|
|---|
| 424 | MPedCalcFromLoGain pedlo3("MPedCalcWithExtractor");
|
|---|
| 425 | pedlo3.SetPedestalUpdate(kTRUE);
|
|---|
| 426 | pedlo3.SetRandomCalculation(kFALSE);
|
|---|
| 427 | pedlo3.SetNamePedestalCamIn("MPedestalFundamental");
|
|---|
| 428 | pedlo3.SetNamePedestalCamOut("MPedestalFromExtractor");
|
|---|
| 429 |
|
|---|
| 430 | if (extractor1)
|
|---|
| 431 | {
|
|---|
| 432 | extractor1->SetPedestals(&pedcamab);
|
|---|
| 433 |
|
|---|
| 434 | if (extractor1->InheritsFrom("MExtractTimeAndCharge"))
|
|---|
| 435 | {
|
|---|
| 436 | pedlo2.SetExtractor((MExtractTimeAndCharge*)extractor1);
|
|---|
| 437 | pedlo3.SetExtractor((MExtractTimeAndCharge*)extractor1);
|
|---|
| 438 | const Int_t win = ((MExtractTimeAndCharge*)extractor1)->GetWindowSizeHiGain();
|
|---|
| 439 | pedlo1.SetExtractWindow(15, win);
|
|---|
| 440 | pedlo2.SetExtractWindow(15, win/*obsolete*/);
|
|---|
| 441 | pedlo3.SetExtractWindow(15, win/*obsolete*/);
|
|---|
| 442 | }
|
|---|
| 443 | else
|
|---|
| 444 | {
|
|---|
| 445 | // FIXME: How to get the fixed value 15 automatically?
|
|---|
| 446 | const Int_t f = (Int_t)(15.5+extractor1->GetHiGainFirst());
|
|---|
| 447 | const Int_t n = (Int_t)(15.5+extractor1->GetNumHiGainSamples());
|
|---|
| 448 | pedlo1.SetExtractWindow(f, n);
|
|---|
| 449 | pedlo2.SetExtractWindow(f, n);
|
|---|
| 450 | pedlo3.SetExtractWindow(f, n);
|
|---|
| 451 | }
|
|---|
| 452 | }
|
|---|
| 453 | if (extractor2)
|
|---|
| 454 | extractor2->SetPedestals(&pedcamab);
|
|---|
| 455 |
|
|---|
| 456 | if (extractor3)
|
|---|
| 457 | extractor3->SetPedestals(&pedcamab);
|
|---|
| 458 |
|
|---|
| 459 | MFCosmics fcosmics;
|
|---|
| 460 | fcosmics.SetNamePedestalCam("MPedestalFundamental");
|
|---|
| 461 | MContinue contcos(&fcosmics, "ContTrigEvts");
|
|---|
| 462 | contcos.SetInverted();
|
|---|
| 463 |
|
|---|
| 464 | MMcPedestalCopy pcopy;
|
|---|
| 465 | MTaskEnv taskenv1("ExtractSignal");
|
|---|
| 466 | MTaskEnv taskenv2("ExtractTime");
|
|---|
| 467 | MTaskEnv taskenv3("ExtractInterlaced");
|
|---|
| 468 | taskenv1.SetDefault(extractor1);
|
|---|
| 469 | taskenv2.SetDefault(extractor2);
|
|---|
| 470 | taskenv3.SetDefault(extractor3);
|
|---|
| 471 |
|
|---|
| 472 | MCalibrateData calib;
|
|---|
| 473 | //
|
|---|
| 474 | // This is new calibration to eff. photo-electrons, hard-coded as decided
|
|---|
| 475 | // at the Wuerzburg software meeting 26.01.05
|
|---|
| 476 | //
|
|---|
| 477 | #warning Default calibration now in equiv. photo-electrons!
|
|---|
| 478 | calib.SetSignalType(MCalibrateData::kPhe);
|
|---|
| 479 |
|
|---|
| 480 | if (IsUseMC()) // MC file
|
|---|
| 481 | {
|
|---|
| 482 | calib.SetCalibrationMode(MCalibrateData::kFfactor);
|
|---|
| 483 | calib.SetPedestalFlag(MCalibrateData::kRun);
|
|---|
| 484 | // FIXME: What to do for MC files???
|
|---|
| 485 | calib.AddPedestal("MPedestalCam", "MPedPhotFundamental");
|
|---|
| 486 | calib.AddPedestal("MPedestalCam", "MPedPhotFromExtractor");
|
|---|
| 487 | calib.AddPedestal("MPedestalCam", "MPedPhotFromExtractorRndm");
|
|---|
| 488 | }
|
|---|
| 489 | else
|
|---|
| 490 | {
|
|---|
| 491 | calib.AddPedestal("Fundamental");
|
|---|
| 492 | calib.AddPedestal("FromExtractor");
|
|---|
| 493 | calib.AddPedestal("FromExtractorRndm");
|
|---|
| 494 | calib.SetPedestalFlag(MCalibrateData::kEvent);
|
|---|
| 495 | }
|
|---|
| 496 |
|
|---|
| 497 | MExtractPINDiode pinext;
|
|---|
| 498 | MExtractBlindPixel bldext;
|
|---|
| 499 |
|
|---|
| 500 | MFTriggerPattern fcalib("CalibFilter");
|
|---|
| 501 | MCalibrationChargeCalc chcalc;
|
|---|
| 502 | MCalibrationRelTimeCalc recalc;
|
|---|
| 503 | MCalibCalcFromPast pacalc;
|
|---|
| 504 |
|
|---|
| 505 | fcalib.RequireCalibration();
|
|---|
| 506 | // fcalib.SetInverted();
|
|---|
| 507 |
|
|---|
| 508 | pinext.SetPedestals(&pedcamab);
|
|---|
| 509 | bldext.SetPedestals(&pedcamab);
|
|---|
| 510 | chcalc.SetPedestals(&pedcamextr);
|
|---|
| 511 |
|
|---|
| 512 | pacalc.SetChargeCalc(&chcalc);
|
|---|
| 513 | if (fIsRelTimesUpdate)
|
|---|
| 514 | pacalc.SetRelTimeCalc(&recalc);
|
|---|
| 515 | pacalc.SetCalibrate(&calib);
|
|---|
| 516 |
|
|---|
| 517 | //
|
|---|
| 518 | // Intensity Calibration histogramming
|
|---|
| 519 | //
|
|---|
| 520 | MFillH filpin("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode", "FillPINDiode");
|
|---|
| 521 | MFillH filbnd("MHCalibrationChargeBlindCam", "MExtractedSignalBlindPixel", "FillBlindCam");
|
|---|
| 522 | MFillH filcam("MHCalibrationChargeCam", "MExtractedSignalCam", "FillChargeCam");
|
|---|
| 523 | MFillH filtme("MHCalibrationRelTimeCam", "MArrivalTimeCam", "FillRelTime");
|
|---|
| 524 | MFillH filhil("MHCalibrationHiLoCam", "MExtractedSignalCam", "FillHiLoRatio");
|
|---|
| 525 |
|
|---|
| 526 | filpin.SetBit(MFillH::kDoNotDisplay);
|
|---|
| 527 | filbnd.SetBit(MFillH::kDoNotDisplay);
|
|---|
| 528 | filcam.SetBit(MFillH::kDoNotDisplay);
|
|---|
| 529 | filtme.SetBit(MFillH::kDoNotDisplay);
|
|---|
| 530 | filhil.SetBit(MFillH::kDoNotDisplay);
|
|---|
| 531 |
|
|---|
| 532 | MCalibrateRelTimes caltm;
|
|---|
| 533 | MBadPixelsCalc bpcal;
|
|---|
| 534 | MBadPixelsTreat treat;
|
|---|
| 535 |
|
|---|
| 536 | bpcal.SetNamePedPhotCam("MPedPhotFromExtractor");
|
|---|
| 537 | treat.AddNamePedPhotCam("MPedPhotFundamental");
|
|---|
| 538 | treat.AddNamePedPhotCam("MPedPhotFromExtractor");
|
|---|
| 539 | treat.AddNamePedPhotCam("MPedPhotFromExtractorRndm");
|
|---|
| 540 | if (!extractor2 && !extractor1->InheritsFrom("MExtractTimeAndCharge"))
|
|---|
| 541 | treat.SetProcessTimes(kFALSE);
|
|---|
| 542 |
|
|---|
| 543 |
|
|---|
| 544 | MHCamEvent evt0(0, "PedFLG", "Fundamental Pedestal from Lo Gain;;P [cnts/sl]");
|
|---|
| 545 | MHCamEvent evt1(2, "PedRmsFLG", "RMS from Extractor applied to ped.;;\\sigma_{p} [cnts/sl]");
|
|---|
| 546 | MHCamEvent evt2(0, "Extra'd", "Extracted Signal;;S [cnts/sl]");
|
|---|
| 547 | // MHCamEvent evt3(4, "PedPhot", "Calibrated Pedestal;;P [phe]");
|
|---|
| 548 | MHCamEvent evt4(5, "PedRMS", "Calibrated RMS from Extractor applied to ped.;;\\sigma_{p} [phe]");
|
|---|
| 549 | MHCamEvent evt5(3, "Interp'd", "Interpolated Signal;;S [phe]");
|
|---|
| 550 | MHCamEvent evt6(2, "Unsuitable", "Fraction of unsuitable events per Pixel;;[1]");
|
|---|
| 551 | MHCamEvent evt7(0, "Times", "Arrival Time;;T [fadc sl]");
|
|---|
| 552 | MHCamEvent evt8(0, "Conv", "Calibration Conv. Factors;;[phe/fadc cnts]");
|
|---|
| 553 |
|
|---|
| 554 | evt0.EnableVariance();
|
|---|
| 555 | evt1.EnableVariance();
|
|---|
| 556 | evt2.EnableVariance();
|
|---|
| 557 | // evt3.EnableVariance();
|
|---|
| 558 | evt4.EnableVariance();
|
|---|
| 559 | evt5.EnableVariance();
|
|---|
| 560 | evt7.EnableVariance();
|
|---|
| 561 | // evt8.EnableVariance();
|
|---|
| 562 |
|
|---|
| 563 | MFillH fill0(&evt0, "MPedestalFundamental", "FillPedFLG");
|
|---|
| 564 | MFillH fill1(&evt1, "MPedestalFromExtractor", "FillPedRmsFLG");
|
|---|
| 565 | MFillH fill2(&evt2, "MExtractedSignalCam", "FillExtracted");
|
|---|
| 566 | // MFillH fill3(&evt3, "MPedPhotFundamental", "FillPedPhot");
|
|---|
| 567 | MFillH fill4(&evt4, "MPedPhotFromExtractor", "FillPedRMS");
|
|---|
| 568 | MFillH fill5(&evt5, "MCerPhotEvt", "FillInterpolated");
|
|---|
| 569 | MFillH fill6(&evt6, "MBadPixelsCam", "FillUnsuitable");
|
|---|
| 570 | MFillH fill7(&evt7, "MArrivalTime", "FillTimes");
|
|---|
| 571 | MFillH fill8(&evt8, "MCalibConstCam", "FillConv");
|
|---|
| 572 |
|
|---|
| 573 | MTaskEnv fillflorian("FinalFantasy");
|
|---|
| 574 | fillflorian.SetDefault();
|
|---|
| 575 |
|
|---|
| 576 | // The second rule is for the case reading raw-files!
|
|---|
| 577 | MWriteRootFile write(2, Form("%s{s/_D_/_Y_}{s/.raw$/.root}", fPathOut.Data()), fOverwrite);
|
|---|
| 578 | // Run Header
|
|---|
| 579 | write.AddContainer("MRawRunHeader", "RunHeaders");
|
|---|
| 580 | write.AddContainer("MBadPixelsCam", "RunHeaders");
|
|---|
| 581 | write.AddContainer("MGeomCam", "RunHeaders");
|
|---|
| 582 | // Monte Carlo Headers
|
|---|
| 583 | write.AddContainer("MMcTrigHeader", "RunHeaders", kFALSE);
|
|---|
| 584 | write.AddContainer("MMcConfigRunHeader", "RunHeaders", kFALSE);
|
|---|
| 585 | write.AddContainer("MMcCorsikaRunHeader", "RunHeaders", kFALSE);
|
|---|
| 586 | // Monte Carlo
|
|---|
| 587 | write.AddContainer("MMcEvt", "Events", kFALSE);
|
|---|
| 588 | write.AddContainer("MMcTrig", "Events", kFALSE);
|
|---|
| 589 | // Data tree
|
|---|
| 590 | write.AddContainer("MCerPhotEvt", "Events");
|
|---|
| 591 | write.AddContainer("MPedPhotFundamental", "Events");
|
|---|
| 592 | write.AddContainer("MPedPhotFromExtractor", "Events");
|
|---|
| 593 | write.AddContainer("MPedPhotFromExtractorRndm", "Events");
|
|---|
| 594 | write.AddContainer("MTime", "Events", kFALSE);
|
|---|
| 595 | write.AddContainer("MRawEvtHeader", "Events");
|
|---|
| 596 | write.AddContainer("MArrivalTime", "Events", kFALSE);
|
|---|
| 597 | write.AddContainer("MPointingPos", "Events", kFALSE);
|
|---|
| 598 | // Slow-Control: Current-tree
|
|---|
| 599 | write.AddContainer("MTimeCurrents", "Currents", kFALSE);
|
|---|
| 600 | write.AddContainer("MCameraDC", "Currents", kFALSE);
|
|---|
| 601 | write.AddContainer("MReportCurrents", "Currents", kFALSE);
|
|---|
| 602 | // Slow-Control: Camera-tree
|
|---|
| 603 | write.AddContainer("MReportCamera", "Camera", kFALSE);
|
|---|
| 604 | write.AddContainer("MTimeCamera", "Camera", kFALSE);
|
|---|
| 605 | write.AddContainer("MCameraAUX", "Camera", kFALSE);
|
|---|
| 606 | write.AddContainer("MCameraCalibration", "Camera", kFALSE);
|
|---|
| 607 | write.AddContainer("MCameraCooling", "Camera", kFALSE);
|
|---|
| 608 | write.AddContainer("MCameraHV", "Camera", kFALSE);
|
|---|
| 609 | write.AddContainer("MCameraLV", "Camera", kFALSE);
|
|---|
| 610 | write.AddContainer("MCameraLids", "Camera", kFALSE);
|
|---|
| 611 | // Slow-Control: Trigger-tree
|
|---|
| 612 | write.AddContainer("MReportTrigger", "Trigger", kFALSE);
|
|---|
| 613 | write.AddContainer("MTimeTrigger", "Trigger", kFALSE);
|
|---|
| 614 | // Slow-Control: Drive-tree
|
|---|
| 615 | write.AddContainer("MReportDrive", "Drive", kFALSE);
|
|---|
| 616 | write.AddContainer("MTimeDrive", "Drive", kFALSE);
|
|---|
| 617 | // Slow-Control: Central Control-tree
|
|---|
| 618 | write.AddContainer("MReportCC", "CC", kFALSE);
|
|---|
| 619 | write.AddContainer("MTimeCC", "CC", kFALSE);
|
|---|
| 620 |
|
|---|
| 621 | // Now setup tasklist for events
|
|---|
| 622 | MTaskList tlist2;
|
|---|
| 623 |
|
|---|
| 624 | tlist2.AddToList(&caldec);
|
|---|
| 625 | tlist2.AddToList(&decode);
|
|---|
| 626 | tlist2.AddToList(&apply);
|
|---|
| 627 | tlist2.AddToList(&merge);
|
|---|
| 628 | if (IsUseMC())
|
|---|
| 629 | tlist2.AddToList(&pcopy);
|
|---|
| 630 | else
|
|---|
| 631 | {
|
|---|
| 632 | tlist2.AddToList(&pedlo1);
|
|---|
| 633 | tlist2.AddToList(&pedlo2);
|
|---|
| 634 | tlist2.AddToList(&pedlo3);
|
|---|
| 635 | }
|
|---|
| 636 | if (fIsInterlaced)
|
|---|
| 637 | {
|
|---|
| 638 | pinext.SetFilter(&fcalib);
|
|---|
| 639 | bldext.SetFilter(&fcalib);
|
|---|
| 640 | taskenv3.SetFilter(&fcalib);
|
|---|
| 641 | pacalc.SetFilter(&fcalib);
|
|---|
| 642 | filcam.SetFilter(&fcalib);
|
|---|
| 643 | filtme.SetFilter(&fcalib);
|
|---|
| 644 | filbnd.SetFilter(&fcalib);
|
|---|
| 645 | filpin.SetFilter(&fcalib);
|
|---|
| 646 | chcalc.SetFilter(&fcalib);
|
|---|
| 647 | recalc.SetFilter(&fcalib);
|
|---|
| 648 |
|
|---|
| 649 | tlist2.AddToList(&fcalib);
|
|---|
| 650 | tlist2.AddToList(&pinext);
|
|---|
| 651 | tlist2.AddToList(&bldext);
|
|---|
| 652 | tlist2.AddToList(&taskenv3);
|
|---|
| 653 | tlist2.AddToList(&pacalc);
|
|---|
| 654 | tlist2.AddToList(&filcam);
|
|---|
| 655 | if (fIsRelTimesUpdate)
|
|---|
| 656 | tlist2.AddToList(&filtme);
|
|---|
| 657 | tlist2.AddToList(&filbnd);
|
|---|
| 658 | tlist2.AddToList(&filpin);
|
|---|
| 659 | tlist2.AddToList(&chcalc);
|
|---|
| 660 | if (fIsRelTimesUpdate)
|
|---|
| 661 | tlist2.AddToList(&recalc);
|
|---|
| 662 | }
|
|---|
| 663 |
|
|---|
| 664 | tlist2.AddToList(&conttp);
|
|---|
| 665 | if (extractor1)
|
|---|
| 666 | tlist2.AddToList(&taskenv1);
|
|---|
| 667 | if (extractor2)
|
|---|
| 668 | tlist2.AddToList(&taskenv2);
|
|---|
| 669 | tlist2.AddToList(&fill0);
|
|---|
| 670 | tlist2.AddToList(&fill1);
|
|---|
| 671 | tlist2.AddToList(&contcos);
|
|---|
| 672 | if (fIsHiLoCalibration)
|
|---|
| 673 | tlist2.AddToList(&filhil);
|
|---|
| 674 | tlist2.AddToList(&fill2);
|
|---|
| 675 | tlist2.AddToList(&calib);
|
|---|
| 676 | if (extractor2 || extractor1->InheritsFrom("MExtractTimeAndCharge"))
|
|---|
| 677 | tlist2.AddToList(&caltm);
|
|---|
| 678 |
|
|---|
| 679 | tlist2.AddToList(&bpcal);
|
|---|
| 680 | tlist2.AddToList(&treat);
|
|---|
| 681 | tlist2.AddToList(&fill6);
|
|---|
| 682 | // tlist2.AddToList(&fill3);
|
|---|
| 683 | tlist2.AddToList(&fill4);
|
|---|
| 684 | tlist2.AddToList(&fill5);
|
|---|
| 685 | if (extractor2 || extractor1->InheritsFrom("MExtractTimeAndCharge"))
|
|---|
| 686 | tlist2.AddToList(&fill7);
|
|---|
| 687 |
|
|---|
| 688 | tlist2.AddToList(&fillflorian);
|
|---|
| 689 |
|
|---|
| 690 | // Setup List for Drive-tree
|
|---|
| 691 | MPointingPosCalc pcalc;
|
|---|
| 692 |
|
|---|
| 693 | // Now setup main tasklist
|
|---|
| 694 | tlist.AddToList(IsUseRawData() ? (MTask*)&rawread : (MTask*)&readreal);
|
|---|
| 695 | if (IsUseRootData())
|
|---|
| 696 | tlist2.AddToList(&pextr);
|
|---|
| 697 | tlist.AddToList(&tlist2, IsUseRootData() ? "Events" : "All");
|
|---|
| 698 | if (fIsInterlaced)
|
|---|
| 699 | tlist.AddToList(&fill8);
|
|---|
| 700 |
|
|---|
| 701 | if (IsUseMC())
|
|---|
| 702 | tlist.AddToList(&pcalc, "Drive");
|
|---|
| 703 |
|
|---|
| 704 | tlist.AddToList(&write);
|
|---|
| 705 |
|
|---|
| 706 | // Create and setup the eventloop
|
|---|
| 707 | MEvtLoop evtloop(fName);
|
|---|
| 708 | evtloop.SetParList(&plist);
|
|---|
| 709 | evtloop.SetDisplay(fDisplay);
|
|---|
| 710 | evtloop.SetLogStream(fLog);
|
|---|
| 711 | if (!SetupEnv(evtloop))
|
|---|
| 712 | return kFALSE;
|
|---|
| 713 |
|
|---|
| 714 | // Execute first analysis
|
|---|
| 715 | const Bool_t rc = evtloop.Eventloop(fMaxEvents);
|
|---|
| 716 |
|
|---|
| 717 | // Print statistics
|
|---|
| 718 | tlist.PrintStatistics();
|
|---|
| 719 |
|
|---|
| 720 | // make sure owned object are deleted
|
|---|
| 721 | if (extractor1)
|
|---|
| 722 | delete extractor1;
|
|---|
| 723 | if (extractor2)
|
|---|
| 724 | delete extractor2;
|
|---|
| 725 | if (extractor3)
|
|---|
| 726 | delete extractor3;
|
|---|
| 727 |
|
|---|
| 728 | // return if job failed
|
|---|
| 729 | if (!rc)
|
|---|
| 730 | {
|
|---|
| 731 | *fLog << err << GetDescriptor() << ": Failed." << endl;
|
|---|
| 732 | return kFALSE;
|
|---|
| 733 | }
|
|---|
| 734 |
|
|---|
| 735 | // if everything went ok write and display result
|
|---|
| 736 | DisplayResult(plist);
|
|---|
| 737 |
|
|---|
| 738 | if (!WriteResult(interlacedcont))
|
|---|
| 739 | return kFALSE;
|
|---|
| 740 |
|
|---|
| 741 | // return if job went ok
|
|---|
| 742 | *fLog << all << GetDescriptor() << ": Done." << endl;
|
|---|
| 743 | *fLog << endl << endl;
|
|---|
| 744 |
|
|---|
| 745 | return kTRUE;
|
|---|
| 746 | }
|
|---|
| 747 |
|
|---|
| 748 |
|
|---|
| 749 | void MJCalibrateSignal::DisplayResult(MParList &plist)
|
|---|
| 750 | {
|
|---|
| 751 |
|
|---|
| 752 | if (!fDisplay)
|
|---|
| 753 | return;
|
|---|
| 754 |
|
|---|
| 755 | if (!fIsHiLoCalibration)
|
|---|
| 756 | return;
|
|---|
| 757 |
|
|---|
| 758 | //
|
|---|
| 759 | // Get container from list
|
|---|
| 760 | //
|
|---|
| 761 | MGeomCam &geomcam = *(MGeomCam*)plist.FindObject("MGeomCam");
|
|---|
| 762 | MCalibrationHiLoCam *cam = (MCalibrationHiLoCam*)plist.FindObject("MCalibrationHiLoCam");
|
|---|
| 763 |
|
|---|
| 764 | // Create histograms to display
|
|---|
| 765 | MHCamera disp1 (geomcam, "HiLoConv", "Ratio Amplification HiGain vs. LoGain (Charges)");
|
|---|
| 766 | MHCamera disp2 (geomcam, "HiLoDiff", "Arrival Time Diff. HiGain vs. LoGain (Times)");
|
|---|
| 767 |
|
|---|
| 768 | disp1.SetCamContent(*cam, 0);
|
|---|
| 769 | disp1.SetCamError( *cam, 1);
|
|---|
| 770 | disp2.SetCamContent(*cam, 5);
|
|---|
| 771 | disp2.SetCamError( *cam, 6);
|
|---|
| 772 |
|
|---|
| 773 | disp1.SetYTitle("R [1]");
|
|---|
| 774 | disp2.SetYTitle("\\Delta T [FADC sl.]");
|
|---|
| 775 |
|
|---|
| 776 |
|
|---|
| 777 | TCanvas &c1 = fDisplay->AddTab("HiLoConv");
|
|---|
| 778 | c1.Divide(2,3);
|
|---|
| 779 |
|
|---|
| 780 | disp1.CamDraw(c1, 1, 2, 1);
|
|---|
| 781 | disp2.CamDraw(c1, 2, 2, 1);
|
|---|
| 782 | }
|
|---|
| 783 |
|
|---|