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 #include "StPhmdDetector.h"
00027 #include "StPhmdHit.h"
00028 #include "StPhmdModule.h"
00029 #include "StPhmdClusterCollection.h"
00030
00031
00032 ClassImp(StPhmdDetector)
00033
00034 StPhmdDetector::StPhmdDetector()
00035 {
00036 mDetectorId = kUnknownId;
00037 memset(mModulesNHit,0,sizeof(mModulesNHit));
00038 memset(mModules ,0,sizeof(mModules ));
00039 mClusters = 0;
00040 }
00041
00042 StPhmdDetector::StPhmdDetector(StDetectorId id)
00043 {
00044 mDetectorId = id;
00045 memset(mModulesNHit,0,sizeof(mModulesNHit));
00046 memset(mModules ,0,sizeof(mModules ));
00047 mClusters = 0;
00048 for (int i=0; i<mMaxModules; i++)
00049 this->setModule(new StPhmdModule(), i);
00050 }
00051
00052 StPhmdDetector::~StPhmdDetector()
00053 {
00054 for (int i=0; i<mMaxModules; i++) delete mModules[i];
00055 memset(mModules ,0,sizeof(mModules ));
00056 delete mClusters; mClusters = 0;
00057 }
00058
00059 bool
00060 StPhmdDetector::addHit(StPhmdHit* hit)
00061 {
00062 if (hit) {
00063 unsigned int m = static_cast<unsigned int>(hit->module());
00064 if (m <= mMaxModules) {
00065 mModules[m]->hits().push_back(hit);
00066 mModulesNHit[m]++;
00067 return true;
00068 }
00069 }
00070 return false;
00071 }
00072
00073 int
00074 StPhmdDetector::moduleHits(unsigned int i)
00075 {
00076 if (i <= mMaxModules)
00077 return mModulesNHit[i];
00078 else
00079 return 0;
00080 }
00081
00082 unsigned int
00083 StPhmdDetector::numberOfModules() const { return mMaxModules; }
00084
00085 unsigned int
00086 StPhmdDetector::numberOfHits() const
00087 {
00088 unsigned int sum = 0;
00089 return sum;
00090 }
00091
00092 StPhmdModule*
00093 StPhmdDetector::module(unsigned int i)
00094 {
00095 if (i < mMaxModules)
00096 return (mModules[i]);
00097 else
00098 return 0;
00099 }
00100
00101 const StPhmdModule*
00102 StPhmdDetector::module(unsigned int i) const
00103 {
00104 if (i < mMaxModules)
00105 return (mModules[i]);
00106 else
00107 return 0;
00108 }
00109
00110 void
00111 StPhmdDetector::setModule(StPhmdModule* val, unsigned int IdMod)
00112 {
00113 if (val) {
00114 if (IdMod < mMaxModules) {
00115 if (mModules[IdMod]) delete mModules[IdMod];
00116 mModules[IdMod] = val;
00117 }
00118 }
00119 }
00120
00121 StPhmdClusterCollection*
00122 StPhmdDetector::cluster() {return mClusters;}
00123
00124 const StPhmdClusterCollection*
00125 StPhmdDetector::cluster() const {return mClusters;}
00126
00127 void
00128 StPhmdDetector::setCluster(StPhmdClusterCollection* val)
00129 {
00130 if (mClusters) delete mClusters;
00131 mClusters = val;
00132 }
00133
00134 ostream& operator<<(ostream& os, const StPhmdHit& h)
00135 {
00136 os << "super=" << h.superModule();
00137 os << "\tsubDetector=" << h.subDetector();
00138 os << "\trow=" << h.row();
00139 os << "\tcolumn=" << h.column();
00140 os << "\tedep=" << h.energy();
00141 return os;
00142 }