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