source: trunk/MagicSoft/Mars/mimage/MConcentration.cc@ 4608

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