StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFgtSeededClusterAlgo.cxx
1 //
2 // $Id: StFgtSeededClusterAlgo.cxx,v 1.31 2014/01/16 18:22:51 xuanli Exp $
3 // $Log: StFgtSeededClusterAlgo.cxx,v $
4 // Revision 1.31 2014/01/16 18:22:51 xuanli
5 // Fix the error for stardev production
6 //
7 // Revision 1.30 2013/03/24 20:25:24 jeromel
8 // SeededClusterAlgo created a canvas on exit, removed
9 //
10 // Revision 1.29 2013/03/15 15:53:49 avossen
11 // check seed before overwriting w/ next to cluster flag
12 //
13 // Revision 1.28 2013/03/13 15:57:35 akio
14 // Fix a bug with ZS data and phi-even strip clustering logic
15 // Also remove some kStFgtNumTimebins and use dynamic local mMaxTimeBin from StFgtCollection
16 //
17 // Revision 1.27 2013/02/20 23:33:28 avossen
18 // add strips on both sides of the cluster
19 //
20 // Revision 1.26 2013/02/20 02:18:19 avossen
21 // *** empty log message ***
22 //
23 // Revision 1.25 2013/02/20 01:32:27 avossen
24 // added n strips before and after cluster
25 //
26 // Revision 1.24 2013/02/19 18:24:04 avossen
27 // *** empty log message ***
28 //
29 // Revision 1.23 2012/12/10 23:18:01 avossen
30 // merged cluster finder
31 //
32 // Revision 1.22 2012/11/27 18:00:07 akio
33 // - Filling NStrip/SeedType/MaxTimebin/EvenOddChargeAsy in StFgtHit
34 // - Accepting kFgtSeedTypes4 & 5 for clustring
35 // - Setting kFgtClusterTooBig instead of kFgtClusterNo into strips when cluster is too big
36 // (Seedtype of the seed strip will not be overwritten)
37 // - Adding setThreshold2AddStrip() [proposed default 2 ~ 3 from cosmic data... no idea for run12 data]
38 // This will be used in isSameCluster() and this number times ChargeUncert() will be the threshold on charge
39 // (timebin sum) for a strip to be included in cluster if neighbore. It was hard coded to be 1.0 before.
40 // Too low threshold sometimes kill cluster because "cluster too big"
41 // - Slight code change to make trying different weight for getting R/PHI easy...
42 // - Slight code change for phi/even strip logic... hopefully improved
43 //
44 // Revision 1.21 2012/07/03 23:21:24 avossen
45 // *** empty log message ***
46 //
47 // Revision 1.20 2012/07/03 03:32:29 avossen
48 // ordinate now computed correctly...
49 //
50 // Revision 1.19 2012/06/30 23:30:37 avossen
51 // small changes in seeded cluster finder
52 //
53 // Revision 1.18 2012/06/14 04:43:03 avossen
54 // fixed geoId bug
55 //
56 // Revision 1.17 2012/06/12 19:28:48 avossen
57 // *** empty log message ***
58 //
59 // Revision 1.16 2012/06/10 01:05:19 avossen
60 // *** empty log message ***
61 //
62 // Revision 1.15 2012/06/09 18:03:50 avossen
63 // fixed bug
64 //
65 // Revision 1.14 2012/06/08 20:22:21 avossen
66 // updated cluster algo to find even p clusters
67 //
68 // Revision 1.13 2012/06/08 03:52:41 avossen
69 // added one sigma strips to clusters
70 //
71 // Revision 1.12 2012/03/17 23:30:16 avossen
72 // fudged the cluster maker
73 //
74 // Revision 1.11 2012/03/16 19:50:18 balewski
75 // *** empty log message ***
76 //
77 // Revision 1.10 2012/03/16 19:49:46 avossen
78 // *** empty log message ***
79 //
80 // Revision 1.9 2012/03/16 19:43:19 avossen
81 // added option to allow to jump strips
82 //
83 // Revision 1.8 2012/03/16 19:41:15 avossen
84 // added option to allow to jump strips
85 //
86 // Revision 1.7 2012/03/08 17:43:40 avossen
87 // added default cluster algo, made StFgtIClusterAlgo destructor =0
88 //
89 // Revision 1.6 2012/03/07 18:07:45 sgliske
90 // StFgtStrip::getClusterSeed() -> StFgtStrip::getClusterSeedType
91 // StFgtStrip::setClusterSeed() -> StFgtStrip::setClusterSeedType
92 //
93 // Revision 1.5 2012/03/07 03:57:23 avossen
94 // various updates
95 //
96 // Revision 1.4 2012/03/06 18:54:28 avossen
97 // added weighted mean and error to seeded clustering
98 //
99 // Revision 1.3 2012/03/01 16:38:13 avossen
100 // implemented tweaks to clustering
101 //
102 // Revision 1.2 2012/02/29 20:29:08 avossen
103 // changes to seed and cluster algo
104 //
105 // Revision 1.1 2012/02/28 19:34:29 avossen
106 // added new cluster maker
107 //
108 
109 // \class StFgtSeededClusterAlgo
110 // \author Anselm Vossen (avossen@indiana.edu)
111 //
112 #include "TStyle.h"
113 #include "StFgtSeededClusterAlgo.h"
114 #include "StRoot/StFgtUtil/geometry/StFgtGeom.h"
115 //#include <TCanvas.h>
116 #include "StRoot/StEvent/StFgtCollection.h"
117 #include "StRoot/StEvent/StFgtStripCollection.h"
118 #include "StRoot/StEvent/StFgtStrip.h"
119 #include "StRoot/StEvent/StFgtHitCollection.h"
120 #include "StRoot/StEvent/StFgtHit.h"
121 #include "StRoot/StFgtUtil/StFgtConsts.h"
122 #include "StRoot/StFgtDbMaker/StFgtDbMaker.h"
123 #include "StRoot/StFgtDbMaker/StFgtDb.h"
124 
125 
126 //for floor
127 #include <math.h>
128 #include <TH1F.h>
129 #include <TH2F.h>
130 #include <TF1.h>
131 #include <TGraphAsymmErrors.h>
132 #include <TGraphErrors.h>
133 #include <TGraph.h>
134 
135 //#define KEEP_BIG_AND_NOISY_CLUSTERS
136 
137 
138 StFgtSeededClusterAlgo::StFgtSeededClusterAlgo():up(true),down(false),stepTwo(true),mThreshold2AddStrip(3.0),numAdditionalStrips(2),mDb(0)
139 {
140  //nothing else to do....
141 };
142 
143 
144 Int_t StFgtSeededClusterAlgo::Init()
145 {
146  hGaussFitStatus=new TH1D("fgt_gFitStatus","gFitStatus",10,-1,8);
147  hGaussFitChi2=new TH1D("fgt_gFitChi2overNdf","gFitChi2overNdf",100,0,10);
148  hTbFitStatus=new TH1D("fgt_tbFitStatus","tbFitStatus",10,-1,8);
149  hTbFitChi2=new TH1D("fgt_tbFitChi2","tbFitChi2",100,0,10);
150 
151  hTbMaxCorr=new TH2D("fgt_tbmaxcorr","tbmaxcorr",200,0,1000,200,0,1000);
152  hTbMaxRatio=new TH1D("fgt_tbmaxratio","tbmaxratio",200,0,1);
153  hTbSideCorr=new TH2D("fgt_tbsidecorr","tbsidecorr",200,0,1000,200,0,1000);
154  hTbSideRatio=new TH1D("fgt_tbsideratio","tbsideratio",200,0,1);
155 
156  return kStOk;
157 };
158 //void StFgtSeededClusterAlgo::doStripFit(stripWeightMap_t &strips)
159 void StFgtSeededClusterAlgo::doStripFit(void* stripsT)
160 {
161  stripWeightMap_t& strips = *((stripWeightMap_t*) stripsT);
162  Double_t x[40];
163  Double_t y[40];
164  Double_t ex[40];
165  Double_t ey[40];
166  int numStripsInClu=strips.size();
167  // TF1 *func = new TF1("func","[0]*(x>[1])*(x-[1])**2*exp(-(x-[1])*[2])");
168  TF1 *func = new TF1("func","[0]*(x>[1])*(x-[1])**2*exp(-(x-[1])*0.55)");
169  func->SetParName(0,"A");
170  func->SetParName(1,"t0");
171  // func->SetParName(2,"invtau");
172 
173  int stripIt=0;
174  int stripMaxPos=-1;
175  int stripMaxAdc=-1;
176  for(stripWeightMap_t::iterator it=strips.begin();it!=strips.end();it++)
177  {
178  // cout <<"setting bin " << binCounter << " to " << it->first->getCharge()<<endl;
179  // h1->SetBinContent(binCounter,it->first->getCharge());
180  // StFgtGeom::getPhysicalCoordinate(it->first->getGeoId(),disc,quadrant,layer,ordinate,lowerSpan,upperSpan);
181 
182  for(int tb=0;tb<mMaxTimeBin;tb++)
183  {
184  y[tb]=it->first->getAdc(tb);
185  if(y[tb]>stripMaxAdc)
186  {
187  stripMaxPos=stripIt;
188  stripMaxAdc=y[tb];
189  }
190  }
191  stripIt++;
192  }
193  stripIt=0;
194  for(stripWeightMap_t::iterator it=strips.begin();it!=strips.end();it++)
195  {
196  // cout <<"setting bin " << binCounter << " to " << it->first->getCharge()<<endl;
197  // h1->SetBinContent(binCounter,it->first->getCharge());
198  // StFgtGeom::getPhysicalCoordinate(it->first->getGeoId(),disc,quadrant,layer,ordinate,lowerSpan,upperSpan);
199  // cout <<"adc vals: ";
200  for(int tb=0;tb<mMaxTimeBin;tb++)
201  {
202  x[tb]=tb;
203  y[tb]=it->first->getAdc(tb);
204  ey[tb]=it->first->getPedErr();
205  ex[tb]=0;
206  // cout <<y[tb] <<", ";
207  }
208  // cout <<endl;
209  TGraphErrors* tg1=new TGraphErrors(mMaxTimeBin,x,y,ex,ey);
210  Int_t tbFitStatus=tg1->Fit(func);
211  float amp,t0,invtau,chi2Ndf, chi2;
212  amp=func->GetParameter(0);
213  t0=func->GetParameter(1);
214  // invtau=func->GetParameter(2);
215  chi2Ndf=func->GetChisquare()/(float)func->GetNDF();
216  chi2=func->GetChisquare();
217  if(chi2Ndf>0.1 && chi2Ndf<2&& tbFitStatus==0)
218  {
219  if(stripIt==stripMaxPos)
220  {
221  hTbMaxCorr->Fill(it->first->getCharge(),amp);
222  hTbMaxRatio->Fill(amp/it->first->getCharge());
223  }
224  else
225  {
226  hTbSideCorr->Fill(it->first->getCharge(),amp);
227  hTbSideRatio->Fill(amp/it->first->getCharge());
228  }
229  it->first->setCharge(amp);
230  }
231  stripIt++;
232  hTbFitStatus->Fill(tbFitStatus);
233  hTbFitChi2->Fill(chi2Ndf);
234  delete tg1;
235  }
236  delete func;
237 }
238 
239 
240 Float_t StFgtSeededClusterAlgo::doClusterShapeFit(void* stripsT)
241 {
242  stripWeightMap_t& strips = *((stripWeightMap_t*) stripsT);
243  Double_t x[40];
244  Double_t y[40];
245  Double_t ex[40];
246  Double_t ey[40];
247  Double_t ordinate, lowerSpan, upperSpan;
248  Short_t disc, quadrant;
249  Char_t layer;
250  Double_t firstOrd,lastOrd;
251  StFgtGeom::getPhysicalCoordinate(strips.begin()->first->getGeoId(),disc,quadrant,layer,firstOrd,lowerSpan,upperSpan);
252  StFgtGeom::getPhysicalCoordinate((strips.rbegin())->first->getGeoId(),disc,quadrant,layer,lastOrd,lowerSpan,upperSpan);
253  if(firstOrd>lastOrd)
254  {
255  Double_t tmpOrd=lastOrd;
256  lastOrd=firstOrd;
257  firstOrd=tmpOrd;
258  }
259  Double_t sigGuess=(lastOrd-firstOrd)/2;
260  Double_t ampGuess=-9999;//set later
261  Double_t meanGuess=0;//set later
262 
263  // TH1F* h1=new TH1F("h1","h1",numStripsInClu,firstOrd,lastOrd);
264 
265  int binCounter=0;//1 for histo
266 
267  for(stripWeightMap_t::iterator it=strips.begin();it!=strips.end();it++)
268  {
269  // cout <<"setting bin " << binCounter << " to " << it->first->getCharge()<<endl;
270  // h1->SetBinContent(binCounter,it->first->getCharge());
271  StFgtGeom::getPhysicalCoordinate(it->first->getGeoId(),disc,quadrant,layer,ordinate,lowerSpan,upperSpan);
272  x[binCounter]=ordinate;
273  y[binCounter]=it->first->getCharge();
274  if(y[binCounter]>ampGuess)
275  ampGuess=y[binCounter];
276  meanGuess+=ordinate;
277  ey[binCounter]=it->first->getChargeUncert()*1.6;//akio's factor
278  ex[binCounter]=0;
279  // cout <<"counter: " << binCounter << " x: " << ordinate <<" charge: "<< y[binCounter] <<" error: " << ey[binCounter] <<endl;
280  binCounter++;
281  }
282  meanGuess/=strips.size();
283 
284  TGraphErrors* tg=new TGraphErrors(binCounter,x,y,ex,ey);
285  // h1->Fit("gaus");
286 
287 
288  TF1* f1=new TF1("f1","gaus",firstOrd-0.001,lastOrd+0.001);
289  f1->SetParameters(ampGuess,meanGuess,sigGuess);
290 
291  Int_t fitStatus=tg->Fit("f1");
292  hGaussFitChi2->Fill(f1->GetChisquare()/(float)f1->GetNDF());
293  hGaussFitStatus->Fill(fitStatus);
294  // TF1* f1=(TF1*)h1->GetFunction("gaus");
295  // TF1* f1=(TF1*)tg->GetFunction("gaus");
296  float fAmp=f1->GetParameter(1);
297  // delete h1;
298  delete f1;
299  delete tg;
300  // cout <<"del function" << endl;
301  //probably not a good idea...
302  // delete f1;
303 
305  if(binCounter>=3&&fitStatus==0&& fAmp>=firstOrd && fAmp<=lastOrd)
306  return fAmp;
307  else
308  return -1;
309 }
310 
313 {
314  Double_t ordinate, lowerSpan, upperSpan;
315  Short_t disc, quadrant;
316  Char_t layer;
317  Double_t accuCharge=0;
318  Double_t accuChargeWeight=0;
319  Double_t accuChargeWeightEven=0;
320  Double_t accuChargeEven=0;
321  Double_t accuChargeUneven=0;
322  Double_t accuChargeSq=0;
323  Double_t accuChargeSqEven=0;
324  Double_t accuChargeSqWeight=0;
325  Double_t accuChargeError=0;
326  Double_t accuChargeErrorEven=0;
327  Int_t numStrips=0;
328  Int_t numStripsEven=0;
329  Double_t meanOrdinate=0;
330  Double_t meanOrdinateWeight=0;
331  Double_t meanSqOrdinate=0;
332  Double_t meanOrdinateEven=0;
333  Double_t meanOrdinateEvenWeight=0;
334  Double_t meanSqOrdinateEven=0;
335  Double_t meanGeoId=0;
336  Double_t meanGeoIdEven=0;
337  Bool_t chargeEven=false;
338 
339  stripWeightMap_t &strips = cluster->getStripWeightMap();
340 
341  float a[kFgtNumTimeBins]; memset(a,0,sizeof(a)); // adc vs timebin (sum of all strips in cluster)
342  float e[kFgtNumTimeBins]; memset(e,0,sizeof(e)); // adc err vs timebin (sum of all strips in cluster)
343  int flag[kFgtNumTimeBins]; memset(flag,0,sizeof(flag)); //if saturated
344  int seedtype=0;
345 
346 
348 #ifdef DO_FGT_STRIP_FIT
349  doStripFit(&strips);
350 #endif
351 
352  Float_t clusterShapeFitAmp=-1;
353 #ifdef DO_FGT_CLUSTER_SHAPE_FIT
354  clusterShapeFitAmp=doClusterShapeFit(&strips);
355 #endif
356 
357  for(stripWeightMap_t::iterator it=strips.begin();it!=strips.end();it++)
358  {
359  Double_t charge=it->first->getCharge();
360  //Double_t charge=it->first->getMaxAdc();
361  Double_t weight=charge;
362  //Double_t weight=charge*charge;
363  //Double_t weight=sqrt(charge);
364  //Double_t weight=log(charge);
365  accuCharge+=charge;
366  accuChargeWeight+=weight;
367  for(int i=0; i<mMaxTimeBin; i++) {
368  a[i]+=it->first->getAdc(i);
369  e[i]+=it->first->getPedErr() * it->first->getPedErr();
370  if(it->first->getAdc(i) > 2800) {flag[i]=1;}
371  }
372  int type=it->first->getClusterSeedType();
373  if(type>=kFgtSeedType1 && type<kFgtSeedTypeMax) {
374  if(seedtype==0) {seedtype=type;}
375  else if(type<seedtype) {seedtype=type;} //take smallest seedtype besides kFgtSeedTypeNo as cluster seed type
376  }
377  // cout <<"looking at geo id " << it->first->getGeoId() <<" for cluster info filling " <<endl;
378  StFgtGeom::getPhysicalCoordinate(it->first->getGeoId(),disc,quadrant,layer,ordinate,lowerSpan,upperSpan);
379  if(it->first->getGeoId()%2)
380  accuChargeUneven+=charge;
381  else
382  {
383  accuChargeWeightEven+=weight;
384  numStripsEven++;
385  accuChargeEven+=charge;
386  //accuChargeSqEven+=(charge*charge);
387  accuChargeSqEven+=(weight*weight);
388  accuChargeErrorEven+=it->first->getChargeUncert();
389  //meanSqOrdinateEven+=ordinate*ordinate*charge*charge;
390  meanSqOrdinateEven+=ordinate*ordinate*weight*weight;
391  //meanGeoIdEven+=((it->first->getGeoId())*(charge));
392  meanGeoIdEven+=((it->first->getGeoId())*(weight));
393  meanOrdinateEven+=ordinate*charge;
394  meanOrdinateEvenWeight+=ordinate*weight;
395  }
396 
397  //accuChargeSq+=(charge*charge);
398  accuChargeSq+=(weight*weight);
399  accuChargeError+=it->first->getChargeUncert();
400  numStrips++;
401 
402  meanOrdinate+=ordinate*charge;
403  meanOrdinateWeight+=ordinate*weight;
404  //meanSqOrdinate+=ordinate*ordinate*charge*charge;
405  meanSqOrdinate+=ordinate*ordinate*weight*weight;
406  // cout <<"charge: " << charge << " ordinate: " << ordinate << " meanSqOrd: " << meanSqOrdinate << endl;
407  //meanGeoId+=((it->first->getGeoId())*(charge));
408  meanGeoId+=((it->first->getGeoId())*(weight));
409  }
410  // cout <<"setting seedtype: " << seedtype <<endl;
411  cluster->setSeedType(seedtype);
412 
413  int maxtbin;
414  float maxadc=0.0;
415  for(int i=0; i<mMaxTimeBin; i++){
416  e[i]=sqrt(e[i]);
417  if(a[i]>maxadc){
418  maxadc=a[i];
419  maxtbin=i;
420  }
421  }
422  cluster->setMaxTimeBin(maxtbin);
423  cluster->calcMaxAdc();
424 
425 #ifdef __LANDAU_FIT__
426  //landau fitting with asymm error
427  TGraphAsymmErrors *g = new TGraphAsymmErrors(mMaxTimeBin);
428  for(int i=0; i<mMaxTimeBin; i++){
429  g->SetPoint(i,float(i),float(a[i]));
430  float eh=e[i];
431  if(flag[i]==1) eh=2000;
432  g->SetPointError(i,0,0,e[i],eh);
433  //printf("tmax=%2d i=%2d adc=%5.0f err=%4.0f\n",mMaxTimeBin,i,a[i],e[i]);
434  }
435  int res=g->Fit("landau","0Q");
436  TF1 *f = g->GetFunction("landau");
437  float chi2=f->GetChisquare()/float(f->GetNDF());
438  cluster->setLandau(f->GetParameter(0),f->GetParameter(1),f->GetParameter(2),chi2);
439  //printf("Norm=%6.1f Mpv=%6.2f Sigma=%6.2f Chi2=%6.2f\n",f->GetParameter(0),f->GetParameter(1),f->GetParameter(2),chi2);
440 #endif
441 
442  float asy=(accuChargeEven-accuChargeUneven)/accuCharge;
443  cluster->setEvenOddChargeAsy(asy);
444  if(asy>0.8 && layer=='P' && numStripsEven>=2)
445  {
446  // cout <<"charge even cluster " << endl;
447  chargeEven=true;
448  //cout <<"r probably < 20"<<endl;
449  //r is probably in r<20
450  // accuCharge-=accuChargeUneven;
451  stripWeightMap_t::iterator it=strips.begin();
452  while(it!=strips.end())
453  {
454  // cout <<"strip geoId: "<< it->first->getGeoId() << endl;
455  if(it->first->getGeoId()%2)
456  {
457  // cout <<"erased! " << endl;
458  // it->first->setClusterSeedType(kFgtSeedTypeNo);
460  if(it->first->getClusterSeedType()==kFgtSeedTypeNo || it->first->getClusterSeedType()>kFgtClusterSeedInSeaOfNoise)
461  it->first->setClusterSeedType(kFgtNextToCluster);
462  strips.erase(it);
463  if(!strips.empty())
464  it=strips.begin();
465  else
466  break;
467  }
468  else
469  it++;
470  }
471  // cout <<"done erasing"<<endl;
472  }
473 
474  stripWeightMap_t::reverse_iterator itBack=strips.rbegin();
475  // if(strips.size()>1)
476  // {
477  if(itBack->first->getClusterSeedType()==kFgtClusterPart)
478  itBack->first->setClusterSeedType(kFgtClusterEndUp);
479  // if(strips.begin()->first->getClusterSeedType()>=kFgtSeedType1 && strips.begin()->first->getClusterSeedType()<=kFgtSeedType3)
480  if(strips.begin()->first->getClusterSeedType()==kFgtClusterPart)
481  (strips.begin())->first->setClusterSeedType(kFgtClusterEndDown);
482  // }
483 
484  if(chargeEven)
485  {
486  cluster->setCharge(accuChargeEven);
487  meanOrdinateEven /= (Double_t)accuChargeEven;
488  meanOrdinateEvenWeight /= (Double_t)accuChargeWeightEven;
489  // cout <<" event charge: geoevn: " << meanGeoIdEven <<" charge: " << accuChargeWeightEven << " geo: " << meanGeoIdEven/accuChargeWeightEven <<endl;
490  meanGeoIdEven /= accuChargeWeightEven;
491  meanSqOrdinateEven /= (Double_t)accuChargeSqEven;
492 
493  meanGeoId=meanGeoIdEven;
494  meanOrdinate=meanOrdinateEven;
495  meanOrdinateWeight=meanOrdinateEvenWeight;
496  // meanSqOrdinate -= meanOrdinateEven*meanOrdinateEven;
497  meanSqOrdinate=meanSqOrdinateEven;
498  meanSqOrdinate=-meanOrdinate*meanOrdinate;
499  accuChargeError=accuChargeErrorEven;
500  numStrips=numStripsEven;
501  }
502  else
503  {
504  cluster->setCharge(accuCharge);
505  meanOrdinate /= (Double_t)accuCharge;
506  meanOrdinateWeight /= (Double_t)accuChargeWeight;
507  meanGeoId /= accuChargeWeight;
508  meanSqOrdinate /= (Double_t)accuChargeSq;
509  meanSqOrdinate -= meanOrdinate*meanOrdinate;
510  }
511  numStrips > 1 ? cluster->setChargeUncert(sqrt(accuChargeError/((Double_t)numStrips-1))) : cluster->setChargeUncert(sqrt(accuChargeError/((Double_t)numStrips)));
512 
513 
514  //cout <<" meanOrdinate: " << meanOrdinate <<" error: " << meanSqOrdinate <<endl;
515  //cout <<" meanOrdinate= " << meanOrdinate <<" meanOrdinateWeight=" << meanOrdinateWeight <<endl;
516 
517  if( meanSqOrdinate > 0 )
518  meanSqOrdinate = sqrt(meanSqOrdinate);
519  // meanSqOrdinate is now the st. dev. of the ordinate
520  // avoid unreasonable small uncertainty, due to small cluster sizes
521 
522  Double_t pitch = ( layer == 'R' ? StFgtGeom::radStrip_pitch() : StFgtGeom::phiStrip_pitch() );
523  //cout <<" pitch is : " <<pitch <<endl;
524  // if( meanSqOrdinate < 2*pitch )
525  // cout <<"got " << meanOrdinate << " as weighted result " <<endl;
526  //replace with fit result
527  if(clusterShapeFitAmp>0)
528  meanOrdinate=clusterShapeFitAmp;
529  if( meanSqOrdinate < 0.001 )
530  meanSqOrdinate = pitch;
531  if(layer=='R')
532  {
533  cluster->setPositionR(meanOrdinateWeight);
534  cluster->setErrorR(meanSqOrdinate);
535  }
536  else
537  {
538  cluster->setPositionPhi(meanOrdinateWeight);
539  cluster->setErrorPhi(meanSqOrdinate);
540  }
541  if(meanGeoId<0)
542  {
543  // cout <<"geo id < 0, " <<" even? " << chargeEven <<" accuChargeWeight: " << accuChargeWeight <<endl;
544  }
545  // cout <<"mean geo Id: " << meanGeoId << " setting to: " <<floor(meanGeoId+0.5) <<endl;
546  cluster->setCentralStripGeoId(floor(meanGeoId+0.5));
547  // cout <<"setting geo id cluster: " << cluster->getCentralStripGeoId()<<endl;
548  // if(cluster->getCentralStripGeoId()<=0)
549  //if(cluster->getCentralStripGeoId()==18974)
550  /* {
551  // cout <<" cluster has strips: " <<endl;
552  for(stripWeightMap_t::iterator it=strips.begin();it!=strips.end();it++)
553  {
554  Double_t charge=it->first->getCharge();
555  cout <<"charge: " << it->first->getCharge() << " geoId: "<< it->first->getGeoId() <<endl;
556  }
557  cout <<"cluster charge: "<< cluster->charge() <<endl;
558  }*/
559 
560  cluster->setNstrip(numStrips);
561 
563 
564  if(!strips.empty())
565  // if(false)
566  {
567  stripWeightMap_t::iterator itFirstStrip=strips.begin();
568  stripWeightMap_t::reverse_iterator itLastStrip=strips.rbegin();
569  Int_t firstGeoId=itFirstStrip->first->getGeoId();
570  Int_t lastGeoId=itLastStrip->first->getGeoId();
571  StFgtGeom::getPhysicalCoordinate(firstGeoId,disc,quadrant,layer,ordinate,lowerSpan,upperSpan);
572  //lets assume that the strip exist, since it is part of the cluster
573  Int_t clusterQuad=quadrant;
574  Int_t clusterLayer=layer;
575  Int_t clusterDisk=disc;
576  // cout <<" looking at disk: " << disc <<endl;
577  Int_t rdo, arm, apv, chan;
578  firstGeoId--;
579 
580  // cout <<"last geo Id: " << lastGeoId <<endl;
581  lastGeoId++;
582  // cout <<"looking at cluster with first geo: " << firstGeoId <<" and last: " << lastGeoId <<endl;
583  for(int iGeo=firstGeoId;iGeo>(firstGeoId-(chargeEven+1)*numAdditionalStrips);iGeo--)
584  {
585  Int_t ret=StFgtGeom::getPhysicalCoordinate(iGeo,disc,quadrant,layer,ordinate,lowerSpan,upperSpan);
587  if(ret!=kFgtError)
588  {
589  if(disc==clusterDisk&&layer==clusterLayer&&quadrant==clusterQuad)
590  {
591  for( StSPtrVecFgtStripIterator it=allStrips.getStripVec().begin();it!=allStrips.getStripVec().end();++it)
592  {
593  if((*it)->getGeoId()==iGeo)
594  {
595  if((*it)->getClusterSeedType()==kFgtSeedTypeNo || (*it)->getClusterSeedType()>kFgtClusterSeedInSeaOfNoise)
596  (*it)->setClusterSeedType(kFgtNextToCluster);
597  }
598 
599  }
602  /*
603  if(mDb)
604  {
605  mDb->getElecCoordFromGeoId(iGeo, rdo,arm,apv,chan);
606  Int_t elecId = StFgtGeom::encodeElectronicId( rdo, arm, apv, chan );
607  StFgtStrip* stripPtr = allStrips.getStrip( elecId );
608  if(elecId>=kFgtNumElecIds)
609  cout <<"wrong elec id!!!!!!!!!!!!!!" << endl;
610  //existed data
611  if(!stripPtr)
612  cout <<"no Strip!!! " <<endl;
613  //shouldn't happen
614  if(stripPtr->getGeoId()>=0)
615  {
616  // cout <<"read geo id: " << stripPtr->getGeoId() <<endl;
617  // cout <<" the pointer is: " << stripPtr <<endl;
618 
619  // stripPtr->setClusterSeedType(kFgtNextToCluster);
620  // cout <<"added geo: " << iGeo <<endl;
621  }
622  }
623  else
624  {
625  // cout <<"no db! " <<endl;
626  }
627  */
628 
629  }
630  }
631  }
632  for(int iGeo=lastGeoId;iGeo<(lastGeoId+(chargeEven+1)*numAdditionalStrips);iGeo++)
633  {
634  Int_t ret=StFgtGeom::getPhysicalCoordinate(iGeo,disc,quadrant,layer,ordinate,lowerSpan,upperSpan);
635  if(ret!=kFgtError)
636  {
637  if(disc==clusterDisk&&layer==clusterLayer&&quadrant==clusterQuad)
638  {
639 
640  for( StSPtrVecFgtStripIterator it=allStrips.getStripVec().begin();it!=allStrips.getStripVec().end();++it)
641  {
642  if((*it)->getGeoId()==iGeo)
643  {
644  // cout <<"from vec: "<< (*it) <<endl;
645  if((*it)->getClusterSeedType()==kFgtSeedTypeNo || (*it)->getClusterSeedType()>kFgtClusterSeedInSeaOfNoise)
646  (*it)->setClusterSeedType(kFgtNextToCluster);
647  }
648 
649  }
650 
652  /*
653  if(mDb)
654  {
655  cout <<"got db " <<endl;
656  mDb->getElecCoordFromGeoId(iGeo, rdo,arm,apv,chan);
657  Int_t elecId = StFgtGeom::encodeElectronicId( rdo, arm, apv, chan );
658  if(elecId>=kFgtNumElecIds)
659  cout <<"wrong elec id!!!!!!!!!!!!!!" << endl;
660  StFgtStrip* stripPtr = allStrips.getStrip( elecId );
661  //existed data
662  if(!stripPtr)
663  cout <<"no Strip!!! " <<endl; //shouldn't happen
664  if(stripPtr->getGeoId()>=0)
665  {
666  cout <<"read geo id: " << stripPtr->getGeoId() <<endl;
667  stripPtr->setClusterSeedType(kFgtNextToCluster);
668  cout <<"added geo: " << iGeo <<endl;
669  }
670  }
671  */
673 
674  }
675  }
676  }
677  }
678 
679 
680 // cout <<"end fill.." <<endl;
681 }
682 
683 
684 
685 Int_t StFgtSeededClusterAlgo::Finish()
686 {
687 #if 0
688  if(gFile){
689  //TCanvas c;
690  hGaussFitStatus->Write();
691  hGaussFitChi2->Write();
692  hTbFitStatus->Write();
693  hTbFitChi2->Write();
694  hTbMaxCorr->Write();
695  hTbMaxRatio->Write();
696  hTbSideCorr->Write();
697  hTbSideRatio->Write();
698  }
699 #endif
700  return kStOk;
701 }
702 
703 
705 Bool_t StFgtSeededClusterAlgo::isSameCluster(StSPtrVecFgtStripIterator itSeed,StSPtrVecFgtStripIterator nextStrip)
706 {
707  // Float_t chargeUncert = (*itSeed)->getChargeUncert() > (*nextStrip)->getChargeUncert() ? (*itSeed)->getChargeUncert() : (*nextStrip)->getChargeUncert();
708  // if((*itSeed)->getCharge() > (*nextStrip)->getCharge() - 2*chargeUncert && (*nextStrip)->getCharge() > 2*(*nextStrip)->getChargeUncert())
709 
710 
711  //prevent problems in the pedstals so that low noise makes the cluster go on forever and thus makes it look like a cluster that is too big:
712  //if two relatively low strips follow each other, end cluster. We could check in addition if the ratio between the two is close to one
713  if((*nextStrip)->getCharge()< 2*(*nextStrip)->getChargeUncert() && ((*itSeed)->getCharge()<2*(*itSeed)->getChargeUncert()))
714  return false;
715 
716  if((*nextStrip)->getCharge() > mThreshold2AddStrip*(*nextStrip)->getChargeUncert() && (*nextStrip)->getChargeUncert() >0 && (*nextStrip)->getClusterSeedType()!=kFgtDeadStrip)
717  return true;
718  else
719  return false;
720 }
721 
723 Int_t StFgtSeededClusterAlgo::addStrips2Cluster(StFgtHit* clus, StSPtrVecFgtStripIterator itSeed, StSPtrVecFgtStripIterator itVecBegin, StSPtrVecFgtStripIterator itVecEnd,
724  Bool_t direction, Int_t sidedSize)
725 {
726  bool isPhi, isR;
727  Short_t seedDisc, seedQuad, seedStrip;
728  Short_t disc, quadrant,strip;
729  //,noLayer='z';
730  Char_t layer,seedLayer;
731  //Double_t ordinate, lowerSpan, upperSpan;
732  int debug=0;
733 
734  StFgtGeom::decodeGeoId((*itSeed)->getGeoId(),seedDisc,seedQuad,seedLayer,seedStrip);
735  if(debug) cout <<"Layer="<<seedLayer<<" adding strips from gid=" << (*itSeed)->getGeoId();
736 
737  Int_t inc=1;
738  if(direction==down) {
739  if(debug) cout <<" down : ";
740  inc=(-1);
741  }else{
742  if(debug) cout <<" up : ";
743  }
744  isPhi=(seedLayer=='P');
745  isR=(!isPhi);
746 
747 
748  StSPtrVecFgtStripIterator nextStrip=itSeed+inc;
749  if(nextStrip<itVecBegin || nextStrip >=itVecEnd) {
750  if(debug) { cout << " Not added because run out of strips"<<endl;}
751  return true;
752  }
753  StFgtGeom::decodeGeoId((*nextStrip)->getGeoId(),disc,quadrant,layer,strip);
754  if(seedLayer!=layer || seedQuad!=quadrant || seedDisc!=disc){
755  if(debug) { cout << " Not added because not in same quad/layer"<<endl;}
756  return true;
757  }
758 
759  Int_t deadStripsSkipped=0;
760  //if(debug) cout << " Next strip gid="<<(*nextStrip)->getGeoId();
761 
762  //jump over dead strips while its still in same quad/layer
763  while(nextStrip>=itVecBegin && nextStrip <itVecEnd && (*nextStrip)->getClusterSeedType()==kFgtDeadStrip) {
764  nextStrip+=inc;
765  deadStripsSkipped++;
766  StFgtGeom::decodeGeoId((*nextStrip)->getGeoId(),disc,quadrant,layer,strip);
767  if(seedLayer!=layer || seedQuad!=quadrant || seedDisc!=disc){
768  if(debug) { cout << " Skipped dead strip, and next is not added because not in same quad/layer"<<endl;}
769  return true;
770  }
771  //the next printout might lead to a crash...
772  //if(debug) cout <<"\n Dead strip ("<<deadStripsSkipped<<"). Skip and looking at next gid="<< (*nextStrip)->getGeoId()<<endl;
773  }
774 
775  bool isHit = false;
776  bool adjacentStrip = false;
777  if(nextStrip >=itVecBegin && nextStrip <itVecEnd){
778  //cout <<"still looking at "<< (*nextStrip)->getGeoId()<<endl;
779  StFgtGeom::decodeGeoId((*nextStrip)->getGeoId(),disc,quadrant,layer,strip);
780  // if(isPhi)
781  //cout <<"stepTwo: " << stepTwo << " nextStripID: " << (*nextStrip)->getGeoId() << " seedLayer: " << seedLayer <<" layer: " << layer <<endl;
783  //in the end we check what range the geoId's of the clusters span, then we know if it is too big
784  // bool adjacentStrip=((abs((*nextStrip)->getGeoId()-(*itSeed)->getGeoId()))<(2+deadStripsSkipped));
785  //adjacentStrip=((layer==seedLayer)&&(quadrant==seedQuadrant)&&((abs((*nextStrip)->getGeoId()-(*itSeed)->getGeoId()))<(2+deadStripsSkipped)));
786  adjacentStrip=((layer==seedLayer)&&(quadrant==seedQuad)&&((abs(strip-seedStrip)<(2+deadStripsSkipped))));
787  //cout <<"looking at "<< (*nextStrip)->getGeoId()<< " adjacent: " << adjacentStrip <<endl;
788  if(adjacentStrip) isHit=isSameCluster(itSeed,nextStrip);
789 
790  //So the next strip is not dead (we skipped those) and the same layer. So if it is not in the cluster, we give one more chance to the one after that if it is even.
791  //But the condition is that it is exactly 2 away. If it is more and still even (so it could be that there is an even
792  //hit then nothing due to short phi and then a dead strip and then nothing due to short and then a signal... that would be quite a stretch..
793  //adjacent strip is only checking if in same layer, if that is not true, the strip after that will not be in the same layer either
794  if(stepTwo && isPhi && adjacentStrip && !isHit && seedStrip%2==0){
795  if(debug) cout <<"\n adjacent has no charge but phi and even. Looking for next gid="<<(*(nextStrip+inc))->getGeoId();
796  if((nextStrip+inc) >=itVecBegin && (nextStrip+inc)<itVecEnd)
797  {
799  short disc2,quadrant2,strip2;
800  char layer2;
801  StFgtGeom::decodeGeoId((*(nextStrip+inc))->getGeoId(),disc2,quadrant2,layer2,strip2);
802  adjacentStrip=(layer2==seedLayer && quadrant2==seedQuad && abs(strip2-seedStrip)<=(2+deadStripsSkipped) && strip2%2==0);
803  isHit=isSameCluster(itSeed,nextStrip);
804  if(isHit) nextStrip+=inc;
805  if(debug){
806  cout <<"geoid of next next: " << (*(nextStrip+inc))->getGeoId() <<" of seed: " << (*itSeed)->getGeoId() <<" deadStrips skipped: " << deadStripsSkipped<<endl;
807  cout <<"diff in geo: " <<(abs((*nextStrip+inc)->getGeoId()-(*itSeed)->getGeoId()==(2+deadStripsSkipped)))<< endl;
808  cout <<"adjacentStrip="<<adjacentStrip;
809  }
810  }
811  }
812 
813  //if zero suppressed data, odd strip may not exist... So check if this is even and should be added
814  if(stepTwo && isPhi && !isHit && seedStrip%2==0){
815  if(debug) cout <<"\n This is not adjacent but phi and even. Check this strips"<<endl;
816  if(nextStrip>=itVecBegin && nextStrip<itVecEnd)
817  {
818  StFgtGeom::decodeGeoId((*nextStrip)->getGeoId(),disc,quadrant,layer,strip);
819  adjacentStrip=(layer==seedLayer && quadrant==seedQuad && abs(strip-seedStrip)==2);
820  if(adjacentStrip) {
821  isHit=isSameCluster(itSeed,nextStrip);
822  if(debug){ cout << " Checked this strip because phi and even isHit=" << isHit << endl; }
823  }
824  }
825  }
826  }
827 
828  //if the new strip is adjacent and it seems to belong to the same cluster, add it
829  if(isHit){
830  (*nextStrip)->setClusterSeedType(kFgtClusterPart);
831  stripWeightMap_t &stripWeightMap = clus->getStripWeightMap();
832  stripWeightMap[ *nextStrip ] = 1;
834  if(sidedSize+1<=kFgtMaxClusterSize/2){
835  if(debug) cout << " Added\n";
836  return addStrips2Cluster(clus,nextStrip,itVecBegin,itVecEnd,direction,sidedSize+1); //to return a kFgtClusterTooBig which is discovered downthe line
837  }else{
838  //cout <<" Cluster too big, stopping here : sidedSize+1="<<sidedSize+1<<" kFgtMaxClusterSize="<<kFgtMaxClusterSize<<endl;
839  return kFgtClusterTooBig;
840  }
841  }else{
842  if(debug) {
843  if(adjacentStrip) {cout << " Not added because not adjacent"<<endl;}
844  else {cout << " Not added because no charge"<<endl;}
845  }
846  }
847  return true;
848 
849 }
850 
855 {
856  mMaxTimeBin=0;
857  if(&fgtCollection){ mMaxTimeBin=fgtCollection.getNumTimeBins(); }
858  if(mMaxTimeBin==0) return kStOk;
859 
860  // cout.precision(10);
861  //we make use of the fact, that the hits are already sorted by geoId
862  strips.sortByGeoId();
863  Float_t defaultError = 0.001;
864  Short_t disc, quadrant;
865  //,noLayer='z';
866  Char_t layer;
867  Double_t ordinate, lowerSpan, upperSpan;//, prvOrdinate;
868  Double_t accuCharge=0;
869  bool isPhi, isR;
870  StFgtHit* newCluster=0;
871  //to compute energy weighted strip id
872  Double_t meanGeoId=0;
873  //for R < R/2 cm the difference in geo id of the phi strips is 2 and only even numbers are used...
874  //const
875 
879  Int_t lastGeoIdInCluster=-1;
880  for( StSPtrVecFgtStripIterator it=strips.getStripVec().begin();it!=strips.getStripVec().end();++it)
881  {
882  //the last cluster includes this seed strip
883  // cout <<"last geo id is: " << lastGeoIdInCluster <<endl;
886  //so maybe the strip just has to be shared (which it is) because it is eaten by both
887  if((*it)->getGeoId()<lastGeoIdInCluster && lastGeoIdInCluster>0)
888  continue;
889  //found seed for a cluster
890  if( (*it)->getClusterSeedType() >=kFgtSeedType1 && (*it)->getClusterSeedType() < kFgtSeedTypeMax )
891  {
892  // cout <<"found seed for geo id: " << (*it)->getGeoId() <<endl;
893  //if((*it)->getGeoId()==31318)
894  // {
895  // cout <<"seed type: "<< (*it)->getClusterSeedType()<< "charge: " << (*it)->getCharge()<<" adc: ";
896  // for(int i=0;i<mMaxTimeBin;i++)
897  //{
898  // cout <<(*it)->getAdc(i) <<" ";
899  //}
900  // cout <<endl;
901  //}
904  // if(ringing( it, strips.getStripVec().begin(),strips.getStripVec().end(), down,0,layer))
905  // continue; //was it
907  int searchRange=(int)(floor(kFgtMaxClusterSize/2)+kFgtNumAdditionalStrips);
908  StSPtrVecFgtStripIterator firstStrip=it-(int)(floor(kFgtMaxClusterSize/2)+kFgtNumAdditionalStrips);
909  StSPtrVecFgtStripIterator lastStrip=it+(int)(floor(kFgtMaxClusterSize/2)+kFgtNumAdditionalStrips);
910  if(firstStrip<strips.getStripVec().begin())
911  firstStrip=strips.getStripVec().begin();
912  Int_t stripsW_Charge=0;
913  Int_t stripsWO_Charge=0;
914  //compare with energy in cluster
915  // cout << " looking around " << (*it)->getGeoId() << ": " << (*firstStrip)->getGeoId() <<" to something... " <<endl;
916  for(StSPtrVecFgtStripIterator it2=firstStrip;(it2!=strips.getStripVec().end())&&(it2<=lastStrip);it2++)
917  {
918  if(fabs((*it)->getGeoId()-(*it2)->getGeoId())<searchRange)
919  {
920  if((*it2)->getClusterSeedType()!=kFgtDeadStrip)
921  {
922  if((*it2)->getCharge()>2*(*it2)->getChargeUncert())
923  {
924  // cout <<" strip: " << (*it2)->getGeoId() << " has high charge " <<endl;
925  stripsW_Charge++;
926  }
927  }
928  }
929  }
930  // cout<<" high charge strips: " << stripsW_Charge <<" low: " << stripsWO_Charge<<endl;
931  //if more than half the strips have charge, we don't count strips w/o charge due to zero suppression
932  if(stripsW_Charge>searchRange && stripsW_Charge > kFgtMaxClusterSize)
933  {
934  (*it)->setClusterSeedType(kFgtClusterSeedInSeaOfNoise);
935 #ifndef KEEP_BIG_AND_NOISY_CLUSTERS
936  continue;
937 #endif
938  }
939 
941 
942 
943  StFgtGeom::getPhysicalCoordinate((*it)->getGeoId(),disc,quadrant,layer,ordinate,lowerSpan,upperSpan);
944  isPhi=(layer=='P');
945  isR=(!isPhi);
946  newCluster=new StFgtHit(clusters.getHitVec().size(),meanGeoId,accuCharge, disc, quadrant, layer, ordinate, defaultError,ordinate, defaultError,0.0,0.0);
947  stripWeightMap_t &stripWeightMap = newCluster->getStripWeightMap();
948  stripWeightMap[ *it ] = 1;
949  //add strips to cluster going down
950  //the function is recursive, stops if the condition that the next strip
951  //belongs to the cluster is not met anymore,
952  //big clusters return clusterToBig, then we erase the seed because ist was probably noise
953  if(addStrips2Cluster(newCluster, it, strips.getStripVec().begin(),strips.getStripVec().end(), down,0)==kFgtClusterTooBig)
954  {
955  //cout <<"cluster too big!, begin at: " << newCluster->getStripWeightMap().begin()->first->getGeoId()<<endl;
956  //reset strips
957 
958 #ifndef KEEP_BIG_AND_NOISY_CLUSTERS
959  //akio's change: keep seed flags
960  for(stripWeightMap_t::iterator it=newCluster->getStripWeightMap().begin();it!=newCluster->getStripWeightMap().end();it++)
961  {
962  if(it->first->getClusterSeedType()<kFgtSeedType1 || it->first->getClusterSeedType()>kFgtSeedTypeMax)
963  it->first->setClusterSeedType(kFgtClusterTooBig);
964  }
965  delete newCluster;
966  continue;
967 #endif
968  }
969  //add strips to cluster going up
970  if(addStrips2Cluster(newCluster, it, strips.getStripVec().begin(),strips.getStripVec().end(), up,0)==kFgtClusterTooBig)
971  {
972 
973 #ifndef KEEP_BIG_AND_NOISY_CLUSTERS
974 
975  // cout <<"cluster too big!, begin at: " << newCluster->getStripWeightMap().begin()->first->getGeoId()<<endl;
976  for(stripWeightMap_t::iterator it=newCluster->getStripWeightMap().begin();it!=newCluster->getStripWeightMap().end();it++)
977  {
978  if(it->first->getClusterSeedType()<kFgtSeedType1 || it->first->getClusterSeedType()>kFgtSeedTypeMax)
979  it->first->setClusterSeedType(kFgtClusterTooBig);
980  }
981  delete newCluster;
982  continue;
983 #endif
984  }
985 
987  stripWeightMap_t &stripWM = newCluster->getStripWeightMap();
988  // if(stripWM.size()==1)
989  if(false)
990  {
991  StSPtrVecFgtStripIterator stripInClu=0;
992  for(StSPtrVecFgtStripIterator it=firstStrip;it<=lastStrip&&it!=strips.getStripVec().end();it++)
993  {
994  if((*it)->getGeoId()==stripWM.begin()->first->getGeoId())
995  stripInClu=it;
996  break;
997  }
998  if(stripInClu!=0)
999  {
1000  StSPtrVecFgtStripIterator stripLow=stripInClu;
1001  stripLow--;
1002  if(stripLow>=strips.getStripVec().begin())
1003  {
1004  // cout <<"adding low " <<endl;
1005  stripWM[*stripLow]=1;
1006  }
1007  StSPtrVecFgtStripIterator stripHigh=stripInClu;
1008  stripHigh++;
1009  if(stripHigh<strips.getStripVec().end())
1010  {
1011  // cout <<"adding high " <<endl;
1012  stripWM[*stripHigh]=1;
1013  }
1014  }
1015  }
1016  // if(stripWM.size()==2)
1017  if(false)
1018  {
1019  // cout <<"only two strips in cluster " <<endl;
1020  StSPtrVecFgtStripIterator stripInClu=0;
1021  for(StSPtrVecFgtStripIterator it=firstStrip;it<=lastStrip&& it<=lastStrip&&it!=strips.getStripVec().end();it++)
1022  {
1023  // cout <<"looping" <<endl;
1024  // cout <<"checking "<<(*it)->getGeoId() <<" with: "<<stripWM.begin()->first->getGeoId()<<" last: "<< (*lastStrip)->getGeoId()<<endl;
1025  if((*it)->getGeoId()==stripWM.begin()->first->getGeoId())
1026  {
1027  stripInClu=it;
1028  // cout <<"found " <<endl;
1029  break;
1030  }
1031 
1032  }
1033  // cout <<"end of loop " << endl;
1034 
1035  if(stripInClu!=0)
1036  {
1037  // cout <<"found one geo id: " << (*stripInClu)->getGeoId()<<endl;
1038  StSPtrVecFgtStripIterator stripHigh=stripInClu;
1039  StSPtrVecFgtStripIterator stripNew=stripInClu;
1040  stripHigh++;
1041  //must be since we have two strips
1042  if(stripHigh< strips.getStripVec().end())
1043  {
1044  if((*stripHigh)->getCharge() >(*stripInClu)->getCharge())
1045  {
1046  stripNew=stripHigh;
1047  stripNew++;
1048  }
1049  else
1050  {
1051  stripNew=stripInClu;
1052  stripNew--;
1053  }
1054 
1055  if(stripNew>=strips.getStripVec().begin()&& stripNew<strips.getStripVec().end())
1056  {
1057  // cout <<"adding strip with geo id: " << (*stripNew)->getGeoId()<<endl;
1058  stripWM[*stripNew]=1;
1059  }
1060  }
1061  }
1062  }
1064 
1065 
1066  //
1067  //compute errors etc
1068  FillClusterInfo(newCluster,strips);
1069  clusters.getHitVec().push_back(newCluster);
1070  //now of course we have to check where the cluster ends so that we don't start another cluster if there is another seed
1071  lastGeoIdInCluster=newCluster->getStripWeightMap().rbegin()->first->getGeoId();
1072  }
1073  }
1074  return kStOk;
1075 }
1076 
1077 //Bool_t StFgtSeededClusterAlgo::up;
1078 //Bool_t StFgtSeededClusterAlgo::down;
1079 
1080 StFgtSeededClusterAlgo::~StFgtSeededClusterAlgo()
1081 {
1082 }
1083 
1084 ClassImp(StFgtSeededClusterAlgo);
Bool_t isSameCluster(StFgtStrip **itSeed, StFgtStrip **nextStrip)
function to check if the strip belongs to the cluster. If it returns false we stop adding strips to t...
virtual Int_t doClustering(const StFgtCollection &fgtCollection, StFgtStripCollection &strips, StFgtHitCollection &clusters)
the main function, using a collection of strips tht fired to build clusters of neighbouring strips ...
Int_t addStrips2Cluster(StFgtHit *clus, StFgtStrip **itSeed, StFgtStrip **itVecBegin, StFgtStrip **itVecEnd, Bool_t direction, Int_t sidedSize)
migrated to A2C maker
void FillClusterInfo(StFgtHit *cluster, StFgtStripCollection &allStrips)
fill in cluster info like charge from the strips
Definition: Stypes.h:41