StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StIstSimpleClusterAlgo.cxx
1 #include "StEvent/StEvent.h"
2 #include "StMessMgr.h"
3 #include "StIstClusterMaker/StIstSimpleClusterAlgo.h"
4 #include "StIstUtil/StIstCollection.h"
5 #include "StIstUtil/StIstRawHitCollection.h"
6 #include "StIstUtil/StIstRawHit.h"
7 #include "StIstUtil/StIstClusterCollection.h"
8 #include "StIstUtil/StIstCluster.h"
9 #include "StIstUtil/StIstConsts.h"
10 
11 #include <math.h>
12 #include <iostream>
13 #include <iterator>
14 #include <vector>
15 
16 
17 Int_t StIstSimpleClusterAlgo::splitCluster(int cSize, int clusterSizeList[], StIstRawHit *rawHitPtr[], StIstCluster *clusterIt, StIstClusterCollection &clusters, unsigned char numTimeBins)
18 {
19  StIstRawHit *rawHitPtr0 = 0;
20  StIstRawHit *rawHitPtr1 = 0;
21  StIstRawHit *rawHitPtr2 = 0;
22  StIstRawHit *rawHitPtr3 = 0;
23 
24  StIstCluster *newClusterTmp = 0;
25 
26  unsigned char maxTb = UCHAR_MAX;
27  unsigned char ladder = 0, sensor = 0;
28  float meanRow = 0, meanColumn = 0;
29  float totCharge = 0., totChargeErr = 0.;
30  unsigned char clusterSize = 0; unsigned char clusterSizeRPhi = 0;
31  unsigned char clusterSizeZ = 0;
32  unsigned char clusterType = kIstSimpleClusterAlgo;
33 
34  float weightSplit = 0., weightSplit2 = 0., tmpSumChargeSplit = 0.;
35 
36  //split cluster w/ size = 3
37  if (cSize == 3) {
38  rawHitPtr0 = rawHitPtr[0];
39  rawHitPtr1 = rawHitPtr[1];
40  rawHitPtr2 = rawHitPtr[2];
41 
42  unsigned char tmpRawHitMaxTb0, tmpRawHitMaxTb1, tmpRawHitMaxTb2;
43 
44  if (mTimeBin < numTimeBins) {
45  tmpRawHitMaxTb0 = tmpRawHitMaxTb1 = tmpRawHitMaxTb2 = mTimeBin;
46  }
47  else {
48  tmpRawHitMaxTb0 = tmpRawHitMaxTb1 = tmpRawHitMaxTb2 = clusterIt->getMaxTimeBin();
49  }
50 
51  float tmpRawHitMaxCharge0 = rawHitPtr0->getCharge(tmpRawHitMaxTb0);
52  float tmpRawHitMaxCharge1 = rawHitPtr1->getCharge(tmpRawHitMaxTb1);
53  float tmpRawHitMaxCharge2 = rawHitPtr2->getCharge(tmpRawHitMaxTb2);
54 
55  //cluster spliting: raw hit 0 + part of raw hit 1
56  tmpSumChargeSplit = tmpRawHitMaxCharge0 + tmpRawHitMaxCharge1 * tmpRawHitMaxCharge0 / (tmpRawHitMaxCharge0 + tmpRawHitMaxCharge2);
57  weightSplit = tmpRawHitMaxCharge0 / tmpSumChargeSplit;
58 
59  clusterSize = clusterSizeList[0];
60  clusterSizeZ = clusterSizeList[1];
61  clusterSizeRPhi = clusterSizeList[2];
62 
63  ladder = rawHitPtr0->getLadder();
64  sensor = rawHitPtr0->getSensor();
65  maxTb = tmpRawHitMaxTb0;
66  meanColumn = weightSplit * rawHitPtr0->getColumn() + (1.0 - weightSplit) * rawHitPtr1->getColumn();
67  meanRow = weightSplit * rawHitPtr0->getRow() + (1.0 - weightSplit) * rawHitPtr1->getRow();
68  totCharge = tmpSumChargeSplit;
69  totChargeErr = sqrt( (rawHitPtr0->getChargeErr(tmpRawHitMaxTb0) * rawHitPtr0->getChargeErr(tmpRawHitMaxTb0) + rawHitPtr1->getChargeErr(tmpRawHitMaxTb1) * rawHitPtr1->getChargeErr(tmpRawHitMaxTb1)) / clusterSize );
70 
71  clusterIt->setLadder(ladder);
72  clusterIt->setSensor(sensor);
73  clusterIt->setMeanColumn(meanColumn);
74  clusterIt->setMeanRow(meanRow);
75  clusterIt->setTotCharge(totCharge);
76  clusterIt->setTotChargeErr(totChargeErr);
77  clusterIt->setNRawHits(clusterSize);
78  clusterIt->setNRawHitsRPhi(clusterSizeRPhi);
79  clusterIt->setNRawHitsZ(clusterSizeZ);
80  clusterIt->setMaxTimeBin(maxTb);
81  clusterIt->setClusteringType(clusterType);
82 
83  std::vector< StIstRawHit * > &rawHitVecTmp = clusterIt->getRawHitVec();
84  std::vector< StIstRawHit * >::iterator rawHitIterator = rawHitVecTmp.end();
85  rawHitIterator--;
86  rawHitVecTmp.erase(rawHitIterator); //remove the rawHit[2]
87 
88  //cluster spliting: part of raw hit 1 + raw hit 2
89  tmpSumChargeSplit = tmpRawHitMaxCharge2 + tmpRawHitMaxCharge1 * tmpRawHitMaxCharge2 / (tmpRawHitMaxCharge0 + tmpRawHitMaxCharge2);
90  weightSplit = tmpRawHitMaxCharge2 / tmpSumChargeSplit;
91 
92  clusterSize = clusterSizeList[3];
93  clusterSizeZ = clusterSizeList[4];
94  clusterSizeRPhi = clusterSizeList[5];
95 
96  ladder = rawHitPtr2->getLadder();
97  sensor = rawHitPtr2->getSensor();
98  maxTb = tmpRawHitMaxTb2;
99  meanColumn = weightSplit * rawHitPtr2->getColumn() + (1.0 - weightSplit) * rawHitPtr1->getColumn();
100  meanRow = weightSplit * rawHitPtr2->getRow() + (1.0 - weightSplit) * rawHitPtr1->getRow();
101  totCharge = tmpSumChargeSplit;
102  totChargeErr = sqrt( (rawHitPtr2->getChargeErr(tmpRawHitMaxTb2) * rawHitPtr2->getChargeErr(tmpRawHitMaxTb2) + rawHitPtr1->getChargeErr(tmpRawHitMaxTb1) * rawHitPtr1->getChargeErr(tmpRawHitMaxTb1)) / clusterSize );
103 
104  newClusterTmp = new StIstCluster((int)ladder * 10000 + clusters.getClusterVec().size(), ladder, sensor, meanRow, meanColumn, totCharge, totChargeErr, clusterType);
105  newClusterTmp->setNRawHits(clusterSize);
106  newClusterTmp->setNRawHitsRPhi(clusterSizeRPhi);
107  newClusterTmp->setNRawHitsZ(clusterSizeZ);
108  newClusterTmp->setMaxTimeBin(maxTb);
109 
110  std::vector< StIstRawHit * > &rawHitVecTmp2 = newClusterTmp->getRawHitVec();
111  rawHitVecTmp2.push_back(rawHitPtr1);
112  rawHitVecTmp2.push_back(rawHitPtr2);
113 
114  clusters.getClusterVec().push_back(newClusterTmp);
115  }
116 
117  // split cluster w/ size = 4
118  if (cSize == 4) {
119  rawHitPtr0 = rawHitPtr[0];
120  rawHitPtr1 = rawHitPtr[1];
121  rawHitPtr2 = rawHitPtr[2];
122  rawHitPtr3 = rawHitPtr[3];
123 
124  unsigned char tmpRawHitMaxTb0, tmpRawHitMaxTb1, tmpRawHitMaxTb2, tmpRawHitMaxTb3;
125 
126  if (mTimeBin < numTimeBins) {
127  tmpRawHitMaxTb0 = tmpRawHitMaxTb1 = tmpRawHitMaxTb2 = tmpRawHitMaxTb3 = mTimeBin;
128  }
129  else {
130  tmpRawHitMaxTb0 = tmpRawHitMaxTb1 = tmpRawHitMaxTb2 = tmpRawHitMaxTb3 = clusterIt->getMaxTimeBin();
131  }
132 
133  float tmpRawHitMaxCharge0 = rawHitPtr0->getCharge(tmpRawHitMaxTb0);
134  float tmpRawHitMaxCharge1 = rawHitPtr1->getCharge(tmpRawHitMaxTb1);
135  float tmpRawHitMaxCharge2 = rawHitPtr2->getCharge(tmpRawHitMaxTb2);
136  float tmpRawHitMaxCharge3 = rawHitPtr3->getCharge(tmpRawHitMaxTb3);
137 
138  //cluster spliting: raw hit 0 + part of raw hit 1
139  tmpSumChargeSplit = tmpRawHitMaxCharge0 + tmpRawHitMaxCharge1 * tmpRawHitMaxCharge0 / (tmpRawHitMaxCharge0 + tmpRawHitMaxCharge2 + tmpRawHitMaxCharge3);
140  weightSplit = tmpRawHitMaxCharge0 / tmpSumChargeSplit;
141 
142  clusterSize = clusterSizeList[0];
143  clusterSizeZ = clusterSizeList[1];
144  clusterSizeRPhi = clusterSizeList[2];
145 
146  ladder = rawHitPtr0->getLadder();
147  sensor = rawHitPtr0->getSensor();
148  maxTb = tmpRawHitMaxTb0;
149  meanColumn = weightSplit * rawHitPtr0->getColumn() + (1.0 - weightSplit) * rawHitPtr1->getColumn();
150  meanRow = weightSplit * rawHitPtr0->getRow() + (1.0 - weightSplit) * rawHitPtr1->getRow();
151  totCharge = tmpSumChargeSplit;
152  totChargeErr = sqrt( (rawHitPtr0->getChargeErr(tmpRawHitMaxTb0) * rawHitPtr0->getChargeErr(tmpRawHitMaxTb0) + rawHitPtr1->getChargeErr(tmpRawHitMaxTb1) * rawHitPtr1->getChargeErr(tmpRawHitMaxTb1)) / clusterSize );
153 
154  clusterIt->setLadder(ladder);
155  clusterIt->setSensor(sensor);
156  clusterIt->setMeanColumn(meanColumn);
157  clusterIt->setMeanRow(meanRow);
158  clusterIt->setTotCharge(totCharge);
159  clusterIt->setTotChargeErr(totChargeErr);
160  clusterIt->setNRawHits(clusterSize);
161  clusterIt->setNRawHitsRPhi(clusterSizeRPhi);
162  clusterIt->setNRawHitsZ(clusterSizeZ);
163  clusterIt->setMaxTimeBin(maxTb);
164  clusterIt->setClusteringType(clusterType);
165 
166  std::vector< StIstRawHit * > &rawHitVecTmp3 = clusterIt->getRawHitVec();
167  std::vector< StIstRawHit * >::iterator rawHitIterator = rawHitVecTmp3.end();
168  rawHitIterator--;
169  rawHitVecTmp3.erase(rawHitIterator); //remove the rawHit[3]
170  rawHitIterator--;
171  rawHitVecTmp3.erase(rawHitIterator); //remove the rawHit[2]
172 
173  //cluster spliting: part of raw hit 1 + raw hit 2 + raw hit 3
174  tmpSumChargeSplit = tmpRawHitMaxCharge2 + tmpRawHitMaxCharge3 + tmpRawHitMaxCharge1 * (tmpRawHitMaxCharge2 + tmpRawHitMaxCharge3) / (tmpRawHitMaxCharge0 + tmpRawHitMaxCharge2 + tmpRawHitMaxCharge3);
175  weightSplit = tmpRawHitMaxCharge2 / tmpSumChargeSplit;
176  weightSplit2 = tmpRawHitMaxCharge3 / tmpSumChargeSplit;
177 
178  clusterSize = clusterSizeList[3];
179  clusterSizeZ = clusterSizeList[4];
180  clusterSizeRPhi = clusterSizeList[5];
181 
182  ladder = rawHitPtr2->getLadder();
183  sensor = rawHitPtr2->getSensor();
184  maxTb = tmpRawHitMaxTb2;
185  meanColumn = weightSplit * rawHitPtr2->getColumn() + weightSplit2 * rawHitPtr3->getColumn() + (1.0 - weightSplit - weightSplit2) * rawHitPtr1->getColumn();
186  meanRow = weightSplit * rawHitPtr2->getRow() + weightSplit2 * rawHitPtr3->getRow() + (1.0 - weightSplit - weightSplit2) * rawHitPtr1->getRow();
187  totCharge = tmpSumChargeSplit;
188  totChargeErr = sqrt( (rawHitPtr3->getChargeErr(tmpRawHitMaxTb3) * rawHitPtr3->getChargeErr(tmpRawHitMaxTb3) + rawHitPtr2->getChargeErr(tmpRawHitMaxTb2) * rawHitPtr2->getChargeErr(tmpRawHitMaxTb2) + rawHitPtr1->getChargeErr(tmpRawHitMaxTb1) * rawHitPtr1->getChargeErr(tmpRawHitMaxTb1)) / clusterSize );
189 
190  newClusterTmp = new StIstCluster((int)ladder * 10000 + clusters.getClusterVec().size(), ladder, sensor, meanRow, meanColumn, totCharge, totChargeErr, clusterType);
191  newClusterTmp->setNRawHits(clusterSize);
192  newClusterTmp->setNRawHitsRPhi(clusterSizeRPhi);
193  newClusterTmp->setNRawHitsZ(clusterSizeZ);
194  newClusterTmp->setMaxTimeBin(maxTb);
195 
196  std::vector< StIstRawHit * > &rawHitVecTmp4 = newClusterTmp->getRawHitVec();
197  rawHitVecTmp4.push_back(rawHitPtr1);
198  rawHitVecTmp4.push_back(rawHitPtr2);
199  rawHitVecTmp4.push_back(rawHitPtr3);
200 
201  clusters.getClusterVec().push_back(newClusterTmp);
202  }
203 
204  return kStOk;
205 };
206 
207 Int_t StIstSimpleClusterAlgo::doSplitting(StIstClusterCollection &clusters, unsigned char numTimeBins)
208 {
209  //loop found clusters in current event
210  for (std::vector< StIstCluster * >::iterator clusterIt = clusters.getClusterVec().begin(); clusterIt != clusters.getClusterVec().end(); clusterIt++) {
211  StIstRawHit *rawHitPtr[] = {0, 0, 0, 0};
212  unsigned char tmpRawHitMaxTb[] = {0, 0, 0, 0};
213  float tmpRawHitMaxCharge[] = {0., 0., 0., 0.};
214  int tmpClusterSizeList[] = {1, 1, 1, 1, 1, 1};//{clusterSize_1, clusterSizeZ_1, clusterSizeRPhi_1, clusterSize_2, clusterSizeZ_2, clusterSizeRPhi_2}
215 
216  //splitting clusters w/ size = 3
217  if ( (*clusterIt)->getNRawHits() == 3 ) {
218  tmpClusterSizeList[0] = 2; tmpClusterSizeList[3] = 2;
219  int index = 0;
220 
221  for (std::vector< StIstRawHit * >::iterator rawHitVecIt = (*clusterIt)->getRawHitVec().begin(); index < 3 && rawHitVecIt != (*clusterIt)->getRawHitVec().end(); rawHitVecIt++) {
222  rawHitPtr[index] = *rawHitVecIt;
223 
224  if (mTimeBin < numTimeBins) {
225  tmpRawHitMaxTb[index] = mTimeBin;
226  }
227  else {
228  tmpRawHitMaxTb[index] = (*clusterIt)->getMaxTimeBin();//the raw hits belong to the same cluster should be at same time bin
229  }
230 
231  tmpRawHitMaxCharge[index] = rawHitPtr[index]->getCharge(tmpRawHitMaxTb[index]);
232  index ++;
233  }
234 
235  //cases 1-4: 2 2 1 2
236  //topology: 2 1 0 , 1 , 0 , 1 0
237  // 0
238  if ( ((*clusterIt)->getNRawHitsZ() == 3) || ((*clusterIt)->getNRawHitsRPhi() == 3) ||
239  (((*clusterIt)->getNRawHitsZ() == 2) && ((*clusterIt)->getNRawHitsRPhi() == 2) && (rawHitPtr[0]->getColumn() == rawHitPtr[2]->getColumn() - 1) && (rawHitPtr[0]->getRow() == rawHitPtr[2]->getRow() - 1)) ) {
240  if ( (tmpRawHitMaxCharge[1] <= tmpRawHitMaxCharge[0]) && (tmpRawHitMaxCharge[1] <= tmpRawHitMaxCharge[2]) ) {
241  if ( (*clusterIt)->getNRawHitsZ() == 3 ) {
242  tmpClusterSizeList[1] = 2; tmpClusterSizeList[2] = 1; tmpClusterSizeList[4] = 2; tmpClusterSizeList[5] = 1;
243  }
244  else if ( (*clusterIt)->getNRawHitsRPhi() == 3 ) {
245  tmpClusterSizeList[1] = 1; tmpClusterSizeList[2] = 2; tmpClusterSizeList[4] = 1; tmpClusterSizeList[5] = 2;
246  }
247  else if ( ((*clusterIt)->getNRawHitsZ() == 2) && (rawHitPtr[0]->getColumn() == rawHitPtr[1]->getColumn()) ) {
248  tmpClusterSizeList[1] = 1; tmpClusterSizeList[2] = 2; tmpClusterSizeList[4] = 2; tmpClusterSizeList[5] = 1;
249  }
250  else {
251  tmpClusterSizeList[1] = 2; tmpClusterSizeList[2] = 1; tmpClusterSizeList[4] = 1; tmpClusterSizeList[5] = 2;
252  }
253 
254  Int_t split3_4_ierr = splitCluster(3, tmpClusterSizeList, rawHitPtr, *clusterIt, clusters, numTimeBins); // do splitting for the current cluster
255 
256  if (split3_4_ierr != kStOk)
257  LOG_WARN << "Cluster (ladder/sensor/meanColumn/meanRow: " << (*clusterIt)->getLadder() << "/" << (*clusterIt)->getSensor() << "/" << (*clusterIt)->getMeanColumn() << "/" << (*clusterIt)->getMeanRow() << ") splitting failed! returned " << split3_4_ierr << endm;
258  }
259  } //end cases 1-4
260 
261  //cases 5-6: 2 0 1
262  //topology: 1 , 2 0
263  else if ( ((*clusterIt)->getNRawHitsZ() == 2) && (rawHitPtr[0]->getColumn() == rawHitPtr[2]->getColumn() - 1) && (rawHitPtr[0]->getRow() == rawHitPtr[2]->getRow()) ) {
264  //case 5
265  if ( (rawHitPtr[1]->getColumn() == rawHitPtr[2]->getColumn()) && (tmpRawHitMaxCharge[2] <= tmpRawHitMaxCharge[0]) && (tmpRawHitMaxCharge[2] <= tmpRawHitMaxCharge[1]) ) {
266  tmpClusterSizeList[1] = 2; tmpClusterSizeList[2] = 1; tmpClusterSizeList[4] = 1; tmpClusterSizeList[5] = 2;
267  //exchange raw hit 1 and raw hit 2 position in the temperary raw hits array
268  rawHitPtr[3] = rawHitPtr[2];
269  rawHitPtr[2] = rawHitPtr[1];
270  rawHitPtr[1] = rawHitPtr[3];
271  rawHitPtr[3] = 0;
272 
273  Int_t split3_5_ierr = splitCluster(3, tmpClusterSizeList, rawHitPtr, *clusterIt, clusters, numTimeBins); // do splitting for the current cluster
274 
275  if (split3_5_ierr != kStOk)
276  LOG_WARN << "Cluster (ladder/sensor/meanColumn/meanRow: " << (*clusterIt)->getLadder() << "/" << (*clusterIt)->getSensor() << "/" << (*clusterIt)->getMeanColumn() << "/" << (*clusterIt)->getMeanRow() << ") splitting failed! returned " << split3_5_ierr << endm;
277  }
278 
279  //case 6
280  if ( (rawHitPtr[0]->getColumn() == rawHitPtr[1]->getColumn()) && (tmpRawHitMaxCharge[0] <= tmpRawHitMaxCharge[1]) && (tmpRawHitMaxCharge[0] <= tmpRawHitMaxCharge[2]) ) {
281  tmpClusterSizeList[1] = 1; tmpClusterSizeList[2] = 2; tmpClusterSizeList[4] = 2; tmpClusterSizeList[5] = 1;
282  //exchange raw hit 0 and raw hit 1 position in the temperary raw hits array
283  rawHitPtr[3] = rawHitPtr[0];
284  rawHitPtr[0] = rawHitPtr[1];
285  rawHitPtr[1] = rawHitPtr[3];
286  rawHitPtr[3] = 0;
287 
288  Int_t split3_6_ierr = splitCluster(3, tmpClusterSizeList, rawHitPtr, *clusterIt, clusters, numTimeBins); // do splitting for the current cluster
289 
290  if (split3_6_ierr != kStOk)
291  LOG_WARN << "Cluster (ladder/sensor/meanColumn/meanRow: " << (*clusterIt)->getLadder() << "/" << (*clusterIt)->getSensor() << "/" << (*clusterIt)->getMeanColumn() << "/" << (*clusterIt)->getMeanRow() << ") splitting failed! returned " << split3_6_ierr << endm;
292  }
293  }
294  } //end splitting loop for clusters with size = 3
295 
296  //splitting clusters w/ size = 4
297  if ( (*clusterIt)->getNRawHits() == 4 ) {
298  tmpClusterSizeList[0] = 2; tmpClusterSizeList[3] = 3;
299  Int_t index = 0;
300 
301  for (std::vector< StIstRawHit * >::iterator rawHitVecIt = (*clusterIt)->getRawHitVec().begin(); index < 4 && rawHitVecIt != (*clusterIt)->getRawHitVec().end(); rawHitVecIt++) {
302  rawHitPtr[index] = *rawHitVecIt;
303 
304  if (mTimeBin < numTimeBins) {
305  tmpRawHitMaxTb[index] = mTimeBin;
306  }
307  else {
308  tmpRawHitMaxTb[index] = (*clusterIt)->getMaxTimeBin();//the raw hits belong to the same cluster should be at same time bin
309  }
310 
311  tmpRawHitMaxCharge[index] = rawHitPtr[index]->getCharge(tmpRawHitMaxTb[index]);
312  index ++;
313  }
314 
315  // 3
316  //cases 1-8: 2 3 2 1 3 3 2 3 3 2 3
317  //topology: 3 2 1 0 , 1 , 0 , 2 1 0 , 1 , 2 , 1 0 , 2 1
318  // 0 0 1 0 0
319  if ( ((*clusterIt)->getNRawHitsZ() == 4) ||
320  ((*clusterIt)->getNRawHitsRPhi() == 4) ||
321  (((*clusterIt)->getNRawHitsZ() == 3) && (rawHitPtr[1]->getColumn() == rawHitPtr[0]->getColumn()) && (rawHitPtr[1]->getRow() == rawHitPtr[0]->getRow() + 1) && (rawHitPtr[2]->getRow() == rawHitPtr[1]->getRow()) && (rawHitPtr[3]->getRow() == rawHitPtr[2]->getRow())) ||
322  (((*clusterIt)->getNRawHitsZ() == 3) && (rawHitPtr[3]->getColumn() == rawHitPtr[2]->getColumn()) && (rawHitPtr[3]->getRow() == rawHitPtr[2]->getRow() + 1) && (rawHitPtr[1]->getRow() == rawHitPtr[0]->getRow()) && (rawHitPtr[2]->getRow() == rawHitPtr[1]->getRow())) ||
323  (((*clusterIt)->getNRawHitsRPhi() == 3) && (rawHitPtr[3]->getColumn() == rawHitPtr[2]->getColumn() + 1) && (rawHitPtr[3]->getRow() == rawHitPtr[2]->getRow()) && (rawHitPtr[1]->getColumn() == rawHitPtr[0]->getColumn()) && (rawHitPtr[2]->getColumn() == rawHitPtr[1]->getColumn())) ||
324  (((*clusterIt)->getNRawHitsRPhi() == 3) && (rawHitPtr[1]->getColumn() == rawHitPtr[0]->getColumn() + 1) && (rawHitPtr[1]->getRow() == rawHitPtr[0]->getRow()) && (rawHitPtr[2]->getColumn() == rawHitPtr[1]->getColumn()) && (rawHitPtr[3]->getColumn() == rawHitPtr[2]->getColumn())) ||
325  (((*clusterIt)->getNRawHitsZ() == 3) && (rawHitPtr[1]->getColumn() == rawHitPtr[2]->getColumn()) && (rawHitPtr[2]->getRow() == rawHitPtr[1]->getRow() + 1) && (rawHitPtr[1]->getRow() == rawHitPtr[0]->getRow()) && (rawHitPtr[3]->getRow() == rawHitPtr[2]->getRow())) ||
326  (((*clusterIt)->getNRawHitsRPhi() == 3) && (rawHitPtr[1]->getRow() == rawHitPtr[2]->getRow()) && (rawHitPtr[2]->getColumn() == rawHitPtr[1]->getColumn() + 1) && (rawHitPtr[1]->getColumn() == rawHitPtr[0]->getColumn()) && (rawHitPtr[3]->getColumn() == rawHitPtr[2]->getColumn())) ) {
327  //the 2nd raw hit with minimum ADC
328  if ( (tmpRawHitMaxCharge[1] <= tmpRawHitMaxCharge[0]) && (tmpRawHitMaxCharge[1] <= tmpRawHitMaxCharge[2]) && (tmpRawHitMaxCharge[1] <= tmpRawHitMaxCharge[3]) ) {
329  //0, 1, 2, 3
330  if ( (*clusterIt)->getNRawHitsZ() == 4 ) {
331  tmpClusterSizeList[1] = 2; tmpClusterSizeList[2] = 1; tmpClusterSizeList[4] = 3; tmpClusterSizeList[5] = 1;
332  }
333  else if ( (*clusterIt)->getNRawHitsRPhi() == 4 ) {
334  tmpClusterSizeList[1] = 1; tmpClusterSizeList[2] = 2; tmpClusterSizeList[4] = 1; tmpClusterSizeList[5] = 3;
335  }
336  else if ( ((*clusterIt)->getNRawHitsZ() == 3) && (rawHitPtr[1]->getColumn() == rawHitPtr[0]->getColumn()) && (rawHitPtr[1]->getRow() == rawHitPtr[0]->getRow() + 1) && (rawHitPtr[2]->getRow() == rawHitPtr[1]->getRow()) && (rawHitPtr[3]->getRow() == rawHitPtr[2]->getRow()) ) {
337  tmpClusterSizeList[1] = 1; tmpClusterSizeList[2] = 2; tmpClusterSizeList[4] = 3; tmpClusterSizeList[5] = 1;
338  }
339  else if ( ((*clusterIt)->getNRawHitsZ() == 3) && (rawHitPtr[3]->getColumn() == rawHitPtr[2]->getColumn()) && (rawHitPtr[3]->getRow() == rawHitPtr[2]->getRow() + 1) && (rawHitPtr[1]->getRow() == rawHitPtr[0]->getRow()) && (rawHitPtr[2]->getRow() == rawHitPtr[1]->getRow()) ) {
340  tmpClusterSizeList[1] = 2; tmpClusterSizeList[2] = 1; tmpClusterSizeList[4] = 2; tmpClusterSizeList[5] = 2;
341  }
342  else if ( ((*clusterIt)->getNRawHitsRPhi() == 3) && (rawHitPtr[3]->getColumn() == rawHitPtr[2]->getColumn() + 1) && (rawHitPtr[3]->getRow() == rawHitPtr[2]->getRow()) && (rawHitPtr[1]->getColumn() == rawHitPtr[0]->getColumn()) && (rawHitPtr[2]->getColumn() == rawHitPtr[1]->getColumn()) ) {
343  tmpClusterSizeList[1] = 1; tmpClusterSizeList[2] = 2; tmpClusterSizeList[4] = 2; tmpClusterSizeList[5] = 2;
344  }
345  else if ( ((*clusterIt)->getNRawHitsRPhi() == 3) && (rawHitPtr[1]->getColumn() == rawHitPtr[0]->getColumn() + 1) && (rawHitPtr[1]->getRow() == rawHitPtr[0]->getRow()) && (rawHitPtr[2]->getColumn() == rawHitPtr[1]->getColumn()) && (rawHitPtr[3]->getColumn() == rawHitPtr[2]->getColumn()) ) {
346  tmpClusterSizeList[1] = 2; tmpClusterSizeList[2] = 1; tmpClusterSizeList[4] = 1; tmpClusterSizeList[5] = 3;
347  }
348  else if ( ((*clusterIt)->getNRawHitsZ() == 3) && (rawHitPtr[1]->getColumn() == rawHitPtr[2]->getColumn()) && (rawHitPtr[2]->getRow() == rawHitPtr[1]->getRow() + 1) && (rawHitPtr[1]->getRow() == rawHitPtr[0]->getRow()) && (rawHitPtr[3]->getRow() == rawHitPtr[2]->getRow()) ) {
349  tmpClusterSizeList[1] = 2; tmpClusterSizeList[2] = 1; tmpClusterSizeList[4] = 2; tmpClusterSizeList[5] = 2;
350  }
351  else {
352  tmpClusterSizeList[1] = 1; tmpClusterSizeList[2] = 2; tmpClusterSizeList[4] = 2; tmpClusterSizeList[5] = 2;
353  }
354 
355  Int_t split4_8_ierr = splitCluster(4, tmpClusterSizeList, rawHitPtr, *clusterIt, clusters, numTimeBins); // do splitting for the current cluster
356 
357  if (split4_8_ierr != kStOk)
358  LOG_WARN << "Cluster (ladder/sensor/meanColumn/meanRow: " << (*clusterIt)->getLadder() << "/" << (*clusterIt)->getSensor() << "/" << (*clusterIt)->getMeanColumn() << "/" << (*clusterIt)->getMeanRow() << ") splitting failed! returned " << split4_8_ierr << endm;
359  }
360 
361  //the 3rd raw hit with minimum ADC
362  if ( (tmpRawHitMaxCharge[2] <= tmpRawHitMaxCharge[0]) && (tmpRawHitMaxCharge[2] <= tmpRawHitMaxCharge[1]) && (tmpRawHitMaxCharge[2] <= tmpRawHitMaxCharge[3]) ) {
363  StIstRawHit *rawHitPtrTmp = 0;
364  //3, 2, 1, 0
365  rawHitPtrTmp = rawHitPtr[0];
366  rawHitPtr[0] = rawHitPtr[3];
367  rawHitPtr[3] = rawHitPtrTmp;
368  rawHitPtrTmp = rawHitPtr[2];
369  rawHitPtr[2] = rawHitPtr[1];
370  rawHitPtr[1] = rawHitPtrTmp;
371 
372  if ( (*clusterIt)->getNRawHitsZ() == 4 )
373  { tmpClusterSizeList[1] = 2; tmpClusterSizeList[2] = 1; tmpClusterSizeList[4] = 3; tmpClusterSizeList[5] = 1; }
374  else if ( (*clusterIt)->getNRawHitsRPhi() == 4 )
375  { tmpClusterSizeList[1] = 1; tmpClusterSizeList[2] = 2; tmpClusterSizeList[4] = 1; tmpClusterSizeList[5] = 3; }
376  else if ( ((*clusterIt)->getNRawHitsZ() == 3) && (rawHitPtr[1]->getColumn() == rawHitPtr[0]->getColumn()) && (rawHitPtr[1]->getRow() == rawHitPtr[0]->getRow() + 1) && (rawHitPtr[2]->getRow() == rawHitPtr[1]->getRow()) && (rawHitPtr[3]->getRow() == rawHitPtr[2]->getRow()) )
377  { tmpClusterSizeList[1] = 2; tmpClusterSizeList[2] = 1; tmpClusterSizeList[4] = 2; tmpClusterSizeList[5] = 2; }
378  else if ( ((*clusterIt)->getNRawHitsZ() == 3) && (rawHitPtr[3]->getColumn() == rawHitPtr[2]->getColumn()) && (rawHitPtr[3]->getRow() == rawHitPtr[2]->getRow() + 1) && (rawHitPtr[1]->getRow() == rawHitPtr[0]->getRow()) && (rawHitPtr[2]->getRow() == rawHitPtr[1]->getRow()) )
379  { tmpClusterSizeList[1] = 1; tmpClusterSizeList[2] = 2; tmpClusterSizeList[4] = 3; tmpClusterSizeList[5] = 1; }
380  else if ( ((*clusterIt)->getNRawHitsRPhi() == 3) && (rawHitPtr[3]->getColumn() == rawHitPtr[2]->getColumn() + 1) && (rawHitPtr[3]->getRow() == rawHitPtr[2]->getRow()) && (rawHitPtr[1]->getColumn() == rawHitPtr[0]->getColumn()) && (rawHitPtr[2]->getColumn() == rawHitPtr[1]->getColumn()) )
381  { tmpClusterSizeList[1] = 2; tmpClusterSizeList[2] = 1; tmpClusterSizeList[4] = 1; tmpClusterSizeList[5] = 3; }
382  else if ( ((*clusterIt)->getNRawHitsRPhi() == 3) && (rawHitPtr[1]->getColumn() == rawHitPtr[0]->getColumn() + 1) && (rawHitPtr[1]->getRow() == rawHitPtr[0]->getRow()) && (rawHitPtr[2]->getColumn() == rawHitPtr[1]->getColumn()) && (rawHitPtr[3]->getColumn() == rawHitPtr[2]->getColumn()) )
383  { tmpClusterSizeList[1] = 1; tmpClusterSizeList[2] = 2; tmpClusterSizeList[4] = 2; tmpClusterSizeList[5] = 2; }
384  else if ( ((*clusterIt)->getNRawHitsZ() == 3) && (rawHitPtr[1]->getColumn() == rawHitPtr[2]->getColumn()) && (rawHitPtr[2]->getRow() == rawHitPtr[1]->getRow() + 1) && (rawHitPtr[1]->getRow() == rawHitPtr[0]->getRow()) && (rawHitPtr[3]->getRow() == rawHitPtr[2]->getRow()) )
385  { tmpClusterSizeList[1] = 2; tmpClusterSizeList[2] = 1; tmpClusterSizeList[4] = 2; tmpClusterSizeList[5] = 2; }
386  else
387  { tmpClusterSizeList[1] = 1; tmpClusterSizeList[2] = 2; tmpClusterSizeList[4] = 2; tmpClusterSizeList[5] = 2; }
388 
389  Int_t split4_8_ierr = splitCluster(4, tmpClusterSizeList, rawHitPtr, *clusterIt, clusters, numTimeBins); // do splitting for the current cluster
390 
391  if (split4_8_ierr != kStOk)
392  LOG_WARN << "Cluster (ladder/sensor/meanColumn/meanRow: " << (*clusterIt)->getLadder() << "/" << (*clusterIt)->getSensor() << "/" << (*clusterIt)->getMeanColumn() << "/" << (*clusterIt)->getMeanRow() << ") splitting failed! returned " << split4_8_ierr << endm;
393  }
394  } //end cases 1-8
395 
396  //case 9: 3 1 0
397  //topology: 2
398  else if ( (((*clusterIt)->getNRawHitsZ() == 3) && (rawHitPtr[3]->getColumn() == rawHitPtr[2]->getColumn()) && (rawHitPtr[3]->getRow() == rawHitPtr[2]->getRow() + 1) && (rawHitPtr[3]->getRow() == rawHitPtr[1]->getRow()) && (rawHitPtr[1]->getRow() == rawHitPtr[0]->getRow())) ) {
399  //the 2nd raw hit with minimum ADC
400  if ( (tmpRawHitMaxCharge[1] <= tmpRawHitMaxCharge[0]) && (tmpRawHitMaxCharge[1] <= tmpRawHitMaxCharge[2]) && (tmpRawHitMaxCharge[1] <= tmpRawHitMaxCharge[3]) ) {
401  tmpClusterSizeList[1] = 2; tmpClusterSizeList[2] = 1; tmpClusterSizeList[4] = 2; tmpClusterSizeList[5] = 2;
402  StIstRawHit *rawHitPtrTmp = 0;
403  //0, 1, 3, 2
404  rawHitPtrTmp = rawHitPtr[3];
405  rawHitPtr[3] = rawHitPtr[2];
406  rawHitPtr[2] = rawHitPtrTmp;
407 
408  Int_t split4_9_ierr = splitCluster(4, tmpClusterSizeList, rawHitPtr, *clusterIt, clusters, numTimeBins); // do splitting for the current cluster
409 
410  if (split4_9_ierr != kStOk)
411  LOG_WARN << "Cluster (ladder/sensor/meanColumn/meanRow: " << (*clusterIt)->getLadder() << "/" << (*clusterIt)->getSensor() << "/" << (*clusterIt)->getMeanColumn() << "/" << (*clusterIt)->getMeanRow() << ") splitting failed! returned " << split4_9_ierr << endm;
412  }
413 
414  //the 4th raw hit with minimum ADC
415  if ( (tmpRawHitMaxCharge[3] <= tmpRawHitMaxCharge[0]) && (tmpRawHitMaxCharge[3] <= tmpRawHitMaxCharge[1]) && (tmpRawHitMaxCharge[3] <= tmpRawHitMaxCharge[2]) ) {
416  tmpClusterSizeList[1] = 1; tmpClusterSizeList[2] = 2; tmpClusterSizeList[4] = 3; tmpClusterSizeList[5] = 1;
417  StIstRawHit *rawHitPtrTmp = 0;
418  //2, 3, 1, 0
419  rawHitPtrTmp = rawHitPtr[0];
420  rawHitPtr[0] = rawHitPtr[2];
421  rawHitPtr[2] = rawHitPtr[1];
422  rawHitPtr[1] = rawHitPtr[3];
423  rawHitPtr[3] = rawHitPtrTmp;
424 
425  Int_t split4_9_ierr = splitCluster(4, tmpClusterSizeList, rawHitPtr, *clusterIt, clusters, numTimeBins); // do splitting for the current cluster
426 
427  if (split4_9_ierr != kStOk)
428  LOG_WARN << "Cluster (ladder/sensor/meanColumn/meanRow: " << (*clusterIt)->getLadder() << "/" << (*clusterIt)->getSensor() << "/" << (*clusterIt)->getMeanColumn() << "/" << (*clusterIt)->getMeanRow() << ") splitting failed! returned " << split4_9_ierr << endm;
429  }
430  }//end case 9
431 
432  //case 10: 1
433  //topology: 3 2 0
434  else if ( (((*clusterIt)->getNRawHitsZ() == 3) && (rawHitPtr[1]->getColumn() == rawHitPtr[0]->getColumn()) && (rawHitPtr[1]->getRow() == rawHitPtr[0]->getRow() + 1) && (rawHitPtr[3]->getRow() == rawHitPtr[2]->getRow()) && (rawHitPtr[2]->getRow() == rawHitPtr[0]->getRow())) ) {
435  //the 1st raw hit with minimum ADC
436  if ( (tmpRawHitMaxCharge[0] <= tmpRawHitMaxCharge[1]) && (tmpRawHitMaxCharge[0] <= tmpRawHitMaxCharge[2]) && (tmpRawHitMaxCharge[0] <= tmpRawHitMaxCharge[3]) ) {
437  tmpClusterSizeList[1] = 1; tmpClusterSizeList[2] = 2; tmpClusterSizeList[4] = 3; tmpClusterSizeList[5] = 1;
438  StIstRawHit *rawHitPtrTmp = 0;
439  //1, 0, 2, 3
440  rawHitPtrTmp = rawHitPtr[0];
441  rawHitPtr[0] = rawHitPtr[1];
442  rawHitPtr[1] = rawHitPtrTmp;
443 
444  Int_t split4_10_ierr = splitCluster(4, tmpClusterSizeList, rawHitPtr, *clusterIt, clusters, numTimeBins); // do splitting for the current cluster
445 
446  if (split4_10_ierr != kStOk)
447  LOG_WARN << "Cluster (ladder/sensor/meanColumn/meanRow: " << (*clusterIt)->getLadder() << "/" << (*clusterIt)->getSensor() << "/" << (*clusterIt)->getMeanColumn() << "/" << (*clusterIt)->getMeanRow() << ") splitting failed! returned " << split4_10_ierr << endm;
448  }
449 
450  //the 3rd raw hit with minimum ADC
451  if ( (tmpRawHitMaxCharge[2] <= tmpRawHitMaxCharge[0]) && (tmpRawHitMaxCharge[2] <= tmpRawHitMaxCharge[1]) && (tmpRawHitMaxCharge[2] <= tmpRawHitMaxCharge[3]) ) {
452  tmpClusterSizeList[1] = 2; tmpClusterSizeList[2] = 1; tmpClusterSizeList[4] = 2; tmpClusterSizeList[5] = 2;
453  StIstRawHit *rawHitPtrTmp = 0;
454  //3, 2, 0, 1
455  rawHitPtrTmp = rawHitPtr[0];
456  rawHitPtr[0] = rawHitPtr[3];
457  rawHitPtr[3] = rawHitPtr[1];
458  rawHitPtr[1] = rawHitPtr[2];
459  rawHitPtr[2] = rawHitPtrTmp;
460 
461  Int_t split4_10_ierr = splitCluster(4, tmpClusterSizeList, rawHitPtr, *clusterIt, clusters, numTimeBins); // do splitting for the current cluster
462 
463  if (split4_10_ierr != kStOk)
464  LOG_WARN << "Cluster (ladder/sensor/meanColumn/meanRow: " << (*clusterIt)->getLadder() << "/" << (*clusterIt)->getSensor() << "/" << (*clusterIt)->getMeanColumn() << "/" << (*clusterIt)->getMeanRow() << ") splitting failed! returned " << split4_10_ierr << endm;
465  }
466  }//end case 10
467 
468  //case 11: 2
469  //topology: 1
470  // 3 0
471  else if ( (((*clusterIt)->getNRawHitsRPhi() == 3) && (rawHitPtr[3]->getColumn() == rawHitPtr[0]->getColumn() + 1) && (rawHitPtr[3]->getRow() == rawHitPtr[0]->getRow()) && (rawHitPtr[2]->getColumn() == rawHitPtr[1]->getColumn()) && (rawHitPtr[1]->getColumn() == rawHitPtr[0]->getColumn())) ) {
472  //the 1st raw hit with minimum ADC
473  if ( (tmpRawHitMaxCharge[0] <= tmpRawHitMaxCharge[1]) && (tmpRawHitMaxCharge[0] <= tmpRawHitMaxCharge[2]) && (tmpRawHitMaxCharge[0] <= tmpRawHitMaxCharge[3]) ) {
474  tmpClusterSizeList[1] = 2; tmpClusterSizeList[2] = 1; tmpClusterSizeList[4] = 1; tmpClusterSizeList[5] = 3;
475  StIstRawHit *rawHitPtrTmp = 0;
476  //3, 0, 1, 2
477  rawHitPtrTmp = rawHitPtr[0];
478  rawHitPtr[0] = rawHitPtr[3];
479  rawHitPtr[3] = rawHitPtr[2];
480  rawHitPtr[2] = rawHitPtr[1];
481  rawHitPtr[1] = rawHitPtrTmp;
482 
483  Int_t split4_11_ierr = splitCluster(4, tmpClusterSizeList, rawHitPtr, *clusterIt, clusters, numTimeBins); // do splitting for the current cluster
484 
485  if (split4_11_ierr != kStOk)
486  LOG_WARN << "Cluster (ladder/sensor/meanColumn/meanRow: " << (*clusterIt)->getLadder() << "/" << (*clusterIt)->getSensor() << "/" << (*clusterIt)->getMeanColumn() << "/" << (*clusterIt)->getMeanRow() << ") splitting failed! returned " << split4_11_ierr << endm;
487  }
488 
489  //the 2nd raw hit with minimum ADC
490  if ( (tmpRawHitMaxCharge[1] <= tmpRawHitMaxCharge[0]) && (tmpRawHitMaxCharge[1] <= tmpRawHitMaxCharge[2]) && (tmpRawHitMaxCharge[1] <= tmpRawHitMaxCharge[3]) ) {
491  tmpClusterSizeList[1] = 1; tmpClusterSizeList[2] = 2; tmpClusterSizeList[4] = 2; tmpClusterSizeList[5] = 2;
492  StIstRawHit *rawHitPtrTmp = 0;
493  //2, 1, 0, 3
494  rawHitPtrTmp = rawHitPtr[0];
495  rawHitPtr[0] = rawHitPtr[2];
496  rawHitPtr[2] = rawHitPtrTmp;
497 
498  Int_t split4_11_ierr = splitCluster(4, tmpClusterSizeList, rawHitPtr, *clusterIt, clusters, numTimeBins); // do splitting for the current cluster
499 
500  if (split4_11_ierr != kStOk)
501  LOG_WARN << "Cluster (ladder/sensor/meanColumn/meanRow: " << (*clusterIt)->getLadder() << "/" << (*clusterIt)->getSensor() << "/" << (*clusterIt)->getMeanColumn() << "/" << (*clusterIt)->getMeanRow() << ") splitting failed! returned " << split4_11_ierr << endm;
502  }
503  }//end case 11
504 
505  //case 12: 3 0
506  //topology: 2
507  // 1
508  else if ( (((*clusterIt)->getNRawHitsRPhi() == 3) && (rawHitPtr[3]->getRow() == rawHitPtr[0]->getRow()) && (rawHitPtr[3]->getColumn() == rawHitPtr[0]->getColumn() + 1) && (rawHitPtr[3]->getColumn() == rawHitPtr[2]->getColumn()) && (rawHitPtr[2]->getColumn() == rawHitPtr[1]->getColumn())) ) {
509  //the 4th raw hit with minimum ADC
510  if ( (tmpRawHitMaxCharge[3] <= tmpRawHitMaxCharge[0]) && (tmpRawHitMaxCharge[3] <= tmpRawHitMaxCharge[1]) && (tmpRawHitMaxCharge[3] <= tmpRawHitMaxCharge[2]) ) {
511  tmpClusterSizeList[1] = 2; tmpClusterSizeList[2] = 1; tmpClusterSizeList[4] = 1; tmpClusterSizeList[5] = 3;
512  StIstRawHit *rawHitPtrTmp = 0;
513  //0, 3, 2, 1
514  rawHitPtrTmp = rawHitPtr[1];
515  rawHitPtr[1] = rawHitPtr[3];
516  rawHitPtr[3] = rawHitPtrTmp;
517 
518  Int_t split4_12_ierr = splitCluster(4, tmpClusterSizeList, rawHitPtr, *clusterIt, clusters, numTimeBins); // do splitting for the current cluster
519 
520  if (split4_12_ierr != kStOk)
521  LOG_WARN << "Cluster (ladder/sensor/meanColumn/meanRow: " << (*clusterIt)->getLadder() << "/" << (*clusterIt)->getSensor() << "/" << (*clusterIt)->getMeanColumn() << "/" << (*clusterIt)->getMeanRow() << ") splitting failed! returned " << split4_12_ierr << endm;
522  }
523 
524  //the 3rd raw hit with minimum ADC
525  if ( (tmpRawHitMaxCharge[2] <= tmpRawHitMaxCharge[0]) && (tmpRawHitMaxCharge[2] <= tmpRawHitMaxCharge[1]) && (tmpRawHitMaxCharge[2] <= tmpRawHitMaxCharge[3]) ) {
526  tmpClusterSizeList[1] = 1; tmpClusterSizeList[2] = 2; tmpClusterSizeList[4] = 2; tmpClusterSizeList[5] = 2;
527  StIstRawHit *rawHitPtrTmp = 0;
528  //1, 2, 3, 0
529  rawHitPtrTmp = rawHitPtr[0];
530  rawHitPtr[0] = rawHitPtr[1];
531  rawHitPtr[1] = rawHitPtr[2];
532  rawHitPtr[2] = rawHitPtr[3];
533  rawHitPtr[3] = rawHitPtrTmp;
534 
535  Int_t split4_12_ierr = splitCluster(4, tmpClusterSizeList, rawHitPtr, *clusterIt, clusters, numTimeBins); // do splitting for the current cluster
536 
537  if (split4_12_ierr != kStOk)
538  LOG_WARN << "Cluster (ladder/sensor/meanColumn/meanRow: " << (*clusterIt)->getLadder() << "/" << (*clusterIt)->getSensor() << "/" << (*clusterIt)->getMeanColumn() << "/" << (*clusterIt)->getMeanRow() << ") splitting failed! returned " << split4_12_ierr << endm;
539  }
540  }//end case 12
541 
542  //case 13: 2 0
543  //topology: 3 1
544  else if ( (((*clusterIt)->getNRawHitsZ() == 3) && (rawHitPtr[1]->getColumn() == rawHitPtr[2]->getColumn()) && (rawHitPtr[2]->getRow() == rawHitPtr[1]->getRow() + 1) && (rawHitPtr[3]->getRow() == rawHitPtr[1]->getRow()) && (rawHitPtr[2]->getRow() == rawHitPtr[0]->getRow())) ) {
545  //the 3rd raw hit with minimum ADC
546  if ( (tmpRawHitMaxCharge[2] <= tmpRawHitMaxCharge[0]) && (tmpRawHitMaxCharge[2] <= tmpRawHitMaxCharge[1]) && (tmpRawHitMaxCharge[2] <= tmpRawHitMaxCharge[3]) ) {
547  tmpClusterSizeList[1] = 2; tmpClusterSizeList[2] = 1; tmpClusterSizeList[4] = 2; tmpClusterSizeList[5] = 2;
548  StIstRawHit *rawHitPtrTmp = 0;
549  //0, 2, 1, 3
550  rawHitPtrTmp = rawHitPtr[1];
551  rawHitPtr[1] = rawHitPtr[2];
552  rawHitPtr[2] = rawHitPtrTmp;
553 
554  Int_t split4_13_ierr = splitCluster(4, tmpClusterSizeList, rawHitPtr, *clusterIt, clusters, numTimeBins); // do splitting for the current cluster
555 
556  if (split4_13_ierr != kStOk)
557  LOG_WARN << "Cluster (ladder/sensor/meanColumn/meanRow: " << (*clusterIt)->getLadder() << "/" << (*clusterIt)->getSensor() << "/" << (*clusterIt)->getMeanColumn() << "/" << (*clusterIt)->getMeanRow() << ") splitting failed! returned " << split4_13_ierr << endm;
558  }
559 
560  //the 2nd raw hit with minimum ADC
561  if ( (tmpRawHitMaxCharge[1] <= tmpRawHitMaxCharge[0]) && (tmpRawHitMaxCharge[1] <= tmpRawHitMaxCharge[2]) && (tmpRawHitMaxCharge[1] <= tmpRawHitMaxCharge[3]) ) {
562  tmpClusterSizeList[1] = 2; tmpClusterSizeList[2] = 1; tmpClusterSizeList[4] = 2; tmpClusterSizeList[5] = 2;
563  StIstRawHit *rawHitPtrTmp = 0;
564  //3, 1, 2, 0
565  rawHitPtrTmp = rawHitPtr[0];
566  rawHitPtr[0] = rawHitPtr[3];
567  rawHitPtr[3] = rawHitPtrTmp;
568 
569  Int_t split4_13_ierr = splitCluster(4, tmpClusterSizeList, rawHitPtr, *clusterIt, clusters, numTimeBins); // do splitting for the current cluster
570 
571  if (split4_13_ierr != kStOk)
572  LOG_WARN << "Cluster (ladder/sensor/meanColumn/meanRow: " << (*clusterIt)->getLadder() << "/" << (*clusterIt)->getSensor() << "/" << (*clusterIt)->getMeanColumn() << "/" << (*clusterIt)->getMeanRow() << ") splitting failed! returned " << split4_13_ierr << endm;
573  }
574  }//end case 13
575 
576  //case 14: 1
577  //topology: 3 0
578  // 2
579  else if ( (((*clusterIt)->getNRawHitsRPhi() == 3) && (rawHitPtr[3]->getRow() == rawHitPtr[0]->getRow()) && (rawHitPtr[3]->getColumn() == rawHitPtr[0]->getColumn() + 1) && (rawHitPtr[3]->getColumn() == rawHitPtr[2]->getColumn()) && (rawHitPtr[0]->getColumn() == rawHitPtr[1]->getColumn())) ) {
580  //the 1st raw hit with minimum ADC
581  if ( (tmpRawHitMaxCharge[0] <= tmpRawHitMaxCharge[1]) && (tmpRawHitMaxCharge[0] <= tmpRawHitMaxCharge[2]) && (tmpRawHitMaxCharge[0] <= tmpRawHitMaxCharge[3]) ) {
582  tmpClusterSizeList[1] = 1; tmpClusterSizeList[2] = 2; tmpClusterSizeList[4] = 2; tmpClusterSizeList[5] = 2;
583  StIstRawHit *rawHitPtrTmp = 0;
584  //1, 0, 3, 2
585  rawHitPtrTmp = rawHitPtr[0];
586  rawHitPtr[0] = rawHitPtr[1];
587  rawHitPtr[1] = rawHitPtrTmp;
588  rawHitPtrTmp = rawHitPtr[2];
589  rawHitPtr[2] = rawHitPtr[3];
590  rawHitPtr[3] = rawHitPtrTmp;
591 
592  Int_t split4_14_ierr = splitCluster(4, tmpClusterSizeList, rawHitPtr, *clusterIt, clusters, numTimeBins); // do splitting for the current cluster
593 
594  if (split4_14_ierr != kStOk)
595  LOG_WARN << "Cluster (ladder/sensor/meanColumn/meanRow: " << (*clusterIt)->getLadder() << "/" << (*clusterIt)->getSensor() << "/" << (*clusterIt)->getMeanColumn() << "/" << (*clusterIt)->getMeanRow() << ") splitting failed! returned " << split4_14_ierr << endm;
596  }
597 
598  //the 4th raw hit with minimum ADC
599  if ( (tmpRawHitMaxCharge[3] <= tmpRawHitMaxCharge[0]) && (tmpRawHitMaxCharge[3] <= tmpRawHitMaxCharge[1]) && (tmpRawHitMaxCharge[3] <= tmpRawHitMaxCharge[2]) ) {
600  tmpClusterSizeList[1] = 1; tmpClusterSizeList[2] = 2; tmpClusterSizeList[4] = 2; tmpClusterSizeList[5] = 2;
601  StIstRawHit *rawHitPtrTmp = 0;
602  //2, 3, 0, 1
603  rawHitPtrTmp = rawHitPtr[0];
604  rawHitPtr[0] = rawHitPtr[2];
605  rawHitPtr[2] = rawHitPtrTmp;
606  rawHitPtrTmp = rawHitPtr[1];
607  rawHitPtr[1] = rawHitPtr[3];
608  rawHitPtr[3] = rawHitPtrTmp;
609 
610  Int_t split4_14_ierr = splitCluster(4, tmpClusterSizeList, rawHitPtr, *clusterIt, clusters, numTimeBins); // do splitting for the current cluster
611 
612  if (split4_14_ierr != kStOk)
613  LOG_WARN << "Cluster (ladder/sensor/meanColumn/meanRow: " << (*clusterIt)->getLadder() << "/" << (*clusterIt)->getSensor() << "/" << (*clusterIt)->getMeanColumn() << "/" << (*clusterIt)->getMeanRow() << ") splitting failed! returned " << split4_14_ierr << endm;
614  }
615  }//end case 14
616  }//end splitting loop for clusters with size = 4
617 
618  if ( (*clusterIt)->getNRawHits() > 4 || (*clusterIt)->getNRawHits() < 3 )
619  continue;
620 
621  }//end clusters loop
622 
623  return kStOk;
624 };
625 
626 Int_t StIstSimpleClusterAlgo::doClustering(const StIstCollection &istCollection, StIstRawHitCollection &rawHitsOriginal, StIstClusterCollection &clusters )
627 {
628  unsigned char maxTb = UCHAR_MAX, usedTb = UCHAR_MAX;
629  unsigned char ladder = 0, sensor = 0, column = 0, row = 0;
630  float meanRow = 0., meanColumn = 0.;
631  float totCharge = 0., totChargeErr = 0.;
632  unsigned char clusterSize = 0, clusterSizeRPhi = 0, clusterSizeZ = 0;
633  unsigned char clusterType = kIstSimpleClusterAlgo;
634 
635  //get number of time bin used in this event
636  static unsigned char nTimeBins = istCollection.getNumTimeBins();
637  //sort raw hits in increasing order by geometry ID
638  rawHitsOriginal.sortByGeoId();
639 
640  //copy raw hit collection to a temporary vector
641  std::vector<StIstRawHit *> rawHits;
642  rawHits.reserve( rawHitsOriginal.getRawHitVec().size() );
643 
644  for ( std::vector< StIstRawHit * >::iterator rawHitIt = rawHitsOriginal.getRawHitVec().begin(); rawHitIt != rawHitsOriginal.getRawHitVec().end(); ++rawHitIt)
645  {
646  rawHits.push_back( new StIstRawHit( *(*rawHitIt)) );
647  }
648 
649  //do clustering
650  if (rawHits.size() > 0) {
651  std::vector<StIstRawHit *>::iterator rawHitIt = rawHits.begin();
652  //first raw hit
653  maxTb = (*rawHitIt)->getMaxTimeBin();
654 
655  if (maxTb >= nTimeBins) maxTb = (*rawHitIt)->getDefaultTimeBin();
656 
657  if (mTimeBin < nTimeBins) {
658  usedTb = mTimeBin;
659  }
660  else
661  usedTb = maxTb;
662 
663  ladder = (*rawHitIt)->getLadder();
664  sensor = (*rawHitIt)->getSensor();
665  column = (*rawHitIt)->getColumn();
666  row = (*rawHitIt)->getRow();
667  totCharge = (*rawHitIt)->getCharge(usedTb);
668  totChargeErr = (*rawHitIt)->getChargeErr(usedTb);
669  meanRow = row;
670  meanColumn = column;
671  clusterSize = 1;
672  clusterSizeRPhi = 1;
673  clusterSizeZ = 1;
674 
675  //first cluster (the 1st raw hit)
676  StIstCluster *newCluster = new StIstCluster((int)ladder * 10000 + clusters.getClusterVec().size(), ladder, sensor, meanRow, meanColumn, totCharge, totChargeErr, clusterType);
677  newCluster->setNRawHits(clusterSize);
678  newCluster->setNRawHitsRPhi(clusterSizeRPhi);
679  newCluster->setNRawHitsZ(clusterSizeZ);
680  newCluster->setMaxTimeBin(maxTb);
681 
682  std::vector< StIstRawHit * > &rawHitVec = newCluster->getRawHitVec();
683  rawHitVec.push_back(*rawHitIt);
684 
685  clusters.getClusterVec().push_back(newCluster); //store the first raw hit as the first cluster in the vector container
686 
687  //remove the clustered 1st raw hit from the raw hits list
688  rawHits.erase( rawHitIt );
689 
690  if ( rawHits.size() != 0 ) { //more than one raw hits found
691  float weight, tempSumCharge;
692  std::vector< StIstCluster * >::iterator clusterIt = clusters.getClusterVec().begin();
693 
694  //loop the existed clusters vector constainer
695  while ( clusterIt != clusters.getClusterVec().end() && !rawHits.empty() ) {
696  //loop the raw hits belong to the ith cluster
697  for (std::vector< StIstRawHit * >::iterator rawHitVecIt = (*clusterIt)->getRawHitVec().begin(); rawHitVecIt != (*clusterIt)->getRawHitVec().end(); rawHitVecIt++) {
698  StIstRawHit *rawHitPtr = *rawHitVecIt;
699  //loop rest raw hits in vector container
700  rawHitIt = rawHits.begin();
701 
702  while ( rawHitIt != rawHits.end() ) {
703  // check raw hit[i] and raw hit of ith existed cluster in a same column/row over one sensor area
704  if ( (((*rawHitIt)->getSensor() == rawHitPtr->getSensor()) && ((*rawHitIt)->getRow() == rawHitPtr->getRow()) && (((*rawHitIt)->getColumn() == rawHitPtr->getColumn() + 1) || ((*rawHitIt)->getColumn() == rawHitPtr->getColumn() - 1) )) ||
705  (((*rawHitIt)->getSensor() == rawHitPtr->getSensor()) && ((*rawHitIt)->getColumn() == rawHitPtr->getColumn()) && (((*rawHitIt)->getRow() == rawHitPtr->getRow() + 1) || ((*rawHitIt)->getRow() == rawHitPtr->getRow() - 1) )) ) {
706  clusterSize = (*clusterIt)->getNRawHits() + 1;
707 
708  if ( ((*rawHitIt)->getRow() == rawHitPtr->getRow()) )
709  clusterSizeZ = (*clusterIt)->getNRawHitsZ() + 1; //same row
710 
711  if ( ((*rawHitIt)->getColumn() == rawHitPtr->getColumn()) )
712  clusterSizeRPhi = (*clusterIt)->getNRawHitsRPhi() + 1; //same column
713 
714  maxTb = (*clusterIt)->getMaxTimeBin();
715 
716  if (mTimeBin < nTimeBins) {
717  usedTb = mTimeBin;
718  }
719  else
720  usedTb = maxTb;
721 
722  float currentRawHitCharge = (*rawHitIt)->getCharge(usedTb);
723  tempSumCharge = (*clusterIt)->getTotCharge() + currentRawHitCharge;
724  weight = currentRawHitCharge / tempSumCharge;
725 
726  ladder = (*clusterIt)->getLadder();
727  sensor = (*clusterIt)->getSensor();
728  meanColumn = (1.0 - weight) * (*clusterIt)->getMeanColumn() + weight * (*rawHitIt)->getColumn();
729  meanRow = (1.0 - weight) * (*clusterIt)->getMeanRow() + weight * (*rawHitIt)->getRow();
730  totCharge = tempSumCharge;
731  totChargeErr = sqrt( ( (*clusterIt)->getTotChargeErr() * (*clusterIt)->getTotChargeErr() + (*rawHitIt)->getChargeErr(usedTb) * (*rawHitIt)->getChargeErr(usedTb) ) / clusterSize );
732 
733  (*clusterIt)->setLadder(ladder);
734  (*clusterIt)->setSensor(sensor);
735  (*clusterIt)->setMeanColumn(meanColumn);
736  (*clusterIt)->setMeanRow(meanRow);
737  (*clusterIt)->setTotCharge(totCharge);
738  (*clusterIt)->setTotChargeErr(totChargeErr);
739  (*clusterIt)->setNRawHits(clusterSize);
740  (*clusterIt)->setNRawHitsRPhi(clusterSizeRPhi);
741  (*clusterIt)->setNRawHitsZ(clusterSizeZ);
742  (*clusterIt)->setMaxTimeBin(maxTb);
743  (*clusterIt)->setClusteringType(clusterType);
744 
745  //include the raw hit to the cluster's component vector
746  int itPosition = std::distance((*clusterIt)->getRawHitVec().begin(), rawHitVecIt);
747  (*clusterIt)->getRawHitVec().push_back(*rawHitIt);
748  rawHitVecIt = (*clusterIt)->getRawHitVec().begin() + itPosition;
749 
750  //remove the clustered ith raw hit from the raw hits list
751  int distance = std::distance(rawHits.begin(), rawHitIt);
752  rawHits.erase( rawHitIt );
753  rawHitIt = rawHits.begin() + distance;
754  }//same row/column decision loop over
755  else
756  rawHitIt++;
757  } //raw hits loop over
758  }//ith cluster's raw hits loop over
759 
760  //if the rawHitIt_th raw hit does not belong to the existed ith clusters then create a new cluster.
761  if (rawHits.size() < 1)
762  continue;
763 
764  rawHitIt = rawHits.begin();
765 
766  maxTb = (*rawHitIt)->getMaxTimeBin();
767 
768  if (maxTb >= nTimeBins) maxTb = (*rawHitIt)->getDefaultTimeBin();
769 
770  if (mTimeBin < nTimeBins) {
771  usedTb = mTimeBin;
772  }
773  else
774  usedTb = maxTb;
775 
776  ladder = (*rawHitIt)->getLadder();
777  sensor = (*rawHitIt)->getSensor();
778  column = (*rawHitIt)->getColumn();
779  row = (*rawHitIt)->getRow();
780  totCharge = (*rawHitIt)->getCharge(usedTb);
781  totChargeErr = (*rawHitIt)->getChargeErr(usedTb);
782  meanRow = row;
783  meanColumn = column;
784  clusterSize = 1;
785  clusterSizeRPhi = 1;
786  clusterSizeZ = 1;
787 
788  StIstCluster *newCluster1 = new StIstCluster((int)ladder * 10000 + clusters.getClusterVec().size(), ladder, sensor, meanRow, meanColumn, totCharge, totChargeErr, clusterType);
789  newCluster1->setNRawHits(clusterSize);
790  newCluster1->setNRawHitsRPhi(clusterSizeRPhi);
791  newCluster1->setNRawHitsZ(clusterSizeZ);
792  newCluster1->setMaxTimeBin(maxTb);
793 
794  int distanceCluster = std::distance(clusters.getClusterVec().begin(), clusterIt);
795 
796  std::vector< StIstRawHit * > &rawHitVec1 = newCluster1->getRawHitVec();
797  rawHitVec1.push_back(*rawHitIt);
798 
799  clusters.getClusterVec().push_back(newCluster1);
800 
801  clusterIt = clusters.getClusterVec().begin() + distanceCluster;
802  clusterIt++;
803  //remove the clustered 1st raw hit from the raw hits list
804  rawHits.erase( rawHitIt );
805  }//clusters loop over
806  }//end raw hits number > 1 cut
807  }//end raw hits number > 0 cut
808 
810  if (mSplitCluster) {
811  Int_t loc_ierr = doSplitting(clusters, nTimeBins);
812 
813  if (loc_ierr != kStOk) {
814  LOG_WARN << "StIstClusterMaker::Make(): Cluster splitting for ladder " << ladder << " returned " << loc_ierr << endm;
815  }
816  }
817 
818  return kStOk;
819 };
820 
821 
822 /***************************************************************************
823 *
824 * $Log: StIstSimpleClusterAlgo.cxx,v $
825 * Revision 1.18 2018/01/04 17:34:37 smirnovd
826 * [Cosmetic] Remove StRoot/ from include path
827 *
828 * $STAR/StRoot is already in the default path search
829 *
830 * Revision 1.17 2015/05/20 20:53:57 smirnovd
831 * Removed a priori true condition without changing the logic
832 *
833 * mTimeBin is unsigned char always >= 0
834 *
835 * Revision 1.16 2015/05/20 20:53:53 smirnovd
836 * Set default value of unsigned variables in a more explicit way
837 *
838 * Revision 1.15 2015/05/20 20:08:06 huangbc
839 * change unsigned char maxTb = -1 to char maxTb = -1.
840 *
841 * Revision 1.14 2015/05/19 16:19:47 perev
842 * bug #3102 Clearup
843 *
844 * Revision 1.13 2014/09/18 06:27:25 ypwang
845 * remove unneccessary check for raw hit electroincis ID check
846 *
847 * Revision 1.12 2014/09/17 20:39:45 smirnovd
848 * Squashed commit of the following:
849 *
850 * commit 37d3d404a31c9b152811232af55d37177162269d
851 * Author: Dmitri Smirnov <d.s@plexoos.com>
852 * Date: Wed Sep 17 16:11:22 2014 -0400
853 *
854 * Added an author to reflect on contributions
855 *
856 * commit 6ceacb443d2d35bc21295b81a3d25b7433d40260
857 * Author: Dmitri Smirnov <d.s@plexoos.com>
858 * Date: Wed Sep 17 16:09:48 2014 -0400
859 *
860 * [Minor] Reversed the logic and saved one level of intentation
861 *
862 * commit 4bc24031445ecce9f19b940697d13cc8a755aaf1
863 * Author: Dmitri Smirnov <d.s@plexoos.com>
864 * Date: Wed Sep 17 16:06:42 2014 -0400
865 *
866 * Do not use standard ROOT's dictionary macroses since the classes are transient by design
867 *
868 * Revision 1.11 2014/09/17 20:33:32 smirnovd
869 * Squashed commit of the following:
870 *
871 * commit 72dc19a6663ea31c719c1a61f6d2b4752dd766aa
872 * Author: Dmitri Smirnov <d.s@plexoos.com>
873 * Date: Wed Sep 17 12:34:42 2014 -0400
874 *
875 * Minor code refactoring, clean up
876 *
877 * commit e083a10a9fb60b7dcce692ef8043b9227c12768b
878 * Author: Dmitri Smirnov <d.s@plexoos.com>
879 * Date: Wed Sep 17 12:18:16 2014 -0400
880 *
881 * Removed pointless comments
882 *
883 * commit 88d51857362c91c954704cec4a31a0b0fa7fccc5
884 * Author: Dmitri Smirnov <d.s@plexoos.com>
885 * Date: Wed Sep 17 12:17:26 2014 -0400
886 *
887 * Updated description in doxygen comments
888 *
889 * commit eb09527489179fc7dab6aa7f23fd132b25185bb1
890 * Author: Dmitri Smirnov <d.s@plexoos.com>
891 * Date: Tue Sep 9 15:15:56 2014 -0400
892 *
893 * StIstScanClusterAlgo: Removed unused variable
894 *
895 * commit 1a8df63533c71a0e2ba4d8275ebf89f4e3004765
896 * Author: Dmitri Smirnov <d.s@plexoos.com>
897 * Date: Fri Aug 22 16:04:47 2014 -0400
898 *
899 * Neatened headers: Removed unused, spelled paths in includes explicitly as it slightly helps in identifying dependencies
900 *
901 * commit 972e8ed41403bd680ade5ecc509f8bca004e86ee
902 * Author: Dmitri Smirnov <d.s@plexoos.com>
903 * Date: Wed Sep 17 12:34:20 2014 -0400
904 *
905 * Minor stylistic changes
906 *
907 * commit 57daf5a1e0b3246fd12f1dd1c2ca089b62930c83
908 * Author: Dmitri Smirnov <d.s@plexoos.com>
909 * Date: Tue Sep 16 16:29:14 2014 -0400
910 *
911 * Improved doxygen comments
912 *
913 * Revision 1.10 2014/09/07 13:54:45 ypwang
914 * move setUsedTimeBin() and setSplitFlag() setters from inherited classes to their base class StIstIClusterAlgo.h
915 *
916 * Revision 1.9 2014/09/07 11:41:36 ypwang
917 * ClassDef version updated from 1 to 0, and remove Init() function
918 *
919 * Revision 1.8 2014/08/22 15:55:15 smirnovd
920 * Fixed style with astyle -s3 -p -H -A3 -k3 -O -o -y -Y -f
921 *
922 * Revision 1.7 2014/08/22 15:50:00 smirnovd
923 * Moved CVS history to the end of file
924 *
925 * Revision 1.6 2014/02/16 21:42:54 ypwang
926 * getting number of time bins used in current event by StIstCollection::getNumTimeBins() function
927 *
928 * Revision 1.5 2014/02/15 20:12:58 ypwang
929 * update due to replace raw hit container type from std::map to std::vector, and minor bug corrected for the simple clustering algorithm
930 *
931 * Revision 1.4 2014/02/10 16:33:44 smirnovd
932 * Trimmed trailing spaces, expanded tabs to eight spaces
933 *
934 * Revision 1.3 2014/02/08 03:34:16 ypwang
935 * updating scripts
936 *
937 *
938 ****************************************************************************
939 * StIstSimpleClusterAlgo.cxx,v 1.0
940 * Revision 1.0 2013/11/04 15:55:30 Yaping
941 * Initial version
942 ****************************************************************************/
unsigned char getLadder() const
1-24
Definition: StIstRawHit.cxx:46
unsigned char getColumn() const
1-12
Definition: StIstRawHit.cxx:62
unsigned char getRow() const
1-64
Definition: StIstRawHit.cxx:56
unsigned char getSensor() const
1-6
Definition: StIstRawHit.cxx:51
Definition: Stypes.h:41