50 #include "StEmcDetector.h"
51 #include "StEmcRawHit.h"
52 #include "StEmcModule.h"
53 #include "StEmcClusterCollection.h"
56 static const char rcsid[] =
"$Id: StEmcDetector.cxx,v 2.12 2004/10/14 20:00:18 ullrich Exp $";
62 StEmcDetector::StEmcDetector(StDetectorId
id,
unsigned int n)
67 for(
int i=0; i<120;i++) {
74 StEmcDetector::~StEmcDetector()
76 for(
int i=0; i<120;i++)
if(mModules[i])
delete mModules[i];
77 if (mClusters)
delete mClusters;
81 StEmcDetector::clear()
83 for(
int i=0; i<120;i++) mModules[i] = 0;
85 for(
int i=0; i<mMaxNumberOfCrates; i++)
86 mCrateStatusFlag[i] = crateUnknown;
94 unsigned int m = hit->module();
95 if (m > 0 && m <= mNumberOfModules) {
96 mModules[m-1]->hits().push_back(hit);
104 StEmcDetector::detectorId()
const {
return mDetectorId; }
107 StEmcDetector::numberOfModules()
const {
return mNumberOfModules; }
110 StEmcDetector::numberOfHits()
const
112 unsigned int sum = 0;
113 for (
unsigned int m=0;m<mNumberOfModules;m++) sum+= mModules[m]->hits().size();
118 StEmcDetector::printNumberOfHits()
const
120 printf(
" Detector %i : nhits %i\n",
int(mDetectorId), numberOfHits());
125 StEmcDetector::getEnergy(
const int pri)
const
127 float e = 0., eM = 0.;
128 for (
unsigned int m=0;m<mNumberOfModules;m++) {
129 if(mModules[m]->numberOfHits()==0)
continue;
130 eM = mModules[m]->getEnergy();
133 if(eM !=0 ) printf(
"%3i(m) : e %9.4f ", m+1, eM);
134 if(eM < 0.) printf(
" !!");
139 if(pri>0) printf(
"det %i : energy %9.4f GeV/c \n",
int(mDetectorId), e);
145 StEmcDetector::module(
unsigned int i)
147 if (i > 0 && i <= mNumberOfModules)
return (mModules[i-1]);
152 StEmcDetector::module(
unsigned int i)
const
154 if (i > 0 && i <= mNumberOfModules)
return (mModules[i-1]);
159 StEmcDetector::cluster() {
return mClusters;}
162 StEmcDetector::cluster()
const {
return mClusters;}
164 StEmcCrateStatus StEmcDetector::crateStatus(
int crate)
const {
165 if (crate > 0 && crate <= mMaxNumberOfCrates)
166 return mCrateStatusFlag[crate-1];
174 if (mClusters)
delete mClusters;
179 StEmcDetector::setModule(
StEmcModule* val,
int IdMod)
182 if (IdMod >= 0 && IdMod < static_cast<int>(mNumberOfModules)) {
183 if (mModules[IdMod])
delete mModules[IdMod];
184 mModules[IdMod] = val;
189 void StEmcDetector::setCrateStatus(
int crate, StEmcCrateStatus flag) {
190 if (crate > 0 && crate <= mMaxNumberOfCrates)
191 mCrateStatusFlag[crate-1] = flag;
194 bool StEmcDetector::IsFolder()
const
196 if(numberOfHits())
return true;