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

Last change on this file since 6215 was 5142, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 4.3 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 "MCerPhotPix.h"
53#include "MCerPhotEvt.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 MCerPhotEvt &evt, const MHillas &hillas)
109{
110 Float_t maxpix[9] = {0,0,0,0,0,0,0,0,0}; // [#phot]
111
112 TIter Next(evt);
113 MCerPhotPix *pix = 0;
114 while ((pix=(MCerPhotPix*)Next()))
115 {
116 const Int_t pixid = pix->GetPixId();
117 const Double_t nphot = pix->GetNumPhotons()* geom.GetPixRatio(pixid);
118
119 // Get number of photons in the 8 most populated pixels
120 if (maxpix[0]<=nphot)
121 {
122 for(int i=0;i<8;i++)
123 maxpix[8-i]=maxpix[7-i];
124 maxpix[0]=nphot;
125 continue;
126 }
127
128 // Check if the latest value is 'somewhere in between'
129 for (int i=0; i<8; i++)
130 {
131 if (nphot>=maxpix[7-i])
132 continue;
133
134 for(int j=0;j<i-1;j++)
135 maxpix[7-j]=maxpix[6-j]; // [#phot]
136
137 maxpix[8-i]=nphot;
138 break;
139 }
140 }
141
142 // Compute concentrations from the 8 pixels with higher signal
143 fConc[0]=maxpix[0];
144
145 // No calculate the integral of the n highest pixels
146 for(int i=1; i<8; i++)
147 fConc[i] = fConc[i-1]+maxpix[i];
148
149 for(int i=0; i<8; i++)
150 fConc[i] /= hillas.GetSize(); // [ratio]
151
152 SetReadyToSave();
153
154 return 0;
155}
Note: See TracBrowser for help on using the repository browser.