StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StSsdCluster.cc
1 // $Id: StSsdCluster.cc,v 1.1 2006/10/16 16:43:29 bouchet Exp $
2 //
3 // $Log: StSsdCluster.cc,v $
4 // Revision 1.1 2006/10/16 16:43:29 bouchet
5 // StSsdUtil regroups now methods for the classes StSsdStrip, StSsdCluster and StSsdPoint
6 //
7 // Revision 1.5 2005/04/25 14:13:23 bouchet
8 // new method makeScfCtrlHistograms and makeScmCtrlHistograms and Clusternoise is coded as a float
9 //
10 // Revision 1.4 2005/03/18 14:24:21 lmartin
11 // missing CVS header added
12 //
13 
14 #include "StSsdUtil/StSsdCluster.hh"
15 
16 StSsdCluster::StSsdCluster(Int_t rNCluster)
17 {
18  mNCluster = rNCluster;
19  mFirstStrip = 769;
20  mClusterSize = 0;
21  mTotAdc = 0;
22  mFirstAdc = 0;
23  mLastAdc = 0;
24  mTotNoise = 0;
25  mStripMean = 0;
26  mFlag = 0;
27  mIdMcHit = new int[SSD_MAXIDMCHIT];
28  for(Int_t e=0;e<SSD_MAXIDMCHIT;e++) mIdMcHit[e] = 0;
29  mPrevCluster = 0;
30  mNextCluster = 0;
31 }
32 
33 StSsdCluster::StSsdCluster(Int_t rNCluster, Int_t rFirstStrip, Int_t rClusterSize, Int_t rTotAdc, Int_t rFirstAdc, Int_t rLastAdc, Float_t rTotNoise, Float_t rStripMean, Int_t rFlag, Int_t *rIdMcHit)
34 {
35  mNCluster = rNCluster;
36  mFirstStrip = rFirstStrip;
37  mClusterSize = rClusterSize;
38  mTotAdc = rTotAdc;
39  mFirstAdc = rFirstAdc;
40  mLastAdc = rLastAdc;
41  mTotNoise = rTotNoise;
42  mStripMean = rStripMean;
43  mFlag = rFlag;
44  mIdMcHit = new int[SSD_MAXIDMCHIT];
45  for(Int_t e=0;e<SSD_MAXIDMCHIT;e++) mIdMcHit[e] = rIdMcHit[e];
46  mPrevCluster = 0;
47  mNextCluster = 0;
48 }
49 
50 StSsdCluster::StSsdCluster(const StSsdCluster & originalCluster)
51 {
52  mNCluster = originalCluster.mNCluster;
53  mFirstStrip = originalCluster.mFirstStrip;
54  mClusterSize = originalCluster.mClusterSize;
55  mTotAdc = originalCluster.mTotAdc;
56  mFirstAdc = originalCluster.mFirstAdc;
57  mLastAdc = originalCluster.mLastAdc;
58  mTotNoise = originalCluster.mTotNoise;
59  mStripMean = originalCluster.mStripMean;
60  mFlag = originalCluster.mFlag;
61  mIdMcHit = new int[SSD_MAXIDMCHIT];
62  for(Int_t e=0;e<SSD_MAXIDMCHIT;e++) mIdMcHit[e] = originalCluster.mIdMcHit[e];
63  mPrevCluster = originalCluster.mPrevCluster;
64  mNextCluster = originalCluster.mNextCluster;
65 }
66 
67 StSsdCluster::~StSsdCluster()
68 { delete [] mIdMcHit; }
69 
70 StSsdCluster& StSsdCluster::operator=(const StSsdCluster originalCluster)
71 {
72  mNCluster = originalCluster.mNCluster;
73  mFirstStrip = originalCluster.mFirstStrip;
74  mClusterSize = originalCluster.mClusterSize;
75  mTotAdc = originalCluster.mTotAdc;
76  mFirstAdc = originalCluster.mFirstAdc;
77  mLastAdc = originalCluster.mLastAdc;
78  mTotNoise = originalCluster.mTotNoise;
79  mStripMean = originalCluster.mStripMean;
80  mFlag = originalCluster.mFlag;
81  for(Int_t e=0;e<SSD_MAXIDMCHIT;e++) mIdMcHit[e] = originalCluster.mIdMcHit[e];
82  mPrevCluster = originalCluster.mPrevCluster;
83  mNextCluster = originalCluster.mNextCluster;
84  return *this;
85 }
86 
87 void StSsdCluster::setNCluster(Int_t rNCluster)
88 { mNCluster = rNCluster;}
89 
90 void StSsdCluster::setFirstStrip(Int_t rFirstStrip)
91 { mFirstStrip = rFirstStrip;}
92 
93 void StSsdCluster::setClusterSize(Int_t rClusterSize)
94 { mClusterSize = rClusterSize;}
95 
96 void StSsdCluster::setTotAdc(Int_t rTotAdc)
97 { mTotAdc = rTotAdc;}
98 
99 void StSsdCluster::setFirstAdc(Int_t rFirstAdc)
100 { mFirstAdc = rFirstAdc;}
101 
102 void StSsdCluster::setLastAdc(Int_t rLastAdc)
103 { mLastAdc = rLastAdc;}
104 
105 void StSsdCluster::setTotNoise(Float_t rTotNoise)
106 { mTotNoise = rTotNoise;}
107 
108 void StSsdCluster::setStripMean(Float_t rStripMean)
109 { mStripMean = rStripMean;}
110 
111 void StSsdCluster::setFlag(Int_t rFlag)
112 { mFlag = rFlag;}
113 
114 void StSsdCluster::setIdMcHit(Int_t rIdMcHit, Int_t iR)
115 { mIdMcHit[iR] = rIdMcHit; }
116 
117 void StSsdCluster::setPrevCluster(StSsdCluster *rPrevCluster)
118 { mPrevCluster = rPrevCluster;}
119 
120 void StSsdCluster::setNextCluster(StSsdCluster *rNextCluster)
121 { mNextCluster = rNextCluster;}
122 
123 
124 Int_t StSsdCluster::getNCluster()
125 { return mNCluster;}
126 
127 Int_t StSsdCluster::getFirstStrip()
128 { return mFirstStrip;}
129 
130 Int_t StSsdCluster::getClusterSize()
131 { return mClusterSize;}
132 
133 Int_t StSsdCluster::getTotAdc()
134 { return mTotAdc;}
135 
136 Int_t StSsdCluster::getFirstAdc()
137 { return mFirstAdc;}
138 
139 Int_t StSsdCluster::getLastAdc()
140 { return mLastAdc;}
141 
142 Float_t StSsdCluster::getTotNoise()
143 { return mTotNoise;}
144 
145 Float_t StSsdCluster::getStripMean()
146 { return mStripMean;}
147 
148 Int_t StSsdCluster::getFlag()
149 { return mFlag;}
150 
151 Int_t StSsdCluster::getIdMcHit(Int_t iR)
152 { return mIdMcHit[iR]; }
153 
154 StSsdCluster* StSsdCluster::getPrevCluster()
155 { return mPrevCluster;}
156 
157 StSsdCluster* StSsdCluster::getNextCluster()
158 { return mNextCluster;}
159 
160 StSsdCluster* StSsdCluster::giveCopy()
161 {
162  StSsdCluster *ptrClone = new StSsdCluster(this->mNCluster);
163  ptrClone->mFirstStrip = this->mFirstStrip;
164  ptrClone->mClusterSize = this->mClusterSize;
165  ptrClone->mTotAdc = this->mTotAdc;
166  ptrClone->mFirstAdc = this->mFirstAdc;
167  ptrClone->mLastAdc = this->mLastAdc;
168  ptrClone->mTotNoise = this->mTotNoise;
169  ptrClone->mStripMean = this->mStripMean;
170  ptrClone->mFlag = this->mFlag;
171  for(Int_t e=0;e<SSD_MAXIDMCHIT;e++) ptrClone->mIdMcHit[e] = this->mIdMcHit[e];
172  return ptrClone;
173 }
174 
175 void StSsdCluster::copyTo(StSsdCluster *ptrClone)
176 {
177  ptrClone->mFirstStrip = this->mFirstStrip;
178  ptrClone->mClusterSize = this->mClusterSize;
179  ptrClone->mFlag = this->mFlag;
180  ptrClone->mTotAdc = this->mTotAdc;
181  ptrClone->mFirstAdc = this->mFirstAdc;
182  ptrClone->mLastAdc = this->mLastAdc;
183  ptrClone->mTotNoise = this->mTotNoise;
184  ptrClone->mStripMean = this->mStripMean;
185  for(Int_t e=0;e<SSD_MAXIDMCHIT;e++) ptrClone->mIdMcHit[e] = this->mIdMcHit[e];
186 }
187 
188 
189 void StSsdCluster::update(StSsdStrip *ptr,Float_t rWeight)
190 {
191  Int_t tmpTotAdc = this->mTotAdc;
192  this->mTotAdc += (int)(ptr->getDigitSig()*rWeight);
193  this->mTotNoise += (ptr->getSigma()*rWeight);
194  if(ptr->getNStrip()<this->mFirstStrip)
195  {
196  this->mFirstStrip = ptr->getNStrip();
197  this->mFirstAdc = (int)(ptr->getDigitSig()*rWeight);
198  }
199  if(ptr->getNStrip()>=(this->mFirstStrip+this->mClusterSize))
200  {
201  this->mLastAdc = (int)(ptr->getDigitSig()*rWeight);
202  }
203  this->mStripMean = (tmpTotAdc*this->mStripMean+ptr->getNStrip()*(int)(ptr->getDigitSig()*rWeight))/mTotAdc;
204 
205 
206  // for evaluation only...
207  Int_t a = 0;
208  Int_t b = 0;
209  Int_t c = 0;
210  Int_t flag = 1;
211  while((a<SSD_MAXIDMCHIT)&&(this->getIdMcHit(a)!=0)) a++;
212  while((b<SSD_MAXIDMCHIT)&&(a<SSD_MAXIDMCHIT)&&(ptr->getIdMcHit(b)!=0))
213  {
214  flag = 1;
215  for(c=0;c<SSD_MAXIDMCHIT-a;c++)
216  {if(this->getIdMcHit(c)==ptr->getIdMcHit(b)) flag=0;}
217  if(flag)
218  {
219  this->setIdMcHit(ptr->getIdMcHit(b),a);
220  a++;
221  }
222  b++;
223  }
224  this->mClusterSize++;
225  return;
226 }
227