| 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 "MHCamEventTH.h"
|
|---|
| 56 | #include "MPedestalCam.h"
|
|---|
| 57 | #include "MBadPixelsCam.h"
|
|---|
| 58 | #include "MArrivalTimeCam.h"
|
|---|
| 59 |
|
|---|
| 60 | #include "MCalibrationQECam.h"
|
|---|
| 61 | #include "MCalibrationBlindCam.h"
|
|---|
| 62 | #include "MCalibrationChargeCam.h"
|
|---|
| 63 | #include "MCalibrationRelTimeCam.h"
|
|---|
| 64 | #include "MCalibrationChargePINDiode.h"
|
|---|
| 65 | #include "MCalibrationHiLoCam.h"
|
|---|
| 66 | #include "MCalibrationPulseTimeCam.h"
|
|---|
| 67 | #include "MCalibrationPatternDecode.h"
|
|---|
| 68 |
|
|---|
| 69 | #include "MCalibrationChargeCalc.h"
|
|---|
| 70 | #include "MCalibrationRelTimeCalc.h"
|
|---|
| 71 |
|
|---|
| 72 | #include "MCalibrationIntensityChargeCam.h"
|
|---|
| 73 | #include "MCalibrationIntensityBlindCam.h"
|
|---|
| 74 | #include "MCalibrationIntensityRelTimeCam.h"
|
|---|
| 75 | #include "MCalibrationIntensityQECam.h"
|
|---|
| 76 | #include "MBadPixelsIntensityCam.h"
|
|---|
| 77 |
|
|---|
| 78 | #include "MHCalibrationChargeCam.h"
|
|---|
| 79 | #include "MHCalibrationChargeBlindCam.h"
|
|---|
| 80 | #include "MHCalibrationChargePINDiode.h"
|
|---|
| 81 | #include "MHCalibrationRelTimeCam.h"
|
|---|
| 82 | #include "MHCalibrationPulseTimeCam.h"
|
|---|
| 83 | #include "MHCalibrationHiLoCam.h"
|
|---|
| 84 | #include "MHCamera.h"
|
|---|
| 85 |
|
|---|
| 86 | #include "MCalibCalcFromPast.h"
|
|---|
| 87 |
|
|---|
| 88 | #include "MReadReports.h"
|
|---|
| 89 | #include "MReadMarsFile.h"
|
|---|
| 90 | #include "MRawFileRead.h"
|
|---|
| 91 | #include "MContinue.h"
|
|---|
| 92 | #include "MTriggerPatternDecode.h"
|
|---|
| 93 | #include "MFTriggerPattern.h"
|
|---|
| 94 | #include "MGeomApply.h"
|
|---|
| 95 | //#include "MMcPedestalCopy.h"
|
|---|
| 96 | #include "MPointingPosCalc.h"
|
|---|
| 97 | #include "MPointingPosInterpolate.h"
|
|---|
| 98 | #include "MPedCalcFromLoGain.h"
|
|---|
| 99 | #include "MExtractor.h"
|
|---|
| 100 | #include "MExtractTimeAndCharge.h"
|
|---|
| 101 | #include "MExtractPINDiode.h"
|
|---|
| 102 | #include "MExtractBlindPixel.h"
|
|---|
| 103 | #include "MFCosmics.h"
|
|---|
| 104 | #include "MTaskEnv.h"
|
|---|
| 105 | #include "MCalibrateData.h"
|
|---|
| 106 | #include "MCalibrateRelTimes.h"
|
|---|
| 107 | #include "MBadPixelsMerge.h"
|
|---|
| 108 | #include "MBadPixelsCalc.h"
|
|---|
| 109 | #include "MBadPixelsTreat.h"
|
|---|
| 110 | #include "MFillH.h"
|
|---|
| 111 | #include "MWriteRootFile.h"
|
|---|
| 112 |
|
|---|
| 113 | ClassImp(MJCalibrateSignal);
|
|---|
| 114 |
|
|---|
| 115 | using namespace std;
|
|---|
| 116 |
|
|---|
| 117 | // --------------------------------------------------------------------------
|
|---|
| 118 | //
|
|---|
| 119 | // Default constructor.
|
|---|
| 120 | //
|
|---|
| 121 | // Sets:
|
|---|
| 122 | // - fIsInterlaced to kTRUE
|
|---|
| 123 | // - fIsRelTimesUpdate to kFALSE
|
|---|
| 124 | // - fIsHiLoCalibration to kFALSE
|
|---|
| 125 | // - fPulsePosCheck to kTRUE
|
|---|
| 126 | //
|
|---|
| 127 | MJCalibrateSignal::MJCalibrateSignal(const char *name, const char *title)
|
|---|
| 128 | : fExtractor(0), fIsInterlaced(kTRUE), fIsRelTimesUpdate(kFALSE)
|
|---|
| 129 | {
|
|---|
| 130 | fName = name ? name : "MJCalibrateSignal";
|
|---|
| 131 | fTitle = title ? title : "Tool to calibrate data";
|
|---|
| 132 |
|
|---|
| 133 | SetPulsePosCheck();
|
|---|
| 134 | //fCruns = NULL;
|
|---|
| 135 | }
|
|---|
| 136 |
|
|---|
| 137 | MJCalibrateSignal::~MJCalibrateSignal()
|
|---|
| 138 | {
|
|---|
| 139 | if (fExtractor)
|
|---|
| 140 | delete fExtractor;
|
|---|
| 141 | }
|
|---|
| 142 |
|
|---|
| 143 | void MJCalibrateSignal::SetExtractor(const MExtractor *ext)
|
|---|
| 144 | {
|
|---|
| 145 | if (fExtractor)
|
|---|
| 146 | delete fExtractor;
|
|---|
| 147 |
|
|---|
| 148 | fExtractor = ext ? (MExtractor*)ext->Clone() : NULL;
|
|---|
| 149 | }
|
|---|
| 150 |
|
|---|
| 151 | const char* MJCalibrateSignal::GetInputFile() const
|
|---|
| 152 | {
|
|---|
| 153 | const TString name(GetInputFileName());
|
|---|
| 154 | if (name.IsNull())
|
|---|
| 155 | return "";
|
|---|
| 156 |
|
|---|
| 157 | return Form("%s/%s", fPathIn.Data(), name.Data());
|
|---|
| 158 | }
|
|---|
| 159 |
|
|---|
| 160 | const char* MJCalibrateSignal::GetInputFileName() const
|
|---|
| 161 | {
|
|---|
| 162 |
|
|---|
| 163 | if (fSequence.IsValid())
|
|---|
| 164 | return Form("calib%08d.root", fSequence.GetSequence());
|
|---|
| 165 |
|
|---|
| 166 | // if (!fCruns)
|
|---|
| 167 | return "";
|
|---|
| 168 |
|
|---|
| 169 | // return Form("%s-F1.root", (const char*)fCruns->GetRunsAsFileName());
|
|---|
| 170 | }
|
|---|
| 171 |
|
|---|
| 172 | Bool_t MJCalibrateSignal::WriteResult(TObjArray &cont)
|
|---|
| 173 | {
|
|---|
| 174 | if (IsNoStorage())
|
|---|
| 175 | return kTRUE;
|
|---|
| 176 |
|
|---|
| 177 | const TString name(Form("signal%08d.root", fSequence.GetSequence()));
|
|---|
| 178 | return WriteContainer(cont, name);
|
|---|
| 179 | }
|
|---|
| 180 |
|
|---|
| 181 | Bool_t MJCalibrateSignal::ReadCalibration(TObjArray &l, MBadPixelsCam &cam, MExtractor* &ext2, MExtractor* &ext3, TString &geom) const
|
|---|
| 182 | {
|
|---|
| 183 |
|
|---|
| 184 | const TString fname = GetInputFile();
|
|---|
| 185 |
|
|---|
| 186 | *fLog << inf << "Reading from file: " << fname << endl;
|
|---|
| 187 |
|
|---|
| 188 | TFile file(fname, "READ");
|
|---|
| 189 | if (!file.IsOpen())
|
|---|
| 190 | {
|
|---|
| 191 | *fLog << err << dbginf << "ERROR - Could not open file " << fname << endl;
|
|---|
| 192 | return kFALSE;
|
|---|
| 193 | }
|
|---|
| 194 |
|
|---|
| 195 | TObject *o = file.Get("ExtractSignal");
|
|---|
| 196 | if (o && !o->InheritsFrom(MExtractor::Class()))
|
|---|
| 197 | {
|
|---|
| 198 | *fLog << err << dbginf << "ERROR - ExtractSignal read from " << fname << " doesn't inherit from MExtractor!" << endl;
|
|---|
| 199 | return kFALSE;
|
|---|
| 200 | }
|
|---|
| 201 | ext3 = o ? (MExtractor*)o->Clone() : NULL;
|
|---|
| 202 |
|
|---|
| 203 | o = file.Get("ExtractTime");
|
|---|
| 204 | if (o && !o->InheritsFrom(MExtractor::Class()))
|
|---|
| 205 | {
|
|---|
| 206 | *fLog << err << dbginf << "ERROR - ExtractTime read from " << fname << " doesn't inherit from MExtractor!" << endl;
|
|---|
| 207 | return kFALSE;
|
|---|
| 208 | }
|
|---|
| 209 | ext2 = o ? (MExtractor*)o->Clone() : NULL;
|
|---|
| 210 | if (!ext3 && !ext2)
|
|---|
| 211 | {
|
|---|
| 212 | *fLog << err << dbginf << "ERROR - Neither ExtractSignal nor ExrtractTime found in " << fname << "!" << endl;
|
|---|
| 213 | return kFALSE;
|
|---|
| 214 | }
|
|---|
| 215 |
|
|---|
| 216 | o = file.Get("MGeomCam");
|
|---|
| 217 | if (o && !o->InheritsFrom(MGeomCam::Class()))
|
|---|
| 218 | {
|
|---|
| 219 | *fLog << err << dbginf << "ERROR - MGeomCam read from " << fname << " doesn't inherit from MGeomCam!" << endl;
|
|---|
| 220 | return kFALSE;
|
|---|
| 221 | }
|
|---|
| 222 | geom = o ? o->ClassName() : "";
|
|---|
| 223 |
|
|---|
| 224 | TObjArray cont(l);
|
|---|
| 225 | cont.Add(&cam);
|
|---|
| 226 | return ReadContainer(cont);
|
|---|
| 227 | }
|
|---|
| 228 | /*
|
|---|
| 229 | Bool_t MJCalibrateSignal::ReadExtractorCosmics(MExtractor* &ext1) const
|
|---|
| 230 | {
|
|---|
| 231 |
|
|---|
| 232 | const TString fname = Form("pedy%08d.root",fSequence.GetSequence());
|
|---|
| 233 |
|
|---|
| 234 | *fLog << inf << "Reading from file: " << fname << endl;
|
|---|
| 235 |
|
|---|
| 236 | TFile file(fname, "READ");
|
|---|
| 237 | if (!file.IsOpen())
|
|---|
| 238 | {
|
|---|
| 239 | *fLog << warn << "Could not find or open file " << fname << endl;
|
|---|
| 240 | return kFALSE;
|
|---|
| 241 | }
|
|---|
| 242 |
|
|---|
| 243 | TObject *o = file.Get("ExtractSignal");
|
|---|
| 244 | if (o && !o->InheritsFrom(MExtractor::Class()))
|
|---|
| 245 | {
|
|---|
| 246 | *fLog << err << dbginf << "ERROR - ExtractSignal read from " << fname << " doesn't inherit from MExtractor!" << endl;
|
|---|
| 247 | return kFALSE;
|
|---|
| 248 | }
|
|---|
| 249 | if (o)
|
|---|
| 250 | {
|
|---|
| 251 | delete ext1;
|
|---|
| 252 | ext1 = (MExtractor*)o->Clone();
|
|---|
| 253 | }
|
|---|
| 254 | else
|
|---|
| 255 | *fLog << warn << "No signal extractor found in " << fname << endl;
|
|---|
| 256 |
|
|---|
| 257 | file.Close();
|
|---|
| 258 | return kTRUE;
|
|---|
| 259 | }
|
|---|
| 260 | */
|
|---|
| 261 | // --------------------------------------------------------------------------
|
|---|
| 262 | //
|
|---|
| 263 | // MJCalibration allows to setup several option by a resource file:
|
|---|
| 264 | // MJCalibrateSignal.RawData: yes,no
|
|---|
| 265 | //
|
|---|
| 266 | // For more details see the class description and the corresponding Getters
|
|---|
| 267 | //
|
|---|
| 268 | Bool_t MJCalibrateSignal::CheckEnvLocal()
|
|---|
| 269 | {
|
|---|
| 270 | SetInterlaced(GetEnv("Interlaced", fIsInterlaced));
|
|---|
| 271 | SetRelTimesUpdate(GetEnv("RelTimesUpdate", fIsRelTimesUpdate));
|
|---|
| 272 |
|
|---|
| 273 | return MJCalib::CheckEnvLocal();
|
|---|
| 274 | }
|
|---|
| 275 |
|
|---|
| 276 | Bool_t MJCalibrateSignal::ProcessFile(MPedestalCam &pedcamab, MPedestalCam &pedcambias,
|
|---|
| 277 | MPedestalCam &pedcamextr)
|
|---|
| 278 | {
|
|---|
| 279 | if (!fSequence.IsValid())
|
|---|
| 280 | {
|
|---|
| 281 | if (!fRuns)
|
|---|
| 282 | {
|
|---|
| 283 | *fLog << err << "ERROR - Sequence invalid and no runs chosen!" << endl;
|
|---|
| 284 | return kFALSE;
|
|---|
| 285 | }
|
|---|
| 286 |
|
|---|
| 287 | if (fRuns->GetNumRuns() != fRuns->GetNumEntries())
|
|---|
| 288 | {
|
|---|
| 289 | *fLog << err << "Number of files found doesn't match number of runs... abort."
|
|---|
| 290 | << fRuns->GetNumRuns() << " vs. " << fRuns->GetNumEntries() << endl;
|
|---|
| 291 | return kFALSE;
|
|---|
| 292 | }
|
|---|
| 293 | *fLog << "Calibrate data from ";
|
|---|
| 294 | *fLog << "Runs " << fRuns->GetRunsAsString() << endl;
|
|---|
| 295 | *fLog << endl;
|
|---|
| 296 | }
|
|---|
| 297 |
|
|---|
| 298 | //if (!CheckEnv())
|
|---|
| 299 | // return kFALSE;
|
|---|
| 300 |
|
|---|
| 301 | CheckEnv();
|
|---|
| 302 |
|
|---|
| 303 | // --------------------------------------------------------------------------------
|
|---|
| 304 |
|
|---|
| 305 | *fLog << inf;
|
|---|
| 306 | fLog->Separator(GetDescriptor());
|
|---|
| 307 | *fLog << "Calculate calibrated data from runs ";
|
|---|
| 308 | *fLog << fSequence.GetName() << endl;
|
|---|
| 309 | *fLog << endl;
|
|---|
| 310 |
|
|---|
| 311 | // --------------------------------------------------------------------------------
|
|---|
| 312 |
|
|---|
| 313 | MDirIter iter;
|
|---|
| 314 | if (fSequence.IsValid())
|
|---|
| 315 | {
|
|---|
| 316 | const Int_t n0 = fSequence.SetupDatRuns(iter, fPathData, IsUseRawData());
|
|---|
| 317 | const Int_t n1 = fSequence.GetNumDatRuns();
|
|---|
| 318 | if (n0==0)
|
|---|
| 319 | {
|
|---|
| 320 | *fLog << err << "ERROR - No input files of sequence found!" << endl;
|
|---|
| 321 | return kFALSE;
|
|---|
| 322 | }
|
|---|
| 323 | if (n0!=n1)
|
|---|
| 324 | {
|
|---|
| 325 | *fLog << err << "ERROR - Number of files found (" << n0 << ") doesn't match number of files in sequence (" << n1 << ")" << endl;
|
|---|
| 326 | if (fLog->GetDebugLevel()>4)
|
|---|
| 327 | {
|
|---|
| 328 | *fLog << dbg << "Files which are searched:" << endl;
|
|---|
| 329 | iter.Print();
|
|---|
| 330 | }
|
|---|
| 331 | return kFALSE;
|
|---|
| 332 | }
|
|---|
| 333 | }
|
|---|
| 334 |
|
|---|
| 335 | // Read File
|
|---|
| 336 | MCalibrationIntensityChargeCam ichcam;
|
|---|
| 337 | MCalibrationIntensityQECam iqecam;
|
|---|
| 338 | MCalibrationIntensityBlindCam iblcam;
|
|---|
| 339 | MCalibrationIntensityRelTimeCam itmcam;
|
|---|
| 340 | MBadPixelsIntensityCam ibdcam;
|
|---|
| 341 |
|
|---|
| 342 | MHCalibrationChargeCam hchacam;
|
|---|
| 343 | MHCalibrationChargeBlindCam hbndcam;
|
|---|
| 344 | MHCalibrationChargePINDiode hpndiod;
|
|---|
| 345 | MHCalibrationRelTimeCam hrelcam;
|
|---|
| 346 |
|
|---|
| 347 | hchacam.SetOscillations(kFALSE);
|
|---|
| 348 | hbndcam.SetOscillations(kFALSE);
|
|---|
| 349 | hrelcam.SetOscillations(kFALSE);
|
|---|
| 350 |
|
|---|
| 351 | MCalibrationChargeCam calcam;
|
|---|
| 352 | MCalibrationQECam qecam;
|
|---|
| 353 | MCalibrationBlindCam bndcam;
|
|---|
| 354 | MCalibrationChargePINDiode pind;
|
|---|
| 355 | MCalibrationRelTimeCam tmcam;
|
|---|
| 356 | MCalibrationHiLoCam hilcam;
|
|---|
| 357 | MCalibrationPulseTimeCam pulcam;
|
|---|
| 358 |
|
|---|
| 359 | MBadPixelsCam badpix;
|
|---|
| 360 |
|
|---|
| 361 | TObjArray interlacedcont;
|
|---|
| 362 | if (fIsInterlaced)
|
|---|
| 363 | {
|
|---|
| 364 | interlacedcont.Add(&ichcam);
|
|---|
| 365 | interlacedcont.Add(&iqecam);
|
|---|
| 366 | interlacedcont.Add(&iblcam);
|
|---|
| 367 | interlacedcont.Add(&itmcam);
|
|---|
| 368 | interlacedcont.Add(&ibdcam);
|
|---|
| 369 | interlacedcont.Add(&hchacam);
|
|---|
| 370 | if (IsUseBlindPixel())
|
|---|
| 371 | interlacedcont.Add(&hbndcam);
|
|---|
| 372 | if (IsUsePINDiode())
|
|---|
| 373 | interlacedcont.Add(&hpndiod);
|
|---|
| 374 | if (fIsRelTimesUpdate)
|
|---|
| 375 | interlacedcont.Add(&hrelcam);
|
|---|
| 376 | }
|
|---|
| 377 |
|
|---|
| 378 | MExtractor *extractor1=fExtractor;
|
|---|
| 379 | MExtractor *extractor2=0;
|
|---|
| 380 | MExtractor *extractor3=0;
|
|---|
| 381 | TString geom;
|
|---|
| 382 |
|
|---|
| 383 | TObjArray calibcont;
|
|---|
| 384 | calibcont.Add(&calcam);
|
|---|
| 385 | calibcont.Add(&qecam);
|
|---|
| 386 | calibcont.Add(&bndcam);
|
|---|
| 387 | calibcont.Add(&pind);
|
|---|
| 388 | calibcont.Add(&tmcam);
|
|---|
| 389 |
|
|---|
| 390 | if (!ReadCalibration(calibcont, badpix, extractor2, extractor3, geom))
|
|---|
| 391 | return kFALSE;
|
|---|
| 392 |
|
|---|
| 393 | *fLog << all;
|
|---|
| 394 | if (!geom.IsNull())
|
|---|
| 395 | *fLog << inf << "Camera geometry found in file: " << geom << endl;
|
|---|
| 396 | else
|
|---|
| 397 | *fLog << inf << "No Camera geometry found using default <MGeomCamMagic>" << endl;
|
|---|
| 398 |
|
|---|
| 399 | if (extractor3)
|
|---|
| 400 | {
|
|---|
| 401 | *fLog << underline << "Signal Extractor found in calibration file" << endl;
|
|---|
| 402 | extractor3->Print();
|
|---|
| 403 | *fLog << endl;
|
|---|
| 404 | }
|
|---|
| 405 | else
|
|---|
| 406 | *fLog << inf << "No Signal Extractor: ExtractSignal in file." << endl;
|
|---|
| 407 |
|
|---|
| 408 |
|
|---|
| 409 | if (extractor1)
|
|---|
| 410 | {
|
|---|
| 411 | *fLog << underline << "Modified Signal Extractor set by user." << endl;
|
|---|
| 412 | extractor1->Print();
|
|---|
| 413 | *fLog << endl;
|
|---|
| 414 | }
|
|---|
| 415 | else
|
|---|
| 416 | {
|
|---|
| 417 | *fLog << inf << "No modified Signal Extractor set by user... using ExtractSignal." << endl;
|
|---|
| 418 | extractor1 = extractor3 ? (MExtractor*)extractor3->Clone() : 0;
|
|---|
| 419 | }
|
|---|
| 420 |
|
|---|
| 421 | if (extractor2)
|
|---|
| 422 | {
|
|---|
| 423 | *fLog << underline << "Time Extractor found in calibration file" << endl;
|
|---|
| 424 | extractor2->Print();
|
|---|
| 425 | *fLog << endl;
|
|---|
| 426 | }
|
|---|
| 427 | else
|
|---|
| 428 | *fLog << inf << "No Time Extractor: ExtractTime in file." << endl;
|
|---|
| 429 |
|
|---|
| 430 | // This is necessary for the case in which it is not in the files
|
|---|
| 431 | MBadPixelsCam badcam;
|
|---|
| 432 |
|
|---|
| 433 | // Setup Parlist
|
|---|
| 434 | MParList plist;
|
|---|
| 435 | plist.AddToList(this); // take care of fDisplay!
|
|---|
| 436 | plist.AddToList(&badcam);
|
|---|
| 437 | plist.AddToList(&hilcam);
|
|---|
| 438 | plist.AddToList(&calibcont); // Using AddToList(TObjArray *)
|
|---|
| 439 | plist.AddToList(&interlacedcont); // Using AddToList(TObjArray *)
|
|---|
| 440 | plist.AddToList(&pulcam);
|
|---|
| 441 |
|
|---|
| 442 | // Setup Tasklist
|
|---|
| 443 | MTaskList tlist;
|
|---|
| 444 | plist.AddToList(&tlist);
|
|---|
| 445 |
|
|---|
| 446 | MReadReports readreal;
|
|---|
| 447 | readreal.AddTree("Events", "MTime.", kTRUE);
|
|---|
| 448 | readreal.AddTree("Trigger");
|
|---|
| 449 | readreal.AddTree("Camera");
|
|---|
| 450 | readreal.AddTree("Drive");
|
|---|
| 451 | readreal.AddTree("CC");
|
|---|
| 452 | readreal.AddTree("Currents");
|
|---|
| 453 |
|
|---|
| 454 | MReadMarsFile readmc("Events");
|
|---|
| 455 | readmc.DisableAutoScheme();
|
|---|
| 456 |
|
|---|
| 457 | MRawFileRead rawread(NULL);
|
|---|
| 458 |
|
|---|
| 459 | MRead *read = 0;
|
|---|
| 460 | switch (GetDataFlag())
|
|---|
| 461 | {
|
|---|
| 462 | case kIsUseRawData: read = &rawread; break;
|
|---|
| 463 | case kIsUseMC: read = &readmc; break;
|
|---|
| 464 | case kIsUseRootData: read = &readreal; break;
|
|---|
| 465 | }
|
|---|
| 466 | read->AddFiles(fSequence.IsValid() ? iter : *fRuns);
|
|---|
| 467 |
|
|---|
| 468 | const TString fname(Form("%s{s/_D_/_Y_}{s/.raw$/.root}", fPathOut.Data()));
|
|---|
| 469 |
|
|---|
| 470 |
|
|---|
| 471 | // Skips MC which have no contents. This are precisely the
|
|---|
| 472 | // events which fullfilled the MC Lvl1 trigger and an
|
|---|
| 473 | // arbitrary cut (typically at 50phe) to speed up simulation
|
|---|
| 474 | MContinue contmc("MRawEvtData.GetNumPixels<0.5", "ContEmptyMC");
|
|---|
| 475 |
|
|---|
| 476 | MPointingPosInterpolate pextr;
|
|---|
| 477 | pextr.AddFiles(&iter);
|
|---|
| 478 |
|
|---|
| 479 | MGeomApply apply; // Only necessary to create geometry
|
|---|
| 480 | if (!geom.IsNull())
|
|---|
| 481 | apply.SetGeometry(geom);
|
|---|
| 482 | MBadPixelsMerge merge(&badpix);
|
|---|
| 483 |
|
|---|
| 484 | // Make sure that pedcamab has the correct name
|
|---|
| 485 | pedcamab.SetName("MPedestalFundamental");
|
|---|
| 486 | pedcamextr.SetName("MPedestalFromExtractorRndm");
|
|---|
| 487 | pedcambias.SetName("MPedestalFromExtractor");
|
|---|
| 488 | plist.AddToList(&pedcamextr);
|
|---|
| 489 | plist.AddToList(&pedcambias);
|
|---|
| 490 | plist.AddToList(&pedcamab);
|
|---|
| 491 |
|
|---|
| 492 | MArrivalTimeCam timecam;
|
|---|
| 493 | plist.AddToList(&timecam);
|
|---|
| 494 |
|
|---|
| 495 | // Check for interleaved events
|
|---|
| 496 | MCalibrationPatternDecode caldec;
|
|---|
| 497 | MTriggerPatternDecode decode;
|
|---|
| 498 |
|
|---|
| 499 | MFTriggerPattern ftp;
|
|---|
| 500 | // ftp.RequireCalibration();
|
|---|
| 501 | ftp.DenyCalibration();
|
|---|
| 502 | ftp.DenyPedestal();
|
|---|
| 503 | // ftp.DenyPinDiode();
|
|---|
| 504 | ftp.SetInverted();
|
|---|
| 505 | MContinue conttp(&ftp, "ContTrigPattern");
|
|---|
| 506 | // --> tlist2
|
|---|
| 507 |
|
|---|
| 508 | // Do signal and pedestal calculation
|
|---|
| 509 | MPedCalcFromLoGain pedlo1("MPedCalcFundamental");
|
|---|
| 510 | pedlo1.SetPedestalUpdate(kTRUE);
|
|---|
| 511 | pedlo1.SetNamePedestalCamOut("MPedestalFundamental");
|
|---|
| 512 |
|
|---|
| 513 | MPedCalcFromLoGain pedlo2("MPedCalcWithExtractorRndm");
|
|---|
| 514 | pedlo2.SetPedestalUpdate(kTRUE);
|
|---|
| 515 | pedlo2.SetRandomCalculation(kTRUE);
|
|---|
| 516 | pedlo2.SetNamePedestalCamIn("MPedestalFundamental");
|
|---|
| 517 | pedlo2.SetNamePedestalCamOut("MPedestalFromExtractorRndm");
|
|---|
| 518 |
|
|---|
| 519 | MPedCalcFromLoGain pedlo3("MPedCalcWithExtractor");
|
|---|
| 520 | pedlo3.SetPedestalUpdate(kTRUE);
|
|---|
| 521 | pedlo3.SetRandomCalculation(kFALSE);
|
|---|
| 522 | pedlo3.SetNamePedestalCamIn("MPedestalFundamental");
|
|---|
| 523 | pedlo3.SetNamePedestalCamOut("MPedestalFromExtractor");
|
|---|
| 524 |
|
|---|
| 525 | if (extractor1)
|
|---|
| 526 | {
|
|---|
| 527 | extractor1->SetPedestals(&pedcamab);
|
|---|
| 528 |
|
|---|
| 529 | if (extractor1->InheritsFrom("MExtractTimeAndCharge"))
|
|---|
| 530 | {
|
|---|
| 531 | pedlo2.SetExtractor((MExtractTimeAndCharge*)extractor1);
|
|---|
| 532 | pedlo3.SetExtractor((MExtractTimeAndCharge*)extractor1);
|
|---|
| 533 | const Int_t win = ((MExtractTimeAndCharge*)extractor1)->GetWindowSizeHiGain();
|
|---|
| 534 | pedlo1.SetExtractWindow(15, win);
|
|---|
| 535 | pedlo2.SetExtractWindow(15, win/*obsolete*/);
|
|---|
| 536 | pedlo3.SetExtractWindow(15, win/*obsolete*/);
|
|---|
| 537 | }
|
|---|
| 538 | else
|
|---|
| 539 | {
|
|---|
| 540 | // FIXME: How to get the fixed value 15 automatically?
|
|---|
| 541 | const Int_t f = (Int_t)(15.5+extractor1->GetHiGainFirst());
|
|---|
| 542 | const Int_t n = (Int_t)(15.5+extractor1->GetNumHiGainSamples());
|
|---|
| 543 | pedlo1.SetExtractWindow(f, n);
|
|---|
| 544 | pedlo2.SetExtractWindow(f, n);
|
|---|
| 545 | pedlo3.SetExtractWindow(f, n);
|
|---|
| 546 | }
|
|---|
| 547 | }
|
|---|
| 548 | if (extractor2)
|
|---|
| 549 | extractor2->SetPedestals(&pedcamab);
|
|---|
| 550 |
|
|---|
| 551 | if (extractor3)
|
|---|
| 552 | extractor3->SetPedestals(&pedcamab);
|
|---|
| 553 |
|
|---|
| 554 | MFCosmics fcosmics;
|
|---|
| 555 | fcosmics.SetNamePedestalCam("MPedestalFundamental");
|
|---|
| 556 | MContinue contcos(&fcosmics, "ContTrigEvts");
|
|---|
| 557 | contcos.SetInverted();
|
|---|
| 558 |
|
|---|
| 559 | //MMcPedestalCopy pcopy;
|
|---|
| 560 | MTaskEnv taskenv1("ExtractSignal");
|
|---|
| 561 | MTaskEnv taskenv2("ExtractTime");
|
|---|
| 562 | MTaskEnv taskenv3("ExtractInterlaced");
|
|---|
| 563 | taskenv1.SetDefault(extractor1);
|
|---|
| 564 | taskenv2.SetDefault(extractor2);
|
|---|
| 565 | taskenv3.SetDefault(extractor3);
|
|---|
| 566 |
|
|---|
| 567 | //
|
|---|
| 568 | // This is new calibration to photo-electrons, hard-coded
|
|---|
| 569 | // as decided at the Wuerzburg software meeting 26.01.05
|
|---|
| 570 | //
|
|---|
| 571 | MCalibrateData calib;
|
|---|
| 572 | calib.SetSignalType(MCalibrateData::kPhe);
|
|---|
| 573 | calib.AddPedestal("Fundamental");
|
|---|
| 574 | calib.AddPedestal("FromExtractor");
|
|---|
| 575 | calib.AddPedestal("FromExtractorRndm");
|
|---|
| 576 | calib.SetPedestalFlag(MCalibrateData::kEvent);
|
|---|
| 577 | //----------------------------------------------------------
|
|---|
| 578 |
|
|---|
| 579 | MExtractPINDiode pinext;
|
|---|
| 580 | MExtractBlindPixel bldext;
|
|---|
| 581 |
|
|---|
| 582 | MFTriggerPattern fcalib("CalibFilter");
|
|---|
| 583 | fcalib.RequireCalibration();
|
|---|
| 584 |
|
|---|
| 585 | MCalibrationChargeCalc chcalc;
|
|---|
| 586 | MCalibrationRelTimeCalc recalc;
|
|---|
| 587 | MCalibCalcFromPast pacalc;
|
|---|
| 588 | chcalc.SetOutputFile("");
|
|---|
| 589 | recalc.SetOutputFile("");
|
|---|
| 590 |
|
|---|
| 591 | pinext.SetPedestals(&pedcamab);
|
|---|
| 592 | bldext.SetPedestals(&pedcamab);
|
|---|
| 593 | chcalc.SetPedestals(&pedcamextr);
|
|---|
| 594 |
|
|---|
| 595 | pacalc.SetChargeCalc(&chcalc);
|
|---|
| 596 | if (fIsRelTimesUpdate)
|
|---|
| 597 | pacalc.SetRelTimeCalc(&recalc);
|
|---|
| 598 | pacalc.SetCalibrate(&calib);
|
|---|
| 599 |
|
|---|
| 600 | //
|
|---|
| 601 | // Intensity Calibration histogramming
|
|---|
| 602 | //
|
|---|
| 603 | MFillH filpin("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode", "FillPINDiode");
|
|---|
| 604 | MFillH filbnd("MHCalibrationChargeBlindCam", "MExtractedSignalBlindPixel", "FillBlindCam");
|
|---|
| 605 | MFillH filcam("MHCalibrationChargeCam", "MExtractedSignalCam", "FillChargeCam");
|
|---|
| 606 | MFillH filtme("MHCalibrationRelTimeCam", "MArrivalTimeCam", "FillRelTime");
|
|---|
| 607 | MFillH filhil("MHCalibrationHiLoCam", "MExtractedSignalCam", "FillHiLoRatio");
|
|---|
| 608 | MFillH filpul("MHCalibrationPulseTimeCam", "MRawEvtData", "FillPulseTime");
|
|---|
| 609 |
|
|---|
| 610 | filpin.SetBit(MFillH::kDoNotDisplay);
|
|---|
| 611 | filbnd.SetBit(MFillH::kDoNotDisplay);
|
|---|
| 612 | filcam.SetBit(MFillH::kDoNotDisplay);
|
|---|
| 613 | filtme.SetBit(MFillH::kDoNotDisplay);
|
|---|
| 614 | filhil.SetBit(MFillH::kDoNotDisplay);
|
|---|
| 615 | filpul.SetBit(MFillH::kDoNotDisplay);
|
|---|
| 616 |
|
|---|
| 617 | MCalibrateRelTimes caltm;
|
|---|
| 618 | MBadPixelsCalc bpcal;
|
|---|
| 619 | MBadPixelsTreat treat;
|
|---|
| 620 |
|
|---|
| 621 | bpcal.SetNamePedPhotCam("MPedPhotFromExtractor");
|
|---|
| 622 | treat.AddNamePedPhotCam("MPedPhotFundamental");
|
|---|
| 623 | treat.AddNamePedPhotCam("MPedPhotFromExtractor");
|
|---|
| 624 | treat.AddNamePedPhotCam("MPedPhotFromExtractorRndm");
|
|---|
| 625 | if (!extractor2 && !extractor1->InheritsFrom("MExtractTimeAndCharge"))
|
|---|
| 626 | treat.SetProcessTimes(kFALSE);
|
|---|
| 627 |
|
|---|
| 628 | MHCamEvent evt0(0, "PedFLG", "Fundamental Pedestal from Lo Gain;;P [cnts/sl]");
|
|---|
| 629 | MHCamEvent evt1(2, "PedRmsFLG", "RMS from Extractor applied to ped.;;\\sigma_{p} [cnts/sl]");
|
|---|
| 630 | MHCamEvent evt2(0, "Extra'd", "Extracted Signal;;S [cnts/sl]");
|
|---|
| 631 | // MHCamEvent evt3(4, "PedPhot", "Calibrated Pedestal;;P [phe]");
|
|---|
| 632 | MHCamEvent evt4(5, "PedRMS", "Calibrated RMS from Extractor applied to ped.;;\\sigma_{p} [phe]");
|
|---|
| 633 | MHCamEvent evt5(0, "Interp'd", "Interpolated Signal;;S [phe]");
|
|---|
| 634 | MHCamEvent evt6(2, "Unsuitable", "Fraction of unsuitable events per Pixel;;[1]");
|
|---|
| 635 | MHCamEvent evt7(6, "Times", "Calibrated Arrival Time;;T [fadc sl]");
|
|---|
| 636 | MHCamEvent evt8(0, "Conv", "Calibration Conv. Factors;;[phe/fadc cnts]");
|
|---|
| 637 | MHCamEvent evt9(7, "PulsePos", "Pulse Position of cosmics (>15phe);;T"); //Calibration Conv. Factors;;[phe/fadc cnts]
|
|---|
| 638 | /*
|
|---|
| 639 | MHCamEventTH evt9(6, "PulsePos", "Pulse Position of cosmics"); //Calibration Conv. Factors;;[phe/fadc cnts]
|
|---|
| 640 | evt9.SetNameThreshold("MCerPhotEvt");
|
|---|
| 641 | evt9.SetThreshold(15);
|
|---|
| 642 | */
|
|---|
| 643 | /*
|
|---|
| 644 | evt0.EnableSqrtVariance();
|
|---|
| 645 | evt1.EnableSqrtVariance();
|
|---|
| 646 | evt2.EnableSqrtVariance();
|
|---|
| 647 | // evt3.EnableVariance();
|
|---|
| 648 | evt4.EnableSqrtVariance();
|
|---|
| 649 | evt5.EnableSqrtVariance();
|
|---|
| 650 | evt7.EnableSqrtVariance();
|
|---|
| 651 | evt8.EnableSqrtVariance();
|
|---|
| 652 | */
|
|---|
| 653 | MFillH fill0(&evt0, "MPedestalFundamental", "FillPedFLG");
|
|---|
| 654 | MFillH fill1(&evt1, "MPedestalFromExtractorRndm", "FillPedRmsFLG");
|
|---|
| 655 | MFillH fill2(&evt2, "MExtractedSignalCam", "FillExtracted");
|
|---|
| 656 | // MFillH fill3(&evt3, "MPedPhotFundamental", "FillPedPhot");
|
|---|
| 657 | MFillH fill4(&evt4, "MPedPhotFromExtractorRndm", "FillPedRMS");
|
|---|
| 658 | MFillH fill5(&evt5, "MSignalCam", "FillInterpolated");
|
|---|
| 659 | MFillH fill6(&evt6, "MBadPixelsCam", "FillUnsuitable");
|
|---|
| 660 | MFillH fill7(&evt7, "MSignalCam", "FillTimes");
|
|---|
| 661 | MFillH fill8(&evt8, "MCalibConstCam", "FillConv");
|
|---|
| 662 | MFillH fill9(&evt9, "MSignalCam", "FillPulse");
|
|---|
| 663 |
|
|---|
| 664 | MTaskEnv fillflorian("FinalFantasy");
|
|---|
| 665 | fillflorian.SetDefault();
|
|---|
| 666 |
|
|---|
| 667 | // The second rule is for the case reading raw-files!
|
|---|
| 668 | MWriteRootFile write(2, fname, fOverwrite?"RECREATE":"NEW");
|
|---|
| 669 | // Run Header
|
|---|
| 670 | write.AddContainer("MRawRunHeader", "RunHeaders");
|
|---|
| 671 | write.AddContainer("MBadPixelsCam", "RunHeaders");
|
|---|
| 672 | write.AddContainer("MGeomCam", "RunHeaders");
|
|---|
| 673 | // Monte Carlo Headers
|
|---|
| 674 | write.AddContainer("MMcRunHeader", "RunHeaders", kFALSE);
|
|---|
| 675 | write.AddContainer("MMcFadcHeader", "RunHeaders", kFALSE);
|
|---|
| 676 | write.AddContainer("MMcTrigHeader", "RunHeaders", kFALSE);
|
|---|
| 677 | write.AddContainer("MMcConfigRunHeader", "RunHeaders", kFALSE);
|
|---|
| 678 | write.AddContainer("MMcCorsikaRunHeader", "RunHeaders", kFALSE);
|
|---|
| 679 | // Monte Carlo
|
|---|
| 680 | write.AddContainer("MMcEvt", "Events", kFALSE);
|
|---|
| 681 | write.AddContainer("MMcTrig", "Events", kFALSE);
|
|---|
| 682 | // Data tree
|
|---|
| 683 | write.AddContainer("MSignalCam", "Events");
|
|---|
| 684 | write.AddContainer("MPedPhotFundamental", "Events");
|
|---|
| 685 | write.AddContainer("MPedPhotFromExtractor", "Events");
|
|---|
| 686 | write.AddContainer("MPedPhotFromExtractorRndm", "Events");
|
|---|
| 687 | write.AddContainer("MTime", "Events", kFALSE);
|
|---|
| 688 | write.AddContainer("MRawEvtHeader", "Events");
|
|---|
| 689 | //write.AddContainer("MArrivalTime", "Events", kFALSE);
|
|---|
| 690 | //write.AddContainer("MPointingPos", "Events", kFALSE);
|
|---|
| 691 | // Slow-Control: Current-tree
|
|---|
| 692 | write.AddContainer("MTimeCurrents", "Currents", kFALSE);
|
|---|
| 693 | write.AddContainer("MCameraDC", "Currents", kFALSE);
|
|---|
| 694 | write.AddContainer("MReportCurrents", "Currents", kFALSE);
|
|---|
| 695 | // Slow-Control: Camera-tree
|
|---|
| 696 | write.AddContainer("MReportCamera", "Camera", kFALSE);
|
|---|
| 697 | write.AddContainer("MTimeCamera", "Camera", kFALSE);
|
|---|
| 698 | write.AddContainer("MCameraAUX", "Camera", kFALSE);
|
|---|
| 699 | write.AddContainer("MCameraCalibration", "Camera", kFALSE);
|
|---|
| 700 | write.AddContainer("MCameraCooling", "Camera", kFALSE);
|
|---|
| 701 | write.AddContainer("MCameraHV", "Camera", kFALSE);
|
|---|
| 702 | write.AddContainer("MCameraLV", "Camera", kFALSE);
|
|---|
| 703 | write.AddContainer("MCameraLids", "Camera", kFALSE);
|
|---|
| 704 | // Slow-Control: Trigger-tree
|
|---|
| 705 | write.AddContainer("MReportTrigger", "Trigger", kFALSE);
|
|---|
| 706 | write.AddContainer("MTimeTrigger", "Trigger", kFALSE);
|
|---|
| 707 | // Slow-Control: Drive-tree
|
|---|
| 708 | write.AddContainer("MReportDrive", "Drive", kFALSE);
|
|---|
| 709 | write.AddContainer("MTimeDrive", "Drive", kFALSE);
|
|---|
| 710 | // Slow-Control: Central Control-tree
|
|---|
| 711 | write.AddContainer("MReportCC", "CC", kFALSE);
|
|---|
| 712 | write.AddContainer("MTimeCC", "CC", kFALSE);
|
|---|
| 713 |
|
|---|
| 714 | // Write the special MC tree
|
|---|
| 715 | MWriteRootFile writemc(2, fname, fOverwrite?"RECREATE":"NEW");
|
|---|
| 716 | writemc.SetName("WriteMC");
|
|---|
| 717 | writemc.AddContainer("MMcEvtBasic", "OriginalMC");
|
|---|
| 718 |
|
|---|
| 719 | // Now setup tasklist for events
|
|---|
| 720 | MTaskList tlist2;
|
|---|
| 721 |
|
|---|
| 722 | tlist2.AddToList(&caldec);
|
|---|
| 723 | tlist2.AddToList(&decode);
|
|---|
| 724 | tlist2.AddToList(&apply);
|
|---|
| 725 | tlist2.AddToList(&merge);
|
|---|
| 726 | tlist2.AddToList(&pedlo1);
|
|---|
| 727 | tlist2.AddToList(&pedlo2);
|
|---|
| 728 | tlist2.AddToList(&pedlo3);
|
|---|
| 729 | //-----------------------------------------------------------
|
|---|
| 730 |
|
|---|
| 731 | MTaskList tlist3;
|
|---|
| 732 | tlist3.SetFilter(&fcalib);
|
|---|
| 733 |
|
|---|
| 734 | if (fIsInterlaced)
|
|---|
| 735 | {
|
|---|
| 736 | tlist2.AddToList(&fcalib);
|
|---|
| 737 | tlist2.AddToList(&tlist3);
|
|---|
| 738 |
|
|---|
| 739 | tlist3.AddToList(&pinext);
|
|---|
| 740 | tlist3.AddToList(&bldext);
|
|---|
| 741 | tlist3.AddToList(&taskenv3);
|
|---|
| 742 | tlist3.AddToList(&pacalc);
|
|---|
| 743 | tlist3.AddToList(&filcam);
|
|---|
| 744 | if (fIsRelTimesUpdate)
|
|---|
| 745 | tlist3.AddToList(&filtme);
|
|---|
| 746 | if (IsUseBlindPixel())
|
|---|
| 747 | tlist3.AddToList(&filbnd);
|
|---|
| 748 | if (IsUsePINDiode())
|
|---|
| 749 | tlist3.AddToList(&filpin);
|
|---|
| 750 | tlist3.AddToList(&chcalc);
|
|---|
| 751 | if (fIsRelTimesUpdate)
|
|---|
| 752 | tlist3.AddToList(&recalc);
|
|---|
| 753 | }
|
|---|
| 754 |
|
|---|
| 755 | // Continue for all non-cosmic events
|
|---|
| 756 | tlist2.AddToList(&conttp);
|
|---|
| 757 | if (extractor1)
|
|---|
| 758 | tlist2.AddToList(&taskenv1);
|
|---|
| 759 | if (extractor2)
|
|---|
| 760 | tlist2.AddToList(&taskenv2);
|
|---|
| 761 | tlist2.AddToList(&fill0);
|
|---|
| 762 | tlist2.AddToList(&fill1);
|
|---|
| 763 | tlist2.AddToList(&contcos);
|
|---|
| 764 | if (fIsHiLoCalibration)
|
|---|
| 765 | tlist2.AddToList(&filhil);
|
|---|
| 766 | if (fIsPulsePosCheck)
|
|---|
| 767 | tlist2.AddToList(&filpul);
|
|---|
| 768 | tlist2.AddToList(&fill2);
|
|---|
| 769 | tlist2.AddToList(&calib);
|
|---|
| 770 | if (extractor2 || extractor1->InheritsFrom("MExtractTimeAndCharge"))
|
|---|
| 771 | tlist2.AddToList(&caltm);
|
|---|
| 772 | if (fIsInterlaced)
|
|---|
| 773 | tlist2.AddToList(&fill8);
|
|---|
| 774 | tlist2.AddToList(&bpcal);
|
|---|
| 775 | tlist2.AddToList(&treat);
|
|---|
| 776 | tlist2.AddToList(&fill6);
|
|---|
| 777 | // tlist2.AddToList(&fill3);
|
|---|
| 778 | tlist2.AddToList(&fill4);
|
|---|
| 779 | tlist2.AddToList(&fill5);
|
|---|
| 780 | if (extractor2 || extractor1->InheritsFrom("MExtractTimeAndCharge"))
|
|---|
| 781 | tlist2.AddToList(&fill7);
|
|---|
| 782 | tlist2.AddToList(&fill9);
|
|---|
| 783 |
|
|---|
| 784 | tlist2.AddToList(&fillflorian);
|
|---|
| 785 |
|
|---|
| 786 | // Setup List for Drive-tree
|
|---|
| 787 | //MPointingPosCalc pcalc;
|
|---|
| 788 |
|
|---|
| 789 | // Now setup main tasklist
|
|---|
| 790 | tlist.AddToList(read);
|
|---|
| 791 | if (IsUseMC())
|
|---|
| 792 | {
|
|---|
| 793 | tlist.AddToList(&writemc);
|
|---|
| 794 | tlist.AddToList(&contmc);
|
|---|
| 795 | }
|
|---|
| 796 |
|
|---|
| 797 | if (IsUseRootData())
|
|---|
| 798 | tlist2.AddToList(&pextr);
|
|---|
| 799 | tlist.AddToList(&tlist2, IsUseRootData() ? "Events" : "All");
|
|---|
| 800 |
|
|---|
| 801 | //if (IsUseMC())
|
|---|
| 802 | // tlist.AddToList(&pcalc, "Drive");
|
|---|
| 803 |
|
|---|
| 804 | tlist.AddToList(&write);
|
|---|
| 805 |
|
|---|
| 806 | // Create and setup the eventloop
|
|---|
| 807 | MEvtLoop evtloop(fName);
|
|---|
| 808 | evtloop.SetParList(&plist);
|
|---|
| 809 | evtloop.SetDisplay(fDisplay);
|
|---|
| 810 | evtloop.SetLogStream(fLog);
|
|---|
| 811 | if (!SetupEnv(evtloop))
|
|---|
| 812 | return kFALSE;
|
|---|
| 813 |
|
|---|
| 814 | // Execute first analysis
|
|---|
| 815 | const Bool_t rc = evtloop.Eventloop(fMaxEvents);
|
|---|
| 816 |
|
|---|
| 817 | // Print statistics
|
|---|
| 818 | if (read->GetNumExecutions()>0)
|
|---|
| 819 | tlist.PrintStatistics();
|
|---|
| 820 |
|
|---|
| 821 | // make sure owned object are deleted
|
|---|
| 822 | if (extractor1 && extractor1!=fExtractor)
|
|---|
| 823 | delete extractor1;
|
|---|
| 824 | if (extractor2)
|
|---|
| 825 | delete extractor2;
|
|---|
| 826 | if (extractor3)
|
|---|
| 827 | delete extractor3;
|
|---|
| 828 |
|
|---|
| 829 | // return if job failed
|
|---|
| 830 | if (!rc)
|
|---|
| 831 | {
|
|---|
| 832 | *fLog << err << GetDescriptor() << ": Failed." << endl;
|
|---|
| 833 | return kFALSE;
|
|---|
| 834 | }
|
|---|
| 835 |
|
|---|
| 836 | // if everything went ok write and display result
|
|---|
| 837 | DisplayResult(plist);
|
|---|
| 838 |
|
|---|
| 839 | if (fIsPixelCheck)
|
|---|
| 840 | {
|
|---|
| 841 | if (fIsPulsePosCheck)
|
|---|
| 842 | {
|
|---|
| 843 | MHCalibrationPulseTimeCam *pcam = (MHCalibrationPulseTimeCam*)plist.FindObject("MHCalibrationPulseTimeCam");
|
|---|
| 844 | MHCalibrationPix &pix1 = (*pcam)[fCheckedPixId];
|
|---|
| 845 | pix1.DrawClone("");
|
|---|
| 846 | }
|
|---|
| 847 |
|
|---|
| 848 | if (fIsHiLoCalibration)
|
|---|
| 849 | {
|
|---|
| 850 | MHCalibrationHiLoCam *hcam = (MHCalibrationHiLoCam*)plist.FindObject("MHCalibrationHiLoCam");
|
|---|
| 851 | MHCalibrationPix &pix2 = (*hcam)[fCheckedPixId];
|
|---|
| 852 | pix2.DrawClone("");
|
|---|
| 853 | }
|
|---|
| 854 | }
|
|---|
| 855 |
|
|---|
| 856 | interlacedcont.Add(&pulcam);
|
|---|
| 857 |
|
|---|
| 858 | if (fIsHiLoCalibration)
|
|---|
| 859 | interlacedcont.Add(&hilcam);
|
|---|
| 860 |
|
|---|
| 861 | if (IsHistsStorage())
|
|---|
| 862 | {
|
|---|
| 863 | interlacedcont.Add(plist.FindObject("MHCalibrationHiLoCam"));
|
|---|
| 864 | interlacedcont.Add(plist.FindObject("MHCalibrationPulseTimeCam"));
|
|---|
| 865 | }
|
|---|
| 866 |
|
|---|
| 867 | if (!WriteResult(interlacedcont))
|
|---|
| 868 | return kFALSE;
|
|---|
| 869 |
|
|---|
| 870 | // return if job went ok
|
|---|
| 871 | *fLog << all << GetDescriptor() << ": Done." << endl;
|
|---|
| 872 | *fLog << endl << endl;
|
|---|
| 873 |
|
|---|
| 874 | return kTRUE;
|
|---|
| 875 | }
|
|---|
| 876 |
|
|---|
| 877 |
|
|---|
| 878 | void MJCalibrateSignal::DisplayResult(MParList &plist)
|
|---|
| 879 | {
|
|---|
| 880 |
|
|---|
| 881 | if (!fDisplay)
|
|---|
| 882 | return;
|
|---|
| 883 |
|
|---|
| 884 | MGeomCam &geomcam = *(MGeomCam*)plist.FindObject("MGeomCam");
|
|---|
| 885 | /*
|
|---|
| 886 | //
|
|---|
| 887 | // Get container from list
|
|---|
| 888 | //
|
|---|
| 889 | MCalibrationPulseTimeCam *pcam = (MCalibrationPulseTimeCam*)plist.FindObject("MCalibrationPulseTimeCam");
|
|---|
| 890 |
|
|---|
| 891 | MHCamera disp11 (geomcam, "PulseTime", "Mean pulse arrival time cosmics");
|
|---|
| 892 | MHCamera disp21 (geomcam, "PulseTimeRMS", "RMS of pulse arrival time cosmics");
|
|---|
| 893 |
|
|---|
| 894 | if (pcam)
|
|---|
| 895 | {
|
|---|
| 896 | disp11.SetCamContent(*pcam, 0);
|
|---|
| 897 | disp11.SetCamError( *pcam, 1);
|
|---|
| 898 | disp21.SetCamContent(*pcam, 2);
|
|---|
| 899 | disp21.SetCamError( *pcam, 3);
|
|---|
| 900 | }
|
|---|
| 901 |
|
|---|
| 902 | disp11.SetYTitle("T [FADC sl.]");
|
|---|
| 903 | disp21.SetYTitle("T [FADC sl.]");
|
|---|
| 904 |
|
|---|
| 905 | if (fIsPulsePosCheck)
|
|---|
| 906 | {
|
|---|
| 907 | TCanvas &c0 = fDisplay->AddTab("PulseTime");
|
|---|
| 908 | c0.Divide(2,3);
|
|---|
| 909 |
|
|---|
| 910 | disp11.CamDraw(c0, 1, 2, 1);
|
|---|
| 911 | disp21.CamDraw(c0, 2, 2, 1);
|
|---|
| 912 | }
|
|---|
| 913 | */
|
|---|
| 914 | if (!fIsHiLoCalibration)
|
|---|
| 915 | return;
|
|---|
| 916 |
|
|---|
| 917 | MCalibrationHiLoCam *hcam = (MCalibrationHiLoCam*)plist.FindObject("MCalibrationHiLoCam");
|
|---|
| 918 |
|
|---|
| 919 | // Create histograms to display
|
|---|
| 920 | MHCamera disp1 (geomcam, "HiLoConv", "Ratio Amplification HiGain vs. LoGain (Charges)");
|
|---|
| 921 | MHCamera disp2 (geomcam, "HiLoDiff", "Arrival Time Diff. HiGain vs. LoGain (Times)");
|
|---|
| 922 |
|
|---|
| 923 | disp1.SetCamContent(*hcam, 0);
|
|---|
| 924 | disp1.SetCamError( *hcam, 1);
|
|---|
| 925 | disp2.SetCamContent(*hcam, 5);
|
|---|
| 926 | disp2.SetCamError( *hcam, 6);
|
|---|
| 927 |
|
|---|
| 928 | disp1.SetYTitle("R [1]");
|
|---|
| 929 | disp2.SetYTitle("\\Delta T [FADC sl.]");
|
|---|
| 930 |
|
|---|
| 931 |
|
|---|
| 932 | TCanvas &c1 = fDisplay->AddTab("HiLoConv");
|
|---|
| 933 | c1.Divide(2,3);
|
|---|
| 934 |
|
|---|
| 935 | disp1.CamDraw(c1, 1, 2, 1);
|
|---|
| 936 | disp2.CamDraw(c1, 2, 2, 1);
|
|---|
| 937 | }
|
|---|
| 938 |
|
|---|