source: JEM-EUSO/esaf_lal/tags/v1_r0/esaf/packages/simulation/detector/tools/src/OADBHeader.cc @ 117

Last change on this file since 117 was 117, checked in by moretto, 11 years ago

ESAF version compilable on mac OS

File size: 3.1 KB
Line 
1// ESAF : Euso Simulation and Analysis Framework
2// $Id: OADBHeader.cc 1814 2005-05-03 21:05:02Z thea $
3// A.Thea, J.Watts created Mar, 16 2004
4
5#include "OADBHeader.hh"
6#include "TMath.h"
7#include "Riostream.h"
8#include "utils.hh"
9#include <typeinfo>
10
11ClassImp(OADBHeader)
12   
13// ctor
14OADBHeader::OADBHeader(): fXYStep(0), fEntranceDiscRadius(0), fNumAngles(0),
15    fAngles(NULL), fNumWavelengths(0), fWavelengths(NULL), fNumRows(0),
16    fNumCols(NULL) { 
17}
18
19// dtor
20OADBHeader::~OADBHeader() {
21}
22
23// copy
24void OADBHeader::Copy( TObject& o) const {
25
26    OADBHeader* h = dynamic_cast<OADBHeader*>(&o);
27    h->fXYStep = fXYStep;
28    h->fEntranceDiscRadius = fEntranceDiscRadius;
29    h->fNumRows = fNumRows;
30}
31
32// getters
33
34// returns the n of columns of row
35Int_t OADBHeader::GetNumCols( Int_t row ) const {
36    if (row < 0 || row > fNumRows-1 ) return -1;
37    else return fNumCols[row];
38}
39
40// get the i-th angle
41Float_t OADBHeader::GetAngle(Int_t i) const {
42    if (i < 0 || i > fNumAngles-1 ) return -1;
43    else return fAngles[i];
44}
45
46// get the i-th wavelength
47Float_t OADBHeader::GetWavelength(Int_t i) const {
48    if (i < 0 || i > fNumWavelengths-1 ) return -1;
49    else return fWavelengths[i];
50}
51
52// returns the total number of positions
53Int_t OADBHeader::GetNumPos() const {
54    Int_t size(0);
55    for(Int_t i(0); i<fNumRows; i++) {
56        size+=fNumCols[i];
57    }
58    return size;
59}
60
61
62// setters
63// set the number of columns to r and resize fNumCols
64void OADBHeader::SetNumRows( Int_t r ) {
65    if ( r < 0 )
66        throw runtime_error("SetNumRows: index < 0");
67   
68    if (fNumRows ==  r)
69        return;
70   
71    if ( fNumCols )
72        delete [] fNumCols;
73    fNumRows = r;
74    fNumCols = new Int_t[fNumRows];
75    for(Int_t i(0); i < fNumRows; i++) {
76        fNumCols[i] = 0;
77    }
78} 
79
80// set the number of cols at the r-th row to c
81void OADBHeader::SetNumCols( Int_t r, Int_t c ) {
82    if ( r < fNumRows && r >= 0 )
83        fNumCols[r]=c;
84}
85
86// set the number of angles to n and resize fAngles
87void OADBHeader::SetNumAngles( Int_t n ) {
88    if ( n < 0 )
89        throw runtime_error("SetNumAngles: index < 0");
90   
91    if (fNumAngles ==  n)
92        return;
93   
94    if ( fAngles )
95        delete [] fAngles;
96    fNumAngles = n;
97    fAngles = new Float_t[fNumAngles];
98    for(Int_t i(0); i < fNumAngles; i++) {
99        fAngles[i] = 0;
100    }
101} 
102
103// set the angle at the i-th row to th
104void OADBHeader::SetAngle( Int_t i, Float_t th ) {
105    if ( i < fNumAngles && i >= 0 )
106        fAngles[i]=th;
107}
108
109// set the number of wavelengths to n and resize fWavelengths
110void OADBHeader::SetNumWavelengths( Int_t n ) {
111    if ( n < 0 )
112        throw runtime_error("SetNumWavelengths: index < 0");
113   
114    if (fNumWavelengths ==  n)
115        return;
116   
117    if ( fWavelengths )
118        delete [] fWavelengths;
119    fNumWavelengths = n;
120    fWavelengths = new Float_t[fNumWavelengths];
121    for(Int_t i(0); i < fNumWavelengths; i++) {
122        fWavelengths[i] = 0;
123    }
124} 
125
126// set the wavelength at the i-th row to th
127void OADBHeader::SetWavelength( Int_t i, Float_t th ) {
128    if ( i < fNumWavelengths && i >= 0 )
129        fWavelengths[i]=th;
130}
131
Note: See TracBrowser for help on using the repository browser.