// ESAF : Euso Simulation and Analysis Framework
// $Id: RecoCellInfo.cc,v 1.7 2004/06/17 08:20:07 thea Exp $
// Marco Pallavicini created Nov, 18 2003
#include "RecoCellInfo.hh"
#include "RecoCellHit.hh"
#include "utils.hh"
ClassImp(RecoCellInfo)
// ctor
RecoCellInfo::RecoCellInfo(Int_t id) : fCellId(id) {
}
// dtor
RecoCellInfo::~RecoCellInfo() {
for( size_t i(0); i<fHits.size(); i++ ) {
delete fHits[i];
}
fHits.clear();
}
// return hit checking valid index
const RecoCellHit *RecoCellInfo::GetHit(UInt_t i) const {
if ( i > fHits.size() || i < 0 )
throw runtime_error("Index out of bound in RecoCellInfo::GetHit()");
return fHits[i];
}
// add a hit
void RecoCellInfo::AddHit(Int_t id, Int_t counts,Int_t gtu) {
fHits.push_back( new RecoCellHit( id, counts, gtu ));
}
// return total number of counts in macrocell
Int_t RecoCellInfo::GetNumberofCounts() const {
Int_t total=0;
for (Int_t i=0; i<GetNumberofHits(); i++) {
total+=fHits[i]->GetCounts();
}
return total;
}
// return Gtu id of first photoelectron detected in macrocell
Int_t RecoCellInfo::GetFirstGtu() const {
Int_t first = fHits[0]->GetGtu();
for (Int_t i=1; i<GetNumberofHits(); i++) {
if (fHits[i]->GetGtu() < first)
first = fHits[i]->GetGtu();
}
return first;
}
// return Gtu id of last photoelectron detected in macrocell
Int_t RecoCellInfo::GetLastGtu() const {
Int_t last = fHits[0]->GetGtu();
for (Int_t i=1; i<GetNumberofHits(); i++) {
if (fHits[i]->GetGtu() > last)
last = fHits[i]->GetGtu();
}
return last;
}