37 #include "StMuPmdCollection.h"
39 #include "StMuPmdUtil.h"
40 #include "StMuPmdCluster.h"
41 #include "StMuPmdHit.h"
47 for(
int i=0;i<2;i++) {
53 StMuPmdCollection::StMuPmdCollection(StMuPmdCollection& o) {
54 for (
int i=0; i<2; i++) {
55 mPmdClusters[i] = (TClonesArray*)o.mPmdClusters[i]->Clone();
56 mPmdHits[i] = (TClonesArray*)o.mPmdHits[i]->Clone();
60 void StMuPmdCollection::init(
int detector)
62 mPmdClusters[detector - pmd] =
new TClonesArray(
"StMuPmdCluster",0);
63 mPmdHits[detector - pmd] =
new TClonesArray(
"StMuPmdHit",0);
66 StMuPmdCollection::~StMuPmdCollection()
68 delete mPmdClusters[0];mPmdClusters[0]=0;
69 delete mPmdClusters[1];mPmdClusters[1]=0;
72 delete mPmdHits[0];mPmdHits[0]=0;
73 delete mPmdHits[1];mPmdHits[1]=0;
76 void StMuPmdCollection::DeleteThis()
78 for (
int i=0; i<2; i++) mPmdClusters[i]->Delete();
79 for (
int i=0; i<2; i++) mPmdHits[i]->Delete();
82 void StMuPmdCollection::clear(Option_t *option)
84 mPmdClusters[0]->Delete();
85 mPmdClusters[1]->Delete();
87 mPmdHits[0]->Delete();
88 mPmdHits[1]->Delete();
92 int StMuPmdCollection::getNClusters(
int detector)
94 if(detector<pmd || detector>cpv)
return 0;
95 TClonesArray *tca =NULL;
96 if(detector>=pmd && detector <= cpv) tca = mPmdClusters[detector-pmd];
100 return tca->GetEntriesFast();
107 int StMuPmdCollection::getNHits(
int detector)
109 if(detector<pmd || detector>cpv)
return 0;
110 TClonesArray *tca =NULL;
111 if(detector>=pmd && detector <= cpv) tca = mPmdHits[detector-pmd];
115 return tca->GetEntriesFast();
122 StMuPmdCluster* StMuPmdCollection::getCluster(
int clusterId,
int detector)
124 if(detector<pmd || detector>cpv)
return NULL;
125 TClonesArray *tca = NULL;
126 if(detector>=pmd && detector <= cpv) tca = mPmdClusters[detector-pmd];
127 int counter = tca->GetEntriesFast();
128 if(clusterId<0 || clusterId>counter)
return NULL;
132 StMuPmdHit* StMuPmdCollection::getHit(
int hitId,
int detector)
134 if(detector<pmd || detector>cpv)
return NULL;
135 TClonesArray *tca = NULL;
136 if(detector>=pmd && detector <= cpv) tca = mPmdHits[detector-pmd];
137 int counter = tca->GetEntriesFast();
138 if(hitId<0 || hitId>counter)
return NULL;
141 void StMuPmdCollection::addCluster(
int detector)
143 if(detector<pmd || detector>cpv)
return;
144 TClonesArray *tca =NULL;
145 if(detector>=pmd && detector <= cpv) tca = mPmdClusters[detector-pmd];
148 if(mPmdClusters[detector -pmd] == NULL){
150 tca = mPmdClusters[detector-pmd];
152 if(tca) counter=tca->GetEntriesFast();
159 void StMuPmdCollection::addHit(
int detector)
161 if(detector<pmd || detector>cpv)
return;
162 TClonesArray *tca =NULL;
163 if(detector>=pmd && detector <= cpv) tca = mPmdHits[detector-pmd];
166 if(mPmdHits[detector -pmd] == NULL){
168 tca = mPmdHits[detector-pmd];
170 if(tca) counter=tca->GetEntriesFast();