source: trunk/Mars/mhft/MGeomCamMagicEnhance.cc@ 19503

Last change on this file since 19503 was 7208, checked in by tbretz, 19 years ago
*** empty log message ***
File size: 5.4 KB
Line 
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): Christoph Kolodziejski, 12/2004 <mailto:>
19! Author(s): Thomas Bretz, 12/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
20!
21! Copyright: MAGIC Software Development, 2004-2005
22!
23!
24\* ======================================================================== */
25
26//////////////////////////////////////////////////////////////////////////////
27//
28// MGeomCamMagicEnhance
29//
30// This task takes MSignalCam assuming that it is related to the Magic
31// camera geometry. By deviding and interpolation it resamples MSignalCam
32// such, that afterwards it is related to a geometry MGeomCamMagicXT
33//
34//////////////////////////////////////////////////////////////////////////////
35#include "MGeomCamMagicEnhance.h"
36
37#include "MLog.h"
38#include "MLogManip.h"
39
40#include "MParList.h"
41
42#include "MSignalCam.h"
43#include "MSignalPix.h"
44
45#include "MArrayD.h"
46
47ClassImp(MGeomCamMagicEnhance);
48
49using namespace std;
50
51const char *MGeomCamMagicEnhance::fgNameSignalCamIn = "MSignalCam";
52const char *MGeomCamMagicEnhance::fgNameSignalCamOut = "MSignalCam";
53
54// ---------------------------------------------------------------------------
55//
56// Default Constructor - empty
57//
58MGeomCamMagicEnhance::MGeomCamMagicEnhance(const char *name, const char *title)
59 : fNameSignalCamIn(fgNameSignalCamIn), fNameSignalCamOut(fgNameSignalCamOut),
60 fEvtIn(0), fEvtOut(0)
61{
62 fName = name ? name : "MGeomCamMagicEnhance";
63 fTitle = title ? title : "Task to convert MSignalCam from MGeomCamMagic to MGeomCamMagicXT";
64}
65
66// ---------------------------------------------------------------------------
67//
68// Search for MSignalCam input and output container.
69//
70Int_t MGeomCamMagicEnhance::PreProcess(MParList *plist)
71{
72 fEvtIn = (MSignalCam*)plist->FindObject(fNameSignalCamIn, "MSignalCam");
73 if (!fEvtIn)
74 {
75 *fLog << err << fNameSignalCamIn << " [MSignalCam] not found... abort." << endl;
76 return kFALSE;
77 }
78
79 fEvtOut = (MSignalCam*)plist->FindCreateObj("MSignalCam", fNameSignalCamOut);
80 if (!fEvtOut)
81 return kFALSE;
82
83 return kTRUE;
84}
85
86// ---------------------------------------------------------------------------
87//
88// Convert MCerPhotEvent into a new MArrayD depending on the new geometry
89//
90MArrayD MGeomCamMagicEnhance::Convert() const
91{
92 Double_t dEvt[577];
93 for (int i = 0; i<577; ++i)
94 dEvt[i] = (*fEvtIn)[i].GetNumPhotons();
95
96 MArrayD dEvent(1141);
97 memcpy(dEvent.GetArray(), dEvt, 577*sizeof(Double_t));
98
99 int k = 397; // alter Pixelindex
100 int m = 397; // neuer Index nach einem Durchlauf
101
102 double* pEvent = dEvent.GetArray() + 397;
103
104 for( int i = 0 ; i < 4 ; ++i )
105 {
106 for( int j = 0; j < 6; ++j )
107 for( int h = 0; h < 6 + i; ++h )
108 {
109 if( !j && !h )
110 *(pEvent++) = 0.25*0.5*( dEvt[ m ] + dEvt[ m + (6 + i)*6 - 1 ] );
111
112 *(pEvent++) = 0.25*dEvt[ k ];
113
114 if(!(j == 5 && h == 5 + i)){
115 if( i && h != 5 + i){
116 *(pEvent++) = 0.25*1/3.*( dEvt[ k ] + dEvt[ k + 1 ] + dEvt[ k - (5 + i)*6 - j ] );
117 }else
118 *(pEvent++) = 0.25*0.5*( dEvt[ k ] + dEvt[ k + 1 ] );
119 }
120 k++;
121 }
122
123 k = m;
124
125 for( int j = 0; j < 6; ++j )
126 for( int h = 0; h < 6 + i; ++h )
127 {
128 if( !h && !j ){
129 if( i != 3)
130 *(pEvent++) = 0.25*0.25*( dEvt[ m ] + dEvt[ m + (6 + i)*6 - 1 ] + dEvt[ m + (6 + i)*6 ] + dEvt[ m + 12*i + 77 /*m + (6 + i)*6 + (6 + i + 1)*6 - 1*/ ] );
131 else
132 *(pEvent++) = 0.25*0.5*( dEvt[ m ] + dEvt[ m + (6 + i)*6 - 1 ] );
133 }
134
135 if( !h && j ){
136 if( i != 3 ){
137 *(pEvent++) = 0.25*0.25*( dEvt[ k - 1 ] + dEvt[ k ] + dEvt[ k + (6 + i)*6 + j - 1 ] + dEvt[ k + (6 + i)*6 + j ] );
138 }else
139 *(pEvent++) = 0.25*0.5*( dEvt[ k - 1 ] + dEvt[ k ] );
140 }
141
142 *(pEvent++) = 0.25*dEvt[ k ];
143 *(pEvent++) = 0.25*dEvt[ k ];
144
145 k++;
146
147 }
148
149 m += (6 + i)*6;
150 }
151
152 return dEvent;
153}
154
155// ---------------------------------------------------------------------------
156//
157// Call Convert and copy result into output MSignalCam
158//
159Int_t MGeomCamMagicEnhance::Process()
160{
161 // Convert old stylish magic camera into new enhanced version
162 const MArrayD res(Convert());
163
164 // Copy result into output MSignalCam
165 fEvtOut->InitSize(res.GetSize());
166
167 for (UInt_t i=0; i<res.GetSize(); i++)
168 fEvtOut->AddPixel(i, res[i], 0);
169
170 //fEvtOut->FixSize();
171 fEvtOut->SetReadyToSave();
172
173 return kTRUE;
174}
175
Note: See TracBrowser for help on using the repository browser.