//////////////////////////////////////////////////////////// // $Id: IDataHit.cxx,v 1.11 2010/07/07 17:35:44 mcgrew Exp $ // //////////////////////////////////////////////////////////// #include "IDataHit.hxx" #include "HEPUnits.hxx" ClassImp(COMET::IDataHit); ClassImp(COMET::IWritableDataHit); COMET::IDataHit::IDataHit() {} COMET::IDataHit::IDataHit(const COMET::IWritableDataHit& h) : COMET::ISingleHit(h), fProxy(h.fProxy) {} COMET::IDataHit::~IDataHit() { } int COMET::IDataHit::GetDigitCount() const { if (fProxy.IsValid()) return fProxy.GetContainer().size(); else return 0; } const COMET::IDigitProxy& COMET::IDataHit::GetDigit(int i) const { if (i!=0) throw COMET::EHitOutOfRange(); if (!fProxy.IsValid()) throw COMET::EHitOutOfRange(); return fProxy; } COMET::IWritableDataHit::IWritableDataHit() {} COMET::IWritableDataHit::IWritableDataHit(const COMET::IWritableDataHit& h) : COMET::IDataHit(h) {} COMET::IWritableDataHit::~IWritableDataHit() {} ////////////////////////////////////////////////// // Setter methods for COMET::IWritableDataHit ////////////////////////////////////////////////// void COMET::IWritableDataHit::SetGeomID(COMET::IGeometryId id) { fGeomID = id; } void COMET::IWritableDataHit::SetCharge(double q) {fCharge = q;} void COMET::IWritableDataHit::SetTime(double t) {fTime = t;} void COMET::IWritableDataHit::SetDigit(COMET::IDigitProxy proxy) { fProxy = proxy; if (fProxy.IsValid()) { try { COMET::IDigit* digit = *fProxy; if (digit) { if (fChannelID.AsUInt() == 0) { fChannelID = digit->GetChannelId(); } else if (fChannelID != digit->GetChannelId() && digit->GetChannelId().AsUInt() != 0) { COMETError("Hit channel id disagrees with digit proxy"); } } } catch (...) {} } else if (fChannelID.AsUInt() == 0) { COMETError("Invalid digit used to create hit." " Use SetChannelId to set channel before SetDigit."); } } void COMET::IWritableDataHit::SetChannelID(COMET::IChannelId id) {fChannelID = id;} void COMET::IWritableDataHit::SetChargeValidity(bool valid) { COMET::IHit::SetChargeValidity(valid); } void COMET::IWritableDataHit::SetTimeValidity(bool valid) { COMET::IHit::SetTimeValidity(valid); }