00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <assert.h>
00032 #include <string.h>
00033
00034 #include "StMuPmdCollection.h"
00035 #include "Stiostream.h"
00036 #include "StMuPmdUtil.h"
00037 #include "StMuPmdCluster.h"
00038 #include "StMuPmdHit.h"
00039 static StMuPmdUtil util;
00040 ClassImp(StMuPmdCollection)
00041
00042 StMuPmdCollection::StMuPmdCollection()
00043 {
00044 for(int i=0;i<2;i++) {
00045 mPmdHits[i] = 0;
00046 mPmdClusters[i] = 0;
00047 }
00048 }
00049
00050 StMuPmdCollection::StMuPmdCollection(StMuPmdCollection& o) {
00051 for ( int i=0; i<2; i++) {
00052 mPmdClusters[i] = (TClonesArray*)o.mPmdClusters[i]->Clone();
00053 mPmdHits[i] = (TClonesArray*)o.mPmdHits[i]->Clone();
00054 }
00055 }
00056
00057 void StMuPmdCollection::init(int detector)
00058 {
00059 mPmdClusters[detector - pmd] = new TClonesArray("StMuPmdCluster",0);
00060 mPmdHits[detector - pmd] = new TClonesArray("StMuPmdHit",0);
00061 }
00062
00063 StMuPmdCollection::~StMuPmdCollection()
00064 {
00065 delete mPmdClusters[0];mPmdClusters[0]=0;
00066 delete mPmdClusters[1];mPmdClusters[1]=0;
00067
00068
00069 delete mPmdHits[0];mPmdHits[0]=0;
00070 delete mPmdHits[1];mPmdHits[1]=0;
00071 }
00072
00073 void StMuPmdCollection::DeleteThis()
00074 {
00075 for ( int i=0; i<2; i++) mPmdClusters[i]->Delete();
00076 for ( int i=0; i<2; i++) mPmdHits[i]->Delete();
00077 }
00078
00079 void StMuPmdCollection::clear(Option_t *option)
00080 {
00081 mPmdClusters[0]->Delete();
00082 mPmdClusters[1]->Delete();
00083
00084 mPmdHits[0]->Delete();
00085 mPmdHits[1]->Delete();
00086 return;
00087 }
00088
00089 int StMuPmdCollection::getNClusters(int detector)
00090 {
00091 if(detector<pmd || detector>cpv) return 0;
00092 TClonesArray *tca =NULL;
00093 if(detector>=pmd && detector <= cpv) tca = mPmdClusters[detector-pmd];
00094
00095 if (tca) {
00096
00097 return tca->GetEntries();
00098 } else {
00099
00100 return 0;
00101 }
00102 }
00103
00104 int StMuPmdCollection::getNHits(int detector)
00105 {
00106 if(detector<pmd || detector>cpv) return 0;
00107 TClonesArray *tca =NULL;
00108 if(detector>=pmd && detector <= cpv) tca = mPmdHits[detector-pmd];
00109
00110 if (tca) {
00111
00112 return tca->GetEntries();
00113 } else {
00114
00115 return 0;
00116 }
00117 }
00118
00119 StMuPmdCluster* StMuPmdCollection::getCluster(int clusterId,int detector)
00120 {
00121 if(detector<pmd || detector>cpv) return NULL;
00122 TClonesArray *tca = NULL;
00123 if(detector>=pmd && detector <= cpv) tca = mPmdClusters[detector-pmd];
00124 int counter = tca->GetEntriesFast();
00125 if(clusterId<0 || clusterId>counter) return NULL;
00126 return (StMuPmdCluster*)tca->At(clusterId);
00127 }
00128
00129 StMuPmdHit* StMuPmdCollection::getHit(int hitId,int detector)
00130 {
00131 if(detector<pmd || detector>cpv) return NULL;
00132 TClonesArray *tca = NULL;
00133 if(detector>=pmd && detector <= cpv) tca = mPmdHits[detector-pmd];
00134 int counter = tca->GetEntriesFast();
00135 if(hitId<0 || hitId>counter) return NULL;
00136 return (StMuPmdHit*)tca->At(hitId);
00137 }
00138 void StMuPmdCollection::addCluster(int detector)
00139 {
00140 if(detector<pmd || detector>cpv) return;
00141 TClonesArray *tca =NULL;
00142 if(detector>=pmd && detector <= cpv) tca = mPmdClusters[detector-pmd];
00143
00144 int counter =0;
00145 if(mPmdClusters[detector -pmd] == NULL){
00146 init(detector);
00147 tca = mPmdClusters[detector-pmd];
00148 }
00149 if(tca) counter=tca->GetEntriesFast();
00150
00151 new ((*tca)[counter]) StMuPmdCluster();
00152
00153 return;
00154 }
00155
00156 void StMuPmdCollection::addHit(int detector)
00157 {
00158 if(detector<pmd || detector>cpv) return;
00159 TClonesArray *tca =NULL;
00160 if(detector>=pmd && detector <= cpv) tca = mPmdHits[detector-pmd];
00161
00162 int counter =0;
00163 if(mPmdHits[detector -pmd] == NULL){
00164 init(detector);
00165 tca = mPmdHits[detector-pmd];
00166 }
00167 if(tca) counter=tca->GetEntriesFast();
00168
00169 new ((*tca)[counter]) StMuPmdHit();
00170
00171 return;
00172 }