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