| 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): Sebastian Raducci 12/2003 <mailto:raducci@fisica.uniud.it>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2002-2004
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | //
|
|---|
| 27 | // MArrivalTimeCalc
|
|---|
| 28 | //
|
|---|
| 29 | // This is a task that calculates the arrival times of photons.
|
|---|
| 30 | // It returns the absolute maximum of the spline that interpolates
|
|---|
| 31 | // the FADC slices
|
|---|
| 32 | //
|
|---|
| 33 | // Input Containers:
|
|---|
| 34 | // MRawEvtData
|
|---|
| 35 | //
|
|---|
| 36 | // Output Containers:
|
|---|
| 37 | // MArrivalTime
|
|---|
| 38 | // MRawEvtData
|
|---|
| 39 | //
|
|---|
| 40 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 41 | #include "MArrivalTimeCalc.h"
|
|---|
| 42 |
|
|---|
| 43 | #include "MLog.h"
|
|---|
| 44 | #include "MLogManip.h"
|
|---|
| 45 |
|
|---|
| 46 | #include "MParList.h"
|
|---|
| 47 |
|
|---|
| 48 | #include "MGeomCam.h"
|
|---|
| 49 | #include "MArrivalTime.h"
|
|---|
| 50 | #include "MRawEvtData.h"
|
|---|
| 51 | #include "MRawEvtPixelIter.h"
|
|---|
| 52 |
|
|---|
| 53 | ClassImp(MArrivalTimeCalc);
|
|---|
| 54 |
|
|---|
| 55 | using namespace std;
|
|---|
| 56 |
|
|---|
| 57 | // --------------------------------------------------------------------------
|
|---|
| 58 | //
|
|---|
| 59 | // Default constructor.
|
|---|
| 60 | //
|
|---|
| 61 | MArrivalTimeCalc::MArrivalTimeCalc(const char *name, const char *title)
|
|---|
| 62 | {
|
|---|
| 63 | fName = name ? name : "MArrivalTimeCalc";
|
|---|
| 64 | fTitle = title ? title : "Calculate photons arrival time";
|
|---|
| 65 |
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | // --------------------------------------------------------------------------
|
|---|
| 69 | //
|
|---|
| 70 | // The PreProcess searches for the following input containers:
|
|---|
| 71 | // - MRawEvtData
|
|---|
| 72 | // - MArrivalTime
|
|---|
| 73 | //
|
|---|
| 74 | // The following output containers are also searched and created if
|
|---|
| 75 | // they were not found:
|
|---|
| 76 | // - MArrivalTime
|
|---|
| 77 | //
|
|---|
| 78 | Int_t MArrivalTimeCalc::PreProcess(MParList *pList)
|
|---|
| 79 | {
|
|---|
| 80 | fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
|
|---|
| 81 | if (!fRawEvt)
|
|---|
| 82 | {
|
|---|
| 83 | *fLog << err << "MRawEvtData not found... aborting." << endl;
|
|---|
| 84 | return kFALSE;
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | fArrTime = (MArrivalTime*)pList->FindCreateObj(AddSerialNumber("MArrivalTime"));
|
|---|
| 88 | if (!fArrTime)
|
|---|
| 89 | return kFALSE;
|
|---|
| 90 |
|
|---|
| 91 | return kTRUE;
|
|---|
| 92 | }
|
|---|
| 93 |
|
|---|
| 94 | // --------------------------------------------------------------------------
|
|---|
| 95 | //
|
|---|
| 96 | // The ReInit searches for the following input containers:
|
|---|
| 97 | // - MGeomCam
|
|---|
| 98 | //
|
|---|
| 99 | Bool_t MArrivalTimeCalc::ReInit(MParList *pList)
|
|---|
| 100 | {
|
|---|
| 101 | MGeomCam *cam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
|
|---|
| 102 | if (!cam)
|
|---|
| 103 | {
|
|---|
| 104 | *fLog << err << GetDescriptor() << ": No MGeomCam found... aborting." << endl;
|
|---|
| 105 | return kFALSE;
|
|---|
| 106 | }
|
|---|
| 107 |
|
|---|
| 108 | fArrTime->InitSize(cam->GetNumPixels());
|
|---|
| 109 |
|
|---|
| 110 | return kTRUE;
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 | // --------------------------------------------------------------------------
|
|---|
| 115 | //
|
|---|
| 116 | // Evaluation of the mean arrival times (spline interpolation)
|
|---|
| 117 | // per pixel and store them in the MArrivalTime container.
|
|---|
| 118 | //
|
|---|
| 119 | Int_t MArrivalTimeCalc::Process()
|
|---|
| 120 | {
|
|---|
| 121 | MRawEvtPixelIter pixel(fRawEvt);
|
|---|
| 122 |
|
|---|
| 123 | while (pixel.Next())
|
|---|
| 124 | {
|
|---|
| 125 | const UInt_t idx = pixel.GetPixelId();
|
|---|
| 126 |
|
|---|
| 127 | // If pixel is saturated we use LoGains
|
|---|
| 128 | if (pixel.GetMaxHiGainSample() == 0xff && pixel.HasLoGain())
|
|---|
| 129 | {
|
|---|
| 130 | const Byte_t *ptr = pixel.GetLoGainSamples();
|
|---|
| 131 | const Short_t nSlice = fRawEvt->GetNumLoGainSamples();
|
|---|
| 132 | fArrTime->Calc(ptr, nSlice, idx);
|
|---|
| 133 | }
|
|---|
| 134 | // Use HiGains
|
|---|
| 135 | else
|
|---|
| 136 | {
|
|---|
| 137 | const Byte_t *ptr = pixel.GetHiGainSamples();
|
|---|
| 138 | const Short_t nSlice = fRawEvt->GetNumHiGainSamples();
|
|---|
| 139 | fArrTime->Calc(ptr, nSlice, idx);
|
|---|
| 140 | }
|
|---|
| 141 | // If pixel is saturated and hasn't lo gains we do nothing, it's value remains -1
|
|---|
| 142 | }
|
|---|
| 143 |
|
|---|
| 144 | fArrTime->SetReadyToSave();
|
|---|
| 145 |
|
|---|
| 146 | return kTRUE;
|
|---|
| 147 | }
|
|---|