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

Last change on this file since 3551 was 3543, checked in by gaug, 22 years ago
*** empty log message ***
File size: 4.6 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 const UInt_t npixevt = evt.GetNumPixels();
119
120 Float_t maxpix[9] = {0,0,0,0,0,0,0,0,0}; // [#phot]
121
122 for (UInt_t i=0; i<npixevt; i++)
123 {
124 const MCerPhotPix &pix = evt[i];
125
126 // skip unused pixels
127 if (!pix.IsPixelUsed())
128 continue;
129
130 const Int_t pixid = pix.GetPixId();
131
132 const MGeomPix &gpix = geom[pixid];
133
134 Double_t nphot = pix.GetNumPhotons();
135
136 //
137 // Now we are working on absolute values of nphot, which
138 // must take pixel size into account
139 //
140 nphot *= geom.GetPixRatio(pixid);
141
142 // Get number of photons in the 8 most populated pixels
143
144 if(maxpix[0]<=nphot) {
145 for(int i=0;i<8;i++)
146 maxpix[8-i]=maxpix[7-i];
147 maxpix[0]=nphot;
148 }
149 else
150 for(int i=0;i<8;i++){
151 if (nphot<maxpix[7-i]){
152 for(int j=0;j<i-1;j++){
153 maxpix[7-j]=maxpix[6-j]; // [#phot]
154 }
155 maxpix[8-i]=nphot;
156 break;
157 }
158 }
159
160 }
161
162 // Compute concentrations from the 8 pixels with higher signal
163
164 fConc[0]=maxpix[0];
165 for(int i=1;i<8;i++)
166 {
167 fConc[i]=fConc[i-1]+maxpix[i];
168 }
169
170 for(int i=0;i<8;i++)
171 {
172 fConc[i]/=hillas.GetSize(); // [ratio]
173 }
174
175 SetReadyToSave();
176
177}
178
179
Note: See TracBrowser for help on using the repository browser.