StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMuFttCollection.cxx
1 /***************************************************************************
2  *
3  * $Id: StMuFttCollection.cxx
4  *
5  * Author: jdb, 2021
6  ***************************************************************************
7  *
8  * Description: Fcs data interface to StMuFttRawHit, StMuFttCluster, StMuFttPoint, and StMuFcsInfo
9  *
10  ***************************************************************************/
11 
12 #include "StMuDSTMaker/COMMON/StMuFttCollection.h"
13 #include "StMuDSTMaker/COMMON/StMuFttCluster.h"
14 #include "StMuDSTMaker/COMMON/StMuFttRawHit.h"
15 #include "StMuDSTMaker/COMMON/StMuFttPoint.h"
16 
17 #include "St_base/StMessMgr.h"
18 
19 ClassImp(StMuFttCollection)
20 
21 StMuFttCollection::StMuFttCollection() { mHits = 0; mClusters = 0; mPoints = 0; }
22 
23 StMuFttCollection::~StMuFttCollection() {
24  delete mHits;
25  delete mClusters;
26  delete mPoints;
27  mHits = mClusters = mPoints = nullptr;
28 }
29 
30 void StMuFttCollection::init() {
31  mHits = new TClonesArray("StMuFttRawHit", 0);
32  mClusters = new TClonesArray("StMuFttCluster", 0);
33  mPoints = new TClonesArray("StMuFttPoint", 0);
34 }
35 
36 StMuFttRawHit* StMuFttCollection::addRawHit(){
37  if(!mHits) init();
38  int counter = mHits->GetEntriesFast();
39  StMuFttRawHit* newFcsHit = new ((*mHits)[counter]) StMuFttRawHit();
40  return newFcsHit;
41 }
42 
43 StMuFttCluster* StMuFttCollection::addCluster() {
44  if (!mClusters) init();
45  int counter = mClusters->GetEntriesFast();
46  return new ((*mClusters)[counter]) StMuFttCluster;
47 }
48 
49 StMuFttPoint* StMuFttCollection::addPoint() {
50  if (!mPoints) init();
51  int counter = mPoints->GetEntriesFast();
52  return new ((*mPoints)[counter]) StMuFttPoint;
53 }
54 
55 unsigned int StMuFttCollection::numberOfRawHits() const{
56  if(!mHits) return 0;
57  return mHits->GetEntriesFast();
58 }
59 
60 unsigned int StMuFttCollection::numberOfClusters() const {
61  if (!mClusters) return 0;
62  return mClusters->GetEntriesFast();
63 }
64 
65 unsigned int StMuFttCollection::numberOfPoints() const {
66  if (!mPoints) return 0;
67  return mPoints->GetEntriesFast();
68 }
69 
70 StMuFttRawHit* StMuFttCollection::getRawHit(int index){
71  if(!mHits) return NULL;
72  return (StMuFttRawHit*) mHits->At(index);
73 }
74 
75 StMuFttCluster* StMuFttCollection::getCluster(int index) {
76  if (!mClusters) return NULL;
77  return static_cast<StMuFttCluster*>(mClusters->At(index));
78 }
79 
80 StMuFttPoint* StMuFttCollection::getPoint(int index) {
81  if (!mPoints) return NULL;
82  return static_cast<StMuFttPoint*>(mPoints->At(index));
83 }