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