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

Last change on this file since 4839 was 4710, checked in by tbretz, 20 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@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// Initializes the values with defaults. For the default values see the
78// source code.
79//
80void MConcentration::Reset()
81{
82 for (int i=0; i<9; i++)
83 fConc[i] = -1;
84}
85
86// --------------------------------------------------------------------------
87//
88// Print the Concetration Parameters to *fLog
89//
90void MConcentration::Print(Option_t *) const
91{
92 *fLog << all;
93 *fLog << "Concentrations (" << GetName() << ")" << endl;
94 for(int i=0;i<9;i++)
95 *fLog << "Conc" << i+1 <<" = "<< fConc[i] << endl;
96}
97
98// --------------------------------------------------------------------------
99//
100// Calculate the Concentrations from a Cherenkov photon event
101// assuming Cher.photons/pixel, their standard hillas parameters
102// and pixel coordinates are given.
103// In case you don't call Calc from within an eventloop make sure, that
104// you call the Reset member function before.
105//
106// Returns:
107// Nothing.
108//
109Int_t MConcentration::Calc(const MGeomCam &geom, const MCerPhotEvt &evt, const MHillas &hillas)
110{
111 Float_t maxpix[9] = {0,0,0,0,0,0,0,0,0}; // [#phot]
112
113 TIter Next(evt);
114 MCerPhotPix *pix = 0;
115 while ((pix=(MCerPhotPix*)Next()))
116 {
117 const Int_t pixid = pix->GetPixId();
118 const Double_t nphot = pix->GetNumPhotons()* geom.GetPixRatio(pixid);
119
120 // Get number of photons in the 8 most populated pixels
121 if (maxpix[0]<=nphot)
122 {
123 for(int i=0;i<8;i++)
124 maxpix[8-i]=maxpix[7-i];
125 maxpix[0]=nphot;
126 continue;
127 }
128
129 // Check if the latest value is 'somewhere in between'
130 for (int i=0; i<8; i++)
131 {
132 if (nphot>=maxpix[7-i])
133 continue;
134
135 for(int j=0;j<i-1;j++)
136 maxpix[7-j]=maxpix[6-j]; // [#phot]
137
138 maxpix[8-i]=nphot;
139 break;
140 }
141 }
142
143 // Compute concentrations from the 8 pixels with higher signal
144 fConc[0]=maxpix[0];
145
146 // No calculate the integral of the n highest pixels
147 for(int i=1; i<8; i++)
148 fConc[i] = fConc[i-1]+maxpix[i];
149
150 for(int i=0; i<8; i++)
151 fConc[i] /= hillas.GetSize(); // [ratio]
152
153 SetReadyToSave();
154
155 return 0;
156}
Note: See TracBrowser for help on using the repository browser.