42 lines
724 B
C++
42 lines
724 B
C++
//CaloGrid.hh
|
|
|
|
#include "CaloCell.hh"
|
|
|
|
#ifndef CALOGRID_HH
|
|
#define CALOGRID_HH
|
|
class CaloGrid
|
|
{
|
|
public:
|
|
CaloGrid( int nx, int ny ) {
|
|
init(nx, ny );
|
|
}
|
|
CaloGrid( const CaloGrid& other ) {
|
|
// Set everything using init to allocate memory
|
|
init(other.nx, other.ny ) ;
|
|
|
|
// Copy elements
|
|
// Because we make it a 1Dim array, we can simply run over all elements in one go
|
|
for (int i=0 ; i<nx*ny ; i++ ) {
|
|
cells[i] = other.cells[i] ;
|
|
}
|
|
}
|
|
~CaloGrid() {
|
|
delete[] cells;
|
|
}
|
|
|
|
CaloCell* cell(int x, int y);
|
|
|
|
|
|
private:
|
|
int nx, ny ;
|
|
CaloCell* cells ;
|
|
|
|
void init( int in_nx, int in_ny ) {
|
|
nx = in_nx ;
|
|
ny = in_ny ;
|
|
|
|
// contigious cells
|
|
cells = new CaloCell[ nx*ny ];
|
|
}
|
|
} ;
|
|
#endif
|