This repository has been archived on 2021-11-03. You can view files and clone it, but cannot push or open issues or pull requests.
2019-12-17 15:05:27 +01:00
|
|
|
//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);
|
2020-06-30 14:00:21 +02:00
|
|
|
const CaloCell* cell(int x, int y) const {
|
|
|
|
return const_cast<CaloCell*> (cell(x, y));
|
|
|
|
}
|
2019-12-17 15:05:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
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
|