source: trunk/Mars/mcamera/MCameraTH.cc@ 15732

Last change on this file since 15732 was 8955, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 3.8 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, 5/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
19! Author(s): Florian Goebel 11/2005 <mailto:fgoebel@mppmu.mpg.de>
20!
21! Copyright: MAGIC Software Development, 2000-2006
22!
23!
24\* ======================================================================== */
25
26/////////////////////////////////////////////////////////////////////////////
27//
28// MCameraTH
29//
30// Class Version 2:
31// ----------------
32// + Bool_t fIsValid; // fTH contains valid information
33//
34/////////////////////////////////////////////////////////////////////////////
35#include "MCameraTH.h"
36
37#include <TMath.h>
38
39#include "MLog.h"
40#include "MLogManip.h"
41
42#include "MCameraTD.h"
43
44ClassImp(MCameraTH);
45
46using namespace std;
47
48// --------------------------------------------------------------------------
49//
50// Default constructor.
51//
52MCameraTH::MCameraTH(Int_t size, const char *name, const char *title)
53 : fTH(size), fIsValid(kTRUE)
54{
55 fName = name ? name : "MCameraTH";
56 fTitle = title ? title : "Storage container for the pixel discriminator threshold";
57}
58
59// --------------------------------------------------------------------------
60//
61// Interprete the TH (discriminator thresholds) part of the report
62//
63Bool_t MCameraTH::InterpreteTH(TString &str, Int_t ver, MCameraTD &td)
64{
65 // Skip the TH (discriminator thresholds) part of the report (for old
66 // CC files with wrong or nonsense number of TH-Bytes)
67 if (ver<200507190)
68 {
69 Ssiz_t pr = str.First(' ');
70 if (pr<0)
71 {
72 *fLog << warn << "WARNING - No TH information found at all." << endl;
73 return kFALSE;
74 }
75 if (pr!=1154)
76 {
77 td.Invalidate();
78
79 str.Remove(0, pr);
80 str=str.Strip(TString::kLeading);
81 return kTRUE;
82 }
83 }
84
85 const char *pos = str.Data();
86 const char *end = str.Data()+577*2;
87
88 Int_t i=0;
89 while (pos<end)
90 {
91 const Char_t hex[3] = { pos[0], pos[1], 0 };
92 pos += 2;
93
94 const Int_t n=sscanf(hex, "%2hhx", &fTH[i++]);
95 if (n==1)
96 continue;
97
98 *fLog << warn << "WARNING - Reading hexadecimal TH information." << endl;
99 return kFALSE;
100 }
101
102 SetValid();
103
104 str.Remove(0, end-str.Data()); // Remove TH
105 str=str.Strip(TString::kLeading);
106 return kTRUE;
107}
108
109// --------------------------------------------------------------------------
110//
111// Print the discriminator thresholds
112//
113void MCameraTH::Print(Option_t *) const
114{
115 *fLog << all << underline << GetDescriptor() << endl;
116 for (int i=0; i<fTH.GetSize(); i++)
117 *fLog << " " << (int)fTH[i];
118 *fLog << endl;
119}
120
121// --------------------------------------------------------------------------
122//
123// Return the discriminator thresholds
124//
125Byte_t MCameraTH::GetMin() const
126{
127 Byte_t val = 0xff;
128 for (int i=0; i<fTH.GetSize(); i++)
129 val = TMath::Min(val, fTH[i]);
130 return val;
131}
132
133// --------------------------------------------------------------------------
134//
135// Return the discriminator thresholds
136//
137Byte_t MCameraTH::GetMax() const
138{
139 Byte_t val = 0;
140 for (int i=0; i<fTH.GetSize(); i++)
141 val = TMath::Max(val, fTH[i]);
142 return val;
143}
Note: See TracBrowser for help on using the repository browser.