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-2004
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MArrivalTime
|
---|
28 | //
|
---|
29 | // Times are calculated using the TSpline5 Root Class
|
---|
30 | //
|
---|
31 | /////////////////////////////////////////////////////////////////////////////
|
---|
32 | #include "MArrivalTime.h"
|
---|
33 |
|
---|
34 | #include "MGeomCam.h"
|
---|
35 | #include "MGeomPix.h"
|
---|
36 |
|
---|
37 | #include "MLog.h"
|
---|
38 | #include "MLogManip.h"
|
---|
39 |
|
---|
40 | #include "MRawEvtPixelIter.h"
|
---|
41 | #include "MRawEvtData.h"
|
---|
42 |
|
---|
43 | ClassImp(MArrivalTime);
|
---|
44 |
|
---|
45 | using namespace std;
|
---|
46 |
|
---|
47 | #warning Commented out all usage of fPixelCehcked - THIS WILL CRASH YOUR PROGRAM!
|
---|
48 |
|
---|
49 | // --------------------------------------------------------------------------
|
---|
50 | //
|
---|
51 | // Creates an object containing the arrival time for each pixel in the event
|
---|
52 | //
|
---|
53 | MArrivalTime::MArrivalTime(const char *name, const char *title)
|
---|
54 | {
|
---|
55 | fName = name ? name : "MArrivalTime";
|
---|
56 | fTitle = title ? title : "Photons arrival times Information";
|
---|
57 | }
|
---|
58 |
|
---|
59 | // -------------------------------------------------------------------------
|
---|
60 | //
|
---|
61 | // Sets every pixel arrival time to -1
|
---|
62 | //
|
---|
63 | void MArrivalTime::Reset()
|
---|
64 | {
|
---|
65 | //
|
---|
66 | // Do not use 'TArray::Reset()' or memset. It sets all single
|
---|
67 | // bytes to -1 (in other words, it fills the array with 0xff)
|
---|
68 | for (int i=0; i<fData.GetSize(); i++)
|
---|
69 | fData[i] = -1;
|
---|
70 | }
|
---|
71 |
|
---|
72 | void MArrivalTime::InitSize(Int_t i)
|
---|
73 | {
|
---|
74 | fData.Set(i);
|
---|
75 | }
|
---|
76 |
|
---|
77 | // -------------------------------------------------------------------------
|
---|
78 | //
|
---|
79 | // Set the arrival time in one pixel
|
---|
80 | //
|
---|
81 | void MArrivalTime::SetTime(const Int_t i, const Float_t t)
|
---|
82 | {
|
---|
83 | fData[i] = t;
|
---|
84 | }
|
---|
85 |
|
---|
86 | // -------------------------------------------------------------------------
|
---|
87 | //
|
---|
88 | // Finds the clusters with similar Arrival Time
|
---|
89 | //
|
---|
90 | // PRELIMINARY!! For now the Arrival Time is not the one calculated with
|
---|
91 | // the splines, but it's the Max Slice Idx
|
---|
92 | //
|
---|
93 | // TEST!! This method is used only for test. Do not use it until
|
---|
94 | // it becomes stable
|
---|
95 | //
|
---|
96 | void MArrivalTime::EvalClusters(const MRawEvtData &evt, const MGeomCam &geom)
|
---|
97 | {
|
---|
98 | const Int_t n = geom.GetNumPixels();
|
---|
99 |
|
---|
100 | fData2.Set(n);
|
---|
101 | fData2.Reset(-1.0);
|
---|
102 | fData3.Set(n);
|
---|
103 | fData3.Reset(-1.0);
|
---|
104 | fData4.Set(n);
|
---|
105 | fData4.Reset(-1.0);
|
---|
106 | fData5.Set(n);
|
---|
107 | fData5.Reset(-1.0);
|
---|
108 |
|
---|
109 | MRawEvtPixelIter pixel((MRawEvtData*)&evt);
|
---|
110 |
|
---|
111 | // Array that says if a pixel has been already checked or not
|
---|
112 |
|
---|
113 | // for (Int_t i = 0; i < n; i++)
|
---|
114 | // fPixelChecked[i] = kFALSE;
|
---|
115 |
|
---|
116 | // This fakeData array will be subsituted with the fData Array.
|
---|
117 | fakeData.Set(n);
|
---|
118 | fakeData.Reset();
|
---|
119 |
|
---|
120 | while ( pixel.Next() )
|
---|
121 | {
|
---|
122 | fakeData[pixel.GetPixelId()]=pixel.GetIdxMaxHiLoGainSample();
|
---|
123 | }
|
---|
124 | // End of fakeData preparation
|
---|
125 | *fLog << warn << "fin qui bene" << endl;
|
---|
126 | // Max dimension of cluster
|
---|
127 | Short_t dimCluster;
|
---|
128 |
|
---|
129 | while ( pixel.Next() )
|
---|
130 | {
|
---|
131 | /*
|
---|
132 | if (!fPixelChecked[pixel.GetPixelId()])
|
---|
133 | {
|
---|
134 | dimCluster = 0;
|
---|
135 | fCluster.Set(n);
|
---|
136 | fCluster.Reset(-1);
|
---|
137 | fCluster[dimCluster]=pixel.GetPixelId();
|
---|
138 | dimCluster++;
|
---|
139 |
|
---|
140 | CheckNeighbours(evt,geom,
|
---|
141 | pixel.GetPixelId(), &dimCluster);
|
---|
142 |
|
---|
143 | if (dimCluster > 4)
|
---|
144 | {
|
---|
145 | for (Int_t i = 0; i < dimCluster; i++)
|
---|
146 | fData5[fCluster[i]]=fakeData[fCluster[i]];
|
---|
147 | }
|
---|
148 | if (dimCluster > 3)
|
---|
149 | {
|
---|
150 | for (Int_t i = 0; i < dimCluster; i++)
|
---|
151 | fData4[fCluster[i]]=fakeData[fCluster[i]];
|
---|
152 | }
|
---|
153 | if (dimCluster > 2)
|
---|
154 | {
|
---|
155 | for (Int_t i = 0; i < dimCluster; i++)
|
---|
156 | fData3[fCluster[i]]=fakeData[fCluster[i]];
|
---|
157 | }
|
---|
158 | if (dimCluster > 1)
|
---|
159 | {
|
---|
160 | for (Int_t i = 0; i < dimCluster; i++)
|
---|
161 | fData2[fCluster[i]]=fakeData[fCluster[i]];
|
---|
162 | }
|
---|
163 | } */
|
---|
164 | }
|
---|
165 |
|
---|
166 | }
|
---|
167 |
|
---|
168 | // --------------------------------------------------------------------------
|
---|
169 | //
|
---|
170 | // Function to check the nearest neighbour pixels arrivaltime
|
---|
171 | //
|
---|
172 | void MArrivalTime::CheckNeighbours(const MRawEvtData &evt, const MGeomCam &geom,
|
---|
173 | Short_t idx, Short_t *dimCluster)
|
---|
174 | {
|
---|
175 | Byte_t numNeighbors=geom[idx].GetNumNeighbors();
|
---|
176 | //fPixelChecked[idx] = kTRUE;
|
---|
177 |
|
---|
178 | for (Byte_t i=0x00; i < numNeighbors; i++)
|
---|
179 | {
|
---|
180 |
|
---|
181 | /*
|
---|
182 | if (!fPixelChecked[geom[idx].GetNeighbor(i)] &&
|
---|
183 | fakeData[idx] == fakeData[geom[idx].GetNeighbor(i)])
|
---|
184 | {
|
---|
185 | fCluster[*dimCluster]=geom[idx].GetNeighbor(i);
|
---|
186 | *dimCluster++;
|
---|
187 | CheckNeighbours(evt, geom,
|
---|
188 | geom[idx].GetNeighbor(i), dimCluster);
|
---|
189 | }
|
---|
190 | */
|
---|
191 | }
|
---|
192 | }
|
---|
193 | // --------------------------------------------------------------------------
|
---|
194 | //
|
---|
195 | // Returns the arrival time value
|
---|
196 | //
|
---|
197 | Bool_t MArrivalTime::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
---|
198 | {
|
---|
199 | if (idx<0 || idx>=fData.GetSize())
|
---|
200 | return kFALSE;
|
---|
201 |
|
---|
202 | switch (type)
|
---|
203 | {
|
---|
204 | case 0:
|
---|
205 | case 1:
|
---|
206 | val = fData[idx];
|
---|
207 | break;
|
---|
208 | case 2:
|
---|
209 | val = fData2[idx];
|
---|
210 | break;
|
---|
211 | case 3:
|
---|
212 | val = fData3[idx];
|
---|
213 | break;
|
---|
214 | case 4:
|
---|
215 | val = fData4[idx];
|
---|
216 | break;
|
---|
217 | case 5:
|
---|
218 | val = fData5[idx];
|
---|
219 | break;
|
---|
220 | }
|
---|
221 |
|
---|
222 | return kTRUE;
|
---|
223 | }
|
---|
224 |
|
---|
225 | void MArrivalTime::DrawPixelContent(Int_t num) const
|
---|
226 | {
|
---|
227 | *fLog << warn << "MArrivalTime::DrawPixelContent - not available." << endl;
|
---|
228 | }
|
---|