CCell.h
//-----------------------------------------------------------------------------
//
//
// COOL Program Library
// Copyright (C) CERES collaboration, 1996
//
// Declarations for CCell class.
//
// Node that the operators new and delete are overloaded
// in order to provide a more efficient memory management
// (see class CMemoryPool).
//
//-----------------------------------------------------------------------------
#ifndef CCELL_H
#define CCELL_H
#include <rw/tpordvec.h>
#include "cool.h"
#include "CMemoryPool.h"
class CMCDigiHit;
class CSidcCluster;
class CCell {
public:
inline CCell(); // dummy cell with illegal coordinates
inline CCell(int, int, float); // create cell with (anode, tbin, amp)
inline ~CCell();
public:
void* operator new(size_t) { return mempool.alloc(); }
void operator delete(void* p) { mempool.free(p); }
public:
CBoolean operator== (const CCell& cell) const;
public:
int getX() const { return anode; } // needed for cyclic array
int getY() const { return timeBin; } // needed for cyclic array
int getAnode() const { return anode; }
int getTimeBin() const { return timeBin; }
float getAmp() const { return amp; }
const CSidcCluster* getCluster() const { return cluster; }
void setAmp(float val) { amp = val; }
void setCluster(CSidcCluster *newCluster) { cluster = newCluster; }
public:
void addMCDigiHit(CMCDigiHit*);
inline const RWTPtrOrderedVector<CMCDigiHit>* getMCHits() const { return mcHits; };
protected:
RWTPtrOrderedVector<CMCDigiHit>* mcHits;
protected:
int anode;
int timeBin;
float amp;
CSidcCluster *cluster;
private:
static CMemoryPool mempool;
};
CCell::CCell()
{
anode = 0;
timeBin = 0;
amp = 0;
cluster = 0;
mcHits = 0;
}
CCell::CCell(int an, int tb, float a)
{
anode = an;
timeBin = tb;
amp = a;
cluster = 0;
mcHits = 0;
}
CCell::~CCell()
{
if (mcHits != 0) {
mcHits->clear();
delete mcHits;
}
}
#endif /* CCELL_H */