source: trunk/Mars/mcamera/MCameraTD.cc@ 10083

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