| 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, 2000-2003
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | //
|
|---|
| 27 | // MArrivalTime
|
|---|
| 28 | //
|
|---|
| 29 | // P R E L I M I N A R Y
|
|---|
| 30 | // Do not use this container. It has yet to be defined.
|
|---|
| 31 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 32 | #include "MArrivalTime.h"
|
|---|
| 33 |
|
|---|
| 34 | #include "MGeomCam.h"
|
|---|
| 35 |
|
|---|
| 36 | #include "MLog.h"
|
|---|
| 37 | #include "MLogManip.h"
|
|---|
| 38 |
|
|---|
| 39 | #include "MRawEvtPixelIter.h"
|
|---|
| 40 | #include "MRawEvtData.h"
|
|---|
| 41 |
|
|---|
| 42 | ClassImp(MArrivalTime);
|
|---|
| 43 |
|
|---|
| 44 | using namespace std;
|
|---|
| 45 |
|
|---|
| 46 | // --------------------------------------------------------------------------
|
|---|
| 47 | //
|
|---|
| 48 | // Creates an object containing the arrival time for each pixel in the event
|
|---|
| 49 | //
|
|---|
| 50 | MArrivalTime::MArrivalTime(const char *name, const char *title)
|
|---|
| 51 | {
|
|---|
| 52 | fName = name ? name : "MArrivalTime";
|
|---|
| 53 | fTitle = title ? title : "Photons arrival times Information";
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | //
|
|---|
| 57 | // Calculates the arrival time for each pixel (for now, simply by finding the peak)
|
|---|
| 58 | //
|
|---|
| 59 |
|
|---|
| 60 | void MArrivalTime::Calc(const MRawEvtData &evt, const MGeomCam &geom)
|
|---|
| 61 | {
|
|---|
| 62 | const Int_t n = geom.GetNumPixels();
|
|---|
| 63 |
|
|---|
| 64 | fData.Set(n);
|
|---|
| 65 | fData.Reset();
|
|---|
| 66 |
|
|---|
| 67 | MRawEvtPixelIter pixel((MRawEvtData*)&evt);
|
|---|
| 68 |
|
|---|
| 69 | Int_t saturatedpixels = 0;
|
|---|
| 70 |
|
|---|
| 71 | while ( pixel.Next() )
|
|---|
| 72 | {
|
|---|
| 73 | const UInt_t idx = pixel.GetPixelId();
|
|---|
| 74 |
|
|---|
| 75 | Byte_t *ptr = pixel.GetHiGainSamples();
|
|---|
| 76 |
|
|---|
| 77 | Int_t n = evt.GetNumHiGainSamples();
|
|---|
| 78 |
|
|---|
| 79 | Int_t i;
|
|---|
| 80 |
|
|---|
| 81 | Double_t arrtime = 0;
|
|---|
| 82 |
|
|---|
| 83 | Double_t maxsign = 0;
|
|---|
| 84 |
|
|---|
| 85 | for (i=0; i<n; i++)
|
|---|
| 86 | {
|
|---|
| 87 | if (ptr[i]==0xff)
|
|---|
| 88 | break;
|
|---|
| 89 | if (ptr[i]>maxsign)
|
|---|
| 90 | {
|
|---|
| 91 | maxsign = ptr[i];
|
|---|
| 92 | arrtime = i+1;
|
|---|
| 93 | }
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 | Bool_t saturatedlg = kFALSE;
|
|---|
| 97 |
|
|---|
| 98 | if (i!=n)
|
|---|
| 99 | {
|
|---|
| 100 | arrtime = 0;
|
|---|
| 101 | maxsign = 0;
|
|---|
| 102 |
|
|---|
| 103 | ptr = pixel.GetLoGainSamples();
|
|---|
| 104 | if (ptr==NULL)
|
|---|
| 105 | {
|
|---|
| 106 | *fLog << warn << "WARNING - Pixel #" << idx
|
|---|
| 107 | << " saturated but has no low gains... skipping!" << endl;
|
|---|
| 108 | return;
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 111 | for (i=0; i<n; i++)
|
|---|
| 112 | {
|
|---|
| 113 | if (ptr[i]==0xff)
|
|---|
| 114 | saturatedlg = kTRUE;
|
|---|
| 115 |
|
|---|
| 116 | if (ptr[i]>maxsign)
|
|---|
| 117 | {
|
|---|
| 118 | maxsign = ptr[i];
|
|---|
| 119 | arrtime = i+1;
|
|---|
| 120 | }
|
|---|
| 121 | }
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | fData[idx]=arrtime;
|
|---|
| 125 |
|
|---|
| 126 | if (saturatedlg)
|
|---|
| 127 | saturatedpixels++;
|
|---|
| 128 | }
|
|---|
| 129 |
|
|---|
| 130 | if (saturatedpixels>0)
|
|---|
| 131 | *fLog << warn << "WARNING: " << saturatedpixels
|
|---|
| 132 | << " pixel(s) had saturating low gains..." << endl;
|
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 | }
|
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 | // --------------------------------------------------------------------------
|
|---|
| 139 | //
|
|---|
| 140 | // Returns the arrival time value (for now, it's the FADC slice number).
|
|---|
| 141 | //
|
|---|
| 142 |
|
|---|
| 143 | Bool_t MArrivalTime::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
|---|
| 144 | {
|
|---|
| 145 | if (idx<0 || idx>=fData.GetSize())
|
|---|
| 146 | return kFALSE;
|
|---|
| 147 |
|
|---|
| 148 | val = fData[idx];
|
|---|
| 149 | return kTRUE;
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 | void MArrivalTime::DrawPixelContent(Int_t num) const
|
|---|
| 153 | {
|
|---|
| 154 | *fLog << warn << "MArrivalTime::DrawPixelContent - not available." << endl;
|
|---|
| 155 | }
|
|---|