source: branches/MarsISDCBranchBasedOn17887/mtemp/mifae/library/MTopology.cc@ 18665

Last change on this file since 18665 was 5658, checked in by rico, 20 years ago
*** empty log message ***
File size: 3.0 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): Josep Flix 09/2004 <mailto:jflix@ifae.es>
19!
20! Copyright: MAGIC Software Development, 2004
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MTopology
28//
29// Storage Container for topology parameters:
30//
31// fDistance = SUM_(i,j) D_ij , where i,j<UsedPixels and d_ij are distances
32// between pixels. This characterizes topology.
33//
34// fUsed = Used Pixels after image cleaning.
35//
36/////////////////////////////////////////////////////////////////////////////
37
38#include "MTopology.h"
39
40#include <iostream>
41
42#include "MGeomPix.h"
43#include "MGeomCam.h"
44#include "MCerPhotPix.h"
45#include "MCerPhotEvt.h"
46
47#include "MLog.h"
48#include "MLogManip.h"
49
50using namespace std;
51ClassImp(MTopology);
52
53
54// --------------------------------------------------------------------------
55//
56// Default constructor.
57//
58
59MTopology::MTopology(const char *name, const char *title)
60{
61 fName = name ? name : "MTopology";
62 fTitle = title ? title : "Parameters related to Topology of images after image cleaning";
63
64 Reset();
65}
66
67void MTopology::Reset()
68{
69 fDistance = -1;
70 fUsed = -1;
71}
72
73void MTopology::Print(Option_t *opt) const
74{
75 *fLog << all << GetDescriptor() << ":" << endl;
76 *fLog << "Topology Distance [mm] = " << fDistance << ": ";
77 *fLog << "Used Pixels = " << fUsed << ": " << endl;
78
79}
80
81Int_t MTopology::Calc(const MGeomCam &geom, const MCerPhotEvt &evt)
82{
83 const Int_t Pixels = evt.GetNumPixels();
84
85 Double_t X[Pixels];
86 Double_t Y[Pixels];
87 Int_t NPixels[Pixels];
88
89 if (Pixels < 3)
90 {
91 Reset();
92 return 1;
93 };
94
95 MCerPhotPix *pix = 0;
96
97 TIter Next(evt);
98
99 fN_Pixels = 0;
100
101 Double_t fDist = 0.;
102
103 while ((pix=(MCerPhotPix*)Next()))
104 {
105 const MGeomPix &gpix = geom[pix->GetPixId()];
106
107 NPixels[fN_Pixels] = pix->GetPixId();
108 X[fN_Pixels] = gpix.GetX();
109 Y[fN_Pixels] = gpix.GetY();
110
111 fN_Pixels++;
112 };
113
114 for (int i = 0; i < fN_Pixels ; i++){
115 for (int j = 0; j < fN_Pixels ; j++){
116 fDist += sqrt(pow(X[j]-X[i],2) + pow(Y[j]-Y[i],2));
117 };
118 };
119
120 fDistance = (Int_t)(fDist+.5);
121
122 SetDistance(fDistance);
123 SetUsedPixels(fN_Pixels);
124
125 SetReadyToSave();
126
127 return 0;
128
129}
Note: See TracBrowser for help on using the repository browser.