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
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #include "StEmcDetector.h"
00051 #include "StEmcRawHit.h"
00052 #include "StEmcModule.h"
00053 #include "StEmcClusterCollection.h"
00054 #include <TBrowser.h>
00055 #include <StAutoBrowse.h>
00056
00057 static const char rcsid[] = "$Id: StEmcDetector.cxx,v 2.12 2004/10/14 20:00:18 ullrich Exp $";
00058
00059 ClassImp(StEmcDetector)
00060
00061 StEmcDetector::StEmcDetector() { clear(); }
00062
00063 StEmcDetector::StEmcDetector(StDetectorId id, unsigned int n)
00064 {
00065 clear();
00066 mDetectorId = id;
00067 mNumberOfModules = n;
00068 for(int i=0; i<120;i++) {
00069 mModules[i] = new StEmcModule();
00070
00071
00072 }
00073 }
00074
00075 StEmcDetector::~StEmcDetector()
00076 {
00077 for(int i=0; i<120;i++) if(mModules[i]) delete mModules[i];
00078 if (mClusters) delete mClusters;
00079 }
00080
00081 void
00082 StEmcDetector::clear()
00083 {
00084 for(int i=0; i<120;i++) mModules[i] = 0;
00085 mClusters = 0;
00086 for(int i=0; i<mMaxNumberOfCrates; i++)
00087 mCrateStatusFlag[i] = crateUnknown;
00088 }
00089
00090
00091 bool
00092 StEmcDetector::addHit(StEmcRawHit* hit)
00093 {
00094 if (hit) {
00095 unsigned int m = hit->module();
00096 if (m > 0 && m <= mNumberOfModules) {
00097 mModules[m-1]->hits().push_back(hit);
00098 return true;
00099 }
00100 }
00101 return false;
00102 }
00103
00104 StDetectorId
00105 StEmcDetector::detectorId() const { return mDetectorId; }
00106
00107 unsigned int
00108 StEmcDetector::numberOfModules() const { return mNumberOfModules; }
00109
00110 unsigned int
00111 StEmcDetector::numberOfHits() const
00112 {
00113 unsigned int sum = 0;
00114 for (unsigned int m=0;m<mNumberOfModules;m++) sum+= mModules[m]->hits().size();
00115 return sum;
00116 }
00117
00118 void
00119 StEmcDetector::printNumberOfHits() const
00120 {
00121 printf(" Detector %i : nhits %i\n", int(mDetectorId), numberOfHits());
00122 return;
00123 }
00124
00125 double
00126 StEmcDetector::getEnergy(const int pri) const
00127 {
00128 float e = 0., eM = 0.;
00129 for (unsigned int m=0;m<mNumberOfModules;m++) {
00130 if(mModules[m]->numberOfHits()==0) continue;
00131 eM = mModules[m]->getEnergy();
00132 e += eM;
00133 if(pri>1) {
00134 if(eM !=0 ) printf("%3i(m) : e %9.4f ", m+1, eM);
00135 if(eM < 0.) printf(" !!");
00136 printf("\n");
00137 }
00138 }
00139
00140 if(pri>0) printf("det %i : energy %9.4f GeV/c \n", int(mDetectorId), e);
00141
00142 return e;
00143 }
00144
00145 StEmcModule*
00146 StEmcDetector::module(unsigned int i)
00147 {
00148 if (i > 0 && i <= mNumberOfModules) return (mModules[i-1]);
00149 else return 0;
00150 }
00151
00152 const StEmcModule*
00153 StEmcDetector::module(unsigned int i) const
00154 {
00155 if (i > 0 && i <= mNumberOfModules) return (mModules[i-1]);
00156 else return 0;
00157 }
00158
00159 StEmcClusterCollection*
00160 StEmcDetector::cluster() {return mClusters;}
00161
00162 const StEmcClusterCollection*
00163 StEmcDetector::cluster() const {return mClusters;}
00164
00165 StEmcCrateStatus StEmcDetector::crateStatus(int crate) const {
00166 if (crate > 0 && crate <= mMaxNumberOfCrates)
00167 return mCrateStatusFlag[crate-1];
00168 else
00169 return crateUnknown;
00170 }
00171
00172 void
00173 StEmcDetector::setCluster(StEmcClusterCollection* val)
00174 {
00175 if (mClusters) delete mClusters;
00176 mClusters = val;
00177 }
00178
00179 void
00180 StEmcDetector::setModule(StEmcModule* val,int IdMod)
00181 {
00182 if (val) {
00183 if (IdMod >= 0 && IdMod < static_cast<int>(mNumberOfModules)) {
00184 if (mModules[IdMod]) delete mModules[IdMod];
00185 mModules[IdMod] = val;
00186 }
00187 }
00188 }
00189
00190 void StEmcDetector::setCrateStatus(int crate, StEmcCrateStatus flag) {
00191 if (crate > 0 && crate <= mMaxNumberOfCrates)
00192 mCrateStatusFlag[crate-1] = flag;
00193 }
00194
00195 bool StEmcDetector::IsFolder() const
00196 {
00197 if(numberOfHits()) return true;
00198 else return false;
00199 }
00200
00201 void
00202 StEmcDetector::Browse(TBrowser *b)
00203 {
00204 char name[10];
00205 for (unsigned int m=0;m<mNumberOfModules;m++) {
00206 if(mModules[m]->IsFolder()) {
00207
00208
00209
00210 sprintf(name,"Module%3.3i",m+1);
00211 b->Add(mModules[m],name);
00212 }
00213 }
00214 StAutoBrowse::Browse(mClusters, b);
00215 }