source: trunk/Mars/mimage/MConcentration.cc@ 19344

Last change on this file since 19344 was 8957, checked in by tbretz, 17 years ago
*** empty log message ***
File size: 4.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): Thomas Bretz 12/2000 <mailto:tbretz@atsro.uni-wuerzburg.de>
19! Author(s): Rudolf Bock 10/2001 <mailto:Rudolf.Bock@cern.ch>
20! Author(s): Wolfgang Wittek 6/2002 <mailto:wittek@mppmu.mpg.de>
21! Author(s): Oscar Blanch 3/2004 <mailto:blanch@ifae.es>
22!
23! Copyright: MAGIC Software Development, 2000-2004
24!
25!
26\* ======================================================================== */
27
28/////////////////////////////////////////////////////////////////////////////
29//
30// MConcentration
31//
32// Storage Container for Concentration parameters
33//
34//
35// Version 1:
36// ----------
37// fConc[i] [ratio] Number of photons in the i+1 more populated pixels
38// over the event size (till i=7).
39//
40/////////////////////////////////////////////////////////////////////////////
41#include "MConcentration.h"
42
43
44#include <TArrayF.h>
45#include <TArrayI.h>
46
47#include "MHillas.h"
48
49#include "MGeomPix.h"
50#include "MGeomCam.h"
51
52#include "MSignalPix.h"
53#include "MSignalCam.h"
54
55#include "MLog.h"
56#include "MLogManip.h"
57
58ClassImp(MConcentration);
59
60using namespace std;
61
62// --------------------------------------------------------------------------
63//
64// Default constructor.
65//
66MConcentration::MConcentration(const char *name, const char *title)
67{
68 fName = name ? name : "MConcentration";
69 fTitle = title ? title : "Storage container for concentrations";
70
71 Reset();
72}
73
74// --------------------------------------------------------------------------
75//
76// Initializes the values with defaults. For the default values see the
77// source code.
78//
79void MConcentration::Reset()
80{
81 for (int i=0; i<9; i++)
82 fConc[i] = -1;
83}
84
85// --------------------------------------------------------------------------
86//
87// Print the Concetration Parameters to *fLog
88//
89void MConcentration::Print(Option_t *) const
90{
91 *fLog << all;
92 *fLog << "Concentrations (" << GetName() << ")" << endl;
93 for(int i=0;i<9;i++)
94 *fLog << "Conc" << i+1 <<" = "<< fConc[i] << endl;
95}
96
97// --------------------------------------------------------------------------
98//
99// Calculate the Concentrations from a Cherenkov photon event
100// assuming Cher.photons/pixel, their standard hillas parameters
101// and pixel coordinates are given.
102// In case you don't call Calc from within an eventloop make sure, that
103// you call the Reset member function before.
104//
105// Returns:
106// Nothing.
107//
108Int_t MConcentration::Calc(const MGeomCam &geom, const MSignalCam &evt, const MHillas &hillas)
109{
110 Float_t maxpix[9] = {0,0,0,0,0,0,0,0,0}; // [#phot]
111
112 const UInt_t npix = evt.GetNumPixels();
113 for (UInt_t j=0; j<npix; j++)
114 {
115 const MSignalPix &pix = evt[j];
116 if (!pix.IsPixelUsed())
117 continue;
118
119 const Double_t nphot = pix.GetNumPhotons()* geom.GetPixRatio(j);
120
121 // Get number of photons in the 8 most populated pixels
122 if (maxpix[0]<=nphot)
123 {
124 for(int i=0;i<8;i++)
125 maxpix[8-i]=maxpix[7-i];
126 maxpix[0]=nphot;
127 continue;
128 }
129
130 // Check if the latest value is 'somewhere in between'
131 for (int i=0; i<8; i++)
132 {
133 if (nphot>=maxpix[7-i])
134 continue;
135
136 for(int k=0;k<i-1;k++)
137 maxpix[7-k]=maxpix[6-k]; // [#phot]
138
139 maxpix[8-i]=nphot;
140 break;
141 }
142 }
143
144 // Compute concentrations from the 8 pixels with higher signal
145 fConc[0]=maxpix[0];
146
147 // No calculate the integral of the n highest pixels
148 for(int i=1; i<8; i++)
149 fConc[i] = fConc[i-1]+maxpix[i];
150
151 for(int i=0; i<8; i++)
152 fConc[i] /= hillas.GetSize(); // [ratio]
153
154 SetReadyToSave();
155
156 return 0;
157}
Note: See TracBrowser for help on using the repository browser.