| 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 | ! Thomas Bretz, 01/2004
|
|---|
| 20 | !
|
|---|
| 21 | ! Copyright: MAGIC Software Development, 2000-2004
|
|---|
| 22 | !
|
|---|
| 23 | !
|
|---|
| 24 | \* ======================================================================== */
|
|---|
| 25 |
|
|---|
| 26 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 27 | //
|
|---|
| 28 | // MExtractFixedWindow
|
|---|
| 29 | //
|
|---|
| 30 | // Extracts the signal from a fixed window
|
|---|
| 31 | //
|
|---|
| 32 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 33 | #include "MExtractFixedWindow.h"
|
|---|
| 34 | #include "MExtractor.h"
|
|---|
| 35 |
|
|---|
| 36 | #include <fstream>
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 | ClassImp(MExtractFixedWindow);
|
|---|
| 40 |
|
|---|
| 41 | using namespace std;
|
|---|
| 42 |
|
|---|
| 43 | const Byte_t MExtractFixedWindow::fgHiGainFirst = 3;
|
|---|
| 44 | const Byte_t MExtractFixedWindow::fgHiGainLast = 14;
|
|---|
| 45 | const Byte_t MExtractFixedWindow::fgLoGainFirst = 3;
|
|---|
| 46 | const Byte_t MExtractFixedWindow::fgLoGainLast = 14;
|
|---|
| 47 | // --------------------------------------------------------------------------
|
|---|
| 48 | //
|
|---|
| 49 | // Default constructor.
|
|---|
| 50 | //
|
|---|
| 51 | MExtractFixedWindow::MExtractFixedWindow(const char *name, const char *title)
|
|---|
| 52 | {
|
|---|
| 53 | fName = name ? name : "MExtractFixedWindow";
|
|---|
| 54 | fTitle = title ? title : "Signal Extractor for a fixed FADC window";
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 | SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
|
|---|
| 58 |
|
|---|
| 59 | fNumHiGainSamples = (Float_t)(fHiGainLast-fHiGainFirst) + 1.;
|
|---|
| 60 | fNumLoGainSamples = (Float_t)(fLoGainLast-fLoGainFirst) + 1.;
|
|---|
| 61 |
|
|---|
| 62 | fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
|
|---|
| 63 | fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 | void MExtractFixedWindow::FindSignalHiGain(Byte_t *ptr, Int_t size, Int_t &sum, Byte_t &sat) const
|
|---|
| 68 | {
|
|---|
| 69 |
|
|---|
| 70 | Byte_t *end = ptr + fHiGainLast - fHiGainFirst + 1;
|
|---|
| 71 |
|
|---|
| 72 | sum = 0;
|
|---|
| 73 | sat = 0;
|
|---|
| 74 |
|
|---|
| 75 | while (ptr<end)
|
|---|
| 76 | {
|
|---|
| 77 | sum += *ptr;
|
|---|
| 78 |
|
|---|
| 79 | if (*ptr++ >= fSaturationLimit)
|
|---|
| 80 | sat++;
|
|---|
| 81 | }
|
|---|
| 82 | }
|
|---|
| 83 |
|
|---|
| 84 | void MExtractFixedWindow::FindSignalLoGain(Byte_t *ptr, Int_t size, Int_t &sum, Byte_t &sat) const
|
|---|
| 85 | {
|
|---|
| 86 |
|
|---|
| 87 | Byte_t *end = ptr + fLoGainLast - fLoGainFirst + 1;
|
|---|
| 88 |
|
|---|
| 89 | sum = 0;
|
|---|
| 90 | sat = 0;
|
|---|
| 91 |
|
|---|
| 92 | while (ptr<end)
|
|---|
| 93 | {
|
|---|
| 94 | sum += *ptr;
|
|---|
| 95 |
|
|---|
| 96 | if (*ptr++ >= fSaturationLimit)
|
|---|
| 97 | sat++;
|
|---|
| 98 | }
|
|---|
| 99 | }
|
|---|
| 100 |
|
|---|
| 101 | // --------------------------------------------------------------------------
|
|---|
| 102 | //
|
|---|
| 103 | // Implementation of SavePrimitive. Used to write the call to a constructor
|
|---|
| 104 | // to a macro. In the original root implementation it is used to write
|
|---|
| 105 | // gui elements to a macro-file.
|
|---|
| 106 | //
|
|---|
| 107 | void MExtractFixedWindow::StreamPrimitive(ofstream &out) const
|
|---|
| 108 | {
|
|---|
| 109 |
|
|---|
| 110 | out << " " << ClassName() << " " << GetUniqueName() << "(\"";
|
|---|
| 111 | out << "\"" << fName << "\", \"" << fTitle << "\");" << endl;
|
|---|
| 112 |
|
|---|
| 113 | if (fSaturationLimit!=fgSaturationLimit)
|
|---|
| 114 | {
|
|---|
| 115 | out << " " << GetUniqueName() << ".SetSaturationLimit(";
|
|---|
| 116 | out << (int)fSaturationLimit << ");" << endl;
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 | const Bool_t arg4 = fNumLoGainSamples+fLoGainFirst-1 != fgLoGainLast;
|
|---|
| 120 | const Bool_t arg3 = arg4 || fLoGainFirst != fgLoGainFirst;
|
|---|
| 121 | const Bool_t arg2 = arg3 || fNumHiGainSamples+fHiGainFirst-1 != fgHiGainLast;
|
|---|
| 122 | const Bool_t arg1 = arg2 || fHiGainFirst != fgHiGainFirst;
|
|---|
| 123 |
|
|---|
| 124 | if (!arg1)
|
|---|
| 125 | return;
|
|---|
| 126 |
|
|---|
| 127 | out << " " << GetUniqueName() << ".SetRange(";
|
|---|
| 128 | out << (int)fLoGainFirst;
|
|---|
| 129 | if (arg2)
|
|---|
| 130 | {
|
|---|
| 131 | out << ", " << (int)(fNumHiGainSamples+fHiGainFirst-1);
|
|---|
| 132 | if (arg3)
|
|---|
| 133 | {
|
|---|
| 134 | out << ", " << (int)fLoGainFirst;
|
|---|
| 135 | if (arg4)
|
|---|
| 136 | out << ", " << (int)(fNumLoGainSamples+fLoGainFirst-1);
|
|---|
| 137 | }
|
|---|
| 138 | }
|
|---|
| 139 | out << ");" << endl;
|
|---|
| 140 | }
|
|---|