| 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): Markus Gaug 04/2004 <mailto:markus@ifae.es>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2004
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | //
|
|---|
| 27 | // MCalibrateRelTimes
|
|---|
| 28 | //
|
|---|
| 29 | // This task takes the extracted arrival times from MArrivalTimeCam for each
|
|---|
| 30 | // pixel and applies the offset calibrated in MCalibrationRelTimeCam
|
|---|
| 31 | // The calibrated arrival time and its error gets stored in MSignalCam.
|
|---|
| 32 | //
|
|---|
| 33 | // Input Containers:
|
|---|
| 34 | // MArrivalTimeCam
|
|---|
| 35 | // MCalibrationRelTimeCam
|
|---|
| 36 | //
|
|---|
| 37 | // Output Containers:
|
|---|
| 38 | // MSignalCam
|
|---|
| 39 | //
|
|---|
| 40 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 41 | #include "MCalibrateRelTimes.h"
|
|---|
| 42 |
|
|---|
| 43 | #include "MLog.h"
|
|---|
| 44 | #include "MLogManip.h"
|
|---|
| 45 |
|
|---|
| 46 | #include "MParList.h"
|
|---|
| 47 | #include "MH.h"
|
|---|
| 48 |
|
|---|
| 49 | #include "MGeomCam.h"
|
|---|
| 50 |
|
|---|
| 51 | #include "MCalibrationRelTimeCam.h"
|
|---|
| 52 | #include "MCalibrationRelTimePix.h"
|
|---|
| 53 |
|
|---|
| 54 | #include "MArrivalTimeCam.h"
|
|---|
| 55 | #include "MArrivalTimePix.h"
|
|---|
| 56 |
|
|---|
| 57 | #include "MBadPixelsCam.h"
|
|---|
| 58 | #include "MBadPixelsPix.h"
|
|---|
| 59 |
|
|---|
| 60 | #include "MSignalCam.h"
|
|---|
| 61 | #include "MSignalPix.h"
|
|---|
| 62 |
|
|---|
| 63 | ClassImp(MCalibrateRelTimes);
|
|---|
| 64 |
|
|---|
| 65 | using namespace std;
|
|---|
| 66 | // --------------------------------------------------------------------------
|
|---|
| 67 | //
|
|---|
| 68 | // Default constructor.
|
|---|
| 69 | //
|
|---|
| 70 | MCalibrateRelTimes::MCalibrateRelTimes(const char *name, const char *title)
|
|---|
| 71 | : fGeomCam(NULL), fCalibrations(NULL), fBadPixels(NULL), fSignals(NULL),
|
|---|
| 72 | fArrivalTime(NULL)
|
|---|
| 73 | {
|
|---|
| 74 | fName = name ? name : "MCalibrateRelTimes";
|
|---|
| 75 | fTitle = title ? title : "Task to calculate the calibrated arrival times of photons in one event";
|
|---|
| 76 | }
|
|---|
| 77 |
|
|---|
| 78 | // --------------------------------------------------------------------------
|
|---|
| 79 | //
|
|---|
| 80 | // The PreProcess searches for the following input containers:
|
|---|
| 81 | // - MGeomCam
|
|---|
| 82 | // - MCalibrationRelTimesCam
|
|---|
| 83 | // - MArrivalTimeCam
|
|---|
| 84 | // - MBadPixelsCam
|
|---|
| 85 | //
|
|---|
| 86 | Int_t MCalibrateRelTimes::PreProcess(MParList *pList)
|
|---|
| 87 | {
|
|---|
| 88 |
|
|---|
| 89 | fSignals = (MArrivalTimeCam*)pList->FindObject(AddSerialNumber("MArrivalTimeCam"));
|
|---|
| 90 |
|
|---|
| 91 | if (!fSignals)
|
|---|
| 92 | {
|
|---|
| 93 | *fLog << err << AddSerialNumber("MArrivalTimeCam") << " not found ... aborting" << endl;
|
|---|
| 94 | return kFALSE;
|
|---|
| 95 | }
|
|---|
| 96 |
|
|---|
| 97 | fBadPixels = (MBadPixelsCam*)pList->FindObject(AddSerialNumber("MBadPixelsCam"));
|
|---|
| 98 | if (!fBadPixels)
|
|---|
| 99 | *fLog << warn << AddSerialNumber("MBadPixelsCam") << " not found ... no action" << endl;
|
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 | fCalibrations = (MCalibrationRelTimeCam*)pList->FindObject(AddSerialNumber("MCalibrationRelTimeCam"));
|
|---|
| 103 | if (!fCalibrations)
|
|---|
| 104 | {
|
|---|
| 105 | *fLog << err << AddSerialNumber("MCalibrationRelTimeCam") << " not found ... aborting." << endl;
|
|---|
| 106 | return kFALSE;
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 | fArrivalTime = (MSignalCam*)pList->FindCreateObj(AddSerialNumber("MSignalCam"));
|
|---|
| 111 | if (!fArrivalTime)
|
|---|
| 112 | return kFALSE;
|
|---|
| 113 |
|
|---|
| 114 | return kTRUE;
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | // --------------------------------------------------------------------------
|
|---|
| 118 | //
|
|---|
| 119 | // Apply the calibration factors to the extracted signal according to the
|
|---|
| 120 | // selected calibration method
|
|---|
| 121 | //
|
|---|
| 122 | Int_t MCalibrateRelTimes::Process()
|
|---|
| 123 | {
|
|---|
| 124 | const UInt_t npix = fSignals->GetSize();
|
|---|
| 125 |
|
|---|
| 126 | for (UInt_t pixidx=0; pixidx<npix; pixidx++)
|
|---|
| 127 | {
|
|---|
| 128 | MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCalibrations)[pixidx];
|
|---|
| 129 |
|
|---|
| 130 | if (fBadPixels && (*fBadPixels)[pixidx].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
|
|---|
| 131 | continue;
|
|---|
| 132 |
|
|---|
| 133 | const Float_t offset = pix.GetTimeOffset();
|
|---|
| 134 |
|
|---|
| 135 | MArrivalTimePix &sig = (*fSignals)[pixidx];
|
|---|
| 136 |
|
|---|
| 137 | Float_t signal;
|
|---|
| 138 |
|
|---|
| 139 | if (sig.IsLoGainUsed())
|
|---|
| 140 | signal = sig.GetArrivalTimeLoGain();
|
|---|
| 141 | else
|
|---|
| 142 | signal = sig.GetArrivalTimeHiGain();
|
|---|
| 143 |
|
|---|
| 144 | const Float_t time = signal - offset;
|
|---|
| 145 |
|
|---|
| 146 | (*fArrivalTime)[pixidx].SetArrivalTime(time);
|
|---|
| 147 |
|
|---|
| 148 | } /* for (UInt_t pixidx=0; pixidx<npix; pixidx++) */
|
|---|
| 149 |
|
|---|
| 150 | fArrivalTime->SetReadyToSave();
|
|---|
| 151 |
|
|---|
| 152 | return kTRUE;
|
|---|
| 153 | }
|
|---|