File indexing completed on 2025-08-05 08:16:09
0001 #include "TpcRawHitContainerv2.h"
0002 #include "TpcRawHitv2.h"
0003
0004 #include <TClonesArray.h>
0005
0006 static const int NTPCHITS = 10000;
0007
0008 TpcRawHitContainerv2::TpcRawHitContainerv2()
0009 : TpcRawHitsTCArray(new TClonesArray("TpcRawHitv2", NTPCHITS))
0010 {
0011 }
0012
0013 TpcRawHitContainerv2::~TpcRawHitContainerv2()
0014 {
0015 TpcRawHitsTCArray->Clear("C");
0016 delete TpcRawHitsTCArray;
0017 }
0018
0019 void TpcRawHitContainerv2::Reset()
0020 {
0021 TpcRawHitsTCArray->Clear("C");
0022 TpcRawHitsTCArray->Expand(NTPCHITS);
0023 }
0024
0025 void TpcRawHitContainerv2::identify(std::ostream &os) const
0026 {
0027 os << "TpcRawHitContainerv2" << std::endl;
0028 os << "containing " << TpcRawHitsTCArray->GetEntriesFast() << " Tpc hits" << std::endl;
0029
0030 TpcRawHit *tpchit = static_cast<TpcRawHit *>(TpcRawHitsTCArray->At(0));
0031 if (tpchit)
0032 {
0033 os << "for beam clock: " << std::hex << tpchit->get_bco() << std::dec << std::endl;
0034 }
0035 }
0036
0037 int TpcRawHitContainerv2::isValid() const
0038 {
0039 return TpcRawHitsTCArray->GetSize();
0040 }
0041
0042 unsigned int TpcRawHitContainerv2::get_nhits()
0043 {
0044 return TpcRawHitsTCArray->GetEntriesFast();
0045 }
0046
0047 TpcRawHit *TpcRawHitContainerv2::AddHit()
0048 {
0049 TpcRawHit *newhit = new ((*TpcRawHitsTCArray)[TpcRawHitsTCArray->GetLast() + 1]) TpcRawHitv2();
0050 return newhit;
0051 }
0052
0053 TpcRawHit *TpcRawHitContainerv2::AddHit(TpcRawHit *tpchit)
0054 {
0055 TpcRawHit *newhit = new ((*TpcRawHitsTCArray)[TpcRawHitsTCArray->GetLast() + 1]) TpcRawHitv2(tpchit);
0056 return newhit;
0057 }
0058
0059 TpcRawHit *TpcRawHitContainerv2::get_hit(unsigned int index)
0060 {
0061 return (TpcRawHit *) TpcRawHitsTCArray->At(index);
0062 }