StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMuFstCollection.cxx
1 /***************************************************************************
2  *
3  * $Id: StMuFstCollection.cxx
4  *
5  * Author: tchuang, 2022
6  ***************************************************************************
7  *
8  * Description: Fst data interface to StMuFstRawHit and StMuFstHit
9  *
10  ***************************************************************************/
11 
12 #include "StMuDSTMaker/COMMON/StMuFstCollection.h"
13 #include "StMuDSTMaker/COMMON/StMuFstRawHit.h"
14 #include "StMuDSTMaker/COMMON/StMuFstHit.h"
15 
16 #include "St_base/StMessMgr.h"
17 
18 ClassImp(StMuFstCollection)
19 
20 StMuFstCollection::StMuFstCollection() { mRawHits = 0; mHits = 0; }
21 
22 StMuFstCollection::~StMuFstCollection() {
23  delete mRawHits;
24  delete mHits;
25  mRawHits = nullptr;
26  mHits = nullptr;
27 }
28 
29 void StMuFstCollection::init() {
30  mRawHits = new TClonesArray("StMuFstRawHit", 0);
31  mHits = new TClonesArray("StMuFstHit", 0);
32 }
33 
34 StMuFstRawHit* StMuFstCollection::addRawHit() {
35  if (!mRawHits) init();
36  int counter = mRawHits->GetEntriesFast();
37  return new ((*mRawHits)[counter]) StMuFstRawHit;
38 }
39 
40 StMuFstHit* StMuFstCollection::addHit() {
41  if (!mHits) init();
42  int counter = mHits->GetEntriesFast();
43  return new ((*mHits)[counter]) StMuFstHit;
44 }
45 
46 unsigned int StMuFstCollection::numberOfRawHits() const {
47  if (!mRawHits) return 0;
48  return mRawHits->GetEntriesFast();
49 }
50 
51 unsigned int StMuFstCollection::numberOfHits() const {
52  if (!mHits) return 0;
53  return mHits->GetEntriesFast();
54 }
55 
56 StMuFstRawHit* StMuFstCollection::getRawHit(int index) {
57  if (!mRawHits) return NULL;
58  return static_cast<StMuFstRawHit*>(mRawHits->At(index));
59 }
60 
61 StMuFstHit* StMuFstCollection::getHit(int index) {
62  if (!mHits) return NULL;
63  return static_cast<StMuFstHit*>(mHits->At(index));
64 }