StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMuRHICfCollection.cxx
1 #include "StMuRHICfCollection.h"
2 #include "StMuRHICfRawHit.h"
3 #include "StMuRHICfHit.h"
4 #include "StMuRHICfPoint.h"
5 
6 ClassImp(StMuRHICfCollection)
7 
9 {
10  mRawHit = 0;
11  mHit = 0;
12  mPoint = 0;
13 }
14 
15 StMuRHICfCollection::~StMuRHICfCollection()
16 {
17  if(mRawHit){delete mRawHit;}
18  if(mHit){delete mHit;}
19  if(mPoint){delete mPoint;}
20  mRawHit = NULL;
21  mHit = NULL;
22  mPoint = NULL;
23 }
24 
25 void StMuRHICfCollection::init()
26 {
27  mRawHit = new TClonesArray("StMuRHICfRawHit", 1);
28  mHit = new TClonesArray("StMuRHICfHit", 1);
29  mPoint = new TClonesArray("StMuRHICfPoint", 0);
30 }
31 
32 unsigned int StMuRHICfCollection::numberOfPoints() const
33 {
34  if (!mPoint) return 0;
35  return mPoint->GetEntriesFast();
36 }
37 
38 StMuRHICfRawHit* StMuRHICfCollection::addRawHit()
39 {
40  if(!mRawHit){init();}
41  StMuRHICfRawHit* muRHICfRawHit = (StMuRHICfRawHit*) mRawHit -> ConstructedAt(0);
42  return muRHICfRawHit;
43 }
44 
45 StMuRHICfHit* StMuRHICfCollection::addHit()
46 {
47  if(!mHit){init();}
48  StMuRHICfHit* muRHICfHit = (StMuRHICfHit*) mHit -> ConstructedAt(0);
49  return muRHICfHit;
50 }
51 
52 StMuRHICfPoint* StMuRHICfCollection::addPoint()
53 {
54  if(!mPoint){init();}
55  int counter = mPoint->GetEntriesFast();
56  return new ((*mPoint)[counter]) StMuRHICfPoint;
57 }
58 
59 StMuRHICfRawHit* StMuRHICfCollection::getRawHit()
60 {
61  if(!mRawHit){return NULL;}
62  return (StMuRHICfRawHit*) mRawHit -> At(0);
63 }
64 
65 StMuRHICfHit* StMuRHICfCollection::getHit()
66 {
67  if(!mHit){return NULL;}
68  return (StMuRHICfHit*) mHit -> At(0);
69 }
70 
71 StMuRHICfPoint* StMuRHICfCollection::getPoint(Int_t index)
72 {
73  if(!mPoint){return NULL;}
74  return static_cast<StMuRHICfPoint*>(mPoint->At(index));
75 }
76 
77 TClonesArray* StMuRHICfCollection::getPointArray(){return mPoint;}
78 
79 void StMuRHICfCollection::setRHICfRawHitArray(TClonesArray *array){mRawHit = array;}
80 void StMuRHICfCollection::setRHICfHitArray(TClonesArray *array){mHit = array;}
81 void StMuRHICfCollection::setRHICfPointArray(TClonesArray* array){mPoint = array;}