| 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 09/2003 <mailto:markus@ifae.es>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2001
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | // //
|
|---|
| 27 | // MExtractSignal //
|
|---|
| 28 | // //
|
|---|
| 29 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 30 |
|
|---|
| 31 | #include "MExtractSignal.h"
|
|---|
| 32 |
|
|---|
| 33 | #include "MExtractedSignalCam.h"
|
|---|
| 34 | #include "MExtractedSignalPix.h"
|
|---|
| 35 |
|
|---|
| 36 | #include "MPedestalCam.h"
|
|---|
| 37 | #include "MPedestalPix.h"
|
|---|
| 38 |
|
|---|
| 39 | #include "MLog.h"
|
|---|
| 40 | #include "MLogManip.h"
|
|---|
| 41 |
|
|---|
| 42 | #include "MParList.h"
|
|---|
| 43 | #include "MH.h"
|
|---|
| 44 |
|
|---|
| 45 | #include "MRawRunHeader.h"
|
|---|
| 46 | #include "MRawEvtData.h" // MRawEvtData::GetNumPixels
|
|---|
| 47 | #include "MRawEvtPixelIter.h"
|
|---|
| 48 |
|
|---|
| 49 | #include "TMath.h"
|
|---|
| 50 |
|
|---|
| 51 | ClassImp(MExtractSignal);
|
|---|
| 52 |
|
|---|
| 53 | using namespace std;
|
|---|
| 54 | // --------------------------------------------------------------------------
|
|---|
| 55 | //
|
|---|
| 56 | // Default constructor.
|
|---|
| 57 | //
|
|---|
| 58 | MExtractSignal::MExtractSignal(const char *name, const char *title)
|
|---|
| 59 | : fSaturationLimit(255),
|
|---|
| 60 | fConversionHiLo(10.)
|
|---|
| 61 | {
|
|---|
| 62 |
|
|---|
| 63 | fName = name ? name : "MExtractSignal";
|
|---|
| 64 | fTitle = title ? title : "Task to extract the signal from the FADC slices";
|
|---|
| 65 |
|
|---|
| 66 | AddToBranchList("MRawEvtData.*");
|
|---|
| 67 | }
|
|---|
| 68 |
|
|---|
| 69 | // --------------------------------------------------------------------------
|
|---|
| 70 | //
|
|---|
| 71 | // The PreProcess searches for the following input containers:
|
|---|
| 72 | // - MRawEvtData
|
|---|
| 73 | // - MPedestalCam
|
|---|
| 74 | //
|
|---|
| 75 | // The following output containers are also searched and created if
|
|---|
| 76 | // they were not found:
|
|---|
| 77 | //
|
|---|
| 78 | // - MExtractedSignalCam
|
|---|
| 79 | //
|
|---|
| 80 | Int_t MExtractSignal::PreProcess(MParList *pList)
|
|---|
| 81 | {
|
|---|
| 82 |
|
|---|
| 83 | fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
|
|---|
| 84 | if (!fRawEvt)
|
|---|
| 85 | {
|
|---|
| 86 | *fLog << dbginf << "MRawEvtData not found... aborting." << endl;
|
|---|
| 87 | return kFALSE;
|
|---|
| 88 | }
|
|---|
| 89 |
|
|---|
| 90 | const MRawRunHeader *runheader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
|
|---|
| 91 | if (!runheader)
|
|---|
| 92 | *fLog << warn << dbginf << "Warning - cannot check file type, MRawRunHeader not found." << endl;
|
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 | fSignals = (MExtractedSignalCam*)pList->FindCreateObj("MExtractedSignalCam");
|
|---|
| 96 | if (!fSignals)
|
|---|
| 97 | return kFALSE;
|
|---|
| 98 |
|
|---|
| 99 | fPedestals = (MPedestalCam*)pList->FindObject("MPedestalCam");
|
|---|
| 100 | if (!fPedestals)
|
|---|
| 101 | {
|
|---|
| 102 | *fLog << err << dbginf << "Cannot find MPedestalCam ... aborting" << endl;
|
|---|
| 103 | return kFALSE;
|
|---|
| 104 | }
|
|---|
| 105 |
|
|---|
| 106 | return kTRUE;
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 | // --------------------------------------------------------------------------
|
|---|
| 111 | //
|
|---|
| 112 | // The ReInit searches for the following input containers:
|
|---|
| 113 | // - MRawRunHeader
|
|---|
| 114 | //
|
|---|
| 115 | Bool_t MExtractSignal::ReInit(MParList *pList )
|
|---|
| 116 | {
|
|---|
| 117 |
|
|---|
| 118 | fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
|
|---|
| 119 | if (!fRunHeader)
|
|---|
| 120 | {
|
|---|
| 121 | *fLog << dbginf << "MRawRunHeader not found... aborting." << endl;
|
|---|
| 122 | return kFALSE;
|
|---|
| 123 | }
|
|---|
| 124 |
|
|---|
| 125 | fNumHiGainSamples = fRunHeader->GetNumSamplesHiGain();
|
|---|
| 126 | fNumLoGainSamples = fRunHeader->GetNumSamplesLoGain();
|
|---|
| 127 | fSqrtHiGainSamples = TMath::Sqrt((float)fNumHiGainSamples);
|
|---|
| 128 | fSqrtLoGainSamples = TMath::Sqrt((float)fNumLoGainSamples);
|
|---|
| 129 |
|
|---|
| 130 | //
|
|---|
| 131 | // FIXME: The next statement simply does not work:
|
|---|
| 132 | // fRawEvt->GetNumPixels() returns always 0
|
|---|
| 133 | //
|
|---|
| 134 |
|
|---|
| 135 | fSignals->InitSize(577);
|
|---|
| 136 | // fExtractedSignals->InitSize(fRawEvt->GetNumPixels());
|
|---|
| 137 |
|
|---|
| 138 | return kTRUE;
|
|---|
| 139 | }
|
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 | // --------------------------------------------------------------------------
|
|---|
| 143 | //
|
|---|
| 144 | // Calculate the integral of the FADC time slices and store them as a new
|
|---|
| 145 | // pixel in the MExtractedSignalCam container.
|
|---|
| 146 | //
|
|---|
| 147 | Int_t MExtractSignal::Process()
|
|---|
| 148 | {
|
|---|
| 149 |
|
|---|
| 150 | MRawEvtPixelIter pixel(fRawEvt);
|
|---|
| 151 | fSignals->Clear();
|
|---|
| 152 |
|
|---|
| 153 | while (pixel.Next())
|
|---|
| 154 | {
|
|---|
| 155 |
|
|---|
| 156 | UShort_t satHi = 0;
|
|---|
| 157 | UShort_t satLo = 0;
|
|---|
| 158 | Float_t sum = 0.;
|
|---|
| 159 | Float_t sumerr = 0.;
|
|---|
| 160 |
|
|---|
| 161 | const Int_t pixid = pixel.GetPixelId();
|
|---|
| 162 | const MPedestalPix &ped = (*fPedestals)[pixid];
|
|---|
| 163 | MExtractedSignalPix &pix = (*fSignals)[pixid];
|
|---|
| 164 |
|
|---|
| 165 | const Float_t pedes = ped.GetPedestal();
|
|---|
| 166 | const Float_t pedrms = ped.GetPedestalRms();
|
|---|
| 167 |
|
|---|
| 168 | //
|
|---|
| 169 | // FIXME: This is preliminary, we will change to pedestals per slice!!!
|
|---|
| 170 | // Assume pedestals per time slice ==> multiply with number of slices
|
|---|
| 171 | //
|
|---|
| 172 |
|
|---|
| 173 | UInt_t max = pixel.GetMaxHiGainSample();
|
|---|
| 174 |
|
|---|
| 175 | if (max <= fSaturationLimit) // take Hi Gain, no saturation
|
|---|
| 176 | {
|
|---|
| 177 | sum = (float)pixel.GetSumHiGainSamples() - pedes*fNumHiGainSamples;
|
|---|
| 178 | sumerr = pedrms*fSqrtHiGainSamples;
|
|---|
| 179 | }
|
|---|
| 180 | else // Lo Gain
|
|---|
| 181 | {
|
|---|
| 182 |
|
|---|
| 183 | satHi++;
|
|---|
| 184 |
|
|---|
| 185 | sum = (float)pixel.GetSumLoGainSamples() - pedes*fNumLoGainSamples ;
|
|---|
| 186 | sum *= fConversionHiLo;
|
|---|
| 187 |
|
|---|
| 188 | sumerr = pedrms*fSqrtLoGainSamples;
|
|---|
| 189 |
|
|---|
| 190 | max = pixel.GetMaxLoGainSample();
|
|---|
| 191 |
|
|---|
| 192 | if (max > fSaturationLimit)
|
|---|
| 193 | {
|
|---|
| 194 | *fLog << err << dbginf
|
|---|
| 195 | << "Warning: Saturation of Lo Gain reached in pixel: "
|
|---|
| 196 | << pixid << " " << " sum = " << sum << endl;
|
|---|
| 197 | satLo++;
|
|---|
| 198 | }
|
|---|
| 199 |
|
|---|
| 200 | }
|
|---|
| 201 |
|
|---|
| 202 | pix.SetGainSaturation((satHi),(satHi),(satLo));
|
|---|
| 203 | pix.SetExtractedSignal(sum,sumerr);
|
|---|
| 204 |
|
|---|
| 205 | } /* while (pixel.Next()) */
|
|---|
| 206 |
|
|---|
| 207 | fSignals->SetReadyToSave();
|
|---|
| 208 |
|
|---|
| 209 | return kTRUE;
|
|---|
| 210 | }
|
|---|
| 211 |
|
|---|
| 212 | Int_t MExtractSignal::PostProcess()
|
|---|
| 213 | {
|
|---|
| 214 |
|
|---|
| 215 | return kTRUE;
|
|---|
| 216 |
|
|---|
| 217 | }
|
|---|