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 #include "StPmdDetector.h"
00029 #include "StPmdHit.h"
00030 #include "StPmdModule.h"
00031 #include "StPmdClusterCollection.h"
00032
00033
00034 ClassImp(StPmdDetector)
00035
00036 StPmdDetector::StPmdDetector()
00037 {
00038 mDetectorId=0;
00039 mNumberOfModules=0;
00040
00041 memset(mModules_NHit,0,sizeof(mModules_NHit));
00042 memset(mModules ,0,sizeof(mModules ));
00043 mClusters=0;
00044 }
00045
00046 StPmdDetector::StPmdDetector(Int_t id, unsigned int n)
00047 {
00048 mClusters = 0;
00049 mDetectorId = id;
00050 mNumberOfModules = n;
00051 memset(mModules_NHit,0,sizeof(mModules_NHit));
00052 memset(mModules ,0,sizeof(mModules ));
00053 for(int i=0; i<12;i++)
00054 {
00055 StPmdModule * module = new StPmdModule();
00056 setModule(module,i);
00057 }
00058
00059 }
00060
00061 StPmdDetector::~StPmdDetector()
00062 {
00063 for(int i=0; i<12;i++) delete mModules[i];
00064 delete mClusters; mClusters=0;
00065 }
00066
00067 bool
00068 StPmdDetector::addHit(StPmdHit* hit)
00069 {
00070 if (hit){
00071 Int_t m = hit->module();
00072 if (m > 0 && m <= 12)
00073 {
00074 mModules[m-1]->Hits()->Add(hit);
00075 mModules_NHit[m-1]++;
00076 return kTRUE;
00077 }
00078 }
00079 return kFALSE;
00080 }
00081
00082 Int_t
00083 StPmdDetector::module_hit(Int_t i) {
00084 if (i > 0 && i <= 12) {
00085 return mModules_NHit[i-1]; }
00086 else return 0;
00087 }
00088
00089 unsigned int
00090 StPmdDetector::numberOfModules() const { return mNumberOfModules; }
00091
00092 unsigned int
00093 StPmdDetector::numberOfHits() const
00094 {
00095 unsigned int sum = 0;
00096 for(Int_t i=0;i<12;i++){
00097
00098 sum=sum+mModules_NHit[i];
00099 }
00100 return sum;
00101 }
00102
00103 StPmdModule*
00104 StPmdDetector::module(unsigned int i)
00105 {
00106 if (i > 0 && i <= 12) return (mModules[i-1]);
00107 else return 0;
00108 }
00109
00110 void
00111 StPmdDetector::setModule(StPmdModule* val,int IdMod)
00112 {
00113 if (val)
00114 {
00115 if (IdMod >= 0 && IdMod < static_cast<int>(mNumberOfModules))
00116 {
00117 mModules_NHit[IdMod]=0;
00118 delete mModules[IdMod];
00119 mModules[IdMod] = val;
00120 }
00121 }
00122 }
00123
00124 StPmdClusterCollection*
00125 StPmdDetector::cluster() {return mClusters;}
00126
00127 void
00128 StPmdDetector::setCluster(StPmdClusterCollection* val)
00129 {
00130
00131 delete mClusters;
00132 mClusters = val;
00133 }
00134