StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMuFcsCollection.cxx
1 /***************************************************************************
2  *
3  * $Id: StMuFcsCollection.cxx,v 1.0 2021/11/17 16:22:36 jdb Exp $
4  *
5  * Author: Daniel Brandenburg, 2021
6  ***************************************************************************
7  *
8  * Description: Fcs data interface to StMuFcsHit, StMuFcsCluster, StMuFcsPoint, and StMuFcsInfo
9  *
10  ***************************************************************************/
11 
12 #include "StMuDSTMaker/COMMON/StMuFcsCollection.h"
13 #include "StMuDSTMaker/COMMON/StMuFcsCluster.h"
14 #include "StMuDSTMaker/COMMON/StMuFcsHit.h"
15 #include "StMuDSTMaker/COMMON/StMuFcsPoint.h"
16 #include "StMuDSTMaker/COMMON/StMuFcsInfo.h"
17 
18 #include "St_base/StMessMgr.h"
19 
20 static const char rcsid[] = "$Id: StMuFcsCollection.cxx,v 1.6 2021/09/26 16:22:36 jdb Exp $";
21 
22 ClassImp(StMuFcsCollection)
23 
24 StMuFcsCollection::StMuFcsCollection() { mHits = 0; mClusters = 0; mPoints = 0; mInfo = 0; }
25 
26 StMuFcsCollection::~StMuFcsCollection() {
27  delete mHits;
28  delete mClusters;
29  delete mPoints;
30  delete mInfo;
31  mHits = mClusters = mPoints = mInfo = nullptr;
32 }
33 
34 void StMuFcsCollection::init() {
35  mHits = new TClonesArray("StMuFcsHit", 0);
36  mClusters = new TClonesArray("StMuFcsCluster", 0);
37  mPoints = new TClonesArray("StMuFcsPoint", 0);
38  mInfo = new TClonesArray("StMuFcsInfo", 0);
39 }
40 
41 StMuFcsHit* StMuFcsCollection::addHit(){
42  if(!mHits) init();
43  int counter = mHits->GetEntriesFast();
44  StMuFcsHit* newFcsHit = new ((*mHits)[counter]) StMuFcsHit();
45  return newFcsHit;
46 }
47 
48 StMuFcsCluster* StMuFcsCollection::addCluster() {
49  if (!mClusters) init();
50  int counter = mClusters->GetEntriesFast();
51  return new ((*mClusters)[counter]) StMuFcsCluster;
52 }
53 
54 StMuFcsPoint* StMuFcsCollection::addPoint() {
55  if (!mPoints) init();
56  int counter = mPoints->GetEntriesFast();
57  return new ((*mPoints)[counter]) StMuFcsPoint;
58 }
59 
60 StMuFcsInfo* StMuFcsCollection::addInfo() {
61  if (!mInfo) init();
62  int counter = mInfo->GetEntriesFast();
63  return new ((*mInfo)[counter]) StMuFcsInfo;
64 }
65 
66 unsigned int StMuFcsCollection::numberOfHits() const{
67  if(!mHits) return 0;
68  return mHits->GetEntriesFast();
69 }
70 
71 unsigned int StMuFcsCollection::numberOfClusters() const {
72  if (!mClusters) return 0;
73  return mClusters->GetEntriesFast();
74 }
75 
76 unsigned int StMuFcsCollection::numberOfPoints() const {
77  if (!mPoints) return 0;
78  return mPoints->GetEntriesFast();
79 }
80 
81 StMuFcsHit* StMuFcsCollection::getHit(int index){
82  if(!mHits) return NULL;
83  return (StMuFcsHit*) mHits->At(index);
84 }
85 
86 StMuFcsCluster* StMuFcsCollection::getCluster(int index) {
87  if (!mClusters) return NULL;
88  return static_cast<StMuFcsCluster*>(mClusters->At(index));
89 }
90 
91 StMuFcsPoint* StMuFcsCollection::getPoint(int index) {
92  if (!mPoints) return NULL;
93  return static_cast<StMuFcsPoint*>(mPoints->At(index));
94 }
95 
96 StMuFcsInfo* StMuFcsCollection::getInfo() {
97  if (!mInfo) return NULL;
98  return static_cast<StMuFcsInfo*>(mInfo->At(0));
99 }
100 
101 Int_t StMuFcsCollection::fcsReconstructionFlag() {
102  return getInfo()->fcsReconstructionFlag();
103 }
104 void StMuFcsCollection::setFcsReconstructionFlag(Int_t v){
105  getInfo()->setFcsReconstructionFlag(v);
106 }
107 
108 unsigned int StMuFcsCollection::indexOfFirstHit( unsigned int idet ){
109  return getInfo()->hitIndex(idet);
110 }
111 
112 unsigned int StMuFcsCollection::indexOfFirstCluster( unsigned int idet ){
113  return getInfo()->clusterIndex(idet);
114 }
115 
116 unsigned int StMuFcsCollection::indexOfFirstPoint( unsigned int idet ){
117  return getInfo()->pointIndex(idet);
118 }
119 
120 unsigned int StMuFcsCollection::numberOfHits( unsigned int idet ){
121  return (getInfo()->hitIndex(idet+1) - getInfo()->hitIndex(idet));
122 }
123 
124 unsigned int StMuFcsCollection::numberOfClusters( unsigned int idet ){
125  return (getInfo()->clusterIndex(idet+1) - getInfo()->clusterIndex(idet));
126 }
127 
128 unsigned int StMuFcsCollection::numberOfPoints( unsigned int idet ){
129  return (getInfo()->pointIndex(idet+1) - getInfo()->pointIndex(idet));
130 }